Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEAM-11][BE][민지노&&필] 3주차 PR 입니다 #283

Open
wants to merge 40 commits into
base: team11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4fa868d
feat: Entity 설계
Minzino May 28, 2022
eb8b8ae
chore: 초기 데이터 입력
PhilSoGooood May 31, 2022
dfd4694
Merge pull request #37 from wnsxor1993/feature-entity
Minzino May 31, 2022
5857eff
Feat: Room 상세 조회기능 구현
Minzino Jun 2, 2022
af97364
Chore: GitHub Actions 세팅
Minzino Jun 2, 2022
5bf5331
chore: 패키지 분리
Minzino Jun 2, 2022
2258819
refactor: 상세조회시 DTO를 반환하도록 변경
Minzino Jun 2, 2022
6c166ab
refactor: WishList FetchType LAZY 적용 및 컬럼이름 삭제
Minzino Jun 2, 2022
c3eeafc
Merge pull request #43 from wnsxor1993/feature-search
Minzino Jun 2, 2022
a96c81a
chore: github actions 설정
PhilSoGooood Jun 4, 2022
19c051f
fix: 배포용 스크립트 파일 수정
Minzino Jun 4, 2022
38845b7
fix: GitHUb Actions 트리커 브랜치 수정
Minzino Jun 4, 2022
2e70228
fix: application.yml 파일 수정
Minzino Jun 4, 2022
059b7b7
feat: MainEvent(히어로 이미지 영역) 엔티티 생성
Minzino Jun 6, 2022
27cd4a6
feat: ArroungSpotDto 생성
Minzino Jun 6, 2022
a51fe14
feat: 홈화면 테마 여행지(ThemeSpot) 담당 엔티티와 DTO 생성
Minzino Jun 6, 2022
115554c
fix: 변수 RoomType을 Enum 타입으로 변경
Minzino Jun 6, 2022
e5e2e5d
fix: 불필요한 변수 삭제
Minzino Jun 7, 2022
7cdcd50
feat: 행정구역 인기여행지를 받아오기 위한 클래스 생성
Minzino Jun 7, 2022
f7020ff
feat: 메인 홈 화면 Controller, Service, Dto 생성
Minzino Jun 7, 2022
ab00bfb
fix: Location 생성자를 롬복으로 적용
Minzino Jun 7, 2022
a308437
feat: ThemeRepository, MainEventRepository 생성
Minzino Jun 7, 2022
50ee00f
fix: RoomController의 RequestMapping 수정
Minzino Jun 7, 2022
2debc26
Merge pull request #55 from wnsxor1993/feature-district
Minzino Jun 7, 2022
efd722f
fix: 행정구역의 구분을 주기위해 Dto에 id를 추가
Minzino Jun 7, 2022
f2529fd
feat: Open API를 사용해서 현재위치를 기준으로 여행지와의 거리를 반환
Minzino Jun 8, 2022
52533b6
Merge pull request #64 from wnsxor1993/feature-openapi
PhilSoGooood Jun 8, 2022
55d8840
fix: 라이브러리를 통한 시간 및 거리 단위 변환
PhilSoGooood Jun 8, 2022
9a1480a
Merge pull request #67 from wnsxor1993/feature-openapi
Minzino Jun 9, 2022
4c43731
Update README.md
PhilSoGooood Jun 9, 2022
ca38301
refactor: 불필요한 클래스 제거
PhilSoGooood Jun 9, 2022
ecf0e0f
refactor: 불필요한 ENUM클래스와 DTO클래스 삭제
Minzino Jun 9, 2022
4921ea2
refactor: 홈화면에서 현재 위치와 여행지와의 거리 및 이동시간을 반환하도록 수정
PhilSoGooood Jun 9, 2022
fdd438a
feat: 방 조회 기능 구현
Minzino Jun 9, 2022
ce23eeb
test: 배포 테스트
PhilSoGooood Jun 9, 2022
72d7c45
test: 배포 테스트
PhilSoGooood Jun 9, 2022
625a35e
test: 배포 테스트
PhilSoGooood Jun 9, 2022
58f5c58
refactor: 코드 리뷰 반영(반복문 -> stream)
PhilSoGooood Jun 10, 2022
39e2d95
refactor: 코드 리뷰 반영(actuator 사용)
PhilSoGooood Jun 10, 2022
71c9750
chore: 환경 설정 변경
PhilSoGooood Jun 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Java CI with Gradle

