-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e17f03c
commit 1d7414d
Showing
23 changed files
with
498 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/main/java/dongguk/osori/domain/goal/service/GoalService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/dongguk/osori/domain/portfolio/controller/PortfolioController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package dongguk.osori.domain.portfolio.controller; | ||
|
||
import dongguk.osori.domain.portfolio.dto.PortfolioBaseDto; | ||
import dongguk.osori.domain.portfolio.dto.PortfolioDetailDto; | ||
import dongguk.osori.domain.portfolio.dto.PortfolioRequestDto; | ||
import dongguk.osori.domain.portfolio.service.PortfolioService; | ||
import jakarta.servlet.http.HttpSession; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/portfolios") | ||
@RequiredArgsConstructor | ||
public class PortfolioController { | ||
|
||
private final PortfolioService portfolioService; | ||
private final HttpSession httpSession; | ||
|
||
@PostMapping | ||
public ResponseEntity<PortfolioDetailDto> createPortfolio(@RequestBody PortfolioRequestDto requestDto) { | ||
Long userId = (Long) httpSession.getAttribute("userId"); | ||
return ResponseEntity.ok(portfolioService.createPortfolio(userId, requestDto)); | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<List<PortfolioBaseDto>> getPortfolioList() { | ||
Long userId = (Long) httpSession.getAttribute("userId"); | ||
return ResponseEntity.ok(portfolioService.getPortfolioList(userId)); | ||
} | ||
|
||
@GetMapping("/{portfolioId}") | ||
public ResponseEntity<PortfolioDetailDto> getPortfolioDetail(@PathVariable("portfolioId") Long portfolioId) { | ||
Long userId = (Long) httpSession.getAttribute("userId"); | ||
return ResponseEntity.ok(portfolioService.getPortfolioDetail(userId, portfolioId)); | ||
} | ||
|
||
|
||
@PutMapping("/{portfolioId}") | ||
public ResponseEntity<PortfolioDetailDto> updatePortfolio( | ||
@PathVariable("portfolioId") Long portfolioId, | ||
@RequestBody PortfolioRequestDto requestDto | ||
) { | ||
Long userId = (Long) httpSession.getAttribute("userId"); | ||
return ResponseEntity.ok(portfolioService.updatePortfolio(userId, portfolioId, requestDto)); | ||
} | ||
|
||
|
||
@DeleteMapping("/{portfolioId}") | ||
public ResponseEntity<Void> deletePortfolio(@PathVariable("portfolioId") Long portfolioId) { | ||
Long userId = (Long) httpSession.getAttribute("userId"); | ||
portfolioService.deletePortfolio(userId, portfolioId); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/dongguk/osori/domain/portfolio/dto/ExperienceDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dongguk.osori.domain.portfolio.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ExperienceDto { | ||
private String situation; | ||
private String task; | ||
private String action; | ||
private String result; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/dongguk/osori/domain/portfolio/dto/PmiDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package dongguk.osori.domain.portfolio.dto; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PmiDto { | ||
private String plus; | ||
private String minus; | ||
private String interesting; | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
src/main/java/dongguk/osori/domain/portfolio/dto/PortfolioBaseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dongguk.osori.domain.portfolio.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
/* | ||
목록 조회 dto | ||
*/ | ||
public class PortfolioBaseDto { | ||
private Long portfolioId; | ||
private String name; | ||
private LocalDate startDate; | ||
private List<String> tags; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/dongguk/osori/domain/portfolio/dto/PortfolioDetailDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dongguk.osori.domain.portfolio.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PortfolioDetailDto { | ||
private PortfolioBaseDto baseInfo; | ||
private ExperienceDto experience; | ||
private PmiDto pmi; | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/dongguk/osori/domain/portfolio/dto/PortfolioRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package dongguk.osori.domain.portfolio.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PortfolioRequestDto { | ||
private String name; | ||
private LocalDate startDate; | ||
private List<String> tags; | ||
private ExperienceDto experience; | ||
private PmiDto pmi; | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/dongguk/osori/domain/portfolio/entity/Experience.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package dongguk.osori.domain.portfolio.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@Entity | ||
public class Experience { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long experienceId; | ||
|
||
private String situation; | ||
private String task; | ||
private String action; | ||
private String result; | ||
|
||
|
||
|
||
public Experience(String situation, String task, String action, String result) { | ||
this.situation = situation; | ||
this.task = task; | ||
this.action = action; | ||
this.result = result; | ||
} | ||
|
||
public void setPortfolio(Portfolio portfolio) { | ||
this.portfolio = portfolio; | ||
} | ||
|
||
public void update(String situation, String task, String action, String result) { | ||
this.situation = situation; | ||
this.task = task; | ||
this.action = action; | ||
this.result = result; | ||
} | ||
|
||
@OneToOne | ||
@JoinColumn(name = "portfolio_id", nullable = false) | ||
private Portfolio portfolio; | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/dongguk/osori/domain/portfolio/entity/Pmi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dongguk.osori.domain.portfolio.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@Entity | ||
public class Pmi { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long pmiId; | ||
|
||
private String plus; | ||
private String minus; | ||
private String interesting; | ||
|
||
public Pmi(String plus, String minus, String interesting) { | ||
this.plus = plus; | ||
this.minus = minus; | ||
this.interesting = interesting; | ||
} | ||
|
||
public void setPortfolio(Portfolio portfolio) { | ||
this.portfolio = portfolio; | ||
} | ||
|
||
public void update(String plus, String minus, String interesting) { | ||
this.plus = plus; | ||
this.minus = minus; | ||
this.interesting = interesting; | ||
} | ||
|
||
@OneToOne | ||
@JoinColumn(name = "portfolio_id", nullable = false) | ||
private Portfolio portfolio; | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/dongguk/osori/domain/portfolio/entity/Portfolio.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package dongguk.osori.domain.portfolio.entity; | ||
|
||
import dongguk.osori.domain.user.entity.User; | ||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@Entity | ||
public class Portfolio { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long portfolioId; | ||
|
||
private String name; | ||
private LocalDate startDate; | ||
|
||
@ElementCollection | ||
@CollectionTable(name = "portfolio_tags", joinColumns = @JoinColumn(name = "portfolio_id")) | ||
@Column(name = "tag") | ||
private Set<String> tags = new HashSet<>(); | ||
|
||
public Portfolio(String name, LocalDate startDate, Set<String> tags, Experience experience, Pmi pmi, User user) { | ||
this.name = name; | ||
this.startDate = startDate; | ||
this.tags = tags; | ||
this.user = user; | ||
setExperience(experience); | ||
setPmi(pmi); | ||
} | ||
|
||
public void update(String name, LocalDate startDate, Set<String> tags) { | ||
this.name = name; | ||
this.startDate = startDate; | ||
this.tags = tags; | ||
} | ||
|
||
public void setExperience(Experience experience) { | ||
this.experience = experience; | ||
if (experience != null) { | ||
experience.setPortfolio(this); | ||
} | ||
} | ||
|
||
public void setPmi(Pmi pmi) { | ||
this.pmi = pmi; | ||
if (pmi != null) { | ||
pmi.setPortfolio(this); | ||
} | ||
} | ||
|
||
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "portfolio") | ||
private Experience experience; | ||
|
||
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "portfolio") | ||
private Pmi pmi; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id", nullable = false) | ||
private User user; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dongguk.osori.domain.portfolio.entity; | ||
|
||
public enum Tag { | ||
전공, 교양, 교내동아리, 교외동아리, 학회, 봉사활동, 인턴, 아르바이트, | ||
대외활동, 서포터즈, 기자단, 강연행사, 스터디, 부트캠프, 프로젝트, 연구, | ||
학생회, 기타 | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/dongguk/osori/domain/portfolio/repository/ExperienceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dongguk.osori.domain.portfolio.repository; | ||
|
||
import dongguk.osori.domain.portfolio.entity.Experience; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface ExperienceRepository extends JpaRepository<Experience, Long> { | ||
} |
Oops, something went wrong.