Commit 5901ab6664ff54f5d5536d02f6823e8b2e6ed9e2

Authored by YunaiV
1 parent 267b1790

mp:增加 server 草稿箱的分页、添加;已发布的分页、提交

Showing 16 changed files with 247 additions and 20 deletions
yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java
@@ -34,9 +34,17 @@ public interface ErrorCodeConstants { @@ -34,9 +34,17 @@ public interface ErrorCodeConstants {
34 // ========== 公众号素材 1006004000============ 34 // ========== 公众号素材 1006004000============
35 ErrorCode MATERIAL_UPLOAD_FAIL = new ErrorCode(1006004000, "上传素材失败,原因:{}"); 35 ErrorCode MATERIAL_UPLOAD_FAIL = new ErrorCode(1006004000, "上传素材失败,原因:{}");
36 36
37 - // ========== 公众号素材 1006005000============ 37 + // ========== 公众号消息 1006005000============
38 ErrorCode MESSAGE_SEND_FAIL = new ErrorCode(1006005000, "发送消息失败,原因:{}"); 38 ErrorCode MESSAGE_SEND_FAIL = new ErrorCode(1006005000, "发送消息失败,原因:{}");
39 39
  40 + // ========== 公众号发布能力 1006006000============
  41 + ErrorCode FREE_PUBLISH_LIST_FAIL = new ErrorCode(1006006000, "获得已成功发布列表失败,原因:{}");
  42 + ErrorCode FREE_PUBLISH_SUBMIT_FAIL = new ErrorCode(1006006001, "提交发布失败,原因:{}");
  43 +
  44 + // ========== 公众号草稿 1006007000============
  45 + ErrorCode DRAFT_LIST_FAIL = new ErrorCode(1006007000, "获得草稿列表失败,原因:{}");
  46 + ErrorCode DRAFT_CREATE_FAIL = new ErrorCode(1006007001, "创建草稿失败,原因:{}");
  47 +
40 // TODO 要处理下 48 // TODO 要处理下
41 ErrorCode MENU_NOT_EXISTS = new ErrorCode(1006001002, "菜单不存在"); 49 ErrorCode MENU_NOT_EXISTS = new ErrorCode(1006001002, "菜单不存在");
42 50
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java
@@ -19,7 +19,7 @@ import javax.validation.Valid; @@ -19,7 +19,7 @@ import javax.validation.Valid;
19 19
20 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 20 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
21 21
22 -@Api(tags = "管理后台 - 粉丝消息表") 22 +@Api(tags = "管理后台 - 粉丝消息")
23 @RestController 23 @RestController
24 @RequestMapping("/mp/message") 24 @RequestMapping("/mp/message")
25 @Validated 25 @Validated
@@ -29,7 +29,7 @@ public class MpMessageController { @@ -29,7 +29,7 @@ public class MpMessageController {
29 private MpMessageService mpMessageService; 29 private MpMessageService mpMessageService;
30 30
31 @GetMapping("/page") 31 @GetMapping("/page")
32 - @ApiOperation("获得粉丝消息表分页") 32 + @ApiOperation("获得粉丝消息分页")
33 @PreAuthorize("@ss.hasPermission('mp:message:query')") 33 @PreAuthorize("@ss.hasPermission('mp:message:query')")
34 public CommonResult<PageResult<MpMessageRespVO>> getWxFansMsgPage(@Valid MpMessagePageReqVO pageVO) { 34 public CommonResult<PageResult<MpMessageRespVO>> getWxFansMsgPage(@Valid MpMessagePageReqVO pageVO) {
35 PageResult<MpMessageDO> pageResult = mpMessageService.getWxFansMsgPage(pageVO); 35 PageResult<MpMessageDO> pageResult = mpMessageService.getWxFansMsgPage(pageVO);
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/MpMessageBaseVO.java
@@ -12,7 +12,7 @@ import java.util.List; @@ -12,7 +12,7 @@ import java.util.List;
12 12
13 // TODO 芋艿:VO 的注解 13 // TODO 芋艿:VO 的注解
14 /** 14 /**
15 - * 粉丝消息表 Base VO,提供给添加、修改、详细的子 VO 使用 15 + * 粉丝消息 Base VO,提供给添加、修改、详细的子 VO 使用
16 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 16 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
17 */ 17 */
18 @Data 18 @Data
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/MpMessagePageReqVO.java
@@ -5,7 +5,7 @@ import lombok.*; @@ -5,7 +5,7 @@ import lombok.*;
5 import io.swagger.annotations.*; 5 import io.swagger.annotations.*;
6 import cn.iocoder.yudao.framework.common.pojo.PageParam; 6 import cn.iocoder.yudao.framework.common.pojo.PageParam;
7 7
8 -@ApiModel("管理后台 - 粉丝消息表分页 Request VO") 8 +@ApiModel("管理后台 - 粉丝消息分页 Request VO")
9 @Data 9 @Data
10 @EqualsAndHashCode(callSuper = true) 10 @EqualsAndHashCode(callSuper = true)
11 @ToString(callSuper = true) 11 @ToString(callSuper = true)
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/MpMessageRespVO.java
1 package cn.iocoder.yudao.module.mp.controller.admin.message.vo; 1 package cn.iocoder.yudao.module.mp.controller.admin.message.vo;
2 2
3 -import lombok.*; 3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +import lombok.ToString;
4 8
5 -import java.util.*; 9 +import java.util.Date;
6 10
7 -import io.swagger.annotations.*;  
8 -  
9 -@ApiModel("管理后台 - 粉丝消息表 Response VO") 11 +@ApiModel("管理后台 - 粉丝消息 Response VO")
10 @Data 12 @Data
11 @EqualsAndHashCode(callSuper = true) 13 @EqualsAndHashCode(callSuper = true)
12 @ToString(callSuper = true) 14 @ToString(callSuper = true)
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http 0 → 100644
  1 +### 请求 /mp/draft/page 接口 => 成功
  2 +GET {{baseUrl}}/mp/draft/page?accountId=1&pageNo=1&pageSize=10
  3 +Content-Type: application/json
  4 +Authorization: Bearer {{token}}
  5 +tenant-id: {{adminTenentId}}
  6 +
  7 +### 请求 /mp/draft/create 接口 => 成功
  8 +POST {{baseUrl}}/mp/draft/create?accountId=1
  9 +Content-Type: application/json
  10 +Authorization: Bearer {{token}}
  11 +tenant-id: {{adminTenentId}}
  12 +
  13 +{
  14 + "articles": [
  15 + {
  16 + "title": "我是标题",
  17 + "author": "我是作者",
  18 + "digest": "我是摘要",
  19 + "content": "我是内容",
  20 + "contentSourceUrl": "https://www.iocoder.cn",
  21 + "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn"
  22 + }
  23 + ]
  24 +}
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mp.controller.admin.news;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.PageUtils;
  6 +import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpDraftPageReqVO;
  7 +import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory;
  8 +import io.swagger.annotations.Api;
  9 +import io.swagger.annotations.ApiImplicitParam;
  10 +import io.swagger.annotations.ApiOperation;
  11 +import me.chanjar.weixin.common.error.WxErrorException;
  12 +import me.chanjar.weixin.mp.api.WxMpService;
  13 +import me.chanjar.weixin.mp.bean.draft.WxMpAddDraft;
  14 +import me.chanjar.weixin.mp.bean.draft.WxMpDraftItem;
  15 +import me.chanjar.weixin.mp.bean.draft.WxMpDraftList;
  16 +import org.springframework.validation.annotation.Validated;
  17 +import org.springframework.web.bind.annotation.*;
  18 +
  19 +import javax.annotation.Resource;
  20 +
  21 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  22 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  23 +import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.DRAFT_CREATE_FAIL;
  24 +import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.DRAFT_LIST_FAIL;
  25 +
  26 +// TODO 芋艿:权限
  27 +@Api(tags = "管理后台 - 公众号草稿")
  28 +@RestController
  29 +@RequestMapping("/mp/draft")
  30 +@Validated
  31 +public class MpDraftController {
  32 +
  33 + @Resource
  34 + private MpServiceFactory mpServiceFactory;
  35 +
  36 + @GetMapping("/page")
  37 + @ApiOperation("获得草稿分页")
  38 + public CommonResult<PageResult<WxMpDraftItem>> getDraftPage(MpDraftPageReqVO reqVO) {
  39 + // 从公众号查询已发布的图文列表
  40 + WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId());
  41 + WxMpDraftList draftList;
  42 + try {
  43 + draftList = mpService.getDraftService().listDraft(PageUtils.getStart(reqVO), reqVO.getPageSize());
  44 + } catch (WxErrorException e) {
  45 + throw exception(DRAFT_LIST_FAIL, e.getError().getErrorMsg());
  46 + }
  47 +
  48 + // 返回分页
  49 + return success(new PageResult<>(draftList.getItems(), draftList.getTotalCount().longValue()));
  50 + }
  51 +
  52 + @PostMapping("/create")
  53 + @ApiOperation("创建草稿")
  54 + @ApiImplicitParam(name = "accountId", value = "公众号账号的编号", required = true,
  55 + example = "1024", dataTypeClass = Long.class)
  56 + public CommonResult<String> createDraft(@RequestParam("accountId") Long accountId,
  57 + @RequestBody WxMpAddDraft reqVO) {
  58 + WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId);
  59 + try {
  60 + String mediaId = mpService.getDraftService().addDraft(reqVO);
  61 + return success(mediaId);
  62 + } catch (WxErrorException e) {
  63 + throw exception(DRAFT_CREATE_FAIL, e.getError().getErrorMsg());
  64 + }
  65 + }
  66 +
  67 +}
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http 0 → 100644
  1 +### 请求 /mp/free-publish/page 接口 => 成功
  2 +GET {{baseUrl}}/mp/free-publish/page?accountId=1&pageNo=1&pageSize=10
  3 +Content-Type: application/json
  4 +Authorization: Bearer {{token}}
  5 +tenant-id: {{adminTenentId}}
  6 +
  7 +### 请求 /mp/free-publish/submit 接口 => 成功
  8 +POST {{baseUrl}}/mp/free-publish/submit?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-pEm50d1qKxNPkZVzrRZthSJHKCgiylCf4tARZfybZ_O
  9 +Content-Type: application/json
  10 +Authorization: Bearer {{token}}
  11 +tenant-id: {{adminTenentId}}
  12 +
  13 +{}
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mp.controller.admin.news;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.PageUtils;
  6 +import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpFreePublishPageReqVO;
  7 +import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory;
  8 +import io.swagger.annotations.Api;
  9 +import io.swagger.annotations.ApiImplicitParam;
  10 +import io.swagger.annotations.ApiImplicitParams;
  11 +import io.swagger.annotations.ApiOperation;
  12 +import me.chanjar.weixin.common.error.WxErrorException;
  13 +import me.chanjar.weixin.mp.api.WxMpService;
  14 +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishItem;
  15 +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishList;
  16 +import org.springframework.validation.annotation.Validated;
  17 +import org.springframework.web.bind.annotation.*;
  18 +
  19 +import javax.annotation.Resource;
  20 +
  21 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  22 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  23 +import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*;
  24 +
  25 +// TODO 芋艿:权限
  26 +@Api(tags = "管理后台 - 公众号发布能力")
  27 +@RestController
  28 +@RequestMapping("/mp/free-publish")
  29 +@Validated
  30 +public class MpFreePublishController {
  31 +
  32 + @Resource
  33 + private MpServiceFactory mpServiceFactory;
  34 +
  35 + @GetMapping("/page")
  36 + @ApiOperation("获得已发布的图文分页")
  37 + public CommonResult<PageResult<WxMpFreePublishItem>> getFreePublishPage(MpFreePublishPageReqVO reqVO) {
  38 + // 从公众号查询已发布的图文列表
  39 + WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId());
  40 + WxMpFreePublishList publicationRecords;
  41 + try {
  42 + publicationRecords = mpService.getFreePublishService().getPublicationRecords(
  43 + PageUtils.getStart(reqVO), reqVO.getPageSize());
  44 + } catch (WxErrorException e) {
  45 + throw exception(FREE_PUBLISH_LIST_FAIL, e.getError().getErrorMsg());
  46 + }
  47 +
  48 + // 返回分页
  49 + return success(new PageResult<>(publicationRecords.getItems(), publicationRecords.getTotalCount().longValue()));
  50 + }
  51 +
  52 + @PostMapping("/submit")
  53 + @ApiOperation("发布草稿")
  54 + @ApiImplicitParams({
  55 + @ApiImplicitParam(name = "accountId", value = "公众号账号的编号", required = true,
  56 + example = "1024", dataTypeClass = Long.class),
  57 + @ApiImplicitParam(name = "mediaId", value = "要发布的草稿的 media_id", required = true,
  58 + example = "2048", dataTypeClass = String.class)
  59 + })
  60 + public CommonResult<String> submitFreePublish(@RequestParam("accountId") Long accountId,
  61 + @RequestParam("mediaId") String mediaId) {
  62 + WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId);
  63 + try {
  64 + String publishId = mpService.getFreePublishService().submit(mediaId);
  65 + return success(publishId);
  66 + } catch (WxErrorException e) {
  67 + throw exception(FREE_PUBLISH_SUBMIT_FAIL, e.getError().getErrorMsg());
  68 + }
  69 + }
  70 +
  71 +
  72 +}
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mp.controller.admin.news.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import lombok.ToString;
  9 +
  10 +import javax.validation.constraints.NotNull;
  11 +
  12 +@ApiModel("管理后台 - 公众号草稿的分页 Request VO")
  13 +@Data
  14 +@EqualsAndHashCode(callSuper = true)
  15 +@ToString(callSuper = true)
  16 +public class MpDraftPageReqVO extends PageParam {
  17 +
  18 + @ApiModelProperty(value = "公众号账号的编号", required = true, example = "1024")
  19 + @NotNull(message = "公众号账号的编号不能为空")
  20 + private Long accountId;
  21 +
  22 +}
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mp.controller.admin.news.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import lombok.ToString;
  9 +
  10 +import javax.validation.constraints.NotNull;
  11 +
  12 +@ApiModel("管理后台 - 公众号已发布列表的分页 Request VO")
  13 +@Data
  14 +@EqualsAndHashCode(callSuper = true)
  15 +@ToString(callSuper = true)
  16 +public class MpFreePublishPageReqVO extends PageParam {
  17 +
  18 + @ApiModelProperty(value = "公众号账号的编号", required = true, example = "1024")
  19 + @NotNull(message = "公众号账号的编号不能为空")
  20 + private Long accountId;
  21 +
  22 +}
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java
@@ -11,7 +11,7 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; @@ -11,7 +11,7 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
11 import javax.validation.Valid; 11 import javax.validation.Valid;
12 12
13 /** 13 /**
14 - * 粉丝消息表 Service 接口 14 + * 粉丝消息 Service 接口
15 * 15 *
16 * @author 芋道源码 16 * @author 芋道源码
17 */ 17 */
@@ -19,10 +19,10 @@ public interface MpMessageService { @@ -19,10 +19,10 @@ public interface MpMessageService {
19 19
20 // TODO 芋艿:方法名要优化下 20 // TODO 芋艿:方法名要优化下
21 /** 21 /**
22 - * 获得粉丝消息表分页 22 + * 获得粉丝消息分页
23 * 23 *
24 * @param pageReqVO 分页查询 24 * @param pageReqVO 分页查询
25 - * @return 粉丝消息表 分页 25 + * @return 粉丝消息分页
26 */ 26 */
27 PageResult<MpMessageDO> getWxFansMsgPage(MpMessagePageReqVO pageReqVO); 27 PageResult<MpMessageDO> getWxFansMsgPage(MpMessagePageReqVO pageReqVO);
28 28
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java
@@ -35,7 +35,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU @@ -35,7 +35,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
35 import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MESSAGE_SEND_FAIL; 35 import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MESSAGE_SEND_FAIL;
36 36
37 /** 37 /**
38 - * 粉丝消息表 Service 实现类 38 + * 粉丝消息 Service 实现类
39 * 39 *
40 * @author 芋道源码 40 * @author 芋道源码
41 */ 41 */
yudao-ui-admin/src/api/mp/message.js
1 import request from '@/utils/request' 1 import request from '@/utils/request'
2 2
3 -// 获得粉丝消息表分页 3 +// 获得粉丝消息分页
4 export function getMessagePage(query) { 4 export function getMessagePage(query) {
5 return request({ 5 return request({
6 url: '/mp/message/page', 6 url: '/mp/message/page',
yudao-ui-admin/src/views/mp/components/wx-material-select/main.vue
@@ -113,8 +113,6 @@ @@ -113,8 +113,6 @@
113 import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'; 113 import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue';
114 import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'; 114 import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue';
115 import { getMaterialPage } from "@/api/mp/material"; 115 import { getMaterialPage } from "@/api/mp/material";
116 - // import {getPage as getPageNews} from '@/api/wxmp/wxfreepublish'  
117 - // import {getPage as getPageNewsDraft} from '@/api/wxmp/wxdraft'  
118 116
119 export default { 117 export default {
120 name: "wxMaterialSelect", 118 name: "wxMaterialSelect",
@@ -128,8 +126,7 @@ @@ -128,8 +126,7 @@
128 type: Object, 126 type: Object,
129 required: true 127 required: true
130 }, 128 },
131 - //图文类型:1、已发布图文;2、草稿箱图文  
132 - newsType:{ 129 + newsType:{ // 图文类型:1、已发布图文;2、草稿箱图文
133 type: String, 130 type: String,
134 default: "1" 131 default: "1"
135 }, 132 },
yudao-ui-admin/src/views/mp/message/index.vue
@@ -144,7 +144,7 @@ export default { @@ -144,7 +144,7 @@ export default {
144 showSearch: true, 144 showSearch: true,
145 // 总条数 145 // 总条数
146 total: 0, 146 total: 0,
147 - // 粉丝消息表 列表 147 + // 粉丝消息列表
148 list: [], 148 list: [],
149 // 弹出层标题 149 // 弹出层标题
150 title: "", 150 title: "",