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

해커톤 코드 마이그레이션 #79

Merged
merged 25 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b18a086
chore: 스프링독 설정 파일 작성
jminkkk Jul 15, 2024
7128c41
docs: 템플릿 생성 API 작성
jminkkk Jul 15, 2024
2e4479a
docs: 템플릿 목록 조회 API 작성
jminkkk Jul 15, 2024
f70d45e
docs: 템플릿 단건 조회 API 작성
jminkkk Jul 15, 2024
bcd3a14
Merge pull request #22 from jminkkk/docs/swagger_api
HoeSeong123 Jul 15, 2024
bf66ded
feat(workflows): actions ci 파이프라인 구성
zeus6768 Jul 15, 2024
412b94b
docs: pull-request 템플릿 작성
kyum-q Jul 15, 2024
f874538
docs: pull-request 템플릿 이름 변경
kyum-q Jul 15, 2024
ce30328
Merge pull request #32 from zeus6768/feat/ci
zeus6768 Jul 15, 2024
1e032d9
Merge pull request #34 from kyum-q/docs/pull-request
kyum-q Jul 15, 2024
cdf95aa
feat(workflows): cd 파이프라인 구성
kyum-q Jul 15, 2024
5cb9df1
test(workflows): cd 파이프라인 구성
kyum-q Jul 15, 2024
2d92966
feat(workflows): cd 파이프라인 구성
kyum-q Jul 15, 2024
93f1d13
Merge pull request #42 from kyum-q/feat/cd
kyum-q Jul 15, 2024
82df56f
fix(workflows): cd 파이프라인 구성 해커톤 브랜치 추가
kyum-q Jul 15, 2024
f4eefb6
Merge pull request #43 from kyum-q/feat/cd
kyum-q Jul 15, 2024
388e7ba
fix(workflows): cd 파이프라인 구성 if 제거
kyum-q Jul 15, 2024
c8ab892
Merge pull request #44 from kyum-q/feat/cd
kyum-q Jul 15, 2024
563943d
fix(workflows): cd 파이프라인 구성 build-jar 위치 수정
kyum-q Jul 15, 2024
a7915b1
test(codezap): 테스트를 위한 컨트롤러 추가
kyum-q Jul 15, 2024
9ab4d2b
Merge pull request #45 from kyum-q/feat/cd
kyum-q Jul 15, 2024
3b226e3
fix(workflows): cd 파이프라인 구성 build-jar 위치 수정
kyum-q Jul 15, 2024
8632942
Merge pull request #46 from kyum-q/feat/cd
kyum-q Jul 15, 2024
5164195
Template 목록 조회, 상세 조회, 작성 기능 (#76)
HoeSeong123 Jul 17, 2024
941ecfa
Template 목록 조회, 상세 조회, 생성 기능 (#78)
Hain-tain Jul 17, 2024
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
10 changes: 10 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## ⚡️ 관련 이슈
close #이슈번호

## 📍주요 변경 사항
### 1. 주요 변경 사항은 이러이러합니다.
### - 이렇게도 쓸 수 있어요

## 🎸기타
### 1. 이런걸 더 고려해봐야 할 것 같습니다.
### - 이런 것도 해야해요.
56 changes: 56 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and deploy

on:
push:
branches:
- develop
- main
- hackathon

jobs:
build:
runs-on: ubuntu-latest
env:
build-directory: ./backend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Build with Gradle Wrapper
run: ./gradlew bootJar
working-directory: ${{ env.build-directory }}
- name: Archive JAR file
uses: actions/upload-artifact@v4
with:
name: build-jar
path: backend/build/libs/*.jar

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download JAR artifact
uses: actions/download-artifact@v4
with:
name: build-jar
- name: Copy JAR to remote server
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_SSH_KEY }}
target: ${{ secrets.WORK_DIRECTORY }}
source: '*.jar'
- name: Execute Server Init Script
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_SSH_KEY }}
target: ${{ secrets.WORK_DIRECTORY }}
script_stop: true
script: chmod +x ./deploy.sh && sh ./deploy.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

### macOS ###
.DS_Store

### Environment Variable ###
.env
3 changes: 3 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

compileOnly 'org.projectlombok:lombok:0.11.0'
annotationProcessor 'org.projectlombok:lombok'

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'

runtimeOnly 'com.mysql:mysql-connector-j:9.0.0'
Expand Down
13 changes: 13 additions & 0 deletions backend/src/main/java/codezap/TestController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package codezap;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

@GetMapping("/test")
String test() {
return "success";
}
}
36 changes: 36 additions & 0 deletions backend/src/main/java/codezap/extension/domain/Extension.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package codezap.extension.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

import codezap.global.domain.BaseTimeEntity;
import codezap.language.domain.Language;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "extension")
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class Extension extends BaseTimeEntity {

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "language_id", nullable = false)
private Language language;

@Column(nullable = false, unique = true)
private String name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package codezap.extension.repository;

import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;

import codezap.extension.domain.Extension;

public interface ExtensionRepository extends JpaRepository<Extension, Long> {
Optional<Extension> findByName(String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package codezap.global;

import java.time.format.DateTimeFormatter;
import java.util.TimeZone;

import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

@Configuration
public class DateTimeFormatConfiguration {
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm";

@Bean
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
return jacksonObjectMapperBuilder -> {
jacksonObjectMapperBuilder.timeZone(TimeZone.getTimeZone("UTC"));
jacksonObjectMapperBuilder.serializers(
new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)));
};
}
}
24 changes: 24 additions & 0 deletions backend/src/main/java/codezap/global/SpringDocConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package codezap.global;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;

@OpenAPIDefinition(info = @io.swagger.v3.oas.annotations.info.Info(title = "코드잽 API", version = "v1"))
@Configuration
public class SpringDocConfiguration {

@Bean
public OpenAPI openAPI() {
Info info = new Info()
.title("코드잽 API")
.version("v1.0")
.description("코드잽 API 명세서입니다.");

return new OpenAPI()
.info(info);
}
}
15 changes: 15 additions & 0 deletions backend/src/main/java/codezap/global/WebCorsConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package codezap.global;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebCorsConfiguration implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("*");
}
}
27 changes: 27 additions & 0 deletions backend/src/main/java/codezap/global/domain/BaseTimeEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package codezap.global.domain;

import java.time.LocalDateTime;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Getter;

@EntityListeners(AuditingEntityListener.class)
@MappedSuperclass
@Getter
public class BaseTimeEntity {

@CreatedDate
@Column(updatable = false, nullable = false)
private LocalDateTime createdAt;

@LastModifiedDate
@Column(nullable = false)
private LocalDateTime modifiedAt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package codezap.global.domain;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@Configuration
@EnableJpaAuditing
public class JpaAuditingConfiguration {
}
28 changes: 28 additions & 0 deletions backend/src/main/java/codezap/language/domain/Language.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package codezap.language.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import codezap.global.domain.BaseTimeEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "language")
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Language extends BaseTimeEntity {

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

@Column(nullable = false)
private String name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package codezap.language.repository;

import java.util.NoSuchElementException;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;

import codezap.language.domain.Language;

public interface LanguageRepository extends JpaRepository<Language, Long> {

Optional<Language> findByName(String name);

default Language getByName(String name) {
return findByName(name).orElseThrow(
() -> new NoSuchElementException(name + " 언어가 존재하지 않습니다."));
}
}
30 changes: 30 additions & 0 deletions backend/src/main/java/codezap/member/domain/Member.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package codezap.member.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import codezap.global.domain.BaseTimeEntity;
import lombok.Getter;

@Entity
@Table(name = "member")
@Getter
public class Member extends BaseTimeEntity {

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

@Column(unique = true, nullable = false)
private String email;

@Column(nullable = false)
private String password;

@Column(nullable = false)
private String nickname;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package codezap.member.repository;

import org.springframework.data.jpa.repository.JpaRepository;

import codezap.member.domain.Member;

public interface MemberRepository extends JpaRepository<Member, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package codezap.representative_snippet.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;

import codezap.global.domain.BaseTimeEntity;
import codezap.snippet.domain.Snippet;
import codezap.template.domain.Template;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "representative_snippet")
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class RepresentativeSnippet extends BaseTimeEntity {

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

@OneToOne
@JoinColumn(name = "template_id")
private Template template;

@OneToOne
@JoinColumn(name = "snippet_id", nullable = false)
private Snippet snippet;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package codezap.representative_snippet.repository;

import org.springframework.data.jpa.repository.JpaRepository;

import codezap.representative_snippet.domain.RepresentativeSnippet;

public interface RepresentativeSnippetRepository extends JpaRepository<RepresentativeSnippet, Long> {
}
Loading