package com.yeshi.fanli.service.impl.user;
|
|
import com.yeshi.fanli.dao.user.UserFunctionsLimitDao;
|
import com.yeshi.fanli.entity.SystemFunction;
|
import com.yeshi.fanli.entity.bus.user.UserFunctionsLimit;
|
import com.yeshi.fanli.service.inter.user.UserFunctionsLimitService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
|
/**
|
* @author Administrator
|
* @title: UserFunctionsLimitServiceImpl
|
* @description: TODO
|
* @date 2021/9/13 19:22
|
*/
|
@Service
|
public class UserFunctionsLimitServiceImpl implements UserFunctionsLimitService {
|
|
@Resource
|
private UserFunctionsLimitDao userFunctionsLimitDao;
|
|
@Override
|
public void save(UserFunctionsLimit limit) throws Exception {
|
if (limit == null || limit.getFunction() == null || limit.getUid() == null) {
|
throw new Exception("参数不完整");
|
}
|
if (limit.getCreateTime() == null) {
|
limit.setCreateTime(new Date());
|
}
|
|
if (limit.getStartTime() == null) {
|
limit.setStartTime(new Date());
|
}
|
//默认封禁10年
|
if (limit.getEndTime() == null) {
|
limit.setEndTime(new Date(limit.getStartTime().getTime() + 1000 * 60 * 60 * 24L * 365 * 10));
|
}
|
|
userFunctionsLimitDao.save(limit);
|
}
|
|
@Override
|
public boolean isLimit(Long uid, SystemFunction function, Date date) {
|
UserFunctionsLimitDao.DaoQuery daoQuery = new UserFunctionsLimitDao.DaoQuery();
|
daoQuery.nowDate = date;
|
daoQuery.function = function;
|
daoQuery.uid = uid;
|
return userFunctionsLimitDao.count(daoQuery) > 0;
|
}
|
}
|