Skip to content

Commit

Permalink
Merge pull request #8 from KEA-ACCELER/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
chromato99 authored Aug 17, 2023
2 parents eb3e1e0 + fbe691d commit 02a5cd3
Show file tree
Hide file tree
Showing 18 changed files with 760 additions and 477 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/gradle-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Gradle Test

on:
push:
branches: [ main, develop ]


jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Gradle 빌드 캐싱
id: gradle-cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Gradle 테스트
run: ./gradlew test
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ dependencies {

//Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'

//Openfeign
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '4.0.2'
}

tasks.named('test') {
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/kea/alog/issue/IssueApplication.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package kea.alog.issue;

import java.util.Collections;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;

@EnableFeignClients
@SpringBootApplication
public class IssueApplication {

public static void main(String[] args) {
SpringApplication.run(IssueApplication.class, args);
//SpringApplication.run(IssueApplication.class, args);
SpringApplication app = new SpringApplication(IssueApplication.class);
app.setDefaultProperties(Collections.singletonMap("server.port", "8084"));
app.run(args);
}

}
125 changes: 37 additions & 88 deletions src/main/java/kea/alog/issue/controller/CommentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,112 +2,61 @@

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import kea.alog.issue.config.Result;
import kea.alog.issue.controller.dto.CommentDto.*;
import kea.alog.issue.domain.comment.Comment;
import kea.alog.issue.service.CommentService;
import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/issue/comment")
@RequestMapping("/api/issue/comments")
public class CommentController {
final private CommentService commentService;

@PostMapping("/commentCreate")
public ResponseEntity<Result> createComment(@RequestBody CommentCreateOrUpdateDto commentCreateDto){
Long commentPk = commentService.createComment(commentCreateDto);
if(commentPk > 0L){
Result result = Result.builder()
.data(commentPk)
.isSuccess(true)
.message("Success Crated")
.build();
return ResponseEntity.ok().body(result);
} else {
Result result = Result.builder()
.isSuccess(false)
.message("Failed create")
.build();
return ResponseEntity.badRequest().body(result);
}
}
@Autowired
CommentService commentService;

@PutMapping("/commentUpdate/{commentPk}")
public ResponseEntity<Result> updateComment(@PathVariable Long commentPk, @RequestBody CommentCreateOrUpdateDto reqDto) {
Long updateId = commentService.updateComment(commentPk, reqDto);
if(updateId > 0L) {
Result result = Result.builder()
.data(updateId)
.isSuccess(true)
.message("Success updated")
.build();
return ResponseEntity.ok().body(result);
} else {
Result result = Result.builder()
.isSuccess(false)
.message("Failed Update")
.build();
return ResponseEntity.badRequest().body(result);
}
@Operation(summary = "댓글 생성 ")
@ApiResponse(responseCode = "200", description = "댓글 생성 성공, 실패시 null 반환")
@PostMapping("/")
public ResponseEntity<Long> createComment(@RequestBody CommentCreateRequestDto commentCreateRequestDto) {
Long commentPk = commentService.createComment(commentCreateRequestDto);
return ResponseEntity.ok(commentPk);
}

@GetMapping("/{commentPk}")
public ResponseEntity<Result> getOneComment(@PathVariable Long commentPk){
CommentDataDto rspDto = commentService.getComment(commentPk);
if(rspDto.getCommentPk() != 0L){
Result result = Result.builder()
.isSuccess(true)
.data(rspDto)
.message("불러오기 완료")
.build();
return ResponseEntity.ok().body(result);
} else {
Result result = Result.builder()
.isSuccess(false)
.message("불러오기 실패")
.build();
return ResponseEntity.badRequest().body(result);
}
@Operation(summary = "댓글 삭제")
@DeleteMapping("")
public ResponseEntity<String> commentDelete(@RequestParam Long commentPk){
String result = commentService.deleteComment(commentPk);
return ResponseEntity.ok(result);
}
@GetMapping("/{issuePk}/{currentPage}")
public ResponseEntity<Result> getListComment(@PathVariable Long issuePk, @PathVariable Long curentPage){
List<CommentDataDto> comments = commentService.getCommentList(issuePk, curentPage);
if(comments.size() > 0){
Result result = Result.builder()
.isSuccess(true)
.data(comments)
.message("불러오기 완료")
.build();
return ResponseEntity.ok().body(result);
} else {
Result result = Result.builder()
.isSuccess(false)
.message("없거나 실패함")
.build();
return ResponseEntity.badRequest().body(result);
}

@Operation(summary = "최신순으로 댓글 조회")
@GetMapping("/by/date")
public ResponseEntity<List<Comment>> commentList(@RequestParam Long issuePk,
@Parameter(description = "페이지 넘버, 디폴트 0") @RequestParam(defaultValue = "0") int page,
@Parameter(description = "페이지 사이즈, 디폴트 10") @RequestParam(defaultValue = "10") int size){
List<Comment> commentList = commentService.getCommentList(issuePk, page, size);
return ResponseEntity.ok(commentList);
}
@DeleteMapping("/commentDelete/{commentPk}")
public ResponseEntity<Result> commentDelete(@PathVariable Long commentPk){
boolean isDelete = commentService.deleteComment(commentPk);
if(isDelete){
Result result = Result.builder()
.isSuccess(true)
.message("Success Deleted")
.build();
return ResponseEntity.ok().body(result);
} else {
Result result = Result.builder()
.isSuccess(false)
.message("Failed Delete")
.build();
return ResponseEntity.badRequest().body(result);
}

@Operation(summary = "특정인이 쓴 댓글 조회")
@GetMapping("/by/author")
public ResponseEntity<List<Comment>> commentListByAuthor(@RequestParam Long issuePk, @RequestParam Long authorPk,
@Parameter(description = "페이지 넘버, 디폴트 0") @RequestParam(defaultValue = "0") int page,
@Parameter(description = "페이지 사이즈, 디폴트 10") @RequestParam(defaultValue = "10") int size){
List<Comment> commentList = commentService.getCommentListByAuthor(issuePk, authorPk, page, size);
return ResponseEntity.ok(commentList);
}




}
Loading

0 comments on commit 02a5cd3

Please sign in to comment.