refactor: 优化系统日志、在线用户、存储管理、部门管理相关代码

This commit is contained in:
Charles7c 2024-04-22 23:13:25 +08:00
parent e2d0be1ba0
commit a2e4f9a28b
4 changed files with 19 additions and 10 deletions

View File

@ -51,7 +51,7 @@ public class DeptResp extends BaseDetailResp {
* 名称 * 名称
*/ */
@Schema(description = "名称", example = "测试部") @Schema(description = "名称", example = "测试部")
@ExcelProperty(value = "名称") @ExcelProperty(value = "名称", order = 2)
private String name; private String name;
/** /**
@ -60,41 +60,42 @@ public class DeptResp extends BaseDetailResp {
@Schema(description = "上级部门 ID", example = "2") @Schema(description = "上级部门 ID", example = "2")
@ConditionOnExpression(value = "#target.parentId != 0") @ConditionOnExpression(value = "#target.parentId != 0")
@AssembleMethod(targetType = DeptService.class, method = @ContainerMethod(bindMethod = "get", resultType = DeptResp.class), props = @Mapping(src = "name", ref = "parentName")) @AssembleMethod(targetType = DeptService.class, method = @ContainerMethod(bindMethod = "get", resultType = DeptResp.class), props = @Mapping(src = "name", ref = "parentName"))
@ExcelProperty(value = "上级部门 ID", order = 3)
private Long parentId; private Long parentId;
/** /**
* 上级部门 * 上级部门
*/ */
@Schema(description = "上级部门", example = "天津总部") @Schema(description = "上级部门", example = "天津总部")
@ExcelProperty(value = "上级部门") @ExcelProperty(value = "上级部门", order = 4)
private String parentName; private String parentName;
/** /**
* 状态 * 状态
*/ */
@Schema(description = "状态1启用2禁用", type = "Integer", allowableValues = {"1", "2"}, example = "1") @Schema(description = "状态1启用2禁用", type = "Integer", allowableValues = {"1", "2"}, example = "1")
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class) @ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class, order = 5)
private DisEnableStatusEnum status; private DisEnableStatusEnum status;
/** /**
* 排序 * 排序
*/ */
@Schema(description = "排序", example = "3") @Schema(description = "排序", example = "3")
@ExcelProperty(value = "排序") @ExcelProperty(value = "排序", order = 6)
private Integer sort; private Integer sort;
/** /**
* 是否为系统内置数据 * 是否为系统内置数据
*/ */
@Schema(description = "是否为系统内置数据", example = "false") @Schema(description = "是否为系统内置数据", example = "false")
@ExcelProperty(value = "系统内置") @ExcelProperty(value = "系统内置", order = 7)
private Boolean isSystem; private Boolean isSystem;
/** /**
* 描述 * 描述
*/ */
@Schema(description = "描述", example = "测试部描述信息") @Schema(description = "描述", example = "测试部描述信息")
@ExcelProperty(value = "描述") @ExcelProperty(value = "描述", order = 8)
private String description; private String description;
@Override @Override

View File

@ -96,7 +96,10 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO
List<StorageDO> storageList = baseMapper.lambdaQuery().in(StorageDO::getId, ids).list(); List<StorageDO> storageList = baseMapper.lambdaQuery().in(StorageDO::getId, ids).list();
storageList.forEach(s -> { storageList.forEach(s -> {
CheckUtils.throwIfEqual(Boolean.TRUE, s.getIsDefault(), "[{}] 是默认存储,不允许禁用", s.getName()); CheckUtils.throwIfEqual(Boolean.TRUE, s.getIsDefault(), "[{}] 是默认存储,不允许禁用", s.getName());
this.unload(BeanUtil.copyProperties(s, StorageReq.class)); // 卸载启用状态的存储
if (DisEnableStatusEnum.ENABLE.equals(s.getStatus())) {
this.unload(BeanUtil.copyProperties(s, StorageReq.class));
}
}); });
} }

View File

@ -46,13 +46,13 @@ import top.continew.starter.web.model.R;
@Tag(name = "在线用户 API") @Tag(name = "在线用户 API")
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/monitor/online/user") @RequestMapping("/monitor/online")
public class OnlineUserController { public class OnlineUserController {
private final OnlineUserService onlineUserService; private final OnlineUserService onlineUserService;
@Operation(summary = "分页查询列表", description = "分页查询列表") @Operation(summary = "分页查询列表", description = "分页查询列表")
@SaCheckPermission("monitor:online:user:list") @SaCheckPermission("monitor:online:list")
@GetMapping @GetMapping
public R<PageResp<OnlineUserResp>> page(OnlineUserQuery query, @Validated PageQuery pageQuery) { public R<PageResp<OnlineUserResp>> page(OnlineUserQuery query, @Validated PageQuery pageQuery) {
return R.ok(onlineUserService.page(query, pageQuery)); return R.ok(onlineUserService.page(query, pageQuery));
@ -60,7 +60,7 @@ public class OnlineUserController {
@Operation(summary = "强退在线用户", description = "强退在线用户") @Operation(summary = "强退在线用户", description = "强退在线用户")
@Parameter(name = "token", description = "令牌", example = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOjEsInJuU3RyIjoiTUd6djdyOVFoeHEwdVFqdFAzV3M5YjVJRzh4YjZPSEUifQ.7q7U3ouoN7WPhH2kUEM7vPe5KF3G_qavSG-vRgIxKvE", in = ParameterIn.PATH) @Parameter(name = "token", description = "令牌", example = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOjEsInJuU3RyIjoiTUd6djdyOVFoeHEwdVFqdFAzV3M5YjVJRzh4YjZPSEUifQ.7q7U3ouoN7WPhH2kUEM7vPe5KF3G_qavSG-vRgIxKvE", in = ParameterIn.PATH)
@SaCheckPermission("monitor:online:user:delete") @SaCheckPermission("monitor:online:kickout")
@DeleteMapping("/{token}") @DeleteMapping("/{token}")
public R<Void> kickout(@PathVariable String token) { public R<Void> kickout(@PathVariable String token) {
String currentToken = StpUtil.getTokenValue(); String currentToken = StpUtil.getTokenValue();

View File

@ -16,6 +16,7 @@
package top.continew.admin.webapi.system; package top.continew.admin.webapi.system;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.enums.ParameterIn;
@ -51,6 +52,7 @@ public class LogController {
private final LogService baseService; private final LogService baseService;
@Operation(summary = "分页查询列表", description = "分页查询列表") @Operation(summary = "分页查询列表", description = "分页查询列表")
@SaCheckPermission("monitor:log:list")
@GetMapping @GetMapping
public R<PageResp<LogResp>> page(LogQuery query, @Validated PageQuery pageQuery) { public R<PageResp<LogResp>> page(LogQuery query, @Validated PageQuery pageQuery) {
return R.ok(baseService.page(query, pageQuery)); return R.ok(baseService.page(query, pageQuery));
@ -58,18 +60,21 @@ public class LogController {
@Operation(summary = "查询详情", description = "查询详情") @Operation(summary = "查询详情", description = "查询详情")
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
@SaCheckPermission("monitor:log:list")
@GetMapping("/{id}") @GetMapping("/{id}")
public R<LogDetailResp> get(@PathVariable Long id) { public R<LogDetailResp> get(@PathVariable Long id) {
return R.ok(baseService.get(id)); return R.ok(baseService.get(id));
} }
@Operation(summary = "导出登录日志", description = "导出登录日志") @Operation(summary = "导出登录日志", description = "导出登录日志")
@SaCheckPermission("monitor:log:export")
@GetMapping("/export/login") @GetMapping("/export/login")
public void exportLoginLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response) { public void exportLoginLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response) {
baseService.exportLoginLog(query, sortQuery, response); baseService.exportLoginLog(query, sortQuery, response);
} }
@Operation(summary = "导出操作日志", description = "导出操作日志") @Operation(summary = "导出操作日志", description = "导出操作日志")
@SaCheckPermission("monitor:log:export")
@GetMapping("/export/operation") @GetMapping("/export/operation")
public void exportOperationLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response) { public void exportOperationLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response) {
baseService.exportOperationLog(query, sortQuery, response); baseService.exportOperationLog(query, sortQuery, response);