Quellcode durchsuchen

组织机构适配

raojiang vor 6 Monaten
Ursprung
Commit
3d05648b40

+ 6 - 239
api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDept.java

@@ -2,13 +2,8 @@ package com.ruoyi.system.api.domain;
 
 import com.ruoyi.common.core.web.domain.BaseEntity;
 import lombok.Data;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
+import lombok.EqualsAndHashCode;
 
-import javax.validation.constraints.Email;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -17,6 +12,7 @@ import java.util.List;
  * 
  * @author ruoyi
  */
+@EqualsAndHashCode(callSuper = true)
 @Data
 public class SysDept extends BaseEntity {
     private static final long serialVersionUID = 1L;
@@ -51,243 +47,14 @@ public class SysDept extends BaseEntity {
     /** 删除标志(0代表存在 2代表删除) */
     private String delFlag;
 
-    /** 父部门名称 */
-    private String parentName;
-    /** 仓数量 **/
-    private Integer specialCount;
-    /** 库数量 **/
-    private Integer terminalCount;
-    /** 工厂编码 */
-    private String factoryCode;
-
-    private List<String> factoryCodeList;
-    public Long getFactoryId() {
-        return factoryId;
-    }
-
-    public void setFactoryId(Long factoryId) {
-        this.factoryId = factoryId;
-    }
-
-    /** 工厂ID */
-    private Long factoryId;
-
     /** 工厂名称 */
     private String shortName;
-    private String factoryName;
     private String deptLv;
     private String deptLvName;
     private String deptCode;
+    private String struLevel;
+    private String struType;
+    private String iscOrgId;
     /** 子部门 */
-    private List<SysDept> children = new ArrayList<SysDept>();
-
-    public String getShortName() {
-        return shortName;
-    }
-
-    public void setShortName(String shortName) {
-        this.shortName = shortName;
-    }
-
-    public Long getDeptId()
-    {
-        return deptId;
-    }
-
-    public void setDeptId(Long deptId)
-    {
-        this.deptId = deptId;
-    }
-
-    public Long getParentId()
-    {
-        return parentId;
-    }
-
-    public void setParentId(Long parentId)
-    {
-        this.parentId = parentId;
-    }
-
-    public String getAncestors()
-    {
-        return ancestors;
-    }
-
-    public void setAncestors(String ancestors)
-    {
-        this.ancestors = ancestors;
-    }
-
-    @NotBlank(message = "部门名称不能为空")
-    @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
-    public String getDeptName()
-    {
-        return deptName;
-    }
-
-    public void setDeptName(String deptName)
-    {
-        this.deptName = deptName;
-    }
-
-    @NotNull(message = "显示顺序不能为空")
-    public Integer getOrderNum()
-    {
-        return orderNum;
-    }
-
-    public void setOrderNum(Integer orderNum)
-    {
-        this.orderNum = orderNum;
-    }
-
-    public String getLeader()
-    {
-        return leader;
-    }
-
-    public void setLeader(String leader)
-    {
-        this.leader = leader;
-    }
-
-    @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
-    public String getPhone()
-    {
-        return phone;
-    }
-
-    public void setPhone(String phone)
-    {
-        this.phone = phone;
-    }
-
-    @Email(message = "邮箱格式不正确")
-    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
-    public String getEmail()
-    {
-        return email;
-    }
-
-    public void setEmail(String email)
-    {
-        this.email = email;
-    }
-
-    public String getStatus()
-    {
-        return status;
-    }
-
-    public void setStatus(String status)
-    {
-        this.status = status;
-    }
-
-    public String getDelFlag()
-    {
-        return delFlag;
-    }
-
-    public void setDelFlag(String delFlag)
-    {
-        this.delFlag = delFlag;
-    }
-
-    public String getParentName()
-    {
-        return parentName;
-    }
-
-    public void setParentName(String parentName)
-    {
-        this.parentName = parentName;
-    }
-
-    public List<SysDept> getChildren()
-    {
-        return children;
-    }
-
-    public void setChildren(List<SysDept> children)
-    {
-        this.children = children;
-    }
-
-    public Integer getSpecialCount() {
-        return specialCount;
-    }
-
-    public void setSpecialCount(Integer specialCount) {
-        this.specialCount = specialCount;
-    }
-
-    public Integer getTerminalCount() {
-        return terminalCount;
-    }
-
-    public void setTerminalCount(Integer terminalCount) {
-        this.terminalCount = terminalCount;
-    }
-
-    public String getFactoryCode() {
-        return factoryCode;
-    }
-
-    public void setFactoryCode(String factoryCode) {
-        this.factoryCode = factoryCode;
-    }
-
-    public String getFactoryName() {
-        return factoryName;
-    }
-
-    public void setFactoryName(String factoryName) {
-        this.factoryName = factoryName;
-    }
-
-    public String getDeptLv() {
-        return deptLv;
-    }
-
-    public void setDeptLv(String deptLv) {
-        this.deptLv = deptLv;
-    }
-
-    public String getDeptLvName() {
-        return deptLvName;
-    }
-
-    public void setDeptLvName(String deptLvName) {
-        this.deptLvName = deptLvName;
-    }
-
-    public String getDeptCode() {
-        return deptCode;
-    }
-
-    public void setDeptCode(String deptCode) {
-        this.deptCode = deptCode;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("deptId", getDeptId())
-            .append("parentId", getParentId())
-            .append("ancestors", getAncestors())
-            .append("deptName", getDeptName())
-            .append("orderNum", getOrderNum())
-            .append("leader", getLeader())
-            .append("phone", getPhone())
-            .append("email", getEmail())
-            .append("status", getStatus())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .toString();
-    }
+    private List<SysDept> children = new ArrayList<>();
 }

+ 2 - 0
common/common-core/src/main/java/com/hdkj/lt/core/sys/dao/DwdShbDsFeederBaseMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.hdkj.lt.core.bizms.modle.po.DwdShbDsFeederBase;
 import com.hdkj.lt.core.sys.model.dto.FeederCacheDTO;
 import com.hdkj.lt.core.sys.model.dto.FeederFileDTO;
+import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -15,6 +16,7 @@ import java.util.List;
 * @createDate 2025-05-24 18:27:00
 * @Entity generator.domain.DwdShbDsFeederBase
 */
+@Mapper
 public interface DwdShbDsFeederBaseMapper extends BaseMapper<DwdShbDsFeederBase> {
 
     List<FeederFileDTO> getFeederFile(@Param("limit") int limit ,@Param("offset") int offset);

+ 2 - 0
common/common-core/src/main/java/com/hdkj/lt/core/sys/dao/SwitchProtectionSettingsMapper.java

@@ -3,6 +3,7 @@ package com.hdkj.lt.core.sys.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.hdkj.lt.core.bizms.modle.po.FhzgSwitchProtectionSettings;
+import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -13,6 +14,7 @@ import java.util.List;
 * @createDate 2025-05-24 18:25:11
 * @Entity generator.domain.FhzgSwitchProtectionSettings
 */
+@Mapper
 public interface SwitchProtectionSettingsMapper extends BaseMapper<FhzgSwitchProtectionSettings> {
 
     int updateParentLinePsrId(@Param("nameList") List<String> nameList);

+ 153 - 0
common/common-core/src/main/java/com/hdkj/lt/core/sys/dao/SysDeptMapper.java

@@ -0,0 +1,153 @@
+package com.hdkj.lt.core.sys.dao;
+
+import com.ruoyi.system.api.domain.SysDept;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 部门管理 数据层
+ *
+ * @author ruoyi
+ */
+@Mapper
+public interface SysDeptMapper
+{
+    /**
+     * 查询部门管理数据
+     *
+     * @param dept 部门信息
+     * @return 部门信息集合
+     */
+    public List<SysDept> selectDeptList(SysDept dept);
+
+    /**
+     * 根据角色ID查询部门树信息
+     *
+     * @param roleId 角色ID
+     * @param deptCheckStrictly 部门树选择项是否关联显示
+     * @return 选中部门列表
+     */
+    public List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
+
+    public List<SysDept> selectDeptListByParentId(@Param("parentId") Long parentId);
+
+
+    /**
+     * 根据部门ID查询信息
+     *
+     * @param deptId 部门ID
+     * @return 部门信息
+     */
+    public SysDept selectDeptById(Long deptId);
+
+    /**
+     * 根据ID查询所有子部门
+     *
+     * @param deptId 部门ID
+     * @return 部门列表
+     */
+    public List<SysDept> selectChildrenDeptById(Long deptId);
+
+    /**
+     * 根据ID查询所有子部门(正常状态)
+     *
+     * @param deptId 部门ID
+     * @return 子部门数
+     */
+    public int selectNormalChildrenDeptById(Long deptId);
+
+    /**
+     * 是否存在子节点
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    public int hasChildByDeptId(Long deptId);
+
+    /**
+     * 查询部门是否存在用户
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    public int checkDeptExistUser(Long deptId);
+
+    /**
+     * 校验部门名称是否唯一
+     *
+     * @param deptName 部门名称
+     * @param parentId 父部门ID
+     * @return 结果
+     */
+    public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
+
+    /**
+     * 新增部门信息
+     *
+     * @param dept 部门信息
+     * @return 结果
+     */
+    public int insertDept(SysDept dept);
+
+    /**
+     * 修改部门信息
+     *
+     * @param dept 部门信息
+     * @return 结果
+     */
+    public int updateDept(SysDept dept);
+
+    /**
+     * 修改所在部门正常状态
+     *
+     * @param deptIds 部门ID组
+     */
+    public void updateDeptStatusNormal(Long[] deptIds);
+
+    /**
+     * 修改子元素关系
+     *
+     * @param depts 子元素
+     * @return 结果
+     */
+    public int updateDeptChildren(@Param("depts") List<SysDept> depts);
+
+    /**
+     * 删除部门管理信息
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    public int deleteDeptById(Long deptId);
+
+    /**
+     * 根据用户id获取dept
+     * @param userId
+     * @return
+     */
+    List<SysDept> selectDeptByUserId(Long userId);
+    /**
+     * 根据deptCode获取dept
+     * @param deptCode
+     * @return
+     */
+    List<SysDept> selectDeptListByDeptCode(String deptCode);
+
+
+    /**
+     * 查询所有的部门信息
+     * @return
+     */
+    List<SysDept> getAllDeptList();
+
+    int selectOne(String deptName);
+
+
+    int deleteDeptByIds(@Param("deptIds") List<Long> deptIds);
+
+    SysDept selectDeptName(@Param("deptName")String deptName, @Param("deptCode")String deptCode);
+
+    SysDept selectDept(@Param("deptCode")String deptCode);
+}

+ 121 - 0
common/common-core/src/main/java/com/hdkj/lt/core/sys/dao/SysRoleMapper.java

@@ -0,0 +1,121 @@
+package com.hdkj.lt.core.sys.dao;
+
+import com.ruoyi.system.api.domain.SysRole;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 角色表 数据层
+ *
+ * @author ruoyi
+ */
+@Mapper
+public interface SysRoleMapper
+{
+    /**
+     * 根据条件分页查询角色数据
+     *
+     * @param role 角色信息
+     * @return 角色数据集合信息
+     */
+    public List<SysRole> selectRoleList(SysRole role);
+
+    /**
+     * 根据用户ID查询角色
+     *
+     * @param userId 用户ID
+     * @return 角色列表
+     */
+    public List<SysRole> selectRolePermissionByUserId(Long userId);
+
+    /**
+     * 查询所有角色
+     *
+     * @return 角色列表
+     */
+    public List<SysRole> selectRoleAll();
+
+    /**
+     * 根据用户ID获取角色选择框列表
+     *
+     * @param userId 用户ID
+     * @return 选中角色ID列表
+     */
+    public List<Long> selectRoleListByUserId(Long userId);
+
+    /**
+     * 通过角色ID查询角色
+     *
+     * @param roleId 角色ID
+     * @return 角色对象信息
+     */
+    public SysRole selectRoleById(Long roleId);
+
+    /**
+     * 根据用户ID查询角色
+     *
+     * @param userName 用户名
+     * @return 角色列表
+     */
+    public List<SysRole> selectRolesByUserName(String userName);
+
+    /**
+     * 校验角色名称是否唯一
+     *
+     * @param roleName 角色名称
+     * @return 角色信息
+     */
+    public SysRole checkRoleNameUnique(String roleName);
+
+    /**
+     * 校验角色权限是否唯一
+     *
+     * @param roleKey 角色权限
+     * @return 角色信息
+     */
+    public SysRole checkRoleKeyUnique(String roleKey);
+
+    /**
+     * 修改角色信息
+     *
+     * @param role 角色信息
+     * @return 结果
+     */
+    public int updateRole(SysRole role);
+
+    /**
+     * 新增角色信息
+     *
+     * @param role 角色信息
+     * @return 结果
+     */
+    public int insertRole(SysRole role);
+
+    /**
+     * 通过角色ID删除角色
+     *
+     * @param roleId 角色ID
+     * @return 结果
+     */
+    public int deleteRoleById(Long roleId);
+
+    /**
+     * 批量删除角色信息
+     *
+     * @param roleIds 需要删除的角色ID
+     * @return 结果
+     */
+    public int deleteRoleByIds(Long[] roleIds);
+
+    List<SysRole> selectRoleListBy(@Param("roleIds") List<Long> roleIds);
+
+    /**
+     * 供应商给子账号添加专属权限用
+     *
+     *
+     * @return 结果
+     */
+    List<SysRole> selecRole();
+}

+ 190 - 0
common/common-core/src/main/java/com/hdkj/lt/core/sys/model/po/SysAppMenu.java

@@ -0,0 +1,190 @@
+package com.hdkj.lt.core.sys.model.po;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Author: sqz
+ * @Date: 2025/03/05/9:45
+ * @Description:
+ */
+public class SysAppMenu extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    private Long menuId;
+    private Long parentId;
+    private String menuName;
+    private String menuType;
+    private String icon;
+    private String path;
+    private String perms;
+    private Integer sort;
+    private String status;
+    private String visible;
+    private String component;
+    /** 是否为外链(0是 1否) */
+    private String isFrame;
+
+    // 子菜单(树形结构)
+    private List<SysAppMenu> children;
+
+    private String createBy;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    private String updateBy;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    private String remark;
+
+
+    public String getComponent() {
+        return component;
+    }
+
+    public void setComponent(String component) {
+        this.component = component;
+    }
+
+    public String getVisible() {
+        return visible;
+    }
+
+    public void setVisible(String visible) {
+        this.visible = visible;
+    }
+
+    public Long getMenuId() {
+        return menuId;
+    }
+
+    public void setMenuId(Long menuId) {
+        this.menuId = menuId;
+    }
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getMenuName() {
+        return menuName;
+    }
+
+    public void setMenuName(String menuName) {
+        this.menuName = menuName;
+    }
+
+    public String getMenuType() {
+        return menuType;
+    }
+
+    public void setMenuType(String menuType) {
+        this.menuType = menuType;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public String getPerms() {
+        return perms;
+    }
+
+    public void setPerms(String perms) {
+        this.perms = perms;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public List<SysAppMenu> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<SysAppMenu> children) {
+        this.children = children;
+    }
+
+    public String getIsFrame() {
+        return isFrame;
+    }
+
+    public void setIsFrame(String isFrame) {
+        this.isFrame = isFrame;
+    }
+
+    public String getCreateBy() {
+        return createBy;
+    }
+
+    public void setCreateBy(String createBy) {
+        this.createBy = createBy;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateBy() {
+        return updateBy;
+    }
+
+    public void setUpdateBy(String updateBy) {
+        this.updateBy = updateBy;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+}

+ 281 - 0
common/common-core/src/main/java/com/hdkj/lt/core/sys/model/po/SysMenu.java

@@ -0,0 +1,281 @@
+package com.hdkj.lt.core.sys.model.po;
+
+import com.ruoyi.common.core.web.domain.BaseEntity;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 菜单权限表 sys_menu
+ * 
+ * @author ruoyi
+ */
+public class SysMenu extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 菜单ID */
+    private Long menuId;
+
+    /** 菜单名称 */
+    private String menuName;
+
+    /** 父菜单名称 */
+    private String parentName;
+
+    /** 父菜单ID */
+    private Long parentId;
+
+    /** 显示顺序 */
+    private Integer orderNum;
+
+    /** 路由地址 */
+    private String path;
+
+    /** 组件路径 */
+    private String component;
+
+    /** 路由参数 */
+    private String query;
+
+    /** 路由名称,默认和路由地址相同的驼峰格式(注意:因为vue3版本的router会删除名称相同路由,为避免名字的冲突,特殊情况可以自定义) */
+    private String routeName;
+
+    /** 是否为外链(0是 1否) */
+    private String isFrame;
+
+    /** 是否缓存(0缓存 1不缓存) */
+    private String isCache;
+
+    /** 类型(M目录 C菜单 F按钮) */
+    private String menuType;
+
+    /** 显示状态(0显示 1隐藏) */
+    private String visible;
+    
+    /** 菜单状态(0正常 1停用) */
+    private String status;
+
+    /** 权限字符串 */
+    private String perms;
+
+    /** 菜单图标 */
+    private String icon;
+
+    private String belongType;
+
+    /** 子菜单 */
+    private List<SysMenu> children = new ArrayList<SysMenu>();
+
+    public Long getMenuId()
+    {
+        return menuId;
+    }
+
+    public void setMenuId(Long menuId)
+    {
+        this.menuId = menuId;
+    }
+
+    @NotBlank(message = "菜单名称不能为空")
+    @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
+    public String getMenuName()
+    {
+        return menuName;
+    }
+
+    public void setMenuName(String menuName)
+    {
+        this.menuName = menuName;
+    }
+
+    public String getParentName()
+    {
+        return parentName;
+    }
+
+    public void setParentName(String parentName)
+    {
+        this.parentName = parentName;
+    }
+
+    public Long getParentId()
+    {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId)
+    {
+        this.parentId = parentId;
+    }
+
+    @NotNull(message = "显示顺序不能为空")
+    public Integer getOrderNum()
+    {
+        return orderNum;
+    }
+
+    public void setOrderNum(Integer orderNum)
+    {
+        this.orderNum = orderNum;
+    }
+
+    @Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
+    public String getPath()
+    {
+        return path;
+    }
+
+    public void setPath(String path)
+    {
+        this.path = path;
+    }
+
+    @Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
+    public String getComponent()
+    {
+        return component;
+    }
+
+    public void setComponent(String component)
+    {
+        this.component = component;
+    }
+
+    public String getQuery()
+    {
+        return query;
+    }
+
+    public void setQuery(String query)
+    {
+        this.query = query;
+    }
+
+    public String getRouteName()
+    {
+        return routeName;
+    }
+
+    public void setRouteName(String routeName)
+    {
+        this.routeName = routeName;
+    }
+
+    public String getIsFrame()
+    {
+        return isFrame;
+    }
+
+    public void setIsFrame(String isFrame)
+    {
+        this.isFrame = isFrame;
+    }
+
+    public String getIsCache()
+    {
+        return isCache;
+    }
+
+    public void setIsCache(String isCache)
+    {
+        this.isCache = isCache;
+    }
+
+    @NotBlank(message = "菜单类型不能为空")
+    public String getMenuType()
+    {
+        return menuType;
+    }
+
+    public void setMenuType(String menuType)
+    {
+        this.menuType = menuType;
+    }
+
+    public String getVisible()
+    {
+        return visible;
+    }
+
+    public void setVisible(String visible)
+    {
+        this.visible = visible;
+    }
+
+    public String getStatus()
+    {
+        return status;
+    }
+
+    public void setStatus(String status)
+    {
+        this.status = status;
+    }
+
+    @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
+    public String getPerms()
+    {
+        return perms;
+    }
+
+    public void setPerms(String perms)
+    {
+        this.perms = perms;
+    }
+
+    public String getIcon()
+    {
+        return icon;
+    }
+
+    public void setIcon(String icon)
+    {
+        this.icon = icon;
+    }
+
+    public List<SysMenu> getChildren()
+    {
+        return children;
+    }
+
+    public void setChildren(List<SysMenu> children)
+    {
+        this.children = children;
+    }
+
+    public String getBelongType() {
+        return belongType;
+    }
+
+    public void setBelongType(String belongType) {
+        this.belongType = belongType;
+    }
+
+    @Override
+    public String toString() {
+        return "SysMenu{" +
+                "menuId=" + menuId +
+                ", menuName='" + menuName + '\'' +
+                ", parentName='" + parentName + '\'' +
+                ", parentId=" + parentId +
+                ", orderNum=" + orderNum +
+                ", path='" + path + '\'' +
+                ", component='" + component + '\'' +
+                ", query='" + query + '\'' +
+                ", routeName='" + routeName + '\'' +
+                ", isFrame='" + isFrame + '\'' +
+                ", isCache='" + isCache + '\'' +
+                ", menuType='" + menuType + '\'' +
+                ", visible='" + visible + '\'' +
+                ", status='" + status + '\'' +
+                ", perms='" + perms + '\'' +
+                ", icon='" + icon + '\'' +
+                ", belongType='" + belongType + '\'' +
+                ", children=" + children +
+                '}';
+    }
+}

+ 116 - 0
common/common-core/src/main/java/com/hdkj/lt/core/sys/model/vo/TreeSelect.java

@@ -0,0 +1,116 @@
+package com.hdkj.lt.core.sys.model.vo;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.hdkj.lt.core.sys.model.po.SysAppMenu;
+import com.hdkj.lt.core.sys.model.po.SysMenu;
+import com.ruoyi.common.core.constant.UserConstants;
+import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.system.api.domain.SysDept;
+
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Treeselect树结构实体类
+ *
+ * @author ruoyi
+ */
+public class TreeSelect implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 节点ID */
+    private Long id;
+
+    /** 节点名称 */
+    private String label;
+
+    private String  belongType;
+    /** 节点禁用 */
+    private boolean disabled = false;
+
+    /** 子节点 */
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    private List<TreeSelect> children;
+
+    public String getBelongType() {
+        return belongType;
+    }
+
+    public void setBelongType(String belongType) {
+        this.belongType = belongType;
+    }
+
+    public TreeSelect()
+    {
+
+    }
+
+    public TreeSelect(SysDept dept)
+    {
+        this.id = dept.getDeptId();
+        this.label = dept.getDeptName();
+        this.disabled = StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus());
+        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
+    }
+
+    public TreeSelect(SysMenu menu)
+    {
+        this.id = menu.getMenuId();
+        this.label = menu.getMenuName();
+        this.belongType = menu.getBelongType();
+        this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
+    }
+
+    public TreeSelect(SysAppMenu menu)
+    {
+        this.id = menu.getMenuId();
+        this.label = menu.getMenuName();
+        if(CollectionUtil.isNotEmpty(menu.getChildren())){
+            this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
+        }
+    }
+
+    public Long getId()
+    {
+        return id;
+    }
+
+    public void setId(Long id)
+    {
+        this.id = id;
+    }
+
+    public String getLabel()
+    {
+        return label;
+    }
+
+    public void setLabel(String label)
+    {
+        this.label = label;
+    }
+
+    public boolean isDisabled()
+    {
+        return disabled;
+    }
+
+    public void setDisabled(boolean disabled)
+    {
+        this.disabled = disabled;
+    }
+
+    public List<TreeSelect> getChildren()
+    {
+        return children;
+    }
+
+    public void setChildren(List<TreeSelect> children)
+    {
+        this.children = children;
+    }
+}

+ 139 - 0
common/common-core/src/main/java/com/hdkj/lt/core/sys/service/ISysDeptService.java

@@ -0,0 +1,139 @@
+package com.hdkj.lt.core.sys.service;
+
+import com.hdkj.lt.core.sys.model.vo.TreeSelect;
+import com.ruoyi.system.api.domain.SysDept;
+
+import java.util.List;
+
+/**
+ * 部门管理 服务层
+ *
+ * @author ruoyi
+ */
+public interface ISysDeptService
+{
+    /**
+     * 查询部门管理数据
+     *
+     * @param dept 部门信息
+     * @return 部门信息集合
+     */
+    public List<SysDept> selectDeptList(SysDept dept);
+
+    /**
+     * 查询部门树结构信息
+     *
+     * @param dept 部门信息
+     * @return 部门树信息集合
+     */
+    public List<TreeSelect> selectDeptTreeList(SysDept dept);
+
+    /**
+     * 构建前端所需要树结构
+     *
+     * @param depts 部门列表
+     * @return 树结构列表
+     */
+    public List<SysDept> buildDeptTree(List<SysDept> depts);
+
+    /**
+     * 构建前端所需要下拉树结构
+     *
+     * @param depts 部门列表
+     * @return 下拉树结构列表
+     */
+    public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
+
+    /**
+     * 根据角色ID查询部门树信息
+     *
+     * @param roleId 角色ID
+     * @return 选中部门列表
+     */
+    public List<Long> selectDeptListByRoleId(Long roleId);
+
+    /**
+     * 根据部门ID查询信息
+     *
+     * @param deptId 部门ID
+     * @return 部门信息
+     */
+    public SysDept selectDeptById(Long deptId);
+
+
+    public List<SysDept> selectDeptListByParentId(Long parentId);
+    /**
+     * 根据ID查询所有子部门(正常状态)
+     *
+     * @param deptId 部门ID
+     * @return 子部门数
+     */
+    public int selectNormalChildrenDeptById(Long deptId);
+
+    /**
+     * 是否存在部门子节点
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    public boolean hasChildByDeptId(Long deptId);
+
+    /**
+     * 查询部门是否存在用户
+     *
+     * @param deptId 部门ID
+     * @return 结果 true 存在 false 不存在
+     */
+    public boolean checkDeptExistUser(Long deptId);
+
+    /**
+     * 校验部门名称是否唯一
+     *
+     * @param dept 部门信息
+     * @return 结果
+     */
+    public boolean checkDeptNameUnique(SysDept dept);
+
+    /**
+     * 校验部门是否有数据权限
+     *
+     * @param deptId 部门id
+     */
+    public void checkDeptDataScope(Long deptId);
+
+    /**
+     * 新增保存部门信息
+     *
+     * @param dept 部门信息
+     * @return 结果
+     */
+    public int insertDept(SysDept dept);
+
+    /**
+     * 修改保存部门信息
+     *
+     * @param dept 部门信息
+     * @return 结果
+     */
+    public int updateDept(SysDept dept);
+
+    /**
+     * 删除部门管理信息
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    public int deleteDeptById(Long deptId);
+
+    List<SysDept> selectDeptByUserId(Long userId);
+
+    List<SysDept> selectDeptListByDeptCode(String deptCode);
+
+    /**
+     * 获取部门列表数据
+     * @return
+     */
+    List<SysDept> getAllDeptList();
+
+    SysDept selectDept(String deptCode);
+}

+ 366 - 0
common/common-core/src/main/java/com/hdkj/lt/core/sys/service/impl/SysDeptServiceImpl.java

@@ -0,0 +1,366 @@
+package com.hdkj.lt.core.sys.service.impl;
+
+import com.hdkj.lt.core.sys.dao.SysDeptMapper;
+import com.hdkj.lt.core.sys.dao.SysRoleMapper;
+import com.hdkj.lt.core.sys.model.vo.TreeSelect;
+import com.hdkj.lt.core.sys.service.ISysDeptService;
+import com.ruoyi.common.core.constant.UserConstants;
+import com.ruoyi.common.core.exception.ServiceException;
+import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.core.utils.SpringUtils;
+import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.security.utils.SecurityUtils;
+import com.ruoyi.system.api.domain.SysDept;
+import com.ruoyi.system.api.domain.SysRole;
+import com.ruoyi.system.api.domain.SysUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 部门管理 服务实现
+ *
+ * @author ruoyi
+ */
+@Service
+public class SysDeptServiceImpl implements ISysDeptService
+{
+    @Autowired
+    private SysDeptMapper deptMapper;
+
+    @Autowired
+    private SysRoleMapper roleMapper;
+
+    /**
+     * 查询部门管理数据
+     *
+     * @param dept 部门信息
+     * @return 部门信息集合
+     */
+    @Override
+    public List<SysDept> selectDeptList(SysDept dept)
+    {
+        return deptMapper.selectDeptList(dept);
+    }
+
+    /**
+     * 查询部门树结构信息
+     *
+     * @param dept 部门信息
+     * @return 部门树信息集合
+     */
+    @Override
+    public List<TreeSelect> selectDeptTreeList(SysDept dept)
+    {
+        List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
+        return buildDeptTreeSelect(depts);
+    }
+
+    /**
+     * 构建前端所需要树结构
+     *
+     * @param depts 部门列表
+     * @return 树结构列表
+     */
+    @Override
+    public List<SysDept> buildDeptTree(List<SysDept> depts)
+    {
+        List<SysDept> returnList = new ArrayList<SysDept>();
+        List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
+        for (SysDept dept : depts)
+        {
+            // 如果是顶级节点, 遍历该父节点的所有子节点
+            if (!tempList.contains(dept.getParentId()))
+            {
+                recursionFn(depts, dept);
+                returnList.add(dept);
+            }
+        }
+        if (returnList.isEmpty())
+        {
+            returnList = depts;
+        }
+        return returnList;
+    }
+
+    /**
+     * 构建前端所需要下拉树结构
+     *
+     * @param depts 部门列表
+     * @return 下拉树结构列表
+     */
+    @Override
+    public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
+    {
+        List<SysDept> deptTrees = buildDeptTree(depts);
+        return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
+    }
+
+    /**
+     * 根据角色ID查询部门树信息
+     *
+     * @param roleId 角色ID
+     * @return 选中部门列表
+     */
+    @Override
+    public List<Long> selectDeptListByRoleId(Long roleId)
+    {
+        SysRole role = roleMapper.selectRoleById(roleId);
+        return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
+    }
+
+    /**
+     * 根据部门ID查询信息
+     *
+     * @param deptId 部门ID
+     * @return 部门信息
+     */
+    @Override
+    public SysDept selectDeptById(Long deptId)
+    {
+        return deptMapper.selectDeptById(deptId);
+    }
+
+    @Override
+    public List<SysDept> selectDeptListByParentId(Long parentId)
+    {
+        return deptMapper.selectDeptListByParentId(parentId);
+    }
+
+
+    /**
+     * 根据ID查询所有子部门(正常状态)
+     *
+     * @param deptId 部门ID
+     * @return 子部门数
+     */
+    @Override
+    public int selectNormalChildrenDeptById(Long deptId)
+    {
+        return deptMapper.selectNormalChildrenDeptById(deptId);
+    }
+
+    /**
+     * 是否存在子节点
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    @Override
+    public boolean hasChildByDeptId(Long deptId)
+    {
+        int result = deptMapper.hasChildByDeptId(deptId);
+        return result > 0;
+    }
+
+    /**
+     * 查询部门是否存在用户
+     *
+     * @param deptId 部门ID
+     * @return 结果 true 存在 false 不存在
+     */
+    @Override
+    public boolean checkDeptExistUser(Long deptId)
+    {
+        int result = deptMapper.checkDeptExistUser(deptId);
+        return result > 0;
+    }
+
+    /**
+     * 校验部门名称是否唯一
+     *
+     * @param dept 部门信息
+     * @return 结果
+     */
+    @Override
+    public boolean checkDeptNameUnique(SysDept dept)
+    {
+        Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
+        SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
+        if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
+        {
+            return UserConstants.NOT_UNIQUE;
+        }
+        return UserConstants.UNIQUE;
+    }
+
+    /**
+     * 校验部门是否有数据权限
+     *
+     * @param deptId 部门id
+     */
+    @Override
+    public void checkDeptDataScope(Long deptId)
+    {
+        if (!SysUser.isAdmin(SecurityUtils.getUserId()) && StringUtils.isNotNull(deptId))
+        {
+            SysDept dept = new SysDept();
+            dept.setDeptId(deptId);
+            List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
+            if (StringUtils.isEmpty(depts))
+            {
+                throw new ServiceException("没有权限访问部门数据!");
+            }
+        }
+    }
+
+    /**
+     * 新增保存部门信息
+     *
+     * @param dept 部门信息
+     * @return 结果
+     */
+    @Override
+    public int insertDept(SysDept dept)
+    {   //现在没有树结构 只有一级结构
+//        SysDept info = deptMapper.selectDeptById(dept.getParentId());
+//        // 如果父节点不为正常状态,则不允许新增子节点
+//        if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
+//        {
+//            throw new ServiceException("部门停用,不允许新增");
+//        }
+//        dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
+        return deptMapper.insertDept(dept);
+    }
+
+    /**
+     * 修改保存部门信息
+     *
+     * @param dept 部门信息
+     * @return 结果
+     */
+    @Override
+    public int updateDept(SysDept dept)
+    {
+        SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
+        SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
+        if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
+        {
+            String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
+            String oldAncestors = oldDept.getAncestors();
+            dept.setAncestors(newAncestors);
+            updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+        }
+        int result = deptMapper.updateDept(dept);
+        if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
+                && !StringUtils.equals("0", dept.getAncestors()))
+        {
+            // 如果该部门是启用状态,则启用该部门的所有上级部门
+            updateParentDeptStatusNormal(dept);
+        }
+        return result;
+    }
+
+    /**
+     * 修改该部门的父级部门状态
+     *
+     * @param dept 当前部门
+     */
+    private void updateParentDeptStatusNormal(SysDept dept)
+    {
+        String ancestors = dept.getAncestors();
+        Long[] deptIds = Convert.toLongArray(ancestors);
+        deptMapper.updateDeptStatusNormal(deptIds);
+    }
+
+    /**
+     * 修改子元素关系
+     *
+     * @param deptId 被修改的部门ID
+     * @param newAncestors 新的父ID集合
+     * @param oldAncestors 旧的父ID集合
+     */
+    public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors)
+    {
+        List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
+        for (SysDept child : children)
+        {
+            child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
+        }
+        if (children.size() > 0)
+        {
+            deptMapper.updateDeptChildren(children);
+        }
+    }
+
+    /**
+     * 删除部门管理信息
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    @Override
+    public int deleteDeptById(Long deptId)
+    {
+        return deptMapper.deleteDeptById(deptId);
+    }
+
+    /**
+     * 递归列表
+     */
+    private void recursionFn(List<SysDept> list, SysDept t)
+    {
+        // 得到子节点列表
+        List<SysDept> childList = getChildList(list, t);
+        t.setChildren(childList);
+        for (SysDept tChild : childList)
+        {
+            if (hasChild(list, tChild))
+            {
+                recursionFn(list, tChild);
+            }
+        }
+    }
+
+    /**
+     * 得到子节点列表
+     */
+    private List<SysDept> getChildList(List<SysDept> list, SysDept t)
+    {
+        List<SysDept> tlist = new ArrayList<SysDept>();
+        Iterator<SysDept> it = list.iterator();
+        while (it.hasNext())
+        {
+            SysDept n = (SysDept) it.next();
+            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
+            {
+                tlist.add(n);
+            }
+        }
+        return tlist;
+    }
+
+    /**
+     * 判断是否有子节点
+     */
+    private boolean hasChild(List<SysDept> list, SysDept t)
+    {
+        return getChildList(list, t).size() > 0 ? true : false;
+    }
+
+    @Override
+    public List<SysDept> selectDeptByUserId(Long userId)
+    {
+        return deptMapper.selectDeptByUserId(userId);
+    }
+
+    @Override
+    public List<SysDept> selectDeptListByDeptCode(String deptCode) {
+        return deptMapper.selectDeptListByDeptCode(deptCode);
+    }
+
+    @Override
+    public List<SysDept> getAllDeptList() {
+        return deptMapper.getAllDeptList();
+    }
+
+    @Override
+    public SysDept selectDept(String deptCode) {
+        return deptMapper.selectDept(deptCode);
+    }
+
+}

