Browse Source

finikes alpha 8

finikes 2 năm trước cách đây
mục cha
commit
72116f04ef

+ 16 - 0
pom.xml

@@ -22,6 +22,22 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-core</artifactId>
+            <version>4.6.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.83</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.2</version>
+        </dependency>
         <dependency>
             <groupId>org.mybatis.spring.boot</groupId>
             <artifactId>mybatis-spring-boot-starter</artifactId>

+ 64 - 0
src/main/java/com/finikes/oc/common/SMSSender.java

@@ -0,0 +1,64 @@
+package com.finikes.oc.common;
+
+import com.alibaba.fastjson.JSONObject;
+import com.aliyuncs.CommonRequest;
+import com.aliyuncs.CommonResponse;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.exceptions.ServerException;
+import com.aliyuncs.http.MethodType;
+import com.aliyuncs.profile.DefaultProfile;
+
+import java.util.Map;
+
+public class SMSSender {
+    /**
+     * 发送短信验证码
+     *
+     * @param phone        接收短信的手机号
+     * @param templateCode 短信模板CODE
+     * @param codeMap      验证码map 集合
+     * @return
+     */
+    public static Boolean sendMessage(String phone, String templateCode, Map<String, Object> codeMap) {
+
+        /**
+         * 连接阿里云:
+         *
+         * 三个参数:
+         * regionId 不要动,默认使用官方的
+         * accessKeyId 自己的用户accessKeyId
+         * accessSecret 自己的用户accessSecret
+         */
+        DefaultProfile profile = DefaultProfile.getProfile(
+                "cn-hangzhou", "", "");
+        IAcsClient client = new DefaultAcsClient(profile);
+
+        // 构建请求:
+        CommonRequest request = new CommonRequest();
+        request.setSysMethod(MethodType.POST);
+        request.setSysDomain("dysmsapi.aliyuncs.com");
+        request.setSysVersion("2017-05-25");
+        request.setSysAction("SendSms");
+
+        // 自定义参数:
+        request.putQueryParameter("PhoneNumbers", phone);// 手机号
+        request.putQueryParameter("SignName", "CSP网上商城");// 短信签名
+        request.putQueryParameter("TemplateCode", templateCode);// 短信模版CODE
+
+        // 构建短信验证码
+        request.putQueryParameter("TemplateParam", JSONObject.toJSONString(codeMap));
+
+        try {
+            CommonResponse response = client.getCommonResponse(request);
+            System.out.println(response.getData());
+            return response.getHttpResponse().isSuccess();
+        } catch (ServerException e) {
+            e.printStackTrace();
+        } catch (ClientException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+}

+ 1 - 1
src/main/resources/mapper/HouseRelationMapper.xml

@@ -20,7 +20,7 @@
         WHERE passportId = #{id}
     </select>
 
-    <update id="updateVeriCode" parameterType="com.finikes.oc.base.entity.Passport">
+    <update id="update" parameterType="com.finikes.oc.management.entity.HouseRelation">
         UPDATE t_house_relation
         SET state      = #{state},
             certificateNo = #{certificateNo},