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

This commit is contained in:
YunaiV 2023-01-12 22:49:55 +08:00
parent 267b1790ec
commit 5901ab6664
16 changed files with 247 additions and 20 deletions

View File

@ -34,9 +34,17 @@ public interface ErrorCodeConstants {
// ========== 公众号素材 1006004000============ // ========== 公众号素材 1006004000============
ErrorCode MATERIAL_UPLOAD_FAIL = new ErrorCode(1006004000, "上传素材失败,原因:{}"); ErrorCode MATERIAL_UPLOAD_FAIL = new ErrorCode(1006004000, "上传素材失败,原因:{}");
// ========== 公众号素材 1006005000============ // ========== 公众号消息 1006005000============
ErrorCode MESSAGE_SEND_FAIL = new ErrorCode(1006005000, "发送消息失败,原因:{}"); ErrorCode MESSAGE_SEND_FAIL = new ErrorCode(1006005000, "发送消息失败,原因:{}");
// ========== 公众号发布能力 1006006000============
ErrorCode FREE_PUBLISH_LIST_FAIL = new ErrorCode(1006006000, "获得已成功发布列表失败,原因:{}");
ErrorCode FREE_PUBLISH_SUBMIT_FAIL = new ErrorCode(1006006001, "提交发布失败,原因:{}");
// ========== 公众号草稿 1006007000============
ErrorCode DRAFT_LIST_FAIL = new ErrorCode(1006007000, "获得草稿列表失败,原因:{}");
ErrorCode DRAFT_CREATE_FAIL = new ErrorCode(1006007001, "创建草稿失败,原因:{}");
// TODO 要处理下 // TODO 要处理下
ErrorCode MENU_NOT_EXISTS = new ErrorCode(1006001002, "菜单不存在"); ErrorCode MENU_NOT_EXISTS = new ErrorCode(1006001002, "菜单不存在");

View File

@ -19,7 +19,7 @@ import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Api(tags = "管理后台 - 粉丝消息") @Api(tags = "管理后台 - 粉丝消息")
@RestController @RestController
@RequestMapping("/mp/message") @RequestMapping("/mp/message")
@Validated @Validated
@ -29,7 +29,7 @@ public class MpMessageController {
private MpMessageService mpMessageService; private MpMessageService mpMessageService;
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("获得粉丝消息分页") @ApiOperation("获得粉丝消息分页")
@PreAuthorize("@ss.hasPermission('mp:message:query')") @PreAuthorize("@ss.hasPermission('mp:message:query')")
public CommonResult<PageResult<MpMessageRespVO>> getWxFansMsgPage(@Valid MpMessagePageReqVO pageVO) { public CommonResult<PageResult<MpMessageRespVO>> getWxFansMsgPage(@Valid MpMessagePageReqVO pageVO) {
PageResult<MpMessageDO> pageResult = mpMessageService.getWxFansMsgPage(pageVO); PageResult<MpMessageDO> pageResult = mpMessageService.getWxFansMsgPage(pageVO);

View File

@ -12,7 +12,7 @@ import java.util.List;
// TODO 芋艿VO 的注解 // TODO 芋艿VO 的注解
/** /**
* 粉丝消息 Base VO提供给添加修改详细的子 VO 使用 * 粉丝消息 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成 * 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/ */
@Data @Data

View File

@ -5,7 +5,7 @@ import lombok.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
@ApiModel("管理后台 - 粉丝消息分页 Request VO") @ApiModel("管理后台 - 粉丝消息分页 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)

View File

@ -1,12 +1,14 @@
package cn.iocoder.yudao.module.mp.controller.admin.message.vo; package cn.iocoder.yudao.module.mp.controller.admin.message.vo;
import lombok.*; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.*; import java.util.Date;
import io.swagger.annotations.*; @ApiModel("管理后台 - 粉丝消息 Response VO")
@ApiModel("管理后台 - 粉丝消息表 Response VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)

View File

@ -0,0 +1,24 @@
### 请求 /mp/draft/page 接口 => 成功
GET {{baseUrl}}/mp/draft/page?accountId=1&pageNo=1&pageSize=10
Content-Type: application/json
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
### 请求 /mp/draft/create 接口 => 成功
POST {{baseUrl}}/mp/draft/create?accountId=1
Content-Type: application/json
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
{
"articles": [
{
"title": "我是标题",
"author": "我是作者",
"digest": "我是摘要",
"content": "我是内容",
"contentSourceUrl": "https://www.iocoder.cn",
"thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn"
}
]
}

View File

@ -0,0 +1,67 @@
package cn.iocoder.yudao.module.mp.controller.admin.news;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpDraftPageReqVO;
import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.draft.WxMpAddDraft;
import me.chanjar.weixin.mp.bean.draft.WxMpDraftItem;
import me.chanjar.weixin.mp.bean.draft.WxMpDraftList;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.DRAFT_CREATE_FAIL;
import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.DRAFT_LIST_FAIL;
// TODO 芋艿权限
@Api(tags = "管理后台 - 公众号草稿")
@RestController
@RequestMapping("/mp/draft")
@Validated
public class MpDraftController {
@Resource
private MpServiceFactory mpServiceFactory;
@GetMapping("/page")
@ApiOperation("获得草稿分页")
public CommonResult<PageResult<WxMpDraftItem>> getDraftPage(MpDraftPageReqVO reqVO) {
// 从公众号查询已发布的图文列表
WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId());
WxMpDraftList draftList;
try {
draftList = mpService.getDraftService().listDraft(PageUtils.getStart(reqVO), reqVO.getPageSize());
} catch (WxErrorException e) {
throw exception(DRAFT_LIST_FAIL, e.getError().getErrorMsg());
}
// 返回分页
return success(new PageResult<>(draftList.getItems(), draftList.getTotalCount().longValue()));
}
@PostMapping("/create")
@ApiOperation("创建草稿")
@ApiImplicitParam(name = "accountId", value = "公众号账号的编号", required = true,
example = "1024", dataTypeClass = Long.class)
public CommonResult<String> createDraft(@RequestParam("accountId") Long accountId,
@RequestBody WxMpAddDraft reqVO) {
WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId);
try {
String mediaId = mpService.getDraftService().addDraft(reqVO);
return success(mediaId);
} catch (WxErrorException e) {
throw exception(DRAFT_CREATE_FAIL, e.getError().getErrorMsg());
}
}
}

View File

@ -0,0 +1,13 @@
### 请求 /mp/free-publish/page 接口 => 成功
GET {{baseUrl}}/mp/free-publish/page?accountId=1&pageNo=1&pageSize=10
Content-Type: application/json
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
### 请求 /mp/free-publish/submit 接口 => 成功
POST {{baseUrl}}/mp/free-publish/submit?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-pEm50d1qKxNPkZVzrRZthSJHKCgiylCf4tARZfybZ_O
Content-Type: application/json
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
{}

View File

@ -0,0 +1,72 @@
package cn.iocoder.yudao.module.mp.controller.admin.news;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpFreePublishPageReqVO;
import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishItem;
import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishList;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*;
// TODO 芋艿权限
@Api(tags = "管理后台 - 公众号发布能力")
@RestController
@RequestMapping("/mp/free-publish")
@Validated
public class MpFreePublishController {
@Resource
private MpServiceFactory mpServiceFactory;
@GetMapping("/page")
@ApiOperation("获得已发布的图文分页")
public CommonResult<PageResult<WxMpFreePublishItem>> getFreePublishPage(MpFreePublishPageReqVO reqVO) {
// 从公众号查询已发布的图文列表
WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId());
WxMpFreePublishList publicationRecords;
try {
publicationRecords = mpService.getFreePublishService().getPublicationRecords(
PageUtils.getStart(reqVO), reqVO.getPageSize());
} catch (WxErrorException e) {
throw exception(FREE_PUBLISH_LIST_FAIL, e.getError().getErrorMsg());
}
// 返回分页
return success(new PageResult<>(publicationRecords.getItems(), publicationRecords.getTotalCount().longValue()));
}
@PostMapping("/submit")
@ApiOperation("发布草稿")
@ApiImplicitParams({
@ApiImplicitParam(name = "accountId", value = "公众号账号的编号", required = true,
example = "1024", dataTypeClass = Long.class),
@ApiImplicitParam(name = "mediaId", value = "要发布的草稿的 media_id", required = true,
example = "2048", dataTypeClass = String.class)
})
public CommonResult<String> submitFreePublish(@RequestParam("accountId") Long accountId,
@RequestParam("mediaId") String mediaId) {
WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId);
try {
String publishId = mpService.getFreePublishService().submit(mediaId);
return success(publishId);
} catch (WxErrorException e) {
throw exception(FREE_PUBLISH_SUBMIT_FAIL, e.getError().getErrorMsg());
}
}
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.mp.controller.admin.news.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@ApiModel("管理后台 - 公众号草稿的分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MpDraftPageReqVO extends PageParam {
@ApiModelProperty(value = "公众号账号的编号", required = true, example = "1024")
@NotNull(message = "公众号账号的编号不能为空")
private Long accountId;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.mp.controller.admin.news.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@ApiModel("管理后台 - 公众号已发布列表的分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MpFreePublishPageReqVO extends PageParam {
@ApiModelProperty(value = "公众号账号的编号", required = true, example = "1024")
@NotNull(message = "公众号账号的编号不能为空")
private Long accountId;
}

View File

@ -11,7 +11,7 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import javax.validation.Valid; import javax.validation.Valid;
/** /**
* 粉丝消息 Service 接口 * 粉丝消息 Service 接口
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@ -19,10 +19,10 @@ public interface MpMessageService {
// TODO 芋艿方法名要优化下 // TODO 芋艿方法名要优化下
/** /**
* 获得粉丝消息分页 * 获得粉丝消息分页
* *
* @param pageReqVO 分页查询 * @param pageReqVO 分页查询
* @return 粉丝消息 分页 * @return 粉丝消息分页
*/ */
PageResult<MpMessageDO> getWxFansMsgPage(MpMessagePageReqVO pageReqVO); PageResult<MpMessageDO> getWxFansMsgPage(MpMessagePageReqVO pageReqVO);

View File

@ -35,7 +35,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MESSAGE_SEND_FAIL; import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MESSAGE_SEND_FAIL;
/** /**
* 粉丝消息 Service 实现类 * 粉丝消息 Service 实现类
* *
* @author 芋道源码 * @author 芋道源码
*/ */

View File

@ -1,6 +1,6 @@
import request from '@/utils/request' import request from '@/utils/request'
// 获得粉丝消息分页 // 获得粉丝消息分页
export function getMessagePage(query) { export function getMessagePage(query) {
return request({ return request({
url: '/mp/message/page', url: '/mp/message/page',

View File

@ -113,8 +113,6 @@
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'; import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue';
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'; import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue';
import { getMaterialPage } from "@/api/mp/material"; import { getMaterialPage } from "@/api/mp/material";
// import {getPage as getPageNews} from '@/api/wxmp/wxfreepublish'
// import {getPage as getPageNewsDraft} from '@/api/wxmp/wxdraft'
export default { export default {
name: "wxMaterialSelect", name: "wxMaterialSelect",
@ -128,8 +126,7 @@
type: Object, type: Object,
required: true required: true
}, },
//12稿 newsType:{ // 12稿
newsType:{
type: String, type: String,
default: "1" default: "1"
}, },

View File

@ -144,7 +144,7 @@ export default {
showSearch: true, showSearch: true,
// //
total: 0, total: 0,
// //
list: [], list: [],
// //
title: "", title: "",