From b27e51c2f2076440e3f336c6f393b59459ea506c Mon Sep 17 00:00:00 2001 From: LHS-11 Date: Sun, 12 Nov 2023 16:53:12 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EC=9E=84=EC=8B=9C=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EC=82=AD=EC=A0=9C=20API=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9E=84=EC=8B=9C=20=EC=A0=95=EC=B1=85=20=EB=8D=94?= =?UTF-8?q?=EB=AF=B8=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80=20API?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/policy/dao/PolicyRepository.java | 6 +-- .../domain/user/api/UserController.java | 7 +++ .../domain/user/application/UserService.java | 52 +++++++++++++++++++ .../userpolicy/dao/UserPolicyRepository.java | 2 + 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyRepository.java b/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyRepository.java index da4e4d7..a585e47 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyRepository.java +++ b/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyRepository.java @@ -43,10 +43,10 @@ public interface PolicyRepository extends JpaRepository { List findAllBySupportPolicyType(SupportPolicyType supportPolicyType); - @EntityGraph(attributePaths = {"jobTypes","educationTypes","policySplzTypes","supportPolicyTypes"}) + @EntityGraph(attributePaths = {"jobTypes", "educationTypes", "policySplzTypes", "supportPolicyTypes"}) @Query(value = "SELECT p FROM Policy p " + "WHERE (p.areaCode = :areaCode AND p.cityCode = :cityCode) OR (p.areaCode = :areaCode AND p.cityCode IS NULL) OR (p.areaCode = :central) " + - "AND :age between p.minAge and p.maxAge") // p.minAge <= :age AND p.maxAge >= :age" + "AND :age between p.minAge and p.maxAge") List findByAreaCodeAndCityCodeAndAge(@Param("areaCode") AreaCode areaCode, @Param("central") AreaCode central, @Param("cityCode") CityCode cityCode, @Param("age") int age); -} +} \ No newline at end of file diff --git a/src/main/java/com/cmc/zenefitserver/domain/user/api/UserController.java b/src/main/java/com/cmc/zenefitserver/domain/user/api/UserController.java index a7536bf..ef91bcf 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/user/api/UserController.java +++ b/src/main/java/com/cmc/zenefitserver/domain/user/api/UserController.java @@ -125,4 +125,11 @@ public CommonResponse delete(@AuthUser User user){ return CommonResponse.success(null); } + @GetMapping("/dummy") + public CommonResponse addDummy(@AuthUser User user){ + userService.addPolicyDummy(user); + return CommonResponse.success(null); + } + + } diff --git a/src/main/java/com/cmc/zenefitserver/domain/user/application/UserService.java b/src/main/java/com/cmc/zenefitserver/domain/user/application/UserService.java index 57f9644..bd2a292 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/user/application/UserService.java +++ b/src/main/java/com/cmc/zenefitserver/domain/user/application/UserService.java @@ -13,6 +13,7 @@ import com.cmc.zenefitserver.domain.user.domain.User; import com.cmc.zenefitserver.domain.user.dto.*; import com.cmc.zenefitserver.domain.userpolicy.dao.UserPolicyRepository; +import com.cmc.zenefitserver.domain.userpolicy.domain.UserPolicy; import com.cmc.zenefitserver.global.auth.jwt.JwtService; import com.cmc.zenefitserver.global.common.request.TokenRequestDto; import com.cmc.zenefitserver.global.common.response.TokenResponseDto; @@ -212,10 +213,61 @@ public void updateManualStatus(User user) { userRepository.save(user); } + @Transactional public void delete(User user) { + userPolicyRepository.deleteAllByUser(user); userRepository.delete(user); } + @Transactional + public void addPolicyDummy(User user){ + Policy policy = policyRepository.findById(1L).get(); + Policy policy2 = policyRepository.findById(2L).get(); + Policy policy3 = policyRepository.findById(3L).get(); + Policy policy4 = policyRepository.findById(4L).get(); + Policy policy5 = policyRepository.findById(5L).get(); + Policy policy6 = policyRepository.findById(6L).get(); + Policy policy7 = policyRepository.findById(7L).get(); + Policy policy8 = policyRepository.findById(8L).get(); + Policy policy9 = policyRepository.findById(9L).get(); + Policy policy10 = policyRepository.findById(10L).get(); + + Policy policy11 = policyRepository.findById(11L).get(); + Policy policy12 = policyRepository.findById(12L).get(); + Policy policy13 = policyRepository.findById(13L).get(); + Policy policy14 = policyRepository.findById(14L).get(); + Policy policy15 = policyRepository.findById(15L).get(); + Policy policy16 = policyRepository.findById(16L).get(); + Policy policy17 = policyRepository.findById(17L).get(); + Policy policy18 = policyRepository.findById(18L).get(); + Policy policy19 = policyRepository.findById(19L).get(); + Policy policy20 = policyRepository.findById(20L).get(); + + List interestPolices = List.of(policy, policy2, policy3, policy4, policy5, policy6, policy7, policy8, policy9 , policy10); + List appliyPolices = List.of(policy11, policy12, policy13, policy14, policy15, policy16, policy17, policy18, policy19 , policy20); + + for (Policy interestPolicy : interestPolices) { + UserPolicy userPolicy = UserPolicy.builder() + .user(user) + .policy(interestPolicy) + .interestFlag(true) + .applyFlag(false) + .build(); + userPolicyRepository.save(userPolicy); + } + + for (Policy applyPolicy : appliyPolices) { + UserPolicy userPolicy = UserPolicy.builder() + .user(user) + .policy(applyPolicy) + .interestFlag(false) + .applyFlag(true) + .build(); + userPolicyRepository.save(userPolicy); + } + + } + public List getRecommendPolicyDummy() { Policy loansPolicy = policyRepository.findAllBySupportPolicyType(SupportPolicyType.LOANS).get(0); Policy moneyPolicy = policyRepository.findAllBySupportPolicyType(SupportPolicyType.MONEY).get(0); diff --git a/src/main/java/com/cmc/zenefitserver/domain/userpolicy/dao/UserPolicyRepository.java b/src/main/java/com/cmc/zenefitserver/domain/userpolicy/dao/UserPolicyRepository.java index 76db429..aa7c76b 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/userpolicy/dao/UserPolicyRepository.java +++ b/src/main/java/com/cmc/zenefitserver/domain/userpolicy/dao/UserPolicyRepository.java @@ -34,4 +34,6 @@ public interface UserPolicyRepository extends JpaRepository { void deleteAllByUserAndApplyFlag(User user, boolean applyFlag); + void deleteAllByUser(User user); + }