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

Commit 27f158ac authored by 张国柄's avatar 张国柄

+api:店铺商品管理:批量导入数据;

parent c699e5dc
package com.liquidnet.service.goblin.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class GoblinGoodsImportDto {
@ExcelProperty(value = "商品编码")
private String spuCode;
@ExcelProperty(value = "商品名称")
private String spuName;
@ExcelProperty(value = "商品图片")
private String spuImgs;
@ExcelProperty(value = "商品规格")
private String skuSpec;
@ExcelProperty(value = "规格编码")
private String skuCode;
@ExcelProperty(value = "价格")
private BigDecimal price;
@ExcelProperty(value = "库存")
private Integer stock;
@ExcelProperty(value = "规格图片")
private String skuImg;
@ExcelProperty(value = "规格条码")
private String skuBarCode;
// @ExcelProperty(value = "商品条码")
// private String spuBarCode;
}
package com.liquidnet.service.goblin.controller.manage;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.service.impl.manage.GoblinStoreMgtGoodsImportService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank;
import java.io.IOException;
@Api(tags = "店铺商品管理")
@Slf4j
@RestController
@RequestMapping("store/mgt/goods")
public class GoblinStoreMgtGoodsImportController {
@Autowired
GoblinRedisUtils goblinRedisUtils;
@Autowired
private GoblinStoreMgtGoodsImportService goblinStoreMgtGoodsImportService;
@PostMapping("/upload")
@ApiOperation(value = "批量导入数据", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", dataType = "File", name = "file", value = "文件", required = true),
@ApiImplicitParam(type = "form", dataType = "Integer", name = "dataType", value = "导入数据类型[1-商品数据]", example = "1"),
@ApiImplicitParam(type = "form", dataType = "String", name = "storeId", value = "店铺ID"),
})
public ResponseDto<String> upload(@RequestParam MultipartFile file, @RequestParam int dataType,
@RequestParam @NotBlank(message = "店铺ID不能为空") String storeId) {
String currentUid = CurrentUtil.getCurrentUid();
if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
try {
switch (dataType) {
case 1:
goblinStoreMgtGoodsImportService.goodsInformationDataAnalysisProcessing(file, currentUid, storeId);
break;
case 2:
default:
return ResponseDto.failure(ErrorMapping.get("39001"));
}
} catch (LiquidnetServiceException e) {
return ResponseDto.failure(e.getMessage());
} catch (IOException e) {
log.error("店铺商品管理:批量导入数据:异常[UID={},dataType={},fileName={}]", currentUid, dataType, file.getOriginalFilename(), e);
return ResponseDto.failure("数据错误,解析失败");
}
return ResponseDto.success();
}
}
......@@ -506,6 +506,10 @@ public class GoblinMongoUtils {
return mongoTemplate.insert(vo, GoblinGoodsInfoVo.class.getSimpleName());
}
public List<GoblinGoodsInfoVo> insertMgtGoodsInfoVos(List<GoblinGoodsInfoVo> vos) {
return (List<GoblinGoodsInfoVo>) mongoTemplate.insert(vos, GoblinGoodsInfoVo.class.getSimpleName());
}
public void upsertGoodsInfoVo(GoblinGoodsInfoVo vo) {
Document document = (Document) mongoConverter.convertToMongoType(vo);
Update update = Update.fromDocument(document);
......@@ -739,6 +743,10 @@ public class GoblinMongoUtils {
return mongoTemplate.insert(vo, GoblinGoodsSkuInfoVo.class.getSimpleName());
}
public List<GoblinGoodsSkuInfoVo> insertMgtGoodsSkuInfoVos(List<GoblinGoodsSkuInfoVo> vos) {
return (List<GoblinGoodsSkuInfoVo>) mongoTemplate.insert(vos, GoblinGoodsSkuInfoVo.class.getSimpleName());
}
public UpdateResult upsertGoodsSkuInfoVo(GoblinGoodsSkuInfoVo vo) {
Document document = (Document) mongoConverter.convertToMongoType(vo);
Update update = Update.fromDocument(document);
......
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