-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from Gongjakso/feat/apply
Apply 코드 수정
- Loading branch information
Showing
15 changed files
with
296 additions
and
230 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
16 changes: 12 additions & 4 deletions
16
src/main/java/com/gongjakso/server/domain/apply/dto/ApplicationRes.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 |
---|---|---|
@@ -1,21 +1,29 @@ | ||
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.StackType; | ||
import jakarta.validation.constraints.Null; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
public record ApplicationRes( | ||
Boolean is_decision, | ||
ApplyType applyType, | ||
String major, | ||
String application, | ||
String recruit_part, | ||
List<String> category, | ||
String recruit_role, | ||
List<String> stackName | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
List<String> postStack, | ||
@Null | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
List<StackType> myStack | ||
|
||
) { | ||
public static ApplicationRes of(Apply apply, List<String> category,List<String> stackName){ | ||
return new ApplicationRes(apply.getIsDecision(),apply.getApplication(), apply.getRecruit_part(), category, apply.getRecruit_role(), stackName); | ||
return new ApplicationRes(apply.getApplyType(),apply.getMember().getMajor(),apply.getApplication(), apply.getRecruit_part(), category, stackName,apply.getStackTypeList()); | ||
} | ||
} |
61 changes: 45 additions & 16 deletions
61
src/main/java/com/gongjakso/server/domain/apply/dto/ApplyReq.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 |
---|---|---|
@@ -1,30 +1,59 @@ | ||
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.apply.enumerate.StackType; | ||
import com.gongjakso.server.domain.member.entity.Member; | ||
import com.gongjakso.server.domain.post.entity.Post; | ||
import com.gongjakso.server.domain.post.entity.StackName; | ||
import com.gongjakso.server.global.exception.ApplicationException; | ||
import com.gongjakso.server.global.exception.ErrorCode; | ||
import jakarta.validation.constraints.Null; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public record ApplyReq( | ||
String application, | ||
String recruit_part, | ||
String recruit_role, | ||
String type, | ||
Boolean isPass, | ||
Boolean is_open, | ||
Boolean isDecision | ||
String applyType, | ||
@Null | ||
List<String> stack | ||
) { | ||
public Apply toEntity(Member member, Post post_id){ | ||
return Apply.builder() | ||
.member(member) | ||
.post(post_id) | ||
.application(application) | ||
.recruit_part(recruit_part) | ||
.recruit_role(recruit_role) | ||
.type(PostType.valueOf(type)) | ||
.isPass(false) | ||
.is_open(false) | ||
.isDecision(false) | ||
.build(); | ||
public Apply toEntity(Member member, Post post){ | ||
if(type.equals("CONTEST")){ | ||
return Apply.builder() | ||
.member(member) | ||
.post(post) | ||
.application(application) | ||
.recruit_part(recruit_part) | ||
.type(PostType.valueOf(type)) | ||
.applyType(ApplyType.NONE) | ||
.build(); | ||
}else { | ||
List<StackType> stackTypeList = new ArrayList<>(); | ||
for (String stackName : stack) { | ||
try { | ||
StackType stackType = StackType.valueOf(stackName.toUpperCase()); | ||
stackTypeList.add(stackType); | ||
} catch (IllegalArgumentException e) { | ||
throw new ApplicationException(ErrorCode.INVALID_STACK_TYPE_EXCEPTION); | ||
} | ||
} | ||
|
||
return Apply.builder() | ||
.member(member) | ||
.post(post) | ||
.application(application) | ||
.recruit_part(recruit_part) | ||
.type(PostType.valueOf(type)) | ||
.applyType(ApplyType.NONE) | ||
.stackTypeList(stackTypeList) | ||
.build(); | ||
} | ||
} | ||
} |
13 changes: 7 additions & 6 deletions
13
src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package com.gongjakso.server.domain.apply.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.gongjakso.server.domain.post.entity.Post; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
public record ApplyRes( | ||
String title, | ||
LocalDateTime startDate, | ||
LocalDateTime endDate, | ||
Long max_person, | ||
Long total_person, | ||
int current_person, | ||
Long max_person, | ||
Boolean postType, | ||
List<String> category, | ||
List<String> stackName | ||
List<String> category | ||
) { | ||
public static ApplyRes of(Post post, int current_person, List<String> category, List<String> stackName){ | ||
return new ApplyRes(post.getTitle(),post.getStartDate(),post.getEndDate(),post.getMaxPerson(),current_person,post.isPostType(), category, stackName); | ||
public static ApplyRes of(Post post, int current_person, List<String> category){ | ||
return new ApplyRes(post.getTitle(),post.getStartDate(),post.getEndDate(),(post.getMaxPerson()+1),current_person,post.getMaxPerson(),post.isPostType(), category); | ||
} | ||
} |
11 changes: 9 additions & 2 deletions
11
src/main/java/com/gongjakso/server/domain/apply/dto/CategoryRes.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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package com.gongjakso.server.domain.apply.dto; | ||
|
||
import java.util.List; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import java.util.List; | ||
public record CategoryRes( | ||
List<String> category | ||
List<String> category, | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
List<String> stack | ||
) { | ||
public static CategoryRes of(List<String> category, | ||
List<String> stack){ | ||
return new CategoryRes(category,stack); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/main/java/com/gongjakso/server/domain/apply/enumerate/ApplyType.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,5 @@ | ||
package com.gongjakso.server.domain.apply.enumerate; | ||
|
||
public enum ApplyType { | ||
NONE,OPEN_APPLY,NOT_PASS,PASS | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/gongjakso/server/domain/apply/enumerate/StackType.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,6 @@ | ||
package com.gongjakso.server.domain.apply.enumerate; | ||
|
||
public enum StackType { | ||
REACT,TYPESCRIPT,JAVASCRIPT,NEXTJS,NODEJS,JAVA,SPRING, | ||
KOTLIN,SWIFT,FLUTTER,ETC | ||
} |
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
Oops, something went wrong.