调整product服务项目结构,商品规格列表接口

This commit is contained in:
q2118cs
2020-05-06 17:04:38 +08:00
parent 9f3dc3c087
commit 4669e81645
139 changed files with 3915 additions and 111 deletions

View File

@@ -2,14 +2,25 @@ package cn.iocoder.mall.product.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.product"})
@EnableAsync(proxyTargetClass = true)
public class ProductApplication {
public static void main(String[] args) {
SpringApplication.run(ProductApplication.class, args);
}
/**
* 设置需要读取的配置文件的名字。
* 基于 {@link org.springframework.boot.context.config.ConfigFileApplicationListener#CONFIG_NAME_PROPERTY} 实现。
*/
private static final String CONFIG_NAME_VALUE = "biz,rest,rpc,application";
public static void main(String[] args) {
// 设置环境变量
System.setProperty(ConfigFileApplicationListener.CONFIG_NAME_PROPERTY, CONFIG_NAME_VALUE);
// 启动 Spring Boot 应用
SpringApplication.run(ProductApplication.class, args);
}
}

View File

@@ -1,140 +0,0 @@
package cn.iocoder.mall.product.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder;
import cn.iocoder.mall.product.api.ProductAttrService;
import cn.iocoder.mall.product.api.bo.ProductAttrBO;
import cn.iocoder.mall.product.api.bo.ProductAttrPageBO;
import cn.iocoder.mall.product.api.bo.ProductAttrSimpleBO;
import cn.iocoder.mall.product.api.bo.ProductAttrValueBO;
import cn.iocoder.mall.product.api.dto.*;
import cn.iocoder.mall.product.application.convert.ProductAttrConvert;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductAttrPageVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductAttrSimpleVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductAttrVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductAttrValueVO;
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 java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("admins")
@Api("商品规格")
public class AdminsProductAttrController {
@Reference(validation = "true", version = "${dubbo.provider.ProductAttrService.version}")
private ProductAttrService productAttrService;
@GetMapping("/attr/page")
@ApiOperation("获得规格分页")
public CommonResult<AdminsProductAttrPageVO> attrPage(@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
// 创建 ProductAttrPageDTO 对象
ProductAttrPageDTO productAttrPageDTO = new ProductAttrPageDTO().setName(name).setPageNo(pageNo).setPageSize(pageSize);
// 查询分页
ProductAttrPageBO result = productAttrService.getProductAttrPage(productAttrPageDTO);
// 返回结果
return success(ProductAttrConvert.INSTANCE.convert2(result));
}
@GetMapping("/attr/tree")
@ApiOperation(value = "获得规格树结构", notes = "该接口返回的信息更为精简。一般用于前端缓存数据字典到本地。")
public CommonResult<List<AdminsProductAttrSimpleVO>> tree() {
// 查询全列表
List<ProductAttrSimpleBO> result = productAttrService.getProductAttrList();
// 返回结果
return success(ProductAttrConvert.INSTANCE.convert(result));
}
@PostMapping("/attr/add")
@ApiOperation(value = "创建商品规格")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "规格名", required = true, example = "颜色")
})
public CommonResult<AdminsProductAttrVO> addAttr(@RequestParam("name") String name) {
// 创建 ProductAttrAddDTO 对象
ProductAttrAddDTO productAttrAddDTO = new ProductAttrAddDTO().setName(name);
// 添加
ProductAttrBO result = productAttrService.addProductAttr(AdminSecurityContextHolder.getContext().getAdminId(), productAttrAddDTO);
// 返回结果
return success(ProductAttrConvert.INSTANCE.convert3(result));
}
@PostMapping("/attr/update")
@ApiOperation(value = "修改商品规格")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "规格编号", required = true, example = "1"),
@ApiImplicitParam(name = "name", value = "规格名", required = true, example = "颜色")
})
public CommonResult<Boolean> updateAttr(@RequestParam("id") Integer id,
@RequestParam("name") String name) {
// 创建 ProductAttrUpdateDTO 对象
ProductAttrUpdateDTO productAttrUpdateDTO = new ProductAttrUpdateDTO().setId(id).setName(name);
// 更新
return 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 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<AdminsProductAttrValueVO> addAttrValue(@RequestParam("attrId") Integer attrId,
@RequestParam("name") String name) {
// 创建 ProductAttrValueAddDTO 对象
ProductAttrValueAddDTO productAttrValueAddDTO = new ProductAttrValueAddDTO().setAttrId(attrId).setName(name);
// 添加
ProductAttrValueBO result = productAttrService.addProductAttrValue(AdminSecurityContextHolder.getContext().getAdminId(), productAttrValueAddDTO);
// 返回结果
return success(ProductAttrConvert.INSTANCE.convert4(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 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 success(productAttrService.updateProductAttrValueStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status));
}
// TODO 芋艿 暂时不考虑 delete Attr Value 。因为关联逻辑比较多
}

View File

@@ -1,113 +0,0 @@
package cn.iocoder.mall.product.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.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

@@ -1,126 +0,0 @@
package cn.iocoder.mall.product.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder;
import cn.iocoder.mall.product.api.ProductCategoryService;
import cn.iocoder.mall.product.api.bo.ProductCategoryBO;
import cn.iocoder.mall.product.api.constant.ProductCategoryConstants;
import cn.iocoder.mall.product.api.dto.ProductCategoryAddDTO;
import cn.iocoder.mall.product.api.dto.ProductCategoryUpdateDTO;
import cn.iocoder.mall.product.application.convert.ProductCategoryConvert;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryTreeNodeVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryVO;
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 java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("admins/category")
@Api("商品分类")
public class AdminsProductCategoryController {
@Reference(validation = "true", version = "${dubbo.provider.ProductCategoryService.version}")
private ProductCategoryService productCategoryService;
@GetMapping("/tree")
@ApiOperation("获得分类树结构")
public CommonResult<List<AdminsProductCategoryTreeNodeVO>> tree() {
List<ProductCategoryBO> productCategories = productCategoryService.getAll();
// 创建 ProductCategoryTreeNodeVO Map
Map<Integer, AdminsProductCategoryTreeNodeVO> treeNodeMap = productCategories.stream().collect(Collectors.toMap(ProductCategoryBO::getId, ProductCategoryConvert.Admins.INSTANCE::convert));
// 处理父子关系
treeNodeMap.values().stream()
.filter(node -> !node.getPid().equals(ProductCategoryConstants.PID_ROOT))
.forEach((childNode) -> {
// 获得父节点
AdminsProductCategoryTreeNodeVO parentNode = treeNodeMap.get(childNode.getPid());
if (parentNode.getChildren() == null) { // 初始化 children 数组
parentNode.setChildren(new ArrayList<>());
}
// 将自己添加到父节点中
parentNode.getChildren().add(childNode);
});
// 获得到所有的根节点
List<AdminsProductCategoryTreeNodeVO> rootNodes = treeNodeMap.values().stream()
.filter(node -> node.getPid().equals(ProductCategoryConstants.PID_ROOT))
.sorted(Comparator.comparing(AdminsProductCategoryTreeNodeVO::getSort))
.collect(Collectors.toList());
return success(rootNodes);
}
@PostMapping("/add")
@ApiOperation(value = "创建商品分类")
@ApiImplicitParams({
@ApiImplicitParam(name = "pid", value = "父级分类编号", required = true, example = "1"),
@ApiImplicitParam(name = "name", value = "分类名字(标识)", required = true, example = "admin/info"),
@ApiImplicitParam(name = "description", value = "描述", required = true, example = "1"),
@ApiImplicitParam(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/"),
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "1"),
})
public CommonResult<AdminsProductCategoryVO> add(@RequestParam("pid") Integer pid,
@RequestParam("name") String name,
@RequestParam("description") String description,
@RequestParam(value = "picUrl", required = false) String picUrl,
@RequestParam("sort") Integer sort) {
// 创建 ProductCategoryAddDTO 对象
ProductCategoryAddDTO productCategoryAddDTO = new ProductCategoryAddDTO().setPid(pid).setName(name)
.setDescription(description).setPicUrl(picUrl).setSort(sort);
// 创建商品分类
ProductCategoryBO result = productCategoryService.addProductCategory(AdminSecurityContextHolder.getContext().getAdminId(), productCategoryAddDTO);
// 返回结果
return success(ProductCategoryConvert.Admins.INSTANCE.convert2(result));
}
@PostMapping("/update")
@ApiOperation(value = "更新商品分类")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "分类编号", required = true, example = "1"),
@ApiImplicitParam(name = "pid", value = "父级分类编号", required = true, example = "1"),
@ApiImplicitParam(name = "name", value = "分类名字(标识)", required = true, example = "admin/info"),
@ApiImplicitParam(name = "description", value = "描述", required = true, example = "1"),
@ApiImplicitParam(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/"),
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "1"),
})
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
@RequestParam("pid") Integer pid,
@RequestParam("name") String name,
@RequestParam("description") String description,
@RequestParam(value = "picUrl", required = false) String picUrl,
@RequestParam("sort") Integer sort) {
// 创建 ProductCategoryUpdateDTO 对象
ProductCategoryUpdateDTO productCategoryAddDTO = new ProductCategoryUpdateDTO().setId(id).setPid(pid).setName(name)
.setDescription(description).setPicUrl(picUrl).setSort(sort);
// 更新商品分类
return success(productCategoryService.updateProductCategory(AdminSecurityContextHolder.getContext().getAdminId(), productCategoryAddDTO));
}
@PostMapping("/update_status")
@ApiOperation(value = "更新商品分类状态")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "商品分类编号", required = true, example = "1"),
@ApiImplicitParam(name = "status", value = "状态。1 - 开启2 - 禁用", required = true, example = "1"),
})
public CommonResult<Boolean> updateStatus(@RequestParam("id") Integer id,
@RequestParam("status") Integer status) {
return success(productCategoryService.updateProductCategoryStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status));
}
@PostMapping("/delete")
@ApiOperation(value = "删除商品分类")
@ApiImplicitParam(name = "id", value = "商品分类编号", required = true, example = "1")
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
return success(productCategoryService.deleteProductCategory(AdminSecurityContextHolder.getContext().getAdminId(), id));
}
}

View File

@@ -1,168 +0,0 @@
package cn.iocoder.mall.product.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder;
import cn.iocoder.mall.product.api.ProductSpuService;
import cn.iocoder.mall.product.api.bo.ProductSpuBO;
import cn.iocoder.mall.product.api.bo.ProductSpuDetailBO;
import cn.iocoder.mall.product.api.bo.ProductSpuPageBO;
import cn.iocoder.mall.product.api.dto.*;
import cn.iocoder.mall.product.application.convert.ProductSpuConvert;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductSpuDetailVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductSpuPageVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductSpuVO;
import com.alibaba.fastjson.JSON;
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 java.util.Collection;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("admins")
@Api("商品 SPU + SKU")
public class AdminsProductSpuController {
@Reference(validation = "true", version = "${dubbo.provider.ProductSpuService.version}")
private ProductSpuService productSpuService;
@PostMapping("/spu/add")
@ApiOperation("创建商品")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "SPU 名字", required = true, example = "厮大牛逼"),
@ApiImplicitParam(name = "sellPoint", value = "卖点", required = true, example = "各种 MQ 骚操作"),
@ApiImplicitParam(name = "description", value = "描述", required = true, example = "你就说强不强 MQ 骚操作"),
@ApiImplicitParam(name = "cid", value = "分类编号", required = true, example = "反正我是信了"),
@ApiImplicitParam(name = "picUrls", value = "商品主图地址的数组", required = true, example = "http://www.iocoder.cn"),
@ApiImplicitParam(name = "visible", value = "是否上架商品(是否可见)", required = true, example = "true"),
@ApiImplicitParam(name = "skuStr", value = "SKU 字符串", required = true, example = "[{\"attrs\": [1,3 ], \"price\": 1, \"quantity\": 100, \"picUrl\": \"http://www.iocoder.cn\"}]"),
})
public CommonResult<AdminsProductSpuDetailVO> add(@RequestParam("name") String name,
@RequestParam("sellPoint") String sellPoint,
@RequestParam("description") String description,
@RequestParam("cid") Integer cid,
@RequestParam("picUrls") List<String> picUrls,
@RequestParam("visible") Boolean visible,
@RequestParam("skuStr") String skuStr) { // TODO 芋艿,因为考虑不使用 json 接受参数,所以这里手动转。
// 创建 ProductSpuAddDTO 对象
ProductSpuAddDTO productSpuAddDTO = new ProductSpuAddDTO().setName(name).setSellPoint(sellPoint)
.setDescription(description).setCid(cid).setPicUrls(picUrls).setVisible(visible)
.setSkus(parseSkus(skuStr, ProductSkuAddOrUpdateDTO.class));
// 保存商品
ProductSpuDetailBO result = productSpuService.addProductSpu(AdminSecurityContextHolder.getContext().getAdminId(), productSpuAddDTO);
// 返回结果
return success(ProductSpuConvert.INSTANCE.convert(result));
}
@PostMapping("/spu/update")
@ApiOperation("更新商品")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SPU 编号", required = true, example = "100"),
@ApiImplicitParam(name = "name", value = "SPU 名字", required = true, example = "厮大牛逼"),
@ApiImplicitParam(name = "sellPoint", value = "卖点", required = true, example = "各种 MQ 骚操作"),
@ApiImplicitParam(name = "description", value = "描述", required = true, example = "你就说强不强 MQ 骚操作"),
@ApiImplicitParam(name = "cid", value = "分类编号", required = true, example = "反正我是信了"),
@ApiImplicitParam(name = "picUrls", value = "商品主图地址的数组", required = true, example = "http://www.iocoder.cn"),
@ApiImplicitParam(name = "visible", value = "是否上架商品(是否可见)", required = true, example = "true"),
@ApiImplicitParam(name = "skuStr", value = "SKU 字符串", required = true, example = "[{\"attrs\": [1,3 ], \"price\": 1, \"quantity\": 100, \"picUrl\": \"http://www.iocoder.cn\"}]"),
})
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
@RequestParam("name") String name,
@RequestParam("sellPoint") String sellPoint,
@RequestParam("description") String description,
@RequestParam("cid") Integer cid,
@RequestParam("picUrls") List<String> picUrls,
@RequestParam("visible") Boolean visible,
@RequestParam("skuStr") String skuStr) { // TODO 芋艿,因为考虑不使用 json 接受参数,所以这里手动转。
// 创建 ProductSpuUpdateDTO 对象
ProductSpuUpdateDTO productSpuUpdateDTO = new ProductSpuUpdateDTO().setId(id).setName(name).setSellPoint(sellPoint)
.setDescription(description).setCid(cid).setPicUrls(picUrls).setVisible(visible)
.setSkus(parseSkus(skuStr, ProductSkuAddOrUpdateDTO.class));
// 更新商品
productSpuService.updateProductSpu(AdminSecurityContextHolder.getContext().getAdminId(), productSpuUpdateDTO);
return success(true);
}
@PostMapping("/spu/update_sort")
@ApiOperation("更新商品的排序")
public CommonResult<Boolean> updateSort(@RequestParam("id") Integer id,
@RequestParam("sort") Integer sort) {
return success(productSpuService.updateProductSpuSort(AdminSecurityContextHolder.getContext().getAdminId(), id, sort));
}
// TODO 芋艿,删除功能暂时不做。主要原因是,关联的数据太多。删除带来的问题会比较大
@GetMapping("/spu/page")
@ApiOperation("商品 SPU 分页列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "商品名称,模糊匹配", example = "小王"),
@ApiImplicitParam(name = "status", value = "状态", example = "可选值1-在售中2-已售罄3-仓库中;"),
@ApiImplicitParam(name = "cid", value = "商品分类编号", example = "10"),
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
})
public CommonResult<AdminsProductSpuPageVO> spuPage(@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "status") Integer status,
@RequestParam(value = "cid", required = false) Integer cid,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
// 创建 ProductSpuPageDTO 对象
ProductSpuPageDTO productSpuPageDTO = new ProductSpuPageDTO().setName(name).setCid(cid).setPageNo(pageNo).setPageSize(pageSize);
switch (status) {
case 1:
productSpuPageDTO.setVisible(true).setHasQuantity(true);
break;
case 2:
productSpuPageDTO.setVisible(true).setHasQuantity(false);
break;
case 3:
productSpuPageDTO.setVisible(false);
break;
}
ProductSpuPageBO result = productSpuService.getProductSpuPage(productSpuPageDTO);
return success(ProductSpuConvert.INSTANCE.convert2(result));
}
@GetMapping("/spu/search_list")
@ApiOperation("商品 SPU 搜索列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "商品名称,模糊匹配", example = "小王"),
})
public CommonResult<List<AdminsProductSpuVO>> spuSearchList(@RequestParam(value = "name", required = false) String name) {
// 创建 ProductSpuSearchListDTO 对象
ProductSpuSearchListDTO productSpuSearchListDTO = new ProductSpuSearchListDTO().setName(name);
// 执行搜索
List<ProductSpuBO> list = productSpuService.getProductSpuSearchList(productSpuSearchListDTO);
// 转换返回
return success(ProductSpuConvert.INSTANCE.convert3(list));
}
@GetMapping("/spu/info")
@ApiOperation("商品 SPU 明细")
@ApiImplicitParam(name = "id", value = "SPU 编号", required = true, example = "100")
public CommonResult<AdminsProductSpuDetailVO> spuInfo(@RequestParam("id") Integer id) {
return success(ProductSpuConvert.INSTANCE.convert(productSpuService.getProductSpuDetail(id)));
}
@GetMapping("/spu/list")
@ApiOperation("商品 SPU 列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "商品 SPU 编号数组", example = "1,2,3"),
})
public CommonResult<List<AdminsProductSpuVO>> spuList(@RequestParam("ids") Collection<Integer> ids) {
List<ProductSpuBO> list = productSpuService.getProductSpuList(ids);
// 转换返回
return success(ProductSpuConvert.INSTANCE.convert3(list));
}
private <T> List<T> parseSkus(String skuStr, Class<T> clazz) {
return JSON.parseArray(skuStr, clazz);
}
}

View File

@@ -1,54 +0,0 @@
package cn.iocoder.mall.product.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.product.api.UserProductSpuCollectionsService;
import cn.iocoder.mall.product.api.bo.UserProductSpuCollectionsPageBO;
import cn.iocoder.mall.product.api.dto.UserProductSpuCollectionsPageDTO;
import cn.iocoder.mall.user.sdk.annotation.RequiresLogin;
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 用户收藏
* @author xiaofeng
* @date 2019/07/07 11:06
* @version 1.0
*/
@RestController
@RequestMapping("users/favorite")
@Api("用户收藏")
public class UserFavoriteController {
@Reference(validation = "true", version = "${dubbo.provider.UserProductSpuCollectionsService.version}")
private UserProductSpuCollectionsService userProductSpuCollectionsService;
@GetMapping("page")
@RequiresLogin
@ApiOperation("用户商品收藏列表")
public CommonResult<UserProductSpuCollectionsPageBO> getUserProductSpuCollectionsPage(
@Validated UserProductSpuCollectionsPageDTO userProductSpuCollectionsPageDTO) {
final Integer userId = UserSecurityContextHolder.getContext().getUserId();
userProductSpuCollectionsPageDTO.setUserId(userId);
return userProductSpuCollectionsService.getUserProductSpuCollectionsPage(userProductSpuCollectionsPageDTO);
}
@DeleteMapping("remove")
@RequiresLogin
@ApiOperation(value = "用户商品收藏-删除")
public CommonResult<Boolean> removeUserFavorite(@RequestParam("spuId") final Integer spuId) {
final Integer userId = UserSecurityContextHolder.getContext().getUserId();
return userProductSpuCollectionsService.deleteUserProductSpuCollections(userId, spuId);
}
@GetMapping("hasUserFavorite")
@RequiresLogin
@ApiOperation(value = "用户商品收藏-是否收藏")
public CommonResult<Boolean> hasUserSpuFavorite(@RequestParam("spuId") final Integer spuId) {
final Integer userId = UserSecurityContextHolder.getContext().getUserId();
return userProductSpuCollectionsService.hasUserSpuFavorite(spuId, userId);
}
}

