|
@@ -1,44 +0,0 @@
|
|
|
-package com.malk.jiangshi.service.impl;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.malk.jiangshi.entity.Product;
|
|
|
-import com.malk.jiangshi.mapper.ProductMapper;
|
|
|
-import com.malk.jiangshi.service.JiangshiService;
|
|
|
-import org.checkerframework.checker.units.qual.A;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-@Service
|
|
|
-public class JiangshiServiceImpl extends ServiceImpl<ProductMapper, Product> implements JiangshiService {
|
|
|
- @Autowired
|
|
|
- private ProductMapper productMapper;
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public void addProduct(Product product) {
|
|
|
- productMapper.insert(product);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void updateProduct(Map map) {
|
|
|
- String code = String.valueOf(map.get("code"));
|
|
|
- int num = Integer.parseInt(String.valueOf(map.get("num")));
|
|
|
- String type = String.valueOf(map.get("type"));
|
|
|
- LambdaQueryWrapper<Product> productLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- productLambdaQueryWrapper.eq(Product::getCode, code)
|
|
|
- .eq(Product::getValidFlag,"1");
|
|
|
- Product product = productMapper.selectOne(productLambdaQueryWrapper);
|
|
|
- if (type.equals("add")){
|
|
|
- product.setNum(product.getNum()+num);
|
|
|
- }else if (type.equals("sub")){
|
|
|
- product.setNum(product.getNum()-num);
|
|
|
- }
|
|
|
-
|
|
|
- productMapper.updateById(product);
|
|
|
- }
|
|
|
-}
|