|
| 1 | +package com.weve.controller; |
| 2 | + |
| 3 | +import com.weve.common.api.payload.BasicResponse; |
| 4 | +import com.weve.dto.request.PostAppreciateRequest; |
| 5 | +import com.weve.dto.response.GetAppreciateListResponse; |
| 6 | +import com.weve.dto.response.GetAppreciateResponse; |
| 7 | +import com.weve.service.AppreciateService; |
| 8 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 9 | +import lombok.RequiredArgsConstructor; |
| 10 | +import lombok.extern.slf4j.Slf4j; |
| 11 | +import org.springframework.security.core.annotation.AuthenticationPrincipal; |
| 12 | +import org.springframework.security.core.userdetails.UserDetails; |
| 13 | +import org.springframework.validation.annotation.Validated; |
| 14 | +import org.springframework.web.bind.annotation.*; |
| 15 | + |
| 16 | +@RestController |
| 17 | +@RequiredArgsConstructor |
| 18 | +@Validated |
| 19 | +@Slf4j |
| 20 | +@RequestMapping("/api/appreciate") |
| 21 | +@Tag(name = "Appreciate", description = "Appreciate 관련 API입니다.") |
| 22 | +public class AppreciateController { |
| 23 | + |
| 24 | + private final AppreciateService appreciateService; |
| 25 | + |
| 26 | + // 감사인사 작성하기 |
| 27 | + @PostMapping |
| 28 | + public BasicResponse<?> postAppreciate(@AuthenticationPrincipal UserDetails userDetails, @RequestBody PostAppreciateRequest request) { |
| 29 | + |
| 30 | + String username = userDetails.getUsername(); |
| 31 | + appreciateService.postAppreciate(username, request); |
| 32 | + return BasicResponse.onSuccess(null); |
| 33 | + } |
| 34 | + |
| 35 | + // 감사편지 상세 조회 (어르신용) |
| 36 | + @GetMapping("/details") |
| 37 | + public BasicResponse<GetAppreciateResponse.SeniorVer> getAppreciate(@AuthenticationPrincipal UserDetails userDetails, @RequestParam Long worryId) { |
| 38 | + |
| 39 | + String username = userDetails.getUsername(); |
| 40 | + GetAppreciateResponse.SeniorVer response = appreciateService.getAppreciate(username, worryId); |
| 41 | + return BasicResponse.onSuccess(response); |
| 42 | + } |
| 43 | + |
| 44 | + // 감사편지 목록 조회 |
| 45 | + @GetMapping |
| 46 | + public BasicResponse<GetAppreciateListResponse> getAppreciateList(@AuthenticationPrincipal UserDetails userDetails) { |
| 47 | + |
| 48 | + String username = userDetails.getUsername(); |
| 49 | + GetAppreciateListResponse response = appreciateService.getAppreciateList(username).getResult(); |
| 50 | + return BasicResponse.onSuccess(response); |
| 51 | + } |
| 52 | +} |
0 commit comments