Selaa lähdekoodia

Merge remote-tracking branch 'remotes/origin/developer' into developerA

chao 4 vuotta sitten
vanhempi
commit
75cfb8afc1

+ 7 - 0
src/main/java/com/caimei365/user/components/CommonService.java

@@ -6,6 +6,7 @@ import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.utils.ValidateUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -25,6 +26,8 @@ public class CommonService {
     private BaseMapper baseMapper;
     @Resource
     private LoginMapper loginMapper;
+    @Value("${spring.cloud.config.profile}")
+    private String profile;
     /**
      * 校验邮箱
      * @param email 邮箱
@@ -51,6 +54,10 @@ public class CommonService {
         if (result != null) {return result;}
         if (StringUtils.isNotBlank(smsCode)){
             String redisSmsCode = (String) redisService.get("code:" + mobile);
+            // 开发 和 测试环境 固定短信验证码 666666
+            if ("dev".equals(profile) || "beta".equals(profile)){
+                redisSmsCode = (null != redisSmsCode && !"null".equals(redisSmsCode) ? redisSmsCode : "666666");
+            }
             if (!redisSmsCode.equals(smsCode)) {
                 return "手机验证码错误";
             }

+ 23 - 2
src/main/java/com/caimei365/user/service/impl/BaseServiceImpl.java

@@ -10,6 +10,7 @@ import com.caimei365.user.utils.ImageCaptchaUtil;
 import com.caimei365.user.utils.ValidateUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -31,6 +32,8 @@ public class BaseServiceImpl implements BaseService {
     private RedisService redisService;
     @Resource
     private BaseMapper baseMapper;
+    @Value("${spring.cloud.config.profile}")
+    private String profile;
 
     /**
      * 获取图片验证码
@@ -39,6 +42,7 @@ public class BaseServiceImpl implements BaseService {
      */
     @Override
     public ResponseJson<Map<String, Object>> getCaptchaImage(Integer platformType) {
+        log.info(profile);
         Map<String, Object> result = new HashMap<>(2);
         try {
             ImageCaptchaUtil.Captcha captcha = null;
@@ -103,8 +107,17 @@ public class BaseServiceImpl implements BaseService {
         // 验证手机号
         String result = ValidateUtil.validateMobile(mobile);
         if (result != null) {return ResponseJson.error(result);}
+        if (StringUtils.isNotBlank(profile)) {
+            // 开发 和 测试环境 固定短信验证码 666666
+            if("dev".equals(profile) || "beta".equals(profile)){
+                redisService.set("code:"+mobile, "666666", 1800L);
+                String codeType = activateCodeType == 1 ? "找回密码" : (activateCodeType == 2 ? "注册机构" : "注册供应商");
+                log.info(codeType + ",发送到:" + mobile + "的短信验证码("+ profile +")为: 666666");
+                return ResponseJson.success("发送验证码成功");
+            }
+        }
         // 检查图片验证码
-        if (null != isCheckCaptcha && isCheckCaptcha != 1){
+        if (null == isCheckCaptcha || 0 == isCheckCaptcha){
             Boolean checkFlag = checkCaptchaImage(token, imgCode, platformType);
             if (!checkFlag) {
                 return ResponseJson.error("图片验证码错误");
@@ -160,8 +173,16 @@ public class BaseServiceImpl implements BaseService {
         // 验证手机号
         String result = ValidateUtil.validateMobile(mobile);
         if (result != null) {return ResponseJson.error(result);}
+        if (StringUtils.isNotBlank(profile)) {
+            // 开发 和 测试环境 固定短信验证码 666666
+            if("dev".equals(profile) || "beta".equals(profile)){
+                redisService.set("code:"+mobile, "666666", 1800L);
+                log.info("绑定账号,发送到:" + mobile + "的短信验证码("+ profile +")为: 666666");
+                return ResponseJson.success("发送验证码成功");
+            }
+        }
         // 检查图片验证码
-        if (null != isCheckCaptcha && isCheckCaptcha != 1){
+        if (null == isCheckCaptcha || 0 == isCheckCaptcha){
             Boolean checkFlag = checkCaptchaImage(token, imgCode, platformType);
             if (!checkFlag) {
                 return ResponseJson.error("图片验证码错误");

+ 2 - 1
src/main/resources/bootstrap.yml

@@ -9,5 +9,6 @@ spring:
     config:                             # Config客户端配置
       profile: @activatedProperties@    # 启用配置后缀名称
       label: master                     # 分支名称
-      uri: http://120.79.162.1:18001          # 配置中心地址
+      # uri: http://47.119.112.46:18001       # 配置中心地址(开发中)
+      uri: http://120.79.162.1:18001          # 配置中心地址(正式环境)
       name: user                        # 配置文件名称