Skip to content

Commit

Permalink
Merge pull request #73 from soolung/feat/#63-add
Browse files Browse the repository at this point in the history
ADD :: 사람 추가 api (#63)
  • Loading branch information
Yunyeong-Ko authored Apr 2, 2023
2 parents bf353d0 + 796ac54 commit a5220c4
Show file tree
Hide file tree
Showing 50 changed files with 521 additions and 164 deletions.
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ GOOGLE_BASE_URL=string
GOOGLE_CLIENT=string
GOOGLE_REDIRECT=string
GOOGLE_SECRET=string

JWT_SECRET=string

DB_PORT=number
DB_NAME=string
DB_USERNAME=string
DB_PASSWORD=string
DB_ROOT_PASSWORD=string
DB_HOST=string

REDIS_HOST=string
REDIS_PORT=number
REDIS_PASSWORD=string

BUCKET_NAME=string
S3_REGION=string
S3_ACCESS_KEY=string
S3_SECRET_KEY=string
S3_SECRET_KEY=string
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.* @soolung/backend
8 changes: 8 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ jobs:
echo DB_USERNAME=${{ secrets.DB_USERNAME }} >> .env
echo DB_PASSWORD=${{ secrets.DB_PASSWORD }} >> .env
echo DB_ROOT_PASSWORD=${{ secrets.DB_ROOT_PASSWORD }} >> .env
echo DB_HOST=${{ secrets.DB_HOST }} >> .env
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env
echo DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} >> .env
echo DOCKER_REPO=${{ secrets.DOCKER_REPO }} >> .env
echo GOOGLE_BASE_URL=${{ secrets.GOOGLE_BASE_URL }} >> .env
echo GOOGLE_CLIENT=${{ secrets.GOOGLE_CLIENT }} >> .env
echo GOOGLE_REDIRECT=${{ secrets.GOOGLE_REDIRECT }} >> .env
Expand All @@ -77,6 +81,10 @@ jobs:
echo S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }} >> .env
echo S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }} >> .env
echo REDIS_HOST=${{ secrets.REDIS_HOST }} >> .env
echo REDIS_PORT=${{ secrets.REDIS_PORT }} >> .env
echo REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }} >> .env
docker-compose up -d
docker image prune -f
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/dev.cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ jobs:
echo DB_USERNAME=${{ secrets.DB_USERNAME }} >> .env
echo DB_PASSWORD=${{ secrets.DB_PASSWORD }} >> .env
echo DB_ROOT_PASSWORD=${{ secrets.DB_ROOT_PASSWORD }} >> .env
echo DB_HOST=${{ secrets.DEV_DB_HOST }} >> .env
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env
echo DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} >> .env
echo DOCKER_REPO=${{ secrets.DEV_DOCKER_REPO }} >> .env
echo GOOGLE_BASE_URL=${{ secrets.GOOGLE_BASE_URL }} >> .env
echo GOOGLE_CLIENT=${{ secrets.GOOGLE_CLIENT }} >> .env
echo GOOGLE_REDIRECT=${{ secrets.GOOGLE_REDIRECT_DEV }} >> .env
Expand All @@ -77,6 +81,10 @@ jobs:
echo S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }} >> .env
echo S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }} >> .env
echo REDIS_HOST=${{ secrets.DEV_REDIS_HOST }} >> .env
echo REDIS_PORT=${{ secrets.REDIS_PORT }} >> .env
echo REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }} >> .env
docker-compose -f docker-compose.dev.yml up -d
docker image prune -f
Expand Down
8 changes: 5 additions & 3 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ services:
- "--collation-server=utf8mb4_unicode_ci"

redis:
image: redis:latest
image: redis:7.0-alpine
container_name: soolung_simblue_redis
hostname: soolung
command: redis-server --port 6379
command: /bin/sh -c "redis-server --requirepass $$REDIS_PASSWORD"
env_file:
- .env
ports:
- "6379:6379"
- ${REDIS_PORT}:6379

application:
image: ${DOCKER_USERNAME}/${DOCKER_REPO}
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ services:
image: redis:latest
container_name: soolung_simblue_redis
hostname: soolung
command: redis-server --port 6379
command: /bin/sh -c "redis-server --requirepass soolung"
env_file:
- .env
ports:
- "6379:6379"
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ services:
- "--collation-server=utf8mb4_unicode_ci"

simblue-redis:
image: redis:latest
image: redis:7.0-alpine
container_name: soolung_simblue_redis
hostname: soolung
command: redis-server --port 6379
command: /bin/sh -c "redis-server --requirepass $$REDIS_PASSWORD"
env_file:
- .env
ports:
- "6379:6379"
- ${REDIS_PORT}:6379

simblue-application:
image: ${DOCKER_USERNAME}/${DOCKER_REPO}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Application extends BaseTimeEntity {
@Column(nullable = false, length = 20)
private String title;

@Column(nullable = true, length = 200)
@Column(nullable = true, length = 500)
private String description;

@Column(nullable = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.soogung.simblue.domain.application.domain;

import com.soogung.simblue.domain.application.domain.type.QuestionType;
import com.soogung.simblue.domain.user.facade.UserFacade;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -39,4 +41,12 @@ public void putReplyBlock(ReplyBlock replyBlock) {
this.replyBlock = replyBlock;
replyBlock.getReplies().add(this);
}

public String getAnswer(UserFacade userFacade) {
if (question.getType() == QuestionType.PEOPLE) {
return userFacade.getName(Long.valueOf(answer));
}

return answer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

public interface ApplicationRepository extends JpaRepository<Application, Long>, ApplicationRepositoryCustom {

@Query("SELECT a FROM Application a WHERE a.state = 'ALWAYS' OR a.state = 'OPENED'")
@Query("SELECT a FROM Application a WHERE a.state = 'ALWAYS' OR a.state = 'OPENED' ORDER BY a.id DESC")
List<Application> findAllByOrderByIdDesc(Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum QuestionType {
LINK(false),
RADIO(true),
CHECKBOX(true),
PEOPLE(false),
;

private final boolean hasAnswer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ApplicationStatusResponse getMyApplication() {
}

@GetMapping("/{id}/result")
public ResultBlockResponse getApplicationResult(@PathVariable Long id) {
public ApplicationResultResponse getApplicationResult(@PathVariable Long id) {
return queryApplicationResultService.execute(id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class ApplicationRequest {
private String title;

@Nullable
@Size(max = 500)
private String description;

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.time.LocalDate;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.Objects;
import java.util.stream.Collectors;

@Getter
Expand Down Expand Up @@ -44,9 +44,7 @@ public static ApplicationDetailResponse of(Application application, List<NoticeR
.build();
}

public static ApplicationDetailResponse of(Application application, List<NoticeResponse> noticeList, List<ReplyDetailResponse> replyDetailList) {
AtomicInteger index = new AtomicInteger();

public static ApplicationDetailResponse of(Application application, List<NoticeResponse> noticeList, List<ReplyListResponse> replyList) {
return ApplicationDetailResponse.builder()
.id(application.getId())
.title(application.getTitle())
Expand All @@ -58,7 +56,11 @@ public static ApplicationDetailResponse of(Application application, List<NoticeR
.state(application.getState())
.questionList(
application.getQuestionList().stream()
.map((q) -> QuestionResponse.of(q, replyDetailList.get(index.getAndIncrement())))
.map((q) -> QuestionResponse.of(q,
replyList.stream().filter(r -> r.getQuestionId() == q.getId())
.findFirst()
.orElse(null)
))
.collect(Collectors.toList()))
.noticeList(noticeList)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

@Getter
@AllArgsConstructor
public class ResultBlockResponse {
public class ApplicationResultResponse {
private ApplicationResponse application;
private List<NoticeResponse> noticeList;
private List<String> questionList;
private List<ResultResponse> resultList;
private List<SimpleQuestionResponse> questionList;
private List<ReplyBlockResponse> resultList;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.soogung.simblue.domain.application.presentation.dto.response;

import com.soogung.simblue.domain.application.domain.Question;
import com.soogung.simblue.domain.application.domain.Reply;
import com.soogung.simblue.domain.application.domain.type.QuestionType;
import lombok.Builder;
import lombok.Getter;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Getter
Expand All @@ -19,7 +19,7 @@ public class QuestionResponse {
private Boolean isRequired;
private QuestionType type;
private List<AnswerResponse> answerList;
private List<String> replyDetailList;
private List<String> replyList;

public static QuestionResponse of(Question question) {
return QuestionResponse.builder()
Expand All @@ -36,7 +36,7 @@ public static QuestionResponse of(Question question) {
.build();
}

public static QuestionResponse of(Question question, ReplyDetailResponse replyDetail) {
public static QuestionResponse of(Question question, ReplyListResponse replyList) {
return QuestionResponse.builder()
.id(question.getId())
.question(question.getQuestion())
Expand All @@ -48,7 +48,7 @@ public static QuestionResponse of(Question question, ReplyDetailResponse replyDe
question.getAnswerList().stream()
.map(AnswerResponse::of)
.collect(Collectors.toList()) : null)
.replyDetailList(replyDetail.getReplyDetailList())
.replyList(Objects.nonNull(replyList) ? replyList.getReplyList() : null)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

@Getter
@AllArgsConstructor
public class ResultResponse {
public class ReplyBlockResponse {
private String name;
private String studentNumber;
private List<String> replyList;
private List<ReplyResponse> replyList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

@Getter
@AllArgsConstructor
public class ReplyDetailResponse {
private List<String> replyDetailList;
public class ReplyListResponse {

private Long questionId;
private List<String> replyList;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.soogung.simblue.domain.application.presentation.dto.response;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class ReplyResponse {

private Long questionId;
private String reply;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.soogung.simblue.domain.application.presentation.dto.response;

import com.soogung.simblue.domain.application.domain.Question;
import com.soogung.simblue.domain.application.domain.type.QuestionType;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class SimpleQuestionResponse {

private Long id;
private String question;
private QuestionType type;

public static SimpleQuestionResponse of(Question question) {
return SimpleQuestionResponse.builder()
.id(question.getId())
.question(question.getQuestion())
.type(question.getType())
.build();
}
}
Loading

0 comments on commit a5220c4

Please sign in to comment.