Skip to content

Commit

Permalink
feat : 임시 회원삭제 API 수정 및 임시 정책 더미데이터 추가 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
LHS-11 committed Nov 12, 2023
1 parent 837fbdb commit b27e51c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public interface PolicyRepository extends JpaRepository<Policy, Long> {

List<Policy> 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<Policy> findByAreaCodeAndCityCodeAndAge(@Param("areaCode") AreaCode areaCode, @Param("central") AreaCode central, @Param("cityCode") CityCode cityCode, @Param("age") int age);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,11 @@ public CommonResponse<String> delete(@AuthUser User user){
return CommonResponse.success(null);
}

@GetMapping("/dummy")
public CommonResponse<String> addDummy(@AuthUser User user){
userService.addPolicyDummy(user);
return CommonResponse.success(null);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Policy> interestPolices = List.of(policy, policy2, policy3, policy4, policy5, policy6, policy7, policy8, policy9 , policy10);
List<Policy> 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<HomeInfoResponseDto.HomePolicyInfo> getRecommendPolicyDummy() {
Policy loansPolicy = policyRepository.findAllBySupportPolicyType(SupportPolicyType.LOANS).get(0);
Policy moneyPolicy = policyRepository.findAllBySupportPolicyType(SupportPolicyType.MONEY).get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public interface UserPolicyRepository extends JpaRepository<UserPolicy, Long> {

void deleteAllByUserAndApplyFlag(User user, boolean applyFlag);

void deleteAllByUser(User user);

}

0 comments on commit b27e51c

Please sign in to comment.