From 3053f3c6a8ea26d204e83e9f17a418d6928da5bc Mon Sep 17 00:00:00 2001
From: zhaoxiaohao <913652501@qq.com>
Date: Tue, 16 Jun 2020 19:19:11 +0800
Subject: [PATCH] Merge branch 'dev' of http://192.168.2.240:7070/r/kidgrow-microservices-platform into dev

---
 kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysOrganizationServiceImpl.java |   45 ++++++++++++++++++++++++++-------------------
 1 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysOrganizationServiceImpl.java b/kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysOrganizationServiceImpl.java
index 09a1b2d..90a1bdf 100644
--- a/kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysOrganizationServiceImpl.java
+++ b/kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysOrganizationServiceImpl.java
@@ -9,6 +9,7 @@
 import com.kidgrow.redis.util.RedisConstant;
 import com.kidgrow.redis.util.RedisUtils;
 import com.kidgrow.usercenter.mapper.SysOrganizationMapper;
+import com.kidgrow.usercenter.mapper.SysUserOrgMapper;
 import com.kidgrow.usercenter.service.ISysOrganizationService;
 import com.kidgrow.usercenter.vo.SysOrganizationVo;
 import lombok.extern.slf4j.Slf4j;
@@ -18,10 +19,7 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -38,7 +36,8 @@
 public class SysOrganizationServiceImpl extends SuperServiceImpl<SysOrganizationMapper, SysOrganization> implements ISysOrganizationService {
     @Autowired
     RedisUtils redisUtils;
-
+    @Autowired
+    SysUserOrgMapper sysUserOrgMapper;
     /**
      * 列表
      *
@@ -142,6 +141,13 @@
         return ResultBody.ok().data(treeData);
     }
 
+    @Override
+    public int deleteByUserId(Long userId) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("userId", userId);
+        return sysUserOrgMapper.deleteByMap(params);
+    }
+
     /**
      * 将数据  封装成  tree   (递归方式)
      *
@@ -156,7 +162,7 @@
         for (Long id : idList
         ) {
             Map<String, Object> map = new HashMap<>();
-            map.put("id", ""+id);
+            map.put("id", "" + id);
             map.put("name", collect.get(id).getOrgName());
             map.put("level", collect.get(id).getOrgLevel());
             map.put("parentId", collect.get(id).getOrgParentId());
@@ -189,7 +195,7 @@
         } else {
             //更新
             SysOrganization sysOrg = baseMapper.selectById(sysOrganization.getId());
-            if(sysOrg.getOrgParentId()!=sysOrganization.getOrgParentId()){
+            if (sysOrg.getOrgParentId() != sysOrganization.getOrgParentId()) {
                 String code = this.getCode(sysOrganization);
                 sysOrganization.setOrgCode(code);
             }
@@ -203,36 +209,37 @@
 
     /**
      * 获取自己组织的code
+     *
      * @param sysOrganization
      * @return
      */
-    public String getCode(SysOrganization sysOrganization){
+    public String getCode(SysOrganization sysOrganization) {
         //获取父级
         Long orgParentId = sysOrganization.getOrgParentId();
         if (orgParentId == null) {
             return null;
         }
         SysOrganization sysOrg = baseMapper.selectById(orgParentId);
-        if(sysOrg!=null){
+        if (sysOrg != null) {
             String orgCode = sysOrg.getOrgCode();
             //查询
-            QueryWrapper queryWrapper=new QueryWrapper();
-            queryWrapper.eq("org_parent_id",sysOrg.getId());
+            QueryWrapper queryWrapper = new QueryWrapper();
+            queryWrapper.eq("org_parent_id", sysOrg.getId());
             queryWrapper.orderByAsc("id");
             List<SysOrganization> list = baseMapper.selectList(queryWrapper);
-            if (list.size()>0) {
+            if (list.size() > 0) {
                 SysOrganization sysOrganizationLast = list.get(list.size() - 1);
                 String orgCodeLast = sysOrganizationLast.getOrgCode();
-                String orgCodeLastQianZhui=orgCodeLast.substring(0,orgCodeLast.length() - 4);
+                String orgCodeLastQianZhui = orgCodeLast.substring(0, orgCodeLast.length() - 4);
                 Integer codenum = Integer.valueOf(orgCodeLast.substring(orgCodeLast.length() - 4));
-                String str="0000";
-                str+=(codenum+1);
+                String str = "0000";
+                str += (codenum + 1);
                 String substring = str.substring(str.length() - 4);
-                return orgCodeLastQianZhui+substring;
-            }else {
+                return orgCodeLastQianZhui + substring;
+            } else {
                 String fucode = sysOrg.getOrgCode();
-                String str="0001";
-                return fucode+str;
+                String str = "0001";
+                return fucode + str;
             }
 
         }

--
Gitblit v1.8.0