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

Commit f36012c9 authored by 张国柄's avatar 张国柄

~MONGO.SQL;

parent d0ff9b36
package com.liquidnet.service.goblin.dto.vo; package com.liquidnet.service.goblin.dto.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.liquidnet.commons.lang.util.DateUtil;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
......
use dev_ln_scene; use dev_ln_scene;
#创建集合 // ================================================== 创建集合
db.createCollection("GoblinSelfGoodsCategoryVo");
db.createCollection("GoblinStoreGoodsCategoryVo");
db.createCollection("GoblinMgtCategorySpecVo");
db.createCollection("GoblinSelfTagVo");
db.createCollection("GoblinServiceSupportVo");
db.createCollection("GoblinStoreNoticeVo");
db.createCollection("GoblinStoreConfigVo");
db.createCollection("GoblinStoreInfoVo"); db.createCollection("GoblinStoreInfoVo");
db.createCollection("GoblinGoodsInfoVo");
db.createCollection("GoblinGoodsSkuInfoVo");
db.createCollection("GoblinStoreCouponBasicVo");
db.createCollection("GoblinUserCouponVo");
// ================================================== 创建分片
#创建索引
db.GoblinStoreInfoVo.createIndex({storeId:"hashed"});
#创建分片
sh.enableSharding("dev_ln_scene"); sh.enableSharding("dev_ln_scene");
sh.shardCollection("dev_ln_scene.GoblinSelfGoodsCategoryVo",{"cateId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinStoreGoodsCategoryVo",{"cateId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinMgtCategorySpecVo",{"cateId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinSelfTagVo",{"tagId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinServiceSupportVo",{"ssid":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinStoreNoticeVo",{"noticeId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinStoreConfigVo",{"storeId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinStoreInfoVo",{"storeId":"hashed"}); sh.shardCollection("dev_ln_scene.GoblinStoreInfoVo",{"storeId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinGoodsInfoVo",{"spuId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinGoodsSkuInfoVo",{"skuId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinStoreCouponBasicVo",{"storeCouponId":"hashed"});
sh.shardCollection("dev_ln_scene.GoblinUserCouponVo",{"ucouponId":"hashed"});
// ================================================== 创建索引
db.GoblinStoreGoodsCategoryVo.createIndex({storeId:"hashed"});
db.GoblinMgtCategorySpecVo.createIndex({cateId:"hashed"});
db.GoblinSelfTagVo.createIndex({tagBelong:"hashed"});
db.GoblinServiceSupportVo.createIndex({ssid:"hashed"});
db.GoblinStoreNoticeVo.createIndex({storeId:"hashed"});
db.GoblinStoreConfigVo.createIndex({storeId:"hashed"});
db.GoblinStoreInfoVo.createIndex({storeId:"hashed"});
db.GoblinGoodsInfoVo.createIndex({spuId:"hashed"});
db.GoblinGoodsInfoVo.createIndex({storeId:"hashed"});
db.GoblinGoodsInfoVo.createIndex({spuNo:"hashed"});
db.GoblinGoodsSkuInfoVo.createIndex({skuId:"hashed"});
db.GoblinGoodsSkuInfoVo.createIndex({storeId:"hashed"});
db.GoblinStoreCouponBasicVo.createIndex({storeCouponId:"hashed"});
db.GoblinUserCouponVo.createIndex({uid:"hashed"});
\ No newline at end of file
...@@ -271,8 +271,7 @@ public class GoblinMongoUtils { ...@@ -271,8 +271,7 @@ public class GoblinMongoUtils {
public boolean updateStoreInfoVo(GoblinStoreInfoVo vo) { public boolean updateStoreInfoVo(GoblinStoreInfoVo vo) {
return mongoTemplate.getCollection(GoblinStoreInfoVo.class.getSimpleName()) return mongoTemplate.getCollection(GoblinStoreInfoVo.class.getSimpleName())
.updateOne( .updateOne(Query.query(Criteria.where("storeId").is(vo.getStoreId())).getQueryObject(),
Query.query(Criteria.where("storeId").is(vo.getStoreId())).getQueryObject(),
ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo)) ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo))
).getModifiedCount() > 0; ).getModifiedCount() > 0;
} }
...@@ -416,15 +415,6 @@ public class GoblinMongoUtils { ...@@ -416,15 +415,6 @@ public class GoblinMongoUtils {
: vos.stream().map(GoblinGoodsInfoVo::getSpuId).collect(Collectors.toList()); : vos.stream().map(GoblinGoodsInfoVo::getSpuId).collect(Collectors.toList());
} }
// SKU信息
public List<String> getMgtGoodsSkuIds(String storeId, List<String> spuIdList) {
Query query = Query.query(Criteria.where("storeId").is(storeId).and("delFlg").is("0").and("spuId").in(spuIdList.toArray()));
query.fields().include("skuId");
List<GoblinGoodsSkuInfoVo> vos = mongoTemplate.find(query, GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
return CollectionUtils.isEmpty(vos) ? CollectionUtil.arrayListString()
: vos.stream().map(GoblinGoodsSkuInfoVo::getSkuId).collect(Collectors.toList());
}
// SPU信息 // SPU信息
public GoblinGoodsInfoVo getGoodsInfoVo(String spuId) { public GoblinGoodsInfoVo getGoodsInfoVo(String spuId) {
// return mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId).and("delFlg").is("0").and("shelvesStatus").is("3")), // return mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId).and("delFlg").is("0").and("shelvesStatus").is("3")),
...@@ -551,6 +541,15 @@ public class GoblinMongoUtils { ...@@ -551,6 +541,15 @@ public class GoblinMongoUtils {
GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName()); GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
} }
// SKU信息
public List<String> getMgtGoodsSkuIds(String storeId, List<String> spuIdList) {
Query query = Query.query(Criteria.where("storeId").is(storeId).and("delFlg").is("0").and("spuId").in(spuIdList.toArray()));
query.fields().include("skuId");
List<GoblinGoodsSkuInfoVo> vos = mongoTemplate.find(query, GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
return CollectionUtils.isEmpty(vos) ? CollectionUtil.arrayListString()
: vos.stream().map(GoblinGoodsSkuInfoVo::getSkuId).collect(Collectors.toList());
}
// SKU信息 // SKU信息
// public GoblinGoodsSkuInfoVo getMgtGoodsSkuInfoVo(String skuId) { // public GoblinGoodsSkuInfoVo getMgtGoodsSkuInfoVo(String skuId) {
// return mongoTemplate.findOne(Query.query(Criteria.where("skuId").is(skuId).and("delFlg").is("0")), // return mongoTemplate.findOne(Query.query(Criteria.where("skuId").is(skuId).and("delFlg").is("0")),
......
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