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

Commit 7d7e257a authored by 胡佳晨's avatar 胡佳晨

Merge remote-tracking branch 'origin/dev_goblin' into dev_goblin

parents cdee87ec 3b100546
......@@ -6,7 +6,6 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.common.exception.constant.ErrorCode;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.PagedResult;
......@@ -78,42 +77,41 @@ public class GoblinStoreMgtGoodsController {
}
@ApiOperationSupport(order = 2)
@ApiOperation(value = "SPU导出")
@ApiOperation(value = "SPU导出", notes = "#以POST模拟FORM表单请求该接口")
@PostMapping("export")
public void export(@Valid @RequestBody GoblinStoreMgtGoodsFilterParam storeMgtGoodsFilterParam,
HttpServletResponse response) {
public void export(@Valid GoblinStoreMgtGoodsFilterParam storeMgtGoodsFilterParam, HttpServletResponse response) {
String currentUid = CurrentUtil.getCurrentUid();
List<String> storeIds = goblinRedisUtils.getStoreIds(currentUid);
String storeId = storeMgtGoodsFilterParam.getStoreId();
boolean storeIdIsBlank = StringUtils.isBlank(storeId);
if (CollectionUtils.isEmpty(storeIds) || (
!storeIdIsBlank && !goblinRedisUtils.hasStoreId(currentUid, storeId)
)) {
return;
}
if (log.isDebugEnabled()) {
log.debug("商品管理:SPU导出:[UID={},GoblinStoreMgtGoodsFilterParam={}]", currentUid, JsonUtils.toJson(storeMgtGoodsFilterParam));
}
if (storeIdIsBlank) {
storeMgtGoodsFilterParam.setStoreId(storeIds.get(0));
}
try {
List<String> storeIds = goblinRedisUtils.getStoreIds(currentUid);
String storeId = storeMgtGoodsFilterParam.getStoreId();
boolean storeIdIsBlank = StringUtils.isBlank(storeId);
if (CollectionUtils.isEmpty(storeIds) || (
!storeIdIsBlank && !goblinRedisUtils.hasStoreId(currentUid, storeId)
)) {
return;
}
if (log.isDebugEnabled()) {
log.debug("商品管理:SPU导出:[UID={},GoblinStoreMgtGoodsFilterParam={}]", currentUid, JsonUtils.toJson(storeMgtGoodsFilterParam));
}
if (storeIdIsBlank) {
storeMgtGoodsFilterParam.setStoreId(storeIds.get(0));
}
storeMgtGoodsFilterParam.setPageNum(1);
storeMgtGoodsFilterParam.setPageSize(2000);
PagedResult<GoblinStoreMgtGoodsListVo> pagedResult = goblinstoreMgtGoodsService.goodsList(storeMgtGoodsFilterParam);
List<GoblinStoreMgtGoodsListVo> rows = pagedResult.getList();
ArrayList<GoblinStoreMgtGoodsListVoExcel> rowsToExcels = ObjectUtil.getGoblinStoreMgtGoodsListVoExcelArrayList();
rows.forEach(row -> rowsToExcels.add(GoblinStoreMgtGoodsListVoExcel.getNew().copy(row)));
storeMgtGoodsFilterParam.setPageNum(1);
storeMgtGoodsFilterParam.setPageSize(2000);
PagedResult<GoblinStoreMgtGoodsListVo> pagedResult = goblinstoreMgtGoodsService.goodsList(storeMgtGoodsFilterParam);
List<GoblinStoreMgtGoodsListVo> rows = pagedResult.getList();
List<GoblinStoreMgtGoodsListVoExcel> rowsToExcels = ObjectUtil.getGoblinStoreMgtGoodsListVoExcelArrayList();
rows.forEach(row -> rowsToExcels.add(GoblinStoreMgtGoodsListVoExcel.getNew().copy(row)));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = "商品数据" + DateUtil.Formatter.yyyyMMddHHmmssTrim.format(LocalDateTime.now());
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("商品数据", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
try {
EasyExcel.write(response.getOutputStream()).sheet("SPU").doWrite(rows);
EasyExcel.write(response.getOutputStream(), GoblinStoreMgtGoodsListVoExcel.class).sheet("SPU").doWrite(rowsToExcels);
} catch (IOException e) {
log.error("商品管理:SPU导出:异常[UID={},storeId={},ex.msg={}]", currentUid, storeId, e.getLocalizedMessage());
log.error("商品管理:SPU导出:异常[UID={},ex.msg={}]", currentUid, e.getLocalizedMessage());
}
}
......
......@@ -61,7 +61,9 @@ public class GoblinStoreMgtGoodsListVoExcel implements Serializable, Cloneable {
this.setSpuNo(source.getSpuNo());
this.setCoverPic(source.getCoverPic());
this.setName(source.getName());
this.setCateMerge(source.getCateFid() + "/" + source.getCateSid() + "/" + source.getCateTid());
this.setCateMerge(StringUtils.defaultString(source.getCateFid(), "") + "/"
+ StringUtils.defaultString(source.getCateSid(), "") + "/"
+ StringUtils.defaultString(source.getCateTid(), ""));
this.setPriceRange("¥" + source.getPriceGe().toString() + " - ¥" + source.getPriceLe().toString());
switch (source.getShelvesStatus()) {
case "0":
......
......@@ -109,12 +109,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
@Override
public GoblinFrontHotWord getHotWord() {
if(!redisUtil.hasKey(GoblinRedisConst.FRONT_HOTWORD)){
return null;
}
List<GoblinFrontHotWord> list=goblinRedisUtils.getHotWord();
// int index= (int) redisUtil.get(GoblinRedisConst.FRONT_HOTWORD_INDEX);
//获得value
List<GoblinFrontHotWord> list= (List<GoblinFrontHotWord>) redisUtil.get(GoblinRedisConst.FRONT_HOTWORD);
/* index++;
String hotWord="";
redisUtil.set(GoblinRedisConst.FRONT_HOTWORD_INDEX,index);
......
......@@ -10,6 +10,7 @@ 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.liquidnet.service.goblin.entity.GoblinFrontHotWord;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.UpdateOneModel;
import com.mongodb.client.model.WriteModel;
......@@ -896,4 +897,9 @@ public class GoblinMongoUtils {
GoblinFrontBanner.class, GoblinFrontBanner.class.getSimpleName());
}
public List<GoblinFrontHotWord> getHotWord() {
Query query = Query.query(Criteria.where("delTag").is(0));
return mongoTemplate.find(query,
GoblinFrontHotWord.class, GoblinFrontHotWord.class.getSimpleName());
}
}
......@@ -9,6 +9,7 @@ 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 com.liquidnet.service.goblin.entity.GoblinFrontHotWord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
......@@ -884,6 +885,15 @@ public class GoblinRedisUtils {
}
return vo;
}
// 热词降级
public List<GoblinFrontHotWord> getHotWord() {
List<GoblinFrontHotWord> vo= (List<GoblinFrontHotWord>) redisUtil.get(GoblinRedisConst.FRONT_HOTWORD);
if (null == vo ) {
//降级
return goblinMongoUtils.getHotWord();
}
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