Skip to content

Commit

Permalink
GETP-99 feat: 피플 정보 엔티티를 값 타입으로 분해 (#48)
Browse files Browse the repository at this point in the history
* GETP-99 rename: Hashtag와 TechStack을 global.domain.values로 이동

* GETP-99 feat: 피플 관련 DTO validation 로직 추가

* GETP-99 feat: 피플 관련 VO에 validation 로직 추가

* GETP-99 feat: DTO에서 VO를 직접 의존하도록 변경

* GETP-99 feat: 엔티티에 엔티티-VO 변환 책임을 전가

* GETP-99 feat: 피플 프로필 등록의 엔드 포인트를 /people/me/profile로 변경

* GETP-99 test: 테스트 코드에 대해 변경 사항 반영

* GETP-99 chore: Github Action CI의 Gradle caching을 actions/setup-gradle로 변경
  • Loading branch information
scv1702 authored Apr 1, 2024
1 parent 90604f5 commit 481505d
Show file tree
Hide file tree
Showing 43 changed files with 641 additions and 433 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/deploy-develop-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,9 @@ jobs:
echo "${{ secrets.ENV }}" >> .env.dev
- name: Cache Gradle packages
uses: actions/cache@v4
uses: gradle/actions/setup-gradle@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}

- name: Build with Gradle
run: ./dev.sh
9 changes: 2 additions & 7 deletions .github/workflows/pull-request-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@ jobs:
echo "${{ secrets.ENV }}" >> .env.test
- name: Cache Gradle packages
uses: actions/cache@v4
uses: gradle/actions/setup-gradle@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}

- name: Test with Gradle
run: ./test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package es.princip.getp.domain.people.controller;

import es.princip.getp.domain.member.domain.entity.Member;
import es.princip.getp.domain.people.dto.request.CreatePeopleProfileRequest;
import es.princip.getp.domain.people.dto.request.UpdatePeopleProfileRequest;
import es.princip.getp.domain.people.dto.request.UpdatePeopleRequest;
import es.princip.getp.domain.people.dto.response.people.PeopleResponse;
import es.princip.getp.domain.people.dto.response.people.UpdatePeopleResponse;
import es.princip.getp.domain.people.dto.response.peopleProfile.CreatePeopleProfileResponse;
import es.princip.getp.domain.people.dto.response.peopleProfile.DetailPeopleProfileResponse;
import es.princip.getp.domain.people.dto.response.peopleProfile.UpdatePeopleProfileResponse;
import es.princip.getp.domain.people.service.PeopleProfileService;
Expand All @@ -19,6 +21,7 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -63,6 +66,24 @@ public ResponseEntity<ApiSuccessResult<PeopleResponse>> getMyPeople(
return ResponseEntity.ok().body(ApiResponse.success(HttpStatus.OK, response));
}

/**
* 피플 프로필 등록
*
* @param request 등록할 피플 프로필 정보
* @return 등록된 피플 프로필 정보
*/
@PostMapping("/profile")
@PreAuthorize("hasRole('PEOPLE') and isAuthenticated()")
public ResponseEntity<ApiSuccessResult<CreatePeopleProfileResponse>> createPeopleProfile(
@RequestBody @Valid CreatePeopleProfileRequest request,
@AuthenticationPrincipal PrincipalDetails principalDetails) {
Member member = principalDetails.getMember();
CreatePeopleProfileResponse response =
CreatePeopleProfileResponse.from(peopleProfileService.create(member.getMemberId(), request));
return ResponseEntity.status(HttpStatus.CREATED)
.body(ApiResponse.success(HttpStatus.CREATED, response));
}

/**
* 내 피플 프로필 조회
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package es.princip.getp.domain.people.controller;

import es.princip.getp.domain.member.domain.entity.Member;
import es.princip.getp.domain.people.dto.request.CreatePeopleRequest;
import es.princip.getp.domain.people.dto.response.people.CardPeopleResponse;
import es.princip.getp.domain.people.dto.response.people.CreatePeopleResponse;
import es.princip.getp.domain.people.dto.response.people.DetailPeopleResponse;
import es.princip.getp.domain.people.dto.response.people.PublicDetailPeopleResponse;
import es.princip.getp.domain.people.service.PeopleProfileService;
import es.princip.getp.domain.people.service.PeopleService;
import es.princip.getp.global.security.details.PrincipalDetails;
import es.princip.getp.global.util.ApiResponse;
import es.princip.getp.global.util.ApiResponse.ApiSuccessResult;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
Expand All @@ -16,21 +29,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import es.princip.getp.domain.member.domain.entity.Member;
import es.princip.getp.domain.people.dto.request.CreatePeopleProfileRequest;
import es.princip.getp.domain.people.dto.request.CreatePeopleRequest;
import es.princip.getp.domain.people.dto.response.people.CardPeopleResponse;
import es.princip.getp.domain.people.dto.response.people.CreatePeopleResponse;
import es.princip.getp.domain.people.dto.response.people.DetailPeopleResponse;
import es.princip.getp.domain.people.dto.response.people.PublicDetailPeopleResponse;
import es.princip.getp.domain.people.dto.response.peopleProfile.CreatePeopleProfileResponse;
import es.princip.getp.domain.people.service.PeopleProfileService;
import es.princip.getp.domain.people.service.PeopleService;
import es.princip.getp.global.security.details.PrincipalDetails;
import es.princip.getp.global.util.ApiResponse;
import es.princip.getp.global.util.ApiResponse.ApiSuccessResult;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/people")
Expand Down Expand Up @@ -58,24 +56,6 @@ public ResponseEntity<ApiSuccessResult<CreatePeopleResponse>> createPeople(
.body(ApiResponse.success(HttpStatus.CREATED, response));
}

/**
* 피플 프로필 등록
*
* @param request 등록할 피플 프로필 정보
* @return 등록된 피플 프로필 정보
*/
@PostMapping("/profile")
@PreAuthorize("hasRole('PEOPLE') and isAuthenticated()")
public ResponseEntity<ApiSuccessResult<CreatePeopleProfileResponse>> createPeopleProfile(
@RequestBody @Valid CreatePeopleProfileRequest request,
@AuthenticationPrincipal PrincipalDetails principalDetails) {
Member member = principalDetails.getMember();
CreatePeopleProfileResponse response =
CreatePeopleProfileResponse.from(peopleProfileService.create(member.getMemberId(), request));
return ResponseEntity.status(HttpStatus.CREATED)
.body(ApiResponse.success(HttpStatus.CREATED, response));
}

/**
* 포트폴리오 개발 진행 후 완성 예정 - 피플 상세 조회
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public People(final String nickname,
this.member = member;
}

public void update(UpdatePeopleRequest request) {
public void update(final UpdatePeopleRequest request) {
this.nickname = request.nickname();
this.email = request.email();
this.phoneNumber = request.phoneNumber();
this.peopleType = PeopleType.valueOf(request.peopleType());
this.peopleType = request.peopleType();
this.profileImageUri = request.profileImageUri();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package es.princip.getp.domain.people.domain.entity;

import es.princip.getp.domain.base.BaseTimeEntity;
import es.princip.getp.domain.hashtag.domain.values.Hashtag;
import es.princip.getp.global.domain.values.Hashtag;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
Expand All @@ -13,6 +13,7 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
Expand All @@ -23,25 +24,22 @@ public class PeopleHashtag extends BaseTimeEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "people_hashtag_id")
private Long peopleHashtagId;
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "people_profile_id")
private PeopleProfile peopleProfile;

@Embedded
@Getter
private Hashtag hashtag;

private PeopleHashtag(PeopleProfile peopleProfile, Hashtag hashtag) {
this.peopleProfile = peopleProfile;
this.hashtag = hashtag;
}

public static PeopleHashtag of(PeopleProfile peopleProfile, String hashtag) {
return new PeopleHashtag(peopleProfile, Hashtag.from(hashtag));
}

public String getValue() {
return hashtag.getValue();
public static PeopleHashtag of(PeopleProfile peopleProfile, Hashtag hashtag) {
return new PeopleHashtag(peopleProfile, hashtag);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package es.princip.getp.domain.people.domain.entity;

import jakarta.persistence.Entity;
import es.princip.getp.domain.base.BaseTimeEntity;
import es.princip.getp.domain.people.domain.values.Portfolio;
import es.princip.getp.domain.people.dto.PortfolioForm;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -26,7 +25,7 @@ public class PeoplePortfolio extends BaseTimeEntity {
@Id
@Column(name = "people_portfolio_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long peoplePortfolioId;
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "people_profile_id")
Expand All @@ -40,19 +39,7 @@ private PeoplePortfolio(PeopleProfile peopleProfile, Portfolio portfolio) {
this.portfolio = portfolio;
}

public static PeoplePortfolio of(PeopleProfile peopleProfile, PortfolioForm portfolio) {
return new PeoplePortfolio(peopleProfile, Portfolio.from(portfolio));
}

public String getUri() {
return portfolio.getUri();
}

public String getDescription() {
return portfolio.getDescription();
}

public Portfolio getPortfolio() {
return portfolio;
public static PeoplePortfolio of(PeopleProfile peopleProfile, Portfolio portfolio) {
return new PeoplePortfolio(peopleProfile, portfolio);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package es.princip.getp.domain.people.domain.entity;

import java.util.ArrayList;
import java.util.List;

import es.princip.getp.domain.people.dto.PortfolioForm;
import es.princip.getp.domain.people.domain.values.Education;
import es.princip.getp.domain.people.domain.values.Portfolio;
import es.princip.getp.domain.people.dto.request.UpdatePeopleProfileRequest;
import es.princip.getp.global.domain.values.Hashtag;
import es.princip.getp.global.domain.values.TechStack;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
Expand All @@ -16,6 +17,8 @@
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -30,16 +33,16 @@ public class PeopleProfile {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "people_profile_id")
private Long peopleProfileId;
private Long id;

@Column(name = "introduction")
private String introduction;

@Column(name = "activity_area")
private String activityArea;

@Column(name = "education")
private String education;
@Embedded
private Education education;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "people_id")
Expand All @@ -54,13 +57,32 @@ public class PeopleProfile {
@OneToMany(mappedBy = "peopleProfile", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PeoplePortfolio> portfolios = new ArrayList<>();

public List<Hashtag> getHashtags() {
return hashtags.stream()
.map(PeopleHashtag::getHashtag)
.toList();
}

public List<TechStack> getTechStacks() {
return techStacks.stream()
.map(PeopleTechStack::getTechStack)
.toList();
}

public List<Portfolio> getPortfolios() {
return portfolios.stream()
.map(PeoplePortfolio::getPortfolio)
.toList();
}

@Builder
public PeopleProfile(final String introduction,
public PeopleProfile(
final String introduction,
final String activityArea,
final String education,
final List<String> hashtags,
final List<String> techStacks,
final List<PortfolioForm> portfolios,
final Education education,
final List<Hashtag> hashtags,
final List<TechStack> techStacks,
final List<Portfolio> portfolios,
final People people
) {
this.introduction = introduction;
Expand All @@ -78,7 +100,7 @@ public PeopleProfile(final String introduction,
this.people = people;
}

public void update(UpdatePeopleProfileRequest request) {
public void update(final UpdatePeopleProfileRequest request) {
this.introduction = request.introduction();
this.activityArea = request.activityArea();
this.education = request.education();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package es.princip.getp.domain.people.domain.entity;

import es.princip.getp.domain.base.BaseTimeEntity;
import es.princip.getp.domain.techStack.domain.values.TechStack;
import es.princip.getp.global.domain.values.TechStack;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
Expand All @@ -13,6 +13,7 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
Expand All @@ -23,22 +24,23 @@ public class PeopleTechStack extends BaseTimeEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "people_tech_stack_id")
private Long peopleTechStackId;
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "people_profile_id")
private PeopleProfile peopleProfile;

@Embedded
@Getter
private TechStack techStack;

private PeopleTechStack(PeopleProfile peopleProfile, TechStack techStack) {
this.peopleProfile = peopleProfile;
this.techStack = techStack;
}

public static PeopleTechStack of(PeopleProfile peopleProfile, String techStack) {
return new PeopleTechStack(peopleProfile, TechStack.from(techStack));
public static PeopleTechStack of(PeopleProfile peopleProfile, TechStack techStack) {
return new PeopleTechStack(peopleProfile, techStack);
}

public String getValue() {
Expand Down
Loading

0 comments on commit 481505d

Please sign in to comment.