Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
5uhwann committed Jan 4, 2024
2 parents a5b85cd + 4e77b75 commit 28139c7
Show file tree
Hide file tree
Showing 55 changed files with 438 additions and 23 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies {
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
implementation "com.querydsl:querydsl-apt:${queryDslVersion}"
implementation('org.flywaydb:flyway-core:6.4.2')
implementation 'org.springdoc:springdoc-openapi-ui:1.6.9'

runtimeOnly 'mysql:mysql-connector-java'
compileOnly 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.plzgraduate.myongjigraduatebe.auth.adaptor.in.web.signin;

import javax.validation.Valid;

import org.springframework.web.bind.annotation.RequestBody;

import com.plzgraduate.myongjigraduatebe.auth.application.port.in.TokenResponse;
import com.plzgraduate.myongjigraduatebe.core.meta.LoginUser;

import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "SignIn", description = "로그인 API")
public interface SignInApiPresentation {

@Operation(summary = "로그인")
TokenResponse signIn(@Valid @RequestBody SignInRequest signInRequest);

@Hidden
String check(@LoginUser Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@WebAdapter
@RequestMapping("api/v1/auth")
@RequiredArgsConstructor
public class SignInController {
public class SignInController implements SignInApiPresentation {

private final SignInUseCase signInUseCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.plzgraduate.myongjigraduatebe.auth.application.port.in.signin.SignInCommand;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -13,9 +14,11 @@
public class SignInRequest {

@NotBlank(message = "아아디를 입력해주세요.")
@Schema(name = "authId", example = "plzgraduate")
private String authId;

@NotBlank(message = "비밀번호를 입력해주세요.")
@Schema(name = "password", example = "Plz1231343!")
private String password;

@Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.plzgraduate.myongjigraduatebe.auth.adaptor.in.web.token;

import javax.validation.Valid;

import org.springframework.web.bind.annotation.RequestBody;

import com.plzgraduate.myongjigraduatebe.auth.application.port.in.AccessTokenResponse;

import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "Token", description = "토큰 발급 API")
public interface TokenApiPresentation {

AccessTokenResponse newToken(@Valid @RequestBody TokenRequest tokenRequest);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@WebAdapter
@RequiredArgsConstructor
@RequestMapping("/api/v1/auth")
public class TokenController {
public class TokenController implements TokenApiPresentation {

private final TokenUseCase tokenUseCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.plzgraduate.myongjigraduatebe.auth.application.port.in.token.TokenCommand;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -13,6 +14,7 @@
public class TokenRequest {

@NotBlank(message = "unexpected token")
@Schema(name = "refreshToken", example = "7f734e1b-669d-430e-ac78-270e3863db50")
private String refreshToken;

@Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.plzgraduate.myongjigraduatebe.auth.application.port.in;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class AccessTokenResponse {

@Schema(name = "accessToken", example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
private String accessToken;

@Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.plzgraduate.myongjigraduatebe.auth.application.port.in;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -8,7 +9,10 @@
@NoArgsConstructor
public class TokenResponse {

@Schema(name = "accessToken", example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
private String accessToken;

@Schema(name = "refreshToken", example = "7f734e1b-669d-430e-ac78-270e3863db50")
private String refreshToken;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

import com.plzgraduate.myongjigraduatebe.core.meta.WebAdapter;

import io.swagger.v3.oas.annotations.Hidden;

@WebAdapter
@RequestMapping("/api/v1")
@Hidden
public class HealthCheckController {

@GetMapping("/health")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
API_V1_PREFIX + "/users/{student-number}/auth-id", // 아이디 찾기
API_V1_PREFIX + "/users/{student-number}/validate", // 유저 검증
API_V1_PREFIX + "/users/password", // 비밀번호 재설정
API_V1_PREFIX + "/health" //헬스체크
API_V1_PREFIX + "/health", //헬스체크
"/api-docs",
"/swagger-custom-ui.html",
"/v3/api-docs/**",
"/swagger-ui/**",
"/api-docs/**",
"/swagger-ui.html"
).permitAll()
.anyRequest().authenticated()
.and()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.plzgraduate.myongjigraduatebe.core.config;

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

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

@Configuration
public class SwaggerConfig {

@Bean
public OpenAPI springOpenApi() {
return new OpenAPI().info(new Info()
.title("Myongji-Graduate API Documentation")
.description("졸업을 부탁해 서비스의 API 명세서입니다.")
.version("v2.0.0"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.plzgraduate.myongjigraduatebe.graduation.adpater.in.web;

import com.plzgraduate.myongjigraduatebe.core.meta.LoginUser;
import com.plzgraduate.myongjigraduatebe.graduation.application.port.in.response.GraduationResponse;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "CalculateGraduation", description = "유저의 졸업 결과를 계산하는 API")
public interface CalculateGraduationApiPresentation {

@Parameter(name = "userId", description = "로그인한 유저의 PK값")
GraduationResponse calculate(@LoginUser Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@WebAdapter
@RequestMapping("/api/v1/graduation")
@RequiredArgsConstructor
public class CalculateGraduationController {
public class CalculateGraduationController implements CalculateGraduationApiPresentation {

private final CalculateGraduationUseCase calculateGraduationUseCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationResult;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Getter
public class BasicInfoResponse {

@Schema(name = "name", example = "홍길동")
private final String name;
@Schema(name = "studentNumber", example = "60202000")
private final String studentNumber;
@Schema(name = "major", example = "응용소프트웨어전공")
private final String major;
@Schema(name = "totalCredit", example = "132")
private final int totalCredit;
@Schema(name = "takenCredit", example = "50")
private final double takenCredit;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import com.plzgraduate.myongjigraduatebe.graduation.domain.model.ChapelResult;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Getter
public class ChapelResultResponse {

@Schema(name = "takenCount", example = "4")
private final int takenCount;
@Schema(name = "completed", example = "true")
private final boolean completed;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@

import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailCategoryResult;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Getter
public class DetailGraduationCategoryResultResponse {

@Schema(name = "categoryName", example = "공통교양(기독교)")
private final String categoryName;
@Schema(name = "totalCredits", example = "4")
private final int totalCredits;
@Schema(name = "takenCredits", example = "4")
private final int takenCredits;
private final List<LectureResponse> takenLectures;
private final List<LectureResponse> haveToLectures;
@Schema(name = "completed", example = "true")
private final boolean completed;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@

import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailGraduationResult;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Getter
public class DetailGraduationResultResponse {

@Schema(name = "totalCredit", example = "12")
private final int totalCredit;
@Schema(name = "takenCredit", example = "9")
private final double takenCredit;
private final List<DetailGraduationCategoryResultResponse> detailCategory;
@Schema(name = "completed", example = "false")
private final boolean completed;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationResult;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

Expand All @@ -20,6 +21,7 @@ public class GraduationResponse {
private final DetailGraduationResultResponse major;
private final RestResultResponse normalCulture;
private final RestResultResponse freeElective;
@Schema(name = "graduated", example = "false")
private final boolean graduated;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Getter
public class LectureResponse {

@Schema(name = "id", example = "6")
private final Long id;
@Schema(name = "code", example = "KMA02103")
private final String code;
@Schema(name = "name", example = "종교와과학")
private final String name;
@Schema(name = "credit", example = "2")
private final int credit;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.FreeElectiveGraduationResult;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.NormalCultureGraduationResult;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Getter
public class RestResultResponse {

@Schema(name = "totalCredit", example = "10")
private final int totalCredit;
@Schema(name = "takenCredit", example = "5")
private final int takenCredit;
@Schema(name = "completed", example = "false")
private final boolean completed;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@ private void calculateFreeElectiveLeftCredit(User user, Set<Lecture> taken,

private void calculateNormalLeftCredit(Set<Lecture> taken, Set<TakenLecture> finishedTakenLecture,
DetailCategoryResult commonCultureDetailCategoryResult) {
int normalLeftCredit = finishedTakenLecture.stream()
List<TakenLecture> cultureAndArtExceptionLectures = finishedTakenLecture.stream()
.filter(takenLecture -> 문화와예술_예외_과목.contains(takenLecture.getLecture())
&& takenLecture.getYear() == 2022
&& takenLecture.getSemester() == FIRST)
.mapToInt(takenLecture -> takenLecture.getLecture().getCredit())
.sum();
taken.removeAll(문화와예술_예외_과목);
commonCultureDetailCategoryResult.addNormalLeftCredit(normalLeftCredit);
.collect(Collectors.toList());
if (!cultureAndArtExceptionLectures.isEmpty()) {
cultureAndArtExceptionLectures.stream()
.map(TakenLecture::getLecture)
.forEach(taken::remove);
int normalLeftCredit = cultureAndArtExceptionLectures.stream()
.mapToInt(exceptionLecture -> exceptionLecture.getLecture().getCredit())
.sum();
commonCultureDetailCategoryResult.addNormalLeftCredit(normalLeftCredit);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.plzgraduate.myongjigraduatebe.lecture.adapter.in.web;

import javax.validation.constraints.Size;

import org.springframework.web.bind.annotation.RequestParam;

import com.plzgraduate.myongjigraduatebe.lecture.application.port.in.search.SearchLectureResponse;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "SearchLecture", description = "type과 keyword를 통해 과목정보를 검색하는 API")
public interface SearchLectureApiPresentation {

SearchLectureResponse searchLecture(
@Parameter(name = "type", description = "과목명 또는 과목코드") @RequestParam(defaultValue = "name") String type,
@Parameter(name = "keyword", description = "검색어 2자리 이상") @RequestParam @Size(min = 2, message = "검색어를 2자리 이상 입력해주세요.") String keyword
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@RequiredArgsConstructor
@RequestMapping("/api/v1/lectures")
@Validated
public class SearchLectureController {
public class SearchLectureController implements SearchLectureApiPresentation {

private final SearchLectureUseCase searchLectureUseCase;

Expand Down
Loading

0 comments on commit 28139c7

Please sign in to comment.