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

Commit 3ccbe655 authored by 张国柄's avatar 张国柄

~API:商品管理:分类管理;

parent 080622ce
...@@ -8,6 +8,8 @@ import lombok.Data; ...@@ -8,6 +8,8 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@ApiModel(value = "GoblinStoreGoodsCategoryVo", description = "店铺商品分类") @ApiModel(value = "GoblinStoreGoodsCategoryVo", description = "店铺商品分类")
@Data @Data
...@@ -30,45 +32,15 @@ public class GoblinStoreGoodsCategoryVo implements Serializable, Cloneable { ...@@ -30,45 +32,15 @@ public class GoblinStoreGoodsCategoryVo implements Serializable, Cloneable {
@ApiModelProperty(position = 18, value = "删除标记[0-未删除|1-删除]") @ApiModelProperty(position = 18, value = "删除标记[0-未删除|1-删除]")
private String delFlg; private String delFlg;
public GoblinStoreGoodsCategoryVo setStoreId(String storeId) { private String createdBy;
this.storeId = storeId; @JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
return this; private LocalDateTime createdAt;
} private String updatedBy;
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
public GoblinStoreGoodsCategoryVo setCateId(String cateId) { private LocalDateTime updatedAt;
this.cateId = cateId; private String deletedBy;
return this; @JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
} private LocalDateTime deletedAt;
public GoblinStoreGoodsCategoryVo setName(String name) {
this.name = name;
return this;
}
public GoblinStoreGoodsCategoryVo setSort(Integer sort) {
this.sort = sort;
return this;
}
public GoblinStoreGoodsCategoryVo setGrade(String grade) {
this.grade = grade;
return this;
}
public GoblinStoreGoodsCategoryVo setCatePid(String catePid) {
this.catePid = catePid;
return this;
}
public GoblinStoreGoodsCategoryVo setNeIsbn(String neIsbn) {
this.neIsbn = neIsbn;
return this;
}
public GoblinStoreGoodsCategoryVo setDelFlg(String delFlg) {
this.delFlg = delFlg;
return this;
}
private static final GoblinStoreGoodsCategoryVo obj = new GoblinStoreGoodsCategoryVo(); private static final GoblinStoreGoodsCategoryVo obj = new GoblinStoreGoodsCategoryVo();
...@@ -79,4 +51,15 @@ public class GoblinStoreGoodsCategoryVo implements Serializable, Cloneable { ...@@ -79,4 +51,15 @@ public class GoblinStoreGoodsCategoryVo implements Serializable, Cloneable {
return new GoblinStoreGoodsCategoryVo(); return new GoblinStoreGoodsCategoryVo();
} }
} }
public GoblinStoreGoodsCategoryVo copy(GoblinSelfGoodsCategoryVo source) {
if (null == source) return this;
this.setCateId(source.getCateId());
this.setName(source.getName());
this.setSort(source.getSort());
this.setGrade(source.getGrade());
this.setCatePid(source.getCatePid());
this.setNeIsbn(source.getNeIsbn());
return this;
}
} }
...@@ -16,28 +16,28 @@ public interface IGoblinStoreMgtCategoryService { ...@@ -16,28 +16,28 @@ public interface IGoblinStoreMgtCategoryService {
/** /**
* 店铺商品分类:添加 * 店铺商品分类:添加
* *
* @param uid UID * @param storeId 店铺ID
* @param storeGoodsCategoryVos List<GoblinStoreGoodsCategoryVo> * @param addStoreGoodsCategoryVos List<GoblinStoreGoodsCategoryVo>
* @return boolean * @param storeGoodsCategoryVosCache List<GoblinStoreGoodsCategoryVo>
*/ */
boolean add(String uid, List<GoblinStoreGoodsCategoryVo> storeGoodsCategoryVos); void add(String storeId, List<GoblinStoreGoodsCategoryVo> addStoreGoodsCategoryVos, List<GoblinStoreGoodsCategoryVo> storeGoodsCategoryVosCache);
/** /**
* 店铺商品分类:编辑 * 店铺商品分类:编辑
* *
* @param uid UID * @param updateStoreGoodsCategoryVo GoblinStoreGoodsCategoryVo
* @param storeGoodsCategoryVo GoblinStoreGoodsCategoryVo * @param storeGoodsCategoryVosCache List<GoblinStoreGoodsCategoryVo>
* @return boolean * @return boolean
*/ */
boolean edit(String uid, GoblinStoreGoodsCategoryVo storeGoodsCategoryVo); boolean edit(GoblinStoreGoodsCategoryVo updateStoreGoodsCategoryVo, List<GoblinStoreGoodsCategoryVo> storeGoodsCategoryVosCache);
/** /**
* 店铺商品分类:删除 * 店铺商品分类:删除
* *
* @param uid UID * @param uid UID
* @param storeId 店铺ID * @param storeId 店铺ID
* @param cateid 店铺分类ID * @param cateId 店铺分类ID
* @return boolean * @return boolean
*/ */
boolean del(String uid, String storeId, String cateid); boolean del(String uid, String storeId, String cateId);
} }
package com.liquidnet.service.goblin.service.impl.manage; package com.liquidnet.service.goblin.service.impl.manage;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreGoodsCategoryVo; import com.liquidnet.service.goblin.dto.vo.GoblinStoreGoodsCategoryVo;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtCategoryService; import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtCategoryService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils; import com.liquidnet.service.goblin.util.GoblinMongoUtils;
...@@ -7,8 +10,12 @@ import com.liquidnet.service.goblin.util.GoblinRedisUtils; ...@@ -7,8 +10,12 @@ import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.QueueUtils; import com.liquidnet.service.goblin.util.QueueUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Optional;
@Service @Service
public class GoblinStoreMgtCategoryServiceImpl implements IGoblinStoreMgtCategoryService { public class GoblinStoreMgtCategoryServiceImpl implements IGoblinStoreMgtCategoryService {
...@@ -25,20 +32,65 @@ public class GoblinStoreMgtCategoryServiceImpl implements IGoblinStoreMgtCategor ...@@ -25,20 +32,65 @@ public class GoblinStoreMgtCategoryServiceImpl implements IGoblinStoreMgtCategor
} }
@Override @Override
public boolean add(String uid, List<GoblinStoreGoodsCategoryVo> storeGoodsCategoryVos) { public void add(String storeId, List<GoblinStoreGoodsCategoryVo> addStoreGoodsCategoryVos, List<GoblinStoreGoodsCategoryVo> storeGoodsCategoryVosCache) {
// TODO: 2022/1/11 zhanggb goblinMongoUtils.setStoreGoodsCategoryVos(addStoreGoodsCategoryVos);
return true;
if (CollectionUtils.isEmpty(storeGoodsCategoryVosCache)) {
storeGoodsCategoryVosCache = addStoreGoodsCategoryVos;
} else {
storeGoodsCategoryVosCache.addAll(addStoreGoodsCategoryVos);
}
goblinRedisUtils.setStoreGoodsCategoryVos(storeId, storeGoodsCategoryVosCache);
LinkedList<Object[]> initStoreGoodsCategoryObjs = CollectionUtil.linkedListObjectArr();
addStoreGoodsCategoryVos.forEach(r -> initStoreGoodsCategoryObjs.add(new Object[]{
r.getStoreId(), r.getCateId(), r.getName(), r.getSort(), r.getGrade(), r.getCatePid(), r.getNeIsbn(), r.getCreatedBy(), r.getCreatedAt()
}));
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("goblin_store_goods_category.insert", initStoreGoodsCategoryObjs));
} }
@Override @Override
public boolean edit(String uid, GoblinStoreGoodsCategoryVo storeGoodsCategoryVo) { public boolean edit(GoblinStoreGoodsCategoryVo updateStoreGoodsCategoryVo, List<GoblinStoreGoodsCategoryVo> storeGoodsCategoryVosCache) {
// TODO: 2022/1/11 zhanggb if (goblinMongoUtils.updateStoreGoodsCategoryVo(updateStoreGoodsCategoryVo)) {
goblinRedisUtils.setStoreGoodsCategoryVos(updateStoreGoodsCategoryVo.getStoreId(), storeGoodsCategoryVosCache);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(), SqlMapping.get("goblin_store_goods_category.update",
updateStoreGoodsCategoryVo.getName(), updateStoreGoodsCategoryVo.getSort(), updateStoreGoodsCategoryVo.getUpdatedBy(),
updateStoreGoodsCategoryVo.getUpdatedAt(), updateStoreGoodsCategoryVo.getStoreId(), updateStoreGoodsCategoryVo.getCateId())
);
return true; return true;
} }
return false;
}
@Override @Override
public boolean del(String uid, String storeId, String cateid) { public boolean del(String uid, String storeId, String cateId) {
// TODO: 2022/1/11 zhanggb List<GoblinStoreGoodsCategoryVo> storeGoodsCategoryVosCache = goblinRedisUtils.getStoreGoodsCategoryVos(storeId);
int beforeSize = storeGoodsCategoryVosCache.size();
storeGoodsCategoryVosCache.removeIf(r -> r.getCateId().equals(cateId));
int afterSize = storeGoodsCategoryVosCache.size();
if (beforeSize > afterSize) {
LocalDateTime now = LocalDateTime.now();
GoblinStoreGoodsCategoryVo delStoreGoodsCategoryVo = GoblinStoreGoodsCategoryVo.getNew();
delStoreGoodsCategoryVo.setStoreId(storeId);
delStoreGoodsCategoryVo.setCateId(cateId);
delStoreGoodsCategoryVo.setDelFlg("1");
delStoreGoodsCategoryVo.setUpdatedBy(uid);
delStoreGoodsCategoryVo.setUpdatedAt(now);
delStoreGoodsCategoryVo.setDeletedBy(uid);
delStoreGoodsCategoryVo.setDeletedAt(now);
if (goblinMongoUtils.updateStoreGoodsCategoryVo(delStoreGoodsCategoryVo)) {
goblinRedisUtils.setStoreGoodsCategoryVos(storeId, storeGoodsCategoryVosCache);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("goblin_store_goods_category.remove",
uid, now, uid, now, storeId, cateId)
);
}
}
return true; return true;
} }
} }
...@@ -54,6 +54,17 @@ public class GoblinMongoUtils { ...@@ -54,6 +54,17 @@ public class GoblinMongoUtils {
/* ---------------------------------------- 店铺分类数据源 ---------------------------------------- */ /* ---------------------------------------- 店铺分类数据源 ---------------------------------------- */
public void setStoreGoodsCategoryVos(List<GoblinStoreGoodsCategoryVo> vos) {
mongoTemplate.insert(vos, GoblinStoreGoodsCategoryVo.class.getSimpleName());
}
public boolean updateStoreGoodsCategoryVo(GoblinStoreGoodsCategoryVo vo) {
return mongoTemplate.getCollection(GoblinStoreGoodsCategoryVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("storeId").is(vo.getStoreId()).and("cateId").is(vo.getCateId())).getQueryObject(),
ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo))
).getModifiedCount() > 0;
}
public List<GoblinStoreGoodsCategoryVo> getStoreGoodsCategoryVos(String storeId) { public List<GoblinStoreGoodsCategoryVo> getStoreGoodsCategoryVos(String storeId) {
return mongoTemplate.find(Query.query(Criteria.where("storeId").is(storeId)), return mongoTemplate.find(Query.query(Criteria.where("storeId").is(storeId)),
GoblinStoreGoodsCategoryVo.class, GoblinStoreGoodsCategoryVo.class.getSimpleName()); GoblinStoreGoodsCategoryVo.class, GoblinStoreGoodsCategoryVo.class.getSimpleName());
...@@ -300,7 +311,7 @@ public class GoblinMongoUtils { ...@@ -300,7 +311,7 @@ public class GoblinMongoUtils {
// SPU分页 // SPU分页
public PagedResult<GoblinStoreMgtGoodsListVo> getGoodsInfoVo(GoblinStoreMgtGoodsFilterParam filterParam) { public PagedResult<GoblinStoreMgtGoodsListVo> getGoodsInfoVo(GoblinStoreMgtGoodsFilterParam filterParam) {
Criteria criteria = Criteria.where("delFlg").is("0"); Criteria criteria = Criteria.where("delFlg").is("0").and("storeId").is(filterParam.getStoreId());
if (StringUtils.isNotBlank(filterParam.getKeyword())) { if (StringUtils.isNotBlank(filterParam.getKeyword())) {
Pattern pattern = Pattern.compile("^.*" + filterParam.getKeyword() + ".*$", Pattern.CASE_INSENSITIVE); Pattern pattern = Pattern.compile("^.*" + filterParam.getKeyword() + ".*$", Pattern.CASE_INSENSITIVE);
criteria.andOperator( criteria.andOperator(
......
...@@ -119,6 +119,10 @@ public class GoblinRedisUtils { ...@@ -119,6 +119,10 @@ public class GoblinRedisUtils {
/* ---------------------------------------- 店铺分类数据源 ---------------------------------------- */ /* ---------------------------------------- 店铺分类数据源 ---------------------------------------- */
public boolean setStoreGoodsCategoryVos(String storeId, List<GoblinStoreGoodsCategoryVo> vos) {
return redisUtil.set(GoblinRedisConst.BASIC_STORE_GOODS_CATEGORY.concat(storeId), JsonUtils.toJson(vos));
}
public List<GoblinStoreGoodsCategoryVo> getStoreGoodsCategoryVos(String storeId) { public List<GoblinStoreGoodsCategoryVo> getStoreGoodsCategoryVos(String storeId) {
String rk = GoblinRedisConst.BASIC_STORE_GOODS_CATEGORY.concat(storeId); String rk = GoblinRedisConst.BASIC_STORE_GOODS_CATEGORY.concat(storeId);
String valStr = (String) redisUtil.get(rk); String valStr = (String) redisUtil.get(rk);
......
...@@ -16,6 +16,10 @@ goblin_store_notice.update=UPDATE goblin_store_notice set content=?,release_time ...@@ -16,6 +16,10 @@ goblin_store_notice.update=UPDATE goblin_store_notice set content=?,release_time
goblin_store_notice.release=UPDATE goblin_store_notice SET release_time=?,status='1',updated_by=?,updated_at=? WHERE store_id=? AND notice_id=? goblin_store_notice.release=UPDATE goblin_store_notice SET release_time=?,status='1',updated_by=?,updated_at=? WHERE store_id=? AND notice_id=?
goblin_store_notice.remove=UPDATE goblin_store_notice SET del_flg='1',updated_by=?,updated_at=? WHERE store_id=? AND notice_id=? goblin_store_notice.remove=UPDATE goblin_store_notice SET del_flg='1',updated_by=?,updated_at=? WHERE store_id=? AND notice_id=?
#---- 店铺商品分类信息
goblin_store_goods_category.insert=INSERT INTO goblin_store_goods_category (store_id,cate_id,name,sort,grade,cate_pid,ne_isbn,created_by,created_at)VALUES(?,?,?,?,?,?,?,?,?)
goblin_store_goods_category.update=UPDATE goblin_store_goods_category SET name=?,sort=?,updated_by=?,updated_at=? WHERE store_id=? AND cate_id=?
goblin_store_goods_category.remove=UPDATE goblin_store_goods_category SET del_flg='1',updated_by=?,updated_at=?,deleted_by=?,updated_at=? WHERE store_id=? AND cate_id=?
#---- 商品信息 #---- 商品信息
goblin_goods.insert=INSERT INTO goblin_goods (spu_id,spu_no,name,subtitle,sell_price, price_ge,price_le,intro,details,cover_pic, video,spec_mode,store_id,cate_fid,cate_sid, cate_tid,store_cate_fid,store_cate_sid,store_cate_tid,brand_id, shelves_handle,shelves_time,spu_validity,virtual_flg,status, shelves_status,spu_appear,shelves_at,created_by,created_at, logistics_template)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) goblin_goods.insert=INSERT INTO goblin_goods (spu_id,spu_no,name,subtitle,sell_price, price_ge,price_le,intro,details,cover_pic, video,spec_mode,store_id,cate_fid,cate_sid, cate_tid,store_cate_fid,store_cate_sid,store_cate_tid,brand_id, shelves_handle,shelves_time,spu_validity,virtual_flg,status, shelves_status,spu_appear,shelves_at,created_by,created_at, logistics_template)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_goods.update_by_shelves=UPDATE goblin_goods SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND spu_appear='0' goblin_goods.update_by_shelves=UPDATE goblin_goods SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND spu_appear='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