考试功能
parent
c9160253b4
commit
ef83c6b961
@ -1,12 +1,32 @@
|
||||
package com.tz.platform.exam.feign.biz;
|
||||
|
||||
import com.tz.platform.entity.Question;
|
||||
import com.tz.platform.repository.QuestionDao;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FeignExamBiz {
|
||||
@Autowired
|
||||
private QuestionDao questionDao;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,List<Question>> redisTemplate;
|
||||
|
||||
public boolean putToCache(List<Long> ids,String key,long seconds){
|
||||
try {
|
||||
List<Question> questionList = questionDao.findAllByIdIn(ids);
|
||||
redisTemplate.opsForValue().set(key, questionList, seconds, TimeUnit.SECONDS);
|
||||
}catch (Exception ex){
|
||||
log.info("试题预热失败:{}",ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue