管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-03 9bce48a9f30f7d80c43f43f46d40df20fcb00e15
src/main/java/com/lf/server/controller/all/PermsController.java
@@ -1,19 +1,26 @@
package com.lf.server.controller.all;
import com.lf.server.aspect.SysLog;
import com.lf.server.annotation.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.entity.data.DirEntity;
import com.lf.server.entity.sys.MenuEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.StringHelper;
import com.lf.server.service.all.PermsService;
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.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -29,6 +36,9 @@
    @Autowired
    TokenService tokenService;
    @Autowired
    MenuService menuService;
    @SysLog()
    @ApiOperation(value = "查询当前用户的资源授权")
@@ -104,8 +114,8 @@
    @SysLog()
    @ApiOperation(value = "清空所有授权缓存")
    @GetMapping(value = "/clearAllCache")
    public ResponseMsg<Boolean> clearAllCache() {
    @GetMapping(value = "/deleteAllCache")
    public ResponseMsg<Boolean> deleteAllCache() {
        try {
            permsService.clearAllCache();
@@ -114,4 +124,43 @@
            return fail(ex.getMessage(), 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.getMessage(), 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);
            }
            List<MenuEntity> list = permsService.selectMenuRecursive(id, ue.getUid());
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
}