1. 新增 api 绑定客户凭证进行权限校验

2. 去除 api 定义的缓存策略
3. 新增短信渠道
4. 新增用户信息模糊查询
5. 修复全局的单元测试
This commit is contained in:
chenbowen
2025-12-12 10:03:10 +08:00
parent 99645c5ac8
commit cae0b9e4af
66 changed files with 1323 additions and 211 deletions

View File

@@ -2,12 +2,15 @@ package com.zt.plat.module.system.api.sms;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO;
import com.zt.plat.module.system.api.sms.dto.log.SmsLogRespDTO;
import com.zt.plat.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
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;
import jakarta.validation.Valid;
@@ -25,4 +28,8 @@ public interface SmsSendApi {
@Operation(summary = "发送单条短信给 Member 用户", description = "在 mobile 为空时,使用 userId 加载对应 Member 的手机号")
CommonResult<Long> sendSingleSmsToMember(@Valid @RequestBody SmsSendSingleToUserReqDTO reqDTO);
@GetMapping(PREFIX + "/log/get")
@Operation(summary = "根据日志编号查询短信状态")
CommonResult<SmsLogRespDTO> getSmsLog(@RequestParam("id") Long id);
}

View File

@@ -0,0 +1,73 @@
package com.zt.plat.module.system.api.sms.dto.log;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Map;
@Data
@Schema(description = "RPC 服务 - 短信日志返回 DTO")
public class SmsLogRespDTO {
@Schema(description = "日志编号", example = "123")
private Long id;
@Schema(description = "短信渠道编码", example = "HL95")
private String channelCode;
@Schema(description = "模板编码", example = "HL95_TEST")
private String templateCode;
@Schema(description = "短信类型")
private Integer templateType;
@Schema(description = "模板内容")
private String templateContent;
@Schema(description = "模板参数")
private Map<String, Object> templateParams;
@Schema(description = "短信 API 模板编号")
private String apiTemplateId;
@Schema(description = "手机号", example = "13800138000")
private String mobile;
@Schema(description = "用户编号", example = "1024")
private Long userId;
@Schema(description = "用户类型")
private Integer userType;
@Schema(description = "发送状态")
private Integer sendStatus;
@Schema(description = "发送时间")
private LocalDateTime sendTime;
@Schema(description = "发送结果编码")
private String apiSendCode;
@Schema(description = "发送结果信息")
private String apiSendMsg;
@Schema(description = "发送请求ID")
private String apiRequestId;
@Schema(description = "发送序列号")
private String apiSerialNo;
@Schema(description = "接收状态")
private Integer receiveStatus;
@Schema(description = "接收时间")
private LocalDateTime receiveTime;
@Schema(description = "接收结果编码")
private String apiReceiveCode;
@Schema(description = "接收结果信息")
private String apiReceiveMsg;
}

View File

@@ -107,6 +107,7 @@ public interface ErrorCodeConstants {
ErrorCode SMS_CHANNEL_NOT_EXISTS = new ErrorCode(1_002_011_000, "短信渠道不存在");
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, "该短信渠道不支持余额查询");
// ========== 短信模板 1-002-012-000 ==========
ErrorCode SMS_TEMPLATE_NOT_EXISTS = new ErrorCode(1_002_012_000, "短信模板不存在");
@@ -120,6 +121,7 @@ public interface ErrorCodeConstants {
ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1_002_013_000, "手机号不存在");
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, "短信回调签名校验失败");
// ========== 短信验证码 1-002-014-000 ==========
ErrorCode SMS_CODE_NOT_FOUND = new ErrorCode(1_002_014_000, "验证码不存在");

View File

@@ -1,7 +1,10 @@
package com.zt.plat.module.system.api.sms;
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 org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -16,6 +19,8 @@ public class SmsSendApiImpl implements SmsSendApi {
@Resource
private SmsSendService smsSendService;
@Resource
private SmsLogService smsLogService;
@Override
public CommonResult<Long> sendSingleSmsToAdmin(SmsSendSingleToUserReqDTO reqDTO) {
@@ -29,4 +34,9 @@ public class SmsSendApiImpl implements SmsSendApi {
reqDTO.getTemplateCode(), reqDTO.getTemplateParams()));
}
@Override
public CommonResult<SmsLogRespDTO> getSmsLog(Long id) {
return success(BeanUtils.toBean(smsLogService.getSmsLog(id), SmsLogRespDTO.class));
}
}

View File

@@ -71,6 +71,14 @@ public class SmsChannelController {
return success(BeanUtils.toBean(pageResult, SmsChannelRespVO.class));
}
@GetMapping("/balance")
@Operation(summary = "查询短信渠道余额")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:sms-channel:query')")
public CommonResult<Integer> getBalance(@RequestParam("id") Long id) {
return success(smsChannelService.queryBalance(id));
}
@GetMapping({"/list-all-simple", "/simple-list"})
@Operation(summary = "获得短信渠道精简列表", description = "包含被禁用的短信渠道")
public CommonResult<List<SmsChannelSimpleRespVO>> getSimpleSmsChannelList() {

View File

@@ -32,6 +32,9 @@ public class SmsChannelRespVO {
@NotNull(message = "短信 API 的账号不能为空")
private String apiKey;
@Schema(description = "企业编号epid", example = "123456")
private String epid;
@Schema(description = "短信 API 的密钥", example = "yuanma")
private String apiSecret;

View File

@@ -17,6 +17,9 @@ public class SmsChannelSaveReqVO {
@NotNull(message = "短信签名不能为空")
private String signature;
@Schema(description = "企业编号epid", example = "123456")
private String epid;
@Schema(description = "渠道编码,参见 SmsChannelEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "YUN_PIAN")
@NotNull(message = "渠道编码不能为空")
private String code;

View File

@@ -29,6 +29,9 @@ public class UserPageReqVO extends PageParam {
@Schema(description = "手机号码,模糊匹配", example = "zt")
private String mobile;
@Schema(description = "关键词(昵称/账号/手机号模糊匹配)", example = "张三")
private String keyword;
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
private Integer status;

View File

@@ -35,6 +35,10 @@ public class SmsChannelDO extends BaseDO {
* 短信签名
*/
private String signature;
/**
* 企业编号epid
*/
private String epid;
/**
* 渠道编码
*

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