Yangzw 10 місяців тому
батько
коміт
bba941b1fc
10 змінених файлів з 384 додано та 0 видалено
  1. 2 0
      feifan-module-system/feifan-module-system-api/src/main/java/cn/newfeifan/mall/module/system/enums/ErrorCodeConstants.java
  2. 94 0
      feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/wechatmsgtemplate/WechatMsgTemplateController.java
  3. 30 0
      feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/wechatmsgtemplate/vo/WechatMsgTemplatePageReqVO.java
  4. 33 0
      feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/wechatmsgtemplate/vo/WechatMsgTemplateRespVO.java
  5. 22 0
      feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/wechatmsgtemplate/vo/WechatMsgTemplateSaveReqVO.java
  6. 40 0
      feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/dal/dataobject/wechatmsgtemplate/WechatMsgTemplateDO.java
  7. 28 0
      feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/dal/mysql/wechatmsgtemplate/WechatMsgTemplateMapper.java
  8. 53 0
      feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/service/wechatmsgtemplate/WechatMsgTemplateService.java
  9. 70 0
      feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/service/wechatmsgtemplate/WechatMsgTemplateServiceImpl.java
  10. 12 0
      feifan-module-system/feifan-module-system-biz/src/main/resources/mapper/wechatmsgtemplate/WechatMsgTemplateMapper.xml

+ 2 - 0
feifan-module-system/feifan-module-system-api/src/main/java/cn/newfeifan/mall/module/system/enums/ErrorCodeConstants.java

@@ -171,4 +171,6 @@ public interface ErrorCodeConstants {
     // ========== 站内信发送 1-002-028-000 ==========
     ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
 
+    ErrorCode WECHAT_MSG_TEMPLATE_NOT_EXISTS = new ErrorCode(1_002_028_001, "微信消息模板不存在");
+
 }

+ 94 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/wechatmsgtemplate/WechatMsgTemplateController.java

