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