parent
c77ca554c0
commit
872977d4c2
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
<version>3.6.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-common-sms</artifactId>
|
||||
|
||||
<description>
|
||||
ruoyi-common-sms 短信模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.7.0</version> <!-- 或其他兼容版本 -->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.7.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,24 @@
|
||||
package com.ruoyi.common.sms;
|
||||
|
||||
import com.ruoyi.common.sms.component.SmsComponent;
|
||||
import com.ruoyi.common.sms.properties.XunDaYunXinProperties;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(XunDaYunXinProperties.class)
|
||||
public class XunDaYunXinAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public SmsComponent smsComponent() {
|
||||
return new SmsComponent();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
package com.ruoyi.common.sms.entity;
|
@ -0,0 +1 @@
|
||||
package com.ruoyi.common.sms.entity.request;
|
@ -0,0 +1,32 @@
|
||||
package com.ruoyi.common.sms.entity.response;
|
||||
|
||||
public class SmsEntity {
|
||||
private String mid;
|
||||
private String mobile;
|
||||
private int result;
|
||||
|
||||
// Getters and Setters
|
||||
public String getMid() {
|
||||
return mid;
|
||||
}
|
||||
|
||||
public void setMid(String mid) {
|
||||
this.mid = mid;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public int getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(int result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.ruoyi.common.sms.entity.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SmsResponse<T> {
|
||||
private Integer status;
|
||||
private Integer balance;
|
||||
private List<T> list;
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
com.ruoyi.common.sms.XunDaYunXinAutoConfiguration
|
||||
com.ruoyi.common.sms.component.SmsComponent
|
@ -0,0 +1,12 @@
|
||||
package com.ruoyi.system.process;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
|
||||
/**
|
||||
*根据流程类型 执行不同的处理器
|
||||
*/
|
||||
public interface ProcessHandler {
|
||||
|
||||
|
||||
AjaxResult invoke();
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.ruoyi.system.process.enums;
|
||||
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
|
||||
public enum ProcessHandlerEnum {
|
||||
|
||||
H5_HANDLER("H5_HANDLER", "H5Handler"),
|
||||
HALF_HANDLER("HALF_HANDLER", "HalfHandler");
|
||||
final String code;
|
||||
|
||||
final String name;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
ProcessHandlerEnum(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static String getNameByCode(String code) {
|
||||
ProcessHandlerEnum[] processHandlerEnums = values();
|
||||
for (ProcessHandlerEnum processHandlerEnum : processHandlerEnums) {
|
||||
if (processHandlerEnum.getCode().equals(code)) {
|
||||
return processHandlerEnum.getName();
|
||||
}
|
||||
}
|
||||
String msg = String.format("请检查对应的流程处理器是否实现,编码为:%s", code);
|
||||
throw new ServiceException(msg, 500);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.system.process.handler;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.system.process.ProcessHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component(value = "H5Handler")
|
||||
public class H5Handler implements ProcessHandler {
|
||||
@Override
|
||||
public AjaxResult invoke() {
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.ruoyi.system.process.handler;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.system.process.ProcessHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component(value = "HalfHandler")
|
||||
public class HalfHandler implements ProcessHandler {
|
||||
@Override
|
||||
public AjaxResult invoke() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
package com.ruoyi.system.process;
|
@ -0,0 +1,48 @@
|
||||
package com.ruoyi.system;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.sms.component.SmsComponent;
|
||||
import com.ruoyi.common.sms.entity.response.SmsResponse;
|
||||
import org.assertj.core.util.Maps;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.hutool.extra.spring.SpringUtil.getActiveProfile;
|
||||
|
||||
@SpringBootTest
|
||||
public class RuoYiSystemApplicationTest {
|
||||
|
||||
@Autowired
|
||||
SmsComponent smsComponent;
|
||||
|
||||
@Test
|
||||
public void testGroupMsg(){
|
||||
|
||||
String mobile = "15826189779,15826189779,17382317154";
|
||||
String content = "123456";
|
||||
|
||||
SmsResponse groupMsg = smsComponent.sendGroupMsg(mobile, content);
|
||||
System.out.println(JSONUtil.toJsonStr(groupMsg));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testP2pMsg(){
|
||||
|
||||
String content = "123456";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("15826189779", content);
|
||||
SmsResponse sendP2PMsg = smsComponent.sendP2PMsg(params);
|
||||
System.out.println(JSONUtil.toJsonStr(sendP2PMsg));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getActivePro(){
|
||||
|
||||
String activeProfile = getActiveProfile();
|
||||
System.out.println(activeProfile);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue