| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package cn.com.goldenwater.dcproj.service.impl.tac;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.dao.TacObjSubject515Dao;
- import cn.com.goldenwater.dcproj.dao.TacObjSubjectDao;
- import cn.com.goldenwater.dcproj.model.TacObjSubject;
- import cn.com.goldenwater.dcproj.param.TacObjSubjectParam;
- import cn.com.goldenwater.dcproj.service.TacObjSubjectService;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.redis.core.RedisTemplate;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.List;
- import java.util.concurrent.TimeUnit;
- /**
- * @author lune
- * @date 2019-6-19
- */
- @Service
- @Transactional
- public class TacObjSubjectServiceImpl extends AbstractCrudService<TacObjSubject, TacObjSubjectParam> implements TacObjSubjectService {
- @Autowired
- private TacObjSubjectDao tacObjSubjectDao;
- @Autowired
- private TacObjSubject515Dao tacObjSubject515Dao;
- @Autowired
- private RedisTemplate redisTemplate;
- public TacObjSubjectServiceImpl(TacObjSubjectDao tacObjSubjectDao) {
- super(tacObjSubjectDao);
- this.tacObjSubjectDao = tacObjSubjectDao;
- }
- @Override
- public String selectCount() {
- return tacObjSubjectDao.selectCount() + "";
- }
- @Override
- public List<TacObjSubject> listType() {
- return tacObjSubjectDao.listType();
- }
- @Override
- public TacObjSubject getOne(String str) {
- if(StringUtils.isBlank(str)){
- return new TacObjSubject();
- }
- TacObjSubject objSubject= (TacObjSubject) redisTemplate.opsForValue().get("tac_obj_subject_"+str);
- if(objSubject==null){
- synchronized (this){
- objSubject= (TacObjSubject) redisTemplate.opsForValue().get("tac_obj_subject_"+str);
- if(objSubject==null) {
- objSubject = tacObjSubjectDao.get(str);
- if (objSubject != null) {
- redisTemplate.opsForValue().set("tac_obj_subject_"+str, objSubject, 10, TimeUnit.MINUTES);
- }else{
- objSubject=tacObjSubject515Dao.get(str);
- }
- }
- }
- }
- return objSubject;
- }
- }
|