forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEATURE] 직무, 자기소개 수정 api #168 # 169
- Loading branch information
Showing
10 changed files
with
147 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
backend/src/main/java/com/coffee/backend/domain/user/controller/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.coffee.backend.domain.user.controller; | ||
|
||
import com.coffee.backend.domain.auth.controller.AuthenticationPrincipal; | ||
import com.coffee.backend.domain.user.dto.IntroductionUpdateRequest; | ||
import com.coffee.backend.domain.user.dto.PositionUpdateRequest; | ||
import com.coffee.backend.domain.user.dto.UserDto; | ||
import com.coffee.backend.domain.user.entity.Position; | ||
import com.coffee.backend.domain.user.entity.User; | ||
import com.coffee.backend.domain.user.service.UserService; | ||
import com.coffee.backend.utils.ApiResponse; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/user") | ||
@RequiredArgsConstructor | ||
public class UserController { | ||
private final UserService userService; | ||
|
||
@PostMapping("/position/update") | ||
public ResponseEntity<ApiResponse<UserDto>> position(@AuthenticationPrincipal User user, | ||
@RequestBody PositionUpdateRequest dto) { | ||
return ResponseEntity.ok(ApiResponse.success(userService.updateUserPosition(user, dto.getPosition()))); | ||
} | ||
|
||
@PostMapping("/introduction/update") | ||
public ResponseEntity<ApiResponse<UserDto>> position(@AuthenticationPrincipal User user, | ||
@RequestBody IntroductionUpdateRequest dto) { | ||
return ResponseEntity.ok(ApiResponse.success(userService.updateUserIntroduction(user, dto.getIntroduction()))); | ||
} | ||
|
||
@GetMapping("/position/list") | ||
public ResponseEntity<ApiResponse<List<String>>> positionList() { | ||
return ResponseEntity.ok( | ||
ApiResponse.success(Arrays.stream(Position.values()).map(position -> position.getName()).toList())); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/com/coffee/backend/domain/user/dto/IntroductionUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.coffee.backend.domain.user.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class IntroductionUpdateRequest { | ||
private String introduction; | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/com/coffee/backend/domain/user/dto/PositionUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.coffee.backend.domain.user.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class PositionUpdateRequest { | ||
private String position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
backend/src/main/java/com/coffee/backend/domain/user/entity/Position.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.coffee.backend.domain.user.entity; | ||
|
||
import com.coffee.backend.exception.CustomException; | ||
import com.coffee.backend.exception.ErrorCode; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import java.util.Arrays; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@AllArgsConstructor | ||
@Slf4j | ||
@Getter | ||
public enum Position { | ||
P00("선택안함"), | ||
P01("서버/백엔드"), | ||
P02("프론트엔드"), | ||
P03("웹 풀스택"), | ||
P04("안드로이드"), | ||
P05("ios"), | ||
P06("머신러닝"), | ||
P07("인공지능(AI)"), | ||
P08("데이터 엔지니어링"), | ||
P09("DBA"), | ||
P10("모바일 게임"), | ||
P11("게임 클라이언트"), | ||
P12("게임 서버"), | ||
P13("시스템 소프트웨어"), | ||
P14("시스템/네트워크"), | ||
P15("데브옵스"), | ||
P16("인터넷 보안"), | ||
P17("임베디드 소프트웨어"), | ||
P18("로보틱스 미들웨어"), | ||
P19("QA"), | ||
P20("사물인터넷(IoT)"), | ||
P21("응용 프로그램"), | ||
P22("블록체인"), | ||
P23("개발PM"), | ||
P24("웹 퍼블리싱"), | ||
P25("크로스 플랫폼"), | ||
P26("VR/AR/3D"), | ||
P27("ERP"), | ||
P28("그래픽스"); | ||
|
||
private final String name; | ||
|
||
@JsonCreator // value 이름으로 Position 생성 (ex. "선택안함" -> Position.P00) | ||
public static Position of(final String param) { | ||
return Arrays.stream(values()).filter(position -> position.name.equals(param)) | ||
.findFirst() | ||
.orElseThrow(() -> { | ||
log.info("Invalid position: {}", param); | ||
return new CustomException(ErrorCode.ILLEGAL_ARGUMENT_POSITION); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters