[+]增加国密SM4加解密工具包

This commit is contained in:
maimaishu
2026-01-12 11:05:28 +08:00
parent 674ef07c5a
commit 2489a7f73e
78 changed files with 6284 additions and 17 deletions

View File

@@ -0,0 +1,72 @@
package com.zt.plat.module.system.api.msg;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.module.system.api.sms.dto.log.SmsLogRespDTO;
import com.zt.plat.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO;
import com.zt.plat.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 消息发送")
public interface MsgSendApi {
String PREFIX = ApiConstants.PREFIX + "/msg/send";
@PostMapping(PREFIX + "/sendTextMsg")
@Operation(summary = "发送企业微信文本消息", description = "在 mobile 为空时,使用 userId 加载对应 Admin 的手机号")
CommonResult<Long> sendTextMsg(@Valid @RequestBody SmsSendSingleToUserReqDTO reqDTO);
@PostMapping(PREFIX + "/sendImageMsg")
@Operation(summary = "发送企业微信图片消息", description = "在 mobile 为空时,使用 userId 加载对应 Member 的手机号")
CommonResult<Long> sendImageMsg(@Valid @RequestBody SmsSendSingleToUserReqDTO reqDTO);
@GetMapping(PREFIX + "/sendVoiceMsg")
@Operation(summary = "发送企业微信语音消息")
CommonResult<SmsLogRespDTO> getSmsLog(@RequestParam("id") Long id);
@PostMapping(PREFIX + "/sendVideoMsg")
@Operation(summary = "发送企业微信视频消息", description = "在 mobile 为空时,使用 userId 加载对应 Admin 的手机号")
CommonResult<Long> sendVideoMsg(@Valid @RequestBody SmsSendSingleToUserReqDTO reqDTO);
@PostMapping(PREFIX + "/sendFileMsg")
@Operation(summary = "发送企业微信文件消息", description = "在 mobile 为空时,使用 userId 加载对应 Member 的手机号")
CommonResult<Long> sendFileMsg(@Valid @RequestBody SmsSendSingleToUserReqDTO reqDTO);
@GetMapping(PREFIX + "/sendTextCardMsg")
@Operation(summary = "发送企业微信文本卡片消息")
CommonResult<SmsLogRespDTO> sendTextCardMsg(@RequestParam("id") Long id);
@PostMapping(PREFIX + "/sendTextCardMsgPich01")
@Operation(summary = "发送企业微信文本卡片消息 -物资存货智能管理 预警信息", description = "在 mobile 为空时,使用 userId 加载对应 Admin 的手机号")
CommonResult<Long> sendTextCardMsgPich01(@Valid @RequestBody SmsSendSingleToUserReqDTO reqDTO);
@PostMapping(PREFIX + "/sendNewsMsg")
@Operation(summary = "发送企业微信图文消息", description = "在 mobile 为空时,使用 userId 加载对应 Member 的手机号")
CommonResult<Long> sendNewsMsg(@Valid @RequestBody SmsSendSingleToUserReqDTO reqDTO);
@GetMapping(PREFIX + "/sendMpNewsMsg")
@Operation(summary = "发送企业微信图文消息mpnews")
CommonResult<SmsLogRespDTO> sendMpNewsMsg(@RequestParam("id") Long id);
@PostMapping(PREFIX + "/sendMarkdownMsg")
@Operation(summary = "发送企业微信小程序通知消息", description = "在 mobile 为空时,使用 userId 加载对应 Admin 的手机号")
CommonResult<Long> sendMarkdownMsg(@Valid @RequestBody SmsSendSingleToUserReqDTO reqDTO);
@PostMapping(PREFIX + "/sendMiniProgramNoticeMsg")
@Operation(summary = "发送企业微信图片消息", description = "在 mobile 为空时,使用 userId 加载对应 Member 的手机号")
CommonResult<Long> sendMiniProgramNoticeMsg(@Valid @RequestBody SmsSendSingleToUserReqDTO reqDTO);
@GetMapping(PREFIX + "/sendInteractiveTaskCardMsg")
@Operation(summary = "发送企业微信任务卡片消息")
CommonResult<SmsLogRespDTO> sendInteractiveTaskCardMsg(@RequestParam("id") Long id);
}

View File

