From 48bea21a46067daa1c35ddff7a57f98661e00527 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 4 Jan 2023 00:18:43 +0800 Subject: [PATCH] =?UTF-8?q?mp=EF=BC=9A=E6=B8=85=E7=90=86=E5=86=97=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/mp/builder/AbstractBuilder.java | 15 -- .../yudao/module/mp/builder/ImageBuilder.java | 21 --- .../yudao/module/mp/builder/TextBuilder.java | 19 --- .../WxNewsArticleItemController.java | 103 ------------ .../vo/WxNewsArticleItemBaseVO.java | 52 ------ .../vo/WxNewsArticleItemCreateReqVO.java | 12 -- .../vo/WxNewsArticleItemExcelVO.java | 62 ------- .../vo/WxNewsArticleItemExportReqVO.java | 63 ------- .../vo/WxNewsArticleItemPageReqVO.java | 66 -------- .../vo/WxNewsArticleItemRespVO.java | 21 --- .../vo/WxNewsArticleItemUpdateReqVO.java | 18 -- .../WxNewsTemplateController.java | 103 ------------ .../newstemplate/vo/WxNewsTemplateBaseVO.java | 25 --- .../vo/WxNewsTemplateCreateReqVO.java | 12 -- .../vo/WxNewsTemplateExcelVO.java | 35 ---- .../vo/WxNewsTemplateExportReqVO.java | 36 ---- .../vo/WxNewsTemplatePageReqVO.java | 39 ----- .../newstemplate/vo/WxNewsTemplateRespVO.java | 21 --- .../vo/WxNewsTemplateUpdateReqVO.java | 18 -- .../mp/convert/message/MpMessageConvert.java | 1 + .../WxNewsArticleItemConvert.java | 34 ---- .../newstemplate/WxNewsTemplateConvert.java | 34 ---- .../dal/dataobject/message/MpAutoReplyDO.java | 9 +- .../newsarticleitem/WxNewsArticleItemDO.java | 83 --------- .../newstemplate/WxNewsTemplateDO.java | 47 ------ .../dal/mysql/message/MpAutoReplyMapper.java | 35 ++++ .../WxNewsArticleItemMapper.java | 58 ------- .../newstemplate/WxNewsTemplateMapper.java | 40 ----- .../message/MessageAutoReplyHandler.java | 158 +----------------- .../service/handler/user/LocationHandler.java | 31 ++-- .../handler/user/SubscribeHandler.java | 4 +- .../service/message/MpAutoReplyService.java | 22 +++ .../message/MpAutoReplyServiceImpl.java | 58 +++++++ .../WxNewsArticleItemService.java | 71 -------- .../WxNewsArticleItemServiceImpl.java | 85 ---------- .../newstemplate/WxNewsTemplateService.java | 71 -------- .../WxNewsTemplateServiceImpl.java | 85 ---------- 37 files changed, 149 insertions(+), 1518 deletions(-) delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/AbstractBuilder.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/ImageBuilder.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/TextBuilder.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/WxNewsArticleItemController.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemBaseVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemCreateReqVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemExcelVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemExportReqVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemPageReqVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemRespVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemUpdateReqVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/WxNewsTemplateController.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateBaseVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateCreateReqVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateExcelVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateExportReqVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplatePageReqVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateRespVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateUpdateReqVO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/newsarticleitem/WxNewsArticleItemConvert.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/newstemplate/WxNewsTemplateConvert.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/newsarticleitem/WxNewsArticleItemDO.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/newstemplate/WxNewsTemplateDO.java create mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/newsarticleitem/WxNewsArticleItemMapper.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/newstemplate/WxNewsTemplateMapper.java create mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java create mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newsarticleitem/WxNewsArticleItemService.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newsarticleitem/WxNewsArticleItemServiceImpl.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newstemplate/WxNewsTemplateService.java delete mode 100644 yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newstemplate/WxNewsTemplateServiceImpl.java diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/AbstractBuilder.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/AbstractBuilder.java deleted file mode 100644 index e2b0424c1..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/AbstractBuilder.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.mp.builder; - -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -// TODO @亚洲:看看是不是可以使用 convert 来做,更符合项目 -public abstract class AbstractBuilder { - protected final Logger logger = LoggerFactory.getLogger(getClass()); - - public abstract WxMpXmlOutMessage build(String content, - WxMpXmlMessage wxMessage, WxMpService service); -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/ImageBuilder.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/ImageBuilder.java deleted file mode 100644 index 421f46181..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/ImageBuilder.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.builder; - -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutImageMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -public class ImageBuilder extends AbstractBuilder { - - @Override - public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, - WxMpService service) { - - WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE().mediaId(content) - .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) - .build(); - - return m; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/TextBuilder.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/TextBuilder.java deleted file mode 100644 index bd951990e..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/builder/TextBuilder.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.mp.builder; - -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutTextMessage; - -public class TextBuilder extends AbstractBuilder { - - @Override - public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, - WxMpService service) { - WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content) - .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) - .build(); - return m; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/WxNewsArticleItemController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/WxNewsArticleItemController.java deleted file mode 100644 index 652c56c78..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/WxNewsArticleItemController.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem; - -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.annotations.*; - -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; - -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo.*; -import cn.iocoder.yudao.module.mp.dal.dataobject.newsarticleitem.WxNewsArticleItemDO; -import cn.iocoder.yudao.module.mp.convert.newsarticleitem.WxNewsArticleItemConvert; -import cn.iocoder.yudao.module.mp.service.newsarticleitem.WxNewsArticleItemService; - -@Api(tags = "管理后台 - 图文消息文章列表表 ") -@RestController -@RequestMapping("/wechatMp/wx-news-article-item") -@Validated -public class WxNewsArticleItemController { - - @Resource - private WxNewsArticleItemService wxNewsArticleItemService; - - @PostMapping("/create") - @ApiOperation("创建图文消息文章列表表 ") - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-article-item:create')") - public CommonResult createWxNewsArticleItem(@Valid @RequestBody WxNewsArticleItemCreateReqVO createReqVO) { - return success(wxNewsArticleItemService.createWxNewsArticleItem(createReqVO)); - } - - @PutMapping("/update") - @ApiOperation("更新图文消息文章列表表 ") - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-article-item:update')") - public CommonResult updateWxNewsArticleItem(@Valid @RequestBody WxNewsArticleItemUpdateReqVO updateReqVO) { - wxNewsArticleItemService.updateWxNewsArticleItem(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @ApiOperation("删除图文消息文章列表表 ") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class) - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-article-item:delete')") - public CommonResult deleteWxNewsArticleItem(@RequestParam("id") Integer id) { - wxNewsArticleItemService.deleteWxNewsArticleItem(id); - return success(true); - } - - @GetMapping("/get") - @ApiOperation("获得图文消息文章列表表 ") - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-article-item:query')") - public CommonResult getWxNewsArticleItem(@RequestParam("id") Integer id) { - WxNewsArticleItemDO wxNewsArticleItem = wxNewsArticleItemService.getWxNewsArticleItem(id); - return success(WxNewsArticleItemConvert.INSTANCE.convert(wxNewsArticleItem)); - } - - @GetMapping("/list") - @ApiOperation("获得图文消息文章列表表 列表") - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-article-item:query')") - public CommonResult> getWxNewsArticleItemList(@RequestParam("ids") Collection ids) { - List list = wxNewsArticleItemService.getWxNewsArticleItemList(ids); - return success(WxNewsArticleItemConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @ApiOperation("获得图文消息文章列表表 分页") - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-article-item:query')") - public CommonResult> getWxNewsArticleItemPage(@Valid WxNewsArticleItemPageReqVO pageVO) { - PageResult pageResult = wxNewsArticleItemService.getWxNewsArticleItemPage(pageVO); - return success(WxNewsArticleItemConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/export-excel") - @ApiOperation("导出图文消息文章列表表 Excel") - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-article-item:export')") - @OperateLog(type = EXPORT) - public void exportWxNewsArticleItemExcel(@Valid WxNewsArticleItemExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = wxNewsArticleItemService.getWxNewsArticleItemList(exportReqVO); - // 导出 Excel - List datas = WxNewsArticleItemConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "图文消息文章列表表 .xls", "数据", WxNewsArticleItemExcelVO.class, datas); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemBaseVO.java deleted file mode 100644 index 78a5e96e9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemBaseVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo; - -import lombok.*; -import io.swagger.annotations.*; - -/** - * 图文消息文章列表表 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class WxNewsArticleItemBaseVO { - - @ApiModelProperty(value = "标题") - private String title; - - @ApiModelProperty(value = "摘要") - private String digest; - - @ApiModelProperty(value = "作者") - private String author; - - @ApiModelProperty(value = "是否展示封面图片(0/1)") - private String showCoverPic; - - @ApiModelProperty(value = "上传微信,封面图片标识") - private String thumbMediaId; - - @ApiModelProperty(value = "内容") - private String content; - - @ApiModelProperty(value = "内容链接") - private String contentSourceUrl; - - @ApiModelProperty(value = "文章排序") - private Integer orderNo; - - @ApiModelProperty(value = "图片路径") - private String picPath; - - @ApiModelProperty(value = "是否可以留言") - private String needOpenComment; - - @ApiModelProperty(value = "是否仅粉丝可以留言") - private String onlyFansCanComment; - - @ApiModelProperty(value = "图文ID") - private String newsId; - - @ApiModelProperty(value = "微信账号ID") - private String wxAccountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemCreateReqVO.java deleted file mode 100644 index 8dba64c05..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo; - -import lombok.*; -import io.swagger.annotations.*; - -@ApiModel("管理后台 - 图文消息文章列表表 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WxNewsArticleItemCreateReqVO extends WxNewsArticleItemBaseVO { - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemExcelVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemExcelVO.java deleted file mode 100644 index d1172e539..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemExcelVO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo; - -import lombok.*; - -import java.util.*; - -import com.alibaba.excel.annotation.ExcelProperty; - -/** - * 图文消息文章列表表 Excel VO - * - * @author 芋道源码 - */ -@Data -public class WxNewsArticleItemExcelVO { - - @ExcelProperty("主键") - private Integer id; - - @ExcelProperty("标题") - private String title; - - @ExcelProperty("摘要") - private String digest; - - @ExcelProperty("作者") - private String author; - - @ExcelProperty("是否展示封面图片(0/1)") - private String showCoverPic; - - @ExcelProperty("上传微信,封面图片标识") - private String thumbMediaId; - - @ExcelProperty("内容") - private String content; - - @ExcelProperty("内容链接") - private String contentSourceUrl; - - @ExcelProperty("文章排序") - private Integer orderNo; - - @ExcelProperty("图片路径") - private String picPath; - - @ExcelProperty("是否可以留言") - private String needOpenComment; - - @ExcelProperty("是否仅粉丝可以留言") - private String onlyFansCanComment; - - @ExcelProperty("图文ID") - private String newsId; - - @ExcelProperty("微信账号ID") - private String wxAccountId; - - @ExcelProperty("创建时间") - private Date createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemExportReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemExportReqVO.java deleted file mode 100644 index 90571a766..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemExportReqVO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo; - -import lombok.*; - -import java.util.*; - -import io.swagger.annotations.*; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@ApiModel(value = "管理后台 - 图文消息文章列表表 Excel 导出 Request VO", description = "参数和 WxNewsArticleItemPageReqVO 是一致的") -@Data -public class WxNewsArticleItemExportReqVO { - - @ApiModelProperty(value = "标题") - private String title; - - @ApiModelProperty(value = "摘要") - private String digest; - - @ApiModelProperty(value = "作者") - private String author; - - @ApiModelProperty(value = "是否展示封面图片(0/1)") - private String showCoverPic; - - @ApiModelProperty(value = "上传微信,封面图片标识") - private String thumbMediaId; - - @ApiModelProperty(value = "内容") - private String content; - - @ApiModelProperty(value = "内容链接") - private String contentSourceUrl; - - @ApiModelProperty(value = "文章排序") - private Integer orderNo; - - @ApiModelProperty(value = "图片路径") - private String picPath; - - @ApiModelProperty(value = "是否可以留言") - private String needOpenComment; - - @ApiModelProperty(value = "是否仅粉丝可以留言") - private String onlyFansCanComment; - - @ApiModelProperty(value = "图文ID") - private String newsId; - - @ApiModelProperty(value = "微信账号ID") - private String wxAccountId; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "开始创建时间") - private Date beginCreateTime; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "结束创建时间") - private Date endCreateTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemPageReqVO.java deleted file mode 100644 index 52b6af862..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemPageReqVO.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo; - -import lombok.*; - -import java.util.*; - -import io.swagger.annotations.*; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@ApiModel("管理后台 - 图文消息文章列表表 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WxNewsArticleItemPageReqVO extends PageParam { - - @ApiModelProperty(value = "标题") - private String title; - - @ApiModelProperty(value = "摘要") - private String digest; - - @ApiModelProperty(value = "作者") - private String author; - - @ApiModelProperty(value = "是否展示封面图片(0/1)") - private String showCoverPic; - - @ApiModelProperty(value = "上传微信,封面图片标识") - private String thumbMediaId; - - @ApiModelProperty(value = "内容") - private String content; - - @ApiModelProperty(value = "内容链接") - private String contentSourceUrl; - - @ApiModelProperty(value = "文章排序") - private Integer orderNo; - - @ApiModelProperty(value = "图片路径") - private String picPath; - - @ApiModelProperty(value = "是否可以留言") - private String needOpenComment; - - @ApiModelProperty(value = "是否仅粉丝可以留言") - private String onlyFansCanComment; - - @ApiModelProperty(value = "图文ID") - private String newsId; - - @ApiModelProperty(value = "微信账号ID") - private String wxAccountId; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "开始创建时间") - private Date beginCreateTime; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "结束创建时间") - private Date endCreateTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemRespVO.java deleted file mode 100644 index 7ed2c33df..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo; - -import lombok.*; - -import java.util.*; - -import io.swagger.annotations.*; - -@ApiModel("管理后台 - 图文消息文章列表表 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WxNewsArticleItemRespVO extends WxNewsArticleItemBaseVO { - - @ApiModelProperty(value = "主键", required = true) - private Integer id; - - @ApiModelProperty(value = "创建时间", required = true) - private Date createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemUpdateReqVO.java deleted file mode 100644 index 72f235185..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newsarticleitem/vo/WxNewsArticleItemUpdateReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo; - -import lombok.*; -import io.swagger.annotations.*; - -import javax.validation.constraints.*; - -@ApiModel("管理后台 - 图文消息文章列表表 更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WxNewsArticleItemUpdateReqVO extends WxNewsArticleItemBaseVO { - - @ApiModelProperty(value = "主键", required = true) - @NotNull(message = "主键不能为空") - private Integer id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/WxNewsTemplateController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/WxNewsTemplateController.java deleted file mode 100644 index c6c7220cb..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/WxNewsTemplateController.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newstemplate; - -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.annotations.*; - -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; - -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo.*; -import cn.iocoder.yudao.module.mp.dal.dataobject.newstemplate.WxNewsTemplateDO; -import cn.iocoder.yudao.module.mp.convert.newstemplate.WxNewsTemplateConvert; -import cn.iocoder.yudao.module.mp.service.newstemplate.WxNewsTemplateService; - -@Api(tags = "管理后台 - 图文消息模板") -@RestController -@RequestMapping("/wechatMp/wx-news-template") -@Validated -public class WxNewsTemplateController { - - @Resource - private WxNewsTemplateService wxNewsTemplateService; - - @PostMapping("/create") - @ApiOperation("创建图文消息模板") - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-template:create')") - public CommonResult createWxNewsTemplate(@Valid @RequestBody WxNewsTemplateCreateReqVO createReqVO) { - return success(wxNewsTemplateService.createWxNewsTemplate(createReqVO)); - } - - @PutMapping("/update") - @ApiOperation("更新图文消息模板") - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-template:update')") - public CommonResult updateWxNewsTemplate(@Valid @RequestBody WxNewsTemplateUpdateReqVO updateReqVO) { - wxNewsTemplateService.updateWxNewsTemplate(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @ApiOperation("删除图文消息模板") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class) - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-template:delete')") - public CommonResult deleteWxNewsTemplate(@RequestParam("id") Integer id) { - wxNewsTemplateService.deleteWxNewsTemplate(id); - return success(true); - } - - @GetMapping("/get") - @ApiOperation("获得图文消息模板") - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-template:query')") - public CommonResult getWxNewsTemplate(@RequestParam("id") Integer id) { - WxNewsTemplateDO wxNewsTemplate = wxNewsTemplateService.getWxNewsTemplate(id); - return success(WxNewsTemplateConvert.INSTANCE.convert(wxNewsTemplate)); - } - - @GetMapping("/list") - @ApiOperation("获得图文消息模板列表") - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-template:query')") - public CommonResult> getWxNewsTemplateList(@RequestParam("ids") Collection ids) { - List list = wxNewsTemplateService.getWxNewsTemplateList(ids); - return success(WxNewsTemplateConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @ApiOperation("获得图文消息模板分页") - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-template:query')") - public CommonResult> getWxNewsTemplatePage(@Valid WxNewsTemplatePageReqVO pageVO) { - PageResult pageResult = wxNewsTemplateService.getWxNewsTemplatePage(pageVO); - return success(WxNewsTemplateConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/export-excel") - @ApiOperation("导出图文消息模板 Excel") - @PreAuthorize("@ss.hasPermission('wechatMp:wx-news-template:export')") - @OperateLog(type = EXPORT) - public void exportWxNewsTemplateExcel(@Valid WxNewsTemplateExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = wxNewsTemplateService.getWxNewsTemplateList(exportReqVO); - // 导出 Excel - List datas = WxNewsTemplateConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "图文消息模板.xls", "数据", WxNewsTemplateExcelVO.class, datas); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateBaseVO.java deleted file mode 100644 index 387243ed8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateBaseVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo; - -import lombok.*; -import io.swagger.annotations.*; - -/** - * 图文消息模板 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class WxNewsTemplateBaseVO { - - @ApiModelProperty(value = "模板名称") - private String tplName; - - @ApiModelProperty(value = "是否已上传微信") - private String isUpload; - - @ApiModelProperty(value = "素材ID") - private String mediaId; - - @ApiModelProperty(value = "微信账号ID") - private String wxAccountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateCreateReqVO.java deleted file mode 100644 index 0e4996b92..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo; - -import lombok.*; -import io.swagger.annotations.*; - -@ApiModel("管理后台 - 图文消息模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WxNewsTemplateCreateReqVO extends WxNewsTemplateBaseVO { - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateExcelVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateExcelVO.java deleted file mode 100644 index 0d0823249..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateExcelVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo; - -import lombok.*; - -import java.util.*; - -import com.alibaba.excel.annotation.ExcelProperty; - -/** - * 图文消息模板 Excel VO - * - * @author 芋道源码 - */ -@Data -public class WxNewsTemplateExcelVO { - - @ExcelProperty("主键 主键ID") - private Integer id; - - @ExcelProperty("模板名称") - private String tplName; - - @ExcelProperty("是否已上传微信") - private String isUpload; - - @ExcelProperty("素材ID") - private String mediaId; - - @ExcelProperty("微信账号ID") - private String wxAccountId; - - @ExcelProperty("创建时间") - private Date createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateExportReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateExportReqVO.java deleted file mode 100644 index 12c30ab94..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateExportReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo; - -import lombok.*; - -import java.util.*; - -import io.swagger.annotations.*; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@ApiModel(value = "管理后台 - 图文消息模板 Excel 导出 Request VO", description = "参数和 WxNewsTemplatePageReqVO 是一致的") -@Data -public class WxNewsTemplateExportReqVO { - - @ApiModelProperty(value = "模板名称") - private String tplName; - - @ApiModelProperty(value = "是否已上传微信") - private String isUpload; - - @ApiModelProperty(value = "素材ID") - private String mediaId; - - @ApiModelProperty(value = "微信账号ID") - private String wxAccountId; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "开始创建时间") - private Date beginCreateTime; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "结束创建时间") - private Date endCreateTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplatePageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplatePageReqVO.java deleted file mode 100644 index f0e85c0aa..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplatePageReqVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo; - -import lombok.*; - -import java.util.*; - -import io.swagger.annotations.*; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@ApiModel("管理后台 - 图文消息模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WxNewsTemplatePageReqVO extends PageParam { - - @ApiModelProperty(value = "模板名称") - private String tplName; - - @ApiModelProperty(value = "是否已上传微信") - private String isUpload; - - @ApiModelProperty(value = "素材ID") - private String mediaId; - - @ApiModelProperty(value = "微信账号ID") - private String wxAccountId; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "开始创建时间") - private Date beginCreateTime; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "结束创建时间") - private Date endCreateTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateRespVO.java deleted file mode 100644 index 697ff642c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo; - -import lombok.*; - -import java.util.*; - -import io.swagger.annotations.*; - -@ApiModel("管理后台 - 图文消息模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WxNewsTemplateRespVO extends WxNewsTemplateBaseVO { - - @ApiModelProperty(value = "主键 主键ID", required = true) - private Integer id; - - @ApiModelProperty(value = "创建时间", required = true) - private Date createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateUpdateReqVO.java deleted file mode 100644 index e8ae49a8a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/newstemplate/vo/WxNewsTemplateUpdateReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo; - -import lombok.*; -import io.swagger.annotations.*; - -import javax.validation.constraints.*; - -@ApiModel("管理后台 - 图文消息模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WxNewsTemplateUpdateReqVO extends WxNewsTemplateBaseVO { - - @ApiModelProperty(value = "主键 主键ID", required = true) - @NotNull(message = "主键 主键ID不能为空") - private Integer id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java index 9a1067ef2..e3cfea7ec 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java @@ -27,6 +27,7 @@ public interface MpMessageConvert { @Mappings(value = { @Mapping(source = "msgType", target = "type"), + @Mapping(target = "createTime", ignore = true), }) MpMessageDO convert(WxMpXmlMessage wxMessage); diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/newsarticleitem/WxNewsArticleItemConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/newsarticleitem/WxNewsArticleItemConvert.java deleted file mode 100644 index b20717d3e..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/newsarticleitem/WxNewsArticleItemConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.newsarticleitem; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; -import cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo.*; -import cn.iocoder.yudao.module.mp.dal.dataobject.newsarticleitem.WxNewsArticleItemDO; - -/** - * 图文消息文章列表表 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface WxNewsArticleItemConvert { - - WxNewsArticleItemConvert INSTANCE = Mappers.getMapper(WxNewsArticleItemConvert.class); - - WxNewsArticleItemDO convert(WxNewsArticleItemCreateReqVO bean); - - WxNewsArticleItemDO convert(WxNewsArticleItemUpdateReqVO bean); - - WxNewsArticleItemRespVO convert(WxNewsArticleItemDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/newstemplate/WxNewsTemplateConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/newstemplate/WxNewsTemplateConvert.java deleted file mode 100644 index e6cf754fd..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/newstemplate/WxNewsTemplateConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.newstemplate; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; -import cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo.*; -import cn.iocoder.yudao.module.mp.dal.dataobject.newstemplate.WxNewsTemplateDO; - -/** - * 图文消息模板 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface WxNewsTemplateConvert { - - WxNewsTemplateConvert INSTANCE = Mappers.getMapper(WxNewsTemplateConvert.class); - - WxNewsTemplateDO convert(WxNewsTemplateCreateReqVO bean); - - WxNewsTemplateDO convert(WxNewsTemplateUpdateReqVO bean); - - WxNewsTemplateRespVO convert(WxNewsTemplateDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java index 5a698f0ac..0dd15fef6 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.mp.dal.dataobject.message; +import cn.iocoder.yudao.framework.common.util.collection.SetUtils; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyMatchEnum; @@ -13,6 +14,8 @@ import lombok.ToString; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.api.WxConsts.XmlMsgType; +import java.util.Set; + /** * 微信消息自动回复 DO * @@ -25,6 +28,10 @@ import me.chanjar.weixin.common.api.WxConsts.XmlMsgType; @ToString(callSuper = true) public class MpAutoReplyDO extends BaseDO { + public static Set REQUEST_MESSAGE_TYPE = SetUtils.asSet(WxConsts.XmlMsgType.TEXT, WxConsts.XmlMsgType.IMAGE, + WxConsts.XmlMsgType.VOICE, WxConsts.XmlMsgType.VIDEO, WxConsts.XmlMsgType.SHORTVIDEO, + WxConsts.XmlMsgType.LOCATION, WxConsts.XmlMsgType.LINK); + /** * 主键 */ @@ -72,7 +79,7 @@ public class MpAutoReplyDO extends BaseDO { * * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#MESSAGE} * - * 枚举 {@link XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、SHORTVIDEO、LOCATION、LINK + * 枚举 {@link XmlMsgType} 中的 {@link #REQUEST_MESSAGE_TYPE} */ private String requestMessageType; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/newsarticleitem/WxNewsArticleItemDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/newsarticleitem/WxNewsArticleItemDO.java deleted file mode 100644 index 7cb9b6ac9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/newsarticleitem/WxNewsArticleItemDO.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.newsarticleitem; - -import lombok.*; - -import java.util.*; - -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 图文消息文章列表表 DO - * - * @author 芋道源码 - */ -@TableName("wx_news_article_item") -@KeySequence("wx_news_article_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class WxNewsArticleItemDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Integer id; - /** - * 标题 - */ - private String title; - /** - * 摘要 - */ - private String digest; - /** - * 作者 - */ - private String author; - /** - * 是否展示封面图片(0/1) - */ - private String showCoverPic; - /** - * 上传微信,封面图片标识 - */ - private String thumbMediaId; - /** - * 内容 - */ - private String content; - /** - * 内容链接 - */ - private String contentSourceUrl; - /** - * 文章排序 - */ - private Integer orderNo; - /** - * 图片路径 - */ - private String picPath; - /** - * 是否可以留言 - */ - private String needOpenComment; - /** - * 是否仅粉丝可以留言 - */ - private String onlyFansCanComment; - /** - * 图文ID - */ - private String newsId; - /** - * 微信账号ID - */ - private String wxAccountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/newstemplate/WxNewsTemplateDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/newstemplate/WxNewsTemplateDO.java deleted file mode 100644 index 524bb19d2..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/newstemplate/WxNewsTemplateDO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.newstemplate; - -import lombok.*; - -import java.util.*; - -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 图文消息模板 DO - * - * @author 芋道源码 - */ -@TableName("wx_news_template") -@KeySequence("wx_news_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class WxNewsTemplateDO extends BaseDO { - - /** - * 主键 主键ID - */ - @TableId - private Integer id; - /** - * 模板名称 - */ - private String tplName; - /** - * 是否已上传微信 - */ - private String isUpload; - /** - * 素材ID - */ - private String mediaId; - /** - * 微信账号ID - */ - private String wxAccountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java new file mode 100644 index 000000000..3cd0dd386 --- /dev/null +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.mp.dal.mysql.message; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; +import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyMatchEnum; +import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; + +import java.util.List; + +public interface MpAutoReplyMapper extends BaseMapperX { + + default List selectListByAppIdAndKeywordAll(String appId, String requestKeyword) { + return selectList(new LambdaQueryWrapperX() + .eq(MpAutoReplyDO::getAppId, appId) + .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) + .eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.ALL.getMatch()) + .eq(MpAutoReplyDO::getRequestKeyword, requestKeyword)); + } + + default List selectListByAppIdAndKeywordLike(String appId, String requestKeyword) { + return selectList(new LambdaQueryWrapperX() + .eq(MpAutoReplyDO::getAppId, appId) + .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) + .eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.LIKE.getMatch()) + .like(MpAutoReplyDO::getRequestKeyword, requestKeyword)); + } + + default List selectListByAppIdAndMessage(String appId, String requestMessageType) { + return selectList(new LambdaQueryWrapperX() + .eq(MpAutoReplyDO::getAppId, appId) + .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.MESSAGE.getType()) + .eq(MpAutoReplyDO::getRequestMessageType, requestMessageType)); + } +} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/newsarticleitem/WxNewsArticleItemMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/newsarticleitem/WxNewsArticleItemMapper.java deleted file mode 100644 index 2b072097e..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/newsarticleitem/WxNewsArticleItemMapper.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.newsarticleitem; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.mp.dal.dataobject.newsarticleitem.WxNewsArticleItemDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo.*; - -/** - * 图文消息文章列表表 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface WxNewsArticleItemMapper extends BaseMapperX { - - default PageResult selectPage(WxNewsArticleItemPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(WxNewsArticleItemDO::getTitle, reqVO.getTitle()) - .eqIfPresent(WxNewsArticleItemDO::getDigest, reqVO.getDigest()) - .eqIfPresent(WxNewsArticleItemDO::getAuthor, reqVO.getAuthor()) - .eqIfPresent(WxNewsArticleItemDO::getShowCoverPic, reqVO.getShowCoverPic()) - .eqIfPresent(WxNewsArticleItemDO::getThumbMediaId, reqVO.getThumbMediaId()) - .eqIfPresent(WxNewsArticleItemDO::getContent, reqVO.getContent()) - .eqIfPresent(WxNewsArticleItemDO::getContentSourceUrl, reqVO.getContentSourceUrl()) - .eqIfPresent(WxNewsArticleItemDO::getOrderNo, reqVO.getOrderNo()) - .eqIfPresent(WxNewsArticleItemDO::getPicPath, reqVO.getPicPath()) - .eqIfPresent(WxNewsArticleItemDO::getNeedOpenComment, reqVO.getNeedOpenComment()) - .eqIfPresent(WxNewsArticleItemDO::getOnlyFansCanComment, reqVO.getOnlyFansCanComment()) - .eqIfPresent(WxNewsArticleItemDO::getNewsId, reqVO.getNewsId()) - .eqIfPresent(WxNewsArticleItemDO::getWxAccountId, reqVO.getWxAccountId()) - .betweenIfPresent(WxNewsArticleItemDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc(WxNewsArticleItemDO::getId)); - } - - default List selectList(WxNewsArticleItemExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(WxNewsArticleItemDO::getTitle, reqVO.getTitle()) - .eqIfPresent(WxNewsArticleItemDO::getDigest, reqVO.getDigest()) - .eqIfPresent(WxNewsArticleItemDO::getAuthor, reqVO.getAuthor()) - .eqIfPresent(WxNewsArticleItemDO::getShowCoverPic, reqVO.getShowCoverPic()) - .eqIfPresent(WxNewsArticleItemDO::getThumbMediaId, reqVO.getThumbMediaId()) - .eqIfPresent(WxNewsArticleItemDO::getContent, reqVO.getContent()) - .eqIfPresent(WxNewsArticleItemDO::getContentSourceUrl, reqVO.getContentSourceUrl()) - .eqIfPresent(WxNewsArticleItemDO::getOrderNo, reqVO.getOrderNo()) - .eqIfPresent(WxNewsArticleItemDO::getPicPath, reqVO.getPicPath()) - .eqIfPresent(WxNewsArticleItemDO::getNeedOpenComment, reqVO.getNeedOpenComment()) - .eqIfPresent(WxNewsArticleItemDO::getOnlyFansCanComment, reqVO.getOnlyFansCanComment()) - .eqIfPresent(WxNewsArticleItemDO::getNewsId, reqVO.getNewsId()) - .eqIfPresent(WxNewsArticleItemDO::getWxAccountId, reqVO.getWxAccountId()) - .betweenIfPresent(WxNewsArticleItemDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc(WxNewsArticleItemDO::getId)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/newstemplate/WxNewsTemplateMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/newstemplate/WxNewsTemplateMapper.java deleted file mode 100644 index f5c03b848..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/newstemplate/WxNewsTemplateMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.newstemplate; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.mp.dal.dataobject.newstemplate.WxNewsTemplateDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo.*; - -/** - * 图文消息模板 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface WxNewsTemplateMapper extends BaseMapperX { - - default PageResult selectPage(WxNewsTemplatePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(WxNewsTemplateDO::getTplName, reqVO.getTplName()) - .eqIfPresent(WxNewsTemplateDO::getIsUpload, reqVO.getIsUpload()) - .eqIfPresent(WxNewsTemplateDO::getMediaId, reqVO.getMediaId()) - .eqIfPresent(WxNewsTemplateDO::getWxAccountId, reqVO.getWxAccountId()) - .betweenIfPresent(WxNewsTemplateDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc(WxNewsTemplateDO::getId)); - } - - default List selectList(WxNewsTemplateExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(WxNewsTemplateDO::getTplName, reqVO.getTplName()) - .eqIfPresent(WxNewsTemplateDO::getIsUpload, reqVO.getIsUpload()) - .eqIfPresent(WxNewsTemplateDO::getMediaId, reqVO.getMediaId()) - .eqIfPresent(WxNewsTemplateDO::getWxAccountId, reqVO.getWxAccountId()) - .betweenIfPresent(WxNewsTemplateDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc(WxNewsTemplateDO::getId)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java index 19681b535..30d94a97c 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java @@ -1,30 +1,17 @@ package cn.iocoder.yudao.module.mp.service.handler.message; -import cn.hutool.core.io.FileUtil; -import cn.hutool.http.HtmlUtil; -import cn.hutool.http.HttpUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.infra.api.file.FileApi; -import cn.iocoder.yudao.module.mp.builder.TextBuilder; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; +import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; +import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; +import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.mp.api.WxMpMessageHandler; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import org.apache.commons.lang3.StringUtils; -import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.io.File; -import java.io.UnsupportedEncodingException; import java.util.Map; /** @@ -37,145 +24,18 @@ import java.util.Map; public class MessageAutoReplyHandler implements WxMpMessageHandler { @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpAccountService mpAccountService; - - @Resource - private MpMessageService mpMessageService; - - @Resource - private FileApi fileApi; - - // auto reply - // createMessage - // outmessage + private MpAutoReplyService mpAutoReplyService; @Override public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService weixinService, WxSessionManager sessionManager) { - log.info("收到信息内容:{}", JsonUtils.toJsonString(wxMessage)); - log.info("关键字:{}", wxMessage.getContent()); - -// if (!wxMessage.getMsgType().equals(WxConsts.XmlMsgType.EVENT)) { -// //可以选择将消息保存到本地 -// -// // 获取微信用户基本信息 -// try { -// WxMpUser wxmpUser = weixinService.getUserService() -// .userInfo(wxMessage.getFromUser(), null); -// if (wxmpUser != null) { -// MpAccountDO wxAccount = mpAccountService.findBy(MpAccountDO::getAccount, wxMessage.getToUser()); -// if (wxAccount != null) { -// -// if (wxMessage.getMsgType().equals(WxConsts.XmlMsgType.TEXT)) { -// WxFansMsgCreateReqVO wxFansMsg = new WxFansMsgCreateReqVO(); -// wxFansMsg.setOpenid(wxmpUser.getOpenId()); -// try { -// wxFansMsg.setNickname(wxmpUser.getNickname().getBytes("UTF-8")); -// } catch (UnsupportedEncodingException e) { -// e.printStackTrace(); -// } -// wxFansMsg.setHeadimgUrl(wxmpUser.getHeadImgUrl()); -// wxFansMsg.setWxAccountId(String.valueOf(wxAccount.getId())); -// wxFansMsg.setMsgType(wxMessage.getMsgType()); -// wxFansMsg.setContent(wxMessage.getContent()); -// wxFansMsg.setIsRes("1"); -// -// //组装回复消息 -// String content = processContent(wxMessage); -// content = HtmlUtil.escape(content); -// wxFansMsg.setResContent(content); -// -// mpMessageService.createWxFansMsg(wxFansMsg); -// return new TextBuilder().build(content, wxMessage, weixinService); -// -// } -// if (wxMessage.getMsgType().equals(WxConsts.XmlMsgType.IMAGE)) { -// WxFansMsgCreateReqVO wxFansMsg = new WxFansMsgCreateReqVO(); -// wxFansMsg.setOpenid(wxmpUser.getOpenId()); -// try { -// wxFansMsg.setNickname(wxmpUser.getNickname().getBytes("UTF-8")); -// } catch (UnsupportedEncodingException e) { -// e.printStackTrace(); -// } -// wxFansMsg.setHeadimgUrl(wxmpUser.getHeadImgUrl()); -// wxFansMsg.setWxAccountId(String.valueOf(wxAccount.getId())); -// wxFansMsg.setMsgType(wxMessage.getMsgType()); -// wxFansMsg.setMediaId(wxMessage.getMediaId()); -// wxFansMsg.setPicUrl(wxMessage.getPicUrl()); -// String downloadDirStr = fileApi.createFile(HttpUtil.downloadBytes(wxMessage.getPicUrl())); -// File downloadDir = new File(downloadDirStr); -// if (!downloadDir.exists()) { -// downloadDir.mkdirs(); -// } -// String filepath = downloadDirStr + System.currentTimeMillis() + ".png"; -// //微信pic url下载到本地,防止失效 -// long size = HttpUtil.downloadFile(wxMessage.getPicUrl(), FileUtil.file(filepath)); -// log.info("download pic size : {}", size); -// wxFansMsg.setPicPath(filepath); -// wxFansMsg.setIsRes("0"); -// mpMessageService.createWxFansMsg(wxFansMsg); -// } -// -// } -// } -// } catch (WxErrorException e) { -// if (e.getError().getErrorCode() == 48001) { -// log.info("该公众号没有获取用户信息权限!"); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// } -// -// //当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服 -// try { -// if (StringUtils.startsWithAny(wxMessage.getContent(), "你好", "客服") -// && weixinService.getKefuService().kfOnlineList() -// .getKfOnlineList().size() > 0) { -// return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE() -// .fromUser(wxMessage.getToUser()) -// .toUser(wxMessage.getFromUser()).build(); -// } -// } catch (WxErrorException e) { -// e.printStackTrace(); -// } - - //组装默认回复消息 - return new TextBuilder().build("测试", wxMessage, weixinService); - } - - - //处理回复信息,优先级,关键字、智能机器人、默认值 - String processContent(WxMpXmlMessage wxMessage) { - String content = "你猜"; - /* content = processReceiveTextContent(wxMessage); - if(StringUtils.isNotBlank( content )){ - return content; + // 只处理指定类型的消息 + if (!MpAutoReplyDO.REQUEST_MESSAGE_TYPE.contains(wxMessage.getMsgType())) { + return null; } - content = defaultResponseContent;*/ - return content; + // 自动回复 + return mpAutoReplyService.replyForMessage(MpContextHolder.getAppId(), wxMessage); } - //处理关键字 - String processReceiveTextContent(WxMpXmlMessage wxMessage) { - String content = ""; - /* WxAccountDO wxAccount = wxAccountService.findBy( WxAccountDO::getAccount,wxMessage.getToUser()); - if(wxAccount != null){ - WxReceiveText wxReceiveTextTpl = new WxReceiveText(); - wxReceiveTextTpl.setWxAccountId( String.valueOf( wxAccount.getId() ) ); - wxReceiveTextTpl.setReceiveText( wxMessage.getContent() ); - List wxReceiveTextList = wxReceiveTextService.findListByReceiveTest( wxReceiveTextTpl ); - if(wxReceiveTextList != null && wxReceiveTextList.size() > 0){ - WxReceiveText wxReceiveText = wxReceiveTextList.get( 0 ); - WxTextTemplate wxTextTemplate = wxTextTemplateService.findById( Integer.parseInt( wxReceiveText.getTplId() ) ); - content = wxTextTemplate.getContent(); - } - }*/ - return content; - } - - } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java index 4ad37be81..b84086287 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.mp.service.handler.user; -import cn.iocoder.yudao.module.mp.builder.TextBuilder; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.mp.api.WxMpMessageHandler; @@ -11,8 +10,6 @@ import org.springframework.stereotype.Component; import java.util.Map; -import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType; - /** * 上报地理位置的事件处理器 * @@ -25,20 +22,20 @@ public class LocationHandler implements WxMpMessageHandler { @Override public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService, WxSessionManager sessionManager) { - if (wxMessage.getMsgType().equals(XmlMsgType.LOCATION)) { - //TODO 接收处理用户发送的地理位置消息 - try { - String content = "感谢反馈,您的的地理位置已收到!"; - return new TextBuilder().build(content, wxMessage, null); - } catch (Exception e) { - log.error("位置消息接收处理失败", e); - return null; - } - } - - //上报地理位置事件 - log.info("上报地理位置,纬度 : {},经度 : {},精度 : {}", - wxMessage.getLatitude(), wxMessage.getLongitude(), String.valueOf(wxMessage.getPrecision())); +// if (wxMessage.getMsgType().equals(XmlMsgType.LOCATION)) { +// //TODO 接收处理用户发送的地理位置消息 +// try { +// String content = "感谢反馈,您的的地理位置已收到!"; +// return new TextBuilder().build(content, wxMessage, null); +// } catch (Exception e) { +// log.error("位置消息接收处理失败", e); +// return null; +// } +// } +// +// //上报地理位置事件 +// log.info("上报地理位置,纬度 : {},经度 : {},精度 : {}", +// wxMessage.getLatitude(), wxMessage.getLongitude(), String.valueOf(wxMessage.getPrecision())); //TODO 可以将用户地理位置信息保存到本地数据库,以便以后使用 diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java index 08f51621a..7d77d8e29 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.mp.service.handler.user; -import cn.iocoder.yudao.module.mp.builder.TextBuilder; import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; import cn.iocoder.yudao.module.mp.service.account.MpAccountService; @@ -56,7 +55,8 @@ public class SubscribeHandler implements WxMpMessageHandler { } // 第三步,回复关注的欢迎语 TODO 芋艿:关注的欢迎语 - return new TextBuilder().build("感谢关注", wxMessage, weixinService); +// return new TextBuilder().build("感谢关注", wxMessage, weixinService); + return null; } /** diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java new file mode 100644 index 000000000..b4f22f31d --- /dev/null +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.mp.service.message; + +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; + +/** + * 公众号的自动回复 Service 接口 + * + * @author 芋道源码 + */ +public interface MpAutoReplyService { + + /** + * 当收到消息时,自动回复 + * + * @param appId 微信公众号 appId + * @param wxMessage 消息 + * @return 回复的消息 + */ + WxMpXmlOutMessage replyForMessage(String appId, WxMpXmlMessage wxMessage); + +} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java new file mode 100644 index 000000000..ba350942a --- /dev/null +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.mp.service.message; + +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; +import cn.iocoder.yudao.module.mp.dal.mysql.message.MpAutoReplyMapper; +import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyMatchEnum; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 公众号的自动回复 Service 实现类 + * + * @author 芋道源码 + */ +@Resource +@Validated +public class MpAutoReplyServiceImpl implements MpAutoReplyService { + + @Resource + private MpAutoReplyService mpAutoReplyService; + + @Resource + private MpAutoReplyMapper mpAutoReplyMapper; + + @Override + public WxMpXmlOutMessage replyForMessage(String appId, WxMpXmlMessage wxMessage) { + // 第一步,匹配自动回复 + List replies = null; + // 1.1 关键字 + if (wxMessage.getMsgType().equals(WxConsts.XmlMsgType.TEXT)) { + // 完全匹配 + replies = mpAutoReplyMapper.selectListByAppIdAndKeywordAll(appId, wxMessage.getContent()); + if (CollUtil.isEmpty(replies)) { + // 模糊匹配 + replies = mpAutoReplyMapper.selectListByAppIdAndKeywordLike(appId, wxMessage.getContent()); + } + } + // 1.2 消息类型 + if (CollUtil.isEmpty(replies)) { + replies = mpAutoReplyMapper.selectListByAppIdAndMessage(appId, wxMessage.getMsgType()); + } + if (CollUtil.isEmpty(replies)) { + return null; + } + + // 第二步,基于自动回复,创建消息 + + + // 第三步,将消息转换成 WxMpXmlOutMessage 返回 + return null; + } + +} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newsarticleitem/WxNewsArticleItemService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newsarticleitem/WxNewsArticleItemService.java deleted file mode 100644 index c18076858..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newsarticleitem/WxNewsArticleItemService.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.newsarticleitem; - -import java.util.*; -import javax.validation.*; - -import cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo.*; -import cn.iocoder.yudao.module.mp.dal.dataobject.newsarticleitem.WxNewsArticleItemDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -/** - * 图文消息文章列表表 Service 接口 - * - * @author 芋道源码 - */ -public interface WxNewsArticleItemService { - - /** - * 创建图文消息文章列表表 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Integer createWxNewsArticleItem(@Valid WxNewsArticleItemCreateReqVO createReqVO); - - /** - * 更新图文消息文章列表表 - * - * @param updateReqVO 更新信息 - */ - void updateWxNewsArticleItem(@Valid WxNewsArticleItemUpdateReqVO updateReqVO); - - /** - * 删除图文消息文章列表表 - * - * @param id 编号 - */ - void deleteWxNewsArticleItem(Integer id); - - /** - * 获得图文消息文章列表表 - * - * @param id 编号 - * @return 图文消息文章列表表 - */ - WxNewsArticleItemDO getWxNewsArticleItem(Integer id); - - /** - * 获得图文消息文章列表表 列表 - * - * @param ids 编号 - * @return 图文消息文章列表表 列表 - */ - List getWxNewsArticleItemList(Collection ids); - - /** - * 获得图文消息文章列表表 分页 - * - * @param pageReqVO 分页查询 - * @return 图文消息文章列表表 分页 - */ - PageResult getWxNewsArticleItemPage(WxNewsArticleItemPageReqVO pageReqVO); - - /** - * 获得图文消息文章列表表 列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 图文消息文章列表表 列表 - */ - List getWxNewsArticleItemList(WxNewsArticleItemExportReqVO exportReqVO); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newsarticleitem/WxNewsArticleItemServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newsarticleitem/WxNewsArticleItemServiceImpl.java deleted file mode 100644 index 52b6b6b99..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newsarticleitem/WxNewsArticleItemServiceImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.newsarticleitem; - -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -import org.springframework.validation.annotation.Validated; - -import java.util.*; - -import cn.iocoder.yudao.module.mp.controller.admin.newsarticleitem.vo.*; -import cn.iocoder.yudao.module.mp.dal.dataobject.newsarticleitem.WxNewsArticleItemDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.mp.convert.newsarticleitem.WxNewsArticleItemConvert; -import cn.iocoder.yudao.module.mp.dal.mysql.newsarticleitem.WxNewsArticleItemMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 图文消息文章列表表 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class WxNewsArticleItemServiceImpl implements WxNewsArticleItemService { - - @Resource - private WxNewsArticleItemMapper wxNewsArticleItemMapper; - - @Override - public Integer createWxNewsArticleItem(WxNewsArticleItemCreateReqVO createReqVO) { - // 插入 - WxNewsArticleItemDO wxNewsArticleItem = WxNewsArticleItemConvert.INSTANCE.convert(createReqVO); - wxNewsArticleItemMapper.insert(wxNewsArticleItem); - // 返回 - return wxNewsArticleItem.getId(); - } - - @Override - public void updateWxNewsArticleItem(WxNewsArticleItemUpdateReqVO updateReqVO) { - // 校验存在 - this.validateWxNewsArticleItemExists(updateReqVO.getId()); - // 更新 - WxNewsArticleItemDO updateObj = WxNewsArticleItemConvert.INSTANCE.convert(updateReqVO); - wxNewsArticleItemMapper.updateById(updateObj); - } - - @Override - public void deleteWxNewsArticleItem(Integer id) { - // 校验存在 - this.validateWxNewsArticleItemExists(id); - // 删除 - wxNewsArticleItemMapper.deleteById(id); - } - - private void validateWxNewsArticleItemExists(Integer id) { - if (wxNewsArticleItemMapper.selectById(id) == null) { - throw exception(COMMON_NOT_EXISTS); - } - } - - @Override - public WxNewsArticleItemDO getWxNewsArticleItem(Integer id) { - return wxNewsArticleItemMapper.selectById(id); - } - - @Override - public List getWxNewsArticleItemList(Collection ids) { - return wxNewsArticleItemMapper.selectBatchIds(ids); - } - - @Override - public PageResult getWxNewsArticleItemPage(WxNewsArticleItemPageReqVO pageReqVO) { - return wxNewsArticleItemMapper.selectPage(pageReqVO); - } - - @Override - public List getWxNewsArticleItemList(WxNewsArticleItemExportReqVO exportReqVO) { - return wxNewsArticleItemMapper.selectList(exportReqVO); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newstemplate/WxNewsTemplateService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newstemplate/WxNewsTemplateService.java deleted file mode 100644 index fb854b97b..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newstemplate/WxNewsTemplateService.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.newstemplate; - -import java.util.*; -import javax.validation.*; - -import cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo.*; -import cn.iocoder.yudao.module.mp.dal.dataobject.newstemplate.WxNewsTemplateDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -/** - * 图文消息模板 Service 接口 - * - * @author 芋道源码 - */ -public interface WxNewsTemplateService { - - /** - * 创建图文消息模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Integer createWxNewsTemplate(@Valid WxNewsTemplateCreateReqVO createReqVO); - - /** - * 更新图文消息模板 - * - * @param updateReqVO 更新信息 - */ - void updateWxNewsTemplate(@Valid WxNewsTemplateUpdateReqVO updateReqVO); - - /** - * 删除图文消息模板 - * - * @param id 编号 - */ - void deleteWxNewsTemplate(Integer id); - - /** - * 获得图文消息模板 - * - * @param id 编号 - * @return 图文消息模板 - */ - WxNewsTemplateDO getWxNewsTemplate(Integer id); - - /** - * 获得图文消息模板列表 - * - * @param ids 编号 - * @return 图文消息模板列表 - */ - List getWxNewsTemplateList(Collection ids); - - /** - * 获得图文消息模板分页 - * - * @param pageReqVO 分页查询 - * @return 图文消息模板分页 - */ - PageResult getWxNewsTemplatePage(WxNewsTemplatePageReqVO pageReqVO); - - /** - * 获得图文消息模板列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 图文消息模板列表 - */ - List getWxNewsTemplateList(WxNewsTemplateExportReqVO exportReqVO); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newstemplate/WxNewsTemplateServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newstemplate/WxNewsTemplateServiceImpl.java deleted file mode 100644 index ac20950d0..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/newstemplate/WxNewsTemplateServiceImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.newstemplate; - -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -import org.springframework.validation.annotation.Validated; - -import java.util.*; - -import cn.iocoder.yudao.module.mp.controller.admin.newstemplate.vo.*; -import cn.iocoder.yudao.module.mp.dal.dataobject.newstemplate.WxNewsTemplateDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.mp.convert.newstemplate.WxNewsTemplateConvert; -import cn.iocoder.yudao.module.mp.dal.mysql.newstemplate.WxNewsTemplateMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 图文消息模板 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class WxNewsTemplateServiceImpl implements WxNewsTemplateService { - - @Resource - private WxNewsTemplateMapper wxNewsTemplateMapper; - - @Override - public Integer createWxNewsTemplate(WxNewsTemplateCreateReqVO createReqVO) { - // 插入 - WxNewsTemplateDO wxNewsTemplate = WxNewsTemplateConvert.INSTANCE.convert(createReqVO); - wxNewsTemplateMapper.insert(wxNewsTemplate); - // 返回 - return wxNewsTemplate.getId(); - } - - @Override - public void updateWxNewsTemplate(WxNewsTemplateUpdateReqVO updateReqVO) { - // 校验存在 - this.validateWxNewsTemplateExists(updateReqVO.getId()); - // 更新 - WxNewsTemplateDO updateObj = WxNewsTemplateConvert.INSTANCE.convert(updateReqVO); - wxNewsTemplateMapper.updateById(updateObj); - } - - @Override - public void deleteWxNewsTemplate(Integer id) { - // 校验存在 - this.validateWxNewsTemplateExists(id); - // 删除 - wxNewsTemplateMapper.deleteById(id); - } - - private void validateWxNewsTemplateExists(Integer id) { - if (wxNewsTemplateMapper.selectById(id) == null) { - throw exception(COMMON_NOT_EXISTS); - } - } - - @Override - public WxNewsTemplateDO getWxNewsTemplate(Integer id) { - return wxNewsTemplateMapper.selectById(id); - } - - @Override - public List getWxNewsTemplateList(Collection ids) { - return wxNewsTemplateMapper.selectBatchIds(ids); - } - - @Override - public PageResult getWxNewsTemplatePage(WxNewsTemplatePageReqVO pageReqVO) { - return wxNewsTemplateMapper.selectPage(pageReqVO); - } - - @Override - public List getWxNewsTemplateList(WxNewsTemplateExportReqVO exportReqVO) { - return wxNewsTemplateMapper.selectList(exportReqVO); - } - -}