From b8ae356c7384d1392793fb4b2e5592b5216c675e Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:50:39 +0900 Subject: [PATCH 01/17] #213 feat : existPorfolio save api --- .../controller/PortfolioController.java | 19 +++++----- .../domain/portfolio/entity/Portfolio.java | 17 ++++++++- .../repository/PortfolioRepository.java | 9 ++++- .../portfolio/service/PortfolioService.java | 36 ++++++++++++++++--- 4 files changed, 66 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java index 3b1d1f57..6b307499 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java @@ -1,5 +1,7 @@ package com.gongjakso.server.domain.portfolio.controller; +import com.gongjakso.server.domain.contest.dto.request.UpdateContestDto; +import com.gongjakso.server.domain.contest.dto.response.ContestRes; import com.gongjakso.server.domain.portfolio.dto.request.PortfolioReq; import com.gongjakso.server.domain.portfolio.dto.response.PortfolioRes; import com.gongjakso.server.domain.portfolio.dto.response.SimplePortfolioRes; @@ -11,14 +13,8 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -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; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -66,4 +62,11 @@ public ApplicationResponse deletePortfolio(@AuthenticationPrincipal Princi public ApplicationResponse> getMyPortfolios(@AuthenticationPrincipal PrincipalDetails principalDetails) { return ApplicationResponse.ok(portfolioService.getMyPortfolios(principalDetails.getMember())); } + + @Operation(description = "포트폴리오 파일 및 링크 업로드 API") + @PostMapping("/exist-protfolio") + public ApplicationResponse update(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ + portfolioService.saveExistPortfolio(principalDetails.getMember(),image,notionUri); + return ApplicationResponse.ok(); + } } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java index ff563f67..094adaf9 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java @@ -12,6 +12,7 @@ import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.SQLDelete; import org.hibernate.type.SqlTypes; +import org.springframework.data.redis.connection.ReactiveGeoCommands; @Getter @Entity @@ -36,13 +37,27 @@ public class Portfolio extends BaseTimeEntity { @JdbcTypeCode(SqlTypes.JSON) private PortfolioData portfolioData; - @Builder + @Column(name = "file_uri",columnDefinition = "text") + private String fileUri; + + @Column(name = "notion_uri",columnDefinition = "text") + private String notionUri; + + @Builder(builderMethodName = "portfolioBuilder") public Portfolio(Member member, String portfolioName, PortfolioData portfolioData) { this.member = member; this.portfolioName = portfolioName; this.portfolioData = portfolioData; } + @Builder(builderMethodName = "existPortfolioBuilder") + public Portfolio(Member member, String fileUri, String notionUri){ + this.member = member; + this.fileUri = fileUri; + this.notionUri = notionUri; + } + + public void updateName(String updatedName) { this.portfolioName = updatedName; } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java index cb0cc04b..d9030f8c 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java @@ -1,11 +1,18 @@ package com.gongjakso.server.domain.portfolio.repository; +import com.gongjakso.server.domain.member.entity.Member; import com.gongjakso.server.domain.portfolio.entity.Portfolio; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface PortfolioRepository extends JpaRepository, PortfolioRepositoryCustom{ Optional findByIdAndDeletedAtIsNull(Long portfolioId); - long countByDeletedAtIsNull(); + @Query("SELECT EXISTS (" + + "SELECT 1 FROM Portfolio po " + + "WHERE po.member = :member AND (po.fileUri IS NOT NULL OR po.notionUri IS NOT NULL))") + Boolean existsExistPortfolioByMember(@Param("member") Member member); + Optional findPortfolioByMember(Member member); } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index f94554fd..ab3a1ebc 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -10,9 +10,13 @@ import com.gongjakso.server.global.exception.ApplicationException; import com.gongjakso.server.global.exception.ErrorCode; import java.util.List; + +import com.gongjakso.server.global.util.s3.S3Client; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; @Service @Transactional(readOnly = true) @@ -20,6 +24,9 @@ public class PortfolioService { private final PortfolioRepository portfolioRepository; + private final S3Client s3Client; + private final String S3_PORTFOLIO_DIR_NAME = "portfolio"; + // PortfolioName 생성 로직을 분리 private String generatePortfolioName(String portfolioName) { @@ -104,11 +111,7 @@ public PortfolioRes registerPortfolio(Member member, PortfolioReq portfolioReq) String portfolioName = generatePortfolioName(portfolioReq.portfolioName()); PortfolioData portfolioData = convertToPortfolioData(portfolioReq); - Portfolio portfolio = Portfolio.builder() - .member(member) - .portfolioName(portfolioName) - .portfolioData(portfolioData) - .build(); + Portfolio portfolio = new Portfolio(member,portfolioName,portfolioData); Portfolio savedPortfolio = portfolioRepository.save(portfolio); @@ -165,4 +168,27 @@ public List getMyPortfolios(Member member) { .map(SimplePortfolioRes::of) .toList(); } + + @Transactional + public void saveExistPortfolio(Member member, MultipartFile image, String notionUri){ + //등록된 파일이나 노션 링크 있는지 확인 + //Validation + Boolean isExist = portfolioRepository.existsExistPortfolioByMember(member); + if (!isExist){ + throw new ApplicationException(ErrorCode.ALREADY_EXIST_EXCEPTION); + } + if(image.isEmpty() && notionUri.isEmpty()){ + throw new ApplicationException(ErrorCode.PORTFOLIO_SAVE_FAILED_EXCEPTION); + } + //Business + String s3Url = null; + if (image != null && !image.isEmpty()) { + s3Url = s3Client.upload(image, S3_PORTFOLIO_DIR_NAME); + } + if (notionUri.isEmpty()){ + notionUri=null; + } + Portfolio portfolio = new Portfolio(member,s3Url,notionUri); + portfolioRepository.save(portfolio); + } } \ No newline at end of file From 4e9960b5ae8d90dc05e1fb34d98c26cacf5b40cc Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sat, 21 Sep 2024 19:34:55 +0900 Subject: [PATCH 02/17] #213 update,delete,find api --- .../controller/PortfolioController.java | 27 +++++++++-- .../dto/response/ExistPortfolioRes.java | 15 +++++++ .../domain/portfolio/entity/Portfolio.java | 5 +++ .../portfolio/service/PortfolioService.java | 45 +++++++++++++++++-- 4 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/gongjakso/server/domain/portfolio/dto/response/ExistPortfolioRes.java diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java index 6b307499..627d69f0 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java @@ -1,8 +1,7 @@ package com.gongjakso.server.domain.portfolio.controller; -import com.gongjakso.server.domain.contest.dto.request.UpdateContestDto; -import com.gongjakso.server.domain.contest.dto.response.ContestRes; import com.gongjakso.server.domain.portfolio.dto.request.PortfolioReq; +import com.gongjakso.server.domain.portfolio.dto.response.ExistPortfolioRes; import com.gongjakso.server.domain.portfolio.dto.response.PortfolioRes; import com.gongjakso.server.domain.portfolio.dto.response.SimplePortfolioRes; import com.gongjakso.server.domain.portfolio.service.PortfolioService; @@ -65,8 +64,30 @@ public ApplicationResponse> getMyPortfolios(@Authentica @Operation(description = "포트폴리오 파일 및 링크 업로드 API") @PostMapping("/exist-protfolio") - public ApplicationResponse update(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ + public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ portfolioService.saveExistPortfolio(principalDetails.getMember(),image,notionUri); return ApplicationResponse.ok(); } + + @Operation(description = "포트폴리오 파일 및 링크 업로드 삭제 API") + @PostMapping("/exist-protfolio/{portfolio_id}") + public ApplicationResponse deleteExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId){ + portfolioService.deleteExistPortfolio(principalDetails.getMember(),portfolioId); + return ApplicationResponse.ok(); + } + + @Operation(description = "포트폴리오 파일 및 링크 업로드 업데이트 API") + @PostMapping("/exist-protfolio/{portfolio_id}") + public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ + portfolioService.updateExistPortfolio(principalDetails.getMember(),portfolioId,image,notionUri); + return ApplicationResponse.ok(); + } + + @Operation(description = "포트폴리오 파일 및 링크 업로드 가져오기 API") + @PostMapping("/exist-protfolio/{portfolio_id}") + public ApplicationResponse findExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ + return ApplicationResponse.ok(portfolioService.findExistPorfolio(principalDetails.getMember(),portfolioId)); + } + + } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/ExistPortfolioRes.java b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/ExistPortfolioRes.java new file mode 100644 index 00000000..5143d332 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/ExistPortfolioRes.java @@ -0,0 +1,15 @@ +package com.gongjakso.server.domain.portfolio.dto.response; + +import com.gongjakso.server.domain.portfolio.entity.Portfolio; + +public record ExistPortfolioRes( + String fileUri, + String notionUri +) { + public static ExistPortfolioRes of(Portfolio portfolio) { + return new ExistPortfolioRes( + portfolio.getFileUri(), + portfolio.getNotionUri() + ); + } +} diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java index 094adaf9..031a6642 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java @@ -1,5 +1,6 @@ package com.gongjakso.server.domain.portfolio.entity; +import com.gongjakso.server.domain.contest.dto.request.UpdateContestDto; import com.gongjakso.server.domain.member.entity.Member; import com.gongjakso.server.domain.portfolio.vo.PortfolioData; import com.gongjakso.server.global.common.BaseTimeEntity; @@ -56,6 +57,10 @@ public Portfolio(Member member, String fileUri, String notionUri){ this.fileUri = fileUri; this.notionUri = notionUri; } + public void updateExistPortfolio(Portfolio portfolio, String fileUri, String notionUri) { + this.fileUri = (fileUri == null) ? this.fileUri : portfolio.getFileUri(); + this.notionUri = (notionUri == null) ? this.notionUri : portfolio.getNotionUri(); + } public void updateName(String updatedName) { diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index ab3a1ebc..fbb25523 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -2,6 +2,7 @@ import com.gongjakso.server.domain.member.entity.Member; import com.gongjakso.server.domain.portfolio.dto.request.PortfolioReq; +import com.gongjakso.server.domain.portfolio.dto.response.ExistPortfolioRes; import com.gongjakso.server.domain.portfolio.dto.response.PortfolioRes; import com.gongjakso.server.domain.portfolio.dto.response.SimplePortfolioRes; import com.gongjakso.server.domain.portfolio.entity.Portfolio; @@ -15,7 +16,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; @Service @@ -185,10 +185,47 @@ public void saveExistPortfolio(Member member, MultipartFile image, String notion if (image != null && !image.isEmpty()) { s3Url = s3Client.upload(image, S3_PORTFOLIO_DIR_NAME); } - if (notionUri.isEmpty()){ - notionUri=null; - } Portfolio portfolio = new Portfolio(member,s3Url,notionUri); portfolioRepository.save(portfolio); } + + @Transactional + public void deleteExistPortfolio(Member member, Long id){ + Portfolio portfolio = portfolioRepository.findById(id).orElseThrow(()-> new ApplicationException(ErrorCode.NOT_FOUND_EXCEPTION)); + if(!member.getId().equals(portfolio.getMember().getId())){ + throw new ApplicationException(ErrorCode.UNAUTHORIZED_EXCEPTION); + } + if(portfolio.getFileUri() != null){ + s3Client.delete(portfolio.getFileUri()); + } + portfolioRepository.delete(portfolio); + } + + @Transactional + public void updateExistPortfolio(Member member, Long id, MultipartFile image, String notionUri){ + //등록된 파일이나 노션 링크 있는지 확인 + //Validation + Portfolio portfolio = portfolioRepository.findById(id).orElseThrow(()-> new ApplicationException(ErrorCode.NOT_FOUND_EXCEPTION)); + if(!member.getId().equals(portfolio.getMember().getId())){ + throw new ApplicationException(ErrorCode.UNAUTHORIZED_EXCEPTION); + } + //Business + String s3Url = null; + if (image != null && !image.isEmpty()) { + s3Client.delete(portfolio.getFileUri()); + s3Url = s3Client.upload(image, S3_PORTFOLIO_DIR_NAME); + } + portfolio.updateExistPortfolio(portfolio,s3Url,notionUri); + portfolioRepository.save(portfolio); + } + + public ExistPortfolioRes findExistPorfolio(Member member, Long id){ + //Validation + Portfolio portfolio = portfolioRepository.findById(id).orElseThrow(()-> new ApplicationException(ErrorCode.NOT_FOUND_EXCEPTION)); + if (!portfolio.getMember().getId().equals(member.getId())) { + throw new ApplicationException(ErrorCode.FORBIDDEN_EXCEPTION); + } + return new ExistPortfolioRes(portfolio.getFileUri(),portfolio.getNotionUri()); + } + } \ No newline at end of file From cc7ca735a4815d9ff539e0fba2af2b12a4172420 Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sat, 21 Sep 2024 19:41:53 +0900 Subject: [PATCH 03/17] #213 fix : controller method --- .../domain/portfolio/controller/PortfolioController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java index 627d69f0..a8f69358 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java @@ -70,21 +70,21 @@ public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal P } @Operation(description = "포트폴리오 파일 및 링크 업로드 삭제 API") - @PostMapping("/exist-protfolio/{portfolio_id}") + @DeleteMapping("/exist-protfolio/{portfolio_id}") public ApplicationResponse deleteExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId){ portfolioService.deleteExistPortfolio(principalDetails.getMember(),portfolioId); return ApplicationResponse.ok(); } @Operation(description = "포트폴리오 파일 및 링크 업로드 업데이트 API") - @PostMapping("/exist-protfolio/{portfolio_id}") + @PatchMapping("/exist-protfolio/{portfolio_id}") public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ portfolioService.updateExistPortfolio(principalDetails.getMember(),portfolioId,image,notionUri); return ApplicationResponse.ok(); } @Operation(description = "포트폴리오 파일 및 링크 업로드 가져오기 API") - @PostMapping("/exist-protfolio/{portfolio_id}") + @GetMapping("/exist-protfolio/{portfolio_id}") public ApplicationResponse findExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ return ApplicationResponse.ok(portfolioService.findExistPorfolio(principalDetails.getMember(),portfolioId)); } From 277010dc07bf2ee8a4d872a70f0ad498c7d14cca Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sat, 21 Sep 2024 23:43:21 +0900 Subject: [PATCH 04/17] #213 fix: add portfolioName --- .../domain/portfolio/controller/PortfolioController.java | 6 +++--- .../gongjakso/server/domain/portfolio/entity/Portfolio.java | 3 ++- .../domain/portfolio/repository/PortfolioRepository.java | 2 +- .../server/domain/portfolio/service/PortfolioService.java | 6 ++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java index a8f69358..c459c5ba 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java @@ -64,7 +64,7 @@ public ApplicationResponse> getMyPortfolios(@Authentica @Operation(description = "포트폴리오 파일 및 링크 업로드 API") @PostMapping("/exist-protfolio") - public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ + public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestPart(required = false,name = "image") MultipartFile image, @RequestPart(required = false,name = "notionUri") String notionUri){ portfolioService.saveExistPortfolio(principalDetails.getMember(),image,notionUri); return ApplicationResponse.ok(); } @@ -78,14 +78,14 @@ public ApplicationResponse deleteExistPortfolio(@AuthenticationPrincipal P @Operation(description = "포트폴리오 파일 및 링크 업로드 업데이트 API") @PatchMapping("/exist-protfolio/{portfolio_id}") - public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ + public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false,name = "image") MultipartFile image, @RequestPart(required = false,name = "notionUri") String notionUri){ portfolioService.updateExistPortfolio(principalDetails.getMember(),portfolioId,image,notionUri); return ApplicationResponse.ok(); } @Operation(description = "포트폴리오 파일 및 링크 업로드 가져오기 API") @GetMapping("/exist-protfolio/{portfolio_id}") - public ApplicationResponse findExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false) MultipartFile image, @RequestPart(required = false) String notionUri){ + public ApplicationResponse findExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("portfolio_id") Long portfolioId){ return ApplicationResponse.ok(portfolioService.findExistPorfolio(principalDetails.getMember(),portfolioId)); } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java index 031a6642..22f6a7a3 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java @@ -52,8 +52,9 @@ public Portfolio(Member member, String portfolioName, PortfolioData portfolioDat } @Builder(builderMethodName = "existPortfolioBuilder") - public Portfolio(Member member, String fileUri, String notionUri){ + public Portfolio(Member member, String portfolioName, String fileUri, String notionUri){ this.member = member; + this.portfolioName = portfolioName; this.fileUri = fileUri; this.notionUri = notionUri; } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java index d9030f8c..55408763 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java @@ -14,5 +14,5 @@ public interface PortfolioRepository extends JpaRepository, Por "SELECT 1 FROM Portfolio po " + "WHERE po.member = :member AND (po.fileUri IS NOT NULL OR po.notionUri IS NOT NULL))") Boolean existsExistPortfolioByMember(@Param("member") Member member); - Optional findPortfolioByMember(Member member); + Optional findPortfolioById(Long portfolioId); } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index fbb25523..3c609334 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -174,7 +174,7 @@ public void saveExistPortfolio(Member member, MultipartFile image, String notion //등록된 파일이나 노션 링크 있는지 확인 //Validation Boolean isExist = portfolioRepository.existsExistPortfolioByMember(member); - if (!isExist){ + if (isExist){ throw new ApplicationException(ErrorCode.ALREADY_EXIST_EXCEPTION); } if(image.isEmpty() && notionUri.isEmpty()){ @@ -185,7 +185,7 @@ public void saveExistPortfolio(Member member, MultipartFile image, String notion if (image != null && !image.isEmpty()) { s3Url = s3Client.upload(image, S3_PORTFOLIO_DIR_NAME); } - Portfolio portfolio = new Portfolio(member,s3Url,notionUri); + Portfolio portfolio = new Portfolio(member,generatePortfolioName(null),s3Url,notionUri); portfolioRepository.save(portfolio); } @@ -205,6 +205,7 @@ public void deleteExistPortfolio(Member member, Long id){ public void updateExistPortfolio(Member member, Long id, MultipartFile image, String notionUri){ //등록된 파일이나 노션 링크 있는지 확인 //Validation + System.out.println(id); Portfolio portfolio = portfolioRepository.findById(id).orElseThrow(()-> new ApplicationException(ErrorCode.NOT_FOUND_EXCEPTION)); if(!member.getId().equals(portfolio.getMember().getId())){ throw new ApplicationException(ErrorCode.UNAUTHORIZED_EXCEPTION); @@ -215,6 +216,7 @@ public void updateExistPortfolio(Member member, Long id, MultipartFile image, St s3Client.delete(portfolio.getFileUri()); s3Url = s3Client.upload(image, S3_PORTFOLIO_DIR_NAME); } + System.out.println(notionUri); portfolio.updateExistPortfolio(portfolio,s3Url,notionUri); portfolioRepository.save(portfolio); } From 41f6ead584394e58aacae4518419fc34f2ba02a8 Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sun, 22 Sep 2024 00:22:12 +0900 Subject: [PATCH 05/17] #213 fix : exists profolio uri --- .../server/domain/portfolio/entity/Portfolio.java | 6 +++--- .../portfolio/repository/PortfolioRepository.java | 2 +- .../domain/portfolio/service/PortfolioService.java | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java index 22f6a7a3..a7682519 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/entity/Portfolio.java @@ -58,9 +58,9 @@ public Portfolio(Member member, String portfolioName, String fileUri, String not this.fileUri = fileUri; this.notionUri = notionUri; } - public void updateExistPortfolio(Portfolio portfolio, String fileUri, String notionUri) { - this.fileUri = (fileUri == null) ? this.fileUri : portfolio.getFileUri(); - this.notionUri = (notionUri == null) ? this.notionUri : portfolio.getNotionUri(); + public void updatePortfolioUri(Portfolio portfolio, String fileUri, String notionUri) { + this.fileUri = (fileUri == null) ? this.fileUri : fileUri; + this.notionUri = (notionUri == null) ? this.notionUri : notionUri; } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java index 55408763..b49d6399 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java @@ -12,7 +12,7 @@ public interface PortfolioRepository extends JpaRepository, Por long countByDeletedAtIsNull(); @Query("SELECT EXISTS (" + "SELECT 1 FROM Portfolio po " + - "WHERE po.member = :member AND (po.fileUri IS NOT NULL OR po.notionUri IS NOT NULL))") + "WHERE po.member = :member AND (po.fileUri IS NOT NULL OR po.notionUri IS NOT NULL) AND po.deletedAt IS NULL )") Boolean existsExistPortfolioByMember(@Param("member") Member member); Optional findPortfolioById(Long portfolioId); } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index 3c609334..c2ba8d14 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -195,7 +195,7 @@ public void deleteExistPortfolio(Member member, Long id){ if(!member.getId().equals(portfolio.getMember().getId())){ throw new ApplicationException(ErrorCode.UNAUTHORIZED_EXCEPTION); } - if(portfolio.getFileUri() != null){ + if(portfolio.getFileUri() != null&& !portfolio.getFileUri().isEmpty()){ s3Client.delete(portfolio.getFileUri()); } portfolioRepository.delete(portfolio); @@ -205,19 +205,19 @@ public void deleteExistPortfolio(Member member, Long id){ public void updateExistPortfolio(Member member, Long id, MultipartFile image, String notionUri){ //등록된 파일이나 노션 링크 있는지 확인 //Validation - System.out.println(id); - Portfolio portfolio = portfolioRepository.findById(id).orElseThrow(()-> new ApplicationException(ErrorCode.NOT_FOUND_EXCEPTION)); + Portfolio portfolio = portfolioRepository.findById(id).orElseThrow(()-> new ApplicationException(ErrorCode.PORTFOLIO_NOT_FOUND_EXCEPTION)); if(!member.getId().equals(portfolio.getMember().getId())){ throw new ApplicationException(ErrorCode.UNAUTHORIZED_EXCEPTION); } //Business String s3Url = null; if (image != null && !image.isEmpty()) { - s3Client.delete(portfolio.getFileUri()); + if(portfolio.getFileUri()!=null && !portfolio.getFileUri().isEmpty()){ + s3Client.delete(portfolio.getFileUri()); + } s3Url = s3Client.upload(image, S3_PORTFOLIO_DIR_NAME); } - System.out.println(notionUri); - portfolio.updateExistPortfolio(portfolio,s3Url,notionUri); + portfolio.updatePortfolioUri(portfolio,s3Url,notionUri); portfolioRepository.save(portfolio); } From 529a1b9350059e9dce5c33700d734417ab734563 Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sun, 22 Sep 2024 00:31:19 +0900 Subject: [PATCH 06/17] =?UTF-8?q?#213=20fix=20:=20image->file=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../portfolio/controller/PortfolioController.java | 8 ++++---- .../domain/portfolio/service/PortfolioService.java | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java index c459c5ba..b30c1e2f 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java @@ -64,8 +64,8 @@ public ApplicationResponse> getMyPortfolios(@Authentica @Operation(description = "포트폴리오 파일 및 링크 업로드 API") @PostMapping("/exist-protfolio") - public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestPart(required = false,name = "image") MultipartFile image, @RequestPart(required = false,name = "notionUri") String notionUri){ - portfolioService.saveExistPortfolio(principalDetails.getMember(),image,notionUri); + public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestPart(required = false,name = "file") MultipartFile file, @RequestPart(required = false,name = "notionUri") String notionUri){ + portfolioService.saveExistPortfolio(principalDetails.getMember(),file,notionUri); return ApplicationResponse.ok(); } @@ -78,8 +78,8 @@ public ApplicationResponse deleteExistPortfolio(@AuthenticationPrincipal P @Operation(description = "포트폴리오 파일 및 링크 업로드 업데이트 API") @PatchMapping("/exist-protfolio/{portfolio_id}") - public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false,name = "image") MultipartFile image, @RequestPart(required = false,name = "notionUri") String notionUri){ - portfolioService.updateExistPortfolio(principalDetails.getMember(),portfolioId,image,notionUri); + public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false,name = "file") MultipartFile file, @RequestPart(required = false,name = "notionUri") String notionUri){ + portfolioService.updateExistPortfolio(principalDetails.getMember(),portfolioId,file,notionUri); return ApplicationResponse.ok(); } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index c2ba8d14..6e19868e 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -170,20 +170,20 @@ public List getMyPortfolios(Member member) { } @Transactional - public void saveExistPortfolio(Member member, MultipartFile image, String notionUri){ + public void saveExistPortfolio(Member member, MultipartFile file, String notionUri){ //등록된 파일이나 노션 링크 있는지 확인 //Validation Boolean isExist = portfolioRepository.existsExistPortfolioByMember(member); if (isExist){ throw new ApplicationException(ErrorCode.ALREADY_EXIST_EXCEPTION); } - if(image.isEmpty() && notionUri.isEmpty()){ + if(file.isEmpty() && notionUri.isEmpty()){ throw new ApplicationException(ErrorCode.PORTFOLIO_SAVE_FAILED_EXCEPTION); } //Business String s3Url = null; - if (image != null && !image.isEmpty()) { - s3Url = s3Client.upload(image, S3_PORTFOLIO_DIR_NAME); + if (file != null && !file.isEmpty()) { + s3Url = s3Client.upload(file, S3_PORTFOLIO_DIR_NAME); } Portfolio portfolio = new Portfolio(member,generatePortfolioName(null),s3Url,notionUri); portfolioRepository.save(portfolio); @@ -202,7 +202,7 @@ public void deleteExistPortfolio(Member member, Long id){ } @Transactional - public void updateExistPortfolio(Member member, Long id, MultipartFile image, String notionUri){ + public void updateExistPortfolio(Member member, Long id, MultipartFile file, String notionUri){ //등록된 파일이나 노션 링크 있는지 확인 //Validation Portfolio portfolio = portfolioRepository.findById(id).orElseThrow(()-> new ApplicationException(ErrorCode.PORTFOLIO_NOT_FOUND_EXCEPTION)); @@ -211,11 +211,11 @@ public void updateExistPortfolio(Member member, Long id, MultipartFile image, St } //Business String s3Url = null; - if (image != null && !image.isEmpty()) { + if (file != null && !file.isEmpty()) { if(portfolio.getFileUri()!=null && !portfolio.getFileUri().isEmpty()){ s3Client.delete(portfolio.getFileUri()); } - s3Url = s3Client.upload(image, S3_PORTFOLIO_DIR_NAME); + s3Url = s3Client.upload(file, S3_PORTFOLIO_DIR_NAME); } portfolio.updatePortfolioUri(portfolio,s3Url,notionUri); portfolioRepository.save(portfolio); From 0fc4c68c02aeabece14dbb7552785565e09e3251 Mon Sep 17 00:00:00 2001 From: yumzen Date: Sun, 22 Sep 2024 11:32:51 +0900 Subject: [PATCH 07/17] =?UTF-8?q?[#226]=20Fix:=20team=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=20=EC=8B=9C=20=EC=A7=80=EC=9B=90=EC=83=81=ED=83=9C=EB=A9=B4=20?= =?UTF-8?q?applyStatus=EC=99=80=20applyId=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/apply/enumerate/ApplyStatus.java | 6 +++--- .../apply/repository/ApplyRepository.java | 1 + .../domain/team/dto/response/TeamRes.java | 13 +++++++++++-- .../domain/team/service/TeamService.java | 18 +++++++++++------- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/apply/enumerate/ApplyStatus.java b/src/main/java/com/gongjakso/server/domain/apply/enumerate/ApplyStatus.java index f69a6bf3..ed36827f 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/enumerate/ApplyStatus.java +++ b/src/main/java/com/gongjakso/server/domain/apply/enumerate/ApplyStatus.java @@ -6,9 +6,9 @@ @Getter @RequiredArgsConstructor public enum ApplyStatus { - COMPLETED("지원 완료"), - ACCEPTED("합격"), - REJECTED("불합격"); + COMPLETED("합류 대기중"), + ACCEPTED("합류 완료"), + REJECTED("미선발"); private final String description; } diff --git a/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java b/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java index 11e41767..d074d88f 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java +++ b/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java @@ -9,4 +9,5 @@ public interface ApplyRepository extends JpaRepository, ApplyReposi Boolean existsByMemberIdAndTeamIdAndDeletedAtIsNull(Long memberId, Long teamId); Optional findByIdAndDeletedAtIsNull(Long applyId); Optional findByTeamIdAndDeletedAtIsNull(Long teamId); + Optional findByTeamIdAndMemberIdAndDeletedAtIsNull(Long teamId, Long memberId); } diff --git a/src/main/java/com/gongjakso/server/domain/team/dto/response/TeamRes.java b/src/main/java/com/gongjakso/server/domain/team/dto/response/TeamRes.java index 52fa7f9b..931bf873 100644 --- a/src/main/java/com/gongjakso/server/domain/team/dto/response/TeamRes.java +++ b/src/main/java/com/gongjakso/server/domain/team/dto/response/TeamRes.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; +import com.gongjakso.server.domain.apply.entity.Apply; import com.gongjakso.server.domain.team.entity.Team; import com.gongjakso.server.domain.team.vo.RecruitPart; import io.swagger.v3.oas.annotations.media.Schema; @@ -82,7 +83,13 @@ public record TeamRes( int viewCount, @Schema(description = "사용자 역할", example = "LEADER") - String teamRole + String teamRole, + + @Schema(description = "지원 상태", example = "합류 대기중 | 합류 완료 | 미선발") + String applyStatus, + + @Schema(description = "지원 ID", example = "1") + Long applyId ) { @Builder @@ -108,7 +115,7 @@ public static RecruitPartRes of(RecruitPart recruitPart) { } - public static TeamRes of(Team team, String teamRole) { + public static TeamRes of(Team team, String teamRole, Apply apply) { List recruitPartRes = (team.getRecruitPart() != null) ? team.getRecruitPart().stream() .map(RecruitPartRes::of) .toList() : null; @@ -136,6 +143,8 @@ public static TeamRes of(Team team, String teamRole) { .contestLink(team.getContest().getContestLink()) .scrapCount(team.getScrapCount()) .teamRole(teamRole) + .applyStatus(apply != null ? apply.getStatus().getDescription() : null) + .applyId(apply != null ? apply.getId() : null) .build(); } } diff --git a/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java b/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java index 9432555a..48a54fc1 100644 --- a/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java +++ b/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java @@ -46,7 +46,7 @@ public TeamRes createTeam(Member member, Long contestId, TeamReq teamReq) { Team savedTeam = teamRepository.save(team); // Response - return TeamRes.of(savedTeam, "LEADER"); + return TeamRes.of(savedTeam, "LEADER", null); } @Transactional @@ -68,7 +68,7 @@ public TeamRes updateTeam(Member member, Long contestId, Long teamId, TeamReq te Team updatedTeam = teamRepository.save(team); // Response - return TeamRes.of(updatedTeam, "LEADER"); + return TeamRes.of(updatedTeam, "LEADER", null); } @Transactional @@ -91,7 +91,7 @@ public TeamRes extendRecruit(Member member, Long contestId, Long teamId, LocalDa Team updatedTeam = teamRepository.save(team); // Response - return TeamRes.of(updatedTeam, "LEADER"); + return TeamRes.of(updatedTeam, "LEADER", null); } @Transactional @@ -113,7 +113,7 @@ public TeamRes closeRecruit(Member member, Long contestId, Long teamId) { Team updatedTeam = teamRepository.save(team); // Response - return TeamRes.of(updatedTeam, "LEADER"); + return TeamRes.of(updatedTeam, "LEADER", null); } @Transactional @@ -135,7 +135,7 @@ public TeamRes cancelRecruit(Member member, Long contestId, Long teamId) { Team updatedTeam = teamRepository.save(team); // Response - return TeamRes.of(updatedTeam, "LEADER"); + return TeamRes.of(updatedTeam, "LEADER", null); } @Transactional @@ -172,14 +172,18 @@ public TeamRes getTeam(Member member, Long contestId, Long teamId) { .toList(); String teamRole = "GENERAL"; + Apply apply = null; + if(member != null && team.getMember().getId().equals(member.getId())){ teamRole = "LEADER"; }else if(member != null && appliers.stream().anyMatch(applier -> applier.getId().equals(member.getId()))){ teamRole = "APPLIER"; + apply = applyRepository.findByTeamIdAndMemberIdAndDeletedAtIsNull(teamId, member.getId()) + .orElseThrow(() -> new ApplicationException(ErrorCode.APPLY_NOT_FOUND_EXCEPTION)); } // Business Logic - return TeamRes.of(team, teamRole); + return TeamRes.of(team, teamRole, apply); } public Page getTeamListWithContest(Long contestId, String province, String district, Pageable pageable) { @@ -298,6 +302,6 @@ public TeamRes changeTeamStatus(Member member, Long contestId, Long teamId, Stri Team updatedTeam = teamRepository.save(team); // Response - return TeamRes.of(updatedTeam, "LEADER"); + return TeamRes.of(updatedTeam, "LEADER", null); } } From 9b0480ae40fb057a7d42a8c5d2e973f276237fac Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sun, 22 Sep 2024 15:54:47 +0900 Subject: [PATCH 08/17] =?UTF-8?q?#228=20fix=20:=20controller=20=EC=98=A4?= =?UTF-8?q?=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/portfolio/controller/PortfolioController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java index b30c1e2f..8fc78010 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/controller/PortfolioController.java @@ -63,28 +63,28 @@ public ApplicationResponse> getMyPortfolios(@Authentica } @Operation(description = "포트폴리오 파일 및 링크 업로드 API") - @PostMapping("/exist-protfolio") + @PostMapping("/exist-portfolio") public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestPart(required = false,name = "file") MultipartFile file, @RequestPart(required = false,name = "notionUri") String notionUri){ portfolioService.saveExistPortfolio(principalDetails.getMember(),file,notionUri); return ApplicationResponse.ok(); } @Operation(description = "포트폴리오 파일 및 링크 업로드 삭제 API") - @DeleteMapping("/exist-protfolio/{portfolio_id}") + @DeleteMapping("/exist-portfolio/{portfolio_id}") public ApplicationResponse deleteExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId){ portfolioService.deleteExistPortfolio(principalDetails.getMember(),portfolioId); return ApplicationResponse.ok(); } @Operation(description = "포트폴리오 파일 및 링크 업로드 업데이트 API") - @PatchMapping("/exist-protfolio/{portfolio_id}") + @PatchMapping("/exist-portfolio/{portfolio_id}") public ApplicationResponse updateExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId, @RequestPart(required = false,name = "file") MultipartFile file, @RequestPart(required = false,name = "notionUri") String notionUri){ portfolioService.updateExistPortfolio(principalDetails.getMember(),portfolioId,file,notionUri); return ApplicationResponse.ok(); } @Operation(description = "포트폴리오 파일 및 링크 업로드 가져오기 API") - @GetMapping("/exist-protfolio/{portfolio_id}") + @GetMapping("/exist-portfolio/{portfolio_id}") public ApplicationResponse findExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("portfolio_id") Long portfolioId){ return ApplicationResponse.ok(portfolioService.findExistPorfolio(principalDetails.getMember(),portfolioId)); } From 5114322a0c746451eb691eaf53076cc8f86b24eb Mon Sep 17 00:00:00 2001 From: yumzen Date: Sun, 22 Sep 2024 15:57:00 +0900 Subject: [PATCH 09/17] =?UTF-8?q?[#229]=20Fix:=20Portfolio=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../portfolio/dto/response/SimplePortfolioRes.java | 14 +++++++++----- .../domain/portfolio/service/PortfolioService.java | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java index ee60919d..5a628ed7 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java @@ -1,19 +1,23 @@ package com.gongjakso.server.domain.portfolio.dto.response; +import com.fasterxml.jackson.annotation.JsonInclude; import com.gongjakso.server.domain.portfolio.entity.Portfolio; import java.time.LocalDateTime; +@JsonInclude(JsonInclude.Include.NON_NULL) public record SimplePortfolioRes( Long PortfolioId, String PortfolioName, - LocalDateTime modifiedAt + LocalDateTime modifiedAt, + Boolean isRegistered ) { - public static SimplePortfolioRes of(Portfolio portfolio) { + public static SimplePortfolioRes of(Portfolio portfolio, Boolean isRegistered) { return new SimplePortfolioRes( - portfolio.getId(), - portfolio.getPortfolioName(), - portfolio.getModifiedAt() + isRegistered ? portfolio.getId() : null, + isRegistered ? portfolio.getPortfolioName() : null, + isRegistered ? portfolio.getModifiedAt() : null, + isRegistered ); } } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index 6e19868e..0b4cd418 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -164,8 +164,13 @@ public void deletePortfolio(Member member, Long portfolioId) { public List getMyPortfolios(Member member) { List portfolioList = portfolioRepository.findByMemberAndDeletedAtIsNull(member); + + if (portfolioList.isEmpty()) { + return List.of(SimplePortfolioRes.of(null, false)); + } + return portfolioList.stream() - .map(SimplePortfolioRes::of) + .map(portfolio -> SimplePortfolioRes.of(portfolio, true)) .toList(); } From fdb1ebdd2522a02bb9b8f28ad181e8a16b990fc3 Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:03:15 +0900 Subject: [PATCH 10/17] =?UTF-8?q?#228=20fix=20:=20portfolio=20file=20null,?= =?UTF-8?q?empty=20=EC=A1=B0=EA=B1=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/domain/portfolio/service/PortfolioService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index 6e19868e..5e34479e 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -182,7 +182,7 @@ public void saveExistPortfolio(Member member, MultipartFile file, String notionU } //Business String s3Url = null; - if (file != null && !file.isEmpty()) { + if ( file!=null || !file.isEmpty()) { s3Url = s3Client.upload(file, S3_PORTFOLIO_DIR_NAME); } Portfolio portfolio = new Portfolio(member,generatePortfolioName(null),s3Url,notionUri); @@ -195,7 +195,7 @@ public void deleteExistPortfolio(Member member, Long id){ if(!member.getId().equals(portfolio.getMember().getId())){ throw new ApplicationException(ErrorCode.UNAUTHORIZED_EXCEPTION); } - if(portfolio.getFileUri() != null&& !portfolio.getFileUri().isEmpty()){ + if(portfolio.getFileUri() != null || !portfolio.getFileUri().isEmpty()){ s3Client.delete(portfolio.getFileUri()); } portfolioRepository.delete(portfolio); From cd0cf994c88907f46d91af5455bd64b10a744c7d Mon Sep 17 00:00:00 2001 From: yumzen Date: Sun, 22 Sep 2024 16:38:48 +0900 Subject: [PATCH 11/17] =?UTF-8?q?[#229]=20Fix:=20Portfolio=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/portfolio/dto/response/SimplePortfolioRes.java | 8 +++++--- .../server/domain/portfolio/service/PortfolioService.java | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java index 5a628ed7..ab232350 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java @@ -10,14 +10,16 @@ public record SimplePortfolioRes( Long PortfolioId, String PortfolioName, LocalDateTime modifiedAt, - Boolean isRegistered + Boolean isRegistered, + Boolean isExistPortfolio ) { - public static SimplePortfolioRes of(Portfolio portfolio, Boolean isRegistered) { + public static SimplePortfolioRes of(Portfolio portfolio, Boolean isRegistered, Boolean isExistPortfolio) { return new SimplePortfolioRes( isRegistered ? portfolio.getId() : null, isRegistered ? portfolio.getPortfolioName() : null, isRegistered ? portfolio.getModifiedAt() : null, - isRegistered + isRegistered, + isExistPortfolio ); } } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index 0b4cd418..1fbd0607 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -166,11 +166,11 @@ public List getMyPortfolios(Member member) { List portfolioList = portfolioRepository.findByMemberAndDeletedAtIsNull(member); if (portfolioList.isEmpty()) { - return List.of(SimplePortfolioRes.of(null, false)); + return List.of(SimplePortfolioRes.of(null, false, null)); } return portfolioList.stream() - .map(portfolio -> SimplePortfolioRes.of(portfolio, true)) + .map(portfolio -> SimplePortfolioRes.of(portfolio, true, portfolio.getFileUri() != null || portfolio.getNotionUri() != null)) .toList(); } From e34da516d6bc5568e4ec71085581eb189d4647c8 Mon Sep 17 00:00:00 2001 From: yumzen Date: Sun, 22 Sep 2024 16:40:44 +0900 Subject: [PATCH 12/17] =?UTF-8?q?[#229]=20Fix:=20Portfolio=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/portfolio/dto/response/SimplePortfolioRes.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java index ab232350..b7e2cfd3 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/dto/response/SimplePortfolioRes.java @@ -11,15 +11,15 @@ public record SimplePortfolioRes( String PortfolioName, LocalDateTime modifiedAt, Boolean isRegistered, - Boolean isExistPortfolio + Boolean isExistedPortfolio ) { - public static SimplePortfolioRes of(Portfolio portfolio, Boolean isRegistered, Boolean isExistPortfolio) { + public static SimplePortfolioRes of(Portfolio portfolio, Boolean isRegistered, Boolean isExistedPortfolio) { return new SimplePortfolioRes( isRegistered ? portfolio.getId() : null, isRegistered ? portfolio.getPortfolioName() : null, isRegistered ? portfolio.getModifiedAt() : null, isRegistered, - isExistPortfolio + isExistedPortfolio ); } } From 4f8cfc1ea70791a50db62415c8f8fd765d3e783b Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:56:05 +0900 Subject: [PATCH 13/17] =?UTF-8?q?#228=20fix=20:=20empty=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/domain/portfolio/service/PortfolioService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java index 5e34479e..c4add3ee 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/service/PortfolioService.java @@ -177,12 +177,12 @@ public void saveExistPortfolio(Member member, MultipartFile file, String notionU if (isExist){ throw new ApplicationException(ErrorCode.ALREADY_EXIST_EXCEPTION); } - if(file.isEmpty() && notionUri.isEmpty()){ + if (file == null && notionUri == null){ throw new ApplicationException(ErrorCode.PORTFOLIO_SAVE_FAILED_EXCEPTION); } //Business String s3Url = null; - if ( file!=null || !file.isEmpty()) { + if ( file!=null ) { s3Url = s3Client.upload(file, S3_PORTFOLIO_DIR_NAME); } Portfolio portfolio = new Portfolio(member,generatePortfolioName(null),s3Url,notionUri); @@ -211,7 +211,7 @@ public void updateExistPortfolio(Member member, Long id, MultipartFile file, Str } //Business String s3Url = null; - if (file != null && !file.isEmpty()) { + if ( file!=null ) { if(portfolio.getFileUri()!=null && !portfolio.getFileUri().isEmpty()){ s3Client.delete(portfolio.getFileUri()); } From dec1d58a30f948e0eb91046d2ff999b8c1d0f54a Mon Sep 17 00:00:00 2001 From: yumzen Date: Sun, 22 Sep 2024 20:27:59 +0900 Subject: [PATCH 14/17] =?UTF-8?q?[#234]=20Feat:=20=ED=8A=B9=EC=A0=95=20?= =?UTF-8?q?=ED=8C=80=EC=9D=98=20=EC=A7=80=EC=9B=90=EC=9E=90=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/dto/response/SimpleApplyRes.java | 39 +++++++++++++++++++ .../apply/repository/ApplyRepository.java | 2 + .../team/controller/TeamController.java | 9 +++++ .../domain/team/service/TeamService.java | 15 +++++++ 4 files changed, 65 insertions(+) create mode 100644 src/main/java/com/gongjakso/server/domain/apply/dto/response/SimpleApplyRes.java diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/response/SimpleApplyRes.java b/src/main/java/com/gongjakso/server/domain/apply/dto/response/SimpleApplyRes.java new file mode 100644 index 00000000..3ac49bf3 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/response/SimpleApplyRes.java @@ -0,0 +1,39 @@ +package com.gongjakso.server.domain.apply.dto.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.gongjakso.server.domain.apply.entity.Apply; +import jakarta.validation.constraints.NotNull; +import lombok.Builder; + +@Builder +@JsonInclude(JsonInclude.Include.NON_NULL) +public record SimpleApplyRes( + @NotNull + Long applyId, + + @NotNull + Long teamId, + + @NotNull + Long memberId, + String memberName, + Long portfolioId, + String portfolioName, + String status, + String part, + Boolean isViewed +) { + public static SimpleApplyRes of(Apply apply){ + return SimpleApplyRes.builder() + .applyId(apply.getId()) + .teamId(apply.getTeam().getId()) + .memberId(apply.getMember().getId()) + .memberName(apply.getMember().getName()) + .portfolioId(apply.getPortfolioInfo().getPortfolio() != null ? apply.getPortfolioInfo().getPortfolio().getId() : null) + .portfolioName(apply.getPortfolioInfo().getPortfolio() != null ? apply.getPortfolioInfo().getPortfolio().getPortfolioName() : null) + .status(apply.getStatus().name()) + .part(apply.getPart()) + .isViewed(apply.isViewed()) + .build(); + } +} diff --git a/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java b/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java index d074d88f..d4a45899 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java +++ b/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java @@ -3,6 +3,7 @@ import com.gongjakso.server.domain.apply.entity.Apply; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; import java.util.Optional; public interface ApplyRepository extends JpaRepository, ApplyRepositoryCustom { @@ -10,4 +11,5 @@ public interface ApplyRepository extends JpaRepository, ApplyReposi Optional findByIdAndDeletedAtIsNull(Long applyId); Optional findByTeamIdAndDeletedAtIsNull(Long teamId); Optional findByTeamIdAndMemberIdAndDeletedAtIsNull(Long teamId, Long memberId); + List findAllByTeamIdAndDeletedAtIsNull(Long teamId); } diff --git a/src/main/java/com/gongjakso/server/domain/team/controller/TeamController.java b/src/main/java/com/gongjakso/server/domain/team/controller/TeamController.java index 696d15f2..8cd42485 100644 --- a/src/main/java/com/gongjakso/server/domain/team/controller/TeamController.java +++ b/src/main/java/com/gongjakso/server/domain/team/controller/TeamController.java @@ -1,5 +1,6 @@ package com.gongjakso.server.domain.team.controller; +import com.gongjakso.server.domain.apply.dto.response.SimpleApplyRes; import com.gongjakso.server.domain.team.dto.request.TeamReq; import com.gongjakso.server.domain.team.dto.response.ScrapRes; import com.gongjakso.server.domain.team.dto.response.SimpleTeamRes; @@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.*; import java.time.LocalDate; +import java.util.List; @RestController @@ -162,4 +164,11 @@ public ApplicationResponse changeTeamStatus(@AuthenticationPrincipal Pr @RequestParam(value = "status") String status) { return ApplicationResponse.ok(teamService.changeTeamStatus(principalDetails.getMember(), contestId, teamId, status)); } + + @Operation(summary = "특정 팀의 지원자 리스트 조회", description = "특정 팀의 지원자 리스트를 조회하는 API") + @GetMapping("/team/{team_id}") + public ApplicationResponse> getAppliesByTeam(@AuthenticationPrincipal PrincipalDetails principalDetails, + @PathVariable("team_id") Long teamId) { + return ApplicationResponse.ok(teamService.getApplyList(principalDetails.getMember(), teamId)); + } } diff --git a/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java b/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java index 48a54fc1..cd9f1860 100644 --- a/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java +++ b/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java @@ -1,5 +1,6 @@ package com.gongjakso.server.domain.team.service; +import com.gongjakso.server.domain.apply.dto.response.SimpleApplyRes; import com.gongjakso.server.domain.apply.entity.Apply; import com.gongjakso.server.domain.apply.repository.ApplyRepository; import com.gongjakso.server.domain.contest.entity.Contest; @@ -304,4 +305,18 @@ public TeamRes changeTeamStatus(Member member, Long contestId, Long teamId, Stri // Response return TeamRes.of(updatedTeam, "LEADER", null); } + + public List getApplyList(Member member, Long teamId) { + // Validation + Team team = teamRepository.findByIdAndDeletedAtIsNull(teamId) + .orElseThrow(() -> new ApplicationException(ErrorCode.TEAM_NOT_FOUND_EXCEPTION)); + if (!team.getMember().getId().equals(member.getId())) { + throw new ApplicationException(ErrorCode.FORBIDDEN_EXCEPTION); + } + + // Business Logic & Response + return applyRepository.findAllByTeamIdAndDeletedAtIsNull(teamId).stream() + .map(SimpleApplyRes::of) + .toList(); + } } From 41a2df9149b592f89edc7e385c8dbb2513c1e23c Mon Sep 17 00:00:00 2001 From: yumzen Date: Sun, 22 Sep 2024 21:13:07 +0900 Subject: [PATCH 15/17] =?UTF-8?q?fix:=20=ED=8C=80=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gongjakso/server/domain/team/service/TeamService.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java b/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java index cd9f1860..cbdd10ae 100644 --- a/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java +++ b/src/main/java/com/gongjakso/server/domain/team/service/TeamService.java @@ -168,16 +168,12 @@ public TeamRes getTeam(Member member, Long contestId, Long teamId) { throw new ApplicationException(ErrorCode.TEAM_NOT_FOUND_EXCEPTION); } - List appliers = applyRepository.findByTeamIdAndDeletedAtIsNull(teamId).stream() - .map(Apply::getMember) - .toList(); - String teamRole = "GENERAL"; Apply apply = null; if(member != null && team.getMember().getId().equals(member.getId())){ teamRole = "LEADER"; - }else if(member != null && appliers.stream().anyMatch(applier -> applier.getId().equals(member.getId()))){ + }else if(member != null && applyRepository.findByTeamIdAndMemberIdAndDeletedAtIsNull(teamId, member.getId()).isPresent()){ teamRole = "APPLIER"; apply = applyRepository.findByTeamIdAndMemberIdAndDeletedAtIsNull(teamId, member.getId()) .orElseThrow(() -> new ApplicationException(ErrorCode.APPLY_NOT_FOUND_EXCEPTION)); From 0a2d7efa73a540d624ed1ec801cb7d0a3ebc86fd Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Mon, 23 Sep 2024 00:15:57 +0900 Subject: [PATCH 16/17] #239 fix : total size --- .../server/domain/team/repository/TeamRepositoryImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gongjakso/server/domain/team/repository/TeamRepositoryImpl.java b/src/main/java/com/gongjakso/server/domain/team/repository/TeamRepositoryImpl.java index 4edbb647..419f7333 100644 --- a/src/main/java/com/gongjakso/server/domain/team/repository/TeamRepositoryImpl.java +++ b/src/main/java/com/gongjakso/server/domain/team/repository/TeamRepositoryImpl.java @@ -191,6 +191,7 @@ public Page findParticipatePagination(Long memberId, Pageable pag Long total = queryFactory.select(team.count()) .from(team) .where( + team.status.in(teamStatusList), team.deletedAt.isNull() ) .fetchOne(); @@ -224,6 +225,7 @@ public Page findScrapPagination(Long memberId, Pageable pageable) Long total = queryFactory.select(team.count()) .from(team) .where( + team.id.in(teamIdList), team.deletedAt.isNull() ) .fetchOne(); From 34f21cfe5c9f07e69a3e199f91f717edccfeca7f Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Mon, 23 Sep 2024 00:37:46 +0900 Subject: [PATCH 17/17] =?UTF-8?q?#241=20refactor=20:=20query->querydsl?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contest/repository/ContestRepositoryCustom.java | 7 +++++++ .../domain/contest/repository/ContestRepositoryImpl.java | 2 -- .../domain/portfolio/repository/PortfolioRepository.java | 4 ---- .../portfolio/repository/PortfolioRepositoryCustom.java | 1 + .../portfolio/repository/PortfolioRepositoryImpl.java | 9 +++++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/contest/repository/ContestRepositoryCustom.java b/src/main/java/com/gongjakso/server/domain/contest/repository/ContestRepositoryCustom.java index d23f9339..e1fbf013 100644 --- a/src/main/java/com/gongjakso/server/domain/contest/repository/ContestRepositoryCustom.java +++ b/src/main/java/com/gongjakso/server/domain/contest/repository/ContestRepositoryCustom.java @@ -6,5 +6,12 @@ import org.springframework.data.domain.Pageable; public interface ContestRepositoryCustom { + /** + * 찾고자하는 단어 검색 + * @param word searchWord + * @param sort 정렬순 + */ Page searchList (String word, String sort, Pageable pageable); + + } diff --git a/src/main/java/com/gongjakso/server/domain/contest/repository/ContestRepositoryImpl.java b/src/main/java/com/gongjakso/server/domain/contest/repository/ContestRepositoryImpl.java index 12d72885..4dbd9cb0 100644 --- a/src/main/java/com/gongjakso/server/domain/contest/repository/ContestRepositoryImpl.java +++ b/src/main/java/com/gongjakso/server/domain/contest/repository/ContestRepositoryImpl.java @@ -21,8 +21,6 @@ public ContestRepositoryImpl(EntityManager em) { this.queryFactory = new JPAQueryFactory(em); } - //최신순으로 정렬 - //제목,본문 기준으로 검색 @Override public Page searchList(String word, String sortAt, Pageable pageable) { List contestList = queryFactory diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java index b49d6399..6b20ed0e 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepository.java @@ -10,9 +10,5 @@ public interface PortfolioRepository extends JpaRepository, PortfolioRepositoryCustom{ Optional findByIdAndDeletedAtIsNull(Long portfolioId); long countByDeletedAtIsNull(); - @Query("SELECT EXISTS (" + - "SELECT 1 FROM Portfolio po " + - "WHERE po.member = :member AND (po.fileUri IS NOT NULL OR po.notionUri IS NOT NULL) AND po.deletedAt IS NULL )") - Boolean existsExistPortfolioByMember(@Param("member") Member member); Optional findPortfolioById(Long portfolioId); } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepositoryCustom.java b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepositoryCustom.java index d7ddf394..c21b09b0 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepositoryCustom.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepositoryCustom.java @@ -7,4 +7,5 @@ public interface PortfolioRepositoryCustom { List findByMemberAndDeletedAtIsNull(Member member); + Boolean existsExistPortfolioByMember(Member member); } diff --git a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepositoryImpl.java b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepositoryImpl.java index df152c6b..4f01f4f7 100644 --- a/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepositoryImpl.java +++ b/src/main/java/com/gongjakso/server/domain/portfolio/repository/PortfolioRepositoryImpl.java @@ -20,4 +20,13 @@ public List findByMemberAndDeletedAtIsNull(Member member) { .and(portfolio.deletedAt.isNull())) .fetch(); } + + public Boolean existsExistPortfolioByMember(Member member){ + return queryFactory + .selectFrom(portfolio) + .where(portfolio.member.eq(member) + .and(portfolio.fileUri.isNotNull().or(portfolio.notionUri.isNotNull())) + .and(portfolio.deletedAt.isNull())) + .fetchFirst()!=null; + } }