From 71beeabe9c57053f0e913fefccafdb454479f01d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 7 Jan 2023 11:07:02 +0800 Subject: [PATCH] =?UTF-8?q?mp=EF=BC=9A=E5=AE=8C=E6=88=90=20menu=20?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=B6=88=E6=81=AF=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/menu/MpMenuController.http | 14 ++ .../admin/menu/vo/MpMenuBaseVO.java | 3 - .../admin/menu/vo/MpMenuSaveReqVO.java | 7 + .../module/mp/convert/menu/MpMenuConvert.java | 15 ++ .../convert/message/MpAutoReplyConvert.java | 2 +- .../mp/convert/message/MpMessageConvert.java | 2 +- .../mp/dal/dataobject/menu/MpMenuDO.java | 203 ++++++++---------- .../dal/dataobject/message/MpAutoReplyDO.java | 5 +- .../mp/dal/mysql/menu/MpMenuMapper.java | 5 +- .../mp/service/menu/MpMenuServiceImpl.java | 51 ++--- .../message/bo/MpMessageSendOutReqBO.java | 3 +- 11 files changed, 150 insertions(+), 160 deletions(-) diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http index 85b202374..8124ad831 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http @@ -16,5 +16,19 @@ tenant-id: {{adminTenentId}} "name":"搜索", "type":"view", "url":"http://www.soso.com/" + }, + { + "name": "父按钮", + "subButtons": [ + { + "type":"click", + "name":"归去来兮", + "key":"MUSIC" + }, + { + "name":"不说", + "type":"view", + "url":"https://www.soso.com/" + }] }] } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java index 070d7c2f5..9d292863d 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java @@ -18,7 +18,4 @@ public class MpMenuBaseVO { @NotNull(message = "公众号账号的编号不能为空") private Long accountId; - @NotNull(message = "按钮不能为空") - private List buttons; - } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java index 6c84eb2e5..9f2aff61e 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java @@ -2,6 +2,10 @@ package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; import lombok.*; import io.swagger.annotations.*; +import me.chanjar.weixin.common.bean.menu.WxMenuButton; + +import javax.validation.constraints.NotNull; +import java.util.List; @ApiModel("管理后台 - 微信菜单保存 Request VO") @Data @@ -9,4 +13,7 @@ import io.swagger.annotations.*; @ToString(callSuper = true) public class MpMenuSaveReqVO extends MpMenuBaseVO { + @NotNull(message = "按钮不能为空") + private List buttons; + } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java index 6de73893e..87c475fb7 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java @@ -2,7 +2,10 @@ package cn.iocoder.yudao.module.mp.convert.menu; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; @@ -16,4 +19,16 @@ public interface MpMenuConvert { MpMenuRespVO convert(MpMenuDO bean); + @Mappings({ + @Mapping(source = "menu.appId", target = "appId"), + @Mapping(source = "menu.replyMessageType", target = "type"), + @Mapping(source = "menu.replyContent", target = "content"), + @Mapping(source = "menu.replyMediaId", target = "mediaId"), + @Mapping(source = "menu.replyMediaUrl", target = "mediaUrl"), + @Mapping(source = "menu.replyTitle", target = "title"), + @Mapping(source = "menu.replyDescription", target = "description"), + @Mapping(source = "menu.replyArticles", target = "articles"), + }) + MpMessageSendOutReqBO convert(String openid, MpMenuDO menu); + } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java index a14c5fee1..be14fd9e6 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java @@ -20,7 +20,7 @@ public interface MpAutoReplyConvert { @Mapping(source = "reply.responseMediaUrl", target = "mediaUrl"), @Mapping(source = "reply.responseTitle", target = "title"), @Mapping(source = "reply.responseDescription", target = "description"), - @Mapping(source = "reply.responseArticle", target = "article"), + @Mapping(source = "reply.responseArticles", target = "articles"), }) MpMessageSendOutReqBO convert(String openid, MpAutoReplyDO reply); 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 f440bf39b..cbd2a7118 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 @@ -64,7 +64,7 @@ public interface MpMessageConvert { .setTitle(sendReqBO.getTitle()).setDescription(sendReqBO.getDescription()); break; case WxConsts.XmlMsgType.NEWS: // 5. 图文 - message.setArticles(Collections.singletonList(sendReqBO.getArticle())); + message.setArticles(sendReqBO.getArticles()); break; default: throw new IllegalArgumentException("不支持的消息类型:" + message.getType()); diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java index 24889116c..8376e1c22 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.mp.dal.dataobject.menu; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; 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.dal.dataobject.message.MpMessageDO; @@ -8,7 +7,6 @@ import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -20,8 +18,6 @@ import java.util.List; /** * 微信菜单 DO * - * 一个公众号,只有一个 MpMenuDO 记录。一个公众号的多个菜单,对应到就是 {@link #buttons} 多个按钮 - * * @author 芋道源码 */ @TableName(value = "mp_menu", autoResultMap = true) @@ -32,7 +28,12 @@ import java.util.List; public class MpMenuDO extends BaseDO { /** - * 主键 + * 编号 - 顶级菜单 + */ + public static final Long ID_ROOT = 0L; + + /** + * 编号 */ @TableId private Long id; @@ -50,127 +51,105 @@ public class MpMenuDO extends BaseDO { private String appId; /** - * 按钮列表 + * 菜单名称 */ - @TableField(typeHandler = ButtonTypeHandler.class) - private List