|
@@ -5,16 +5,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
-import com.management.platform.mapper.ProdMaterialMapper;
|
|
|
|
-import com.management.platform.mapper.ProdProcedureMapper;
|
|
|
|
-import com.management.platform.mapper.ProductMapper;
|
|
|
|
-import com.management.platform.mapper.UserMapper;
|
|
|
|
|
|
+import com.management.platform.mapper.*;
|
|
import com.management.platform.service.ProdMaterialService;
|
|
import com.management.platform.service.ProdMaterialService;
|
|
import com.management.platform.service.ProdProcedureService;
|
|
import com.management.platform.service.ProdProcedureService;
|
|
import com.management.platform.service.ProductService;
|
|
import com.management.platform.service.ProductService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -32,6 +30,7 @@ import java.util.Map;
|
|
* @since 2023-07-02
|
|
* @since 2023-07-02
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
|
|
+@Transactional
|
|
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
|
|
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
|
|
@Resource
|
|
@Resource
|
|
ProductMapper productMapper;
|
|
ProductMapper productMapper;
|
|
@@ -45,6 +44,9 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
ProdMaterialMapper prodMaterialMapper;
|
|
ProdMaterialMapper prodMaterialMapper;
|
|
@Resource
|
|
@Resource
|
|
ProdMaterialService prodMaterialService;
|
|
ProdMaterialService prodMaterialService;
|
|
|
|
+ @Resource
|
|
|
|
+ PlanMapper planMapper;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg getProductPage(Integer cateId, Integer pageIndex, Integer pageSize, String name, String code, HttpServletRequest request) {
|
|
public HttpRespMsg getProductPage(Integer cateId, Integer pageIndex, Integer pageSize, String name, String code, HttpServletRequest request) {
|
|
@@ -117,4 +119,26 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
map.put("")*/
|
|
map.put("")*/
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg delete(Integer id) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ //TODO : 需检测是否被使用
|
|
|
|
+ int count = planMapper.selectCount(
|
|
|
|
+ new LambdaQueryWrapper<Plan>()
|
|
|
|
+ .eq(id != null, Plan::getProductId, id)
|
|
|
|
+ );
|
|
|
|
+ System.out.println(count);
|
|
|
|
+ if(count==0){
|
|
|
|
+
|
|
|
|
+ prodProcedureMapper.delete(new LambdaQueryWrapper<ProdProcedure>().eq(id!=null,ProdProcedure::getProductId,id));
|
|
|
|
+ prodMaterialMapper.delete(new LambdaQueryWrapper<ProdMaterial>().eq(id!=null,ProdMaterial::getProductId,id));
|
|
|
|
+ productMapper.deleteById(id);
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ msg.setError("this product is used!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
}
|
|
}
|