-
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.
Merge pull request #49 from How-homework-out/master
Master
- Loading branch information
Showing
6 changed files
with
97 additions
and
7 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
17 changes: 17 additions & 0 deletions
17
src/main/java/inha/how/Domain/dto/calendar/CalendarAddRes.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,17 @@ | ||
package inha.how.Domain.dto.calendar; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.cglib.core.Local; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class CalendarAddRes { | ||
private LocalDate localDate; | ||
private Long routId; | ||
private Boolean check; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/inha/how/Domain/dto/calendar/CalendarModifyReq.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,13 @@ | ||
package inha.how.Domain.dto.calendar; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class CalendarModifyReq { | ||
private boolean chk; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,59 @@ | ||
package inha.how.Service; | ||
|
||
import inha.how.Config.BaseResponseStatus; | ||
import inha.how.Config.exception.BaseException; | ||
import inha.how.Domain.dto.calendar.CalendarAddRes; | ||
import inha.how.Domain.dto.calendar.CalendarInfoMapping; | ||
import inha.how.Domain.dto.calendar.CalendarModifyReq; | ||
import inha.how.Domain.entity.Calendar; | ||
import inha.how.Domain.entity.Routine; | ||
import inha.how.Domain.entity.User; | ||
import inha.how.Repository.CalendarRepository; | ||
import inha.how.Repository.Routine.RoutineRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Service | ||
public class CalendarService { | ||
private final CalendarRepository calendarRepository; | ||
private final RoutineRepository routineRepository; | ||
|
||
public List<CalendarInfoMapping> findCalendar(User user){ | ||
List<CalendarInfoMapping> calendarInfoMappingList = calendarRepository.findCalendarByUser(user); | ||
|
||
return calendarInfoMappingList; | ||
} | ||
|
||
public void CalendarAdd(){ | ||
public void CalendarAdd(User user, CalendarAddRes calendarAddRes){ | ||
Long routId= calendarAddRes.getRoutId(); | ||
LocalDate localDate=calendarAddRes.getLocalDate(); | ||
Boolean check = calendarAddRes.getCheck(); | ||
|
||
Routine routine = routineRepository.findRoutineById(routId); | ||
|
||
Calendar calendar=new Calendar(); | ||
calendar.setUser(user); | ||
calendar.setDate(localDate); | ||
calendar.setCheck(check); | ||
calendar.setRoutine(routine); | ||
|
||
calendarRepository.save(calendar); | ||
} | ||
|
||
@Transactional | ||
//modifyCalendar: 달력 체크 수정 | ||
public void modifyCalendar(Long id, CalendarModifyReq calendarModifyReq){ | ||
Calendar calendar= calendarRepository.findById(id).orElseThrow(()->new BaseException(BaseResponseStatus.CALENDAR_NOT_FOUND)); | ||
|
||
log.error("check: "+calendarModifyReq.isChk()); | ||
calendar.setCheck(calendarModifyReq.isChk()); | ||
} | ||
|
||
} |