251222_04_ENH : RequestBody에 Valid 적용 및 중괄호 스타일 통일

This commit is contained in:
2025-12-22 16:50:36 +09:00
parent cf3adf883b
commit 09e0b4ca05
35 changed files with 209 additions and 124 deletions

View File

@@ -9,7 +9,9 @@ import com.kri.contact.server.dto.UserInfoDto;
import com.kri.contact.server.dto.systemlog.UploadUserContentDto;
import com.kri.contact.server.service.SystemEventLogService;
import com.kri.contact.server.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@@ -29,20 +31,23 @@ public class UserController {
private final UserService userService;
private final SystemEventLogService systemEventLogService;
@Operation(summary = "ID 가용 여부 검사")
@GetMapping("/check-user-id")
public DataVerificationDto checkUserId(@RequestParam String userId){
public DataVerificationDto checkUserId(@RequestParam String userId) {
return userService.checkUserId(userId);
}
@Operation(summary = "사용자 정보 조회")
@GetMapping("/{userId}")
public UserInfoDto getUser(@PathVariable String userId){
public UserInfoDto getUser(@PathVariable String userId) {
return userService.getUser(userId);
}
@Operation(summary = "사용자 목록 조회")
@GetMapping()
public List<UserInfoDto> getUserList(RequestUserContext ctx){
public List<UserInfoDto> getUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE){
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserList();
}
else{
@@ -50,32 +55,36 @@ public class UserController {
}
}
@Operation(summary = "컨택원/면접원 목록 조회")
@GetMapping("fieldwork")
public List<UserInfoDto> getFiledoworkUserList(RequestUserContext ctx){
public List<UserInfoDto> getFiledoworkUserList(RequestUserContext ctx) {
String searchCmpn = ctx.getUserCmpn();
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE){
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
searchCmpn = "";
}
return userService.getFieldworkUserListWithCmpn(searchCmpn);
}
@Operation(summary = "외주사 목록 조회")
@GetMapping("outsource")
List<UserInfoDto> getOutsourceList(){
List<UserInfoDto> getOutsourceList() {
return userService.getOutsourceList();
}
@Operation(summary = "사용자 회사 목록 조회")
@GetMapping("cmpn")
public List<String> getUserCmpnList(RequestUserContext ctx){
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE){
public List<String> getUserCmpnList(RequestUserContext ctx) {
if(ctx.getUserRole() < ContactConstant.OUTSOURCE_USER_ROLE) {
return userService.getUserCmpnList();
}
return Collections.emptyList();
}
@Operation(summary = "사용자 생성")
@PutMapping
public void createUser(@RequestBody UserInfoDto userInfo, RequestUserContext ctx){
public void createUser(@Valid @RequestBody UserInfoDto userInfo, RequestUserContext ctx) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
@@ -84,6 +93,7 @@ public class UserController {
systemEventLogService.writeCreateUserLog(regId, now, clientIp, userInfo);
}
@Operation(summary = "사용자 일괄 생성(엑셀 업로드)")
@PostMapping("/excel")
public ExcelUploadResponseDto createUserFromExcel(
@RequestPart("file") MultipartFile file,
@@ -107,8 +117,9 @@ public class UserController {
return result;
}
@Operation(summary = "사용자 일괄 생성 양식 다운로드")
@PostMapping("/excel/template")
public ResponseEntity<byte[]> exportUserTemplate(){
public ResponseEntity<byte[]> exportUserTemplate() {
byte[] bytes = userService.exportUserTemplate();
return ResponseEntity.ok()
@@ -119,8 +130,9 @@ public class UserController {
.body(bytes);
}
@Operation(summary = "사용자 정보 수정")
@PatchMapping()
public void updateUser(@RequestBody UserInfoDto dto, RequestUserContext ctx){
public void updateUser(@Valid @RequestBody UserInfoDto dto, RequestUserContext ctx) {
String modId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
@@ -129,8 +141,9 @@ public class UserController {
systemEventLogService.writeUpdateUserLog(modId, now, clientIp, dto);
}
@Operation(summary = "사용자 삭제(소프트 삭제)")
@DeleteMapping("/{userId}")
public void deleteUser(@PathVariable String userId, RequestUserContext ctx){
public void deleteUser(@PathVariable String userId, RequestUserContext ctx) {
String regId = ctx.getUserId();
String clientIp = ctx.getClientIp();
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();