style: 添加测试ELFK日志

This commit is contained in:
有来技术 2021-08-30 01:15:27 +08:00
parent 33126d1f04
commit 3fa265de01
4 changed files with 13 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -28,6 +29,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/api/v1/menus") @RequestMapping("/api/v1/menus")
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j
public class MenuController { public class MenuController {
private final ISysMenuService menuService; private final ISysMenuService menuService;
@ -52,6 +54,7 @@ public class MenuController {
@ApiOperation(value = "菜单路由Route层级列表") @ApiOperation(value = "菜单路由Route层级列表")
@GetMapping("/route") @GetMapping("/route")
public Result getMenuRouteList() { public Result getMenuRouteList() {
log.info("加载菜单路由");
List<RouteVO> menuList = menuService.listRoute(); List<RouteVO> menuList = menuService.listRoute();
return Result.success(menuList); return Result.success(menuList);
} }

View File

@ -1,6 +1,7 @@
package com.youlai.admin.controller; package com.youlai.admin.controller;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -130,6 +131,8 @@ public class UserController {
@ApiOperation(value = "获取当前登陆的用户信息") @ApiOperation(value = "获取当前登陆的用户信息")
@GetMapping("/me") @GetMapping("/me")
public Result<UserVO> getCurrentUser() { public Result<UserVO> getCurrentUser() {
UserVO userVO = new UserVO(); UserVO userVO = new UserVO();
// 用户基本信息 // 用户基本信息
@ -145,6 +148,8 @@ public class UserController {
List<String> perms = iSysPermissionService.listBtnPermByRoles(roles); List<String> perms = iSysPermissionService.listBtnPermByRoles(roles);
userVO.setPerms(perms); userVO.setPerms(perms);
log.info("获取当前登陆的用户信息:{}", JSONUtil.toJsonStr(userVO));
return Result.success(userVO); return Result.success(userVO);
} }
} }

View File

@ -1,6 +1,7 @@
package com.youlai.auth.controller; package com.youlai.auth.controller;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.nimbusds.jose.jwk.JWKSet; import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.RSAKey; import com.nimbusds.jose.jwk.RSAKey;
import com.youlai.auth.common.enums.OAuthClientEnum; import com.youlai.auth.common.enums.OAuthClientEnum;
@ -21,6 +22,7 @@ import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint;
import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.security.KeyPair; import java.security.KeyPair;
import java.security.Principal; import java.security.Principal;
import java.security.interfaces.RSAPublicKey; import java.security.interfaces.RSAPublicKey;
@ -62,6 +64,7 @@ public class OAuthController {
* 方式二放在请求头Request Headers中的Authorization字段且经过加密例如 Basic Y2xpZW50OnNlY3JldA== 明文等于 client:secret * 方式二放在请求头Request Headers中的Authorization字段且经过加密例如 Basic Y2xpZW50OnNlY3JldA== 明文等于 client:secret
*/ */
String clientId = JwtUtils.getOAuthClientId(); String clientId = JwtUtils.getOAuthClientId();
log.info("OAuth认证授权 客户端ID:{},请求参数:{}", clientId, JSONUtil.toJsonStr(parameters));
OAuthClientEnum client = OAuthClientEnum.getByClientId(clientId); OAuthClientEnum client = OAuthClientEnum.getByClientId(clientId);
switch (client) { switch (client) {
case TEST: // knife4j接口测试文档使用 client_id/client_secret : client/123456 case TEST: // knife4j接口测试文档使用 client_id/client_secret : client/123456
@ -72,7 +75,7 @@ public class OAuthController {
} }
@ApiOperation(value = "微信授权登录") @ApiOperation(value = "微信授权登录")
@ApiImplicitParam(name = "code", value = "小程序授权code",paramType = "path") @ApiImplicitParam(name = "code", value = "小程序授权code", paramType = "path")
@PostMapping("/token/{code}") @PostMapping("/token/{code}")
public Result wechatLogin(@PathVariable String code, @RequestBody UserInfo userInfo) { public Result wechatLogin(@PathVariable String code, @RequestBody UserInfo userInfo) {
OAuthToken token = wechatAuthService.login(code, userInfo); OAuthToken token = wechatAuthService.login(code, userInfo);

View File

@ -52,6 +52,7 @@ public class SecurityGlobalFilter implements GlobalFilter, Ordered {
if (env.equals("prod") if (env.equals("prod")
&& (HttpMethod.DELETE.toString().equals(request.getMethodValue()) // 删除方法 && (HttpMethod.DELETE.toString().equals(request.getMethodValue()) // 删除方法
|| HttpMethod.PUT.toString().equals(request.getMethodValue())) // 修改方法 || HttpMethod.PUT.toString().equals(request.getMethodValue())) // 修改方法
|| HttpMethod.POST.toString().equals(request.getMethodValue()) // 新增方法新增不存在的路由导致系统无法访问
) { ) {
return ResponseUtils.writeErrorInfo(response, ResultCode.FORBIDDEN_OPERATION); return ResponseUtils.writeErrorInfo(response, ResultCode.FORBIDDEN_OPERATION);
} }