+ 19 - 10
common/common-core/src/main/java/com/hdkj/lt/core/sys/service/impl/SysStruServiceImpl.java

@@ -1,6 +1,5 @@
 package com.hdkj.lt.core.sys.service.impl;
 
-import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.StopWatch;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -15,12 +14,13 @@ import com.hdkj.lt.core.sys.dao.SysStruMapper;
 import com.hdkj.lt.core.sys.model.dto.OrgInfoDto;
 import com.hdkj.lt.core.sys.model.dto.StruTreeCacheDTO;
 import com.hdkj.lt.core.sys.model.dto.UnitQueryDTO;
+import com.hdkj.lt.core.sys.model.po.OrganizationBo;
 import com.hdkj.lt.core.sys.model.po.SysStru;
-import com.hdkj.lt.core.sys.service.ISysDictService;
+import com.hdkj.lt.core.sys.service.ISysDeptService;
 import com.hdkj.lt.core.sys.service.ISysStruService;
 import com.hdkj.lt.utils.cache.RedisRepository;
 import com.hdkj.lt.utils.tree.TreeBuilder;
-import com.hdkj.lt.core.sys.model.po.OrganizationBo;
+import com.ruoyi.system.api.domain.SysDept;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -44,6 +44,8 @@ public class SysStruServiceImpl extends ServiceImpl<SysStruMapper, SysStru> impl
 
     private final RedisRepository redisRepository;
 
