Skip to content

Commit

Permalink
Merge branch 'main' into fix/team
Browse files Browse the repository at this point in the history
  • Loading branch information
dl-00-e8 committed Sep 23, 2024
2 parents 7a3391f + 8970f67 commit a9f3698
Show file tree
Hide file tree
Showing 17 changed files with 271 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
@Getter
@RequiredArgsConstructor
public enum ApplyStatus {
COMPLETED("지원 완료"),
ACCEPTED("합격"),
REJECTED("불합격");
COMPLETED("합류 대기중"),
ACCEPTED("합류 완료"),
REJECTED("미선발");

private final String description;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
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<Apply, Long>, ApplyRepositoryCustom {
Boolean existsByMemberIdAndTeamIdAndDeletedAtIsNull(Long memberId, Long teamId);
Optional<Apply> findByIdAndDeletedAtIsNull(Long applyId);
Optional<Apply> findByTeamIdAndDeletedAtIsNull(Long teamId);
Optional<Apply> findByTeamIdAndMemberIdAndDeletedAtIsNull(Long teamId, Long memberId);
List<Apply> findAllByTeamIdAndDeletedAtIsNull(Long teamId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,12 @@
import org.springframework.data.domain.Pageable;

public interface ContestRepositoryCustom {
/**
* 찾고자하는 단어 검색
* @param word searchWord
* @param sort 정렬순
*/
Page<Contest> searchList (String word, String sort, Pageable pageable);


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public ContestRepositoryImpl(EntityManager em) {
this.queryFactory = new JPAQueryFactory(em);
}

//최신순으로 정렬
//제목,본문 기준으로 검색
@Override
public Page<Contest> searchList(String word, String sortAt, Pageable pageable) {
List<Contest> contestList = queryFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gongjakso.server.domain.portfolio.controller;

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;
Expand All @@ -11,14 +12,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;

Expand Down Expand Up @@ -66,4 +61,33 @@ public ApplicationResponse<Void> deletePortfolio(@AuthenticationPrincipal Princi
public ApplicationResponse<List<SimplePortfolioRes>> getMyPortfolios(@AuthenticationPrincipal PrincipalDetails principalDetails) {
return ApplicationResponse.ok(portfolioService.getMyPortfolios(principalDetails.getMember()));
}

@Operation(description = "포트폴리오 파일 및 링크 업로드 API")
@PostMapping("/exist-portfolio")
public ApplicationResponse<Void> 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-portfolio/{portfolio_id}")
public ApplicationResponse<Void> deleteExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("portfolio_id") Long portfolioId){
portfolioService.deleteExistPortfolio(principalDetails.getMember(),portfolioId);
return ApplicationResponse.ok();
}

@Operation(description = "포트폴리오 파일 및 링크 업로드 업데이트 API")
@PatchMapping("/exist-portfolio/{portfolio_id}")
public ApplicationResponse<Void> 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-portfolio/{portfolio_id}")
public ApplicationResponse<ExistPortfolioRes> findExistPortfolio(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("portfolio_id") Long portfolioId){
return ApplicationResponse.ok(portfolioService.findExistPorfolio(principalDetails.getMember(),portfolioId));
}


}
Original file line number Diff line number Diff line change
@@ -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()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
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,
Boolean isExistedPortfolio
) {
public static SimplePortfolioRes of(Portfolio portfolio) {
public static SimplePortfolioRes of(Portfolio portfolio, Boolean isRegistered, Boolean isExistedPortfolio) {
return new SimplePortfolioRes(
portfolio.getId(),
portfolio.getPortfolioName(),
portfolio.getModifiedAt()
isRegistered ? portfolio.getId() : null,
isRegistered ? portfolio.getPortfolioName() : null,
isRegistered ? portfolio.getModifiedAt() : null,
isRegistered,
isExistedPortfolio
);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,6 +13,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
Expand All @@ -36,13 +38,32 @@ 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 portfolioName, String fileUri, String notionUri){
this.member = member;
this.portfolioName = portfolioName;
this.fileUri = fileUri;
this.notionUri = notionUri;
}
public void updatePortfolioUri(Portfolio portfolio, String fileUri, String notionUri) {
this.fileUri = (fileUri == null) ? this.fileUri : fileUri;
this.notionUri = (notionUri == null) ? this.notionUri : notionUri;
}


public void updateName(String updatedName) {
this.portfolioName = updatedName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
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<Portfolio, Long>, PortfolioRepositoryCustom{
Optional<Portfolio> findByIdAndDeletedAtIsNull(Long portfolioId);

long countByDeletedAtIsNull();
Optional<Portfolio> findPortfolioById(Long portfolioId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

public interface PortfolioRepositoryCustom {
List<Portfolio> findByMemberAndDeletedAtIsNull(Member member);
Boolean existsExistPortfolioByMember(Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ public List<Portfolio> 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;
}
}
Loading

0 comments on commit a9f3698

Please sign in to comment.