dongxin 1 год назад
Родитель
Сommit
5efbf58bfb
18 измененных файлов с 509 добавлено и 168 удалено
  1. 96 0
      commons/src/main/java/com/jzg/commons/entity/dto/SysSystemAddParam.java
  2. 100 0
      commons/src/main/java/com/jzg/commons/entity/dto/SysSystemEditParam.java
  3. 35 0
      commons/src/main/java/com/jzg/commons/entity/dto/SysSystemParam.java
  4. 13 5
      commons/src/main/java/com/jzg/commons/entity/po/SysUser.java
  5. 7 19
      commons/src/main/java/com/jzg/commons/entity/vo/SysSystemVo.java
  6. 3 0
      commons/src/main/java/com/jzg/commons/entity/vo/UpAndDownVo.java
  7. 32 33
      platform/src/main/java/com/jzg/controller/SysSystemController.java
  8. 6 5
      platform/src/main/java/com/jzg/controller/SysUserController.java
  9. 12 0
      platform/src/main/java/com/jzg/mapper/SysSystemMapper.java
  10. 10 0
      platform/src/main/java/com/jzg/mapper/SysUserMapper.java
  11. 21 8
      platform/src/main/java/com/jzg/service/SysSystemService.java
  12. 80 52
      platform/src/main/java/com/jzg/service/impl/SysSystemServiceImpl.java
  13. 2 7
      platform/src/main/java/com/jzg/service/impl/SysUserServiceImpl.java
  14. 56 25
      platform/src/main/resources/mapper/SysSystemMapper.xml
  15. 16 2
      platform/src/main/resources/mapper/SysUserMapper.xml
  16. 7 3
      tenant/organization/src/main/java/com/jzg/organization/controller/DeptController.java
  17. 1 1
      tenant/organization/src/main/java/com/jzg/organization/service/SysDeptService.java
  18. 12 8
      tenant/organization/src/main/java/com/jzg/organization/service/impl/SysDeptServiceImpl.java

+ 96 - 0
commons/src/main/java/com/jzg/commons/entity/dto/SysSystemAddParam.java

@@ -0,0 +1,96 @@
+package com.jzg.commons.entity.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+
+@Schema(description = "租户表新增dto")
+@Data
+public class SysSystemAddParam {
+
+    /** 租户Code */
+    @Schema(description = "租户code")
+    @Size(min=1,max=20,message = "租户编码长度不能大于20")
+    @NotNull(message = "租户编码不能为空")
+    private String sysCode;
+
+    /** 租户名称 */
+    @Schema(description = "租户名称")
+    @Size(min=1,max=20,message = "租户名称长度不能大于20")
+    @NotNull(message = "租户名称不能为空")
+    private String sysName;
+
+    /** 租户名称 */
+    @Schema(description = "租户简称")
+    @NotNull(message = "租户简称不能为空")
+    private String shortName;
+
+    @Schema(description = "管理员姓名")
+    @Size(min=1,max=20,message = "管理员姓名长度不能大于20")
+    @NotNull(message = "管理员姓名不能为空")
+    private String userName;
+
+    @Schema(description = "管理员账号")
+    @Size(min=1,max=20,message = "管理员账号长度不能大于20")
+    @NotNull(message = "管理员账号不能为空")
+    private String userAccount;
+
+    /** 省 */
+    @Schema(description = "省id")
+    @NotNull(message = "请选择租户所在地区")
+    private String provinceId;
+
+    /** 市 */
+    @Schema(description = "市id")
+    @NotNull(message = "请选择租户所在地区")
+    private String cityId;
+
+    /** 区 */
+    @Schema(description = "区id")
+    @NotNull(message = "请选择租户所在地区")
+    private String districtId;
+
+    /** 详细地址 */
+    @Schema(description = "详细地址")
+    @NotNull(message = "请输入租户详细地址")
+    private String address;
+
+    /** 租户类型 0-保险公司 1-保险分公司 2-保险经济公司 3-汽车经销商 4-保险代理公司 */
+    @Schema(description = "租户类型  0-保险公司 1-保险分公司 2-保险经济公司 3-汽车经销商 4-保险代理公司 ")
+    @NotNull(message = "请选择机构类型")
+    private Integer sysType;
+
+    /** 详细地址 */
+    @Schema(description = "租户状态 0-停用 1-在用")
+    private Integer available;
+
+    /** 系统图标 */
+    @Schema(description = "系统图标")
+    @NotNull(message = "品牌LOGO不能为空")
+    private String sysIcon;
+
+    /** 联系人 */
+    @Schema(description = "联系人")
+    private String contact;
+
+    /** 联系电话 */
+    @Schema(description = "联系电话")
+    private String telephone;
+
+    /** 联系人地址 */
+    @Schema(description = "联系人地址")
+    private String contactAdress;
+
+    /** 联系人职务 */
+    @Schema(description = "联系人职务")
+    private String contactJob;
+
+    /** 企业规模(人)*/
+    @Schema(description = "企业规模(人)")
+    private Integer businessSize;
+
+    /** 法人代表 */
+    @Schema(description = "法人代表")
+    private String legalName;
+}

+ 100 - 0
commons/src/main/java/com/jzg/commons/entity/dto/SysSystemEditParam.java

