|
@@ -12,6 +12,7 @@ import com.management.platform.util.MessageUtils;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -22,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -54,8 +56,10 @@ public class ProductController {
|
|
@RequestMapping("/addOrUpdate")
|
|
@RequestMapping("/addOrUpdate")
|
|
public HttpRespMsg addOrUpdate(Product product){
|
|
public HttpRespMsg addOrUpdate(Product product){
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
- Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
product.setCompanyId(companyId);
|
|
product.setCompanyId(companyId);
|
|
|
|
+ product.setCreatorId(user.getId());
|
|
int count;
|
|
int count;
|
|
if(product.getId()==null){
|
|
if(product.getId()==null){
|
|
count = productService.count(new LambdaQueryWrapper<Product>().eq(Product::getCompanyId, companyId).eq(Product::getProductCode, product.getProductCode()));
|
|
count = productService.count(new LambdaQueryWrapper<Product>().eq(Product::getCompanyId, companyId).eq(Product::getProductCode, product.getProductCode()));
|
|
@@ -75,16 +79,20 @@ public class ProductController {
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/delete")
|
|
@RequestMapping("/delete")
|
|
- public HttpRespMsg delete(Integer id){
|
|
|
|
|
|
+ public HttpRespMsg delete(String ids){
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
- int count = taskService.count(new LambdaQueryWrapper<Task>().eq(Task::getProductId, id));
|
|
|
|
- if(count>0){
|
|
|
|
- msg.setError("当前产品已绑定到相关任务,删除失败");
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- if(!productService.removeById(id)){
|
|
|
|
- msg.setError("验证失败");
|
|
|
|
- return msg;
|
|
|
|
|
|
+ if(!StringUtils.isEmpty(ids)){
|
|
|
|
+ String[] split = ids.split(",");
|
|
|
|
+ List<String> idList = Arrays.asList(split);
|
|
|
|
+ int count = taskService.count(new LambdaQueryWrapper<Task>().in(Task::getProductId, idList));
|
|
|
|
+ if(count>0){
|
|
|
|
+ msg.setError("当前产品已绑定到相关任务,删除失败");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if(!productService.removeByIds(idList)){
|
|
|
|
+ msg.setError("验证失败");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|