Commit 47f071560fdcf1456cffe348229d0eb0bb88ffbb
1 parent
69e653cd
mp:menu 菜单的修改,移除多余的类
Showing
24 changed files
with
302 additions
and
633 deletions
http-client.env.json
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | "local": { | 2 | "local": { |
| 3 | "baseUrl": "http://127.0.0.1:48080/admin-api", | 3 | "baseUrl": "http://127.0.0.1:48080/admin-api", |
| 4 | "token": "test1", | 4 | "token": "test1", |
| 5 | - "appTenantId": "1", | 5 | + "adminTenentId": "1", |
| 6 | 6 | ||
| 7 | "appApi": "http://127.0.0.1:48080/app-api", | 7 | "appApi": "http://127.0.0.1:48080/app-api", |
| 8 | "appToken": "test247", | 8 | "appToken": "test247", |
yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java
| @@ -3,15 +3,15 @@ package cn.iocoder.yudao.module.mp.enums; | @@ -3,15 +3,15 @@ package cn.iocoder.yudao.module.mp.enums; | ||
| 3 | import cn.iocoder.yudao.framework.common.exception.ErrorCode; | 3 | import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | - * Member 错误码枚举类 | 6 | + * Mp 错误码枚举类 |
| 7 | * | 7 | * |
| 8 | - * wechatMp 系统,使用 1-004-000-000 段 | 8 | + * mp 系统,使用 1-006-000-000 段 |
| 9 | */ | 9 | */ |
| 10 | public interface ErrorCodeConstants { | 10 | public interface ErrorCodeConstants { |
| 11 | 11 | ||
| 12 | // ========== 用户相关 1004001000============ | 12 | // ========== 用户相关 1004001000============ |
| 13 | - ErrorCode WX_ACCOUNT_NOT_EXISTS = new ErrorCode(1004001000, "公众号账户不存在"); | ||
| 14 | - ErrorCode WX_ACCOUNT_FANS_NOT_EXISTS = new ErrorCode(1004001001, "粉丝账号不存在"); | ||
| 15 | - ErrorCode COMMON_NOT_EXISTS = new ErrorCode(1004001002, "用户不存在"); | 13 | + ErrorCode WX_ACCOUNT_NOT_EXISTS = new ErrorCode(1006001000, "公众号账户不存在"); |
| 14 | + ErrorCode WX_ACCOUNT_FANS_NOT_EXISTS = new ErrorCode(1006001001, "粉丝账号不存在"); | ||
| 15 | + ErrorCode COMMON_NOT_EXISTS = new ErrorCode(1006001002, "用户不存在"); | ||
| 16 | 16 | ||
| 17 | } | 17 | } |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java
| @@ -22,8 +22,8 @@ public class MpAccountBaseVO { | @@ -22,8 +22,8 @@ public class MpAccountBaseVO { | ||
| 22 | @NotNull(message = "公众号账户不能为空") | 22 | @NotNull(message = "公众号账户不能为空") |
| 23 | private String account; | 23 | private String account; |
| 24 | 24 | ||
| 25 | - @ApiModelProperty(value = "公众号 appid", required = true) | ||
| 26 | - @NotNull(message = "公众号 appid 不能为空") | 25 | + @ApiModelProperty(value = "公众号 appId", required = true, example = "wx5b23ba7a5589ecbb") |
| 26 | + @NotNull(message = "公众号 appId 不能为空") | ||
| 27 | private String appId; | 27 | private String appId; |
| 28 | 28 | ||
| 29 | @ApiModelProperty(value = "公众号密钥", required = true) | 29 | @ApiModelProperty(value = "公众号密钥", required = true) |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/accountfanstag/WxAccountFansTagController.java
| @@ -88,16 +88,4 @@ public class WxAccountFansTagController { | @@ -88,16 +88,4 @@ public class WxAccountFansTagController { | ||
| 88 | return success(WxAccountFansTagConvert.INSTANCE.convertPage(pageResult)); | 88 | return success(WxAccountFansTagConvert.INSTANCE.convertPage(pageResult)); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | - @GetMapping("/export-excel") | ||
| 92 | - @ApiOperation("导出粉丝标签关联 Excel") | ||
| 93 | - @PreAuthorize("@ss.hasPermission('wechatMp:wx-account-fans-tag:export')") | ||
| 94 | - @OperateLog(type = EXPORT) | ||
| 95 | - public void exportWxAccountFansTagExcel(@Valid WxAccountFansTagExportReqVO exportReqVO, | ||
| 96 | - HttpServletResponse response) throws IOException { | ||
| 97 | - List<WxAccountFansTagDO> list = wxAccountFansTagService.getWxAccountFansTagList(exportReqVO); | ||
| 98 | - // 导出 Excel | ||
| 99 | - List<WxAccountFansTagExcelVO> datas = WxAccountFansTagConvert.INSTANCE.convertList02(list); | ||
| 100 | - ExcelUtils.write(response, "粉丝标签关联.xls", "数据", WxAccountFansTagExcelVO.class, datas); | ||
| 101 | - } | ||
| 102 | - | ||
| 103 | } | 91 | } |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http
0 → 100644
| 1 | +### 请求 /login 接口 => 成功 | ||
| 2 | +POST {{baseUrl}}/mp/menu/save | ||
| 3 | +Content-Type: application/json | ||
| 4 | +Authorization: Bearer {{token}} | ||
| 5 | +tenant-id: {{adminTenentId}} | ||
| 6 | + | ||
| 7 | +{ | ||
| 8 | + "accountId": "1", | ||
| 9 | + "buttons": [ | ||
| 10 | + { | ||
| 11 | + "type":"click", | ||
| 12 | + "name":"今日歌曲", | ||
| 13 | + "key":"V1001_TODAY_MUSIC" | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + "name":"搜索", | ||
| 17 | + "type":"view", | ||
| 18 | + "url":"http://www.soso.com/" | ||
| 19 | + }] | ||
| 20 | +} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mp.controller.admin.menu; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.mp.convert.menu.MpMenuConvert; | ||
| 4 | +import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; | ||
| 5 | +import org.springframework.web.bind.annotation.*; | ||
| 6 | + | ||
| 7 | +import javax.annotation.Resource; | ||
| 8 | + | ||
| 9 | +import org.springframework.validation.annotation.Validated; | ||
| 10 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 11 | +import io.swagger.annotations.*; | ||
| 12 | + | ||
| 13 | +import javax.validation.*; | ||
| 14 | + | ||
| 15 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 16 | + | ||
| 17 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 18 | + | ||
| 19 | +import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; | ||
| 20 | +import cn.iocoder.yudao.module.mp.service.menu.MpMenuService; | ||
| 21 | + | ||
| 22 | +@Api(tags = "管理后台 - 微信菜单") | ||
| 23 | +@RestController | ||
| 24 | +@RequestMapping("/mp/menu") | ||
| 25 | +@Validated | ||
| 26 | +public class MpMenuController { | ||
| 27 | + | ||
| 28 | + @Resource | ||
| 29 | + private MpMenuService mpMenuService; | ||
| 30 | + | ||
| 31 | + @PostMapping("/save") | ||
| 32 | + @ApiOperation("保存微信菜单") | ||
| 33 | + @PreAuthorize("@ss.hasPermission('mp:menu:save')") | ||
| 34 | + public CommonResult<Long> saveMenu(@Valid @RequestBody MpMenuSaveReqVO createReqVO) { | ||
| 35 | + return success(mpMenuService.saveMenu(createReqVO)); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @DeleteMapping("/delete") | ||
| 39 | + @ApiOperation("删除微信菜单") | ||
| 40 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | ||
| 41 | + @PreAuthorize("@ss.hasPermission('mp:menu:delete')") | ||
| 42 | + public CommonResult<Boolean> deleteMenu(@RequestParam("id") Long id) { | ||
| 43 | + mpMenuService.deleteMenu(id); | ||
| 44 | + return success(true); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @GetMapping("/get") | ||
| 48 | + @ApiOperation("获得微信菜单") | ||
| 49 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | ||
| 50 | + @PreAuthorize("@ss.hasPermission('mp:menu:query')") | ||
| 51 | + public CommonResult<MpMenuRespVO> getMenu(@RequestParam("id") Long id) { | ||
| 52 | + MpMenuDO menu = mpMenuService.getMenu(id); | ||
| 53 | + return success(MpMenuConvert.INSTANCE.convert(menu)); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | +} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/WxMenuController.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.controller.admin.menu; | ||
| 2 | - | ||
| 3 | -import org.springframework.web.bind.annotation.*; | ||
| 4 | - | ||
| 5 | -import javax.annotation.Resource; | ||
| 6 | - | ||
| 7 | -import org.springframework.validation.annotation.Validated; | ||
| 8 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 9 | -import io.swagger.annotations.*; | ||
| 10 | - | ||
| 11 | -import javax.validation.*; | ||
| 12 | -import javax.servlet.http.*; | ||
| 13 | -import java.util.*; | ||
| 14 | -import java.io.IOException; | ||
| 15 | - | ||
| 16 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 17 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 18 | - | ||
| 19 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 20 | - | ||
| 21 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 22 | - | ||
| 23 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 24 | - | ||
| 25 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||
| 26 | - | ||
| 27 | -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; | ||
| 28 | -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.WxMenuDO; | ||
| 29 | -import cn.iocoder.yudao.module.mp.convert.menu.WxMenuConvert; | ||
| 30 | -import cn.iocoder.yudao.module.mp.service.menu.WxMenuService; | ||
| 31 | - | ||
| 32 | -@Api(tags = "管理后台 - 微信菜单") | ||
| 33 | -@RestController | ||
| 34 | -@RequestMapping("/wechatMp/wx-menu") | ||
| 35 | -@Validated | ||
| 36 | -public class WxMenuController { | ||
| 37 | - | ||
| 38 | - @Resource | ||
| 39 | - private WxMenuService wxMenuService; | ||
| 40 | - | ||
| 41 | - @PostMapping("/create") | ||
| 42 | - @ApiOperation("创建微信菜单") | ||
| 43 | - @PreAuthorize("@ss.hasPermission('wechatMp:wx-menu:create')") | ||
| 44 | - public CommonResult<Integer> createWxMenu(@Valid @RequestBody WxMenuCreateReqVO createReqVO) { | ||
| 45 | - return success(wxMenuService.createWxMenu(createReqVO)); | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - @PutMapping("/update") | ||
| 49 | - @ApiOperation("更新微信菜单") | ||
| 50 | - @PreAuthorize("@ss.hasPermission('wechatMp:wx-menu:update')") | ||
| 51 | - public CommonResult<Boolean> updateWxMenu(@Valid @RequestBody WxMenuUpdateReqVO updateReqVO) { | ||
| 52 | - wxMenuService.updateWxMenu(updateReqVO); | ||
| 53 | - return success(true); | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - @DeleteMapping("/delete") | ||
| 57 | - @ApiOperation("删除微信菜单") | ||
| 58 | - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class) | ||
| 59 | - @PreAuthorize("@ss.hasPermission('wechatMp:wx-menu:delete')") | ||
| 60 | - public CommonResult<Boolean> deleteWxMenu(@RequestParam("id") Integer id) { | ||
| 61 | - wxMenuService.deleteWxMenu(id); | ||
| 62 | - return success(true); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - @GetMapping("/get") | ||
| 66 | - @ApiOperation("获得微信菜单") | ||
| 67 | - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) | ||
| 68 | - @PreAuthorize("@ss.hasPermission('wechatMp:wx-menu:query')") | ||
| 69 | - public CommonResult<WxMenuRespVO> getWxMenu(@RequestParam("id") Integer id) { | ||
| 70 | - WxMenuDO wxMenu = wxMenuService.getWxMenu(id); | ||
| 71 | - return success(WxMenuConvert.INSTANCE.convert(wxMenu)); | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - @GetMapping("/list") | ||
| 75 | - @ApiOperation("获得微信菜单列表") | ||
| 76 | - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | ||
| 77 | - @PreAuthorize("@ss.hasPermission('wechatMp:wx-menu:query')") | ||
| 78 | - public CommonResult<List<WxMenuRespVO>> getWxMenuList(@RequestParam("ids") Collection<Integer> ids) { | ||
| 79 | - List<WxMenuDO> list = wxMenuService.getWxMenuList(ids); | ||
| 80 | - return success(WxMenuConvert.INSTANCE.convertList(list)); | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - @GetMapping("/page") | ||
| 84 | - @ApiOperation("获得微信菜单分页") | ||
| 85 | - @PreAuthorize("@ss.hasPermission('wechatMp:wx-menu:query')") | ||
| 86 | - public CommonResult<PageResult<WxMenuRespVO>> getWxMenuPage(@Valid WxMenuPageReqVO pageVO) { | ||
| 87 | - PageResult<WxMenuDO> pageResult = wxMenuService.getWxMenuPage(pageVO); | ||
| 88 | - return success(WxMenuConvert.INSTANCE.convertPage(pageResult)); | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - @GetMapping("/export-excel") | ||
| 92 | - @ApiOperation("导出微信菜单 Excel") | ||
| 93 | - @PreAuthorize("@ss.hasPermission('wechatMp:wx-menu:export')") | ||
| 94 | - @OperateLog(type = EXPORT) | ||
| 95 | - public void exportWxMenuExcel(@Valid WxMenuExportReqVO exportReqVO, | ||
| 96 | - HttpServletResponse response) throws IOException { | ||
| 97 | - List<WxMenuDO> list = wxMenuService.getWxMenuList(exportReqVO); | ||
| 98 | - // 导出 Excel | ||
| 99 | - List<WxMenuExcelVO> datas = WxMenuConvert.INSTANCE.convertList02(list); | ||
| 100 | - ExcelUtils.write(response, "微信菜单.xls", "数据", WxMenuExcelVO.class, datas); | ||
| 101 | - } | ||
| 102 | - | ||
| 103 | -} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModelProperty; | ||
| 4 | +import lombok.*; | ||
| 5 | +import me.chanjar.weixin.common.bean.menu.WxMenuButton; | ||
| 6 | + | ||
| 7 | +import javax.validation.constraints.NotNull; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 微信菜单 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 12 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 13 | + */ | ||
| 14 | +@Data | ||
| 15 | +public class MpMenuBaseVO { | ||
| 16 | + | ||
| 17 | + @ApiModelProperty(value = "公众号账号的编号", required = true, example = "2048") | ||
| 18 | + @NotNull(message = "公众号账号的编号不能为空") | ||
| 19 | + private Long accountId; | ||
| 20 | + | ||
| 21 | + @NotNull(message = "按钮不能为空") | ||
| 22 | + private List<WxMenuButton> buttons; | ||
| 23 | + | ||
| 24 | +} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/WxMenuRespVO.java renamed to yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java
| @@ -10,10 +10,10 @@ import io.swagger.annotations.*; | @@ -10,10 +10,10 @@ import io.swagger.annotations.*; | ||
| 10 | @Data | 10 | @Data |
| 11 | @EqualsAndHashCode(callSuper = true) | 11 | @EqualsAndHashCode(callSuper = true) |
| 12 | @ToString(callSuper = true) | 12 | @ToString(callSuper = true) |
| 13 | -public class WxMenuRespVO extends WxMenuBaseVO { | 13 | +public class MpMenuRespVO extends MpMenuBaseVO { |
| 14 | 14 | ||
| 15 | @ApiModelProperty(value = "主键", required = true) | 15 | @ApiModelProperty(value = "主键", required = true) |
| 16 | - private Integer id; | 16 | + private Long id; |
| 17 | 17 | ||
| 18 | @ApiModelProperty(value = "创建时间", required = true) | 18 | @ApiModelProperty(value = "创建时间", required = true) |
| 19 | private Date createTime; | 19 | private Date createTime; |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/WxMenuCreateReqVO.java renamed to yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java
| @@ -3,10 +3,10 @@ package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; | @@ -3,10 +3,10 @@ package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; | ||
| 3 | import lombok.*; | 3 | import lombok.*; |
| 4 | import io.swagger.annotations.*; | 4 | import io.swagger.annotations.*; |
| 5 | 5 | ||
| 6 | -@ApiModel("管理后台 - 微信菜单创建 Request VO") | 6 | +@ApiModel("管理后台 - 微信菜单保存 Request VO") |
| 7 | @Data | 7 | @Data |
| 8 | @EqualsAndHashCode(callSuper = true) | 8 | @EqualsAndHashCode(callSuper = true) |
| 9 | @ToString(callSuper = true) | 9 | @ToString(callSuper = true) |
| 10 | -public class WxMenuCreateReqVO extends WxMenuBaseVO { | 10 | +public class MpMenuSaveReqVO extends MpMenuBaseVO { |
| 11 | 11 | ||
| 12 | } | 12 | } |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/WxMenuBaseVO.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import io.swagger.annotations.*; | ||
| 5 | - | ||
| 6 | -/** | ||
| 7 | - * 微信菜单 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 8 | - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 9 | - */ | ||
| 10 | -@Data | ||
| 11 | -public class WxMenuBaseVO { | ||
| 12 | - | ||
| 13 | - @ApiModelProperty(value = "父ID") | ||
| 14 | - private String parentId; | ||
| 15 | - | ||
| 16 | - @ApiModelProperty(value = "菜单名称") | ||
| 17 | - private String menuName; | ||
| 18 | - | ||
| 19 | - @ApiModelProperty(value = "菜单类型 1文本消息;2图文消息;3网址链接;4小程序") | ||
| 20 | - private String menuType; | ||
| 21 | - | ||
| 22 | - @ApiModelProperty(value = "菜单等级") | ||
| 23 | - private String menuLevel; | ||
| 24 | - | ||
| 25 | - @ApiModelProperty(value = "模板ID") | ||
| 26 | - private String tplId; | ||
| 27 | - | ||
| 28 | - @ApiModelProperty(value = "菜单URL") | ||
| 29 | - private String menuUrl; | ||
| 30 | - | ||
| 31 | - @ApiModelProperty(value = "排序") | ||
| 32 | - private String menuSort; | ||
| 33 | - | ||
| 34 | - @ApiModelProperty(value = "微信账号ID") | ||
| 35 | - private String wxAccountId; | ||
| 36 | - | ||
| 37 | - @ApiModelProperty(value = "小程序appid") | ||
| 38 | - private String miniprogramAppid; | ||
| 39 | - | ||
| 40 | - @ApiModelProperty(value = "小程序页面路径") | ||
| 41 | - private String miniprogramPagepath; | ||
| 42 | - | ||
| 43 | -} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/WxMenuExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | - | ||
| 5 | -import java.util.*; | ||
| 6 | - | ||
| 7 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 微信菜单 Excel VO | ||
| 11 | - * | ||
| 12 | - * @author 芋道源码 | ||
| 13 | - */ | ||
| 14 | -@Data | ||
| 15 | -public class WxMenuExcelVO { | ||
| 16 | - | ||
| 17 | - @ExcelProperty("主键") | ||
| 18 | - private Integer id; | ||
| 19 | - | ||
| 20 | - @ExcelProperty("父ID") | ||
| 21 | - private String parentId; | ||
| 22 | - | ||
| 23 | - @ExcelProperty("菜单名称") | ||
| 24 | - private String menuName; | ||
| 25 | - | ||
| 26 | - @ExcelProperty("菜单类型 1文本消息;2图文消息;3网址链接;4小程序") | ||
| 27 | - private String menuType; | ||
| 28 | - | ||
| 29 | - @ExcelProperty("菜单等级") | ||
| 30 | - private String menuLevel; | ||
| 31 | - | ||
| 32 | - @ExcelProperty("模板ID") | ||
| 33 | - private String tplId; | ||
| 34 | - | ||
| 35 | - @ExcelProperty("菜单URL") | ||
| 36 | - private String menuUrl; | ||
| 37 | - | ||
| 38 | - @ExcelProperty("排序") | ||
| 39 | - private String menuSort; | ||
| 40 | - | ||
| 41 | - @ExcelProperty("微信账号ID") | ||
| 42 | - private String wxAccountId; | ||
| 43 | - | ||
| 44 | - @ExcelProperty("小程序appid") | ||
| 45 | - private String miniprogramAppid; | ||
| 46 | - | ||
| 47 | - @ExcelProperty("小程序页面路径") | ||
| 48 | - private String miniprogramPagepath; | ||
| 49 | - | ||
| 50 | - @ExcelProperty("创建时间") | ||
| 51 | - private Date createTime; | ||
| 52 | - | ||
| 53 | -} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/WxMenuExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | - | ||
| 5 | -import java.util.*; | ||
| 6 | - | ||
| 7 | -import io.swagger.annotations.*; | ||
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | - | ||
| 12 | -@ApiModel(value = "管理后台 - 微信菜单 Excel 导出 Request VO", description = "参数和 WxMenuPageReqVO 是一致的") | ||
| 13 | -@Data | ||
| 14 | -public class WxMenuExportReqVO { | ||
| 15 | - | ||
| 16 | - @ApiModelProperty(value = "父ID") | ||
| 17 | - private String parentId; | ||
| 18 | - | ||
| 19 | - @ApiModelProperty(value = "菜单名称") | ||
| 20 | - private String menuName; | ||
| 21 | - | ||
| 22 | - @ApiModelProperty(value = "菜单类型 1文本消息;2图文消息;3网址链接;4小程序") | ||
| 23 | - private String menuType; | ||
| 24 | - | ||
| 25 | - @ApiModelProperty(value = "菜单等级") | ||
| 26 | - private String menuLevel; | ||
| 27 | - | ||
| 28 | - @ApiModelProperty(value = "模板ID") | ||
| 29 | - private String tplId; | ||
| 30 | - | ||
| 31 | - @ApiModelProperty(value = "菜单URL") | ||
| 32 | - private String menuUrl; | ||
| 33 | - | ||
| 34 | - @ApiModelProperty(value = "排序") | ||
| 35 | - private String menuSort; | ||
| 36 | - | ||
| 37 | - @ApiModelProperty(value = "微信账号ID") | ||
| 38 | - private String wxAccountId; | ||
| 39 | - | ||
| 40 | - @ApiModelProperty(value = "小程序appid") | ||
| 41 | - private String miniprogramAppid; | ||
| 42 | - | ||
| 43 | - @ApiModelProperty(value = "小程序页面路径") | ||
| 44 | - private String miniprogramPagepath; | ||
| 45 | - | ||
| 46 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 47 | - @ApiModelProperty(value = "开始创建时间") | ||
| 48 | - private Date beginCreateTime; | ||
| 49 | - | ||
| 50 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 51 | - @ApiModelProperty(value = "结束创建时间") | ||
| 52 | - private Date endCreateTime; | ||
| 53 | - | ||
| 54 | -} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/WxMenuPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | - | ||
| 5 | -import java.util.*; | ||
| 6 | - | ||
| 7 | -import io.swagger.annotations.*; | ||
| 8 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 9 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 10 | - | ||
| 11 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 12 | - | ||
| 13 | -@ApiModel("管理后台 - 微信菜单分页 Request VO") | ||
| 14 | -@Data | ||
| 15 | -@EqualsAndHashCode(callSuper = true) | ||
| 16 | -@ToString(callSuper = true) | ||
| 17 | -public class WxMenuPageReqVO extends PageParam { | ||
| 18 | - | ||
| 19 | - @ApiModelProperty(value = "父ID") | ||
| 20 | - private String parentId; | ||
| 21 | - | ||
| 22 | - @ApiModelProperty(value = "菜单名称") | ||
| 23 | - private String menuName; | ||
| 24 | - | ||
| 25 | - @ApiModelProperty(value = "菜单类型 1文本消息;2图文消息;3网址链接;4小程序") | ||
| 26 | - private String menuType; | ||
| 27 | - | ||
| 28 | - @ApiModelProperty(value = "菜单等级") | ||
| 29 | - private String menuLevel; | ||
| 30 | - | ||
| 31 | - @ApiModelProperty(value = "模板ID") | ||
| 32 | - private String tplId; | ||
| 33 | - | ||
| 34 | - @ApiModelProperty(value = "菜单URL") | ||
| 35 | - private String menuUrl; | ||
| 36 | - | ||
| 37 | - @ApiModelProperty(value = "排序") | ||
| 38 | - private String menuSort; | ||
| 39 | - | ||
| 40 | - @ApiModelProperty(value = "微信账号ID") | ||
| 41 | - private String wxAccountId; | ||
| 42 | - | ||
| 43 | - @ApiModelProperty(value = "小程序appid") | ||
| 44 | - private String miniprogramAppid; | ||
| 45 | - | ||
| 46 | - @ApiModelProperty(value = "小程序页面路径") | ||
| 47 | - private String miniprogramPagepath; | ||
| 48 | - | ||
| 49 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 50 | - @ApiModelProperty(value = "开始创建时间") | ||
| 51 | - private Date beginCreateTime; | ||
| 52 | - | ||
| 53 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 54 | - @ApiModelProperty(value = "结束创建时间") | ||
| 55 | - private Date endCreateTime; | ||
| 56 | - | ||
| 57 | -} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/WxMenuUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import io.swagger.annotations.*; | ||
| 5 | - | ||
| 6 | -import javax.validation.constraints.*; | ||
| 7 | - | ||
| 8 | -@ApiModel("管理后台 - 微信菜单更新 Request VO") | ||
| 9 | -@Data | ||
| 10 | -@EqualsAndHashCode(callSuper = true) | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class WxMenuUpdateReqVO extends WxMenuBaseVO { | ||
| 13 | - | ||
| 14 | - @ApiModelProperty(value = "主键", required = true) | ||
| 15 | - @NotNull(message = "主键不能为空") | ||
| 16 | - private Integer id; | ||
| 17 | - | ||
| 18 | -} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mp.convert.menu; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | + | ||
| 5 | +import org.mapstruct.Mapper; | ||
| 6 | +import org.mapstruct.factory.Mappers; | ||
| 7 | +import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; | ||
| 8 | +import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; | ||
| 9 | + | ||
| 10 | +@Mapper | ||
| 11 | +public interface MpMenuConvert { | ||
| 12 | + | ||
| 13 | + MpMenuConvert INSTANCE = Mappers.getMapper(MpMenuConvert.class); | ||
| 14 | + | ||
| 15 | + MpMenuDO convert(MpMenuSaveReqVO bean); | ||
| 16 | + | ||
| 17 | + MpMenuRespVO convert(MpMenuDO bean); | ||
| 18 | + | ||
| 19 | +} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/WxMenuConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.convert.menu; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | - | ||
| 7 | -import org.mapstruct.Mapper; | ||
| 8 | -import org.mapstruct.factory.Mappers; | ||
| 9 | -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; | ||
| 10 | -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.WxMenuDO; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 微信菜单 Convert | ||
| 14 | - * | ||
| 15 | - * @author 芋道源码 | ||
| 16 | - */ | ||
| 17 | -@Mapper | ||
| 18 | -public interface WxMenuConvert { | ||
| 19 | - | ||
| 20 | - WxMenuConvert INSTANCE = Mappers.getMapper(WxMenuConvert.class); | ||
| 21 | - | ||
| 22 | - WxMenuDO convert(WxMenuCreateReqVO bean); | ||
| 23 | - | ||
| 24 | - WxMenuDO convert(WxMenuUpdateReqVO bean); | ||
| 25 | - | ||
| 26 | - WxMenuRespVO convert(WxMenuDO bean); | ||
| 27 | - | ||
| 28 | - List<WxMenuRespVO> convertList(List<WxMenuDO> list); | ||
| 29 | - | ||
| 30 | - PageResult<WxMenuRespVO> convertPage(PageResult<WxMenuDO> page); | ||
| 31 | - | ||
| 32 | - List<WxMenuExcelVO> convertList02(List<WxMenuDO> list); | ||
| 33 | - | ||
| 34 | -} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mp.dal.dataobject.menu; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | ||
| 4 | +import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; | ||
| 5 | +import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; | ||
| 6 | +import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; | ||
| 7 | +import lombok.*; | ||
| 8 | + | ||
| 9 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 10 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 11 | +import me.chanjar.weixin.common.bean.menu.WxMenu; | ||
| 12 | +import me.chanjar.weixin.common.bean.menu.WxMenuButton; | ||
| 13 | + | ||
| 14 | +import java.util.List; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * 微信菜单 DO | ||
| 18 | + * | ||
| 19 | + * 一个公众号,只有一个 MpMenuDO 记录。一个公众号的多个菜单,对应到就是 {@link #buttons} 多个按钮 | ||
| 20 | + * | ||
| 21 | + * @author 芋道源码 | ||
| 22 | + */ | ||
| 23 | +@TableName(value = "mp_menu", autoResultMap = true) | ||
| 24 | +@KeySequence("mp_menu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 25 | +@Data | ||
| 26 | +@EqualsAndHashCode(callSuper = true) | ||
| 27 | +@ToString(callSuper = true) | ||
| 28 | +public class MpMenuDO extends BaseDO { | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 主键 | ||
| 32 | + */ | ||
| 33 | + @TableId | ||
| 34 | + private Long id; | ||
| 35 | + /** | ||
| 36 | + * 微信公众号 ID | ||
| 37 | + * | ||
| 38 | + * 关联 {@link MpAccountDO#getId()} | ||
| 39 | + */ | ||
| 40 | + private Long accountId; | ||
| 41 | + /** | ||
| 42 | + * 微信公众号 appid | ||
| 43 | + * | ||
| 44 | + * 冗余 {@link MpAccountDO#getAppId()} | ||
| 45 | + */ | ||
| 46 | + private String appId; | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 按钮列表 | ||
| 50 | + */ | ||
| 51 | + @TableField(typeHandler = WxMenuButtonTypeHandler.class) | ||
| 52 | + private List<WxMenuButton> buttons; | ||
| 53 | + /** | ||
| 54 | + * 同步状态 | ||
| 55 | + * | ||
| 56 | + * true - 已同步 | ||
| 57 | + * false - 未同步 | ||
| 58 | + */ | ||
| 59 | + private Boolean syncStatus; | ||
| 60 | + | ||
| 61 | + // TODO @芋艿:可以找一些新的思路 | ||
| 62 | + public static class WxMenuButtonTypeHandler extends AbstractJsonTypeHandler<List<WxMenuButton>> { | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + protected List<WxMenuButton> parse(String json) { | ||
| 66 | + return JsonUtils.parseArray(json, WxMenuButton.class); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Override | ||
| 70 | + protected String toJson(List<WxMenuButton> obj) { | ||
| 71 | + return JsonUtils.toJsonString(obj); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + } | ||
| 75 | +} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/WxMenuDO.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.dal.dataobject.menu; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | - | ||
| 5 | -import java.util.*; | ||
| 6 | - | ||
| 7 | -import com.baomidou.mybatisplus.annotation.*; | ||
| 8 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * 微信菜单 DO | ||
| 12 | - * | ||
| 13 | - * @author 芋道源码 | ||
| 14 | - */ | ||
| 15 | -@TableName("wx_menu") | ||
| 16 | -@KeySequence("wx_menu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | -@Data | ||
| 18 | -@EqualsAndHashCode(callSuper = true) | ||
| 19 | -@ToString(callSuper = true) | ||
| 20 | -@Builder | ||
| 21 | -@NoArgsConstructor | ||
| 22 | -@AllArgsConstructor | ||
| 23 | -public class WxMenuDO extends BaseDO { | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * 主键 | ||
| 27 | - */ | ||
| 28 | - @TableId | ||
| 29 | - private Integer id; | ||
| 30 | - /** | ||
| 31 | - * 父ID | ||
| 32 | - */ | ||
| 33 | - private String parentId; | ||
| 34 | - /** | ||
| 35 | - * 菜单名称 | ||
| 36 | - */ | ||
| 37 | - private String menuName; | ||
| 38 | - /** | ||
| 39 | - * 菜单类型 1文本消息;2图文消息;3网址链接;4小程序 | ||
| 40 | - */ | ||
| 41 | - private String menuType; | ||
| 42 | - /** | ||
| 43 | - * 菜单等级 | ||
| 44 | - */ | ||
| 45 | - private String menuLevel; | ||
| 46 | - /** | ||
| 47 | - * 模板ID | ||
| 48 | - */ | ||
| 49 | - private String tplId; | ||
| 50 | - /** | ||
| 51 | - * 菜单URL | ||
| 52 | - */ | ||
| 53 | - private String menuUrl; | ||
| 54 | - /** | ||
| 55 | - * 排序 | ||
| 56 | - */ | ||
| 57 | - private String menuSort; | ||
| 58 | - /** | ||
| 59 | - * 微信账号ID | ||
| 60 | - */ | ||
| 61 | - private String wxAccountId; | ||
| 62 | - /** | ||
| 63 | - * 小程序appid | ||
| 64 | - */ | ||
| 65 | - private String miniprogramAppid; | ||
| 66 | - /** | ||
| 67 | - * 小程序页面路径 | ||
| 68 | - */ | ||
| 69 | - private String miniprogramPagepath; | ||
| 70 | - | ||
| 71 | -} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mp.dal.mysql.menu; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; | ||
| 5 | +import org.apache.ibatis.annotations.Mapper; | ||
| 6 | + | ||
| 7 | +@Mapper | ||
| 8 | +public interface MpMenuMapper extends BaseMapperX<MpMenuDO> { | ||
| 9 | + | ||
| 10 | +} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/WxMenuMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.dal.mysql.menu; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 8 | -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.WxMenuDO; | ||
| 9 | -import org.apache.ibatis.annotations.Mapper; | ||
| 10 | -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 微信菜单 Mapper | ||
| 14 | - * | ||
| 15 | - * @author 芋道源码 | ||
| 16 | - */ | ||
| 17 | -@Mapper | ||
| 18 | -public interface WxMenuMapper extends BaseMapperX<WxMenuDO> { | ||
| 19 | - | ||
| 20 | - default PageResult<WxMenuDO> selectPage(WxMenuPageReqVO reqVO) { | ||
| 21 | - return selectPage(reqVO, new LambdaQueryWrapperX<WxMenuDO>() | ||
| 22 | - .eqIfPresent(WxMenuDO::getParentId, reqVO.getParentId()) | ||
| 23 | - .likeIfPresent(WxMenuDO::getMenuName, reqVO.getMenuName()) | ||
| 24 | - .eqIfPresent(WxMenuDO::getMenuType, reqVO.getMenuType()) | ||
| 25 | - .eqIfPresent(WxMenuDO::getMenuLevel, reqVO.getMenuLevel()) | ||
| 26 | - .eqIfPresent(WxMenuDO::getTplId, reqVO.getTplId()) | ||
| 27 | - .eqIfPresent(WxMenuDO::getMenuUrl, reqVO.getMenuUrl()) | ||
| 28 | - .eqIfPresent(WxMenuDO::getMenuSort, reqVO.getMenuSort()) | ||
| 29 | - .eqIfPresent(WxMenuDO::getWxAccountId, reqVO.getWxAccountId()) | ||
| 30 | - .eqIfPresent(WxMenuDO::getMiniprogramAppid, reqVO.getMiniprogramAppid()) | ||
| 31 | - .eqIfPresent(WxMenuDO::getMiniprogramPagepath, reqVO.getMiniprogramPagepath()) | ||
| 32 | - .betweenIfPresent(WxMenuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||
| 33 | - .orderByDesc(WxMenuDO::getId)); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - default List<WxMenuDO> selectList(WxMenuExportReqVO reqVO) { | ||
| 37 | - return selectList(new LambdaQueryWrapperX<WxMenuDO>() | ||
| 38 | - .eqIfPresent(WxMenuDO::getParentId, reqVO.getParentId()) | ||
| 39 | - .likeIfPresent(WxMenuDO::getMenuName, reqVO.getMenuName()) | ||
| 40 | - .eqIfPresent(WxMenuDO::getMenuType, reqVO.getMenuType()) | ||
| 41 | - .eqIfPresent(WxMenuDO::getMenuLevel, reqVO.getMenuLevel()) | ||
| 42 | - .eqIfPresent(WxMenuDO::getTplId, reqVO.getTplId()) | ||
| 43 | - .eqIfPresent(WxMenuDO::getMenuUrl, reqVO.getMenuUrl()) | ||
| 44 | - .eqIfPresent(WxMenuDO::getMenuSort, reqVO.getMenuSort()) | ||
| 45 | - .eqIfPresent(WxMenuDO::getWxAccountId, reqVO.getWxAccountId()) | ||
| 46 | - .eqIfPresent(WxMenuDO::getMiniprogramAppid, reqVO.getMiniprogramAppid()) | ||
| 47 | - .eqIfPresent(WxMenuDO::getMiniprogramPagepath, reqVO.getMiniprogramPagepath()) | ||
| 48 | - .betweenIfPresent(WxMenuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||
| 49 | - .orderByDesc(WxMenuDO::getId)); | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | -} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/WxMenuService.java renamed to yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java
| 1 | package cn.iocoder.yudao.module.mp.service.menu; | 1 | package cn.iocoder.yudao.module.mp.service.menu; |
| 2 | 2 | ||
| 3 | -import java.util.*; | ||
| 4 | import javax.validation.*; | 3 | import javax.validation.*; |
| 5 | 4 | ||
| 6 | import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; | 5 | import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; |
| 7 | -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.WxMenuDO; | ||
| 8 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | +import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; |
| 9 | 7 | ||
| 10 | /** | 8 | /** |
| 11 | * 微信菜单 Service 接口 | 9 | * 微信菜单 Service 接口 |
| 12 | * | 10 | * |
| 13 | * @author 芋道源码 | 11 | * @author 芋道源码 |
| 14 | */ | 12 | */ |
| 15 | -public interface WxMenuService { | 13 | +public interface MpMenuService { |
| 16 | 14 | ||
| 17 | /** | 15 | /** |
| 18 | - * 创建微信菜单 | 16 | + * 保存微信菜单 |
| 19 | * | 17 | * |
| 20 | * @param createReqVO 创建信息 | 18 | * @param createReqVO 创建信息 |
| 21 | * @return 编号 | 19 | * @return 编号 |
| 22 | */ | 20 | */ |
| 23 | - Integer createWxMenu(@Valid WxMenuCreateReqVO createReqVO); | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * 更新微信菜单 | ||
| 27 | - * | ||
| 28 | - * @param updateReqVO 更新信息 | ||
| 29 | - */ | ||
| 30 | - void updateWxMenu(@Valid WxMenuUpdateReqVO updateReqVO); | 21 | + Long saveMenu(@Valid MpMenuSaveReqVO createReqVO); |
| 31 | 22 | ||
| 32 | /** | 23 | /** |
| 33 | * 删除微信菜单 | 24 | * 删除微信菜单 |
| 34 | * | 25 | * |
| 35 | * @param id 编号 | 26 | * @param id 编号 |
| 36 | */ | 27 | */ |
| 37 | - void deleteWxMenu(Integer id); | 28 | + void deleteMenu(Long id); |
| 38 | 29 | ||
| 39 | /** | 30 | /** |
| 40 | * 获得微信菜单 | 31 | * 获得微信菜单 |
| @@ -42,30 +33,6 @@ public interface WxMenuService { | @@ -42,30 +33,6 @@ public interface WxMenuService { | ||
| 42 | * @param id 编号 | 33 | * @param id 编号 |
| 43 | * @return 微信菜单 | 34 | * @return 微信菜单 |
| 44 | */ | 35 | */ |
| 45 | - WxMenuDO getWxMenu(Integer id); | ||
| 46 | - | ||
| 47 | - /** | ||
| 48 | - * 获得微信菜单列表 | ||
| 49 | - * | ||
| 50 | - * @param ids 编号 | ||
| 51 | - * @return 微信菜单列表 | ||
| 52 | - */ | ||
| 53 | - List<WxMenuDO> getWxMenuList(Collection<Integer> ids); | ||
| 54 | - | ||
| 55 | - /** | ||
| 56 | - * 获得微信菜单分页 | ||
| 57 | - * | ||
| 58 | - * @param pageReqVO 分页查询 | ||
| 59 | - * @return 微信菜单分页 | ||
| 60 | - */ | ||
| 61 | - PageResult<WxMenuDO> getWxMenuPage(WxMenuPageReqVO pageReqVO); | ||
| 62 | - | ||
| 63 | - /** | ||
| 64 | - * 获得微信菜单列表, 用于 Excel 导出 | ||
| 65 | - * | ||
| 66 | - * @param exportReqVO 查询条件 | ||
| 67 | - * @return 微信菜单列表 | ||
| 68 | - */ | ||
| 69 | - List<WxMenuDO> getWxMenuList(WxMenuExportReqVO exportReqVO); | 36 | + MpMenuDO getMenu(Long id); |
| 70 | 37 | ||
| 71 | } | 38 | } |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mp.service.menu; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.mp.convert.menu.MpMenuConvert; | ||
| 4 | +import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; | ||
| 5 | +import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; | ||
| 6 | +import me.chanjar.weixin.common.bean.menu.WxMenu; | ||
| 7 | +import me.chanjar.weixin.common.error.WxErrorException; | ||
| 8 | +import me.chanjar.weixin.mp.api.WxMpService; | ||
| 9 | +import org.springframework.context.annotation.Lazy; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | + | ||
| 12 | +import javax.annotation.Resource; | ||
| 13 | + | ||
| 14 | +import org.springframework.validation.annotation.Validated; | ||
| 15 | + | ||
| 16 | +import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; | ||
| 17 | + | ||
| 18 | +import cn.iocoder.yudao.module.mp.dal.mysql.menu.MpMenuMapper; | ||
| 19 | + | ||
| 20 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 21 | +import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * 微信菜单 Service 实现类 | ||
| 25 | + * | ||
| 26 | + * @author 芋道源码 | ||
| 27 | + */ | ||
| 28 | +@Service | ||
| 29 | +@Validated | ||
| 30 | +public class MpMenuServiceImpl implements MpMenuService { | ||
| 31 | + | ||
| 32 | + @Resource | ||
| 33 | + @Lazy // 延迟加载,避免循环引用报错 | ||
| 34 | + private MpServiceFactory mpServiceFactory; | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 37 | + private MpMenuMapper mpMenuMapper; | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public Long saveMenu(MpMenuSaveReqVO createReqVO) { | ||
| 41 | + String appId = "wx5b23ba7a5589ecbb"; | ||
| 42 | + // 插入 | ||
| 43 | + MpMenuDO menu = MpMenuConvert.INSTANCE.convert(createReqVO); | ||
| 44 | +// mpMenuMapper.insert(menu); | ||
| 45 | + | ||
| 46 | + // TODO 同步菜单 | ||
| 47 | + WxMpService mpService = mpServiceFactory.getRequiredMpService(appId); | ||
| 48 | + WxMenu wxMenu = new WxMenu(); | ||
| 49 | + wxMenu.setButtons(createReqVO.getButtons()); | ||
| 50 | + try { | ||
| 51 | + mpService.getMenuService().menuCreate(wxMenu); | ||
| 52 | + } catch (WxErrorException e) { | ||
| 53 | + throw new RuntimeException(e); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + // 返回 | ||
| 57 | + return menu.getId(); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Override | ||
| 61 | + public void deleteMenu(Long id) { | ||
| 62 | + // 校验存在 | ||
| 63 | + validateMenuExists(id); | ||
| 64 | + // 删除 | ||
| 65 | + mpMenuMapper.deleteById(id); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + private void validateMenuExists(Long id) { | ||
| 69 | + if (mpMenuMapper.selectById(id) == null) { | ||
| 70 | + // TODO 芋艿:错误码不太对 | ||
| 71 | + throw exception(COMMON_NOT_EXISTS); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public MpMenuDO getMenu(Long id) { | ||
| 77 | + return mpMenuMapper.selectById(id); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | +} |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/WxMenuServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.mp.service.menu; | ||
| 2 | - | ||
| 3 | -import org.springframework.stereotype.Service; | ||
| 4 | - | ||
| 5 | -import javax.annotation.Resource; | ||
| 6 | - | ||
| 7 | -import org.springframework.validation.annotation.Validated; | ||
| 8 | - | ||
| 9 | -import java.util.*; | ||
| 10 | - | ||
| 11 | -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.*; | ||
| 12 | -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.WxMenuDO; | ||
| 13 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 14 | - | ||
| 15 | -import cn.iocoder.yudao.module.mp.convert.menu.WxMenuConvert; | ||
| 16 | -import cn.iocoder.yudao.module.mp.dal.mysql.menu.WxMenuMapper; | ||
| 17 | - | ||
| 18 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 19 | -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; | ||
| 20 | - | ||
| 21 | -/** | ||
| 22 | - * 微信菜单 Service 实现类 | ||
| 23 | - * | ||
| 24 | - * @author 芋道源码 | ||
| 25 | - */ | ||
| 26 | -@Service | ||
| 27 | -@Validated | ||
| 28 | -public class WxMenuServiceImpl implements WxMenuService { | ||
| 29 | - | ||
| 30 | - @Resource | ||
| 31 | - private WxMenuMapper wxMenuMapper; | ||
| 32 | - | ||
| 33 | - @Override | ||
| 34 | - public Integer createWxMenu(WxMenuCreateReqVO createReqVO) { | ||
| 35 | - // 插入 | ||
| 36 | - WxMenuDO wxMenu = WxMenuConvert.INSTANCE.convert(createReqVO); | ||
| 37 | - wxMenuMapper.insert(wxMenu); | ||
| 38 | - // 返回 | ||
| 39 | - return wxMenu.getId(); | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - @Override | ||
| 43 | - public void updateWxMenu(WxMenuUpdateReqVO updateReqVO) { | ||
| 44 | - // 校验存在 | ||
| 45 | - this.validateWxMenuExists(updateReqVO.getId()); | ||
| 46 | - // 更新 | ||
| 47 | - WxMenuDO updateObj = WxMenuConvert.INSTANCE.convert(updateReqVO); | ||
| 48 | - wxMenuMapper.updateById(updateObj); | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - @Override | ||
| 52 | - public void deleteWxMenu(Integer id) { | ||
| 53 | - // 校验存在 | ||
| 54 | - this.validateWxMenuExists(id); | ||
| 55 | - // 删除 | ||
| 56 | - wxMenuMapper.deleteById(id); | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - private void validateWxMenuExists(Integer id) { | ||
| 60 | - if (wxMenuMapper.selectById(id) == null) { | ||
| 61 | - throw exception(COMMON_NOT_EXISTS); | ||
| 62 | - } | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - @Override | ||
| 66 | - public WxMenuDO getWxMenu(Integer id) { | ||
| 67 | - return wxMenuMapper.selectById(id); | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - @Override | ||
| 71 | - public List<WxMenuDO> getWxMenuList(Collection<Integer> ids) { | ||
| 72 | - return wxMenuMapper.selectBatchIds(ids); | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - @Override | ||
| 76 | - public PageResult<WxMenuDO> getWxMenuPage(WxMenuPageReqVO pageReqVO) { | ||
| 77 | - return wxMenuMapper.selectPage(pageReqVO); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - @Override | ||
| 81 | - public List<WxMenuDO> getWxMenuList(WxMenuExportReqVO exportReqVO) { | ||
| 82 | - return wxMenuMapper.selectList(exportReqVO); | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | -} |