use of com.whoiszxl.entity.ProductColumn in project shopzz by whoiszxl.
the class ProductColumnServiceImpl method detail.
@Override
public ColumnDetailApiResponse detail(Long id) {
String redisKey = RedisKeyPrefixConstants.COLUMN_DETAIL + id;
String columnDetailJson = redisUtils.get(redisKey);
if (StringUtils.isBlank(columnDetailJson)) {
synchronized (ProductColumnServiceImpl.class) {
columnDetailJson = redisUtils.get(redisKey);
if (StringUtils.isBlank(columnDetailJson)) {
ColumnDetailApiResponse response = new ColumnDetailApiResponse();
// 从DB获取
ProductColumn productColumn = super.getById(id);
dozerUtils.map(productColumn, response);
List<ProductColumnSpu> productColumnSpuList = productColumnSpuService.list(Wrappers.<ProductColumnSpu>lambdaQuery().eq(ProductColumnSpu::getColumnId, id));
if (ObjectUtils.isEmpty(productColumnSpuList)) {
ExceptionCatcher.catchValidateEx(ResponseResult.buildError("专栏下无商品"));
}
List<Long> spuIds = productColumnSpuList.stream().map(ProductColumnSpu::getSpuId).collect(Collectors.toList());
String feignParams = ParamUtils.array2Str(spuIds);
ResponseResult<List<SpuFeignDTO>> feignResponse = productFeignClient.getSpuListBySpuIdList(feignParams);
if (!feignResponse.isOk()) {
ExceptionCatcher.catchValidateEx(ResponseResult.buildError(feignResponse.getMessage()));
}
List<SpuFeignDTO> spuFeignDTOList = feignResponse.getData();
List<ColumnSpuApiResponse> columnSpuApiResponses = dozerUtils.mapList(spuFeignDTOList, ColumnSpuApiResponse.class);
response.setSpuList(columnSpuApiResponses);
columnDetailJson = JsonUtil.toJson(response);
redisUtils.set(redisKey, columnDetailJson);
}
}
}
return JsonUtil.fromJson(columnDetailJson, ColumnDetailApiResponse.class);
}
use of com.whoiszxl.entity.ProductColumn in project shopzz by whoiszxl.
the class ColumnAdminController method update.
@SaCheckLogin
@PutMapping
@ApiOperation(value = "更新专栏", notes = "更新专栏", response = ResponseResult.class)
public ResponseResult<Boolean> update(@RequestBody ProductColumnUpdateCommand columnSaveCommand) {
ProductColumn column = dozerUtils.map(columnSaveCommand, ProductColumn.class);
boolean updateFlag = columnService.updateById(column);
return ResponseResult.buildByFlag(updateFlag);
}
use of com.whoiszxl.entity.ProductColumn in project shopzz by whoiszxl.
the class ColumnAdminController method save.
@SaCheckLogin
@PostMapping
@ApiOperation(value = "新增专栏", notes = "新增专栏", response = ResponseResult.class)
public ResponseResult<Boolean> save(@RequestBody ProductColumnSaveCommand columnSaveCommand) {
ProductColumn column = dozerUtils.map(columnSaveCommand, ProductColumn.class);
boolean saveFlag = columnService.save(column);
return ResponseResult.buildByFlag(saveFlag);
}
Aggregations