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

Commit de7323c5 authored by zhengfuxin's avatar zhengfuxin

上线 组件排序

parent 45f33802
......@@ -35,6 +35,7 @@ public class GoblinRedisConst {
public static final String FRONT_FRONT_SECKILL = PREFIX.concat("front_front_seckill"); //前端 首页秒杀
public static final String FRONT_SECKILL = PREFIX.concat("front_seckill"); //前端 秒杀列表
public static final String SELECT_GOODS = PREFIX.concat("select_goods"); //精选商品
public static final String MOUDLE_INDEX = PREFIX.concat("moudle_index"); //moudle_index 组件排序
/* ----------------------------------------------------------------- */
......
package com.liquidnet.client.admin.zhengzai.goblin.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinFrontMoudleIndexService;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.entity.GoblinFrontMoudleIndex;
import com.liquidnet.service.goblin.mapper.GoblinFrontMoudleIndexMapper;
import com.mongodb.BasicDBObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
......@@ -24,6 +32,10 @@ import java.util.List;
public class GoblinFrontMoudleIndexServiceImpl extends ServiceImpl<GoblinFrontMoudleIndexMapper, GoblinFrontMoudleIndex> implements IGoblinFrontMoudleIndexService {
@Autowired
GoblinFrontMoudleIndexMapper goblinFrontMoudleIndexMapper;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private RedisDataSourceUtil redisDataSourceUtil;
@Override
public List<GoblinFrontMoudleIndex> listGoblinFrontMoudleIndex() {
......@@ -44,8 +56,20 @@ public class GoblinFrontMoudleIndexServiceImpl extends ServiceImpl<GoblinFrontMo
//查出数据
List<GoblinFrontMoudleIndex> list=this.listGoblinFrontMoudleIndex();
// mongodb 放入
for(GoblinFrontMoudleIndex goblinFrontMoudleIndex:list){
GoblinFrontMoudleIndex goblinFrontMoudleIndex1=mongoTemplate.findOne(Query.query(Criteria.where("moudleIndexId").is(goblinFrontMoudleIndex.getMoudleIndexId())), GoblinFrontMoudleIndex.class, GoblinFrontMoudleIndex.class.getSimpleName());
if(null==goblinFrontMoudleIndex1){
mongoTemplate.save(goblinFrontMoudleIndex,GoblinFrontMoudleIndex.class.getSimpleName());
}else{
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(goblinFrontMoudleIndex)));
mongoTemplate.getCollection(GoblinFrontMoudleIndex.class.getSimpleName()).updateOne(
Query.query(Criteria.where("moudleIndexId").is(goblinFrontMoudleIndex.getMoudleIndexId())).getQueryObject(),
orderObject
);
}
}
// reids 存入
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.MOUDLE_INDEX,list);
return true;
}
......
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