OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2022-02-18 612b5a21417f3c8dcaed84c1c0691dc883088f61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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);
    }
 
}