From bc21220a5bc4e638d30cffc0316477d7837bb4ff Mon Sep 17 00:00:00 2001 From: Lee ChanMi Date: Fri, 5 May 2023 00:49:02 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feature=20:=20=EC=95=8C=EB=9E=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20api=20=EA=B5=AC=ED=98=84,=20Spring=20data?= =?UTF-8?q?=20jpa=EB=A1=9C=20=EC=A0=84=ED=99=98,=20=20mapper=EC=9D=98=20?= =?UTF-8?q?=EC=A0=84=EB=B0=98=EC=A0=81=EC=9D=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - alarmRepository, RoutineRepository, MappingAlarmRoutineRepository, MissionRepository를 raw JPA에서 Spring Data JPA 인터페이스를 상속받도록 전환 - 알람 수정 api 구현 - mapper 클래스의 메소드 통일 - GetAlarmRes, PatchAlarmRes 등의 Response DTO를 AlarmRes, PostAlarmRequest, PatchAlarmRequest 등의 Requeset DTO를 AlarmReq로 통일 - BaseResponseStatus -> ResponseStatus 이름 변경 - BaseException, GlobalExceptionHandler 위치를 common/exception으로 변경 - BaseResponse의 위치를 common/dto로 변경 - 각 도메인에 dto/response, dto/request 디렉토리 생성 후 dto 위치 이전 --- build.gradle | 4 +- .../togetUp/alarms/AlarmController.java | 69 ++++++--- .../togetUp/alarms/AlarmDao.java | 45 ------ .../togetUp/alarms/AlarmProvider.java | 68 ++++++--- .../togetUp/alarms/AlarmRepository.java | 22 +++ .../togetUp/alarms/AlarmService.java | 138 ++++++++++++++---- .../request/AlarmReq.java} | 30 ++-- .../togetUp/alarms/dto/response/AlarmRes.java | 35 +++++ .../response/AlarmsRes.java} | 8 +- .../togetUp/alarms/model/Alarm.java | 33 ++++- .../togetUp/alarms/model/PostAlarmReq.java | 33 ----- .../common/{ => dto}/BaseResponse.java | 8 +- .../common/{ => exception}/BaseException.java | 4 +- .../GlobalExceptionHandler.java | 9 +- .../ResponseStatus.java} | 6 +- .../common/interfaces/CustomRepository.java | 9 -- .../togetUp/files/FileController.java | 10 +- .../model/MappingAlarmRoutineRepository.java | 17 +++ .../togetUp/missions/MissionDao.java | 25 ---- .../togetUp/missions/MissionRepository.java | 13 ++ .../togetUp/routines/RoutineController.java | 27 ++-- .../togetUp/routines/RoutineDao.java | 48 ------ .../togetUp/routines/RoutineProvider.java | 30 ++-- .../togetUp/routines/RoutineRepository.java | 22 +++ .../togetUp/routines/RoutineService.java | 30 ++-- .../routines/dto/request/RoutineReq.java | 29 ++++ .../response/RoutineRes.java} | 4 +- .../routines/model/PostRoutineReq.java | 17 --- .../togetUp/routines/model/Routine.java | 1 - .../togetUp/users/UserController.java | 14 +- .../togetUp/utils/mappers/AlarmMapper.java | 32 ++-- .../togetUp/utils/mappers/RoutineMapper.java | 4 +- 32 files changed, 485 insertions(+), 359 deletions(-) delete mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmDao.java create mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmRepository.java rename src/main/java/com/wakeUpTogetUp/togetUp/alarms/{model/GetAlarmRes.java => dto/request/AlarmReq.java} (54%) create mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/response/AlarmRes.java rename src/main/java/com/wakeUpTogetUp/togetUp/alarms/{model/GetAlarmsRes.java => dto/response/AlarmsRes.java} (80%) delete mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/PostAlarmReq.java rename src/main/java/com/wakeUpTogetUp/togetUp/common/{ => dto}/BaseResponse.java (80%) rename src/main/java/com/wakeUpTogetUp/togetUp/common/{ => exception}/BaseException.java (73%) rename src/main/java/com/wakeUpTogetUp/togetUp/common/{ => exception}/GlobalExceptionHandler.java (88%) rename src/main/java/com/wakeUpTogetUp/togetUp/common/{BaseResponseStatus.java => exception/ResponseStatus.java} (91%) delete mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/common/interfaces/CustomRepository.java create mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/mappingAlarmRoutine/model/MappingAlarmRoutineRepository.java delete mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/missions/MissionDao.java create mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/missions/MissionRepository.java delete mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineDao.java create mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineRepository.java create mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/routines/dto/request/RoutineReq.java rename src/main/java/com/wakeUpTogetUp/togetUp/routines/{model/GetRoutineRes.java => dto/response/RoutineRes.java} (77%) delete mode 100644 src/main/java/com/wakeUpTogetUp/togetUp/routines/model/PostRoutineReq.java diff --git a/build.gradle b/build.gradle index eb7d7a63..cad51bd5 100644 --- a/build.gradle +++ b/build.gradle @@ -42,8 +42,8 @@ dependencies { implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.0.0' // model struct - implementation 'org.mapstruct:mapstruct:1.4.1.Final' - annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.1.Final' + implementation 'org.mapstruct:mapstruct:1.5.4.Final' + annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.4.Final' // security implementation('org.springframework.boot:spring-boot-starter-security') diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmController.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmController.java index 820940a9..b8fa6f2b 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmController.java @@ -1,10 +1,10 @@ package com.wakeUpTogetUp.togetUp.alarms; -import com.wakeUpTogetUp.togetUp.alarms.model.GetAlarmRes; -import com.wakeUpTogetUp.togetUp.alarms.model.GetAlarmsRes; -import com.wakeUpTogetUp.togetUp.alarms.model.PostAlarmReq; -import com.wakeUpTogetUp.togetUp.common.BaseResponse; -import com.wakeUpTogetUp.togetUp.common.BaseResponseStatus; +import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmRes; +import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmsRes; +import com.wakeUpTogetUp.togetUp.alarms.dto.request.AlarmReq; +import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; +import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @@ -18,34 +18,67 @@ public class AlarmController { private final AlarmService alarmService; private final AlarmProvider alarmProvider; - // 알람 1개 불러오기 + /** + * 알람 1개 불러오기 + * @param userId + * @param alarmId + * @return + */ @GetMapping("{userId}/alarms/{alarmId}") - public BaseResponse GetAlarm(@PathVariable Integer userId, @PathVariable Integer alarmId){ - GetAlarmRes getAlarmRes = alarmProvider.getAlarm(alarmId); + public BaseResponse GetAlarm(@PathVariable Integer userId, @PathVariable Integer alarmId){ + AlarmRes alarmRes = alarmProvider.getAlarm(alarmId); - return new BaseResponse<>(BaseResponseStatus.SUCCESS, getAlarmRes); + return new BaseResponse<>(ResponseStatus.SUCCESS, alarmRes); } - // 사용자 알람, 루틴 목록 불러오기 + /** + * 사용자 알람, 루틴 목록 불러오기 + * @param userId + * @return + */ @GetMapping("{userId}/alarms") - public BaseResponse> GetAlarmsByUserId(@PathVariable Integer userId){ - List getAlarmsResList = alarmProvider.getAlarmsByUserId(userId); + public BaseResponse> GetAlarmsByUserId(@PathVariable Integer userId){ + List alarmsResList = alarmProvider.getAlarmsByUserId(userId); - return new BaseResponse<>(BaseResponseStatus.SUCCESS, getAlarmsResList); + return new BaseResponse<>(ResponseStatus.SUCCESS, alarmsResList); } - // 알람 생성(알람, 알람-루틴 매핑) + /** + * 알람 생성(알람, 알람-루틴 매핑) + * @param userId + * @param alarmReq + * @return + */ @PostMapping("/{userId}/alarms") public BaseResponse createAlarm( @PathVariable("userId") Integer userId, - @RequestBody @Valid PostAlarmReq postAlarmReq + @RequestBody @Valid AlarmReq alarmReq ){ //TODO : jwt 정보와 일치하는지 확인하기 - int createdAlarmId = alarmService.createAlarm(userId, postAlarmReq); + Integer createdAlarmId = alarmService.createAlarm(userId, alarmReq); - return new BaseResponse(BaseResponseStatus.SUCCESS, createdAlarmId); + return new BaseResponse(ResponseStatus.SUCCESS, createdAlarmId); + } + + /** + * 알람 수정 + * @param userId + * @param alarmId + * @param patchAlarmReq + * @return + */ + @PatchMapping("{userId}/alarms/{alarmId}") + public BaseResponse updateAlarm( + @PathVariable Integer userId, + @PathVariable Integer alarmId, + @RequestBody @Valid AlarmReq patchAlarmReq + ) { + // TODO : JWT + + AlarmRes patchAlarmRes = alarmService.updateAlarm(userId, alarmId, patchAlarmReq); + + return new BaseResponse<>(ResponseStatus.SUCCESS, patchAlarmRes); } -// 알람 수정 // 알람 삭제 } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmDao.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmDao.java deleted file mode 100644 index c28795c2..00000000 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmDao.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.wakeUpTogetUp.togetUp.alarms; - -import com.wakeUpTogetUp.togetUp.alarms.model.Alarm; -import com.wakeUpTogetUp.togetUp.alarms.model.GetAlarmRes; -import com.wakeUpTogetUp.togetUp.alarms.model.GetAlarmsRes; -import com.wakeUpTogetUp.togetUp.alarms.model.MappingAlarmRoutine; -import com.wakeUpTogetUp.togetUp.common.interfaces.CustomRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Repository; - -import javax.persistence.EntityManager; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -@Repository -@RequiredArgsConstructor -public class AlarmDao implements CustomRepository { - private final EntityManager em; - - // 알람 저장 - @Override - public void save(Alarm alarm) { - em.persist(alarm); - } - - // 매핑 알람-루틴 저장 - public void save(MappingAlarmRoutine mappingAlarmRoutine) { - em.persist(mappingAlarmRoutine); - } - - @Override - public Optional findById(Integer id) { - Alarm alarm = em.find(Alarm.class, id); - return Optional.ofNullable(alarm); - } - - public Optional> findByUserId(Integer userId) { - List alarmList = em.createQuery("select a from Alarm a where a.user.id = :userId", Alarm.class) - .setParameter("userId", userId) - .getResultList(); - - return Optional.ofNullable(alarmList); - } -} diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmProvider.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmProvider.java index 00741687..5629fdae 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmProvider.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmProvider.java @@ -1,12 +1,12 @@ package com.wakeUpTogetUp.togetUp.alarms; import com.wakeUpTogetUp.togetUp.alarms.model.Alarm; -import com.wakeUpTogetUp.togetUp.alarms.model.GetAlarmRes; -import com.wakeUpTogetUp.togetUp.alarms.model.GetAlarmsRes; -import com.wakeUpTogetUp.togetUp.common.BaseException; -import com.wakeUpTogetUp.togetUp.common.BaseResponseStatus; -import com.wakeUpTogetUp.togetUp.routines.RoutineDao; -import com.wakeUpTogetUp.togetUp.routines.model.GetRoutineRes; +import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmRes; +import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmsRes; +import com.wakeUpTogetUp.togetUp.common.exception.BaseException; +import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.routines.RoutineRepository; +import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; import com.wakeUpTogetUp.togetUp.routines.model.Routine; import com.wakeUpTogetUp.togetUp.utils.mappers.AlarmMapper; import com.wakeUpTogetUp.togetUp.utils.mappers.RoutineMapper; @@ -19,41 +19,63 @@ @Service @RequiredArgsConstructor public class AlarmProvider { - private final AlarmDao alarmDao; - private final RoutineDao routineDao; + private final AlarmRepository alarmRepository; + private final RoutineRepository routineRepository; - public List getAlarmsByUserId(Integer userId) { - List alarmList = alarmDao.findByUserId(userId) + /** + * 유저 아이디로 알람 리스트 가져오기 + * @param userId + * @return + */ + public List getAlarmsByUserId(Integer userId) { + List alarmList = alarmRepository.findByUserId(userId) .orElseThrow( - () -> new BaseException(BaseResponseStatus.ALARM_NOT_FOUND) + () -> new BaseException(ResponseStatus.ALARM_NOT_FOUND) ); - ArrayList getAlarmsResList = new ArrayList<>(); + // dto 매핑 + ArrayList alarmsResList = new ArrayList<>(); for(Alarm alarm : alarmList) { - getAlarmsResList.add(AlarmMapper.INSTANCE.entityToGetAlarmsRes(alarm)); + alarmsResList.add(AlarmMapper.INSTANCE.toAlarmsRes(alarm)); } - return getAlarmsResList; + return alarmsResList; } - public GetAlarmRes getAlarm(Integer alarmId) { + /** + * 알람 아이디로 알람 가져오기 + * @param alarmId + * @return + */ + public AlarmRes getAlarm(Integer alarmId) { // 알람 가져오기 - Alarm alarm = alarmDao.findById(alarmId) + Alarm alarm = alarmRepository.findById(alarmId) .orElseThrow( - () -> new BaseException(BaseResponseStatus.INVALID_ALARM_ID) + () -> new BaseException(ResponseStatus.INVALID_ALARM_ID) ); // 루틴 리스트 가져오기 // 하나도 존재하지 않아도 됨 - List routineList = routineDao.findByAlarmId(alarmId).orElseGet(() -> null); + List routineResList = getRoutineResByAlarmId(alarmId); - ArrayList getRoutineResList = new ArrayList<>(); + AlarmRes alarmRes = AlarmMapper.INSTANCE.toAlarmRes(alarm, routineResList); + + return alarmRes; + } + + /** + * alarmId로 routineRes 리스트 가져오기 + * @param alarmId + * @return + */ + public List getRoutineResByAlarmId(Integer alarmId){ + List routineList = routineRepository.findByAlarmId(alarmId).orElseGet(() -> null); + + ArrayList routineResList = new ArrayList<>(); for(Routine routine : routineList) { - getRoutineResList.add(RoutineMapper.INSTANCE.entityToGetRoutineRes(routine)); + routineResList.add(RoutineMapper.INSTANCE.entityToGetRoutineRes(routine)); } - GetAlarmRes getAlarmRes = AlarmMapper.INSTANCE.entityToGetAlarmRes(alarm, getRoutineResList); - - return getAlarmRes; + return routineResList; } } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmRepository.java new file mode 100644 index 00000000..b4cdeb8a --- /dev/null +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmRepository.java @@ -0,0 +1,22 @@ +package com.wakeUpTogetUp.togetUp.alarms; + +import com.wakeUpTogetUp.togetUp.alarms.model.Alarm; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface AlarmRepository extends JpaRepository { + @Override + S save(S entity); + + @Override + Optional findById(Integer id); + + @Query("select a from Alarm a where a.user.id = :userId") + Optional> findByUserId(@Param(value = "userId") Integer userId); +} diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmService.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmService.java index a03a104b..a7a76888 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmService.java @@ -1,31 +1,44 @@ package com.wakeUpTogetUp.togetUp.alarms; +import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmRes; import com.wakeUpTogetUp.togetUp.alarms.model.Alarm; import com.wakeUpTogetUp.togetUp.alarms.model.MappingAlarmRoutine; -import com.wakeUpTogetUp.togetUp.alarms.model.PostAlarmReq; -import com.wakeUpTogetUp.togetUp.common.BaseException; -import com.wakeUpTogetUp.togetUp.common.BaseResponseStatus; -import com.wakeUpTogetUp.togetUp.routines.RoutineDao; +import com.wakeUpTogetUp.togetUp.alarms.dto.request.AlarmReq; +import com.wakeUpTogetUp.togetUp.common.exception.BaseException; +import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.mappingAlarmRoutine.model.MappingAlarmRoutineRepository; +import com.wakeUpTogetUp.togetUp.routines.RoutineRepository; +import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; import com.wakeUpTogetUp.togetUp.routines.model.Routine; import com.wakeUpTogetUp.togetUp.users.UserRepository; import com.wakeUpTogetUp.togetUp.users.model.User; +import com.wakeUpTogetUp.togetUp.utils.mappers.AlarmMapper; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import javax.transaction.Transactional; +import java.util.List; @Service @RequiredArgsConstructor public class AlarmService { - private final AlarmDao alarmDao; - private final RoutineDao routineDao; + private final AlarmProvider alarmProvider; + private final AlarmRepository alarmRepository; + private final RoutineRepository routineRepository; private final UserRepository userRepository; + private final MappingAlarmRoutineRepository mappingAlarmRoutineRepository; + + /** + * 알람 생성 + * @param userId + * @param postAlarmReq + * @return + */ @Transactional - // TODO : create Alarm 테스트해봐야함 - public int createAlarm(Integer userId, PostAlarmReq postAlarmReq) { + public int createAlarm(Integer userId, AlarmReq postAlarmReq) { User user = userRepository.findById(userId) .orElseThrow( - () -> new BaseException(BaseResponseStatus.INVALID_USER_ID) + () -> new BaseException(ResponseStatus.INVALID_USER_ID) ); Alarm alarm = Alarm.builder() @@ -49,29 +62,96 @@ public int createAlarm(Integer userId, PostAlarmReq postAlarmReq) { .sunday(postAlarmReq.getSunday()) .build(); - alarmDao.save(alarm); - - int alarmId = alarm.getId(); - int i=1; + alarmRepository.save(alarm); // 루틴 리스트가 있으면 if(postAlarmReq.getRoutineIdList() != null) { - // 매핑 알람-루틴 생성 - for(Integer routineId : postAlarmReq.getRoutineIdList()) { - Routine routine = routineDao.findById(routineId) - .orElseThrow( - () -> new BaseException(BaseResponseStatus.INVALID_ROUTINE_ID) - ); - MappingAlarmRoutine mappingAlarmRoutine = MappingAlarmRoutine.builder() - .user(user) - .alarm(alarm) - .routine(routine) - .routineOrder(i) - .build(); - alarmDao.save(mappingAlarmRoutine); - i++; - } + // 매핑 알람 루틴 생성 + createMappingAlarmRoutineList(postAlarmReq, alarm); + } + + return alarm.getId(); + } + + /** + * 알람 수정 + * @param userId + * @param alarmId + * @param patchAlarmReq + * @return + */ + @Transactional + public AlarmRes updateAlarm(Integer userId, Integer alarmId, AlarmReq patchAlarmReq) { + // 추가 값 설정 + patchAlarmReq.setUserId(userId); + patchAlarmReq.setId(alarmId); + + // 알람 수정 + Alarm alarm = alarmRepository.findById(alarmId) + .orElseThrow( + () -> new BaseException(ResponseStatus.INVALID_ALARM_ID) + ); + + alarm.modifyProperties( + patchAlarmReq.getName(), + patchAlarmReq.getIcon(), + patchAlarmReq.getSound(), + patchAlarmReq.getVolume(), + patchAlarmReq.getIsVibrate(), + patchAlarmReq.getIsRoutineOn(), + patchAlarmReq.getSnoozeInterval(), + patchAlarmReq.getSnoozeCnt(), + patchAlarmReq.getStartHour(), + patchAlarmReq.getStartMinute(), + patchAlarmReq.getMonday(), + patchAlarmReq.getTuesday(), + patchAlarmReq.getWednesday(), + patchAlarmReq.getThursday(), + patchAlarmReq.getFriday(), + patchAlarmReq.getSaturday(), + patchAlarmReq.getSunday() + ); + Alarm alarmModified = alarmRepository.save(alarm); + + // 루틴 리스트 수정 + // 연관된 매핑 루틴 리스트 삭제 + mappingAlarmRoutineRepository.deleteByAlarmId(alarmId); + + // 매핑 루틴 리스트 재생성 + createMappingAlarmRoutineList(patchAlarmReq, alarmModified); + + // routine response 리스트 가져오기 + List routineResList = alarmProvider.getRoutineResByAlarmId(alarmId); + + AlarmRes alarmRes = AlarmMapper.INSTANCE.toAlarmRes(alarmModified, routineResList); + + // return + return alarmRes; + } + + /** + * 매핑 알람 루틴 리스트 생성하기 + * @param alarmReq + * @param alarm + */ + protected void createMappingAlarmRoutineList(AlarmReq alarmReq, Alarm alarm){ + int i=1; + + // 매핑 알람-루틴 생성 + for(Integer routineId : alarmReq.getRoutineIdList()) { + Routine routine = routineRepository.findById(routineId) + .orElseThrow( + () -> new BaseException(ResponseStatus.INVALID_ROUTINE_ID) + ); + MappingAlarmRoutine mappingAlarmRoutine = MappingAlarmRoutine.builder() + .user(alarm.getUser()) + .alarm(alarm) + .routine(routine) + .routineOrder(i) + .build(); + + mappingAlarmRoutineRepository.save(mappingAlarmRoutine); + i++; } - return alarmId; } } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/GetAlarmRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/request/AlarmReq.java similarity index 54% rename from src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/GetAlarmRes.java rename to src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/request/AlarmReq.java index 0c0d3eb7..70138bf3 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/GetAlarmRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/request/AlarmReq.java @@ -1,20 +1,19 @@ -package com.wakeUpTogetUp.togetUp.alarms.model; +package com.wakeUpTogetUp.togetUp.alarms.dto.request; -import com.wakeUpTogetUp.togetUp.routines.model.GetRoutineRes; -import com.wakeUpTogetUp.togetUp.routines.model.Routine; import lombok.*; +import javax.persistence.Access; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Null; import java.util.List; @Getter @Setter -@Builder @NoArgsConstructor -@AllArgsConstructor -public class GetAlarmRes { - public GetAlarmRes(Integer id, Integer userId, String name, String icon, String sound, int volume, Boolean isVibrate, Boolean isRoutineOn, Integer snoozeInterval, Integer snoozeCnt, String startHour, String startMinute, Boolean monday, Boolean tuesday, Boolean wednesday, Boolean thursday, Boolean friday, Boolean saturday, Boolean sunday, Boolean isActivated) { - this.id = id; - this.userId = userId; +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class AlarmReq { + @Builder + public AlarmReq(String name, String icon, String sound, Integer volume, Boolean isVibrate, Boolean isRoutineOn, Integer snoozeInterval, Integer snoozeCnt, Integer startHour, Integer startMinute, Boolean monday, Boolean tuesday, Boolean wednesday, Boolean thursday, Boolean friday, Boolean saturday, Boolean sunday, List routineIdList) { this.name = name; this.icon = icon; this.sound = sound; @@ -32,21 +31,23 @@ public GetAlarmRes(Integer id, Integer userId, String name, String icon, String this.friday = friday; this.saturday = saturday; this.sunday = sunday; - this.isActivated = isActivated; + this.routineIdList = routineIdList; } + @Null private Integer id; private Integer userId; + @NotBlank(message = "알람 이름은 공백일 수 없습니다.") private String name; private String icon; private String sound; - private int volume; + private Integer volume; private Boolean isVibrate; private Boolean isRoutineOn; private Integer snoozeInterval; private Integer snoozeCnt; - private String startHour; - private String startMinute; + private Integer startHour; + private Integer startMinute; private Boolean monday; private Boolean tuesday; private Boolean wednesday; @@ -54,6 +55,5 @@ public GetAlarmRes(Integer id, Integer userId, String name, String icon, String private Boolean friday; private Boolean saturday; private Boolean sunday; - private Boolean isActivated; - private List getRoutineResList; + private List routineIdList; // 알람에 등록할 루틴 리스트 } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/response/AlarmRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/response/AlarmRes.java new file mode 100644 index 00000000..c91c8f44 --- /dev/null +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/response/AlarmRes.java @@ -0,0 +1,35 @@ +package com.wakeUpTogetUp.togetUp.alarms.dto.response; + +import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; +import lombok.*; + +import java.util.List; + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AlarmRes { + private Integer id; + private Integer userId; + private String name; + private String icon; + private String sound; + private int volume; + private Boolean isVibrate; + private Boolean isRoutineOn; + private Integer snoozeInterval; + private Integer snoozeCnt; + private Integer startHour; + private Integer startMinute; + private Boolean monday; + private Boolean tuesday; + private Boolean wednesday; + private Boolean thursday; + private Boolean friday; + private Boolean saturday; + private Boolean sunday; + private Boolean isActivated; + private List routineResList; +} diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/GetAlarmsRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/response/AlarmsRes.java similarity index 80% rename from src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/GetAlarmsRes.java rename to src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/response/AlarmsRes.java index 132bc8d3..066a205c 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/GetAlarmsRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/dto/response/AlarmsRes.java @@ -1,4 +1,4 @@ -package com.wakeUpTogetUp.togetUp.alarms.model; +package com.wakeUpTogetUp.togetUp.alarms.dto.response; import lombok.*; @@ -7,7 +7,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class GetAlarmsRes { +public class AlarmsRes { private Integer id; private Integer userId; private String name; @@ -18,8 +18,8 @@ public class GetAlarmsRes { private Boolean isRoutineOn; private Integer snoozeInterval; private Integer snoozeCnt; - private String startHour; - private String startMinute; + private Integer startHour; + private Integer startMinute; private Boolean monday; private Boolean tuesday; private Boolean wednesday; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/Alarm.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/Alarm.java index c6db9c18..beaa5f81 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/Alarm.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/Alarm.java @@ -13,8 +13,12 @@ @NoArgsConstructor @DynamicInsert // insert 시 값이 null인 필드 제외 public class Alarm { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + @Builder - public Alarm(User user, String name, String icon, String sound, Integer volume, Boolean isVibrate, Boolean isRoutineOn, Integer snoozeInterval, Integer snoozeCnt, String startHour, String startMinute, Boolean monday, Boolean tuesday, Boolean wednesday, Boolean thursday, Boolean friday, Boolean saturday, Boolean sunday) { + private Alarm(User user, String name, String icon, String sound, Integer volume, Boolean isVibrate, Boolean isRoutineOn, Integer snoozeInterval, Integer snoozeCnt, Integer startHour, Integer startMinute, Boolean monday, Boolean tuesday, Boolean wednesday, Boolean thursday, Boolean friday, Boolean saturday, Boolean sunday) { this.user = user; this.name = name; this.icon = icon; @@ -35,9 +39,26 @@ public Alarm(User user, String name, String icon, String sound, Integer volume, this.sunday = sunday; } - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; + // TODO : 접근제어자를 public으로 두는게 맞나? + public void modifyProperties(String name, String icon, String sound, Integer volume, Boolean isVibrate, Boolean isRoutineOn, Integer snoozeInterval, Integer snoozeCnt, Integer startHour, Integer startMinute, Boolean monday, Boolean tuesday, Boolean wednesday, Boolean thursday, Boolean friday, Boolean saturday, Boolean sunday) { + this.name = name; + this.icon = icon; + this.sound = sound; + this.volume = volume; + this.isVibrate = isVibrate; + this.isRoutineOn = isRoutineOn; + this.snoozeInterval = snoozeInterval; + this.snoozeCnt = snoozeCnt; + this.startHour = startHour; + this.startMinute = startMinute; + this.monday = monday; + this.tuesday = tuesday; + this.wednesday = wednesday; + this.thursday = thursday; + this.friday = friday; + this.saturday = saturday; + this.sunday = sunday; + } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "userId") private User user; @@ -49,8 +70,8 @@ public Alarm(User user, String name, String icon, String sound, Integer volume, private Boolean isRoutineOn; private Integer snoozeInterval; private Integer snoozeCnt; - private String startHour; - private String startMinute; + private Integer startHour; + private Integer startMinute; private Boolean monday; private Boolean tuesday; private Boolean wednesday; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/PostAlarmReq.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/PostAlarmReq.java deleted file mode 100644 index a7b60973..00000000 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/model/PostAlarmReq.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.wakeUpTogetUp.togetUp.alarms.model; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import java.util.List; - -@Getter -@Setter -@NoArgsConstructor -public class PostAlarmReq { - @NotBlank(message = "알람 이름은 공백일 수 없습니다.") - private String name; - private String icon; - private String sound; - private int volume; - private Boolean isVibrate; - private Boolean isRoutineOn; - private int snoozeInterval; - private int snoozeCnt; - private String startHour; - private String startMinute; - private Boolean monday; - private Boolean tuesday; - private Boolean wednesday; - private Boolean thursday; - private Boolean friday; - private Boolean saturday; - private Boolean sunday; - private List routineIdList; // 알람에 등록할 루틴 리스트 -} diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/BaseResponse.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java similarity index 80% rename from src/main/java/com/wakeUpTogetUp/togetUp/common/BaseResponse.java rename to src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java index 65ee12f3..51dfb771 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/BaseResponse.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java @@ -1,7 +1,9 @@ -package com.wakeUpTogetUp.togetUp.common; +package com.wakeUpTogetUp.togetUp.common.dto; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.wakeUpTogetUp.togetUp.common.exception.BaseException; +import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; import lombok.Getter; @Getter @@ -14,14 +16,14 @@ public class BaseResponse { private T result; // result 없을 시 - public BaseResponse(BaseResponseStatus status) { + public BaseResponse(ResponseStatus status) { this.httpStatusCode = status.getHttpStatus().value(); this.httpReasonPhrase = status.getHttpStatus().getReasonPhrase(); this.message = status.getMessage(); } // result 있을 시 - public BaseResponse(BaseResponseStatus status, T result) { + public BaseResponse(ResponseStatus status, T result) { this.httpStatusCode = status.getHttpStatus().value(); this.httpReasonPhrase = status.getHttpStatus().getReasonPhrase(); this.message = status.getMessage(); diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/BaseException.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/BaseException.java similarity index 73% rename from src/main/java/com/wakeUpTogetUp/togetUp/common/BaseException.java rename to src/main/java/com/wakeUpTogetUp/togetUp/common/exception/BaseException.java index a95ae902..5a674fb6 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/BaseException.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/BaseException.java @@ -1,4 +1,4 @@ -package com.wakeUpTogetUp.togetUp.common; +package com.wakeUpTogetUp.togetUp.common.exception; import lombok.AllArgsConstructor; import lombok.Getter; @@ -9,5 +9,5 @@ @Setter @AllArgsConstructor public class BaseException extends RuntimeException { - private BaseResponseStatus status; + private ResponseStatus status; } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/GlobalExceptionHandler.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/GlobalExceptionHandler.java similarity index 88% rename from src/main/java/com/wakeUpTogetUp/togetUp/common/GlobalExceptionHandler.java rename to src/main/java/com/wakeUpTogetUp/togetUp/common/exception/GlobalExceptionHandler.java index 079ab946..a80e6604 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/GlobalExceptionHandler.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/GlobalExceptionHandler.java @@ -1,6 +1,7 @@ -package com.wakeUpTogetUp.togetUp.common; +package com.wakeUpTogetUp.togetUp.common.exception; //import org.hibernate.TypeMismatchException; +import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.converter.HttpMessageNotReadableException; @@ -40,7 +41,7 @@ protected BaseResponse handleBadRequestException(Exception exception) { exception.getMessage(), exception); - return new BaseResponse<>(BaseResponseStatus.BAD_REQUEST); + return new BaseResponse<>(ResponseStatus.BAD_REQUEST); } // vallidation @@ -48,7 +49,7 @@ protected BaseResponse handleBadRequestException(Exception exception) { protected BaseResponse validException(MethodArgumentNotValidException exception) { String msg = "유효성 검사 실패 : " + exception.getBindingResult().getAllErrors().get(0).getDefaultMessage(); - return new BaseResponse(BaseResponseStatus.BAD_REQUEST, msg); + return new BaseResponse(ResponseStatus.BAD_REQUEST, msg); } // Catch all Exception @@ -58,6 +59,6 @@ protected BaseResponse handleServerException(Exception exception) { exception.getMessage(), exception); - return new BaseResponse<>(BaseResponseStatus.INTERNAL_SERVER_ERROR); + return new BaseResponse<>(ResponseStatus.INTERNAL_SERVER_ERROR); } } \ No newline at end of file diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/BaseResponseStatus.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/ResponseStatus.java similarity index 91% rename from src/main/java/com/wakeUpTogetUp/togetUp/common/BaseResponseStatus.java rename to src/main/java/com/wakeUpTogetUp/togetUp/common/exception/ResponseStatus.java index 70ba3d63..92150487 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/BaseResponseStatus.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/ResponseStatus.java @@ -1,4 +1,4 @@ -package com.wakeUpTogetUp.togetUp.common; +package com.wakeUpTogetUp.togetUp.common.exception; import lombok.Getter; import org.springframework.http.HttpStatus; @@ -7,7 +7,7 @@ * 에러 코드 관리 */ @Getter -public enum BaseResponseStatus { +public enum ResponseStatus { /** * 200번대(성공) */ @@ -56,7 +56,7 @@ public enum BaseResponseStatus { private final HttpStatus httpStatus; private final String message; - private BaseResponseStatus(HttpStatus httpStatus, String message) { + private ResponseStatus(HttpStatus httpStatus, String message) { this.httpStatus = httpStatus; this.message = message; } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/interfaces/CustomRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/interfaces/CustomRepository.java deleted file mode 100644 index d9548904..00000000 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/interfaces/CustomRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.wakeUpTogetUp.togetUp.common.interfaces; - -import java.util.Optional; - -public interface CustomRepository { - public void save(T object); - - public Optional findById(Integer id); -} \ No newline at end of file diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/files/FileController.java b/src/main/java/com/wakeUpTogetUp/togetUp/files/FileController.java index 996bb5d3..49bbea53 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/files/FileController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/files/FileController.java @@ -3,9 +3,9 @@ import java.util.List; -import com.wakeUpTogetUp.togetUp.common.BaseException; -import com.wakeUpTogetUp.togetUp.common.BaseResponse; -import com.wakeUpTogetUp.togetUp.common.BaseResponseStatus; +import com.wakeUpTogetUp.togetUp.common.exception.BaseException; +import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; +import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -53,9 +53,9 @@ public BaseResponse deleteFile(@RequestParam(value = "fileName") String String result = fileService.deleteFile(fileName); if(result.equals("delete process success")) { - return new BaseResponse<>(BaseResponseStatus.SUCCESS); + return new BaseResponse<>(ResponseStatus.SUCCESS); } else { - return new BaseResponse<>(new BaseException(BaseResponseStatus.FILE_NOT_FOUND)); + return new BaseResponse<>(new BaseException(ResponseStatus.FILE_NOT_FOUND)); } } } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/mappingAlarmRoutine/model/MappingAlarmRoutineRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/mappingAlarmRoutine/model/MappingAlarmRoutineRepository.java new file mode 100644 index 00000000..7e4dbd94 --- /dev/null +++ b/src/main/java/com/wakeUpTogetUp/togetUp/mappingAlarmRoutine/model/MappingAlarmRoutineRepository.java @@ -0,0 +1,17 @@ +package com.wakeUpTogetUp.togetUp.mappingAlarmRoutine.model; + +import com.wakeUpTogetUp.togetUp.alarms.model.MappingAlarmRoutine; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +public interface MappingAlarmRoutineRepository extends JpaRepository { + @Override + S save(S entity); + + // 알람 아이디로 삭제 + @Modifying + @Query("DELETE FROM MappingAlarmRoutine mar where mar.alarm.id = :alarmId") + void deleteByAlarmId(@Param(value = "alarmId") Integer alarmId); +} diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/missions/MissionDao.java b/src/main/java/com/wakeUpTogetUp/togetUp/missions/MissionDao.java deleted file mode 100644 index 85f3de3f..00000000 --- a/src/main/java/com/wakeUpTogetUp/togetUp/missions/MissionDao.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.wakeUpTogetUp.togetUp.missions; - -import com.wakeUpTogetUp.togetUp.common.interfaces.CustomRepository; -import com.wakeUpTogetUp.togetUp.missions.model.Mission; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Repository; - -import javax.persistence.EntityManager; -import java.util.Optional; - -@Repository -@RequiredArgsConstructor -public class MissionDao implements CustomRepository { - private final EntityManager em; - @Override - public void save(Mission mission) { - em.persist(mission); - } - - @Override - public Optional findById(Integer id) { - Mission mission = em.find(Mission.class, id); - return Optional.ofNullable(mission); - } -} diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/missions/MissionRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/missions/MissionRepository.java new file mode 100644 index 00000000..2ca985fb --- /dev/null +++ b/src/main/java/com/wakeUpTogetUp/togetUp/missions/MissionRepository.java @@ -0,0 +1,13 @@ +package com.wakeUpTogetUp.togetUp.missions; + +import com.wakeUpTogetUp.togetUp.missions.model.Mission; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface MissionRepository extends JpaRepository { + @Override + Optional findById(Integer id); +} diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineController.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineController.java index 08807260..41b5d28c 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineController.java @@ -1,12 +1,13 @@ package com.wakeUpTogetUp.togetUp.routines; -import com.wakeUpTogetUp.togetUp.common.BaseResponse; -import com.wakeUpTogetUp.togetUp.common.BaseResponseStatus; -import com.wakeUpTogetUp.togetUp.routines.model.GetRoutineRes; -import com.wakeUpTogetUp.togetUp.routines.model.PostRoutineReq; +import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; +import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; +import com.wakeUpTogetUp.togetUp.routines.dto.request.RoutineReq; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; import java.util.List; @RestController @@ -18,32 +19,32 @@ public class RoutineController { // 루틴 1개 가져오기 @GetMapping("{userId}/routines/{routineId}") - public BaseResponse getRoutine( + public BaseResponse getRoutine( @PathVariable("userId") Integer userId, @PathVariable("routineId") Integer routineId ) { - GetRoutineRes getRoutineRes = routineProvider.getRoutine(routineId); + RoutineRes routineRes = routineProvider.getRoutine(routineId); - return new BaseResponse<>(BaseResponseStatus.SUCCESS, getRoutineRes); + return new BaseResponse<>(ResponseStatus.SUCCESS, routineRes); } // 루틴 목록 가져오기 @GetMapping("{userId}/routines") - public BaseResponse> getRoutinesByUserId(@PathVariable Integer userId) { - List getRoutineResList = routineProvider.getRoutinesByUserId(userId); + public BaseResponse> getRoutinesByUserId(@PathVariable Integer userId) { + List routineResList = routineProvider.getRoutinesByUserId(userId); - return new BaseResponse<>(BaseResponseStatus.SUCCESS, getRoutineResList); + return new BaseResponse<>(ResponseStatus.SUCCESS, routineResList); } // 루틴 생성 @PostMapping("{userId}/routines") public BaseResponse createRoutine( @PathVariable("userId") Integer userId, - @RequestBody PostRoutineReq postRoutineReq + @RequestBody @Valid RoutineReq routineReq ) { - Integer createdRoutineId = routineService.createRoutine(userId, postRoutineReq); + Integer createdRoutineId = routineService.createRoutine(userId, routineReq); - return new BaseResponse(BaseResponseStatus.SUCCESS, createdRoutineId); + return new BaseResponse(ResponseStatus.SUCCESS, createdRoutineId); } // 루틴 수정 diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineDao.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineDao.java deleted file mode 100644 index 4df64a6e..00000000 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineDao.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.wakeUpTogetUp.togetUp.routines; - -import com.wakeUpTogetUp.togetUp.alarms.model.Alarm; -import com.wakeUpTogetUp.togetUp.common.interfaces.CustomRepository; -import com.wakeUpTogetUp.togetUp.routines.model.Routine; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Repository; - -import javax.persistence.EntityManager; -import java.util.List; -import java.util.Optional; - -@Repository -@RequiredArgsConstructor -public class RoutineDao implements CustomRepository { - private final EntityManager em; - @Override - public void save(Routine routine) { - em.persist(routine); - } - - @Override - public Optional findById(Integer id) { - return Optional.ofNullable(em.find(Routine.class, id)); - } - - public Optional> findByAlarmId(Integer alarmId) { - List routineList = em.createQuery( - "select r from Routine r " + - "join MappingAlarmRoutine mar on (r.id = mar.routine.id) " + - "where mar.alarm.id = :alarmId", Routine.class) - .setParameter("alarmId", alarmId) - .getResultList(); - - return Optional.ofNullable(routineList); - } - - public Optional> findByUserId(Integer userId) { - List routineList = em.createQuery( - "select r from Routine r " + - "where r.user.id = :userId", - Routine.class) - .setParameter("userId", userId) - .getResultList(); - - return Optional.ofNullable(routineList); - } -} \ No newline at end of file diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineProvider.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineProvider.java index 6f057acb..8fa6e3dc 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineProvider.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineProvider.java @@ -1,8 +1,8 @@ package com.wakeUpTogetUp.togetUp.routines; -import com.wakeUpTogetUp.togetUp.common.BaseException; -import com.wakeUpTogetUp.togetUp.common.BaseResponseStatus; -import com.wakeUpTogetUp.togetUp.routines.model.GetRoutineRes; +import com.wakeUpTogetUp.togetUp.common.exception.BaseException; +import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; import com.wakeUpTogetUp.togetUp.routines.model.Routine; import com.wakeUpTogetUp.togetUp.utils.mappers.RoutineMapper; import lombok.RequiredArgsConstructor; @@ -14,29 +14,29 @@ @Service @RequiredArgsConstructor public class RoutineProvider { - private final RoutineDao routineDao; - public GetRoutineRes getRoutine(Integer routineId) { - Routine routine = routineDao.findById(routineId) + private final RoutineRepository routineRepository; + public RoutineRes getRoutine(Integer routineId) { + Routine routine = routineRepository.findById(routineId) .orElseThrow( - () -> new BaseException(BaseResponseStatus.INVALID_ROUTINE_ID) + () -> new BaseException(ResponseStatus.INVALID_ROUTINE_ID) ); - GetRoutineRes getRoutineRes = RoutineMapper.INSTANCE.entityToGetRoutineRes(routine); + RoutineRes routineRes = RoutineMapper.INSTANCE.toGetRoutineRes(routine); - return getRoutineRes; + return routineRes; } - public List getRoutinesByUserId(Integer userId) { - List routineList = routineDao.findByUserId(userId) + public List getRoutinesByUserId(Integer userId) { + List routineList = routineRepository.findByUserId(userId) .orElseThrow( - () -> new BaseException(BaseResponseStatus.ROUTINE_NOT_FOUND) + () -> new BaseException(ResponseStatus.ROUTINE_NOT_FOUND) ); - ArrayList getRoutineResList = new ArrayList<>(); + ArrayList routineResList = new ArrayList<>(); for(Routine routine : routineList) { - getRoutineResList.add(RoutineMapper.INSTANCE.entityToGetRoutineRes(routine)); + routineResList.add(RoutineMapper.INSTANCE.toGetRoutineRes(routine)); } - return getRoutineResList; + return routineResList; } } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineRepository.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineRepository.java new file mode 100644 index 00000000..fde0041e --- /dev/null +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineRepository.java @@ -0,0 +1,22 @@ +package com.wakeUpTogetUp.togetUp.routines; + +import com.wakeUpTogetUp.togetUp.routines.model.Routine; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface RoutineRepository extends JpaRepository { + @Override + Optional findById(Integer id); + + @Query("SELECT r FROM Routine r JOIN MappingAlarmRoutine mar ON (r.id = mar.routine.id) WHERE mar.alarm.id = :alarmId") + Optional> findByAlarmId(@Param(value = "alarmId") Integer alarmId); + + @Query("select r from Routine r where r.user.id = :userId") + Optional> findByUserId(@Param(value = "userId") Integer userId); +} \ No newline at end of file diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineService.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineService.java index 46ce83bc..600fd8c2 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineService.java @@ -1,10 +1,10 @@ package com.wakeUpTogetUp.togetUp.routines; -import com.wakeUpTogetUp.togetUp.common.BaseException; -import com.wakeUpTogetUp.togetUp.common.BaseResponseStatus; -import com.wakeUpTogetUp.togetUp.missions.MissionDao; +import com.wakeUpTogetUp.togetUp.common.exception.BaseException; +import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.missions.MissionRepository; import com.wakeUpTogetUp.togetUp.missions.model.Mission; -import com.wakeUpTogetUp.togetUp.routines.model.PostRoutineReq; +import com.wakeUpTogetUp.togetUp.routines.dto.request.RoutineReq; import com.wakeUpTogetUp.togetUp.routines.model.Routine; import com.wakeUpTogetUp.togetUp.users.UserRepository; import com.wakeUpTogetUp.togetUp.users.model.User; @@ -16,31 +16,31 @@ @Service @RequiredArgsConstructor public class RoutineService { - private final RoutineDao routineDao; + private final RoutineRepository routineRepository; private final UserRepository userRepository; - private final MissionDao missionDao; + private final MissionRepository missionRepository; // 루틴 생성 @Transactional - public int createRoutine(Integer userId, PostRoutineReq postRoutineReq) { + public int createRoutine(Integer userId, RoutineReq routineReq) { User user = userRepository.findById(userId).orElseThrow( - () -> new BaseException(BaseResponseStatus.INVALID_USER_ID) + () -> new BaseException(ResponseStatus.INVALID_USER_ID) ); - Mission mission = missionDao.findById(postRoutineReq.getMissionId()).orElseThrow( - () -> new BaseException(BaseResponseStatus.INVALID_MISSION_ID) + Mission mission = missionRepository.findById(routineReq.getMissionId()).orElseThrow( + () -> new BaseException(ResponseStatus.INVALID_MISSION_ID) ); Routine routine = Routine.builder() .user(user) .mission(mission) - .name(postRoutineReq.getName()) - .estimatedTime(postRoutineReq.getEstimatedTime()) - .icon(postRoutineReq.getIcon()) - .color(postRoutineReq.getColor()) + .name(routineReq.getName()) + .estimatedTime(routineReq.getEstimatedTime()) + .icon(routineReq.getIcon()) + .color(routineReq.getColor()) .build(); - routineDao.save(routine); + routineRepository.save(routine); return routine.getId(); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/dto/request/RoutineReq.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/dto/request/RoutineReq.java new file mode 100644 index 00000000..60509be5 --- /dev/null +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/dto/request/RoutineReq.java @@ -0,0 +1,29 @@ +package com.wakeUpTogetUp.togetUp.routines.dto.request; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import javax.validation.constraints.Null; + +@Getter +@Setter +@NoArgsConstructor +public class RoutineReq { + public RoutineReq(Integer userId, Integer missionId, String name, Integer estimatedTime, String icon, String color) { + this.userId = userId; + this.missionId = missionId; + this.name = name; + this.estimatedTime = estimatedTime; + this.icon = icon; + this.color = color; + } + @Null + private Integer id; + private Integer userId; + private Integer missionId; + private String name; + private Integer estimatedTime; + private String icon; + private String color; +} diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/model/GetRoutineRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/dto/response/RoutineRes.java similarity index 77% rename from src/main/java/com/wakeUpTogetUp/togetUp/routines/model/GetRoutineRes.java rename to src/main/java/com/wakeUpTogetUp/togetUp/routines/dto/response/RoutineRes.java index fdf754fa..0af6a54e 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/model/GetRoutineRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/dto/response/RoutineRes.java @@ -1,4 +1,4 @@ -package com.wakeUpTogetUp.togetUp.routines.model; +package com.wakeUpTogetUp.togetUp.routines.dto.response; import lombok.*; @@ -7,7 +7,7 @@ @NoArgsConstructor @AllArgsConstructor @Builder -public class GetRoutineRes { +public class RoutineRes { private Integer id; private Integer userId; private Integer missionId; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/model/PostRoutineReq.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/model/PostRoutineReq.java deleted file mode 100644 index aa0dda6e..00000000 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/model/PostRoutineReq.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.wakeUpTogetUp.togetUp.routines.model; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -public class PostRoutineReq { - private int missionId; - private String name; - private int estimatedTime; - private String icon; - private String color; -} diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/model/Routine.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/model/Routine.java index d6099c39..768ae181 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/model/Routine.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/model/Routine.java @@ -6,7 +6,6 @@ import org.hibernate.annotations.DynamicInsert; import javax.persistence.*; -import java.sql.Timestamp; @Entity @Table(name = "routine") diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/users/UserController.java b/src/main/java/com/wakeUpTogetUp/togetUp/users/UserController.java index cdbcbd61..c691e626 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/users/UserController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/users/UserController.java @@ -1,8 +1,8 @@ package com.wakeUpTogetUp.togetUp.users; -import com.wakeUpTogetUp.togetUp.common.BaseException; -import com.wakeUpTogetUp.togetUp.common.BaseResponse; -import com.wakeUpTogetUp.togetUp.common.BaseResponseStatus; +import com.wakeUpTogetUp.togetUp.common.exception.BaseException; +import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; +import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; import com.wakeUpTogetUp.togetUp.users.oauth.GetSocialOAuthRes; import com.wakeUpTogetUp.togetUp.users.oauth.OAuthService; import lombok.RequiredArgsConstructor; @@ -23,11 +23,11 @@ public class UserController { @ResponseBody @PostMapping("/new") // - public BaseResponse join(@RequestBody UserForm form) { + public BaseResponse join(@RequestBody UserForm form) { try { System.out.println("로그인"+form.getLoginType()); userService.createUser(form); - return new BaseResponse(BaseResponseStatus.SUCCESS); + return new BaseResponse(ResponseStatus.SUCCESS); } catch (BaseException exception) { return new BaseResponse<>((exception.getStatus())); } @@ -45,7 +45,7 @@ public BaseResponse socialLoginRedirect(@PathVariable(name="socialLoginT LoginType socialLoginType= LoginType.valueOf(SocialLoginPath.toUpperCase()); String redirectURL= oAuthService.request(socialLoginType); - return new BaseResponse<>(BaseResponseStatus.SUCCESS,redirectURL); + return new BaseResponse<>(ResponseStatus.SUCCESS,redirectURL); } /** * Social Login API Server 요청에 의한 callback 을 처리 @@ -64,7 +64,7 @@ public BaseResponse callback ( LoginType socialLoginType= LoginType.valueOf(socialLoginPath.toUpperCase()); GetSocialOAuthRes getSocialOAuthRes=oAuthService.oAuthLogin(socialLoginType,code); - return new BaseResponse<>(BaseResponseStatus.SUCCESS,getSocialOAuthRes); + return new BaseResponse<>(ResponseStatus.SUCCESS,getSocialOAuthRes); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/utils/mappers/AlarmMapper.java b/src/main/java/com/wakeUpTogetUp/togetUp/utils/mappers/AlarmMapper.java index 9217f02e..e1c5fedd 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/utils/mappers/AlarmMapper.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/utils/mappers/AlarmMapper.java @@ -1,23 +1,33 @@ package com.wakeUpTogetUp.togetUp.utils.mappers; +import com.wakeUpTogetUp.togetUp.alarms.dto.request.AlarmReq; +import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmRes; import com.wakeUpTogetUp.togetUp.alarms.model.Alarm; -import com.wakeUpTogetUp.togetUp.alarms.model.GetAlarmRes; -import com.wakeUpTogetUp.togetUp.alarms.model.GetAlarmsRes; -import com.wakeUpTogetUp.togetUp.routines.model.GetRoutineRes; +import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmsRes; +import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; +import com.wakeUpTogetUp.togetUp.users.UserRepository; +import com.wakeUpTogetUp.togetUp.users.model.User; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import java.util.List; -@Mapper +@Mapper(componentModel = "spring") public interface AlarmMapper { AlarmMapper INSTANCE = Mappers.getMapper(AlarmMapper.class); - // 알람 한 개 가져오기 + // AlarmsRes @Mapping(target = "userId", expression = "java(alarm.getUser().getId())") - default GetAlarmRes entityToGetAlarmRes(Alarm alarm, List getRoutineResList) { - GetAlarmRes getAlarmRes = GetAlarmRes.builder() + AlarmsRes toAlarmsRes(Alarm alarm); + + /** + * Entity to DTO + */ + // AlarmRes + @Mapping(target = "userId", expression = "java(alarm.getUser().getId())") + default AlarmRes toAlarmRes(Alarm alarm, List routineResList) { + AlarmRes alarmRes = AlarmRes.builder() .id(alarm.getId()) .userId(alarm.getUser().getId()) .name(alarm.getName()) @@ -40,12 +50,8 @@ default GetAlarmRes entityToGetAlarmRes(Alarm alarm, List getRout .isActivated(alarm.getIsActivated()) .build(); - getAlarmRes.setGetRoutineResList(getRoutineResList); + alarmRes.setRoutineResList(routineResList); - return getAlarmRes; + return alarmRes; } - - // 알람 여러 개 가져오기 - @Mapping(target = "userId", expression = "java(alarm.getUser().getId())") - GetAlarmsRes entityToGetAlarmsRes(Alarm alarm); } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/utils/mappers/RoutineMapper.java b/src/main/java/com/wakeUpTogetUp/togetUp/utils/mappers/RoutineMapper.java index dd3be361..923c2dce 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/utils/mappers/RoutineMapper.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/utils/mappers/RoutineMapper.java @@ -1,6 +1,6 @@ package com.wakeUpTogetUp.togetUp.utils.mappers; -import com.wakeUpTogetUp.togetUp.routines.model.GetRoutineRes; +import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; import com.wakeUpTogetUp.togetUp.routines.model.Routine; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -12,5 +12,5 @@ public interface RoutineMapper { @Mapping(target = "userId", expression = "java(routine.getUser().getId())") @Mapping(target = "missionId", expression = "java(routine.getMission().getId())") - GetRoutineRes entityToGetRoutineRes(Routine routine); + RoutineRes toGetRoutineRes(Routine routine); } From 4a8d32244663c7f930cdca20653ce08d30b6df4b Mon Sep 17 00:00:00 2001 From: Lee ChanMi Date: Fri, 5 May 2023 01:16:34 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feature=20:=20=EC=95=8C=EB=9E=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20api=20=EA=B5=AC=ED=98=84=20=EB=B0=8F=20?= =?UTF-8?q?=EA=B8=B0=ED=83=80=20=ED=8C=A8=ED=82=A4=EC=A7=80=20=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 알람 수정 api 구현 - mapper 메소드 통일 - repository를 raw jpa에서 spring data jpa로 전환 - 각 도메인에 dto/response, dto/request 디렉토리 추가 - 각 도메인의 dto 통일 - BaseException, GloberExceptionHandler -> common/exception으로 이전 - BaseResponseStatus -> ResponseStatus으로 이름 변경 - BaseResponse를 common/dto에 이전 --- .../java/com/wakeUpTogetUp/togetUp/alarms/AlarmController.java | 2 +- .../java/com/wakeUpTogetUp/togetUp/alarms/AlarmProvider.java | 2 +- .../java/com/wakeUpTogetUp/togetUp/alarms/AlarmService.java | 2 +- .../togetUp/common/{exception => }/ResponseStatus.java | 2 +- .../java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java | 2 +- .../wakeUpTogetUp/togetUp/common/exception/BaseException.java | 1 + .../togetUp/common/exception/GlobalExceptionHandler.java | 1 + .../java/com/wakeUpTogetUp/togetUp/files/FileController.java | 2 +- .../com/wakeUpTogetUp/togetUp/routines/RoutineController.java | 2 +- .../com/wakeUpTogetUp/togetUp/routines/RoutineProvider.java | 2 +- .../java/com/wakeUpTogetUp/togetUp/routines/RoutineService.java | 2 +- .../java/com/wakeUpTogetUp/togetUp/users/UserController.java | 2 +- 12 files changed, 12 insertions(+), 10 deletions(-) rename src/main/java/com/wakeUpTogetUp/togetUp/common/{exception => }/ResponseStatus.java (97%) diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmController.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmController.java index b8fa6f2b..284bac21 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmController.java @@ -4,7 +4,7 @@ import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmsRes; import com.wakeUpTogetUp.togetUp.alarms.dto.request.AlarmReq; import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; -import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmProvider.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmProvider.java index 5629fdae..314e0cfe 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmProvider.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmProvider.java @@ -4,7 +4,7 @@ import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmRes; import com.wakeUpTogetUp.togetUp.alarms.dto.response.AlarmsRes; import com.wakeUpTogetUp.togetUp.common.exception.BaseException; -import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import com.wakeUpTogetUp.togetUp.routines.RoutineRepository; import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; import com.wakeUpTogetUp.togetUp.routines.model.Routine; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmService.java b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmService.java index a7a76888..17e5fe73 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/alarms/AlarmService.java @@ -5,7 +5,7 @@ import com.wakeUpTogetUp.togetUp.alarms.model.MappingAlarmRoutine; import com.wakeUpTogetUp.togetUp.alarms.dto.request.AlarmReq; import com.wakeUpTogetUp.togetUp.common.exception.BaseException; -import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import com.wakeUpTogetUp.togetUp.mappingAlarmRoutine.model.MappingAlarmRoutineRepository; import com.wakeUpTogetUp.togetUp.routines.RoutineRepository; import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/ResponseStatus.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/ResponseStatus.java similarity index 97% rename from src/main/java/com/wakeUpTogetUp/togetUp/common/exception/ResponseStatus.java rename to src/main/java/com/wakeUpTogetUp/togetUp/common/ResponseStatus.java index 92150487..7a796afc 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/ResponseStatus.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/ResponseStatus.java @@ -1,4 +1,4 @@ -package com.wakeUpTogetUp.togetUp.common.exception; +package com.wakeUpTogetUp.togetUp.common; import lombok.Getter; import org.springframework.http.HttpStatus; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java index 51dfb771..a49ccab7 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/dto/BaseResponse.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.wakeUpTogetUp.togetUp.common.exception.BaseException; -import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import lombok.Getter; @Getter diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/BaseException.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/BaseException.java index 5a674fb6..99d36747 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/BaseException.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/BaseException.java @@ -1,5 +1,6 @@ package com.wakeUpTogetUp.togetUp.common.exception; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/GlobalExceptionHandler.java b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/GlobalExceptionHandler.java index a80e6604..b0ba7b87 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/common/exception/GlobalExceptionHandler.java @@ -1,6 +1,7 @@ package com.wakeUpTogetUp.togetUp.common.exception; //import org.hibernate.TypeMismatchException; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/files/FileController.java b/src/main/java/com/wakeUpTogetUp/togetUp/files/FileController.java index 49bbea53..24f1014e 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/files/FileController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/files/FileController.java @@ -5,7 +5,7 @@ import com.wakeUpTogetUp.togetUp.common.exception.BaseException; import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; -import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineController.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineController.java index 41b5d28c..4e3c1b1a 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineController.java @@ -1,7 +1,7 @@ package com.wakeUpTogetUp.togetUp.routines; import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; -import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; import com.wakeUpTogetUp.togetUp.routines.dto.request.RoutineReq; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineProvider.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineProvider.java index 8fa6e3dc..046a5ae5 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineProvider.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineProvider.java @@ -1,7 +1,7 @@ package com.wakeUpTogetUp.togetUp.routines; import com.wakeUpTogetUp.togetUp.common.exception.BaseException; -import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import com.wakeUpTogetUp.togetUp.routines.dto.response.RoutineRes; import com.wakeUpTogetUp.togetUp.routines.model.Routine; import com.wakeUpTogetUp.togetUp.utils.mappers.RoutineMapper; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineService.java b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineService.java index 600fd8c2..65173dd3 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/routines/RoutineService.java @@ -1,7 +1,7 @@ package com.wakeUpTogetUp.togetUp.routines; import com.wakeUpTogetUp.togetUp.common.exception.BaseException; -import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import com.wakeUpTogetUp.togetUp.missions.MissionRepository; import com.wakeUpTogetUp.togetUp.missions.model.Mission; import com.wakeUpTogetUp.togetUp.routines.dto.request.RoutineReq; diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/users/UserController.java b/src/main/java/com/wakeUpTogetUp/togetUp/users/UserController.java index c691e626..2ce31ced 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/users/UserController.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/users/UserController.java @@ -2,7 +2,7 @@ import com.wakeUpTogetUp.togetUp.common.exception.BaseException; import com.wakeUpTogetUp.togetUp.common.dto.BaseResponse; -import com.wakeUpTogetUp.togetUp.common.exception.ResponseStatus; +import com.wakeUpTogetUp.togetUp.common.ResponseStatus; import com.wakeUpTogetUp.togetUp.users.oauth.GetSocialOAuthRes; import com.wakeUpTogetUp.togetUp.users.oauth.OAuthService; import lombok.RequiredArgsConstructor;