[api] AdminUserController.java 이쪽 컨벤션 맞춰 변경
This commit is contained in:
@@ -2,9 +2,9 @@ package com.alist.api.modules.admin.user;
|
||||
|
||||
import com.alist.api.common.response.ApiResponse;
|
||||
import com.alist.api.common.response.ApiResponseCode;
|
||||
import com.alist.api.modules.admin.user.form.AdminUserSignupForm;
|
||||
import com.alist.api.modules.admin.user.form.AdminUserAddForm;
|
||||
import com.alist.api.modules.admin.user.service.AdminUserService;
|
||||
import com.alist.api.modules.admin.user.vo.AdminUserVo;
|
||||
import com.alist.api.modules.admin.user.vo.AdminUserAddVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -27,18 +27,18 @@ public class AdminUserController {
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "사용자 회원가입",
|
||||
description = "새로운 사용자를 등록합니다. 아이디 중복 시 오류를 반환합니다."
|
||||
summary = "관리자 회원가입"
|
||||
, description = "새로운 사용자를 등록합니다. 아이디 중복 시 오류를 반환합니다."
|
||||
)
|
||||
@PostMapping("/signup")
|
||||
public ResponseEntity<ApiResponse<AdminUserVo>> signup(@Valid @RequestBody AdminUserSignupForm adminUserSignupForm) {
|
||||
@PostMapping("/add")
|
||||
public ResponseEntity<ApiResponse<AdminUserAddVo>> adminUserAdd(@Valid @RequestBody AdminUserAddForm adminUserAddForm) {
|
||||
|
||||
AdminUserVo result = adminUserService.adminInsertUser(adminUserSignupForm.toAdminUserDto());
|
||||
AdminUserAddVo adminUserAddVo = adminUserService.insertAdminUserAdd(adminUserAddForm.toDto());
|
||||
|
||||
if (result.getResultCode() == 2004) {
|
||||
return ApiResponse.entity(result, ApiResponseCode.CODE_2004, "아이디");
|
||||
if (adminUserAddVo.getResultCode() == 2004) {
|
||||
return ApiResponse.entity(adminUserAddVo, ApiResponseCode.CODE_2004, "아이디");
|
||||
}
|
||||
|
||||
return ApiResponse.entity(result, ApiResponseCode.CODE_2002, "아이디");
|
||||
return ApiResponse.entity(adminUserAddVo, ApiResponseCode.CODE_2002, "아이디");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class AdminUserDto {
|
||||
public class AdminUserAddDto {
|
||||
private Integer userIdx;
|
||||
private String id;
|
||||
private String userRole;
|
||||
+21
-21
@@ -1,6 +1,6 @@
|
||||
package com.alist.api.modules.admin.user.form;
|
||||
|
||||
import com.alist.api.modules.admin.user.dto.AdminUserDto;
|
||||
import com.alist.api.modules.admin.user.dto.AdminUserAddDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
@@ -11,51 +11,51 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@Getter
|
||||
@Schema(description = "회원 가입 요청 폼")
|
||||
public class AdminUserSignupForm {
|
||||
public class AdminUserAddForm {
|
||||
@Schema(
|
||||
description = "사용자 아이디 (공백 불가)",
|
||||
example = "test"
|
||||
description = "사용자 아이디 (공백 불가)"
|
||||
, example = "test"
|
||||
)
|
||||
@NotBlank(message = "아이디를 입력해주세요.")
|
||||
private String id;
|
||||
|
||||
@Schema(
|
||||
description = "비밀번호 (8~64자, 영문 + 숫자 조합, 공백 불가)",
|
||||
example = "pass1234"
|
||||
description = "비밀번호 (8~64자, 영문 + 숫자 조합, 공백 불가)"
|
||||
, example = "pass1234"
|
||||
)
|
||||
@NotBlank(message = "비밀번호를 입력해주세요.")
|
||||
@Size(min = 8, max = 64, message = "비밀번호는 8~64자여야 합니다.")
|
||||
@Pattern(
|
||||
regexp = "^(?=.*[A-Za-z])(?=.*\\d)\\S+$",
|
||||
message = "비밀번호는 영문과 숫자를 포함하고 공백이 없어야 합니다."
|
||||
regexp = "^(?=.*[A-Za-z])(?=.*\\d)\\S+$"
|
||||
, message = "비밀번호는 영문과 숫자를 포함하고 공백이 없어야 합니다."
|
||||
)
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "사용자 권한(관리자{A:관리자}")
|
||||
@Pattern(
|
||||
regexp = "^A$",
|
||||
message = "사용자 권한(관리자{A:관리자})"
|
||||
regexp = "^A$"
|
||||
, message = "사용자 권한(관리자{A:관리자})"
|
||||
)
|
||||
@Schema(
|
||||
description = "사용자 권한(관리자{A:관리자})",
|
||||
example = "A"
|
||||
description = "사용자 권한(관리자{A:관리자})"
|
||||
, example = "A"
|
||||
)
|
||||
private String userRole;
|
||||
|
||||
@NotBlank(message = "사용자 구분(A:관리자)")
|
||||
@Pattern(regexp = "^A$", message = "관리자 사용자 구분은 A만 가능합니다.")
|
||||
@Schema(
|
||||
description = "사용자 타입(A:관리자)",
|
||||
example = "A"
|
||||
description = "사용자 타입(A:관리자)"
|
||||
, example = "A"
|
||||
)
|
||||
private String userType;
|
||||
|
||||
public AdminUserDto toAdminUserDto() {
|
||||
AdminUserDto adminUserDto = new AdminUserDto();
|
||||
adminUserDto.setId(id.trim());
|
||||
adminUserDto.setPassword(password);
|
||||
adminUserDto.setUserRole(userRole);
|
||||
adminUserDto.setUserType(userType);
|
||||
return adminUserDto;
|
||||
public AdminUserAddDto toDto() {
|
||||
AdminUserAddDto adminUserAddDto = new AdminUserAddDto();
|
||||
adminUserAddDto.setId(id.trim());
|
||||
adminUserAddDto.setPassword(password);
|
||||
adminUserAddDto.setUserRole(userRole);
|
||||
adminUserAddDto.setUserType(userType);
|
||||
return adminUserAddDto;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.alist.api.modules.admin.user.service;
|
||||
|
||||
import com.alist.api.modules.admin.user.dto.AdminUserDto;
|
||||
import com.alist.api.modules.admin.user.vo.AdminUserVo;
|
||||
import com.alist.api.modules.admin.user.dto.AdminUserAddDto;
|
||||
import com.alist.api.modules.admin.user.vo.AdminUserAddVo;
|
||||
import com.alist.api.modules.user.dto.UserDto;
|
||||
import com.alist.api.modules.user.dto.UserTokenDto;
|
||||
import com.alist.api.modules.user.service.UserService;
|
||||
import com.alist.api.modules.user.vo.UserVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -21,24 +19,24 @@ public class AdminUserService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public AdminUserVo adminInsertUser(AdminUserDto adminUserDto) {
|
||||
public AdminUserAddVo insertAdminUserAdd(AdminUserAddDto adminUserAddDto) {
|
||||
|
||||
UserDto userDto = new UserDto();
|
||||
|
||||
userDto.setId(adminUserDto.getId());
|
||||
userDto.setPassword(adminUserDto.getPassword());
|
||||
userDto.setUserRole(adminUserDto.getUserRole());
|
||||
userDto.setUserType(adminUserDto.getUserType());
|
||||
userDto.setId(adminUserAddDto.getId());
|
||||
userDto.setPassword(adminUserAddDto.getPassword());
|
||||
userDto.setUserRole(adminUserAddDto.getUserRole());
|
||||
userDto.setUserType(adminUserAddDto.getUserType());
|
||||
|
||||
UserVo userVo = userService.insertUser(userDto);
|
||||
|
||||
AdminUserVo result = new AdminUserVo();
|
||||
result.setResultCode(userVo.getResultCode());
|
||||
result.setUserIdx(userVo.getUserIdx());
|
||||
result.setId(userVo.getId());
|
||||
result.setUserRole(userVo.getUserRole());
|
||||
result.setUserType(userVo.getUserType());
|
||||
AdminUserAddVo adminUserAddVo = new AdminUserAddVo();
|
||||
adminUserAddVo.setResultCode(userVo.getResultCode());
|
||||
adminUserAddVo.setUserIdx(userVo.getUserIdx());
|
||||
adminUserAddVo.setId(userVo.getId());
|
||||
adminUserAddVo.setUserRole(userVo.getUserRole());
|
||||
adminUserAddVo.setUserType(userVo.getUserType());
|
||||
|
||||
return result;
|
||||
return adminUserAddVo;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import lombok.Setter;
|
||||
@Schema(description = "Admin 사용자 회원가입 응답")
|
||||
@Setter
|
||||
@Getter
|
||||
public class AdminUserVo {
|
||||
public class AdminUserAddVo {
|
||||
@Schema(description = "회원 PK", example = "14")
|
||||
private Integer userIdx;
|
||||
|
||||
Reference in New Issue
Block a user