diff --git a/src/main/java/com/gabojait/gabojaitspring/api/controller/favorite/FavoriteController.java b/src/main/java/com/gabojait/gabojaitspring/api/controller/favorite/FavoriteController.java index 2f7a8538..798b00d4 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/controller/favorite/FavoriteController.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/controller/favorite/FavoriteController.java @@ -5,9 +5,8 @@ import com.gabojait.gabojaitspring.api.dto.common.response.DefaultNoResponse; import com.gabojait.gabojaitspring.api.dto.common.response.PageData; import com.gabojait.gabojaitspring.api.dto.favorite.request.FavoriteDefaultRequest; -import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteTeamResponse; -import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteUserResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileAbstractResponse; +import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteTeamPageResponse; +import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteUserPageResponse; import com.gabojait.gabojaitspring.api.service.favorite.FavoriteService; import com.gabojait.gabojaitspring.auth.JwtProvider; import io.swagger.annotations.Api; @@ -156,7 +155,7 @@ public ResponseEntity updateFavoriteTeam( "- 503 = ONGOING_INSPECTION") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", - content = @Content(schema = @Schema(implementation = ProfileAbstractResponse.class))), + content = @Content(schema = @Schema(implementation = FavoriteUserPageResponse.class))), @ApiResponse(responseCode = "400", description = "BAD REQUEST"), @ApiResponse(responseCode = "401", description = "UNAUTHORIZED"), @ApiResponse(responseCode = "403", description = "FORBIDDEN"), @@ -177,7 +176,7 @@ public ResponseEntity> findPageFavoriteUser( ) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); - PageData> responses = favoriteService.findPageFavoriteUser(username, pageFrom, + PageData> responses = favoriteService.findPageFavoriteUser(username, pageFrom, pageSize); return ResponseEntity.status(FAVORITE_USERS_FOUND.getHttpStatus()) @@ -202,7 +201,7 @@ public ResponseEntity> findPageFavoriteUser( "- 503 = ONGOING_INSPECTION") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", - content = @Content(schema = @Schema(implementation = ProfileAbstractResponse.class))), + content = @Content(schema = @Schema(implementation = FavoriteTeamPageResponse.class))), @ApiResponse(responseCode = "400", description = "BAD REQUEST"), @ApiResponse(responseCode = "401", description = "UNAUTHORIZED"), @ApiResponse(responseCode = "403", description = "FORBIDDEN"), @@ -223,7 +222,7 @@ public ResponseEntity> findPageFavoriteTeam( ) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); - PageData> responses = favoriteService.findPageFavoriteTeam(username, pageFrom, + PageData> responses = favoriteService.findPageFavoriteTeam(username, pageFrom, pageSize); return ResponseEntity.status(FAVORITE_TEAMS_FOUND.getHttpStatus()) diff --git a/src/main/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileController.java b/src/main/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileController.java index e06ffe31..a5c92a2a 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileController.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileController.java @@ -1,17 +1,13 @@ package com.gabojait.gabojaitspring.api.controller.profile; -import com.gabojait.gabojaitspring.api.dto.common.ValidationSequence; import com.gabojait.gabojaitspring.api.dto.common.response.DefaultMultiResponse; import com.gabojait.gabojaitspring.api.dto.common.response.DefaultNoResponse; import com.gabojait.gabojaitspring.api.dto.common.response.DefaultSingleResponse; import com.gabojait.gabojaitspring.api.dto.common.response.PageData; -import com.gabojait.gabojaitspring.api.dto.profile.request.ProfileDefaultRequest; -import com.gabojait.gabojaitspring.api.dto.profile.request.ProfileDescriptionUpdateRequest; +import com.gabojait.gabojaitspring.api.dto.profile.request.ProfileDescriptionRequest; import com.gabojait.gabojaitspring.api.dto.profile.request.ProfileIsSeekRequest; -import com.gabojait.gabojaitspring.api.dto.profile.response.PortfolioUrlResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileDefaultResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileDetailResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileOfferResponse; +import com.gabojait.gabojaitspring.api.dto.profile.request.ProfileUpdateRequest; +import com.gabojait.gabojaitspring.api.dto.profile.response.*; import com.gabojait.gabojaitspring.api.service.profile.ProfileService; import com.gabojait.gabojaitspring.auth.JwtProvider; import com.gabojait.gabojaitspring.domain.user.Position; @@ -30,7 +26,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; -import javax.validation.GroupSequence; import javax.validation.Valid; import javax.validation.constraints.*; @@ -41,10 +36,6 @@ @Api(tags = "프로필") @Validated -@GroupSequence({ProfileController.class, - ValidationSequence.Blank.class, - ValidationSequence.Size.class, - ValidationSequence.Format.class}) @RestController @RequiredArgsConstructor @RequestMapping("/api/v1/user") @@ -63,7 +54,7 @@ public class ProfileController { "- 503 = ONGOING_INSPECTION") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", - content = @Content(schema = @Schema(implementation = ProfileDefaultResponse.class))), + content = @Content(schema = @Schema(implementation = ProfileFindMyselfResponse.class))), @ApiResponse(responseCode = "401", description = "UNAUTHORIZED"), @ApiResponse(responseCode = "403", description = "FORBIDDEN"), @ApiResponse(responseCode = "404", description = "NOT FOUND"), @@ -74,7 +65,7 @@ public class ProfileController { public ResponseEntity> findMyself(HttpServletRequest servletRequest) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); - ProfileDefaultResponse response = profileService.findMyProfile(username); + ProfileFindMyselfResponse response = profileService.findMyProfile(username); return ResponseEntity.status(SELF_PROFILE_FOUND.getHttpStatus()) .body(DefaultSingleResponse.singleDataBuilder() @@ -97,7 +88,7 @@ public ResponseEntity> findMyself(HttpServletReque "- 503 = ONGOING_INSPECTION") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", - content = @Content(schema = @Schema(implementation = ProfileDetailResponse.class))), + content = @Content(schema = @Schema(implementation = ProfileFindOtherResponse.class))), @ApiResponse(responseCode = "400", description = "BAD REQUEST"), @ApiResponse(responseCode = "401", description = "UNAUTHORIZED"), @ApiResponse(responseCode = "403", description = "FORBIDDEN"), @@ -109,12 +100,12 @@ public ResponseEntity> findMyself(HttpServletReque public ResponseEntity> findOther( HttpServletRequest servletRequest, @PathVariable(value = "user-id") - @Positive(message = "회원 식별자는 양수만 가능합니다.", groups = ValidationSequence.Format.class) + @Positive(message = "회원 식별자는 양수만 가능합니다.") Long userId ) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); - ProfileDetailResponse response = profileService.findOtherProfile(username, userId); + ProfileFindOtherResponse response = profileService.findOtherProfile(username, userId); return ResponseEntity.status(PROFILE_FOUND.getHttpStatus()) .body(DefaultSingleResponse.singleDataBuilder() @@ -139,7 +130,7 @@ public ResponseEntity> findOther( "- 503 = ONGOING_INSPECTION") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", - content = @Content(schema = @Schema(implementation = ProfileDefaultResponse.class))), + content = @Content(schema = @Schema(implementation = ProfileImageResponse.class))), @ApiResponse(responseCode = "400", description = "BAD REQUEST"), @ApiResponse(responseCode = "401", description = "UNAUTHORIZED"), @ApiResponse(responseCode = "403", description = "FORBIDDEN"), @@ -152,12 +143,14 @@ public ResponseEntity> findOther( @PostMapping(value = "/image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> uploadProfileImage(HttpServletRequest servletRequest, - @RequestPart(value = "image", required = false) - MultipartFile image) { + public ResponseEntity> uploadProfileImage( + HttpServletRequest servletRequest, + @RequestPart(value = "image", required = false) + MultipartFile image + ) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); - ProfileDefaultResponse response = profileService.uploadProfileImage(username, image); + ProfileImageResponse response = profileService.uploadProfileImage(username, image); return ResponseEntity.status(PROFILE_IMAGE_UPLOADED.getHttpStatus()) .body(DefaultSingleResponse.singleDataBuilder() @@ -177,7 +170,7 @@ public ResponseEntity> uploadProfileImage(HttpServ "- 503 = ONGOING_INSPECTION") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", - content = @Content(schema = @Schema(implementation = ProfileDefaultResponse.class))), + content = @Content(schema = @Schema(implementation = ProfileImageResponse.class))), @ApiResponse(responseCode = "401", description = "UNAUTHORIZED"), @ApiResponse(responseCode = "403", description = "FORBIDDEN"), @ApiResponse(responseCode = "404", description = "NOT FOUND"), @@ -188,7 +181,7 @@ public ResponseEntity> uploadProfileImage(HttpServ public ResponseEntity> deleteProfileImage(HttpServletRequest servletRequest) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); - ProfileDefaultResponse response = profileService.deleteProfileImage(username); + ProfileImageResponse response = profileService.deleteProfileImage(username); return ResponseEntity.status(PROFILE_IMAGE_DELETED.getHttpStatus()) .body(DefaultSingleResponse.singleDataBuilder() @@ -254,7 +247,7 @@ public ResponseEntity updateIsSeekingTeam(HttpServletRequest @PatchMapping("/description") public ResponseEntity updateDescription(HttpServletRequest servletRequest, @RequestBody @Valid - ProfileDescriptionUpdateRequest request) { + ProfileDescriptionRequest request) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); profileService.updateProfileDescription(username, request.getProfileDescription()); @@ -269,12 +262,10 @@ public ResponseEntity updateDescription(HttpServletRequest se @ApiOperation(value = "프로필 업데이트", notes = "<응답 코드>\n" + "- 200 = PROFILE_UPDATED\n" + - "- 400 = POSITION_FIELD_REQUIRED || POSITION_TYPE_INVALID || SKILL_NAME_FIELD_REQUIRED || " + - "SKILL_NAME_LENGTH_INVALID || IS_EXPERIENCED_FIELD_REQUIRED || LEVEL_FIELD_REQUIRED || " + - "LEVEL_TYPE_INVALID || INSTITUTION_NAME_FIELD_REQUIRED || INSTITUTION_NAME_LENGTH_INVALID || " + - "STARTED_AT_FIELD_REQUIRED || IS_CURRENT_FIELD_REQUIRED || CORPORATION_NAME_FIELD_REQUIRED || " + - "CORPORATION_NAME_LENGTH_INVALID || WORK_DESCRIPTION_LENGTH_INVALID || " + - "PORTFOLIO_NAME_FIELD_REQUIRED || PORTFOLIO_NAME_LENGTH_INVALID || " + + "- 400 = POSITION_TYPE_INVALID || SKILL_NAME_LENGTH_INVALID || IS_EXPERIENCED_FIELD_REQUIRED || " + + "LEVEL_FIELD_REQUIRED || LEVEL_TYPE_INVALID || INSTITUTION_NAME_LENGTH_INVALID || " + + "STARTED_AT_FIELD_REQUIRED || IS_CURRENT_FIELD_REQUIRED || CORPORATION_NAME_LENGTH_INVALID || " + + "WORK_DESCRIPTION_LENGTH_INVALID || PORTFOLIO_NAME_LENGTH_INVALID || " + "PORTFOLIO_URL_FIELD_REQUIRED || PORTFOLIO_URL_LENGTH_INVALID || MEDIA_FIELD_REQUIRED || " + "MEDIA_TYPE_INVALID || EDUCATION_DATE_INVALID || EDUCATION_ENDED_AT_FIELD_REQUIRED || " + "WORK_DATE_INVALID || WORK_ENDED_AT_FIELD_REQUIRED\n" + @@ -285,7 +276,7 @@ public ResponseEntity updateDescription(HttpServletRequest se "- 503 = ONGOING_INSPECTION") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", - content = @Content(schema = @Schema(implementation = ProfileDefaultResponse.class))), + content = @Content(schema = @Schema(implementation = ProfileUpdateResponse.class))), @ApiResponse(responseCode = "400", description = "BAD REQUEST"), @ApiResponse(responseCode = "401", description = "UNAUTHORIZED"), @ApiResponse(responseCode = "403", description = "FORBIDDEN"), @@ -296,10 +287,10 @@ public ResponseEntity updateDescription(HttpServletRequest se @PostMapping("/profile") public ResponseEntity> updateProfile(HttpServletRequest servletRequest, @RequestBody @Valid - ProfileDefaultRequest request) { + ProfileUpdateRequest request) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); - ProfileDefaultResponse response = profileService.updateProfile(username, request); + ProfileUpdateResponse response = profileService.updateProfile(username, request); return ResponseEntity.status(PROFILE_UPDATED.getHttpStatus()) .body(DefaultSingleResponse.singleDataBuilder() @@ -336,9 +327,11 @@ public ResponseEntity> updateProfile(HttpServletRe @PostMapping(value = "/portfolio/file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> uploadPortfolioFile(HttpServletRequest servletRequest, - @RequestPart(value = "file", required = false) - MultipartFile file) { + public ResponseEntity> uploadPortfolioFile( + HttpServletRequest servletRequest, + @RequestPart(value = "file", required = false) + MultipartFile file + ) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); PortfolioUrlResponse response = profileService.uploadPortfolioFile(username, file); @@ -367,7 +360,7 @@ public ResponseEntity> uploadPortfolioFile(HttpSer "- 503 = ONGOING_INSPECTION") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK", - content = @Content(schema = @Schema(implementation = ProfileOfferResponse.class))), + content = @Content(schema = @Schema(implementation = ProfilePageResponse.class))), @ApiResponse(responseCode = "400", description = "BAD REQUEST"), @ApiResponse(responseCode = "401", description = "UNAUTHORIZED"), @ApiResponse(responseCode = "403", description = "FORBIDDEN"), @@ -380,20 +373,19 @@ public ResponseEntity> findUsersLookingForTeam( HttpServletRequest servletRequest, @RequestParam(value = "position", required = false, defaultValue = "NONE") @Pattern(regexp = "^(DESIGNER|BACKEND|FRONTEND|MANAGER|NONE)", - message = "포지션은 'DESIGNER', 'BACKEND', 'FRONTEND', 'MANAGER', 또는 'NONE' 중 하나여야 됩니다.", - groups = ValidationSequence.Format.class) + message = "포지션은 'DESIGNER', 'BACKEND', 'FRONTEND', 'MANAGER', 또는 'NONE' 중 하나여야 됩니다.") String position, @RequestParam(value = "page-from", required = false, defaultValue = "9223372036854775806") - @Positive(message = "페이지 시작점은 양수만 가능합니다.", groups = ValidationSequence.Format.class) + @Positive(message = "페이지 시작점은 양수만 가능합니다.") Long pageFrom, @RequestParam(value = "page-size", required = false, defaultValue = "20") - @Positive(message = "페이지 사이즈는 양수만 가능합니다.", groups = ValidationSequence.Format.class) - @Max(value = 100, message = "페이지 사이즈는 100까지의 수만 가능합니다.", groups = ValidationSequence.Format.class) + @Positive(message = "페이지 사이즈는 양수만 가능합니다.") + @Max(value = 100, message = "페이지 사이즈는 100까지의 수만 가능합니다.") Integer pageSize ) { String username = jwtProvider.getUsername(servletRequest.getHeader(AUTHORIZATION)); - PageData> responses = profileService.findPageUser(username, Position.valueOf(position), + PageData> responses = profileService.findPageUser(username, Position.valueOf(position), pageFrom, pageSize); return ResponseEntity.status(USERS_SEEKING_TEAM_FOUND.getHttpStatus()) diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteSkillResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteSkillResponse.java new file mode 100644 index 00000000..8edf4b71 --- /dev/null +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteSkillResponse.java @@ -0,0 +1,46 @@ +package com.gabojait.gabojaitspring.api.dto.favorite.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gabojait.gabojaitspring.domain.profile.Level; +import com.gabojait.gabojaitspring.domain.profile.Skill; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Getter +@ToString +@ApiModel(value = "찜 기술 응답") +public class FavoriteSkillResponse { + + @ApiModelProperty(position = 1, required = true, value = "기술 식별자") + private Long skillId; + + @ApiModelProperty(position = 2, required = true, value = "기술명") + private String skillName; + + @ApiModelProperty(position = 3, required = true, value = "경험 여부", allowableValues = "true, false") + private Boolean isExperienced; + + @ApiModelProperty(position = 4, required = true, value = "레벨", allowableValues = "LOW, MID, HIGH") + private Level level; + + @ApiModelProperty(position = 5, required = true, value = "생성일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createdAt; + + @ApiModelProperty(position = 6, required = true, value = "수정일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updatedAt; + + public FavoriteSkillResponse(Skill skill) { + this.skillId = skill.getId(); + this.skillName = skill.getSkillName(); + this.isExperienced = skill.getIsExperienced(); + this.level = skill.getLevel(); + this.createdAt = skill.getCreatedAt(); + this.updatedAt = skill.getUpdatedAt(); + } +} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteTeamResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteTeamPageResponse.java similarity index 95% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteTeamResponse.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteTeamPageResponse.java index 56757c64..50efbc55 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteTeamResponse.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteTeamPageResponse.java @@ -12,8 +12,8 @@ @Getter @ToString -@ApiModel(value = "찜한 팀 응답") -public class FavoriteTeamResponse { +@ApiModel(value = "찜한 팀 페이지 응답") +public class FavoriteTeamPageResponse { @ApiModelProperty(position = 1, required = true, value = "팀 식별자") private Long teamId; @@ -56,7 +56,7 @@ public class FavoriteTeamResponse { @ApiModelProperty(position = 13, required = true, value = "찜 식별자") private Long favoriteId; - public FavoriteTeamResponse(Favorite favorite) { + public FavoriteTeamPageResponse(Favorite favorite) { Team team = favorite.getFavoriteTeam(); this.teamId = team.getId(); diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteUserPageResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteUserPageResponse.java new file mode 100644 index 00000000..8be77a93 --- /dev/null +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteUserPageResponse.java @@ -0,0 +1,74 @@ +package com.gabojait.gabojaitspring.api.dto.favorite.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gabojait.gabojaitspring.domain.favorite.Favorite; +import com.gabojait.gabojaitspring.domain.profile.Skill; +import com.gabojait.gabojaitspring.domain.user.Position; +import com.gabojait.gabojaitspring.domain.user.User; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +@Getter +@ToString +@ApiModel(value = "찜한 회원 페이지 응답") +public class FavoriteUserPageResponse { + + @ApiModelProperty(position = 1, required = true, value = "회원 식별자") + private Long userId; + + @ApiModelProperty(position = 2, required = true, value = "닉네임") + private String nickname; + + @ApiModelProperty(position = 3, required = true, value = "포지션", + allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER, NONE") + private Position position; + + @ApiModelProperty(position = 4, required = true, value = "리뷰 수") + private Integer reviewCnt; + + @ApiModelProperty(position = 5, required = true, value = "평점") + private Float rating; + + @ApiModelProperty(position = 6, required = true, value = "프로필 사진") + private String imageUrl; + + @ApiModelProperty(position = 7, required = true, value = "기술") + private List skills; + + @ApiModelProperty(position = 8, required = true, value = "찜 식별자") + private Long favoriteId; + + @ApiModelProperty(position = 9, required = true, value = "생성일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime createdAt; + + @ApiModelProperty(position = 10, required = true, value = "수정일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime updatedAt; + + public FavoriteUserPageResponse(Favorite favorite, List skills) { + User user = favorite.getFavoriteUser(); + + this.userId = user.getId(); + this.nickname = user.getNickname(); + this.position = user.getPosition(); + this.reviewCnt = user.getReviewCnt(); + this.rating = user.getRating(); + this.imageUrl = user.getImageUrl(); + + this.skills = skills.stream() + .map(FavoriteSkillResponse::new) + .collect(Collectors.toList()); + + this.favoriteId = favorite.getId(); + + this.createdAt = user.getCreatedAt(); + this.updatedAt = user.getUpdatedAt(); + } +} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteUserResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteUserResponse.java deleted file mode 100644 index bb0a6e71..00000000 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/favorite/response/FavoriteUserResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.gabojait.gabojaitspring.api.dto.favorite.response; - -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileAbstractResponse; -import com.gabojait.gabojaitspring.domain.favorite.Favorite; -import com.gabojait.gabojaitspring.domain.profile.Skill; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.ToString; - -import java.util.List; - -@Getter -@ToString -@ApiModel(value = "찜한 회원 응답") -public class FavoriteUserResponse extends ProfileAbstractResponse { - - @ApiModelProperty(position = 8, required = true, value = "찜 식별자") - private Long favoriteId; - - public FavoriteUserResponse(Favorite favorite, List skills) { - super(favorite.getFavoriteUser(), skills); - - this.favoriteId = favorite.getId(); - } -} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferDefaultResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferDefaultResponse.java index 4a483115..620e2ee9 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferDefaultResponse.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferDefaultResponse.java @@ -1,7 +1,6 @@ package com.gabojait.gabojaitspring.api.dto.offer.response; import com.fasterxml.jackson.annotation.JsonFormat; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileAbstractResponse; import com.gabojait.gabojaitspring.domain.offer.Offer; import com.gabojait.gabojaitspring.domain.offer.OfferedBy; import com.gabojait.gabojaitspring.domain.profile.Skill; @@ -41,7 +40,7 @@ public class OfferDefaultResponse { private LocalDateTime updatedAt; @ApiModelProperty(position = 7, required = true, value = "회원") - private ProfileAbstractResponse user; + private OfferUserResponse user; @ApiModelProperty(position = 8, required = true, value = "팀") private OfferTeamResponse team; @@ -54,7 +53,7 @@ public OfferDefaultResponse(Offer offer, List skills) { this.createdAt = offer.getCreatedAt(); this.updatedAt = offer.getUpdatedAt(); - this.user = new ProfileAbstractResponse(offer.getUser(), skills); + this.user = new OfferUserResponse(offer.getUser(), skills); this.team = new OfferTeamResponse(offer.getTeam()); } } diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferSkillResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferSkillResponse.java new file mode 100644 index 00000000..84ee5e40 --- /dev/null +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferSkillResponse.java @@ -0,0 +1,46 @@ +package com.gabojait.gabojaitspring.api.dto.offer.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gabojait.gabojaitspring.domain.profile.Level; +import com.gabojait.gabojaitspring.domain.profile.Skill; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Getter +@ToString +@ApiModel(value = "제안 기술 응답") +public class OfferSkillResponse { + + @ApiModelProperty(position = 1, required = true, value = "기술 식별자") + private Long skillId; + + @ApiModelProperty(position = 2, required = true, value = "기술명") + private String skillName; + + @ApiModelProperty(position = 3, required = true, value = "경험 여부", allowableValues = "true, false") + private Boolean isExperienced; + + @ApiModelProperty(position = 4, required = true, value = "레벨", allowableValues = "LOW, MID, HIGH") + private Level level; + + @ApiModelProperty(position = 5, required = true, value = "생성일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createdAt; + + @ApiModelProperty(position = 6, required = true, value = "수정일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updatedAt; + + public OfferSkillResponse(Skill skill) { + this.skillId = skill.getId(); + this.skillName = skill.getSkillName(); + this.isExperienced = skill.getIsExperienced(); + this.level = skill.getLevel(); + this.createdAt = skill.getCreatedAt(); + this.updatedAt = skill.getUpdatedAt(); + } +} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileAbstractResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferUserResponse.java similarity index 86% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileAbstractResponse.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferUserResponse.java index 70b10ded..79672d63 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileAbstractResponse.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/offer/response/OfferUserResponse.java @@ -1,4 +1,4 @@ -package com.gabojait.gabojaitspring.api.dto.profile.response; +package com.gabojait.gabojaitspring.api.dto.offer.response; import com.fasterxml.jackson.annotation.JsonFormat; import com.gabojait.gabojaitspring.domain.profile.Skill; @@ -15,8 +15,8 @@ @Getter @ToString -@ApiModel(value = "프로필 요약 응답") -public class ProfileAbstractResponse { +@ApiModel(value = "제안 회원 응답") +public class OfferUserResponse { @ApiModelProperty(position = 1, required = true, value = "회원 식별자") private Long userId; @@ -38,7 +38,7 @@ public class ProfileAbstractResponse { private String imageUrl; @ApiModelProperty(position = 7, required = true, value = "기술") - private List skills; + private List skills; @ApiModelProperty(position = 8, required = true, value = "생성일") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") @@ -48,18 +48,19 @@ public class ProfileAbstractResponse { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") private LocalDateTime updatedAt; - public ProfileAbstractResponse(User user, List skills) { + public OfferUserResponse(User user, List skills) { this.userId = user.getId(); this.nickname = user.getNickname(); this.position = user.getPosition(); this.reviewCnt = user.getReviewCnt(); this.rating = user.getRating(); this.imageUrl = user.getImageUrl(); - this.createdAt = user.getCreatedAt(); - this.updatedAt = user.getUpdatedAt(); this.skills = skills.stream() - .map(SkillDefaultResponse::new) + .map(OfferSkillResponse::new) .collect(Collectors.toList()); + + this.createdAt = user.getCreatedAt(); + this.updatedAt = user.getUpdatedAt(); } } diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/EducationDefaultRequest.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/EducationUpdateRequest.java similarity index 77% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/EducationDefaultRequest.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/EducationUpdateRequest.java index d30e54d4..d241b5be 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/EducationDefaultRequest.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/EducationUpdateRequest.java @@ -1,15 +1,12 @@ package com.gabojait.gabojaitspring.api.dto.profile.request; import com.fasterxml.jackson.annotation.JsonFormat; -import com.gabojait.gabojaitspring.api.dto.common.ValidationSequence; import com.gabojait.gabojaitspring.domain.profile.Education; import com.gabojait.gabojaitspring.domain.user.User; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.*; -import javax.validation.GroupSequence; -import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.time.LocalDate; @@ -19,23 +16,18 @@ @Setter @ToString @NoArgsConstructor(access = AccessLevel.PROTECTED) -@GroupSequence({EducationDefaultRequest.class, - ValidationSequence.Blank.class, - ValidationSequence.Size.class, - ValidationSequence.Format.class}) -@ApiModel(value = "학력 기본 요청") -public class EducationDefaultRequest { +@ApiModel(value = "학력 업데이트 요청") +public class EducationUpdateRequest { @ApiModelProperty(position = 1, required = true, value = "학력 식별자") private Long educationId; @ApiModelProperty(position = 2, required = true, value = "학교명", example = "가보자잇대학교") - @NotBlank(message = "학교명은 필수 입력입니다.", groups = ValidationSequence.Blank.class) - @Size(min = 3, max = 20, message = "학교명은 3~20자만 가능합니다.", groups = ValidationSequence.Size.class) + @Size(min = 3, max = 20, message = "학교명은 3~20자만 가능합니다.") private String institutionName; @ApiModelProperty(position = 3, required = true, value = "시작일", notes = "string", example = "2000-01-01") - @NotNull(message = "시작일은 필수 입력입니다.", groups = ValidationSequence.Blank.class) + @NotNull(message = "시작일은 필수 입력입니다.") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") private LocalDate startedAt; @@ -45,7 +37,7 @@ public class EducationDefaultRequest { @ApiModelProperty(position = 5, required = true, value = "현재 여부", example = "true", allowableValues = "true, false") - @NotNull(message = "현재 여부는 필수 입력입니다.", groups = ValidationSequence.Blank.class) + @NotNull(message = "현재 여부는 필수 입력입니다.") private Boolean isCurrent; public Education toEntity(User user) { @@ -59,7 +51,7 @@ public Education toEntity(User user) { } @Builder - private EducationDefaultRequest(Long educationId, + private EducationUpdateRequest(Long educationId, String institutionName, LocalDate startedAt, LocalDate endedAt, @@ -75,7 +67,7 @@ private EducationDefaultRequest(Long educationId, public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - EducationDefaultRequest that = (EducationDefaultRequest) o; + EducationUpdateRequest that = (EducationUpdateRequest) o; return Objects.equals(educationId, that.educationId) && Objects.equals(institutionName, that.institutionName) && Objects.equals(startedAt, that.startedAt) diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/PortfolioDefaultRequest.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/PortfolioUpdateRequest.java similarity index 69% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/PortfolioDefaultRequest.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/PortfolioUpdateRequest.java index 1aaa9d96..8cc33b2a 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/PortfolioDefaultRequest.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/PortfolioUpdateRequest.java @@ -1,6 +1,5 @@ package com.gabojait.gabojaitspring.api.dto.profile.request; -import com.gabojait.gabojaitspring.api.dto.common.ValidationSequence; import com.gabojait.gabojaitspring.domain.profile.Media; import com.gabojait.gabojaitspring.domain.profile.Portfolio; import com.gabojait.gabojaitspring.domain.user.User; @@ -8,7 +7,6 @@ import io.swagger.annotations.ApiModelProperty; import lombok.*; -import javax.validation.GroupSequence; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; @@ -18,30 +16,24 @@ @Setter @ToString @NoArgsConstructor(access = AccessLevel.PROTECTED) -@GroupSequence({PortfolioDefaultRequest.class, - ValidationSequence.Blank.class, - ValidationSequence.Size.class, - ValidationSequence.Format.class}) -@ApiModel(value = "포트폴리오 기본 요청") -public class PortfolioDefaultRequest { +@ApiModel(value = "포트폴리오 업데이트 요청") +public class PortfolioUpdateRequest { @ApiModelProperty(position = 1, required = true, value = "포트폴리오 식별자") private Long portfolioId; @ApiModelProperty(position = 1, required = true, value = "포트폴리오명", example = "깃허브") - @NotBlank(message = "포트폴리오명는 필수 입력입니다.", groups = ValidationSequence.Blank.class) - @Size(min = 1, max = 10, message = "포트폴리오명은 1~10자만 가능합니다.", groups = ValidationSequence.Size.class) + @Size(min = 1, max = 10, message = "포트폴리오명은 1~10자만 가능합니다.") private String portfolioName; @ApiModelProperty(position = 2, required = true, value = "포트폴리오 URL", example = "github.com/gabojait") - @NotBlank(message = "포트폴리오 URL은 필수 입력입니다.", groups = ValidationSequence.Blank.class) - @Size(min = 1, max = 1000, message = "URL은 1~1000자만 가능합니다.", groups = ValidationSequence.Size.class) + @NotBlank(message = "포트폴리오 URL은 필수 입력입니다.") + @Size(min = 1, max = 1000, message = "URL은 1~1000자만 가능합니다.") private String portfolioUrl; @ApiModelProperty(position = 3, required = true, value = "미디어", example = "LINK") - @NotBlank(message = "미디어는 필수 입력입니다.", groups = ValidationSequence.Blank.class) - @Pattern(regexp = "^(LINK|FILE)", message = "미디어는 'LINK' 또는 'FILE' 중 하나여야 됩니다.", - groups = ValidationSequence.Format.class) + @NotBlank(message = "미디어는 필수 입력입니다.") + @Pattern(regexp = "^(LINK|FILE)", message = "미디어는 'LINK' 또는 'FILE' 중 하나여야 됩니다.") private String media; public Portfolio toEntity(User user) { @@ -54,7 +46,7 @@ public Portfolio toEntity(User user) { } @Builder - private PortfolioDefaultRequest(Long portfolioId, String portfolioName, String portfolioUrl, String media) { + private PortfolioUpdateRequest(Long portfolioId, String portfolioName, String portfolioUrl, String media) { this.portfolioId = portfolioId; this.portfolioName = portfolioName; this.portfolioUrl = portfolioUrl; @@ -65,7 +57,7 @@ private PortfolioDefaultRequest(Long portfolioId, String portfolioName, String p public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - PortfolioDefaultRequest that = (PortfolioDefaultRequest) o; + PortfolioUpdateRequest that = (PortfolioUpdateRequest) o; return Objects.equals(portfolioId, that.portfolioId) && Objects.equals(portfolioName, that.portfolioName) && Objects.equals(portfolioUrl, that.portfolioUrl) diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileDefaultRequest.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileDefaultRequest.java deleted file mode 100644 index 10df26a6..00000000 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileDefaultRequest.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.gabojait.gabojaitspring.api.dto.profile.request; - -import com.gabojait.gabojaitspring.api.dto.common.ValidationSequence; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.*; - -import javax.validation.GroupSequence; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Pattern; -import java.util.ArrayList; -import java.util.List; - -@Getter -@Setter -@ToString -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@GroupSequence({ - ProfileDefaultRequest.class, - ValidationSequence.Blank.class, - ValidationSequence.Size.class, - ValidationSequence.Format.class -}) -@ApiModel(value = "프로필 기본 요청") -public class ProfileDefaultRequest { - - @ApiModelProperty(position = 1, required = true, value = "포지션", example = "NONE", - allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER, NONE") - @NotBlank(message = "포지션은 필수 입력입니다.", groups = ValidationSequence.Blank.class) - @Pattern(regexp = "^(DESIGNER|BACKEND|FRONTEND|MANAGER|NONE)", - message = "포지션은 'DESIGNER', 'BACKEND', 'FRONTEND', 'MANAGER', 또는 'NONE' 중 하나여야 됩니다.", - groups = ValidationSequence.Format.class) - private String position; - - @ApiModelProperty(position = 2, value = "학력들") - @Valid - private List educations = new ArrayList<>(); - - @ApiModelProperty(position = 3, value = "포트폴리오들") - @Valid - private List portfolios = new ArrayList<>(); - - @ApiModelProperty(position = 4, value = "기술들") - @Valid - private List skills = new ArrayList<>(); - - @ApiModelProperty(position = 5, value = "경력들") - @Valid - private List works = new ArrayList<>(); - - @Builder - private ProfileDefaultRequest(String position, - List educations, - List portfolios, - List skills, - List works) { - this.position = position; - this.educations = educations; - this.portfolios = portfolios; - this.skills = skills; - this.works = works; - } -} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileDescriptionUpdateRequest.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileDescriptionRequest.java similarity index 63% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileDescriptionUpdateRequest.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileDescriptionRequest.java index b9c4ce22..f1f2c1d8 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileDescriptionUpdateRequest.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileDescriptionRequest.java @@ -1,28 +1,24 @@ package com.gabojait.gabojaitspring.api.dto.profile.request; -import com.gabojait.gabojaitspring.api.dto.common.ValidationSequence; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.*; -import javax.validation.GroupSequence; import javax.validation.constraints.Size; @Getter @Setter @ToString @NoArgsConstructor(access = AccessLevel.PROTECTED) -@GroupSequence({ProfileDescriptionUpdateRequest.class, - ValidationSequence.Size.class,}) @ApiModel(value = "프로필 자기소개 수정 요청") -public class ProfileDescriptionUpdateRequest { +public class ProfileDescriptionRequest { @ApiModelProperty(position = 1, required = true, value = "자기소개", example = "김가보자잇 자기소개 입니다.") - @Size(max = 120, message = "자기소개는 0~120자만 가능합니다.", groups = ValidationSequence.Size.class) + @Size(max = 120, message = "자기소개는 0~120자만 가능합니다.") private String profileDescription; @Builder - private ProfileDescriptionUpdateRequest(String profileDescription) { + private ProfileDescriptionRequest(String profileDescription) { this.profileDescription = profileDescription; } } diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileIsSeekRequest.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileIsSeekRequest.java index 01d8668d..48d7f93b 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileIsSeekRequest.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileIsSeekRequest.java @@ -1,24 +1,21 @@ package com.gabojait.gabojaitspring.api.dto.profile.request; -import com.gabojait.gabojaitspring.api.dto.common.ValidationSequence; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.*; -import javax.validation.GroupSequence; import javax.validation.constraints.NotNull; @Getter @Setter @ToString @NoArgsConstructor(access = AccessLevel.PROTECTED) -@GroupSequence({ProfileIsSeekRequest.class, ValidationSequence.Blank.class}) @ApiModel(value = "팀 찾기 여부 수정 요청") public class ProfileIsSeekRequest { @ApiModelProperty(position = 1, required = true, value = "팀 찾기 여부", example = "true", allowableValues = "true, false") - @NotNull(message = "팀 찾기 여부는 필수 입력입니다.", groups = ValidationSequence.Blank.class) + @NotNull(message = "팀 찾기 여부는 필수 입력입니다.") private Boolean isSeekingTeam; @Builder diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileUpdateRequest.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileUpdateRequest.java new file mode 100644 index 00000000..2af145dd --- /dev/null +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/ProfileUpdateRequest.java @@ -0,0 +1,53 @@ +package com.gabojait.gabojaitspring.api.dto.profile.request; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; + +import javax.validation.Valid; +import javax.validation.constraints.Pattern; +import java.util.ArrayList; +import java.util.List; + +@Getter +@Setter +@ToString +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@ApiModel(value = "프로필 업데이트 요청") +public class ProfileUpdateRequest { + + @ApiModelProperty(position = 1, required = true, value = "포지션", example = "NONE", + allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER, NONE") + @Pattern(regexp = "^(DESIGNER|BACKEND|FRONTEND|MANAGER|NONE)", + message = "포지션은 'DESIGNER', 'BACKEND', 'FRONTEND', 'MANAGER', 또는 'NONE' 중 하나여야 됩니다.") + private String position; + + @ApiModelProperty(position = 2, value = "학력들") + @Valid + private List educations = new ArrayList<>(); + + @ApiModelProperty(position = 3, value = "포트폴리오들") + @Valid + private List portfolios = new ArrayList<>(); + + @ApiModelProperty(position = 4, value = "기술들") + @Valid + private List skills = new ArrayList<>(); + + @ApiModelProperty(position = 5, value = "경력") + @Valid + private List works = new ArrayList<>(); + + @Builder + private ProfileUpdateRequest(String position, + List educations, + List portfolios, + List skills, + List works) { + this.position = position; + this.educations = educations; + this.portfolios = portfolios; + this.skills = skills; + this.works = works; + } +} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/SkillDefaultRequest.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/SkillUpdateRequest.java similarity index 72% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/SkillDefaultRequest.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/SkillUpdateRequest.java index acee2597..f628fd99 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/SkillDefaultRequest.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/SkillUpdateRequest.java @@ -1,13 +1,12 @@ package com.gabojait.gabojaitspring.api.dto.profile.request; -import com.gabojait.gabojaitspring.api.dto.common.ValidationSequence; import com.gabojait.gabojaitspring.domain.profile.Level; import com.gabojait.gabojaitspring.domain.profile.Skill; import com.gabojait.gabojaitspring.domain.user.User; +import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.*; -import javax.validation.GroupSequence; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; @@ -18,29 +17,24 @@ @Setter @ToString @NoArgsConstructor(access = AccessLevel.PROTECTED) -@GroupSequence({SkillDefaultRequest.class, - ValidationSequence.Blank.class, - ValidationSequence.Size.class, - ValidationSequence.Format.class}) -public class SkillDefaultRequest { +@ApiModel(value = "기술 업데이트 요청") +public class SkillUpdateRequest { @ApiModelProperty(position = 1, required = true, value = "기술 식별자") private Long skillId; @ApiModelProperty(position = 2, required = true, value = "기술명", example = "스프링") - @NotBlank(message = "기술명은 필수 입력입니다.", groups = ValidationSequence.Blank.class) - @Size(min = 1, max = 20, message = "기술명은 1~20자만 가능합니다.", groups = ValidationSequence.Size.class) + @Size(min = 1, max = 20, message = "기술명은 1~20자만 가능합니다.") private String skillName; @ApiModelProperty(position = 3, required = true, value = "경험 여부", example = "true", allowableValues = "true, false") - @NotNull(message = "경험 여부는 필수 입력입니다.", groups = ValidationSequence.Blank.class) + @NotNull(message = "경험 여부는 필수 입력입니다.") private Boolean isExperienced; @ApiModelProperty(position = 4, required = true, value = "레벨", example = "LOW", allowableValues = "LOW, MID, HIGH") - @NotBlank(message = "레벨은 필수 입력입니다.", groups = ValidationSequence.Blank.class) - @Pattern(regexp = "^(LOW|MID|HIGH)", message = "레벨은 'LOW', 'MID', 또는 'HIGH' 중 하나여야 됩니다.", - groups = ValidationSequence.Format.class) + @NotBlank(message = "레벨은 필수 입력입니다.") + @Pattern(regexp = "^(LOW|MID|HIGH)", message = "레벨은 'LOW', 'MID', 또는 'HIGH' 중 하나여야 됩니다.") private String level; public Skill toEntity(User user) { @@ -53,7 +47,7 @@ public Skill toEntity(User user) { } @Builder - private SkillDefaultRequest(Long skillId, String skillName, Boolean isExperienced, String level) { + private SkillUpdateRequest(Long skillId, String skillName, Boolean isExperienced, String level) { this.skillId = skillId; this.skillName = skillName; this.isExperienced = isExperienced; @@ -64,7 +58,7 @@ private SkillDefaultRequest(Long skillId, String skillName, Boolean isExperience public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - SkillDefaultRequest that = (SkillDefaultRequest) o; + SkillUpdateRequest that = (SkillUpdateRequest) o; return Objects.equals(skillId, that.skillId) && Objects.equals(skillName, that.skillName) && level == that.level diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/WorkDefaultRequest.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/WorkUpdateRequest.java similarity index 79% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/WorkDefaultRequest.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/WorkUpdateRequest.java index 7c518c74..c78d8e81 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/WorkDefaultRequest.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/request/WorkUpdateRequest.java @@ -1,15 +1,12 @@ package com.gabojait.gabojaitspring.api.dto.profile.request; import com.fasterxml.jackson.annotation.JsonFormat; -import com.gabojait.gabojaitspring.api.dto.common.ValidationSequence; import com.gabojait.gabojaitspring.domain.profile.Work; import com.gabojait.gabojaitspring.domain.user.User; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.*; -import javax.validation.GroupSequence; -import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.time.LocalDate; @@ -19,27 +16,22 @@ @Setter @ToString @NoArgsConstructor(access = AccessLevel.PROTECTED) -@GroupSequence({WorkDefaultRequest.class, - ValidationSequence.Blank.class, - ValidationSequence.Size.class, - ValidationSequence.Format.class}) -@ApiModel(value = "경력 생성 요청") -public class WorkDefaultRequest { +@ApiModel(value = "경력 업데이트 요청") +public class WorkUpdateRequest { @ApiModelProperty(position = 1, required = true, value = "경력 식별자") private Long workId; @ApiModelProperty(position = 2, required = true, value = "기관명", example = "가보자잇사") - @NotBlank(message = "기관명은 필수 입력입니다.", groups = ValidationSequence.Blank.class) - @Size(min = 1, max = 20, message = "기관명은 1~20자만 가능합니다.", groups = ValidationSequence.Size.class) + @Size(min = 1, max = 20, message = "기관명은 1~20자만 가능합니다.") private String corporationName; @ApiModelProperty(position = 3, value = "경력 설명", example = "가보자잇에서 백엔드 개발") - @Size(max = 100, message = "경력 설명은 0~100자만 가능합니다.", groups = ValidationSequence.Size.class) + @Size(max = 100, message = "경력 설명은 0~100자만 가능합니다.") private String workDescription; @ApiModelProperty(position = 4, required = true, value = "시작일", notes = "string", example = "2000-01-01") - @NotNull(message = "시작일은 필수 입력입니다.", groups = ValidationSequence.Blank.class) + @NotNull(message = "시작일은 필수 입력입니다.") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") private LocalDate startedAt; @@ -49,7 +41,7 @@ public class WorkDefaultRequest { @ApiModelProperty(position = 6, required = true, value = "현재 여부", example = "true", allowableValues = "true, false") - @NotNull(message = "현재 여부은 필수 입력입니다.", groups = ValidationSequence.Blank.class) + @NotNull(message = "현재 여부은 필수 입력입니다.") private Boolean isCurrent; public Work toEntity(User user) { @@ -64,7 +56,7 @@ public Work toEntity(User user) { } @Builder - private WorkDefaultRequest(Long workId, + private WorkUpdateRequest(Long workId, String corporationName, String workDescription, LocalDate startedAt, @@ -82,7 +74,7 @@ private WorkDefaultRequest(Long workId, public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - WorkDefaultRequest that = (WorkDefaultRequest) o; + WorkUpdateRequest that = (WorkUpdateRequest) o; return Objects.equals(workId, that.workId) && Objects.equals(corporationName, that.corporationName) && Objects.equals(workDescription, that.workDescription) diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/EducationDefaultResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/EducationResponse.java similarity index 92% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/EducationDefaultResponse.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/EducationResponse.java index 6a7fc00e..92cfe886 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/EducationDefaultResponse.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/EducationResponse.java @@ -12,8 +12,8 @@ @Getter @ToString -@ApiModel(value = "학력 기본 응답") -public class EducationDefaultResponse { +@ApiModel(value = "학력 응답") +public class EducationResponse { @ApiModelProperty(position = 1, required = true, value = "학력 식별자") private Long educationId; @@ -40,7 +40,7 @@ public class EducationDefaultResponse { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updatedAt; - public EducationDefaultResponse(Education education) { + public EducationResponse(Education education) { this.educationId = education.getId(); this.institutionName = education.getInstitutionName(); this.startedAt = education.getStartedAt(); diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/PortfolioDefaultResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/PortfolioResponse.java similarity index 91% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/PortfolioDefaultResponse.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/PortfolioResponse.java index d2a17653..31627885 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/PortfolioDefaultResponse.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/PortfolioResponse.java @@ -12,8 +12,8 @@ @Getter @ToString -@ApiModel(value = "포트폴리오 기본 응답") -public class PortfolioDefaultResponse { +@ApiModel(value = "포트폴리오 응답") +public class PortfolioResponse { @ApiModelProperty(position = 1, required = true, value = "포트폴리오 식별자") private Long portfolioId; @@ -35,7 +35,7 @@ public class PortfolioDefaultResponse { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updatedAt; - public PortfolioDefaultResponse(Portfolio portfolio) { + public PortfolioResponse(Portfolio portfolio) { this.portfolioId = portfolio.getId(); this.portfolioName = portfolio.getPortfolioName(); this.portfolioUrl = portfolio.getPortfolioUrl(); diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileDefaultResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileDefaultResponse.java deleted file mode 100644 index 7537c737..00000000 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileDefaultResponse.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.gabojait.gabojaitspring.api.dto.profile.response; - -import com.gabojait.gabojaitspring.api.vo.profile.ProfileVO; -import com.gabojait.gabojaitspring.domain.profile.Skill; -import com.gabojait.gabojaitspring.domain.user.User; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.ToString; - -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -@Getter -@ToString -@ApiModel(value = "프로필 기본 응답") -public class ProfileDefaultResponse extends ProfileAbstractResponse { - - @ApiModelProperty(position = 10, required = true, value = "자기소개") - private String profileDescription; - - @ApiModelProperty(position = 11, required = true, value = "리더 여부") - private Boolean isLeader; - - @ApiModelProperty(position = 12, required = true, value = "팀 찾기 여부") - private Boolean isSeekingTeam; - - @ApiModelProperty(position = 13, required = true, value = "학력") - private List educations; - - @ApiModelProperty(position = 14, required = true, value = "포트폴리오") - private List portfolios; - - @ApiModelProperty(position = 15, required = true, value = "경력") - private List works; - - @ApiModelProperty(position = 16, required = true, value = "완료한 팀") - private List completedTeams; - - @ApiModelProperty(position = 17, required = true, value = "현재 팀") - private ProfileTeamResponse currentTeam; - - @ApiModelProperty(position = 18, required = true, value = "리뷰") - private List reviews; - - public ProfileDefaultResponse(User user, - List skills, - ProfileVO profile) { - super(user, skills); - - this.profileDescription = user.getProfileDescription(); - this.isSeekingTeam = user.getIsSeekingTeam(); - - this.educations = profile.getEducations().stream() - .map(EducationDefaultResponse::new) - .collect(Collectors.toList()); - this.portfolios = profile.getPortfolios().stream() - .map(PortfolioDefaultResponse::new) - .collect(Collectors.toList()); - this.works = profile.getWorks().stream() - .map(WorkDefaultResponse::new) - .collect(Collectors.toList()); - - this.completedTeams = profile.getTeamMembers().stream() - .filter(tm -> tm.getTeam().getCompletedAt() != null) - .map(tm -> new ProfileTeamResponse(tm.getTeam())) - .collect(Collectors.toList()); - this.isLeader = false; - profile.getTeamMembers().stream() - .filter(tm -> tm.getTeam().getCompletedAt() == null) - .findFirst() - .ifPresent(tm -> { - this.currentTeam = new ProfileTeamResponse(tm.getTeam()); - this.isLeader = tm.getIsLeader(); - }); - - this.reviews = IntStream.range(0, profile.getReviews().getContent().size()) - .mapToObj(i -> - new ProfileReviewResponse(profile.getReviews().getContent().get(i), (int) (profile.getReviewCnt() - i))) - .collect(Collectors.toList()); - } -} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileDetailResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileDetailResponse.java deleted file mode 100644 index 1a1c4e60..00000000 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileDetailResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.gabojait.gabojaitspring.api.dto.profile.response; - -import com.gabojait.gabojaitspring.api.dto.offer.response.OfferAbstractResponse; -import com.gabojait.gabojaitspring.api.vo.profile.ProfileVO; -import com.gabojait.gabojaitspring.domain.offer.Offer; -import com.gabojait.gabojaitspring.domain.profile.Education; -import com.gabojait.gabojaitspring.domain.profile.Portfolio; -import com.gabojait.gabojaitspring.domain.profile.Skill; -import com.gabojait.gabojaitspring.domain.profile.Work; -import com.gabojait.gabojaitspring.domain.review.Review; -import com.gabojait.gabojaitspring.domain.team.TeamMember; -import com.gabojait.gabojaitspring.domain.user.User; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.ToString; -import org.springframework.data.domain.Page; - -import java.util.List; -import java.util.stream.Collectors; - -@Getter -@ToString -@ApiModel(value = "상세 프로필 응답") -public class ProfileDetailResponse extends ProfileDefaultResponse { - - @ApiModelProperty(position = 19, required = true, value = "제안들") - private List offers; - - @ApiModelProperty(position = 20, required = true, value = "찜 여부", allowableValues = "true, false, null") - private Boolean isFavorite; - - - public ProfileDetailResponse(User user, - List skills, - ProfileVO profile, - List offers, - Boolean isFavorite) { - super(user, skills, profile); - this.isFavorite = isFavorite; - - this.offers = offers.stream() - .map(OfferAbstractResponse::new) - .collect(Collectors.toList()); - } -} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileFindMyselfResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileFindMyselfResponse.java new file mode 100644 index 00000000..561c2c96 --- /dev/null +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileFindMyselfResponse.java @@ -0,0 +1,124 @@ +package com.gabojait.gabojaitspring.api.dto.profile.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gabojait.gabojaitspring.api.vo.profile.ProfileVO; +import com.gabojait.gabojaitspring.domain.profile.Skill; +import com.gabojait.gabojaitspring.domain.user.Position; +import com.gabojait.gabojaitspring.domain.user.User; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +@Getter +@ToString +@ApiModel(value = "프로필 본인 조회 응답") +public class ProfileFindMyselfResponse { + + @ApiModelProperty(position = 1, required = true, value = "회원 식별자") + private Long userId; + + @ApiModelProperty(position = 2, required = true, value = "닉네임") + private String nickname; + + @ApiModelProperty(position = 3, required = true, value = "포지션", + allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER, NONE") + private Position position; + + @ApiModelProperty(position = 4, required = true, value = "리뷰 수") + private Integer reviewCnt; + + @ApiModelProperty(position = 5, required = true, value = "평점") + private Float rating; + + @ApiModelProperty(position = 6, required = true, value = "프로필 사진") + private String imageUrl; + + @ApiModelProperty(position = 7, required = true, value = "자기소개") + private String profileDescription; + + @ApiModelProperty(position = 8, required = true, value = "리더 여부") + private Boolean isLeader; + + @ApiModelProperty(position = 9, required = true, value = "팀 찾기 여부") + private Boolean isSeekingTeam; + + @ApiModelProperty(position = 10, required = true, value = "기술들") + private List skills; + + @ApiModelProperty(position = 11, required = true, value = "학력들") + private List educations; + + @ApiModelProperty(position = 12, required = true, value = "포트폴리오들") + private List portfolios; + + @ApiModelProperty(position = 13, required = true, value = "경력들") + private List works; + + @ApiModelProperty(position = 14, required = true, value = "완료한 팀들") + private List completedTeams; + + @ApiModelProperty(position = 15, required = true, value = "현재 팀") + private ProfileTeamResponse currentTeam; + + @ApiModelProperty(position = 16, required = true, value = "리뷰들") + private List reviews; + + @ApiModelProperty(position = 17, required = true, value = "생성일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime createdAt; + + @ApiModelProperty(position = 18, required = true, value = "수정일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime updatedAt; + + public ProfileFindMyselfResponse(User user, List skills, ProfileVO profile) { + this.userId = user.getId(); + this.nickname = user.getNickname(); + this.position = user.getPosition(); + this.reviewCnt = user.getReviewCnt(); + this.rating = user.getRating(); + this.imageUrl = user.getImageUrl(); + this.profileDescription = user.getProfileDescription(); + this.isSeekingTeam = user.getIsSeekingTeam(); + + this.skills = skills.stream() + .map(SkillResponse::new) + .collect(Collectors.toList()); + this.educations = profile.getEducations().stream() + .map(EducationResponse::new) + .collect(Collectors.toList()); + this.portfolios = profile.getPortfolios().stream() + .map(PortfolioResponse::new) + .collect(Collectors.toList()); + this.works = profile.getWorks().stream() + .map(WorkResponse::new) + .collect(Collectors.toList()); + + this.completedTeams = profile.getTeamMembers().stream() + .filter(tm -> tm.getTeam().getCompletedAt() != null) + .map(tm -> new ProfileTeamResponse(tm.getTeam())) + .collect(Collectors.toList()); + this.isLeader = false; + profile.getTeamMembers().stream() + .filter(tm -> tm.getTeam().getCompletedAt() == null) + .findFirst() + .ifPresent(tm -> { + this.currentTeam = new ProfileTeamResponse(tm.getTeam()); + this.isLeader = tm.getIsLeader(); + }); + + this.reviews = IntStream.range(0, profile.getReviews().getContent().size()) + .mapToObj(i -> + new ProfileReviewResponse(profile.getReviews().getContent().get(i), (int) (profile.getReviewCnt() - i))) + .collect(Collectors.toList()); + + this.createdAt = user.getCreatedAt(); + this.updatedAt = user.getUpdatedAt(); + } +} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileFindOtherResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileFindOtherResponse.java new file mode 100644 index 00000000..af9f7d16 --- /dev/null +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileFindOtherResponse.java @@ -0,0 +1,141 @@ +package com.gabojait.gabojaitspring.api.dto.profile.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gabojait.gabojaitspring.api.dto.offer.response.OfferAbstractResponse; +import com.gabojait.gabojaitspring.api.vo.profile.ProfileVO; +import com.gabojait.gabojaitspring.domain.offer.Offer; +import com.gabojait.gabojaitspring.domain.profile.Skill; +import com.gabojait.gabojaitspring.domain.user.Position; +import com.gabojait.gabojaitspring.domain.user.User; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +@Getter +@ToString +@ApiModel(value = "프로필 단건 조회 응답") +public class ProfileFindOtherResponse { + + @ApiModelProperty(position = 1, required = true, value = "회원 식별자") + private Long userId; + + @ApiModelProperty(position = 2, required = true, value = "닉네임") + private String nickname; + + @ApiModelProperty(position = 3, required = true, value = "포지션", + allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER, NONE") + private Position position; + + @ApiModelProperty(position = 4, required = true, value = "리뷰 수") + private Integer reviewCnt; + + @ApiModelProperty(position = 5, required = true, value = "평점") + private Float rating; + + @ApiModelProperty(position = 6, required = true, value = "프로필 사진") + private String imageUrl; + + @ApiModelProperty(position = 7, required = true, value = "자기소개") + private String profileDescription; + + @ApiModelProperty(position = 8, required = true, value = "리더 여부") + private Boolean isLeader; + + @ApiModelProperty(position = 9, required = true, value = "팀 찾기 여부") + private Boolean isSeekingTeam; + + @ApiModelProperty(position = 10, required = true, value = "기술들") + private List skills; + + @ApiModelProperty(position = 11, required = true, value = "학력들") + private List educations; + + @ApiModelProperty(position = 12, required = true, value = "포트폴리오들") + private List portfolios; + + @ApiModelProperty(position = 13, required = true, value = "경력들") + private List works; + + @ApiModelProperty(position = 14, required = true, value = "완료한 팀들") + private List completedTeams; + + @ApiModelProperty(position = 15, required = true, value = "현재 팀") + private ProfileTeamResponse currentTeam; + + @ApiModelProperty(position = 16, required = true, value = "리뷰들") + private List reviews; + + @ApiModelProperty(position = 17, required = true, value = "제안들") + private List offers; + + @ApiModelProperty(position = 18, required = true, value = "찜 여부", allowableValues = "true, false, null") + private Boolean isFavorite; + + @ApiModelProperty(position = 19, required = true, value = "생성일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime createdAt; + + @ApiModelProperty(position = 20, required = true, value = "수정일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime updatedAt; + + public ProfileFindOtherResponse(User user, + List skills, + ProfileVO profile, + List offers, + Boolean isFavorite) { + this.userId = user.getId(); + this.nickname = user.getNickname(); + this.position = user.getPosition(); + this.reviewCnt = user.getReviewCnt(); + this.rating = user.getRating(); + this.imageUrl = user.getImageUrl(); + this.profileDescription = user.getProfileDescription(); + this.isSeekingTeam = user.getIsSeekingTeam(); + + this.skills = skills.stream() + .map(SkillResponse::new) + .collect(Collectors.toList()); + this.educations = profile.getEducations().stream() + .map(EducationResponse::new) + .collect(Collectors.toList()); + this.portfolios = profile.getPortfolios().stream() + .map(PortfolioResponse::new) + .collect(Collectors.toList()); + this.works = profile.getWorks().stream() + .map(WorkResponse::new) + .collect(Collectors.toList()); + + this.completedTeams = profile.getTeamMembers().stream() + .filter(tm -> tm.getTeam().getCompletedAt() != null) + .map(tm -> new ProfileTeamResponse(tm.getTeam())) + .collect(Collectors.toList()); + this.isLeader = false; + profile.getTeamMembers().stream() + .filter(tm -> tm.getTeam().getCompletedAt() == null) + .findFirst() + .ifPresent(tm -> { + this.currentTeam = new ProfileTeamResponse(tm.getTeam()); + this.isLeader = tm.getIsLeader(); + }); + + this.reviews = IntStream.range(0, profile.getReviews().getContent().size()) + .mapToObj(i -> + new ProfileReviewResponse(profile.getReviews().getContent().get(i), (int) (profile.getReviewCnt() - i))) + .collect(Collectors.toList()); + this.isFavorite = isFavorite; + + this.offers = offers.stream() + .map(OfferAbstractResponse::new) + .collect(Collectors.toList()); + + this.createdAt = user.getCreatedAt(); + this.updatedAt = user.getUpdatedAt(); + } +} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileImageResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileImageResponse.java new file mode 100644 index 00000000..099a3cb2 --- /dev/null +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileImageResponse.java @@ -0,0 +1,124 @@ +package com.gabojait.gabojaitspring.api.dto.profile.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gabojait.gabojaitspring.api.vo.profile.ProfileVO; +import com.gabojait.gabojaitspring.domain.profile.Skill; +import com.gabojait.gabojaitspring.domain.user.Position; +import com.gabojait.gabojaitspring.domain.user.User; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +@Getter +@ToString +@ApiModel(value = "프로필 이미지 응답") +public class ProfileImageResponse { + + @ApiModelProperty(position = 1, required = true, value = "회원 식별자") + private Long userId; + + @ApiModelProperty(position = 2, required = true, value = "닉네임") + private String nickname; + + @ApiModelProperty(position = 3, required = true, value = "포지션", + allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER, NONE") + private Position position; + + @ApiModelProperty(position = 4, required = true, value = "리뷰 수") + private Integer reviewCnt; + + @ApiModelProperty(position = 5, required = true, value = "평점") + private Float rating; + + @ApiModelProperty(position = 6, required = true, value = "프로필 사진") + private String imageUrl; + + @ApiModelProperty(position = 7, required = true, value = "자기소개") + private String profileDescription; + + @ApiModelProperty(position = 8, required = true, value = "리더 여부") + private Boolean isLeader; + + @ApiModelProperty(position = 9, required = true, value = "팀 찾기 여부") + private Boolean isSeekingTeam; + + @ApiModelProperty(position = 10, required = true, value = "기술들") + private List skills; + + @ApiModelProperty(position = 11, required = true, value = "학력들") + private List educations; + + @ApiModelProperty(position = 12, required = true, value = "포트폴리오들") + private List portfolios; + + @ApiModelProperty(position = 13, required = true, value = "경력들") + private List works; + + @ApiModelProperty(position = 14, required = true, value = "완료한 팀들") + private List completedTeams; + + @ApiModelProperty(position = 15, required = true, value = "현재 팀") + private ProfileTeamResponse currentTeam; + + @ApiModelProperty(position = 16, required = true, value = "리뷰들") + private List reviews; + + @ApiModelProperty(position = 17, required = true, value = "생성일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime createdAt; + + @ApiModelProperty(position = 18, required = true, value = "수정일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime updatedAt; + + public ProfileImageResponse(User user, List skills, ProfileVO profile) { + this.userId = user.getId(); + this.nickname = user.getNickname(); + this.position = user.getPosition(); + this.reviewCnt = user.getReviewCnt(); + this.rating = user.getRating(); + this.imageUrl = user.getImageUrl(); + this.profileDescription = user.getProfileDescription(); + this.isSeekingTeam = user.getIsSeekingTeam(); + + this.skills = skills.stream() + .map(SkillResponse::new) + .collect(Collectors.toList()); + this.educations = profile.getEducations().stream() + .map(EducationResponse::new) + .collect(Collectors.toList()); + this.portfolios = profile.getPortfolios().stream() + .map(PortfolioResponse::new) + .collect(Collectors.toList()); + this.works = profile.getWorks().stream() + .map(WorkResponse::new) + .collect(Collectors.toList()); + + this.completedTeams = profile.getTeamMembers().stream() + .filter(tm -> tm.getTeam().getCompletedAt() != null) + .map(tm -> new ProfileTeamResponse(tm.getTeam())) + .collect(Collectors.toList()); + this.isLeader = false; + profile.getTeamMembers().stream() + .filter(tm -> tm.getTeam().getCompletedAt() == null) + .findFirst() + .ifPresent(tm -> { + this.currentTeam = new ProfileTeamResponse(tm.getTeam()); + this.isLeader = tm.getIsLeader(); + }); + + this.reviews = IntStream.range(0, profile.getReviews().getContent().size()) + .mapToObj(i -> + new ProfileReviewResponse(profile.getReviews().getContent().get(i), (int) (profile.getReviewCnt() - i))) + .collect(Collectors.toList()); + + this.createdAt = user.getCreatedAt(); + this.updatedAt = user.getUpdatedAt(); + } +} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileOfferResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileOfferResponse.java index 96a9f497..2681f43f 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileOfferResponse.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileOfferResponse.java @@ -1,30 +1,48 @@ package com.gabojait.gabojaitspring.api.dto.profile.response; -import com.gabojait.gabojaitspring.api.dto.offer.response.OfferAbstractResponse; +import com.fasterxml.jackson.annotation.JsonFormat; import com.gabojait.gabojaitspring.domain.offer.Offer; -import com.gabojait.gabojaitspring.domain.profile.Skill; -import com.gabojait.gabojaitspring.domain.user.User; +import com.gabojait.gabojaitspring.domain.offer.OfferedBy; +import com.gabojait.gabojaitspring.domain.user.Position; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.ToString; -import java.util.List; -import java.util.stream.Collectors; +import java.time.LocalDateTime; @Getter @ToString @ApiModel(value = "프로필 제안 응답") -public class ProfileOfferResponse extends ProfileAbstractResponse { +public class ProfileOfferResponse { - @ApiModelProperty(position = 7, required = true, value = "제안들") - private List offers; + @ApiModelProperty(position = 1, required = true, value = "제안 식별자") + private Long offerId; - public ProfileOfferResponse(User user, List skills, List offers) { - super(user, skills); + @ApiModelProperty(position = 2, required = true, value = "포지션", + allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER") + private Position position; - this.offers = offers.stream() - .map(OfferAbstractResponse::new) - .collect(Collectors.toList()); + @ApiModelProperty(position = 3, required = true, value = "승인 여부", allowableValues = "true, false, null") + private Boolean isAccepted; + + @ApiModelProperty(position = 4, required = true, value = "제안자", allowableValues = "USER, TEAM") + private OfferedBy offeredBy; + + @ApiModelProperty(position = 5, required = true, value = "생성일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createdAt; + + @ApiModelProperty(position = 6, required = true, value = "수정일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updatedAt; + + public ProfileOfferResponse(Offer offer) { + this.offerId = offer.getId(); + this.position = offer.getPosition(); + this.isAccepted = offer.getIsAccepted(); + this.offeredBy = offer.getOfferedBy(); + this.createdAt = offer.getCreatedAt(); + this.updatedAt = offer.getUpdatedAt(); } } diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfilePageResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfilePageResponse.java new file mode 100644 index 00000000..43fe0d9f --- /dev/null +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfilePageResponse.java @@ -0,0 +1,74 @@ +package com.gabojait.gabojaitspring.api.dto.profile.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gabojait.gabojaitspring.api.dto.offer.response.OfferAbstractResponse; +import com.gabojait.gabojaitspring.domain.offer.Offer; +import com.gabojait.gabojaitspring.domain.profile.Skill; +import com.gabojait.gabojaitspring.domain.user.Position; +import com.gabojait.gabojaitspring.domain.user.User; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +@Getter +@ToString +@ApiModel(value = "프로필 페이지 응답") +public class ProfilePageResponse { + + @ApiModelProperty(position = 1, required = true, value = "회원 식별자") + private Long userId; + + @ApiModelProperty(position = 2, required = true, value = "닉네임") + private String nickname; + + @ApiModelProperty(position = 3, required = true, value = "포지션", + allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER, NONE") + private Position position; + + @ApiModelProperty(position = 4, required = true, value = "리뷰 수") + private Integer reviewCnt; + + @ApiModelProperty(position = 5, required = true, value = "평점") + private Float rating; + + @ApiModelProperty(position = 6, required = true, value = "프로필 사진") + private String imageUrl; + + @ApiModelProperty(position = 7, required = true, value = "기술들") + private List skills; + + @ApiModelProperty(position = 8, required = true, value = "제안들") + private List offers; + + @ApiModelProperty(position = 9, required = true, value = "생성일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime createdAt; + + @ApiModelProperty(position = 10, required = true, value = "수정일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime updatedAt; + + public ProfilePageResponse(User user, List skills, List offers) { + this.userId = user.getId(); + this.nickname = user.getNickname(); + this.position = user.getPosition(); + this.reviewCnt = user.getReviewCnt(); + this.rating = user.getRating(); + this.imageUrl = user.getImageUrl(); + + this.skills = skills.stream() + .map(SkillResponse::new) + .collect(Collectors.toList()); + this.offers = offers.stream() + .map(OfferAbstractResponse::new) + .collect(Collectors.toList()); + + this.createdAt = user.getCreatedAt(); + this.updatedAt = user.getUpdatedAt(); + } +} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileUpdateResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileUpdateResponse.java new file mode 100644 index 00000000..28dafbb0 --- /dev/null +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/ProfileUpdateResponse.java @@ -0,0 +1,124 @@ +package com.gabojait.gabojaitspring.api.dto.profile.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gabojait.gabojaitspring.api.vo.profile.ProfileVO; +import com.gabojait.gabojaitspring.domain.profile.Skill; +import com.gabojait.gabojaitspring.domain.user.Position; +import com.gabojait.gabojaitspring.domain.user.User; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +@Getter +@ToString +@ApiModel(value = "프로필 업데이트 응답") +public class ProfileUpdateResponse { + + @ApiModelProperty(position = 1, required = true, value = "회원 식별자") + private Long userId; + + @ApiModelProperty(position = 2, required = true, value = "닉네임") + private String nickname; + + @ApiModelProperty(position = 3, required = true, value = "포지션", + allowableValues = "DESIGNER, BACKEND, FRONTEND, MANAGER, NONE") + private Position position; + + @ApiModelProperty(position = 4, required = true, value = "리뷰 수") + private Integer reviewCnt; + + @ApiModelProperty(position = 5, required = true, value = "평점") + private Float rating; + + @ApiModelProperty(position = 6, required = true, value = "프로필 사진") + private String imageUrl; + + @ApiModelProperty(position = 7, required = true, value = "자기소개") + private String profileDescription; + + @ApiModelProperty(position = 8, required = true, value = "리더 여부") + private Boolean isLeader; + + @ApiModelProperty(position = 9, required = true, value = "팀 찾기 여부") + private Boolean isSeekingTeam; + + @ApiModelProperty(position = 10, required = true, value = "기술들") + private List skills; + + @ApiModelProperty(position = 11, required = true, value = "학력들") + private List educations; + + @ApiModelProperty(position = 12, required = true, value = "포트폴리오들") + private List portfolios; + + @ApiModelProperty(position = 13, required = true, value = "경력들") + private List works; + + @ApiModelProperty(position = 14, required = true, value = "완료한 팀들") + private List completedTeams; + + @ApiModelProperty(position = 15, required = true, value = "현재 팀") + private ProfileTeamResponse currentTeam; + + @ApiModelProperty(position = 16, required = true, value = "리뷰들") + private List reviews; + + @ApiModelProperty(position = 17, required = true, value = "생성일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime createdAt; + + @ApiModelProperty(position = 18, required = true, value = "수정일") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") + private LocalDateTime updatedAt; + + public ProfileUpdateResponse(User user, List skills, ProfileVO profile) { + this.userId = user.getId(); + this.nickname = user.getNickname(); + this.position = user.getPosition(); + this.reviewCnt = user.getReviewCnt(); + this.rating = user.getRating(); + this.imageUrl = user.getImageUrl(); + this.profileDescription = user.getProfileDescription(); + this.isSeekingTeam = user.getIsSeekingTeam(); + + this.skills = skills.stream() + .map(SkillResponse::new) + .collect(Collectors.toList()); + this.educations = profile.getEducations().stream() + .map(EducationResponse::new) + .collect(Collectors.toList()); + this.portfolios = profile.getPortfolios().stream() + .map(PortfolioResponse::new) + .collect(Collectors.toList()); + this.works = profile.getWorks().stream() + .map(WorkResponse::new) + .collect(Collectors.toList()); + + this.completedTeams = profile.getTeamMembers().stream() + .filter(tm -> tm.getTeam().getCompletedAt() != null) + .map(tm -> new ProfileTeamResponse(tm.getTeam())) + .collect(Collectors.toList()); + this.isLeader = false; + profile.getTeamMembers().stream() + .filter(tm -> tm.getTeam().getCompletedAt() == null) + .findFirst() + .ifPresent(tm -> { + this.currentTeam = new ProfileTeamResponse(tm.getTeam()); + this.isLeader = tm.getIsLeader(); + }); + + this.reviews = IntStream.range(0, profile.getReviews().getContent().size()) + .mapToObj(i -> + new ProfileReviewResponse(profile.getReviews().getContent().get(i), (int) (profile.getReviewCnt() - i))) + .collect(Collectors.toList()); + + this.createdAt = user.getCreatedAt(); + this.updatedAt = user.getUpdatedAt(); + } +} diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/SkillDefaultResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/SkillResponse.java similarity index 92% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/SkillDefaultResponse.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/SkillResponse.java index 9e5d7333..540d6079 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/SkillDefaultResponse.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/SkillResponse.java @@ -12,8 +12,8 @@ @Getter @ToString -@ApiModel(value = "기술 기본 응답") -public class SkillDefaultResponse { +@ApiModel(value = "기술 응답") +public class SkillResponse { @ApiModelProperty(position = 1, required = true, value = "기술 식별자") private Long skillId; @@ -35,7 +35,7 @@ public class SkillDefaultResponse { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updatedAt; - public SkillDefaultResponse(Skill skill) { + public SkillResponse(Skill skill) { this.skillId = skill.getId(); this.skillName = skill.getSkillName(); this.isExperienced = skill.getIsExperienced(); diff --git a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/WorkDefaultResponse.java b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/WorkResponse.java similarity index 94% rename from src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/WorkDefaultResponse.java rename to src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/WorkResponse.java index efdd4a0d..0fe9c3e5 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/WorkDefaultResponse.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/dto/profile/response/WorkResponse.java @@ -12,8 +12,8 @@ @Getter @ToString -@ApiModel(value = "경력 기본 응답") -public class WorkDefaultResponse { +@ApiModel(value = "경력 응답") +public class WorkResponse { @ApiModelProperty(position = 1, required = true, value = "경력 식별자") private Long workId; @@ -43,7 +43,7 @@ public class WorkDefaultResponse { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updatedAt; - public WorkDefaultResponse(Work work) { + public WorkResponse(Work work) { this.workId = work.getId(); this.corporationName = work.getCorporationName(); this.workDescription = work.getWorkDescription(); diff --git a/src/main/java/com/gabojait/gabojaitspring/api/service/favorite/FavoriteService.java b/src/main/java/com/gabojait/gabojaitspring/api/service/favorite/FavoriteService.java index 119e7082..3fa9b290 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/service/favorite/FavoriteService.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/service/favorite/FavoriteService.java @@ -2,8 +2,8 @@ import com.gabojait.gabojaitspring.api.dto.common.response.PageData; import com.gabojait.gabojaitspring.api.dto.favorite.request.FavoriteDefaultRequest; -import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteTeamResponse; -import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteUserResponse; +import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteTeamPageResponse; +import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteUserPageResponse; import com.gabojait.gabojaitspring.domain.favorite.Favorite; import com.gabojait.gabojaitspring.domain.profile.Skill; import com.gabojait.gabojaitspring.domain.team.Team; @@ -94,9 +94,9 @@ public void updateFavoriteTeam(String username, long teamId, FavoriteDefaultRequ * @param username 회원 아이디 * @param pageFrom 페이지 시작점 * @param pageSize 페이지 크기 - * @return 찜한 회원 응답들 + * @return 찜한 회원 페이지 응답들 */ - public PageData> findPageFavoriteUser(String username, long pageFrom, int pageSize) { + public PageData> findPageFavoriteUser(String username, long pageFrom, int pageSize) { User user = findUser(username); Page favorites = favoriteRepository.findPageUser(user.getId(), pageFrom, pageSize); @@ -106,8 +106,9 @@ public PageData> findPageFavoriteUser(String username Map> sMap = skills.stream() .collect(Collectors.groupingBy(s -> s.getUser().getId())); - List responses = favorites.stream() - .map(f -> new FavoriteUserResponse(f, sMap.getOrDefault(f.getFavoriteUser().getId(), Collections.emptyList()))) + List responses = favorites.stream() + .map(f -> new FavoriteUserPageResponse(f, + sMap.getOrDefault(f.getFavoriteUser().getId(), Collections.emptyList()))) .collect(Collectors.toList()); return new PageData<>(responses, favorites.getTotalElements()); @@ -119,15 +120,15 @@ public PageData> findPageFavoriteUser(String username * @param username 회원 아이디 * @param pageFrom 페이지 시작점 * @param pageSize 페이지 크기 - * @return 찜한 팀 응답들 + * @return 찜한 팀 페이지 응답들 */ - public PageData> findPageFavoriteTeam(String username, long pageFrom, int pageSize) { + public PageData> findPageFavoriteTeam(String username, long pageFrom, int pageSize) { User user = findUser(username); Page favorites = favoriteRepository.findPageTeam(user.getId(), pageFrom, pageSize); - List responses = favorites.stream() - .map(FavoriteTeamResponse::new) + List responses = favorites.stream() + .map(FavoriteTeamPageResponse::new) .collect(Collectors.toList()); return new PageData<>(responses, favorites.getTotalElements()); diff --git a/src/main/java/com/gabojait/gabojaitspring/api/service/profile/ProfileService.java b/src/main/java/com/gabojait/gabojaitspring/api/service/profile/ProfileService.java index ccdfbc15..3e302942 100644 --- a/src/main/java/com/gabojait/gabojaitspring/api/service/profile/ProfileService.java +++ b/src/main/java/com/gabojait/gabojaitspring/api/service/profile/ProfileService.java @@ -2,10 +2,7 @@ import com.gabojait.gabojaitspring.api.dto.common.response.PageData; import com.gabojait.gabojaitspring.api.dto.profile.request.*; -import com.gabojait.gabojaitspring.api.dto.profile.response.PortfolioUrlResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileDefaultResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileDetailResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileOfferResponse; +import com.gabojait.gabojaitspring.api.dto.profile.response.*; import com.gabojait.gabojaitspring.api.vo.profile.ProfileVO; import com.gabojait.gabojaitspring.common.util.FileUtility; import com.gabojait.gabojaitspring.domain.offer.Offer; @@ -62,14 +59,14 @@ public class ProfileService { * 내 프로필 조회 | * 404(USER_NOT_FOUND) * @param username 회원 아이디 - * @return 프로필 기본 응답 + * @return 프로필 본인 조회 응답 */ - public ProfileDefaultResponse findMyProfile(String username) { + public ProfileFindMyselfResponse findMyProfile(String username) { User user = findUser(username); List skills = skillRepository.findAll(user.getId()); ProfileVO profile = findProfileInfo(user); - return new ProfileDefaultResponse(user, skills, profile); + return new ProfileFindMyselfResponse(user, skills, profile); } /** @@ -77,10 +74,10 @@ public ProfileDefaultResponse findMyProfile(String username) { * 404(USER_NOT_FOUND) * @param username 내 회원 아이디 * @param userId 타겟 회원 식별자 - * @return 프로필 상세 응답 + * @return 프로필 단건 조회 응답 */ @Transactional - public ProfileDetailResponse findOtherProfile(String username, long userId) { + public ProfileFindOtherResponse findOtherProfile(String username, long userId) { User targetUser = findUser(userId); List skills = skillRepository.findAll(targetUser.getId()); @@ -97,7 +94,7 @@ public ProfileDetailResponse findOtherProfile(String username, long userId) { targetUser.visit(); } - return new ProfileDetailResponse(targetUser, skills, profile, offers, isFavorite); + return new ProfileFindOtherResponse(targetUser, skills, profile, offers, isFavorite); } /** @@ -108,10 +105,10 @@ public ProfileDetailResponse findOtherProfile(String username, long userId) { * 500(SERVER_ERROR) * @param username 회원 아이디 * @param image 프로필 이미지 - * @return 프로필 기본 응답 + * @return 프로필 이미지 응답 */ @Transactional - public ProfileDefaultResponse uploadProfileImage(String username, MultipartFile image) { + public ProfileImageResponse uploadProfileImage(String username, MultipartFile image) { User user = findUser(username); String url = fileUtility.upload(profileImgBucketName, user.getId().toString(), UUID.randomUUID().toString(), @@ -122,17 +119,17 @@ public ProfileDefaultResponse uploadProfileImage(String username, MultipartFile List skills = skillRepository.findAll(user.getId()); ProfileVO profile = findProfileInfo(user); - return new ProfileDefaultResponse(user, skills, profile); + return new ProfileImageResponse(user, skills, profile); } /** * 프로필 이미지 삭제 | * 404(USER_NOT_FOUND) * @param username 회원 아이디 - * @return 프로필 기본 응답 + * @return 프로필 이미지 응답 */ @Transactional - public ProfileDefaultResponse deleteProfileImage(String username) { + public ProfileImageResponse deleteProfileImage(String username) { User user = findUser(username); user.updateImageUrl(null); @@ -140,7 +137,7 @@ public ProfileDefaultResponse deleteProfileImage(String username) { List skills = skillRepository.findAll(user.getId()); ProfileVO profile = findProfileInfo(user); - return new ProfileDefaultResponse(user, skills, profile); + return new ProfileImageResponse(user, skills, profile); } /** @@ -161,11 +158,11 @@ public void updateIsSeekingTeam(String username, boolean isSeekingTeam) { * 400(EDUCATION_DATE_INVALID / EDUCATION_ENDED_AT_FIELD_REQUIRED / WORK_DATE_INVALID / WORK_ENDED_AT_FIELD_REQUIRED) * 404(USER_NOT_FOUND) * @param username 회원 아이디 - * @param request 프로필 기본 요청 - * @return 프로필 기본 응답 + * @param request 프로필 업데이트 요청 + * @return 프로필 업데이트 응답 */ @Transactional - public ProfileDefaultResponse updateProfile(String username, ProfileDefaultRequest request) { + public ProfileUpdateResponse updateProfile(String username, ProfileUpdateRequest request) { User user = findUser(username); validateDate(request.getEducations(), request.getWorks()); @@ -179,16 +176,16 @@ public ProfileDefaultResponse updateProfile(String username, ProfileDefaultReque List skills = skillRepository.findAll(user.getId()); ProfileVO profile = findProfileInfo(user); - return new ProfileDefaultResponse(user, skills, profile); + return new ProfileUpdateResponse(user, skills, profile); } /** * 학력들 생성 수정 및 삭제 | * @param user 회원 - * @param requests 학력 기본 요청 + * @param requests 학력 업데이트 요청들 */ @Transactional - public void updateEducations(User user, List requests) { + public void updateEducations(User user, List requests) { List currentEducations = educationRepository.findAll(user.getId()); if (requests.isEmpty()) { @@ -196,7 +193,7 @@ public void updateEducations(User user, List requests) return; } - for (EducationDefaultRequest request : requests) { + for (EducationUpdateRequest request : requests) { if (request.getEducationId() == null) educationRepository.save(request.toEntity(user)); else @@ -220,10 +217,10 @@ public void updateEducations(User user, List requests) /** * 포트폴리오들 생성 수정 및 삭제 * @param user 회원 - * @param requests 포트폴리오 기본 요청 + * @param requests 포트폴리오 업데이트 요청들 */ @Transactional - public void updatePortfolios(User user, List requests) { + public void updatePortfolios(User user, List requests) { List currentPortfolios = portfolioRepository.findAll(user.getId()); if (requests.isEmpty()) { @@ -231,7 +228,7 @@ public void updatePortfolios(User user, List requests) return; } - for (PortfolioDefaultRequest request : requests) { + for (PortfolioUpdateRequest request : requests) { if (request.getPortfolioId() == null) portfolioRepository.save(request.toEntity(user)); else @@ -254,10 +251,10 @@ public void updatePortfolios(User user, List requests) /** * 기술들 생성 수정 및 삭제 * @param user 회원 - * @param requests 기술 기본 요청 + * @param requests 기술 업데이트 요청들 */ @Transactional - public void updateSkills(User user, List requests) { + public void updateSkills(User user, List requests) { List currentSkills = skillRepository.findAll(user.getId()); if (requests.isEmpty()) { @@ -265,7 +262,7 @@ public void updateSkills(User user, List requests) { return; } - for (SkillDefaultRequest request : requests) { + for (SkillUpdateRequest request : requests) { if (request.getSkillId() == null) skillRepository.save(request.toEntity(user)); else @@ -288,10 +285,10 @@ public void updateSkills(User user, List requests) { /** * 경력들 생성 수정 및 삭제 * @param user 회원 - * @param requests 경력 기본 요청 + * @param requests 경력 업데이트 요청들 */ @Transactional - public void updateWorks(User user, List requests) { + public void updateWorks(User user, List requests) { List currentWorks = workRepository.findAll(user.getId()); if (requests.isEmpty()) { @@ -299,7 +296,7 @@ public void updateWorks(User user, List requests) { return; } - for (WorkDefaultRequest request : requests) { + for (WorkUpdateRequest request : requests) { if (request.getWorkId() == null) workRepository.save(request.toEntity(user)); else @@ -325,11 +322,11 @@ public void updateWorks(User user, List requests) { * 날짜 검증 | * 400(EDUCATION_DATE_INVALID / EDUCATION_ENDED_AT_FIELD_REQUIRED / WORK_DATE_INVALID / * WORK_ENDED_AT_FIELD_REQUIRED) - * @param educations 학력들 - * @param works 경력들 + * @param educationRequests 학력 업데이트 요청들 + * @param workRequests 경력 업데이트 요청들 */ - private void validateDate(List educations, List works) { - educations.forEach(education -> { + private void validateDate(List educationRequests, List workRequests) { + educationRequests.forEach(education -> { if (education.getEndedAt() == null) { if (!education.getIsCurrent()) throw new CustomException(EDUCATION_ENDED_AT_FIELD_REQUIRED); @@ -339,7 +336,7 @@ private void validateDate(List educations, List { + workRequests.forEach(work -> { if (work.getEndedAt() == null) { if (!work.getIsCurrent()) throw new CustomException(WORK_ENDED_AT_FIELD_REQUIRED); @@ -390,7 +387,7 @@ public PortfolioUrlResponse uploadPortfolioFile(String username, MultipartFile f * @param pageSize 페이지 크기 * @return 프로필 제안 응답들 */ - public PageData> findPageUser(String username, Position position, long pageFrom, int pageSize) { + public PageData> findPageUser(String username, Position position, long pageFrom, int pageSize) { User user = findUser(username); PageData> users = userRepository.findPage(position, pageFrom, pageSize); @@ -409,10 +406,10 @@ public PageData> findPageUser(String username, Positi Map> oMap = offers.stream() .collect(Collectors.groupingBy(o -> o.getUser().getId())); - List responses = users.getData() + List responses = users.getData() .stream() .map(u -> - new ProfileOfferResponse(u, + new ProfilePageResponse(u, sMap.getOrDefault(u.getId(), Collections.emptyList()), oMap.getOrDefault(u.getId(), Collections.emptyList()))) .collect(Collectors.toList()); diff --git a/src/main/java/com/gabojait/gabojaitspring/config/SwaggerConfig.java b/src/main/java/com/gabojait/gabojaitspring/config/SwaggerConfig.java index f32b914a..f2d8ba1f 100644 --- a/src/main/java/com/gabojait/gabojaitspring/config/SwaggerConfig.java +++ b/src/main/java/com/gabojait/gabojaitspring/config/SwaggerConfig.java @@ -2,8 +2,9 @@ import com.fasterxml.classmate.TypeResolver; import com.gabojait.gabojaitspring.api.dto.common.response.*; -import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteTeamResponse; -import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteUserResponse; +import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteSkillResponse; +import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteTeamPageResponse; +import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteUserPageResponse; import com.gabojait.gabojaitspring.api.dto.notification.response.NotificationDefaultResponse; import com.gabojait.gabojaitspring.api.dto.offer.response.OfferAbstractResponse; import com.gabojait.gabojaitspring.api.dto.offer.response.OfferDefaultResponse; @@ -11,7 +12,6 @@ import com.gabojait.gabojaitspring.api.dto.review.response.ReviewFindAllTeamResponse; import com.gabojait.gabojaitspring.api.dto.review.response.ReviewFindTeamResponse; import com.gabojait.gabojaitspring.api.dto.review.response.ReviewPageResponse; -import com.gabojait.gabojaitspring.api.dto.team.request.TeamUpdateRequest; import com.gabojait.gabojaitspring.api.dto.team.response.*; import com.gabojait.gabojaitspring.api.dto.user.response.*; import org.springframework.context.annotation.Bean; @@ -52,30 +52,34 @@ public Docket api() { .additionalModels(typeResolver.resolve(UserLoginResponse.class)) .additionalModels(typeResolver.resolve(UserFindMyselfResponse.class)) .additionalModels(typeResolver.resolve(UserContactResponse.class)) - .additionalModels(typeResolver.resolve(EducationDefaultResponse.class)) - .additionalModels(typeResolver.resolve(PortfolioDefaultResponse.class)) - .additionalModels(typeResolver.resolve(PortfolioUrlResponse.class)) - .additionalModels(typeResolver.resolve(SkillDefaultResponse.class)) - .additionalModels(typeResolver.resolve(WorkDefaultResponse.class)) - .additionalModels(typeResolver.resolve(ProfileAbstractResponse.class)) - .additionalModels(typeResolver.resolve(ProfileDefaultResponse.class)) - .additionalModels(typeResolver.resolve(ProfileDetailResponse.class)) - .additionalModels(typeResolver.resolve(ProfileOfferResponse.class)) + .additionalModels(typeResolver.resolve(EducationResponse.class)) + .additionalModels(typeResolver.resolve(PortfolioResponse.class)) + .additionalModels(typeResolver.resolve(SkillResponse.class)) + .additionalModels(typeResolver.resolve(WorkResponse.class)) + .additionalModels(typeResolver.resolve(PortfolioResponse.class)) .additionalModels(typeResolver.resolve(ProfileReviewResponse.class)) + .additionalModels(typeResolver.resolve(ProfileTeamResponse.class)) + .additionalModels(typeResolver.resolve(ProfileOfferResponse.class)) + .additionalModels(typeResolver.resolve(PortfolioUrlResponse.class)) + .additionalModels(typeResolver.resolve(ProfileFindMyselfResponse.class)) + .additionalModels(typeResolver.resolve(ProfileFindOtherResponse.class)) + .additionalModels(typeResolver.resolve(ProfileImageResponse.class)) + .additionalModels(typeResolver.resolve(ProfileUpdateResponse.class)) .additionalModels(typeResolver.resolve(TeamCreateResponse.class)) .additionalModels(typeResolver.resolve(TeamFindResponse.class)) .additionalModels(typeResolver.resolve(TeamMemberResponse.class)) .additionalModels(typeResolver.resolve(TeamMyCurrentResponse.class)) .additionalModels(typeResolver.resolve(TeamPageResponse.class)) - .additionalModels(typeResolver.resolve(TeamUpdateRequest.class)) + .additionalModels(typeResolver.resolve(TeamUpdateResponse.class)) .additionalModels(typeResolver.resolve(ReviewFindAllTeamResponse.class)) .additionalModels(typeResolver.resolve(ReviewFindTeamResponse.class)) .additionalModels(typeResolver.resolve(ReviewPageResponse.class)) .additionalModels(typeResolver.resolve(OfferAbstractResponse.class)) .additionalModels(typeResolver.resolve(OfferDefaultResponse.class)) .additionalModels(typeResolver.resolve(NotificationDefaultResponse.class)) - .additionalModels(typeResolver.resolve(FavoriteTeamResponse.class)) - .additionalModels(typeResolver.resolve(FavoriteUserResponse.class)) + .additionalModels(typeResolver.resolve(FavoriteTeamPageResponse.class)) + .additionalModels(typeResolver.resolve(FavoriteUserPageResponse.class)) + .additionalModels(typeResolver.resolve(FavoriteSkillResponse.class)) .useDefaultResponseMessages(false) .apiInfo(apiInfo()) .securityContexts(Collections.singletonList(securityContext())) diff --git a/src/test/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileControllerTest.java b/src/test/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileControllerTest.java index 954f7d3e..be8a6c55 100644 --- a/src/test/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileControllerTest.java +++ b/src/test/java/com/gabojait/gabojaitspring/api/controller/profile/ProfileControllerTest.java @@ -188,7 +188,7 @@ void givenBlankIsSeekingTeam_whenUpdateIsSeekingTeam_thenReturn400() throws Exce @DisplayName("자기소개 업데이트를 하면 200을 반환한다.") void givenValid_whenUpdateDescription_thenReturn200() throws Exception { // given - ProfileDescriptionUpdateRequest request = createValidProfileDescriptionUpdateRequest(); + ProfileDescriptionRequest request = createValidProfileDescriptionRequest(); // when ResultActions actions = mockMvc.perform( @@ -210,7 +210,7 @@ void givenValid_whenUpdateDescription_thenReturn200() throws Exception { @DisplayName("자기소개 200자 초과일시 자기소개 업데이트를 하면 400을 반환한다.") void givenMoreThan200SizeProfileDescription_whenUpdateDescription_thenReturn400() throws Exception { // given - ProfileDescriptionUpdateRequest request = createValidProfileDescriptionUpdateRequest(); + ProfileDescriptionRequest request = createValidProfileDescriptionRequest(); request.setProfileDescription("가".repeat(200)); // when @@ -233,7 +233,7 @@ void givenMoreThan200SizeProfileDescription_whenUpdateDescription_thenReturn400( @DisplayName("프로필 업데이트를 하면 200을 반환한다.") void givenValid_whenUpdateProfile_thenReturn200() throws Exception { // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); // when ResultActions actions = mockMvc.perform( @@ -251,34 +251,11 @@ void givenValid_whenUpdateProfile_thenReturn200() throws Exception { .value(PROFILE_UPDATED.getMessage())); } - @Test - @DisplayName("포지션 미입력시 프로필 업데이트를 하면 400을 반환한다.") - void givenBlankPosition_whenUpdateProfile_thenReturn400() throws Exception { - // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); - request.setPosition(""); - - // when - ResultActions actions = mockMvc.perform( - post("/api/v1/user/profile") - .content(objectMapper.writeValueAsString(request)) - .contentType(APPLICATION_JSON) - ); - - // then - actions.andDo(print()) - .andExpect(status().isBadRequest()) - .andExpect(jsonPath("$.responseCode") - .value(POSITION_FIELD_REQUIRED.name())) - .andExpect(jsonPath("$.responseMessage") - .value(POSITION_FIELD_REQUIRED.getMessage())); - } - @Test @DisplayName("잘못된 포지션 타입일시 프로필 업데이트를 하면 400을 반환한다.") void givenFormatPosition_whenUpdateProfile_thenReturn400() throws Exception { // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.setPosition("OPERATOR"); // when @@ -297,34 +274,11 @@ void givenFormatPosition_whenUpdateProfile_thenReturn400() throws Exception { .value(POSITION_TYPE_INVALID.getMessage())); } - @Test - @DisplayName("기술명 미입력시 프로필 업데이트를 하면 400을 반환한다.") - void givenBlankSkillName_whenUpdateProfile_thenReturn400() throws Exception { - // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); - request.getSkills().get(0).setSkillName(""); - - // when - ResultActions actions = mockMvc.perform( - post("/api/v1/user/profile") - .content(objectMapper.writeValueAsString(request)) - .contentType(APPLICATION_JSON) - ); - - // then - actions.andDo(print()) - .andExpect(status().isBadRequest()) - .andExpect(jsonPath("$.responseCode") - .value(SKILL_NAME_FIELD_REQUIRED.name())) - .andExpect(jsonPath("$.responseMessage") - .value(SKILL_NAME_FIELD_REQUIRED.getMessage())); - } - @Test @DisplayName("기술명 20자 초과일시 프로필 업데이트를 하면 400을 반환한다.") void givenGreaterThan20SkillName_whenUpdateProfile_thenReturn400() throws Exception { // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getSkills().get(0).setSkillName("가".repeat(21)); // when @@ -347,7 +301,7 @@ void givenGreaterThan20SkillName_whenUpdateProfile_thenReturn400() throws Except @DisplayName("경험 여부 미입력시 프로필 업데이트를 하면 400을 반환한다.") void givenBlankIsExperienced_whenUpdateProfile_thenReturn400() throws Exception { // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getSkills().get(0).setIsExperienced(null); // when @@ -370,7 +324,7 @@ void givenBlankIsExperienced_whenUpdateProfile_thenReturn400() throws Exception @DisplayName("레벨 미입력시 프로필 업데이트를 하면 400을 반환한다.") void givenBlankLevel_whenUpdateProfile_thenReturn400() throws Exception { // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getSkills().get(0).setLevel(null); // when @@ -390,10 +344,10 @@ void givenBlankLevel_whenUpdateProfile_thenReturn400() throws Exception { } @Test - @DisplayName("올바르지 않은 레벨로로 프로필 업데이트를 하면 400을 반환한다.") + @DisplayName("올바르지 않은 레벨로 프로필 업데이트를 하면 400을 반환한다.") void givenFormatLevel_whenUpdateProfile_thenReturn400() throws Exception { // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getSkills().get(0).setLevel("GOOD"); // when @@ -412,34 +366,11 @@ void givenFormatLevel_whenUpdateProfile_thenReturn400() throws Exception { .value(LEVEL_TYPE_INVALID.getMessage())); } - @Test - @DisplayName("학교명 미입력시 프로필 업데이트를 하면 400을 반환한다.") - void givenBlankInstitutionName_whenUpdateProfile_thenReturn400() throws Exception { - // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); - request.getEducations().get(0).setInstitutionName(""); - - // when - ResultActions actions = mockMvc.perform( - post("/api/v1/user/profile") - .content(objectMapper.writeValueAsString(request)) - .contentType(APPLICATION_JSON) - ); - - // then - actions.andDo(print()) - .andExpect(status().isBadRequest()) - .andExpect(jsonPath("$.responseCode") - .value(INSTITUTION_NAME_FIELD_REQUIRED.name())) - .andExpect(jsonPath("$.responseMessage") - .value(INSTITUTION_NAME_FIELD_REQUIRED.getMessage())); - } - @Test @DisplayName("학교명 3자 미만일시 프로필 업데이트를 하면 400을 반환한다.") void givenLessThan3InstitutionName_whenUpdateProfile_thenReturn400() throws Exception { // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getEducations().get(0).setInstitutionName("대학"); // when @@ -462,7 +393,7 @@ void givenLessThan3InstitutionName_whenUpdateProfile_thenReturn400() throws Exce @DisplayName("학교명 3자 미만일시 프로필 업데이트를 하면 400을 반환한다.") void givenGreaterThan20InstitutionName_whenUpdateProfile_thenReturn400() throws Exception { // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getEducations().get(0).setInstitutionName("대".repeat(21)); // when @@ -485,7 +416,7 @@ void givenGreaterThan20InstitutionName_whenUpdateProfile_thenReturn400() throws @DisplayName("시작일 미입력시 프로필 업데이트를 하면 400을 반환한다.") void givenBlankStartedAt_whenUpdateProfile_thenReturn400() throws Exception { // given - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getEducations().get(0).setStartedAt(null); // when @@ -627,18 +558,18 @@ void givenGreaterThan100PageSize_whenFindUsersLookingForTeam_theReturn400() thro .value(PAGE_SIZE_RANGE_INVALID.getMessage())); } - private ProfileDefaultRequest createValidProfileDefaultRequest() { - return ProfileDefaultRequest.builder() + private ProfileUpdateRequest createValidProfileUpdateRequest() { + return ProfileUpdateRequest.builder() .position(Position.BACKEND.toString()) - .educations(List.of(createValidEducationDefaultRequest())) - .portfolios(List.of(createValidPortfolioDefaultRequest())) - .skills(List.of(createValidSkillDefaultRequest())) - .works(List.of(createValidWorkDefaultRequest())) + .educations(List.of(createValidEducationUpdateRequest())) + .portfolios(List.of(createValidPortfolioUpdateRequest())) + .skills(List.of(createValidSkillUpdateRequest())) + .works(List.of(createValidWorkUpdateRequest())) .build(); } - private EducationDefaultRequest createValidEducationDefaultRequest() { - return EducationDefaultRequest.builder() + private EducationUpdateRequest createValidEducationUpdateRequest() { + return EducationUpdateRequest.builder() .institutionName("가보자잇대") .startedAt(LocalDate.of(2000, 1, 1)) .endedAt(LocalDate.of(2001, 1, 1)) @@ -646,24 +577,24 @@ private EducationDefaultRequest createValidEducationDefaultRequest() { .build(); } - private PortfolioDefaultRequest createValidPortfolioDefaultRequest() { - return PortfolioDefaultRequest.builder() + private PortfolioUpdateRequest createValidPortfolioUpdateRequest() { + return PortfolioUpdateRequest.builder() .portfolioName("깃허브") .portfolioUrl("github.com/gabojait") .media(Media.LINK.toString()) .build(); } - private SkillDefaultRequest createValidSkillDefaultRequest() { - return SkillDefaultRequest.builder() + private SkillUpdateRequest createValidSkillUpdateRequest() { + return SkillUpdateRequest.builder() .skillName("스프링") .isExperienced(true) .level(Level.HIGH.toString()) .build(); } - private WorkDefaultRequest createValidWorkDefaultRequest() { - return WorkDefaultRequest.builder() + private WorkUpdateRequest createValidWorkUpdateRequest() { + return WorkUpdateRequest.builder() .corporationName("가보자잇사") .workDescription("백엔드 개발") .startedAt(LocalDate.of(2000, 1, 1)) @@ -672,8 +603,8 @@ private WorkDefaultRequest createValidWorkDefaultRequest() { .build(); } - private ProfileDescriptionUpdateRequest createValidProfileDescriptionUpdateRequest() { - return ProfileDescriptionUpdateRequest.builder() + private ProfileDescriptionRequest createValidProfileDescriptionRequest() { + return ProfileDescriptionRequest.builder() .profileDescription("안녕하세요.") .build(); } diff --git a/src/test/java/com/gabojait/gabojaitspring/api/service/favorite/FavoriteServiceTest.java b/src/test/java/com/gabojait/gabojaitspring/api/service/favorite/FavoriteServiceTest.java index ca5f02ac..74986825 100644 --- a/src/test/java/com/gabojait/gabojaitspring/api/service/favorite/FavoriteServiceTest.java +++ b/src/test/java/com/gabojait/gabojaitspring/api/service/favorite/FavoriteServiceTest.java @@ -2,8 +2,8 @@ import com.gabojait.gabojaitspring.api.dto.common.response.PageData; import com.gabojait.gabojaitspring.api.dto.favorite.request.FavoriteDefaultRequest; -import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteTeamResponse; -import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteUserResponse; +import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteTeamPageResponse; +import com.gabojait.gabojaitspring.api.dto.favorite.response.FavoriteUserPageResponse; import com.gabojait.gabojaitspring.domain.favorite.Favorite; import com.gabojait.gabojaitspring.domain.team.Team; import com.gabojait.gabojaitspring.domain.user.Contact; @@ -210,7 +210,7 @@ void givenValid_whenFindPageFavoriteUser_thenReturn() { int pageSize = 2; // when - PageData> responses = favoriteService.findPageFavoriteUser(user1.getUsername(), + PageData> responses = favoriteService.findPageFavoriteUser(user1.getUsername(), pageFrom, pageSize); // then @@ -261,7 +261,7 @@ void givenValid_whenFindPageFavoriteTeam_thenReturn() { int pageSize = 2; // when - PageData> responses = favoriteService.findPageFavoriteTeam(user.getUsername(), + PageData> responses = favoriteService.findPageFavoriteTeam(user.getUsername(), pageFrom, pageSize); // then diff --git a/src/test/java/com/gabojait/gabojaitspring/api/service/profile/ProfileServiceTest.java b/src/test/java/com/gabojait/gabojaitspring/api/service/profile/ProfileServiceTest.java index 90606477..3584cf8d 100644 --- a/src/test/java/com/gabojait/gabojaitspring/api/service/profile/ProfileServiceTest.java +++ b/src/test/java/com/gabojait/gabojaitspring/api/service/profile/ProfileServiceTest.java @@ -2,10 +2,7 @@ import com.gabojait.gabojaitspring.api.dto.common.response.PageData; import com.gabojait.gabojaitspring.api.dto.profile.request.*; -import com.gabojait.gabojaitspring.api.dto.profile.response.PortfolioUrlResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileDefaultResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileDetailResponse; -import com.gabojait.gabojaitspring.api.dto.profile.response.ProfileOfferResponse; +import com.gabojait.gabojaitspring.api.dto.profile.response.*; import com.gabojait.gabojaitspring.common.util.FileUtility; import com.gabojait.gabojaitspring.domain.offer.Offer; import com.gabojait.gabojaitspring.domain.offer.OfferedBy; @@ -13,7 +10,6 @@ import com.gabojait.gabojaitspring.domain.review.Review; import com.gabojait.gabojaitspring.domain.team.Team; import com.gabojait.gabojaitspring.domain.team.TeamMember; -import com.gabojait.gabojaitspring.domain.team.TeamMemberStatus; import com.gabojait.gabojaitspring.domain.user.*; import com.gabojait.gabojaitspring.exception.CustomException; import com.gabojait.gabojaitspring.repository.offer.OfferRepository; @@ -112,7 +108,7 @@ void givenMyUserId_whenMyFindProfile_thenReturn() { teamMemberRepository.save(currentTeamMember); // when - ProfileDefaultResponse response = profileService.findMyProfile(user2.getUsername()); + ProfileFindMyselfResponse response = profileService.findMyProfile(user2.getUsername()); // then assertThat(userRepository.findById(user2.getId()).get().getVisitedCnt()) @@ -258,7 +254,7 @@ void givenOtherUserId_whenFindOtherProfile_thenReturn() { teamMemberRepository.save(currentTeamMember); // when - ProfileDetailResponse response = profileService.findOtherProfile(user1.getUsername(), user2.getId()); + ProfileFindOtherResponse response = profileService.findOtherProfile(user1.getUsername(), user2.getId()); // then assertThat(userRepository.findById(user2.getId()).get().getVisitedCnt()) @@ -407,7 +403,7 @@ void givenMyUserId_whenFindOtherProfile_thenReturn() { teamMemberRepository.save(currentTeamMember); // when - ProfileDetailResponse response = profileService.findOtherProfile(user2.getUsername(), user2.getId()); + ProfileFindOtherResponse response = profileService.findOtherProfile(user2.getUsername(), user2.getId()); // then assertThat(userRepository.findById(user2.getId()).get().getVisitedCnt()) @@ -550,7 +546,7 @@ void givenValid_whenUploadProfileImage_thenReturn() { MultipartFile image = new MockMultipartFile("data", "filename.txt", "image/png", "image".getBytes()); // when - ProfileDefaultResponse response = profileService.uploadProfileImage(user.getUsername(), image); + ProfileImageResponse response = profileService.uploadProfileImage(user.getUsername(), image); // then assertThat(response.getImageUrl()).isNotBlank(); @@ -608,7 +604,7 @@ void givenUsername_whenDeleteProfileImage_thenReturn() { User user = createSavedDefaultUser("tester@gabojait.com", "tester", "테스터"); // when - ProfileDefaultResponse response = profileService.deleteProfileImage(user.getUsername()); + ProfileImageResponse response = profileService.deleteProfileImage(user.getUsername()); // then assertThat(response.getImageUrl()).isNull(); @@ -698,15 +694,15 @@ void givenValid_whenUpdateEducations_thenReturn() { Education education3 = createEducation("가보자잇대", LocalDate.of(2002, 1, 1), user); educationRepository.saveAll(List.of(education1, education2, education3)); - EducationDefaultRequest request1 = createEducationDefaultRequest(education2.getId(), + EducationUpdateRequest request1 = createEducationUpdateRequest(education2.getId(), education2.getInstitutionName(), education2.getStartedAt(), education2.getEndedAt(), education2.getIsCurrent()); - EducationDefaultRequest request2 = createEducationDefaultRequest(education3.getId(), "가볼까잇대", + EducationUpdateRequest request2 = createEducationUpdateRequest(education3.getId(), "가볼까잇대", LocalDate.of(2003, 1, 1), LocalDate.of(2004, 1, 1), false); - EducationDefaultRequest request3 = createEducationDefaultRequest(null, "가보자잇대학원", + EducationUpdateRequest request3 = createEducationUpdateRequest(null, "가보자잇대학원", LocalDate.of(2004, 1, 1), null, true); - List requests = new ArrayList<>(List.of(request1, request2, request3)); + List requests = new ArrayList<>(List.of(request1, request2, request3)); // when profileService.updateEducations(user, requests); @@ -737,14 +733,14 @@ void givenValid_whenUpdatePortfolios_thenReturn() { Portfolio portfolio3 = createPortfolio("포트폴리오3", user); portfolioRepository.saveAll(List.of(portfolio1, portfolio2, portfolio3)); - PortfolioDefaultRequest request1 = createPortfolioDefaultRequest(portfolio2.getId(), + PortfolioUpdateRequest request1 = createPortfolioUpdateRequest(portfolio2.getId(), portfolio2.getPortfolioName(), portfolio2.getPortfolioUrl(), portfolio2.getMedia().toString()); - PortfolioDefaultRequest request2 = createPortfolioDefaultRequest(portfolio3.getId(), "포트폴리오4", + PortfolioUpdateRequest request2 = createPortfolioUpdateRequest(portfolio3.getId(), "포트폴리오4", "github.com/gabojait1", Media.FILE.toString()); - PortfolioDefaultRequest request3 = createPortfolioDefaultRequest(null, "포트폴리오5", + PortfolioUpdateRequest request3 = createPortfolioUpdateRequest(null, "포트폴리오5", "github.com/gabojait2", Media.LINK.toString()); - List requests = new ArrayList<>(List.of(request1, request2, request3)); + List requests = new ArrayList<>(List.of(request1, request2, request3)); // when profileService.updatePortfolios(user, requests); @@ -772,12 +768,12 @@ void givenValid_whenUpdateSkills_thenReturn() { Skill skill3 = createSkill("스킬3", user); skillRepository.saveAll(List.of(skill1, skill2, skill3)); - SkillDefaultRequest request1 = createSkillDefaultRequest(skill2.getId(), skill2.getSkillName(), + SkillUpdateRequest request1 = createSkillUpdateRequest(skill2.getId(), skill2.getSkillName(), skill2.getIsExperienced(), skill2.getLevel().toString()); - SkillDefaultRequest request2 = createSkillDefaultRequest(skill3.getId(), "스킬4", false, Level.LOW.toString()); - SkillDefaultRequest request3 = createSkillDefaultRequest(null, "스킬4", true, Level.HIGH.toString()); + SkillUpdateRequest request2 = createSkillUpdateRequest(skill3.getId(), "스킬4", false, Level.LOW.toString()); + SkillUpdateRequest request3 = createSkillUpdateRequest(null, "스킬4", true, Level.HIGH.toString()); - List requests = new ArrayList<>(List.of(request1, request2, request3)); + List requests = new ArrayList<>(List.of(request1, request2, request3)); // when profileService.updateSkills(user, requests); @@ -805,14 +801,14 @@ void givenValid_whenUpdateWorks_thenReturn() { Work work3 = createWork("경력3", LocalDate.of(2002, 1, 1), user); workRepository.saveAll(List.of(work1, work2, work3)); - WorkDefaultRequest request1 = createWorkDefaultRequest(work2.getId(), work2.getCorporationName(), + WorkUpdateRequest request1 = createWorkUpdateRequest(work2.getId(), work2.getCorporationName(), work2.getWorkDescription(), work2.getStartedAt(), work2.getEndedAt(), work2.getIsCurrent()); - WorkDefaultRequest request2 = createWorkDefaultRequest(work3.getId(), "경력4", "경력4", LocalDate.of(2003, 1, 1), + WorkUpdateRequest request2 = createWorkUpdateRequest(work3.getId(), "경력4", "경력4", LocalDate.of(2003, 1, 1), LocalDate.of(2004, 1, 1), false); - WorkDefaultRequest request3 = createWorkDefaultRequest(null, "경력5", "경력5", LocalDate.of(2004, 1, 1), + WorkUpdateRequest request3 = createWorkUpdateRequest(null, "경력5", "경력5", LocalDate.of(2004, 1, 1), LocalDate.of(2005, 1, 1), false); - List requests = new ArrayList<>(List.of(request1, request2, request3)); + List requests = new ArrayList<>(List.of(request1, request2, request3)); // when profileService.updateWorks(user, requests); @@ -838,10 +834,10 @@ void givenValid_whenUpdateProfile_thenReturn() { // given User user = createSavedDefaultUser("tester@gabojait.com", "tester", "테스터"); - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); // when - ProfileDefaultResponse response = profileService.updateProfile(user.getUsername(), request); + ProfileUpdateResponse response = profileService.updateProfile(user.getUsername(), request); // then assertThat(response.getPosition().toString()).isEqualTo(request.getPosition()); @@ -888,7 +884,7 @@ void givenInvalidEducationDate_whenUpdateProfile_thenThrow() { // given User user = createSavedDefaultUser("tester@gabojait.com", "tester", "테스터"); - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getEducations().get(0).setStartedAt(LocalDate.of(2001, 1, 1)); request.getEducations().get(0).setEndedAt(LocalDate.of(2000, 1, 1)); request.getEducations().get(0).setIsCurrent(false); @@ -906,7 +902,7 @@ void givenBlankEducationEndedAt_whenUpdateProfile_thenThrow() { // given User user = createSavedDefaultUser("tester@gabojait.com", "tester", "테스터"); - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getEducations().get(0).setStartedAt(LocalDate.of(2001, 1, 1)); request.getEducations().get(0).setEndedAt(null); request.getEducations().get(0).setIsCurrent(false); @@ -924,7 +920,7 @@ void givenInvalidWorkDate_whenUpdateProfile_thenThrow() { // given User user = createSavedDefaultUser("tester@gabojait.com", "tester", "테스터"); - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getWorks().get(0).setStartedAt(LocalDate.of(2001, 1, 1)); request.getWorks().get(0).setEndedAt(LocalDate.of(2000, 1, 1)); request.getWorks().get(0).setIsCurrent(false); @@ -942,7 +938,7 @@ void givenBlankWorkEndedAt_whenUpdateProfile_thenThrow() { // given User user = createSavedDefaultUser("tester@gabojait.com", "tester", "테스터"); - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); request.getWorks().get(0).setStartedAt(LocalDate.of(2001, 1, 1)); request.getWorks().get(0).setEndedAt(null); request.getWorks().get(0).setIsCurrent(false); @@ -960,7 +956,7 @@ void givenNonExistingUsername_whenUpdateProfile_thenThrow() { // given String username = "tester"; - ProfileDefaultRequest request = createValidProfileDefaultRequest(); + ProfileUpdateRequest request = createValidProfileUpdateRequest(); // when & then assertThatThrownBy(() -> profileService.updateProfile(username, request)) @@ -1053,7 +1049,7 @@ void givenValid_whenFindPageUser_thenReturn() { int pageSize = 2; // when - PageData> users = profileService.findPageUser(user1.getUsername(), position, + PageData> users = profileService.findPageUser(user1.getUsername(), position, pageFrom, pageSize); // then @@ -1097,16 +1093,16 @@ void givenNonExistingUser_whenFindPageUser_thenThrow() { .isEqualTo(USER_NOT_FOUND); } - private ProfileDefaultRequest createValidProfileDefaultRequest() { - EducationDefaultRequest educationRequest = createEducationDefaultRequest(null, "가보자잇대", + private ProfileUpdateRequest createValidProfileUpdateRequest() { + EducationUpdateRequest educationRequest = createEducationUpdateRequest(null, "가보자잇대", LocalDate.of(2004, 1, 1), null, true); - PortfolioDefaultRequest portfolioRequest = createPortfolioDefaultRequest(null, "포트폴리오", + PortfolioUpdateRequest portfolioRequest = createPortfolioUpdateRequest(null, "포트폴리오", "github.com/gabojait", Media.LINK.toString()); - SkillDefaultRequest skillRequest = createSkillDefaultRequest(null, "스킬", true, Level.HIGH.toString()); - WorkDefaultRequest workRequest = createWorkDefaultRequest(null, "경력", "경력", LocalDate.of(2004, 1, 1), + SkillUpdateRequest skillRequest = createSkillUpdateRequest(null, "스킬", true, Level.HIGH.toString()); + WorkUpdateRequest workRequest = createWorkUpdateRequest(null, "경력", "경력", LocalDate.of(2004, 1, 1), LocalDate.of(2005, 1, 1), false); - return ProfileDefaultRequest.builder() + return ProfileUpdateRequest.builder() .position(Position.DESIGNER.toString()) .educations(List.of(educationRequest)) .portfolios(List.of(portfolioRequest)) @@ -1115,13 +1111,13 @@ private ProfileDefaultRequest createValidProfileDefaultRequest() { .build(); } - private WorkDefaultRequest createWorkDefaultRequest(Long workId, - String corporationName, - String workDescription, - LocalDate startedAt, - LocalDate endedAt, - Boolean isCurrent) { - return WorkDefaultRequest.builder() + private WorkUpdateRequest createWorkUpdateRequest(Long workId, + String corporationName, + String workDescription, + LocalDate startedAt, + LocalDate endedAt, + Boolean isCurrent) { + return WorkUpdateRequest.builder() .workId(workId) .corporationName(corporationName) .workDescription(workDescription) @@ -1131,11 +1127,11 @@ private WorkDefaultRequest createWorkDefaultRequest(Long workId, .build(); } - private SkillDefaultRequest createSkillDefaultRequest(Long skillId, - String skillName, - Boolean isExperienced, - String level) { - return SkillDefaultRequest.builder() + private SkillUpdateRequest createSkillUpdateRequest(Long skillId, + String skillName, + Boolean isExperienced, + String level) { + return SkillUpdateRequest.builder() .skillId(skillId) .skillName(skillName) .isExperienced(isExperienced) @@ -1143,11 +1139,11 @@ private SkillDefaultRequest createSkillDefaultRequest(Long skillId, .build(); } - private PortfolioDefaultRequest createPortfolioDefaultRequest(Long portfolioId, - String portfolioName, - String portfolioUrl, - String media) { - return PortfolioDefaultRequest.builder() + private PortfolioUpdateRequest createPortfolioUpdateRequest(Long portfolioId, + String portfolioName, + String portfolioUrl, + String media) { + return PortfolioUpdateRequest.builder() .portfolioId(portfolioId) .portfolioName(portfolioName) .portfolioUrl(portfolioUrl) @@ -1155,12 +1151,12 @@ private PortfolioDefaultRequest createPortfolioDefaultRequest(Long portfolioId, .build(); } - private EducationDefaultRequest createEducationDefaultRequest(Long educationId, - String institutionName, - LocalDate startedAt, - LocalDate endedAt, - Boolean isCurrent) { - return EducationDefaultRequest.builder() + private EducationUpdateRequest createEducationUpdateRequest(Long educationId, + String institutionName, + LocalDate startedAt, + LocalDate endedAt, + Boolean isCurrent) { + return EducationUpdateRequest.builder() .educationId(educationId) .institutionName(institutionName) .startedAt(startedAt)