diff --git a/HealthMer/src/main/java/com/minijean/healthmer/controller/TimerController.java b/HealthMer/src/main/java/com/minijean/healthmer/controller/TimerController.java index ed42255..c1602db 100644 --- a/HealthMer/src/main/java/com/minijean/healthmer/controller/TimerController.java +++ b/HealthMer/src/main/java/com/minijean/healthmer/controller/TimerController.java @@ -7,7 +7,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -23,7 +22,6 @@ import com.minijean.healthmer.model.dto.TimerRequest; import com.minijean.healthmer.model.service.TimerService; import com.minijean.healthmer.util.JwtUtil; -import com.minijean.healthmer.model.dto.SearchCondition; @RestController @RequestMapping("/api/v1/timer") @@ -35,7 +33,6 @@ public class TimerController { public TimerController(TimerService timerService, JwtUtil jtwUtil) { this.timerService = timerService; this.jtwUtil = jtwUtil; - } @GetMapping("") @@ -48,17 +45,7 @@ public ResponseEntity listAll(@RequestHeader(HttpHeaders.AUTHORIZATION) Strin return new ResponseEntity<>(list, HttpStatus.OK); } - @GetMapping("/search") - public ResponseEntity search(@ModelAttribute SearchCondition condition) { - System.out.println("안 된다"); - System.out.println(condition.toString()); - List list = timerService.searchTimer(condition); - if (list == null || list.size() == 0) { - return new ResponseEntity(HttpStatus.NO_CONTENT); - } - return new ResponseEntity<>(list, HttpStatus.OK); - } @GetMapping("/{id}") public ResponseEntity oneTimer(@PathVariable("id") long id) { @@ -122,11 +109,14 @@ public ResponseEntity listCategory(@PathVariable("id") long id) { } @PostMapping("/create") - public ResponseEntity create(@RequestBody TimerRequest timerRequest) { - + public ResponseEntity create(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorizationHeader, @RequestBody TimerRequest timerRequest) { + long userId = jtwUtil.extractUserId(authorizationHeader); + Timer timer = timerRequest.getTimer(); + timer.setUserId(userId); + timerRequest.setTimer(timer); + Timer createdTimer = timerService.createTimer(timerRequest); return new ResponseEntity<>(createdTimer, HttpStatus.CREATED); } - } diff --git a/HealthMer/src/main/resources/Mappers/TimerMapper.xml b/HealthMer/src/main/resources/Mappers/TimerMapper.xml index 3c402f4..76cce1d 100644 --- a/HealthMer/src/main/resources/Mappers/TimerMapper.xml +++ b/HealthMer/src/main/resources/Mappers/TimerMapper.xml @@ -15,15 +15,12 @@