Merge remote-tracking branch 'origin/dev' into dev
| | |
| | | |
| | | /** 父部门名称 */ |
| | | private String parentName; |
| | | |
| | | private String orgCode; |
| | | |
| | | /** 子部门 */ |
| | | private List<SysDept> children = new ArrayList<SysDept>(); |
| | |
| | | this.children = children; |
| | | } |
| | | |
| | | public String getOrgCode() { |
| | | return orgCode; |
| | | } |
| | | |
| | | public void setOrgCode(String orgCode) { |
| | | this.orgCode = orgCode; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("orgCode", getOrgCode()) |
| | | .toString(); |
| | | } |
| | | } |
| | |
| | | break; |
| | | } |
| | | else if (DATA_SCOPE_CUSTOM.equals(dataScope)) |
| | | { |
| | | { /*自定义数据权限*/ |
| | | if (scopeCustomIds.size() > 1) |
| | | { |
| | | // 多个自定数据权限使用in查询,避免多次拼接。 |
| | |
| | | } |
| | | } |
| | | else if (DATA_SCOPE_DEPT.equals(dataScope)) |
| | | { |
| | | { /*本部门数据权限*/ |
| | | sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); |
| | | } |
| | | else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) |
| | | { |
| | | { /*本部门以及以下数据权限*/ |
| | | sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptAlias, user.getDeptId(), user.getDeptId())); |
| | | } |
| | | else if (DATA_SCOPE_SELF.equals(dataScope)) |
| | | { |
| | | { /*仅本人数据权限*/ |
| | | if (StringUtils.isNotBlank(userAlias)) |
| | | { |
| | | sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId())); |
| | |
| | | /** 部门ID */ |
| | | private Long deptId; |
| | | |
| | | |
| | | /**部门组织编码*/ |
| | | private String deptOrgCode; |
| | | |
| | | public Long getRoleId() |
| | | { |
| | | return roleId; |
| | |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | |
| | | public String getDeptOrgCode() { |
| | | return deptOrgCode; |
| | | } |
| | | |
| | | public void setDeptOrgCode(String deptOrgCode) { |
| | | this.deptOrgCode = deptOrgCode; |
| | | } |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("roleId", getRoleId()) |
| | | .append("deptId", getDeptId()) |
| | | .append("deptOrgCode", getDeptOrgCode()) |
| | | .toString(); |
| | | } |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteDeptById(Long deptId); |
| | | |
| | | List<SysDept> selectDeptListByIdList(List<Long> deptIdList); |
| | | } |
| | |
| | | package com.aps.system.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | |
| | | import com.aps.system.api.domain.SysDept; |
| | | import com.aps.system.mapper.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import com.aps.system.domain.SysRoleDept; |
| | | import com.aps.system.domain.SysRoleMenu; |
| | | import com.aps.system.domain.SysUserRole; |
| | | import com.aps.system.mapper.SysRoleDeptMapper; |
| | | import com.aps.system.mapper.SysRoleMapper; |
| | | import com.aps.system.mapper.SysRoleMenuMapper; |
| | | import com.aps.system.mapper.SysUserRoleMapper; |
| | | import com.aps.system.service.ISysRoleService; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private SysRoleDeptMapper roleDeptMapper; |
| | | |
| | | @Autowired |
| | | private SysDeptMapper deptMapper; |
| | | /** |
| | | * 根据条件分页查询角色数据 |
| | | * |
| | |
| | | int rows = 1; |
| | | // 新增角色与部门(数据权限)管理 |
| | | List<SysRoleDept> list = new ArrayList<SysRoleDept>(); |
| | | for (Long deptId : role.getDeptIds()) |
| | | Long[] deptIds = role.getDeptIds(); |
| | | List<SysDept> sysDepts = deptMapper.selectDeptListByIdList(Arrays.asList(deptIds)); |
| | | |
| | | for (Long deptId : deptIds) |
| | | { |
| | | SysRoleDept rd = new SysRoleDept(); |
| | | rd.setRoleId(role.getRoleId()); |
| | | rd.setDeptId(deptId); |
| | | list.add(rd); |
| | | Optional<SysDept> first = sysDepts.stream().filter(sysDept -> sysDept.getDeptId().equals(deptId)).findFirst(); |
| | | if(first.isPresent()){ |
| | | SysDept sysDept = first.get(); |
| | | SysRoleDept rd = new SysRoleDept(); |
| | | rd.setRoleId(role.getRoleId()); |
| | | rd.setDeptId(deptId); |
| | | rd.setDeptOrgCode(sysDept.getOrgCode()); |
| | | list.add(rd); |
| | | } |
| | | |
| | | } |
| | | if (list.size() > 0) |
| | | { |
| | |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="orgCode" column="org_code" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectDeptVo"> |
| | | select d.dept_id, 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 |
| | | select d.dept_id, 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.org_code |
| | | from sys_dept d |
| | | </sql> |
| | | |
| | |
| | | <if test="email != null and email != ''">email,</if> |
| | | <if test="status != null">status,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | <if test="orgCode != null and orgCode != ''">org_code,</if> |
| | | create_time |
| | | )values( |
| | | <if test="deptId != null and deptId != 0">#{deptId},</if> |
| | |
| | | <if test="email != null and email != ''">#{email},</if> |
| | | <if test="status != null">#{status},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | <if test="orgCode != null and orgCode != ''">#{orgCode},</if> |
| | | now() |
| | | ) |
| | | </insert> |
| | |
| | | <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> |
| | | <if test="orgCode != null and orgCode != ''">org_code = #{orgCode},</if> |
| | | update_time = now() |
| | | </set> |
| | | where dept_id = #{deptId} |
| | |
| | | <delete id="deleteDeptById" parameterType="Long"> |
| | | update sys_dept set del_flag = '2' where dept_id = #{deptId} |
| | | </delete> |
| | | <select id="selectDeptListByIdList" parameterType="Long" resultMap="SysDeptResult"> |
| | | <include refid="selectDeptVo"/> |
| | | where d.del_flag = '0' and dept_id in |
| | | <foreach collection="deptIdList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | order by d.parent_id, d.order_num |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | </delete> |
| | | |
| | | <insert id="batchRoleDept"> |
| | | insert into sys_role_dept(role_id, dept_id) values |
| | | insert into sys_role_dept(role_id, dept_id,dept_org_code) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.roleId},#{item.deptId}) |
| | | (#{item.roleId},#{item.deptId},#{item.deptOrgCode}) |
| | | </foreach> |
| | | </insert> |
| | | |