admin
2020-06-19 31e20ddb1eafa5bf64a0824629fb8c7a05450318
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
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);
    }
}