-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: 타이머 등록 조회 삭제 기능 추가 (삭제 기능 점검 미흡)
- Loading branch information
Showing
12 changed files
with
712 additions
and
1 deletion.
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
95 changes: 95 additions & 0 deletions
95
HealthMer/src/main/java/com/minijean/healthmer/controller/TimerController.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,95 @@ | ||
package com.minijean.healthmer.controller; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.minijean.healthmer.model.dto.HealthCategory; | ||
import com.minijean.healthmer.model.dto.Routine; | ||
import com.minijean.healthmer.model.dto.Timer; | ||
import com.minijean.healthmer.model.dto.TimerCategory; | ||
import com.minijean.healthmer.model.dto.TimerRequest; | ||
import com.minijean.healthmer.model.service.TimerService; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/timer") | ||
@CrossOrigin("http://localhost:5173") | ||
public class TimerController { | ||
|
||
private final TimerService timerService; | ||
|
||
public TimerController(TimerService timerService) { | ||
this.timerService = timerService; | ||
} | ||
|
||
@GetMapping("") | ||
public ResponseEntity<?> listAll(){ | ||
List<Timer> list = timerService.getTimerList(); | ||
|
||
if(list == null || list.size() == 0) { | ||
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); | ||
} | ||
return new ResponseEntity<>(list, HttpStatus.OK); | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
public ResponseEntity<?> deleteTimer(@PathVariable("id") long id){ | ||
|
||
System.out.println("id는" + id); | ||
boolean isDeleted = timerService.removeTimer(id); | ||
|
||
if(isDeleted) { | ||
return ResponseEntity.status(HttpStatus.OK).body("Timer deleted"); | ||
} | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Fail Delete"); | ||
} | ||
|
||
@GetMapping("/{id}/routine") | ||
public ResponseEntity<?> listRoutine(@PathVariable("id") long id){ | ||
List<Routine> list = timerService.getRoutineList(id); | ||
|
||
if(list == null || list.size() == 0) { | ||
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); | ||
} | ||
return new ResponseEntity<>(list, HttpStatus.OK); | ||
} | ||
|
||
@GetMapping("/category") | ||
public ResponseEntity<?> listCategory(){ | ||
List<HealthCategory> list = timerService.getHealthCategoryList(); | ||
|
||
if(list == null || list.size() == 0) { | ||
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); | ||
} | ||
return new ResponseEntity<>(list, HttpStatus.OK); | ||
} | ||
|
||
@GetMapping("/{id}/category") | ||
public ResponseEntity<?> listCategory(@PathVariable("id") long id){ | ||
List<TimerCategory> list = timerService.getCategoryList(id); | ||
|
||
if(list == null || list.size() == 0) { | ||
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); | ||
} | ||
return new ResponseEntity<>(list, HttpStatus.OK); | ||
} | ||
|
||
@PostMapping("/create") | ||
public ResponseEntity<Timer> create(@RequestBody TimerRequest timerRequest){ | ||
|
||
Timer createdTimer = timerService.createTimer(timerRequest); | ||
|
||
return new ResponseEntity<>(createdTimer, HttpStatus.CREATED); | ||
} | ||
|
||
} | ||
|
49 changes: 49 additions & 0 deletions
49
HealthMer/src/main/java/com/minijean/healthmer/model/dao/TimerDao.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,49 @@ | ||
package com.minijean.healthmer.model.dao; | ||
|
||
import java.util.List; | ||
|
||
import com.minijean.healthmer.model.dto.HealthCategory; | ||
import com.minijean.healthmer.model.dto.Routine; | ||
import com.minijean.healthmer.model.dto.SearchCondition; | ||
import com.minijean.healthmer.model.dto.Timer; | ||
import com.minijean.healthmer.model.dto.TimerCategory; | ||
|
||
public interface TimerDao { | ||
|
||
/** 전체 타이머 조회 */ | ||
public List<Timer> selectAll(); | ||
|
||
/** 전체 헬스 카테고리 조회 */ | ||
public List<HealthCategory> selectHealthCategory(); | ||
|
||
/** 타이머 하나의 전체 카테고리 조회 */ | ||
public List<TimerCategory> selectAllCategory(long id); | ||
|
||
/** 타이머 하나의 전체 루틴 조회 */ | ||
public List<Routine> selectAllRoutine(long id); | ||
|
||
/** 타이머 등록 */ | ||
public int insertTimer(Timer timer); | ||
|
||
/** 타이머 카테고리 등록 */ | ||
public int insertTimerCategory(List<TimerCategory> category); | ||
|
||
/** 타이머 하위 루틴 등록 */ | ||
public int insertRoutines(List<Routine> routines); | ||
|
||
/** 타이머 수정 */ | ||
public int updateTimer(Timer timer); | ||
|
||
/** 타이머 하위 루틴 수정 */ | ||
public int updateRoutines(List<Routine> routines); | ||
|
||
/** 타이머 한 개 삭제 (하위 루틴도 삭제됨) */ | ||
public int deleteTimer(long id); | ||
|
||
/** 타이머 달성치 증가 */ | ||
public void updateCompleteCount(long id); | ||
|
||
/** 검색을 통한 타이머 조회*/ | ||
public List<Timer> searchTimer(SearchCondition condition); | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
HealthMer/src/main/java/com/minijean/healthmer/model/dto/HealthCategory.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 com.minijean.healthmer.model.dto; | ||
|
||
public class HealthCategory { | ||
private long id; | ||
private String name; | ||
|
||
public HealthCategory() { | ||
|
||
} | ||
|
||
public HealthCategory(long id, String name) { | ||
super(); | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HealthCategory [id=" + id + ", name=" + name + "]"; | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
HealthMer/src/main/java/com/minijean/healthmer/model/dto/Routine.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,69 @@ | ||
package com.minijean.healthmer.model.dto; | ||
|
||
public class Routine { | ||
private long id; | ||
private long timerInfoId; | ||
private String name; | ||
private short time; | ||
private short isRest; | ||
|
||
public Routine() { | ||
|
||
} | ||
|
||
public Routine(long id, long timerInfoId, String name, short time, short isRest) { | ||
super(); | ||
this.id = id; | ||
this.timerInfoId = timerInfoId; | ||
this.name = name; | ||
this.time = time; | ||
this.isRest = isRest; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public long getTimerInfoId() { | ||
return timerInfoId; | ||
} | ||
|
||
public void setTimerInfoId(long timerInfoId) { | ||
this.timerInfoId = timerInfoId; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public short getTime() { | ||
return time; | ||
} | ||
|
||
public void setTime(short time) { | ||
this.time = time; | ||
} | ||
|
||
public short getIsRest() { | ||
return isRest; | ||
} | ||
|
||
public void setIsRest(short isRest) { | ||
this.isRest = isRest; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Routine [id=" + id + ", timerInfoId=" + timerInfoId + ", name=" + name + ", time=" + time + ", isRest=" | ||
+ isRest + "]"; | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
HealthMer/src/main/java/com/minijean/healthmer/model/dto/SearchCondition.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,59 @@ | ||
package com.minijean.healthmer.model.dto; | ||
|
||
public class SearchCondition { | ||
private String key; | ||
private String word; | ||
private String orderBy; | ||
private String orderByDir; | ||
|
||
public SearchCondition() { | ||
|
||
} | ||
|
||
public SearchCondition(String key, String word, String orderBy, String orderByDir) { | ||
super(); | ||
this.key = key; | ||
this.word = word; | ||
this.orderBy = orderBy; | ||
this.orderByDir = orderByDir; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public void setKey(String key) { | ||
this.key = key; | ||
} | ||
|
||
public String getWord() { | ||
return word; | ||
} | ||
|
||
public void setWord(String word) { | ||
this.word = word; | ||
} | ||
|
||
public String getOrderBy() { | ||
return orderBy; | ||
} | ||
|
||
public void setOrderBy(String orderBy) { | ||
this.orderBy = orderBy; | ||
} | ||
|
||
public String getOrderByDir() { | ||
return orderByDir; | ||
} | ||
|
||
public void setOrderByDir(String orderByDir) { | ||
this.orderByDir = orderByDir; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SearchCondition [key=" + key + ", word=" + word + ", orderBy=" + orderBy + ", orderByDir=" + orderByDir | ||
+ "]"; | ||
} | ||
|
||
} |
Oops, something went wrong.