@@ -0,0 +1,44 @@
package com.zt.plat.module.system.api.sms.dto.code;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@Accessors(chain = true)
public class User implements Serializable {
/**
* 返回码
*/
private Integer errcode;
/**
* 对返回码的文本描述内容
*/
private String errmsg;
/**
* 成员UserID
*/
private String UserId;
/**
* 手机设备号(由中铝集团在安装时随机生成,删除重装会改变,升级不受影响)
*/
private String DeviceId;
/**
* 成员身份信息2超级管理员, 4:分级管理员5普通成员
*/
private Integer usertype;
/**
* 判断受否授权成功
*
* @return true-授权成功、false-授权失败
*/
public boolean isAuthorized() {
return this.getErrcode() == 0;
}
}

View File

@@ -3,7 +3,6 @@ package com.zt.plat.module.system.api.sms.dto.send;
import com.zt.plat.framework.common.validation.Mobile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import jakarta.validation.constraints.NotEmpty;
import java.util.Map;

View File

@@ -108,6 +108,9 @@ public interface ErrorCodeConstants {
ErrorCode SMS_CHANNEL_DISABLE = new ErrorCode(1_002_011_001, "短信渠道不处于开启状态,不允许选择");
ErrorCode SMS_CHANNEL_HAS_CHILDREN = new ErrorCode(1_002_011_002, "无法删除,该短信渠道还有短信模板");
ErrorCode SMS_CHANNEL_BALANCE_UNSUPPORTED = new ErrorCode(1_002_011_003, "该短信渠道不支持余额查询");
ErrorCode MSG_CHANNEL_NOT_EXISTS = new ErrorCode(1_002_011_004, "消息渠道不存在");
// ========== 短信模板 1-002-012-000 ==========
ErrorCode SMS_TEMPLATE_NOT_EXISTS = new ErrorCode(1_002_012_000, "短信模板不存在");
@@ -122,6 +125,7 @@ public interface ErrorCodeConstants {
ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_013_001, "模板参数({})缺失");
ErrorCode SMS_SEND_TEMPLATE_NOT_EXISTS = new ErrorCode(1_002_013_002, "短信模板不存在");
ErrorCode SMS_CALLBACK_SIGN_INVALID = new ErrorCode(1_002_013_100, "短信回调签名校验失败");
ErrorCode MSG_CALLBACK_SIGN_INVALID = new ErrorCode(1_002_013_101, "消息回调签名校验失败");
// ========== 短信验证码 1-002-014-000 ==========
ErrorCode SMS_CODE_NOT_FOUND = new ErrorCode(1_002_014_000, "验证码不存在");

View File

@@ -191,6 +191,13 @@
<artifactId>zt-spring-boot-starter-mq</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.13.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@@ -0,0 +1,84 @@
package com.zt.plat.module.system.api.msg;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.system.api.sms.dto.log.SmsLogRespDTO;
import com.zt.plat.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO;
import com.zt.plat.module.system.service.sms.SmsLogService;
import com.zt.plat.module.system.service.sms.SmsSendService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
@RestController
@Validated
public class MsgSendApiImpl implements MsgSendApi {
@Resource
private SmsSendService smsSendService;
@Resource
private SmsLogService smsLogService;
@Override
public CommonResult<Long> sendTextMsg(SmsSendSingleToUserReqDTO reqDTO) {
return null;
}
@Override
public CommonResult<Long> sendImageMsg(SmsSendSingleToUserReqDTO reqDTO) {
return null;
}
@Override
public CommonResult<SmsLogRespDTO> getSmsLog(Long id) {
return success(BeanUtils.toBean(smsLogService.getSmsLog(id), SmsLogRespDTO.class));
}
@Override
public CommonResult<Long> sendVideoMsg(SmsSendSingleToUserReqDTO reqDTO) {
return null;
}
@Override
public CommonResult<Long> sendFileMsg(SmsSendSingleToUserReqDTO reqDTO) {
return null;
}
@Override
public CommonResult<SmsLogRespDTO> sendTextCardMsg(Long id) {
return null;
}
@Override
public CommonResult<Long> sendTextCardMsgPich01(SmsSendSingleToUserReqDTO reqDTO) {
return null;
}
@Override
public CommonResult<Long> sendNewsMsg(SmsSendSingleToUserReqDTO reqDTO) {
return null;
}
@Override
public CommonResult<SmsLogRespDTO> sendMpNewsMsg(Long id) {
return null;
}
@Override
public CommonResult<Long> sendMarkdownMsg(SmsSendSingleToUserReqDTO reqDTO) {
return null;
}
@Override
public CommonResult<Long> sendMiniProgramNoticeMsg(SmsSendSingleToUserReqDTO reqDTO) {
return null;
}
@Override
public CommonResult<SmsLogRespDTO> sendInteractiveTaskCardMsg(Long id) {
return null;
}
}

View File

@@ -0,0 +1,18 @@
package com.zt.plat.module.system.controller.admin.sms;
import com.zt.plat.module.system.service.sms.SmsSendService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "管理后台 - 消息回调")
@RestController
@RequestMapping("/system/sms/callback")
public class MsgCallBackController {
@Resource
private SmsSendService smsSendService;
}

