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

🏄 :: (Meogo-52) feign client #53

Merged
merged 10 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies {
implementation("com.amazonaws:aws-java-sdk-s3:1.12.529")
implementation("com.google.firebase:firebase-admin:8.1.0")
implementation("javax.servlet:javax.servlet-api:4.0.1")
implementation("org.springframework.cloud:spring-cloud-starter-openfeign:3.1.4")
meltapplee marked this conversation as resolved.
Show resolved Hide resolved
compileOnly("org.projectlombok:lombok")
runtimeOnly("com.mysql:mysql-connector-j")
annotationProcessor("org.projectlombok:lombok")
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/org/meogo/MeogoBackendApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import org.meogo.global.jwt.JwtProperties
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.runApplication
import org.springframework.cloud.openfeign.EnableFeignClients

@EnableFeignClients(basePackages = ["org.meogo"])
@EnableConfigurationProperties(JwtProperties::class)
@SpringBootApplication(scanBasePackages = [ "org.meogo"])
class MeogoBackendApplication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.meogo.domain.bookmark.presentation

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.meogo.domain.bookmark.service.BookmarkService
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.DeleteMapping
Expand All @@ -10,25 +12,30 @@ import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController

@Tag(name = "Bookmark API")
@RestController
@RequestMapping("/bookmark")
class BookmarkController(
private val bookmarkService: BookmarkService
) {

@Operation(summary = "북마크 생성")
@ResponseStatus(HttpStatus.OK)
@PostMapping
fun create(@RequestParam(name = "school_id")schoolId: Int) =
bookmarkService.execute(schoolId)

@Operation(summary = "내 북마크 조회")
@GetMapping("/query/my")
fun myBookmarks() =
bookmarkService.queryBookmarkedSchool()

@Operation(summary = "북마크 여부 조회")
@GetMapping("/query")
fun isBookmarked(@RequestParam(name = "school_id")schoolId: Int) =
bookmarkService.queryIsBookmarked(schoolId)

@Operation(summary = "북마크 취소")
@ResponseStatus(HttpStatus.NO_CONTENT)
@DeleteMapping
fun delete(@RequestParam(name = "school_id")schoolId: Int) =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.meogo.domain.comment.presentation

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.meogo.domain.comment.presentation.dto.request.CommentRequest
import org.meogo.domain.comment.service.CreateCommentService
import org.meogo.domain.comment.service.DeleteCommentService
Expand All @@ -13,19 +15,22 @@ import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@Tag(name = "Comment API")
@RestController
@RequestMapping("/comment")
class CommentController(
private val createCommentService: CreateCommentService,
private val deleteCommentService: DeleteCommentService
) {
@Operation(summary = "댓글 작성")
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
fun create(
@Valid @RequestBody
request: CommentRequest
) = createCommentService.execute(request)

@Operation(summary = "댓글 삭제")
@DeleteMapping()
@ResponseStatus(HttpStatus.NO_CONTENT)
fun delete(@RequestParam(name = "comment_id")id: Long) =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.meogo.domain.post.presentation

import lombok.RequiredArgsConstructor
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.meogo.domain.post.presentation.dto.request.PostRequest
import org.meogo.domain.post.service.CreatePostService
import org.meogo.domain.post.service.DeletePostService
Expand All @@ -22,7 +23,7 @@ import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
import javax.validation.Valid

@RequiredArgsConstructor
@Tag(name = "Community API")
@RestController
@RequestMapping("/community")
class PostController(
Expand All @@ -35,6 +36,7 @@ class PostController(
private val queryMyPostService: QueryMyPostService
) {

@Operation(summary = "게시글 작성")
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
fun create(
Expand All @@ -45,11 +47,13 @@ class PostController(
) =
createPostService.execute(request, image)

@DeleteMapping()
@Operation(summary = "게시글 삭제")
@DeleteMapping
@ResponseStatus(HttpStatus.NO_CONTENT)
fun delete(@RequestParam("post_id") id: Long) =
deletePostService.execute(id)

@Operation(summary = "게시글 수정")
@PatchMapping("/modify")
fun modify(
@RequestParam("post_id") id: Long,
Expand All @@ -59,16 +63,20 @@ class PostController(
@RequestPart("image") image: MultipartFile?
) = modifyPostService.execute(id, request, image)

@Operation(summary = "모든 게시글 조회")
@GetMapping("/query/all")
fun queryAll() = queryAllPostService.execute()

@Operation(summary = "학교별 게시글 조회")
@GetMapping("/query")
fun querySchool(@RequestParam(name = "school_id") schoolId: Int) = querySchoolPostService.execute(schoolId)

@Operation(summary = "게시글 상세보기")
@GetMapping("/query/detail")
fun queryPostDetail(@RequestParam(name = "post_id") id: Long) =
queryPostDetailService.execute(id)

@Operation(summary = "내가 쓴 게시글 조회")
@GetMapping("/query/my")
fun queryMyPosts() = queryMyPostService.execute()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.meogo.domain.question.presentation

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.meogo.domain.question.enum.QuestionType
import org.meogo.domain.question.presentation.dto.request.ModifyQuestionRequest
import org.meogo.domain.question.presentation.dto.request.QuestionRequest
Expand All @@ -21,6 +23,7 @@ import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@Tag(name = "Question API")
@RestController
@RequestMapping("/question")
class QuestionController(
Expand All @@ -31,13 +34,15 @@ class QuestionController(
private val modifyQuestionService: ModifyQuestionService,
private val deleteQuestionService: DeleteQuestionService
) {
@Operation(summary = "질문 작성")
@ResponseStatus(HttpStatus.CREATED)
@PostMapping
fun createQuestion(
@Valid @RequestBody
request: QuestionRequest
) = createQuestionService.execute(request)

@Operation(summary = "질문 수정")
@PatchMapping("/modify")
fun modifyQuestion(
@RequestParam(name = "question_id")
Expand All @@ -47,22 +52,26 @@ class QuestionController(
) =
modifyQuestionService.execute(questionId, request)

@Operation(summary = "학교별 질문 조회")
@GetMapping("/query")
fun querySchoolQuestion(@RequestParam(name = "school_id")schoolId: Int) =
querySchoolQuestionService.execute(schoolId)

@Operation(summary = "학교별 + 태그별 질문 조회")
@GetMapping("/query/tag")
fun queryTypeQuestion(
@RequestParam(name = "school_id")schoolId: Int,
@RequestParam(name = "tag") type: QuestionType
) = queryTypeQuestionService.execute(schoolId, type)

@Operation(summary = "질문 상세보기")
@GetMapping("/detail")
fun queryDetail(@RequestParam(name = "question_id")questionId: Long) =
queryDetailQuestionService.execute(questionId)

@Operation(summary = "질문 삭제")
@ResponseStatus(HttpStatus.NO_CONTENT)
@DeleteMapping()
@DeleteMapping
fun deleteQuestion(@RequestParam(name = "question_id")questionId: Long) =
deleteQuestionService.execute(questionId)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.meogo.domain.review.presentation

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.meogo.domain.review.presentation.dto.request.ModifyReviewRequest
import org.meogo.domain.review.presentation.dto.request.ReviewRequest
import org.meogo.domain.review.service.CreateReviewService
Expand All @@ -24,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
import javax.validation.Valid

@Tag(name = "Review API")
@RestController
@RequestMapping("/review")
class ReviewController(
Expand All @@ -36,6 +39,7 @@ class ReviewController(
private val queryKeywordsService: QueryKeywordsService,
private val queryMatchService: QueryMatchService
) {
@Operation(summary = "리뷰 작성")
@PostMapping
@ResponseStatus(value = HttpStatus.CREATED)
fun create(
Expand All @@ -46,10 +50,12 @@ class ReviewController(
) =
createReviewService.execute(request, images)

@Operation(summary = "학교별 리뷰 조회")
@GetMapping("/query")
fun queryAllBySchoolId(@RequestParam(name = "school_id") schoolId: Int) =
queryAllBySchoolIdService.queryAllBySchoolId(schoolId)

@Operation(summary = "리뷰 수정")
@PatchMapping("/modify")
fun modify(
@RequestParam(name = "review_id") reviewId: Long,
Expand All @@ -58,21 +64,26 @@ class ReviewController(
) =
modifyReviewService.modifyReview(reviewId, request, images)

@Operation(summary = "리뷰 삭제")
@DeleteMapping
@ResponseStatus(value = HttpStatus.NO_CONTENT)
fun delete(@RequestParam(name = "review_id") reviewId: Long) =
deleteReviewService.deleteReview(reviewId)

@Operation(summary = "학교별 리뷰 사진 조회")
@GetMapping("/pic")
fun queryReviewPicture(@RequestParam(name = "school_id") schoolId: Int) =
queryReviewPictureService.queryReviewPicture(schoolId)

@Operation(summary = "라뷰 결과 조회")
@GetMapping("/query/result")
fun querySchoolReviewResult(@RequestParam(name = "school_id") schoolId: Int) = querySchoolReviewResultService.execute(schoolId)

@Operation(summary = "리뷰 키워드 반환")
@GetMapping("/keyword")
fun queryKeyword() = queryKeywordsService.execute()

@Operation(summary = "해당 학교인지 여부 반환")
@GetMapping("/match")
fun schoolMatch(@RequestParam(name = "school_id") schoolId: Int) =
queryMatchService.execute(schoolId)
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/org/meogo/domain/school/domain/School.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.meogo.domain.school.domain

data class School(
val id: Int,
val link: String,
val schoolGubun: String,
val adres: String,
val schoolName: String
)
5 changes: 5 additions & 0 deletions src/main/kotlin/org/meogo/domain/school/enum/Gubun.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.meogo.domain.school.enum

enum class Gubun(val value: String) {
ELEM("elem_list"), MIDD("midd_list"), HIGH("high_list"), UNIV("univ_list"), SEET("seet_list"), ETC("alte_list")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.meogo.domain.school.presentation

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.meogo.domain.school.enum.Gubun
import org.meogo.domain.school.service.QuerySchoolService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@Tag(name = "School API")
@RestController
@RequestMapping("/school")
class SchoolController(
private val querySchoolService: QuerySchoolService
) {

@Operation(summary = "학교 정보 조회")
@GetMapping
fun getSchools(
@RequestParam(name = "gubun")
gubun: Gubun,
@RequestParam(name = "region")
region: String?,
@RequestParam(name = "name")
name: String?,
@RequestParam(name = "sch1")
sch1: String?
) = querySchoolService.execute(gubun, region, name, sch1)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.meogo.domain.school.service

import org.meogo.domain.school.enum.Gubun
import org.meogo.global.feign.CareerFeignClientService
import org.springframework.stereotype.Service

@Service
class QuerySchoolService(
private val careerFeignClientService: CareerFeignClientService
) {

fun execute(gubun: Gubun, region: String?, name: String?, sch1: String?) =
careerFeignClientService.getSchoolInfo(gubun, name, region, sch1).sortedBy { it.schoolName }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.meogo.domain.user.presentation

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.meogo.domain.user.presentation.dto.request.UserCheckRequest
import org.meogo.domain.user.presentation.dto.request.UserModifyRequest
import org.meogo.domain.user.presentation.dto.request.UserSignInRequest
Expand All @@ -23,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
import javax.validation.Valid

@Tag(name = "User API")
@RestController
@RequestMapping("/user")
class UserController(
Expand All @@ -32,6 +35,7 @@ class UserController(
private val queryMyPageService: QueryMyPageService,
private val modifyUserInfoService: ModifyUserInfoService
) {
@Operation(summary = "회원가입")
@PostMapping("/signup")
@ResponseStatus(HttpStatus.CREATED)
fun signUp(
Expand All @@ -40,18 +44,22 @@ class UserController(
): TokenResponse =
userSignUpService.execute(request)

@Operation(summary = "로그인")
@PostMapping("/signin")
fun signIn(@RequestBody request: UserSignInRequest): TokenResponse =
userSignInService.execute(request)

@Operation(summary = "아이디 중복 여부 반환")
@PostMapping("/check")
fun checkAccountId(@RequestBody request: UserCheckRequest): Boolean =
userCheckAccountIdService.execute(request)

@Operation(summary = "마이페이지")
@GetMapping("/my")
fun myPage(): MyPageResponse =
queryMyPageService.execute()

@Operation(summary = "마이페이지 수정")
@PatchMapping("/modify")
fun updateProfile(
@RequestPart(name = "image")
Expand Down
Loading
Loading