42 changed files with 3090 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||
package org.dromara.system.api; |
|||
|
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.system.api.domain.vo.RemoteClientVo; |
|||
|
|||
/** |
|||
* 客户端服务 |
|||
* |
|||
* @author Michelle.Chung |
|||
*/ |
|||
public interface RemoteSubmailConfigService { |
|||
|
|||
/** |
|||
* 根据客户端id获取客户端详情 |
|||
* |
|||
* @return 客户端对象 |
|||
*/ |
|||
R<String> remoteCmdSend(String code, String multiParam ); |
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<parent> |
|||
<groupId>org.dromara</groupId> |
|||
<artifactId>dk-common</artifactId> |
|||
<version>${revision}</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>common-rocketmq</artifactId> |
|||
|
|||
<description> |
|||
common-rocketmq 配置中心 |
|||
</description> |
|||
|
|||
<dependencies> |
|||
<!--rocketmq消息队列--> |
|||
<dependency> |
|||
<groupId>org.apache.rocketmq</groupId> |
|||
<artifactId>rocketmq-client</artifactId> |
|||
<version> 4.9.0</version> |
|||
</dependency> |
|||
|
|||
<!--RocketMQ--> |
|||
<dependency> |
|||
<groupId>org.apache.rocketmq</groupId> |
|||
<artifactId>rocketmq-spring-boot-starter</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>org.dromara</groupId> |
|||
<artifactId>common-core</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>org.dromara</groupId> |
|||
<artifactId>common-nacos</artifactId> |
|||
</dependency> |
|||
|
|||
</dependencies> |
|||
|
|||
|
|||
</project> |
@ -0,0 +1,58 @@ |
|||
package org.dromara.common.rocketmq.config; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.rocketmq.client.exception.MQClientException; |
|||
import org.apache.rocketmq.client.producer.DefaultMQProducer; |
|||
import org.dromara.common.rocketmq.model.ProducerMode; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.autoconfigure.AutoConfiguration; |
|||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|||
import org.springframework.context.annotation.Bean; |
|||
|
|||
|
|||
/** |
|||
* mq搭建地址连接 |
|||
* 生产者初者连接信息 具体看nacos配置 |
|||
*/ |
|||
@AutoConfiguration |
|||
@Slf4j |
|||
@EnableConfigurationProperties(ProducerMode.class) |
|||
public class ProducerConfig { |
|||
|
|||
/** |
|||
* 远程调用连接信息 |
|||
*/ |
|||
public static DefaultMQProducer producer; |
|||
|
|||
/** |
|||
* 连接客户端信息配置 具体看nacos配置 |
|||
*/ |
|||
@Autowired |
|||
private ProducerMode producerMode; |
|||
|
|||
@Bean |
|||
public DefaultMQProducer getRocketMQProducer() { |
|||
producer = new DefaultMQProducer(producerMode.getGroupName()); |
|||
producer.setNamesrvAddr(producerMode.getNameServer()); |
|||
//如果需要同一个jvm中不同的producer往不同的mq集群发送消息,需要设置不同的instanceName
|
|||
if(producerMode.getMaxMessageSize()!=null){ |
|||
producer.setMaxMessageSize(producerMode.getMaxMessageSize()); |
|||
} |
|||
if(producerMode.getSendMsgTimeout()!=null){ |
|||
producer.setSendMsgTimeout(producerMode.getSendMsgTimeout()); |
|||
} |
|||
//如果发送消息失败,设置重试次数,默认为2次
|
|||
if(producerMode.getRetryTimesWhenSendFailed()!=null){ |
|||
producer.setRetryTimesWhenSendFailed(producerMode.getRetryTimesWhenSendFailed()); |
|||
} |
|||
producer.setVipChannelEnabled(false); |
|||
try { |
|||
producer.start(); |
|||
log.info("生产者初始化成功:{}",producer.toString()); |
|||
} catch (MQClientException e) { |
|||
log.error("生产者初始化失败:{}",e.getMessage()); |
|||
} |
|||
return producer; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,25 @@ |
|||
package org.dromara.common.rocketmq.model; |
|||
|
|||
import lombok.Data; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.cloud.context.config.annotation.RefreshScope; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* 生产者初始化 |
|||
*/ |
|||
@Data |
|||
@ConfigurationProperties(prefix = "rocketmq.producer") |
|||
public class ProducerMode { |
|||
|
|||
private String groupName; |
|||
|
|||
private String nameServer; |
|||
|
|||
private Integer maxMessageSize; |
|||
|
|||
private Integer sendMsgTimeout; |
|||
|
|||
private Integer retryTimesWhenSendFailed; |
|||
} |
@ -0,0 +1,189 @@ |
|||
package org.dromara.common.rocketmq.producer; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.rocketmq.client.exception.MQBrokerException; |
|||
import org.apache.rocketmq.client.exception.MQClientException; |
|||
import org.apache.rocketmq.client.producer.SendCallback; |
|||
import org.apache.rocketmq.client.producer.SendResult; |
|||
import org.apache.rocketmq.common.message.Message; |
|||
import org.apache.rocketmq.remoting.common.RemotingHelper; |
|||
import org.apache.rocketmq.remoting.exception.RemotingException; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.text.DateFormat; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
import static org.dromara.common.rocketmq.config.ProducerConfig.producer; |
|||
|
|||
|
|||
/** |
|||
* 消息发送 |
|||
*/ |
|||
@Slf4j |
|||
public class MessageProducerUtil { |
|||
|
|||
/** |
|||
* 同步发送消息 |
|||
* @param topic 主题 |
|||
* @param tag 标签 |
|||
* @param key 自定义的key,根据业务来定 |
|||
* @param value 消息的内容 |
|||
* 通过调用 send() 方法发送消息,阻塞等待服务器响应。 |
|||
*/ |
|||
public static SendResult sendSynchronizeMessage(String topic, String tag, String key, String value){ |
|||
String body = "topic:【"+topic+"】, tag:【"+tag+"】, key:【"+key+"】, value:【"+value+"】"; |
|||
try { |
|||
Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); |
|||
System.out.println("生产者发送消息:"+ JSON.toJSONString(value)); |
|||
SendResult result = producer.send(msg); |
|||
return result; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
log.error("消息初始化失败!body:{}",body); |
|||
|
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 单向发送消息 |
|||
* @param topic 主题 |
|||
* @param tag 标签 |
|||
* @param key 自定义的key,根据业务来定 |
|||
* @param value 消息的内容 |
|||
* 单向发送:通过调用 sendOneway() 方法发送消息,不关心发送结果,适用于对可靠性要求不高的场景。 |
|||
*/ |
|||
public static void sendOnewayMessage(String topic, String tag, String key, String value){ |
|||
String body = "topic:【"+topic+"】, tag:【"+tag+"】, key:【"+key+"】, value:【"+value+"】"; |
|||
try { |
|||
Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); |
|||
System.out.println("生产者发送消息:"+ JSON.toJSONString(value)); |
|||
producer.sendOneway(msg); |
|||
} catch (UnsupportedEncodingException e) { |
|||
log.error("消息初始化失败!body:{}",body); |
|||
|
|||
} catch (MQClientException | InterruptedException | RemotingException e) { |
|||
log.error("消息发送失败! body:{}",body); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 批量发送消息 |
|||
* @param messages 消息列表 |
|||
* 批量发送:通过调用 send() 方法并传入多条消息,实现批量发送消息。 |
|||
*/ |
|||
// public static SendResult sendBatchMessage(List<Message> messages){
|
|||
// String body = messages.toString();
|
|||
// try {
|
|||
// System.out.println("生产者发送消息:"+ messages);
|
|||
// // 发送批量消息
|
|||
// SendResult sendResult = producer.send(messages);
|
|||
// return sendResult;
|
|||
// } catch (MQClientException | InterruptedException | RemotingException e) {
|
|||
// log.error("消息发送失败! body:{}",body);
|
|||
// } catch (MQBrokerException e) {
|
|||
// throw new RuntimeException(e);
|
|||
// }
|
|||
// return null;
|
|||
// }
|
|||
|
|||
|
|||
/** |
|||
* 发送有序的消息 |
|||
* @param messagesList Message集合 |
|||
* @param messageQueueNumber 消息队列数量,根据实际情况设定 |
|||
* 顺序发送: messageQueueNumber 表示消息的业务标识,可以根据具体需求进行设置来保证消息按顺序发送。 |
|||
*/ |
|||
// public static SendResult sendOrderlyMessage(List<Message> messagesList, Integer messageQueueNumber) {
|
|||
// SendResult result = null;
|
|||
// for (Message message : messagesList) {
|
|||
// try {
|
|||
// result = producer.send(message, (list, msg, arg) -> {
|
|||
// Integer queueNumber = (Integer) arg;
|
|||
// //int queueIndex = queueNumber % list.size();
|
|||
// return list.get(queueNumber);
|
|||
// }, messageQueueNumber);//根据编号取模,选择消息队列
|
|||
// } catch (MQClientException | RemotingException | MQBrokerException | InterruptedException e) {
|
|||
// log.error("发送有序消息失败");
|
|||
// return result;
|
|||
// }
|
|||
// }
|
|||
// return result;
|
|||
// }
|
|||
|
|||
/** |
|||
* 发送延迟消息 |
|||
* @param topic 主题 |
|||
* @param tag 标签 |
|||
* @param key 自定义的key,根据业务来定 |
|||
* @param value 消息的内容 |
|||
* 延迟发送:通过设置延迟级别来实现延迟发送消息。 |
|||
*/ |
|||
public static SendResult sendDelayMessage(String topic, String tag, String key, String value) |
|||
{ |
|||
SendResult result = null; |
|||
try |
|||
{ |
|||
Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); |
|||
//设置消息延迟级别,我这里设置5,对应就是延时一分钟
|
|||
// "1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h"
|
|||
msg.setDelayTimeLevel(4); |
|||
// 发送消息到一个Broker
|
|||
result = producer.send(msg); |
|||
// 通过sendResult返回消息是否成功送达
|
|||
log.info("发送延迟消息结果:======sendResult:{}", result); |
|||
DateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|||
log.info("发送时间:{}", format.format(new Date())); |
|||
return result; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
e.printStackTrace(); |
|||
log.error("延迟消息队列推送消息异常:{},推送内容:{}", e.getMessage(), result); |
|||
} |
|||
return result; |
|||
} |
|||
/** |
|||
* 发送异步的消息 |
|||
* @param topic 主题 |
|||
* @param tag 标签 |
|||
* @param key 自定义的key,根据业务来定 |
|||
* @param value 消息的内容 |
|||
* 通过调用 send() 方法,并传入一个 SendCallback 对象,在发送消息的同时可以继续处理其他逻辑,消息发送结果通过回调函数通知。 |
|||
*/ |
|||
public static SendResult sendAsyncProducerMessage(String topic, String tag, String key, String value){ |
|||
|
|||
try { |
|||
//创建一个消息实例,指定主题、标签和消息体。
|
|||
Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); |
|||
System.out.println("生产者发送消息:"+ JSON.toJSONString(value)); |
|||
producer.send(msg,new SendCallback() { |
|||
// 异步回调的处理
|
|||
@Override |
|||
public void onSuccess(SendResult sendResult) { |
|||
System.out.printf("%-10d 异步发送消息成功 %s %n", msg, sendResult.getMsgId()); |
|||
} |
|||
@Override |
|||
public void onException(Throwable e) { |
|||
System.out.printf("%-10d 异步发送消息失败 %s %n", msg, e); |
|||
e.printStackTrace(); |
|||
} |
|||
}); |
|||
} catch (MQClientException e) { |
|||
e.printStackTrace(); |
|||
} catch (RemotingException e) { |
|||
e.printStackTrace(); |
|||
} catch (InterruptedException e) { |
|||
e.printStackTrace(); |
|||
} catch (UnsupportedEncodingException e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1 @@ |
|||
org.dromara.common.rocketmq.config.ProducerConfig |
@ -0,0 +1,79 @@ |
|||
package org.dromara.sample.storage.config; |
|||
|
|||
import io.minio.MinioClient; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* Minio 配置信息 |
|||
* |
|||
* @author ruoyi |
|||
*/ |
|||
@Configuration |
|||
@ConfigurationProperties(prefix = "osstianyi") |
|||
public class OssTianyiConfig |
|||
{ |
|||
|
|||
private String endPoint; |
|||
private String accessKey; |
|||
private String secretKey; |
|||
private String bucketName; |
|||
|
|||
public String getEndPoint() { |
|||
return endPoint; |
|||
} |
|||
|
|||
public void setEndPoint(String endPoint) { |
|||
this.endPoint = endPoint; |
|||
} |
|||
|
|||
public String getAccessKey() |
|||
{ |
|||
return accessKey; |
|||
} |
|||
|
|||
public void setAccessKey(String accessKey) |
|||
{ |
|||
this.accessKey = accessKey; |
|||
} |
|||
|
|||
public String getSecretKey() |
|||
{ |
|||
return secretKey; |
|||
} |
|||
|
|||
public void setSecretKey(String secretKey) |
|||
{ |
|||
this.secretKey = secretKey; |
|||
} |
|||
|
|||
public String getBucketName() |
|||
{ |
|||
return bucketName; |
|||
} |
|||
|
|||
public void setBucketName(String bucketName) |
|||
{ |
|||
this.bucketName = bucketName; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "OssTianyiConfig{" + |
|||
"endPoint='" + endPoint + '\'' + |
|||
", accessKey='" + accessKey + '\'' + |
|||
", secretKey='" + secretKey + '\'' + |
|||
", bucketName='" + bucketName + '\'' + |
|||
'}'; |
|||
} |
|||
|
|||
@Bean |
|||
public MinioClient getMinioClient() |
|||
{ |
|||
// System.out.println("OssTianyiConfig");
|
|||
// System.out.println("OssTianyiConfig" + endPoint);
|
|||
System.out.println(toString()); |
|||
return MinioClient.builder().endpoint(endPoint).credentials(accessKey, secretKey).build(); |
|||
} |
|||
} |
@ -0,0 +1,58 @@ |
|||
package org.dromara.sample.storage.controller; |
|||
|
|||
|
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.sample.storage.domain.SysUploadFile; |
|||
import org.dromara.sample.storage.util.OssTianyiClientUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.util.HashMap; |
|||
|
|||
/** |
|||
* 系统上传文件Controller |
|||
* |
|||
* @author tom |
|||
* @date 2024-12-21 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/ossTianyi") |
|||
public class OssTianyiController extends BaseController |
|||
{ |
|||
|
|||
@Autowired |
|||
private OssTianyiClientUtils ossTianyiClientUtils; |
|||
|
|||
/** |
|||
* 查询系统上传文件列表 (实际是上传接口) |
|||
*/ |
|||
@SaCheckPermission("file:sysUploadFile:list") |
|||
@GetMapping("/list") |
|||
public TableDataInfo list(SysUploadFile sysUploadFile) |
|||
{ |
|||
String localFilePath = "D:\\123pan\\page.html"; |
|||
try{ |
|||
ossTianyiClientUtils.uploadFileTest("page.html","dev/temp",localFilePath); |
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
@GetMapping("/upload") |
|||
public R<HashMap<String, Object>> upload(@RequestPart("file") MultipartFile file) { |
|||
try { |
|||
ossTianyiClientUtils.uploadFile("page.html", "dev/temp", file); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,211 @@ |
|||
package org.dromara.sample.storage.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import org.apache.commons.lang3.builder.ToStringBuilder; |
|||
import org.apache.commons.lang3.builder.ToStringStyle; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
|
|||
/** |
|||
* 系统上传文件对象 sys_upload_file |
|||
* |
|||
* @author tom |
|||
* @date 2024-12-21 |
|||
*/ |
|||
@TableName("sys_upload_file") |
|||
public class SysUploadFile extends BaseEntity |
|||
{ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** ID */ |
|||
@TableId(value="id",type = IdType.AUTO) |
|||
private Long id; |
|||
|
|||
/** 删除标记 */ |
|||
@TableField("del_flag") |
|||
private Long delFlag; |
|||
|
|||
/** 文件名称 */ |
|||
@TableField("name") |
|||
private String name; |
|||
|
|||
/** 上传时文件名 */ |
|||
@TableField("file_name") |
|||
private String fileName; |
|||
|
|||
/** 物理路径 */ |
|||
@TableField("path") |
|||
private String path; |
|||
|
|||
/** 文件URL */ |
|||
@TableField("url") |
|||
private String url; |
|||
|
|||
/** 文件扩展名 */ |
|||
@TableField("extend") |
|||
private String extend; |
|||
|
|||
/** 文件类型 */ |
|||
@TableField("dict_file_type") |
|||
private Long dictFileType; |
|||
|
|||
/** 关联对象ID */ |
|||
@TableField("object_id") |
|||
private Long objectId; |
|||
|
|||
/** 关联对象类型 */ |
|||
@TableField("object_type") |
|||
private String objectType; |
|||
|
|||
/** 关联对象ID */ |
|||
@TableField("object_link_id") |
|||
private String objectLinkId; |
|||
|
|||
/** 排序 */ |
|||
@TableField("sort") |
|||
private Long sort; |
|||
|
|||
/** 标签 */ |
|||
@TableField("tags") |
|||
private String tags; |
|||
|
|||
public void setId(Long id) |
|||
{ |
|||
this.id = id; |
|||
} |
|||
|
|||
public Long getId() |
|||
{ |
|||
return id; |
|||
} |
|||
public void setDelFlag(Long delFlag) |
|||
{ |
|||
this.delFlag = delFlag; |
|||
} |
|||
|
|||
public Long getDelFlag() |
|||
{ |
|||
return delFlag; |
|||
} |
|||
public void setName(String name) |
|||
{ |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getName() |
|||
{ |
|||
return name; |
|||
} |
|||
public void setFileName(String fileName) |
|||
{ |
|||
this.fileName = fileName; |
|||
} |
|||
|
|||
public String getFileName() |
|||
{ |
|||
return fileName; |
|||
} |
|||
public void setPath(String path) |
|||
{ |
|||
this.path = path; |
|||
} |
|||
|
|||
public String getPath() |
|||
{ |
|||
return path; |
|||
} |
|||
public void setUrl(String url) |
|||
{ |
|||
this.url = url; |
|||
} |
|||
|
|||
public String getUrl() |
|||
{ |
|||
return url; |
|||
} |
|||
public void setExtend(String extend) |
|||
{ |
|||
this.extend = extend; |
|||
} |
|||
|
|||
public String getExtend() |
|||
{ |
|||
return extend; |
|||
} |
|||
public void setDictFileType(Long dictFileType) |
|||
{ |
|||
this.dictFileType = dictFileType; |
|||
} |
|||
|
|||
public Long getDictFileType() |
|||
{ |
|||
return dictFileType; |
|||
} |
|||
public void setObjectId(Long objectId) |
|||
{ |
|||
this.objectId = objectId; |
|||
} |
|||
|
|||
public Long getObjectId() |
|||
{ |
|||
return objectId; |
|||
} |
|||
public void setObjectType(String objectType) |
|||
{ |
|||
this.objectType = objectType; |
|||
} |
|||
|
|||
public String getObjectType() |
|||
{ |
|||
return objectType; |
|||
} |
|||
|
|||
public String getObjectLinkId() { |
|||
return objectLinkId; |
|||
} |
|||
|
|||
public void setObjectLinkId(String objectLinkId) { |
|||
this.objectLinkId = objectLinkId; |
|||
} |
|||
|
|||
public void setSort(Long sort) |
|||
{ |
|||
this.sort = sort; |
|||
} |
|||
|
|||
public Long getSort() |
|||
{ |
|||
return sort; |
|||
} |
|||
|
|||
public String getTags() { |
|||
return tags; |
|||
} |
|||
|
|||
public void setTags(String tags) { |
|||
this.tags = tags; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
|||
.append("id", getId()) |
|||
.append("createBy", getCreateBy()) |
|||
.append("createTime", getCreateTime()) |
|||
.append("updateBy", getUpdateBy()) |
|||
.append("updateTime", getUpdateTime()) |
|||
.append("delFlag", getDelFlag()) |
|||
.append("name", getName()) |
|||
.append("fileName", getFileName()) |
|||
.append("path", getPath()) |
|||
.append("url", getUrl()) |
|||
.append("extend", getExtend()) |
|||
.append("dictFileType", getDictFileType()) |
|||
.append("objectId", getObjectId()) |
|||
.append("objectType", getObjectType()) |
|||
.append("sort", getSort()) |
|||
.toString(); |
|||
} |
|||
} |
@ -0,0 +1,174 @@ |
|||
package org.dromara.sample.storage.util; |
|||
|
|||
import cn.hutool.core.io.FileUtil; |
|||
import io.minio.*; |
|||
import io.minio.errors.*; |
|||
import io.minio.messages.Item; |
|||
import org.dromara.sample.storage.config.OssTianyiConfig; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.io.BufferedInputStream; |
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.nio.file.Files; |
|||
import java.security.InvalidKeyException; |
|||
import java.security.NoSuchAlgorithmException; |
|||
|
|||
@Component |
|||
public class OssTianyiClientUtils { |
|||
|
|||
private static MinioClient minioClient; |
|||
|
|||
// private static String endPoint = "https://jiangsu-10.zos.ctyun.cn"; //地域节点,可访问
|
|||
// // private static String endPoint = "https://dk-ty-oss-bucket.jiangsu-10.zos.ctyun.cn"; //说是桶的域名地址,支持公网访问ZOS,实测报错
|
|||
// private static String minioAccessKey = "22e3f37368a242b38f4f25d98c9baf1f";
|
|||
// private static String minioSecretKey = "0d858850666248e59830d9a596847062";
|
|||
|
|||
// private static String bucketName = "dk-ty-oss-bucket";
|
|||
// private String bucketName = "dkossbucket";
|
|||
private String objectName = "page.html"; |
|||
//注意,天翼云里默认路径就是文件名,不需要在前面加根路径/
|
|||
private String filePath = "dev/temp/"; |
|||
private String fileDir = "dev"; |
|||
|
|||
|
|||
@Autowired |
|||
OssTianyiConfig ossTianyiConfig; |
|||
|
|||
@Autowired |
|||
public OssTianyiClientUtils(OssTianyiConfig ossTianyiConfig) { |
|||
this.ossTianyiConfig = ossTianyiConfig; |
|||
init(); |
|||
} |
|||
|
|||
private void init() { |
|||
this.minioClient = MinioClient.builder() |
|||
.endpoint(ossTianyiConfig.getEndPoint()) |
|||
.credentials(ossTianyiConfig.getAccessKey(), ossTianyiConfig.getSecretKey()) |
|||
.build(); |
|||
} |
|||
|
|||
/** |
|||
* 天翼云OSS初始化(采用S3 Compatible Storage) |
|||
*/ |
|||
// public void tianyiOssInit() {
|
|||
// minioClient = MinioClient.builder()
|
|||
// .endpoint(ossTianyiConfig.getEndPoint())
|
|||
// .credentials(ossTianyiConfig.getAccessKey(), ossTianyiConfig.getSecretKey())
|
|||
// .build();
|
|||
// }
|
|||
|
|||
/** |
|||
* 文件上传 (固定) |
|||
*/ |
|||
public void uploadFileTest(String objectName, String filePath, String localFilePath) throws Exception { |
|||
File file = new File(localFilePath); |
|||
BufferedInputStream inputStream = FileUtil.getInputStream(file); |
|||
String contentType = Files.probeContentType(file.toPath()); |
|||
if (contentType == null) { |
|||
contentType = "application/octet-stream"; |
|||
} |
|||
PutObjectArgs args = PutObjectArgs.builder() |
|||
.bucket(ossTianyiConfig.getBucketName()) |
|||
.object(filePath + objectName) |
|||
.stream(inputStream, FileUtil.size(file), -1) |
|||
.contentType(contentType) |
|||
.build(); |
|||
minioClient.putObject(args); |
|||
} |
|||
|
|||
public void uploadFile(String s, String s1, MultipartFile file) { |
|||
try { |
|||
PutObjectArgs args = PutObjectArgs.builder() |
|||
.bucket(ossTianyiConfig.getBucketName()) |
|||
.object( file.getName()) |
|||
.stream(file.getInputStream(), file.getSize(), -1) |
|||
.contentType(file.getContentType()) |
|||
.build(); |
|||
minioClient.putObject(args); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* 文件删除 |
|||
*/ |
|||
public void deleteFile(String bucketName, String objectName) throws Exception { |
|||
minioClient.removeObject( |
|||
RemoveObjectArgs.builder() |
|||
.bucket(bucketName) |
|||
.object(objectName) |
|||
.build()); |
|||
} |
|||
|
|||
/** |
|||
* 文件下载 |
|||
*/ |
|||
public void downloadFile(String bucketName, String objectName, String downloadPath) throws Exception { |
|||
InputStream inputStream = minioClient.getObject( |
|||
GetObjectArgs.builder() |
|||
.bucket(bucketName) |
|||
.object(objectName) |
|||
.build() |
|||
); |
|||
FileUtil.writeFromStream(inputStream, new File(downloadPath)); |
|||
} |
|||
|
|||
/** |
|||
* 文件列表 |
|||
* @param bucketName |
|||
* @param prefix |
|||
*/ |
|||
public void listFiles(String bucketName, String prefix) { |
|||
Iterable<Result<Item>> results = minioClient.listObjects( |
|||
ListObjectsArgs.builder() |
|||
.bucket(bucketName) |
|||
.prefix(prefix) |
|||
.recursive(true) |
|||
.build() |
|||
); |
|||
|
|||
try { |
|||
for (Result<Item> result : results) { |
|||
try { |
|||
// System.out.println("文件名:" + result.get().objectName()); // 获取对象名称(文件路径)
|
|||
System.out.println(result.get().objectName()); // 获取对象名称(文件路径)
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
System.err.println("文件读取异常: " + e.getMessage()); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
// public void updateFile(String bucketName, String objectName, String filePath, String localFilePath) throws Exception {
|
|||
// uploadFile(bucketName, objectName, filePath, localFilePath);
|
|||
// }
|
|||
|
|||
|
|||
// public static void main(String[] args) throws Exception {
|
|||
// String localFilePath = "D:\\123pan\\page.html";
|
|||
//
|
|||
// tianyiOssInit("", "", "");
|
|||
// uploadFile(bucketName, objectName, filePath, localFilePath);//正常
|
|||
//// deleteFile(bucketName, filePath + objectName);//正常
|
|||
//// listFiles(bucketName, fileDir + "/"); // 正常
|
|||
//
|
|||
//// downloadFile(bucketName, filePath + objectName, "D:\\123pan\\downloaded_page.html"); //正常
|
|||
//
|
|||
// }
|
|||
|
|||
} |
@ -0,0 +1,106 @@ |
|||
package org.dromara.system.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.validation.constraints.*; |
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
|||
import org.dromara.common.log.annotation.Log; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.log.enums.BusinessType; |
|||
import org.dromara.common.excel.utils.ExcelUtil; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigUserVo; |
|||
import org.dromara.system.domain.bo.SysSubmailConfigUserBo; |
|||
import org.dromara.system.service.ISysSubmailConfigUserService; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* 赛邮服务配置用户 |
|||
* 前端访问路由地址为:/system/sysSubmailConfigUser |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/sysSubmailConfigUser") |
|||
public class SysSubmailConfigUserController extends BaseController { |
|||
|
|||
private final ISysSubmailConfigUserService sysSubmailConfigUserService; |
|||
|
|||
/** |
|||
* 查询赛邮服务配置用户列表 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfigUser:list") |
|||
@GetMapping("/list") |
|||
public TableDataInfo<SysSubmailConfigUserVo> list(SysSubmailConfigUserBo bo, PageQuery pageQuery) { |
|||
return sysSubmailConfigUserService.queryPageList(bo, pageQuery); |
|||
} |
|||
|
|||
/** |
|||
* 导出赛邮服务配置用户列表 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfigUser:export") |
|||
@Log(title = "赛邮服务配置用户", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
public void export(SysSubmailConfigUserBo bo, HttpServletResponse response) { |
|||
List<SysSubmailConfigUserVo> list = sysSubmailConfigUserService.queryList(bo); |
|||
ExcelUtil.exportExcel(list, "赛邮服务配置用户", SysSubmailConfigUserVo.class, response); |
|||
} |
|||
|
|||
/** |
|||
* 获取赛邮服务配置用户详细信息 |
|||
* |
|||
* @param id 主键 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfigUser:query") |
|||
@GetMapping("/{id}") |
|||
public R<SysSubmailConfigUserVo> getInfo(@NotNull(message = "主键不能为空") |
|||
@PathVariable Long id) { |
|||
return R.ok(sysSubmailConfigUserService.queryById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增赛邮服务配置用户 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfigUser:add") |
|||
@Log(title = "赛邮服务配置用户", businessType = BusinessType.INSERT) |
|||
@RepeatSubmit() |
|||
@PostMapping() |
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysSubmailConfigUserBo bo) { |
|||
return toAjax(sysSubmailConfigUserService.insertByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 修改赛邮服务配置用户 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfigUser:edit") |
|||
@Log(title = "赛邮服务配置用户", businessType = BusinessType.UPDATE) |
|||
@RepeatSubmit() |
|||
@PutMapping() |
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysSubmailConfigUserBo bo) { |
|||
return toAjax(sysSubmailConfigUserService.updateByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 删除赛邮服务配置用户 |
|||
* |
|||
* @param ids 主键串 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfigUser:remove") |
|||
@Log(title = "赛邮服务配置用户", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{ids}") |
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable Long[] ids) { |
|||
return toAjax(sysSubmailConfigUserService.deleteWithValidByIds(List.of(ids), true)); |
|||
} |
|||
} |
@ -0,0 +1,217 @@ |
|||
package org.dromara.system.controller.system; |
|||
|
|||
import java.nio.file.CopyOption; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import cn.hutool.core.bean.copier.CopyOptions; |
|||
import cn.hutool.core.util.BooleanUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.http.HttpRequest; |
|||
import cn.hutool.http.HttpUtil; |
|||
import cn.hutool.json.JSONArray; |
|||
import cn.hutool.json.JSONObject; |
|||
import cn.hutool.json.JSONUtil; |
|||
import lombok.RequiredArgsConstructor; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.validation.constraints.*; |
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.dromara.common.core.utils.SpringUtils; |
|||
import org.dromara.system.domain.SysSubmailConfigUser; |
|||
import org.dromara.system.domain.SysSubmailLog; |
|||
import org.dromara.system.domain.SysUser; |
|||
import org.dromara.system.domain.bo.SysSubmailConfigUserBo; |
|||
import org.dromara.system.domain.bo.SysSubmailLogBo; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigUserVo; |
|||
import org.dromara.system.service.ISysConfigService; |
|||
import org.dromara.system.service.ISysSubmailConfigUserService; |
|||
import org.dromara.system.service.ISysSubmailLogService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
|||
import org.dromara.common.log.annotation.Log; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.log.enums.BusinessType; |
|||
import org.dromara.common.excel.utils.ExcelUtil; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigVo; |
|||
import org.dromara.system.domain.bo.SysSubmailConfigBo; |
|||
import org.dromara.system.service.ISysSubmailConfigService; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* 赛邮服务配置 |
|||
* 前端访问路由地址为:/system/sysSubmailConfig |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/submailConfig") |
|||
public class SysSubmailConfigController extends BaseController { |
|||
|
|||
private final ISysSubmailConfigService sysSubmailConfigService; |
|||
|
|||
@Autowired |
|||
private ISysSubmailConfigUserService sysSubmailConfigUserService; |
|||
|
|||
/** |
|||
* 查询赛邮服务配置列表 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfig:list") |
|||
@GetMapping("/list") |
|||
public TableDataInfo<SysSubmailConfigVo> list(SysSubmailConfigBo bo, PageQuery pageQuery) { |
|||
TableDataInfo<SysSubmailConfigVo> sysSubmailConfigVoTableDataInfo = sysSubmailConfigService.queryPageList(bo, pageQuery); |
|||
List<SysSubmailConfigVo> rows = sysSubmailConfigVoTableDataInfo.getRows(); |
|||
List<Long> configIds = rows.stream().map(SysSubmailConfigVo::getId).toList(); |
|||
|
|||
List<SysSubmailConfigUserVo> sysSubmailConfigUserVoList = sysSubmailConfigUserService.selectConfigUserByConfigIds(configIds); |
|||
for (SysSubmailConfigVo configVo : rows) { |
|||
List<SysSubmailConfigUserVo> collect = sysSubmailConfigUserVoList.stream().filter(item -> item.getSubmailConfigId().equals(configVo.getId())).collect(Collectors.toList()); |
|||
configVo.setConfigUserList(collect); |
|||
} |
|||
return sysSubmailConfigVoTableDataInfo; |
|||
} |
|||
|
|||
@SaCheckPermission("system:sysSubmailConfig:list") |
|||
@GetMapping("/listAll") |
|||
public List<SysSubmailConfigVo> listAll(SysSubmailConfigBo bo) { |
|||
return sysSubmailConfigService.queryList(bo); |
|||
} |
|||
|
|||
/** |
|||
* 导出赛邮服务配置列表 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfig:export") |
|||
@Log(title = "赛邮服务配置", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
public void export(SysSubmailConfigBo bo, HttpServletResponse response) { |
|||
List<SysSubmailConfigVo> list = sysSubmailConfigService.queryList(bo); |
|||
ExcelUtil.exportExcel(list, "赛邮服务配置", SysSubmailConfigVo.class, response); |
|||
} |
|||
|
|||
/** |
|||
* 获取赛邮服务配置详细信息 |
|||
* |
|||
* @param id 主键 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfig:query") |
|||
@GetMapping("/{id}") |
|||
public R<SysSubmailConfigVo> getInfo(@NotNull(message = "主键不能为空") |
|||
@PathVariable Long id) { |
|||
return R.ok(sysSubmailConfigService.queryById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增赛邮服务配置 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfig:add") |
|||
@Log(title = "赛邮服务配置", businessType = BusinessType.INSERT) |
|||
@RepeatSubmit() |
|||
@PostMapping() |
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysSubmailConfigBo bo) { |
|||
return toAjax(sysSubmailConfigService.insertByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 修改赛邮服务配置 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfig:edit") |
|||
@Log(title = "赛邮服务配置", businessType = BusinessType.UPDATE) |
|||
@RepeatSubmit() |
|||
@PutMapping() |
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysSubmailConfigBo bo) { |
|||
return toAjax(sysSubmailConfigService.updateByBo(bo)); |
|||
} |
|||
|
|||
//配置
|
|||
@SaCheckPermission("system:sysSubmailConfig:edit") |
|||
@Log(title = "配置赛邮服务配置用户", businessType = BusinessType.UPDATE) |
|||
@RepeatSubmit() |
|||
@PutMapping("/configUser") |
|||
public R<Void> configUser(@Validated(EditGroup.class) @RequestBody SysSubmailConfigBo bo) { |
|||
|
|||
//删除旧配置
|
|||
SysSubmailConfigUserBo userBo = new SysSubmailConfigUserBo(); |
|||
userBo.setSubmailConfigId(bo.getId()); |
|||
List<SysSubmailConfigUserVo> sysSubmailConfigUserVoList = sysSubmailConfigUserService.queryList(userBo); |
|||
List<Long> configUserIds = sysSubmailConfigUserVoList.stream().map(SysSubmailConfigUserVo::getId).toList(); |
|||
sysSubmailConfigUserService.deleteWithValidByIds(configUserIds,true); |
|||
|
|||
//保留新配置
|
|||
for (SysUser sysUser : bo.getConfigUserList()) { |
|||
SysSubmailConfigUserBo sysSubmailConfigUser = new SysSubmailConfigUserBo(); |
|||
sysSubmailConfigUser.setSubmailConfigId(bo.getId()); |
|||
sysSubmailConfigUser.setUserId(sysUser.getUserId()); |
|||
sysSubmailConfigUser.setName(sysUser.getNickName()); |
|||
sysSubmailConfigUser.setPhonenumber(sysUser.getPhonenumber()); |
|||
sysSubmailConfigUserService.insertByBo(sysSubmailConfigUser); |
|||
} |
|||
|
|||
return toAjax(1); |
|||
} |
|||
|
|||
/** |
|||
* 删除赛邮服务配置 |
|||
* |
|||
* @param ids 主键串 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailConfig:remove") |
|||
@Log(title = "赛邮服务配置", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{ids}") |
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable Long[] ids) { |
|||
return toAjax(sysSubmailConfigService.deleteWithValidByIds(List.of(ids), true)); |
|||
} |
|||
|
|||
//发送测试
|
|||
|
|||
@Autowired |
|||
private ISysSubmailLogService sysSubmailLogService; |
|||
|
|||
/** |
|||
* |
|||
* @param code 必须传参:smsMultixsend |
|||
* @param multiParam 前台传参 JSON.stringfy( {"jobName":"翟山街道华盛","labelCn":"普通垃圾","labelEn":"garbage","deptName":"翟山街道","lat":"34.20994348014929","lng":"117.2054671683176"}) |
|||
* @return |
|||
*/ |
|||
@RepeatSubmit() |
|||
@PostMapping("/cmdSend") |
|||
public R<String> cmdSend(@RequestParam("code") String code, @RequestParam("multiParam") String multiParam) { |
|||
if(StrUtil.isBlank(code)){ |
|||
return R.fail("发送类型为空"); |
|||
} |
|||
return sysSubmailConfigService.cmdSend(code, multiParam); |
|||
} |
|||
|
|||
//发送测试
|
|||
@RepeatSubmit() |
|||
@PostMapping("/autoSend") |
|||
public R<String> autoSend(@Validated(AddGroup.class) @RequestBody SysSubmailConfigBo bo) { |
|||
|
|||
//判断是否配置用户
|
|||
SysSubmailConfigUserBo mailUserQuery = new SysSubmailConfigUserBo(); |
|||
mailUserQuery.setSubmailConfigId(bo.getId()); |
|||
List<SysSubmailConfigUserVo> sysSubmailConfigUserVoList = sysSubmailConfigUserService.queryList(mailUserQuery); |
|||
List<SysSubmailConfigUserVo> configUserVoList = sysSubmailConfigUserVoList.stream().filter(item -> StrUtil.isNotBlank(item.getPhonenumber())).collect(Collectors.toList()); |
|||
if(configUserVoList.size() <= 0) { |
|||
return R.fail("暂无配置有效用户"); |
|||
} |
|||
|
|||
String result = sysSubmailConfigService.submailSendUtil(bo, configUserVoList); |
|||
|
|||
return R.ok(result); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,106 @@ |
|||
package org.dromara.system.controller.system; |
|||
|
|||
import java.util.List; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.validation.constraints.*; |
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
|||
import org.dromara.common.log.annotation.Log; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.log.enums.BusinessType; |
|||
import org.dromara.common.excel.utils.ExcelUtil; |
|||
import org.dromara.system.domain.vo.SysSubmailLogVo; |
|||
import org.dromara.system.domain.bo.SysSubmailLogBo; |
|||
import org.dromara.system.service.ISysSubmailLogService; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* 赛邮服务发送log |
|||
* 前端访问路由地址为:/system/sysSubmailLog |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/submailLog") |
|||
public class SysSubmailLogController extends BaseController { |
|||
|
|||
private final ISysSubmailLogService sysSubmailLogService; |
|||
|
|||
/** |
|||
* 查询赛邮服务发送log列表 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailLog:list") |
|||
@GetMapping("/list") |
|||
public TableDataInfo<SysSubmailLogVo> list(SysSubmailLogBo bo, PageQuery pageQuery) { |
|||
return sysSubmailLogService.queryPageList(bo, pageQuery); |
|||
} |
|||
|
|||
/** |
|||
* 导出赛邮服务发送log列表 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailLog:export") |
|||
@Log(title = "赛邮服务发送log", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
public void export(SysSubmailLogBo bo, HttpServletResponse response) { |
|||
List<SysSubmailLogVo> list = sysSubmailLogService.queryList(bo); |
|||
ExcelUtil.exportExcel(list, "赛邮服务发送log", SysSubmailLogVo.class, response); |
|||
} |
|||
|
|||
/** |
|||
* 获取赛邮服务发送log详细信息 |
|||
* |
|||
* @param id 主键 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailLog:query") |
|||
@GetMapping("/{id}") |
|||
public R<SysSubmailLogVo> getInfo(@NotNull(message = "主键不能为空") |
|||
@PathVariable Long id) { |
|||
return R.ok(sysSubmailLogService.queryById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增赛邮服务发送log |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailLog:add") |
|||
@Log(title = "赛邮服务发送log", businessType = BusinessType.INSERT) |
|||
@RepeatSubmit() |
|||
@PostMapping() |
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysSubmailLogBo bo) { |
|||
return toAjax(sysSubmailLogService.insertByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 修改赛邮服务发送log |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailLog:edit") |
|||
@Log(title = "赛邮服务发送log", businessType = BusinessType.UPDATE) |
|||
@RepeatSubmit() |
|||
@PutMapping() |
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysSubmailLogBo bo) { |
|||
return toAjax(sysSubmailLogService.updateByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 删除赛邮服务发送log |
|||
* |
|||
* @param ids 主键串 |
|||
*/ |
|||
@SaCheckPermission("system:sysSubmailLog:remove") |
|||
@Log(title = "赛邮服务发送log", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{ids}") |
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable Long[] ids) { |
|||
return toAjax(sysSubmailLogService.deleteWithValidByIds(List.of(ids), true)); |
|||
} |
|||
} |
@ -0,0 +1,92 @@ |
|||
package org.dromara.system.domain; |
|||
|
|||
import org.dromara.common.tenant.core.TenantEntity; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* 赛邮服务配置对象 sys_submail_config |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@TableName("sys_submail_config") |
|||
public class SysSubmailConfig extends TenantEntity { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 字典编码 |
|||
*/ |
|||
@TableId(value = "id") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 接口名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 接口编码 |
|||
*/ |
|||
private String code; |
|||
|
|||
/** |
|||
* 赛邮类型(Mail, Message,Voice,Internationalsms,Mobiledata) |
|||
*/ |
|||
private String type; |
|||
|
|||
/** |
|||
* 接口Url |
|||
*/ |
|||
private String url; |
|||
|
|||
/** |
|||
* AppId |
|||
*/ |
|||
private String appid; |
|||
|
|||
/** |
|||
* signature |
|||
*/ |
|||
private String signature; |
|||
private String project; //模板编码
|
|||
|
|||
/** |
|||
* tag参数 |
|||
*/ |
|||
private String tag; |
|||
|
|||
/** |
|||
* UNIX 时间戳 |
|||
*/ |
|||
private String timestamp; |
|||
|
|||
/** |
|||
* API 授权模式(normal) |
|||
*/ |
|||
private String signType; |
|||
|
|||
/** |
|||
* signature加密计算方式 |
|||
*/ |
|||
private String signVersion; |
|||
|
|||
/** |
|||
* 最新反馈状态(1是 0否) |
|||
*/ |
|||
private String latestResStatus; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,52 @@ |
|||
package org.dromara.system.domain; |
|||
|
|||
import org.dromara.common.tenant.core.TenantEntity; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* 赛邮服务配置用户对象 sys_submail_config_user |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@TableName("sys_submail_config_user") |
|||
public class SysSubmailConfigUser extends TenantEntity { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* ID |
|||
*/ |
|||
@TableId(value = "id") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 赛邮配置ID |
|||
*/ |
|||
private Long submailConfigId; |
|||
private Long userId; |
|||
|
|||
/** |
|||
* 用户名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String phonenumber; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,109 @@ |
|||
package org.dromara.system.domain; |
|||
|
|||
import org.dromara.common.tenant.core.TenantEntity; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* 赛邮服务发送log对象 sys_submail_log |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@TableName("sys_submail_log") |
|||
public class SysSubmailLog extends TenantEntity { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 字典编码 |
|||
*/ |
|||
@TableId(value = "id") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 赛邮配置ID |
|||
*/ |
|||
private Long submailConfigId; |
|||
|
|||
/** |
|||
* 接口名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 接口编码 |
|||
*/ |
|||
private String code; |
|||
|
|||
/** |
|||
* 接口Url |
|||
*/ |
|||
private String url; |
|||
|
|||
/** |
|||
* 接收人 |
|||
*/ |
|||
// @TableField("to_receiver")
|
|||
private String toReceiver; |
|||
|
|||
/** |
|||
* 内容 |
|||
*/ |
|||
private String content; |
|||
|
|||
/** |
|||
* 模板编码 |
|||
*/ |
|||
private String project; |
|||
|
|||
/** |
|||
* 整合文本 |
|||
*/ |
|||
private String multi; |
|||
|
|||
/** |
|||
* 动态变量 |
|||
*/ |
|||
private String vars; |
|||
|
|||
/** |
|||
* tag参数 |
|||
*/ |
|||
private String tag; |
|||
|
|||
/** |
|||
* UNIX 时间戳 |
|||
*/ |
|||
private String timestamp; |
|||
|
|||
/** |
|||
* API 授权模式(normal) |
|||
*/ |
|||
private String signType; |
|||
|
|||
/** |
|||
* signature加密计算方式 |
|||
*/ |
|||
private String signVersion; |
|||
|
|||
/** |
|||
* 最新反馈状态(1是 0否) |
|||
*/ |
|||
private String latestResStatus; |
|||
|
|||
private String result; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,117 @@ |
|||
package org.dromara.system.domain.bo; |
|||
|
|||
import org.dromara.system.domain.SysSubmailConfig; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import jakarta.validation.constraints.*; |
|||
import org.dromara.system.domain.SysUser; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 赛邮服务配置业务对象 sys_submail_config |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@AutoMapper(target = SysSubmailConfig.class, reverseConvertGenerate = false) |
|||
public class SysSubmailConfigBo extends BaseEntity { |
|||
|
|||
/** |
|||
* 字典编码 |
|||
*/ |
|||
@NotNull(message = "ID不能为空", groups = { EditGroup.class }) |
|||
private Long id; |
|||
|
|||
/** |
|||
* 接口名称 |
|||
*/ |
|||
@NotBlank(message = "接口名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String name; |
|||
|
|||
/** |
|||
* 接口编码 |
|||
*/ |
|||
@NotBlank(message = "接口编码不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String code; |
|||
|
|||
/** |
|||
* 赛邮类型(Mail, Message,Voice,Internationalsms,Mobiledata) |
|||
*/ |
|||
@NotBlank(message = "赛邮类型(Mail, Message,Voice,Internationalsms,Mobiledata)不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String type; |
|||
|
|||
/** |
|||
* 接口Url |
|||
*/ |
|||
@NotBlank(message = "接口Url不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String url; |
|||
|
|||
/** |
|||
* AppId |
|||
*/ |
|||
@NotBlank(message = "AppId不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String appid; |
|||
|
|||
/** |
|||
* signature |
|||
*/ |
|||
@NotBlank(message = "signature不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String signature; |
|||
private String project; //模板编码
|
|||
|
|||
/** |
|||
* tag参数 |
|||
*/ |
|||
// @NotBlank(message = "tag参数不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String tag; |
|||
|
|||
/** |
|||
* UNIX 时间戳 |
|||
*/ |
|||
// @NotBlank(message = "UNIX 时间戳不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String timestamp; |
|||
|
|||
/** |
|||
* API 授权模式(normal) |
|||
*/ |
|||
// @NotBlank(message = "API 授权模式(normal)不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String signType; |
|||
|
|||
/** |
|||
* signature加密计算方式 |
|||
*/ |
|||
// @NotBlank(message = "signature加密计算方式不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String signVersion; |
|||
|
|||
/** |
|||
* 最新反馈状态(1是 0否) |
|||
*/ |
|||
// @NotBlank(message = "最新反馈状态(1是 0否)不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String latestResStatus; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
// @NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String remark; |
|||
|
|||
|
|||
|
|||
//发送传参
|
|||
private String to; //接收人
|
|||
private String content; //内容
|
|||
private String multi; //整合文本
|
|||
private String multiParam; //整合文本-单个参数(适合批量发送)
|
|||
private String vars; //动态变量
|
|||
private Long[] configUserIds; //动态变量
|
|||
private List<SysUser> configUserList; //动态变量
|
|||
|
|||
|
|||
} |
@ -0,0 +1,58 @@ |
|||
package org.dromara.system.domain.bo; |
|||
|
|||
import org.dromara.system.domain.SysSubmailConfigUser; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
/** |
|||
* 赛邮服务配置用户业务对象 sys_submail_config_user |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@AutoMapper(target = SysSubmailConfigUser.class, reverseConvertGenerate = false) |
|||
public class SysSubmailConfigUserBo extends BaseEntity { |
|||
|
|||
/** |
|||
* ID |
|||
*/ |
|||
@NotNull(message = "ID不能为空", groups = { EditGroup.class }) |
|||
private Long id; |
|||
|
|||
/** |
|||
* 赛邮配置ID |
|||
*/ |
|||
@NotNull(message = "赛邮配置ID不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private Long submailConfigId; |
|||
|
|||
@NotNull(message = "用户ID不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private Long userId; |
|||
|
|||
|
|||
/** |
|||
* 用户名称 |
|||
*/ |
|||
@NotBlank(message = "用户名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String name; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
@NotBlank(message = "手机号不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String phonenumber; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,126 @@ |
|||
package org.dromara.system.domain.bo; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import org.dromara.system.domain.SysSubmailLog; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
/** |
|||
* 赛邮服务发送log业务对象 sys_submail_log |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@AutoMapper(target = SysSubmailLog.class, reverseConvertGenerate = false) |
|||
public class SysSubmailLogBo extends BaseEntity { |
|||
|
|||
/** |
|||
* 字典编码 |
|||
*/ |
|||
@NotNull(message = "字典编码不能为空", groups = { EditGroup.class }) |
|||
private Long id; |
|||
|
|||
/** |
|||
* 赛邮配置ID |
|||
*/ |
|||
@NotNull(message = "赛邮配置ID不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private Long submailConfigId; |
|||
|
|||
/** |
|||
* 接口名称 |
|||
*/ |
|||
@NotBlank(message = "接口名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String name; |
|||
|
|||
/** |
|||
* 接口编码 |
|||
*/ |
|||
// @NotBlank(message = "接口编码不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String code; |
|||
|
|||
/** |
|||
* 接口Url |
|||
*/ |
|||
@NotBlank(message = "接口Url不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String url; |
|||
|
|||
/** |
|||
* 接收人 |
|||
*/ |
|||
// @NotBlank(message = "接收人不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
// @TableField("to_receiver")
|
|||
// private String to;
|
|||
private String toReceiver; |
|||
|
|||
/** |
|||
* 内容 |
|||
*/ |
|||
// @NotBlank(message = "内容不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String content; |
|||
|
|||
/** |
|||
* 模板编码 |
|||
*/ |
|||
// @NotBlank(message = "模板编码不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String project; |
|||
|
|||
/** |
|||
* 整合文本 |
|||
*/ |
|||
// @NotBlank(message = "整合文本不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String multi; |
|||
|
|||
/** |
|||
* 动态变量 |
|||
*/ |
|||
// @NotBlank(message = "动态变量不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String vars; |
|||
|
|||
/** |
|||
* tag参数 |
|||
*/ |
|||
// @NotBlank(message = "tag参数不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String tag; |
|||
|
|||
/** |
|||
* UNIX 时间戳 |
|||
*/ |
|||
// @NotBlank(message = "UNIX 时间戳不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String timestamp; |
|||
|
|||
/** |
|||
* API 授权模式(normal) |
|||
*/ |
|||
// @NotBlank(message = "API 授权模式(normal)不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String signType; |
|||
|
|||
/** |
|||
* signature加密计算方式 |
|||
*/ |
|||
// @NotBlank(message = "signature加密计算方式不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String signVersion; |
|||
|
|||
/** |
|||
* 最新反馈状态(1是 0否) |
|||
*/ |
|||
// @NotBlank(message = "最新反馈状态(1是 0否)不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String latestResStatus; |
|||
|
|||
private String result; |
|||
|
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
// @NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
|
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
package org.dromara.system.domain.vo; |
|||
|
|||
import org.dromara.system.domain.SysSubmailConfigUser; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import org.dromara.common.excel.annotation.ExcelDictFormat; |
|||
import org.dromara.common.excel.convert.ExcelDictConvert; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 赛邮服务配置用户视图对象 sys_submail_config_user |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = SysSubmailConfigUser.class) |
|||
public class SysSubmailConfigUserVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* ID |
|||
*/ |
|||
@ExcelProperty(value = "ID") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 赛邮配置ID |
|||
*/ |
|||
@ExcelProperty(value = "赛邮配置ID") |
|||
private Long submailConfigId; |
|||
|
|||
|
|||
@ExcelProperty(value = "用户ID") |
|||
private Long userId; |
|||
|
|||
|
|||
/** |
|||
* 用户名称 |
|||
*/ |
|||
@ExcelProperty(value = "用户名称") |
|||
private String name; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
@ExcelProperty(value = "手机号") |
|||
private String phonenumber; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
@ExcelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,115 @@ |
|||
package org.dromara.system.domain.vo; |
|||
|
|||
import org.dromara.system.domain.SysSubmailConfig; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import org.dromara.common.excel.annotation.ExcelDictFormat; |
|||
import org.dromara.common.excel.convert.ExcelDictConvert; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import org.dromara.system.domain.SysUser; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 赛邮服务配置视图对象 sys_submail_config |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = SysSubmailConfig.class) |
|||
public class SysSubmailConfigVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 字典编码 |
|||
*/ |
|||
@ExcelProperty(value = "字典编码") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 接口名称 |
|||
*/ |
|||
@ExcelProperty(value = "接口名称") |
|||
private String name; |
|||
|
|||
/** |
|||
* 接口编码 |
|||
*/ |
|||
@ExcelProperty(value = "接口编码") |
|||
private String code; |
|||
|
|||
/** |
|||
* 赛邮类型(Mail, Message,Voice,Internationalsms,Mobiledata) |
|||
*/ |
|||
@ExcelProperty(value = "赛邮类型(Mail, Message,Voice,Internationalsms,Mobiledata)") |
|||
private String type; |
|||
|
|||
/** |
|||
* 接口Url |
|||
*/ |
|||
@ExcelProperty(value = "接口Url") |
|||
private String url; |
|||
|
|||
/** |
|||
* AppId |
|||
*/ |
|||
@ExcelProperty(value = "AppId") |
|||
private String appid; |
|||
|
|||
/** |
|||
* signature |
|||
*/ |
|||
@ExcelProperty(value = "signature") |
|||
private String signature; |
|||
private String project; //模板编码
|
|||
/** |
|||
* tag参数 |
|||
*/ |
|||
@ExcelProperty(value = "tag参数") |
|||
private String tag; |
|||
|
|||
/** |
|||
* UNIX 时间戳 |
|||
*/ |
|||
@ExcelProperty(value = "UNIX 时间戳") |
|||
private String timestamp; |
|||
|
|||
/** |
|||
* API 授权模式(normal) |
|||
*/ |
|||
@ExcelProperty(value = "API 授权模式(normal)") |
|||
private String signType; |
|||
|
|||
/** |
|||
* signature加密计算方式 |
|||
*/ |
|||
@ExcelProperty(value = "signature加密计算方式") |
|||
private String signVersion; |
|||
|
|||
/** |
|||
* 最新反馈状态(1是 0否) |
|||
*/ |
|||
@ExcelProperty(value = "最新反馈状态", converter = ExcelDictConvert.class) |
|||
@ExcelDictFormat(dictType = "sys_yes_no") |
|||
private String latestResStatus; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
@ExcelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
private Long[] configUserIds; //动态变量
|
|||
private List<SysSubmailConfigUserVo> configUserList; //动态变量
|
|||
|
|||
|
|||
} |
@ -0,0 +1,134 @@ |
|||
package org.dromara.system.domain.vo; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import org.dromara.system.domain.SysSubmailLog; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import org.dromara.common.excel.annotation.ExcelDictFormat; |
|||
import org.dromara.common.excel.convert.ExcelDictConvert; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 赛邮服务发送log视图对象 sys_submail_log |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = SysSubmailLog.class) |
|||
public class SysSubmailLogVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 字典编码 |
|||
*/ |
|||
@ExcelProperty(value = "字典编码") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 赛邮配置ID |
|||
*/ |
|||
@ExcelProperty(value = "赛邮配置ID") |
|||
private Long submailConfigId; |
|||
|
|||
/** |
|||
* 接口名称 |
|||
*/ |
|||
@ExcelProperty(value = "接口名称") |
|||
private String name; |
|||
|
|||
/** |
|||
* 接口编码 |
|||
*/ |
|||
@ExcelProperty(value = "接口编码") |
|||
private String code; |
|||
|
|||
/** |
|||
* 接口Url |
|||
*/ |
|||
@ExcelProperty(value = "接口Url") |
|||
private String url; |
|||
|
|||
/** |
|||
* 接收人 |
|||
*/ |
|||
@ExcelProperty(value = "接收人") |
|||
// @TableField("to_receiver")
|
|||
private String toReceiver; |
|||
|
|||
/** |
|||
* 内容 |
|||
*/ |
|||
@ExcelProperty(value = "内容") |
|||
private String content; |
|||
|
|||
/** |
|||
* 模板编码 |
|||
*/ |
|||
@ExcelProperty(value = "模板编码") |
|||
private String project; |
|||
|
|||
/** |
|||
* 整合文本 |
|||
*/ |
|||
@ExcelProperty(value = "整合文本") |
|||
private String multi; |
|||
|
|||
/** |
|||
* 动态变量 |
|||
*/ |
|||
@ExcelProperty(value = "动态变量") |
|||
private String vars; |
|||
|
|||
/** |
|||
* tag参数 |
|||
*/ |
|||
@ExcelProperty(value = "tag参数") |
|||
private String tag; |
|||
|
|||
/** |
|||
* UNIX 时间戳 |
|||
*/ |
|||
@ExcelProperty(value = "UNIX 时间戳") |
|||
private String timestamp; |
|||
|
|||
/** |
|||
* API 授权模式(normal) |
|||
*/ |
|||
@ExcelProperty(value = "API 授权模式(normal)") |
|||
private String signType; |
|||
|
|||
/** |
|||
* signature加密计算方式 |
|||
*/ |
|||
@ExcelProperty(value = "signature加密计算方式") |
|||
private String signVersion; |
|||
|
|||
/** |
|||
* 最新反馈状态(1是 0否) |
|||
*/ |
|||
@ExcelProperty(value = "最新反馈状态", converter = ExcelDictConvert.class) |
|||
@ExcelDictFormat(dictType = "sys_yes_no") |
|||
private String latestResStatus; |
|||
|
|||
@ExcelProperty(value = "返回结果") |
|||
private String result; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
@ExcelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
|
|||
} |
@ -0,0 +1,39 @@ |
|||
package org.dromara.system.dubbo; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.apache.dubbo.config.annotation.DubboService; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.system.api.RemoteClientService; |
|||
import org.dromara.system.api.RemoteSubmailConfigService; |
|||
import org.dromara.system.api.domain.vo.RemoteClientVo; |
|||
import org.dromara.system.domain.vo.SysClientVo; |
|||
import org.dromara.system.service.ISysClientService; |
|||
import org.dromara.system.service.ISysSubmailConfigService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 客户端服务 |
|||
* |
|||
* @author Michelle.Chung |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
@DubboService |
|||
public class RemoteSubmailConfigServiceImpl implements RemoteSubmailConfigService { |
|||
|
|||
|
|||
private final ISysSubmailConfigService sysSubmailConfigService; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* @param code 必须传参:smsMultixsend |
|||
* @param multiParam 前台传参 JSON.stringfy( {"jobName":"翟山街道华盛","labelCn":"普通垃圾","labelEn":"garbage","deptName":"翟山街道","lat":"34.20994348014929","lng":"117.2054671683176"}) |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public R<String> remoteCmdSend(String code, String multiParam) { |
|||
return sysSubmailConfigService.cmdSend(code, multiParam); |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
package org.dromara.system.mapper; |
|||
|
|||
import org.dromara.system.domain.SysSubmailConfig; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* 赛邮服务配置Mapper接口 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
public interface SysSubmailConfigMapper extends BaseMapperPlus<SysSubmailConfig, SysSubmailConfigVo> { |
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package org.dromara.system.mapper; |
|||
|
|||
import org.dromara.system.domain.SysSubmailConfigUser; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigUserVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* 赛邮服务配置用户Mapper接口 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
public interface SysSubmailConfigUserMapper extends BaseMapperPlus<SysSubmailConfigUser, SysSubmailConfigUserVo> { |
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package org.dromara.system.mapper; |
|||
|
|||
import org.dromara.system.domain.SysSubmailLog; |
|||
import org.dromara.system.domain.vo.SysSubmailLogVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* 赛邮服务发送logMapper接口 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
public interface SysSubmailLogMapper extends BaseMapperPlus<SysSubmailLog, SysSubmailLogVo> { |
|||
|
|||
} |
@ -0,0 +1,75 @@ |
|||
package org.dromara.system.service; |
|||
|
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.system.domain.SysSubmailConfig; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigUserVo; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigVo; |
|||
import org.dromara.system.domain.bo.SysSubmailConfigBo; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 赛邮服务配置Service接口 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
public interface ISysSubmailConfigService { |
|||
|
|||
/** |
|||
* 查询赛邮服务配置 |
|||
* |
|||
* @param id 主键 |
|||
* @return 赛邮服务配置 |
|||
*/ |
|||
SysSubmailConfigVo queryById(Long id); |
|||
|
|||
/** |
|||
* 分页查询赛邮服务配置列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 赛邮服务配置分页列表 |
|||
*/ |
|||
TableDataInfo<SysSubmailConfigVo> queryPageList(SysSubmailConfigBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的赛邮服务配置列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 赛邮服务配置列表 |
|||
*/ |
|||
List<SysSubmailConfigVo> queryList(SysSubmailConfigBo bo); |
|||
|
|||
/** |
|||
* 新增赛邮服务配置 |
|||
* |
|||
* @param bo 赛邮服务配置 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(SysSubmailConfigBo bo); |
|||
|
|||
/** |
|||
* 修改赛邮服务配置 |
|||
* |
|||
* @param bo 赛邮服务配置 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(SysSubmailConfigBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除赛邮服务配置信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
|||
|
|||
R<String> cmdSend(String code, String multiParam); |
|||
|
|||
String submailSendUtil(SysSubmailConfigBo bo, List<SysSubmailConfigUserVo> configUserVoList); |
|||
} |
@ -0,0 +1,73 @@ |
|||
package org.dromara.system.service; |
|||
|
|||
import org.dromara.system.domain.SysSubmailConfigUser; |
|||
import org.dromara.system.domain.bo.SysSubmailConfigBo; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigUserVo; |
|||
import org.dromara.system.domain.bo.SysSubmailConfigUserBo; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 赛邮服务配置用户Service接口 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
public interface ISysSubmailConfigUserService { |
|||
|
|||
/** |
|||
* 查询赛邮服务配置用户 |
|||
* |
|||
* @param id 主键 |
|||
* @return 赛邮服务配置用户 |
|||
*/ |
|||
SysSubmailConfigUserVo queryById(Long id); |
|||
|
|||
/** |
|||
* 分页查询赛邮服务配置用户列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 赛邮服务配置用户分页列表 |
|||
*/ |
|||
TableDataInfo<SysSubmailConfigUserVo> queryPageList(SysSubmailConfigUserBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的赛邮服务配置用户列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 赛邮服务配置用户列表 |
|||
*/ |
|||
List<SysSubmailConfigUserVo> queryList(SysSubmailConfigUserBo bo); |
|||
|
|||
/** |
|||
* 新增赛邮服务配置用户 |
|||
* |
|||
* @param bo 赛邮服务配置用户 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(SysSubmailConfigUserBo bo); |
|||
|
|||
/** |
|||
* 修改赛邮服务配置用户 |
|||
* |
|||
* @param bo 赛邮服务配置用户 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(SysSubmailConfigUserBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除赛邮服务配置用户信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
|||
|
|||
List<SysSubmailConfigUserVo> selectConfigUserByConfigIds(List<Long> configIds); |
|||
|
|||
} |
@ -0,0 +1,69 @@ |
|||
package org.dromara.system.service; |
|||
|
|||
import org.dromara.system.domain.SysSubmailLog; |
|||
import org.dromara.system.domain.vo.SysSubmailLogVo; |
|||
import org.dromara.system.domain.bo.SysSubmailLogBo; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 赛邮服务发送logService接口 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
public interface ISysSubmailLogService { |
|||
|
|||
/** |
|||
* 查询赛邮服务发送log |
|||
* |
|||
* @param id 主键 |
|||
* @return 赛邮服务发送log |
|||
*/ |
|||
SysSubmailLogVo queryById(Long id); |
|||
|
|||
/** |
|||
* 分页查询赛邮服务发送log列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 赛邮服务发送log分页列表 |
|||
*/ |
|||
TableDataInfo<SysSubmailLogVo> queryPageList(SysSubmailLogBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的赛邮服务发送log列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 赛邮服务发送log列表 |
|||
*/ |
|||
List<SysSubmailLogVo> queryList(SysSubmailLogBo bo); |
|||
|
|||
/** |
|||
* 新增赛邮服务发送log |
|||
* |
|||
* @param bo 赛邮服务发送log |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(SysSubmailLogBo bo); |
|||
|
|||
/** |
|||
* 修改赛邮服务发送log |
|||
* |
|||
* @param bo 赛邮服务发送log |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(SysSubmailLogBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除赛邮服务发送log信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
|||
} |
@ -0,0 +1,272 @@ |
|||
package org.dromara.system.service.impl; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import cn.hutool.core.bean.copier.CopyOptions; |
|||
import cn.hutool.core.util.BooleanUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.http.HttpUtil; |
|||
import cn.hutool.json.JSONArray; |
|||
import cn.hutool.json.JSONObject; |
|||
import cn.hutool.json.JSONUtil; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.core.utils.SpringUtils; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.dromara.system.domain.bo.SysSubmailConfigUserBo; |
|||
import org.dromara.system.domain.bo.SysSubmailLogBo; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigUserVo; |
|||
import org.dromara.system.service.ISysConfigService; |
|||
import org.dromara.system.service.ISysSubmailConfigUserService; |
|||
import org.dromara.system.service.ISysSubmailLogService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.system.domain.bo.SysSubmailConfigBo; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigVo; |
|||
import org.dromara.system.domain.SysSubmailConfig; |
|||
import org.dromara.system.mapper.SysSubmailConfigMapper; |
|||
import org.dromara.system.service.ISysSubmailConfigService; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 赛邮服务配置Service业务层处理 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class SysSubmailConfigServiceImpl implements ISysSubmailConfigService { |
|||
|
|||
private final SysSubmailConfigMapper baseMapper; |
|||
|
|||
@Autowired |
|||
private ISysSubmailConfigUserService sysSubmailConfigUserService; |
|||
@Autowired |
|||
private ISysSubmailLogService sysSubmailLogService; |
|||
|
|||
/** |
|||
* 查询赛邮服务配置 |
|||
* |
|||
* @param id 主键 |
|||
* @return 赛邮服务配置 |
|||
*/ |
|||
@Override |
|||
public SysSubmailConfigVo queryById(Long id){ |
|||
return baseMapper.selectVoById(id); |
|||
} |
|||
|
|||
/** |
|||
* 分页查询赛邮服务配置列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 赛邮服务配置分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<SysSubmailConfigVo> queryPageList(SysSubmailConfigBo bo, PageQuery pageQuery) { |
|||
LambdaQueryWrapper<SysSubmailConfig> lqw = buildQueryWrapper(bo); |
|||
Page<SysSubmailConfigVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的赛邮服务配置列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 赛邮服务配置列表 |
|||
*/ |
|||
@Override |
|||
public List<SysSubmailConfigVo> queryList(SysSubmailConfigBo bo) { |
|||
LambdaQueryWrapper<SysSubmailConfig> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<SysSubmailConfig> buildQueryWrapper(SysSubmailConfigBo bo) { |
|||
Map<String, Object> params = bo.getParams(); |
|||
LambdaQueryWrapper<SysSubmailConfig> lqw = Wrappers.lambdaQuery(); |
|||
lqw.like(StringUtils.isNotBlank(bo.getName()), SysSubmailConfig::getName, bo.getName()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getCode()), SysSubmailConfig::getCode, bo.getCode()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getType()), SysSubmailConfig::getType, bo.getType()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysSubmailConfig::getUrl, bo.getUrl()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getAppid()), SysSubmailConfig::getAppid, bo.getAppid()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getSignature()), SysSubmailConfig::getSignature, bo.getSignature()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getTag()), SysSubmailConfig::getTag, bo.getTag()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getTimestamp()), SysSubmailConfig::getTimestamp, bo.getTimestamp()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getSignType()), SysSubmailConfig::getSignType, bo.getSignType()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getSignVersion()), SysSubmailConfig::getSignVersion, bo.getSignVersion()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getLatestResStatus()), SysSubmailConfig::getLatestResStatus, bo.getLatestResStatus()); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增赛邮服务配置 |
|||
* |
|||
* @param bo 赛邮服务配置 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(SysSubmailConfigBo bo) { |
|||
SysSubmailConfig add = MapstructUtils.convert(bo, SysSubmailConfig.class); |
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setId(add.getId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改赛邮服务配置 |
|||
* |
|||
* @param bo 赛邮服务配置 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(SysSubmailConfigBo bo) { |
|||
SysSubmailConfig update = MapstructUtils.convert(bo, SysSubmailConfig.class); |
|||
validEntityBeforeSave(update); |
|||
return baseMapper.updateById(update) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(SysSubmailConfig entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除赛邮服务配置信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
} |
|||
return baseMapper.deleteByIds(ids) > 0; |
|||
} |
|||
|
|||
@Override |
|||
public R<String> cmdSend(String code, String multiParam) { |
|||
|
|||
//找到生效配置
|
|||
SysSubmailConfigBo bo = new SysSubmailConfigBo(); |
|||
bo.setCode(code); |
|||
List<SysSubmailConfigVo> sysSubmailConfigVoTempList = this.queryList(bo); |
|||
if (sysSubmailConfigVoTempList.size() <= 0) { |
|||
return R.fail("暂无有效配置"); |
|||
} |
|||
SysSubmailConfigVo firstConfigVo = sysSubmailConfigVoTempList.get(0); |
|||
|
|||
BeanUtil.copyProperties(firstConfigVo,bo); |
|||
bo.setMultiParam(multiParam); |
|||
|
|||
//判断是否配置用户
|
|||
SysSubmailConfigUserBo mailUserQuery = new SysSubmailConfigUserBo(); |
|||
mailUserQuery.setSubmailConfigId(bo.getId()); |
|||
List<SysSubmailConfigUserVo> sysSubmailConfigUserVoList = sysSubmailConfigUserService.queryList(mailUserQuery); |
|||
List<SysSubmailConfigUserVo> configUserVoList = sysSubmailConfigUserVoList.stream().filter(item -> StrUtil.isNotBlank(item.getPhonenumber())).collect(Collectors.toList()); |
|||
if(configUserVoList.size() <= 0) { |
|||
return R.fail("暂无配置有效用户"); |
|||
} |
|||
|
|||
String result = submailSendUtil(bo, configUserVoList); |
|||
return R.ok(result); |
|||
} |
|||
|
|||
public String submailSendUtil(SysSubmailConfigBo bo, List<SysSubmailConfigUserVo> configUserVoList) { |
|||
String subMailSaveFlag = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("submail.log.save"); |
|||
HashMap<String, Object> postParam = new HashMap<>(); |
|||
postParam.put("appid", bo.getAppid()); |
|||
postParam.put("signature", bo.getSignature()); |
|||
|
|||
String phonenumber = configUserVoList.get(0).getPhonenumber(); |
|||
String result = ""; |
|||
switch (bo.getCode()){ |
|||
case "smsSend": //短信发送 to/content
|
|||
postParam.put("to", phonenumber); |
|||
postParam.put("content", bo.getContent()); |
|||
result = HttpUtil.post(bo.getUrl(), postParam); //JSONUtil.parseObj(result).getStr("status")
|
|||
saveConfigLog(bo, subMailSaveFlag, phonenumber, result); |
|||
break; |
|||
case "smsXsend": //短信模板发送 to/project
|
|||
postParam.put("to", phonenumber); |
|||
postParam.put("project", bo.getProject()); |
|||
postParam.put("vars", bo.getVars()); |
|||
result = HttpUtil.post(bo.getUrl(), postParam); |
|||
saveConfigLog(bo, subMailSaveFlag, phonenumber, result); |
|||
break; |
|||
case "smsMultisend": //短信一对多发送 multi
|
|||
// postParam.put("to", phonenumber);
|
|||
// postParam.put("project", bo.getProject());
|
|||
// postParam.put("vars", bo.getVars());
|
|||
// result = HttpUtil.post(bo.getUrl(), postParam);
|
|||
// saveConfigLog(bo, subMailSaveFlag, phonenumber, result);
|
|||
break; |
|||
case "smsMultixsend": //短信模板一对多发送 project/multi
|
|||
postParam.put("to", phonenumber); |
|||
postParam.put("project", bo.getProject()); |
|||
// 拼接multi
|
|||
JSONArray multiJson = new JSONArray(); |
|||
for (SysSubmailConfigUserVo sysSubmailConfigUserVo : configUserVoList) { |
|||
JSONObject entries = new JSONObject(); |
|||
entries.set("to",sysSubmailConfigUserVo.getPhonenumber()); |
|||
entries.set("vars", JSONUtil.parseObj(bo.getMultiParam())); |
|||
multiJson.add(entries); |
|||
} |
|||
String multiJsonStr = multiJson.toString(); |
|||
// postParam.put("multi", multiJson.toString());
|
|||
postParam.put("multi", multiJsonStr); |
|||
|
|||
result = HttpUtil.post(bo.getUrl(), postParam); |
|||
saveConfigLog(bo, subMailSaveFlag, phonenumber, result); |
|||
break; |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
//保存config发送log
|
|||
private void saveConfigLog(SysSubmailConfigBo bo, String subMailSaveFlag, String phonenumber, String result) { |
|||
String [] ignoreProp = {"id","createBy","createTime","updateBy","updateTime","remark"}; |
|||
|
|||
if(BooleanUtil.toBoolean(subMailSaveFlag)){ |
|||
SysSubmailLogBo sysSubmailLog = new SysSubmailLogBo(); |
|||
BeanUtil.copyProperties(bo, sysSubmailLog, CopyOptions.create().setIgnoreProperties(ignoreProp)); |
|||
sysSubmailLog.setSubmailConfigId(bo.getId()); |
|||
sysSubmailLog.setToReceiver(phonenumber); |
|||
sysSubmailLog.setContent(bo.getContent()); |
|||
String latestStatus = ""; |
|||
if(JSONUtil.isTypeJSONArray(result)) { |
|||
latestStatus = new JSONObject(JSONUtil.parseArray(result).get(0)).getStr("status"); |
|||
}else{ |
|||
latestStatus = JSONUtil.parseObj(result).getStr("status"); |
|||
} |
|||
boolean successFlag = "success".equals(latestStatus); |
|||
String latestResStatus = successFlag ? "Y" : "N"; |
|||
sysSubmailLog.setLatestResStatus(latestResStatus); |
|||
sysSubmailLog.setResult(result); |
|||
sysSubmailLogService.insertByBo(sysSubmailLog); |
|||
|
|||
//更新状态
|
|||
SysSubmailConfigBo sysSubmailConfigBo = new SysSubmailConfigBo(); |
|||
sysSubmailConfigBo.setId(bo.getId()); |
|||
sysSubmailConfigBo.setLatestResStatus(latestResStatus); |
|||
this.updateByBo(sysSubmailConfigBo); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,140 @@ |
|||
package org.dromara.system.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.system.domain.bo.SysSubmailConfigUserBo; |
|||
import org.dromara.system.domain.vo.SysSubmailConfigUserVo; |
|||
import org.dromara.system.domain.SysSubmailConfigUser; |
|||
import org.dromara.system.mapper.SysSubmailConfigUserMapper; |
|||
import org.dromara.system.service.ISysSubmailConfigUserService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* 赛邮服务配置用户Service业务层处理 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class SysSubmailConfigUserServiceImpl implements ISysSubmailConfigUserService { |
|||
|
|||
private final SysSubmailConfigUserMapper baseMapper; |
|||
|
|||
/** |
|||
* 查询赛邮服务配置用户 |
|||
* |
|||
* @param id 主键 |
|||
* @return 赛邮服务配置用户 |
|||
*/ |
|||
@Override |
|||
public SysSubmailConfigUserVo queryById(Long id){ |
|||
return baseMapper.selectVoById(id); |
|||
} |
|||
|
|||
/** |
|||
* 分页查询赛邮服务配置用户列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 赛邮服务配置用户分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<SysSubmailConfigUserVo> queryPageList(SysSubmailConfigUserBo bo, PageQuery pageQuery) { |
|||
LambdaQueryWrapper<SysSubmailConfigUser> lqw = buildQueryWrapper(bo); |
|||
Page<SysSubmailConfigUserVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的赛邮服务配置用户列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 赛邮服务配置用户列表 |
|||
*/ |
|||
@Override |
|||
public List<SysSubmailConfigUserVo> queryList(SysSubmailConfigUserBo bo) { |
|||
LambdaQueryWrapper<SysSubmailConfigUser> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<SysSubmailConfigUser> buildQueryWrapper(SysSubmailConfigUserBo bo) { |
|||
Map<String, Object> params = bo.getParams(); |
|||
LambdaQueryWrapper<SysSubmailConfigUser> lqw = Wrappers.lambdaQuery(); |
|||
lqw.eq(bo.getSubmailConfigId() != null, SysSubmailConfigUser::getSubmailConfigId, bo.getSubmailConfigId()); |
|||
lqw.like(StringUtils.isNotBlank(bo.getName()), SysSubmailConfigUser::getName, bo.getName()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getPhonenumber()), SysSubmailConfigUser::getPhonenumber, bo.getPhonenumber()); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增赛邮服务配置用户 |
|||
* |
|||
* @param bo 赛邮服务配置用户 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(SysSubmailConfigUserBo bo) { |
|||
SysSubmailConfigUser add = MapstructUtils.convert(bo, SysSubmailConfigUser.class); |
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setId(add.getId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改赛邮服务配置用户 |
|||
* |
|||
* @param bo 赛邮服务配置用户 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(SysSubmailConfigUserBo bo) { |
|||
SysSubmailConfigUser update = MapstructUtils.convert(bo, SysSubmailConfigUser.class); |
|||
validEntityBeforeSave(update); |
|||
return baseMapper.updateById(update) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(SysSubmailConfigUser entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除赛邮服务配置用户信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
} |
|||
return baseMapper.deleteByIds(ids) > 0; |
|||
} |
|||
|
|||
@Override |
|||
public List<SysSubmailConfigUserVo> selectConfigUserByConfigIds(List<Long> configIds) { |
|||
LambdaQueryWrapper<SysSubmailConfigUser> lambdaQueryWrapper = new LambdaQueryWrapper(); |
|||
lambdaQueryWrapper.in(SysSubmailConfigUser::getSubmailConfigId,configIds); |
|||
List<SysSubmailConfigUserVo> sysSubmailConfigUserVoList = baseMapper.selectVoList(lambdaQueryWrapper); |
|||
return sysSubmailConfigUserVoList; |
|||
} |
|||
} |
@ -0,0 +1,144 @@ |
|||
package org.dromara.system.service.impl; |
|||
|
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.system.domain.bo.SysSubmailLogBo; |
|||
import org.dromara.system.domain.vo.SysSubmailLogVo; |
|||
import org.dromara.system.domain.SysSubmailLog; |
|||
import org.dromara.system.mapper.SysSubmailLogMapper; |
|||
import org.dromara.system.service.ISysSubmailLogService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* 赛邮服务发送logService业务层处理 |
|||
* |
|||
* @author szs |
|||
* @date 2025-05-11 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class SysSubmailLogServiceImpl implements ISysSubmailLogService { |
|||
|
|||
private final SysSubmailLogMapper baseMapper; |
|||
|
|||
/** |
|||
* 查询赛邮服务发送log |
|||
* |
|||
* @param id 主键 |
|||
* @return 赛邮服务发送log |
|||
*/ |
|||
@Override |
|||
public SysSubmailLogVo queryById(Long id){ |
|||
return baseMapper.selectVoById(id); |
|||
} |
|||
|
|||
/** |
|||
* 分页查询赛邮服务发送log列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 赛邮服务发送log分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<SysSubmailLogVo> queryPageList(SysSubmailLogBo bo, PageQuery pageQuery) { |
|||
LambdaQueryWrapper<SysSubmailLog> lqw = buildQueryWrapper(bo); |
|||
lqw.orderByDesc(BaseEntity::getCreateTime); |
|||
Page<SysSubmailLogVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的赛邮服务发送log列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 赛邮服务发送log列表 |
|||
*/ |
|||
@Override |
|||
public List<SysSubmailLogVo> queryList(SysSubmailLogBo bo) { |
|||
LambdaQueryWrapper<SysSubmailLog> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<SysSubmailLog> buildQueryWrapper(SysSubmailLogBo bo) { |
|||
Map<String, Object> params = bo.getParams(); |
|||
LambdaQueryWrapper<SysSubmailLog> lqw = Wrappers.lambdaQuery(); |
|||
lqw.eq(bo.getSubmailConfigId() != null, SysSubmailLog::getSubmailConfigId, bo.getSubmailConfigId()); |
|||
lqw.like(StringUtils.isNotBlank(bo.getName()), SysSubmailLog::getName, bo.getName()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getCode()), SysSubmailLog::getCode, bo.getCode()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysSubmailLog::getUrl, bo.getUrl()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getToReceiver()), SysSubmailLog::getToReceiver, bo.getToReceiver()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getContent()), SysSubmailLog::getContent, bo.getContent()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getProject()), SysSubmailLog::getProject, bo.getProject()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getMulti()), SysSubmailLog::getMulti, bo.getMulti()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getVars()), SysSubmailLog::getVars, bo.getVars()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getTag()), SysSubmailLog::getTag, bo.getTag()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getTimestamp()), SysSubmailLog::getTimestamp, bo.getTimestamp()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getSignType()), SysSubmailLog::getSignType, bo.getSignType()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getSignVersion()), SysSubmailLog::getSignVersion, bo.getSignVersion()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getLatestResStatus()), SysSubmailLog::getLatestResStatus, bo.getLatestResStatus()); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增赛邮服务发送log |
|||
* |
|||
* @param bo 赛邮服务发送log |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(SysSubmailLogBo bo) { |
|||
SysSubmailLog add = MapstructUtils.convert(bo, SysSubmailLog.class); |
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setId(add.getId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改赛邮服务发送log |
|||
* |
|||
* @param bo 赛邮服务发送log |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(SysSubmailLogBo bo) { |
|||
SysSubmailLog update = MapstructUtils.convert(bo, SysSubmailLog.class); |
|||
validEntityBeforeSave(update); |
|||
return baseMapper.updateById(update) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(SysSubmailLog entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除赛邮服务发送log信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
} |
|||
return baseMapper.deleteByIds(ids) > 0; |
|||
} |
|||
} |
@ -0,0 +1,7 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="org.dromara.system.mapper.SysSubmailConfigMapper"> |
|||
|
|||
</mapper> |
@ -0,0 +1,7 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="org.dromara.system.mapper.SysSubmailConfigUserMapper"> |
|||
|
|||
</mapper> |
@ -0,0 +1,7 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="org.dromara.system.mapper.SysSubmailLogMapper"> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue