package kr.wisestone.owl.service.impl;
|
|
import kr.wisestone.owl.constant.MsgConstants;
|
import kr.wisestone.owl.domain.User;
|
import kr.wisestone.owl.domain.UserWithDraw;
|
import kr.wisestone.owl.exception.OwlRuntimeException;
|
import kr.wisestone.owl.repository.UserWithDrawRepository;
|
import kr.wisestone.owl.service.UserWithDrawService;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
@Service
|
public class UserWithDrawServiceImpl extends AbstractServiceImpl<UserWithDraw, Long, JpaRepository<UserWithDraw, Long>> implements UserWithDrawService {
|
|
private static final Logger log = LoggerFactory.getLogger(UserWithDrawServiceImpl.class);
|
|
@Autowired
|
private UserWithDrawRepository userWithDrawRepository;
|
|
@Override
|
protected JpaRepository<UserWithDraw, Long> getRepository() {
|
return this.userWithDrawRepository;
|
}
|
|
// 회원 탈퇴가 예정되어 있는지 확인하고 없으면 회원 탈퇴 예정으로 등록한다.
|
@Override
|
@Transactional
|
public void addUserWithDraw(User user) {
|
UserWithDraw userWithDraw = this.findByAccount(user.getAccount());
|
|
if (userWithDraw != null) {
|
throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.USER_WITH_DRAW_EXIST));
|
}
|
|
this.userWithDrawRepository.saveAndFlush(new UserWithDraw(user.getAccount()));
|
}
|
|
// 암호화된 이메일 주소로 회원 탈퇴 정보를 조회한다.
|
@Override
|
@Transactional(readOnly = true)
|
public UserWithDraw findByAccount(String account) {
|
return this.userWithDrawRepository.findByAccount(account);
|
}
|
|
}
|