Browse Source

产品线删除时同时删除系统自动生成的服务端

Zhaops 6 years atrás
parent
commit
b0d848450a

+ 11 - 3
diagbotman-service/src/main/java/com/diagbot/facade/ProductServiceFacade.java

@@ -12,6 +12,7 @@ import com.diagbot.entity.ServiceInfo;
 import com.diagbot.entity.ServiceToken;
 import com.diagbot.entity.wrapper.ProductServiceWrapper;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.ServiceTypeEnum;
 import com.diagbot.enums.StatusEnum;
 import com.diagbot.enums.TokenTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
@@ -23,6 +24,7 @@ import com.diagbot.util.GuidUtil;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.ProductServiceSaveVO;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.stereotype.Component;
 
 import java.util.Date;
@@ -197,13 +199,19 @@ public class ProductServiceFacade extends ProductServiceServiceImpl {
         serviceTokenFacade.update(new ServiceToken(), tokenUpdateWrapper);
 
         //删除产品服务端关联
-        for (ProductService productService : productServiceList) {
-            productService.setIsDeleted(IsDeleteEnum.Y.getKey());
-        }
         UpdateWrapper<ProductService> productServiceUpdateWrapper = new UpdateWrapper<>();
         productServiceUpdateWrapper.in("id", map.keySet());
         productServiceUpdateWrapper.set("is_deleted", IsDeleteEnum.Y.getKey());
         this.update(new ProductService(), productServiceUpdateWrapper);
+
+        //删除系统自动生成的服务端
+        Map<Long, List<ProductService>> serviceMap = EntityUtil.makeEntityListMap(productServiceList, "service_id");
+        UpdateWrapper<ServiceInfo> serviceInfoUpdateWrapper = new UpdateWrapper<>();
+        serviceInfoUpdateWrapper.in("id", serviceMap.keySet())
+                .eq("type", ServiceTypeEnum.Sys_Create.getKey())
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .set("is_deleted", IsDeleteEnum.Y.getKey());
+        serviceInfoFacade.update(new ServiceInfo(), serviceInfoUpdateWrapper);
         return true;
     }