7 files deleted
18 files modified
| | |
| | | String ROLE_ID = "role::id:"; |
| | | |
| | | /** |
| | | * 机构 |
| | | */ |
| | | String DEPT_ID = "dept::id:"; |
| | | |
| | | /** |
| | | * 岗位 |
| | | */ |
| | | String JOB_ID = "job::id:"; |
| | |
| | | * @param request / |
| | | */ |
| | | public void save(JwtUserDto jwtUserDto, String token, HttpServletRequest request){ |
| | | String dept = jwtUserDto.getUser().getDept().getName(); |
| | | String ip = StringUtils.getIp(request); |
| | | String id = tokenProvider.getId(token); |
| | | String browser = StringUtils.getBrowser(request); |
| | | String address = StringUtils.getCityInfo(ip); |
| | | OnlineUserDto onlineUserDto = null; |
| | | try { |
| | | onlineUserDto = new OnlineUserDto(id, jwtUserDto.getUsername(), jwtUserDto.getUser().getNickName(), dept, browser , ip, address, EncryptUtils.desEncrypt(token), new Date()); |
| | | onlineUserDto = new OnlineUserDto(id, jwtUserDto.getUsername(), jwtUserDto.getUser().getNickName(), browser , ip, address, EncryptUtils.desEncrypt(token), new Date()); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(),e); |
| | | } |
| | |
| | | for (OnlineUserDto user : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("用户名", user.getUserName()); |
| | | map.put("机构", user.getDept()); |
| | | map.put("登录IP", user.getIp()); |
| | | map.put("登录地点", user.getAddress()); |
| | | map.put("浏览器", user.getBrowser()); |
| | |
| | | // 获取用户的权限 |
| | | List<AuthorityDto> authorities = roleService.buildPermissions(user); |
| | | // 初始化JwtUserDto |
| | | jwtUserDto = new JwtUserDto(user, dataService.getDeptIds(user), authorities); |
| | | jwtUserDto = new JwtUserDto(user, dataService.getDataIds(user), authorities); |
| | | // 添加缓存数据 |
| | | userCacheManager.addUserCache(username, jwtUserDto); |
| | | } |
| | |
| | | @ApiModelProperty(value = "昵称") |
| | | private String nickName; |
| | | |
| | | @ApiModelProperty(value = "岗位") |
| | | private String dept; |
| | | |
| | | @ApiModelProperty(value = "浏览器") |
| | | private String browser; |
| | | |
| | |
| | | @ApiModelProperty(value = "菜单", hidden = true) |
| | | private Set<Menu> menus; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "机构", hidden = true) |
| | | private Set<Dept> depts; |
| | | |
| | | @NotBlank |
| | | @ApiModelProperty(value = "名称", hidden = true) |
| | | private String name; |
| | |
| | | @ApiModelProperty(value = "用户岗位") |
| | | private Set<Job> jobs; |
| | | |
| | | @TableField(value = "dept_id") |
| | | @ApiModelProperty(hidden = true) |
| | | private Long deptId; |
| | | |
| | | @ApiModelProperty(value = "用户机构") |
| | | @TableField(exist = false) |
| | | private Dept dept; |
| | | |
| | | @NotBlank |
| | | @ApiModelProperty(value = "用户类型(BUYER、MERCHANT、RIDER、ADMIN、SUPPLIER、AGENT)") |
| | | private String userType; |
| | |
| | | import lombok.Data; |
| | | import java.io.Serializable; |
| | | import java.sql.Timestamp; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author Z |
| | |
| | | @ApiModelProperty(value = "ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "多个ID") |
| | | private Set<Long> deptIds = new HashSet<>(); |
| | | |
| | | @ApiModelProperty(value = "模糊查询") |
| | | private String blurry; |
| | | |
| | | @ApiModelProperty(value = "是否启用") |
| | | private Boolean enabled; |
| | | |
| | | @ApiModelProperty(value = "机构ID") |
| | | private Long deptId; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | private List<Timestamp> createTime; |
| | |
| | | package com.oying.modules.system.mapper; |
| | | |
| | | import com.oying.modules.system.domain.Dept; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import java.util.Set; |
| | |
| | | */ |
| | | @Mapper |
| | | public interface RoleDeptMapper { |
| | | void insertData(@Param("roleId") Long roleId, @Param("depts") Set<Dept> depts); |
| | | void insertData(@Param("roleId") Long roleId, @Param("ids") Set<Long> ids); |
| | | |
| | | void deleteByRoleId(@Param("roleId") Long roleId); |
| | | |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author Z |
| | |
| | | Role findByName(@Param("name") String name); |
| | | |
| | | List<Role> findByUserId(@Param("userId") Long userId); |
| | | |
| | | int countByDepts(@Param("deptIds") Set<Long> deptIds); |
| | | |
| | | @Select("SELECT role.role_id as id FROM sys_role role, sys_roles_menus rm " + |
| | | "WHERE role.role_id = rm.role_id AND rm.menu_id = #{menuId}") |
| | |
| | | |
| | | List<User> findByRoleId(@Param("roleId") Long roleId); |
| | | |
| | | List<User> findByRoleDeptId(@Param("deptId") Long deptId); |
| | | |
| | | List<User> findByMenuId(@Param("menuId") Long menuId); |
| | | |
| | | int countByJobs(@Param("jobIds") Set<Long> jobIds); |
| | | |
| | | int countByDepts(@Param("deptIds") Set<Long> deptIds); |
| | | |
| | | int countByRoles(@Param("roleIds") Set<Long> roleIds); |
| | | |
| | |
| | | package com.oying.modules.system.rest; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.oying.modules.system.domain.Dept; |
| | | import com.oying.modules.system.domain.Role; |
| | | import com.oying.modules.system.domain.User; |
| | | import com.oying.modules.system.domain.dto.UserPassVo; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.oying.annotation.Log; |
| | | import com.oying.config.properties.RsaProperties; |
| | | import com.oying.modules.system.service.DataService; |
| | | import com.oying.exception.BadRequestException; |
| | | import com.oying.modules.system.service.DeptService; |
| | | import com.oying.modules.system.service.RoleService; |
| | | import com.oying.modules.system.domain.dto.UserQueryCriteria; |
| | | import com.oying.modules.system.service.VerifyService; |
| | |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | |
| | | private final PasswordEncoder passwordEncoder; |
| | | private final UserService userService; |
| | | private final DataService dataService; |
| | | private final DeptService deptService; |
| | | private final RoleService roleService; |
| | | private final VerifyService verificationCodeService; |
| | | |
| | |
| | | @PreAuthorize("@el.check('user:list')") |
| | | public ResponseEntity<Object> queryUser(UserQueryCriteria criteria) { |
| | | Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize()); |
| | | if (!ObjectUtils.isEmpty(criteria.getDeptId())) { |
| | | criteria.getDeptIds().add(criteria.getDeptId()); |
| | | // 先查找是否存在子节点 |
| | | List<Dept> data = deptService.findByPid(criteria.getDeptId()); |
| | | // 然后把子节点的ID都加入到集合中 |
| | | criteria.getDeptIds().addAll(deptService.getDeptChildren(data)); |
| | | } |
| | | // 数据权限 |
| | | List<Long> dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername())); |
| | | // criteria.getDeptIds() 不为空并且数据权限不为空则取交集 |
| | | if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) { |
| | | // 取交集 |
| | | criteria.getDeptIds().retainAll(dataScopes); |
| | | if (!CollectionUtil.isEmpty(criteria.getDeptIds())) { |
| | | return new ResponseEntity<>(R.success(userService.queryAll(criteria, page)), HttpStatus.OK); |
| | | } |
| | | } else { |
| | | // 否则取并集 |
| | | criteria.getDeptIds().addAll(dataScopes); |
| | | return new ResponseEntity<>(R.success(userService.queryAll(criteria, page)), HttpStatus.OK); |
| | | } |
| | | return new ResponseEntity<>(R.success(), HttpStatus.OK); |
| | | return new ResponseEntity<>(R.success(userService.queryAll(criteria, page)), HttpStatus.OK); |
| | | } |
| | | |
| | | @Log("新增用户") |
| | |
| | | // 默认密码 123456 |
| | | resources.setPassword(passwordEncoder.encode("123456")); |
| | | userService.create(resources); |
| | | return new ResponseEntity<>(R.success(),HttpStatus.CREATED); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.CREATED); |
| | | } |
| | | |
| | | @Log("修改用户") |
| | |
| | | public ResponseEntity<Object> updateUser(@Validated(User.Update.class) @RequestBody User resources) throws Exception { |
| | | checkLevel(resources); |
| | | userService.update(resources); |
| | | return new ResponseEntity<>(R.success(),HttpStatus.NO_CONTENT); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @Log("修改用户:个人中心") |
| | |
| | | throw new BadRequestException("不能修改他人资料"); |
| | | } |
| | | userService.updateCenter(resources); |
| | | return new ResponseEntity<>(R.success(),HttpStatus.NO_CONTENT); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @Log("删除用户") |
| | |
| | | } |
| | | } |
| | | userService.delete(ids); |
| | | return new ResponseEntity<>(R.success(),HttpStatus.OK); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.OK); |
| | | } |
| | | |
| | | @ApiOperation("修改密码") |
| | |
| | | throw new BadRequestException("新密码不能与旧密码相同"); |
| | | } |
| | | userService.updatePass(user.getUsername(), passwordEncoder.encode(newPass)); |
| | | return new ResponseEntity<>(R.success(),HttpStatus.OK); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.OK); |
| | | } |
| | | |
| | | @ApiOperation("重置密码") |
| | |
| | | public ResponseEntity<Object> resetPwd(@RequestBody Set<Long> ids) { |
| | | String pwd = passwordEncoder.encode("123456"); |
| | | userService.resetPwd(ids, pwd); |
| | | return new ResponseEntity<>(R.success(),HttpStatus.OK); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.OK); |
| | | } |
| | | |
| | | @ApiOperation("修改头像") |
| | |
| | | } |
| | | verificationCodeService.validated(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey() + resources.getEmail(), code); |
| | | userService.updateEmail(user.getUsername(), resources.getEmail()); |
| | | return new ResponseEntity<>(R.success(),HttpStatus.OK); |
| | | return new ResponseEntity<>(R.success(), HttpStatus.OK); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param user / |
| | | * @return / |
| | | */ |
| | | List<Long> getDeptIds(User user); |
| | | List<Long> getDataIds(User user); |
| | | } |
| | |
| | | package com.oying.modules.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.oying.modules.system.domain.Dept; |
| | | import com.oying.modules.system.domain.Role; |
| | | import com.oying.modules.system.domain.User; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.oying.modules.system.service.DataService; |
| | | import com.oying.modules.system.service.DeptService; |
| | | import com.oying.modules.system.service.RoleService; |
| | | import com.oying.utils.CacheKey; |
| | | import com.oying.utils.RedisUtils; |
| | |
| | | |
| | | private final RedisUtils redisUtils; |
| | | private final RoleService roleService; |
| | | private final DeptService deptService; |
| | | |
| | | /** |
| | | * 用户角色和用户机构改变时需清理缓存 |
| | |
| | | * @return / |
| | | */ |
| | | @Override |
| | | public List<Long> getDeptIds(User user) { |
| | | public List<Long> getDataIds(User user) { |
| | | String key = CacheKey.DATA_USER + user.getId(); |
| | | List<Long> ids = redisUtils.getList(key, Long.class); |
| | | if (CollUtil.isEmpty(ids)) { |
| | | Set<Long> deptIds = new HashSet<>(); |
| | | Set<Long> dataIds = new HashSet<>(); |
| | | // 查询用户角色 |
| | | List<Role> roleList = roleService.findByUsersId(user.getId()); |
| | | // 获取对应的机构ID |
| | |
| | | DataScopeEnum dataScopeEnum = DataScopeEnum.find(role.getDataScope()); |
| | | switch (Objects.requireNonNull(dataScopeEnum)) { |
| | | case THIS_LEVEL: |
| | | deptIds.add(user.getDept().getId()); |
| | | break; |
| | | case CUSTOMIZE: |
| | | deptIds.addAll(getCustomize(deptIds, role)); |
| | | dataIds.addAll(getCustomize(dataIds, role)); |
| | | break; |
| | | default: |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | ids = new ArrayList<>(deptIds); |
| | | ids = new ArrayList<>(dataIds); |
| | | redisUtils.set(key, ids, 1, TimeUnit.DAYS); |
| | | } |
| | | return ids; |
| | |
| | | |
| | | /** |
| | | * 获取自定义的数据权限 |
| | | * @param deptIds 机构ID |
| | | * @param dataIds 机构ID |
| | | * @param role 角色 |
| | | * @return 数据权限ID |
| | | */ |
| | | public Set<Long> getCustomize(Set<Long> deptIds, Role role){ |
| | | Set<Dept> depts = deptService.findByRoleId(role.getId()); |
| | | for (Dept dept : depts) { |
| | | deptIds.add(dept.getId()); |
| | | List<Dept> deptChildren = deptService.findByPid(dept.getId()); |
| | | if (CollUtil.isNotEmpty(deptChildren)) { |
| | | deptIds.addAll(deptService.getDeptChildren(deptChildren)); |
| | | } |
| | | } |
| | | return deptIds; |
| | | public Set<Long> getCustomize(Set<Long> dataIds, Role role){ |
| | | System.out.println(role); |
| | | return dataIds; |
| | | } |
| | | } |
| | |
| | | } |
| | | save(resources); |
| | | // 判断是否有机构数据,若有,则需创建关联 |
| | | if (CollectionUtil.isNotEmpty(resources.getDepts())) { |
| | | roleDeptMapper.insertData(resources.getId(), resources.getDepts()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | role.setName(resources.getName()); |
| | | role.setDescription(resources.getDescription()); |
| | | role.setDataScope(resources.getDataScope()); |
| | | role.setDepts(resources.getDepts()); |
| | | role.setLevel(resources.getLevel()); |
| | | // 更新 |
| | | saveOrUpdate(role); |
| | | // 删除关联机构数据 |
| | | roleDeptMapper.deleteByRoleId(resources.getId()); |
| | | // 判断是否有机构数据,若有,则需更新关联 |
| | | if (CollectionUtil.isNotEmpty(resources.getDepts())) { |
| | | roleDeptMapper.insertData(resources.getId(), resources.getDepts()); |
| | | } |
| | | |
| | | // 更新相关缓存 |
| | | delCaches(role.getId(), null); |
| | | } |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void create(User resources) { |
| | | resources.setDeptId(resources.getDept().getId()); |
| | | if (userMapper.findByUsername(resources.getUsername()) != null) { |
| | | throw new EntityExistException(User.class, "username", resources.getUsername()); |
| | | } |
| | | if (userMapper.findByEmail(resources.getEmail()) != null) { |
| | | throw new EntityExistException(User.class, "email", resources.getEmail()); |
| | | } |
| | | if (userMapper.findByPhone(resources.getPhone()) != null) { |
| | | throw new EntityExistException(User.class, "phone", resources.getPhone()); |
| | | } |
| | | // if (userMapper.findByEmail(resources.getEmail()) != null) { |
| | | // throw new EntityExistException(User.class, "email", resources.getEmail()); |
| | | // } |
| | | // if (userMapper.findByPhone(resources.getPhone()) != null) { |
| | | // throw new EntityExistException(User.class, "phone", resources.getPhone()); |
| | | // } |
| | | save(resources); |
| | | // 保存用户岗位 |
| | | userJobMapper.insertData(resources.getId(), resources.getJobs()); |
| | |
| | | public void update(User resources) throws Exception { |
| | | User user = getById(resources.getId()); |
| | | User user1 = userMapper.findByUsername(resources.getUsername()); |
| | | User user2 = userMapper.findByEmail(resources.getEmail()); |
| | | User user3 = userMapper.findByPhone(resources.getPhone()); |
| | | // User user2 = userMapper.findByEmail(resources.getEmail()); |
| | | // User user3 = userMapper.findByPhone(resources.getPhone()); |
| | | if (user1 != null && !user.getId().equals(user1.getId())) { |
| | | throw new EntityExistException(User.class, "username", resources.getUsername()); |
| | | } |
| | | if (user2 != null && !user.getId().equals(user2.getId())) { |
| | | throw new EntityExistException(User.class, "email", resources.getEmail()); |
| | | } |
| | | if (user3 != null && !user.getId().equals(user3.getId())) { |
| | | throw new EntityExistException(User.class, "phone", resources.getPhone()); |
| | | } |
| | | // if (user2 != null && !user.getId().equals(user2.getId())) { |
| | | // throw new EntityExistException(User.class, "email", resources.getEmail()); |
| | | // } |
| | | // if (user3 != null && !user.getId().equals(user3.getId())) { |
| | | // throw new EntityExistException(User.class, "phone", resources.getPhone()); |
| | | // } |
| | | // 如果用户的角色改变 |
| | | if (!resources.getRoles().equals(user.getRoles())) { |
| | | redisUtils.del(CacheKey.DATA_USER + resources.getId()); |
| | |
| | | redisUtils.del(CacheKey.ROLE_AUTH + resources.getId()); |
| | | redisUtils.del(CacheKey.ROLE_USER + resources.getId()); |
| | | } |
| | | // 修改机构会影响 数据权限 |
| | | if (!Objects.equals(resources.getDept(),user.getDept())) { |
| | | redisUtils.del(CacheKey.DATA_USER + resources.getId()); |
| | | } |
| | | // 如果用户被禁用,则清除用户登录信息 |
| | | if(!resources.getEnabled()){ |
| | | onlineUserService.kickOutForUsername(resources.getUsername()); |
| | | } |
| | | user.setDeptId(resources.getDept().getId()); |
| | | user.setUsername(resources.getUsername()); |
| | | user.setEmail(resources.getEmail()); |
| | | user.setEnabled(resources.getEnabled()); |
| | | user.setRoles(resources.getRoles()); |
| | | user.setDept(resources.getDept()); |
| | | user.setJobs(resources.getJobs()); |
| | | user.setPhone(resources.getPhone()); |
| | | user.setNickName(resources.getNickName()); |
| | |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("用户名", user.getUsername()); |
| | | map.put("角色", roles); |
| | | map.put("机构", user.getDept().getName()); |
| | | map.put("岗位", user.getJobs().stream().map(Job::getName).collect(Collectors.toList())); |
| | | map.put("邮箱", user.getEmail()); |
| | | map.put("状态", user.getEnabled() ? "启用" : "禁用"); |
| | |
| | | <insert id="insertData"> |
| | | insert into sys_roles_depts (role_id, dept_id) |
| | | values |
| | | <foreach collection="depts" item="item" open="(" separator="),(" close=")"> |
| | | <foreach collection="ids" item="item" open="(" separator="),(" close=")"> |
| | | #{roleId}, #{item.id} |
| | | </foreach> |
| | | </insert> |
| | |
| | | <result column="menu_title" property="title"/> |
| | | <result column="menu_permission" property="permission"/> |
| | | </collection> |
| | | <collection property="depts" ofType="com.oying.modules.system.domain.Dept"> |
| | | <id column="dept_id" property="id"/> |
| | | <result column="dept_name" property="name"/> |
| | | </collection> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | |
| | | |
| | | <sql id="Menu_Column_List"> |
| | | menu.menu_id as menu_id, menu.title as menu_title, menu.permission as menu_permission |
| | | </sql> |
| | | |
| | | <sql id="Dept_Column_List"> |
| | | dept.dept_id as dept_id, dept.name as dept_name |
| | | </sql> |
| | | |
| | | <sql id="Where_sql"> |
| | |
| | | |
| | | <select id="findAll" resultMap="BaseResultMap"> |
| | | select role.*, |
| | | <include refid="Dept_Column_List"/>, |
| | | <include refid="Menu_Column_List"/> |
| | | from ( |
| | | select |
| | |
| | | left join sys_roles_menus srm on role.role_role_id = srm.role_id |
| | | left join sys_menu menu on menu.menu_id = srm.menu_id |
| | | left join sys_roles_depts srd on role.role_role_id = srd.role_id |
| | | left join sys_dept dept on dept.dept_id = srd.dept_id |
| | | order by role.role_level |
| | | </select> |
| | | |
| | |
| | | <select id="findById" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"/>, |
| | | <include refid="Dept_Column_List"/>, |
| | | <include refid="Menu_Column_List"/> |
| | | from sys_role role |
| | | left join sys_roles_menus srm on role.role_id = srm.role_id |
| | | left join sys_menu menu on menu.menu_id = srm.menu_id |
| | | left join sys_roles_depts srd on role.role_id = srd.role_id |
| | | left join sys_dept dept on dept.dept_id = srd.dept_id |
| | | where role.role_id = #{roleId} |
| | | </select> |
| | | |
| | | <select id="findByUserId" resultMap="BaseResultMap"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/>, |
| | | <include refid="Dept_Column_List"/>, |
| | | <include refid="Menu_Column_List"/> |
| | | from sys_role role |
| | | left join sys_roles_menus srm on role.role_id = srm.role_id |
| | | left join sys_menu menu on menu.menu_id = srm.menu_id |
| | | left join sys_roles_depts srd on role.role_id = srd.role_id |
| | | left join sys_dept dept on dept.dept_id = srd.dept_id |
| | | left join sys_users_roles ur on role.role_id = ur.role_id |
| | | WHERE role.role_id = ur.role_id AND ur.user_id = #{userId} |
| | | </select> |
| | | |
| | | <select id="countByDepts" resultType="int"> |
| | | select count(*) |
| | | from sys_role r, sys_roles_depts d |
| | | where r.role_id = d.role_id |
| | | and d.dept_id in |
| | | <foreach collection="deptIds" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | </select> |
| | | </mapper> |
| | |
| | | <mapper namespace="com.oying.modules.system.mapper.UserMapper"> |
| | | <resultMap id="BaseResultMap" type="com.oying.modules.system.domain.User"> |
| | | <id column="user_user_id" property="id"/> |
| | | <result column="user_dept_id" property="deptId"/> |
| | | <result column="user_username" property="username"/> |
| | | <result column="user_user_type" property="userType"/> |
| | | <result column="user_openid" property="openid"/> |
| | |
| | | <result column="user_update_by" property="updateBy"/> |
| | | <result column="user_create_time" property="createTime"/> |
| | | <result column="user_update_time" property="updateTime"/> |
| | | <association property="dept" javaType="com.oying.modules.system.domain.Dept"> |
| | | <id column="dept_id" property="id"/> |
| | | <result column="dept_name" property="name"/> |
| | | </association> |
| | | <collection property="jobs" ofType="com.oying.modules.system.domain.Job"> |
| | | <id column="job_id" property="id"/> |
| | | <result column="job_name" property="name"/> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | u.user_id as user_user_id, u.dept_id as user_dept_id, u.username as user_username, |
| | | u.user_id as user_user_id, u.username as user_username, |
| | | u.user_type as user_user_type,u.openid as user_openid, |
| | | u.nick_name as user_nick_name, u.email as user_email, u.phone as user_phone, |
| | | u.gender as user_gender, u.avatar_name as user_avatar_name, u.avatar_path as user_avatar_path, |
| | | u.enabled as user_enabled, u.pwd_reset_time as user_pwd_reset_time, u.create_by as user_create_by, |
| | | u.update_by as user_update_by, u.create_time as user_create_time, u.update_time as user_update_time, |
| | | d.dept_id as dept_id, d.name as dept_name |
| | | u.update_by as user_update_by, u.create_time as user_create_time, u.update_time as user_update_time |
| | | </sql> |
| | | |
| | | <sql id="Job_Column_List"> |
| | |
| | | </if> |
| | | <if test="criteria.enabled != null"> |
| | | and u.enabled = #{criteria.enabled} |
| | | </if> |
| | | <if test="criteria.deptIds != null and criteria.deptIds.size() != 0"> |
| | | and u.dept_id in |
| | | <foreach collection="criteria.deptIds" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | </if> |
| | | <if test="criteria.blurry != null and criteria.blurry != ''"> |
| | | and ( |
| | |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | <include refid="Whrer_Sql"/> |
| | | order by u.user_id desc |
| | | <if test="criteria.offset != null"> |
| | |
| | | u.password user_password, u.is_admin user_is_admin, |
| | | <include refid="Base_Column_List"/> |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | where u.username = #{username} |
| | | </select> |
| | | |
| | |
| | | u.password user_password, u.is_admin user_is_admin, |
| | | <include refid="Base_Column_List"/> |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | where u.openid = #{openid} |
| | | </select> |
| | | |
| | |
| | | group by u.user_id |
| | | </select> |
| | | |
| | | <select id="findByRoleDeptId" resultType="com.oying.modules.system.domain.User"> |
| | | SELECT u.* FROM sys_user u, sys_users_roles r, sys_roles_depts d |
| | | WHERE u.user_id = r.user_id AND r.role_id = d.role_id AND d.dept_id = #{deptId} |
| | | group by u.user_id |
| | | </select> |
| | | |
| | | <select id="findByMenuId" resultType="com.oying.modules.system.domain.User"> |
| | | SELECT u.user_id as id, u.username FROM sys_user u, sys_users_roles ur, sys_roles_menus rm |
| | | WHERE u.user_id = ur.user_id AND ur.role_id = rm.role_id AND rm.menu_id = #{menuId} |
| | |
| | | WHERE u.user_id = j.user_id AND j.job_id IN |
| | | <foreach collection="jobIds" item="jobId" open="(" separator="," close=")"> |
| | | #{jobId} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="countByDepts" resultType="int"> |
| | | SELECT count(*) FROM sys_user u |
| | | WHERE u.dept_id IN |
| | | <foreach collection="deptIds" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | </select> |
| | | |