|
@@ -1,102 +0,0 @@
|
|
|
-package cn.com.countrygarden.bi.main.controller;
|
|
|
-
|
|
|
-import cn.com.countrygarden.bi.main.core.Result;
|
|
|
-import cn.com.countrygarden.bi.main.exception.ServiceException;
|
|
|
-import cn.com.countrygarden.bi.main.model.AccessToken;
|
|
|
-import cn.com.countrygarden.bi.main.model.sys.Role;
|
|
|
-import cn.com.countrygarden.bi.main.service.MenuService;
|
|
|
-import cn.com.countrygarden.bi.main.service.RoleService;
|
|
|
-import cn.com.countrygarden.bi.main.service.UserFunctionService;
|
|
|
-import cn.com.countrygarden.bi.main.service.UserRoleService;
|
|
|
-import cn.com.countrygarden.bi.main.service.erp.impl.ExcelArrearageServiceImpl;
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.Date;
|
|
|
-
|
|
|
-/**
|
|
|
- * package: cn.com.countrygarden.bi.main.controller
|
|
|
- * describe:
|
|
|
- * creat_user: lxin
|
|
|
- * creat_date: 2022/8/14
|
|
|
- * creat_time: 21:53
|
|
|
- **/
|
|
|
-@RestController("DomainNameController")
|
|
|
-@RequestMapping("/api/DomainName")//*0*/api/role"
|
|
|
-public class DomainNameController extends BaseController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private MenuService menuService;//*0*
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private UserRoleService userRoleService;//*0*
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private UserFunctionService userFunctionService;//*0*
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private RoleService roleService;//*0*
|
|
|
-
|
|
|
- private final org.slf4j.Logger logger = LoggerFactory.getLogger(ExcelArrearageServiceImpl.class);//*0*好像没用,去掉
|
|
|
-
|
|
|
- @GetMapping(value = "/listRole", produces = "application/json;charset=utf-8")
|
|
|
- public Result list(Role role,
|
|
|
- @RequestParam(value = "size", required = false, defaultValue = "10") int size,
|
|
|
- @RequestParam(value = "page", required = false, defaultValue = "1") int page,
|
|
|
- HttpServletRequest request){
|
|
|
- AccessToken token = this.getAccessToken();
|
|
|
- return roleService.queryRoleInfo(role,token.getUserCode(),page,size);
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(value = "add")
|
|
|
- public Result add(Role role,
|
|
|
- @RequestParam(value = "menusIds", required = true)String menusIds,
|
|
|
- @RequestParam(value = "functionIds", required = true)String functionIds,
|
|
|
- HttpServletRequest request){
|
|
|
- if(StringUtils.isEmpty(role.getCode())){
|
|
|
- throw new ServiceException("接口异常,角色编号不能为空!");
|
|
|
- }
|
|
|
- boolean existFlag=roleService.checkRoleCodeExist(role.getCode());
|
|
|
-// 添加角色
|
|
|
- if(existFlag){
|
|
|
- throw new ServiceException("接口异常,角色编号不能重复");
|
|
|
- }
|
|
|
- AccessToken token = getAccessToken(request);
|
|
|
- roleService.checkIsAdmin(token.getUserCode());
|
|
|
- role.setCreatedBy(token.getUserCode());
|
|
|
- role.setCreatedDate(new Date());
|
|
|
- role.setEnable(true);
|
|
|
- return roleService.addRoleOrMenusAndFunctions(role,menusIds,functionIds);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @GetMapping(value = "/one", produces = "application/json;charset=utf-8")
|
|
|
- public Result queryById(@RequestParam(value = "id", required = true)Integer id,
|
|
|
- HttpServletRequest request){
|
|
|
- return roleService.queryDataById(id);
|
|
|
- }
|
|
|
-
|
|
|
- @PutMapping(value = "/edit")
|
|
|
- public Result edit(Role role,
|
|
|
- @RequestParam(value = "menusIds", required = true)String menusIds,
|
|
|
- @RequestParam(value = "functionIds", required = true)String functionIds,
|
|
|
- HttpServletRequest request){
|
|
|
- AccessToken token = getAccessToken(request);
|
|
|
- roleService.checkIsAdmin(token.getUserCode());
|
|
|
- role.setUpdatedBy(token.getUserCode());
|
|
|
- role.setUpdatedDate(new Date());
|
|
|
- return roleService.edit(role,menusIds,functionIds);
|
|
|
- }
|
|
|
-
|
|
|
- @DeleteMapping(value="/del")
|
|
|
- public Result del(@RequestParam(value = "id", required = true)Integer id){
|
|
|
- AccessToken token = this.getAccessToken();
|
|
|
- roleService.checkIsAdmin(token.getUserCode());
|
|
|
- return roleService.del(id);
|
|
|
- }
|
|
|
-
|
|
|
-}
|