-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from 7th-UMC-Hackathon-TeamV/feat/likebtn
feat : 공감 누르기 기능
- Loading branch information
Showing
6 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/banban/springboot/apiPayload/exception/handler/NewsHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package banban.springboot.apiPayload.exception.handler; | ||
|
||
import banban.springboot.apiPayload.code.BaseErrorCode; | ||
import banban.springboot.apiPayload.exception.GeneralException; | ||
|
||
public class NewsHandler extends GeneralException { | ||
public NewsHandler(BaseErrorCode errorCode) { | ||
super(errorCode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/banban/springboot/web/controller/NewsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package banban.springboot.web.controller; | ||
|
||
import banban.springboot.apiPayload.ApiResponse; | ||
import banban.springboot.domain.entity.News; | ||
import banban.springboot.service.NewsService; | ||
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.ApiResponses; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Validated | ||
@RequestMapping("/api") | ||
public class NewsController { | ||
|
||
private final NewsService newsService; | ||
|
||
// 뉴스 공감 누르기 | ||
@PostMapping("/news/{newsId}/likes") | ||
@Operation(summary = "공감 누르기 API",description = "뉴스에 공감 누르는 API입니다.") | ||
@ApiResponses({ | ||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"), | ||
}) | ||
@Parameters({ | ||
@Parameter(name = "newsId", description = "뉴스글의 ID, path variable 입니다!") | ||
}) | ||
public ApiResponse<Void> updatePromotionProject(@PathVariable(name = "newsId") Long newsId){ | ||
|
||
newsService.addNewsLike(newsId); | ||
|
||
return ApiResponse.onSuccess(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters