合并代码

This commit is contained in:
岳鹏磊
2019-05-31 18:38:02 +08:00
parent d008e92baa
commit 7f092ce6c8
155 changed files with 9832 additions and 13 deletions

View File

@@ -0,0 +1,113 @@
package cn.iocoder.mall.product.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
import cn.iocoder.mall.product.api.ProductBrandService;
import cn.iocoder.mall.product.api.bo.ProductBrandBO;
import cn.iocoder.mall.product.api.bo.ProductBrangPageBO;
import cn.iocoder.mall.product.api.dto.ProductBrandAddDTO;
import cn.iocoder.mall.product.api.dto.ProductBrandPageDTO;
import cn.iocoder.mall.product.api.dto.ProductBrandUpdateDTO;
import cn.iocoder.mall.product.application.convert.ProductBrandConvert;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductBrandVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductBrangPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("admins/brand")
@Api("商品品牌")
public class AdminsProductBrandController {
@Reference(validation = "true", version = "${dubbo.provider.ProductBrandService.version}")
private ProductBrandService productBrandService;
@PostMapping("/add")
@ApiOperation("创建品牌")
@ApiImplicitParams({
@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")
})
public CommonResult<AdminsProductBrandVO> add(@RequestParam("name") String name,
@RequestParam("description") String description,
@RequestParam("picUrl") String picUrl,
@RequestParam("status") Integer status) {
// 创建 ProductBrandAddDTO 对象
ProductBrandAddDTO productBrandAddDTO = new ProductBrandAddDTO().setName(name).setDescription(description)
.setPicUrl(picUrl).setStatus(status);
// 保存商品
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")
})
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
@RequestParam("name") String name,
@RequestParam("description") String description,
@RequestParam("picUrl") String picUrl,
@RequestParam("status") Integer status) {
// 创建 productBrandUpdateDTO 对象
ProductBrandUpdateDTO productBrandUpdateDTO = new ProductBrandUpdateDTO().setId(id).setName(name).setDescription(description)
.setPicUrl(picUrl).setStatus(status);
// 更新商品
productBrandService.updateProductBrand(AdminSecurityContextHolder.getContext().getAdminId(), productBrandUpdateDTO);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获取品牌")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "品牌主键", required = true, example = "1")
})
public CommonResult<AdminsProductBrandVO> 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<AdminsProductBrangPageVO> attrPage(@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "description", required = false) String description,
@RequestParam(value = "status", required = false) Integer status,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
// 创建 ProductAttrPageDTO 对象
ProductBrandPageDTO productBrandPageDTO = new ProductBrandPageDTO().setName(name)
.setDescription(description)
.setStatus(status)
.setPageNo(pageNo)
.setPageSize(pageSize);
// 查询分页
ProductBrangPageBO result = productBrandService.getProductBrandPage(productBrandPageDTO);
// 返回结果
return success(ProductBrandConvert.INSTANCE.convert(result));
}
}

View File

@@ -0,0 +1,22 @@
package cn.iocoder.mall.product.application.convert;
import cn.iocoder.mall.product.api.bo.ProductBrandBO;
import cn.iocoder.mall.product.api.bo.ProductBrangPageBO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductBrandVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductBrangPageVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper
public interface ProductBrandConvert {
ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
@Mappings({})
AdminsProductBrandVO convert(ProductBrandBO result);
@Mappings({})
AdminsProductBrangPageVO convert(ProductBrangPageBO result);
}

View File

@@ -0,0 +1,38 @@
package cn.iocoder.mall.product.application.vo.admins;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 商品品牌 VO
*/
@ApiModel(value = "商品品牌 VO")
@Data
@Accessors(chain = true)
public class AdminsProductBrandVO {
/**
* 品牌编号
*/
@ApiModelProperty(value = "品牌编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "名称", required = true, example = "安踏")
private String name;
@ApiModelProperty(value = "描述", required = true, example = "安踏拖鞋")
private String description;
@ApiModelProperty(value = "图片地址", required = true, example = "http://www.iocoder.cn")
private String picUrl;
@ApiModelProperty(value = "状态 1-开启 2-禁用", required = true, example = "1")
private Integer status;
}

View File

@@ -0,0 +1,25 @@
package cn.iocoder.mall.product.application.vo.admins;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 商品品牌分页 BO
*/
@ApiModel("商品品牌分页")
@Data
@Accessors(chain = true)
public class AdminsProductBrangPageVO {
@ApiModelProperty(value = "品牌数组", required = true)
private List<AdminsProductBrandVO> brands;
@ApiModelProperty(value = "总数", required = true)
private Integer count;
}

View File

@@ -16,8 +16,6 @@ server:
servlet:
context-path: /product-api/
swagger:
enable: false
management:
@@ -27,3 +25,10 @@ management:
include: health,info,env,metrics,prometheus
metrics:
enabled: true
swagger:
enable: true
title: 商品子系统
description: 商品子系统
version: 1.0.0
base-package: cn.iocoder.mall.product.application.controller