Compare commits

..

No commits in common. "c48769872dddb2e41703975c37a76f8282f7d427" and "52798ce478c49fec9167a75a12b80885020aefbc" have entirely different histories.

View File

@ -18,7 +18,6 @@ import org.jeecg.modules.gen.userinfo.entity.UserInfo;
import org.jeecg.modules.gen.userinfo.mapper.UserInfoMapper;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.*;
import org.jeecg.common.system.vo.DictModel;
import java.util.LinkedHashMap;
import java.util.List;
@ -34,7 +33,6 @@ import org.jeecg.common.util.PasswordUtil;
import org.jeecg.common.util.RedisUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.BeanUtils;
import org.jeecg.common.system.api.ISysBaseAPI;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -54,8 +52,6 @@ public class UserBizController {
private UserBizService userBizService;
@Autowired
private UserInfoMapper userInfoMapper;
@Autowired
private ISysBaseAPI sysBaseApi;
@PostMapping("/login")
@Operation(summary = "用户登录")
@ -70,10 +66,10 @@ public class UserBizController {
// step.2 校验用户是否存在且有效
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysUser::getUsername, username);
queryWrapper.eq(SysUser::getUsername,username);
SysUser sysUser = sysUserService.getOne(queryWrapper);
Result<?> checkResult = sysUserService.checkUserIsEffective(sysUser);
if (!checkResult.isSuccess()) {
if(!checkResult.isSuccess()) {
return result.error500(checkResult.getMessage());
}
@ -88,7 +84,7 @@ public class UserBizController {
// step.4 登录成功获取用户信息
JSONObject obj = new JSONObject(new LinkedHashMap<>());
// 1.生成token
//1.生成token
String token = JwtUtil.sign(username, syspassword);
// 设置token缓存有效时间
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
@ -122,14 +118,13 @@ public class UserBizController {
/**
* 记录登录失败次数
*
* @param username
*/
private void addLoginFailOvertimes(String username) {
private void addLoginFailOvertimes(String username){
String key = CommonConstant.LOGIN_FAIL + username;
Object failTime = redisUtil.get(key);
Integer val = 0;
if (failTime != null) {
if(failTime!=null){
val = Integer.parseInt(failTime.toString());
}
// 10分钟一分钟为60s
@ -166,7 +161,8 @@ public class UserBizController {
// 4. 根据用户ID查询user_info表信息
UserInfo userInfo = userInfoMapper.selectOne(
new QueryWrapper<UserInfo>().eq("user_id", sysUser.getId()));
new QueryWrapper<UserInfo>().eq("user_id", sysUser.getId())
);
// 5. 构建返回结果
UserInfoResponse response = new UserInfoResponse();
@ -190,15 +186,4 @@ public class UserBizController {
return Result.error(500, "查询用户信息失败:" + e.getMessage());
}
}
@GetMapping("/schools")
@Operation(summary = "查询学校列表")
@IgnoreAuth
public Result<List<String>> querySchools() {
List<DictModel> list = sysBaseApi.getDictItems("school_list");
List<String> schools = list.stream()
.map(d -> d.getLabel())
.collect(Collectors.toList());
return Result.OK(schools);
}
}