@@ -0,0 +1,100 @@
+package com.jzg.commons.entity.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+
+@Schema(description = "租户表修改dto")
+@Data
+public class SysSystemEditParam {
+
+    @NotNull(message = "租户id不能为空")
+    @Schema(description = "租户id")
+    private String id;
+
+    /** 租户Code */
+    @Schema(description = "租户code")
+    @Size(min=1,max=20,message = "租户编码长度不能大于20")
+    @NotNull(message = "租户编码不能为空")
+    private String sysCode;
+
+    /** 租户名称 */
+    @Schema(description = "租户名称")
+    @Size(min=1,max=20,message = "租户名称长度不能大于20")
+    @NotNull(message = "租户名称不能为空")
+    private String sysName;
+
+    /** 租户名称 */
+    @Schema(description = "租户简称")
+    @NotNull(message = "租户简称不能为空")
+    private String shortName;
+
+    @Schema(description = "管理员姓名")
+    @Size(min=1,max=20,message = "管理员姓名长度不能大于20")
+    @NotNull(message = "管理员姓名不能为空")
+    private String userName;
+
+    @Schema(description = "管理员账号")
+    @Size(min=1,max=20,message = "管理员账号长度不能大于20")
+    @NotNull(message = "管理员账号不能为空")
+    private String userAccount;
+
+    /** 省 */
+    @Schema(description = "省id")
+    @NotNull(message = "请选择租户所在地区")
+    private String provinceId;
+
+    /** 市 */
+    @Schema(description = "市id")
+    @NotNull(message = "请选择租户所在地区")
+    private String cityId;
+
+    /** 区 */
+    @Schema(description = "区id")
+    @NotNull(message = "请选择租户所在地区")
+    private String districtId;
+
+    /** 详细地址 */
+    @Schema(description = "详细地址")
+    @NotNull(message = "请输入租户详细地址")
+    private String address;
+
+    /** 租户类型 0-保险公司 1-保险分公司 2-保险经济公司 3-汽车经销商 4-保险代理公司 */
+    @Schema(description = "租户类型  0-保险公司 1-保险分公司 2-保险经济公司 3-汽车经销商 4-保险代理公司 ")
+    @NotNull(message = "请选择机构类型")
+    private Integer sysType;
+
+    /** 详细地址 */
+    @Schema(description = "租户状态 0-停用 1-在用")
+    private Integer available;
+
+    /** 系统图标 */
+    @Schema(description = "系统图标")
+    @NotNull(message = "品牌LOGO不能为空")
+    private String sysIcon;
+
+    /** 联系人 */
+    @Schema(description = "联系人")
+    private String contact;
+
+    /** 联系电话 */
+    @Schema(description = "联系电话")
+    private String telephone;
+
+    /** 联系人地址 */
+    @Schema(description = "联系人地址")
+    private String contactAdress;
+
+    /** 联系人职务 */
+    @Schema(description = "联系人职务")
+    private String contactJob;
+
+    /** 企业规模(人)*/
+    @Schema(description = "企业规模(人)")
+    private Integer businessSize;
+
+    /** 法人代表 */
+    @Schema(description = "法人代表")
+    private String legalName;
+}

+ 35 - 0
commons/src/main/java/com/jzg/commons/entity/dto/SysSystemParam.java

@@ -0,0 +1,35 @@
+package com.jzg.commons.entity.dto;
+
+import com.jzg.commons.core.base.PageRequest;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+@Schema(description = "租户表分页查询dto")
+@Data
+public class SysSystemParam extends PageRequest  {
+
+    /** 省 */
+    @Schema(description = "省id")
+    private String provinceId;
+
+    /** 市 */
+    @Schema(description = "市id")
+    private String cityId;
+
+    /** 区 */
+    @Schema(description = "区id")
+    private String districtId;
+
+    /** 租户类型 0-保险公司 1-保险分公司 2-保险经济公司 3-汽车经销商 4-保险代理公司 */
+    @Schema(description = "租户类型  0-保险公司 1-保险分公司 2-保险经济公司 3-汽车经销商 4-保险代理公司 ")
+    private Integer sysType;
+
+    /** 租户信息搜索值 */
+    @Schema(description = "租户信息搜索值")
+    private String searchValue;
+
+    /** 联系人信息搜索值 */
+    @Schema(description = "联系人信息搜索值")
+    private String contactValue;
+}

+ 13 - 5
commons/src/main/java/com/jzg/commons/entity/po/SysUser.java

