Commit bcf72378 authored by 技术部-任文超's avatar 技术部-任文超

魔法值修复---第三批

parent 7bcf3b72
......@@ -25,7 +25,11 @@ public interface Constants {
Long VERIFICATION_CODE_FINITE_COUNT = 3L;
String X_AUTH_TOKEN = "x-auth-token";
int VERIFICATION_LEN = 2;
int SMS_CODE_LEN_4 = 4;
int SMS_CODE_LEN_6 = 6;
int TOKEN_LENGTH = 36;
int MD5_LENGTH = 32;
int THOUSAND_SECOND = 1000;
int MILLIS_PER_SECOND = 1000;
int MILLIS_OF_TEN_SECOND = 10000;
......
......@@ -225,7 +225,7 @@ public class UserController implements IBaseController {
byte[] buf = Base64.decodeBase64(credential);
credential = new String(buf, Charset.forName("UTF-8"));
String[] credentialArr = credential.split(Constants.SPLIT_CHAR);
if (credentialArr.length != 2) {
if (credentialArr.length != Constants.VERIFICATION_LEN) {
result.put(Constants.CHECK_FAIL, JsonResult.buildErrorStateResult("登录失败", null));
return result;
}
......
......@@ -338,7 +338,7 @@ public class WeChatController implements IBaseController {
LOGGER.info("微信登录:redirect不为null,创建session跳到指定前端页面.");
AuthBean authBean = sessionService.createSession(user, loginProperties);
LOGGER.info("微信登录:跳转地址{}", domain + "/weixin/callback?phoneNo=" + user.getPhoneNo() + "&token=" + authBean.getToken());
Long channelId = "baitiao".equals(merchant.getName()) ? 222L : 1L;
Long channelId = "baitiao".equals(merchant.getName()) ? Constants.Channel.BAITIAO : 1L;
String target = "baitiao".equals(merchant.getName()) ? "cashTarget5" : "cashTarget4";
return domain + "/landing?token=" + authBean.getToken() + "&registerFrom=" + registerFrom +
"&channelId=" + channelId + "&key=" + merchant.getName() + "&target=" + target + "&isWechat=true";
......
......@@ -147,7 +147,7 @@ public class InnerController implements IBaseController {
if (md5Value == null) {
return JsonResult.buildErrorStateResult("参数错误", null);
}
if (md5Value.length() != 32) {
if (md5Value.length() != Constants.MD5_LENGTH) {
return JsonResult.buildErrorStateResult("参数长度有误", null);
}
......
......@@ -41,15 +41,15 @@ public class UserApiController {
private ISmsService smsService;
@RequestMapping("/user/is_passwd_set")
public JsonResult isPasswordSet(String key, String phoneNo) {
if (!"abc1234".equals(key) || StringUtils.isEmpty(phoneNo)) {
public JsonResult isPasswordSet(String phoneNo) {
if (StringUtils.isEmpty(phoneNo)) {
return JsonResult.buildErrorStateResult(null, null);
}
User user = userService.findByPhoneWithCache(phoneNo);
if (null == user) {
return JsonResult.buildErrorStateResult(null, null);
}
if (StringUtils.length(user.getPassword()) == 32) {
if (StringUtils.length(user.getPassword()) == Constants.MD5_LENGTH) {
return JsonResult.buildSuccessResult(null, null);
}
return JsonResult.buildErrorStateResult(null, null, 2L);
......
......@@ -3,6 +3,7 @@ package cn.quantgroup.xyqb.model;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import lombok.Data;
import org.springframework.util.Assert;
import java.io.Serializable;
......@@ -25,7 +26,7 @@ public class UserInfo implements Serializable {
private String IdNo;
public UserInfo(User user, UserDetail userDetail) {
assert user != null;
Assert.notNull(user, "User信息无效");
this.id = user.getId();
this.phoneNo = user.getPhoneNo();
this.registerFrom = user.getRegisteredFrom();
......
......@@ -3,6 +3,7 @@ package cn.quantgroup.xyqb.model;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import lombok.Data;
import org.springframework.util.Assert;
import java.io.Serializable;
import java.util.Optional;
......@@ -35,7 +36,7 @@ public class UserModel implements Serializable {
}
public UserModel(User user, UserDetail userDetail) {
assert user != null;
Assert.notNull(user, "User信息无效");
this.id = user.getId();
this.phoneNo = user.getPhoneNo();
this.registerFrom = user.getRegisteredFrom();
......
......@@ -54,7 +54,7 @@ public interface IWeChatUserRepository extends JpaRepository<WechatUserInfo, Lon
* @param userId - 用户标识
* @return 记录更新行数
*/
@Transactional(propagation = MANDATORY)
@Transactional(propagation = MANDATORY, rollbackFor = Exception.class)
@Modifying
@Query(value = "update wechat_userinfo set user_id=null,phone_no='*' where open_id=?1 or user_id=?2", nativeQuery = true)
int dissociateUser(String openId, Long userId);
......
......@@ -23,8 +23,6 @@ import java.util.Objects;
*/
@Slf4j
public class GeetestLib {
protected static final int SUCCESS_CHALLENGE_LENGTH = 32;
protected final String verName = "4.0";
private String apiUrl;
......@@ -162,7 +160,7 @@ public class GeetestLib {
gtlog("return_challenge:" + return_challenge);
if (return_challenge.length() == SUCCESS_CHALLENGE_LENGTH) {
if (return_challenge.length() == Constants.MD5_LENGTH) {
this.responseStr = this.getSuccessPreProcessRes(this.md5Encode(return_challenge + this.privateKey));
......
......@@ -69,7 +69,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
registerFrom = 1L;
}
Long channelId = userRegisterParam.getChannelId();
if (Objects.equals(channelId, 222L)) {
if (Objects.equals(channelId, Constants.Channel.BAITIAO)) {
user.setRegisteredFrom(channelId);
} else {
user.setRegisteredFrom(registerFrom);
......
......@@ -8,8 +8,6 @@ import cn.quantgroup.xyqb.service.sms.ISmsService;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
......@@ -26,11 +24,6 @@ import java.util.Collections;
@Service
@Slf4j
public class SmsServiceImpl implements ISmsService {
private static final Logger LOGGER = LoggerFactory.getLogger(SmsServiceImpl.class);
private static final int SMS_VERIFICATION_MAXLEN = 4;
private static final String SMS_VERIFY_PREFIX = "sms:verify:";
private static SmsSender smsSender = null;
@Value("${sms.is.debug}")
......@@ -98,7 +91,7 @@ public class SmsServiceImpl implements ISmsService {
return false;
}
String[] arr = randomCode.split(":");
if (arr.length != 2) {
if (arr.length != Constants.VERIFICATION_LEN) {
return false;
}
String uniqueId = arr[0];
......
......@@ -50,7 +50,8 @@ public class Jdk8Test {
@Test
public void random() {
for(int i=0; i<10; i++){
int count = 10;
for(int i=0; i<count; i++){
log.info("{}-random:{}", i, RandomStringUtils.random(6, RANDOM_CHARS));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment