Skip to content

Commit

Permalink
Merge pull request #228 from sopt-makers/sohyeon_#227
Browse files Browse the repository at this point in the history
[REFACTOR] app, web 분리
  • Loading branch information
thguss authored Feb 15, 2024
2 parents 72ceda6 + 223b4ff commit 292ef02
Show file tree
Hide file tree
Showing 275 changed files with 5,188 additions and 3,926 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/cd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ jobs:
- name: Create application.yml
run: |
pwd
touch src/main/resources/application-dev.yml
echo "${{ secrets.APPLICATION_DEV }}" >> src/main/resources/application-dev.yml
cat src/main/resources/application-dev.yml
cd ./operation-api/src/main/resources
touch ./application-dev.yml
echo "${{ secrets.APPLICATION_DEV }}" >> ./application-dev.yml
cat ./application-dev.yml
- name: Build with Gradle
run: ./gradlew build
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ jobs:
- name: Create application.yml
run: |
pwd
touch src/main/resources/application-prod.yml
echo "${{ secrets.APPLICATION_PROD }}" >> src/main/resources/application-prod.yml
cat src/main/resources/application-prod.yml
cd ./operation-api/src/main/resources
touch ./application-prod.yml
echo "${{ secrets.APPLICATION_PROD }}" >> ./application-prod.yml
cat ./application-prod.yml
- name: Build with Gradle
run: ./gradlew build
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ jobs:
- name: Create application.yml
run: |
pwd
touch src/main/resources/application-dev.yml
echo "${{ secrets.APPLICATION_DEV }}" >> src/main/resources/application-dev.yml
cat src/main/resources/application-dev.yml
cd ./operation-api/src/main/resources
touch ./application-dev.yml
echo "${{ secrets.APPLICATION_DEV }}" >> ./application-dev.yml
cat ./application-dev.yml
- name: Build with Gradle
run: ./gradlew build
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ out/
.vscode/

### config yml ###
application-**.yml
application-**.yml

*/src/main/generated
96 changes: 36 additions & 60 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,79 +1,55 @@
buildscript {
ext {
queryDslVersion = "5.0.0"
repositories {
mavenCentral()
}
}

plugins {
id 'java'
id 'org.springframework.boot' version '2.7.4'
id 'org.springframework.boot' version '3.0.0'
id 'io.spring.dependency-management' version '1.1.0'
id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10'
}

group = 'org.sopt.makers'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
allprojects {
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}
group = 'org.sopt.makers.operation'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
implementation "com.querydsl:querydsl-apt:${queryDslVersion}"
testImplementation 'junit:junit:4.13.1'
testImplementation 'junit:junit:4.13.1'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
repositories {
mavenCentral()
}

// jwt
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.2'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.2'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.2'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

testImplementation 'org.springframework.boot:spring-boot-starter-test'
dependencies {
// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'

// swagger
implementation 'io.springfox:springfox-boot-starter:3.0.0'
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
// test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}

// gson
implementation 'com.google.code.gson:gson:2.8.9'
tasks.named('test') {
useJUnitPlatform()
}
}

tasks.named('test') {
useJUnitPlatform()
jar {
enabled = true
}

def querydslDir = "$buildDir/generated/querydsl"

querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets {
main.java.srcDir querydslDir
}
compileQuerydsl{
options.annotationProcessorPath = configurations.querydsl
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
querydsl.extendsFrom compileClasspath
}
bootJar {
enabled = false
}
24 changes: 24 additions & 0 deletions operation-api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
jar {
enabled = false
}

bootJar {
enabled = true
}

dependencies {
// module
implementation project(path: ':operation-auth')
implementation project(path: ':operation-common')
implementation project(path: ':operation-domain')
implementation project(path: ':operation-external')

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'

// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sopt.makers.operation;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(
scanBasePackageClasses = {AuthRoot.class, CommonRoot.class, DomainRoot.class, ExternalRoot.class}
)
public class OperationApplication {

public static void main(String[] args) {
SpringApplication.run(OperationApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.sopt.makers.operation.app.attendance.api;

import java.security.Principal;

import org.sopt.makers.operation.app.attendance.dto.request.LectureAttendRequest;
import org.sopt.makers.operation.dto.BaseResponse;
import org.springframework.http.ResponseEntity;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.NonNull;

@Tag(name = "앱 출석 관련 API")
public interface AppAttendanceApi {

@Operation(
security = @SecurityRequirement(name = "Authorization"),
summary = "앱 출석 API",
responses = {
@ApiResponse(
responseCode = "200",
description = "출석 성공"
),
@ApiResponse(
responseCode = "400",
description = "잘못된 요청"
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류"
)
}
)
ResponseEntity<BaseResponse<?>> attend(
@RequestBody LectureAttendRequest request,
@Parameter(hidden = true) @NonNull Principal principal);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.sopt.makers.operation.app.attendance.api;

import static org.sopt.makers.operation.code.success.app.AttendanceSuccessCode.*;

import java.security.Principal;

import org.sopt.makers.operation.app.attendance.dto.request.LectureAttendRequest;
import org.sopt.makers.operation.app.attendance.service.AppAttendanceService;
import org.sopt.makers.operation.common.util.CommonUtils;
import org.sopt.makers.operation.util.ApiResponseUtil;
import org.sopt.makers.operation.dto.BaseResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/app/attendances")
public class AppAttendanceApiController implements AppAttendanceApi {

private final AppAttendanceService attendanceService;
private final CommonUtils utils;

@Override
@PostMapping("/attend")
public ResponseEntity<BaseResponse<?>> attend(@RequestBody LectureAttendRequest request, Principal principal) {
val memberId = utils.getMemberId(principal);
val response = attendanceService.attend(memberId, request);
return ApiResponseUtil.success(SUCCESS_ATTEND, response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.makers.operation.app.attendance.dto.request;

import lombok.NonNull;

public record LectureAttendRequest(
long subLectureId,
@NonNull String code
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sopt.makers.operation.app.attendance.dto.response;

import static lombok.AccessLevel.*;

import lombok.Builder;

import org.sopt.makers.operation.attendance.domain.SubAttendance;

@Builder(access = PRIVATE)
public record LectureAttendResponse(
long subLectureId
) {
public static LectureAttendResponse of(SubAttendance subAttendance) {
return LectureAttendResponse.builder()
.subLectureId(subAttendance.getSubLecture().getId())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.sopt.makers.operation.app.attendance.service;

import org.sopt.makers.operation.app.attendance.dto.request.LectureAttendRequest;
import org.sopt.makers.operation.app.attendance.dto.response.LectureAttendResponse;

public interface AppAttendanceService {
LectureAttendResponse attend(long memberId, LectureAttendRequest request);
}
Loading

0 comments on commit 292ef02

Please sign in to comment.