mp:清理冗余代码

This commit is contained in:
YunaiV 2023-01-04 00:18:43 +08:00
parent 3cf8575317
commit 48bea21a46
37 changed files with 149 additions and 1518 deletions

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<Integer> createWxNewsArticleItem(@Valid @RequestBody WxNewsArticleItemCreateReqVO createReqVO) {
return success(wxNewsArticleItemService.createWxNewsArticleItem(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新图文消息文章列表表 ")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-news-article-item:update')")
public CommonResult<Boolean> 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<Boolean> 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<WxNewsArticleItemRespVO> 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<List<WxNewsArticleItemRespVO>> getWxNewsArticleItemList(@RequestParam("ids") Collection<Integer> ids) {
List<WxNewsArticleItemDO> list = wxNewsArticleItemService.getWxNewsArticleItemList(ids);
return success(WxNewsArticleItemConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@ApiOperation("获得图文消息文章列表表 分页")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-news-article-item:query')")
public CommonResult<PageResult<WxNewsArticleItemRespVO>> getWxNewsArticleItemPage(@Valid WxNewsArticleItemPageReqVO pageVO) {
PageResult<WxNewsArticleItemDO> 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<WxNewsArticleItemDO> list = wxNewsArticleItemService.getWxNewsArticleItemList(exportReqVO);
// 导出 Excel
List<WxNewsArticleItemExcelVO> datas = WxNewsArticleItemConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "图文消息文章列表表 .xls", "数据", WxNewsArticleItemExcelVO.class, datas);
}
}

View File

@ -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;
}

View File

@ -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 {
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<Integer> createWxNewsTemplate(@Valid @RequestBody WxNewsTemplateCreateReqVO createReqVO) {
return success(wxNewsTemplateService.createWxNewsTemplate(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新图文消息模板")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-news-template:update')")
public CommonResult<Boolean> 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<Boolean> 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<WxNewsTemplateRespVO> 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<List<WxNewsTemplateRespVO>> getWxNewsTemplateList(@RequestParam("ids") Collection<Integer> ids) {
List<WxNewsTemplateDO> list = wxNewsTemplateService.getWxNewsTemplateList(ids);
return success(WxNewsTemplateConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@ApiOperation("获得图文消息模板分页")
@PreAuthorize("@ss.hasPermission('wechatMp:wx-news-template:query')")
public CommonResult<PageResult<WxNewsTemplateRespVO>> getWxNewsTemplatePage(@Valid WxNewsTemplatePageReqVO pageVO) {
PageResult<WxNewsTemplateDO> 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<WxNewsTemplateDO> list = wxNewsTemplateService.getWxNewsTemplateList(exportReqVO);
// 导出 Excel
List<WxNewsTemplateExcelVO> datas = WxNewsTemplateConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "图文消息模板.xls", "数据", WxNewsTemplateExcelVO.class, datas);
}
}

View File

@ -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;
}

View File

@ -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 {
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -27,6 +27,7 @@ public interface MpMessageConvert {
@Mappings(value = {
@Mapping(source = "msgType", target = "type"),
@Mapping(target = "createTime", ignore = true),
})
MpMessageDO convert(WxMpXmlMessage wxMessage);

View File

@ -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<WxNewsArticleItemRespVO> convertList(List<WxNewsArticleItemDO> list);
PageResult<WxNewsArticleItemRespVO> convertPage(PageResult<WxNewsArticleItemDO> page);
List<WxNewsArticleItemExcelVO> convertList02(List<WxNewsArticleItemDO> list);
}

View File

@ -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<WxNewsTemplateRespVO> convertList(List<WxNewsTemplateDO> list);
PageResult<WxNewsTemplateRespVO> convertPage(PageResult<WxNewsTemplateDO> page);
List<WxNewsTemplateExcelVO> convertList02(List<WxNewsTemplateDO> list);
}

View File

@ -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<String> 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} 中的 TEXTIMAGEVOICEVIDEOSHORTVIDEOLOCATIONLINK
* 枚举 {@link XmlMsgType} 中的 {@link #REQUEST_MESSAGE_TYPE}
*/
private String requestMessageType;

View File

@ -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") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 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;
}

View File

@ -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") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 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;
}

View File

@ -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<MpAutoReplyDO> {
default List<MpAutoReplyDO> selectListByAppIdAndKeywordAll(String appId, String requestKeyword) {
return selectList(new LambdaQueryWrapperX<MpAutoReplyDO>()
.eq(MpAutoReplyDO::getAppId, appId)
.eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType())
.eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.ALL.getMatch())
.eq(MpAutoReplyDO::getRequestKeyword, requestKeyword));
}
default List<MpAutoReplyDO> selectListByAppIdAndKeywordLike(String appId, String requestKeyword) {
return selectList(new LambdaQueryWrapperX<MpAutoReplyDO>()
.eq(MpAutoReplyDO::getAppId, appId)
.eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType())
.eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.LIKE.getMatch())
.like(MpAutoReplyDO::getRequestKeyword, requestKeyword));
}
default List<MpAutoReplyDO> selectListByAppIdAndMessage(String appId, String requestMessageType) {
return selectList(new LambdaQueryWrapperX<MpAutoReplyDO>()
.eq(MpAutoReplyDO::getAppId, appId)
.eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.MESSAGE.getType())
.eq(MpAutoReplyDO::getRequestMessageType, requestMessageType));
}
}

View File

@ -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<WxNewsArticleItemDO> {
default PageResult<WxNewsArticleItemDO> selectPage(WxNewsArticleItemPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<WxNewsArticleItemDO>()
.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<WxNewsArticleItemDO> selectList(WxNewsArticleItemExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<WxNewsArticleItemDO>()
.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));
}
}

View File

@ -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<WxNewsTemplateDO> {
default PageResult<WxNewsTemplateDO> selectPage(WxNewsTemplatePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<WxNewsTemplateDO>()
.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<WxNewsTemplateDO> selectList(WxNewsTemplateExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<WxNewsTemplateDO>()
.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));
}
}

View File

@ -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<String, Object> 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);
// 只处理指定类型的消息
if (!MpAutoReplyDO.REQUEST_MESSAGE_TYPE.contains(wxMessage.getMsgType())) {
return null;
}
//处理回复信息优先级关键字智能机器人默认值
String processContent(WxMpXmlMessage wxMessage) {
String content = "你猜";
/* content = processReceiveTextContent(wxMessage);
if(StringUtils.isNotBlank( content )){
return content;
// 自动回复
return mpAutoReplyService.replyForMessage(MpContextHolder.getAppId(), wxMessage);
}
content = defaultResponseContent;*/
return content;
}
//处理关键字
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<WxReceiveText> 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;
}
}

View File

@ -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<String, Object> 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 可以将用户地理位置信息保存到本地数据库以便以后使用

View File

@ -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;
}
/**

View File

@ -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);
}

View File

@ -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<MpAutoReplyDO> 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;
}
}

View File

@ -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<WxNewsArticleItemDO> getWxNewsArticleItemList(Collection<Integer> ids);
/**
* 获得图文消息文章列表表 分页
*
* @param pageReqVO 分页查询
* @return 图文消息文章列表表 分页
*/
PageResult<WxNewsArticleItemDO> getWxNewsArticleItemPage(WxNewsArticleItemPageReqVO pageReqVO);
/**
* 获得图文消息文章列表表 列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 图文消息文章列表表 列表
*/
List<WxNewsArticleItemDO> getWxNewsArticleItemList(WxNewsArticleItemExportReqVO exportReqVO);
}

View File

@ -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<WxNewsArticleItemDO> getWxNewsArticleItemList(Collection<Integer> ids) {
return wxNewsArticleItemMapper.selectBatchIds(ids);
}
@Override
public PageResult<WxNewsArticleItemDO> getWxNewsArticleItemPage(WxNewsArticleItemPageReqVO pageReqVO) {
return wxNewsArticleItemMapper.selectPage(pageReqVO);
}
@Override
public List<WxNewsArticleItemDO> getWxNewsArticleItemList(WxNewsArticleItemExportReqVO exportReqVO) {
return wxNewsArticleItemMapper.selectList(exportReqVO);
}
}

View File

@ -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<WxNewsTemplateDO> getWxNewsTemplateList(Collection<Integer> ids);
/**
* 获得图文消息模板分页
*
* @param pageReqVO 分页查询
* @return 图文消息模板分页
*/
PageResult<WxNewsTemplateDO> getWxNewsTemplatePage(WxNewsTemplatePageReqVO pageReqVO);
/**
* 获得图文消息模板列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 图文消息模板列表
*/
List<WxNewsTemplateDO> getWxNewsTemplateList(WxNewsTemplateExportReqVO exportReqVO);
}

View File

@ -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<WxNewsTemplateDO> getWxNewsTemplateList(Collection<Integer> ids) {
return wxNewsTemplateMapper.selectBatchIds(ids);
}
@Override
public PageResult<WxNewsTemplateDO> getWxNewsTemplatePage(WxNewsTemplatePageReqVO pageReqVO) {
return wxNewsTemplateMapper.selectPage(pageReqVO);
}
@Override
public List<WxNewsTemplateDO> getWxNewsTemplateList(WxNewsTemplateExportReqVO exportReqVO) {
return wxNewsTemplateMapper.selectList(exportReqVO);
}
}