xin
2025-06-06 24e84dca4ffd61cc92338263c3825e0944542f2e
删除用户机构
7 files deleted
18 files modified
934 ■■■■■ changed files
oying-common/src/main/java/com/oying/utils/CacheKey.java 5 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/security/service/OnlineUserService.java 4 ●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/security/service/UserDetailsServiceImpl.java 2 ●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/security/service/dto/OnlineUserDto.java 3 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/domain/Dept.java 92 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/domain/Role.java 4 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/domain/User.java 8 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/domain/dto/DeptQueryCriteria.java 32 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/domain/dto/UserQueryCriteria.java 8 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/mapper/DeptMapper.java 32 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/mapper/RoleDeptMapper.java 3 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/mapper/RoleMapper.java 3 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/mapper/UserMapper.java 4 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/rest/DeptController.java 114 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/rest/UserController.java 44 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/service/DataService.java 2 ●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/service/DeptService.java 110 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/service/impl/DataServiceImpl.java 27 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/service/impl/DeptServiceImpl.java 265 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/service/impl/RoleServiceImpl.java 8 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/system/service/impl/UserServiceImpl.java 36 ●●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/system/DeptMapper.xml 70 ●●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/system/RoleDeptMapper.xml 2 ●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/system/RoleMapper.xml 23 ●●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/system/UserMapper.xml 33 ●●●●● patch | view | raw | blame | history
oying-common/src/main/java/com/oying/utils/CacheKey.java
@@ -35,11 +35,6 @@
    String ROLE_ID = "role::id:";
    /**
     * 机构
     */
    String DEPT_ID = "dept::id:";
    /**
     * 岗位
     */
    String JOB_ID = "job::id:";
oying-system/src/main/java/com/oying/modules/security/service/OnlineUserService.java
@@ -35,14 +35,13 @@
     * @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);
        }
@@ -103,7 +102,6 @@
        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());
oying-system/src/main/java/com/oying/modules/security/service/UserDetailsServiceImpl.java
@@ -40,7 +40,7 @@
                // 获取用户的权限
                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);
            }
oying-system/src/main/java/com/oying/modules/security/service/dto/OnlineUserDto.java
@@ -24,9 +24,6 @@
    @ApiModelProperty(value = "昵称")
    private String nickName;
    @ApiModelProperty(value = "岗位")
    private String dept;
    @ApiModelProperty(value = "浏览器")
    private String browser;
oying-system/src/main/java/com/oying/modules/system/domain/Dept.java
File was deleted
oying-system/src/main/java/com/oying/modules/system/domain/Role.java
@@ -38,10 +38,6 @@
    @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;
oying-system/src/main/java/com/oying/modules/system/domain/User.java
@@ -39,14 +39,6 @@
    @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;
oying-system/src/main/java/com/oying/modules/system/domain/dto/DeptQueryCriteria.java
File was deleted
oying-system/src/main/java/com/oying/modules/system/domain/dto/UserQueryCriteria.java
@@ -4,9 +4,7 @@
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
@@ -18,17 +16,11 @@
    @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;
oying-system/src/main/java/com/oying/modules/system/mapper/DeptMapper.java
File was deleted
oying-system/src/main/java/com/oying/modules/system/mapper/RoleDeptMapper.java
@@ -1,6 +1,5 @@
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;
@@ -11,7 +10,7 @@
 */
@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);
oying-system/src/main/java/com/oying/modules/system/mapper/RoleMapper.java
@@ -7,7 +7,6 @@
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Set;
/**
 * @author Z
@@ -27,8 +26,6 @@
    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}")
oying-system/src/main/java/com/oying/modules/system/mapper/UserMapper.java
@@ -41,13 +41,9 @@
    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);
oying-system/src/main/java/com/oying/modules/system/rest/DeptController.java
File was deleted
oying-system/src/main/java/com/oying/modules/system/rest/UserController.java
@@ -1,8 +1,6 @@
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;
@@ -12,9 +10,7 @@
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;
@@ -24,8 +20,6 @@
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;
@@ -47,8 +41,6 @@
    private final PasswordEncoder passwordEncoder;
    private final UserService userService;
    private final DataService dataService;
    private final DeptService deptService;
    private final RoleService roleService;
    private final VerifyService verificationCodeService;
@@ -64,28 +56,8 @@
    @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("新增用户")
@@ -97,7 +69,7 @@
        // 默认密码 123456
        resources.setPassword(passwordEncoder.encode("123456"));
        userService.create(resources);
        return new ResponseEntity<>(R.success(),HttpStatus.CREATED);
        return new ResponseEntity<>(R.success(), HttpStatus.CREATED);
    }
    @Log("修改用户")
@@ -107,7 +79,7 @@
    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("修改用户:个人中心")
@@ -118,7 +90,7 @@
            throw new BadRequestException("不能修改他人资料");
        }
        userService.updateCenter(resources);
        return new ResponseEntity<>(R.success(),HttpStatus.NO_CONTENT);
        return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT);
    }
    @Log("删除用户")
@@ -134,7 +106,7 @@
            }
        }
        userService.delete(ids);
        return new ResponseEntity<>(R.success(),HttpStatus.OK);
        return new ResponseEntity<>(R.success(), HttpStatus.OK);
    }
    @ApiOperation("修改密码")
@@ -150,7 +122,7 @@
            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("重置密码")
@@ -158,7 +130,7 @@
    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("修改头像")
@@ -178,7 +150,7 @@
        }
        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);
    }
    /**
oying-system/src/main/java/com/oying/modules/system/service/DataService.java
@@ -16,5 +16,5 @@
     * @param user /
     * @return /
     */
    List<Long> getDeptIds(User user);
    List<Long> getDataIds(User user);
}
oying-system/src/main/java/com/oying/modules/system/service/DeptService.java
File was deleted
oying-system/src/main/java/com/oying/modules/system/service/impl/DataServiceImpl.java
@@ -1,12 +1,10 @@
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;
@@ -26,7 +24,6 @@
    private final RedisUtils redisUtils;
    private final RoleService roleService;
    private final DeptService deptService;
    /**
     * 用户角色和用户机构改变时需清理缓存
@@ -34,11 +31,11 @@
     * @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
@@ -46,16 +43,15 @@
                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;
@@ -63,19 +59,12 @@
    /**
     * 获取自定义的数据权限
     * @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;
    }
}
oying-system/src/main/java/com/oying/modules/system/service/impl/DeptServiceImpl.java
File was deleted
oying-system/src/main/java/com/oying/modules/system/service/impl/RoleServiceImpl.java
@@ -79,9 +79,6 @@
        }
        save(resources);
        // 判断是否有机构数据,若有,则需创建关联
        if (CollectionUtil.isNotEmpty(resources.getDepts())) {
            roleDeptMapper.insertData(resources.getId(), resources.getDepts());
        }
    }
    @Override
@@ -95,16 +92,13 @@
        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);
    }
oying-system/src/main/java/com/oying/modules/system/service/impl/UserServiceImpl.java
@@ -72,16 +72,15 @@
    @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());
@@ -94,17 +93,17 @@
    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());
@@ -112,20 +111,14 @@
            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());
@@ -251,7 +244,6 @@
            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() ? "启用" : "禁用");
oying-system/src/main/resources/mapper/system/DeptMapper.xml
File was deleted
oying-system/src/main/resources/mapper/system/RoleDeptMapper.xml
@@ -5,7 +5,7 @@
    <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>
oying-system/src/main/resources/mapper/system/RoleMapper.xml
@@ -16,10 +16,6 @@
            <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">
@@ -30,10 +26,6 @@
    <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">
@@ -57,7 +49,6 @@
    <select id="findAll" resultMap="BaseResultMap">
        select role.*,
        <include refid="Dept_Column_List"/>,
        <include refid="Menu_Column_List"/>
        from (
        select
@@ -72,7 +63,6 @@
        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>
@@ -90,37 +80,24 @@
    <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>
oying-system/src/main/resources/mapper/system/UserMapper.xml
@@ -3,7 +3,6 @@
<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"/>
@@ -21,10 +20,6 @@
        <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"/>
@@ -38,13 +33,12 @@
    </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">
@@ -62,12 +56,6 @@
            </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 (
@@ -90,7 +78,6 @@
        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">
@@ -115,7 +102,6 @@
        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>
@@ -124,7 +110,6 @@
        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>
@@ -144,12 +129,6 @@
        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}
@@ -161,14 +140,6 @@
        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>