@@ -0,0 +1,94 @@
+package cn.newfeifan.mall.module.system.controller.admin.wechatmsgtemplate;
+
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import javax.validation.*;
+import javax.servlet.http.*;
+import java.util.*;
+import java.io.IOException;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.CommonResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
+
+import cn.newfeifan.mall.framework.excel.core.util.ExcelUtils;
+
+import cn.newfeifan.mall.framework.operatelog.core.annotations.OperateLog;
+import static cn.newfeifan.mall.framework.operatelog.core.enums.OperateTypeEnum.*;
+
+import cn.newfeifan.mall.module.system.controller.admin.wechatmsgtemplate.vo.*;
+import cn.newfeifan.mall.module.system.dal.dataobject.wechatmsgtemplate.WechatMsgTemplateDO;
+import cn.newfeifan.mall.module.system.service.wechatmsgtemplate.WechatMsgTemplateService;
+
+@Tag(name = "管理后台 - 微信消息模板")
+@RestController
+@RequestMapping("/system/wechat-msg-template")
+@Validated
+public class WechatMsgTemplateController {
+
+    @Resource
+    private WechatMsgTemplateService wechatMsgTemplateService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建微信消息模板")
+    @PreAuthorize("@ss.hasPermission('system:wechat-msg-template:create')")
+    public CommonResult<Long> createWechatMsgTemplate(@Valid @RequestBody WechatMsgTemplateSaveReqVO createReqVO) {
+        return success(wechatMsgTemplateService.createWechatMsgTemplate(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新微信消息模板")
+    @PreAuthorize("@ss.hasPermission('system:wechat-msg-template:update')")
+    public CommonResult<Boolean> updateWechatMsgTemplate(@Valid @RequestBody WechatMsgTemplateSaveReqVO updateReqVO) {
+        wechatMsgTemplateService.updateWechatMsgTemplate(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除微信消息模板")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('system:wechat-msg-template:delete')")
+    public CommonResult<Boolean> deleteWechatMsgTemplate(@RequestParam("id") Long id) {
+        wechatMsgTemplateService.deleteWechatMsgTemplate(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得微信消息模板")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('system:wechat-msg-template:query')")
+    public CommonResult<WechatMsgTemplateRespVO> getWechatMsgTemplate(@RequestParam("id") Long id) {
+        WechatMsgTemplateDO wechatMsgTemplate = wechatMsgTemplateService.getWechatMsgTemplate(id);
+        return success(BeanUtils.toBean(wechatMsgTemplate, WechatMsgTemplateRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得微信消息模板分页")
+    @PreAuthorize("@ss.hasPermission('system:wechat-msg-template:query')")
+    public CommonResult<PageResult<WechatMsgTemplateRespVO>> getWechatMsgTemplatePage(@Valid WechatMsgTemplatePageReqVO pageReqVO) {
+        PageResult<WechatMsgTemplateDO> pageResult = wechatMsgTemplateService.getWechatMsgTemplatePage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, WechatMsgTemplateRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出微信消息模板 Excel")
+    @PreAuthorize("@ss.hasPermission('system:wechat-msg-template:export')")
+    @OperateLog(type = EXPORT)
+    public void exportWechatMsgTemplateExcel(@Valid WechatMsgTemplatePageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<WechatMsgTemplateDO> list = wechatMsgTemplateService.getWechatMsgTemplatePage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "微信消息模板.xls", "数据", WechatMsgTemplateRespVO.class,
+                        BeanUtils.toBean(list, WechatMsgTemplateRespVO.class));
+    }
+
+}

+ 30 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/wechatmsgtemplate/vo/WechatMsgTemplatePageReqVO.java

@@ -0,0 +1,30 @@
+package cn.newfeifan.mall.module.system.controller.admin.wechatmsgtemplate.vo;
+
+import lombok.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 微信消息模板分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class WechatMsgTemplatePageReqVO extends PageParam {
+
+    @Schema(description = "微信消息模板id", example = "29466")
+    private String wechatMsgTemplateId;
+
+    @Schema(description = "备注、说明", example = "随便")
+    private String remark;
+
+    @Schema(description = "消息模板参数")
+    private String messageTemplateParameters;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 33 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/wechatmsgtemplate/vo/WechatMsgTemplateRespVO.java

@@ -0,0 +1,33 @@
+package cn.newfeifan.mall.module.system.controller.admin.wechatmsgtemplate.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "管理后台 - 微信消息模板 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class WechatMsgTemplateRespVO {
+
+    @Schema(description = "模板id,非自增,由开发人员编号,对应java中的常量", requiredMode = Schema.RequiredMode.REQUIRED, example = "13788")
+    @ExcelProperty("模板id,非自增,由开发人员编号,对应java中的常量")
+    private Long id;
+
+    @Schema(description = "微信消息模板id", example = "29466")
+    @ExcelProperty("微信消息模板id")
+    private String wechatMsgTemplateId;
+
+    @Schema(description = "备注、说明", example = "随便")
+    @ExcelProperty("备注、说明")
+    private String remark;
+
+    @Schema(description = "消息模板参数")
+    @ExcelProperty("消息模板参数")
+    private String messageTemplateParameters;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 22 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/wechatmsgtemplate/vo/WechatMsgTemplateSaveReqVO.java

@@ -0,0 +1,22 @@
+package cn.newfeifan.mall.module.system.controller.admin.wechatmsgtemplate.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+
+@Schema(description = "管理后台 - 微信消息模板新增/修改 Request VO")
+@Data
+public class WechatMsgTemplateSaveReqVO {
+
+    @Schema(description = "模板id,非自增,由开发人员编号,对应java中的常量", requiredMode = Schema.RequiredMode.REQUIRED, example = "13788")
+    private Long id;
+
+    @Schema(description = "微信消息模板id", example = "29466")
+    private String wechatMsgTemplateId;
+
+    @Schema(description = "备注、说明", example = "随便")
+    private String remark;
+
+    @Schema(description = "消息模板参数")
+    private String messageTemplateParameters;
+
+}

+ 40 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/dal/dataobject/wechatmsgtemplate/WechatMsgTemplateDO.java

@@ -0,0 +1,40 @@
+package cn.newfeifan.mall.module.system.dal.dataobject.wechatmsgtemplate;
+
+import lombok.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 微信消息模板 DO
+ *
+ * @author 非繁人
+ */
+@TableName("system_wechat_msg_template")
+@KeySequence("system_wechat_msg_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class WechatMsgTemplateDO extends BaseDO {
+
+    /**
+     * 模板id,非自增,由开发人员编号,对应java中的常量
+     */
+    @TableId
+    private Long id;
+    /**
+     * 微信消息模板id
+     */
+    private String wechatMsgTemplateId;
+    /**
+     * 备注、说明
+     */
+    private String remark;
+    /**
+     * 消息模板参数
+     */
+    private String messageTemplateParameters;
+
+}

+ 28 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/dal/mysql/wechatmsgtemplate/WechatMsgTemplateMapper.java

@@ -0,0 +1,28 @@
+package cn.newfeifan.mall.module.system.dal.mysql.wechatmsgtemplate;
+
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.module.system.dal.dataobject.wechatmsgtemplate.WechatMsgTemplateDO;
+import org.apache.ibatis.annotations.Mapper;
+import cn.newfeifan.mall.module.system.controller.admin.wechatmsgtemplate.vo.*;
+
+/**
+ * 微信消息模板 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface WechatMsgTemplateMapper extends BaseMapperX<WechatMsgTemplateDO> {
+
+    default PageResult<WechatMsgTemplateDO> selectPage(WechatMsgTemplatePageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<WechatMsgTemplateDO>()
+                .eqIfPresent(WechatMsgTemplateDO::getWechatMsgTemplateId, reqVO.getWechatMsgTemplateId())
+                .eqIfPresent(WechatMsgTemplateDO::getRemark, reqVO.getRemark())
+                .eqIfPresent(WechatMsgTemplateDO::getMessageTemplateParameters, reqVO.getMessageTemplateParameters())
+                .betweenIfPresent(WechatMsgTemplateDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(WechatMsgTemplateDO::getId));
+    }
+
+}

+ 53 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/service/wechatmsgtemplate/WechatMsgTemplateService.java

@@ -0,0 +1,53 @@
+package cn.newfeifan.mall.module.system.service.wechatmsgtemplate;
+
+import javax.validation.*;
+import cn.newfeifan.mall.module.system.controller.admin.wechatmsgtemplate.vo.*;
+import cn.newfeifan.mall.module.system.dal.dataobject.wechatmsgtemplate.WechatMsgTemplateDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+
+/**
+ * 微信消息模板 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface WechatMsgTemplateService {
+
+    /**
+     * 创建微信消息模板
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createWechatMsgTemplate(@Valid WechatMsgTemplateSaveReqVO createReqVO);
+
+    /**
+     * 更新微信消息模板
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateWechatMsgTemplate(@Valid WechatMsgTemplateSaveReqVO updateReqVO);
+
+    /**
+     * 删除微信消息模板
+     *
+     * @param id 编号
+     */
+    void deleteWechatMsgTemplate(Long id);
+
+    /**
+     * 获得微信消息模板
+     *
+     * @param id 编号
+     * @return 微信消息模板
+     */
+    WechatMsgTemplateDO getWechatMsgTemplate(Long id);
+
+    /**
+     * 获得微信消息模板分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 微信消息模板分页
+     */
+    PageResult<WechatMsgTemplateDO> getWechatMsgTemplatePage(WechatMsgTemplatePageReqVO pageReqVO);
+
+}

+ 70 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/service/wechatmsgtemplate/WechatMsgTemplateServiceImpl.java

@@ -0,0 +1,70 @@
+package cn.newfeifan.mall.module.system.service.wechatmsgtemplate;
+
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import cn.newfeifan.mall.module.system.controller.admin.wechatmsgtemplate.vo.*;
+import cn.newfeifan.mall.module.system.dal.dataobject.wechatmsgtemplate.WechatMsgTemplateDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+
+import cn.newfeifan.mall.module.system.dal.mysql.wechatmsgtemplate.WechatMsgTemplateMapper;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.system.enums.ErrorCodeConstants.*;
+
+/**
+ * 微信消息模板 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class WechatMsgTemplateServiceImpl implements WechatMsgTemplateService {
+
+    @Resource
+    private WechatMsgTemplateMapper wechatMsgTemplateMapper;
+
+    @Override
+    public Long createWechatMsgTemplate(WechatMsgTemplateSaveReqVO createReqVO) {
+        // 插入
+        WechatMsgTemplateDO wechatMsgTemplate = BeanUtils.toBean(createReqVO, WechatMsgTemplateDO.class);
+        wechatMsgTemplateMapper.insert(wechatMsgTemplate);
+        // 返回
+        return wechatMsgTemplate.getId();
+    }
+
+    @Override
+    public void updateWechatMsgTemplate(WechatMsgTemplateSaveReqVO updateReqVO) {
+        // 校验存在
+        validateWechatMsgTemplateExists(updateReqVO.getId());
+        // 更新
+        WechatMsgTemplateDO updateObj = BeanUtils.toBean(updateReqVO, WechatMsgTemplateDO.class);
+        wechatMsgTemplateMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteWechatMsgTemplate(Long id) {
+        // 校验存在
+        validateWechatMsgTemplateExists(id);
+        // 删除
+        wechatMsgTemplateMapper.deleteById(id);
+    }
+
+    private void validateWechatMsgTemplateExists(Long id) {
+        if (wechatMsgTemplateMapper.selectById(id) == null) {
+            throw exception(WECHAT_MSG_TEMPLATE_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public WechatMsgTemplateDO getWechatMsgTemplate(Long id) {
+        return wechatMsgTemplateMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<WechatMsgTemplateDO> getWechatMsgTemplatePage(WechatMsgTemplatePageReqVO pageReqVO) {
+        return wechatMsgTemplateMapper.selectPage(pageReqVO);
+    }
+
+}

+ 12 - 0
feifan-module-system/feifan-module-system-biz/src/main/resources/mapper/wechatmsgtemplate/WechatMsgTemplateMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.newfeifan.mall.module.system.dal.mysql.wechatmsgtemplate.WechatMsgTemplateMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.zhongxing.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>