package com.moral.api.controller;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.moral.api.entity.Menu;
|
import com.moral.api.service.GroupMenuService;
|
import com.moral.api.service.MenuService;
|
import com.moral.constant.ResponseCodeEnum;
|
import com.moral.constant.ResultMessage;
|
import com.moral.util.TokenUtils;
|
|
@Slf4j
|
@Api(tags = {"菜单管理"})
|
@RestController
|
@RequestMapping("/menu")
|
public class MenuController {
|
|
@Autowired
|
private GroupMenuService groupMenuService;
|
|
@Autowired
|
private MenuService menuService;
|
|
@ApiOperation(value = "组分配菜单", notes = "组分配菜单")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
|
})
|
@RequestMapping(value = "allot", method = RequestMethod.POST)
|
public ResultMessage allot(@RequestBody Map<String, Object> parameters) {
|
if (!parameters.containsKey("groupId")) {
|
return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
|
ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
|
}
|
groupMenuService.allotMenus(parameters);
|
return ResultMessage.ok();
|
}
|
|
@ApiOperation(value = "菜单列表", notes = "菜单列表")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
|
})
|
@RequestMapping(value = "menu-list", method = RequestMethod.POST)
|
public ResultMessage selectMenus() {
|
Map<String, Object> currentUserInfo = (Map<String, Object>)TokenUtils.getUserInfo();
|
Map<String, Object> orgInfo = (Map<String, Object>) currentUserInfo.get("organization");
|
List<Menu> menus = menuService.getMenuList((Integer) orgInfo.get("id"));
|
return ResultMessage.ok(menus);
|
}
|
|
@ApiOperation(value = "层级菜单", notes = "层级菜单")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
|
})
|
@RequestMapping(value = "select", method = RequestMethod.GET)
|
public ResultMessage select() {
|
Map<String, Object> currentUserInfo = (Map<String, Object>)TokenUtils.getUserInfo();
|
Map<String, Object> orgInfo = (Map<String, Object>) currentUserInfo.get("organization");
|
Map<String, Object> result = menuService.selectMenusByOrgId((Integer) orgInfo.get("id"));
|
return ResultMessage.ok(result);
|
}
|
|
@ApiOperation(value = "获取组菜单ids", notes = "获取组菜单ids")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
|
})
|
@RequestMapping(value = "getMenuIds", method = RequestMethod.GET)
|
public ResultMessage getMenuIds(Integer groupId) {
|
List<Integer> menusIds = groupMenuService.getMenusIds(groupId);
|
return ResultMessage.ok(menusIds);
|
}
|
}
|