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());
|
}
|
|
}
|