package com.ks.tool.bkz.service.impl.user;
|
|
import com.ks.tool.bkz.dao.mybatis.sdlj.SDLJShareOpenHistoryMapper;
|
import com.ks.tool.bkz.entity.user.SDLJShareOpenHistory;
|
import com.ks.tool.bkz.exception.SDLJShareOpenHistoryException;
|
import com.ks.tool.bkz.service.user.SDLJShareOpenHistoryService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
|
@Service
|
public class SDLJShareOpenHistoryServiceImpl implements SDLJShareOpenHistoryService {
|
@Resource
|
private SDLJShareOpenHistoryMapper sdljShareOpenHistoryMapper;
|
|
@Override
|
public boolean isOpen(Long uid) {
|
SDLJShareOpenHistory history = sdljShareOpenHistoryMapper.selectByUidAndTime(uid, new Date());
|
if (history == null)
|
return false;
|
return true;
|
}
|
|
@Override
|
public Date getExpireTime(Long uid) {
|
SDLJShareOpenHistory history = sdljShareOpenHistoryMapper.selectLatestOpenHistory(uid);
|
if (history == null)
|
return null;
|
return history.getExpireTime();
|
}
|
|
@Override
|
public void addHistory(SDLJShareOpenHistory history) throws SDLJShareOpenHistoryException {
|
if (history == null || history.getUid() == null || history.getCreateTime() == null || history.getExpireTime() == null)
|
throw new SDLJShareOpenHistoryException(1, "参数不完整");
|
sdljShareOpenHistoryMapper.insertSelective(history);
|
}
|
|
@Override
|
public SDLJShareOpenHistory selectLatestHistory(Long uid) {
|
return sdljShareOpenHistoryMapper.selectLatestOpenHistory(uid);
|
}
|
}
|