From 1d53dd8f501a98ddcce8146443b51b357ef5f9b1 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 29 十二月 2022 16:55:46 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/all/PermsController.java | 93 +++++++++++++++++++++++++++++++++------------- 1 files changed, 66 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/lf/server/controller/all/PermsController.java b/src/main/java/com/lf/server/controller/all/PermsController.java index defdde7..f4cb903 100644 --- a/src/main/java/com/lf/server/controller/all/PermsController.java +++ b/src/main/java/com/lf/server/controller/all/PermsController.java @@ -1,18 +1,20 @@ 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.sys.UserEntity; import com.lf.server.service.all.PermsService; +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; /** @@ -26,15 +28,20 @@ @Autowired PermsService permsService; + @Autowired + TokenService tokenService; + @SysLog() - @ApiOperation(value = "鏍规嵁鐢ㄦ埛Uid鏌ヨ璧勬簮鎺堟潈") - @ApiImplicitParams({ - @ApiImplicitParam(name = "uid", value = "鐢ㄦ埛Uid", dataType = "String", paramType = "query", example = "admin") - }) + @ApiOperation(value = "鏌ヨ褰撳墠鐢ㄦ埛鐨勮祫婧愭巿鏉�") @GetMapping(value = "/selectRes") - public ResponseMsg<List<ResAuthEntity>> selectRes(String uid) { + public ResponseMsg<List<ResAuthEntity>> selectRes(HttpServletRequest req) { try { - List<ResAuthEntity> rs = permsService.selectRes(uid); + UserEntity ue = tokenService.getCurrentUser(req); + if (ue == null) { + return fail("鐢ㄦ埛鏈櫥褰�", null); + } + + List<ResAuthEntity> rs = permsService.selectRes(ue.getUid()); return success(rs); } catch (Exception ex) { @@ -43,14 +50,16 @@ } @SysLog() - @ApiOperation(value = "鏍规嵁鐢ㄦ埛Uid鏌ヨ鑿滃崟鎺堟潈") - @ApiImplicitParams({ - @ApiImplicitParam(name = "uid", value = "鐢ㄦ埛Uid", dataType = "String", paramType = "query", example = "admin") - }) + @ApiOperation(value = "鏌ヨ褰撳墠鐢ㄦ埛鐨勮彍鍗曟巿鏉�") @GetMapping(value = "/selectMenus") - public ResponseMsg<List<MenusAuthEntity>> selectMenus(String uid) { + public ResponseMsg<List<MenusAuthEntity>> selectMenus(HttpServletRequest req) { try { - List<MenusAuthEntity> rs = permsService.selectMenus(uid); + UserEntity ue = tokenService.getCurrentUser(req); + if (ue == null) { + return fail("鐢ㄦ埛鏈櫥褰�", null); + } + + List<MenusAuthEntity> rs = permsService.selectMenus(ue.getUid()); return success(rs); } catch (Exception ex) { @@ -59,14 +68,16 @@ } @SysLog() - @ApiOperation(value = "鏍规嵁鐢ㄦ埛Uid鏌ヨ鏉冮檺鎺堟潈") - @ApiImplicitParams({ - @ApiImplicitParam(name = "uid", value = "鐢ㄦ埛Uid", dataType = "String", paramType = "query", example = "admin") - }) + @ApiOperation(value = "鏌ヨ褰撳墠鐢ㄦ埛鐨勬潈闄愭巿鏉�") @GetMapping(value = "/selectPerms") - public ResponseMsg<List<String>> selectPerms(String uid) { + public ResponseMsg<List<String>> selectPerms(HttpServletRequest req) { try { - List<String> rs = permsService.selectPerms(uid); + UserEntity ue = tokenService.getCurrentUser(req); + if (ue == null) { + return fail("鐢ㄦ埛鏈櫥褰�", null); + } + + List<String> rs = permsService.selectPerms(ue.getUid()); return success(rs); } catch (Exception ex) { @@ -75,18 +86,46 @@ } @SysLog() - @ApiOperation(value = "鏍规嵁鐢ㄦ埛Uid鏌ヨ鏉冮檺鎺堟潈瀹炰綋闆嗗悎") - @ApiImplicitParams({ - @ApiImplicitParam(name = "uid", value = "鐢ㄦ埛Uid", dataType = "String", paramType = "query", example = "admin") - }) + @ApiOperation(value = "鏌ヨ褰撳墠鐢ㄦ埛鐨勬潈闄愭巿鏉冨疄浣撻泦鍚�") @GetMapping(value = "/selectPermsEntity") - public ResponseMsg<List<PermsAuthEntity>> selectPermsEntity(String uid) { + public ResponseMsg<List<PermsAuthEntity>> selectPermsEntity(HttpServletRequest req) { try { - List<PermsAuthEntity> rs = permsService.selectPermsEntity(uid); + UserEntity ue = tokenService.getCurrentUser(req); + if (ue == null) { + return fail("鐢ㄦ埛鏈櫥褰�", null); + } + + List<PermsAuthEntity> rs = permsService.selectPermsEntity(ue.getUid()); return success(rs); } catch (Exception ex) { return fail(ex.getMessage(), null); } } + + @SysLog() + @ApiOperation(value = "娓呯┖鎵�鏈夋巿鏉冪紦瀛�") + @GetMapping(value = "/deleteAllCache") + public ResponseMsg<Boolean> deleteAllCache() { + try { + permsService.clearAllCache(); + + return success(true); + } catch (Exception ex) { + return fail(ex.getMessage(), false); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ鐢ㄦ埛瑙掕壊") + @GetMapping("/selectRoles") + public ResponseMsg<Object> selectRoles(HttpServletRequest req, HttpServletResponse res) { + try { + // + + return success(null); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } } -- Gitblit v1.9.3