添加注释

master
chen 2 years ago
parent b70537c88b
commit a0e687b9ff
  1. 1
      src/main/java/com/huoran/iasf/common/exception/BusinessException.java
  2. 3
      src/main/java/com/huoran/iasf/common/job/task/TestTask.java
  3. 12
      src/main/java/com/huoran/iasf/common/job/utils/ScheduleJob.java
  4. 60
      src/main/java/com/huoran/iasf/common/job/utils/ScheduleUtils.java
  5. 2
      src/main/java/com/huoran/iasf/common/utils/Constant.java
  6. 41
      src/main/java/com/huoran/iasf/controller/CaptchaController.java
  7. 4
      src/main/java/com/huoran/iasf/controller/RoleController.java
  8. 15
      src/main/java/com/huoran/iasf/controller/UserController.java
  9. 10
      src/main/java/com/huoran/iasf/entity/SysContentEntity.java
  10. 10
      src/main/java/com/huoran/iasf/entity/SysDept.java
  11. 6
      src/main/java/com/huoran/iasf/entity/SysFilesEntity.java
  12. 15
      src/main/java/com/huoran/iasf/entity/SysPermission.java
  13. 19
      src/main/java/com/huoran/iasf/entity/SysRole.java
  14. 36
      src/main/java/com/huoran/iasf/entity/SysUser.java
  15. 10
      src/main/java/com/huoran/iasf/service/HttpSessionService.java
  16. 13
      src/main/java/com/huoran/iasf/service/impl/SysJobServiceImpl.java
  17. 34
      src/main/java/com/huoran/iasf/service/impl/UserServiceImpl.java
  18. 2
      src/main/java/com/huoran/iasf/vo/req/UserRoleOperationReqVO.java