View File

@@ -1,37 +0,0 @@
package cn.iocoder.mall.product.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.product.api.ProductCategoryService;
import cn.iocoder.mall.product.api.bo.ProductCategoryBO;
import cn.iocoder.mall.product.application.convert.ProductCategoryConvert;
import cn.iocoder.mall.product.application.vo.users.UsersProductCategoryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("users/category")
@Api("商品分类")
public class UsersProductCategoryController {
@Reference(validation = "true", version = "${dubbo.provider.ProductCategoryService.version}")
@Autowired
private ProductCategoryService productCategoryService;
@GetMapping("/list")
@ApiOperation("获得指定编号下的子分类的数组")
@ApiImplicitParam(name = "pid", value = "指定分类编号", required = true, example = "0")
public CommonResult<List<UsersProductCategoryVO>> list(@RequestParam("pid") Integer pid) {
List<ProductCategoryBO> result = productCategoryService.getListByPid(pid);
return CommonResult.success(ProductCategoryConvert.Users.INSTANCE.convertToVO(result));
}
}

View File

@@ -1,39 +0,0 @@
package cn.iocoder.mall.product.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.product.api.ProductSpuCollectionService;
import cn.iocoder.mall.user.sdk.annotation.RequiresLogin;
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* 商品收藏接口
* @author xiaofeng
* @date 2019/07/01 23:21
* @version 1.0
*/
@RestController
@RequestMapping("users/spu")
@Api("商品收藏")
public class UsersProductSpuCollectionController {
@Reference(validation = "true", version = "${dubbo.provider.ProductSpuCollectionService.version}")
private ProductSpuCollectionService productSpuCollectionService;
@PostMapping("/collection/{spuId}/{hasCollectionType}")
@ApiOperation("商品收藏")
@RequiresLogin
public CommonResult<Boolean> productSpuCollection(@PathVariable("spuId") Integer spuId,
@PathVariable("hasCollectionType") Integer hasCollectionType) {
final Integer userId = UserSecurityContextHolder.getContext().getUserId();
return success(productSpuCollectionService.productSpuCollection(spuId, hasCollectionType,userId));
}
}

