Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sejoon00 authored Aug 26, 2024
2 parents ef62057 + 1cd97ca commit 76e91bb
Show file tree
Hide file tree
Showing 34 changed files with 439 additions and 92 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
port: ${{ secrets.SERVER_PORT }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_KEY }}
script: |
Expand All @@ -49,6 +50,6 @@ jobs:
./gradlew clean build
./gradlew openapi3
docker rm bbo-gak-server_back_1 --force
docker rmi bbo-gak-server_back
docker rm bbo-gak-server-back-1 --force
docker rmi bbo-gak-server-back
docker-compose -f docker-compose-dev.yml up --build -d
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bootJar {
}

openapi3 {
server = "http://114.70.23.79:8080"
server = "https://dev.bbogak.com"
title = "뽀각 API 문서"
description = "뽀각 API 문서입니다."
version = "0.0.1"
Expand Down
38 changes: 35 additions & 3 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
back:
build:
Expand Down Expand Up @@ -32,6 +30,35 @@ services:
- SENTRY_DSN=${SENTRY_DSN}
depends_on:
- mysql
networks:
- bbogak

nginx:
image: nginx:latest
container_name: nginx
volumes:
- /etc/nginx/:/etc/nginx/
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
ports:
- "80:80"
- "443:443"
depends_on:
- back
networks:
- bbogak
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"

certbot:
container_name: certbot
image: certbot/certbot
restart: unless-stopped
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
networks:
- bbogak

mysql:
image: mysql:8.0
Expand All @@ -45,6 +72,11 @@ services:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql

networks:
- bbogak
volumes:
mysql_data:

networks:
bbogak:
driver: bridge
3 changes: 3 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d
41 changes: 41 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
events {
worker_connections 1024;
}

https {
upstream was {
server backend:8080; #서비스명
}

server {
listen 80;
server_name dev.anifriends.site; # 발급한 도메인 주소
server_tokens off;

location /.well-known/acme-challenge/ {
root /var/www/certbot; # Certbot을 통해 Let's Encrypt 인증서를 발급받을 때 사용하는 경로
}

location / {
return 301 https://$host$request_uri; # 모든 HTTP 요청을 HTTPS로 리다이렉션
}
}

server {
listen 443 ssl;
server_name dev.anifriends.site;
server_tokens off;

ssl_certificate /etc/letsencrypt/live/dev.anifriends.site/fullchain.pem; # SSL/TLS 인증서 경로
ssl_certificate_key /etc/letsencrypt/live/dev.anifriends.site/privkey.pem; # SSL/TLS 개인 키 경로
include /etc/letsencrypt/options-ssl-nginx.conf; # Let's Encrypt에서 제공하는 Nginx SSL 옵션
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

location / {
proxy_pass http://was;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.server.bbo_gak.domain.card.dto.request.CardContentUpdateRequest;
import com.server.bbo_gak.domain.card.dto.request.CardCreateRequest;
import com.server.bbo_gak.domain.card.dto.request.CardTitleUpdateRequest;
import com.server.bbo_gak.domain.card.dto.request.CardTypeUpdateRequest;
import com.server.bbo_gak.domain.card.dto.response.CardCreateResponse;
import com.server.bbo_gak.domain.card.dto.response.CardGetResponse;
import com.server.bbo_gak.domain.card.dto.response.CardListGetResponse;
Expand Down Expand Up @@ -46,9 +47,11 @@ public ResponseEntity<CardGetResponse> getCardDetail(
@GetMapping("/cards")
public ResponseEntity<List<CardListGetResponse>> getCardList(
@AuthUser User user,
@RequestParam("type") String type) {
@RequestParam("type") String type,
@RequestParam(value = "tag-ids", required = false) List<Long> tagIdList
) {

return ResponseEntity.ok(cardService.getCardList(user, type));
return ResponseEntity.ok(cardService.getCardList(user, type, tagIdList));
}

@PostMapping("/card")
Expand All @@ -59,6 +62,16 @@ public ResponseEntity<CardCreateResponse> createCard(
return ResponseEntity.ok(cardService.createCard(user, cardCreateRequest));
}

@PutMapping("/cards/{card-id}/card-type")
public ResponseEntity<Void> updateCardType(
@AuthUser User user,
@PathVariable("card-id") Long cardId,
@RequestBody CardTypeUpdateRequest request
) {
cardService.updateCardType(user, cardId, request);
return ResponseEntity.ok().body(null);
}

@PutMapping("/cards/{card-id}/title")
public ResponseEntity<Void> updateCardTitle(
@AuthUser User user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ public ResponseEntity<CardTypeCountInRecruitGetResponse> getCardTypeCounts(@Auth
}

@GetMapping("/recruits/{recruit-id}/cards")
public ResponseEntity<List<CardListGetResponse>> getCardDetail(
public ResponseEntity<List<CardListGetResponse>> getCardList(
@AuthUser User user,
@PathVariable("recruit-id") Long recruitId,
@RequestParam("type") String type) {
@RequestParam("type") String type,
@RequestParam(value = "tag-ids", required = false) List<Long> tagIdList) {

return ResponseEntity.ok(cardInRecruitService.getCardListInRecruit(user, recruitId, type));
return ResponseEntity.ok(cardInRecruitService.getCardListInRecruit(user, recruitId, type, tagIdList));
}

@PostMapping("/recruits/{recruit-id}/cards/{card-id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public class TagController {
private final TagService tagService;

@GetMapping("/tags")
public ResponseEntity<List<TagGetResponse>> getAllTagList() {
return ResponseEntity.ok(tagService.getAllTagList());
public ResponseEntity<List<TagGetResponse>> getAllTagList(
@AuthUser User user
) {
return ResponseEntity.ok(tagService.getAllTagList(user));
}

@GetMapping("/cards/{card-id}/tags")
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/com/server/bbo_gak/domain/card/dao/CardDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public List<Card> findAllByUserIdAndCardTypeValueList(User user, CardTypeValue[]
QCard qCard = QCard.card;
QCardType qCardType = QCardType.cardType;

createRecruitBooleanBuilder(qCard, isRecruit);

return query.selectFrom(qCard)
.leftJoin(qCard.cardTypeList, qCardType).fetchJoin()
.where(qCard.user.id.eq(user.getId())
Expand All @@ -41,13 +39,12 @@ public List<Card> findAllByUserIdAndCardTypeValue(User user, CardTypeValue cardT
QCard qCard = QCard.card;
QCardType qCardType = QCardType.cardType;

createRecruitBooleanBuilder(qCard, recruitId);

return query.selectFrom(qCard)
.leftJoin(qCard.cardTypeList, qCardType).fetchJoin()
.where(qCard.user.id.eq(user.getId())
.and(qCardType.cardTypeValue.eq(cardTypeValue))
.and(createRecruitBooleanBuilder(qCard, recruitId)))
.and(createRecruitBooleanBuilder(qCard, recruitId))
)
.distinct()
.fetch();
}
Expand All @@ -72,6 +69,5 @@ private BooleanBuilder createRecruitBooleanBuilder(QCard qCard, Long recruitId)
}

return builder.and(qCard.recruit.id.eq(recruitId)).and(qCard.copyFlag.isTrue());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public interface CardRepository extends JpaRepository<Card, Long> {
Optional<Card> findByIdAndUser(Long id, User user);

List<Card> findAllByUser(User user);

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.server.bbo_gak.domain.card.dao;

import com.server.bbo_gak.domain.card.entity.Tag;
import com.server.bbo_gak.domain.user.entity.Job;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;

public interface TagRepository extends JpaRepository<Tag, Long> {

List<Tag> findAllByJob(Job job);

List<Tag> findAllByIdIsNotIn(List<Long> idList);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public record CardCreateRequest(
List<String> cardTypeValueList,

@Size(max = 3)
List<Long> tagIdList
List<Long> tagIdList,

String cardTypeValueGroup
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.server.bbo_gak.domain.card.dto.request;

import java.util.List;

public record CardTypeUpdateRequest(
List<String> cardTypeValueList,

String cardTypeValueGroup
) {

}
10 changes: 10 additions & 0 deletions src/main/java/com/server/bbo_gak/domain/card/entity/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,15 @@ public void updateContent(String content) {
this.content = content;
}

public void updateCardTypeList(List<CardType> cardTypeList) {
this.cardTypeList = cardTypeList;
}

public boolean isTagListContain(List<Tag> tagList) {
return cardTagList.stream()
.map(CardTag::getTag)
.anyMatch(tagList::contains);
}


}
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
package com.server.bbo_gak.domain.card.entity;

import com.server.bbo_gak.global.error.exception.ErrorCode;
import com.server.bbo_gak.global.error.exception.NotFoundException;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum CardTypeValueGroup {

MY_INFO(new CardTypeValue[]{CardTypeValue.EXPERIENCE, CardTypeValue.INTERVIEW_QUESTION,
MY_INFO("내_정보", new CardTypeValue[]{CardTypeValue.EXPERIENCE, CardTypeValue.INTERVIEW_QUESTION,
CardTypeValue.PERSONAL_STATEMENT}),

RECRUIT(new CardTypeValue[]{CardTypeValue.ASSIGNMENT_PREPARING, CardTypeValue.DOCUMENT_PREPARING,
RECRUIT("공고", new CardTypeValue[]{CardTypeValue.ASSIGNMENT_PREPARING, CardTypeValue.DOCUMENT_PREPARING,
CardTypeValue.INTERVIEW_PREPARING});


private String value;
private CardTypeValue[] cardTypeValueList;

public static CardTypeValueGroup findByValue(String value) {
return Arrays.stream(CardTypeValueGroup.values())
.filter(cardType -> cardType.getValue().equals(value))
.findFirst()
.orElseThrow((() -> new NotFoundException(ErrorCode.CARD_TYPE_VALUE_GROUP_NOT_FOUND)));
}

public boolean contains(CardTypeValue cardTypeValue) {
return Arrays.asList(cardTypeValueList).contains(cardTypeValue);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/server/bbo_gak/domain/card/entity/Tag.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.server.bbo_gak.domain.card.entity;

import com.server.bbo_gak.domain.user.entity.Job;
import com.server.bbo_gak.global.common.BaseEntity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
Expand Down Expand Up @@ -29,5 +31,8 @@ public class Tag extends BaseEntity {
@Enumerated(EnumType.STRING)
private TagType tagType;

@Enumerated(EnumType.STRING)
private Job job;

private String name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.server.bbo_gak.domain.card.dao.CardRepository;
import com.server.bbo_gak.domain.card.dao.CardTagRepository;
import com.server.bbo_gak.domain.card.dao.CardTypeRepository;
import com.server.bbo_gak.domain.card.dao.TagRepository;
import com.server.bbo_gak.domain.card.dto.response.CardCreateResponse;
import com.server.bbo_gak.domain.card.dto.response.CardListGetResponse;
import com.server.bbo_gak.domain.card.dto.response.CardTypeCountInRecruitGetResponse;
Expand All @@ -18,13 +19,16 @@
import com.server.bbo_gak.domain.card.entity.CardType;
import com.server.bbo_gak.domain.card.entity.CardTypeValue;
import com.server.bbo_gak.domain.card.entity.CardTypeValueGroup;
import com.server.bbo_gak.domain.card.entity.Tag;
import com.server.bbo_gak.domain.recruit.dao.RecruitRepository;
import com.server.bbo_gak.domain.recruit.entity.Recruit;
import com.server.bbo_gak.domain.user.entity.User;
import com.server.bbo_gak.global.error.exception.ErrorCode;
import com.server.bbo_gak.global.error.exception.NotFoundException;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
Expand All @@ -44,6 +48,7 @@ public class CardInRecruitService {
private final CardTagRepository cardTagRepository;
private final CardImageRepository cardImageRepository;
private final CardCopyInfoRepository cardCopyInfoRepository;
private final TagRepository tagRepository;


@Transactional(readOnly = true)
Expand All @@ -57,12 +62,16 @@ public CardTypeCountInRecruitGetResponse getCardTypeCountsInRecruit(User user) {
}

@Transactional(readOnly = true)
public List<CardListGetResponse> getCardListInRecruit(User user, Long recruitId, String cardTypeValue) {
public List<CardListGetResponse> getCardListInRecruit(User user, Long recruitId, String cardTypeValue
, List<Long> tagIdList) {

List<Tag> tagList = tagRepository.findAllById(Optional.ofNullable(tagIdList).orElse(Collections.emptyList()));

List<Card> cards = cardDao.findAllByUserIdAndCardTypeValue(user, CardTypeValue.findByValue(cardTypeValue),
recruitId);

return cards.stream()
.filter(card -> tagList.isEmpty() || card.isTagListContain(tagList))
.sorted(Comparator.comparing(Card::getUpdatedDate).reversed())
.map(card -> CardListGetResponse.of(card, card.getCardTagList()))
.collect(Collectors.toList());
Expand Down
Loading

0 comments on commit 76e91bb

Please sign in to comment.