mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2025-01-04 01:52:21 +08:00
feat:商品微服务结构优化
This commit is contained in:
parent
faf4b8dd47
commit
89f5069391
@ -1,4 +1,4 @@
|
||||
package com.youlai.mall.pms.bo;
|
||||
package com.youlai.mall.pms.bo.admin;
|
||||
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSku;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpuAttrValue;
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.mall.pms.bo;
|
||||
package com.youlai.mall.pms.bo.app;
|
||||
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSku;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpuAttrValue;
|
||||
@ -13,7 +13,7 @@ import java.util.List;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AppProductBO {
|
||||
public class ProductBO {
|
||||
|
||||
private SpuDTO spu;
|
||||
|
@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "分类属性接口")
|
||||
@Api(tags = "【系统管理】分类属性")
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/v1/attrs")
|
||||
@ -26,7 +26,7 @@ public class AttrController {
|
||||
|
||||
private IPmsCategoryAttrService iPmsCategoryAttrService;
|
||||
|
||||
@ApiOperation(value = "属性分类列表", httpMethod = "GET")
|
||||
@ApiOperation(value = "分类属性列表", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "categoryId", value = "分类ID", paramType = "query", dataType = "Long")
|
||||
|
||||
|
@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "品牌接口")
|
||||
@Api(tags = "【系统管理】品牌接口")
|
||||
@RestController
|
||||
@RequestMapping("/brands")
|
||||
@Slf4j
|
||||
|
@ -19,7 +19,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "商品分类接口")
|
||||
@Api(tags = "【系统管理】商品分类")
|
||||
@RestController
|
||||
@RequestMapping("/categories")
|
||||
@Slf4j
|
||||
|
@ -13,17 +13,17 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Api(tags = "商品sku接口")
|
||||
@Api(tags = "【系统管理】商品库存")
|
||||
@RestController
|
||||
@RequestMapping("/api.admin/v1/sku")
|
||||
@RequestMapping("/api.admin/v1/inventories")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class SkuController {
|
||||
public class InventoryController {
|
||||
|
||||
private IPmsSkuService iPmsSkuService;
|
||||
|
||||
@ApiOperation(value = "商品sku详情", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "商品sku id", required = true, paramType = "path", dataType = "Long")
|
||||
@ApiOperation(value = "库存明细", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "商品SKU ID", required = true, paramType = "path", dataType = "Long")
|
||||
@GetMapping("/{id}")
|
||||
public Result<SkuDTO> detail(@PathVariable Long id) {
|
||||
PmsSku sku = iPmsSkuService.getById(id);
|
||||
@ -32,7 +32,7 @@ public class SkuController {
|
||||
return Result.success(skuDTO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改商品库存", httpMethod = "PUT")
|
||||
@ApiOperation(value = "修改库存", httpMethod = "PUT")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "商品id", required = true, paramType = "path", dataType = "Long"),
|
||||
@ApiImplicitParam(name = "sku", value = "实体JSON对象", required = true, paramType = "body", dataType = "PmsSku")
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.common.enums.QueryModeEnum;
|
||||
import com.youlai.common.result.Result;
|
||||
import com.youlai.common.result.ResultCode;
|
||||
import com.youlai.mall.pms.bo.ProductBO;
|
||||
import com.youlai.mall.pms.bo.admin.ProductBO;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpu;
|
||||
import com.youlai.mall.pms.service.IPmsSpuService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "商品接口")
|
||||
@Api(tags = "【系统管理】商品信息")
|
||||
@RestController
|
||||
@RequestMapping("/api.admin/v1/products")
|
||||
@Slf4j
|
||||
|
@ -16,16 +16,16 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "规格接口")
|
||||
@Api(tags = "【系统管理】商品规格")
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/v1/specs")
|
||||
@RequestMapping("/admin-api/v1/specifications")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class SpecController {
|
||||
public class SpecificationController {
|
||||
|
||||
private IPmsCategorySpecService iPmsCategorySpecService;
|
||||
|
||||
@ApiOperation(value = "规格分类列表", httpMethod = "GET")
|
||||
@ApiOperation(value = "分类规格列表", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "categoryId", value = "分类ID", paramType = "query", dataType = "Long")
|
||||
})
|
@ -17,12 +17,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "分类接口【移动端】")
|
||||
@RestController
|
||||
@Api(tags = "【移动端】商品分类")
|
||||
@RestController("AppCategoryController")
|
||||
@RequestMapping("/api.app/v1/categories")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class AppCategoryController {
|
||||
public class CategoryController {
|
||||
|
||||
private IPmsCategoryService iPmsCategoryService;
|
||||
|
@ -17,12 +17,11 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "商品SKU")
|
||||
@RestController
|
||||
@RequestMapping("/api.app/v1/sku")
|
||||
@Slf4j
|
||||
@Api(tags = "【移动端】商品库存")
|
||||
@RestController("AppInventoryController")
|
||||
@RequestMapping("/api.app/v1/inventories")
|
||||
@AllArgsConstructor
|
||||
public class AppSkuController {
|
||||
public class InventoryController {
|
||||
|
||||
private IPmsSkuService iPmsSkuService;
|
||||
|
@ -3,7 +3,7 @@ package com.youlai.mall.pms.controller.app;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.common.result.Result;
|
||||
import com.youlai.mall.pms.bo.AppProductBO;
|
||||
import com.youlai.mall.pms.bo.app.ProductBO;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpu;
|
||||
import com.youlai.mall.pms.service.IPmsSpuService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -11,15 +11,13 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Api(tags = "商品接口")
|
||||
@RestController
|
||||
@Api(tags = "【移动端】商品信息")
|
||||
@RestController("AppProductController")
|
||||
@RequestMapping("/api.app/v1/products")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class AppProductController {
|
||||
public class ProductController {
|
||||
|
||||
private IPmsSpuService iPmsSpuService;
|
||||
|
||||
@ -47,8 +45,8 @@ public class AppProductController {
|
||||
@ApiOperation(value = "商品详情", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "商品id", required = true, paramType = "path", dataType = "Long")
|
||||
@GetMapping("/{id}")
|
||||
public Result<AppProductBO> detail(@PathVariable Long id) {
|
||||
AppProductBO product = iPmsSpuService.getProductByIdForApp(id);
|
||||
public Result<ProductBO> detail(@PathVariable Long id) {
|
||||
ProductBO product = iPmsSpuService.getProductByIdForApp(id);
|
||||
return Result.success(product);
|
||||
}
|
||||
|
@ -3,8 +3,7 @@ package com.youlai.mall.pms.service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.mall.pms.bo.AppProductBO;
|
||||
import com.youlai.mall.pms.bo.ProductBO;
|
||||
import com.youlai.mall.pms.bo.app.ProductBO;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsSpu;
|
||||
import java.util.List;
|
||||
|
||||
@ -13,13 +12,13 @@ public interface IPmsSpuService extends IService<PmsSpu> {
|
||||
|
||||
IPage<PmsSpu> list(Page<PmsSpu> page, PmsSpu spu);
|
||||
|
||||
boolean add(ProductBO spuBO);
|
||||
boolean add(com.youlai.mall.pms.bo.admin.ProductBO spuBO);
|
||||
|
||||
ProductBO getBySpuId(Long id);
|
||||
com.youlai.mall.pms.bo.admin.ProductBO getBySpuId(Long id);
|
||||
|
||||
boolean removeBySpuIds(List<Long> spuIds);
|
||||
|
||||
boolean updateById(ProductBO spuBO);
|
||||
boolean updateById(com.youlai.mall.pms.bo.admin.ProductBO spuBO);
|
||||
|
||||
AppProductBO getProductByIdForApp(Long id);
|
||||
ProductBO getProductByIdForApp(Long id);
|
||||
}
|
||||
|
@ -7,8 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.mall.pms.bo.AppProductBO;
|
||||
import com.youlai.mall.pms.bo.ProductBO;
|
||||
import com.youlai.mall.pms.bo.app.ProductBO;
|
||||
import com.youlai.mall.pms.mapper.PmsSpuMapper;
|
||||
import com.youlai.mall.pms.pojo.domain.*;
|
||||
import com.youlai.mall.pms.pojo.dto.SpuDTO;
|
||||
@ -44,7 +43,7 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean add(ProductBO spuBO) {
|
||||
public boolean add(com.youlai.mall.pms.bo.admin.ProductBO spuBO) {
|
||||
SpuDTO spuDTO = spuBO.getSpu();
|
||||
List<PmsSpuAttrValue> attrs = spuBO.getAttrs();
|
||||
List<PmsSpuSpecValue> specs = spuBO.getSpecs();
|
||||
@ -81,7 +80,7 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductBO getBySpuId(Long id) {
|
||||
public com.youlai.mall.pms.bo.admin.ProductBO getBySpuId(Long id) {
|
||||
// spu
|
||||
SpuDTO spuDTO = new SpuDTO();
|
||||
PmsSpu spu = this.getById(id);
|
||||
@ -102,13 +101,13 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
List<PmsSku> skuList = iPmsSkuService.list(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, id));
|
||||
|
||||
// 组合
|
||||
ProductBO spuBO = new ProductBO(spuDTO, attrs, specs, skuList);
|
||||
com.youlai.mall.pms.bo.admin.ProductBO spuBO = new com.youlai.mall.pms.bo.admin.ProductBO(spuDTO, attrs, specs, skuList);
|
||||
return spuBO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateById(ProductBO spuBO) {
|
||||
public boolean updateById(com.youlai.mall.pms.bo.admin.ProductBO spuBO) {
|
||||
SpuDTO spuDTO = spuBO.getSpu();
|
||||
|
||||
List<PmsSpuAttrValue> attrs = spuBO.getAttrs();
|
||||
@ -196,7 +195,7 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppProductBO getProductByIdForApp(Long spuId) {
|
||||
public ProductBO getProductByIdForApp(Long spuId) {
|
||||
// spu
|
||||
PmsSpu spu = this.getById(spuId);
|
||||
SpuDTO spuDTO = new SpuDTO();
|
||||
@ -218,7 +217,7 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
// sku
|
||||
List<PmsSku> skuList = iPmsSkuService.list(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, spuId));
|
||||
|
||||
AppProductBO product = new AppProductBO(spuDTO, attrs, specs, skuList);
|
||||
ProductBO product = new ProductBO(spuDTO, attrs, specs, skuList);
|
||||
return product;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.mall.pms.controller;
|
||||
|
||||
import com.youlai.common.result.ResultCode;
|
||||
import com.youlai.mall.pms.bo.AppProductBO;
|
||||
import com.youlai.mall.pms.bo.app.ProductBO;
|
||||
import com.youlai.mall.pms.controller.admin.ProductController;
|
||||
import com.youlai.mall.pms.pojo.domain.PmsCategorySpec;
|
||||
import com.youlai.mall.pms.service.IPmsSpuAttrValueService;
|
||||
@ -69,7 +69,7 @@ public class ProductControllerTest {
|
||||
|
||||
@Test
|
||||
public void getProduct() {
|
||||
AppProductBO product = iPmsSpuService.getProductByIdForApp(1l);
|
||||
ProductBO product = iPmsSpuService.getProductByIdForApp(1l);
|
||||
log.info(product.toString());
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "广告接口")
|
||||
@Api(tags = "【系统管理】营销广告")
|
||||
@RestController
|
||||
@RequestMapping("/api.admin/v1/adverts")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class AdminAdvertController {
|
||||
public class AdvertController {
|
||||
|
||||
private ISmsAdvertService iSmsAdvertService;
|
||||
|
@ -14,12 +14,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "广告接口")
|
||||
@RestController
|
||||
@Api(tags = "【移动端】营销广告")
|
||||
@RestController("AppAdvertController")
|
||||
@RequestMapping("/api.app/v1/adverts")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class AppAdvertController {
|
||||
public class AdvertController {
|
||||
|
||||
private ISmsAdvertService iSmsAdvertService;
|
||||
|
Loading…
Reference in New Issue
Block a user