Skip to content

Commit

Permalink
Merge branch 'main' into feat/apply
Browse files Browse the repository at this point in the history
  • Loading branch information
sycuuui authored May 6, 2024
2 parents c308a86 + 6bd7eb1 commit 6b1de3b
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 111 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'org.springframework.boot:spring-boot-starter-mail'

// Lombok
compileOnly 'org.projectlombok:lombok'
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/gongjakso/server/ServerApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.web.config.PageableHandlerMethodArgumentResolverCustomizer;

@EnableJpaAuditing
@SpringBootApplication
Expand All @@ -13,4 +15,10 @@ public static void main(String[] args) {
System.out.println("Gongjakso Server is running");
}

@Bean
public PageableHandlerMethodArgumentResolverCustomizer customize() {
return p -> {
p.setOneIndexedParameters(true); // 1부터 시작
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,10 @@ public ApplicationResponse<List<MyPageRes>> getMyApplyList(@AuthenticationPrinci
public ApplicationResponse<ApplicationRes> getMyApplication(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("post_id") Long postId){
return ApplicationResponse.ok(applyService.getMyApplication(principalDetails.getMember(), postId));
}

@Operation(summary = "지원 취소 API", description = "해당 공고에 대한 지원을 취소한다.")
@PatchMapping("/cancel/{apply_id}")
public ApplicationResponse<PatchApplyRes> cancelApply(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("apply_id") Long applyId){
return ApplicationResponse.ok(applyService.cancelApply(principalDetails.getMember(), applyId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

@Builder
public record ApplicationRes(
Long applyId,
ApplyType applyType,
String member_name,
String memberName,
String major,
String phone,
String application,
String recruit_part,
String recruitPart,
List<String> category,
@JsonInclude(JsonInclude.Include.NON_NULL)
List<String> postStack,
Expand All @@ -24,7 +25,18 @@ public record ApplicationRes(
List<String> applyStack

) {
public static ApplicationRes of(Apply apply, List<String> category,List<String> stackName,List<String> applyStack){
return new ApplicationRes(apply.getApplyType(),apply.getMember().getName(), apply.getMember().getMajor(),apply.getMember().getPhone(),apply.getApplication(), apply.getRecruit_part(), category, stackName,applyStack);
public static ApplicationRes of(Apply apply, List<String> category, List<String> stackName, List<String> applyStack) {
return ApplicationRes.builder()
.applyId(apply.getApplyId())
.applyType(apply.getApplyType())
.memberName(apply.getMember().getName())
.major(apply.getMember().getMajor())
.phone(apply.getMember().getPhone())
.application(apply.getApplication())
.recruitPart(apply.getRecruit_part())
.category(category)
.postStack(stackName)
.applyStack(applyStack)
.build();
}
}
12 changes: 10 additions & 2 deletions src/main/java/com/gongjakso/server/domain/apply/dto/ApplyList.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.gongjakso.server.domain.apply.dto;

import com.gongjakso.server.domain.apply.entity.Apply;
import lombok.Builder;

@Builder
public record ApplyList(
Long apply_id,
String name,
String state
String state,
Boolean is_canceled
) {
public static ApplyList of(Apply apply,String state){
return new ApplyList(apply.getApplyId(),apply.getMember().getName(),state);
return ApplyList.builder()
.apply_id(apply.getApplyId())
.name(apply.getMember().getName())
.state(state)
.is_canceled(apply.getIsCanceled())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.gongjakso.server.domain.apply.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.gongjakso.server.domain.apply.entity.Apply;
import com.gongjakso.server.domain.apply.enumerate.ApplyType;
import com.gongjakso.server.domain.apply.enumerate.PostType;
import com.gongjakso.server.domain.member.entity.Member;
import lombok.Builder;

@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public record PatchApplyRes(
Long applyId,
Long memberId,
String memberName,
Long postId,
String application,
String recruitPart,
PostType type,
ApplyType applyType,
Boolean isCanceled
) {

public static PatchApplyRes of(Apply apply, Member member) {
return PatchApplyRes.builder()
.applyId(apply.getApplyId())
.memberId(apply.getMember().getMemberId())
.memberName(member.getName())
.postId(apply.getPost().getPostId())
.application(apply.getApplication())
.applyType(apply.getApplyType())
.recruitPart(apply.getRecruit_part())
.isCanceled(apply.getIsCanceled())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.gongjakso.server.domain.apply.dto;

import java.time.LocalDateTime;
import java.time.LocalDate;

public record PeriodReq(
LocalDateTime finishDate
LocalDate finishDate
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ public class Apply extends BaseTimeEntity {
@Enumerated(EnumType.STRING)
private ApplyType applyType;

@Column(name = "is_canceled", nullable = false)
private Boolean isCanceled;

public void updateIsCanceled(Boolean isCanceled) {
this.isCanceled = isCanceled;
}

@Builder
public Apply(Long applyId, Member member,Post post,String application,String recruit_part,PostType type, ApplyType applyType){
this.applyId=applyId;
public Apply(Member member,Post post,String application,String recruit_part,PostType type, ApplyType applyType){
this.member=member;
this.post=post;
this.application=application;
this.recruit_part=recruit_part;
this.type=type;
this.applyType=applyType;
this.isCanceled= Boolean.FALSE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;

public interface ApplyRepository extends JpaRepository<Apply,Long> {

long countApplyWithStackNameUsingFetchJoinByPost(Post post);

long countApplyWithStackNameUsingFetchJoinByPostAndApplyType(Post post,ApplyType applyType);

boolean existsApplyByMemberAndPost(Member member,Post post);

Page<Apply> findAllByPost(Post post, Pageable pageable);

Page<Apply> findApplyByApplyTypeAndMember(ApplyType applyType, Member member, Pageable pageable);

List<Apply> findAllByMemberAndDeletedAtIsNull(Member member);

Apply findApplyByMemberAndPost(Member member,Post post);

Optional<Apply> findApplyByApplyIdAndDeletedAtIsNull(Long applyId);
}
Loading

0 comments on commit 6b1de3b

Please sign in to comment.