on:
push:
branches: [ BE-deploy ]
pull_request:
branches: [ BE-deploy ]

jobs:
build:

runs-on: ubuntu-latest

defaults:
run:
working-directory: ./BE

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'

- name: Insert data source information into application.yml
run: |
sed -i "s|datasource_url|$DATASOURCE_URL|g" ./src/main/resources/application.yml
sed -i "s|datasource_username|$DATASOURCE_USERNAME|g" ./src/main/resources/application.yml
sed -i "s|datasource_password|$DATASOURCE_PASSWORD|g" ./src/main/resources/application.yml
env:
DATASOURCE_URL: ${{ secrets.DATASOURCE_URL }}
DATASOURCE_USERNAME: ${{ secrets.DATASOURCE_USERNAME }}
DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }}

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew bootJar

# 도커 빌드(도커 이미지 생성)
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t philsogood/airbnb:1.0 .
docker push ${{ secrets.DOCKER_USERNAME }}/airbnb:1.0
docker rmi ${{ secrets.DOCKER_USERNAME }}/airbnb:1.0

# 디렉토리 생성
- name: Make Directory
run: mkdir -p deploy

# appspec.yml 파일 복사
- name: Copy appspec.yml
run: cp appspec.yml ./deploy

# script files 복사
- name: Copy script
run: cp ./scripts/*.sh ./deploy

# 파일 압축
- name: Make zip file
run: zip -r ./airbnb.zip ./deploy

# S3와 CodeDeploy를 통한 배포
- name: Deploy
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2


- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 --acl private ./airbnb.zip s3://airbnb-phil-deploy-dockerimage/

- name: Start CodeDeploy
run: aws deploy create-deployment --application-name Airbnb-Codedeploy-Application --deployment-group-name Airbnb-Codedeploy-Target-Group --s3-location bucket=airbnb-phil-deploy-dockerimage,key=airbnb.zip,bundleType=zip

# 배경 성공시 슬랙 알람
- name: action-slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: Github Action Test # default: 8398a7@action-slack
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always() # Pick up events even if the job fails or is canceled.
18 changes: 18 additions & 0 deletions BE/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# JDK11 이미지 사용
FROM openjdk:11-jdk

#마운트에 /tmp를 사용하는 이유
#문서는 아래와 같이 작성되어 있습니다.
#spring boot의 Tomcat의 default 저장소가 /tmp인데
#위와 같이 볼륨 마운트를 해주면 호스트의 /var/lib/docker에 임시파일을 만들고
#컨테이너 안의 /tmp 와 연결할 수 있다는 뜻입니다.
VOLUME /tmp

# JAR_FILE 변수에 값을 저장
ARG JAR_FILE=./build/libs/*.jar

# 변수에 저장된 것을 컨데이너 실행시 이름을 app.jar파일로 변경하여 컨테이너에 저장
COPY ${JAR_FILE} app.jar

# 빌드된 이미지가 run 될 때 실행할 명령어
ENTRYPOINT ["java","-jar","/app.jar"]
18 changes: 18 additions & 0 deletions BE/appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/app/
overwrite: yes

permissions:
- object: /
pattern: "**"
owner: ubuntu
group: ubuntu

hooks:
ApplicationStart:
- location: deploy.sh
timeout: 60
runas: ubuntu
15 changes: 11 additions & 4 deletions BE/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ plugins {
id 'java'
}

group = 'com.team11'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand All @@ -25,8 +21,19 @@ dependencies {
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation fileTree(dir: 'libs', include: '*.jar')
}

tasks.named('test') {
useJUnitPlatform()
}

jar {
enabled = false
}

bootJar {
archivesBaseName = 'app'
archiveFileName = 'app.jar'
archiveVersion = "0.0.0"
}
14 changes: 14 additions & 0 deletions BE/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 가동중인 jpa-shop 도커 중단 및 삭제
sudo docker ps -a -q --filter "name=airbnb" | grep -q . && docker stop airbnb && docker rm airbnb | true

# 기존 이미지 삭제
sudo docker rmi philsogood/airbnb:1.0

# 도커허브 이미지 pull
sudo docker pull philsogood/airbnb:1.0

# 도커 run
sudo docker run -d -p 80:8080 --name airbnb philsogood/airbnb:1.0

# 사용하지 않는 불필요한 이미지 삭제 -> 현재 컨테이너가 물고 있는 이미지는 삭제되지 않습니다.
sudo docker rmi -f $(docker images -f "dangling=true" -q) || true
23 changes: 23 additions & 0 deletions BE/sql/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

insert into room (city, country, state, street, zipcode, average_grade, description, name, price, check_in_time,
check_out_time, number_of_bathroom, number_of_bed, number_of_bedroom, room_type, host_id)
VALUES ('종로구', '한국', '서울시', '짱짱로', 1234, 3, '짱짱이에요', '[독채한옥] 도심속 고요한 휴식의 공간, 서울의하루 가회동', 196714, 14, 10, 2, 2, 2,
'RESIDENCE', 1),
('광주시', '한국', '경기도', '선을로', 1234, 4, '칭찬해요', '오포숲-숲뷰 맛집/넷플릭스/무료주차공간/매일 소독/서현10분', 100714, 15, 11, 2, 2, 2, 'SHARE_HOUSE', 1);

insert into room_image (image_path, room_id)
values ('https://a0.muscache.com/im/pictures/miso/Hostinvg-22724133/original/8514626f-60c8-4118-b207-b25285305915.jpeg?im_w=960',
1),
('https://a0.muscache.com/im/pictures/miso/Hosting-22724133/original/a98f70e9-a56e-41cd-9363-2656dfccb353.jpeg?im_w=720',
1),
('https://a0.muscache.com/im/pictures/miso/Hosting-22724133/original/551e045b-8e9f-4c78-aa18-b32d6388ab59.jpeg?im_w=720',
1),
('https://a0.muscache.com/im/pictures/5a6d01a9-3ba3-457c-a504-de665e65057d.jpg?im_w=960', 2),
('https://a0.muscache.com/im/pictures/ca4d3ad4-5bec-4643-83f5-785a7e8afc1e.jpg?im_w=720', 2),
('https://a0.muscache.com/im/pictures/d29bb793-e264-422a-9a2b-96f5377f4153.jpg?im_w=720', 2);

insert into host (name)
values ('meenzino'),
('phil');


27 changes: 27 additions & 0 deletions BE/src/main/java/com/team11/airbnb/domain/District.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.team11.airbnb.domain;

import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@AllArgsConstructor
@NoArgsConstructor
public class District {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한 줄에 하나의 애노테이션만 씁시다!!

private Long id;

private String name;
private String imagePath;

@Embedded
private Location location;

}
21 changes: 21 additions & 0 deletions BE/src/main/java/com/team11/airbnb/domain/Host.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.team11.airbnb.domain;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor
public class Host {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private boolean isSuperHost;
private String profileImagePath;

}
17 changes: 17 additions & 0 deletions BE/src/main/java/com/team11/airbnb/domain/Location.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.team11.airbnb.domain;

import javax.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Embeddable
@AllArgsConstructor
@NoArgsConstructor
@Getter
public class Location {

private String latitude;
private String longitude;

}
26 changes: 26 additions & 0 deletions BE/src/main/java/com/team11/airbnb/domain/MainEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.team11.airbnb.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@NoArgsConstructor
@AllArgsConstructor
@Getter
public class MainEvent {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String title;
private String label;
private String imagePath;
private String buttonText;

}
35 changes: 35 additions & 0 deletions BE/src/main/java/com/team11/airbnb/domain/Reservation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.team11.airbnb.domain;

import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@NoArgsConstructor
@Getter
public class Reservation {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "room_id")
private Room room;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@Embedded
private ReservationSchedule reservationSchedule;

private int fixedPrice;

}
19 changes: 19 additions & 0 deletions BE/src/main/java/com/team11/airbnb/domain/ReservationSchedule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.team11.airbnb.domain;

import java.time.LocalDateTime;
import javax.persistence.Embeddable;

@Embeddable
public class ReservationSchedule {

private LocalDateTime checkInDate;
private LocalDateTime checkOutDate;

protected ReservationSchedule() {
}

public ReservationSchedule(LocalDateTime checkInDate, LocalDateTime checkOutDate) {
this.checkInDate = checkInDate;
this.checkOutDate = checkOutDate;
}
}
33 changes: 33 additions & 0 deletions BE/src/main/java/com/team11/airbnb/domain/Review.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.team11.airbnb.domain;

import com.fasterxml.jackson.annotation.JsonBackReference;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor
public class Review {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "room_id")
private Room room;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

private int grade;
private String content;

}
Loading