Skip to content

Commit

Permalink
Merge pull request #4 from Modagbul/backend_main
Browse files Browse the repository at this point in the history
로그인, 소모임 승인, 반려
  • Loading branch information
minsu20 authored Dec 2, 2023
2 parents 266eac1 + 72ed28a commit 3da04a5
Show file tree
Hide file tree
Showing 112 changed files with 3,433 additions and 16 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/backend-cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
working-directory: ./backend
APPLICATION: ${{ secrets.APPLICATION }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
APPLE_KEY: ${{ secrets.APPLE_KEY }}

steps:
# 소스 코드 체크아웃
Expand Down Expand Up @@ -44,13 +43,20 @@ jobs:
cd ./backend/src/main/resources
touch ./application.yml
echo "${{env.APPLICATION}}" > ./application.yml
touch ./firebase-key.json
echo "${{env.GOOGLE_APPLICATION_CREDENTIALS}}" | base64 --decode > ./firebase-key.json
# 설정 파일을 작업공간에 저장
- uses: actions/upload-artifact@v2
with:
name: application.yml
path: ./backend/src/main/resources/application.yml

- uses: actions/upload-artifact@v2
with:
name: firebase-key.json
path: ./backend/src/main/resources/firebase-key.json

# gradlew 권한 설정
- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
FROM openjdk:17-jdk
ARG JAR_FILE=./build/libs/dashboardback-0.0.1-SNAPSHOT.jar
ARG JAR_FILE=./backend/build/libs/backend-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

# 문서를 이미지의 /static/docs 디렉토리에 복사
COPY ./backend/build/docs/asciidoc/*.html /static/docs/

# 애플리케이션 실행 시 -cp 옵션을 사용하여 /static/docs 디렉토리를 클래스패스에 추가
ENTRYPOINT ["java","-cp",".:/static/docs","-jar","/app.jar"]


6 changes: 5 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build/
!**/src/test/**/build/

### STS ###
.apt_generated
.apt_generate
.classpath
.factorypath
.project
Expand Down Expand Up @@ -37,3 +37,7 @@ out/
.vscode/

.DS_Store
application.yml

### Querydsl ###
src/main/generated/
82 changes: 79 additions & 3 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
id "org.asciidoctor.jvm.convert" version "3.3.2"
}

group = 'com.moing.bo.'
Expand All @@ -12,24 +13,99 @@ java {
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
asciidoctorExt
}

repositories {
mavenCentral()
}

bootJar {
dependsOn asciidoctor
from ("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.security:spring-security-test'
implementation 'org.springframework.boot:spring-boot-starter-security'


//jwt
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.5'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.5'

// Qeurydsl
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

// Redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

// Fcm
implementation 'com.google.firebase:firebase-admin:8.2.0'


implementation 'org.springframework.retry:spring-retry:2.0.4'

// RestDocs
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor' // (3)
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' // (4)


}

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

//querydsl
def querydslSrcDir = 'src/main/generated'
clean {
delete file(querydslSrcDir)
}
tasks.withType(JavaCompile) {
options.generatedSourceOutputDirectory = file(querydslSrcDir)
}

//Rest docs
ext {
snippetsDir = file('build/generated-snippets') // (5)
}

tasks.named('test') {
useJUnitPlatform()
outputs.dir snippetsDir // (6)
}

asciidoctor {
configurations 'asciidoctorExt' // (7)
baseDirFollowsSourceFile() // (8)
inputs.dir snippetsDir // (9)
dependsOn test // (10)
}

asciidoctor.doFirst {
delete file('src/main/resources/static/docs') // (11)
}

task copyDocument(type: Copy) { // (12)
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static/docs")
}

build {
dependsOn copyDocument
}
6 changes: 6 additions & 0 deletions backend/src/docs/asciidoc/Admin-API.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[Admin-API]]
= Admin API

[[Admin-로그인]]
== Admin 로그인
operation::admin-controller-test/sign_in[snippets='http-request,request-fields,http-response,response-fields']
61 changes: 61 additions & 0 deletions backend/src/docs/asciidoc/Overview.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[[Overview-Response]]
== ErrorCode


=== Error Response DTO
|===
| isSuccess(Boolean) | timeStamp(LocalDateTime) | errorCode(String) | message(String)
|===

=== Common ErrorCode
|===
| ErrorCode | Scope | Description

| `400`
| 전체
| 요청 형식 자체가 틀리거나 권한이 없음

| `403`
| 전체
| 접근 권한이 존재하지 않음 (로그인 안한 경우)

| `405`
| 전체
| HTTP 메서드가 리소스에서 허용되지 않음

| `500`
| 전체
| 서버오류

| `J0001`
| 전체
| 예상치 못한 오류

| `J0002`
| 전체
| 잘못된 JWT 서명

|`J0003`
| 전체
| 만료된 토큰

| `J0004`
| 전체
| 지원되지 않는 토큰

| `J0005`
| 전체
| 접근이 거부됨

| `J0006`
| 전체
| 토큰이 잘못됨

| `J0007`
| 전체
| 추가 정보 입력 (닉네임) 안함

| `J0008`
| 재발급 시
| 유효하지 않은 refresh Token
|===
37 changes: 37 additions & 0 deletions backend/src/docs/asciidoc/Team-API.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[[Team-API]]
= Team API

[[Team-새로운-소모임-조회]]
== Team 새로운 소모임 조회
operation::team-controller-test/get_team[snippets='http-request,query-parameters,http-response,response-fields']

== Team Category
|===
| Category | Description

| `SPORTS`
| 스포츠/운동

| `HABIT`
| 생활습관 개선

| `TEST`
| 시험/취업준비

| `STUDY`
| 스터디/공부

| `READING`
| 독서

| `ETC`
| 그외 자기계발
|===

[[Team-소모임-승인하기]]
== Team 소모임 승인하기
operation::team-controller-test/approve_team[snippets='http-request,query-parameters,http-response,response-fields']

[[Team-소모임-반려하기]]
== Team 소모임 반려하기
operation::team-controller-test/reject_team[snippets='http-request,query-parameters,http-response,response-fields']
14 changes: 14 additions & 0 deletions backend/src/docs/asciidoc/api.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= Moing BO API Doc
:doctype: book
:icons: font
:source-highlighter: highlightjs
:toc: left
:toclevels: 1
:sectlinks:

include::Overview.adoc[]
include::Admin-API.adoc[]
include::Team-API.adoc[]



Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing
public class BackendApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.moing.bo.backend.domain.admin.application.dto.request;

import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
public class SignInRequest {
@NotBlank(message="id 을 입력해주세요.")
private String id;

@NotBlank(message = "password 을 입력해주세요.")
private String password;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.moing.bo.backend.domain.admin.application.dto.request;

import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
public class SignUpRequest {
@NotBlank(message="id 을 입력해주세요.")
private String id;

@NotBlank(message = "password 을 입력해주세요.")
private String password;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.moing.bo.backend.domain.admin.application.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

public record CheckIdResponse(
Boolean isDuplicated
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.moing.bo.backend.domain.admin.application.dto.response;

import com.moing.bo.backend.global.response.TokenInfoResponse;

public record SignInResponse(
String accessToken,
String refreshToken
) {
public static SignInResponse from(TokenInfoResponse tokenInfoResponse) {
return new SignInResponse(
tokenInfoResponse.getAccessToken(),
tokenInfoResponse.getRefreshToken()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.moing.bo.backend.domain.admin.application.mapper;

import com.moing.bo.backend.domain.admin.application.dto.request.SignUpRequest;
import com.moing.bo.backend.domain.admin.domain.constant.Role;
import com.moing.bo.backend.domain.admin.domain.entity.Admin;
import com.moing.bo.backend.domain.team.domain.constant.ApprovalStatus;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class AdminMapper {

public Admin toAdmin(SignUpRequest signUpRequest) {
return Admin.builder()
.loginId(signUpRequest.getId())
.password(signUpRequest.getPassword())
.role(Role.ADMIN)
.approvedStatus(ApprovalStatus.NO_CONFIRMATION)
.build();
}
}
Loading

0 comments on commit 3da04a5

Please sign in to comment.