diff --git a/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/mail/MailTemplateApi.java b/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/mail/MailTemplateApi.java new file mode 100644 index 0000000..8b148a6 --- /dev/null +++ b/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/mail/MailTemplateApi.java @@ -0,0 +1,23 @@ +package org.agt.module.system.api.mail; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.agt.framework.common.pojo.CommonResult; +import org.agt.module.system.api.mail.dto.MailTemplateSaveReqDTO; +import org.agt.module.system.enums.ApiConstants; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = +@Tag(name = "RPC 服务 - 邮件") +public interface MailTemplateApi { + + String PREFIX = ApiConstants.PREFIX + "/mail/template"; + + @PostMapping(PREFIX + "/update-template") + @Operation(summary = "更新单条邮件模板", description = "在 mail 为空时,使用 userId 加载对应 Admin 的邮箱") + CommonResult updateMailTemplate(@Valid @RequestBody MailTemplateSaveReqDTO reqDTO); + +} diff --git a/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/mail/dto/MailTemplateSaveReqDTO.java b/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/mail/dto/MailTemplateSaveReqDTO.java new file mode 100644 index 0000000..57bf935 --- /dev/null +++ b/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/mail/dto/MailTemplateSaveReqDTO.java @@ -0,0 +1,46 @@ +package org.agt.module.system.api.mail.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 邮件模版创建/修改 Request DTO") +@Data +public class MailTemplateSaveReqDTO { + + @Schema(description = "编号", example = "1024") + private Long id; + + @Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试名字") + @NotNull(message = "名称不能为空") + private String name; + + @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") + @NotNull(message = "模版编号不能为空") + private String code; + + @Schema(description = "发送的邮箱账号编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "发送的邮箱账号编号不能为空") + private Long accountId; + + @Schema(description = "发送人名称", example = "芋头") + private String nickname; + + @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "注册成功") + @NotEmpty(message = "标题不能为空") + private String title; + + @Schema(description = "内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好,注册成功啦") + @NotEmpty(message = "内容不能为空") + private String content; + + @Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "状态不能为空") + private Integer status; + + @Schema(description = "备注", example = "奥特曼") + private String remark; + +} diff --git a/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/notify/NotifyTemplateApi.java b/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/notify/NotifyTemplateApi.java new file mode 100644 index 0000000..5fb914d --- /dev/null +++ b/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/notify/NotifyTemplateApi.java @@ -0,0 +1,22 @@ +package org.agt.module.system.api.notify; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.agt.framework.common.pojo.CommonResult; +import org.agt.module.system.api.notify.dto.NotifyTemplateSaveReqDTO; +import org.agt.module.system.enums.ApiConstants; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = +@Tag(name = "RPC 服务 - 站内信") +public interface NotifyTemplateApi { + + String PREFIX = ApiConstants.PREFIX + "/notify/template"; + + @PostMapping(PREFIX + "/update-template") + @Operation(summary = "更新单条站内信模板") + CommonResult updateNotifyTemplate(@Valid @RequestBody NotifyTemplateSaveReqDTO reqDTO); +} diff --git a/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/notify/dto/NotifyTemplateSaveReqDTO.java b/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/notify/dto/NotifyTemplateSaveReqDTO.java new file mode 100644 index 0000000..3bb640a --- /dev/null +++ b/agt-module-system/agt-module-system-api/src/main/java/org/agt/module/system/api/notify/dto/NotifyTemplateSaveReqDTO.java @@ -0,0 +1,46 @@ +package org.agt.module.system.api.notify.dto; + +import org.agt.framework.common.enums.CommonStatusEnum; +import org.agt.framework.common.validation.InEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 站内信模版创建/修改 Request DTO") +@Data +public class NotifyTemplateSaveReqDTO { + + @Schema(description = "ID", example = "1024") + private Long id; + + @Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版") + @NotEmpty(message = "模版名称不能为空") + private String name; + + @Schema(description = "模版编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "SEND_TEST") + @NotNull(message = "模版编码不能为空") + private String code; + + @Schema(description = "模版类型,对应 system_notify_template_type 字典", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "模版类型不能为空") + private Integer type; + + @Schema(description = "发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") + @NotEmpty(message = "发送人名称不能为空") + private String nickname; + + @Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是模版内容") + @NotEmpty(message = "模版内容不能为空") + private String content; + + @Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "状态不能为空") + @InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}") + private Integer status; + + @Schema(description = "备注", example = "我是备注") + private String remark; + +} diff --git a/agt-module-system/agt-module-system-server/src/main/java/org/agt/module/system/api/mail/MailTemplateApiImpl.java b/agt-module-system/agt-module-system-server/src/main/java/org/agt/module/system/api/mail/MailTemplateApiImpl.java new file mode 100644 index 0000000..ea8c823 --- /dev/null +++ b/agt-module-system/agt-module-system-server/src/main/java/org/agt/module/system/api/mail/MailTemplateApiImpl.java @@ -0,0 +1,28 @@ +package org.agt.module.system.api.mail; + +import jakarta.annotation.Resource; +import org.agt.framework.common.pojo.CommonResult; +import org.agt.framework.common.util.object.BeanUtils; +import org.agt.module.system.api.mail.dto.MailTemplateSaveReqDTO; +import org.agt.module.system.controller.admin.mail.vo.template.MailTemplateSaveReqVO; +import org.agt.module.system.service.mail.MailTemplateService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RestController; + +import static org.agt.framework.common.pojo.CommonResult.success; + +@RestController // 提供 RESTful API 接口,给 Feign 调用 +@Validated +public class MailTemplateApiImpl implements MailTemplateApi { + + @Resource + private MailTemplateService mailTemplateService; + + @Override + public CommonResult updateMailTemplate(MailTemplateSaveReqDTO reqDTO) { + MailTemplateSaveReqVO reqVO = BeanUtils.toBean(reqDTO, MailTemplateSaveReqVO.class); + mailTemplateService.updateMailTemplate(reqVO); + return success(true); + } + +} diff --git a/agt-module-system/agt-module-system-server/src/main/java/org/agt/module/system/api/notify/NotifyTemplateApiImpl.java b/agt-module-system/agt-module-system-server/src/main/java/org/agt/module/system/api/notify/NotifyTemplateApiImpl.java new file mode 100644 index 0000000..564e6c6 --- /dev/null +++ b/agt-module-system/agt-module-system-server/src/main/java/org/agt/module/system/api/notify/NotifyTemplateApiImpl.java @@ -0,0 +1,27 @@ +package org.agt.module.system.api.notify; + +import jakarta.annotation.Resource; +import org.agt.framework.common.pojo.CommonResult; +import org.agt.framework.common.util.object.BeanUtils; +import org.agt.module.system.api.notify.dto.NotifyTemplateSaveReqDTO; +import org.agt.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO; +import org.agt.module.system.service.notify.NotifyTemplateService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RestController; + +import static org.agt.framework.common.pojo.CommonResult.success; + +@RestController // 提供 RESTful API 接口,给 Feign 调用 +@Validated +public class NotifyTemplateApiImpl implements NotifyTemplateApi { + + @Resource + private NotifyTemplateService notifyTemplateService; + + @Override + public CommonResult updateNotifyTemplate(NotifyTemplateSaveReqDTO reqDTO) { + notifyTemplateService.updateNotifyTemplate(BeanUtils.toBean(reqDTO, NotifyTemplateSaveReqVO.class)); + return success(true); + } + +}