forked from TeamMajorLink/majorLink_server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request TeamMajorLink#27 from kchaeeun/feat#26
- Loading branch information
Showing
24 changed files
with
744 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
majorLink/src/main/java/com/example/majorLink/controller/ProfileCardController.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,78 @@ | ||
package com.example.majorLink.controller; | ||
|
||
import com.example.majorLink.domain.User; | ||
import com.example.majorLink.dto.request.ProfileCardRequest; | ||
import com.example.majorLink.dto.response.ProfileCardResponse; | ||
import com.example.majorLink.global.auth.AuthUser; | ||
import com.example.majorLink.service.ProfileCardService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.UUID; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/profile-card") | ||
public class ProfileCardController { | ||
private final ProfileCardService profileCardService; | ||
|
||
/** | ||
* 프로필 카드 등록 API | ||
* [POST] /profile-card | ||
* @param authUser | ||
* @param request | ||
* @return | ||
*/ | ||
@PostMapping | ||
public ResponseEntity<?> createProfileCard( | ||
@AuthenticationPrincipal AuthUser authUser, | ||
@RequestBody ProfileCardRequest request | ||
) { | ||
User user = authUser.getUser(); | ||
profileCardService.createProfileCard(user, request); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
} | ||
|
||
/** | ||
* 프로필 카드 수정 API | ||
* [PATCH] /profile-card | ||
* @param authUser | ||
* @param request | ||
* @return | ||
*/ | ||
@PatchMapping | ||
public ResponseEntity<?> modifyProfileCard( | ||
@AuthenticationPrincipal AuthUser authUser, | ||
@RequestBody ProfileCardRequest request | ||
) { | ||
User user = authUser.getUser(); | ||
profileCardService.modifyProfileCard(user, request); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
|
||
/** | ||
* 프로필 카드 조회 API | ||
* [GET] /profile-card?userId={userId} | ||
* @param authUser | ||
* @param nickname | ||
* @return | ||
*/ | ||
@GetMapping | ||
public ResponseEntity<ProfileCardResponse> getProfileCard( | ||
@AuthenticationPrincipal AuthUser authUser, | ||
@RequestParam(name = "nickname", required = false) String nickname // nickname이 빈 경우를 대비해 쿼리 파라미터 사용 | ||
) { | ||
User user = null; | ||
if (authUser != null) { | ||
user = authUser.getUser(); | ||
} | ||
ProfileCardResponse profileCardResponse = profileCardService.getProfileCard(user, nickname); | ||
return ResponseEntity.ok() | ||
.body(profileCardResponse); | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
majorLink/src/main/java/com/example/majorLink/domain/Education.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,48 @@ | ||
package com.example.majorLink.domain; | ||
|
||
import com.example.majorLink.domain.enums.CheckStatus; | ||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class Education extends BaseEntity{ | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(nullable = false, length = 50) | ||
private String eduName; | ||
@Column(nullable = false, length = 100) | ||
private String process; | ||
private String start; | ||
private String end; | ||
@Enumerated(EnumType.STRING) | ||
private CheckStatus checkStatus = CheckStatus.UNCHECK; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
public void updateEduName(String eduName) { | ||
this.eduName = eduName; | ||
} | ||
public void updateProcess(String process) { | ||
this.process = process; | ||
} | ||
public void updateStart(String start) { | ||
this.start = start; | ||
} | ||
public void updateEnd(String end) { | ||
this.end = end; | ||
} | ||
public void updateCheckStatus(CheckStatus checkStatus) { | ||
this.checkStatus = checkStatus; | ||
} | ||
|
||
} |
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
19 changes: 19 additions & 0 deletions
19
majorLink/src/main/java/com/example/majorLink/dto/request/EducationRequest.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,19 @@ | ||
package com.example.majorLink.dto.request; | ||
|
||
import com.example.majorLink.domain.enums.CheckStatus; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class EducationRequest { | ||
@NotNull(message = "교육의 id 값을 알아야 수정할 수 있습니다.") | ||
private Long id; | ||
private String eduName; | ||
private String process; | ||
@Size(max = 10, message = "시작일은 10글자를 넘을 수 없습니다.") | ||
private String start; | ||
@Size(max = 10, message = "종료일은 10글자를 넘을 수 없습니다.") | ||
private String end; | ||
private Boolean checkStatus = false; | ||
} |
21 changes: 21 additions & 0 deletions
21
majorLink/src/main/java/com/example/majorLink/dto/request/ProfileCardRequest.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,21 @@ | ||
package com.example.majorLink.dto.request; | ||
|
||
import com.example.majorLink.domain.Education; | ||
import com.example.majorLink.domain.Project; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class ProfileCardRequest { | ||
@Size(max=100, message = "한 줄 소개는 100자를 초과할 수 없습니다.") | ||
private String lineInfo; | ||
@Size(max=1000, message = "자기소개는 1000자를 초과할 수 없습니다.") | ||
private String selfInfo; | ||
private List<EducationRequest> educations; | ||
private List<ProjectRequest> projects; | ||
private List<String> skills; | ||
private String portfolio; | ||
private String link; | ||
} |
Oops, something went wrong.