Skip to content
Merged

Dev #72

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface TblAddressSecondRepository extends JpaRepository<TblAddressSecond, Long> {
List<TblAddressSecond> findByAddressFirst_Id(Long afSeq);
Optional<TblAddressSecond> findByAddressFirstIdAndId(Long firstSeq, Long secondSeq);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.balybus.galaxy.address.repository;

import com.balybus.galaxy.address.domain.TblAddressSecond;
import com.balybus.galaxy.address.domain.TblAddressThird;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface TblAddressThirdRepository extends JpaRepository<TblAddressThird, Long> {
List<TblAddressThird> findByAddressSecond_Id(Long asSeq);
Optional<TblAddressThird> findByAddressSecond_IdAndId(Long asSeq, Long atSeq);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.balybus.galaxy.address.serviceImpl;

import com.balybus.galaxy.address.domain.TblAddressFirst;

public interface TblAddressFirstService {
TblAddressFirst validationCheck(Long afSeq); // 광역시.도 구분자 유효성 확인
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.balybus.galaxy.address.serviceImpl;

import com.balybus.galaxy.address.domain.TblAddressSecond;

public interface TblAddressSecondService {
TblAddressSecond validationCheck(Long firstSeq, Long secondSeq); // 시.군.구 구분자 유효성 확인
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.balybus.galaxy.address.serviceImpl;

import com.balybus.galaxy.address.domain.TblAddressThird;

public interface TblAddressThirdService {
TblAddressThird validationCheck(Long secondSeq, Long thirdSeq); // 읍.면.동 구분자 유효성 확인
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.balybus.galaxy.address.serviceImpl.service;

import com.balybus.galaxy.address.domain.TblAddressFirst;
import com.balybus.galaxy.address.repository.TblAddressFirstRepository;
import com.balybus.galaxy.address.serviceImpl.TblAddressFirstService;
import com.balybus.galaxy.global.exception.BadRequestException;
import com.balybus.galaxy.global.exception.ExceptionCode;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@Slf4j
@RequiredArgsConstructor
@Transactional
public class TblAddressFirstServiceImpl implements TblAddressFirstService {
private final TblAddressFirstRepository addressFirstRepository;

/**
* 광역시.도 구분자 유효성 확인
* @param afSeq Long:광역시.도 구분자
* @return TblAddressFirst:광역시.도 Entity
*/
@Override
public TblAddressFirst validationCheck(Long afSeq) {
Optional<TblAddressFirst> firstOpt = addressFirstRepository.findById(afSeq);
if(firstOpt.isEmpty()) throw new BadRequestException(ExceptionCode.INVALID_ADDRESS);
return firstOpt.get();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
package com.balybus.galaxy.address.serviceImpl.service;

import com.balybus.galaxy.address.domain.TblAddressSecond;
import com.balybus.galaxy.address.repository.TblAddressSecondRepository;
import com.balybus.galaxy.address.serviceImpl.TblAddressSecondService;
import com.balybus.galaxy.global.exception.BadRequestException;
import com.balybus.galaxy.global.exception.ExceptionCode;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@Slf4j
@RequiredArgsConstructor
@Transactional
public class TblAddressSecondServiceImpl implements TblAddressSecondService {
private final TblAddressSecondRepository addressSecondRepository;

/**
* 시.군.구 구분자 유효성 확인
* @param firstSeq Long:광역시.도 구분자
* @param secondSeq Long:시.군.구 구분자
* @return TblAddressSecond: 시.군.구 Entity
*/
@Override
public TblAddressSecond validationCheck(Long firstSeq, Long secondSeq) {
Optional<TblAddressSecond> secondOpt = addressSecondRepository.findByAddressFirstIdAndId(firstSeq, secondSeq);
if(secondOpt.isEmpty()) throw new BadRequestException(ExceptionCode.INVALID_ADDRESS);
return secondOpt.get();
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
package com.balybus.galaxy.address.serviceImpl.service;

import com.balybus.galaxy.address.domain.TblAddressThird;
import com.balybus.galaxy.address.repository.TblAddressThirdRepository;
import com.balybus.galaxy.address.serviceImpl.TblAddressThirdService;
import com.balybus.galaxy.global.exception.BadRequestException;
import com.balybus.galaxy.global.exception.ExceptionCode;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@Slf4j
@RequiredArgsConstructor
@Transactional
public class TblAddressThirdServiceImpl implements TblAddressThirdService {
private final TblAddressThirdRepository addressThirdRepository;

/**
* 읍.면.동 구분자 유효성 확인
* @param secondSeq Long:시.군.구 구분자
* @param thirdSeq Long:읍.면.동 구분자
* @return TblAddressThird:읍.면.동 Entity
*/
@Override
public TblAddressThird validationCheck(Long secondSeq, Long thirdSeq) {
Optional<TblAddressThird> thirdOpt = addressThirdRepository.findByAddressSecond_IdAndId(secondSeq, thirdSeq);
if(thirdOpt.isEmpty()) throw new BadRequestException(ExceptionCode.INVALID_ADDRESS);
return thirdOpt.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ public interface TblCareRepository extends JpaRepository<TblCare, Long> {
and care_val & :calValTotal <> 0
""", nativeQuery = true)
List<Long> findByCareIdList(@Param("topCareSeq") Long topCareSeq, @Param("calValTotal") int calValTotal);

@Query(value = """
select group_concat(care_name separator ', ')
from tbl_care tc
where care_yn = true
and top_care_seq = :topCareSeq
and care_val & :calValTotal <> 0
""", nativeQuery = true)
String findCalNameListStr(@Param("topCareSeq") Long topCareSeq, @Param("calValTotal") int calValTotal);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.balybus.galaxy.domain.tblCare.service;

import com.balybus.galaxy.domain.tblCare.dto.CareBaseDto;
import com.balybus.galaxy.domain.tblCare.dto.CareChoiceListDto;
import com.balybus.galaxy.domain.tblCare.dto.CareRequestDto;
import com.balybus.galaxy.domain.tblCare.dto.CareResponseDto;

public interface TblCareService {
CareResponseDto.GetAllCodeList getAllCodeList(); //전체 코드 조회
CareResponseDto.GetServiceCodeList getServiceCodeList(); //어르신 필요 서비스 리스트 항목
CareResponseDto.GetRequestCodeList getRequestCodeList(CareRequestDto.GetRequestCodeList req); //요청 종류 리스트 항목
CareChoiceListDto getCareChoiceList(CareBaseDto careDto, boolean needWelfare); // 선택한 돌봄 항목 항목별 pk 값 리스트 반환
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public CareResponseDto.GetRequestCodeList getRequestCodeList(CareRequestDto.GetR
* @param needWelfare boolean:복리후생 데이터 반환 여부
* @return CareChoiceListDto
*/
@Override
public CareChoiceListDto getCareChoiceList(CareBaseDto careDto, boolean needWelfare){
CareChoiceListDto resultDto = new CareChoiceListDto();
for(TblCareTopEnum careTopEnum : TblCareTopEnum.values()) {
Expand Down Expand Up @@ -119,4 +120,6 @@ public CareChoiceListDto getCareChoiceList(CareBaseDto careDto, boolean needWelf
}
return resultDto;
}


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.balybus.galaxy.domain.tblMatching;

import com.balybus.galaxy.global.common.CommonServiceImpl;
import com.balybus.galaxy.global.utils.mail.ContentType;
import com.balybus.galaxy.global.utils.mail.SendMailRequest;
import com.balybus.galaxy.global.utils.mail.SendMailUtils;
Expand All @@ -20,7 +21,6 @@
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -35,6 +35,7 @@ public class MatchingServiceImpl {
private final TblPatientLogRepository patientLogRepository;
private final HelperRepository helperRepository;
private final SendMailUtils sendMailUtils;
private final CommonServiceImpl commonService;

@Async
@Transactional
Expand Down Expand Up @@ -93,7 +94,7 @@ public void matchingSystem(Long plSeq){
mailContentList.add(MailMatchingDto.HelperContentDto.builder()
.name(helperEntity.getName())
.gender(helperEntity.getGender() == 1 ? "남" : "여")
.age(calculateAge(LocalDate.parse(helperEntity.getBirthday(), formatter)))
.age(commonService.calculateAge(LocalDate.parse(helperEntity.getBirthday(), formatter)))
.build());
}
matchingRepository.saveAll(saveMatchingList);
Expand All @@ -120,12 +121,4 @@ public void matchingSystem(Long plSeq){
throw new RuntimeException(e);
}
}

private int calculateAge(LocalDate birthDate) {
LocalDate currentDate = LocalDate.now();
// 생일과 현재 날짜의 차이 계산
Period period = Period.between(birthDate, currentDate);
// 나이는 Period 객체의 연도를 반환
return period.getYears();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.balybus.galaxy.global.common;

import com.balybus.galaxy.address.domain.TblAddressFirst;
import com.balybus.galaxy.address.domain.TblAddressSecond;
import com.balybus.galaxy.address.domain.TblAddressThird;
import com.balybus.galaxy.domain.tblImg.dto.ImgRequestDto;
import com.balybus.galaxy.domain.tblImg.dto.ImgResponseDto;
import com.balybus.galaxy.login.domain.type.RoleType;
import org.springframework.security.core.userdetails.UserDetails;

import java.time.LocalDate;

public interface CommonService {
ImgResponseDto.UploadUserImg uploadUserImg(UserDetails userDetails, RoleType roleType, ImgRequestDto.uploadUserImg dto);
int calculateAge(LocalDate birthDate); //만 나이 계산기
String fullAddressString(TblAddressFirst first, TblAddressSecond second, TblAddressThird third); // 주소 반환
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.balybus.galaxy.global.common;

import com.balybus.galaxy.address.domain.TblAddressFirst;
import com.balybus.galaxy.address.domain.TblAddressSecond;
import com.balybus.galaxy.address.domain.TblAddressThird;
import com.balybus.galaxy.domain.tblCenterManager.TblCenterManagerRepository;
import com.balybus.galaxy.domain.tblImg.TblImg;
import com.balybus.galaxy.domain.tblImg.dto.ImgRequestDto;
Expand All @@ -21,6 +24,8 @@
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDate;
import java.time.Period;
import java.util.Map;

@Slf4j
Expand Down Expand Up @@ -123,4 +128,36 @@ private <T extends ChangeProfileImg> Long updateUserProfileImage(
//4. 새로운 이미지 구분자 값 반환
return imgEntity == null ? null : imgEntity.getId();
}

/**
* 나이 계산기(만 나이 반환)
* @param birthDate LocalDate:생년월일
* @return int:만 나이
*/
@Override
public int calculateAge(LocalDate birthDate) {
LocalDate currentDate = LocalDate.now();
// 생일과 현재 날짜의 차이 계산
Period period = Period.between(birthDate, currentDate);
// 나이는 Period 객체의 연도를 반환
return period.getYears();
}

/**
* 주소 이름 정리
* @param first TblAddressFirst:광역시.도
* @param second TblAddressSecond:시.군.구
* @param third TblAddressThird:읍.면.동
* @return String
*/
@Override
public String fullAddressString(TblAddressFirst first, TblAddressSecond second, TblAddressThird third) {
String address = first.getName();

if(first.getId() * 1000 == second.getId()) address = second.getName();
else if (second.getId() * 1000 == third.getId()) address += " " + third.getName();
else address += " " + second.getName() + " " + third.getName();

return address;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.balybus.galaxy.kakao.dto.response.KakaoResponse;
import com.balybus.galaxy.kakao.dto.response.OauthToken;
import com.balybus.galaxy.kakao.repository.TblKakaoRepository;
import com.balybus.galaxy.login.serviceImpl.service.LoginServiceImpl;
import com.balybus.galaxy.login.serviceImpl.login.LoginServiceImpl;
import com.balybus.galaxy.member.domain.TblUser;
import com.balybus.galaxy.member.domain.type.LoginType;
import com.balybus.galaxy.member.dto.request.MemberRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.balybus.galaxy.login.dto.response.AccessTokenResponse;
import com.balybus.galaxy.login.dto.response.RefreshTokenResponse;
import com.balybus.galaxy.login.dto.response.TblHelperResponse;
import com.balybus.galaxy.login.serviceImpl.service.LoginServiceImpl;
import com.balybus.galaxy.login.serviceImpl.login.LoginServiceImpl;
import com.balybus.galaxy.member.dto.request.MemberRequest;
import com.balybus.galaxy.member.dto.response.MemberResponse;
import io.swagger.v3.oas.annotations.Operation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.balybus.galaxy.login.serviceImpl;
package com.balybus.galaxy.login.serviceImpl.login;

import com.balybus.galaxy.domain.tblCenter.dto.CenterRequestDto;
import com.balybus.galaxy.domain.tblCenter.dto.CenterResponseDto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.balybus.galaxy.login.serviceImpl.service;
package com.balybus.galaxy.login.serviceImpl.login;

import com.balybus.galaxy.domain.tblAuthenticationMail.TblAuthenticationMail;
import com.balybus.galaxy.domain.tblAuthenticationMail.TblAuthenticationMailMsgEnum;
Expand Down Expand Up @@ -31,9 +31,7 @@
import com.balybus.galaxy.login.dto.request.HelperCertDTO;
import com.balybus.galaxy.login.dto.request.RefreshTokenDTO;
import com.balybus.galaxy.login.dto.request.SignUpDTO;
import com.balybus.galaxy.login.dto.response.TblHelperResponse;
import com.balybus.galaxy.login.infrastructure.jwt.TokenProvider;
import com.balybus.galaxy.login.serviceImpl.LoginService;
import com.balybus.galaxy.member.domain.TblUser;
import com.balybus.galaxy.member.domain.type.LoginType;
import com.balybus.galaxy.member.dto.request.MemberRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.balybus.galaxy.login.serviceImpl.loginAuth;

import com.balybus.galaxy.domain.tblCenterManager.TblCenterManager;

public interface LoginAuthCheckService {
TblCenterManager checkManager(String userEmail); // 관리자 권한 확인
}
Loading
Loading