修改请求接口无需token

This commit is contained in:
cys841515238
2023-03-03 10:51:56 +08:00
parent a6602f9755
commit 4e7aec5b60
3 changed files with 50 additions and 4 deletions

View File

@@ -67,7 +67,8 @@ public class ShiroConfig {
filterMap.put("/swagger-resources/**", "anon"); filterMap.put("/swagger-resources/**", "anon");
filterMap.put("/captcha.jpg", "anon"); filterMap.put("/captcha.jpg", "anon");
filterMap.put("/aaa.txt", "anon"); filterMap.put("/aaa.txt", "anon");
filterMap.put("/**", "oauth2"); filterMap.put("/**", "anon");
shiroFilter.setFilterChainDefinitionMap(filterMap); shiroFilter.setFilterChainDefinitionMap(filterMap);
return shiroFilter; return shiroFilter;

View File

@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.druid.util.StringUtils; import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@@ -155,7 +156,37 @@ public class MyUserController {
return R.ok(); return R.ok();
} }
@RequestMapping("/register")
public R register(@RequestParam("tel") String tel,
@RequestParam("code") String code,
@RequestParam("password") String password){
String redisCode = redisTemplate.opsForValue().get("RegistCode" + tel);
System.out.println(redisCode);
if (StringUtils.isEmpty(redisCode)){
return R.error(500,"短信验证码已过期,请重试");
}
String lcode = redisCode.split("_")[0];
if (!lcode.equals(code)) {
return R.error(500,"短信验证码不符!");
}
MyUserEntity user = userService.getBaseMapper().selectOne(new QueryWrapper<MyUserEntity>().eq("tel", tel));
if(!ObjectUtil.isEmpty(user)){
return R.error(500,"该手机号已经注册!");
}
String saltMD5 = MD5Utils.getSaltMD5(password);
MyUserEntity myUserEntity = new MyUserEntity();
myUserEntity.setTel(tel);
myUserEntity.setPassword(saltMD5);
userService.save(myUserEntity);
R r = sysUserTokenService.createToken(myUserEntity.getId());
return R.ok("注册成功").put("userInfo",myUserEntity).put("token",r);
}
/** /**
* 常规注册 / 验证码 登录 * 常规注册 / 验证码 登录
*/ */
@@ -229,7 +260,22 @@ public class MyUserController {
*/ */
@RequestMapping("/setPassword") @RequestMapping("/setPassword")
public R setPassword(@RequestParam("phone") String phone, public R setPassword(@RequestParam("phone") String phone,
@RequestParam("password") String password) { @RequestParam("password") String password,
@RequestParam("code") String code) {
String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone);
System.out.println(redisCode);
if (StringUtils.isEmpty(redisCode)){
return R.error(500,"短信验证码已过期,请重试");
}
String lcode = redisCode.split("_")[0];
if (!lcode.equals(code)) {
return R.error(500,"短信验证码不符!");
}
//查询是否存在当前用户手机号 //查询是否存在当前用户手机号
MyUserEntity userEntity = userService.getBaseMapper().selectOne(new QueryWrapper<MyUserEntity>().eq("tel", phone)); MyUserEntity userEntity = userService.getBaseMapper().selectOne(new QueryWrapper<MyUserEntity>().eq("tel", phone));

View File

@@ -5,10 +5,9 @@ server:
max-threads: 1000 max-threads: 1000
min-spare-threads: 30 min-spare-threads: 30
port: 9100 port: 9100
connection-timeout: 6000000ms
servlet: servlet:
context-path: /pb context-path: /pb
connection-timeout: 6000000ms
spring: spring:
# 环境 dev|test|prod # 环境 dev|test|prod
profiles: profiles: