Przeglądaj źródła

机构关联时,互关逻辑优化

JiangChongBo 2 lat temu
rodzic
commit
03fc60ced6

+ 2 - 0
src/main/java/com/caimei/mapper/cmMapper/AuthMapper.java

@@ -32,6 +32,8 @@ public interface AuthMapper {
 
     void updateRelaByAuthId(Integer authId,@Param("relationId")String relationId,@Param("relationName")String relationName);
 
+    CmBrandAuthPo getRelationInfo(Integer id);
+
     Integer getProductWaitAuditNum(Integer authId);
 
     void updateAuthAuditStatus(@Param("authId") Integer authId, @Param("status") Integer status, @Param("auditStatus") Integer auditStatus, @Param("invalidReason") String invalidReason, @Param("auditBy") Integer auditBy, @Param("auditTime") Date auditTime);

+ 9 - 0
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -375,6 +375,15 @@ public class AuthServiceImpl implements AuthService {
               String[] relaIdArr = auth.getRelationId().split(",");
               for(int i=0;i<relaIdArr.length;i++){
                   Integer id = Integer.valueOf(relaIdArr[i]);
+                  //先获取该机构是否与其他机构关联,有则合并
+                  CmBrandAuthPo relationInfo = authMapper.getRelationInfo(id);
+                  if(StringUtils.isNotEmpty(relationInfo.getRelationId())&&StringUtils.isNotEmpty(relationInfo.getRelationName())){
+                      //避免保存一样的数据
+                      if(!relationInfo.getRelationId().contains(relaId)&&!relationInfo.getRelationName().contains(relaName)){
+                          relaId=relaId+","+relationInfo.getRelationId();
+                          relaName=relaName+","+relationInfo.getRelationName();
+                      }
+                  }
                   authMapper.updateRelaByAuthId(id,relaId,relaName);
               }
     }

+ 3 - 0
src/main/resources/mapper/AuthMapper.xml

@@ -75,6 +75,9 @@
             auditTime     = #{auditTime}
         where id = #{authId}
     </update>
+    <select id="getRelationInfo" resultType="com.caimei.model.po.CmBrandAuthPo">
+        select relationId,relationName  from cm_brand_auth where id=#{id}
+    </select>
     <update id="deleteAuthByAuthId">
         update cm_brand_auth
         set delFlag = 1