Search in sources :

Example 1 with ProductColumn

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);
}
Also used : ProductColumnSpu(com.whoiszxl.entity.ProductColumnSpu) ColumnDetailApiResponse(com.whoiszxl.cqrs.response.ColumnDetailApiResponse) SpuFeignDTO(com.whoiszxl.dto.SpuFeignDTO) ColumnSpuApiResponse(com.whoiszxl.cqrs.response.ColumnSpuApiResponse) List(java.util.List) ProductColumn(com.whoiszxl.entity.ProductColumn)

Example 2 with ProductColumn

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);
}
Also used : ProductColumn(com.whoiszxl.entity.ProductColumn) SaCheckLogin(cn.dev33.satoken.annotation.SaCheckLogin) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with ProductColumn

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);
}
Also used : ProductColumn(com.whoiszxl.entity.ProductColumn) SaCheckLogin(cn.dev33.satoken.annotation.SaCheckLogin) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ProductColumn (com.whoiszxl.entity.ProductColumn)3 SaCheckLogin (cn.dev33.satoken.annotation.SaCheckLogin)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ColumnDetailApiResponse (com.whoiszxl.cqrs.response.ColumnDetailApiResponse)1 ColumnSpuApiResponse (com.whoiszxl.cqrs.response.ColumnSpuApiResponse)1 SpuFeignDTO (com.whoiszxl.dto.SpuFeignDTO)1 ProductColumnSpu (com.whoiszxl.entity.ProductColumnSpu)1 List (java.util.List)1