1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package com.fdkankan.manage.controller;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.fdkankan.manage.common.ResultCode;
- import com.fdkankan.manage.config.MenuInit;
- import com.fdkankan.manage.exception.BusinessException;
- import com.fdkankan.manage.vo.request.RequestBase;
- import com.fdkankan.manage.common.ResultData;
- import com.fdkankan.common.util.DateUtil;
- import com.fdkankan.manage.entity.SysMenu;
- import com.fdkankan.manage.service.ISysMenuService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.util.StringUtils;
- import org.springframework.web.bind.annotation.*;
- import java.util.Date;
- import java.util.List;
- /**
- * 系统菜单
- */
- @RestController
- @RequestMapping("/service/manage/sysMenu")
- public class SysMenuController extends BaseController{
- @Autowired
- ISysMenuService menuService;
- @Autowired
- MenuInit menuInit;
- @PostMapping("/add")
- public ResultData add(@RequestBody SysMenu param){
- param.setUpdateTime(DateUtil.date2String(new Date(),DateUtil.DEFAULT_DATE_FORMAT));
- menuService.saveOrUpdate(param);
- menuInit.initMenu();
- return ResultData.ok();
- }
- @PostMapping("/update")
- public ResultData update(@RequestBody SysMenu param){
- if(StringUtils.isEmpty(param.getId())){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- param.setUpdateTime(DateUtil.date2String(new Date(),DateUtil.DEFAULT_DATE_FORMAT));
- menuService.saveOrUpdate(param);
- menuInit.initMenu();
- return ResultData.ok();
- }
- @PostMapping("/delete")
- public ResultData delete(@RequestBody SysMenu param){
- LambdaQueryWrapper<SysMenu> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(SysMenu::getParentId,param.getId());
- menuService.remove(wrapper);
- menuService.removeById(param.getId());
- menuInit.initMenu();
- return ResultData.ok();
- }
- @PostMapping("/list")
- public ResultData list(@RequestBody RequestBase param){
- return ResultData.ok(menuService.pageList(param));
- }
- @PostMapping("/allShowList")
- public ResultData allShowList(){
- return ResultData.ok(menuService.allShowList());
- }
- @GetMapping("/getByUserId")
- public ResultData getByUserId(){
- return ResultData.ok(menuService.getByUserId(getUserId()));
- }
- @GetMapping("/getButtonByUserId")
- public ResultData getButtonByUserId(){
- return ResultData.ok(menuService.getButtonByUserId(getUserId()));
- }
- @GetMapping("/getByRoleId")
- public ResultData getByRoleId(@RequestParam(required = false) Long roleId){
- return ResultData.ok(menuService.getByRoleId(null,roleId));
- }
- @GetMapping("/getMenuIdsByRoleId")
- public ResultData getMenuIdsByRoleId(@RequestParam(required = false) Long roleId){
- return ResultData.ok(menuService.getMenuIdsByRoleId(roleId));
- }
- }
|