View File

@@ -1,57 +0,0 @@
package cn.iocoder.mall.product.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.product.api.ProductSpuService;
import cn.iocoder.mall.product.api.bo.ProductSpuPageBO;
import cn.iocoder.mall.product.api.dto.ProductSpuPageDTO;
import cn.iocoder.mall.product.application.convert.ProductSpuConvert;
import cn.iocoder.mall.product.application.vo.users.UsersProductSpuDetailVO;
import cn.iocoder.mall.product.application.vo.users.UsersProductSpuPageVO;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("users/spu")
@Api("商品 SPU + SKU")
public class UsersProductSpuController {
@Reference(validation = "true", version = "${dubbo.provider.ProductSpuService.version}")
private ProductSpuService productSpuService;
@GetMapping("/info")
@ApiOperation("商品 SPU 明细")
@ApiImplicitParam(name = "id", value = "SPU 编号", required = true, example = "100")
public CommonResult<UsersProductSpuDetailVO> info(@RequestParam("id") Integer id) {
return success(ProductSpuConvert.INSTANCE.convert4(productSpuService.getProductSpuDetail(id)));
}
@GetMapping("/page")
@ApiOperation("商品 SPU 分页列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "cid", value = "分类编号", example = "1"),
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
})
@Deprecated // 使用商品搜索接口
public CommonResult<UsersProductSpuPageVO> page(@RequestParam(value = "cid", required = false) Integer cid,
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
// 创建 ProductSpuPageDTO 对象
ProductSpuPageDTO productSpuPageDTO = new ProductSpuPageDTO().setCid(cid).setVisible(true)
.setPageNo(pageNo).setPageSize(pageSize);
// 查询分页
ProductSpuPageBO result = productSpuService.getProductSpuPage(productSpuPageDTO);
// 返回结果
return success(ProductSpuConvert.INSTANCE.convert3(result));
}
}

View File

@@ -1,34 +0,0 @@
package cn.iocoder.mall.product.application.convert;
import cn.iocoder.mall.product.api.bo.ProductAttrBO;
import cn.iocoder.mall.product.api.bo.ProductAttrPageBO;
import cn.iocoder.mall.product.api.bo.ProductAttrSimpleBO;
import cn.iocoder.mall.product.api.bo.ProductAttrValueBO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductAttrPageVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductAttrSimpleVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductAttrVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductAttrValueVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface ProductAttrConvert {
ProductAttrConvert INSTANCE = Mappers.getMapper(ProductAttrConvert.class);
@Mappings({})
AdminsProductAttrPageVO convert2(ProductAttrPageBO result);
@Mappings({})
List<AdminsProductAttrSimpleVO> convert(List<ProductAttrSimpleBO> result);
@Mappings({})
AdminsProductAttrVO convert3(ProductAttrBO productAttrBO);
@Mappings({})
AdminsProductAttrValueVO convert4(ProductAttrValueBO productAttrValueBO);
}

View File

@@ -1,22 +0,0 @@
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

@@ -1,41 +0,0 @@
package cn.iocoder.mall.product.application.convert;
import cn.iocoder.mall.product.api.bo.ProductCategoryBO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryTreeNodeVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryVO;
import cn.iocoder.mall.product.application.vo.users.UsersProductCategoryVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
public interface ProductCategoryConvert {
@Mapper
interface Users {
Users INSTANCE = Mappers.getMapper(Users.class);
@Mappings({})
UsersProductCategoryVO convertToVO(ProductCategoryBO category);
@Mappings({})
List<UsersProductCategoryVO> convertToVO(List<ProductCategoryBO> categoryList);
}
@Mapper
interface Admins {
Admins INSTANCE = Mappers.getMapper(Admins.class);
@Mappings({})
AdminsProductCategoryTreeNodeVO convert(ProductCategoryBO category);
@Mappings({})
AdminsProductCategoryVO convert2(ProductCategoryBO result);
}
}

View File

@@ -1,40 +0,0 @@
package cn.iocoder.mall.product.application.convert;
import cn.iocoder.mall.product.api.bo.ProductSpuBO;
import cn.iocoder.mall.product.api.bo.ProductSpuDetailBO;
import cn.iocoder.mall.product.api.bo.ProductSpuPageBO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductSpuDetailVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductSpuPageVO;
import cn.iocoder.mall.product.application.vo.admins.AdminsProductSpuVO;
import cn.iocoder.mall.product.application.vo.users.UsersProductSpuDetailVO;
import cn.iocoder.mall.product.application.vo.users.UsersProductSpuPageVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface ProductSpuConvert {
ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class);
@Mappings({})
AdminsProductSpuDetailVO convert(ProductSpuDetailBO productSpuDetailBO);
// @Mappings({})
// CommonResult<AdminsProductSpuDetailVO> convert(CommonResult<ProductSpuDetailBO> result);
@Mappings({})
AdminsProductSpuPageVO convert2(ProductSpuPageBO result);
@Mappings({})
List<AdminsProductSpuVO> convert3(List<ProductSpuBO> result);
@Mappings({})
UsersProductSpuPageVO convert3(ProductSpuPageBO result);
@Mappings({})
UsersProductSpuDetailVO convert4(ProductSpuDetailBO result);
}

View File

@@ -1,22 +0,0 @@
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;
@ApiModel(value = "商品规格属性和值对 VO")
@Data
@Accessors(chain = true)
public class AdminsProductAttrAndValuePairVO {
@ApiModelProperty(value = "规格编号", required = true, example = "1")
private Integer attrId;
@ApiModelProperty(value = "规格名", required = true, example = "颜色")
private String attrName;
@ApiModelProperty(value = "规格值", required = true, example = "10")
private Integer attrValueId;
@ApiModelProperty(value = "规格值名", required = true, example = "红色")
private String attrValueName;
}

View File

@@ -1,27 +0,0 @@
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.Date;
import java.util.List;
@ApiModel(value = "商品规格明细 VO", description = "带有规格值数组")
@Data
@Accessors(chain = true)
public class AdminsProductAttrDetailVO {
@ApiModelProperty(value = "规格编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "规格名", required = true, example = "颜色")
private String name;
@ApiModelProperty(value = "状态", required = true, example = "1")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime;
@ApiModelProperty(value = "规格值数组", required = true)
private List<AdminsProductAttrValueDetailVO> values;
}

View File

@@ -1,20 +0,0 @@
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;
@ApiModel(value = "商品规格明细分页 VO")
@Data
@Accessors(chain = true)
public class AdminsProductAttrPageVO {
@ApiModelProperty(value = "规格数组", required = true)
private List<AdminsProductAttrDetailVO> attrs;
@ApiModelProperty(value = "总数", required = true)
private Integer count;
}

View File

@@ -1,22 +0,0 @@
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;
@ApiModel(value = "商品规格精简 VO", description = "带有规格值数组")
@Data
@Accessors(chain = true)
public class AdminsProductAttrSimpleVO {
@ApiModelProperty(value = "规格编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "规格名", required = true, example = "颜色")
private String name;
@ApiModelProperty(value = "规格值数组", required = true)
private List<AdminsProductAttrValueSimpleVO> values;
}

View File

@@ -1,24 +0,0 @@
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.Date;
@ApiModel(value = "商品规格 VO", description = "不带有规格值数组")
@Data
@Accessors(chain = true)
public class AdminsProductAttrVO {
@ApiModelProperty(value = "规格编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "规格名", required = true, example = "颜色")
private String name;
@ApiModelProperty(value = "状态", required = true, example = "1")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime;
}

View File

@@ -1,24 +0,0 @@
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.Date;
@ApiModel(value = "商品规格值 VO")
@Data
@Accessors(chain = true)
public class AdminsProductAttrValueDetailVO {
@ApiModelProperty(value = "规格值编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "规格值名", required = true, example = "颜色")
private String name;
@ApiModelProperty(value = "状态", required = true, example = "1")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime;
}

View File

@@ -1,18 +0,0 @@
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;
@ApiModel(value = "商品规格值精简 VO")
@Data
@Accessors(chain = true)
public class AdminsProductAttrValueSimpleVO {
@ApiModelProperty(value = "规格值编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "规格值名", required = true, example = "颜色")
private String name;
}

View File

@@ -1,26 +0,0 @@
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.Date;
@ApiModel(value = "商品规格值 VO")
@Data
@Accessors(chain = true)
public class AdminsProductAttrValueVO {
@ApiModelProperty(value = "规格值编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "规格编号", required = true, example = "1")
private Integer attrId;
@ApiModelProperty(value = "规格名", required = true, example = "颜色")
private String name;
@ApiModelProperty(value = "状态", required = true, example = "1")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime;
}

View File

@@ -1,38 +0,0 @@
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

@@ -1,25 +0,0 @@
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

@@ -1,35 +0,0 @@
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.Date;
import java.util.List;
@ApiModel("产品分类树节点 VO")
@Data
@Accessors(chain = true)
public class AdminsProductCategoryTreeNodeVO {
@ApiModelProperty(value = "分类编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "父分类编号", required = true, example = "0")
private Integer pid;
@ApiModelProperty(value = "分类名", required = true, example = "手机")
private String name;
@ApiModelProperty(value = "描述", required = true, example = "这个商品很吊")
private String description;
@ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
private String picUrl;
@ApiModelProperty(value = "排序值", required = true, example = "10")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, notes = "1-开启2-关闭", example = "1")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime;
@ApiModelProperty(value = "子节点数组")
private List<AdminsProductCategoryTreeNodeVO> children;
}

View File

@@ -1,32 +0,0 @@
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.Date;
@ApiModel("产品分类 VO")
@Data
@Accessors(chain = true)
public class AdminsProductCategoryVO {
@ApiModelProperty(value = "分类编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "父分类编号", required = true, example = "0")
private Integer pid;
@ApiModelProperty(value = "分类名", required = true, example = "手机")
private String name;
@ApiModelProperty(value = "描述", required = true, example = "这个商品很吊")
private String description;
@ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
private String picUrl;
@ApiModelProperty(value = "排序值", required = true, example = "10")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, notes = "1-开启2-关闭", example = "1")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime;
}

View File

@@ -1,29 +0,0 @@
package cn.iocoder.mall.product.application.vo.admins;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 商品 Sku 明细 BO
*/
@Data
@Accessors(chain = true)
public class AdminsProductSkuDetailVO {
@ApiModelProperty(value = "sku 编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "SPU 编号", required = true, example = "1")
private Integer spuId;
@ApiModelProperty(value = "图片地址", required = true, example = "http://www.iocoder.cn")
private String picURL;
@ApiModelProperty(value = "规格值数组", required = true)
private List<AdminsProductAttrAndValuePairVO> attrs;
@ApiModelProperty(value = "价格,单位:分", required = true, example = "100")
private Integer price;
@ApiModelProperty(value = "库存数量", required = true, example = "100")
private Integer quantity;
}

View File

@@ -1,43 +0,0 @@
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;
@ApiModel(value = "商品 SPU 详细 VO", description = "包括 SKU 信息 VO")
@Data
@Accessors(chain = true)
public class AdminsProductSpuDetailVO {
@ApiModelProperty(value = "SPU 编号", required = true, example = "1")
private Integer id;
// ========== 基本信息 =========
@ApiModelProperty(value = "SPU 名字", required = true, example = "厮大牛逼")
private String name;
@ApiModelProperty(value = "卖点", required = true, example = "各种 MQ 骚操作")
private String sellPoint;
@ApiModelProperty(value = "描述", required = true, example = "你就说强不强")
private String description;
@ApiModelProperty(value = "分类编号", required = true, example = "反正我是信了")
private Integer cid;
@ApiModelProperty(value = "商品主图地址的数组", required = true, example = "http://www.iocoder.cn")
private List<String> picUrls;
// ========== 其他信息 =========
@ApiModelProperty(value = "是否上架商品(是否可见)", required = true, example = "true")
private Boolean visible;
@ApiModelProperty(value = "排序字段", required = true, example = "10")
private Integer sort;
// ========== SKU =========
/**
* SKU 数组
*/
private List<AdminsProductSkuDetailVO> skus;
}

View File

@@ -1,20 +0,0 @@
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;
@ApiModel("商品 SPU 分页 VO")
@Data
@Accessors(chain = true)
public class AdminsProductSpuPageVO {
@ApiModelProperty(value = "spu 数组", required = true)
private List<AdminsProductSpuVO> list;
@ApiModelProperty(value = "总数", required = true)
private Integer total;
}

View File

@@ -1,38 +0,0 @@
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;
@ApiModel(value = "商品 SPU VO", description = "不包括 SKU 信息 VO")
@Data
@Accessors(chain = true)
public class AdminsProductSpuVO {
@ApiModelProperty(value = "SPU 编号", required = true, example = "1")
private Integer id;
// ========== 基本信息 =========
@ApiModelProperty(value = "SPU 名字", required = true, example = "厮大牛逼")
private String name;
@ApiModelProperty(value = "卖点", required = true, example = "各种 MQ 骚操作")
private String sellPoint;
@ApiModelProperty(value = "描述", required = true, example = "你就说强不强")
private String description;
@ApiModelProperty(value = "分类编号", required = true, example = "反正我是信了")
private Integer cid;
@ApiModelProperty(value = "商品主图地址的数组", required = true, example = "http://www.iocoder.cn")
private List<String> picUrls;
@ApiModelProperty(value = "库存数量", required = true, example = "10")
private Integer quantity;
// ========== 其他信息 =========
@ApiModelProperty(value = "是否上架商品(是否可见)", required = true, example = "true")
private Boolean visible;
@ApiModelProperty(value = "排序字段", required = true, example = "10")
private Integer sort;
}

View File

@@ -1,22 +0,0 @@
package cn.iocoder.mall.product.application.vo.users;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@ApiModel(value = "商品规格属性和值对 VO")
@Data
@Accessors(chain = true)
public class UsersProductAttrAndValuePairVO {
@ApiModelProperty(value = "规格编号", required = true, example = "1")
private Integer attrId;
@ApiModelProperty(value = "规格名", required = true, example = "颜色")
private String attrName;
@ApiModelProperty(value = "规格值", required = true, example = "10")
private Integer attrValueId;
@ApiModelProperty(value = "规格值名", required = true, example = "红色")
private String attrValueName;
}

View File

@@ -1,20 +0,0 @@
package cn.iocoder.mall.product.application.vo.users;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@ApiModel("商品分类(简单)")
@Data
@Accessors(chain = true)
public class UsersProductCategoryVO {
@ApiModelProperty(value = "分类编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "分类名", required = true, example = "手机")
private String name;
@ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
private String picUrl;
}

View File

@@ -1,29 +0,0 @@
package cn.iocoder.mall.product.application.vo.users;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 商品 Sku 明细 BO
*/
@Data
@Accessors(chain = true)
public class UsersProductSkuDetailVO {
@ApiModelProperty(value = "sku 编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "SPU 编号", required = true, example = "1")
private Integer spuId;
@ApiModelProperty(value = "图片地址", required = true, example = "http://www.iocoder.cn")
private String picURL;
@ApiModelProperty(value = "规格值数组", required = true)
private List<UsersProductAttrAndValuePairVO> attrs;
@ApiModelProperty(value = "价格,单位:分", required = true, example = "100")
private Integer price;
@ApiModelProperty(value = "库存数量", required = true, example = "100")
private Integer quantity;
}

View File

@@ -1,37 +0,0 @@
package cn.iocoder.mall.product.application.vo.users;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@ApiModel(value = "商品 SPU 详细 VO", description = "包括 SKU 信息 VO")
@Data
@Accessors(chain = true)
public class UsersProductSpuDetailVO {
@ApiModelProperty(value = "SPU 编号", required = true, example = "1")
private Integer id;
// ========== 基本信息 =========
@ApiModelProperty(value = "SPU 名字", required = true, example = "厮大牛逼")
private String name;
@ApiModelProperty(value = "卖点", required = true, example = "各种 MQ 骚操作")
private String sellPoint;
@ApiModelProperty(value = "描述", required = true, example = "你就说强不强")
private String description;
@ApiModelProperty(value = "分类编号", required = true, example = "反正我是信了")
private Integer cid;
@ApiModelProperty(value = "商品主图地址的数组", required = true, example = "http://www.iocoder.cn")
private List<String> picUrls;
// ========== SKU =========
/**
* SKU 数组
*/
private List<UsersProductSkuDetailVO> skus;
}

View File

@@ -1,20 +0,0 @@
package cn.iocoder.mall.product.application.vo.users;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@ApiModel("商品 SPU 分页 VO")
@Data
@Accessors(chain = true)
public class UsersProductSpuPageVO {
@ApiModelProperty(value = "spu 数组", required = true)
private List<UsersProductSpuVO> spus;
@ApiModelProperty(value = "总数", required = true)
private Integer count;
}

View File

@@ -1,42 +0,0 @@
package cn.iocoder.mall.product.application.vo.users;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@ApiModel(value = "商品 SPU VO", description = "不包括 SKU 信息 VO")
@Data
@Accessors(chain = true)
public class UsersProductSpuVO {
@ApiModelProperty(value = "SPU 编号", required = true, example = "1")
private Integer id;
// ========== 基本信息 =========
@ApiModelProperty(value = "SPU 名字", required = true, example = "厮大牛逼")
private String name;
@ApiModelProperty(value = "卖点", required = true, example = "各种 MQ 骚操作")
private String sellPoint;
@ApiModelProperty(value = "分类编号", required = true, example = "反正我是信了")
private Integer cid;
@ApiModelProperty(value = "商品主图地址的数组", required = true, example = "http://www.iocoder.cn")
private List<String> picUrls;
// ========== Sku 相关字段 =========
/**
* 价格
*
* 目前的计算方式是,以 Sku 最小价格为准
*/
private Integer price;
/**
* 库存数量
*
* 目前的计算方式是,以 Sku 库存累加为准
*/
private Integer quantity;
}

View File

@@ -1,34 +1,9 @@
spring:
# Application 的配置项
application:
name: product-application
# Spring Cloud 配置项
cloud:
# Spring Cloud Sentinel 配置项
sentinel:
transport:
dashboard: s1.iocoder.cn:12088 # Sentinel Dashboard 服务地址
eager: true # 项目启动时,直接连接到 Sentinel
# server
server:
port: 18081
servlet:
context-path: /product-api/
# Profile 的配置项
profiles:
active: local
management:
endpoints:
web:
exposure:
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