View File

@@ -8,11 +8,9 @@ import com.zt.plat.module.system.service.sms.SmsSendService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import jakarta.servlet.http.HttpServletRequest;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 短信回调")
@@ -71,4 +69,13 @@ public class SmsCallbackController {
return success(true);
}
@PostMapping("/zle")
@PermitAll
@TenantIgnore
@Operation(summary = "中铝e办短信的回调")
public CommonResult<Boolean> receiveZleSmsStatus(@RequestBody String requestBody) throws Throwable {
smsSendService.receiveSmsStatus(SmsChannelEnum.ZLE.getCode(), requestBody);
return success(true);
}
}

View File

@@ -6,11 +6,10 @@ import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO;
import com.zt.plat.module.system.controller.admin.sms.vo.template.SmsTemplateRespVO;
import com.zt.plat.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO;
import com.zt.plat.module.system.controller.admin.sms.vo.template.SmsTemplateSendReqVO;
import com.zt.plat.module.system.controller.admin.sms.vo.msg.TextMessage;
import com.zt.plat.module.system.controller.admin.sms.vo.template.*;
import com.zt.plat.module.system.dal.dataobject.sms.SmsTemplateDO;
import com.zt.plat.module.system.service.msg.ISendMsgService;
import com.zt.plat.module.system.service.sms.SmsSendService;
import com.zt.plat.module.system.service.sms.SmsTemplateService;
import io.swagger.v3.oas.annotations.Operation;
@@ -19,13 +18,13 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.zt.plat.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 短信模板")
@@ -37,6 +36,8 @@ public class SmsTemplateController {
private SmsTemplateService smsTemplateService;
@Resource
private SmsSendService smsSendService;
@Resource
private ISendMsgService sendMsgService;
@PostMapping("/create")
@Operation(summary = "创建短信模板")
@@ -100,4 +101,18 @@ public class SmsTemplateController {
sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams()));
}
@PostMapping("/send-msg")
@Operation(summary = "发送消息")
@PreAuthorize("@ss.hasPermission('system:sms-template:send-msg')")
public CommonResult<Object> sendMsg(@Valid @RequestBody MsgTemplateSendReqVO sendReqVO,TextMessage textMessage) throws Exception{
String msgtype = textMessage.getMsgtype();
if (StringUtils.isBlank(msgtype)){
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数缺失:%s",msgtype));
}
//发送消息到MQ
CommonResult<Object> objectCommonResult = sendMsgService.sendTextMsg(sendReqVO,textMessage);
return success(objectCommonResult);
}
}

View File

@@ -0,0 +1,48 @@
package com.zt.plat.module.system.controller.admin.sms.vo.msg;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 企业微信消息发送对象父类
*
* @author dongqiang.hao
*/
@Data
@Accessors(chain = true)
public class BaseMessage implements Serializable {
/**
* 指定接收消息的成员成员ID列表多个接收者用|分隔最多支持1000个。特殊情况指定为”@all”则向该企业应用的全部成员发送
*/
private String touser;
/**
* 指定接收消息的部门部门ID列表多个接收者用|分隔最多支持100个。当touser为”@all”时忽略本参数
*/
private String toparty;
/**
* 指定接收消息的标签标签ID列表多个接收者用|分隔最多支持100个。当touser为”@all”时忽略本参数
*/
private String totag;
/**
* 企业应用的id整型。企业内部开发可在应用的设置页面查看第三方服务商可通过接口 获取企业授权信息 获取该参数值
*/
private String agentid;
/**
* 消息类型
*/
private String msgtype;
/**
* 发送消息的自建应用类型
*/
private String appType;
/**
* 表示是否开启重复消息检查0表示否1表示是默认0
*/
private Integer enable_duplicate_check = 0;
/**
* 表示是否重复消息检查的时间间隔默认1800s最大不超过4小时
*/
private Integer duplicate_check_interval;
}

Some files were not shown because too many files have changed in this diff Show More