Antiloveg 8 lat temu
rodzic
commit
a5f87df91c

+ 10 - 36
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -20,19 +20,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import com.aliyuncs.DefaultAcsClient;
-import com.aliyuncs.IAcsClient;
-import com.aliyuncs.exceptions.ClientException;
-import com.aliyuncs.exceptions.ServerException;
-import com.aliyuncs.profile.DefaultProfile;
-import com.aliyuncs.profile.IClientProfile;
-import com.aliyuncs.sms.model.v20160927.SingleSendSmsRequest;
-import com.aliyuncs.sms.model.v20160927.SingleSendSmsResponse;
 import com.goafanti.admin.service.AftFileService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.service.IndustryCategoryService;
 import com.goafanti.common.utils.LoggerUtils;
+import com.goafanti.common.utils.MobileMessageUtils;
 import com.goafanti.common.utils.PictureUtils;
 import com.goafanti.common.utils.TimeUtils;
 import com.goafanti.common.utils.VerifyCodeUtils;
@@ -59,6 +52,9 @@ public class PublicController extends BaseController {
 	@Value(value = "${static.host}")
 	private String					staticHost			= null;
 
+	@Value(value = "${mobileCodeTemplate}")
+	private String					mobileCodeTemplate	= null;
+
 	@Resource
 	private UserService				userService;
 
@@ -155,36 +151,14 @@ public class PublicController extends BaseController {
 	 * @param res
 	 * @return
 	 */
-	@SuppressWarnings("unused")
 	private Result sendMessage(String mobile, Result res) {
-		// 生成随机字串
-		String mobileVerifyCode = VerifyCodeUtils.generateMobileVerifyCode(6);
-		// 存入Shiro会话session
-		TokenManager.setVal2Session(VerifyCodeUtils.M_CODE, mobileVerifyCode);
+		String mobileVerifyCode = VerifyCodeUtils.generateMobileVerifyCode(6); // 生成随机字串
+		TokenManager.setVal2Session(VerifyCodeUtils.M_CODE, mobileVerifyCode);// 存入Shiro会话session
 		TokenManager.setVal2Session(VerifyCodeUtils.M_CODE_TIME, System.currentTimeMillis());
-		IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKey, accessSecret);
-		try {
-			DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", "Sms", "sms.aliyuncs.com");
-		} catch (ClientException e1) {
-			res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "获取手机验证码异常"));
-			return res;
-		}
-		IAcsClient client = new DefaultAcsClient(profile);
-		SingleSendSmsRequest request = new SingleSendSmsRequest();
-		try {
-			request.setSignName("阿凡提信息科技");// {\"code\":\""+mobileVerifyCode+"\"}
-			request.setTemplateCode("SMS_37845022");
-			request.setParamString("{\"code\":\"" + mobileVerifyCode + "\",\"product\":\"阿凡提信息科技\"}");
-			request.setRecNum(mobile);
-			SingleSendSmsResponse httpResponse = client.getAcsResponse(request);
-		} catch (ServerException e) {
-			res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "获取手机验证码异常"));
-			LoggerUtils.fmtError(getClass(), e, "服务器端手机验证码异常:%s", e.getMessage());
-			return res;
-		} catch (ClientException e) {
-			res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "获取手机验证码异常"));
-			LoggerUtils.fmtError(getClass(), e, "客户端手机验证码异常:%s", e.getMessage());
-			return res;
+		String paramString = "{\"code\":\"" + mobileVerifyCode + "\",\"product\":\"阿凡提信息科技\"}";
+		String ret = MobileMessageUtils.sendMessage(mobileCodeTemplate, paramString, mobile, accessKey, accessSecret);
+		if (StringUtils.isNotBlank(ret)) {
+			res.getError().add(buildError("", "获取手机验证码异常!"));
 		}
 		return res;
 	}

+ 1 - 1
src/main/java/com/goafanti/common/task/PatentTask.java

@@ -69,7 +69,7 @@ public class PatentTask {
 						&& null != p.getPatentApplicationDate()) {
 					try {
 						if (disposeExprire(p, now)) {
-							//sendMessage(p);
+							sendMessage(p);
 						}
 					} catch (ParseException e) {
 					}

+ 49 - 0
src/main/java/com/goafanti/common/utils/MobileMessageUtils.java

@@ -0,0 +1,49 @@
+package com.goafanti.common.utils;
+
+
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.exceptions.ServerException;
+import com.aliyuncs.profile.DefaultProfile;
+import com.aliyuncs.profile.IClientProfile;
+import com.aliyuncs.sms.model.v20160927.SingleSendSmsRequest;
+import com.aliyuncs.sms.model.v20160927.SingleSendSmsResponse;
+import com.goafanti.common.constant.ErrorConstants;
+
+public class MobileMessageUtils {
+	
+	private final static String SIGN_NAME = "阿凡提信息科技";
+	
+	private final static String SERVER_EXCEPTION = "服务器端手机验证码异常:%s";
+	
+	private final static String CLIENT_EXCEPTION = "客户端手机验证码异常:%s";
+
+	@SuppressWarnings("unused")
+	public static String sendMessage(String templateCode, String paramString, String mobile, String accessKey, String accessSecret) {
+		IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKey, accessSecret);
+		try {
+			DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", "Sms", "sms.aliyuncs.com");
+		} catch (ClientException e1) {
+			LoggerUtils.fmtError(MobileMessageUtils.class, e1, CLIENT_EXCEPTION, e1.getMessage());
+			return ErrorConstants.MCODE_ERROR;
+		}
+		IAcsClient client = new DefaultAcsClient(profile);
+		SingleSendSmsRequest request = new SingleSendSmsRequest();
+		try {
+			request.setSignName(SIGN_NAME);
+			request.setTemplateCode(templateCode);
+			request.setParamString(paramString);
+			request.setRecNum(mobile);
+			SingleSendSmsResponse httpResponse = client.getAcsResponse(request);
+		} catch (ServerException e) {
+			LoggerUtils.fmtError(MobileMessageUtils.class, e, SERVER_EXCEPTION, e.getMessage());
+			return ErrorConstants.MCODE_ERROR;
+		} catch (ClientException e) {
+			LoggerUtils.fmtError(MobileMessageUtils.class, e, CLIENT_EXCEPTION, e.getMessage());
+			return ErrorConstants.MCODE_ERROR;
+		}
+		return null;
+	}
+
+}

+ 3 - 1
src/main/resources/props/config_dev.properties

@@ -63,4 +63,6 @@ avatar.host=//afts.hnzhiming.com
 
 aesSecretKey=aft1234567890123
 
-template.cacheable=false
+template.cacheable=false
+
+mobileCodeTemplate=SMS_37845022

+ 2 - 0
src/main/resources/props/config_local.properties

@@ -66,3 +66,5 @@ avatar.host=//afts.hnzhiming.com
 aesSecretKey=aft1234567890123
 
 template.cacheable=false
+
+mobileCodeTemplate=SMS_37845022

+ 2 - 0
src/main/resources/props/config_prod.properties

@@ -54,3 +54,5 @@ app.name=AFT
 static.host=//afts.hnzhiming.com/1.0.28
 
 template.cacheable=true
+
+mobileCodeTemplate=SMS_37845022

+ 3 - 1
src/main/resources/props/config_test.properties

@@ -65,4 +65,6 @@ avatar.host=//aftts.hnzhiming.com
 
 aesSecretKey =aft1234567890123
 
-template.cacheable=true
+template.cacheable=true
+
+mobileCodeTemplate=SMS_37845022

+ 39 - 37
src/main/resources/props/error.properties

@@ -1,62 +1,64 @@
-org.apache.shiro.authc.UnknownAccountException=\u8D26\u53F7\u6216\u5BC6\u7801\u4E0D\u5339\u914D\u3002
-org.apache.shiro.authc.IncorrectCredentialsException=\u8D26\u53F7\u6216\u5BC6\u7801\u4E0D\u5339\u914D\u3002
-org.apache.shiro.authc.LockedAccountException=\u8BE5\u8D26\u53F7\u5DF2\u51BB\u7ED3\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002
-org.apache.shiro.authc.DisabledAccountException=\u8BE5\u8D26\u53F7\u5DF2\u51BB\u7ED3\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002
-org.apache.shiro.authc.ExcessiveAttemptsException=\u5C1D\u8BD5\u6B21\u6570\u8FC7\u591A\uFF0C\u8D26\u53F7\u6682\u65F6\u88AB\u9501\u5B9A\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002
-org.apache.shiro.session.ExpiredSessionException=\u767B\u5F55\u4FE1\u606F\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002
-org.springframework.dao.DataIntegrityViolationException=\u670D\u52A1\u5668\u6253\u4E86\u4E2A\u76F9\u513F\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6216\u7A0D\u540E\u518D\u8BD5\u3002
-org.springframework.jdbc.BadSqlGrammarException=\u6570\u636E\u5F02\u5E38\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6216\u7A0D\u540E\u518D\u8BD5\u3002
-java.text.ParseException=\u53C2\u6570\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u6838\u5BF9\u8F93\u5165\u6570\u636E\u540E\u518D\u8BD5\u3002
-java.lang.IllegalArgumentException=\u53C2\u6570\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u6838\u5BF9\u8F93\u5165\u6570\u636E\u540E\u518D\u8BD5\u3002
-com.alibaba.fastjson.JSONException=\u53C2\u6570\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u6838\u5BF9\u8F93\u5165\u6570\u636E\u540E\u518D\u8BD5\u3002
+org.apache.shiro.authc.UnknownAccountException=\u8d26\u53f7\u6216\u5bc6\u7801\u4e0d\u5339\u914d\u3002
+org.apache.shiro.authc.IncorrectCredentialsException=\u8d26\u53f7\u6216\u5bc6\u7801\u4e0d\u5339\u914d\u3002
+org.apache.shiro.authc.LockedAccountException=\u8be5\u8d26\u53f7\u5df2\u51bb\u7ed3\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u3002
+org.apache.shiro.authc.DisabledAccountException=\u8be5\u8d26\u53f7\u5df2\u51bb\u7ed3\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u3002
+org.apache.shiro.authc.ExcessiveAttemptsException=\u5c1d\u8bd5\u6b21\u6570\u8fc7\u591a\uff0c\u8d26\u53f7\u6682\u65f6\u88ab\u9501\u5b9a\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\u3002
+org.apache.shiro.session.ExpiredSessionException=\u767b\u5f55\u4fe1\u606f\u5df2\u8fc7\u671f\uff0c\u8bf7\u91cd\u65b0\u767b\u5f55\u3002
+org.springframework.dao.DataIntegrityViolationException=\u670d\u52a1\u5668\u6253\u4e86\u4e2a\u76f9\u513f\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u6216\u7a0d\u540e\u518d\u8bd5\u3002
+org.springframework.jdbc.BadSqlGrammarException=\u6570\u636e\u5f02\u5e38\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u6216\u7a0d\u540e\u518d\u8bd5\u3002
+java.text.ParseException=\u53c2\u6570\u683c\u5f0f\u9519\u8bef\uff0c\u8bf7\u6838\u5bf9\u8f93\u5165\u6570\u636e\u540e\u518d\u8bd5\u3002
+java.lang.IllegalArgumentException=\u53c2\u6570\u683c\u5f0f\u9519\u8bef\uff0c\u8bf7\u6838\u5bf9\u8f93\u5165\u6570\u636e\u540e\u518d\u8bd5\u3002
+com.alibaba.fastjson.JSONException=\u53c2\u6570\u683c\u5f0f\u9519\u8bef\uff0c\u8bf7\u6838\u5bf9\u8f93\u5165\u6570\u636e\u540e\u518d\u8bd5\u3002
 
 
-NON_LOGIN=\u7528\u6237\u672A\u767B\u5F55\u3002
+NON_LOGIN=\u7528\u6237\u672a\u767b\u5f55\u3002
 
-VCODE_ERROR=\u9A8C\u8BC1\u7801\u8F93\u5165\u9519\u8BEF\uFF01
+VCODE_ERROR=\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef\uff01
 
-NO_AUTH_ERROR=\u672A\u6388\u6743\u6216\u6388\u6743\u8FC7\u671F\u3002
+NO_AUTH_ERROR=\u672a\u6388\u6743\u6216\u6388\u6743\u8fc7\u671f\u3002
 
-PARAM_ERROR={0}\u53C2\u6570\u9519\u8BEF
+PARAM_ERROR={0}\u53c2\u6570\u9519\u8bef
 
-PARAM_INTEGER_ERROR={0}\u53C2\u6570\u5FC5\u987B\u4E3A\u6570\u5B57\u3002
+PARAM_INTEGER_ERROR={0}\u53c2\u6570\u5fc5\u987b\u4e3a\u6570\u5b57\u3002
 
-PARAM_EMPTY_ERROR={0}\u5FC5\u987B\u6307\u5B9A\u3002
+PARAM_EMPTY_ERROR={0}\u5fc5\u987b\u6307\u5b9a\u3002
 
-PARAM_SIZE_ERROR={0}\u53C2\u6570\u957F\u5EA6\u4E0D\u6B63\u786E\uFF0C\u5FC5\u987B\u5728{min}\u548C{max}\u4E4B\u95F4\u3002
+PARAM_SIZE_ERROR={0}\u53c2\u6570\u957f\u5ea6\u4e0d\u6b63\u786e\uff0c\u5fc5\u987b\u5728{min}\u548c{max}\u4e4b\u95f4\u3002
 
-PARAM_PATTERN_ERROR={0}\u53C2\u6570\u683C\u5F0F\u987B\u6B63\u786E\u6307\u5B9A{1}\u3002
+PARAM_PATTERN_ERROR={0}\u53c2\u6570\u683c\u5f0f\u987b\u6b63\u786e\u6307\u5b9a{1}\u3002
 
-EMAIL_SIZE_ERROR=\u90AE\u7BB1\u5730\u5740\u957F\u5EA6\u9519\u8BEF\uFF01
+EMAIL_SIZE_ERROR=\u90ae\u7bb1\u5730\u5740\u957f\u5ea6\u9519\u8bef\uff01
 
-EMAIL_PATTERN_ERROR=\u90AE\u7BB1\u5730\u5740\u683C\u5F0F\u9519\u8BEF\uFF01
+EMAIL_PATTERN_ERROR=\u90ae\u7bb1\u5730\u5740\u683c\u5f0f\u9519\u8bef\uff01
 
-MOBILE_SIZE_ERROR=\u624B\u673A\u53F7\u957F\u5EA6\u9519\u8BEF\uFF01
+MOBILE_SIZE_ERROR=\u624b\u673a\u53f7\u957f\u5ea6\u9519\u8bef\uff01
 
-MOBILE_PATTERN_ERROR=\u624B\u673A\u53F7\u683C\u5F0F\u9519\u8BEF\uFF01
+MOBILE_PATTERN_ERROR=\u624b\u673a\u53f7\u683c\u5f0f\u9519\u8bef\uff01
 
-DUNPLICATE_KAY_ERROR={0}\u5DF2\u88AB\u4ED6\u4EBA\u6CE8\u518C\uFF01
+DUNPLICATE_KAY_ERROR={0}\u5df2\u88ab\u4ed6\u4eba\u6ce8\u518c\uff01
 
-DATA_EMPTY_ERROR=\u5F53\u524D{0}\u6CA1\u6709\u6570\u636E\u3002
+DATA_EMPTY_ERROR=\u5f53\u524d{0}\u6ca1\u6709\u6570\u636e\u3002
 
-PWD_NOT_MATCH_ERROR=\u539F\u5BC6\u7801\u8F93\u5165\u4E0D\u5339\u914D\u3002
+PWD_NOT_MATCH_ERROR=\u539f\u5bc6\u7801\u8f93\u5165\u4e0d\u5339\u914d\u3002
 
-NON_CERTIFIED=\u672A\u901A\u8FC7\u5B9E\u540D\u8BA4\u8BC1\uFF0C\u65E0\u6CD5\u64CD\u4F5C\uFF01
+MCODE_ERROR=\u83b7\u53d6\u624b\u673a\u9a8c\u8bc1\u7801\u5f02\u5e38\uff01
 
-RECORD_CALLBACK=\u5F53\u524D\u8BB0\u5F55\u5DF2\u9000\u5355\uFF0C\u65E0\u6CD5\u4FEE\u6539\uFF01
+NON_CERTIFIED=\u672a\u901a\u8fc7\u5b9e\u540d\u8ba4\u8bc1\uff0c\u65e0\u6cd5\u64cd\u4f5c\uff01
 
-RECORD_SETTLEMENT=\u5F53\u524D\u8BB0\u5F55\u5DF2\u7ED3\u6B3E\uFF0C\u65E0\u6CD5\u4FEE\u6539\uFF01
+RECORD_CALLBACK=\u5f53\u524d\u8bb0\u5f55\u5df2\u9000\u5355\uff0c\u65e0\u6cd5\u4fee\u6539\uff01
 
-RECORD_REJECT=\u5F53\u524D\u7533\u8BF7\u672A\u901A\u8FC7\uFF0C\u65E0\u6CD5\u4FEE\u6539\uFF0C\u8BF7\u91CD\u65B0\u7533\u8BF7\uFF01
+RECORD_SETTLEMENT=\u5f53\u524d\u8bb0\u5f55\u5df2\u7ed3\u6b3e\uff0c\u65e0\u6cd5\u4fee\u6539\uff01
 
-CONTRACT_PATENT_CREATED=\u5F53\u524D\u5408\u540C\u4E13\u5229\u7533\u8BF7\u5DF2\u521B\u5EFA,\u65E0\u6CD5\u91CD\u590D\u521B\u5EFA\uFF01
+RECORD_REJECT=\u5f53\u524d\u7533\u8bf7\u672a\u901a\u8fc7\uff0c\u65e0\u6cd5\u4fee\u6539\uff0c\u8bf7\u91cd\u65b0\u7533\u8bf7\uff01
 
-CONTRACT_COPYRIGHT_CREATED=\u5F53\u524D\u5408\u540C\u8F6F\u8457\u7533\u8BF7\u5DF2\u521B\u5EFA,\u65E0\u6CD5\u91CD\u590D\u521B\u5EFA\uFF01
+CONTRACT_PATENT_CREATED=\u5f53\u524d\u5408\u540c\u4e13\u5229\u7533\u8bf7\u5df2\u521b\u5efa,\u65e0\u6cd5\u91cd\u590d\u521b\u5efa\uff01
 
-CONTRACT_TECHPROJECT_CREATED=\u5F53\u524D\u5408\u540C\u79D1\u6280\u9879\u76EE\u7533\u8BF7\u5DF2\u521B\u5EFA,\u65E0\u6CD5\u91CD\u590D\u521B\u5EFA\uFF01
+CONTRACT_COPYRIGHT_CREATED=\u5f53\u524d\u5408\u540c\u8f6f\u8457\u7533\u8bf7\u5df2\u521b\u5efa,\u65e0\u6cd5\u91cd\u590d\u521b\u5efa\uff01
 
-CONTRACT_COGNIZANCE_CREATED=\u5F53\u524D\u5408\u540C\u9AD8\u4F01\u8BA4\u5B9A\u7533\u8BF7\u5DF2\u521B\u5EFA,\u65E0\u6CD5\u91CD\u590D\u521B\u5EFA\uFF01
+CONTRACT_TECHPROJECT_CREATED=\u5f53\u524d\u5408\u540c\u79d1\u6280\u9879\u76ee\u7533\u8bf7\u5df2\u521b\u5efa,\u65e0\u6cd5\u91cd\u590d\u521b\u5efa\uff01
 
-EVALUATE_ID=\u8BC4\u4F30\u62A5\u544A\u627E\u4E0D\u5230\uFF01
-EVALUATE_STEP=\u9519\u8BEF\u7684\u8BC4\u4F30\u6B65\u9AA4\uFF01
-EVALUATE_PARAM=\u8BC4\u4F30\u53C2\u6570\u9519\u8BEF\uFF01
+CONTRACT_COGNIZANCE_CREATED=\u5f53\u524d\u5408\u540c\u9ad8\u4f01\u8ba4\u5b9a\u7533\u8bf7\u5df2\u521b\u5efa,\u65e0\u6cd5\u91cd\u590d\u521b\u5efa\uff01
+
+EVALUATE_ID=\u8bc4\u4f30\u62a5\u544a\u627e\u4e0d\u5230\uff01
+EVALUATE_STEP=\u9519\u8bef\u7684\u8bc4\u4f30\u6b65\u9aa4\uff01
+EVALUATE_PARAM=\u8bc4\u4f30\u53c2\u6570\u9519\u8bef\uff01