@@ -2,6 +2,8 @@ package com.jzg.commons.entity.po;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.jzg.commons.core.base.BaseModel;
+import com.jzg.commons.entity.dto.SysSystemAddParam;
+import com.jzg.commons.entity.dto.SysSystemEditParam;
 import com.jzg.commons.entity.vo.SysSystemVo;
 import com.jzg.commons.util.PasswordUtils;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -54,13 +56,19 @@ public class SysUser extends BaseModel{
     @TableField(exist = false)
     private String roleNames;
 
-    public SysUser(SysSystemVo sysSystemVo) {
-        this.username = sysSystemVo.getUserName();
-        this.mobile = sysSystemVo.getUserAccount();
+    public SysUser(SysSystemAddParam param) {
+        this.username = param.getUserName();
+        this.mobile = param.getUserAccount();
         this.salt = PasswordUtils.getSalt();
-        String encryptedPassword = PasswordUtils.encode(sysSystemVo.getPassword(),salt);
+        String encryptedPassword = PasswordUtils.encode("12345678",salt);
         this.password = encryptedPassword;
         this.accountStatus = 1;
-        this.systemCode = sysSystemVo.getSysCode();
+        this.systemCode = param.getSysCode();
+    }
+
+    public SysUser(SysSystemEditParam param) {
+        this.username = param.getUserName();
+        this.mobile = param.getUserAccount();
+        this.systemCode = param.getSysCode();
     }
 }

+ 7 - 19
commons/src/main/java/com/jzg/commons/entity/vo/SysSystemVo.java

@@ -1,5 +1,7 @@
 package com.jzg.commons.entity.vo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.jzg.commons.core.base.BaseModel;
 import com.jzg.commons.core.base.PageRequest;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotNull;
@@ -8,64 +10,47 @@ import lombok.Data;
 
 @Schema(description = "租户表VO")
 @Data
-public class SysSystemVo extends PageRequest {
+public class SysSystemVo extends BaseModel {
 
     @Schema(description = "租户id")
     private String id;
 
     /** 租户Code */
     @Schema(description = "租户code")
-    @Size(min=1,max=20,message = "租户编码长度不能大于20")
-    @NotNull(message = "租户编码不能为空")
     private String sysCode;
 
     /** 租户名称 */
     @Schema(description = "租户名称")
-    @Size(min=1,max=20,message = "租户名称长度不能大于20")
-    @NotNull(message = "租户名称不能为空")
     private String sysName;
 
     /** 租户名称 */
     @Schema(description = "租户简称")
-    @NotNull(message = "租户简称不能为空")
     private String shortName;
 
     @Schema(description = "管理员姓名")
-    @Size(min=1,max=20,message = "管理员姓名长度不能大于20")
-    @NotNull(message = "管理员姓名不能为空")
     private String userName;
 
     @Schema(description = "管理员账号")
-    @Size(min=1,max=20,message = "管理员账号长度不能大于20")
-    @NotNull(message = "管理员账号不能为空")
     private String userAccount;
 
-    @Schema(description = "登录密码")
-    private String password;
-
     /** 省 */
     @Schema(description = "省id")
-    @NotNull(message = "请选择租户所在地区")
     private String provinceId;
 
     /** 市 */
     @Schema(description = "市id")
-    @NotNull(message = "请选择租户所在地区")
     private String cityId;
 
     /** 区 */
     @Schema(description = "区id")
-    @NotNull(message = "请选择租户所在地区")
     private String districtId;
 
     /** 详细地址 */
     @Schema(description = "详细地址")
-    @NotNull(message = "请输入租户详细地址")
     private String address;
 
     /** 租户类型 0-保险公司 1-保险分公司 2-保险经济公司 3-汽车经销商 4-保险代理公司 */
     @Schema(description = "租户类型  0-保险公司 1-保险分公司 2-保险经济公司 3-汽车经销商 4-保险代理公司 ")
-    @NotNull(message = "请选择机构类型")
     private Integer sysType;
 
     /** 详细地址 */
@@ -74,7 +59,6 @@ public class SysSystemVo extends PageRequest {
 
     /** 系统图标 */
     @Schema(description = "系统图标")
-    @NotNull(message = "品牌LOGO不能为空")
     private String sysIcon;
 
     /** 联系人 */
@@ -113,4 +97,8 @@ public class SysSystemVo extends PageRequest {
     @Schema(description = "联系人信息搜索值")
     private String contactValue;
 
+
+    /** 系统图标url */
+    @Schema(description = "系统图标url")
+    private String sysIconUrl;
 }

+ 3 - 0
commons/src/main/java/com/jzg/commons/entity/vo/UpAndDownVo.java

@@ -2,6 +2,7 @@ package com.jzg.commons.entity.vo;
 
 import com.jzg.commons.entity.enums.YesNoEnum;
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
 import lombok.Data;
 
 import java.util.List;
@@ -15,7 +16,9 @@ import java.util.List;
 public class UpAndDownVo {
 
     @Schema(description = "id集合")
+    @NotEmpty(message = "id不能为空")
     private List<Object> ids;
     @Schema(description = "操作类型")
+    @NotEmpty(message = "操作类型不能为空")
     private YesNoEnum opType;
 }

+ 32 - 33
platform/src/main/java/com/jzg/controller/SysSystemController.java

@@ -1,10 +1,16 @@
 package com.jzg.controller;
 
 import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.annotation.Log;
 import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.SysSystemAddParam;
+import com.jzg.commons.entity.dto.SysSystemEditParam;
+import com.jzg.commons.entity.dto.SysSystemParam;
 import com.jzg.commons.entity.enums.BusinessType;
+import com.jzg.commons.entity.enums.YesNoEnum;
+import com.jzg.commons.entity.po.SysSystem;
 import com.jzg.commons.entity.vo.SysRoleVo;
 import com.jzg.commons.entity.vo.SysSystemPermsVo;
 import com.jzg.commons.entity.vo.SysSystemVo;
@@ -50,14 +56,15 @@ public class SysSystemController {
 
     /**
      * 租户列表
-     * @param sysSystemVo
+     * @param param
      * @return
      */
     @PostMapping("/sysList")
     @Operation(summary = "租户列表")
-    public HttpResult sysList(@RequestBody SysSystemVo sysSystemVo){
-        Page page = sysSystemVo.getPage();
-        return HttpResult.ok(sysSystemService.queryPage(page,sysSystemVo));
+    public HttpResult sysList(@RequestBody SysSystemParam param){
+        Page page = param.getPage();
+        Page<SysSystemVo> result = sysSystemService.queryPage(page,param);
+        return HttpResult.ok(result);
     }
 
     /**
@@ -73,62 +80,53 @@ public class SysSystemController {
 
     /**
      * 租户添加
-     * @param sysSystemVo
+     * @param param
      * @return
      */
     @Log(title = "租户管理", businessType = BusinessType.INSERT)
     @Operation(summary = "租户添加")
     @PostMapping("/sysAdd")
-    public HttpResult sysAdd(@Validated @RequestBody SysSystemVo sysSystemVo) {
-        AssertionUtils.isFail(StringUtils.isEmpty(sysSystemVo.getPassword()), "管理员密码不允许为空!");
+    public HttpResult sysAdd(@Validated @RequestBody SysSystemAddParam param) {
         // 编码和名称不允许重复
-        boolean codeExists = sysSystemService.isExistsCode(sysSystemVo.getSysCode(), null);
-        boolean nameExists = sysSystemService.isExistsName(sysSystemVo.getSysName(), null);
+        boolean codeExists = sysSystemService.isExistsCode(param.getSysCode(), null);
+        boolean nameExists = sysSystemService.isExistsName(param.getSysName(), null);
         AssertionUtils.isFail(codeExists,"租户编码重复!");
         AssertionUtils.isFail(nameExists,"租户名称重复!");
-        sysSystemService.sysAdd(sysSystemVo);
+        sysSystemService.sysAdd(param);
         return HttpResult.ok("新增成功");
     }
 
     /**
      * 租户修改
-     * @param sysSystemVo
+     * @param param
      * @return
      */
     @Log(title = "租户管理", businessType = BusinessType.UPDATE)
     @Operation(summary = "租户修改")
     @PutMapping("/sysEdit")
-    public HttpResult sysEdit(@Validated @RequestBody SysSystemVo sysSystemVo) {
-        AssertionUtils.isFail(StringUtils.isNull(sysSystemVo.getId()),"租户id不能为空!");
+    public HttpResult sysEdit(@Validated @RequestBody SysSystemEditParam param) {
         // 编码和名称不允许重复
-        boolean codeExists = sysSystemService.isExistsCode(sysSystemVo.getSysCode(), sysSystemVo.getId());
-        boolean nameExists = sysSystemService.isExistsName(sysSystemVo.getSysName(), sysSystemVo.getId());
+        boolean codeExists = sysSystemService.isExistsCode(param.getSysCode(), param.getId());
+        boolean nameExists = sysSystemService.isExistsName(param.getSysName(), param.getId());
         AssertionUtils.isFail(codeExists,"租户编码重复!");
         AssertionUtils.isFail(nameExists,"租户名称重复!");
-        sysSystemService.sysEdit(sysSystemVo);
+        sysSystemService.sysEdit(param);
         return HttpResult.ok("修改成功");
     }
 
     /**
-     * 删除租户
+     * 批量删除平台用户
      *
-     * @param sysSystemVo
+     * @param ids 主键串
      */
-    @Log(title = "租户", businessType = BusinessType.DELETE)
-    @Operation(summary = "租户删除")
+    @Log(title = "租户管理", businessType = BusinessType.DELETE)
+    @Operation(summary = "批量删除租户")
     @DeleteMapping("/sysDelete")
-    public HttpResult sysDelete(@RequestBody SysSystemVo sysSystemVo){
-        return sysSystemService.sysDelete(sysSystemVo) ? HttpResult.ok("删除租户成功") : HttpResult.error("删除租户失败");
-    }
+    public HttpResult remove(String[] ids) {
+        String errorStr = sysSystemService.sysDeleteValid(List.of(ids));
+        AssertionUtils.isFail(StringUtils.isNotEmpty(errorStr),errorStr);
 
-    @Operation(summary = "租户删除检测")
-    @PostMapping("/sysDeleteValid")
-    public HttpResult roleDeleteValid(@RequestBody SysSystemVo sysSystemVo) {
-        List<String> deptIdList = sysSystemService.sysDeleteValidDept(sysSystemVo);
-        AssertionUtils.isFail(CollUtil.isNotEmpty(deptIdList),"当前机构还有部分子机构,请将这些子机构删除后,再进行删除!");
-        boolean userValid = sysSystemService.sysDeleteValidUser(deptIdList);
-        AssertionUtils.isFail(userValid,"当前机构还有部分员工,请将这些员工变更机构或者删除后,再进行删除!");
-        return HttpResult.ok();
+        return HttpResult.ok(sysSystemService.deleteByIds(List.of(ids))? "删除成功":"删除失败");
     }
 
     /**
@@ -136,11 +134,12 @@ public class SysSystemController {
      * @param upAndDownVo
      * @return
      */
-    @PostMapping("/sysUpAndDown/")
+    @Log(title = "租户管理", businessType = BusinessType.UPDATE)
+    @PostMapping("/sysUpAndDown")
     @Operation(summary = "启用/禁用租户")
     public HttpResult upAndDown(@RequestBody UpAndDownVo upAndDownVo) {
         sysSystemService.upAndDown(upAndDownVo);
-        return HttpResult.ok();
+        return HttpResult.ok(YesNoEnum.YES.equals(upAndDownVo.getOpType())? "启用成功": "禁用成功");
     }
 
 }

+ 6 - 5
platform/src/main/java/com/jzg/controller/SysUserController.java

@@ -5,6 +5,7 @@ import com.jzg.commons.annotation.Log;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.enums.BusinessType;
+import com.jzg.commons.entity.enums.YesNoEnum;
 import com.jzg.commons.entity.vo.SysUserVo;
 import com.jzg.commons.entity.vo.UpAndDownVo;
 import com.jzg.commons.util.AssertionUtils;
@@ -98,13 +99,12 @@ public class SysUserController extends BaseController {
      */
     @Log(title = "平台用户管理", businessType = BusinessType.DELETE)
     @Operation(summary = "批量删除平台用户")
-    @DeleteMapping("/userDelete/{ids}")
-    public HttpResult remove(@NotEmpty(message = "主键不能为空")
-                             @PathVariable String[] ids) {
+    @DeleteMapping("/userDelete")
+    public HttpResult remove(String[] ids) {
         // 校验用户是不是管理员
         Boolean userValid = sysUserService.userDeleteValid(List.of(ids));
         AssertionUtils.isFail(userValid,"管理员不可操作离职!");
-        return HttpResult.ok(sysUserService.deleteByIds(List.of(ids)));
+        return HttpResult.ok(sysUserService.deleteByIds(List.of(ids))? "删除成功":"删除失败");
     }
 
     /**
@@ -112,10 +112,11 @@ public class SysUserController extends BaseController {
      * @param upAndDownVo
      * @return
      */
+    @Log(title = "平台用户管理", businessType = BusinessType.UPDATE)
     @PostMapping("/upAndDown/")
     @Operation(summary = "启用/禁用平台用户")
     public HttpResult upAndDown(@RequestBody UpAndDownVo upAndDownVo) {
         sysUserService.upAndDown(upAndDownVo);
-        return HttpResult.ok();
+        return HttpResult.ok(YesNoEnum.YES.equals(upAndDownVo.getOpType())? "启用成功": "禁用成功");
     }
 }

+ 12 - 0
platform/src/main/java/com/jzg/mapper/SysSystemMapper.java

@@ -1,8 +1,12 @@
 package com.jzg.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jzg.commons.entity.dto.SysSystemParam;
 import com.jzg.commons.entity.po.SysSystem;
+import com.jzg.commons.entity.vo.SysSystemVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 租户管理表Mapper sys_system
@@ -12,6 +16,14 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface SysSystemMapper extends BaseMapper<SysSystem> {
 
+    /**
+     * 列表查询
+     *
+     * @param page
+     * @param param
+     * @return
+     */
+    Page<SysSystemVo> queryPage(Page page, @Param("sysSystemVo") SysSystemParam param);
 }
 
 

+ 10 - 0
platform/src/main/java/com/jzg/mapper/SysUserMapper.java

@@ -1,8 +1,11 @@
 package com.jzg.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.entity.po.SysUser;
+import com.jzg.commons.entity.vo.SysUserVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
 * @author dongxin
@@ -13,6 +16,13 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface SysUserMapper extends BaseMapper<SysUser> {
 
+    /**
+     * 平台用户分页列表查询
+     * @param page
+     * @param sysUserVo
+     * @return
+     */
+    Page<SysUser> queryPage(Page page, @Param("sysUserVo") SysUserVo sysUserVo);
 }
 
 

+ 21 - 8
platform/src/main/java/com/jzg/service/SysSystemService.java

@@ -2,6 +2,9 @@ package com.jzg.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.jzg.commons.entity.dto.SysSystemAddParam;
+import com.jzg.commons.entity.dto.SysSystemEditParam;
+import com.jzg.commons.entity.dto.SysSystemParam;
 import com.jzg.commons.entity.po.SysSystem;
 import com.jzg.commons.entity.po.SysSystemPerms;
 import com.jzg.commons.entity.vo.SysSystemPermsVo;
@@ -56,32 +59,35 @@ public interface SysSystemService extends IService<SysSystem> {
 
     /**
      * 租户分页列表
+     *
      * @param page
-     * @param sysSystemVo
+     * @param param
      * @return
      */
-    public Page<SysSystem> queryPage(Page page, SysSystemVo sysSystemVo);
+    public Page<SysSystemVo> queryPage(Page page, SysSystemParam param);
 
     /**
      * 租户明细
      * @param sysId
      * @return
      */
-    public SysSystem queryById(String sysId);
+    public SysSystemVo queryById(String sysId);
 
     /**
      * 租户新增
-     * @param sysSystemVo
+     *
+     * @param param
      * @return
      */
-    public void sysAdd(SysSystemVo sysSystemVo);
+    public void sysAdd(SysSystemAddParam param);
 
     /**
      * 租户修改
-     * @param sysSystemVo
+     *
+     * @param param
      * @return
      */
-    public void sysEdit(SysSystemVo sysSystemVo);
+    public void sysEdit(SysSystemEditParam param);
 
     /**
      * 启用/禁用租户
@@ -113,7 +119,7 @@ public interface SysSystemService extends IService<SysSystem> {
      * @param sysSystemVo
      * @return
      */
-    List<String> sysDeleteValidDept(SysSystemVo sysSystemVo);
+    String sysDeleteValid(List<String> ids);
 
     /**
      * 判断租户下是否有成员信息
@@ -121,4 +127,11 @@ public interface SysSystemService extends IService<SysSystem> {
      * @return
      */
     boolean sysDeleteValidUser(List<String> ids);
+
+    /**
+     * 批量删除租户
+     * @param ids
+     * @return
+     */
+    boolean deleteByIds(List<String> ids);
 }

+ 80 - 52
platform/src/main/java/com/jzg/service/impl/SysSystemServiceImpl.java

@@ -5,6 +5,9 @@ import cn.hutool.core.convert.Convert;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jzg.commons.entity.dto.SysSystemAddParam;
+import com.jzg.commons.entity.dto.SysSystemEditParam;
+import com.jzg.commons.entity.dto.SysSystemParam;
 import com.jzg.commons.entity.enums.YesNoEnum;
 import com.jzg.commons.entity.po.*;
 import com.jzg.commons.entity.vo.SysSystemPermsVo;
@@ -14,7 +17,6 @@ import com.jzg.commons.util.StringUtils;
 import com.jzg.commons.util.idgen.IdGenerate;
 import com.jzg.mapper.*;
 import com.jzg.service.SysSystemService;
-import com.jzg.commons.util.PasswordUtils;
 import com.jzg.util.MinioUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,7 +25,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -112,28 +113,9 @@ public class SysSystemServiceImpl extends ServiceImpl<SysSystemMapper, SysSystem
     }
 
     @Override
-    public Page<SysSystem> queryPage(Page page, SysSystemVo sysSystemVo) {
-        LambdaQueryWrapper<SysSystem> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(StringUtils.isNotEmpty(sysSystemVo.getProvinceId()),
-                        SysSystem::getProvinceId, sysSystemVo.getProvinceId())
-                .eq(StringUtils.isNotEmpty(sysSystemVo.getCityId()),
-                        SysSystem::getCityId, sysSystemVo.getCityId())
-                .eq(StringUtils.isNotEmpty(sysSystemVo.getDistrictId()),
-                        SysSystem::getDistrictId, sysSystemVo.getDistrictId())
-                .eq(StringUtils.isNotNull(sysSystemVo.getSysType()),
-                        SysSystem::getSysType, sysSystemVo.getSysType())
-                .eq(StringUtils.isNotEmpty(sysSystemVo.getSearchValue()),
-                        SysSystem::getSysName, sysSystemVo.getSearchValue()).or()
-                .eq(StringUtils.isNotEmpty(sysSystemVo.getSearchValue()),
-                        SysSystem::getSysCode, sysSystemVo.getSearchValue())
-                .eq(StringUtils.isNotEmpty(sysSystemVo.getContactValue()),
-                        SysSystem::getContact, sysSystemVo.getContactValue()).or()
-                .eq(StringUtils.isNotEmpty(sysSystemVo.getContactValue()),
-                        SysSystem::getTelephone, sysSystemVo.getContactValue())
-                .eq(SysSystem::getIsTenant, 1)
-                .ne(SysSystem::getParentId, 0);
-        Page<SysSystem> sysPage = page(page, wrapper);
-        List<SysSystem> sysSystemList = sysPage.getRecords();
+    public Page<SysSystemVo> queryPage(Page page, SysSystemParam param) {
+        Page<SysSystemVo> sysPage = baseMapper.queryPage(page, param);
+        List<SysSystemVo> sysSystemList = sysPage.getRecords();
         if(CollUtil.isNotEmpty(sysSystemList)){
             sysSystemList.forEach(sysSystem->{
                 SysUploadFiles files = sysUploadFilesMapper.selectById(sysSystem.getSysIcon());
@@ -146,38 +128,48 @@ public class SysSystemServiceImpl extends ServiceImpl<SysSystemMapper, SysSystem
     }
 
     @Override
-    public SysSystem queryById(String sysId) {
+    public SysSystemVo queryById(String sysId) {
         SysSystem system = this.getById(sysId);
-
-        if(StringUtils.isNotEmpty(system.getSysIcon())){
+        SysSystemVo vo = new SysSystemVo();
+        BeanUtils.copyProperties(system,vo);
+        if(StringUtils.isNotEmpty(vo.getSysIcon())){
             SysUploadFiles files = sysUploadFilesMapper.selectById(system.getSysIcon());
             if(StringUtils.isNotNull(files)){
-                system.setSysIconUrl(minioUtils.getPresignedObjectUrl(bucketName,files.getFileName()));
+                vo.setSysIconUrl(minioUtils.getPresignedObjectUrl(bucketName,files.getFileName()));
             }
         }
         SysUser user = sysUserMapper.selectById(system.getUserId());
-        system.setUserName(user.getUsername());
-        system.setUserAccount(user.getMobile());
-        return system;
+        vo.setUserName(user.getUsername());
+        vo.setUserAccount(user.getMobile());
+        return vo;
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void sysAdd(SysSystemVo sysSystemVo) {
+    public void sysAdd(SysSystemAddParam param) {
         SysSystem sysSystem = new SysSystem();
-        BeanUtils.copyProperties(sysSystemVo, sysSystem);
+        BeanUtils.copyProperties(param, sysSystem);
         sysSystem.setIsTenant(1);
         sysSystem.setAvailable(1);
         sysSystem.setParentId("1");
         this.save(sysSystem);
 
         /** 初始化租户管理员信息 */
-        // 新增管理员用户
-        SysUser user = new SysUser(sysSystemVo);
-        sysUserMapper.insert(user);
+        List<SysUser> userList = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                .eq(SysUser::getMobile, param.getUserAccount())
+        );
+        String userId = null;
+        if(CollUtil.isNotEmpty(userList)){
+            userId = userList.get(0).getId();
+        }else{
+            // 新增管理员用户
+            SysUser user = new SysUser(param);
+            sysUserMapper.insert(user);
+            userId = user.getId();
+        }
         // 新增用户机构关联信息
         SysUserJzgInfo info = new SysUserJzgInfo();
-        info.setUserId(user.getId());
+        info.setUserId(userId);
         info.setDeptId("");// 后期放最顶级的机构
         sysUserJzgInfoMapper.insert(info);
         // 新增管理员角色
@@ -185,28 +177,41 @@ public class SysSystemServiceImpl extends ServiceImpl<SysSystemMapper, SysSystem
         sysRoleMapper.insert(role);
         // 关联用户角色
         SysUserRole userRole = new SysUserRole();
-        userRole.setUserId(user.getId());
+        userRole.setUserId(userId);
         userRole.setRoleId(role.getId());
         sysUserRoleMapper.insert(userRole);
         // 租户绑定管理员信息
-        sysSystem.setUserId(user.getId());
+        sysSystem.setUserId(userId);
         this.updateById(sysSystem);
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void sysEdit(SysSystemVo sysSystemVo) {
+    public void sysEdit(SysSystemEditParam param) {
         SysSystem sysSystem = new SysSystem();
-        BeanUtils.copyProperties(sysSystemVo, sysSystem);
+        BeanUtils.copyProperties(param, sysSystem);
         updateById(sysSystem);
         SysSystem system = getById(sysSystem.getId());
         // 修改管理员信息
-        SysUser user = sysUserMapper.selectById(system.getUserId());
-        user.setUsername(sysSystemVo.getUserName());
-        String encryptedPassword = PasswordUtils.encode(sysSystemVo.getPassword(),user.getSalt());
-        user.setPassword(encryptedPassword);
-        user.setMobile(sysSystemVo.getUserAccount());
-        sysUserMapper.updateById(user);
+
+        List<SysUser> userList = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                .eq(SysUser::getMobile, param.getUserAccount())
+        );
+        SysUser sysUser;
+        if(CollUtil.isNotEmpty(userList)){
+            sysUser = userList.get(0);
+            sysUser.setUsername(param.getUserName());
+            sysUserMapper.updateById(sysUser);
+        }else{
+            // 新增管理员用户
+            sysUser = new SysUser(param);
+            sysUserMapper.insert(sysUser);
+            // 新增用户机构关联信息
+            SysUserJzgInfo info = new SysUserJzgInfo();
+            info.setUserId(sysUser.getId());
+            info.setDeptId("");// 后期放最顶级的机构
+            sysUserJzgInfoMapper.insert(info);
+        }
     }
 
     @Override
@@ -249,12 +254,30 @@ public class SysSystemServiceImpl extends ServiceImpl<SysSystemMapper, SysSystem
     }
 
     @Override
-    public List<String> sysDeleteValidDept(SysSystemVo sysSystemVo) {
-        List<String> deptIdList = sysDeptMapper.selectList(new LambdaQueryWrapper<SysDept>()
+    public String sysDeleteValid(List<String> ids) {
+        List<SysSystem> systemList = baseMapper.selectBatchIds(ids);
+        String errorStr = null;
+        if(CollUtil.isNotEmpty(systemList)){
+            for (SysSystem sysSystem : systemList) {
+                List<String> deptIdList = sysDeptMapper.selectList(new LambdaQueryWrapper<SysDept>()
                         .select(SysDept::getId)
-                        .eq(SysDept::getSystemCode, sysSystemVo.getSysCode())).stream()
-                .map(SysDept::getId).collect(Collectors.toList());
-        return deptIdList;
+                        .eq(SysDept::getSystemCode, sysSystem.getSysCode())).stream()
+                        .map(SysDept::getId).collect(Collectors.toList());
+                if (CollUtil.isNotEmpty(deptIdList)) {
+                    errorStr = "租户["+sysSystem.getSysName()+"]还有部分子机构,请将这些子机构删除后,再进行删除!";
+                    return errorStr;
+                }
+                if(CollUtil.isNotEmpty(deptIdList)){
+                    Long count = sysUserJzgInfoMapper.selectCount(new LambdaQueryWrapper<SysUserJzgInfo>()
+                            .in(SysUserJzgInfo::getDeptId, deptIdList));
+                    if(count > 0){
+                        errorStr = "租户["+sysSystem.getSysName()+"]还有部分员工,请将这些员工变更机构或者删除后,再进行删除!";
+                        return errorStr;
+                    }
+                }
+            }
+        }
+        return errorStr;
     }
 
     @Override
@@ -267,6 +290,11 @@ public class SysSystemServiceImpl extends ServiceImpl<SysSystemMapper, SysSystem
         return false;
     }
 
+    @Override
+    public boolean deleteByIds(List<String> ids) {
+        return baseMapper.deleteByIds(ids) > 0;
+    }
+
 }
 
 

+ 2 - 7
platform/src/main/java/com/jzg/service/impl/SysUserServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jzg.commons.entity.enums.YesNoEnum;
 import com.jzg.commons.entity.po.SysRole;
+import com.jzg.commons.entity.po.SysSystem;
 import com.jzg.commons.entity.po.SysUser;
 import com.jzg.commons.entity.po.SysUserRole;
 import com.jzg.commons.entity.vo.SysUserVo;
@@ -45,13 +46,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
 
     @Override
     public Page<SysUser> queryPage(Page page, SysUserVo sysUserVo) {
-        LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(StringUtils.isNotNull(sysUserVo.getAccountStatus()), SysUser::getAccountStatus, sysUserVo.getAccountStatus())
-                .eq(StringUtils.isNotEmpty(sysUserVo.getSearchValue()), SysUser::getUsername, sysUserVo.getSearchValue()).or()
-                .eq(StringUtils.isNotEmpty(sysUserVo.getSearchValue()), SysUser::getMobile, sysUserVo.getSearchValue()).or()
-                .eq(StringUtils.isNotEmpty(sysUserVo.getSearchValue()), SysUser::getId, sysUserVo.getSearchValue())
-        .eq(SysUser::getSystemCode, "PLATFORM");
-        Page<SysUser> userPage = page(page, wrapper);
+        Page<SysUser> userPage = baseMapper.queryPage(page, sysUserVo);
         List<SysUser> userList = userPage.getRecords();
         if (!userList.isEmpty()) {
             List<String> userIdList = userList.stream().map(user -> user.getId()).collect(Collectors.toList());

+ 56 - 25
platform/src/main/resources/mapper/SysSystemMapper.xml

@@ -5,37 +5,68 @@
 <mapper namespace="com.jzg.mapper.SysSystemMapper">
 
     <resultMap id="SysSystemResult" type="com.jzg.commons.entity.po.SysSystem">
-            <id property="id" column="id" jdbcType="VARCHAR"/>
-            <result property="sysCode" column="sys_code" jdbcType="VARCHAR"/>
-            <result property="sysName" column="sys_name" jdbcType="VARCHAR"/>
-            <result property="shortName" column="short_name" jdbcType="VARCHAR"/>
-            <result property="sysIcon" column="sys_icon" jdbcType="VARCHAR"/>
-            <result property="sysType" column="sys_type" jdbcType="TINYINT"/>
-            <result property="available" column="available" jdbcType="TINYINT"/>
-            <result property="provinceId" column="province_id" jdbcType="VARCHAR"/>
-            <result property="cityId" column="city_id" jdbcType="VARCHAR"/>
-            <result property="districtId" column="district_id" jdbcType="VARCHAR"/>
-            <result property="address" column="address" jdbcType="VARCHAR"/>
-            <result property="contact" column="contact" jdbcType="VARCHAR"/>
-            <result property="telephone" column="telephone" jdbcType="VARCHAR"/>
-            <result property="contactAdress" column="contact_adress" jdbcType="VARCHAR"/>
-            <result property="contactJob" column="contact_job" jdbcType="VARCHAR"/>
-            <result property="businessSize" column="business_size" jdbcType="INTEGER"/>
-            <result property="legalName" column="legal_name" jdbcType="VARCHAR"/>
-            <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
-            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
-            <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
-            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+        <id property="id" column="id" jdbcType="VARCHAR"/>
+        <result property="parentId" column="parent_id" jdbcType="VARCHAR"/>
+        <result property="isTenant" column="is_tenant" jdbcType="TINYINT"/>
+        <result property="sysCode" column="sys_code" jdbcType="VARCHAR"/>
+        <result property="sysName" column="sys_name" jdbcType="VARCHAR"/>
+        <result property="shortName" column="short_name" jdbcType="VARCHAR"/>
+        <result property="userId" column="user_id" jdbcType="VARCHAR"/>
+        <result property="sysIcon" column="sys_icon" jdbcType="VARCHAR"/>
+        <result property="sysType" column="sys_type" jdbcType="TINYINT"/>
+        <result property="available" column="available" jdbcType="TINYINT"/>
+        <result property="provinceId" column="province_id" jdbcType="VARCHAR"/>
+        <result property="cityId" column="city_id" jdbcType="VARCHAR"/>
+        <result property="districtId" column="district_id" jdbcType="VARCHAR"/>
+        <result property="address" column="address" jdbcType="VARCHAR"/>
+        <result property="contact" column="contact" jdbcType="VARCHAR"/>
+        <result property="telephone" column="telephone" jdbcType="VARCHAR"/>
+        <result property="contactAdress" column="contact_adress" jdbcType="VARCHAR"/>
+        <result property="contactJob" column="contact_job" jdbcType="VARCHAR"/>
+        <result property="businessSize" column="business_size" jdbcType="INTEGER"/>
+        <result property="legalName" column="legal_name" jdbcType="VARCHAR"/>
+        <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
+        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+        <result property="isDelete" column="is_delete" jdbcType="TINYINT"/>
     </resultMap>
 
     <sql id="selectSystemVo">
-        select id,sys_code,sys_name,
-               short_name,sys_icon,sys_type,
+        select id,parent_id,is_tenant,
+               sys_code,sys_name,short_name,
+               user_id,sys_icon,sys_type,
                available,province_id,city_id,
                district_id,address,contact,
                telephone,contact_adress,contact_job,
                business_size,legal_name,create_by,
-               create_time,update_by,update_time
-        from sys_oper_log
+               create_time,update_by,update_time,
+               is_delete
+        from sys_system
     </sql>
+    <select id="queryPage" resultType="com.jzg.commons.entity.vo.SysSystemVo">
+        <include refid="selectSystemVo"/>
+        <where>
+            <if test="sysSystemVo.provinceId != null and sysSystemVo.provinceId != ''">
+                and province_id = #{sysSystemVo.provinceId}
+            </if>
+            <if test="sysSystemVo.cityId != null and sysSystemVo.cityId != ''">
+                and city_id = #{sysSystemVo.cityId}
+            </if>
+            <if test="sysSystemVo.districtId != null and sysSystemVo.districtId != ''">
+                and district_id = #{sysSystemVo.districtId}
+            </if>
+            <if test="sysSystemVo.sysType != null and sysSystemVo.sysType != ''">
+                and sys_type = #{sysSystemVo.sysType}
+            </if>
+            <if test="sysSystemVo.searchValue != null and sysSystemVo.searchValue != ''">
+                and ( sys_name = #{sysSystemVo.searchValue} or sys_code = #{sysSystemVo.searchValue})
+            </if>
+            <if test="sysSystemVo.contactValue != null and sysSystemVo.contactValue != ''">
+                and ( contact = #{sysSystemVo.contactValue} or telephone = #{sysSystemVo.contactValue})
+            </if>
+            and is_tenant = 1 and parent_id <![CDATA[ <> ]]> '0' and is_delete = 0
+        </where>
+        ORDER BY create_time DESC
+    </select>
 </mapper>

+ 16 - 2
platform/src/main/resources/mapper/SysUserMapper.xml

@@ -19,10 +19,24 @@
             <result property="systemCode" column="system_code" jdbcType="VARCHAR"/>
     </resultMap>
 
-    <sql id="Base_Column_List">
-        id,username,password,
+    <sql id="selectUserVo">
+        SELECT id,username,password,
         salt,mobile,account_status,
         create_by,create_time,update_by,
         update_time,is_delete,system_code
+        FROM sys_user
     </sql>
+    <select id="queryPage" resultType="com.jzg.commons.entity.po.SysUser">
+        <include refid="selectUserVo"/>
+        <where>
+            <if test="sysUserVo.accountStatus != null and sysUserVo.accountStatus != ''">
+                and account_status = #{sysUserVo.accountStatus}
+            </if>
+            <if test="sysUserVo.searchValue != null and sysUserVo.searchValue != ''">
+                and ( username = #{sysUserVo.searchValue} or mobile = #{sysUserVo.searchValue} or id = #{sysUserVo.searchValue})
+            </if>
+            and system_code = 'PLATFORM' and is_delete = 0
+        </where>
+        ORDER BY create_time DESC
+    </select>
 </mapper>

+ 7 - 3
tenant/organization/src/main/java/com/jzg/organization/controller/DeptController.java

@@ -4,6 +4,7 @@ import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.po.SysDept;
 import com.jzg.commons.entity.vo.SysDeptVo;
+import com.jzg.commons.util.StringUtils;
 import com.jzg.organization.service.SysDeptService;
 import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -52,9 +53,12 @@ public class DeptController extends BaseController {
 
     @Operation(summary = "机构树形查询")
     @PostMapping(value = "/getDeptTree")
-    public HttpResult<List<SysDeptVo>> getDeptTree(){
-        String deptId = getUserDeptId();
-        List<SysDeptVo> deptTree = sysDeptService.getDeptTree(deptId);
+    public HttpResult<List<SysDeptVo>> getDeptTree(String sysCode){
+        String deptId = null;
+        if(StringUtils.isEmpty(sysCode)){
+            deptId = getUserDeptId();
+        }
+        List<SysDeptVo> deptTree = sysDeptService.getDeptTree(deptId,sysCode);
         return HttpResult.ok(deptTree);
     }
 }

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/service/SysDeptService.java

@@ -37,7 +37,7 @@ public interface SysDeptService extends IService<SysDept> {
     /**
      * 机构树
      */
-    List<SysDeptVo> getDeptTree(String deptId);
+    List<SysDeptVo> getDeptTree(String deptId, String sysCode);
 
 
 }

+ 12 - 8
tenant/organization/src/main/java/com/jzg/organization/service/impl/SysDeptServiceImpl.java

@@ -1,7 +1,6 @@
 package com.jzg.organization.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
@@ -9,12 +8,9 @@ import com.jzg.commons.entity.po.SysDept;
 import com.jzg.commons.entity.po.SysSystem;
 import com.jzg.commons.entity.vo.SysUserVo;
 import com.jzg.commons.exception.SystemException;
+import com.jzg.commons.util.StringUtils;
 import com.jzg.commons.util.idgen.IdGenerate;
 import com.jzg.commons.entity.vo.SysDeptVo;
-import com.jzg.commons.entity.po.SysDept;
-import com.jzg.commons.entity.po.SysSystem;
-import com.jzg.commons.entity.vo.SysDeptVo;
-import com.jzg.commons.entity.vo.SysUserVo;
 import com.jzg.organization.mapper.SysDeptMapper;
 import com.jzg.organization.service.SysDeptService;
 import com.jzg.organization.service.SysSystemService;
@@ -71,7 +67,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
         }else{
             sysDept.setRoute(sysDept.getId());
         }
-
+        if (StringUtils.isNotEmpty(sysDeptVo.getSystemCode())){
+            sysDept.setSystemCode(sysDeptVo.getSystemCode());
+        }
         return this.save(sysDept);
     }
 
@@ -154,8 +152,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
     }
 
     @Override
-    public List<SysDeptVo> getDeptTree(String deptId) {
-        String userSystemCode = baseController.getUserSystemCode();
+    public List<SysDeptVo> getDeptTree(String deptId, String sysCode) {
+        String userSystemCode = null;
+        if (StringUtils.isEmpty(sysCode)){
+            userSystemCode = baseController.getUserSystemCode();
+        }else{
+            userSystemCode = sysCode;
+        }
         SysSystem bySysCode = sysSystemService.getBySysCode(userSystemCode);
         List<SysDeptVo> sysDepts = new ArrayList<>();
         SysDept sysDept = getById(deptId);
@@ -164,6 +167,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
         if(!deptId.equals("")) {
             lqw.likeRight(SysDept::getRoute, deptId);
         }
+        lqw.eq(StringUtils.isNotEmpty(sysCode),SysDept::getSystemCode, sysCode);
         List<SysDept> sysDeptList = list(lqw);
         List<SysDeptVo> voDept = new ArrayList<>();
         sysDeptList.forEach(item->{