refactor: 新增用户页面
This commit is contained in:
@@ -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<PageDTO<UserDTO>> list(SearchUserQuery<SearchUserDO> query) {
|
||||
@GetMapping
|
||||
public ResponseDTO<PageDTO<UserDTO>> userList(SearchUserQuery<SearchUserDO> query) {
|
||||
PageDTO<UserDTO> 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<SearchUserDO> query) {
|
||||
@GetMapping("/excel")
|
||||
public void exportUserByExcel(HttpServletResponse response, SearchUserQuery<SearchUserDO> query) {
|
||||
PageDTO<UserDTO> 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<Void> importData(MultipartFile file) {
|
||||
@PostMapping("/excel")
|
||||
public ResponseDTO<Void> importUserByExcel(MultipartFile file) {
|
||||
List<AddUserCommand> 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<UserDetailDTO> 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<Void> 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<Void> resetPassword(@PathVariable Long userId, @RequestBody ResetPasswordCommand command) {
|
||||
command.setUserId(userId);
|
||||
userApplicationService.resetUserPassword(command);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class UserDTO {
|
||||
private String username;
|
||||
|
||||
@ExcelColumn(name = "用户昵称")
|
||||
private String nickName;
|
||||
private String nickname;
|
||||
|
||||
@ExcelColumn(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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<Integer> {
|
||||
|
||||
/**
|
||||
* 用户账户状态
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ public class SysUserEntity extends BaseEntity<SysUserEntity> {
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("用户昵称")
|
||||
@TableField("nick_name")
|
||||
private String nickName;
|
||||
@TableField("nickname")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty("用户类型(00系统用户)")
|
||||
@TableField("user_type")
|
||||
|
||||
Reference in New Issue
Block a user