记得上下班打卡 | git大法好,push需谨慎

Commit f6ecd6f8 authored by zhengfuxin's avatar zhengfuxin

降级查询

parent 05cbab44
......@@ -49,10 +49,10 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
@Override
public ArrayList<GoblinFrontBannerVo> getListBanner() {
if(!redisUtil.hasKey(GoblinRedisConst.FRONT_TOP_BANNER)){
List<GoblinFrontBanner> list=goblinRedisUtils.getListBanner();
if(null==list){
return null;
}
List<GoblinFrontBanner> list= (List<GoblinFrontBanner>) redisUtil.get(GoblinRedisConst.FRONT_TOP_BANNER);
LocalDateTime nowTime= LocalDateTime.now();
ArrayList<GoblinFrontBanner> goblinFrontBannerArrayList= ObjectUtil.getGoblinFrontBannerArrayList();
//查看是否有失效的时间
......@@ -78,10 +78,10 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return list1;
}
public ArrayList<GoblinFrontBannerVo> getMiddleBanner() {
if(!redisUtil.hasKey(GoblinRedisConst.FRONT_MIDDLE_BANNER)){
List<GoblinFrontBanner> list=goblinRedisUtils.getMiddleBanner();
if(null==list){
return null;
}
List<GoblinFrontBanner> list= (List<GoblinFrontBanner>) redisUtil.get(GoblinRedisConst.FRONT_MIDDLE_BANNER);
LocalDateTime nowTime= LocalDateTime.now();
ArrayList<GoblinFrontBanner> goblinFrontBannerArrayList= ObjectUtil.getGoblinFrontBannerArrayList();
//查看是否有失效的时间
......
......@@ -9,6 +9,7 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtNoticeFilterParam;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo;
import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinFrontBanner;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.UpdateOneModel;
import com.mongodb.client.model.WriteModel;
......@@ -884,4 +885,15 @@ public class GoblinMongoUtils {
query.skip(skipCount).limit(size).with(Sort.by(Sort.Order.desc("createdAt")));
return mongoTemplate.find(query, GoblinStoreOrderVo.class, GoblinStoreOrderVo.class.getSimpleName());
}
public List<GoblinFrontBanner> getListBanner() {
Query query = Query.query(Criteria.where("delTag").is(0).and("bannerType").is(1));
return mongoTemplate.find(query,
GoblinFrontBanner.class, GoblinFrontBanner.class.getSimpleName());
}
public List<GoblinFrontBanner> getMiddleBanner() {
Query query = Query.query(Criteria.where("delTag").is(0).and("bannerType").is(2));
return mongoTemplate.find(query,
GoblinFrontBanner.class, GoblinFrontBanner.class.getSimpleName());
}
}
......@@ -8,6 +8,7 @@ import com.liquidnet.commons.lang.util.RandomUtil;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo;
import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinFrontBanner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
......@@ -866,5 +867,23 @@ public class GoblinRedisUtils {
redisUtil.del(GoblinRedisConst.SELECT_GOODS_SPUIDS);
redisUtil.del(GoblinRedisConst.SELECT_GOODS_PAGE1);
}
// banner 降级
public List<GoblinFrontBanner> getListBanner() {
List<GoblinFrontBanner> vo= (List<GoblinFrontBanner>) redisUtil.get(GoblinRedisConst.FRONT_TOP_BANNER);
if (null == vo ) {
//降级
return goblinMongoUtils.getListBanner();
}
return vo;
}
public List<GoblinFrontBanner> getMiddleBanner() {
List<GoblinFrontBanner> vo= (List<GoblinFrontBanner>) redisUtil.get(GoblinRedisConst.FRONT_MIDDLE_BANNER);
if (null == vo ) {
//降级
return goblinMongoUtils.getMiddleBanner();
}
return vo;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment