Merge branch 'master' of http://gitea.yxtsoft.com/yxt_group/mallplus
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.zscat.mallplus.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
/**
|
||||
* @Author dimengzhe
|
||||
@@ -13,6 +14,12 @@ public class SmsEnum {
|
||||
*/
|
||||
public static final Long APP_LOGIN_CODE_TIME_LIMIT = 300L;
|
||||
|
||||
@Value("${redis.key.prefix.loginCode}")
|
||||
private static String REDIS_KEY_PREFIX_LOGIN_CODE;
|
||||
|
||||
@Value("${redis.key.prefix.forgetCode}")
|
||||
private static String REDIS_KEY_PREFIX_FORGET_CODE;
|
||||
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
@@ -22,9 +29,11 @@ public class SmsEnum {
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
LOGIN("1", "loginCode","登录"),
|
||||
LOGIN("1", REDIS_KEY_PREFIX_LOGIN_CODE,"登录"),
|
||||
FORGET("2", REDIS_KEY_PREFIX_FORGET_CODE,"忘记密码"),
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
* code值
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@ import javax.xml.namespace.QName;
|
||||
*/
|
||||
public class SmsConfig {
|
||||
|
||||
static String msgSign="【汇融银链】";
|
||||
static String msgSign="【汇融云链】";
|
||||
public static String SendWaitWorkMsg(String mobile, String pwd,String msg) {
|
||||
try {
|
||||
|
||||
|
||||
@@ -65,6 +65,11 @@ import java.util.Map;
|
||||
@RequestMapping("/api/single/home")
|
||||
public class SingelHomeController {
|
||||
|
||||
@Value("${redis.key.prefix.loginCode}")
|
||||
private String REDIS_KEY_PREFIX_LOGIN_CODE;
|
||||
|
||||
@Value("${redis.key.prefix.forgetCode}")
|
||||
private String REDIS_KEY_PREFIX_FORGET_CODE;
|
||||
@Autowired
|
||||
OssAliyunUtil aliyunOSSUtil;
|
||||
@Value("${jwt.tokenHeader}")
|
||||
@@ -341,8 +346,7 @@ public class SingelHomeController {
|
||||
@ApiOperation(value = "手机号 密码登录")
|
||||
@PostMapping(value = "/login")
|
||||
public Object login(@RequestParam("phone") String phone,
|
||||
@RequestParam("password") String password,
|
||||
@RequestParam(value = "type",required = false)String type) {
|
||||
@RequestParam("password") String password) {
|
||||
if (phone == null || "".equals(phone)) {
|
||||
return new CommonResult().validateFailed("用户名或密码错误");
|
||||
}
|
||||
@@ -378,7 +382,6 @@ public class SingelHomeController {
|
||||
return new CommonResult().validateFailed("手机验证码为空");
|
||||
}
|
||||
try {
|
||||
|
||||
Map<String, Object> token = memberService.loginByCode(phone, authCode);
|
||||
if (token.get("token") == null) {
|
||||
return new CommonResult().validateFailed("用户名或密码错误");
|
||||
@@ -443,7 +446,7 @@ public class SingelHomeController {
|
||||
@IgnoreAuth
|
||||
@ApiOperation("获取验证码")
|
||||
@PostMapping(value = "/sms/codes")
|
||||
public Object sendSmsCode(@RequestParam("phone") String phone,@RequestParam("type")String type) {
|
||||
public Object sendSmsCode(@RequestParam("phone") String phone,@RequestParam(value = "type")String type) {
|
||||
try {
|
||||
if (!PhoneUtil.checkPhone(phone)) {
|
||||
throw new IllegalArgumentException("手机号格式不正确");
|
||||
@@ -454,7 +457,9 @@ public class SingelHomeController {
|
||||
//缓存识别码
|
||||
String redisKey = "";
|
||||
if(SmsEnum.SendEnum.LOGIN.getCode().equals(type)){
|
||||
redisKey = SmsEnum.SendEnum.LOGIN.getRedisKey();
|
||||
redisKey = REDIS_KEY_PREFIX_LOGIN_CODE;
|
||||
}else if(SmsEnum.SendEnum.FORGET.getCode().equals(type)){
|
||||
redisKey = REDIS_KEY_PREFIX_FORGET_CODE;
|
||||
}
|
||||
Date date = new Date();
|
||||
String codeRedis = redisService.get(redisKey + phone);
|
||||
|
||||
@@ -33,14 +33,4 @@ public interface RedisService {
|
||||
*/
|
||||
Long increment(String key, long delta);
|
||||
|
||||
/**
|
||||
* 写入缓存设置时效时间
|
||||
* @param key
|
||||
* @param value
|
||||
* @param expireTime
|
||||
* @return
|
||||
*/
|
||||
boolean set(final String key, Object value, Long expireTime);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -48,17 +48,4 @@ public class RedisServiceImpl implements RedisService {
|
||||
return stringRedisTemplate.opsForValue().increment(key, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(String key, Object value, Long expireTime) {
|
||||
boolean result = false;
|
||||
try {
|
||||
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
|
||||
operations.set(key, value);
|
||||
stringRedisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
|
||||
result = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.zscat.mallplus.enums.SmsEnum;
|
||||
import com.zscat.mallplus.exception.ApiMallPlusException;
|
||||
import com.zscat.mallplus.oms.mapper.OmsOrderMapper;
|
||||
import com.zscat.mallplus.oms.vo.OrderStstic;
|
||||
import com.zscat.mallplus.sys.entity.SysUserVo;
|
||||
import com.zscat.mallplus.sys.mapper.SysAreaMapper;
|
||||
import com.zscat.mallplus.ums.entity.*;
|
||||
import com.zscat.mallplus.ums.mapper.SysAppletSetMapper;
|
||||
@@ -110,6 +111,10 @@ public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
@Value("${redis.key.prefix.authCode}")
|
||||
private String REDIS_KEY_PREFIX_AUTH_CODE;
|
||||
@Value("${redis.key.prefix.loginCode}")
|
||||
private String REDIS_KEY_PREFIX_LOGIN_CODE;
|
||||
@Value("${redis.key.prefix.forgetCode}")
|
||||
private String REDIS_KEY_PREFIX_FORGET_CODE;
|
||||
@Value("${authCode.expire.seconds}")
|
||||
private Long AUTH_CODE_EXPIRE_SECONDS;
|
||||
@Value("${jwt.tokenHead}")
|
||||
@@ -448,7 +453,10 @@ public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember
|
||||
String redisKey = "";
|
||||
if (SmsEnum.SendEnum.LOGIN.getCode().equals(type)) {
|
||||
content = "验证码:" + code + ",用于登录App,有效期5分钟,如非本人操作,请忽略该短信。";
|
||||
redisKey = SmsEnum.SendEnum.LOGIN.getRedisKey();
|
||||
redisKey = REDIS_KEY_PREFIX_LOGIN_CODE;
|
||||
}else if (SmsEnum.SendEnum.FORGET.getCode().equals(type)){
|
||||
content = "验证码:" + code + ",用于修改登录密码,有效期5分钟,如非本人操作,请忽略该短信。";
|
||||
redisKey = REDIS_KEY_PREFIX_FORGET_CODE;
|
||||
}
|
||||
String result = SmsConfig.SendWaitWorkMsg(phone, code, content);
|
||||
if ("1".equals(result)) {
|
||||
@@ -457,7 +465,8 @@ public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember
|
||||
sms.setCode(sms.getCode());
|
||||
sms.setBizId(result);//返回的code
|
||||
sms.setMessage(resultMsg);
|
||||
redisService.set(redisKey + phone, code + date.getTime(), SmsEnum.APP_LOGIN_CODE_TIME_LIMIT);
|
||||
redisService.set(redisKey + phone, code + date.getTime());
|
||||
redisService.expire(redisKey + phone, SmsEnum.APP_LOGIN_CODE_TIME_LIMIT);
|
||||
log.info("发送短信结果:code:{},message:{}, 1,发送成功");
|
||||
}else{
|
||||
//返回的信息
|
||||
@@ -1207,15 +1216,20 @@ public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember
|
||||
String token = null;
|
||||
try {
|
||||
UserDetails userDetails = userDetailsService.loadUserByUsername(phone);
|
||||
|
||||
//验证验证码
|
||||
if (!verifyAuthCode(authCode, phone)) {
|
||||
/*if (!verifyAuthCode(authCode, phone)) {
|
||||
throw new ApiMallPlusException("验证码错误");
|
||||
}*/
|
||||
String codeFromRedis = redisService.get(REDIS_KEY_PREFIX_LOGIN_CODE+ phone);
|
||||
if (StringUtils.isBlank(codeFromRedis)){
|
||||
throw new ApiMallPlusException("短信验证码已失效,请重新发送");
|
||||
}
|
||||
if (!authCode.equals(codeFromRedis.substring(0, 4))) {
|
||||
throw new ApiMallPlusException("短信验证码错误或已失效,请重新获取");
|
||||
}
|
||||
UmsMember member = this.getByUsername(phone);
|
||||
if (member == null || member.getId() == null) {
|
||||
throw new ApiMallPlusException("用户不存在");
|
||||
|
||||
}
|
||||
Authentication authentication = new UsernamePasswordAuthenticationToken(
|
||||
userDetails, null, userDetails.getAuthorities());
|
||||
|
||||
@@ -3,11 +3,14 @@ spring.jackson.time-zone=GMT+8
|
||||
spring.profiles.active=test
|
||||
#spring.profiles.active=dev
|
||||
#===server start===
|
||||
server.port=8083
|
||||
#server.port=8083
|
||||
server.port=8111
|
||||
#===server end===
|
||||
|
||||
#===redis custom key start===
|
||||
redis.key.prefix.authCode=portal:authCode:
|
||||
redis.key.prefix.loginCode=portal:loginCode:
|
||||
redis.key.prefix.forgetCode=portal:forgetCode:
|
||||
redis.key.prefix.orderId=portal:orderId:
|
||||
authCode.expire.seconds=90
|
||||
#===redis custom key end===
|
||||
@@ -27,8 +30,8 @@ jwt.tokenHead=Bearer
|
||||
# \u963F\u91CC\u4E91\u77ED\u4FE1\u914D\u7F6E
|
||||
aliyun.sms.accessKeyId=LTAI4FhoMuUqdigjDnFT1bY6
|
||||
aliyun.sms.accessKeySecret=JvE9FcILlHu5gClmAJr89ZkEv00l9s
|
||||
aliyun.sms.sign.name=\u4EAC\u6021\u541B\u5546\u8D38
|
||||
aliyun.sms.template.code=SMS_164240312
|
||||
aliyun.sms.sign.name=YXT004911
|
||||
aliyun.sms.template.code=yyundong@yuxintong
|
||||
aliyun.sms.expire-minute=2
|
||||
aliyun.sms.day-count=45
|
||||
|
||||
|
||||
Reference in New Issue
Block a user