1
1
package ttakkeun .ttakkeun_server .controller ;
2
2
3
+ import feign .Response ;
3
4
import lombok .RequiredArgsConstructor ;
4
5
import org .springframework .beans .factory .annotation .Autowired ;
5
6
import org .springframework .http .HttpStatus ;
6
7
import org .springframework .http .ResponseEntity ;
7
- import org .springframework .web .bind .annotation .GetMapping ;
8
- import org .springframework .web .bind .annotation .RequestMapping ;
9
- import org .springframework .web .bind .annotation .RequestParam ;
10
- import org .springframework .web .bind .annotation .RestController ;
8
+ import org .springframework .web .bind .annotation .*;
11
9
import ttakkeun .ttakkeun_server .apiPayLoad .ApiResponse ;
12
10
import ttakkeun .ttakkeun_server .apiPayLoad .code .status .ErrorStatus ;
13
11
import ttakkeun .ttakkeun_server .apiPayLoad .code .status .SuccessStatus ;
14
12
import ttakkeun .ttakkeun_server .dto .GetMyPointResponseDTO ;
13
+ import ttakkeun .ttakkeun_server .dto .UpdateMyPointResponseDTO ;
15
14
import ttakkeun .ttakkeun_server .service .DiagnoseService ;
16
15
17
16
import java .util .NoSuchElementException ;
@@ -26,7 +25,7 @@ public class DiagnoseController {
26
25
private DiagnoseService diagnoseService ;
27
26
28
27
// memberId 임의로 입력받아서 조회하는 방식으로 구현함
29
- // 추후 액세스 토큰으로 멤버 아이디 받아와서 조회하는 방식으로 수정 예정
28
+ // 추후 로그인 정보로 멤버 아이디 받아와서 조회하는 방식으로 수정 예정
30
29
@ GetMapping ("/point" )
31
30
public ResponseEntity <ApiResponse <GetMyPointResponseDTO >> getPointsByMember (@ RequestParam ("member-id" ) Long memberId ) {
32
31
try {
@@ -35,10 +34,25 @@ public ResponseEntity<ApiResponse<GetMyPointResponseDTO>> getPointsByMember(@Req
35
34
return ResponseEntity .ok (response );
36
35
} catch (NoSuchElementException e ) {
37
36
ApiResponse <GetMyPointResponseDTO > response = ApiResponse .ofFailure (ErrorStatus .MEMBER_NOT_FOUND , null );
38
- return ResponseEntity .status (HttpStatus .BAD_REQUEST ).body (response );
37
+ return ResponseEntity .status (HttpStatus .NOT_FOUND ).body (response );
39
38
} catch (Exception e ) {
40
39
ApiResponse <GetMyPointResponseDTO > response = ApiResponse .ofFailure (ErrorStatus ._INTERNAL_SERVER_ERROR , null );
41
40
return ResponseEntity .status (HttpStatus .INTERNAL_SERVER_ERROR ).body (response );
42
41
}
43
42
}
43
+
44
+ @ PatchMapping ("/loading" )
45
+ public ResponseEntity <ApiResponse <UpdateMyPointResponseDTO >> updatePointsByMember (@ RequestParam ("member-id" ) Long memberId ) {
46
+ try {
47
+ Integer point = diagnoseService .updatePointsByMember (memberId );
48
+ ApiResponse <UpdateMyPointResponseDTO > response = ApiResponse .of (SuccessStatus ._OK , new UpdateMyPointResponseDTO (point ));
49
+ return ResponseEntity .ok (response );
50
+ } catch (NoSuchElementException e ) {
51
+ ApiResponse <UpdateMyPointResponseDTO > response = ApiResponse .ofFailure (ErrorStatus .MEMBER_NOT_FOUND , null );
52
+ return ResponseEntity .status (HttpStatus .NOT_FOUND ).body (response );
53
+ } catch (Exception e ) {
54
+ ApiResponse <UpdateMyPointResponseDTO > response = ApiResponse .ofFailure (ErrorStatus ._INTERNAL_SERVER_ERROR , null );
55
+ return ResponseEntity .status (HttpStatus .INTERNAL_SERVER_ERROR ).body (response );
56
+ }
57
+ }
44
58
}
0 commit comments