| | |
| | | IGNORE_TABLES.add("common_file"); |
| | | IGNORE_TABLES.add("DepartmentHierarchy"); |
| | | IGNORE_TABLES.add("sys_oper_log"); |
| | | IGNORE_TABLES.add("sys_user_dept"); |
| | | } |
| | | } |
| | |
| | | /**
|
| | | * è·åé¨é¨ID
|
| | | **/
|
| | | public static Long getDeptId()
|
| | | public static Long [] getDeptId()
|
| | | {
|
| | | try
|
| | | {
|
| | | return getLoginUser().getDeptId();
|
| | | return getLoginUser().getDeptIds();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | |
| | | sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, role.getRoleId()));
|
| | | }
|
| | | }
|
| | | 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_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))
|
| | |
| | | /**
|
| | | * é¨é¨ID
|
| | | */
|
| | | private Long deptId;
|
| | | private Long [] deptIds;
|
| | |
|
| | | /**
|
| | | * ç¨æ·å¯ä¸æ è¯
|
| | |
| | | this.permissions = permissions;
|
| | | }
|
| | |
|
| | | public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions)
|
| | | public LoginUser(Long userId, Long [] deptId, SysUser user, Set<String> permissions)
|
| | | {
|
| | | this.userId = userId;
|
| | | this.deptId = deptId;
|
| | | this.deptIds = deptId;
|
| | | this.user = user;
|
| | | this.permissions = permissions;
|
| | | }
|
| | |
|
| | | public LoginUser(Long userId, Long deptId, SysUser user,Integer tenantId, Set<String> permissions)
|
| | | public LoginUser(Long userId, Long [] deptIds, SysUser user,Integer tenantId, Set<String> permissions)
|
| | | {
|
| | | this.userId = userId;
|
| | | this.deptId = deptId;
|
| | | this.deptIds = deptIds;
|
| | | this.user = user;
|
| | | this.permissions = permissions;
|
| | | this.tenantId = tenantId;
|
| | |
| | | this.userId = userId;
|
| | | }
|
| | |
|
| | | public Long getDeptId()
|
| | | public Long [] getDeptIds()
|
| | | {
|
| | | return deptId;
|
| | | return deptIds;
|
| | | }
|
| | |
|
| | | public void setDeptId(Long deptId)
|
| | | public void setDeptId(Long [] deptIds)
|
| | | {
|
| | | this.deptId = deptId;
|
| | | this.deptIds = deptIds;
|
| | | }
|
| | |
|
| | | public String getToken()
|
| | |
| | |
|
| | | public UserDetails createLoginUser(SysUser user)
|
| | | {
|
| | | return new LoginUser(user.getUserId(), user.getDeptId(), user, user.getTenantId(), permissionService.getMenuPermission(user));
|
| | | return new LoginUser(user.getUserId(), user.getDeptIds(), user, user.getTenantId(), permissionService.getMenuPermission(user));
|
| | | }
|
| | | }
|
| | |
| | | /**
|
| | | * è·åç»å½é¨é¨id
|
| | | */
|
| | | public Long getDeptId()
|
| | | public Long [] getDeptId()
|
| | | {
|
| | | return getLoginUser().getDeptId();
|
| | | return getLoginUser().getDeptIds();
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | /** èç¹åç§° */
|
| | | private String label;
|
| | |
|
| | | /** èç¹ID */
|
| | | private Long value;
|
| | |
|
| | | /** èç¹ç¦ç¨ */
|
| | | private boolean disabled = false;
|
| | |
|
| | |
| | | public TreeSelect(SysDept dept)
|
| | | {
|
| | | this.id = dept.getDeptId();
|
| | | this.value = dept.getDeptId();
|
| | | this.label = dept.getDeptName();
|
| | | this.disabled = StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus());
|
| | | this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
| | |
| | | {
|
| | | this.children = children;
|
| | | }
|
| | |
|
| | | public Long getValue() {
|
| | | return value;
|
| | | }
|
| | |
|
| | | public void setValue(Long value) {
|
| | | this.value = value;
|
| | | }
|
| | | }
|
| | |
| | | import java.util.List;
|
| | | import java.util.stream.Collectors;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import com.ruoyi.project.system.domain.vo.SysUserDeptVo;
|
| | | import com.ruoyi.project.system.service.*;
|
| | | import org.apache.commons.lang3.ArrayUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | |
| | | import com.ruoyi.project.system.domain.SysDept;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.service.ISysDeptService;
|
| | | import com.ruoyi.project.system.service.ISysPostService;
|
| | | import com.ruoyi.project.system.service.ISysRoleService;
|
| | | import com.ruoyi.project.system.service.ISysUserService;
|
| | |
|
| | | /**
|
| | | * ç¨æ·ä¿¡æ¯
|
| | |
| | |
|
| | | @Autowired
|
| | | private ISysPostService postService;
|
| | |
|
| | | @Autowired
|
| | | private ISysUserDeptService userDeptService;
|
| | |
|
| | | /**
|
| | | * è·åç¨æ·å表
|
| | |
| | | List<SysRole> roles = roleService.selectRoleAll();
|
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
| | | ajax.put("posts", postService.selectPostAll());
|
| | | SysUserDeptVo sysUserDeptVo = new SysUserDeptVo();
|
| | | sysUserDeptVo.setUserId(userId);
|
| | | List<SysUserDeptVo> sysUserDeptVos = userDeptService.selectUserDeptList(sysUserDeptVo);
|
| | | ajax.put("deptIds",sysUserDeptVos.stream().map(SysUserDeptVo::getDeptId).collect(Collectors.toList()));
|
| | | return ajax;
|
| | | }
|
| | |
|
| | |
| | | @PostMapping
|
| | | public AjaxResult add(@Validated @RequestBody SysUser user)
|
| | | {
|
| | | deptService.checkDeptDataScope(user.getDeptId());
|
| | | roleService.checkRoleDataScope(user.getRoleIds());
|
| | | if (!userService.checkUserNameUnique(user))
|
| | | {
|
| | |
| | | }
|
| | | user.setCreateBy(getUsername());
|
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
| | | // æ¥è¯¢é¡¶å±é¨é¨ç¶idåä¸ºç§æ·tenant_id
|
| | | Long tenantId = deptService.maxLevelDeptId(user.getDeptId());
|
| | | if(tenantId != null){
|
| | | user.setTenantId(tenantId.intValue());
|
| | | }
|
| | | return toAjax(userService.insertUser(user));
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | userService.checkUserAllowed(user);
|
| | | userService.checkUserDataScope(user.getUserId());
|
| | | deptService.checkDeptDataScope(user.getDeptId());
|
| | | roleService.checkRoleDataScope(user.getRoleIds());
|
| | | if (!userService.checkUserNameUnique(user))
|
| | | {
|
| | |
| | | return error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨");
|
| | | }
|
| | | user.setUpdateBy(getUsername());
|
| | | userService.bindUserDept(user);
|
| | | return toAjax(userService.updateUser(user));
|
| | | }
|
| | |
|
| | |
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import javax.validation.constraints.*;
|
| | |
|
| | | import com.baomidou.mybatisplus.annotation.TableField;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.common.xss.Xss;
|
| | |
| | | /** ç¨æ·ID */
|
| | | @Excel(name = "ç¨æ·åºå·", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "ç¨æ·ç¼å·")
|
| | | private Long userId;
|
| | |
|
| | | /** é¨é¨ID */
|
| | | @Excel(name = "é¨é¨ç¼å·", type = Type.IMPORT)
|
| | | private Long deptId;
|
| | |
|
| | | /** ç¨æ·è´¦å· */
|
| | | @Excel(name = "ç»å½åç§°")
|
| | |
| | | /** ç§æ·ID */
|
| | | private Integer tenantId;
|
| | |
|
| | | private Long[] deptIds;
|
| | |
|
| | | @TableField(exist = false)
|
| | | private Long deptId;
|
| | |
|
| | | /**
|
| | | * é¨é¨åç§°
|
| | | */
|
| | | private String deptNames;
|
| | |
|
| | | public SysUser()
|
| | | {
|
| | |
|
| | |
| | | public static boolean isAdmin(Long userId)
|
| | | {
|
| | | return userId != null && 1L == userId;
|
| | | }
|
| | |
|
| | | public Long getDeptId()
|
| | | {
|
| | | return deptId;
|
| | | }
|
| | |
|
| | | public void setDeptId(Long deptId)
|
| | | {
|
| | | this.deptId = deptId;
|
| | | }
|
| | |
|
| | | @Xss(message = "ç¨æ·æµç§°ä¸è½å
å«èæ¬å符")
|
| | |
| | | this.tenantId = tenantId;
|
| | | }
|
| | |
|
| | | public Long[] getDeptIds() {
|
| | | return deptIds;
|
| | | }
|
| | |
|
| | | public void setDeptIds(Long[] deptIds) {
|
| | | this.deptIds = deptIds;
|
| | | }
|
| | |
|
| | | public String getDeptNames() {
|
| | | return deptNames;
|
| | | }
|
| | |
|
| | | public void setDeptNames(String deptNames) {
|
| | | this.deptNames = deptNames;
|
| | | }
|
| | |
|
| | | public Long getDeptId() {
|
| | | return deptId;
|
| | | }
|
| | |
|
| | | public void setDeptId(Long deptId) {
|
| | | this.deptId = deptId;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
| | | .append("userId", getUserId())
|
| | | .append("deptId", getDeptId())
|
| | | .append("userName", getUserName())
|
| | | .append("nickName", getNickName())
|
| | | .append("email", getEmail())
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.project.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class SysUserDept { |
| | | |
| | | private Long id; |
| | | |
| | | private Long userId; |
| | | |
| | | private Long deptId; |
| | | |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "åå»ºç¨æ·") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | @ApiModelProperty(value = "ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty(value = "ä¿®æ¹ç¨æ·") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.project.system.domain.vo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.project.system.domain.SysUserDept; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class SysUserDeptVo extends SysUserDept { |
| | | |
| | | private String deptName; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.project.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.project.system.domain.SysUserDept; |
| | | import com.ruoyi.project.system.domain.vo.SysUserDeptVo; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface SysUserDeptMapper extends BaseMapper<SysUserDept> { |
| | | |
| | | List<SysUserDeptVo> selectUserDeptList(@Param("userDeptVo") SysUserDeptVo userDeptVo); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.project.system.service; |
| | | |
| | | import com.ruoyi.project.system.domain.vo.SysUserDeptVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface ISysUserDeptService { |
| | | |
| | | List<SysUserDeptVo> selectUserDeptList(SysUserDeptVo userDeptVo); |
| | | } |
| | |
| | | * @return
|
| | | */
|
| | | List<SysUser> userListNoPage(SysUser user);
|
| | |
|
| | | /**
|
| | | * ç»å®ç¨æ·é¨é¨
|
| | | * @param user
|
| | | * @return
|
| | | */
|
| | | int bindUserDept(SysUser user);
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.project.system.service.impl; |
| | | |
| | | import com.ruoyi.project.system.domain.vo.SysUserDeptVo; |
| | | import com.ruoyi.project.system.mapper.SysUserDeptMapper; |
| | | import com.ruoyi.project.system.service.ISysUserDeptService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class SysUserDeptServiceImpl implements ISysUserDeptService { |
| | | |
| | | @Autowired |
| | | private SysUserDeptMapper sysUserDeptMapper; |
| | | |
| | | @Override |
| | | public List<SysUserDeptVo> selectUserDeptList(SysUserDeptVo userDeptVo) { |
| | | return sysUserDeptMapper.selectUserDeptList(userDeptVo); |
| | | } |
| | | } |
| | |
| | | import java.util.List;
|
| | | import java.util.stream.Collectors;
|
| | | import javax.validation.Validator;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
| | | import com.ruoyi.project.system.domain.*;
|
| | | import com.ruoyi.project.system.mapper.*;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import com.ruoyi.common.utils.bean.BeanValidators;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
| | | import com.ruoyi.project.system.domain.SysPost;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.domain.SysUserPost;
|
| | | import com.ruoyi.project.system.domain.SysUserRole;
|
| | | import com.ruoyi.project.system.mapper.SysPostMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserPostMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserRoleMapper;
|
| | | import com.ruoyi.project.system.service.ISysConfigService;
|
| | | import com.ruoyi.project.system.service.ISysDeptService;
|
| | | import com.ruoyi.project.system.service.ISysUserService;
|
| | |
| | | @Service
|
| | | public class SysUserServiceImpl implements ISysUserService
|
| | | {
|
| | | @Autowired
|
| | | private SysUserDeptMapper sysUserDeptMapper;
|
| | |
|
| | | private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
| | |
|
| | | @Autowired
|
| | |
| | | insertUserPost(user);
|
| | | // æ°å¢ç¨æ·ä¸è§è²ç®¡ç
|
| | | insertUserRole(user);
|
| | | // æ°å¢é¨é¨å
³è
|
| | | bindUserDept(user);
|
| | | return rows;
|
| | | }
|
| | |
|
| | |
| | | if (StringUtils.isNull(u))
|
| | | {
|
| | | BeanValidators.validateWithException(validator, user);
|
| | | deptService.checkDeptDataScope(user.getDeptId());
|
| | | String password = configService.selectConfigByKey("sys.user.initPassword");
|
| | | user.setPassword(SecurityUtils.encryptPassword(password));
|
| | | user.setCreateBy(operName);
|
| | |
| | | BeanValidators.validateWithException(validator, user);
|
| | | checkUserAllowed(u);
|
| | | checkUserDataScope(u.getUserId());
|
| | | deptService.checkDeptDataScope(user.getDeptId());
|
| | | user.setUserId(u.getUserId());
|
| | | user.setUpdateBy(operName);
|
| | | userMapper.updateUser(user);
|
| | |
| | | public List<SysUser> userListNoPage(SysUser user) {
|
| | | return userMapper.selectUserList(user);
|
| | | }
|
| | |
|
| | | /**
|
| | | * ç»å®ç¨æ·é¨é¨
|
| | | * @param user
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public int bindUserDept(SysUser user) {
|
| | | // å 餿æå
³èç»å®
|
| | | LambdaQueryWrapper<SysUserDept> delWrapper = new LambdaQueryWrapper<>();
|
| | | delWrapper.eq(SysUserDept::getUserId, user.getUserId());
|
| | | sysUserDeptMapper.delete(delWrapper);
|
| | | // éæ°ç»å®
|
| | | for (int i = 0; i < user.getDeptIds().length; i++) {
|
| | | SysUserDept sysUserDept = new SysUserDept();
|
| | | sysUserDept.setDeptId(user.getDeptIds()[i]);
|
| | | sysUserDept.setUserId(user.getUserId());
|
| | | sysUserDeptMapper.insert(sysUserDept);
|
| | | }
|
| | | return user.getDeptIds().length;
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.ruoyi.project.system.mapper.SysUserDeptMapper"> |
| | | |
| | | <select id="selectUserDeptList" resultType="com.ruoyi.project.system.domain.vo.SysUserDeptVo"> |
| | | SELECT |
| | | T1.user_id, |
| | | T1.dept_id, |
| | | T2.dept_name |
| | | FROM |
| | | sys_user_dept T1 |
| | | LEFT JOIN sys_dept T2 ON T1.dept_id = T2.dept_id |
| | | <where> |
| | | <if test="userDeptVo.userId != null"> |
| | | T1.user_id = #{userDeptVo.userId} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |
| | |
| | | |
| | | <resultMap type="com.ruoyi.project.system.domain.SysUser" id="SysUserResult"> |
| | | <id property="userId" column="user_id" /> |
| | | <result property="deptId" column="dept_id" /> |
| | | <result property="userName" column="user_name" /> |
| | | <result property="nickName" column="nick_name" /> |
| | | <result property="email" column="email" /> |
| | |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="remark" column="remark" /> |
| | | <result property="deptNames" column="dept_names" /> |
| | | <result property="tenantId" column="tenant_id" /> |
| | | <association property="dept" javaType="com.ruoyi.project.system.domain.SysDept" resultMap="deptResult" /> |
| | | <collection property="roles" javaType="java.util.List" resultMap="RoleResult" /> |
| | |
| | | </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, |
| | | d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, |
| | | select u.user_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, |
| | | r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.tenant_id |
| | | from sys_user u |
| | | left join sys_dept d on u.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="com.ruoyi.project.system.domain.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, 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,T2.dept_names from sys_user u |
| | | left join |
| | | ( SELECT T1.user_id,GROUP_CONCAT(T2.dept_name SEPARATOR ', ') AS dept_names |
| | | FROM |
| | | sys_user_dept T1 |
| | | LEFT JOIN sys_dept T2 ON T1.dept_id = T2.dept_id |
| | | GROUP BY T1.user_id |
| | | ) T2 on T2.user_id = u.user_id |
| | | where u.del_flag = '0' |
| | | <if test="userId != null and userId != 0"> |
| | | AND u.user_id = #{userId} |
| | |
| | | <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 (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) )) |
| | | <if test="deptId != null"> |
| | | AND u.user_id IN |
| | | ( |
| | | SELECT user_id FROM sys_user_dept WHERE dept_id = #{deptId} |
| | | ) |
| | | </if> |
| | | <!-- æ°æ®èå´è¿æ»¤ --> |
| | | ${params.dataScope} |
| | |
| | | <update id="updateUser" parameterType="com.ruoyi.project.system.domain.SysUser"> |
| | | update sys_user |
| | | <set> |
| | | <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if> |
| | | <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if> |
| | | <if test="email != null ">email = #{email},</if> |
| | | <if test="phonenumber != null ">phonenumber = #{phonenumber},</if> |