@ -11,6 +11,7 @@ import com.huoran.iasf.common.exception.code.ResponseCodeInterface;
* @date 2022年7月28日
*/
public class BusinessException extends RuntimeException {
/**
* 异常编号
*/

@ -2,7 +2,6 @@ package com.huoran.iasf.common.job.task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* 测试定时任务(演示Demo可删除)
@ -12,7 +11,7 @@ import org.springframework.stereotype.Component;
* @version V1.0
* @date 2022年7月28日
*/
@Component("testTask")
// @Component("testTask")
public class TestTask {
private Logger logger = LoggerFactory.getLogger(getClass());

@ -1,3 +1,4 @@
/*
package com.huoran.iasf.common.job.utils;
import com.huoran.iasf.common.utils.R;
@ -14,13 +15,15 @@ import org.springframework.scheduling.quartz.QuartzJobBean;
import java.lang.reflect.Method;
*/
/**
* 定时任务
*
* @author cheney
* @version V1.0
* @date 2022年7月28日
*/
*//*
public class ScheduleJob extends QuartzJobBean {
private Logger logger = LoggerFactory.getLogger(getClass());
@ -80,12 +83,14 @@ public class ScheduleJob extends QuartzJobBean {
}
}
/**
*/
/**
* 判断bean是否有效
*
* @param beanName beanName
* @return 返回信息
*/
*//*
public static R judgeBean(String beanName) {
if (org.springframework.util.StringUtils.isEmpty(beanName)) {
@ -109,3 +114,4 @@ public class ScheduleJob extends QuartzJobBean {
return R.success();
}
}
*/

@ -1,3 +1,4 @@
/*
package com.huoran.iasf.common.job.utils;
import com.huoran.iasf.common.exception.BusinessException;
@ -5,33 +6,41 @@ import com.huoran.iasf.common.utils.Constant;
import com.huoran.iasf.entity.SysJobEntity;
import org.quartz.*;
*/
/**
* 定时任务工具类
*
* @author cheney
* @version V1.0
* @date 2022年7月28日
*/
*//*
public class ScheduleUtils {
private final static String JOB_NAME = "TASK_";
/**
*/
/**
* 获取触发器key
*/
*//*
public static TriggerKey getTriggerKey(String jobId) {
return TriggerKey.triggerKey(JOB_NAME + jobId);
}
/**
*/
/**
* 获取jobKey
*/
*//*
public static JobKey getJobKey(String jobId) {
return JobKey.jobKey(JOB_NAME + jobId);
}
/**
*/
/**
* 获取表达式触发器
*/
*//*
public static CronTrigger getCronTrigger(Scheduler scheduler, String jobId) {
try {
return (CronTrigger) scheduler.getTrigger(getTriggerKey(jobId));
@ -40,9 +49,11 @@ public class ScheduleUtils {
}
}
/**
*/
/**
* 创建定时任务
*/
*//*
public static void createScheduleJob(Scheduler scheduler, SysJobEntity scheduleJob) {
try {
//构建job信息
@ -69,9 +80,11 @@ public class ScheduleUtils {
}
}
/**
*/
/**
* 更新定时任务
*/
*//*
public static void updateScheduleJob(Scheduler scheduler, SysJobEntity scheduleJob) {
try {
TriggerKey triggerKey = getTriggerKey(scheduleJob.getId());
@ -100,9 +113,11 @@ public class ScheduleUtils {
}
}
/**
*/
/**
* 立即执行任务
*/
*//*
public static void run(Scheduler scheduler, SysJobEntity scheduleJob) {
try {
//参数
@ -115,9 +130,11 @@ public class ScheduleUtils {
}
}
/**
*/
/**
* 暂停任务
*/
*//*
public static void pauseJob(Scheduler scheduler, String jobId) {
try {
scheduler.pauseJob(getJobKey(jobId));
@ -126,9 +143,11 @@ public class ScheduleUtils {
}
}
/**
*/
/**
* 恢复任务
*/
*//*
public static void resumeJob(Scheduler scheduler, String jobId) {
try {
scheduler.resumeJob(getJobKey(jobId));
@ -137,9 +156,11 @@ public class ScheduleUtils {
}
}
/**
*/
/**
* 删除定时任务
*/
*//*
public static void deleteScheduleJob(Scheduler scheduler, String jobId) {
try {
scheduler.deleteJob(getJobKey(jobId));
@ -148,3 +169,4 @@ public class ScheduleUtils {
}
}
}
*/

@ -12,7 +12,7 @@ public class Constant {
/**
* redis的token相关
*/
public static final String ACCESS_TOKEN = "authorization";
public static final String ACCESS_TOKEN = "token";
public static final String PERMISSIONS_KEY = "permissions-key";
public static final String USERID_KEY = "userid-key";
public static final String USERNAME_KEY = "username-key";

@ -1,13 +1,20 @@
package com.huoran.iasf.controller;
import com.huoran.iasf.service.RedisService;
import com.wf.captcha.ArithmeticCaptcha;
import com.wf.captcha.utils.CaptchaUtil;
import com.wf.captcha.base.Captcha;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -23,19 +30,39 @@ import java.io.IOException;
@Slf4j
@RequestMapping("/sys")
public class CaptchaController {
@Resource
private RedisService redisService;
/**
* 获取验证码图片
* Gets captcha code.
*
* @param request the request
* @param response the response
* @throws IOException the io exception
*/
@RequestMapping("/getVerify")
/* @RequestMapping("/getVerify")
public void getCaptchaCode(HttpServletRequest request, HttpServletResponse response) throws IOException {
ArithmeticCaptcha captcha = new ArithmeticCaptcha(130, 48);
captcha.setLen(2);
CaptchaUtil.out(captcha, request, response);
}*/
@ApiOperation(value = "登录验证码")
@GetMapping(value = "/getVerify",produces = "image/png")
public void captcha(
@ApiParam(name = "random", value = "随机数", required = true)
@RequestParam String random, HttpServletResponse response){
Captcha captcha = new ArithmeticCaptcha();
//生成验证码
String text = captcha.text();
//缓存验证码
redisService.setAndExpire(random,text,120);
response.setContentType(MediaType.IMAGE_PNG_VALUE);
response.setHeader(HttpHeaders.PRAGMA, "No-cache");
response.setHeader(HttpHeaders.CACHE_CONTROL, "No-cache");
response.setDateHeader(HttpHeaders.EXPIRES, 0L);
try {
captcha.out(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -116,7 +116,7 @@ public class RoleController {
if (!StringUtils.isEmpty(vo.getName())) {
queryWrapper.like(SysRole::getName, vo.getName());
}
if (!StringUtils.isEmpty(vo.getStartTime())) {
/* if (!StringUtils.isEmpty(vo.getStartTime())) {
queryWrapper.gt(SysRole::getCreateTime, vo.getStartTime());
}
if (!StringUtils.isEmpty(vo.getEndTime())) {
@ -124,7 +124,7 @@ public class RoleController {
}
if (!StringUtils.isEmpty(vo.getStatus())) {
queryWrapper.eq(SysRole::getStatus, vo.getStatus());
}
}*/
queryWrapper.orderByDesc(SysRole::getCreateTime);
return R.success(roleService.page(vo.getQueryPage(), queryWrapper));
}

@ -3,7 +3,6 @@ package com.huoran.iasf.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huoran.iasf.common.aop.annotation.LogAnnotation;
import com.huoran.iasf.common.exception.code.BaseResponseCode;
import com.huoran.iasf.common.utils.R;
import com.huoran.iasf.entity.SysUser;
import com.huoran.iasf.entity.SysUserRole;
@ -11,7 +10,6 @@ import com.huoran.iasf.service.HttpSessionService;
import com.huoran.iasf.service.UserRoleService;
import com.huoran.iasf.service.UserService;
import com.huoran.iasf.vo.req.UserRoleOperationReqVO;
import com.wf.captcha.utils.CaptchaUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -24,7 +22,6 @@ import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
@ -49,13 +46,7 @@ public class UserController {
@PostMapping(value = "/user/login")
@ApiOperation(value = "用户登录接口")
public R login(@RequestBody @Valid SysUser vo, HttpServletRequest request) {
//判断验证码
if (!CaptchaUtil.ver(vo.getCaptcha(), request)) {
// 清除session中的验证码
CaptchaUtil.clear(request);
return R.fail("验证码错误!");
}
public R login(@RequestBody @Valid SysUser vo) {
return R.success(userService.login(vo));
}
@ -66,11 +57,11 @@ public class UserController {
return R.success();
}
@GetMapping("/user/unLogin")
/*@GetMapping("/user/unLogin")
@ApiOperation(value = "引导客户端去登录")
public R unLogin() {
return R.getResult(BaseResponseCode.TOKEN_ERROR);
}
}*/
@PutMapping("/user")
@ApiOperation(value = "更新用户信息接口")

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -27,51 +28,60 @@ public class SysContentEntity extends BaseEntity implements Serializable {
* 主键id
*/
@TableId("id")
@ApiModelProperty(value = "主键id")
private String id;
/**
* 主题
*/
@TableField("title")
@ApiModelProperty(value = "主题")
private String title;
/**
* 内容
*/
@TableField("content")
@ApiModelProperty(value = "内容")
private String content;
/**
* 单个图片url
*/
@ApiModelProperty(value = "单个图片url")
private String oneImg;
/**
* 多个图片url
*/
@ApiModelProperty(value = "多个图片url")
private String multipleImg;
/**
* 关键字
*/
@ApiModelProperty(value = "关键字")
private String keywords;
/**
* 类型数据字典
*/
@TableField("type")
@ApiModelProperty(value = "类型")
private String type;
/**
* 创建人
*/
@TableField(value = "create_id", fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建人")
private String createId;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建时间")
private Date createTime;

@ -3,6 +3,7 @@ package com.huoran.iasf.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@ -21,25 +22,34 @@ public class SysDept implements Serializable {
@TableId
private String id;
@ApiModelProperty(value = "部门编号(规则:父级关系编码+自己的编码)")
private String deptNo;
@NotBlank(message = "机构名称不能为空")
@ApiModelProperty(value = "部门名称")
private String name;
@NotBlank(message = "父级不能为空")
@ApiModelProperty(value = "父级id")
private String pid;
@TableField(exist = false)
@ApiModelProperty(value = "父级部门名称")
private String pidName;
@ApiModelProperty(value = "状态(1:正常;0:弃用)")
private Integer status;
@ApiModelProperty(value = "为了维护更深层级关系")
private String relationCode;
@ApiModelProperty(value = "部门经理user_id")
private String deptManagerId;
@ApiModelProperty(value = "部门经理名称")
private String managerName;
@ApiModelProperty(value = "部门经理联系电话")
private String phone;
@TableField(fill = FieldFill.INSERT)

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -27,24 +28,29 @@ public class SysFilesEntity extends BaseEntity implements Serializable {
* 主键
*/
@TableId("id")
@ApiModelProperty(value = "主键")
private String id;
/**
* URL地址
*/
@TableField("url")
@ApiModelProperty(value = "url地址")
private String url;
/**
* 创建时间
*/
@TableField(value = "create_date", fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建时间")
private Date createDate;
@TableField("file_name")
@ApiModelProperty(value = "文件名称")
private String fileName;
@TableField("file_path")
@ApiModelProperty(value = "文件路径")
private String filePath;

@ -3,6 +3,7 @@ package com.huoran.iasf.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@ -20,32 +21,37 @@ import java.util.Date;
@Data
public class SysPermission implements Serializable {
@TableId
private String id;
@NotBlank(message = "菜单权限名称不能为空")
@ApiModelProperty(value = "菜单权限名称")
private String name;
@ApiModelProperty(value = "授权(多个用逗号分隔,如:sys:user:add,sys:user:edit)")
private String perms;
@ApiModelProperty(value = "访问地址URL")
private String url;
@ApiModelProperty(value = "图标")
private String icon;
@ApiModelProperty(value = "a target属性:_self _blank")
private String target;
@NotNull(message = "所属菜单不能为空")
@ApiModelProperty(value = "父级菜单权限id")
private String pid;
@ApiModelProperty(value = "排序")
private Integer orderNum;
@NotNull(message = "菜单权限类型不能为空")
@ApiModelProperty(value = "菜单权限类型(1:目录;2:菜单;3:按钮)")
private Integer type;
/**
* 1正常 2禁用
*/
@ApiModelProperty(value = "状态1:正常 0:禁用")
private Integer status;
@TableField(fill = FieldFill.INSERT)
@ -58,6 +64,7 @@ public class SysPermission implements Serializable {
private Integer deleted;
@TableField(exist = false)
@ApiModelProperty(value = "父级菜单权限名称")
private String pidName;
}

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.huoran.iasf.vo.resp.DeptRespNodeVO;
import com.huoran.iasf.vo.resp.PermissionRespNode;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@ -29,38 +30,52 @@ public class SysRole extends BaseEntity implements Serializable {
private String id;
@NotBlank(message = "名称不能为空")
@ApiModelProperty(value = "角色名称")
private String name;
@ApiModelProperty(value = "角色描述")
private String description;
@ApiModelProperty(value = "状态(1:正常0:弃用)")
private Integer status;
@ApiModelProperty(value = "数据范围(1:所有 2:自定义 3: 本部门及以下部门 4:仅本部门")
private Integer dataScope;
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建时间")
private Date createTime;
@TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty(value = "更新时间")
private Date updateTime;
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "是否删除(1未删除;0已删除)")
private Integer deleted;
@TableField(exist = false)
@ApiModelProperty(value = "权限菜单")
private List<PermissionRespNode> permissionRespNodes;
@TableField(exist = false)
@ApiModelProperty(value = "部门列表")
private List<DeptRespNodeVO> deptRespNodes;
@TableField(exist = false)
/* @TableField(exist = false)
@ApiModelProperty(value = "开始时间")
private String startTime;
@TableField(exist = false)
private String endTime;
@ApiModelProperty(value = "结束时间")
private String endTime;*/
@TableField(exist = false)
@ApiModelProperty(value = "权限")
private List<String> permissions;
@TableField(exist = false)
@ApiModelProperty(value = "部门")
private List<String> depts;
}

@ -3,6 +3,7 @@ package com.huoran.iasf.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -22,67 +23,96 @@ import java.util.List;
@Data
public class SysUser extends BaseEntity implements Serializable {
@TableId
@ApiModelProperty(value = "用户id")
private String id;
@NotBlank(message = "账号不能为空")
@ApiModelProperty(value = "账户名称")
private String username;
@ApiModelProperty(value = "加密盐值")
private String salt;
@NotBlank(message = "密码不能为空")
@ApiModelProperty(value = "用户密码")
private String password;
@TableField(exist = false)
@ApiModelProperty(value = "旧密码")
private String oldPwd;
@TableField(exist = false)
@ApiModelProperty(value = "新密码")
private String newPwd;
@ApiModelProperty(value = "手机号码")
private String phone;
@ApiModelProperty(value = "部门id")
private String deptId;
@TableField(exist = false)
@ApiModelProperty(value = "部门名称")
private String deptName;
@TableField(exist = false)
@ApiModelProperty(value = "部门编号(规则:父级关系编码+自己的编码)")
private String deptNo;
@ApiModelProperty(value = "真实名称")
private String realName;
@ApiModelProperty(value = "昵称")
private String nickName;
@ApiModelProperty(value = "邮箱(唯一)")
private String email;
@ApiModelProperty(value = "账户状态(1.正常 0.锁定 )")
private Integer status;
@ApiModelProperty(value = "性别(1.男 2.女)")
private Integer sex;
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "是否删除(1未删除;0已删除)")
private Integer deleted;
@ApiModelProperty(value = "创建人")
private String createId;
@ApiModelProperty(value = "更新人")
private String updateId;
@ApiModelProperty(value = "创建来源(1.web 2.android 3.ios )")
private Integer createWhere;
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建时间")
private Date createTime;
@TableField(fill = FieldFill.INSERT_UPDATE)
@ApiModelProperty(value = "更新时间")
private Date updateTime;
@TableField(exist = false)
/* @TableField(exist = false)
@ApiModelProperty(value = "开始时间")
private String startTime;
@TableField(exist = false)
private String endTime;
@ApiModelProperty(value = "结束时间")
private String endTime;*/
@TableField(exist = false)
@ApiModelProperty(value = "角色id")
private List<String> roleIds;
@TableField(exist = false)
@ApiModelProperty("随机数")
// @NotNull(message = "随机数不能为空")
private String random;
@TableField(exist = false)
@ApiModelProperty(value = "验证码")
private String captcha;
}

@ -25,17 +25,17 @@ import java.util.Set;
@Service
public class HttpSessionService {
@Resource
private com.huoran.iasf.service.RedisService redisService;
private RedisService redisService;
@Resource
private com.huoran.iasf.service.UserRoleService userRoleService;
private UserRoleService userRoleService;
@Resource
private com.huoran.iasf.service.RolePermissionService rolePermissionService;
private RolePermissionService rolePermissionService;
@Resource
private HttpServletRequest request;
@Resource
private com.huoran.iasf.service.PermissionService permissionService;
private PermissionService permissionService;
@Resource
private com.huoran.iasf.service.RoleService roleService;
private RoleService roleService;
@Value("${spring.redis.key.prefix.userToken}")
private String userTokenPrefix;

@ -1,3 +1,4 @@
/*
package com.huoran.iasf.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -16,13 +17,15 @@ import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
*/
/**
* 定时任务 服务类
*
* @author cheney
* @version V1.0
* @date 2022年7月28日
*/
*//*
@Service("sysJobService")
public class SysJobServiceImpl extends ServiceImpl<SysJobMapper, SysJobEntity> implements SysJobService {
@Resource
@ -30,9 +33,11 @@ public class SysJobServiceImpl extends ServiceImpl<SysJobMapper, SysJobEntity> i
@Resource
private SysJobMapper sysJobMapper;
/**
*/
/**
* 项目启动时初始化定时器
*/
*//*
@PostConstruct
public void init() {
List<SysJobEntity> scheduleJobList = this.list();
@ -112,4 +117,4 @@ public class SysJobServiceImpl extends ServiceImpl<SysJobMapper, SysJobEntity> i
baseMapper.updateById(sysJobEntity);
});
}
}
}*/

@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huoran.iasf.common.exception.BusinessException;
import com.huoran.iasf.common.exception.code.BaseResponseCode;
@ -51,6 +50,9 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
@Resource
private HttpSessionService httpSessionService;
@Resource
private RedisService redisService;
@Value("${spring.redis.allowMultipleLogin}")
private Boolean allowMultipleLogin;
@Value("${spring.profiles.active}")
@ -70,6 +72,8 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
@Override
public LoginRespVO login(SysUser vo) {
//验证码校验
check(vo.getRandom(), vo.getCaptcha());
SysUser sysUser = sysUserMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, vo.getUsername()));
if (null == sysUser) {
throw new BusinessException(BaseResponseCode.NOT_ACCOUNT);
@ -100,6 +104,26 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
return respVO;
}
/**
* 校验验证码
*
* @param random 随机数
* @param code 验证码
* @return boolean
*/
public void check(String random, String code) {
String value = redisService.get(random);
//验证码已过期
if (StringUtils.isEmpty(value)) {
throw new BusinessException(10004, "验证码已过期");
}
//验证码错误
if (!code.equals(value)) {
throw new BusinessException(10005, "验证码错误");
}
redisService.del(random);
}
@Override
public void updateUserInfo(SysUser vo) {
@ -161,12 +185,12 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
if (!StringUtils.isEmpty(vo.getUsername())) {
queryWrapper.like(SysUser::getUsername, vo.getUsername());
}
if (!StringUtils.isEmpty(vo.getStartTime())) {
/* if (!StringUtils.isEmpty(vo.getStartTime())) {
queryWrapper.gt(SysUser::getCreateTime, vo.getStartTime());
}
if (!StringUtils.isEmpty(vo.getEndTime())) {
queryWrapper.lt(SysUser::getCreateTime, vo.getEndTime());
}
}*/
if (!StringUtils.isEmpty(vo.getNickName())) {
queryWrapper.like(SysUser::getNickName, vo.getNickName());
}
@ -220,9 +244,9 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
if (sysUser == null) {
throw new BusinessException(BaseResponseCode.DATA_ERROR);
}
if ("test".equals(env) && "guest".equals(sysUser.getUsername())) {
/* if ("test".equals(env) && "guest".equals(sysUser.getUsername())) {
throw new BusinessException("演示环境禁止修改演示账号密码");
}
}*/
if (!PasswordUtils.matches(sysUser.getSalt(), vo.getOldPwd(), sysUser.getPassword())) {
throw new BusinessException(BaseResponseCode.OLD_PASSWORD_ERROR);

@ -16,9 +16,11 @@ import java.util.List;
*/
@Data
public class UserRoleOperationReqVO {
@ApiModelProperty(value = "用户id")
@NotBlank(message = "用户id不能为空")
private String userId;
@ApiModelProperty(value = "角色id集合")
@NotEmpty(message = "角色id集合不能为空")
private List<String> roleIds;

Loading…
Cancel
Save