Prechádzať zdrojové kódy

增加用户扩展信息

wukai 1 rok pred
rodič
commit
28395b3a0c

+ 107 - 0
doc-admin/src/main/java/com/doc/web/controller/system/SysUserExpandController.java

@@ -0,0 +1,107 @@
+package com.doc.web.controller.system;
+
+import com.doc.common.annotation.Log;
+import com.doc.common.core.controller.BaseController;
+import com.doc.common.core.domain.AjaxResult;
+import com.doc.common.core.domain.entity.SysUserExpand;
+import com.doc.common.core.page.TableDataInfo;
+import com.doc.common.enums.BusinessType;
+import com.doc.common.utils.poi.ExcelUtil;
+import com.doc.system.service.ISysUserExpandService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 用户登录限制Controller
+ * 
+ * @author wukai
+ * @date 2023-10-11
+ */
+@Api(tags="用户登录限制")
+@RestController
+@RequestMapping("/system/expand")
+public class SysUserExpandController extends BaseController
+{
+    @Resource
+    private ISysUserExpandService sysUserExpandService;
+
+    /**
+     * 查询用户登录限制列表
+     */
+    @ApiOperation("查询用户登录限制列表")
+    @PreAuthorize("@ss.hasPermi('system:expand:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(SysUserExpand sysUserExpand)
+    {
+        startPage();
+        List<SysUserExpand> list = sysUserExpandService.selectSysUserExpandList(sysUserExpand);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出用户登录限制列表
+     */
+    @ApiOperation("导出用户登录限制列表")
+    @PreAuthorize("@ss.hasPermi('system:expand:export')")
+    @Log(title = "用户登录限制", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, SysUserExpand sysUserExpand)
+    {
+        List<SysUserExpand> list = sysUserExpandService.selectSysUserExpandList(sysUserExpand);
+        ExcelUtil<SysUserExpand> util = new ExcelUtil<SysUserExpand>(SysUserExpand.class);
+        util.exportExcel(response, list, "用户登录限制数据");
+    }
+
+    /**
+     * 获取用户登录限制详细信息
+     */
+    @ApiOperation("获取用户登录限制详细信息")
+    @PreAuthorize("@ss.hasPermi('system:expand:query')")
+    @GetMapping(value = "/{userId}")
+    public AjaxResult getInfo(@PathVariable("userId") Long userId)
+    {
+        return success(sysUserExpandService.selectSysUserExpandByUserId(userId));
+    }
+
+    /**
+     * 新增用户登录限制
+     */
+    @ApiOperation("新增用户登录限制")
+    @PreAuthorize("@ss.hasPermi('system:expand:add')")
+    @Log(title = "用户登录限制", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody SysUserExpand sysUserExpand)
+    {
+        return toAjax(sysUserExpandService.insertSysUserExpand(sysUserExpand));
+    }
+
+    /**
+     * 修改用户登录限制
+     */
+    @ApiOperation("修改用户登录限制")
+    @PreAuthorize("@ss.hasPermi('system:expand:edit')")
+    @Log(title = "用户登录限制", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody SysUserExpand sysUserExpand)
+    {
+        return toAjax(sysUserExpandService.updateSysUserExpand(sysUserExpand));
+    }
+
+    /**
+     * 删除用户登录限制
+     */
+    @ApiOperation("删除用户登录限制")
+    @PreAuthorize("@ss.hasPermi('system:expand:remove')")
+    @Log(title = "用户登录限制", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{userIds}")
+    public AjaxResult remove(@PathVariable Long[] userIds)
+    {
+        return toAjax(sysUserExpandService.deleteSysUserExpandByUserIds(userIds));
+    }
+}

+ 48 - 37
doc-common/src/main/java/com/doc/common/core/domain/entity/SysUser.java

@@ -39,13 +39,13 @@ public class SysUser extends BaseEntity {
     /**
      * 用户账号
      */
-    @Excel(name = "登录名称")
+    @Excel(name = "账号")
     private String userName;
 
     /**
      * 用户昵称
      */
-    @Excel(name = "用户名称")
+    @Excel(name = "姓名")
     private String nickName;
 
     /**
@@ -132,41 +132,12 @@ public class SysUser extends BaseEntity {
      */
     @TableField(exist = false)
     private Long roleId;
+    @TableField(exist = false)
+    private SysUserExpand expand;
 
-    public SysUser() {
-
-    }
-
-    public SysUser(Long userId) {
-        this.userId = userId;
-    }
-
-    public Long getUserId() {
-        return userId;
-    }
-
-    public void setUserId(Long userId) {
-        this.userId = userId;
-    }
-
-    public boolean isAdmin() {
-        return isAdmin(this.userId);
-    }
-
-    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 = "用户昵称不能包含脚本字符")
-    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
+    @Xss(message = "姓名不能包含脚本字符")
+    @Size(min = 0, max = 30, message = "姓名长度不能超过30个字符")
     public String getNickName() {
         return nickName;
     }
@@ -175,8 +146,8 @@ public class SysUser extends BaseEntity {
         this.nickName = nickName;
     }
 
-    @Xss(message = "用户账号不能包含脚本字符")
-    @NotBlank(message = "用户账号不能为空")
+    @Xss(message = "账号不能包含脚本字符")
+    @NotBlank(message = "账号不能为空")
     @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
     public String getUserName() {
         return userName;
@@ -205,6 +176,38 @@ public class SysUser extends BaseEntity {
         this.phonenumber = phonenumber;
     }
 
+    public SysUser() {
+
+    }
+
+    public SysUser(Long userId) {
+        this.userId = userId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public boolean isAdmin() {
+        return isAdmin(this.userId);
+    }
+
+    public static boolean isAdmin(Long userId) {
+        return userId != null && 1L == userId;
+    }
+
+    public Long getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId) {
+        this.deptId = deptId;
+    }
+
     public String getSex() {
         return sex;
     }
@@ -301,6 +304,14 @@ public class SysUser extends BaseEntity {
         this.roleId = roleId;
     }
 
+    public SysUserExpand getExpand() {
+        return expand;
+    }
+
+    public void setExpand(SysUserExpand expand) {
+        this.expand = expand;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

+ 86 - 0
doc-common/src/main/java/com/doc/common/core/domain/entity/SysUserExpand.java

@@ -0,0 +1,86 @@
+package com.doc.common.core.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.doc.common.annotation.Excel;
+import com.doc.common.core.domain.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.util.Date;
+
+/**
+ * 用户登录限制对象 sys_user_expand
+ *
+ * @author wukai
+ * @date 2023-10-11
+ */
+public class SysUserExpand extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 用户ID
+     */
+    @TableId
+    private Long userId;
+
+    /**
+     * 上次修改密码时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date lastUpdateTime;
+
+    /**
+     * 登录IP限制
+     */
+    private String loginIp;
+
+    /**
+     * 登录时间限制
+     */
+    private String loginTime;
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setLastUpdateTime(Date lastUpdateTime) {
+        this.lastUpdateTime = lastUpdateTime;
+    }
+
+    public Date getLastUpdateTime() {
+        return lastUpdateTime;
+    }
+
+    public void setLoginIp(String loginIp) {
+        this.loginIp = loginIp;
+    }
+
+    public String getLoginIp() {
+        return loginIp;
+    }
+
+    public void setLoginTime(String loginTime) {
+        this.loginTime = loginTime;
+    }
+
+    public String getLoginTime() {
+        return loginTime;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("userId", getUserId())
+                .append("lastUpdateTime", getLastUpdateTime())
+                .append("loginIp", getLoginIp())
+                .append("loginTime", getLoginTime())
+                .toString();
+    }
+}

+ 64 - 0
doc-system/src/main/java/com/doc/system/mapper/SysUserExpandMapper.java

@@ -0,0 +1,64 @@
+package com.doc.system.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.doc.common.core.domain.entity.SysUserExpand;
+
+import java.util.List;
+
+/**
+ * 用户登录限制Mapper接口
+ * 
+ * @author wukai
+ * @date 2023-10-11
+ */
+public interface SysUserExpandMapper extends BaseMapper<SysUserExpand>
+{
+    /**
+     * 查询用户登录限制
+     * 
+     * @param userId 用户登录限制主键
+     * @return 用户登录限制
+     */
+    public SysUserExpand selectSysUserExpandByUserId(Long userId);
+
+    /**
+     * 查询用户登录限制列表
+     * 
+     * @param sysUserExpand 用户登录限制
+     * @return 用户登录限制集合
+     */
+    public List<SysUserExpand> selectSysUserExpandList(SysUserExpand sysUserExpand);
+
+    /**
+     * 新增用户登录限制
+     * 
+     * @param sysUserExpand 用户登录限制
+     * @return 结果
+     */
+    public int insertSysUserExpand(SysUserExpand sysUserExpand);
+
+    /**
+     * 修改用户登录限制
+     * 
+     * @param sysUserExpand 用户登录限制
+     * @return 结果
+     */
+    public int updateSysUserExpand(SysUserExpand sysUserExpand);
+
+    /**
+     * 删除用户登录限制
+     * 
+     * @param userId 用户登录限制主键
+     * @return 结果
+     */
+    public int deleteSysUserExpandByUserId(Long userId);
+
+    /**
+     * 批量删除用户登录限制
+     * 
+     * @param userIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteSysUserExpandByUserIds(Long[] userIds);
+
+}

+ 62 - 0
doc-system/src/main/java/com/doc/system/service/ISysUserExpandService.java

@@ -0,0 +1,62 @@
+package com.doc.system.service;
+
+import com.doc.common.core.domain.entity.SysUserExpand;
+
+import java.util.List;
+
+/**
+ * 用户登录限制Service接口
+ * 
+ * @author wukai
+ * @date 2023-10-11
+ */
+public interface ISysUserExpandService 
+{
+    /**
+     * 查询用户登录限制
+     * 
+     * @param userId 用户登录限制主键
+     * @return 用户登录限制
+     */
+    public SysUserExpand selectSysUserExpandByUserId(Long userId);
+
+    /**
+     * 查询用户登录限制列表
+     * 
+     * @param sysUserExpand 用户登录限制
+     * @return 用户登录限制集合
+     */
+    public List<SysUserExpand> selectSysUserExpandList(SysUserExpand sysUserExpand);
+
+    /**
+     * 新增用户登录限制
+     * 
+     * @param sysUserExpand 用户登录限制
+     * @return 结果
+     */
+    public int insertSysUserExpand(SysUserExpand sysUserExpand);
+
+    /**
+     * 修改用户登录限制
+     * 
+     * @param sysUserExpand 用户登录限制
+     * @return 结果
+     */
+    public int updateSysUserExpand(SysUserExpand sysUserExpand);
+
+    /**
+     * 批量删除用户登录限制
+     * 
+     * @param userIds 需要删除的用户登录限制主键集合
+     * @return 结果
+     */
+    public int deleteSysUserExpandByUserIds(Long[] userIds);
+
+    /**
+     * 删除用户登录限制信息
+     * 
+     * @param userId 用户登录限制主键
+     * @return 结果
+     */
+    public int deleteSysUserExpandByUserId(Long userId);
+}

+ 87 - 0
doc-system/src/main/java/com/doc/system/service/impl/SysUserExpandServiceImpl.java

@@ -0,0 +1,87 @@
+package com.doc.system.service.impl;
+
+import com.doc.common.core.domain.entity.SysUserExpand;
+import com.doc.system.mapper.SysUserExpandMapper;
+import com.doc.system.service.ISysUserExpandService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 用户登录限制Service业务层处理
+ *
+ * @author wukai
+ * @date 2023-10-11
+ */
+@Service
+public class SysUserExpandServiceImpl implements ISysUserExpandService {
+    @Resource
+    private SysUserExpandMapper sysUserExpandMapper;
+
+    /**
+     * 查询用户登录限制
+     *
+     * @param userId 用户登录限制主键
+     * @return 用户登录限制
+     */
+    @Override
+    public SysUserExpand selectSysUserExpandByUserId(Long userId) {
+        return sysUserExpandMapper.selectSysUserExpandByUserId(userId);
+    }
+
+    /**
+     * 查询用户登录限制列表
+     *
+     * @param sysUserExpand 用户登录限制
+     * @return 用户登录限制
+     */
+    @Override
+    public List<SysUserExpand> selectSysUserExpandList(SysUserExpand sysUserExpand) {
+        return sysUserExpandMapper.selectSysUserExpandList(sysUserExpand);
+    }
+
+    /**
+     * 新增用户登录限制
+     *
+     * @param sysUserExpand 用户登录限制
+     * @return 结果
+     */
+    @Override
+    public int insertSysUserExpand(SysUserExpand sysUserExpand) {
+            return sysUserExpandMapper.insertSysUserExpand(sysUserExpand);
+    }
+
+    /**
+     * 修改用户登录限制
+     *
+     * @param sysUserExpand 用户登录限制
+     * @return 结果
+     */
+    @Override
+    public int updateSysUserExpand(SysUserExpand sysUserExpand) {
+        return sysUserExpandMapper.updateSysUserExpand(sysUserExpand);
+    }
+
+    /**
+     * 批量删除用户登录限制
+     *
+     * @param userIds 需要删除的用户登录限制主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSysUserExpandByUserIds(Long[] userIds) {
+        return sysUserExpandMapper.deleteSysUserExpandByUserIds(userIds);
+    }
+
+    /**
+     * 删除用户登录限制信息
+     *
+     * @param userId 用户登录限制主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSysUserExpandByUserId(Long userId) {
+        return sysUserExpandMapper.deleteSysUserExpandByUserId(userId);
+    }
+}

+ 68 - 0
doc-system/src/main/resources/mapper/system/SysUserExpandMapper.xml

@@ -0,0 +1,68 @@
+<?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.doc.system.mapper.SysUserExpandMapper">
+    
+    <resultMap type="SysUserExpand" id="SysUserExpandResult">
+        <result property="userId"    column="USER_ID"    />
+        <result property="lastUpdateTime"    column="LAST_UPDATE_TIME"    />
+        <result property="loginIp"    column="LOGIN_IP"    />
+        <result property="loginTime"    column="LOGIN_TIME"    />
+    </resultMap>
+
+    <sql id="selectSysUserExpandVo">
+        select USER_ID, LAST_UPDATE_TIME, LOGIN_IP, LOGIN_TIME from sys_user_expand
+    </sql>
+
+    <select id="selectSysUserExpandList" parameterType="SysUserExpand" resultMap="SysUserExpandResult">
+        <include refid="selectSysUserExpandVo"/>
+        <where>  
+            <if test="lastUpdateTime != null "> and LAST_UPDATE_TIME = #{lastUpdateTime}</if>
+            <if test="loginIp != null  and loginIp != ''"> and LOGIN_IP = #{loginIp}</if>
+            <if test="loginTime != null  and loginTime != ''"> and LOGIN_TIME = #{loginTime}</if>
+        </where>
+    </select>
+    
+    <select id="selectSysUserExpandByUserId" parameterType="Long" resultMap="SysUserExpandResult">
+        <include refid="selectSysUserExpandVo"/>
+        where USER_ID = #{userId}
+    </select>
+        
+    <insert id="insertSysUserExpand" parameterType="SysUserExpand">
+        insert into sys_user_expand
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">USER_ID,</if>
+            <if test="lastUpdateTime != null">LAST_UPDATE_TIME,</if>
+            <if test="loginIp != null">LOGIN_IP,</if>
+            <if test="loginTime != null">LOGIN_TIME,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="lastUpdateTime != null">#{lastUpdateTime},</if>
+            <if test="loginIp != null">#{loginIp},</if>
+            <if test="loginTime != null">#{loginTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateSysUserExpand" parameterType="SysUserExpand">
+        update sys_user_expand
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="lastUpdateTime != null">LAST_UPDATE_TIME = #{lastUpdateTime},</if>
+            <if test="loginIp != null">LOGIN_IP = #{loginIp},</if>
+            <if test="loginTime != null">LOGIN_TIME = #{loginTime},</if>
+        </trim>
+        where USER_ID = #{userId}
+    </update>
+
+    <delete id="deleteSysUserExpandByUserId" parameterType="Long">
+        delete from sys_user_expand where USER_ID = #{userId}
+    </delete>
+
+    <delete id="deleteSysUserExpandByUserIds" parameterType="String">
+        delete from sys_user_expand where USER_ID in 
+        <foreach item="userId" collection="array" open="(" separator="," close=")">
+            #{userId}
+        </foreach>
+    </delete>
+</mapper>

+ 264 - 207
doc-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -1,221 +1,278 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.doc.system.mapper.SysUserMapper">
 
     <resultMap type="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="phonenumber"  column="phonenumber"  />
-        <result property="sex"          column="sex"          />
-        <result property="avatar"       column="avatar"       />
-        <result property="password"     column="password"     />
-        <result property="status"       column="status"       />
-        <result property="delFlag"      column="del_flag"     />
-        <result property="loginIp"      column="login_ip"     />
-        <result property="loginDate"    column="login_date"   />
-        <result property="createBy"     column="create_by"    />
-        <result property="createTime"   column="create_time"  />
-        <result property="updateBy"     column="update_by"    />
-        <result property="updateTime"   column="update_time"  />
-        <result property="remark"       column="remark"       />
-        <association property="dept"    column="dept_id" javaType="SysDept" resultMap="deptResult" />
-        <collection  property="roles"   javaType="java.util.List"           resultMap="RoleResult" />
+        <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="phonenumber" column="phonenumber"/>
+        <result property="sex" column="sex"/>
+        <result property="avatar" column="avatar"/>
+        <result property="password" column="password"/>
+        <result property="status" column="status"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="loginIp" column="login_ip"/>
+        <result property="loginDate" column="login_date"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+        <association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult"/>
+        <association property="expand" javaType="SysUserExpand" resultMap="expandResult"/>
+        <collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
     </resultMap>
-	
+
+    <resultMap id="expandResult" type="SysUserExpand">
+        <result property="userId" column="uid"/>
+        <result property="lastUpdateTime" column="last_update_time"/>
+        <result property="loginIp" column="login_ip_limit"/>
+        <result property="loginTime" column="login_time_limit"/>
+    </resultMap>
+
     <resultMap id="deptResult" type="SysDept">
-        <id     property="deptId"    column="dept_id"     />
-        <result property="parentId"  column="parent_id"   />
-        <result property="deptName"  column="dept_name"   />
-        <result property="ancestors" column="ancestors"   />
-        <result property="orderNum"  column="order_num"   />
-        <result property="leader"    column="leader"      />
-        <result property="status"    column="dept_status" />
+        <id property="deptId" column="dept_id"/>
+        <result property="parentId" column="parent_id"/>
+        <result property="deptName" column="dept_name"/>
+        <result property="ancestors" column="ancestors"/>
+        <result property="orderNum" column="order_num"/>
+        <result property="leader" column="leader"/>
+        <result property="status" column="dept_status"/>
     </resultMap>
-	
+
     <resultMap id="RoleResult" type="SysRole">
-        <id     property="roleId"       column="role_id"        />
-        <result property="roleName"     column="role_name"      />
-        <result property="roleKey"      column="role_key"       />
-        <result property="roleSort"     column="role_sort"      />
-        <result property="dataScope"     column="data_scope"    />
-        <result property="status"       column="role_status"    />
+        <id property="roleId" column="role_id"/>
+        <result property="roleName" column="role_name"/>
+        <result property="roleKey" column="role_key"/>
+        <result property="roleSort" column="role_sort"/>
+        <result property="dataScope" column="data_scope"/>
+        <result property="status" column="role_status"/>
     </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,
-        r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
+
+    <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,
+               r.role_id,
+               r.role_name,
+               r.role_key,
+               r.role_sort,
+               r.data_scope,
+               r.status  as role_status,
+               e.user_id as uid,
+               e.last_update_time,
+               e.login_ip as login_ip_limit,
+               e.login_time as login_time_limit
         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
+                 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
+                 left join sys_user_expand e on u.user_id = e.user_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
-		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="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') &gt;= 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') &lt;= 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>
-		<!-- 数据范围过滤 -->
-		${params.dataScope}
-	</select>
-	
-	<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
-	    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
-	    where u.del_flag = '0' and r.role_id = #{roleId}
-	    <if test="userName != null and userName != ''">
-			AND u.user_name like concat('%', #{userName}, '%')
-		</if>
-		<if test="phonenumber != null and phonenumber != ''">
-			AND u.phonenumber like concat('%', #{phonenumber}, '%')
-		</if>
-		<!-- 数据范围过滤 -->
-		${params.dataScope}
-	</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
-	    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
-	    where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
-	    and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
-	    <if test="userName != null and userName != ''">
-			AND u.user_name like concat('%', #{userName}, '%')
-		</if>
-		<if test="phonenumber != null and phonenumber != ''">
-			AND u.phonenumber like concat('%', #{phonenumber}, '%')
-		</if>
-		<!-- 数据范围过滤 -->
-		${params.dataScope}
-	</select>
-	
-	<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
-	    <include refid="selectUserVo"/>
-		where u.user_name = #{userName} and u.del_flag = '0'
-	</select>
-	
-	<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
-		<include refid="selectUserVo"/>
-		where u.user_id = #{userId}
-	</select>
-	
-	<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
-		select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
-	</select>
-	
-	<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
-		select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
-	</select>
-	
-	<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
-		select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
-	</select>
-	
-	<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
- 		insert into sys_user(
- 			<if test="userId != null and userId != 0">user_id,</if>
- 			<if test="deptId != null and deptId != 0">dept_id,</if>
- 			<if test="userName != null and userName != ''">user_name,</if>
- 			<if test="nickName != null and nickName != ''">nick_name,</if>
- 			<if test="email != null and email != ''">email,</if>
- 			<if test="avatar != null and avatar != ''">avatar,</if>
- 			<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
- 			<if test="sex != null and sex != ''">sex,</if>
- 			<if test="password != null and password != ''">password,</if>
- 			<if test="status != null and status != ''">status,</if>
- 			<if test="createBy != null and createBy != ''">create_by,</if>
- 			<if test="remark != null and remark != ''">remark,</if>
- 			create_time
- 		)values(
- 			<if test="userId != null and userId != ''">#{userId},</if>
- 			<if test="deptId != null and deptId != ''">#{deptId},</if>
- 			<if test="userName != null and userName != ''">#{userName},</if>
- 			<if test="nickName != null and nickName != ''">#{nickName},</if>
- 			<if test="email != null and email != ''">#{email},</if>
- 			<if test="avatar != null and avatar != ''">#{avatar},</if>
- 			<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
- 			<if test="sex != null and sex != ''">#{sex},</if>
- 			<if test="password != null and password != ''">#{password},</if>
- 			<if test="status != null and status != ''">#{status},</if>
- 			<if test="createBy != null and createBy != ''">#{createBy},</if>
- 			<if test="remark != null and remark != ''">#{remark},</if>
- 			sysdate()
- 		)
-	</insert>
-	
-	<update id="updateUser" parameterType="SysUser">
- 		update sys_user
- 		<set>
- 			<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
- 			<if test="userName != null and userName != ''">user_name = #{userName},</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>
- 			<if test="sex != null and sex != ''">sex = #{sex},</if>
- 			<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
- 			<if test="password != null and password != ''">password = #{password},</if>
- 			<if test="status != null and status != ''">status = #{status},</if>
- 			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
- 			<if test="loginDate != null">login_date = #{loginDate},</if>
- 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- 			<if test="remark != null">remark = #{remark},</if>
- 			update_time = sysdate()
- 		</set>
- 		where user_id = #{userId}
-	</update>
-	
-	<update id="updateUserStatus" parameterType="SysUser">
- 		update sys_user set status = #{status} where user_id = #{userId}
-	</update>
-	
-	<update id="updateUserAvatar" parameterType="SysUser">
- 		update sys_user set avatar = #{avatar} where user_name = #{userName}
-	</update>
-	
-	<update id="resetUserPwd" parameterType="SysUser">
- 		update sys_user set password = #{password} where user_name = #{userName}
-	</update>
-	
-	<delete id="deleteUserById" parameterType="Long">
- 		update sys_user set del_flag = '2' where user_id = #{userId}
- 	</delete>
- 	
- 	<delete id="deleteUserByIds" parameterType="Long">
- 		update sys_user set del_flag = '2' where user_id in
- 		<foreach collection="array" item="userId" open="(" separator="," close=")">
- 			#{userId}
-        </foreach> 
- 	</delete>
-	
+        <include refid="selectUserVo"/>
+        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="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') &gt;= 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') &lt;= 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>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+    </select>
+
+    <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
+        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
+        where u.del_flag = '0' and r.role_id = #{roleId}
+        <if test="userName != null and userName != ''">
+            AND u.user_name like concat('%', #{userName}, '%')
+        </if>
+        <if test="phonenumber != null and phonenumber != ''">
+            AND u.phonenumber like concat('%', #{phonenumber}, '%')
+        </if>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+    </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
+        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
+        where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
+        and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and
+        ur.role_id = #{roleId})
+        <if test="userName != null and userName != ''">
+            AND u.user_name like concat('%', #{userName}, '%')
+        </if>
+        <if test="phonenumber != null and phonenumber != ''">
+            AND u.phonenumber like concat('%', #{phonenumber}, '%')
+        </if>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+    </select>
+
+    <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
+        <include refid="selectUserVo"/>
+        where u.user_name = #{userName} and u.del_flag = '0'
+    </select>
+
+    <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
+        <include refid="selectUserVo"/>
+        where u.user_id = #{userId}
+    </select>
+
+    <select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
+        select user_id, user_name
+        from sys_user
+        where user_name = #{userName}
+          and del_flag = '0' limit 1
+    </select>
+
+    <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
+        select user_id, phonenumber
+        from sys_user
+        where phonenumber = #{phonenumber}
+          and del_flag = '0' limit 1
+    </select>
+
+    <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
+        select user_id, email
+        from sys_user
+        where email = #{email}
+          and del_flag = '0' limit 1
+    </select>
+
+    <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
+        insert into sys_user(
+        <if test="userId != null and userId != 0">user_id,</if>
+        <if test="deptId != null and deptId != 0">dept_id,</if>
+        <if test="userName != null and userName != ''">user_name,</if>
+        <if test="nickName != null and nickName != ''">nick_name,</if>
+        <if test="email != null and email != ''">email,</if>
+        <if test="avatar != null and avatar != ''">avatar,</if>
+        <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
+        <if test="sex != null and sex != ''">sex,</if>
+        <if test="password != null and password != ''">password,</if>
+        <if test="status != null and status != ''">status,</if>
+        <if test="createBy != null and createBy != ''">create_by,</if>
+        <if test="remark != null and remark != ''">remark,</if>
+        create_time
+        )values(
+        <if test="userId != null and userId != ''">#{userId},</if>
+        <if test="deptId != null and deptId != ''">#{deptId},</if>
+        <if test="userName != null and userName != ''">#{userName},</if>
+        <if test="nickName != null and nickName != ''">#{nickName},</if>
+        <if test="email != null and email != ''">#{email},</if>
+        <if test="avatar != null and avatar != ''">#{avatar},</if>
+        <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
+        <if test="sex != null and sex != ''">#{sex},</if>
+        <if test="password != null and password != ''">#{password},</if>
+        <if test="status != null and status != ''">#{status},</if>
+        <if test="createBy != null and createBy != ''">#{createBy},</if>
+        <if test="remark != null and remark != ''">#{remark},</if>
+        sysdate()
+        )
+    </insert>
+
+    <update id="updateUser" parameterType="SysUser">
+        update sys_user
+        <set>
+            <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
+            <if test="userName != null and userName != ''">user_name = #{userName},</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>
+            <if test="sex != null and sex != ''">sex = #{sex},</if>
+            <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
+            <if test="password != null and password != ''">password = #{password},</if>
+            <if test="status != null and status != ''">status = #{status},</if>
+            <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
+            <if test="loginDate != null">login_date = #{loginDate},</if>
+            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            update_time = sysdate()
+        </set>
+        where user_id = #{userId}
+    </update>
+
+    <update id="updateUserStatus" parameterType="SysUser">
+        update sys_user
+        set status = #{status}
+        where user_id = #{userId}
+    </update>
+
+    <update id="updateUserAvatar" parameterType="SysUser">
+        update sys_user
+        set avatar = #{avatar}
+        where user_name = #{userName}
+    </update>
+
+    <update id="resetUserPwd" parameterType="SysUser">
+        update sys_user
+        set password = #{password}
+        where user_name = #{userName}
+    </update>
+
+    <delete id="deleteUserById" parameterType="Long">
+        update sys_user
+        set del_flag = '2'
+        where user_id = #{userId}
+    </delete>
+
+    <delete id="deleteUserByIds" parameterType="Long">
+        update sys_user set del_flag = '2' where user_id in
+        <foreach collection="array" item="userId" open="(" separator="," close=")">
+            #{userId}
+        </foreach>
+    </delete>
+
 </mapper>