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

Refactor 최적화 가능한 것들 최적화 #90

Merged
merged 8 commits into from
Oct 8, 2024
74 changes: 36 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,64 +1,62 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.5'
id 'io.spring.dependency-management' version '1.1.4'
id 'java'
id 'org.springframework.boot' version '3.2.5'
id 'io.spring.dependency-management' version '1.1.4'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {

implementation 'io.jsonwebtoken:jjwt-api:0.12.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.12.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.12.5'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

implementation 'org.springframework.boot:spring-boot-starter-mustache'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

//Querydsl 추가
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
implementation 'io.jsonwebtoken:jjwt-api:0.12.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.12.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.12.5'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

//Querydsl 추가
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

}

tasks.named('bootBuildImage') {
builder = 'paketobuildpacks/builder-jammy-base:latest'
builder = 'paketobuildpacks/builder-jammy-base:latest'
}


tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
@ResponseBody
public class AdminController {

@GetMapping("/admin")
public String adminP() {
@GetMapping("/admin")
public String adminP() {

return "admin Controller";
}
return "admin Controller";
}
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
package com.cotato.squadus.api.admin.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cotato.squadus.api.admin.dto.ClubApplicationListResponse;
import com.cotato.squadus.api.admin.dto.ClubJoinApprovalResponse;
import com.cotato.squadus.api.admin.dto.ClubJoinDenialResponse;
import com.cotato.squadus.domain.club.admin.service.ClubAdminService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Tag(name = "동아리 관리", description = "동아리 관리 관련 API")
@RestController
@RequestMapping("/v1/api/clubs/{clubId}/admin")
@RequiredArgsConstructor
public class ClubAdminController {

private final ClubAdminService clubAdminService;

@PostMapping("/approval/{applicationId}")
@Operation(summary = "동아리 가입 신청 승인", description = "ADMIN 회원인지 검증 후 applicationId를 통해 가입을 승인합니다")
public ResponseEntity<ClubJoinApprovalResponse> approveClubMember(@PathVariable Long clubId, @PathVariable Long applicationId) {
ClubJoinApprovalResponse clubJoinApprovalResponse = clubAdminService.approveApply(clubId, applicationId);
return ResponseEntity.ok(clubJoinApprovalResponse);
}

@PostMapping("/denial/{applicationId}")
@Operation(summary = "동아리 가입 신청 거절", description = "applicationId를 통해 가입을 거절합니다.")
public ResponseEntity<ClubJoinDenialResponse> denyClubMember(@PathVariable Long clubId, @PathVariable Long applicationId) {
ClubJoinDenialResponse clubJoinDenialResponse = clubAdminService.denyApply(clubId, applicationId);
return ResponseEntity.ok(clubJoinDenialResponse);
}

@GetMapping("/applications/{recruitingPostId}")
@Operation(summary = "동아리 가입 신청 내역 조회", description = "clubId를 통해 해당 동아리의 가입 신청 내역을 조회합니다.")
public ResponseEntity<ClubApplicationListResponse> findAllClubApplyByRecruitingPostId(@PathVariable Long clubId, @PathVariable Long recruitingPostId) {
ClubApplicationListResponse allClubApplyByRecruitingPostId = clubAdminService.findAllClubApplyByRecruitingPostId(clubId, recruitingPostId);
return ResponseEntity.ok(allClubApplyByRecruitingPostId);
}
private final ClubAdminService clubAdminService;

@PostMapping("/approval/{applicationId}")
@Operation(summary = "동아리 가입 신청 승인", description = "ADMIN 회원인지 검증 후 applicationId를 통해 가입을 승인합니다")
public ResponseEntity<ClubJoinApprovalResponse> approveClubMember(@PathVariable Long clubId,
@PathVariable Long applicationId) {
ClubJoinApprovalResponse clubJoinApprovalResponse = clubAdminService.approveApply(clubId, applicationId);
return ResponseEntity.ok(clubJoinApprovalResponse);
}

@PostMapping("/denial/{applicationId}")
@Operation(summary = "동아리 가입 신청 거절", description = "applicationId를 통해 가입을 거절합니다.")
public ResponseEntity<ClubJoinDenialResponse> denyClubMember(@PathVariable Long clubId,
@PathVariable Long applicationId) {
ClubJoinDenialResponse clubJoinDenialResponse = clubAdminService.denyApply(clubId, applicationId);
return ResponseEntity.ok(clubJoinDenialResponse);
}

@GetMapping("/applications/{recruitingPostId}")
@Operation(summary = "동아리 가입 신청 내역 조회", description = "clubId를 통해 해당 동아리의 가입 신청 내역을 조회합니다.")
public ResponseEntity<ClubApplicationListResponse> findAllClubApplyByRecruitingPostId(@PathVariable Long clubId,
@PathVariable Long recruitingPostId) {
ClubApplicationListResponse allClubApplyByRecruitingPostId = clubAdminService.findAllClubApplyByRecruitingPostId(
clubId, recruitingPostId);
return ResponseEntity.ok(allClubApplyByRecruitingPostId);
}
}
37 changes: 19 additions & 18 deletions src/main/java/com/cotato/squadus/api/admin/dto/ArticleDto.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
package com.cotato.squadus.api.admin.dto;

import java.time.LocalDateTime;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter
public class ArticleDto {

private String title;
private String subtitle;
private String type;
private LocalDateTime createdAt;
private String tag;
private String content;
private Long views;
private String title;
private String subtitle;
private String type;
private LocalDateTime createdAt;
private String tag;
private String content;
private Long views;

@Builder
public ArticleDto(String title, String subtitle, String type, LocalDateTime createdAt, String tag, String content, Long views) {
this.title = title;
this.subtitle = subtitle;
this.type = type;
this.tag = tag;
this.content = content;
this.views = views;
}
@Builder
public ArticleDto(String title, String subtitle, String type, LocalDateTime createdAt, String tag, String content,
Long views) {
this.title = title;
this.subtitle = subtitle;
this.type = type;
this.tag = tag;
this.content = content;
this.views = views;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import com.cotato.squadus.domain.club.common.entity.ClubApplication;

public record ClubApplicationInfoResponse(
Long applicationId,
Long recruitingPostId,
MemberClubApplicationInfo memberClubApplicationInfo
Long applicationId,
Long recruitingPostId,
MemberClubApplicationInfo memberClubApplicationInfo
) {
public static ClubApplicationInfoResponse from(ClubApplication clubApplication) {
return new ClubApplicationInfoResponse(
clubApplication.getApplicationIdx(),
clubApplication.getRecruitingPost().getPostId(),
MemberClubApplicationInfo.from(clubApplication)
);
}
public static ClubApplicationInfoResponse from(ClubApplication clubApplication) {
return new ClubApplicationInfoResponse(
clubApplication.getApplicationIdx(),
clubApplication.getRecruitingPost().getPostId(),
MemberClubApplicationInfo.from(clubApplication)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.util.List;

public record ClubApplicationListResponse(
List<ClubApplicationInfoResponse> clubApplicationInfoResponseList
List<ClubApplicationInfoResponse> clubApplicationInfoResponseList
) {
public static ClubApplicationListResponse from(List<ClubApplicationInfoResponse> clubApplicationInfoResponseList) {
return new ClubApplicationListResponse(clubApplicationInfoResponseList);
}
public static ClubApplicationListResponse from(List<ClubApplicationInfoResponse> clubApplicationInfoResponseList) {
return new ClubApplicationListResponse(clubApplicationInfoResponseList);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cotato.squadus.api.admin.dto;

public record ClubJoinApprovalResponse(
Long clubMemberId
Long clubMemberId
) {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cotato.squadus.api.admin.dto;

public record ClubJoinDenialResponse(
Long applicationId
Long applicationId
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import com.cotato.squadus.domain.club.common.entity.ClubApplication;

public record MemberClubApplicationInfo(
Long memberIdx,
String username,
String university
Long memberIdx,
String username,
String university
) {
public static MemberClubApplicationInfo from(ClubApplication clubApplication) {
return new MemberClubApplicationInfo(
clubApplication.getMember().getMemberIdx(),
clubApplication.getMember().getUsername(),
clubApplication.getMember().getUniversity()
);
}
public static MemberClubApplicationInfo from(ClubApplication clubApplication) {
return new MemberClubApplicationInfo(
clubApplication.getMember().getMemberIdx(),
clubApplication.getMember().getUsername(),
clubApplication.getMember().getUniversity()
);
}

}
Loading
Loading