Commit 3f1d86efffb10c39b82cf3379a6a4db0b0c957d8
1 parent
a08526d8
fix: 优化IoT告警配置支持动态选择邮件、短信、站内信的模板,不再依赖templateCode。
Showing
16 changed files
with
175 additions
and
8 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/alert/vo/config/IotAlertConfigRespVO.java
| ... | ... | @@ -37,6 +37,15 @@ public class IotAlertConfigRespVO { |
| 37 | 37 | @Schema(description = "接收的类型数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") |
| 38 | 38 | private List<Integer> receiveTypes; |
| 39 | 39 | |
| 40 | + @Schema(description = "短信模板编号", example = "iot_alert_sms") | |
| 41 | + private String smsTemplateCode; | |
| 42 | + | |
| 43 | + @Schema(description = "邮件模板编号", example = "iot_alert_mail") | |
| 44 | + private String mailTemplateCode; | |
| 45 | + | |
| 46 | + @Schema(description = "站内信模板编号", example = "iot_alert_notify") | |
| 47 | + private String notifyTemplateCode; | |
| 48 | + | |
| 40 | 49 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 41 | 50 | private LocalDateTime createTime; |
| 42 | 51 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/alert/vo/config/IotAlertConfigSaveReqVO.java
| ... | ... | @@ -44,4 +44,12 @@ public class IotAlertConfigSaveReqVO { |
| 44 | 44 | @NotEmpty(message = "接收的类型数组不能为空") |
| 45 | 45 | private List<Integer> receiveTypes; |
| 46 | 46 | |
| 47 | + @Schema(description = "短信模板编号", example = "iot_alert_sms") | |
| 48 | + private String smsTemplateCode; | |
| 49 | + | |
| 50 | + @Schema(description = "邮件模板编号", example = "iot_alert_mail") | |
| 51 | + private String mailTemplateCode; | |
| 52 | + | |
| 53 | + @Schema(description = "站内信模板编号", example = "iot_alert_notify") | |
| 54 | + private String notifyTemplateCode; | |
| 47 | 55 | } |
| 48 | 56 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/alert/IotAlertConfigDO.java
| ... | ... | @@ -81,4 +81,22 @@ public class IotAlertConfigDO extends BaseDO { |
| 81 | 81 | @TableField(typeHandler = IntegerListTypeHandler.class) |
| 82 | 82 | private List<Integer> receiveTypes; |
| 83 | 83 | |
| 84 | + /** | |
| 85 | + * 短信模板编号 | |
| 86 | + * | |
| 87 | + * 关联 SmsTemplateDO 的 code 属性 | |
| 88 | + */ | |
| 89 | + private String smsTemplateCode; | |
| 90 | + /** | |
| 91 | + * 邮件模板编号 | |
| 92 | + * | |
| 93 | + * 关联 MailTemplateDO 的 code 属性 | |
| 94 | + */ | |
| 95 | + private String mailTemplateCode; | |
| 96 | + /** | |
| 97 | + * 站内信模板编号 | |
| 98 | + * | |
| 99 | + * 关联 NotifyTemplateDO 的 code 属性 | |
| 100 | + */ | |
| 101 | + private String notifyTemplateCode; | |
| 84 | 102 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/ErrorCodeConstants.java
| ... | ... | @@ -98,6 +98,9 @@ public interface ErrorCodeConstants { |
| 98 | 98 | |
| 99 | 99 | // ========== IoT 告警配置 1-050-013-000 ========== |
| 100 | 100 | ErrorCode ALERT_CONFIG_NOT_EXISTS = new ErrorCode(1_050_013_000, "IoT 告警配置不存在"); |
| 101 | + ErrorCode ALERT_CONFIG_SMS_TEMPLATE_REQUIRED = new ErrorCode(1_050_013_001, "已选择短信接收方式,短信模板不能为空"); | |
| 102 | + ErrorCode ALERT_CONFIG_MAIL_TEMPLATE_REQUIRED = new ErrorCode(1_050_013_002, "已选择邮件接收方式,邮件模板不能为空"); | |
| 103 | + ErrorCode ALERT_CONFIG_NOTIFY_TEMPLATE_REQUIRED = new ErrorCode(1_050_013_003, "已选择站内信接收方式,站内信模板不能为空"); | |
| 101 | 104 | |
| 102 | 105 | // ========== IoT 告警记录 1-050-014-000 ========== |
| 103 | 106 | ErrorCode ALERT_RECORD_NOT_EXISTS = new ErrorCode(1_050_014_000, "IoT 告警记录不存在"); | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/alert/IotAlertConfigServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.alert; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.hutool.core.util.StrUtil; | |
| 3 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | 7 | import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigPageReqVO; |
| 6 | 8 | import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigSaveReqVO; |
| 7 | 9 | import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertConfigDO; |
| 8 | 10 | import cn.iocoder.yudao.module.iot.dal.mysql.alert.IotAlertConfigMapper; |
| 11 | +import cn.iocoder.yudao.module.iot.enums.alert.IotAlertReceiveTypeEnum; | |
| 9 | 12 | import cn.iocoder.yudao.module.iot.service.rule.scene.IotSceneRuleService; |
| 10 | 13 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 11 | 14 | import jakarta.annotation.Resource; |
| ... | ... | @@ -16,7 +19,10 @@ import org.springframework.validation.annotation.Validated; |
| 16 | 19 | import java.util.List; |
| 17 | 20 | |
| 18 | 21 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 22 | +import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.ALERT_CONFIG_MAIL_TEMPLATE_REQUIRED; | |
| 19 | 23 | import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.ALERT_CONFIG_NOT_EXISTS; |
| 24 | +import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.ALERT_CONFIG_NOTIFY_TEMPLATE_REQUIRED; | |
| 25 | +import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.ALERT_CONFIG_SMS_TEMPLATE_REQUIRED; | |
| 20 | 26 | |
| 21 | 27 | /** |
| 22 | 28 | * IoT 告警配置 Service 实现类 |
| ... | ... | @@ -42,6 +48,7 @@ public class IotAlertConfigServiceImpl implements IotAlertConfigService { |
| 42 | 48 | // 校验关联数据是否存在 |
| 43 | 49 | sceneRuleService.validateSceneRuleList(createReqVO.getSceneRuleIds()); |
| 44 | 50 | adminUserApi.validateUserList(createReqVO.getReceiveUserIds()); |
| 51 | + validateReceiveTemplates(createReqVO); | |
| 45 | 52 | |
| 46 | 53 | // 插入 |
| 47 | 54 | IotAlertConfigDO alertConfig = BeanUtils.toBean(createReqVO, IotAlertConfigDO.class); |
| ... | ... | @@ -56,6 +63,7 @@ public class IotAlertConfigServiceImpl implements IotAlertConfigService { |
| 56 | 63 | // 校验关联数据是否存在 |
| 57 | 64 | sceneRuleService.validateSceneRuleList(updateReqVO.getSceneRuleIds()); |
| 58 | 65 | adminUserApi.validateUserList(updateReqVO.getReceiveUserIds()); |
| 66 | + validateReceiveTemplates(updateReqVO); | |
| 59 | 67 | |
| 60 | 68 | // 更新 |
| 61 | 69 | IotAlertConfigDO updateObj = BeanUtils.toBean(updateReqVO, IotAlertConfigDO.class); |
| ... | ... | @@ -76,6 +84,24 @@ public class IotAlertConfigServiceImpl implements IotAlertConfigService { |
| 76 | 84 | } |
| 77 | 85 | } |
| 78 | 86 | |
| 87 | + private void validateReceiveTemplates(IotAlertConfigSaveReqVO reqVO) { | |
| 88 | + if (CollUtil.isEmpty(reqVO.getReceiveTypes())) { | |
| 89 | + return; | |
| 90 | + } | |
| 91 | + if (reqVO.getReceiveTypes().contains(IotAlertReceiveTypeEnum.SMS.getType()) | |
| 92 | + && StrUtil.isBlank(reqVO.getSmsTemplateCode())) { | |
| 93 | + throw exception(ALERT_CONFIG_SMS_TEMPLATE_REQUIRED); | |
| 94 | + } | |
| 95 | + if (reqVO.getReceiveTypes().contains(IotAlertReceiveTypeEnum.MAIL.getType()) | |
| 96 | + && StrUtil.isBlank(reqVO.getMailTemplateCode())) { | |
| 97 | + throw exception(ALERT_CONFIG_MAIL_TEMPLATE_REQUIRED); | |
| 98 | + } | |
| 99 | + if (reqVO.getReceiveTypes().contains(IotAlertReceiveTypeEnum.NOTIFY.getType()) | |
| 100 | + && StrUtil.isBlank(reqVO.getNotifyTemplateCode())) { | |
| 101 | + throw exception(ALERT_CONFIG_NOTIFY_TEMPLATE_REQUIRED); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + | |
| 79 | 105 | @Override |
| 80 | 106 | public IotAlertConfigDO getAlertConfig(Long id) { |
| 81 | 107 | return alertConfigMapper.selectById(id); | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotAlertTriggerSceneRuleAction.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.rule.scene.action; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.util.StrUtil; | |
| 4 | 5 | import cn.hutool.core.date.DatePattern; |
| 5 | 6 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 6 | 7 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| ... | ... | @@ -79,30 +80,38 @@ public class IotAlertTriggerSceneRuleAction implements IotSceneRuleAction { |
| 79 | 80 | } |
| 80 | 81 | Map<String, Object> templateParams = buildTemplateParams(config, deviceMessage, device); |
| 81 | 82 | config.getReceiveUserIds().forEach(userId -> |
| 82 | - config.getReceiveTypes().forEach(receiveType -> sendAlertMessageToUser(userId, receiveType, templateParams))); | |
| 83 | + config.getReceiveTypes().forEach(receiveType -> | |
| 84 | + sendAlertMessageToUser(userId, receiveType, config, templateParams))); | |
| 83 | 85 | } |
| 84 | 86 | |
| 85 | 87 | /** |
| 86 | 88 | * 按指定接收方式,给单个用户发送告警消息 |
| 87 | 89 | */ |
| 88 | - private void sendAlertMessageToUser(Long userId, Integer receiveType, Map<String, Object> templateParams) { | |
| 90 | + private void sendAlertMessageToUser(Long userId, Integer receiveType, IotAlertConfigDO config, | |
| 91 | + Map<String, Object> templateParams) { | |
| 89 | 92 | IotAlertReceiveTypeEnum typeEnum = IotAlertReceiveTypeEnum.of(receiveType); |
| 90 | 93 | if (typeEnum == null) { |
| 91 | 94 | return; |
| 92 | 95 | } |
| 96 | + String templateCode = resolveTemplateCode(config, typeEnum); | |
| 97 | + if (StrUtil.isBlank(templateCode)) {//为了兼容老的结构 | |
| 98 | + templateCode=typeEnum.getTemplateCode(); | |
| 99 | + log.warn("[sendAlertMessageToUser][配置({}) 用户({}) 接收方式({}) 未配置模板,使用默认模板({})]", | |
| 100 | + config.getId(), userId, typeEnum,templateCode); | |
| 101 | + } | |
| 93 | 102 | try { |
| 94 | 103 | switch (typeEnum) { |
| 95 | 104 | case SMS: |
| 96 | 105 | smsSendApi.sendSingleSmsToAdmin(new SmsSendSingleToUserReqDTO().setUserId(userId) |
| 97 | - .setTemplateCode(typeEnum.getTemplateCode()).setTemplateParams(templateParams)); | |
| 106 | + .setTemplateCode(templateCode).setTemplateParams(templateParams)); | |
| 98 | 107 | break; |
| 99 | 108 | case MAIL: |
| 100 | 109 | mailSendApi.sendSingleMailToAdmin(new MailSendSingleToUserReqDTO().setUserId(userId) |
| 101 | - .setTemplateCode(typeEnum.getTemplateCode()).setTemplateParams(templateParams)); | |
| 110 | + .setTemplateCode(templateCode).setTemplateParams(templateParams)); | |
| 102 | 111 | break; |
| 103 | 112 | case NOTIFY: |
| 104 | 113 | notifyMessageSendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO().setUserId(userId) |
| 105 | - .setTemplateCode(typeEnum.getTemplateCode()).setTemplateParams(templateParams)); | |
| 114 | + .setTemplateCode(templateCode).setTemplateParams(templateParams)); | |
| 106 | 115 | break; |
| 107 | 116 | } |
| 108 | 117 | } catch (Exception ex) { |
| ... | ... | @@ -111,6 +120,15 @@ public class IotAlertTriggerSceneRuleAction implements IotSceneRuleAction { |
| 111 | 120 | } |
| 112 | 121 | } |
| 113 | 122 | |
| 123 | + private String resolveTemplateCode(IotAlertConfigDO config, IotAlertReceiveTypeEnum typeEnum) { | |
| 124 | + String templateCode = switch (typeEnum) { | |
| 125 | + case SMS -> config.getSmsTemplateCode(); | |
| 126 | + case MAIL -> config.getMailTemplateCode(); | |
| 127 | + case NOTIFY -> config.getNotifyTemplateCode(); | |
| 128 | + }; | |
| 129 | + return StrUtil.blankToDefault(templateCode, typeEnum.getTemplateCode()); | |
| 130 | + } | |
| 131 | + | |
| 114 | 132 | private Map<String, Object> buildTemplateParams(IotAlertConfigDO config, |
| 115 | 133 | @Nullable IotDeviceMessage deviceMessage, |
| 116 | 134 | @Nullable IotDeviceDO device) { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotAlertTriggerSceneRuleActionTest.java
| ... | ... | @@ -106,6 +106,9 @@ public class IotAlertTriggerSceneRuleActionTest extends BaseMockitoUnitTest { |
| 106 | 106 | IotAlertReceiveTypeEnum.SMS.getType(), |
| 107 | 107 | IotAlertReceiveTypeEnum.MAIL.getType(), |
| 108 | 108 | IotAlertReceiveTypeEnum.NOTIFY.getType())); |
| 109 | + c.setSmsTemplateCode("custom_sms"); | |
| 110 | + c.setMailTemplateCode("custom_mail"); | |
| 111 | + c.setNotifyTemplateCode("custom_notify"); | |
| 109 | 112 | }); |
| 110 | 113 | IotDeviceDO device = randomPojo(IotDeviceDO.class); |
| 111 | 114 | |
| ... | ... | @@ -130,13 +133,13 @@ public class IotAlertTriggerSceneRuleActionTest extends BaseMockitoUnitTest { |
| 130 | 133 | ArgumentCaptor<SmsSendSingleToUserReqDTO> smsCaptor = ArgumentCaptor.forClass(SmsSendSingleToUserReqDTO.class); |
| 131 | 134 | verify(smsSendApi, times(1)).sendSingleSmsToAdmin(smsCaptor.capture()); |
| 132 | 135 | assertEquals(userId, smsCaptor.getValue().getUserId()); |
| 133 | - assertEquals(IotAlertReceiveTypeEnum.SMS.getTemplateCode(), smsCaptor.getValue().getTemplateCode()); | |
| 136 | + assertEquals("custom_sms", smsCaptor.getValue().getTemplateCode()); | |
| 134 | 137 | ArgumentCaptor<MailSendSingleToUserReqDTO> mailCaptor = ArgumentCaptor.forClass(MailSendSingleToUserReqDTO.class); |
| 135 | 138 | verify(mailSendApi, times(1)).sendSingleMailToAdmin(mailCaptor.capture()); |
| 136 | - assertEquals(IotAlertReceiveTypeEnum.MAIL.getTemplateCode(), mailCaptor.getValue().getTemplateCode()); | |
| 139 | + assertEquals("custom_mail", mailCaptor.getValue().getTemplateCode()); | |
| 137 | 140 | ArgumentCaptor<NotifySendSingleToUserReqDTO> notifyCaptor = ArgumentCaptor.forClass(NotifySendSingleToUserReqDTO.class); |
| 138 | 141 | verify(notifyMessageSendApi, times(1)).sendSingleMessageToAdmin(notifyCaptor.capture()); |
| 139 | - assertEquals(IotAlertReceiveTypeEnum.NOTIFY.getTemplateCode(), notifyCaptor.getValue().getTemplateCode()); | |
| 142 | + assertEquals("custom_notify", notifyCaptor.getValue().getTemplateCode()); | |
| 140 | 143 | } |
| 141 | 144 | |
| 142 | 145 | @Test | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateSimpleRespVO.java
| ... | ... | @@ -13,4 +13,7 @@ public class MailTemplateSimpleRespVO { |
| 13 | 13 | @Schema(description = "模版名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "哒哒哒") |
| 14 | 14 | private String name; |
| 15 | 15 | |
| 16 | + @Schema(description = "模版编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "mail_001") | |
| 17 | + private String code; | |
| 18 | + | |
| 16 | 19 | } | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
| ... | ... | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.Notify |
| 8 | 8 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateRespVO; |
| 9 | 9 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO; |
| 10 | 10 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSendReqVO; |
| 11 | +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSimpleRespVO; | |
| 11 | 12 | import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; |
| 12 | 13 | import cn.iocoder.yudao.module.system.service.notify.NotifySendService; |
| 13 | 14 | import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService; |
| ... | ... | @@ -86,6 +87,13 @@ public class NotifyTemplateController { |
| 86 | 87 | return success(BeanUtils.toBean(pageResult, NotifyTemplateRespVO.class)); |
| 87 | 88 | } |
| 88 | 89 | |
| 90 | + @GetMapping({"/list-all-simple", "/simple-list"}) | |
| 91 | + @Operation(summary = "获得站内信模版精简列表") | |
| 92 | + public CommonResult<List<NotifyTemplateSimpleRespVO>> getSimpleTemplateList() { | |
| 93 | + List<NotifyTemplateDO> list = notifyTemplateService.getNotifyTemplateList(); | |
| 94 | + return success(BeanUtils.toBean(list, NotifyTemplateSimpleRespVO.class)); | |
| 95 | + } | |
| 96 | + | |
| 89 | 97 | @PostMapping("/send-notify") |
| 90 | 98 | @Operation(summary = "发送站内信") |
| 91 | 99 | @PreAuthorize("@ss.hasPermission('system:notify-template:send-notify')") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSimpleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 站内信模版的精简 Response VO") | |
| 7 | +@Data | |
| 8 | +public class NotifyTemplateSimpleRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 11 | + private Long id; | |
| 12 | + | |
| 13 | + @Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "系统通知") | |
| 14 | + private String name; | |
| 15 | + | |
| 16 | + @Schema(description = "模版编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "notify_001") | |
| 17 | + private String code; | |
| 18 | + | |
| 19 | +} | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsTemplateController.java
| ... | ... | @@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTempla |
| 10 | 10 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateRespVO; |
| 11 | 11 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; |
| 12 | 12 | import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSendReqVO; |
| 13 | +import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSimpleRespVO; | |
| 13 | 14 | import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; |
| 14 | 15 | import cn.iocoder.yudao.module.system.service.sms.SmsSendService; |
| 15 | 16 | import cn.iocoder.yudao.module.system.service.sms.SmsTemplateService; |
| ... | ... | @@ -88,6 +89,13 @@ public class SmsTemplateController { |
| 88 | 89 | return success(BeanUtils.toBean(pageResult, SmsTemplateRespVO.class)); |
| 89 | 90 | } |
| 90 | 91 | |
| 92 | + @GetMapping({"/list-all-simple", "/simple-list"}) | |
| 93 | + @Operation(summary = "获得短信模板精简列表") | |
| 94 | + public CommonResult<List<SmsTemplateSimpleRespVO>> getSimpleTemplateList() { | |
| 95 | + List<SmsTemplateDO> list = smsTemplateService.getSmsTemplateList(); | |
| 96 | + return success(BeanUtils.toBean(list, SmsTemplateSimpleRespVO.class)); | |
| 97 | + } | |
| 98 | + | |
| 91 | 99 | @GetMapping("/export-excel") |
| 92 | 100 | @Operation(summary = "导出短信模板 Excel") |
| 93 | 101 | @PreAuthorize("@ss.hasPermission('system:sms-template:export')") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/vo/template/SmsTemplateSimpleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.sms.vo.template; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 短信模板的精简 Response VO") | |
| 7 | +@Data | |
| 8 | +public class SmsTemplateSimpleRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 11 | + private Long id; | |
| 12 | + | |
| 13 | + @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "验证码") | |
| 14 | + private String name; | |
| 15 | + | |
| 16 | + @Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "sms_001") | |
| 17 | + private String code; | |
| 18 | + | |
| 19 | +} | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
| ... | ... | @@ -70,6 +70,13 @@ public interface NotifyTemplateService { |
| 70 | 70 | PageResult<NotifyTemplateDO> getNotifyTemplatePage(NotifyTemplatePageReqVO pageReqVO); |
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | + * 获得启用状态的站内信模版列表 | |
| 74 | + * | |
| 75 | + * @return 站内信模版列表 | |
| 76 | + */ | |
| 77 | + List<NotifyTemplateDO> getNotifyTemplateList(); | |
| 78 | + | |
| 79 | + /** | |
| 73 | 80 | * 格式化站内信内容 |
| 74 | 81 | * |
| 75 | 82 | * @param content 站内信模板的内容 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.notify; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.ReUtil; |
| 4 | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | 8 | import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO; |
| ... | ... | @@ -115,6 +116,11 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService { |
| 115 | 116 | return notifyTemplateMapper.selectPage(pageReqVO); |
| 116 | 117 | } |
| 117 | 118 | |
| 119 | + @Override | |
| 120 | + public List<NotifyTemplateDO> getNotifyTemplateList() { | |
| 121 | + return notifyTemplateMapper.selectList(NotifyTemplateDO::getStatus, CommonStatusEnum.ENABLE.getStatus()); | |
| 122 | + } | |
| 123 | + | |
| 118 | 124 | @VisibleForTesting |
| 119 | 125 | void validateNotifyTemplateCodeDuplicate(Long id, String code) { |
| 120 | 126 | NotifyTemplateDO template = notifyTemplateMapper.selectByCode(code); | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateService.java
| ... | ... | @@ -71,6 +71,13 @@ public interface SmsTemplateService { |
| 71 | 71 | PageResult<SmsTemplateDO> getSmsTemplatePage(SmsTemplatePageReqVO pageReqVO); |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | + * 获得启用状态的短信模板列表 | |
| 75 | + * | |
| 76 | + * @return 短信模板列表 | |
| 77 | + */ | |
| 78 | + List<SmsTemplateDO> getSmsTemplateList(); | |
| 79 | + | |
| 80 | + /** | |
| 74 | 81 | * 获得指定短信渠道下的短信模板数量 |
| 75 | 82 | * |
| 76 | 83 | * @param channelId 短信渠道编号 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImpl.java
| ... | ... | @@ -131,6 +131,11 @@ public class SmsTemplateServiceImpl implements SmsTemplateService { |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | @Override |
| 134 | + public List<SmsTemplateDO> getSmsTemplateList() { | |
| 135 | + return smsTemplateMapper.selectList(SmsTemplateDO::getStatus, CommonStatusEnum.ENABLE.getStatus()); | |
| 136 | + } | |
| 137 | + | |
| 138 | + @Override | |
| 134 | 139 | public Long getSmsTemplateCountByChannelId(Long channelId) { |
| 135 | 140 | return smsTemplateMapper.selectCountByChannelId(channelId); |
| 136 | 141 | } | ... | ... |