Przeglądaj źródła

Merge remote-tracking branch 'origin/dev' into dev

tags/24080901
WendyYang 11 miesięcy temu
rodzic
commit
51746f676b
8 zmienionych plików z 214 dodań i 0 usunięć
  1. +85
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/sms/SmsServiceClient.java
  2. +22
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/sms/dto/SmsDto.java
  3. +18
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsReceipt.java
  4. +11
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsReceiptVo.java
  5. +20
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsReply.java
  6. +25
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsReplyResponse.java
  7. +13
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsSendRequest.java
  8. +20
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsSendResponse.java

+ 85
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/sms/SmsServiceClient.java Wyświetl plik

@@ -0,0 +1,85 @@
package com.hz.pm.api.external.sms;

import cn.hutool.core.lang.TypeReference;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hz.pm.api.external.sms.dto.SmsDto;
import com.hz.pm.api.external.sms.vo.SmsReceipt;
import com.hz.pm.api.external.sms.vo.SmsReply;
import com.hz.pm.api.external.sms.vo.SmsSendResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Component
@RequiredArgsConstructor
public class SmsServiceClient {

/**
* 短信服务
*/
@Value("${sms.client-url:}")
private String smsUrl;

public static final String SMS_REPLY = "/sms/reply";
public static final String SMS_SEND = "/sms/send";
public static final String SMS_RECEIPT = "/sms/status";
/**
* 短信回复
* @param result
* @return
*/
public List<SmsReply> smsReply(String result) {
List<SmsReply> smsReplyList;
String refreshUrl = smsUrl + SMS_REPLY;
HashMap<String,Object> map = new HashMap<>();
map.put("result",result);
String responseResult = HttpUtil.post(refreshUrl, map);
JSONObject responseJson = JSON.parseObject(responseResult, JSONObject.class);
String fileData = responseJson.getString("data");
JSONArray result1 = JSON.parseObject(fileData).getJSONArray("result");
smsReplyList = JSONObject.parseArray(result1.toJSONString(),SmsReply.class);
return smsReplyList;
}

/**
* 短信发送
* @return
*/
public SmsDto<SmsSendResponse> smsSend(String content, List<String> phones) {
String phonesSplit = String.join(",", phones);;
String refreshUrl = smsUrl + SMS_SEND;
Map<String,Object> map = new HashMap<>();
map.put("content",content);
map.put("phones",phonesSplit);
String responseResult = HttpUtil.post(refreshUrl, JSON.toJSONString(map));
return JSONUtil.toBean(responseResult, new TypeReference<SmsDto<SmsSendResponse>>() {
}, false);
}

/**
* 短信回执
* @param result
* @return
*/
public SmsReceipt smsReceipt(String result) {
SmsReceipt smsReceipt = null;
String refreshUrl = smsUrl + SMS_RECEIPT;
HashMap<String,Object> map = new HashMap<>();
map.put("result",result);
String responseResult = HttpUtil.post(refreshUrl, map);
JSONObject responseJson = JSON.parseObject(responseResult, JSONObject.class);
String fileData = responseJson.getString("data");
return JSONObject.parseObject(fileData, SmsReceipt.class);
}

}

+ 22
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/sms/dto/SmsDto.java Wyświetl plik

@@ -0,0 +1,22 @@
package com.hz.pm.api.external.sms.dto;

import lombok.Data;

@Data
public class SmsDto<T> {

/**
* 成功状态码
*/
private static final int OK_CODE = 200;
/**
* 失败状态码(未找到资源)
*/
private static final int FAIL_CODE = 404;

private Integer code;

private String msg;

private T data;
}

+ 18
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsReceipt.java Wyświetl plik

@@ -0,0 +1,18 @@
package com.hz.pm.api.external.sms.vo;

import lombok.Data;

@Data
public class SmsReceipt {
// {"result":{"successPhone":["13721760288"]},"success":true,"message":"","rows":0,"sendTime":1703835660175}

private SmsReceiptVo result;

private Boolean success;

private String message;

private Integer rows;

private Long sendTime;
}

+ 11
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsReceiptVo.java Wyświetl plik

@@ -0,0 +1,11 @@
package com.hz.pm.api.external.sms.vo;

import lombok.Data;

import java.util.List;

@Data
public class SmsReceiptVo {

private List<String> successPhone;
}

+ 20
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsReply.java Wyświetl plik

@@ -0,0 +1,20 @@
package com.hz.pm.api.external.sms.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("短信回复具体信息")
public class SmsReply {

@ApiModelProperty("回复的内容")
private String replyContent;

@ApiModelProperty("回复的时间")
private Long replyReplytime;

@ApiModelProperty("回复的手机号")
private String replyMobile;

}

+ 25
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsReplyResponse.java Wyświetl plik

@@ -0,0 +1,25 @@
package com.hz.pm.api.external.sms.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("短信回复响应内容")
public class SmsReplyResponse {

@ApiModelProperty("参数校验失败的错误提示")
private String error;

@ApiModelProperty("发送失败的手机号")
private String errorPhone;

@ApiModelProperty("回复内容")
private SmsReply result;

@ApiModelProperty("发送时间")
private Integer sendTime;

@ApiModelProperty("本地接口请求是否成功标识")
private Boolean success;
}

+ 13
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsSendRequest.java Wyświetl plik

@@ -0,0 +1,13 @@
package com.hz.pm.api.external.sms.vo;

import lombok.Data;

@Data
public class SmsSendRequest {

// 短信内容
private String content;

//短信 手机号,逗号拼接
private String phones;
}

+ 20
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/sms/vo/SmsSendResponse.java Wyświetl plik

@@ -0,0 +1,20 @@
package com.hz.pm.api.external.sms.vo;

import lombok.Data;

@Data
public class SmsSendResponse {

//发送失败的手机号
private String errorPhone;

//返回UUID
private String result;

//发送时间 时间戳
private Long sendTime;

//本次接口请求是否成功
private Boolean success;

}

Ładowanie…
Anuluj
Zapisz