admin
2019-02-21 7e57a20c0ccde504c2f2b2b9fd4a9fd7c89d5e92
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package org.fanli.service.user.service.impl.account;
 
import java.util.Date;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.fanli.facade.user.entity.account.ForbiddenUserIdentifyCode;
import org.fanli.facade.user.entity.account.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum;
import org.fanli.facade.user.exception.account.ForbiddenUserIdentifyCodeException;
import org.fanli.facade.user.service.account.ForbiddenUserIdentifyCodeService;
import org.fanli.service.user.dao.account.ForbiddenUserIdentifyCodeMapper;
import org.springframework.stereotype.Service;
import org.yeshi.utils.StringUtil;
 
@Service
public class ForbiddenUserIdentifyCodeServiceImpl implements ForbiddenUserIdentifyCodeService {
 
    @Resource
    private ForbiddenUserIdentifyCodeMapper forbiddenUserIdentifyCodeMapper;
 
    @Override
    public void addIdentifyCode(ForbiddenUserIdentifyCode identifyCode) throws ForbiddenUserIdentifyCodeException {
        if (identifyCode == null || identifyCode.getType() == null
                || StringUtil.isNullOrEmpty(identifyCode.getIdentifyCode()))
            throw new ForbiddenUserIdentifyCodeException(1, "信息不完整");
 
        ForbiddenUserIdentifyCode old = listByTypeAndIdentifyCode(identifyCode.getType(),
                identifyCode.getIdentifyCode());
        if (old != null)
            throw new ForbiddenUserIdentifyCodeException(2, "信息已存在");
 
        identifyCode.setCreateTime(new Date());
        identifyCode.setEffective(true);
        forbiddenUserIdentifyCodeMapper.insertSelective(identifyCode);
    }
 
    @Override
    public ForbiddenUserIdentifyCode listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum type,
            String identifyCode) {
        List<ForbiddenUserIdentifyCode> list = forbiddenUserIdentifyCodeMapper.listByTypeAndIdentifyCode(type,
                identifyCode);
        if (list != null && list.size() > 0)
            return list.get(0);
        else
            return null;
    }
 
    @Override
    public void update(ForbiddenUserIdentifyCode identifyCode) {
        if (identifyCode == null)
            return;
        identifyCode.setUpdateTime(new Date());
        forbiddenUserIdentifyCodeMapper.updateByPrimaryKeySelective(identifyCode);
    }
 
    @Override
    public void delete(ForbiddenUserIdentifyCode identifyCode) {
        if (identifyCode == null || identifyCode.getId() == null)
            return;
        forbiddenUserIdentifyCodeMapper.deleteByPrimaryKey(identifyCode.getId());
    }
 
}