xiongzhu 2 роки тому
батько
коміт
6c38ca39ab

+ 9 - 0
install-jar.sh

@@ -14,3 +14,12 @@ mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file \
 -Dversion=1.0 \
 -Dversion=1.0 \
 -Dfile=lib/pngquant4j-1.0.jar \
 -Dfile=lib/pngquant4j-1.0.jar \
 -DlocalRepositoryPath=libs
 -DlocalRepositoryPath=libs
+
+
+mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file \
+-DgroupId=masmgc \
+-DartifactId=sms \
+-Dpackaging=jar \
+-Dversion=1.0 \
+-Dfile=lib/masmgc.sdk.sms-1.0.3-SNAPSHOT.jar \
+-DlocalRepositoryPath=libs

BIN
lib/masmgc.sdk.mms-1.0.3-SNAPSHOT.jar


BIN
lib/masmgc.sdk.sms-1.0.3-SNAPSHOT.jar


BIN
libs/masmgc/sms/1.0/sms-1.0.jar


+ 9 - 0
libs/masmgc/sms/1.0/sms-1.0.pom

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>masmgc</groupId>
+  <artifactId>sms</artifactId>
+  <version>1.0</version>
+  <description>POM was created from install:install-file</description>
+</project>

+ 12 - 0
libs/masmgc/sms/maven-metadata-local.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>masmgc</groupId>
+  <artifactId>sms</artifactId>
+  <versioning>
+    <release>1.0</release>
+    <versions>
+      <version>1.0</version>
+    </versions>
+    <lastUpdated>20231007104707</lastUpdated>
+  </versioning>
+</metadata>

+ 9 - 9
libs/org/libjpegturbo/mozjpeg4j/maven-metadata-local.xml

@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <metadata>
 <metadata>
-    <groupId>org.libjpegturbo</groupId>
-    <artifactId>mozjpeg4j</artifactId>
-    <versioning>
-        <release>1.1</release>
-        <versions>
-            <version>1.1</version>
-        </versions>
-        <lastUpdated>20210319095742</lastUpdated>
-    </versioning>
+  <groupId>org.libjpegturbo</groupId>
+  <artifactId>mozjpeg4j</artifactId>
+  <versioning>
+    <release>1.1</release>
+    <versions>
+      <version>1.1</version>
+    </versions>
+    <lastUpdated>20231007104703</lastUpdated>
+  </versioning>
 </metadata>
 </metadata>

+ 9 - 9
libs/org/pngquant/pngquant4j/maven-metadata-local.xml

@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <metadata>
 <metadata>
-    <groupId>org.pngquant</groupId>
-    <artifactId>pngquant4j</artifactId>
-    <versioning>
-        <release>1.0</release>
-        <versions>
-            <version>1.0</version>
-        </versions>
-        <lastUpdated>20210319095744</lastUpdated>
-    </versioning>
+  <groupId>org.pngquant</groupId>
+  <artifactId>pngquant4j</artifactId>
+  <versioning>
+    <release>1.0</release>
+    <versions>
+      <version>1.0</version>
+    </versions>
+    <lastUpdated>20231007104707</lastUpdated>
+  </versioning>
 </metadata>
 </metadata>

+ 6 - 0
pom.xml

@@ -322,6 +322,12 @@
             <groupId>software.amazon.awssdk</groupId>
             <groupId>software.amazon.awssdk</groupId>
             <artifactId>s3control</artifactId>
             <artifactId>s3control</artifactId>
         </dependency>
         </dependency>
+
+        <dependency>
+            <groupId>masmgc</groupId>
+            <artifactId>sms</artifactId>
+            <version>1.0</version>
+        </dependency>
     </dependencies>
     </dependencies>
 
 
 </project>
 </project>

+ 21 - 23
src/main/java/com/izouma/zhirongip/service/sms/AliSmsService.java

@@ -11,6 +11,7 @@ import com.izouma.zhirongip.config.Constants;
 import com.izouma.zhirongip.domain.SmsRecord;
 import com.izouma.zhirongip.domain.SmsRecord;
 import com.izouma.zhirongip.exception.BusinessException;
 import com.izouma.zhirongip.exception.BusinessException;
 import com.izouma.zhirongip.repo.SmsRecordRepo;
 import com.izouma.zhirongip.repo.SmsRecordRepo;
+import com.mascloud.sdkclient.Client;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +20,7 @@ import org.springframework.boot.configurationprocessor.json.JSONException;
 import org.springframework.boot.configurationprocessor.json.JSONObject;
 import org.springframework.boot.configurationprocessor.json.JSONObject;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import javax.annotation.PostConstruct;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.time.ZoneOffset;
 
 
@@ -32,38 +34,33 @@ public class AliSmsService implements SmsService {
     @Autowired
     @Autowired
     private SmsRecordRepo smsRecordRepo;
     private SmsRecordRepo smsRecordRepo;
 
 
+    private Client client;
+
+    @PostConstruct
+    public void init() {
+        client = Client.getInstance();
+        boolean success = client.login("http://112.35.4.197:15000", "sms", "3edc#EDC", "江苏移动信息系统集成有限公司(政企)");
+        if (!success) {
+            log.error("sms login failed");
+        }
+    }
+
     @Override
     @Override
     public String sendVerify(String phone) {
     public String sendVerify(String phone) {
         smsRecordRepo.findLastByPhoneAndExpiresAtAfterAndExpiredFalse(phone, LocalDateTime.now()).ifPresent(record -> {
         smsRecordRepo.findLastByPhoneAndExpiresAtAfterAndExpiredFalse(phone, LocalDateTime.now()).ifPresent(record -> {
             if (record.getCreatedAt().plusMinutes(1L).isAfter(LocalDateTime.now())) {
             if (record.getCreatedAt().plusMinutes(1L).isAfter(LocalDateTime.now())) {
-                long sec = record.getCreatedAt().plusMinutes(1L).toInstant(ZoneOffset.UTC).getEpochSecond() - LocalDateTime.now().toInstant(ZoneOffset.UTC).getEpochSecond() + 1;
+                long sec = record.getCreatedAt().plusMinutes(1L).toInstant(ZoneOffset.UTC)
+                                 .getEpochSecond() - LocalDateTime.now().toInstant(ZoneOffset.UTC).getEpochSecond() + 1;
                 throw new BusinessException("请" + sec + "秒后再试");
                 throw new BusinessException("请" + sec + "秒后再试");
             }
             }
         });
         });
 
 
         String code = RandomStringUtils.randomNumeric(4);
         String code = RandomStringUtils.randomNumeric(4);
-        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
-        IAcsClient client = new DefaultAcsClient(profile);
 
 
-        CommonRequest request = new CommonRequest();
-        request.setMethod(MethodType.POST);
-        request.setDomain("dysmsapi.aliyuncs.com");
-        request.setVersion("2017-05-25");
-        request.setAction("SendSms");
-        request.putQueryParameter("PhoneNumbers", phone);
-        request.putQueryParameter("SignName", Constants.SMS_SIGN_NAME);
-        request.putQueryParameter("TemplateCode", Constants.SMS_TEMPLATE_CODE_GENERIC);
-        request.putQueryParameter("TemplateParam", "{\"code\":\"" + code + "\"}");
         try {
         try {
-            CommonResponse response = client.getCommonResponse(request);
-            if (response.getHttpStatus() != 200) {
-                throw new BusinessException("发送失败,请稍后再试", response.getHttpStatus() + "," + response.getData());
-            }
-            log.info("send sms response {}", response.getData());
-            JSONObject jsonObject = new JSONObject(response.getData());
-            if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
-                throw new BusinessException("发送失败,请稍后再试", jsonObject.getString("Message"));
-            }
+            int rtCode = client.sendDSMS(new String[]{phone}, "您的验证码是" + code + ",5分钟内有效", "", 1, "ubfdvkj65", null, false);
+            log.info("send sms response {}", rtCode);
+
             smsRecordRepo.expire(phone);
             smsRecordRepo.expire(phone);
             String sessionId = RandomStringUtils.randomAlphabetic(10);
             String sessionId = RandomStringUtils.randomAlphabetic(10);
             smsRecordRepo.save(SmsRecord.builder()
             smsRecordRepo.save(SmsRecord.builder()
@@ -74,7 +71,7 @@ public class AliSmsService implements SmsService {
                                         .expired(false)
                                         .expired(false)
                                         .build());
                                         .build());
             return sessionId;
             return sessionId;
-        } catch (ClientException | JSONException e) {
+        } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
             throw new BusinessException("发送失败,请稍后再试", e.getMessage());
             throw new BusinessException("发送失败,请稍后再试", e.getMessage());
         }
         }
@@ -82,7 +79,8 @@ public class AliSmsService implements SmsService {
 
 
     @Override
     @Override
     public void verify(String phone, String code) throws SmsVerifyException {
     public void verify(String phone, String code) throws SmsVerifyException {
-        SmsRecord smsRecord = smsRecordRepo.findLastByPhoneAndExpiresAtAfterAndExpiredFalse(phone, LocalDateTime.now()).orElseThrow(new SmsVerifyException("验证码错误"));
+        SmsRecord smsRecord = smsRecordRepo.findLastByPhoneAndExpiresAtAfterAndExpiredFalse(phone, LocalDateTime.now())
+                                           .orElseThrow(new SmsVerifyException("验证码错误"));
         if (!smsRecord.getCode().equalsIgnoreCase(code)) {
         if (!smsRecord.getCode().equalsIgnoreCase(code)) {
             throw new BusinessException("验证码错误");
             throw new BusinessException("验证码错误");
         }
         }

+ 2 - 1
src/main/java/com/izouma/zhirongip/service/storage/EosStorageService.java

@@ -65,7 +65,7 @@ public class EosStorageService implements StorageService {
 
 
                                       @Override
                                       @Override
                                       public String secretAccessKey() {
                                       public String secretAccessKey() {
-                                          return "e0a82e65ae784d83af6997a774f88375";
+                                          return "5RiHQB6mLUBj5IhzcWuRiGlw0J24dIMFJBJ9x5sI";
                                       }
                                       }
                                   })
                                   })
                                   .endpointOverride(URI.create("https://eos-fujian-1.cmecloud.cn"))
                                   .endpointOverride(URI.create("https://eos-fujian-1.cmecloud.cn"))
@@ -74,6 +74,7 @@ public class EosStorageService implements StorageService {
         PutObjectRequest objectRequest = PutObjectRequest.builder()
         PutObjectRequest objectRequest = PutObjectRequest.builder()
                                                          .bucket("yzip")
                                                          .bucket("yzip")
                                                          .key(path)
                                                          .key(path)
+                                                         .acl("public-read")
                                                          .build();
                                                          .build();
         client.putObject(objectRequest, RequestBody.fromInputStream(inputStream, inputStream.available()));
         client.putObject(objectRequest, RequestBody.fromInputStream(inputStream, inputStream.available()));
 
 

+ 1 - 1
src/main/resources/application.yaml

@@ -72,7 +72,7 @@ wx:
         notifyUrl: http://zhirongip.izouma.com/wx/payNotify
         notifyUrl: http://zhirongip.izouma.com/wx/payNotify
         refundNotifyUrl: http://zhirongip.izouma.com/wx/refundNotify
         refundNotifyUrl: http://zhirongip.izouma.com/wx/refundNotify
 storage:
 storage:
-    provider: aliyun
+    provider: eos
     local_path: /var/www/upload/
     local_path: /var/www/upload/
 aliyun:
 aliyun:
     access-key-id: PXzJyah5rZfWHIIH
     access-key-id: PXzJyah5rZfWHIIH