开始迁移搜索服务
This commit is contained in:
@@ -43,15 +43,6 @@ public class AdminsProductAttrController {
|
||||
@Autowired
|
||||
private ProductAttrService productAttrService;
|
||||
|
||||
@GetMapping("/attr/page")
|
||||
@ApiOperation("获得规格分页")
|
||||
public CommonResult<PageResult<AdminsProductAttrPageResponse>> attrPage(ProductAttrPageRequest request) {
|
||||
ProductAttrPageDTO pageDTO = ProductAttrConvert.INSTANCE.convert(request);
|
||||
PageResult<ProductAttrWithValueBO> productAttrPage = productAttrService.getProductAttrPage(pageDTO);
|
||||
PageResult<AdminsProductAttrPageResponse> adminPageResponse = ProductAttrConvert.INSTANCE.convertPage(productAttrPage);
|
||||
return CommonResult.success(adminPageResponse);
|
||||
}
|
||||
|
||||
@GetMapping("/attr/tree")
|
||||
@ApiOperation(value = "获得规格树结构", notes = "该接口返回的信息更为精简。一般用于前端缓存数据字典到本地。")
|
||||
public CommonResult<List<AdminsProductAttrSimpleResponse>> tree() {
|
||||
@@ -60,76 +51,4 @@ public class AdminsProductAttrController {
|
||||
return CommonResult.success(ProductAttrConvert.INSTANCE.convertSimple(result));
|
||||
}
|
||||
|
||||
@PostMapping("/attr/add")
|
||||
@ApiOperation(value = "创建商品规格")
|
||||
public CommonResult<AdminsProdutAttrResponse> addAttr(@Validated ProductAttrAddRequest addRequest) {
|
||||
// 创建 ProductAttrAddDTO 对象
|
||||
ProductAttrAddDTO productAttrAddDTO = new ProductAttrAddDTO().setName(addRequest.getName());
|
||||
// 添加
|
||||
ProductAttrBO result = productAttrService.addProductAttr(AdminSecurityContextHolder.getContext().getAdminId(), productAttrAddDTO);
|
||||
return CommonResult.success(ProductAttrConvert.INSTANCE.convertAttr(result));
|
||||
}
|
||||
|
||||
@PostMapping("/attr/update")
|
||||
@ApiOperation(value = "修改商品规格")
|
||||
public CommonResult<Boolean> updateAttr(@Validated ProductAttrUpdateRequest updateRequest) {
|
||||
ProductAttrUpdateDTO productAttrUpdateDTO = ProductAttrConvert.INSTANCE.convertUpdate(updateRequest);
|
||||
// 更新
|
||||
return CommonResult.success(productAttrService.updateProductAttr(AdminSecurityContextHolder.getContext().getAdminId(), productAttrUpdateDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/attr/update_status")
|
||||
@ApiOperation(value = "修改商品规格状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "规格编号", required = true, example = "100"),
|
||||
@ApiImplicitParam(name = "status", value = "状态", required = true, example = "1")
|
||||
})
|
||||
public CommonResult<Boolean> updateAttrStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return CommonResult.success(productAttrService.updateProductAttrStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status));
|
||||
}
|
||||
|
||||
// TODO 芋艿 暂时不考虑 delete Attr 。因为关联逻辑比较多
|
||||
|
||||
@PostMapping("/attr_value/add")
|
||||
@ApiOperation(value = "创建商品规格值")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "attrId", value = "规格编号", required = true, example = "100"),
|
||||
@ApiImplicitParam(name = "name", value = "规格值", required = true, example = "蓝色")
|
||||
})
|
||||
public CommonResult<AdminsProductAttrValueResponse> addAttrValue(@Validated ProductAttrValueAddRequest addRequest) {
|
||||
// 创建 ProductAttrValueAddDTO 对象
|
||||
ProductAttrValueAddDTO productAttrValueAddDTO = new ProductAttrValueAddDTO().setAttrId(addRequest.getAttrId()).setName(addRequest.getName());
|
||||
// 添加
|
||||
ProductAttrValueBO result = productAttrService.addProductAttrValue(AdminSecurityContextHolder.getContext().getAdminId(), productAttrValueAddDTO);
|
||||
// 返回结果
|
||||
return CommonResult.success(ProductAttrConvert.INSTANCE.convertAddResponse(result));
|
||||
}
|
||||
|
||||
@PostMapping("/attr_value/update")
|
||||
@ApiOperation(value = "修改商品规格值")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "规格值编号", required = true, example = "100"),
|
||||
@ApiImplicitParam(name = "name", value = "规格值", required = true, example = "蓝色")
|
||||
})
|
||||
public CommonResult<Boolean> updateAttrValue(@RequestParam("id") Integer id,
|
||||
@RequestParam("name") String name) {
|
||||
// 创建 ProductAttrValueUpdateDTO 对象
|
||||
ProductAttrValueUpdateDTO productAttrValueUpdateDTO = new ProductAttrValueUpdateDTO().setId(id).setName(name);
|
||||
// 更新
|
||||
return CommonResult.success(productAttrService.updateProductAttrValue(AdminSecurityContextHolder.getContext().getAdminId(), productAttrValueUpdateDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/attr_value/update_status")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "规格编号", required = true, example = "100"),
|
||||
@ApiImplicitParam(name = "status", value = "状态", required = true, example = "1")
|
||||
})
|
||||
public CommonResult<Boolean> updateAttrValueStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return CommonResult.success(productAttrService.updateProductAttrValueStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status));
|
||||
}
|
||||
|
||||
// TODO 芋艿 暂时不考虑 delete Attr Value 。因为关联逻辑比较多
|
||||
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package cn.iocoder.mall.product.rest.controller.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandAddDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandPageDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandUpdateDTO;
|
||||
import cn.iocoder.mall.product.biz.service.brand.ProductBrandService;
|
||||
import cn.iocoder.mall.product.rest.convert.brand.ProductBrandConvert;
|
||||
import cn.iocoder.mall.product.rest.request.brand.ProductBrandAddRequest;
|
||||
import cn.iocoder.mall.product.rest.request.brand.ProductBrandPageRequest;
|
||||
import cn.iocoder.mall.product.rest.request.brand.ProductBrandUpdateRequest;
|
||||
import cn.iocoder.mall.product.rest.response.brand.AdminsProductBrandResponse;
|
||||
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/brand")
|
||||
@Api("管理员 - 商品品牌 API")
|
||||
@AllArgsConstructor
|
||||
public class AdminsProductBrandController {
|
||||
|
||||
private final ProductBrandService productBrandService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("创建品牌")
|
||||
public CommonResult<AdminsProductBrandResponse> add(@Validated ProductBrandAddRequest addRequest) {
|
||||
// 创建 ProductBrandAddDTO 对象
|
||||
ProductBrandAddDTO productBrandAddDTO = ProductBrandConvert.INSTANCE.convertAdd(addRequest);
|
||||
// 保存品牌
|
||||
ProductBrandBO result = productBrandService.addProductBrand(AdminSecurityContextHolder.getContext().getAdminId(), productBrandAddDTO);
|
||||
// 返回结果
|
||||
return success(ProductBrandConvert.INSTANCE.convert(result));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新商品")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "品牌主键", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "name", value = "品牌名称", required = true, example = "安踏"),
|
||||
@ApiImplicitParam(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋"),
|
||||
@ApiImplicitParam(name = "picUrl", value = "品牌图片", required = true, example = "http://www.iocoder.cn"),
|
||||
@ApiImplicitParam(name = "status", value = "状态 1开启 2禁用", required = true, example = "1")
|
||||
})
|
||||
// TODO FROM 芋艿 to q2118cs:只要改成了 bean 接收,就不用在写 @ApiImplicitParam 注解啦,直接在 bean 里写就 ok 啦
|
||||
public CommonResult<Boolean> update(@Validated ProductBrandUpdateRequest updateRequest) {
|
||||
// 创建 productBrandUpdateDTO 对象
|
||||
ProductBrandUpdateDTO productBrandUpdateDTO = ProductBrandConvert.INSTANCE.convertUpdate(updateRequest);
|
||||
// 更新商品
|
||||
return success(productBrandService.updateProductBrand(AdminSecurityContextHolder.getContext().getAdminId(), productBrandUpdateDTO));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获取品牌")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "品牌主键", required = true, example = "1")
|
||||
})
|
||||
public CommonResult<AdminsProductBrandResponse> add(@RequestParam("id") Integer id) {
|
||||
// 保存商品
|
||||
ProductBrandBO result = productBrandService.getProductBrand(id);
|
||||
// 返回结果
|
||||
return success(ProductBrandConvert.INSTANCE.convert(result));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得品牌分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name", value = "品牌名称", required = true, example = "安踏"),
|
||||
@ApiImplicitParam(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋"),
|
||||
@ApiImplicitParam(name = "status", value = "状态 1开启 2禁用", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "页面大小", required = true, example = "10")
|
||||
})
|
||||
public CommonResult<PageResult<AdminsProductBrandResponse>> attrPage(ProductBrandPageRequest pageRequest) {
|
||||
// 创建 ProductBrandPageDTO 对象
|
||||
ProductBrandPageDTO productBrandPageDTO = ProductBrandConvert.INSTANCE.convertPageRequest(pageRequest);
|
||||
// 查询分页
|
||||
PageResult<ProductBrandBO> productBrandPage = productBrandService.getProductBrandPage(productBrandPageDTO);
|
||||
PageResult<AdminsProductBrandResponse> adminPageResponse = ProductBrandConvert.INSTANCE.convertPage(productBrandPage);
|
||||
return CommonResult.success(adminPageResponse);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,18 +1,7 @@
|
||||
package cn.iocoder.mall.product.rest.convert.attr;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrBO;
|
||||
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrSimpleWithValueBO;
|
||||
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrValueBO;
|
||||
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrWithValueBO;
|
||||
import cn.iocoder.mall.product.biz.dto.attr.ProductAttrPageDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.attr.ProductAttrUpdateDTO;
|
||||
import cn.iocoder.mall.product.rest.request.attr.ProductAttrPageRequest;
|
||||
import cn.iocoder.mall.product.rest.request.attr.ProductAttrUpdateRequest;
|
||||
import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrPageResponse;
|
||||
import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrSimpleResponse;
|
||||
import cn.iocoder.mall.product.rest.response.attr.AdminsProdutAttrResponse;
|
||||
import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrValueResponse;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -24,22 +13,8 @@ public interface ProductAttrConvert {
|
||||
|
||||
ProductAttrConvert INSTANCE = Mappers.getMapper(ProductAttrConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrPageDTO convert(ProductAttrPageRequest bean);
|
||||
|
||||
@Mappings({})
|
||||
PageResult<AdminsProductAttrPageResponse> convertPage(PageResult<ProductAttrWithValueBO> productAttrPage);
|
||||
|
||||
@Mappings({})
|
||||
List<AdminsProductAttrSimpleResponse> convertSimple(List<ProductAttrSimpleWithValueBO> simpleList);
|
||||
|
||||
@Mappings({})
|
||||
AdminsProdutAttrResponse convertAttr(ProductAttrBO attrBO);
|
||||
|
||||
@Mappings({})
|
||||
ProductAttrUpdateDTO convertUpdate(ProductAttrUpdateRequest updateRequest);
|
||||
|
||||
@Mappings({})
|
||||
AdminsProductAttrValueResponse convertAddResponse(ProductAttrValueBO result);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package cn.iocoder.mall.product.rest.convert.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandAddDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandPageDTO;
|
||||
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandUpdateDTO;
|
||||
import cn.iocoder.mall.product.rest.request.brand.ProductBrandAddRequest;
|
||||
import cn.iocoder.mall.product.rest.request.brand.ProductBrandPageRequest;
|
||||
import cn.iocoder.mall.product.rest.request.brand.ProductBrandUpdateRequest;
|
||||
import cn.iocoder.mall.product.rest.response.brand.AdminsProductBrandResponse;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface ProductBrandConvert {
|
||||
|
||||
ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
AdminsProductBrandResponse convert(ProductBrandBO brand);
|
||||
|
||||
@Mappings({})
|
||||
ProductBrandAddDTO convertAdd(ProductBrandAddRequest addRequest);
|
||||
|
||||
@Mappings({})
|
||||
ProductBrandUpdateDTO convertUpdate(ProductBrandUpdateRequest updateRequest);
|
||||
|
||||
@Mappings({})
|
||||
ProductBrandPageDTO convertPageRequest(ProductBrandPageRequest pageRequest);
|
||||
|
||||
@Mappings({})
|
||||
PageResult<AdminsProductBrandResponse> convertPage(PageResult<ProductBrandBO> productBrandPage);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package cn.iocoder.mall.product.rest.response.brand;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* VO
|
||||
*/
|
||||
@ApiModel(value = "商品品牌", description = "商品品牌")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsProductBrandResponse {
|
||||
/**
|
||||
* 规格编号
|
||||
*/
|
||||
@ApiModelProperty(value = "品牌编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(name = "name", value = "品牌名称", required = true, example = "安踏")
|
||||
@NotEmpty(message = "品牌名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(name = "picUrl", value = "品牌图片", required = true, example = "http://www.iocoder.cn")
|
||||
private String picUrl;
|
||||
|
||||
@ApiModelProperty(name = "status", value = "状态 1开启 2禁用", required = true, example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user