mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-19 21:45:06 +08:00
初始化 User 模块的代码
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.dashboard.framework.security.core;
|
||||
|
||||
import cn.iocoder.dashboard.modules.system.enums.user.UserStatus;
|
||||
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@ -46,7 +46,7 @@ public class LoginUser implements UserDetails {
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
private Integer status;
|
||||
|
||||
@Override
|
||||
@JSONField(serialize = false) // 避免序列化
|
||||
@ -63,7 +63,7 @@ public class LoginUser implements UserDetails {
|
||||
@Override
|
||||
@JSONField(serialize = false) // 避免序列化
|
||||
public boolean isEnabled() {
|
||||
return UserStatus.OK.getCode().equals(status);
|
||||
return CommonStatusEnum.ENABLE.getStatus().equals(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull;
|
||||
@Data
|
||||
public class SysRoleUpdateStatusReqVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1024")
|
||||
@ApiModelProperty(value = "角色编号", required = true, example = "1024")
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Long id;
|
||||
|
||||
|
@ -0,0 +1,155 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.user;
|
||||
|
||||
public class SysUserController {
|
||||
|
||||
// /**
|
||||
// * 获取用户列表
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
// @GetMapping("/list")
|
||||
// public TableDataInfo list(SysUser user)
|
||||
// {
|
||||
// startPage();
|
||||
// List<SysUser> list = userService.selectUserList(user);
|
||||
// return getDataTable(list);
|
||||
// }
|
||||
//
|
||||
// @Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||
// @GetMapping("/export")
|
||||
// public AjaxResult export(SysUser user)
|
||||
// {
|
||||
// List<SysUser> list = userService.selectUserList(user);
|
||||
// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
// return util.exportExcel(list, "用户数据");
|
||||
// }
|
||||
//
|
||||
// @Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||
// @PostMapping("/importData")
|
||||
// public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||
// {
|
||||
// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
// List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
// String operName = loginUser.getUsername();
|
||||
// String message = userService.importUser(userList, updateSupport, operName);
|
||||
// return AjaxResult.success(message);
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/importTemplate")
|
||||
// public AjaxResult importTemplate()
|
||||
// {
|
||||
// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
// return util.importTemplateExcel("用户数据");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据用户编号获取详细信息
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
// @GetMapping(value = { "/", "/{userId}" })
|
||||
// public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||
// {
|
||||
// AjaxResult ajax = AjaxResult.success();
|
||||
// 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());
|
||||
// if (StringUtils.isNotNull(userId))
|
||||
// {
|
||||
// ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
||||
// ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||
// ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
||||
// }
|
||||
// return ajax;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 新增用户
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||
// @Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
// @PostMapping
|
||||
// public AjaxResult add(@Validated @RequestBody SysUser user)
|
||||
// {
|
||||
// if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
|
||||
// {
|
||||
// return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
// }
|
||||
// else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
// && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
// {
|
||||
// return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
// }
|
||||
// else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
// && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
// {
|
||||
// return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
// }
|
||||
// user.setCreateBy(SecurityUtils.getUsername());
|
||||
// user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
// return toAjax(userService.insertUser(user));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改用户
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
// @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping
|
||||
// public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||
// {
|
||||
// userService.checkUserAllowed(user);
|
||||
// if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
// && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
// {
|
||||
// return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
// }
|
||||
// else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
// && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
// {
|
||||
// return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
// }
|
||||
// user.setUpdateBy(SecurityUtils.getUsername());
|
||||
// return toAjax(userService.updateUser(user));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除用户
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||
// @Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||
// @DeleteMapping("/{userIds}")
|
||||
// public AjaxResult remove(@PathVariable Long[] userIds)
|
||||
// {
|
||||
// return toAjax(userService.deleteUserByIds(userIds));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 重置密码
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||
// @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping("/resetPwd")
|
||||
// public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||
// {
|
||||
// userService.checkUserAllowed(user);
|
||||
// user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
// user.setUpdateBy(SecurityUtils.getUsername());
|
||||
// return toAjax(userService.resetPwd(user));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 状态修改
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
// @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping("/changeStatus")
|
||||
// public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||
// {
|
||||
// userService.checkUserAllowed(user);
|
||||
// user.setUpdateBy(SecurityUtils.getUsername());
|
||||
// return toAjax(userService.updateUserStatus(user));
|
||||
// }
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.user;
|
||||
|
||||
public class SysUserProfileController {
|
||||
|
||||
// /**
|
||||
// * 个人信息
|
||||
// */
|
||||
// @GetMapping
|
||||
// public AjaxResult profile()
|
||||
// {
|
||||
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
// SysUser user = loginUser.getUser();
|
||||
// AjaxResult ajax = AjaxResult.success(user);
|
||||
// ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||
// ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
||||
// return ajax;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改用户
|
||||
// */
|
||||
// @Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping
|
||||
// public AjaxResult updateProfile(@RequestBody SysUser user)
|
||||
// {
|
||||
// if (userService.updateUserProfile(user) > 0)
|
||||
// {
|
||||
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
// // 更新缓存用户信息
|
||||
// loginUser.getUser().setNickName(user.getNickName());
|
||||
// loginUser.getUser().setPhonenumber(user.getPhonenumber());
|
||||
// loginUser.getUser().setEmail(user.getEmail());
|
||||
// loginUser.getUser().setSex(user.getSex());
|
||||
// tokenService.setLoginUser(loginUser);
|
||||
// return AjaxResult.success();
|
||||
// }
|
||||
// return AjaxResult.error("修改个人信息异常,请联系管理员");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 重置密码
|
||||
// */
|
||||
// @Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping("/updatePwd")
|
||||
// public AjaxResult updatePwd(String oldPassword, String newPassword)
|
||||
// {
|
||||
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
// String userName = loginUser.getUsername();
|
||||
// String password = loginUser.getPassword();
|
||||
// if (!SecurityUtils.matchesPassword(oldPassword, password))
|
||||
// {
|
||||
// return AjaxResult.error("修改密码失败,旧密码错误");
|
||||
// }
|
||||
// if (SecurityUtils.matchesPassword(newPassword, password))
|
||||
// {
|
||||
// return AjaxResult.error("新密码不能与旧密码相同");
|
||||
// }
|
||||
// if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
|
||||
// {
|
||||
// // 更新缓存用户密码
|
||||
// loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
||||
// tokenService.setLoginUser(loginUser);
|
||||
// return AjaxResult.success();
|
||||
// }
|
||||
// return AjaxResult.error("修改密码异常,请联系管理员");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 头像上传
|
||||
// */
|
||||
// @Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||
// @PostMapping("/avatar")
|
||||
// public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException
|
||||
// {
|
||||
// if (!file.isEmpty())
|
||||
// {
|
||||
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
// String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
|
||||
// if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
||||
// {
|
||||
// AjaxResult ajax = AjaxResult.success();
|
||||
// ajax.put("imgUrl", avatar);
|
||||
// // 更新缓存用户头像
|
||||
// loginUser.getUser().setAvatar(avatar);
|
||||
// tokenService.setLoginUser(loginUser);
|
||||
// return ajax;
|
||||
// }
|
||||
// }
|
||||
// return AjaxResult.error("上传图片异常,请联系管理员");
|
||||
// }
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.user.vo.user;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class SysUserBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "用户账号", required = true, example = "yudao")
|
||||
@NotBlank(message = "用户账号不能为空")
|
||||
@Size(max = 30, message = "用户账号长度不能超过30个字符")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
|
||||
@Size(max = 30, message = "用户昵称长度不能超过30个字符")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "备注", example = "我是一个用户")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "部门ID", example = "我是一个用户")
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty(value = "岗位编号数组", example = "1")
|
||||
private Set<Long> postIds;
|
||||
|
||||
@ApiModelProperty(value = "用户邮箱", example = "yudao@iocoder.cn")
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(max = 50, message = "邮箱长度不能超过50个字符")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "手机号码", example = "15601691300")
|
||||
@Size(max = 11, message = "手机号码长度不能超过11个字符")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "用户性别", example = "1", notes = "参见 SysSexEnum 枚举类")
|
||||
private Integer sex;
|
||||
|
||||
@ApiModelProperty(value = "用户头像", example = "http://www.iocoder.cn/xxx.png")
|
||||
private String avatar;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.user.vo.user;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ApiModel("用户创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysUserCreateReqVO extends SysUserBaseVO {
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.user.vo.user;
|
||||
|
||||
import cn.iocoder.dashboard.framework.excel.Excel;
|
||||
import cn.iocoder.dashboard.framework.excel.Excels;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户 Excel 导出响应 VO
|
||||
*/
|
||||
@Data
|
||||
public class SysUserExcelRespVO {
|
||||
|
||||
@Excel(name = "用户序号", cellType = Excel.ColumnType.NUMERIC, prompt = "用户编号")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@Excel(name = "登录名称")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
@Excel(name = "用户名称")
|
||||
private String nickname;
|
||||
|
||||
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
|
||||
private Long deptId;
|
||||
|
||||
@Excel(name = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
@Excel(name = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
||||
private String sex;
|
||||
|
||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||
private Integer status;
|
||||
|
||||
@Excel(name = "最后登录IP", type = Excel.Type.EXPORT)
|
||||
private String loginIp;
|
||||
|
||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
|
||||
private Date loginDate;
|
||||
|
||||
@Excels({
|
||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Excel.Type.EXPORT),
|
||||
@Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT)
|
||||
})
|
||||
private SysDeptDO dept;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.user.vo.user;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("用户信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysUserRespVO extends SysUserBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "最后登陆 IP", required = true, example = "192.168.1.1")
|
||||
private String loginIp;
|
||||
|
||||
@ApiModelProperty(value = "最后登录时间", required = true, example = "时间戳格式")
|
||||
private Date loginDate;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.user.vo.user;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("用户更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysUserUpdateReqVO extends SysUserBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1024")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.user.vo.user;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("用户更新状态 Request VO")
|
||||
@Data
|
||||
public class SysUserUpdateStatusReqVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1024")
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 SysCommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
// @InEnum(value = SysCommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -1,22 +1,18 @@
|
||||
package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.user;
|
||||
|
||||
import cn.iocoder.dashboard.framework.excel.Excel;
|
||||
import cn.iocoder.dashboard.framework.excel.Excels;
|
||||
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO;
|
||||
import cn.iocoder.dashboard.modules.system.enums.common.SysSexEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户 DO
|
||||
@ -26,118 +22,71 @@ import java.util.List;
|
||||
@TableName("sys_user")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
// TODO 芋艿:数据库的字段默认值
|
||||
public class SysUserDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId
|
||||
@Excel(name = "用户序号", cellType = Excel.ColumnType.NUMERIC, prompt = "用户编号")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
|
||||
private Long deptId;
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@Excel(name = "登录名称")
|
||||
@NotBlank(message = "用户账号不能为空")
|
||||
@Size(max = 30, message = "用户账号长度不能超过30个字符")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 加密后的密码
|
||||
*
|
||||
* 因为目前使用 {@link BCryptPasswordEncoder} 加密器,所以无需自己处理 salt 盐
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
@Excel(name = "用户名称")
|
||||
@Size(max = 30, message = "用户昵称长度不能超过30个字符")
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 岗位编号数组
|
||||
*/
|
||||
@TableField(typeHandler = FastjsonTypeHandler.class)
|
||||
private Set<Long> postIds;
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
@Excel(name = "用户邮箱")
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(max = 50, message = "邮箱长度不能超过50个字符")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@Excel(name = "手机号码")
|
||||
@Size(max = 11, message = "手机号码长度不能超过11个字符")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
*
|
||||
* 枚举类 {@link SysSexEnum}
|
||||
*/
|
||||
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
||||
private String sex;
|
||||
|
||||
private Integer sex;
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
* 帐号状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||
// TODO 芋艿:修改成枚举
|
||||
private String status;
|
||||
|
||||
private Integer status;
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
@Excel(name = "最后登录IP", type = Excel.Type.EXPORT)
|
||||
private String loginIp;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
|
||||
private Date loginDate;
|
||||
|
||||
|
||||
// TODO FROM 芋艿:下面的字段,需要忽略
|
||||
|
||||
/**
|
||||
* 部门对象
|
||||
*/
|
||||
@Excels({
|
||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Excel.Type.EXPORT),
|
||||
@Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT)
|
||||
})
|
||||
@TableField(exist = false)
|
||||
private SysDeptDO dept;
|
||||
|
||||
/**
|
||||
* 角色对象
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysRoleDO> roles;
|
||||
|
||||
/**
|
||||
* 角色组
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long[] roleIds;
|
||||
|
||||
/**
|
||||
* 岗位组
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long[] postIds;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.dashboard.modules.system.enums.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SysSexEnum {
|
||||
|
||||
MALE(1), // 男
|
||||
FEMALE(2); // 女
|
||||
|
||||
private final Integer SEX;
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.enums.user;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public enum UserStatus
|
||||
{
|
||||
OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
UserStatus(String code, String info)
|
||||
{
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ import cn.iocoder.dashboard.framework.security.core.LoginUser;
|
||||
import cn.iocoder.dashboard.modules.system.convert.auth.SysAuthConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.redis.dao.auth.SysLoginUserRedisDAO;
|
||||
import cn.iocoder.dashboard.modules.system.enums.user.UserStatus;
|
||||
import cn.iocoder.dashboard.modules.system.service.auth.SysAuthService;
|
||||
import cn.iocoder.dashboard.modules.system.service.auth.SysTokenService;
|
||||
import cn.iocoder.dashboard.modules.system.service.permission.SysPermissionService;
|
||||
@ -199,7 +198,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||
|
||||
// 重新加载 SysUserDO 信息
|
||||
SysUserDO user = userService.getUser(loginUser.getUserId());
|
||||
if (user == null || UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
if (user == null || CommonStatusEnum.DISABLE.getStatus().equals(user.getStatus())) {
|
||||
throw exception(TOKEN_EXPIRED); // 校验 token 时,用户被禁用的情况下,也认为 token 过期,方便前端跳转到登陆界面
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user