管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-04-19 7d824c1e0b6fdd5ddb5d2cd783839895c416c75a
src/main/java/com/lf/server/controller/all/PermsController.java
@@ -1,14 +1,17 @@
package com.lf.server.controller.all;
import com.lf.server.aspect.SysLog;
import com.lf.server.entity.all.MenusAuthEntity;
import com.lf.server.entity.all.PermsAuthEntity;
import com.lf.server.entity.all.ResAuthEntity;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.annotation.SysLog;
import com.lf.server.entity.all.*;
import com.lf.server.entity.data.LayerEntity;
import com.lf.server.entity.sys.MenuEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.service.all.PermsService;
import com.lf.server.service.data.LayerService;
import com.lf.server.service.sys.MenuService;
import com.lf.server.service.sys.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -30,6 +33,12 @@
    @Autowired
    TokenService tokenService;
    @Autowired
    MenuService menuService;
    @Autowired
    LayerService layerService;
    @SysLog()
    @ApiOperation(value = "查询当前用户的资源授权")
    @GetMapping(value = "/selectRes")
@@ -40,11 +49,12 @@
                return fail("用户未登录", null);
            }
            List<ResAuthEntity> rs = permsService.selectRes(ue.getUid());
            String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid();
            List<ResAuthEntity> rs = permsService.selectRes(uid);
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -58,11 +68,12 @@
                return fail("用户未登录", null);
            }
            List<MenusAuthEntity> rs = permsService.selectMenus(ue.getUid());
            String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid();
            List<MenusAuthEntity> rs = permsService.selectMenus(uid);
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -76,11 +87,12 @@
                return fail("用户未登录", null);
            }
            List<String> rs = permsService.selectPerms(ue.getUid());
            String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid();
            List<String> rs = permsService.selectPerms(uid);
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -94,11 +106,12 @@
                return fail("用户未登录", null);
            }
            List<PermsAuthEntity> rs = permsService.selectPermsEntity(ue.getUid());
            String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid();
            List<PermsAuthEntity> rs = permsService.selectPermsEntity(uid);
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -111,7 +124,65 @@
            return success(true);
        } catch (Exception ex) {
            return fail(ex.getMessage(), false);
            return fail(ex, false);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询用户角色")
    @GetMapping("/selectRoles")
    public ResponseMsg<Object> selectRoles(HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
            List<Integer> list = permsService.selectRoles(ue.getUid());
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "递归查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "菜单ID", dataType = "Integer", paramType = "query", example = "14")
    })
    @GetMapping(value = "/selectMenuRecursive")
    public ResponseMsg<Object> selectMenuRecursive(int id, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
            String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid();
            List<MenuEntity> list = permsService.selectMenuRecursive(id, uid);
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询所有图层")
    @GetMapping(value = "/selectLayers")
    public ResponseMsg<Object> selectLayers(HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
            List<LayerEntity> list = layerService.selectAll();
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
}