+    private final ISysDeptService sysDeptService;
+
 //    private final ISysDictService sysDictService;
 
     @Override
@@ -110,16 +112,23 @@ public class SysStruServiceImpl extends ServiceImpl<SysStruMapper, SysStru> impl
     //查询全量的构建全量组织树
     @Override
     public Map<Long, StruTreeCacheDTO> getStruFullTree() {
-        List<SysStru> struList = baseMapper.getStruList();
-        List<StruTreeCacheDTO> struTreeVOList = new ArrayList<>();
-        if (CollUtil.isNotEmpty(struList)) {
-            struList.forEach(e -> {
+        List<SysDept> allDeptList = sysDeptService.getAllDeptList();
+        List<StruTreeCacheDTO> treeList = Lists.newArrayList();
+        if (CollUtil.isNotEmpty(allDeptList)) {
+            allDeptList.forEach(e -> {
                 StruTreeCacheDTO struTreeCacheDTO = new StruTreeCacheDTO();
-                BeanUtil.copyProperties(e, struTreeCacheDTO);
-                struTreeVOList.add(struTreeCacheDTO);
+                struTreeCacheDTO.setParentId(e.getParentId());
+                struTreeCacheDTO.setName(e.getShortName());
+                struTreeCacheDTO.setStruId(e.getDeptId());
+                struTreeCacheDTO.setStruLevel(e.getDeptLv() == null ? null : Integer.valueOf(e.getStruLevel()));
+                struTreeCacheDTO.setOrganAlias(e.getDeptName());
+                struTreeCacheDTO.setStruOrder(e.getOrderNum());
+                struTreeCacheDTO.setStruType(e.getStruType());
+                struTreeCacheDTO.setIscOrgId(e.getIscOrgId());
+                treeList.add(struTreeCacheDTO);
             });
         }
-        Map<Long, StruTreeCacheDTO> result = TreeBuilder.buildFullTree(struTreeVOList);
+        Map<Long, StruTreeCacheDTO> result = TreeBuilder.buildFullTree(treeList);
         return result;
     }
 

+ 219 - 0
common/common-core/src/main/resources/mapper/SysDeptMapper.xml

@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hdkj.lt.core.sys.dao.SysDeptMapper">
+	<resultMap type="com.ruoyi.system.api.domain.SysDept" id="SysDeptResult">
+		<id     property="deptId"     column="dept_id"     />
+		<result property="parentId"   column="parent_id"   />
+		<result property="ancestors"  column="ancestors"   />
+		<result property="deptName"   column="dept_name"   />
+		<result property="orderNum"   column="order_num"   />
+		<result property="leader"     column="leader"      />
+		<result property="phone"      column="phone"       />
+		<result property="email"      column="email"       />
+		<result property="status"     column="status"      />
+		<result property="delFlag"    column="del_flag"    />
+		<result property="createBy"   column="create_by"   />
+		<result property="createTime" column="create_time" />
+		<result property="updateBy"   column="update_by"   />
+		<result property="updateTime" column="update_time" />
+		<result property="shortName" column="short_name" />
+	</resultMap>
+
+	<sql id="selectDeptVo">
+        select d.dept_id,d.dept_code, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
+        ,d.short_name,d.stru_level,d.stru_type,d.isc_org_id
+        from sys_dept d
+    </sql>
+
+	<select id="getAllDeptList" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		<where>
+			d.del_flag = '0'
+		</where>
+		order by d.parent_id, d.order_num
+	</select>
+
+
+	<select id="selectDeptList" parameterType="com.ruoyi.system.api.domain.SysDept" resultMap="SysDeptResult">
+        <include refid="selectDeptVo"/>
+        where d.del_flag = '0'
+		<if test="deptId != null and deptId != 0">
+			AND dept_id = #{deptId}
+		</if>
+        <if test="parentId != null and parentId != 0">
+			AND parent_id = #{parentId}
+		</if>
+		<if test="deptName != null and deptName != ''">
+			AND dept_name like concat('%', #{deptName}, '%')
+		</if>
+		<if test="status != null and status != ''">
+			AND status = #{status}
+		</if>
+		<!-- 数据范围过滤 -->
+		${params.dataScope}
+		order by d.parent_id, d.order_num
+    </select>
+
+	<select id="selectDeptListByParentId" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		where d.del_flag = '0' and status = '0'
+		AND parent_id = #{parentId}
+		<!-- 数据范围过滤 -->
+		order by d.parent_id, d.order_num
+	</select>
+
+    <select id="selectDeptListByRoleId" resultType="java.lang.Long">
+		select d.dept_id
+		from sys_dept d
+            left join sys_role_dept rd on d.dept_id = rd.dept_id
+        where rd.role_id = #{roleId}
+            <if test="deptCheckStrictly">
+              and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
+            </if>
+		order by d.parent_id, d.order_num
+	</select>
+
+    <select id="selectDeptById" parameterType="java.lang.Long" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		where dept_id = #{deptId}
+	</select>
+
+    <select id="checkDeptExistUser" parameterType="java.lang.Long" resultType="int">
+		select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
+	</select>
+
+	<select id="hasChildByDeptId" parameterType="java.lang.Long" resultType="int">
+		select count(1) from sys_dept
+		where del_flag = '0' and parent_id = #{deptId} limit 1
+	</select>
+
+	<select id="selectChildrenDeptById" parameterType="java.lang.Long" resultMap="SysDeptResult">
+		select * from sys_dept where find_in_set(#{deptId}, ancestors)
+	</select>
+
+	<select id="selectNormalChildrenDeptById" parameterType="java.lang.Long" resultType="int">
+		select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
+	</select>
+
+	<select id="checkDeptNameUnique" resultMap="SysDeptResult">
+	    <include refid="selectDeptVo"/>
+		where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
+	</select>
+
+    <insert id="insertDept" parameterType="com.ruoyi.system.api.domain.SysDept"  useGeneratedKeys="true" keyProperty="deptId">
+		insert into sys_dept(
+		<if test="deptId != null and deptId != 0">dept_id,</if>
+		<if test="deptCode != null and deptCode != ''">dept_code,</if>
+		<if test="parentId != null and parentId != 0">parent_id,</if>
+		<if test="deptName != null and deptName != ''">dept_name,</if>
+		<if test="ancestors != null and ancestors != ''">ancestors,</if>
+		<if test="orderNum != null">order_num,</if>
+		<if test="leader != null and leader != ''">leader,</if>
+		<if test="phone != null and phone != ''">phone,</if>
+		<if test="email != null and email != ''">email,</if>
+		<if test="status != null">status,</if>
+		<if test="createBy != null and createBy != ''">create_by,</if>
+		create_time
+		)values(
+		<if test="deptId != null and deptId != 0">#{deptId},</if>
+		<if test="deptCode != null and deptCode != ''">#{deptCode},</if>
+		<if test="parentId != null and parentId != 0">#{parentId},</if>
+		<if test="deptName != null and deptName != ''">#{deptName},</if>
+		<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
+		<if test="orderNum != null">#{orderNum},</if>
+		<if test="leader != null and leader != ''">#{leader},</if>
+		<if test="phone != null and phone != ''">#{phone},</if>
+		<if test="email != null and email != ''">#{email},</if>
+		<if test="status != null">#{status},</if>
+		<if test="createBy != null and createBy != ''">#{createBy},</if>
+		sysdate()
+		)
+	</insert>
+
+	<update id="updateDept" parameterType="com.ruoyi.system.api.domain.SysDept">
+ 		update sys_dept
+ 		<set>
+ 			<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
+ 			<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
+ 			<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
+ 			<if test="orderNum != null">order_num = #{orderNum},</if>
+ 			<if test="leader != null">leader = #{leader},</if>
+ 			<if test="phone != null">phone = #{phone},</if>
+ 			<if test="email != null">email = #{email},</if>
+ 			<if test="status != null and status != ''">status = #{status},</if>
+ 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+ 			update_time = sysdate()
+ 		</set>
+ 		where dept_id = #{deptId}
+	</update>
+
+	<update id="updateDeptChildren" parameterType="java.util.List">
+	    update sys_dept set ancestors =
+	    <foreach collection="depts" item="item" index="index"
+	        separator=" " open="case dept_id" close="end">
+	        when #{item.deptId} then #{item.ancestors}
+	    </foreach>
+	    where dept_id in
+	    <foreach collection="depts" item="item" index="index"
+	        separator="," open="(" close=")">
+	        #{item.deptId}
+	    </foreach>
+	</update>
+
+	<update id="updateDeptStatusNormal" parameterType="java.lang.Long">
+ 	    update sys_dept set status = '0' where dept_id in
+ 	    <foreach collection="array" item="deptId" open="(" separator="," close=")">
+        	#{deptId}
+        </foreach>
+	</update>
+
+	<delete id="deleteDeptById" parameterType="java.lang.Long">
+		update sys_dept set del_flag = '2' where dept_id = #{deptId}
+	</delete>
+
+	<select id="selectDeptByUserId" parameterType="java.lang.Long" resultMap="SysDeptResult">
+		select d.* from sys_user u
+							inner join sys_dept d on
+			d.ancestors like CONCAT('%',u.dept_id,'%')
+				or d.dept_id = u.dept_id
+		where u.user_id =#{userId}
+	</select>
+
+	<select id="selectDeptListByDeptCode" resultType="com.ruoyi.system.api.domain.SysDept"
+			parameterType="java.lang.String">
+		select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.dept_code,
+			   d.del_flag, d.create_by, d.create_time,d.short_name,d.dept_lv,d.dept_lv_name
+		from sys_dept d
+				 join (select dept_id from sys_dept where dept_code = #{deptCode} ) p
+		where d.dept_lv in('02','03','04')
+		  and(d.dept_id = p.dept_id or FIND_IN_SET(p.dept_id,d.ancestors)>0)
+		order by d.dept_code
+	</select>
+
+	<select id="selectOne"  parameterType="java.lang.String">
+		select count(*) from sys_dept
+		where dept_name= #{deptName} and del_flag='0'
+	</select>
+
+	<delete id="deleteDeptByIds" parameterType="java.lang.Long">
+		update sys_dept set del_flag = '2' where dept_id in
+		<foreach collection="deptIds" item="deptId" open="(" close=")" separator=",">
+			#{deptId}
+		</foreach>
+	</delete>
+
+	<select id="selectDeptName"  resultType="com.ruoyi.system.api.domain.SysDept">
+		select * from sys_dept
+		where dept_name= #{deptName} and del_flag='0' and dept_code =#{deptCode}
+	</select>
+
+	<select id="selectDept" resultType="com.ruoyi.system.api.domain.SysDept"
+			parameterType="java.lang.String">
+		select dept_id, dept_name
+		from sys_dept
+				 where dept_code = #{deptCode}
+		limit 1
+	</select>
+</mapper>

+ 173 - 0
common/common-core/src/main/resources/mapper/SysRoleMapper.xml

@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hdkj.lt.core.sys.dao.SysRoleMapper">
+
+	<resultMap type="com.ruoyi.system.api.domain.SysRole" id="SysRoleResult">
+		<id     property="roleId"             column="role_id"               />
+		<result property="roleName"           column="role_name"             />
+		<result property="roleKey"            column="role_key"              />
+		<result property="roleSort"           column="role_sort"             />
+		<result property="dataScope"          column="data_scope"            />
+		<result property="menuCheckStrictly"  column="menu_check_strictly"   />
+		<result property="deptCheckStrictly"  column="dept_check_strictly"   />
+		<result property="status"             column="status"                />
+		<result property="delFlag"            column="del_flag"              />
+		<result property="createBy"           column="create_by"             />
+		<result property="createTime"         column="create_time"           />
+		<result property="updateBy"           column="update_by"             />
+		<result property="updateTime"         column="update_time"           />
+		<result property="remark"             column="remark"                />
+		<result property="singleRole"         column="single_role"           />
+		<result property="belongType"         column="belong_type"           />
+	</resultMap>
+
+	<sql id="selectRoleVo">
+	    select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
+            r.status, r.del_flag, r.create_time, r.remark , r.single_role,r.belong_type
+        from sys_role r
+	        left join sys_user_role ur on ur.role_id = r.role_id
+	        left join sys_user u on u.user_id = ur.user_id
+	        left join sys_dept d on u.dept_id = d.dept_id
+    </sql>
+
+	<select id="selecRole" resultMap="SysRoleResult">
+        select role_id , role_name from sys_role where role_id in ("102","103","104","105")
+    </select>
+
+    <select id="selectRoleList" parameterType="com.ruoyi.system.api.domain.SysRole" resultMap="SysRoleResult">
+		<include refid="selectRoleVo"/>
+		where r.del_flag = '0'
+		<if test="roleId != null and roleId != 0">
+			AND r.role_id = #{roleId}
+		</if>
+		<if test="roleName != null and roleName != ''">
+			AND r.role_name like concat('%', #{roleName}, '%')
+		</if>
+		<if test="status != null and status != ''">
+			AND r.status = #{status}
+		</if>
+		<if test="roleKey != null and roleKey != ''">
+			AND r.role_key like concat('%', #{roleKey}, '%')
+		</if>
+		<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
+			and date_format(r.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
+		</if>
+		<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
+			and date_format(r.create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
+		</if>
+		<!-- 数据范围过滤 -->
+		${params.dataScope}
+		order by r.role_sort
+	</select>
+
+	<select id="selectRolePermissionByUserId" parameterType="java.lang.Long" resultMap="SysRoleResult">
+		<include refid="selectRoleVo"/>
+		WHERE r.del_flag = '0' and ur.user_id = #{userId}
+	</select>
+
+	<select id="selectRoleAll" resultMap="SysRoleResult">
+		<include refid="selectRoleVo"/>
+	</select>
+
+	<select id="selectRoleListByUserId" parameterType="java.lang.Long" resultType="java.lang.Long">
+		select r.role_id
+        from sys_role r
+	        left join sys_user_role ur on ur.role_id = r.role_id
+	        left join sys_user u on u.user_id = ur.user_id
+	    where u.user_id = #{userId}
+	</select>
+
+	<select id="selectRoleById" parameterType="java.lang.Long" resultMap="SysRoleResult">
+		<include refid="selectRoleVo"/>
+		where r.role_id = #{roleId}
+	</select>
+
+	<select id="selectRolesByUserName" parameterType="java.lang.String" resultMap="SysRoleResult">
+		<include refid="selectRoleVo"/>
+		WHERE r.del_flag = '0' and u.user_name = #{userName}
+	</select>
+
+	<select id="checkRoleNameUnique" parameterType="java.lang.String" resultMap="SysRoleResult">
+		<include refid="selectRoleVo"/>
+		 where r.role_name=#{roleName} and r.del_flag = '0' limit 1
+	</select>
+
+	<select id="checkRoleKeyUnique" parameterType="java.lang.String" resultMap="SysRoleResult">
+		<include refid="selectRoleVo"/>
+		 where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
+	</select>
+
+	<select id="selectRoleListBy" resultMap="SysRoleResult">
+		<include refid="selectRoleVo"/>
+		where  r.del_flag = '0'
+		<if test="roleIds != null and roleIds.size != 0">
+			and r.role_id in
+			<foreach collection="roleIds" item="roleId" close=")" open="(" separator=",">
+				#{roleId}
+			</foreach>
+		</if>
+	</select>
+
+ 	<insert id="insertRole" parameterType="com.ruoyi.system.api.domain.SysRole" useGeneratedKeys="true" keyProperty="roleId">
+ 		insert into sys_role(
+ 			<if test="roleId != null and roleId != 0">role_id,</if>
+ 			<if test="roleName != null and roleName != ''">role_name,</if>
+ 			<if test="roleKey != null and roleKey != ''">role_key,</if>
+ 			<if test="roleSort != null">role_sort,</if>
+ 			<if test="dataScope != null and dataScope != ''">data_scope,</if>
+ 			<if test="menuCheckStrictly != null">menu_check_strictly,</if>
+ 			<if test="deptCheckStrictly != null">dept_check_strictly,</if>
+ 			<if test="status != null and status != ''">status,</if>
+ 			<if test="remark != null and remark != ''">remark,</if>
+ 			<if test="createBy != null and createBy != ''">create_by,</if>
+ 			<if test="belongType != null and belongType != ''">belong_type,</if>
+ 			create_time
+ 		)values(
+ 			<if test="roleId != null and roleId != 0">#{roleId},</if>
+ 			<if test="roleName != null and roleName != ''">#{roleName},</if>
+ 			<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
+ 			<if test="roleSort != null">#{roleSort},</if>
+ 			<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
+ 			<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
+ 			<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
+ 			<if test="status != null and status != ''">#{status},</if>
+ 			<if test="remark != null and remark != ''">#{remark},</if>
+ 			<if test="createBy != null and createBy != ''">#{createBy},</if>
+		<if test="belongType != null and belongType != ''">#{belongType},</if>
+ 			sysdate()
+ 		)
+	</insert>
+
+	<update id="updateRole" parameterType="com.ruoyi.system.api.domain.SysRole">
+ 		update sys_role
+ 		<set>
+ 			<if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
+ 			<if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
+ 			<if test="roleSort != null">role_sort = #{roleSort},</if>
+ 			<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
+ 			<if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
+ 			<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
+ 			<if test="status != null and status != ''">status = #{status},</if>
+ 			<if test="singleRole != null and singleRole != ''">single_role = #{singleRole},</if>
+ 			<if test="remark != null">remark = #{remark},</if>
+ 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+ 			<if test="belongType != null and belongType != ''">belong_type = #{belongType},</if>
+ 			update_time = sysdate()
+ 		</set>
+ 		where role_id = #{roleId}
+	</update>
+
+	<delete id="deleteRoleById" parameterType="java.lang.Long">
+ 		update sys_role set del_flag = '2' where role_id = #{roleId}
+ 	</delete>
+
+ 	<delete id="deleteRoleByIds" parameterType="java.lang.Long">
+ 	    update sys_role set del_flag = '2' where role_id in
+ 		<foreach collection="array" item="roleId" open="(" separator="," close=")">
+ 			#{roleId}
+        </foreach>
+ 	</delete>
+
+</mapper>

+ 3 - 3
services/load-transfer-bf/src/main/resources/mapper/SystemThemeMapper.xml

@@ -11,7 +11,7 @@
                  sdd.dict_value
             FROM sys_dict_type sdt
             LEFT JOIN sys_dict_data sdd ON sdt.dict_type = sdd.dict_type
-            WHERE sdt.dict_name = 'system_color' AND sdd.dict_sort = #{param})
+            WHERE sdt.dict_type = 'system_color' AND sdd.dict_sort = #{param})
         WHERE usc.USER_ID = #{userId}
     </update>
 
@@ -27,7 +27,7 @@
             sys_dict_data sdd ON sdt.dict_type = sdd.dict_type
         INNER JOIN
             USER_SYS_COLOR usc ON usc.SYSTEM_COLOR =sdd.dict_value
-        WHERE sdt.dict_name = 'system_color' AND usc.USER_ID = #{userId}
+        WHERE sdt.dict_type = 'system_color' AND usc.USER_ID = #{userId}
     </select>
 
     <select id="getAllSort" resultType="java.lang.Integer">
@@ -36,6 +36,6 @@
         FROM sys_dict_type sdt
         LEFT JOIN
             sys_dict_data sdd on sdt.dict_type = sdd.dict_type
-        WHERE sdt.dict_name = 'system_color'
+        WHERE sdt.dict_type = 'system_color'
     </select>
 </mapper>