🔧 简化 sms 模块的 VO

This commit is contained in:
YunaiV 2023-12-02 22:39:42 +08:00
parent 5c50b5ff13
commit 2014af1c0b
33 changed files with 213 additions and 670 deletions

View File

@ -85,7 +85,7 @@ public class RoleController {
return success(BeanUtils.toBean(pageResult, RoleRespVO.class)); return success(BeanUtils.toBean(pageResult, RoleRespVO.class));
} }
@GetMapping("/list-all-simple") @GetMapping({"/list-all-simple", "/simple-list"})
@Operation(summary = "获取角色精简信息列表", description = "只包含被开启的角色,主要用于前端的下拉选项") @Operation(summary = "获取角色精简信息列表", description = "只包含被开启的角色,主要用于前端的下拉选项")
public CommonResult<List<RoleSimpleRespVO>> getSimpleRoleList() { public CommonResult<List<RoleSimpleRespVO>> getSimpleRoleList() {
List<RoleDO> list = roleService.getRoleListByStatus(singleton(CommonStatusEnum.ENABLE.getStatus())); List<RoleDO> list = roleService.getRoleListByStatus(singleton(CommonStatusEnum.ENABLE.getStatus()));

View File

@ -1,14 +1,17 @@
package cn.iocoder.yudao.module.system.controller.admin.sms; package cn.iocoder.yudao.module.system.controller.admin.sms;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.*;
import cn.iocoder.yudao.module.system.convert.sms.SmsChannelConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import cn.iocoder.yudao.module.system.service.sms.SmsChannelService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import io.swagger.v3.oas.annotations.Parameter; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelRespVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSimpleRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import cn.iocoder.yudao.module.system.service.sms.SmsChannelService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -30,14 +33,14 @@ public class SmsChannelController {
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建短信渠道") @Operation(summary = "创建短信渠道")
@PreAuthorize("@ss.hasPermission('system:sms-channel:create')") @PreAuthorize("@ss.hasPermission('system:sms-channel:create')")
public CommonResult<Long> createSmsChannel(@Valid @RequestBody SmsChannelCreateReqVO createReqVO) { public CommonResult<Long> createSmsChannel(@Valid @RequestBody SmsChannelSaveReqVO createReqVO) {
return success(smsChannelService.createSmsChannel(createReqVO)); return success(smsChannelService.createSmsChannel(createReqVO));
} }
@PutMapping("/update") @PutMapping("/update")
@Operation(summary = "更新短信渠道") @Operation(summary = "更新短信渠道")
@PreAuthorize("@ss.hasPermission('system:sms-channel:update')") @PreAuthorize("@ss.hasPermission('system:sms-channel:update')")
public CommonResult<Boolean> updateSmsChannel(@Valid @RequestBody SmsChannelUpdateReqVO updateReqVO) { public CommonResult<Boolean> updateSmsChannel(@Valid @RequestBody SmsChannelSaveReqVO updateReqVO) {
smsChannelService.updateSmsChannel(updateReqVO); smsChannelService.updateSmsChannel(updateReqVO);
return success(true); return success(true);
} }
@ -56,8 +59,8 @@ public class SmsChannelController {
@Parameter(name = "id", description = "编号", required = true, example = "1024") @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:sms-channel:query')") @PreAuthorize("@ss.hasPermission('system:sms-channel:query')")
public CommonResult<SmsChannelRespVO> getSmsChannel(@RequestParam("id") Long id) { public CommonResult<SmsChannelRespVO> getSmsChannel(@RequestParam("id") Long id) {
SmsChannelDO smsChannel = smsChannelService.getSmsChannel(id); SmsChannelDO channel = smsChannelService.getSmsChannel(id);
return success(SmsChannelConvert.INSTANCE.convert(smsChannel)); return success(BeanUtils.toBean(channel, SmsChannelRespVO.class));
} }
@GetMapping("/page") @GetMapping("/page")
@ -65,16 +68,15 @@ public class SmsChannelController {
@PreAuthorize("@ss.hasPermission('system:sms-channel:query')") @PreAuthorize("@ss.hasPermission('system:sms-channel:query')")
public CommonResult<PageResult<SmsChannelRespVO>> getSmsChannelPage(@Valid SmsChannelPageReqVO pageVO) { public CommonResult<PageResult<SmsChannelRespVO>> getSmsChannelPage(@Valid SmsChannelPageReqVO pageVO) {
PageResult<SmsChannelDO> pageResult = smsChannelService.getSmsChannelPage(pageVO); PageResult<SmsChannelDO> pageResult = smsChannelService.getSmsChannelPage(pageVO);
return success(SmsChannelConvert.INSTANCE.convertPage(pageResult)); return success(BeanUtils.toBean(pageResult, SmsChannelRespVO.class));
} }
@GetMapping("/list-all-simple") @GetMapping({"/list-all-simple", "/simple-list"})
@Operation(summary = "获得短信渠道精简列表", description = "包含被禁用的短信渠道") @Operation(summary = "获得短信渠道精简列表", description = "包含被禁用的短信渠道")
public CommonResult<List<SmsChannelSimpleRespVO>> getSimpleSmsChannelList() { public CommonResult<List<SmsChannelSimpleRespVO>> getSimpleSmsChannelList() {
List<SmsChannelDO> list = smsChannelService.getSmsChannelList(); List<SmsChannelDO> list = smsChannelService.getSmsChannelList();
// 排序后返回给前端
list.sort(Comparator.comparing(SmsChannelDO::getId)); list.sort(Comparator.comparing(SmsChannelDO::getId));
return success(SmsChannelConvert.INSTANCE.convertList03(list)); return success(BeanUtils.toBean(list, SmsChannelSimpleRespVO.class));
} }
} }

View File

@ -1,18 +1,17 @@
package cn.iocoder.yudao.module.system.controller.admin.sms; package cn.iocoder.yudao.module.system.controller.admin.sms;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExcelVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogRespVO;
import cn.iocoder.yudao.module.system.convert.sms.SmsLogConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO;
import cn.iocoder.yudao.module.system.service.sms.SmsLogService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import io.swagger.v3.oas.annotations.tags.Tag; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO;
import cn.iocoder.yudao.module.system.service.sms.SmsLogService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -40,21 +39,22 @@ public class SmsLogController {
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得短信日志分页") @Operation(summary = "获得短信日志分页")
@PreAuthorize("@ss.hasPermission('system:sms-log:query')") @PreAuthorize("@ss.hasPermission('system:sms-log:query')")
public CommonResult<PageResult<SmsLogRespVO>> getSmsLogPage(@Valid SmsLogPageReqVO pageVO) { public CommonResult<PageResult<SmsLogRespVO>> getSmsLogPage(@Valid SmsLogPageReqVO pageReqVO) {
PageResult<SmsLogDO> pageResult = smsLogService.getSmsLogPage(pageVO); PageResult<SmsLogDO> pageResult = smsLogService.getSmsLogPage(pageReqVO);
return success(SmsLogConvert.INSTANCE.convertPage(pageResult)); return success(BeanUtils.toBean(pageResult, SmsLogRespVO.class));
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出短信日志 Excel") @Operation(summary = "导出短信日志 Excel")
@PreAuthorize("@ss.hasPermission('system:sms-log:export')") @PreAuthorize("@ss.hasPermission('system:sms-log:export')")
@OperateLog(type = EXPORT) @OperateLog(type = EXPORT)
public void exportSmsLogExcel(@Valid SmsLogExportReqVO exportReqVO, public void exportSmsLogExcel(@Valid SmsLogPageReqVO exportReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
List<SmsLogDO> list = smsLogService.getSmsLogList(exportReqVO); exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<SmsLogDO> list = smsLogService.getSmsLogPage(exportReqVO).getList();
// 导出 Excel // 导出 Excel
List<SmsLogExcelVO> datas = SmsLogConvert.INSTANCE.convertList02(list); ExcelUtils.write(response, "短信日志.xls", "数据", SmsLogRespVO.class,
ExcelUtils.write(response, "短信日志.xls", "数据", SmsLogExcelVO.class, datas); BeanUtils.toBean(list, SmsLogRespVO.class));
} }
} }

View File

@ -1,17 +1,21 @@
package cn.iocoder.yudao.module.system.controller.admin.sms; package cn.iocoder.yudao.module.system.controller.admin.sms;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.*;
import cn.iocoder.yudao.module.system.convert.sms.SmsTemplateConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
import cn.iocoder.yudao.module.system.service.sms.SmsTemplateService;
import cn.iocoder.yudao.module.system.service.sms.SmsSendService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import io.swagger.v3.oas.annotations.tags.Tag; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO;
import io.swagger.v3.oas.annotations.Parameter; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateRespVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSendReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
import cn.iocoder.yudao.module.system.service.sms.SmsSendService;
import cn.iocoder.yudao.module.system.service.sms.SmsTemplateService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -37,14 +41,14 @@ public class SmsTemplateController {
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建短信模板") @Operation(summary = "创建短信模板")
@PreAuthorize("@ss.hasPermission('system:sms-template:create')") @PreAuthorize("@ss.hasPermission('system:sms-template:create')")
public CommonResult<Long> createSmsTemplate(@Valid @RequestBody SmsTemplateCreateReqVO createReqVO) { public CommonResult<Long> createSmsTemplate(@Valid @RequestBody SmsTemplateSaveReqVO createReqVO) {
return success(smsTemplateService.createSmsTemplate(createReqVO)); return success(smsTemplateService.createSmsTemplate(createReqVO));
} }
@PutMapping("/update") @PutMapping("/update")
@Operation(summary = "更新短信模板") @Operation(summary = "更新短信模板")
@PreAuthorize("@ss.hasPermission('system:sms-template:update')") @PreAuthorize("@ss.hasPermission('system:sms-template:update')")
public CommonResult<Boolean> updateSmsTemplate(@Valid @RequestBody SmsTemplateUpdateReqVO updateReqVO) { public CommonResult<Boolean> updateSmsTemplate(@Valid @RequestBody SmsTemplateSaveReqVO updateReqVO) {
smsTemplateService.updateSmsTemplate(updateReqVO); smsTemplateService.updateSmsTemplate(updateReqVO);
return success(true); return success(true);
} }
@ -63,8 +67,8 @@ public class SmsTemplateController {
@Parameter(name = "id", description = "编号", required = true, example = "1024") @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:sms-template:query')") @PreAuthorize("@ss.hasPermission('system:sms-template:query')")
public CommonResult<SmsTemplateRespVO> getSmsTemplate(@RequestParam("id") Long id) { public CommonResult<SmsTemplateRespVO> getSmsTemplate(@RequestParam("id") Long id) {
SmsTemplateDO smsTemplate = smsTemplateService.getSmsTemplate(id); SmsTemplateDO template = smsTemplateService.getSmsTemplate(id);
return success(SmsTemplateConvert.INSTANCE.convert(smsTemplate)); return success(BeanUtils.toBean(template, SmsTemplateRespVO.class));
} }
@GetMapping("/page") @GetMapping("/page")
@ -72,19 +76,20 @@ public class SmsTemplateController {
@PreAuthorize("@ss.hasPermission('system:sms-template:query')") @PreAuthorize("@ss.hasPermission('system:sms-template:query')")
public CommonResult<PageResult<SmsTemplateRespVO>> getSmsTemplatePage(@Valid SmsTemplatePageReqVO pageVO) { public CommonResult<PageResult<SmsTemplateRespVO>> getSmsTemplatePage(@Valid SmsTemplatePageReqVO pageVO) {
PageResult<SmsTemplateDO> pageResult = smsTemplateService.getSmsTemplatePage(pageVO); PageResult<SmsTemplateDO> pageResult = smsTemplateService.getSmsTemplatePage(pageVO);
return success(SmsTemplateConvert.INSTANCE.convertPage(pageResult)); return success(BeanUtils.toBean(pageResult, SmsTemplateRespVO.class));
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出短信模板 Excel") @Operation(summary = "导出短信模板 Excel")
@PreAuthorize("@ss.hasPermission('system:sms-template:export')") @PreAuthorize("@ss.hasPermission('system:sms-template:export')")
@OperateLog(type = EXPORT) @OperateLog(type = EXPORT)
public void exportSmsTemplateExcel(@Valid SmsTemplateExportReqVO exportReqVO, public void exportSmsTemplateExcel(@Valid SmsTemplatePageReqVO exportReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
List<SmsTemplateDO> list = smsTemplateService.getSmsTemplateList(exportReqVO); exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<SmsTemplateDO> list = smsTemplateService.getSmsTemplatePage(exportReqVO).getList();
// 导出 Excel // 导出 Excel
List<SmsTemplateExcelVO> datas = SmsTemplateConvert.INSTANCE.convertList02(list); ExcelUtils.write(response, "短信模板.xls", "数据", SmsTemplateRespVO.class,
ExcelUtils.write(response, "短信模板.xls", "数据", SmsTemplateExcelVO.class, datas); BeanUtils.toBean(list, SmsTemplateRespVO.class));
} }
@PostMapping("/send-sms") @PostMapping("/send-sms")

View File

@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 短信渠道创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SmsChannelCreateReqVO extends SmsChannelBaseVO {
@Schema(description = "渠道编码,参见 SmsChannelEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "YUN_PIAN")
@NotNull(message = "渠道编码不能为空")
private String code;
}

View File

@ -2,23 +2,43 @@ package cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import org.hibernate.validator.constraints.URL;
import lombok.ToString;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Schema(description = "管理后台 - 短信渠道 Response VO") @Schema(description = "管理后台 - 短信渠道 Response VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) public class SmsChannelRespVO {
@ToString(callSuper = true)
public class SmsChannelRespVO extends SmsChannelBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id; private Long id;
@Schema(description = "短信签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
@NotNull(message = "短信签名不能为空")
private String signature;
@Schema(description = "渠道编码,参见 SmsChannelEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "YUN_PIAN") @Schema(description = "渠道编码,参见 SmsChannelEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "YUN_PIAN")
private String code; private String code;
@Schema(description = "启用状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "启用状态不能为空")
private Integer status;
@Schema(description = "备注", example = "好吃!")
private String remark;
@Schema(description = "短信 API 的账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
@NotNull(message = "短信 API 的账号不能为空")
private String apiKey;
@Schema(description = "短信 API 的密钥", example = "yuanma")
private String apiSecret;
@Schema(description = "短信发送回调 URL", example = "https://www.iocoder.cn")
@URL(message = "回调 URL 格式不正确")
private String callbackUrl;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime; private LocalDateTime createTime;

View File

@ -6,17 +6,21 @@ import org.hibernate.validator.constraints.URL;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
/** @Schema(description = "管理后台 - 短信渠道创建/修改 Request VO")
* 短信渠道 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data @Data
public class SmsChannelBaseVO { public class SmsChannelSaveReqVO {
@Schema(description = "编号", example = "1024")
private Long id;
@Schema(description = "短信签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") @Schema(description = "短信签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
@NotNull(message = "短信签名不能为空") @NotNull(message = "短信签名不能为空")
private String signature; private String signature;
@Schema(description = "渠道编码,参见 SmsChannelEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "YUN_PIAN")
@NotNull(message = "渠道编码不能为空")
private String code;
@Schema(description = "启用状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "启用状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "启用状态不能为空") @NotNull(message = "启用状态不能为空")
private Integer status; private Integer status;

View File

@ -3,18 +3,14 @@ package cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 短信渠道精简 Response VO") @Schema(description = "管理后台 - 短信渠道精简 Response VO")
@Data @Data
public class SmsChannelSimpleRespVO { public class SmsChannelSimpleRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "编号不能为空")
private Long id; private Long id;
@Schema(description = "短信签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") @Schema(description = "短信签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
@NotNull(message = "短信签名不能为空")
private String signature; private String signature;
@Schema(description = "渠道编码,参见 SmsChannelEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "YUN_PIAN") @Schema(description = "渠道编码,参见 SmsChannelEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "YUN_PIAN")

View File

@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 短信渠道更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SmsChannelUpdateReqVO extends SmsChannelBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@ -1,94 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.log;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.framework.excel.core.convert.JsonConvert;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Map;
/**
* 短信日志 Excel VO
*
* @author 芋道源码
*/
@Data
public class SmsLogExcelVO {
@ExcelProperty("编号")
private Long id;
@ExcelProperty("短信渠道编号")
private Long channelId;
@ExcelProperty("短信渠道编码")
private String channelCode;
@ExcelProperty("模板编号")
private Long templateId;
@ExcelProperty("模板编码")
private String templateCode;
@ExcelProperty(value = "短信类型", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_TEMPLATE_TYPE)
private Integer templateType;
@ExcelProperty("短信内容")
private String templateContent;
@ExcelProperty(value = "短信参数", converter = JsonConvert.class)
private Map<String, Object> templateParams;
@ExcelProperty("短信 API 的模板编号")
private String apiTemplateId;
@ExcelProperty("手机号")
private String mobile;
@ExcelProperty("用户编号")
private Long userId;
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
@DictFormat(DictTypeConstants.USER_TYPE)
private Integer userType;
@ExcelProperty(value = "发送状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_SEND_STATUS)
private Integer sendStatus;
@ExcelProperty("发送时间")
private LocalDateTime sendTime;
@ExcelProperty("短信 API 发送结果的编码")
private String apiSendCode;
@ExcelProperty("短信 API 发送失败的提示")
private String apiSendMsg;
@ExcelProperty("短信 API 发送返回的唯一请求 ID")
private String apiRequestId;
@ExcelProperty("短信 API 发送返回的序号")
private String apiSerialNo;
@ExcelProperty(value = "接收状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_RECEIVE_STATUS)
private Integer receiveStatus;
@ExcelProperty("接收时间")
private LocalDateTime receiveTime;
@ExcelProperty("API 接收结果的编码")
private String apiReceiveCode;
@ExcelProperty("API 接收结果的说明")
private String apiReceiveMsg;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -1,38 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.log;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 短信日志 Excel 导出 Request VO参数和 SmsLogPageReqVO 是一致的")
@Data
public class SmsLogExportReqVO {
@Schema(description = "短信渠道编号", example = "10")
private Long channelId;
@Schema(description = "模板编号", example = "20")
private Long templateId;
@Schema(description = "手机号", example = "15601691300")
private String mobile;
@Schema(description = "发送状态", example = "1")
private Integer sendStatus;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "开始发送时间")
private LocalDateTime[] sendTime;
@Schema(description = "接收状态", example = "0")
private Integer receiveStatus;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "开始接收时间")
private LocalDateTime[] receiveTime;
}

View File

@ -1,5 +1,11 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.log; package cn.iocoder.yudao.module.system.controller.admin.sms.vo.log;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.framework.excel.core.convert.JsonConvert;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@ -8,75 +14,103 @@ import java.util.Map;
@Schema(description = "管理后台 - 短信日志 Response VO") @Schema(description = "管理后台 - 短信日志 Response VO")
@Data @Data
@ExcelIgnoreUnannotated
public class SmsLogRespVO { public class SmsLogRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@ExcelProperty("编号")
private Long id; private Long id;
@Schema(description = "短信渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") @Schema(description = "短信渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
@ExcelProperty("短信渠道编号")
private Long channelId; private Long channelId;
@Schema(description = "短信渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "ALIYUN") @Schema(description = "短信渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "ALIYUN")
@ExcelProperty("短信渠道编码")
private String channelCode; private String channelCode;
@Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
@ExcelProperty("模板编号")
private Long templateId; private Long templateId;
@Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "test-01") @Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "test-01")
@ExcelProperty("模板编码")
private String templateCode; private String templateCode;
@Schema(description = "短信类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "短信类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty(value = "短信类型", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_TEMPLATE_TYPE)
private Integer templateType; private Integer templateType;
@Schema(description = "短信内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好,你的验证码是 1024") @Schema(description = "短信内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好,你的验证码是 1024")
@ExcelProperty("短信内容")
private String templateContent; private String templateContent;
@Schema(description = "短信参数", requiredMode = Schema.RequiredMode.REQUIRED, example = "name,code") @Schema(description = "短信参数", requiredMode = Schema.RequiredMode.REQUIRED, example = "name,code")
@ExcelProperty(value = "短信参数", converter = JsonConvert.class)
private Map<String, Object> templateParams; private Map<String, Object> templateParams;
@Schema(description = "短信 API 的模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SMS_207945135") @Schema(description = "短信 API 的模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SMS_207945135")
@ExcelProperty("短信 API 的模板编号")
private String apiTemplateId; private String apiTemplateId;
@Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300")
@ExcelProperty("手机号")
private String mobile; private String mobile;
@Schema(description = "用户编号", example = "10") @Schema(description = "用户编号", example = "10")
@ExcelProperty("用户编号")
private Long userId; private Long userId;
@Schema(description = "用户类型", example = "1") @Schema(description = "用户类型", example = "1")
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
@DictFormat(DictTypeConstants.USER_TYPE)
private Integer userType; private Integer userType;
@Schema(description = "发送状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "发送状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty(value = "发送状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_SEND_STATUS)
private Integer sendStatus; private Integer sendStatus;
@Schema(description = "发送时间") @Schema(description = "发送时间")
@ExcelProperty("发送时间")
private LocalDateTime sendTime; private LocalDateTime sendTime;
@Schema(description = "短信 API 发送结果的编码", example = "SUCCESS") @Schema(description = "短信 API 发送结果的编码", example = "SUCCESS")
@ExcelProperty("短信 API 发送结果的编码")
private String apiSendCode; private String apiSendCode;
@Schema(description = "短信 API 发送失败的提示", example = "成功") @Schema(description = "短信 API 发送失败的提示", example = "成功")
@ExcelProperty("短信 API 发送失败的提示")
private String apiSendMsg; private String apiSendMsg;
@Schema(description = "短信 API 发送返回的唯一请求 ID", example = "3837C6D3-B96F-428C-BBB2-86135D4B5B99") @Schema(description = "短信 API 发送返回的唯一请求 ID", example = "3837C6D3-B96F-428C-BBB2-86135D4B5B99")
@ExcelProperty("短信 API 发送返回的唯一请求 ID")
private String apiRequestId; private String apiRequestId;
@Schema(description = "短信 API 发送返回的序号", example = "62923244790") @Schema(description = "短信 API 发送返回的序号", example = "62923244790")
@ExcelProperty("短信 API 发送返回的序号")
private String apiSerialNo; private String apiSerialNo;
@Schema(description = "接收状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") @Schema(description = "接收状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
@ExcelProperty(value = "接收状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_RECEIVE_STATUS)
private Integer receiveStatus; private Integer receiveStatus;
@Schema(description = "接收时间") @Schema(description = "接收时间")
@ExcelProperty("接收时间")
private LocalDateTime receiveTime; private LocalDateTime receiveTime;
@Schema(description = "API 接收结果的编码", example = "DELIVRD") @Schema(description = "API 接收结果的编码", example = "DELIVRD")
@ExcelProperty("API 接收结果的编码")
private String apiReceiveCode; private String apiReceiveCode;
@Schema(description = "API 接收结果的说明", example = "用户接收成功") @Schema(description = "API 接收结果的说明", example = "用户接收成功")
@ExcelProperty("API 接收结果的说明")
private String apiReceiveMsg; private String apiReceiveMsg;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
} }

View File

@ -1,14 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.template;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 短信模板创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SmsTemplateCreateReqVO extends SmsTemplateBaseVO {
}

View File

@ -1,55 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.template;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 短信模板 Excel VO
*
* @author 芋道源码
*/
@Data
public class SmsTemplateExcelVO {
@ExcelProperty("编号")
private Long id;
@ExcelProperty(value = "短信签名", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_TEMPLATE_TYPE)
private Integer type;
@ExcelProperty(value = "开启状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.COMMON_STATUS)
private Integer status;
@ExcelProperty("模板编码")
private String code;
@ExcelProperty("模板名称")
private String name;
@ExcelProperty("模板内容")
private String content;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("短信 API 的模板编号")
private String apiTemplateId;
@ExcelProperty("短信渠道编号")
private Long channelId;
@ExcelProperty(value = "短信渠道编码", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_CHANNEL_CODE)
private String channelCode;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -1,37 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.template;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 短信模板 Excel 导出 Request VO参数和 SmsTemplatePageReqVO 是一致的")
@Data
public class SmsTemplateExportReqVO {
@Schema(description = "短信签名", example = "1")
private Integer type;
@Schema(description = "开启状态", example = "1")
private Integer status;
@Schema(description = "模板编码,模糊匹配", example = "test_01")
private String code;
@Schema(description = "模板内容,模糊匹配", example = "你好,{name}。你长的太{like}啦!")
private String content;
@Schema(description = "短信 API 的模板编号,模糊匹配", example = "4383920")
private String apiTemplateId;
@Schema(description = "短信渠道编号", example = "10")
private Long channelId;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "创建时间")
private LocalDateTime[] createTime;
}

View File

@ -39,4 +39,4 @@ public class SmsTemplatePageReqVO extends PageParam {
@Schema(description = "创建时间") @Schema(description = "创建时间")
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
} }

View File

@ -1,29 +1,69 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.template; package cn.iocoder.yudao.module.system.controller.admin.sms.vo.template;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@Schema(description = "管理后台 - 短信模板 Response VO") @Schema(description = "管理后台 - 短信模板 Response VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @ExcelIgnoreUnannotated
@ToString(callSuper = true) public class SmsTemplateRespVO {
public class SmsTemplateRespVO extends SmsTemplateBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@ExcelProperty("编号")
private Long id; private Long id;
@Schema(description = "短信渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "ALIYUN") @Schema(description = "短信类型,参见 SmsTemplateTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private String channelCode; @ExcelProperty(value = "短信签名", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_TEMPLATE_TYPE)
private Integer type;
@Schema(description = "开启状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty(value = "开启状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.COMMON_STATUS)
private Integer status;
@Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "test_01")
@ExcelProperty("模板编码")
private String code;
@Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
@ExcelProperty("模板名称")
private String name;
@Schema(description = "模板内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好,{name}。你长的太{like}啦!")
@ExcelProperty("模板内容")
private String content;
@Schema(description = "参数数组", example = "name,code") @Schema(description = "参数数组", example = "name,code")
private List<String> params; private List<String> params;
@Schema(description = "备注", example = "哈哈哈")
@ExcelProperty("备注")
private String remark;
@Schema(description = "短信 API 的模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4383920")
@ExcelProperty("短信 API 的模板编号")
private String apiTemplateId;
@Schema(description = "短信渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
@ExcelProperty("短信渠道编号")
private Long channelId;
@Schema(description = "短信渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "ALIYUN")
@ExcelProperty(value = "短信渠道编码", converter = DictConvert.class)
@DictFormat(DictTypeConstants.SMS_CHANNEL_CODE)
private String channelCode;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
} }

View File

@ -5,12 +5,12 @@ import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
/** @Schema(description = "管理后台 - 短信模板创建/修改 Request VO")
* 短信模板 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data @Data
public class SmsTemplateBaseVO { public class SmsTemplateSaveReqVO {
@Schema(description = "编号", example = "1024")
private Long id;
@Schema(description = "短信类型,参见 SmsTemplateTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "短信类型,参见 SmsTemplateTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "短信类型不能为空") @NotNull(message = "短信类型不能为空")

View File

@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.sms.vo.template;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 短信模板更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SmsTemplateUpdateReqVO extends SmsTemplateBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@ -1,39 +0,0 @@
package cn.iocoder.yudao.module.system.convert.sms;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelRespVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSimpleRespVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 短信渠道 Convert
*
* @author 芋道源码
*/
@Mapper
public interface SmsChannelConvert {
SmsChannelConvert INSTANCE = Mappers.getMapper(SmsChannelConvert.class);
SmsChannelDO convert(SmsChannelCreateReqVO bean);
SmsChannelDO convert(SmsChannelUpdateReqVO bean);
SmsChannelRespVO convert(SmsChannelDO bean);
List<SmsChannelRespVO> convertList(List<SmsChannelDO> list);
PageResult<SmsChannelRespVO> convertPage(PageResult<SmsChannelDO> page);
List<SmsChannelSimpleRespVO> convertList03(List<SmsChannelDO> list);
SmsChannelProperties convert02(SmsChannelDO channel);
}

View File

@ -1,30 +0,0 @@
package cn.iocoder.yudao.module.system.convert.sms;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExcelVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 短信日志 Convert
*
* @author 芋道源码
*/
@Mapper
public interface SmsLogConvert {
SmsLogConvert INSTANCE = Mappers.getMapper(SmsLogConvert.class);
SmsLogRespVO convert(SmsLogDO bean);
List<SmsLogRespVO> convertList(List<SmsLogDO> list);
PageResult<SmsLogRespVO> convertPage(PageResult<SmsLogDO> page);
List<SmsLogExcelVO> convertList02(List<SmsLogDO> list);
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.yudao.module.system.convert.sms;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateExcelVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateRespVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface SmsTemplateConvert {
SmsTemplateConvert INSTANCE = Mappers.getMapper(SmsTemplateConvert.class);
SmsTemplateDO convert(SmsTemplateCreateReqVO bean);
SmsTemplateDO convert(SmsTemplateUpdateReqVO bean);
SmsTemplateRespVO convert(SmsTemplateDO bean);
List<SmsTemplateRespVO> convertList(List<SmsTemplateDO> list);
PageResult<SmsTemplateRespVO> convertPage(PageResult<SmsTemplateDO> page);
List<SmsTemplateExcelVO> convertList02(List<SmsTemplateDO> list);
}

View File

@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.system.dal.mysql.sms;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper @Mapper
public interface SmsLogMapper extends BaseMapperX<SmsLogDO> { public interface SmsLogMapper extends BaseMapperX<SmsLogDO> {
@ -25,16 +22,4 @@ public interface SmsLogMapper extends BaseMapperX<SmsLogDO> {
.orderByDesc(SmsLogDO::getId)); .orderByDesc(SmsLogDO::getId));
} }
default List<SmsLogDO> selectList(SmsLogExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<SmsLogDO>()
.eqIfPresent(SmsLogDO::getChannelId, reqVO.getChannelId())
.eqIfPresent(SmsLogDO::getTemplateId, reqVO.getTemplateId())
.likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile())
.eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus())
.betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime())
.eqIfPresent(SmsLogDO::getReceiveStatus, reqVO.getReceiveStatus())
.betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime())
.orderByDesc(SmsLogDO::getId));
}
} }

View File

@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.system.dal.mysql.sms;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper @Mapper
public interface SmsTemplateMapper extends BaseMapperX<SmsTemplateDO> { public interface SmsTemplateMapper extends BaseMapperX<SmsTemplateDO> {
@ -29,18 +26,6 @@ public interface SmsTemplateMapper extends BaseMapperX<SmsTemplateDO> {
.orderByDesc(SmsTemplateDO::getId)); .orderByDesc(SmsTemplateDO::getId));
} }
default List<SmsTemplateDO> selectList(SmsTemplateExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<SmsTemplateDO>()
.eqIfPresent(SmsTemplateDO::getType, reqVO.getType())
.eqIfPresent(SmsTemplateDO::getStatus, reqVO.getStatus())
.likeIfPresent(SmsTemplateDO::getCode, reqVO.getCode())
.likeIfPresent(SmsTemplateDO::getContent, reqVO.getContent())
.likeIfPresent(SmsTemplateDO::getApiTemplateId, reqVO.getApiTemplateId())
.eqIfPresent(SmsTemplateDO::getChannelId, reqVO.getChannelId())
.betweenIfPresent(SmsTemplateDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(SmsTemplateDO::getId));
}
default Long selectCountByChannelId(Long channelId) { default Long selectCountByChannelId(Long channelId) {
return selectCount(SmsTemplateDO::getChannelId, channelId); return selectCount(SmsTemplateDO::getChannelId, channelId);
} }

View File

@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.system.service.sms;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.sms.core.client.SmsClient; import cn.iocoder.yudao.framework.sms.core.client.SmsClient;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelUpdateReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import javax.validation.Valid; import javax.validation.Valid;
@ -24,14 +23,14 @@ public interface SmsChannelService {
* @param createReqVO 创建信息 * @param createReqVO 创建信息
* @return 编号 * @return 编号
*/ */
Long createSmsChannel(@Valid SmsChannelCreateReqVO createReqVO); Long createSmsChannel(@Valid SmsChannelSaveReqVO createReqVO);
/** /**
* 更新短信渠道 * 更新短信渠道
* *
* @param updateReqVO 更新信息 * @param updateReqVO 更新信息
*/ */
void updateSmsChannel(@Valid SmsChannelUpdateReqVO updateReqVO); void updateSmsChannel(@Valid SmsChannelSaveReqVO updateReqVO);
/** /**
* 删除短信渠道 * 删除短信渠道

View File

@ -2,13 +2,12 @@ package cn.iocoder.yudao.module.system.service.sms;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.sms.core.client.SmsClient; import cn.iocoder.yudao.framework.sms.core.client.SmsClient;
import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory;
import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelUpdateReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSaveReqVO;
import cn.iocoder.yudao.module.system.convert.sms.SmsChannelConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper; import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
@ -47,7 +46,7 @@ public class SmsChannelServiceImpl implements SmsChannelService {
// 查询然后尝试刷新 // 查询然后尝试刷新
SmsChannelDO channel = smsChannelMapper.selectById(id); SmsChannelDO channel = smsChannelMapper.selectById(id);
if (channel != null) { if (channel != null) {
SmsChannelProperties properties = SmsChannelConvert.INSTANCE.convert02(channel); SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class);
smsClientFactory.createOrUpdateSmsClient(properties); smsClientFactory.createOrUpdateSmsClient(properties);
} }
return smsClientFactory.getSmsClient(id); return smsClientFactory.getSmsClient(id);
@ -67,7 +66,7 @@ public class SmsChannelServiceImpl implements SmsChannelService {
// 查询然后尝试刷新 // 查询然后尝试刷新
SmsChannelDO channel = smsChannelMapper.selectByCode(code); SmsChannelDO channel = smsChannelMapper.selectByCode(code);
if (channel != null) { if (channel != null) {
SmsChannelProperties properties = SmsChannelConvert.INSTANCE.convert02(channel); SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class);
smsClientFactory.createOrUpdateSmsClient(properties); smsClientFactory.createOrUpdateSmsClient(properties);
} }
return smsClientFactory.getSmsClient(code); return smsClientFactory.getSmsClient(code);
@ -85,18 +84,18 @@ public class SmsChannelServiceImpl implements SmsChannelService {
private SmsTemplateService smsTemplateService; private SmsTemplateService smsTemplateService;
@Override @Override
public Long createSmsChannel(SmsChannelCreateReqVO createReqVO) { public Long createSmsChannel(SmsChannelSaveReqVO createReqVO) {
SmsChannelDO channel = SmsChannelConvert.INSTANCE.convert(createReqVO); SmsChannelDO channel = BeanUtils.toBean(createReqVO, SmsChannelDO.class);
smsChannelMapper.insert(channel); smsChannelMapper.insert(channel);
return channel.getId(); return channel.getId();
} }
@Override @Override
public void updateSmsChannel(SmsChannelUpdateReqVO updateReqVO) { public void updateSmsChannel(SmsChannelSaveReqVO updateReqVO) {
// 校验存在 // 校验存在
SmsChannelDO channel = validateSmsChannelExists(updateReqVO.getId()); SmsChannelDO channel = validateSmsChannelExists(updateReqVO.getId());
// 更新 // 更新
SmsChannelDO updateObj = SmsChannelConvert.INSTANCE.convert(updateReqVO); SmsChannelDO updateObj = BeanUtils.toBean(updateReqVO, SmsChannelDO.class);
smsChannelMapper.updateById(updateObj); smsChannelMapper.updateById(updateObj);
// 清空缓存 // 清空缓存
@ -108,7 +107,7 @@ public class SmsChannelServiceImpl implements SmsChannelService {
// 校验存在 // 校验存在
SmsChannelDO channel = validateSmsChannelExists(id); SmsChannelDO channel = validateSmsChannelExists(id);
// 校验是否有在使用该账号的模版 // 校验是否有在使用该账号的模版
if (smsTemplateService.countByChannelId(id) > 0) { if (smsTemplateService.getSmsTemplateCountByChannelId(id) > 0) {
throw exception(SMS_CHANNEL_HAS_CHILDREN); throw exception(SMS_CHANNEL_HAS_CHILDREN);
} }
// 删除 // 删除

View File

@ -1,13 +1,11 @@
package cn.iocoder.yudao.module.system.service.sms; package cn.iocoder.yudao.module.system.service.sms;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -67,12 +65,4 @@ public interface SmsLogService {
*/ */
PageResult<SmsLogDO> getSmsLogPage(SmsLogPageReqVO pageReqVO); PageResult<SmsLogDO> getSmsLogPage(SmsLogPageReqVO pageReqVO);
/**
* 获得短信日志列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 短信日志列表
*/
List<SmsLogDO> getSmsLogList(SmsLogExportReqVO exportReqVO);
} }

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.system.service.sms; package cn.iocoder.yudao.module.system.service.sms;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
@ -13,7 +12,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -78,9 +76,4 @@ public class SmsLogServiceImpl implements SmsLogService {
return smsLogMapper.selectPage(pageReqVO); return smsLogMapper.selectPage(pageReqVO);
} }
@Override
public List<SmsLogDO> getSmsLogList(SmsLogExportReqVO exportReqVO) {
return smsLogMapper.selectList(exportReqVO);
}
} }

View File

@ -1,14 +1,11 @@
package cn.iocoder.yudao.module.system.service.sms; package cn.iocoder.yudao.module.system.service.sms;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateUpdateReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -25,14 +22,14 @@ public interface SmsTemplateService {
* @param createReqVO 创建信息 * @param createReqVO 创建信息
* @return 编号 * @return 编号
*/ */
Long createSmsTemplate(@Valid SmsTemplateCreateReqVO createReqVO); Long createSmsTemplate(@Valid SmsTemplateSaveReqVO createReqVO);
/** /**
* 更新短信模板 * 更新短信模板
* *
* @param updateReqVO 更新信息 * @param updateReqVO 更新信息
*/ */
void updateSmsTemplate(@Valid SmsTemplateUpdateReqVO updateReqVO); void updateSmsTemplate(@Valid SmsTemplateSaveReqVO updateReqVO);
/** /**
* 删除短信模板 * 删除短信模板
@ -65,22 +62,13 @@ public interface SmsTemplateService {
*/ */
PageResult<SmsTemplateDO> getSmsTemplatePage(SmsTemplatePageReqVO pageReqVO); PageResult<SmsTemplateDO> getSmsTemplatePage(SmsTemplatePageReqVO pageReqVO);
/**
* 获得短信模板列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 短信模板分页
*/
List<SmsTemplateDO> getSmsTemplateList(SmsTemplateExportReqVO exportReqVO);
/** /**
* 获得指定短信渠道下的短信模板数量 * 获得指定短信渠道下的短信模板数量
* *
* @param channelId 短信渠道编号 * @param channelId 短信渠道编号
* @return 数量 * @return 数量
*/ */
Long countByChannelId(Long channelId); Long getSmsTemplateCountByChannelId(Long channelId);
/** /**
* 格式化短信内容 * 格式化短信内容

View File

@ -6,14 +6,12 @@ import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.sms.core.client.SmsClient; import cn.iocoder.yudao.framework.sms.core.client.SmsClient;
import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO;
import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum; import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateUpdateReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO;
import cn.iocoder.yudao.module.system.convert.sms.SmsTemplateConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsTemplateMapper; import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsTemplateMapper;
@ -55,7 +53,7 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
private SmsChannelService smsChannelService; private SmsChannelService smsChannelService;
@Override @Override
public Long createSmsTemplate(SmsTemplateCreateReqVO createReqVO) { public Long createSmsTemplate(SmsTemplateSaveReqVO createReqVO) {
// 校验短信渠道 // 校验短信渠道
SmsChannelDO channelDO = validateSmsChannel(createReqVO.getChannelId()); SmsChannelDO channelDO = validateSmsChannel(createReqVO.getChannelId());
// 校验短信编码是否重复 // 校验短信编码是否重复
@ -64,7 +62,7 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
validateApiTemplate(createReqVO.getChannelId(), createReqVO.getApiTemplateId()); validateApiTemplate(createReqVO.getChannelId(), createReqVO.getApiTemplateId());
// 插入 // 插入
SmsTemplateDO template = SmsTemplateConvert.INSTANCE.convert(createReqVO); SmsTemplateDO template = BeanUtils.toBean(createReqVO, SmsTemplateDO.class);
template.setParams(parseTemplateContentParams(template.getContent())); template.setParams(parseTemplateContentParams(template.getContent()));
template.setChannelCode(channelDO.getCode()); template.setChannelCode(channelDO.getCode());
smsTemplateMapper.insert(template); smsTemplateMapper.insert(template);
@ -75,7 +73,7 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
@Override @Override
@CacheEvict(cacheNames = RedisKeyConstants.SMS_TEMPLATE, @CacheEvict(cacheNames = RedisKeyConstants.SMS_TEMPLATE,
allEntries = true) // allEntries 清空所有缓存因为可能修改到 code 字段不好清理 allEntries = true) // allEntries 清空所有缓存因为可能修改到 code 字段不好清理
public void updateSmsTemplate(SmsTemplateUpdateReqVO updateReqVO) { public void updateSmsTemplate(SmsTemplateSaveReqVO updateReqVO) {
// 校验存在 // 校验存在
validateSmsTemplateExists(updateReqVO.getId()); validateSmsTemplateExists(updateReqVO.getId());
// 校验短信渠道 // 校验短信渠道
@ -86,7 +84,7 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
validateApiTemplate(updateReqVO.getChannelId(), updateReqVO.getApiTemplateId()); validateApiTemplate(updateReqVO.getChannelId(), updateReqVO.getApiTemplateId());
// 更新 // 更新
SmsTemplateDO updateObj = SmsTemplateConvert.INSTANCE.convert(updateReqVO); SmsTemplateDO updateObj = BeanUtils.toBean(updateReqVO, SmsTemplateDO.class);
updateObj.setParams(parseTemplateContentParams(updateObj.getContent())); updateObj.setParams(parseTemplateContentParams(updateObj.getContent()));
updateObj.setChannelCode(channelDO.getCode()); updateObj.setChannelCode(channelDO.getCode());
smsTemplateMapper.updateById(updateObj); smsTemplateMapper.updateById(updateObj);
@ -126,12 +124,7 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
} }
@Override @Override
public List<SmsTemplateDO> getSmsTemplateList(SmsTemplateExportReqVO exportReqVO) { public Long getSmsTemplateCountByChannelId(Long channelId) {
return smsTemplateMapper.selectList(exportReqVO);
}
@Override
public Long countByChannelId(Long channelId) {
return smsTemplateMapper.selectCountByChannelId(channelId); return smsTemplateMapper.selectCountByChannelId(channelId);
} }

View File

@ -2,14 +2,13 @@ package cn.iocoder.yudao.module.system.service.sms;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.sms.core.client.SmsClient; import cn.iocoder.yudao.framework.sms.core.client.SmsClient;
import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory;
import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelUpdateReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSaveReqVO;
import cn.iocoder.yudao.module.system.convert.sms.SmsChannelConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper; import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -48,7 +47,8 @@ public class SmsChannelServiceTest extends BaseDbUnitTest {
@Test @Test
public void testCreateSmsChannel_success() { public void testCreateSmsChannel_success() {
// 准备参数 // 准备参数
SmsChannelCreateReqVO reqVO = randomPojo(SmsChannelCreateReqVO.class, o -> o.setStatus(randomCommonStatus())); SmsChannelSaveReqVO reqVO = randomPojo(SmsChannelSaveReqVO.class, o -> o.setStatus(randomCommonStatus()))
.setId(null); // 防止 id 被赋值
// 调用 // 调用
Long smsChannelId = smsChannelService.createSmsChannel(reqVO); Long smsChannelId = smsChannelService.createSmsChannel(reqVO);
@ -56,7 +56,7 @@ public class SmsChannelServiceTest extends BaseDbUnitTest {
assertNotNull(smsChannelId); assertNotNull(smsChannelId);
// 校验记录的属性是否正确 // 校验记录的属性是否正确
SmsChannelDO smsChannel = smsChannelMapper.selectById(smsChannelId); SmsChannelDO smsChannel = smsChannelMapper.selectById(smsChannelId);
assertPojoEquals(reqVO, smsChannel); assertPojoEquals(reqVO, smsChannel, "id");
// 断言 cache // 断言 cache
assertNull(smsChannelService.getIdClientCache().getIfPresent(smsChannel.getId())); assertNull(smsChannelService.getIdClientCache().getIfPresent(smsChannel.getId()));
assertNull(smsChannelService.getCodeClientCache().getIfPresent(smsChannel.getCode())); assertNull(smsChannelService.getCodeClientCache().getIfPresent(smsChannel.getCode()));
@ -68,7 +68,7 @@ public class SmsChannelServiceTest extends BaseDbUnitTest {
SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class); SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class);
smsChannelMapper.insert(dbSmsChannel);// @Sql: 先插入出一条存在的数据 smsChannelMapper.insert(dbSmsChannel);// @Sql: 先插入出一条存在的数据
// 准备参数 // 准备参数
SmsChannelUpdateReqVO reqVO = randomPojo(SmsChannelUpdateReqVO.class, o -> { SmsChannelSaveReqVO reqVO = randomPojo(SmsChannelSaveReqVO.class, o -> {
o.setId(dbSmsChannel.getId()); // 设置更新的 ID o.setId(dbSmsChannel.getId()); // 设置更新的 ID
o.setStatus(randomCommonStatus()); o.setStatus(randomCommonStatus());
o.setCallbackUrl(randomString()); o.setCallbackUrl(randomString());
@ -87,7 +87,7 @@ public class SmsChannelServiceTest extends BaseDbUnitTest {
@Test @Test
public void testUpdateSmsChannel_notExists() { public void testUpdateSmsChannel_notExists() {
// 准备参数 // 准备参数
SmsChannelUpdateReqVO reqVO = randomPojo(SmsChannelUpdateReqVO.class); SmsChannelSaveReqVO reqVO = randomPojo(SmsChannelSaveReqVO.class);
// 调用, 并断言异常 // 调用, 并断言异常
assertServiceException(() -> smsChannelService.updateSmsChannel(reqVO), SMS_CHANNEL_NOT_EXISTS); assertServiceException(() -> smsChannelService.updateSmsChannel(reqVO), SMS_CHANNEL_NOT_EXISTS);
@ -127,7 +127,7 @@ public class SmsChannelServiceTest extends BaseDbUnitTest {
// 准备参数 // 准备参数
Long id = dbSmsChannel.getId(); Long id = dbSmsChannel.getId();
// mock 方法 // mock 方法
when(smsTemplateService.countByChannelId(eq(id))).thenReturn(10L); when(smsTemplateService.getSmsTemplateCountByChannelId(eq(id))).thenReturn(10L);
// 调用, 并断言异常 // 调用, 并断言异常
assertServiceException(() -> smsChannelService.deleteSmsChannel(id), SMS_CHANNEL_HAS_CHILDREN); assertServiceException(() -> smsChannelService.deleteSmsChannel(id), SMS_CHANNEL_HAS_CHILDREN);
@ -207,7 +207,7 @@ public class SmsChannelServiceTest extends BaseDbUnitTest {
// 断言 // 断言
assertSame(client, mockClient); assertSame(client, mockClient);
verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> { verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> {
SmsChannelProperties properties = SmsChannelConvert.INSTANCE.convert02(channel); SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class);
return properties.equals(arg); return properties.equals(arg);
})); }));
} }
@ -228,7 +228,7 @@ public class SmsChannelServiceTest extends BaseDbUnitTest {
// 断言 // 断言
assertSame(client, mockClient); assertSame(client, mockClient);
verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> { verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> {
SmsChannelProperties properties = SmsChannelConvert.INSTANCE.convert02(channel); SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class);
return properties.equals(arg); return properties.equals(arg);
})); }));
} }

View File

@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
@ -18,7 +17,6 @@ import org.springframework.context.annotation.Import;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -86,50 +84,6 @@ public class SmsLogServiceImplTest extends BaseDbUnitTest {
assertPojoEquals(dbSmsLog, pageResult.getList().get(0)); assertPojoEquals(dbSmsLog, pageResult.getList().get(0));
} }
@Test
public void testGetSmsLogList() {
// mock 数据
SmsLogDO dbSmsLog = randomSmsLogDO(o -> { // 等会查询到
o.setChannelId(1L);
o.setTemplateId(10L);
o.setMobile("15601691300");
o.setSendStatus(SmsSendStatusEnum.INIT.getStatus());
o.setSendTime(buildTime(2020, 11, 11));
o.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus());
o.setReceiveTime(buildTime(2021, 11, 11));
});
smsLogMapper.insert(dbSmsLog);
// 测试 channelId 不匹配
smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setChannelId(2L)));
// 测试 templateId 不匹配
smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setTemplateId(20L)));
// 测试 mobile 不匹配
smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setMobile("18818260999")));
// 测试 sendStatus 不匹配
smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setSendStatus(SmsSendStatusEnum.IGNORE.getStatus())));
// 测试 sendTime 不匹配
smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setSendTime(buildTime(2020, 12, 12))));
// 测试 receiveStatus 不匹配
smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setReceiveStatus(SmsReceiveStatusEnum.SUCCESS.getStatus())));
// 测试 receiveTime 不匹配
smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setReceiveTime(buildTime(2021, 12, 12))));
// 准备参数
SmsLogExportReqVO reqVO = new SmsLogExportReqVO();
reqVO.setChannelId(1L);
reqVO.setTemplateId(10L);
reqVO.setMobile("156");
reqVO.setSendStatus(SmsSendStatusEnum.INIT.getStatus());
reqVO.setSendTime(buildBetweenTime(2020, 11, 1, 2020, 11, 30));
reqVO.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus());
reqVO.setReceiveTime(buildBetweenTime(2021, 11, 1, 2021, 11, 30));
// 调用
List<SmsLogDO> list = smsLogService.getSmsLogList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbSmsLog, list.get(0));
}
@Test @Test
public void testCreateSmsLog() { public void testCreateSmsLog() {
// 准备参数 // 准备参数

View File

@ -8,10 +8,8 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsClient;
import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO;
import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum; import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateUpdateReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsTemplateMapper; import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsTemplateMapper;
@ -66,11 +64,11 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testCreateSmsTemplate_success() throws Throwable { public void testCreateSmsTemplate_success() throws Throwable {
// 准备参数 // 准备参数
SmsTemplateCreateReqVO reqVO = randomPojo(SmsTemplateCreateReqVO.class, o -> { SmsTemplateSaveReqVO reqVO = randomPojo(SmsTemplateSaveReqVO.class, o -> {
o.setContent("正在进行登录操作{operation},您的验证码是{code}"); o.setContent("正在进行登录操作{operation},您的验证码是{code}");
o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围
o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 范围 o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 范围
}); }).setId(null); // 防止 id 被赋值
// mock Channel 的方法 // mock Channel 的方法
SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> { SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> {
o.setId(reqVO.getChannelId()); o.setId(reqVO.getChannelId());
@ -88,7 +86,7 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
assertNotNull(smsTemplateId); assertNotNull(smsTemplateId);
// 校验记录的属性是否正确 // 校验记录的属性是否正确
SmsTemplateDO smsTemplate = smsTemplateMapper.selectById(smsTemplateId); SmsTemplateDO smsTemplate = smsTemplateMapper.selectById(smsTemplateId);
assertPojoEquals(reqVO, smsTemplate); assertPojoEquals(reqVO, smsTemplate, "id");
assertEquals(Lists.newArrayList("operation", "code"), smsTemplate.getParams()); assertEquals(Lists.newArrayList("operation", "code"), smsTemplate.getParams());
assertEquals(channelDO.getCode(), smsTemplate.getChannelCode()); assertEquals(channelDO.getCode(), smsTemplate.getChannelCode());
} }
@ -100,7 +98,7 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO(); SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO();
smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据 smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据
// 准备参数 // 准备参数
SmsTemplateUpdateReqVO reqVO = randomPojo(SmsTemplateUpdateReqVO.class, o -> { SmsTemplateSaveReqVO reqVO = randomPojo(SmsTemplateSaveReqVO.class, o -> {
o.setId(dbSmsTemplate.getId()); // 设置更新的 ID o.setId(dbSmsTemplate.getId()); // 设置更新的 ID
o.setContent("正在进行登录操作{operation},您的验证码是{code}"); o.setContent("正在进行登录操作{operation},您的验证码是{code}");
o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围
@ -129,7 +127,7 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
@Test @Test
public void testUpdateSmsTemplate_notExists() { public void testUpdateSmsTemplate_notExists() {
// 准备参数 // 准备参数
SmsTemplateUpdateReqVO reqVO = randomPojo(SmsTemplateUpdateReqVO.class); SmsTemplateSaveReqVO reqVO = randomPojo(SmsTemplateSaveReqVO.class);
// 调用, 并断言异常 // 调用, 并断言异常
assertServiceException(() -> smsTemplateService.updateSmsTemplate(reqVO), SMS_TEMPLATE_NOT_EXISTS); assertServiceException(() -> smsTemplateService.updateSmsTemplate(reqVO), SMS_TEMPLATE_NOT_EXISTS);
@ -203,50 +201,6 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
assertPojoEquals(dbSmsTemplate, pageResult.getList().get(0)); assertPojoEquals(dbSmsTemplate, pageResult.getList().get(0));
} }
@Test
public void testGetSmsTemplateList() {
// mock 数据
SmsTemplateDO dbSmsTemplate = randomPojo(SmsTemplateDO.class, o -> { // 等会查询到
o.setType(SmsTemplateTypeEnum.PROMOTION.getType());
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
o.setCode("tudou");
o.setContent("芋道源码");
o.setApiTemplateId("yunai");
o.setChannelId(1L);
o.setCreateTime(buildTime(2021, 11, 11));
});
smsTemplateMapper.insert(dbSmsTemplate);
// 测试 type 不匹配
smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setType(SmsTemplateTypeEnum.VERIFICATION_CODE.getType())));
// 测试 status 不匹配
smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
// 测试 code 不匹配
smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setCode("yuanma")));
// 测试 content 不匹配
smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setContent("源码")));
// 测试 apiTemplateId 不匹配
smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setApiTemplateId("nai")));
// 测试 channelId 不匹配
smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setChannelId(2L)));
// 测试 createTime 不匹配
smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setCreateTime(buildTime(2021, 12, 12))));
// 准备参数
SmsTemplateExportReqVO reqVO = new SmsTemplateExportReqVO();
reqVO.setType(SmsTemplateTypeEnum.PROMOTION.getType());
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
reqVO.setCode("tu");
reqVO.setContent("芋道");
reqVO.setApiTemplateId("yu");
reqVO.setChannelId(1L);
reqVO.setCreateTime(buildBetweenTime(2021, 11, 1, 2021, 12, 1));
// 调用
List<SmsTemplateDO> list = smsTemplateService.getSmsTemplateList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbSmsTemplate, list.get(0));
}
@Test @Test
public void testValidateSmsChannel_success() { public void testValidateSmsChannel_success() {
// 准备参数 // 准备参数