mp:menu 菜单的修改,移除多余的类
parent
69e653cd94
commit
47f071560f
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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,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