Skip to content

Commit

Permalink
Merge pull request #34 from Team-UMC/feature/#23/board-api
Browse files Browse the repository at this point in the history
[FEAT] ๊ฒŒ์‹œํŒ API ๊ตฌํ˜„
  • Loading branch information
tnals2384 authored Jan 31, 2024
2 parents 177c572 + aa92767 commit fe2c861
Show file tree
Hide file tree
Showing 61 changed files with 3,996 additions and 45 deletions.
33 changes: 33 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
// queryDsl Settings
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}

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


java {
sourceCompatibility = '17'
}
Expand All @@ -21,6 +24,7 @@ repositories {
mavenCentral()
}


dependencies {
implementation 'io.jsonwebtoken:jjwt:0.9.1'

Expand All @@ -47,6 +51,12 @@ dependencies {
// s3 setting
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

//query dsl
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"

// ์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ์Šคํƒ€ํ„ฐ ์ถ”๊ฐ€
implementation 'org.springframework.boot:spring-boot-starter-security'

Expand All @@ -63,3 +73,26 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

//querydsl ๋นŒ๋“œ ์˜ต์…˜
def querydslDir = "$buildDir/generated/querydsl"

querydsl {
jpa = true
querydslSourcesDir = querydslDir
}

sourceSets {
main.java.srcDir querydslDir
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
querydsl.extendsFrom compileClasspath
}

compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
}
19 changes: 19 additions & 0 deletions src/main/java/com/umc/networkingService/config/QueryDSLConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.umc.networkingService.config;

import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@RequiredArgsConstructor
public class QueryDSLConfig {
private final EntityManager entityManager;

@Bean
public JPAQueryFactory jpaQueryFactory() {
return new JPAQueryFactory(entityManager);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package com.umc.networkingService.domain.board.controller;

import com.umc.networkingService.config.security.auth.CurrentMember;
import com.umc.networkingService.domain.board.dto.request.comment.BoardCommentAddRequest;
import com.umc.networkingService.domain.board.dto.request.comment.BoardCommentUpdateRequest;
import com.umc.networkingService.domain.board.dto.response.comment.BoardCommentIdResponse;
import com.umc.networkingService.domain.board.dto.response.comment.BoardCommentPagingResponse;
import com.umc.networkingService.domain.board.dto.response.member.MyBoardCommentPagingWebResponse;
import com.umc.networkingService.domain.board.dto.response.member.MyBoardPagingResponse;
import com.umc.networkingService.domain.board.entity.BoardType;
import com.umc.networkingService.domain.board.entity.HostType;
import com.umc.networkingService.domain.board.service.BoardCommentService;
import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.global.common.base.BaseResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

@Tag(name = "๊ฒŒ์‹œํŒ ๋Œ“๊ธ€ API", description = "๊ฒŒ์‹œํŒ ๋Œ“๊ธ€ ๊ด€๋ จ API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/boards/comments")
public class BoardCommentController {

private final BoardCommentService boardCommentService;

@Operation(summary = "๋Œ“๊ธ€ ์ž‘์„ฑ API", description = "๋Œ“๊ธ€์„ ์ž‘์„ฑํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "COMMON200", description = "์„ฑ๊ณต"),
})
@PostMapping
public BaseResponse<BoardCommentIdResponse> addBoardComment(@CurrentMember Member member,
@Valid @RequestBody BoardCommentAddRequest request) {
return BaseResponse.onSuccess(boardCommentService.addBoardComment(member, request));
}

@Operation(summary = "๋Œ“๊ธ€ ์ˆ˜์ • API", description = "๋Œ“๊ธ€์„ ์ˆ˜์ •ํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "COMMON200", description = "์„ฑ๊ณต"),
@ApiResponse(responseCode = "COMMENT001", description = "๋Œ“๊ธ€์„ ์ฐพ์„ ์ˆ˜ ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ"),
@ApiResponse(responseCode = "COMMENT002", description = "๋Œ“๊ธ€ ์ˆ˜์ • ๊ถŒํ•œ์ด ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ"),

})
@PatchMapping("/{commentId}")
public BaseResponse<BoardCommentIdResponse> updateBoardComment(@CurrentMember Member member,
@PathVariable(value = "commentId") UUID commentId,
@Valid @RequestBody BoardCommentUpdateRequest request) {
return BaseResponse.onSuccess(boardCommentService.updateBoardComment(member, commentId, request));
}


@Operation(summary = "๋Œ“๊ธ€ ์‚ญ์ œ API", description = "๋Œ“๊ธ€์„ ์‚ญ์ œํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "COMMON200", description = "์„ฑ๊ณต"),
@ApiResponse(responseCode = "COMMENT001", description = "๋Œ“๊ธ€์„ ์ฐพ์„ ์ˆ˜ ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ"),
@ApiResponse(responseCode = "COMMENT002", description = "๋Œ“๊ธ€ ์‚ญ์ œ ๊ถŒํ•œ์ด ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ")
})
@DeleteMapping("/{commentId}")
public BaseResponse<BoardCommentIdResponse> deleteBoardComment(@CurrentMember Member member,
@PathVariable(value = "commentId") UUID commentId) {
return BaseResponse.onSuccess(boardCommentService.deleteBoardComment(member, commentId));
}

@Operation(summary = " ํŠน์ • ๊ฒŒ์‹œ๊ธ€ ๋Œ“๊ธ€ ๋ชฉ๋ก ์กฐํšŒ API", description = "ํŠน์ • ๊ฒŒ์‹œ๊ธ€์˜ ๋Œ“๊ธ€ ๋ชฉ๋ก์„ ์กฐํšŒํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "COMMON200", description = "์„ฑ๊ณต"),
@ApiResponse(responseCode = "BOARD002", description = "๊ฒŒ์‹œ๊ธ€์„ ์ฐพ์„ ์ˆ˜ ์—†์„ ๊ฒฝ์šฐ ๋ฐœ์ƒ")
})
@Parameters(value = {
@Parameter(name = "page", description = " page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค.")
})
@GetMapping(value = "/{boardId}")
public BaseResponse<BoardCommentPagingResponse> showBoardComments(@CurrentMember Member member,
@PathVariable(value = "boardId") UUID boardId,
@PageableDefault(sort = "created_at", direction = Sort.Direction.ASC)
@Parameter(hidden = true) Pageable pageable) {
return BaseResponse.onSuccess(boardCommentService.showBoardComments(member, boardId, pageable));
}

@Operation(summary = "[APP] ๋‚ด๊ฐ€ ๋Œ“๊ธ€ ์“ด ๊ธ€ ์กฐํšŒ/๊ฒ€์ƒ‰ API", description = "APP์šฉ ๋‚ด๊ฐ€ ๋Œ“๊ธ€ ์“ด ๊ธ€์„ ์กฐํšŒ/๊ฒ€์ƒ‰ํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.")
@ApiResponses(value = {
@ApiResponse(responseCode = "COMMON200", description = "์„ฑ๊ณต"),
})
@Parameters(value = {
@Parameter(name = "keyword", description = "keyword๋ฅผ ์ฃผ์ง€ ์•Š์œผ๋ฉด ๋ชจ๋“  ๋‚ด๊ฐ€ ๋Œ“๊ธ€ ์“ด ๊ธ€์ด ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค. keyword๋ฅผ ์ฃผ๋ฉด ๊ฒ€์ƒ‰์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค."),
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค.")
})
@GetMapping(value = "/member/comments/app")
public BaseResponse<MyBoardPagingResponse> showBoardsByMemberCommentsForApp(@CurrentMember Member member,
@RequestParam(name = "keyword", required = false) String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
return BaseResponse.onSuccess(boardCommentService.showBoardsByMemberCommentForApp(member, keyword, pageable));
}

@Operation(summary = "[WEB] ๋‚ด๊ฐ€ ๋Œ“๊ธ€ ์“ด ๊ธ€ ์กฐํšŒ/๊ฒ€์ƒ‰ API", description = "WEB์šฉ ๋‚ด๊ฐ€ ๋Œ“๊ธ€ ์“ด ๊ธ€์„ ์กฐํšŒ/๊ฒ€์ƒ‰ํ•˜๋Š” API์ž…๋‹ˆ๋‹ค. "+
"host: CENTER, BRANCH, CAMPUS ์ค‘ ํ•˜๋‚˜์˜ ๊ฐ’์„ ๋Œ€๋ฌธ์ž๋กœ ์ฃผ์„ธ์š”. " +
"board: NOTICE, FREE, WORKBOOK, OB, QUESTION ์ค‘ ํ•˜๋‚˜์˜ ๊ฐ’์„ ๋Œ€๋ฌธ์ž๋กœ ์ฃผ์„ธ์š”.")
@ApiResponses(value = {
@ApiResponse(responseCode = "COMMON200", description = "์„ฑ๊ณต"),
})
@Parameters(value = {
@Parameter(name = "keyword", description = "keyword๋ฅผ ์ฃผ์ง€ ์•Š์œผ๋ฉด ๋ชจ๋“  ๋‚ด๊ฐ€ ๋Œ“๊ธ€ ์“ด ๊ธ€์ด ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค. keyword๋ฅผ ์ฃผ๋ฉด ๊ฒ€์ƒ‰์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค."),
@Parameter(name = "page", description = "page ์‹œ์ž‘์€ 0๋ฒˆ๋ถ€ํ„ฐ, ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์กฐํšŒ๋ฉ๋‹ˆ๋‹ค.")})
@GetMapping(value = "/member/comments/web")
public BaseResponse<MyBoardCommentPagingWebResponse> showBoardsByMemberCommentForWeb(@CurrentMember Member member,
@RequestParam(name = "host") HostType hostType,
@RequestParam(name = "board") BoardType boardType,
@RequestParam(name = "keyword", required = false) String keyword,
@PageableDefault(sort = "created_at", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
return BaseResponse.onSuccess(boardCommentService.showBoardsByMemberCommentForWeb(member, hostType, boardType,keyword, pageable));
}
}
Loading

0 comments on commit fe2c861

Please sign in to comment.