fase()尝试elk

dev-2
王熙朝 2024-05-20 22:23:37 +08:00
parent 596dd3544f
commit eb686da73e
25 changed files with 223 additions and 49 deletions

View File

@ -136,6 +136,12 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>7.3</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -78,6 +78,22 @@
<artifactId>muyu-common-swagger</artifactId> <artifactId>muyu-common-swagger</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<!--集成logstash-->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -0,0 +1,56 @@
package com.muyu.system.DCL;
import org.slf4j.MDC;
import java.util.UUID;
public class MDCTraceUtil {
/**
* id
*/
public static final String KEY_TRACE_ID = "traceId";
/**
* id
*/
public static final String TRACE_ID_HEADER = "x-traceId-header";
/**
* traceIdMDC
*/
public static void addTrace() {
String traceId = createTraceId();
// MDC(Mapped Diagnostic Context)诊断上下文映射,是@Slf4j提供的一个支持动态打印日志信息的工具。
MDC.put(KEY_TRACE_ID, traceId);
}
/**
* MDC
*/
public static void putTrace(String traceId) {
MDC.put(KEY_TRACE_ID, traceId);
}
/**
* MDCtraceId
*/
public static String getTraceId() {
return MDC.get(KEY_TRACE_ID);
}
/**
* MDC
*/
public static void removeTrace() {
MDC.remove(KEY_TRACE_ID);
}
/**
* traceId
*/
public static String createTraceId() {
return UUID.randomUUID().toString().replace("-", "");
}
}

View File

@ -5,6 +5,7 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2; import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RestController;
/** /**
* *

View File

@ -0,0 +1,26 @@
package com.muyu.system.config;
import com.muyu.system.interceptor.LogInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class LogWebMvcConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 添加拦截器
registry.addInterceptor(mvcInterceptor())
// 拦截所有请求的路径
.addPathPatterns("/**");
}
@Bean
public LogInterceptor mvcInterceptor() {
return new LogInterceptor();
}
}

View File

@ -50,7 +50,6 @@ public class AccreditController extends BaseController {
* *
* @return * @return
*/ */
@GetMapping("/tableNameList2")
public Result<List<String>> tableNameList2() throws SQLException { public Result<List<String>> tableNameList2() throws SQLException {
List<String> list = service.tableNameList2(); List<String> list = service.tableNameList2();
return Result.success(list); return Result.success(list);
@ -62,7 +61,6 @@ public class AccreditController extends BaseController {
* @return * @return
* @throws SQLException * @throws SQLException
*/ */
@GetMapping("/listSqlJdbc")
public Result listSqlJdbc(@RequestBody Connection connection, String tableName) throws SQLException { public Result listSqlJdbc(@RequestBody Connection connection, String tableName) throws SQLException {
return service.listSqlJdbc(connection, tableName); return service.listSqlJdbc(connection, tableName);
} }
@ -111,7 +109,6 @@ public class AccreditController extends BaseController {
* *
* @return * @return
*/ */
@GetMapping("/listDeptVo")
public Result list() { public Result list() {
List<DeptVO> depts = deptService.selectDeptListVo(); List<DeptVO> depts = deptService.selectDeptListVo();
return success(depts); return success(depts);
@ -122,7 +119,6 @@ public class AccreditController extends BaseController {
* *
* @return * @return
*/ */
@GetMapping("/listSelectSysUser")
public Result<List<SysUserVo>> listSelectSysUser() { public Result<List<SysUserVo>> listSelectSysUser() {
List<SysUserVo> list = userService.listSelectSysUser(); List<SysUserVo> list = userService.listSelectSysUser();
return success(list); return success(list);

View File

@ -33,7 +33,6 @@ public class AssetModelController extends BaseController {
* *
*/ */
@RequiresPermissions("system:model:list") @RequiresPermissions("system:model:list")
@GetMapping("/list")
public Result<TableDataInfo<AssetModel>> list(AssetModel assetModel) { public Result<TableDataInfo<AssetModel>> list(AssetModel assetModel) {
startPage(); startPage();
List<AssetModel> list = assetModelService.selectAssetModelList(assetModel); List<AssetModel> list = assetModelService.selectAssetModelList(assetModel);
@ -56,7 +55,6 @@ public class AssetModelController extends BaseController {
* *
*/ */
@RequiresPermissions("system:model:query") @RequiresPermissions("system:model:query")
@GetMapping(value = "/{annotation}")
public Result getInfo(@PathVariable("annotation") String annotation) { public Result getInfo(@PathVariable("annotation") String annotation) {
return success(assetModelService.selectAssetModelByAnnotation(annotation)); return success(assetModelService.selectAssetModelByAnnotation(annotation));
} }
@ -96,7 +94,6 @@ public class AssetModelController extends BaseController {
* *
* @return * @return
*/ */
@GetMapping("library")
public Result<List<Library>> library() { public Result<List<Library>> library() {
List<Library> list = assetModelService.library(); List<Library> list = assetModelService.library();
return Result.success(list); return Result.success(list);
@ -108,7 +105,6 @@ public class AssetModelController extends BaseController {
* @param libraryName * @param libraryName
* @return * @return
*/ */
@GetMapping("selectTable/{libraryName}")
public Result<List<TableVo>> selectTable(@PathVariable String libraryName) { public Result<List<TableVo>> selectTable(@PathVariable String libraryName) {
List<TableVo> list = assetModelService.selectTable(libraryName); List<TableVo> list = assetModelService.selectTable(libraryName);
return Result.success(list); return Result.success(list);

View File

@ -32,7 +32,6 @@ public class DataAccessController extends BaseController {
* *
*/ */
@RequiresPermissions("system:access:list") @RequiresPermissions("system:access:list")
@GetMapping("/list")
public Result<TableDataInfo<DataAccess>> list(DataAccess dataAccess) { public Result<TableDataInfo<DataAccess>> list(DataAccess dataAccess) {
startPage(); startPage();
List<DataAccess> list = dataAccessService.selectDataAccessList(dataAccess); List<DataAccess> list = dataAccessService.selectDataAccessList(dataAccess);
@ -60,7 +59,6 @@ public class DataAccessController extends BaseController {
* *
*/ */
@RequiresPermissions("system:access:query") @RequiresPermissions("system:access:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) { public Result getInfo(@PathVariable("id") Long id) {
return success(dataAccessService.selectDataAccessById(id)); return success(dataAccessService.selectDataAccessById(id));
} }

View File

@ -34,7 +34,6 @@ public class SysConfigController extends BaseController {
* *
*/ */
@RequiresPermissions("system:config:list") @RequiresPermissions("system:config:list")
@GetMapping("/list")
public Result<TableDataInfo<SysConfig>> list(SysConfig config) { public Result<TableDataInfo<SysConfig>> list(SysConfig config) {
startPage(); startPage();
List<SysConfig> list = configService.pageQuery(config); List<SysConfig> list = configService.pageQuery(config);
@ -53,7 +52,6 @@ public class SysConfigController extends BaseController {
/** /**
* *
*/ */
@GetMapping(value = "/{configId}")
public Result getInfo(@PathVariable Long configId) { public Result getInfo(@PathVariable Long configId) {
return success(configService.getById(configId)); return success(configService.getById(configId));
} }
@ -61,7 +59,6 @@ public class SysConfigController extends BaseController {
/** /**
* *
*/ */
@GetMapping(value = "/configKey/{configKey}")
public Result getConfigKey(@PathVariable String configKey) { public Result getConfigKey(@PathVariable String configKey) {
return success(configService.selectConfigByKey(configKey)); return success(configService.selectConfigByKey(configKey));
} }

View File

@ -33,7 +33,6 @@ public class SysDeptController extends BaseController {
* *
*/ */
@RequiresPermissions("system:dept:list") @RequiresPermissions("system:dept:list")
@GetMapping("/list")
public Result list(SysDept dept) { public Result list(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept); List<SysDept> depts = deptService.selectDeptList(dept);
return success(depts); return success(depts);
@ -43,7 +42,6 @@ public class SysDeptController extends BaseController {
* *
*/ */
@RequiresPermissions("system:dept:list") @RequiresPermissions("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public Result excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) { public Result excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept()); List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
@ -54,7 +52,6 @@ public class SysDeptController extends BaseController {
* *
*/ */
@RequiresPermissions("system:dept:query") @RequiresPermissions("system:dept:query")
@GetMapping(value = "/{deptId}")
public Result getInfo(@PathVariable Long deptId) { public Result getInfo(@PathVariable Long deptId) {
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
return success(deptService.selectDeptById(deptId)); return success(deptService.selectDeptById(deptId));

View File

@ -35,7 +35,6 @@ public class SysDictDataController extends BaseController {
private SysDictTypeService dictTypeService; private SysDictTypeService dictTypeService;
@RequiresPermissions("system:dict:list") @RequiresPermissions("system:dict:list")
@GetMapping("/list")
public Result<TableDataInfo<SysDictData>> list(SysDictData dictData) { public Result<TableDataInfo<SysDictData>> list(SysDictData dictData) {
startPage(); startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData); List<SysDictData> list = dictDataService.selectDictDataList(dictData);
@ -55,7 +54,6 @@ public class SysDictDataController extends BaseController {
* *
*/ */
@RequiresPermissions("system:dict:query") @RequiresPermissions("system:dict:query")
@GetMapping(value = "/{dictCode}")
public Result getInfo(@PathVariable Long dictCode) { public Result getInfo(@PathVariable Long dictCode) {
return success(dictDataService.selectDictDataById(dictCode)); return success(dictDataService.selectDictDataById(dictCode));
} }
@ -63,7 +61,6 @@ public class SysDictDataController extends BaseController {
/** /**
* *
*/ */
@GetMapping(value = "/type/{dictType}")
public Result dictType(@PathVariable String dictType) { public Result dictType(@PathVariable String dictType) {
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data)) { if (StringUtils.isNull(data)) {

View File

@ -29,7 +29,6 @@ public class SysDictTypeController extends BaseController {
private SysDictTypeService dictTypeService; private SysDictTypeService dictTypeService;
@RequiresPermissions("system:dict:list") @RequiresPermissions("system:dict:list")
@GetMapping("/list")
public Result<TableDataInfo<SysDictType>> list(SysDictType dictType) { public Result<TableDataInfo<SysDictType>> list(SysDictType dictType) {
startPage(); startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
@ -49,7 +48,6 @@ public class SysDictTypeController extends BaseController {
* *
*/ */
@RequiresPermissions("system:dict:query") @RequiresPermissions("system:dict:query")
@GetMapping(value = "/{dictId}")
public Result getInfo(@PathVariable Long dictId) { public Result getInfo(@PathVariable Long dictId) {
return success(dictTypeService.selectDictTypeById(dictId)); return success(dictTypeService.selectDictTypeById(dictId));
} }
@ -107,7 +105,6 @@ public class SysDictTypeController extends BaseController {
/** /**
* *
*/ */
@GetMapping("/optionselect")
public Result optionselect() { public Result optionselect() {
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll(); List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return success(dictTypes); return success(dictTypes);

View File

@ -33,7 +33,6 @@ public class SysLogininforController extends BaseController {
private RedisService redisService; private RedisService redisService;
@RequiresPermissions("system:logininfor:list") @RequiresPermissions("system:logininfor:list")
@GetMapping("/list")
public Result<TableDataInfo<SysLogininfor>> list(SysLogininfor logininfor) { public Result<TableDataInfo<SysLogininfor>> list(SysLogininfor logininfor) {
startPage(); startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
@ -66,7 +65,6 @@ public class SysLogininforController extends BaseController {
@RequiresPermissions("system:logininfor:unlock") @RequiresPermissions("system:logininfor:unlock")
@Log(title = "账户解锁", businessType = BusinessType.OTHER) @Log(title = "账户解锁", businessType = BusinessType.OTHER)
@GetMapping("/unlock/{userName}")
public Result unlock(@PathVariable("userName") String userName) { public Result unlock(@PathVariable("userName") String userName) {
redisService.deleteObject(CacheConstants.PWD_ERR_CNT_KEY + userName); redisService.deleteObject(CacheConstants.PWD_ERR_CNT_KEY + userName);
return success(); return success();

View File

@ -32,7 +32,6 @@ public class SysMenuController extends BaseController {
* *
*/ */
@RequiresPermissions("system:menu:list") @RequiresPermissions("system:menu:list")
@GetMapping("/list")
public Result list(SysMenu menu) { public Result list(SysMenu menu) {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuList(menu, userId); List<SysMenu> menus = menuService.selectMenuList(menu, userId);
@ -43,7 +42,6 @@ public class SysMenuController extends BaseController {
* *
*/ */
@RequiresPermissions("system:menu:query") @RequiresPermissions("system:menu:query")
@GetMapping(value = "/{menuId}")
public Result getInfo(@PathVariable Long menuId) { public Result getInfo(@PathVariable Long menuId) {
return success(menuService.selectMenuById(menuId)); return success(menuService.selectMenuById(menuId));
} }
@ -51,7 +49,6 @@ public class SysMenuController extends BaseController {
/** /**
* *
*/ */
@GetMapping("/treeselect")
public Result treeselect(SysMenu menu) { public Result treeselect(SysMenu menu) {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuList(menu, userId); List<SysMenu> menus = menuService.selectMenuList(menu, userId);
@ -61,7 +58,6 @@ public class SysMenuController extends BaseController {
/** /**
* *
*/ */
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public Result roleMenuTreeselect(@PathVariable("roleId") Long roleId) { public Result roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuList(userId); List<SysMenu> menus = menuService.selectMenuList(userId);
@ -128,7 +124,6 @@ public class SysMenuController extends BaseController {
* *
* @return * @return
*/ */
@GetMapping("getRouters")
public Result getRouters() { public Result getRouters() {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);

View File

@ -30,7 +30,6 @@ public class SysNoticeController extends BaseController {
* *
*/ */
@RequiresPermissions("system:notice:list") @RequiresPermissions("system:notice:list")
@GetMapping("/list")
public Result<TableDataInfo<SysNotice>> list(SysNotice notice) { public Result<TableDataInfo<SysNotice>> list(SysNotice notice) {
startPage(); startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice); List<SysNotice> list = noticeService.selectNoticeList(notice);
@ -41,7 +40,6 @@ public class SysNoticeController extends BaseController {
* *
*/ */
@RequiresPermissions("system:notice:query") @RequiresPermissions("system:notice:query")
@GetMapping(value = "/{noticeId}")
public Result getInfo(@PathVariable Long noticeId) { public Result getInfo(@PathVariable Long noticeId) {
return success(noticeService.selectNoticeById(noticeId)); return success(noticeService.selectNoticeById(noticeId));
} }

View File

@ -28,7 +28,6 @@ public class SysOperlogController extends BaseController {
private SysOperLogService operLogService; private SysOperLogService operLogService;
@RequiresPermissions("system:operlog:list") @RequiresPermissions("system:operlog:list")
@GetMapping("/list")
public Result<TableDataInfo<SysOperLog>> list(SysOperLog operLog) { public Result<TableDataInfo<SysOperLog>> list(SysOperLog operLog) {
startPage(); startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog); List<SysOperLog> list = operLogService.selectOperLogList(operLog);

View File

@ -32,7 +32,6 @@ public class SysPostController extends BaseController {
* *
*/ */
@RequiresPermissions("system:post:list") @RequiresPermissions("system:post:list")
@GetMapping("/list")
public Result<TableDataInfo<SysPost>> list(SysPost post) { public Result<TableDataInfo<SysPost>> list(SysPost post) {
startPage(); startPage();
List<SysPost> list = postService.selectPostList(post); List<SysPost> list = postService.selectPostList(post);
@ -52,7 +51,6 @@ public class SysPostController extends BaseController {
* *
*/ */
@RequiresPermissions("system:post:query") @RequiresPermissions("system:post:query")
@GetMapping(value = "/{postId}")
public Result getInfo(@PathVariable Long postId) { public Result getInfo(@PathVariable Long postId) {
return success(postService.selectPostById(postId)); return success(postService.selectPostById(postId));
} }
@ -102,7 +100,6 @@ public class SysPostController extends BaseController {
/** /**
* *
*/ */
@GetMapping("/optionselect")
public Result optionselect() { public Result optionselect() {
List<SysPost> posts = postService.selectPostAll(); List<SysPost> posts = postService.selectPostAll();
return success(posts); return success(posts);

View File

@ -41,7 +41,6 @@ public class SysProfileController extends BaseController {
/** /**
* *
*/ */
@GetMapping
public Result profile() { public Result profile() {
String username = SecurityUtils.getUsername(); String username = SecurityUtils.getUsername();
SysUser user = userService.selectUserByUserName(username); SysUser user = userService.selectUserByUserName(username);

View File

@ -41,7 +41,6 @@ public class SysRoleController extends BaseController {
private SysDeptService deptService; private SysDeptService deptService;
@RequiresPermissions("system:role:list") @RequiresPermissions("system:role:list")
@GetMapping("/list")
public Result<TableDataInfo<SysRole>> list(SysRole role) { public Result<TableDataInfo<SysRole>> list(SysRole role) {
startPage(); startPage();
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> list = roleService.selectRoleList(role);
@ -61,7 +60,6 @@ public class SysRoleController extends BaseController {
* *
*/ */
@RequiresPermissions("system:role:query") @RequiresPermissions("system:role:query")
@GetMapping(value = "/{roleId}")
public Result getInfo(@PathVariable Long roleId) { public Result getInfo(@PathVariable Long roleId) {
roleService.checkRoleDataScope(roleId); roleService.checkRoleDataScope(roleId);
return success(roleService.selectRoleById(roleId)); return success(roleService.selectRoleById(roleId));
@ -141,7 +139,6 @@ public class SysRoleController extends BaseController {
* *
*/ */
@RequiresPermissions("system:role:query") @RequiresPermissions("system:role:query")
@GetMapping("/optionselect")
public Result optionselect() { public Result optionselect() {
return success(roleService.selectRoleAll()); return success(roleService.selectRoleAll());
} }
@ -150,7 +147,6 @@ public class SysRoleController extends BaseController {
* *
*/ */
@RequiresPermissions("system:role:list") @RequiresPermissions("system:role:list")
@GetMapping("/authUser/allocatedList")
public Result<TableDataInfo<SysUser>> allocatedList(SysUser user) { public Result<TableDataInfo<SysUser>> allocatedList(SysUser user) {
startPage(); startPage();
List<SysUser> list = userService.selectAllocatedList(user); List<SysUser> list = userService.selectAllocatedList(user);
@ -161,7 +157,6 @@ public class SysRoleController extends BaseController {
* *
*/ */
@RequiresPermissions("system:role:list") @RequiresPermissions("system:role:list")
@GetMapping("/authUser/unallocatedList")
public Result<TableDataInfo<SysUser>> unallocatedList(SysUser user) { public Result<TableDataInfo<SysUser>> unallocatedList(SysUser user) {
startPage(); startPage();
List<SysUser> list = userService.selectUnallocatedList(user); List<SysUser> list = userService.selectUnallocatedList(user);
@ -203,7 +198,6 @@ public class SysRoleController extends BaseController {
* *
*/ */
@RequiresPermissions("system:role:query") @RequiresPermissions("system:role:query")
@GetMapping(value = "/deptTree/{roleId}")
public Result deptTree(@PathVariable("roleId") Long roleId) { public Result deptTree(@PathVariable("roleId") Long roleId) {
return Result.success( return Result.success(
DeptTreeResp.builder() DeptTreeResp.builder()

View File

@ -60,7 +60,6 @@ public class SysUserController extends BaseController {
* *
*/ */
@RequiresPermissions("system:user:list") @RequiresPermissions("system:user:list")
@GetMapping("/list")
public Result<TableDataInfo<SysUser>> list(SysUser user) { public Result<TableDataInfo<SysUser>> list(SysUser user) {
startPage(); startPage();
List<SysUser> list = userService.selectUserList(user); List<SysUser> list = userService.selectUserList(user);
@ -97,7 +96,6 @@ public class SysUserController extends BaseController {
* *
*/ */
@InnerAuth @InnerAuth
@GetMapping("/info/{username}")
public Result<LoginUser> info(@PathVariable("username") String username) { public Result<LoginUser> info(@PathVariable("username") String username) {
SysUser sysUser = userService.selectUserByUserName(username); SysUser sysUser = userService.selectUserByUserName(username);
if (StringUtils.isNull(sysUser)) { if (StringUtils.isNull(sysUser)) {
@ -135,7 +133,6 @@ public class SysUserController extends BaseController {
* *
* @return * @return
*/ */
@GetMapping("getInfo")
public Result getInfo() { public Result getInfo() {
SysUser user = userService.selectUserById(SecurityUtils.getUserId()); SysUser user = userService.selectUserById(SecurityUtils.getUserId());
// 角色集合 // 角色集合
@ -156,7 +153,6 @@ public class SysUserController extends BaseController {
* *
*/ */
@RequiresPermissions("system:user:query") @RequiresPermissions("system:user:query")
@GetMapping(value = {"/", "/{userId}"})
public Result getInfo(@PathVariable(value = "userId", required = false) Long userId) { public Result getInfo(@PathVariable(value = "userId", required = false) Long userId) {
userService.checkUserDataScope(userId); userService.checkUserDataScope(userId);
UserDetailInfoResp.UserDetailInfoRespBuilder<?, ?> builder = UserDetailInfoResp.builder(); UserDetailInfoResp.UserDetailInfoRespBuilder<?, ?> builder = UserDetailInfoResp.builder();
@ -258,7 +254,6 @@ public class SysUserController extends BaseController {
* *
*/ */
@RequiresPermissions("system:user:query") @RequiresPermissions("system:user:query")
@GetMapping("/authRole/{userId}")
public Result authRole(@PathVariable("userId") Long userId) { public Result authRole(@PathVariable("userId") Long userId) {
SysUser user = userService.selectUserById(userId); SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId); List<SysRole> roles = roleService.selectRolesByUserId(userId);
@ -286,7 +281,6 @@ public class SysUserController extends BaseController {
* *
*/ */
@RequiresPermissions("system:user:list") @RequiresPermissions("system:user:list")
@GetMapping("/deptTree")
public Result deptTree(SysDept dept) { public Result deptTree(SysDept dept) {
return success(deptService.selectDeptTreeList(dept)); return success(deptService.selectDeptTreeList(dept));
} }

View File

@ -35,7 +35,6 @@ public class SysUserOnlineController extends BaseController {
private RedisService redisService; private RedisService redisService;
@RequiresPermissions("monitor:online:list") @RequiresPermissions("monitor:online:list")
@GetMapping("/list")
public Result<TableDataInfo<SysUserOnline>> list(String ipaddr, String userName) { public Result<TableDataInfo<SysUserOnline>> list(String ipaddr, String userName) {
Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>(); List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();

View File

@ -0,0 +1,24 @@
package com.muyu.system.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestLogController {
/**
*
*/
private static final Logger log = LoggerFactory.getLogger(TestLogController.class);
/**
* log访
*/
@GetMapping("/testLog")
public String testLog() {
log.error("测试输出一个日志");
return "success";
}
}

View File

@ -0,0 +1,29 @@
package com.muyu.system.interceptor;
import com.alibaba.druid.util.StringUtils;
import com.muyu.system.DCL.MDCTraceUtil;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class LogInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 客户端可以传入链路ID需要唯一性
String traceId = request.getHeader(MDCTraceUtil.TRACE_ID_HEADER);
if (!StringUtils.isEmpty(traceId)) {
MDCTraceUtil.putTrace(request.getHeader(MDCTraceUtil.TRACE_ID_HEADER));
} else {
MDCTraceUtil.addTrace();
}
return true;
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
MDCTraceUtil.removeTrace();
}
}

View File

@ -26,3 +26,4 @@ spring:
logging: logging:
level: level:
com.muyu.system.mapper: DEBUG com.muyu.system.mapper: DEBUG
config: classpath:logback-spring.xml

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--该日志将日志级别不同的log信息保存到不同的文件中 -->
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<springProperty scope="context" name="springAppName"
source="spring.application.name" />
<!-- 日志在工程中的输出位置 -->
<property name="LOG_FILE" value="${BUILD_FOLDER:-build}/${springAppName}" />
<!-- 控制台的日志输出样式 -->
<property name="CONSOLE_LOG_PATTERN"
value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<!-- 日志输出编码 -->
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!-- 为logstash输出的JSON格式的Appender -->
<appender name="logstash"
class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>ip:4561</destination>
<!-- 日志输出编码 -->
<encoder
class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp>
<timeZone>UTC</timeZone>
</timestamp>
<pattern>
<pattern>
{
"severity": "%level",
"service": "${springAppName:-}",
"trace": "%X{X-B3-TraceId:-}",
"span": "%X{X-B3-SpanId:-}",
"exportable": "%X{X-Span-Export:-}",
"pid": "${PID:-}",
"thread": "%thread",
"class": "%logger{40}",
"rest": "%message"
}
</pattern>
</pattern>
</providers>
</encoder>
</appender>
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="console" />
<appender-ref ref="logstash" />
</root>
</configuration>