19 files modified
3 files added
| | |
| | | { |
| | | startPage(); |
| | | List<SysUser> list = userService.selectUserList(user); |
| | | return getDataTable(list); |
| | | TableDataInfo dataTable = getDataTable(list); |
| | | dataTable.setTotal(userService.selectUserListCount(user)); |
| | | return dataTable; |
| | | } |
| | | |
| | | |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) |
| | | { |
| | | deptService.checkDeptDataScope(user.getDeptId()); |
| | | //deptService.checkDeptDataScope(user.getDeptId()); |
| | | roleService.checkRoleDataScope(user.getRoleIds()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | deptService.checkDeptDataScope(user.getDeptId()); |
| | | //deptService.checkDeptDataScope(user.getDeptId()); |
| | | roleService.checkRoleDataScope(user.getRoleIds()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | |
| | | @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), |
| | | @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) |
| | | }) |
| | | private SysDept dept; |
| | | private List<SysDept> depts; |
| | | |
| | | @ApiModelProperty("角色key") |
| | | private String roleKey; |
| | |
| | | |
| | | /** 角色组 */ |
| | | private Long[] roleIds; |
| | | |
| | | /** 部门组 */ |
| | | private Long[] deptIds; |
| | | |
| | | /** 岗位组 */ |
| | | private Long[] postIds; |
| | |
| | | this.loginDate = loginDate; |
| | | } |
| | | |
| | | public SysDept getDept() |
| | | { |
| | | return dept; |
| | | } |
| | | |
| | | public void setDept(SysDept dept) |
| | | { |
| | | this.dept = dept; |
| | | } |
| | | |
| | | public List<SysRole> getRoles() |
| | | { |
| | |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .append("dept", getDept()) |
| | | .append("depts", getDepts()) |
| | | .toString(); |
| | | } |
| | | |
| | | public List<SysDept> getDepts() { |
| | | return depts; |
| | | } |
| | | |
| | | public void setDepts(List<SysDept> depts) { |
| | | this.depts = depts; |
| | | } |
| | | |
| | | public Long[] getDeptIds() { |
| | | return deptIds; |
| | | } |
| | | |
| | | public void setDeptIds(Long[] deptIds) { |
| | | this.deptIds = deptIds; |
| | | } |
| | | } |
| | |
| | | */ |
| | | private Set<String> permissions; |
| | | |
| | | private Long[] deptIds; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | */ |
| | |
| | | this.deptId = deptId; |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions, Long[] deptIds) { |
| | | this.userId = userId; |
| | | this.deptId = deptId; |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | this.deptIds = deptIds; |
| | | } |
| | | |
| | | public Long getUserId() |
| | |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | public Long[] getDeptIds() { |
| | | return deptIds; |
| | | } |
| | | |
| | | public void setDeptIds(Long[] deptIds) { |
| | | this.deptIds = deptIds; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public static Long[] getDeptIds() |
| | | { |
| | | try |
| | | { |
| | | return getLoginUser().getDeptIds(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取用户账户 |
| | | **/ |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | |
| | | } |
| | | else if (DATA_SCOPE_DEPT.equals(dataScope)) |
| | | { |
| | | // sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); |
| | | if (ObjectUtil.isNotEmpty(user.getDeptIds())) |
| | | { |
| | | sqlString.append(StringUtils.format(" OR {}.dept_id IN ({}) ", deptAlias, StringUtils.join(user.getDeptIds(), ","))); |
| | | } |
| | | else |
| | | { |
| | | 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())); |
| | | Long[] deptIds = user.getDeptIds(); |
| | | if (deptIds != null && deptIds.length > 0) |
| | | { |
| | | // 多个部门时,查询这些部门及其所有子部门 |
| | | StringBuilder deptCondition = new StringBuilder(); |
| | | for (int i = 0; i < deptIds.length; i++) |
| | | { |
| | | if (i > 0) |
| | | { |
| | | deptCondition.append(" OR "); |
| | | } |
| | | deptCondition.append(StringUtils.format("{}.dept_id = {} OR find_in_set({}, {}.ancestors)", deptAlias, deptIds[i], deptIds[i], deptAlias)); |
| | | } |
| | | sqlString.append(StringUtils.format(" OR ( {} )", deptCondition.toString())); |
| | | } |
| | | //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)) |
| | | { |
| | |
| | | package com.gkhy.framework.aspectj; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.gkhy.common.core.domain.entity.SysDept; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.AfterReturning; |
| | |
| | | { |
| | | operLog.setOperName(loginUser.getUsername()); |
| | | SysUser currentUser = loginUser.getUser(); |
| | | if (StringUtils.isNotNull(currentUser) && StringUtils.isNotNull(currentUser.getDept())) |
| | | if (StringUtils.isNotNull(currentUser) && ObjectUtil.isNotEmpty(currentUser.getDepts())) |
| | | { |
| | | operLog.setDeptName(currentUser.getDept().getDeptName()); |
| | | List<SysDept> depts = currentUser.getDepts(); |
| | | String deptNames = depts == null ? "" : depts.stream() |
| | | .map(SysDept::getDeptName) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.joining(",")); |
| | | operLog.setDeptName(deptNames); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.gkhy.framework.web.service; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.gkhy.common.core.domain.entity.SysDept; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.gkhy.common.utils.MessageUtils; |
| | | import com.gkhy.common.utils.StringUtils; |
| | | import com.gkhy.system.service.ISysUserService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户验证处理 |
| | |
| | | } |
| | | |
| | | passwordService.validate(user); |
| | | |
| | | List<SysDept> depts = user.getDepts(); |
| | | if (ObjectUtil.isNotEmpty(depts)){ |
| | | user.setDeptIds(depts.stream().map(SysDept::getDeptId).toArray(Long[]::new)); |
| | | } |
| | | return createLoginUser(user); |
| | | } |
| | | |
| | | public UserDetails createLoginUser(SysUser user) |
| | | { |
| | | if (ObjectUtil.isNotEmpty(user.getDeptIds())){ |
| | | |
| | | return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user), user.getDeptIds()); |
| | | } |
| | | |
| | | return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user)); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.gkhy.system.domain; |
| | | |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | *用户和部门关联 sys_user_dept |
| | | * |
| | | * @author gkhy |
| | | */ |
| | | @Data |
| | | public class SysUserDept |
| | | { |
| | | /** 用户ID */ |
| | | private Long userId; |
| | | |
| | | /** 部门ID */ |
| | | private Long deptId; |
| | | |
| | | } |
| | |
| | | package com.gkhy.system.domain; |
| | | |
| | | import com.gkhy.common.core.domain.entity.SysDept; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 当前在线会话 |
| | | * |
| | |
| | | |
| | | /** 部门名称 */ |
| | | private String deptName; |
| | | |
| | | private List<SysDept> depts; |
| | | |
| | | /** 用户名称 */ |
| | | private String userName; |
| | |
| | | { |
| | | this.loginTime = loginTime; |
| | | } |
| | | |
| | | public List<SysDept> getDepts() { |
| | | return depts; |
| | | } |
| | | |
| | | public void setDepts(List<SysDept> depts) { |
| | | this.depts = depts; |
| | | } |
| | | } |
| | |
| | | List<DailySafetyInspection> getDailySafetyInspectionList(DailySafetyInspection dailySafetyInspection); |
| | | |
| | | int getCheckCount(Long deptId); |
| | | |
| | | int getCheckCountList(List<Long> deptIds); |
| | | } |
| | |
| | | */ |
| | | public SysDept selectDeptById(Long deptId); |
| | | |
| | | List<SysDept> selectDeptByIds (Long[] ids); |
| | | |
| | | /** |
| | | * 根据ID查询所有子部门 |
| | | * |
| New file |
| | |
| | | package com.gkhy.system.mapper; |
| | | |
| | | import com.gkhy.system.domain.SysUserDept; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | *用户与部门关联表 数据层 |
| | | * |
| | | * @author gkhy |
| | | */ |
| | | public interface SysUserDeptMapper |
| | | { |
| | | /** |
| | | * 通过ID删除用户和部门关联 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserDeptByUserId(Long userId); |
| | | |
| | | /** |
| | | * 批量删除用户部门关联信息 |
| | | * |
| | | * @param ids 需要删除的数据ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserDept(Long[] ids); |
| | | |
| | | /** |
| | | * 查询部门使用数量 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | | public int selectCountUserDeptByDeptId(Long deptId); |
| | | |
| | | /** |
| | | * 批量新增用户部门信息 |
| | | * |
| | | * @param userDeptList 用户部门列表 |
| | | * @return 结果 |
| | | */ |
| | | public int batchUserDept(List<SysUserDept> userDeptList); |
| | | } |
| | |
| | | */ |
| | | public List<SysUser> selectUserList(SysUser sysUser); |
| | | |
| | | long selectUserListCount(SysUser sysUser); |
| | | |
| | | List<SysUser> selectUserListByRoleKey(SysUser sysUser); |
| | | |
| | | /** |
| | |
| | | */ |
| | | public List<SysUser> selectUserList(SysUser user); |
| | | |
| | | Long selectUserListCount(SysUser user); |
| | | |
| | | /** |
| | | * 根据角色key部门id查询 |
| | | * @param user |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public int getCheckCount() { |
| | | Long deptId = SecurityUtils.getDeptId(); |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(deptId); |
| | | if (sysDept == null){ |
| | | return 1; |
| | | }else { |
| | | if (!"1".equals(sysDept.getSafety())){ |
| | | Long[] deptIds = SecurityUtils.getDeptIds(); |
| | | if (ObjectUtil.isEmpty(deptIds)){ |
| | | return 1; |
| | | } |
| | | List<SysDept> sysDepts = sysDeptMapper.selectDeptByIds(deptIds); |
| | | if (ObjectUtil.isEmpty(sysDepts)){ |
| | | return 1; |
| | | } |
| | | return dailySafetyInspectionMapper.getCheckCount(deptId); |
| | | List<Long> data = new ArrayList<>(); |
| | | for (SysDept sysDept : sysDepts) { |
| | | if ("1".equals(sysDept.getSafety())){ |
| | | data.add(sysDept.getDeptId()); |
| | | } |
| | | } |
| | | if (ObjectUtil.isEmpty(data)){ |
| | | return 1; |
| | | } |
| | | return dailySafetyInspectionMapper.getCheckCountList(data); |
| | | |
| | | // Long deptId = SecurityUtils.getDeptId(); |
| | | // SysDept sysDept = sysDeptMapper.selectDeptById(deptId); |
| | | // if (sysDept == null){ |
| | | // return 1; |
| | | // }else { |
| | | // if (!"1".equals(sysDept.getSafety())){ |
| | | // return 1; |
| | | // } |
| | | // } |
| | | // return dailySafetyInspectionMapper.getCheckCount(deptId); |
| | | } |
| | | |
| | | |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.gkhy.system.domain.vo.DeptVo; |
| | | import com.gkhy.system.mapper.SysUserDeptMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.gkhy.common.annotation.DataScope; |
| | |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | | |
| | | @Autowired |
| | | private SysUserDeptMapper userDeptMapper; |
| | | |
| | | /** |
| | | * 查询部门管理数据 |
| | |
| | | @Override |
| | | public int deleteDeptById(Long deptId) |
| | | { |
| | | //对应的人员部门 |
| | | if (userDeptMapper.selectCountUserDeptByDeptId(deptId) > 0) |
| | | { |
| | | throw new ServiceException("该部门已绑定人员,请先换绑人员"); |
| | | } |
| | | |
| | | |
| | | return deptMapper.deleteDeptById(deptId); |
| | | } |
| | | |
| | |
| | | package com.gkhy.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.gkhy.common.core.domain.entity.SysDept; |
| | | import org.springframework.stereotype.Service; |
| | | import com.gkhy.common.core.domain.model.LoginUser; |
| | | import com.gkhy.common.utils.StringUtils; |
| | | import com.gkhy.system.domain.SysUserOnline; |
| | | import com.gkhy.system.service.ISysUserOnlineService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 在线用户 服务层处理 |
| | |
| | | sysUserOnline.setBrowser(user.getBrowser()); |
| | | sysUserOnline.setOs(user.getOs()); |
| | | sysUserOnline.setLoginTime(user.getLoginTime()); |
| | | if (StringUtils.isNotNull(user.getUser().getDept())) |
| | | if (ObjectUtil.isNotEmpty(user.getUser().getDepts())) |
| | | { |
| | | sysUserOnline.setDeptName(user.getUser().getDept().getDeptName()); |
| | | List<SysDept> depts = user.getUser().getDepts(); |
| | | String deptNames = depts == null ? "" : depts.stream() |
| | | .map(SysDept::getDeptName) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.joining(",")); |
| | | sysUserOnline.setDepts(user.getUser().getDepts()); |
| | | sysUserOnline.setDeptName(deptNames); |
| | | } |
| | | return sysUserOnline; |
| | | } |
| | |
| | | import javax.validation.Validator; |
| | | |
| | | import com.gkhy.common.core.domain.entity.IdsDto; |
| | | import com.gkhy.system.domain.SysUserDept; |
| | | import com.gkhy.system.mapper.*; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.gkhy.system.domain.SysPost; |
| | | import com.gkhy.system.domain.SysUserPost; |
| | | import com.gkhy.system.domain.SysUserRole; |
| | | import com.gkhy.system.mapper.SysPostMapper; |
| | | import com.gkhy.system.mapper.SysRoleMapper; |
| | | import com.gkhy.system.mapper.SysUserMapper; |
| | | import com.gkhy.system.mapper.SysUserPostMapper; |
| | | import com.gkhy.system.mapper.SysUserRoleMapper; |
| | | import com.gkhy.system.service.ISysConfigService; |
| | | import com.gkhy.system.service.ISysDeptService; |
| | | import com.gkhy.system.service.ISysUserService; |
| | |
| | | @Autowired |
| | | protected Validator validator; |
| | | |
| | | @Autowired |
| | | private SysUserDeptMapper sysUserDeptMapper; |
| | | |
| | | |
| | | /** |
| | | * 根据条件分页查询用户列表 |
| | | * |
| | |
| | | public List<SysUser> selectUserList(SysUser user) |
| | | { |
| | | return userMapper.selectUserList(user); |
| | | } |
| | | |
| | | @Override |
| | | public Long selectUserListCount(SysUser user) { |
| | | return userMapper.selectUserListCount( user); |
| | | } |
| | | |
| | | @Override |
| | |
| | | insertUserPost(user); |
| | | // 新增用户与角色管理 |
| | | insertUserRole(user); |
| | | // 新增用户与部门管理 |
| | | insertUserDept(user); |
| | | return rows; |
| | | } |
| | | |
| | |
| | | userPostMapper.deleteUserPostByUserId(userId); |
| | | // 新增用户与岗位管理 |
| | | insertUserPost(user); |
| | | sysUserDeptMapper.deleteUserDeptByUserId(userId); |
| | | // 新增用户与部门管理 |
| | | insertUserDept(user); |
| | | return userMapper.updateUser(user); |
| | | } |
| | | |
| | |
| | | this.insertUserRole(user.getUserId(), user.getRoleIds()); |
| | | } |
| | | |
| | | public void insertUserDept(SysUser user) |
| | | { |
| | | this.insertUserDept(user.getUserId(), user.getDeptIds()); |
| | | } |
| | | |
| | | /** |
| | | * 新增用户岗位信息 |
| | | * |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新增用户部门信息 |
| | | * |
| | | * @param userId 用户ID |
| | | * @param deptIds 部门组 |
| | | */ |
| | | public void insertUserDept(Long userId, Long[] deptIds) |
| | | { |
| | | if (StringUtils.isNotEmpty(deptIds)) |
| | | { |
| | | // 新增用户部门管理 |
| | | List<SysUserDept> list = new ArrayList<SysUserDept>(deptIds.length); |
| | | for (Long deptId : deptIds) |
| | | { |
| | | SysUserDept du = new SysUserDept(); |
| | | du.setUserId(userId); |
| | | du.setDeptId(deptId); |
| | | list.add(du); |
| | | } |
| | | sysUserDeptMapper.batchUserDept(list); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过用户ID删除用户 |
| | | * |
| | | * @param userId 用户ID |
| | |
| | | userRoleMapper.deleteUserRole(userIds); |
| | | // 删除用户与岗位关联 |
| | | userPostMapper.deleteUserPost(userIds); |
| | | //删除对应的部门人员 |
| | | sysUserDeptMapper.deleteUserDept(userIds); |
| | | return userMapper.deleteUserByIds(userIds); |
| | | } |
| | | |
| | |
| | | and a.dept_id = #{deptId} |
| | | and date_format(b.check_date, '%Y%m') = date_format(now(), '%Y%m') |
| | | </select> |
| | | |
| | | <select id="getCheckCountList" parameterType="java.util.List" resultType="int"> |
| | | select count(*) |
| | | from daily_safety_inspection_dept a |
| | | inner join daily_safety_inspection b on a.daily_safety_inspection_id = b.id |
| | | where b.del_flag = 0 |
| | | and a.dept_id in |
| | | <foreach collection="list" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | and date_format(b.check_date, '%Y%m') = date_format(now(), '%Y%m') |
| | | </select> |
| | | </mapper> |
| | |
| | | from sys_dept d |
| | | where d.dept_id = #{deptId} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectDeptByIds" parameterType="java.util.ArrayList" resultMap="SysDeptResult"> |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.safety, |
| | | (select dept_name from sys_dept where dept_id = d.parent_id) parent_name |
| | | from sys_dept d |
| | | where d.dept_id in |
| | | <foreach collection="array" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | and d.del_flag = '0' |
| | | </select> |
| | | |
| | | <select id="checkDeptExistUser" parameterType="Long" resultType="int"> |
| | | select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' |
| New file |
| | |
| | | <?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.gkhy.system.mapper.SysUserDeptMapper"> |
| | | |
| | | <resultMap type="SysUserDept" id="SysUserDeptResult"> |
| | | <result property="userId" column="user_id" /> |
| | | <result property="deptId" column="dept_id" /> |
| | | </resultMap> |
| | | |
| | | <delete id="deleteUserDeptByUserId" parameterType="Long"> |
| | | delete from sys_user_dept where user_id=#{userId} |
| | | </delete> |
| | | |
| | | <delete id="deleteUserDeptByDeptId" parameterType="Long"> |
| | | delete from sys_user_dept where dept_id=#{deptId} |
| | | </delete> |
| | | |
| | | <select id="selectCountUserDeptByDeptId" resultType="Integer"> |
| | | select count(1) from sys_user_dept where dept_id=#{deptId} |
| | | </select> |
| | | |
| | | <delete id="deleteUserDept" parameterType="Long"> |
| | | delete from sys_user_dept where User_id in |
| | | <foreach collection="array" item="UserId" open="(" separator="," close=")"> |
| | | #{userId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <insert id="batchUserDept"> |
| | | insert into sys_user_dept(user_id, dept_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.userId},#{item.deptId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="remark" column="remark" /> |
| | | <association property="dept" javaType="SysDept" resultMap="deptResult" /> |
| | | <collection property="depts" javaType="java.util.List" resultMap="deptResult" /> |
| | | <collection property="roles" javaType="java.util.List" resultMap="RoleResult" /> |
| | | </resultMap> |
| | | |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="selectUserVo"> |
| | | select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, |
| | | select u.user_id, ud.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, |
| | | d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, |
| | | r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | left join sys_user_dept ud on u.user_id = ud.user_id |
| | | left join sys_dept d on ud.dept_id = d.dept_id |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | | left join sys_role r on r.role_id = ur.role_id |
| | | </sql> |
| | | |
| | | <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> |
| | | select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | select u.user_id, ud.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u |
| | | left join sys_user_dept ud on u.user_id = ud.user_id |
| | | left join sys_dept d on ud.dept_id = d.dept_id |
| | | where u.del_flag = '0' |
| | | <if test="userId != null and userId != 0"> |
| | | AND u.user_id = #{userId} |
| | |
| | | AND date_format(u.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d') |
| | | </if> |
| | | <if test="deptId != null and deptId != 0"> |
| | | AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) )) |
| | | AND (ud.dept_id = #{deptId} OR ud.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) )) |
| | | </if> |
| | | <!-- 数据范围过滤 --> |
| | | ${params.dataScope} |
| | | </select> |
| | | |
| | | |
| | | <!-- 用户列表统计 --> |
| | | <select id="selectUserListCount" parameterType="SysUser" resultType="long"> |
| | | select count(distinct u.user_id) |
| | | from sys_user u |
| | | left join sys_user_dept ud on u.user_id = ud.user_id |
| | | left join sys_dept d on ud.dept_id = d.dept_id |
| | | where u.del_flag = '0' |
| | | <if test="userId != null and userId != 0"> |
| | | AND u.user_id = #{userId} |
| | | </if> |
| | | <if test="userName != null and userName != ''"> |
| | | AND u.user_name like concat('%', #{userName}, '%') |
| | | </if> |
| | | <if test="nickName != null and nickName != ''"> |
| | | and u.nick_name like concat('%',#{nickName},'%') |
| | | </if> |
| | | <if test="status != null and status != ''"> |
| | | AND u.status = #{status} |
| | | </if> |
| | | <if test="phonenumber != null and phonenumber != ''"> |
| | | AND u.phonenumber like concat('%', #{phonenumber}, '%') |
| | | </if> |
| | | <if test="params.beginTime != null and params.beginTime != ''"> |
| | | AND date_format(u.create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d') |
| | | </if> |
| | | <if test="params.endTime != null and params.endTime != ''"> |
| | | AND date_format(u.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d') |
| | | </if> |
| | | <if test="deptId != null and deptId != 0"> |
| | | AND (ud.dept_id = #{deptId} OR ud.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) )) |
| | | </if> |
| | | <!-- 数据范围过滤 --> |
| | | ${params.dataScope} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectUserListByRoleKey" parameterType="SysUser" resultMap="SysUserResult"> |
| | | select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | select u.user_id, ud.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u |
| | | left join sys_user_dept ud on u.user_id = ud.user_id |
| | | left join sys_dept d on ud.dept_id = d.dept_id |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | | left join sys_role r on r.role_id = ur.role_id |
| | | where u.del_flag = '0' and u.status = '0' and r.role_key = #{roleKey} |
| | |
| | | |
| | | |
| | | <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult"> |
| | | select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time |
| | | select distinct u.user_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | left join sys_user_dept ud on u.user_id = ud.user_id |
| | | left join sys_dept d on ud.dept_id = d.dept_id |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | | left join sys_role r on r.role_id = ur.role_id |
| | | where u.del_flag = '0' and r.role_id = #{roleId} |
| | |
| | | </select> |
| | | |
| | | <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult"> |
| | | select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time |
| | | select distinct u.user_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | left join sys_user_dept ud on u.user_id = ud.user_id |
| | | left join sys_dept d on ud.dept_id = d.dept_id |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | | left join sys_role r on r.role_id = ur.role_id |
| | | where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL) |
| | |
| | | select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1 |
| | | </select> |
| | | <select id="selectUserByDeptIds" resultMap="SysUserResult"> |
| | | select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark ,d.dept_name, d.leader |
| | | from sys_user u left join sys_dept d on u.dept_id = d.dept_id |
| | | select u.user_id, ud.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark ,d.dept_name, d.leader |
| | | from sys_user u |
| | | left join sys_user_dept ud on u.user_id = ud.user_id |
| | | left join sys_dept d on ud.dept_id = d.dept_id |
| | | where u.del_flag = '0' |
| | | <if test="nickName!=null and nickName!=''"> |
| | | and u.nick_name like concat('%',#{nickName},'%') |
| | | </if> |
| | | and u.dept_id in |
| | | and ud.dept_id in |
| | | <foreach item="id" collection="deptId" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |