diff --git a/agileboot-admin/src/main/java/com/agileboot/admin/controller/system/SysUserController.java b/agileboot-admin/src/main/java/com/agileboot/admin/controller/system/SysUserController.java index 050f073..d8d9368 100644 --- a/agileboot-admin/src/main/java/com/agileboot/admin/controller/system/SysUserController.java +++ b/agileboot-admin/src/main/java/com/agileboot/admin/controller/system/SysUserController.java @@ -39,12 +39,11 @@ import org.springframework.web.multipart.MultipartFile; /** * 用户信息 - * - * @author ruoyi + * @author valarchie */ @Tag(name = "用户API", description = "用户相关的增删查改") @RestController -@RequestMapping("/system/user") +@RequestMapping("/system/users") @RequiredArgsConstructor public class SysUserController extends BaseController { @@ -56,8 +55,8 @@ public class SysUserController extends BaseController { */ @Operation(summary = "用户列表") @PreAuthorize("@permission.has('system:user:list') AND @dataScope.checkDeptId(#query.deptId)") - @GetMapping("/list") - public ResponseDTO> list(SearchUserQuery query) { + @GetMapping + public ResponseDTO> userList(SearchUserQuery query) { PageDTO page = userApplicationService.getUserList(query); return ResponseDTO.ok(page); } @@ -65,8 +64,8 @@ public class SysUserController extends BaseController { @Operation(summary = "用户列表导出") @AccessLog(title = "用户管理", businessType = BusinessTypeEnum.EXPORT) @PreAuthorize("@permission.has('system:user:export')") - @PostMapping("/export") - public void export(HttpServletResponse response, SearchUserQuery query) { + @GetMapping("/excel") + public void exportUserByExcel(HttpServletResponse response, SearchUserQuery query) { PageDTO userList = userApplicationService.getUserList(query); CustomExcelUtil.writeToResponse(userList.getRows(), UserDTO.class, response); } @@ -74,8 +73,8 @@ public class SysUserController extends BaseController { @Operation(summary = "用户列表导入") @AccessLog(title = "用户管理", businessType = BusinessTypeEnum.IMPORT) @PreAuthorize("@permission.has('system:user:import')") - @PostMapping("/importData") - public ResponseDTO importData(MultipartFile file) { + @PostMapping("/excel") + public ResponseDTO importUserByExcel(MultipartFile file) { List commands = CustomExcelUtil.readFromRequest(AddUserCommand.class, file); for (AddUserCommand command : commands) { @@ -88,8 +87,8 @@ public class SysUserController extends BaseController { * 下载批量导入模板 */ @Operation(summary = "用户导入excel下载") - @PostMapping("/downloadTemplate") - public void downloadTemplate(HttpServletResponse response) { + @GetMapping("/excelTemplate") + public void downloadExcelTemplate(HttpServletResponse response) { CustomExcelUtil.writeToResponse(ListUtil.toList(new AddUserCommand()), AddUserCommand.class, response); } @@ -98,7 +97,7 @@ public class SysUserController extends BaseController { */ @Operation(summary = "用户详情") @PreAuthorize("@permission.has('system:user:query')") - @GetMapping(value = {"/", "/{userId}"}) + @GetMapping("/{userId}") public ResponseDTO getUserDetailInfo(@PathVariable(value = "userId", required = false) Long userId) { UserDetailDTO userDetailInfo = userApplicationService.getUserDetailInfo(userId); return ResponseDTO.ok(userDetailInfo); @@ -122,7 +121,7 @@ public class SysUserController extends BaseController { @Operation(summary = "修改用户") @PreAuthorize("@permission.has('system:user:edit') AND @dataScope.checkUserId(#command.userId)") @AccessLog(title = "用户管理", businessType = BusinessTypeEnum.MODIFY) - @PutMapping + @PutMapping("/{userId}") public ResponseDTO edit(@Validated @RequestBody UpdateUserCommand command) { userApplicationService.updateUser(command); return ResponseDTO.ok(); @@ -148,7 +147,7 @@ public class SysUserController extends BaseController { @Operation(summary = "重置用户密码") @PreAuthorize("@permission.has('system:user:resetPwd') AND @dataScope.checkUserId(#userId)") @AccessLog(title = "用户管理", businessType = BusinessTypeEnum.MODIFY) - @PutMapping("/{userId}/password/reset") + @PutMapping("/{userId}/password") public ResponseDTO resetPassword(@PathVariable Long userId, @RequestBody ResetPasswordCommand command) { command.setUserId(userId); userApplicationService.resetUserPassword(command); diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/system/user/command/AddUserCommand.java b/agileboot-domain/src/main/java/com/agileboot/domain/system/user/command/AddUserCommand.java index 5cf5e54..906ada3 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/system/user/command/AddUserCommand.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/system/user/command/AddUserCommand.java @@ -16,7 +16,7 @@ public class AddUserCommand { private String username; @ExcelColumn(name = "昵称") - private String nickName; + private String nickname; @ExcelColumn(name = "邮件") private String email; @@ -34,7 +34,7 @@ public class AddUserCommand { private String password; @ExcelColumn(name = "状态") - private String status; + private Integer status; @ExcelColumn(name = "角色ID") private Long roleId; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/system/user/dto/UserDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/system/user/dto/UserDTO.java index 00ad407..235a38e 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/system/user/dto/UserDTO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/system/user/dto/UserDTO.java @@ -74,7 +74,7 @@ public class UserDTO { private String username; @ExcelColumn(name = "用户昵称") - private String nickName; + private String nickname; @ExcelColumn(name = "用户类型") private Integer userType; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/system/user/model/UserModel.java b/agileboot-domain/src/main/java/com/agileboot/domain/system/user/model/UserModel.java index 876a983..c68acb1 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/system/user/model/UserModel.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/system/user/model/UserModel.java @@ -71,7 +71,7 @@ public class UserModel extends SysUserEntity { public void loadUpdateProfileCommand(UpdateProfileCommand command) { if (command != null) { this.setSex(command.getSex()); - this.setNickName(command.getNickName()); + this.setNickname(command.getNickName()); this.setPhoneNumber(command.getPhoneNumber()); this.setEmail(command.getEmail()); } diff --git a/agileboot-infrastructure/src/main/java/com/agileboot/infrastructure/cache/map/MapCache.java b/agileboot-infrastructure/src/main/java/com/agileboot/infrastructure/cache/map/MapCache.java index 87fe994..2132dda 100644 --- a/agileboot-infrastructure/src/main/java/com/agileboot/infrastructure/cache/map/MapCache.java +++ b/agileboot-infrastructure/src/main/java/com/agileboot/infrastructure/cache/map/MapCache.java @@ -31,7 +31,7 @@ public class MapCache { } private static void initDictionaryCache() { - + // TODO 这个可以做成自动扫描 loadInCache(BusinessTypeEnum.values()); loadInCache(YesOrNoEnum.values()); loadInCache(StatusEnum.values()); @@ -41,7 +41,7 @@ public class MapCache { loadInCache(OperationStatusEnum.values()); loadInCache(LoginStatusEnum.values()); loadInCache(VisibleStatusEnum.values()); - + loadInCache(UserStatusEnum.values()); } diff --git a/agileboot-orm/src/main/java/com/agileboot/orm/common/enums/UserStatusEnum.java b/agileboot-orm/src/main/java/com/agileboot/orm/common/enums/UserStatusEnum.java index 28a8f5e..23d38cd 100644 --- a/agileboot-orm/src/main/java/com/agileboot/orm/common/enums/UserStatusEnum.java +++ b/agileboot-orm/src/main/java/com/agileboot/orm/common/enums/UserStatusEnum.java @@ -1,35 +1,49 @@ package com.agileboot.orm.common.enums; +import com.agileboot.orm.common.CssTag; import com.agileboot.orm.common.annotations.Dictionary; +import com.agileboot.orm.common.interfaces.DictionaryEnum; /** * 对应sys_user的status字段 * @author valarchie */ @Dictionary(name = "sysUser.status") -public enum UserStatusEnum { +public enum UserStatusEnum implements DictionaryEnum { /** * 用户账户状态 */ - NORMAL(1, "正常"), - DISABLED(2, "禁用"), - FROZEN(3, "冻结"); + NORMAL(1, "正常", CssTag.PRIMARY), + DISABLED(2, "禁用", CssTag.DANGER), + FROZEN(3, "冻结", CssTag.WARNING); private final int value; private final String description; - UserStatusEnum(int value, String description) { + private final String cssTag; + + UserStatusEnum(int value, String description, String cssTag) { this.value = value; this.description = description; + this.cssTag = cssTag; } - public int getValue() { + public Integer getValue() { return value; } + @Override + public String description() { + return this.description; + } + public String getDescription() { return description; } + @Override + public String cssTag() { + return null; + } } diff --git a/agileboot-orm/src/main/java/com/agileboot/orm/system/entity/SysUserEntity.java b/agileboot-orm/src/main/java/com/agileboot/orm/system/entity/SysUserEntity.java index 76a58d3..91586dc 100644 --- a/agileboot-orm/src/main/java/com/agileboot/orm/system/entity/SysUserEntity.java +++ b/agileboot-orm/src/main/java/com/agileboot/orm/system/entity/SysUserEntity.java @@ -49,8 +49,8 @@ public class SysUserEntity extends BaseEntity { private String username; @ApiModelProperty("用户昵称") - @TableField("nick_name") - private String nickName; + @TableField("nickname") + private String nickname; @ApiModelProperty("用户类型(00系统用户)") @TableField("user_type")