Skip to content

Commit

Permalink
refactor: 优化系统日志、在线用户、存储管理、部门管理相关代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Apr 22, 2024
1 parent e2d0be1 commit a2e4f9a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class DeptResp extends BaseDetailResp {
* 名称
*/
@Schema(description = "名称", example = "测试部")
@ExcelProperty(value = "名称")
@ExcelProperty(value = "名称", order = 2)
private String name;

/**
Expand All @@ -60,41 +60,42 @@ public class DeptResp extends BaseDetailResp {
@Schema(description = "上级部门 ID", example = "2")
@ConditionOnExpression(value = "#target.parentId != 0")
@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;

/**
* 上级部门
*/
@Schema(description = "上级部门", example = "天津总部")
@ExcelProperty(value = "上级部门")
@ExcelProperty(value = "上级部门", order = 4)
private String parentName;

/**
* 状态
*/
@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;

/**
* 排序
*/
@Schema(description = "排序", example = "3")
@ExcelProperty(value = "排序")
@ExcelProperty(value = "排序", order = 6)
private Integer sort;

/**
* 是否为系统内置数据
*/
@Schema(description = "是否为系统内置数据", example = "false")
@ExcelProperty(value = "系统内置")
@ExcelProperty(value = "系统内置", order = 7)
private Boolean isSystem;

/**
* 描述
*/
@Schema(description = "描述", example = "测试部描述信息")
@ExcelProperty(value = "描述")
@ExcelProperty(value = "描述", order = 8)
private String description;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ protected void beforeDelete(List<Long> ids) {
List<StorageDO> storageList = baseMapper.lambdaQuery().in(StorageDO::getId, ids).list();
storageList.forEach(s -> {
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));
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@
@Tag(name = "在线用户 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/monitor/online/user")
@RequestMapping("/monitor/online")
public class OnlineUserController {

private final OnlineUserService onlineUserService;

@Operation(summary = "分页查询列表", description = "分页查询列表")
@SaCheckPermission("monitor:online:user:list")
@SaCheckPermission("monitor:online:list")
@GetMapping
public R<PageResp<OnlineUserResp>> page(OnlineUserQuery query, @Validated PageQuery pageQuery) {
return R.ok(onlineUserService.page(query, pageQuery));
}

@Operation(summary = "强退在线用户", description = "强退在线用户")
@Parameter(name = "token", description = "令牌", example = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOjEsInJuU3RyIjoiTUd6djdyOVFoeHEwdVFqdFAzV3M5YjVJRzh4YjZPSEUifQ.7q7U3ouoN7WPhH2kUEM7vPe5KF3G_qavSG-vRgIxKvE", in = ParameterIn.PATH)
@SaCheckPermission("monitor:online:user:delete")
@SaCheckPermission("monitor:online:kickout")
@DeleteMapping("/{token}")
public R<Void> kickout(@PathVariable String token) {
String currentToken = StpUtil.getTokenValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
Expand Down Expand Up @@ -51,25 +52,29 @@ public class LogController {
private final LogService baseService;

@Operation(summary = "分页查询列表", description = "分页查询列表")
@SaCheckPermission("monitor:log:list")
@GetMapping
public R<PageResp<LogResp>> page(LogQuery query, @Validated PageQuery pageQuery) {
return R.ok(baseService.page(query, pageQuery));
}

@Operation(summary = "查询详情", description = "查询详情")
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
@SaCheckPermission("monitor:log:list")
@GetMapping("/{id}")
public R<LogDetailResp> get(@PathVariable Long id) {
return R.ok(baseService.get(id));
}

@Operation(summary = "导出登录日志", description = "导出登录日志")
@SaCheckPermission("monitor:log:export")
@GetMapping("/export/login")
public void exportLoginLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response) {
baseService.exportLoginLog(query, sortQuery, response);
}

@Operation(summary = "导出操作日志", description = "导出操作日志")
@SaCheckPermission("monitor:log:export")
@GetMapping("/export/operation")
public void exportOperationLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response) {
baseService.exportOperationLog(query, sortQuery, response);
Expand Down

0 comments on commit a2e4f9a

Please sign in to comment.