From a79058f1f631cb38130e48cf42feea9c022ee618 Mon Sep 17 00:00:00 2001 From: ah--desktop Date: Thu, 11 Sep 2025 00:15:25 +0800 Subject: [PATCH] =?UTF-8?q?wip:=20=E6=96=B0=E5=A2=9E=E7=94=B5=E5=95=86?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/aspect/PermissionAspect.java | 5 + .../common/aspect/RoleAspect.java | 5 + .../common/model/vo/PageResultVO.java | 6 +- .../ec/controller/OrderController.java | 75 ++++ .../ec/controller/ProductController.java | 66 +++ .../modules/ec/controller/ShopController.java | 66 +++ .../modules/ec/mapper/OrderItemMapper.java | 12 + .../modules/ec/mapper/OrderMapper.java | 12 + .../modules/ec/mapper/ProductMapper.java | 12 + .../modules/ec/mapper/ShopMapper.java | 12 + .../ec/model/dto/order/CreateOrderDTO.java | 68 ++++ .../model/dto/order/CreateOrderItemDTO.java | 53 +++ .../ec/model/dto/order/OrderFilterDTO.java | 57 +++ .../ec/model/dto/order/UpdateOrderDTO.java | 57 +++ .../model/dto/product/CreateProductDTO.java | 48 +++ .../model/dto/product/ProductFilterDTO.java | 44 ++ .../model/dto/product/UpdateProductDTO.java | 48 +++ .../ec/model/dto/shop/CreateShopDTO.java | 32 ++ .../ec/model/dto/shop/ShopFilterDTO.java | 24 ++ .../ec/model/dto/shop/UpdateShopDTO.java | 32 ++ .../modules/ec/model/po/OrderItemPO.java | 95 +++++ .../modules/ec/model/po/OrderPO.java | 101 +++++ .../modules/ec/model/po/ProductPO.java | 95 +++++ .../modules/ec/model/po/ShopPO.java | 82 ++++ .../modules/ec/model/vo/OrderItemVO.java | 75 ++++ .../modules/ec/model/vo/OrderVO.java | 106 +++++ .../modules/ec/model/vo/ProductVO.java | 81 ++++ .../modules/ec/model/vo/ShopVO.java | 68 ++++ .../modules/ec/service/OrderService.java | 56 +++ .../modules/ec/service/ProductService.java | 48 +++ .../modules/ec/service/ShopService.java | 48 +++ .../ec/service/impl/OrderServiceImpl.java | 311 +++++++++++++++ .../ec/service/impl/ProductServiceImpl.java | 208 ++++++++++ .../ec/service/impl/ShopServiceImpl.java | 177 +++++++++ .../modules/media/model/po/MediaFilePO.java | 2 +- .../modules/media/model/po/MediaImagePO.java | 2 +- .../modules/org/model/po/CompanyMenuPO.java | 2 +- .../modules/org/model/po/CompanyPO.java | 2 +- .../modules/org/model/po/DepartmentPO.java | 2 +- .../org/model/po/PositionCompanyMenuPO.java | 2 +- .../modules/org/model/po/PositionPO.java | 2 +- .../org/service/impl/CompanyServiceImpl.java | 8 +- .../service/impl/DepartmentServiceImpl.java | 2 +- .../org/service/impl/PositionServiceImpl.java | 2 +- .../modules/sub/model/po/PlanPO.java | 2 +- .../modules/sub/model/po/SubscriptionPO.java | 2 +- .../modules/sys/mapper/PermissionMapper.java | 19 - .../modules/sys/model/po/MenuPO.java | 2 +- .../sys/model/po/MenuPermissionPO.java | 2 +- .../modules/sys/model/po/UserPO.java | 2 +- .../service/impl/PermissionServiceImpl.java | 34 +- .../sys/service/impl/UserServiceImpl.java | 11 +- .../resources/mapper/PermissionMapper.xml | 50 --- .../web-antd/src/api/core/organization.ts | 28 +- .../apps/web-antd/src/api/ecommerce/apis.ts | 68 ++++ .../apps/web-antd/src/api/ecommerce/index.ts | 6 + .../web-antd/src/api/ecommerce/types/index.ts | 6 + .../src/api/ecommerce/types/types.dto.ts | 77 ++++ .../src/api/ecommerce/types/types.vo.ts | 55 +++ .../apps/web-antd/src/api/org/apis.ts | 100 +++++ .../apps/web-antd/src/api/org/index.ts | 6 + .../apps/web-antd/src/api/org/types/index.ts | 6 + .../web-antd/src/api/org/types/types.dto.ts | 131 ++++++ .../web-antd/src/api/org/types/types.vo.ts | 91 +++++ .../src/router/routes/modules/ecommerce.ts | 9 + .../apps/web-antd/src/types/common.ts | 51 +++ .../apps/web-antd/src/types/index.ts | 5 + .../organization/company-management/index.vue | 171 +++++--- .../department-management/index.vue | 54 +-- .../position-management/index.vue | 50 +-- .../web-antd/src/views/ecommerce/README.md | 17 +- .../data-import/components/FieldMapping.vue | 14 +- .../ecommerce/product-management/index.vue | 375 ++++++++++++++++++ .../views/ecommerce/shop-management/index.vue | 327 ++++++++++++++- 74 files changed, 3841 insertions(+), 241 deletions(-) create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/OrderController.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/ProductController.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/ShopController.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderItemMapper.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderMapper.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/ProductMapper.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/ShopMapper.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderItemDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/OrderFilterDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/UpdateOrderDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/CreateProductDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/ProductFilterDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/UpdateProductDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/CreateShopDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/ShopFilterDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/UpdateShopDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderItemPO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderPO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductPO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ShopPO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderItemVO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderVO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/ProductVO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/ShopVO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/OrderService.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/ProductService.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/ShopService.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderServiceImpl.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductServiceImpl.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ShopServiceImpl.java delete mode 100644 ecom-dmb-backend/src/main/resources/mapper/PermissionMapper.xml create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/apis.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/index.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/index.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/types.dto.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/types.vo.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/org/apis.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/org/index.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/org/types/index.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/org/types/types.dto.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/api/org/types/types.vo.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/types/common.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/types/index.ts create mode 100644 ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product-management/index.vue diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/aspect/PermissionAspect.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/aspect/PermissionAspect.java index 8854eb6e..f75c374f 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/aspect/PermissionAspect.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/aspect/PermissionAspect.java @@ -48,6 +48,11 @@ public class PermissionAspect { log.debug("权限验证 - 用户角色: {}, 公司ID: {}, 岗位ID: {}, 权限码: {}", role, companyId, positionId, annotation.value()); + // 检查角色是否为空 + if (role == null) { + throw new BusinessException("用户角色信息缺失"); + } + // 根据角色进行权限验证 boolean hasPermission = false; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/aspect/RoleAspect.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/aspect/RoleAspect.java index 50a727a5..e8bacd5d 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/aspect/RoleAspect.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/aspect/RoleAspect.java @@ -43,6 +43,11 @@ public class RoleAspect { log.debug("角色权限验证 - 用户角色: {}, 注解配置: {}", role, annotation.description()); + // 检查角色是否为空 + if (role == null) { + throw new BusinessException("用户角色信息缺失"); + } + // 根据角色进行权限验证 boolean hasPermission = false; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/model/vo/PageResultVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/model/vo/PageResultVO.java index 49c7a089..2abd9cea 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/model/vo/PageResultVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/model/vo/PageResultVO.java @@ -11,7 +11,7 @@ import java.util.List; @AllArgsConstructor @NoArgsConstructor public class PageResultVO implements Serializable { - private List list; // 当前页数据 + private List records; // 当前页数据 private Long total; // 总条数 private Integer page; // 当前页码 private Integer pageSize; // 每页条数 @@ -20,8 +20,8 @@ public class PageResultVO implements Serializable { private Boolean hasPrevPage; // 是否有上一页 // 构造函数 - public PageResultVO(List list, Long total, Integer page, Integer pageSize) { - this.list = list; + public PageResultVO(List records, Long total, Integer page, Integer pageSize) { + this.records = records; this.total = total; this.page = page; this.pageSize = pageSize; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/OrderController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/OrderController.java new file mode 100644 index 00000000..d8b64cf4 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/OrderController.java @@ -0,0 +1,75 @@ +package top.xyquan.ecomdmbbackend.modules.ec.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.web.bind.annotation.*; +import top.xyquan.ecomdmbbackend.common.annotation.RequireRole; +import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; +import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; +import top.xyquan.ecomdmbbackend.common.response.ApiResponse; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.CreateOrderDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.OrderFilterDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.UpdateOrderDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.OrderVO; +import top.xyquan.ecomdmbbackend.modules.ec.service.OrderService; + +/** + * 订单管理控制器 + */ +@Tag(name = "订单管理", description = "订单的增删改查接口") +@RestController +@RequestMapping("/ec/order") +public class OrderController { + + private final OrderService orderService; + + public OrderController(OrderService orderService) { + this.orderService = orderService; + } + + @Operation(summary = "创建订单", description = "创建新的订单") + @PostMapping("/create") + @RequireRole(description = "创建订单", allowUser = false) + public ApiResponse createOrder(@Valid @RequestBody CreateOrderDTO createOrderDTO) { + OrderVO orderVO = orderService.createOrder(createOrderDTO); + return ApiResponse.success(orderVO); + } + + @Operation(summary = "更新订单", description = "更新现有订单信息") + @PutMapping("/update/{id}") + @RequireRole(description = "更新订单", allowUser = false) + public ApiResponse updateOrder(@Valid @RequestBody UpdateOrderDTO updateOrderDTO, + @Parameter(description = "订单ID") @PathVariable Long id) { + OrderVO orderVO = orderService.updateOrder(updateOrderDTO, id); + return ApiResponse.success(orderVO); + } + + @Operation(summary = "删除订单", description = "删除指定订单") + @DeleteMapping("/delete/{id}") + @RequireRole(description = "删除订单", allowUser = false) + public ApiResponse deleteOrder( + @Parameter(description = "订单ID") @PathVariable Long id) { + orderService.deleteOrder(id); + return ApiResponse.success(); + } + + @Operation(summary = "分页获取订单列表", description = "分页获取订单列表,支持条件过滤") + @PostMapping("/page") + @RequireRole(description = "查询订单列表", allowUser = true) + public ApiResponse> getOrderPage( + @Valid @RequestBody PageQueryDTO pageQueryDTO) { + PageResultVO result = orderService.getOrderPage(pageQueryDTO); + return ApiResponse.success(result); + } + + @Operation(summary = "获取订单详情", description = "根据ID获取订单详情") + @GetMapping("/detail/{id}") + @RequireRole(description = "查询订单详情", allowUser = true) + public ApiResponse getOrderById( + @Parameter(description = "订单ID") @PathVariable Long id) { + OrderVO orderVO = orderService.getOrderById(id); + return ApiResponse.success(orderVO); + } +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/ProductController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/ProductController.java new file mode 100644 index 00000000..eae98f76 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/ProductController.java @@ -0,0 +1,66 @@ +package top.xyquan.ecomdmbbackend.modules.ec.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.web.bind.annotation.*; +import top.xyquan.ecomdmbbackend.common.annotation.RequireRole; +import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; +import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; +import top.xyquan.ecomdmbbackend.common.response.ApiResponse; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.CreateProductDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.ProductFilterDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.UpdateProductDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ProductVO; +import top.xyquan.ecomdmbbackend.modules.ec.service.ProductService; + +/** + * 商品管理控制器 + */ +@Tag(name = "商品管理", description = "商品的增删改查接口") +@RestController +@RequestMapping("/ec/product") +public class ProductController { + + private final ProductService productService; + + public ProductController(ProductService productService) { + this.productService = productService; + } + + @Operation(summary = "创建商品", description = "创建新的商品") + @PostMapping("/create") + @RequireRole(description = "创建商品", allowUser = false) + public ApiResponse createProduct(@Valid @RequestBody CreateProductDTO createProductDTO) { + ProductVO productVO = productService.createProduct(createProductDTO); + return ApiResponse.success(productVO); + } + + @Operation(summary = "更新商品", description = "更新现有商品信息") + @PutMapping("/update/{id}") + @RequireRole(description = "更新商品", allowUser = false) + public ApiResponse updateProduct(@Valid @RequestBody UpdateProductDTO updateProductDTO, + @Parameter(description = "商品ID") @PathVariable Long id) { + ProductVO productVO = productService.updateProduct(updateProductDTO, id); + return ApiResponse.success(productVO); + } + + @Operation(summary = "删除商品", description = "删除指定商品") + @DeleteMapping("/delete/{id}") + @RequireRole(description = "删除商品", allowUser = false) + public ApiResponse deleteProduct( + @Parameter(description = "商品ID") @PathVariable Long id) { + productService.deleteProduct(id); + return ApiResponse.success(); + } + + @Operation(summary = "分页获取商品列表", description = "分页获取商品列表,支持条件过滤") + @PostMapping("/page") + @RequireRole(description = "查询商品列表", allowUser = true) + public ApiResponse> getProductPage( + @Valid @RequestBody PageQueryDTO pageQueryDTO) { + PageResultVO result = productService.getProductPage(pageQueryDTO); + return ApiResponse.success(result); + } +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/ShopController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/ShopController.java new file mode 100644 index 00000000..4a8799c6 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/controller/ShopController.java @@ -0,0 +1,66 @@ +package top.xyquan.ecomdmbbackend.modules.ec.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.web.bind.annotation.*; +import top.xyquan.ecomdmbbackend.common.annotation.RequireRole; +import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; +import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; +import top.xyquan.ecomdmbbackend.common.response.ApiResponse; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.CreateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.ShopFilterDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.UpdateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ShopVO; +import top.xyquan.ecomdmbbackend.modules.ec.service.ShopService; + +/** + * 店铺管理控制器 + */ +@Tag(name = "店铺管理", description = "店铺的增删改查接口") +@RestController +@RequestMapping("/ec/shop") +public class ShopController { + + private final ShopService shopService; + + public ShopController(ShopService shopService) { + this.shopService = shopService; + } + + @Operation(summary = "创建店铺", description = "创建新的店铺") + @PostMapping("/create") + @RequireRole(description = "创建店铺", allowUser = false) + public ApiResponse createShop(@Valid @RequestBody CreateShopDTO createShopDTO) { + ShopVO shopVO = shopService.createShop(createShopDTO); + return ApiResponse.success(shopVO); + } + + @Operation(summary = "更新店铺", description = "更新现有店铺信息") + @PutMapping("/update/{id}") + @RequireRole(description = "更新店铺", allowUser = false) + public ApiResponse updateShop(@Valid @RequestBody UpdateShopDTO updateShopDTO, + @Parameter(description = "店铺ID") @PathVariable Long id) { + ShopVO shopVO = shopService.updateShop(updateShopDTO, id); + return ApiResponse.success(shopVO); + } + + @Operation(summary = "删除店铺", description = "删除指定店铺") + @DeleteMapping("/delete/{id}") + @RequireRole(description = "删除店铺", allowUser = false) + public ApiResponse deleteShop( + @Parameter(description = "店铺ID") @PathVariable Long id) { + shopService.deleteShop(id); + return ApiResponse.success(); + } + + @Operation(summary = "分页获取店铺列表", description = "分页获取店铺列表,支持条件过滤") + @PostMapping("/page") + @RequireRole(description = "查询店铺列表", allowUser = true) + public ApiResponse> getShopPage( + @Valid @RequestBody PageQueryDTO pageQueryDTO) { + PageResultVO result = shopService.getShopPage(pageQueryDTO); + return ApiResponse.success(result); + } +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderItemMapper.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderItemMapper.java new file mode 100644 index 00000000..0421fd00 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderItemMapper.java @@ -0,0 +1,12 @@ +package top.xyquan.ecomdmbbackend.modules.ec.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderItemPO; + +/** + * 订单明细Mapper接口 + */ +@Mapper +public interface OrderItemMapper extends BaseMapper { +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderMapper.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderMapper.java new file mode 100644 index 00000000..7715e7aa --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderMapper.java @@ -0,0 +1,12 @@ +package top.xyquan.ecomdmbbackend.modules.ec.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderPO; + +/** + * 订单Mapper接口 + */ +@Mapper +public interface OrderMapper extends BaseMapper { +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/ProductMapper.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/ProductMapper.java new file mode 100644 index 00000000..a43159bc --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/ProductMapper.java @@ -0,0 +1,12 @@ +package top.xyquan.ecomdmbbackend.modules.ec.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.ProductPO; + +/** + * 商品Mapper接口 + */ +@Mapper +public interface ProductMapper extends BaseMapper { +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/ShopMapper.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/ShopMapper.java new file mode 100644 index 00000000..0b842425 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/ShopMapper.java @@ -0,0 +1,12 @@ +package top.xyquan.ecomdmbbackend.modules.ec.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.ShopPO; + +/** + * 店铺Mapper接口 + */ +@Mapper +public interface ShopMapper extends BaseMapper { +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderDTO.java new file mode 100644 index 00000000..743d5281 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderDTO.java @@ -0,0 +1,68 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.order; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +/** + * 创建订单DTO + */ +@Data +@Schema(description = "创建订单DTO") +public class CreateOrderDTO { + + /** + * 店铺ID + */ + @Schema(description = "店铺ID", example = "1", required = true) + @NotNull(message = "店铺ID不能为空") + private Long shopId; + + /** + * 订单号 + */ + @Schema(description = "订单号", example = "ORDER202401010001", required = true) + @NotBlank(message = "订单号不能为空") + private String orderNo; + + /** + * 订单状态 0待发货 1已完成 2已取消 + */ + @Schema(description = "订单状态", example = "0", allowableValues = {"0", "1", "2"}) + private Integer status; + + /** + * 订单金额 + */ + @Schema(description = "订单金额", example = "9999.00", required = true) + @NotNull(message = "订单金额不能为空") + private BigDecimal totalAmount; + + /** + * 商家实收金额 + */ + @Schema(description = "商家实收金额", example = "9999.00") + private BigDecimal receivedAmount; + + /** + * 下单时间 + */ + @Schema(description = "下单时间", example = "2024-01-01T10:00:00", required = true) + @NotNull(message = "下单时间不能为空") + private LocalDateTime orderDate; + + /** + * 订单明细列表 + */ + @Schema(description = "订单明细列表", required = true) + @NotEmpty(message = "订单明细不能为空") + @Valid + private List orderItems; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderItemDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderItemDTO.java new file mode 100644 index 00000000..f6909a53 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderItemDTO.java @@ -0,0 +1,53 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.order; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Positive; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 创建订单明细DTO + */ +@Data +@Schema(description = "创建订单明细DTO") +public class CreateOrderItemDTO { + + /** + * 商品ID + */ + @Schema(description = "商品ID", example = "1", required = true) + @NotNull(message = "商品ID不能为空") + private Long productId; + + /** + * 商品名称(冗余存储) + */ + @Schema(description = "商品名称", example = "iPhone 15 Pro", required = true) + @NotBlank(message = "商品名称不能为空") + private String productName; + + /** + * 数量 + */ + @Schema(description = "数量", example = "1", required = true) + @NotNull(message = "数量不能为空") + @Positive(message = "数量必须大于0") + private Integer quantity; + + /** + * 销售单价 + */ + @Schema(description = "销售单价", example = "9999.00", required = true) + @NotNull(message = "销售单价不能为空") + private BigDecimal unitPrice; + + /** + * 小计金额 + */ + @Schema(description = "小计金额", example = "9999.00", required = true) + @NotNull(message = "小计金额不能为空") + private BigDecimal subtotal; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/OrderFilterDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/OrderFilterDTO.java new file mode 100644 index 00000000..f394a193 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/OrderFilterDTO.java @@ -0,0 +1,57 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.order; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 订单分页查询过滤DTO + */ +@Data +@Schema(description = "订单分页查询过滤DTO") +public class OrderFilterDTO { + + /** + * 店铺ID + */ + @Schema(description = "店铺ID", example = "1") + private Long shopId; + + /** + * 订单号(模糊查询) + */ + @Schema(description = "订单号(模糊查询)", example = "ORDER2024") + private String orderNo; + + /** + * 订单状态 + */ + @Schema(description = "订单状态", example = "0", allowableValues = {"0", "1", "2"}) + private Integer status; + + /** + * 订单金额范围-最小值 + */ + @Schema(description = "订单金额范围-最小值", example = "100.00") + private BigDecimal minTotalAmount; + + /** + * 订单金额范围-最大值 + */ + @Schema(description = "订单金额范围-最大值", example = "10000.00") + private BigDecimal maxTotalAmount; + + /** + * 下单时间范围-开始时间 + */ + @Schema(description = "下单时间范围-开始时间", example = "2024-01-01T00:00:00") + private LocalDateTime startOrderDate; + + /** + * 下单时间范围-结束时间 + */ + @Schema(description = "下单时间范围-结束时间", example = "2024-12-31T23:59:59") + private LocalDateTime endOrderDate; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/UpdateOrderDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/UpdateOrderDTO.java new file mode 100644 index 00000000..3b13aba7 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/UpdateOrderDTO.java @@ -0,0 +1,57 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.order; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 更新订单DTO + */ +@Data +@Schema(description = "更新订单DTO") +public class UpdateOrderDTO { + + /** + * 店铺ID + */ + @Schema(description = "店铺ID", example = "1", required = true) + @NotNull(message = "店铺ID不能为空") + private Long shopId; + + /** + * 订单号 + */ + @Schema(description = "订单号", example = "ORDER202401010001", required = true) + @NotBlank(message = "订单号不能为空") + private String orderNo; + + /** + * 订单状态 0待发货 1已完成 2已取消 + */ + @Schema(description = "订单状态", example = "0", allowableValues = {"0", "1", "2"}) + private Integer status; + + /** + * 订单金额 + */ + @Schema(description = "订单金额", example = "9999.00", required = true) + @NotNull(message = "订单金额不能为空") + private BigDecimal totalAmount; + + /** + * 商家实收金额 + */ + @Schema(description = "商家实收金额", example = "9999.00") + private BigDecimal receivedAmount; + + /** + * 下单时间 + */ + @Schema(description = "下单时间", example = "2024-01-01T10:00:00", required = true) + @NotNull(message = "下单时间不能为空") + private LocalDateTime orderDate; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/CreateProductDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/CreateProductDTO.java new file mode 100644 index 00000000..d22df6ba --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/CreateProductDTO.java @@ -0,0 +1,48 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.product; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 创建商品DTO + */ +@Data +@Schema(description = "创建商品DTO") +public class CreateProductDTO { + + /** + * 商品名称 + */ + @Schema(description = "商品名称", example = "iPhone 15 Pro", required = true) + @NotBlank(message = "商品名称不能为空") + private String name; + + /** + * 商品编码 + */ + @Schema(description = "商品编码", example = "IPHONE15PRO001") + private String specCode; + + /** + * 商品SKU + */ + @Schema(description = "商品SKU", example = "IPHONE15PRO-128G-BLUE") + private String skuCode; + + /** + * 主图URL + */ + @Schema(description = "主图URL", example = "https://example.com/product.jpg") + private String mainImage; + + /** + * 成本价 + */ + @Schema(description = "成本价", example = "8000.00", required = true) + @NotNull(message = "成本价不能为空") + private BigDecimal costPrice; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/ProductFilterDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/ProductFilterDTO.java new file mode 100644 index 00000000..6d632890 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/ProductFilterDTO.java @@ -0,0 +1,44 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.product; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 商品分页查询过滤DTO + */ +@Data +@Schema(description = "商品分页查询过滤DTO") +public class ProductFilterDTO { + + /** + * 商品名称(模糊查询) + */ + @Schema(description = "商品名称(模糊查询)", example = "iPhone") + private String name; + + /** + * 商品编码(模糊查询) + */ + @Schema(description = "商品编码(模糊查询)", example = "IPHONE") + private String specCode; + + /** + * 商品SKU(模糊查询) + */ + @Schema(description = "商品SKU(模糊查询)", example = "IPHONE15") + private String skuCode; + + /** + * 成本价范围-最小值 + */ + @Schema(description = "成本价范围-最小值", example = "1000.00") + private BigDecimal minCostPrice; + + /** + * 成本价范围-最大值 + */ + @Schema(description = "成本价范围-最大值", example = "10000.00") + private BigDecimal maxCostPrice; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/UpdateProductDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/UpdateProductDTO.java new file mode 100644 index 00000000..607e7cc4 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/product/UpdateProductDTO.java @@ -0,0 +1,48 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.product; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 更新商品DTO + */ +@Data +@Schema(description = "更新商品DTO") +public class UpdateProductDTO { + + /** + * 商品名称 + */ + @Schema(description = "商品名称", example = "iPhone 15 Pro", required = true) + @NotBlank(message = "商品名称不能为空") + private String name; + + /** + * 商品编码 + */ + @Schema(description = "商品编码", example = "IPHONE15PRO001") + private String specCode; + + /** + * 商品SKU + */ + @Schema(description = "商品SKU", example = "IPHONE15PRO-128G-BLUE") + private String skuCode; + + /** + * 主图URL + */ + @Schema(description = "主图URL", example = "https://example.com/product.jpg") + private String mainImage; + + /** + * 成本价 + */ + @Schema(description = "成本价", example = "8000.00", required = true) + @NotNull(message = "成本价不能为空") + private BigDecimal costPrice; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/CreateShopDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/CreateShopDTO.java new file mode 100644 index 00000000..fdc2528e --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/CreateShopDTO.java @@ -0,0 +1,32 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +/** + * 创建店铺DTO + */ +@Data +@Schema(description = "创建店铺DTO") +public class CreateShopDTO { + + /** + * 店铺名称 + */ + @Schema(description = "店铺名称", example = "旗舰店", required = true) + @NotBlank(message = "店铺名称不能为空") + private String name; + + /** + * logo URL + */ + @Schema(description = "logo URL", example = "https://example.com/logo.jpg") + private String logo; + + /** + * 平台(如淘宝、京东、拼多多) + */ + @Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"}) + private String platform; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/ShopFilterDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/ShopFilterDTO.java new file mode 100644 index 00000000..c8defe4c --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/ShopFilterDTO.java @@ -0,0 +1,24 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 店铺分页查询过滤DTO + */ +@Data +@Schema(description = "店铺分页查询过滤DTO") +public class ShopFilterDTO { + + /** + * 店铺名称(模糊查询) + */ + @Schema(description = "店铺名称(模糊查询)", example = "旗舰") + private String name; + + /** + * 平台 + */ + @Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"}) + private String platform; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/UpdateShopDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/UpdateShopDTO.java new file mode 100644 index 00000000..2a7caed1 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/shop/UpdateShopDTO.java @@ -0,0 +1,32 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +/** + * 更新店铺DTO + */ +@Data +@Schema(description = "更新店铺DTO") +public class UpdateShopDTO { + + /** + * 店铺名称 + */ + @Schema(description = "店铺名称", example = "旗舰店", required = true) + @NotBlank(message = "店铺名称不能为空") + private String name; + + /** + * logo URL + */ + @Schema(description = "logo URL", example = "https://example.com/logo.jpg") + private String logo; + + /** + * 平台(如淘宝、京东、拼多多) + */ + @Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"}) + private String platform; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderItemPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderItemPO.java new file mode 100644 index 00000000..6ffcf0c3 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderItemPO.java @@ -0,0 +1,95 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.po; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 电商-订单明细实体 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("ec_order_item") +public class OrderItemPO { + + /** + * 订单明细ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 订单ID + */ + @TableField("order_id") + private Long orderId; + + /** + * 商品ID + */ + @TableField("product_id") + private Long productId; + + /** + * 商品名称(冗余存储) + */ + @TableField("product_name") + private String productName; + + /** + * 数量 + */ + @TableField("quantity") + private Integer quantity; + + /** + * 销售单价 + */ + @TableField("unit_price") + private BigDecimal unitPrice; + + /** + * 小计金额 + */ + @TableField("subtotal") + private BigDecimal subtotal; + + /** + * 创建时间 + */ + @TableField(value = "create_time", fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; + + /** + * 删除时间 + */ + @TableField("delete_time") + private LocalDateTime deleteTime; + + /** + * 创建人ID + */ + @TableField("create_by") + private Long createBy; + + /** + * 更新人ID + */ + @TableField("update_by") + private Long updateBy; + + /** + * 删除人ID + */ + @TableField("delete_by") + private Long deleteBy; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderPO.java new file mode 100644 index 00000000..a032395d --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderPO.java @@ -0,0 +1,101 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.po; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 电商-订单实体 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("ec_order") +public class OrderPO { + + /** + * 订单ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 公司ID + */ + @TableField("company_id") + private Long companyId; + + /** + * 店铺ID + */ + @TableField("shop_id") + private Long shopId; + + /** + * 订单号 + */ + @TableField("order_no") + private String orderNo; + + /** + * 订单状态 0待发货 1已完成 2已取消 + */ + @TableField("status") + private Integer status; + + /** + * 订单金额 + */ + @TableField("total_amount") + private BigDecimal totalAmount; + + /** + * 商家实收金额 + */ + @TableField("received_amount") + private BigDecimal receivedAmount; + + /** + * 下单时间 + */ + @TableField("order_date") + private LocalDateTime orderDate; + + /** + * 创建时间 + */ + @TableField(value = "create_time", fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; + + /** + * 删除时间 + */ + @TableField("delete_time") + private LocalDateTime deleteTime; + + /** + * 创建人ID + */ + @TableField("create_by") + private Long createBy; + + /** + * 更新人ID + */ + @TableField("update_by") + private Long updateBy; + + /** + * 删除人ID + */ + @TableField("delete_by") + private Long deleteBy; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductPO.java new file mode 100644 index 00000000..1873a55d --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductPO.java @@ -0,0 +1,95 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.po; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 电商-商品实体 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("ec_product") +public class ProductPO { + + /** + * 商品ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 公司ID + */ + @TableField("company_id") + private Long companyId; + + /** + * 商品名称 + */ + @TableField("name") + private String name; + + /** + * 商品编码 + */ + @TableField("spec_code") + private String specCode; + + /** + * 商品SKU + */ + @TableField("sku_code") + private String skuCode; + + /** + * 主图URL + */ + @TableField("main_image") + private String mainImage; + + /** + * 成本价 + */ + @TableField("cost_price") + private BigDecimal costPrice; + + /** + * 创建时间 + */ + @TableField(value = "create_time", fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; + + /** + * 删除时间 + */ + @TableField("delete_time") + private LocalDateTime deleteTime; + + /** + * 创建人ID + */ + @TableField("create_by") + private Long createBy; + + /** + * 更新人ID + */ + @TableField("update_by") + private Long updateBy; + + /** + * 删除人ID + */ + @TableField("delete_by") + private Long deleteBy; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ShopPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ShopPO.java new file mode 100644 index 00000000..bea00332 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ShopPO.java @@ -0,0 +1,82 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.po; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.LocalDateTime; + +/** + * 电商-店铺实体 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("ec_shop") +public class ShopPO { + + /** + * 店铺ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 所属公司ID + */ + @TableField("company_id") + private Long companyId; + + /** + * 店铺名称 + */ + @TableField("name") + private String name; + + /** + * logo URL + */ + @TableField("logo") + private String logo; + + /** + * 平台(如淘宝、京东、拼多多) + */ + @TableField("platform") + private String platform; + + /** + * 创建时间 + */ + @TableField(value = "create_time", fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; + + /** + * 删除时间 + */ + @TableField("delete_time") + private LocalDateTime deleteTime; + + /** + * 创建人ID + */ + @TableField("create_by") + private Long createBy; + + /** + * 更新人ID + */ + @TableField("update_by") + private Long updateBy; + + /** + * 删除人ID + */ + @TableField("delete_by") + private Long deleteBy; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderItemVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderItemVO.java new file mode 100644 index 00000000..0ef2340e --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderItemVO.java @@ -0,0 +1,75 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 订单明细VO + */ +@Data +@Schema(description = "订单明细VO") +public class OrderItemVO { + + /** + * 订单明细ID + */ + @Schema(description = "订单明细ID", example = "1") + private Long id; + + /** + * 订单ID + */ + @Schema(description = "订单ID", example = "1") + private Long orderId; + + /** + * 商品ID + */ + @Schema(description = "商品ID", example = "1") + private Long productId; + + /** + * 商品名称(冗余存储) + */ + @Schema(description = "商品名称", example = "iPhone 15 Pro") + private String productName; + + /** + * 商品主图 + */ + @Schema(description = "商品主图", example = "https://example.com/product.jpg") + private String productImage; + + /** + * 数量 + */ + @Schema(description = "数量", example = "1") + private Integer quantity; + + /** + * 销售单价 + */ + @Schema(description = "销售单价", example = "9999.00") + private BigDecimal unitPrice; + + /** + * 小计金额 + */ + @Schema(description = "小计金额", example = "9999.00") + private BigDecimal subtotal; + + /** + * 创建时间 + */ + @Schema(description = "创建时间", example = "2024-01-01T10:00:00") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @Schema(description = "更新时间", example = "2024-01-01T10:00:00") + private LocalDateTime updateTime; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderVO.java new file mode 100644 index 00000000..54fcc1cb --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderVO.java @@ -0,0 +1,106 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +/** + * 订单VO + */ +@Data +@Schema(description = "订单VO") +public class OrderVO { + + /** + * 订单ID + */ + @Schema(description = "订单ID", example = "1") + private Long id; + + /** + * 公司ID + */ + @Schema(description = "公司ID", example = "1") + private Long companyId; + + /** + * 店铺ID + */ + @Schema(description = "店铺ID", example = "1") + private Long shopId; + + /** + * 店铺名称 + */ + @Schema(description = "店铺名称", example = "旗舰店") + private String shopName; + + /** + * 订单号 + */ + @Schema(description = "订单号", example = "ORDER202401010001") + private String orderNo; + + /** + * 订单状态 0待发货 1已完成 2已取消 + */ + @Schema(description = "订单状态", example = "0", allowableValues = {"0", "1", "2"}) + private Integer status; + + /** + * 订单状态描述 + */ + @Schema(description = "订单状态描述", example = "待发货") + private String statusDesc; + + /** + * 订单金额 + */ + @Schema(description = "订单金额", example = "9999.00") + private BigDecimal totalAmount; + + /** + * 商家实收金额 + */ + @Schema(description = "商家实收金额", example = "9999.00") + private BigDecimal receivedAmount; + + /** + * 下单时间 + */ + @Schema(description = "下单时间", example = "2024-01-01T10:00:00") + private LocalDateTime orderDate; + + /** + * 创建时间 + */ + @Schema(description = "创建时间", example = "2024-01-01T10:00:00") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @Schema(description = "更新时间", example = "2024-01-01T10:00:00") + private LocalDateTime updateTime; + + /** + * 创建人ID + */ + @Schema(description = "创建人ID", example = "1") + private Long createBy; + + /** + * 更新人ID + */ + @Schema(description = "更新人ID", example = "1") + private Long updateBy; + + /** + * 订单明细列表 + */ + @Schema(description = "订单明细列表") + private List orderItems; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/ProductVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/ProductVO.java new file mode 100644 index 00000000..14248493 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/ProductVO.java @@ -0,0 +1,81 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 商品VO + */ +@Data +@Schema(description = "商品VO") +public class ProductVO { + + /** + * 商品ID + */ + @Schema(description = "商品ID", example = "1") + private Long id; + + /** + * 公司ID + */ + @Schema(description = "公司ID", example = "1") + private Long companyId; + + /** + * 商品名称 + */ + @Schema(description = "商品名称", example = "iPhone 15 Pro") + private String name; + + /** + * 商品编码 + */ + @Schema(description = "商品编码", example = "IPHONE15PRO001") + private String specCode; + + /** + * 商品SKU + */ + @Schema(description = "商品SKU", example = "IPHONE15PRO-128G-BLUE") + private String skuCode; + + /** + * 主图URL + */ + @Schema(description = "主图URL", example = "https://example.com/product.jpg") + private String mainImage; + + /** + * 成本价 + */ + @Schema(description = "成本价", example = "8000.00") + private BigDecimal costPrice; + + /** + * 创建时间 + */ + @Schema(description = "创建时间", example = "2024-01-01T10:00:00") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @Schema(description = "更新时间", example = "2024-01-01T10:00:00") + private LocalDateTime updateTime; + + /** + * 创建人ID + */ + @Schema(description = "创建人ID", example = "1") + private Long createBy; + + /** + * 更新人ID + */ + @Schema(description = "更新人ID", example = "1") + private Long updateBy; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/ShopVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/ShopVO.java new file mode 100644 index 00000000..10e58b01 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/ShopVO.java @@ -0,0 +1,68 @@ +package top.xyquan.ecomdmbbackend.modules.ec.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 店铺VO + */ +@Data +@Schema(description = "店铺VO") +public class ShopVO { + + /** + * 店铺ID + */ + @Schema(description = "店铺ID", example = "1") + private Long id; + + /** + * 所属公司ID + */ + @Schema(description = "所属公司ID", example = "1") + private Long companyId; + + /** + * 店铺名称 + */ + @Schema(description = "店铺名称", example = "旗舰店") + private String name; + + /** + * logo URL + */ + @Schema(description = "logo URL", example = "https://example.com/logo.jpg") + private String logo; + + /** + * 平台(如淘宝、京东、拼多多) + */ + @Schema(description = "平台", example = "淘宝") + private String platform; + + /** + * 创建时间 + */ + @Schema(description = "创建时间", example = "2024-01-01T10:00:00") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @Schema(description = "更新时间", example = "2024-01-01T10:00:00") + private LocalDateTime updateTime; + + /** + * 创建人ID + */ + @Schema(description = "创建人ID", example = "1") + private Long createBy; + + /** + * 更新人ID + */ + @Schema(description = "更新人ID", example = "1") + private Long updateBy; +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/OrderService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/OrderService.java new file mode 100644 index 00000000..a75bae47 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/OrderService.java @@ -0,0 +1,56 @@ +package top.xyquan.ecomdmbbackend.modules.ec.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; +import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.CreateOrderDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.OrderFilterDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.UpdateOrderDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderPO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.OrderVO; + +/** + * 订单服务接口 + */ +public interface OrderService extends IService { + + /** + * 创建订单 + * + * @param createOrderDTO 创建订单DTO + * @return 订单VO + */ + OrderVO createOrder(CreateOrderDTO createOrderDTO); + + /** + * 更新订单 + * + * @param updateOrderDTO 更新订单DTO + * @param id 订单ID + * @return 订单VO + */ + OrderVO updateOrder(UpdateOrderDTO updateOrderDTO, Long id); + + /** + * 删除订单 + * + * @param id 订单ID + */ + void deleteOrder(Long id); + + /** + * 分页获取订单列表 + * + * @param pageQueryDTO 分页查询DTO + * @return 分页结果 + */ + PageResultVO getOrderPage(PageQueryDTO pageQueryDTO); + + /** + * 根据ID获取订单详情 + * + * @param id 订单ID + * @return 订单VO + */ + OrderVO getOrderById(Long id); +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/ProductService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/ProductService.java new file mode 100644 index 00000000..39904429 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/ProductService.java @@ -0,0 +1,48 @@ +package top.xyquan.ecomdmbbackend.modules.ec.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; +import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.CreateProductDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.ProductFilterDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.UpdateProductDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.ProductPO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ProductVO; + +/** + * 商品服务接口 + */ +public interface ProductService extends IService { + + /** + * 创建商品 + * + * @param createProductDTO 创建商品DTO + * @return 商品VO + */ + ProductVO createProduct(CreateProductDTO createProductDTO); + + /** + * 更新商品 + * + * @param updateProductDTO 更新商品DTO + * @param id 商品ID + * @return 商品VO + */ + ProductVO updateProduct(UpdateProductDTO updateProductDTO, Long id); + + /** + * 删除商品 + * + * @param id 商品ID + */ + void deleteProduct(Long id); + + /** + * 分页获取商品列表 + * + * @param pageQueryDTO 分页查询DTO + * @return 分页结果 + */ + PageResultVO getProductPage(PageQueryDTO pageQueryDTO); +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/ShopService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/ShopService.java new file mode 100644 index 00000000..aa6adb7c --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/ShopService.java @@ -0,0 +1,48 @@ +package top.xyquan.ecomdmbbackend.modules.ec.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; +import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.CreateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.ShopFilterDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.UpdateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.ShopPO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ShopVO; + +/** + * 店铺服务接口 + */ +public interface ShopService extends IService { + + /** + * 创建店铺 + * + * @param createShopDTO 创建店铺DTO + * @return 店铺VO + */ + ShopVO createShop(CreateShopDTO createShopDTO); + + /** + * 更新店铺 + * + * @param updateShopDTO 更新店铺DTO + * @param id 店铺ID + * @return 店铺VO + */ + ShopVO updateShop(UpdateShopDTO updateShopDTO, Long id); + + /** + * 删除店铺 + * + * @param id 店铺ID + */ + void deleteShop(Long id); + + /** + * 分页获取店铺列表 + * + * @param pageQueryDTO 分页查询DTO + * @return 分页结果 + */ + PageResultVO getShopPage(PageQueryDTO pageQueryDTO); +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderServiceImpl.java new file mode 100644 index 00000000..69343028 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderServiceImpl.java @@ -0,0 +1,311 @@ +package top.xyquan.ecomdmbbackend.modules.ec.service.impl; + +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 org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import top.xyquan.ecomdmbbackend.common.exception.BusinessException; +import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; +import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; +import top.xyquan.ecomdmbbackend.modules.ec.mapper.OrderItemMapper; +import top.xyquan.ecomdmbbackend.modules.ec.mapper.OrderMapper; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.CreateOrderDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.CreateOrderItemDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.OrderFilterDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.UpdateOrderDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderItemPO; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderPO; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.ShopPO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.OrderItemVO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.OrderVO; +import top.xyquan.ecomdmbbackend.modules.ec.service.OrderService; +import top.xyquan.ecomdmbbackend.modules.ec.service.ShopService; +import top.xyquan.ecomdmbbackend.utils.CurrentUserContext; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 订单服务实现类 + */ +@Service +public class OrderServiceImpl extends ServiceImpl implements OrderService { + + private final CurrentUserContext currentUserContext; + private final ShopService shopService; + private final OrderItemMapper orderItemMapper; + + public OrderServiceImpl(CurrentUserContext currentUserContext, ShopService shopService, OrderItemMapper orderItemMapper) { + this.currentUserContext = currentUserContext; + this.shopService = shopService; + this.orderItemMapper = orderItemMapper; + } + + @Override + @Transactional + public OrderVO createOrder(CreateOrderDTO createOrderDTO) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证店铺是否存在且属于当前公司 + ShopPO shop = shopService.getById(createOrderDTO.getShopId()); + if (shop == null || !shop.getCompanyId().equals(companyId)) { + throw new BusinessException("店铺不存在"); + } + + // 验证订单号是否重复 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(OrderPO::getOrderNo, createOrderDTO.getOrderNo()) + .eq(OrderPO::getCompanyId, companyId) + .isNull(OrderPO::getDeleteTime); + if (this.count(wrapper) > 0) { + throw new BusinessException("订单号已存在"); + } + + // 创建订单 + OrderPO order = new OrderPO(); + BeanUtils.copyProperties(createOrderDTO, order); + + // 设置公司ID + order.setCompanyId(companyId); + + // 设置默认值 + if (order.getStatus() == null) { + order.setStatus(0); // 默认待发货 + } + if (order.getReceivedAmount() == null) { + order.setReceivedAmount(order.getTotalAmount()); + } + + // 设置创建人ID + order.setCreateBy(currentUserContext.getCurrentUserId()); + + // 保存订单 + this.save(order); + + // 创建订单明细 + for (CreateOrderItemDTO itemDTO : createOrderDTO.getOrderItems()) { + OrderItemPO orderItem = new OrderItemPO(); + BeanUtils.copyProperties(itemDTO, orderItem); + orderItem.setOrderId(order.getId()); + orderItem.setCreateBy(currentUserContext.getCurrentUserId()); + orderItemMapper.insert(orderItem); + } + + // 转换为VO并返回 + return convertToVO(order); + } + + @Override + @Transactional + public OrderVO updateOrder(UpdateOrderDTO updateOrderDTO, Long id) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证订单是否存在 + OrderPO existingOrder = this.getById(id); + if (existingOrder == null || !existingOrder.getCompanyId().equals(companyId)) { + throw new BusinessException("订单不存在"); + } + + // 验证店铺是否存在且属于当前公司 + ShopPO shop = shopService.getById(updateOrderDTO.getShopId()); + if (shop == null || !shop.getCompanyId().equals(companyId)) { + throw new BusinessException("店铺不存在"); + } + + // 验证订单号是否重复(排除当前订单) + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(OrderPO::getOrderNo, updateOrderDTO.getOrderNo()) + .eq(OrderPO::getCompanyId, companyId) + .ne(OrderPO::getId, id) + .isNull(OrderPO::getDeleteTime); + if (this.count(wrapper) > 0) { + throw new BusinessException("订单号已存在"); + } + + // 更新订单 + OrderPO order = new OrderPO(); + BeanUtils.copyProperties(updateOrderDTO, order); + order.setId(id); + order.setCompanyId(companyId); + + // 设置更新人ID + order.setUpdateBy(currentUserContext.getCurrentUserId()); + + // 更新订单 + this.updateById(order); + + // 转换为VO并返回 + return convertToVO(order); + } + + @Override + @Transactional + public void deleteOrder(Long id) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证订单是否存在 + OrderPO existingOrder = this.getById(id); + if (existingOrder == null || !existingOrder.getCompanyId().equals(companyId)) { + throw new BusinessException("订单不存在"); + } + + // 软删除订单 + OrderPO order = new OrderPO(); + order.setId(id); + order.setDeleteTime(LocalDateTime.now()); + order.setDeleteBy(currentUserContext.getCurrentUserId()); + + this.updateById(order); + + // 软删除订单明细 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(OrderItemPO::getOrderId, id) + .isNull(OrderItemPO::getDeleteTime); + List orderItems = orderItemMapper.selectList(wrapper); + for (OrderItemPO orderItem : orderItems) { + orderItem.setDeleteTime(LocalDateTime.now()); + orderItem.setDeleteBy(currentUserContext.getCurrentUserId()); + orderItemMapper.updateById(orderItem); + } + } + + @Override + public PageResultVO getOrderPage(PageQueryDTO pageQueryDTO) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 创建分页对象 + Page page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize()); + + // 构建查询条件 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(OrderPO::getCompanyId, companyId) + .isNull(OrderPO::getDeleteTime); + + // 添加过滤条件 + OrderFilterDTO filter = pageQueryDTO.getFilters(); + if (filter != null) { + if (filter.getShopId() != null) { + wrapper.eq(OrderPO::getShopId, filter.getShopId()); + } + if (filter.getOrderNo() != null && !filter.getOrderNo().trim().isEmpty()) { + wrapper.like(OrderPO::getOrderNo, filter.getOrderNo()); + } + if (filter.getStatus() != null) { + wrapper.eq(OrderPO::getStatus, filter.getStatus()); + } + if (filter.getMinTotalAmount() != null) { + wrapper.ge(OrderPO::getTotalAmount, filter.getMinTotalAmount()); + } + if (filter.getMaxTotalAmount() != null) { + wrapper.le(OrderPO::getTotalAmount, filter.getMaxTotalAmount()); + } + if (filter.getStartOrderDate() != null) { + wrapper.ge(OrderPO::getOrderDate, filter.getStartOrderDate()); + } + if (filter.getEndOrderDate() != null) { + wrapper.le(OrderPO::getOrderDate, filter.getEndOrderDate()); + } + } + + // 排序 + wrapper.orderByDesc(OrderPO::getOrderDate) + .orderByDesc(OrderPO::getCreateTime); + + // 执行分页查询 + IPage pageResult = this.page(page, wrapper); + + // 转换为VO + List voList = pageResult.getRecords().stream() + .map(this::convertToVO) + .collect(Collectors.toList()); + + // 构建分页结果 + return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize()); + } + + @Override + public OrderVO getOrderById(Long id) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证订单是否存在 + OrderPO order = this.getById(id); + if (order == null || !order.getCompanyId().equals(companyId)) { + throw new BusinessException("订单不存在"); + } + + // 转换为VO + OrderVO orderVO = convertToVO(order); + + // 查询订单明细 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(OrderItemPO::getOrderId, id) + .isNull(OrderItemPO::getDeleteTime) + .orderByAsc(OrderItemPO::getCreateTime); + List orderItems = orderItemMapper.selectList(wrapper); + + // 转换为VO + List orderItemVOs = orderItems.stream() + .map(this::convertOrderItemToVO) + .collect(Collectors.toList()); + + orderVO.setOrderItems(orderItemVOs); + + return orderVO; + } + + /** + * 转换为VO + */ + private OrderVO convertToVO(OrderPO order) { + OrderVO orderVO = new OrderVO(); + BeanUtils.copyProperties(order, orderVO); + + // 设置状态描述 + orderVO.setStatusDesc(getStatusDesc(order.getStatus())); + + // 设置店铺名称 + ShopPO shop = shopService.getById(order.getShopId()); + if (shop != null) { + orderVO.setShopName(shop.getName()); + } + + return orderVO; + } + + /** + * 转换订单明细为VO + */ + private OrderItemVO convertOrderItemToVO(OrderItemPO orderItem) { + OrderItemVO orderItemVO = new OrderItemVO(); + BeanUtils.copyProperties(orderItem, orderItemVO); + return orderItemVO; + } + + /** + * 获取状态描述 + */ + private String getStatusDesc(Integer status) { + if (status == null) { + return "未知"; + } + switch (status) { + case 0: + return "待发货"; + case 1: + return "已完成"; + case 2: + return "已取消"; + default: + return "未知"; + } + } +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductServiceImpl.java new file mode 100644 index 00000000..140e8a4d --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductServiceImpl.java @@ -0,0 +1,208 @@ +package top.xyquan.ecomdmbbackend.modules.ec.service.impl; + +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 org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import top.xyquan.ecomdmbbackend.common.exception.BusinessException; +import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; +import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; +import top.xyquan.ecomdmbbackend.modules.ec.mapper.ProductMapper; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.CreateProductDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.ProductFilterDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.UpdateProductDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.ProductPO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ProductVO; +import top.xyquan.ecomdmbbackend.modules.ec.service.ProductService; +import top.xyquan.ecomdmbbackend.utils.CurrentUserContext; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 商品服务实现类 + */ +@Service +public class ProductServiceImpl extends ServiceImpl implements ProductService { + + private final CurrentUserContext currentUserContext; + + public ProductServiceImpl(CurrentUserContext currentUserContext) { + this.currentUserContext = currentUserContext; + } + + @Override + @Transactional + public ProductVO createProduct(CreateProductDTO createProductDTO) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证商品名称是否重复 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ProductPO::getName, createProductDTO.getName()) + .eq(ProductPO::getCompanyId, companyId) + .isNull(ProductPO::getDeleteTime); + if (this.count(wrapper) > 0) { + throw new BusinessException("商品名称已存在"); + } + + // 验证SKU是否重复 + if (createProductDTO.getSkuCode() != null && !createProductDTO.getSkuCode().trim().isEmpty()) { + LambdaQueryWrapper skuWrapper = new LambdaQueryWrapper<>(); + skuWrapper.eq(ProductPO::getSkuCode, createProductDTO.getSkuCode()) + .eq(ProductPO::getCompanyId, companyId) + .isNull(ProductPO::getDeleteTime); + if (this.count(skuWrapper) > 0) { + throw new BusinessException("商品SKU已存在"); + } + } + + // 创建商品 + ProductPO product = new ProductPO(); + BeanUtils.copyProperties(createProductDTO, product); + + // 设置公司ID + product.setCompanyId(companyId); + + // 设置创建人ID + product.setCreateBy(currentUserContext.getCurrentUserId()); + + // 保存商品 + this.save(product); + + // 转换为VO并返回 + return convertToVO(product); + } + + @Override + @Transactional + public ProductVO updateProduct(UpdateProductDTO updateProductDTO, Long id) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证商品是否存在 + ProductPO existingProduct = this.getById(id); + if (existingProduct == null || !existingProduct.getCompanyId().equals(companyId)) { + throw new BusinessException("商品不存在"); + } + + // 验证商品名称是否重复(排除当前商品) + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ProductPO::getName, updateProductDTO.getName()) + .eq(ProductPO::getCompanyId, companyId) + .ne(ProductPO::getId, id) + .isNull(ProductPO::getDeleteTime); + if (this.count(wrapper) > 0) { + throw new BusinessException("商品名称已存在"); + } + + // 验证SKU是否重复(排除当前商品) + if (updateProductDTO.getSkuCode() != null && !updateProductDTO.getSkuCode().trim().isEmpty()) { + LambdaQueryWrapper skuWrapper = new LambdaQueryWrapper<>(); + skuWrapper.eq(ProductPO::getSkuCode, updateProductDTO.getSkuCode()) + .eq(ProductPO::getCompanyId, companyId) + .ne(ProductPO::getId, id) + .isNull(ProductPO::getDeleteTime); + if (this.count(skuWrapper) > 0) { + throw new BusinessException("商品SKU已存在"); + } + } + + // 更新商品 + ProductPO product = new ProductPO(); + BeanUtils.copyProperties(updateProductDTO, product); + product.setId(id); + product.setCompanyId(companyId); + + // 设置更新人ID + product.setUpdateBy(currentUserContext.getCurrentUserId()); + + // 更新商品 + this.updateById(product); + + // 转换为VO并返回 + return convertToVO(product); + } + + @Override + @Transactional + public void deleteProduct(Long id) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证商品是否存在 + ProductPO existingProduct = this.getById(id); + if (existingProduct == null || !existingProduct.getCompanyId().equals(companyId)) { + throw new BusinessException("商品不存在"); + } + + // 软删除商品 + ProductPO product = new ProductPO(); + product.setId(id); + product.setDeleteTime(LocalDateTime.now()); + product.setDeleteBy(currentUserContext.getCurrentUserId()); + + this.updateById(product); + } + + @Override + public PageResultVO getProductPage(PageQueryDTO pageQueryDTO) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 创建分页对象 + Page page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize()); + + // 构建查询条件 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ProductPO::getCompanyId, companyId) + .isNull(ProductPO::getDeleteTime); + + // 添加过滤条件 + ProductFilterDTO filter = pageQueryDTO.getFilters(); + if (filter != null) { + if (filter.getName() != null && !filter.getName().trim().isEmpty()) { + wrapper.like(ProductPO::getName, filter.getName()); + } + if (filter.getSpecCode() != null && !filter.getSpecCode().trim().isEmpty()) { + wrapper.like(ProductPO::getSpecCode, filter.getSpecCode()); + } + if (filter.getSkuCode() != null && !filter.getSkuCode().trim().isEmpty()) { + wrapper.like(ProductPO::getSkuCode, filter.getSkuCode()); + } + if (filter.getMinCostPrice() != null) { + wrapper.ge(ProductPO::getCostPrice, filter.getMinCostPrice()); + } + if (filter.getMaxCostPrice() != null) { + wrapper.le(ProductPO::getCostPrice, filter.getMaxCostPrice()); + } + } + + // 排序 + wrapper.orderByDesc(ProductPO::getCreateTime); + + // 执行分页查询 + IPage pageResult = this.page(page, wrapper); + + // 转换为VO + List voList = pageResult.getRecords().stream() + .map(this::convertToVO) + .collect(Collectors.toList()); + + // 构建分页结果 + return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize()); + } + + /** + * 转换为VO + */ + private ProductVO convertToVO(ProductPO product) { + ProductVO productVO = new ProductVO(); + BeanUtils.copyProperties(product, productVO); + return productVO; + } +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ShopServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ShopServiceImpl.java new file mode 100644 index 00000000..56e4ed6a --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ShopServiceImpl.java @@ -0,0 +1,177 @@ +package top.xyquan.ecomdmbbackend.modules.ec.service.impl; + +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 org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import top.xyquan.ecomdmbbackend.common.exception.BusinessException; +import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; +import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; +import top.xyquan.ecomdmbbackend.modules.ec.mapper.ShopMapper; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.CreateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.ShopFilterDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.UpdateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ec.model.po.ShopPO; +import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ShopVO; +import top.xyquan.ecomdmbbackend.modules.ec.service.ShopService; +import top.xyquan.ecomdmbbackend.utils.CurrentUserContext; +import top.xyquan.ecomdmbbackend.utils.SecurityUtils; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 店铺服务实现类 + */ +@Service +public class ShopServiceImpl extends ServiceImpl implements ShopService { + + private final CurrentUserContext currentUserContext; + + public ShopServiceImpl(CurrentUserContext currentUserContext) { + this.currentUserContext = currentUserContext; + } + + @Override + @Transactional + public ShopVO createShop(CreateShopDTO createShopDTO) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证店铺名称是否重复 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ShopPO::getName, createShopDTO.getName()) + .eq(ShopPO::getCompanyId, companyId) + .isNull(ShopPO::getDeleteTime); + if (this.count(wrapper) > 0) { + throw new BusinessException("店铺名称已存在"); + } + + // 创建店铺 + ShopPO shop = new ShopPO(); + BeanUtils.copyProperties(createShopDTO, shop); + + // 设置公司ID + shop.setCompanyId(companyId); + + // 设置创建人ID + shop.setCreateBy(currentUserContext.getCurrentUserId()); + + // 保存店铺 + this.save(shop); + + // 转换为VO并返回 + return convertToVO(shop); + } + + @Override + @Transactional + public ShopVO updateShop(UpdateShopDTO updateShopDTO, Long id) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证店铺是否存在 + ShopPO existingShop = this.getById(id); + if (existingShop == null || !existingShop.getCompanyId().equals(companyId)) { + throw new BusinessException("店铺不存在"); + } + + // 验证店铺名称是否重复(排除当前店铺) + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ShopPO::getName, updateShopDTO.getName()) + .eq(ShopPO::getCompanyId, companyId) + .ne(ShopPO::getId, id) + .isNull(ShopPO::getDeleteTime); + if (this.count(wrapper) > 0) { + throw new BusinessException("店铺名称已存在"); + } + + // 更新店铺 + ShopPO shop = new ShopPO(); + BeanUtils.copyProperties(updateShopDTO, shop); + shop.setId(id); + shop.setCompanyId(companyId); + + // 设置更新人ID + shop.setUpdateBy(currentUserContext.getCurrentUserId()); + + // 更新店铺 + this.updateById(shop); + + // 转换为VO并返回 + return convertToVO(shop); + } + + @Override + @Transactional + public void deleteShop(Long id) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证店铺是否存在 + ShopPO existingShop = this.getById(id); + if (existingShop == null || !existingShop.getCompanyId().equals(companyId)) { + throw new BusinessException("店铺不存在"); + } + + // 软删除店铺 + ShopPO shop = new ShopPO(); + shop.setId(id); + shop.setDeleteTime(LocalDateTime.now()); + shop.setDeleteBy(currentUserContext.getCurrentUserId()); + + this.updateById(shop); + } + + @Override + public PageResultVO getShopPage(PageQueryDTO pageQueryDTO) { + // 从token中获取公司ID + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 创建分页对象 + Page page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize()); + + // 构建查询条件 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ShopPO::getCompanyId, companyId) + .isNull(ShopPO::getDeleteTime); + + // 添加过滤条件 + ShopFilterDTO filter = pageQueryDTO.getFilters(); + if (filter != null) { + if (filter.getName() != null && !filter.getName().trim().isEmpty()) { + wrapper.like(ShopPO::getName, filter.getName()); + } + if (filter.getPlatform() != null && !filter.getPlatform().trim().isEmpty()) { + wrapper.eq(ShopPO::getPlatform, filter.getPlatform()); + } + } + + // 排序 + wrapper.orderByDesc(ShopPO::getCreateTime); + + // 执行分页查询 + IPage pageResult = this.page(page, wrapper); + + // 转换为VO + List voList = pageResult.getRecords().stream() + .map(this::convertToVO) + .collect(Collectors.toList()); + + // 构建分页结果 + return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize()); + } + + /** + * 转换为VO + */ + private ShopVO convertToVO(ShopPO shop) { + ShopVO shopVO = new ShopVO(); + BeanUtils.copyProperties(shop, shopVO); + return shopVO; + } +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/media/model/po/MediaFilePO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/media/model/po/MediaFilePO.java index e273f9ce..6eb51f21 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/media/model/po/MediaFilePO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/media/model/po/MediaFilePO.java @@ -17,7 +17,7 @@ public class MediaFilePO { /** * 文件ID */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/media/model/po/MediaImagePO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/media/model/po/MediaImagePO.java index 9d043205..41fb89b4 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/media/model/po/MediaImagePO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/media/model/po/MediaImagePO.java @@ -17,7 +17,7 @@ public class MediaImagePO { /** * 图片ID */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/CompanyMenuPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/CompanyMenuPO.java index 1a9690cc..42ce769d 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/CompanyMenuPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/CompanyMenuPO.java @@ -17,7 +17,7 @@ public class CompanyMenuPO { /** * 关联ID */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/CompanyPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/CompanyPO.java index 0614846a..a55d33ff 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/CompanyPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/CompanyPO.java @@ -17,7 +17,7 @@ public class CompanyPO { /** * 公司ID */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/DepartmentPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/DepartmentPO.java index f8117887..1cb78ab3 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/DepartmentPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/DepartmentPO.java @@ -17,7 +17,7 @@ public class DepartmentPO { /** * 部门ID */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/PositionCompanyMenuPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/PositionCompanyMenuPO.java index ecb85921..b91b43bf 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/PositionCompanyMenuPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/PositionCompanyMenuPO.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; */ @Data @EqualsAndHashCode(callSuper = false) -@TableName("rel_position_company_menu") +@TableName("org_position_company_menu_map") public class PositionCompanyMenuPO { /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/PositionPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/PositionPO.java index f7a293f1..44f85817 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/PositionPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/model/po/PositionPO.java @@ -17,7 +17,7 @@ public class PositionPO { /** * 岗位ID */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/service/impl/CompanyServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/service/impl/CompanyServiceImpl.java index 8aa3c57e..ebf3fb10 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/service/impl/CompanyServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/service/impl/CompanyServiceImpl.java @@ -115,16 +115,16 @@ public class CompanyServiceImpl extends ServiceImpl im // 添加过滤条件 CompanyFilterDTO filterDTO = pageQuery.getFilters(); if (filterDTO != null) { - if (StringUtils.hasText(filterDTO.getName())) { + if (filterDTO.getName() != null && StringUtils.hasText(filterDTO.getName())) { wrapper.like(CompanyPO::getName, filterDTO.getName()); } - if (StringUtils.hasText(filterDTO.getContactPerson())) { + if (filterDTO.getContactPerson() != null && StringUtils.hasText(filterDTO.getContactPerson())) { wrapper.like(CompanyPO::getContactPerson, filterDTO.getContactPerson()); } - if (StringUtils.hasText(filterDTO.getContactPhone())) { + if (filterDTO.getContactPhone() != null && StringUtils.hasText(filterDTO.getContactPhone())) { wrapper.eq(CompanyPO::getContactPhone, filterDTO.getContactPhone()); } - if (StringUtils.hasText(filterDTO.getEmail())) { + if (filterDTO.getEmail() != null && StringUtils.hasText(filterDTO.getEmail())) { wrapper.eq(CompanyPO::getEmail, filterDTO.getEmail()); } if (filterDTO.getStatus() != null) { diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/service/impl/DepartmentServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/service/impl/DepartmentServiceImpl.java index 88dd141a..d32ff8ed 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/service/impl/DepartmentServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/org/service/impl/DepartmentServiceImpl.java @@ -150,7 +150,7 @@ public class DepartmentServiceImpl extends ServiceImpl // 添加过滤条件 PositionFilterDTO queryDTO = pageQueryDTO.getFilters(); if (queryDTO != null) { - if (StringUtils.hasText(queryDTO.getName())) { + if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) { wrapper.like(PositionPO::getName, queryDTO.getName()); } if (queryDTO.getStatus() != null) { diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/model/po/PlanPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/model/po/PlanPO.java index 54197451..196acfdb 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/model/po/PlanPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/model/po/PlanPO.java @@ -17,7 +17,7 @@ public class PlanPO { /** * 套餐ID */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/model/po/SubscriptionPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/model/po/SubscriptionPO.java index 18b768b6..1238ae81 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/model/po/SubscriptionPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sub/model/po/SubscriptionPO.java @@ -18,7 +18,7 @@ public class SubscriptionPO { /** * 记录ID */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/mapper/PermissionMapper.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/mapper/PermissionMapper.java index c4a03554..50df1cfb 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/mapper/PermissionMapper.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/mapper/PermissionMapper.java @@ -1,10 +1,7 @@ package top.xyquan.ecomdmbbackend.modules.sys.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; import top.xyquan.ecomdmbbackend.modules.sys.model.po.PermissionPO; /** @@ -12,20 +9,4 @@ import top.xyquan.ecomdmbbackend.modules.sys.model.po.PermissionPO; */ @Mapper public interface PermissionMapper extends BaseMapper { - - /** - * 分页查询权限列表 - * - * @param page 分页参数 - * @param code 权限码 - * @param name 权限名称 - * @param type 权限类型 - * @param status 状态 - * @return 分页结果 - */ - IPage selectPermissionPage(Page page, - @Param("code") String code, - @Param("name") String name, - @Param("type") String type, - @Param("status") Integer status); } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/MenuPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/MenuPO.java index 01c747a3..7c3db1f1 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/MenuPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/MenuPO.java @@ -17,7 +17,7 @@ public class MenuPO { /** * 菜单ID */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/MenuPermissionPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/MenuPermissionPO.java index 65a532d1..70527374 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/MenuPermissionPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/MenuPermissionPO.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; */ @Data @EqualsAndHashCode(callSuper = false) -@TableName("rel_menu_permission") +@TableName("sys_menu_permission_map") public class MenuPermissionPO { /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/UserPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/UserPO.java index e312751b..51f058c2 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/UserPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/model/po/UserPO.java @@ -17,7 +17,7 @@ public class UserPO { /** * 用户编号 */ - @TableId(value = "id", type = IdType.ASSIGN_ID) + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/service/impl/PermissionServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/service/impl/PermissionServiceImpl.java index 8a74eb86..48c8456a 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/service/impl/PermissionServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/service/impl/PermissionServiceImpl.java @@ -3,6 +3,7 @@ package top.xyquan.ecomdmbbackend.modules.sys.service.impl; 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 org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import top.xyquan.ecomdmbbackend.common.exception.BusinessException; @@ -27,7 +28,7 @@ import java.util.stream.Collectors; * 权限服务实现类 */ @Service -public class PermissionServiceImpl implements PermissionService { +public class PermissionServiceImpl extends ServiceImpl implements PermissionService { private final PermissionMapper permissionMapper; private final CurrentUserContext currentUserContext; @@ -102,12 +103,31 @@ public class PermissionServiceImpl implements PermissionService { public PageResultVO getPermissionPage(PageQueryDTO filterDTO) { Page page = new Page<>(filterDTO.getPage(), filterDTO.getPageSize()); - IPage permissionPage = permissionMapper.selectPermissionPage( - page, - filterDTO.getFilters().getCode(), - filterDTO.getFilters().getName(), - filterDTO.getFilters().getType(), - filterDTO.getFilters().getStatus()); + // 构建查询条件 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + // 添加过滤条件 + PermissionFilterDTO filter = filterDTO.getFilters(); + if (filter != null) { + if (filter.getCode() != null && !filter.getCode().trim().isEmpty()) { + wrapper.like(PermissionPO::getCode, filter.getCode()); + } + if (filter.getName() != null && !filter.getName().trim().isEmpty()) { + wrapper.like(PermissionPO::getName, filter.getName()); + } + if (filter.getType() != null && !filter.getType().trim().isEmpty()) { + wrapper.eq(PermissionPO::getType, filter.getType()); + } + if (filter.getStatus() != null) { + wrapper.eq(PermissionPO::getStatus, filter.getStatus()); + } + } + + // 排序 + wrapper.orderByDesc(PermissionPO::getCreateTime); + + // 执行分页查询 + IPage permissionPage = this.page(page, wrapper); List permissionVOList = permissionPage.getRecords().stream() .map(this::convertToVO) diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/service/impl/UserServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/service/impl/UserServiceImpl.java index ba9e9aa6..77aa194d 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/service/impl/UserServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/service/impl/UserServiceImpl.java @@ -18,6 +18,7 @@ import top.xyquan.ecomdmbbackend.modules.sys.model.vo.UserVO; import top.xyquan.ecomdmbbackend.modules.sys.service.UserService; import top.xyquan.ecomdmbbackend.utils.JwtUtils; import top.xyquan.ecomdmbbackend.utils.SecurityUtils; +import top.xyquan.ecomdmbbackend.utils.TokenPayload; import java.time.LocalDateTime; @@ -214,8 +215,14 @@ public class UserServiceImpl extends ServiceImpl implements private LoginVO generateLoginResponse(UserPO user) { LoginVO loginVO = new LoginVO(); - // 生成JWT令牌,包含用户ID和公司ID - String token = jwtUtils.generateToken(user.getId().toString(), user.getCompanyId()); + // 生成JWT令牌,包含完整的用户信息 + TokenPayload payload = TokenPayload.builder() + .userId(user.getId().toString()) + .companyId(user.getCompanyId()) + .role(user.getRole()) + .positionId(user.getPositionId()) + .build(); + String token = jwtUtils.generateToken(payload); loginVO.setToken(token); // 转换用户信息 diff --git a/ecom-dmb-backend/src/main/resources/mapper/PermissionMapper.xml b/ecom-dmb-backend/src/main/resources/mapper/PermissionMapper.xml deleted file mode 100644 index 6f70bf36..00000000 --- a/ecom-dmb-backend/src/main/resources/mapper/PermissionMapper.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/core/organization.ts b/ecom-dmb-frontend/apps/web-antd/src/api/core/organization.ts index faab012d..57abb840 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/core/organization.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/core/organization.ts @@ -1,20 +1,6 @@ import { requestClient } from '#/api/request'; -// 分页查询参数 -export interface PageQuery { - page: number; - size: number; - filter?: any; -} - -// 分页结果 -export interface PageResult { - records: T[]; - total: number; - size: number; - current: number; - pages: number; -} +import type { PageQueryDTO, PageResultVO } from '#/types/common'; export namespace CompanyApi { /** 公司信息 */ @@ -149,8 +135,8 @@ export namespace PositionApi { } // 公司管理API -export async function getCompanyPageApi(params: PageQuery & { filter?: CompanyApi.CompanyFilter }) { - return requestClient.post>('/company/page', params); +export async function getCompanyPageApi(params: PageQueryDTO) { + return requestClient.post>('/company/page', params); } export async function createCompanyApi(data: CompanyApi.CreateCompanyParams) { @@ -166,8 +152,8 @@ export async function deleteCompanyApi(id: number) { } // 部门管理API -export async function getDepartmentPageApi(params: PageQuery & { filter?: DepartmentApi.DepartmentFilter }) { - return requestClient.post>('/department/page', params); +export async function getDepartmentPageApi(params: PageQueryDTO) { + return requestClient.post>('/department/page', params); } export async function createDepartmentApi(data: DepartmentApi.CreateDepartmentParams) { @@ -183,8 +169,8 @@ export async function deleteDepartmentApi(id: number) { } // 岗位管理API -export async function getPositionPageApi(params: PageQuery & { filter?: PositionApi.PositionFilter }) { - return requestClient.post>('/position/page', params); +export async function getPositionPageApi(params: PageQueryDTO) { + return requestClient.post>('/position/page', params); } export async function createPositionApi(data: PositionApi.CreatePositionParams) { diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/apis.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/apis.ts new file mode 100644 index 00000000..fd8d89fc --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/apis.ts @@ -0,0 +1,68 @@ +import { requestClient } from '#/api/request'; + +import type { PageQueryDTO, PageResultVO } from '#/types/common'; +import type { ShopDTO, ShopVO, ProductDTO, ProductVO } from './types'; + +/** + * 店铺管理API + */ + +/** + * 分页获取店铺列表 + */ +export async function getShopPageApi(params: PageQueryDTO) { + return requestClient.post>('/ec/shop/page', params); +} + +/** + * 创建店铺 + */ +export async function createShopApi(data: ShopDTO.CreateShopDTO) { + return requestClient.post('/ec/shop/create', data); +} + +/** + * 更新店铺 + */ +export async function updateShopApi(id: number, data: ShopDTO.UpdateShopDTO) { + return requestClient.put(`/ec/shop/update/${id}`, data); +} + +/** + * 删除店铺 + */ +export async function deleteShopApi(id: number) { + return requestClient.delete(`/ec/shop/delete/${id}`); +} + +/** + * 商品管理API + */ + +/** + * 分页获取商品列表 + */ +export async function getProductPageApi(params: PageQueryDTO) { + return requestClient.post>('/ec/product/page', params); +} + +/** + * 创建商品 + */ +export async function createProductApi(data: ProductDTO.CreateProductDTO) { + return requestClient.post('/ec/product/create', data); +} + +/** + * 更新商品 + */ +export async function updateProductApi(id: number, data: ProductDTO.UpdateProductDTO) { + return requestClient.put(`/ec/product/update/${id}`, data); +} + +/** + * 删除商品 + */ +export async function deleteProductApi(id: number) { + return requestClient.delete(`/ec/product/delete/${id}`); +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/index.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/index.ts new file mode 100644 index 00000000..9f8f8d01 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/index.ts @@ -0,0 +1,6 @@ +/** + * 电商模块API导出 + */ + +export * from './apis'; +export * from './types'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/index.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/index.ts new file mode 100644 index 00000000..bb7d7a45 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/index.ts @@ -0,0 +1,6 @@ +/** + * 电商模块类型定义导出 + */ + +export * from './types.dto'; +export * from './types.vo'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/types.dto.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/types.dto.ts new file mode 100644 index 00000000..7d3aad09 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/types.dto.ts @@ -0,0 +1,77 @@ +/** + * 电商模块DTO类型定义 + */ + +export namespace ShopDTO { + /** 创建店铺参数 */ + export interface CreateShopDTO { + /** 店铺名称 */ + name: string; + /** logo URL */ + logo?: string; + /** 平台(如淘宝、京东、拼多多) */ + platform?: string; + } + + /** 更新店铺参数 */ + export interface UpdateShopDTO { + /** 店铺名称 */ + name: string; + /** logo URL */ + logo?: string; + /** 平台(如淘宝、京东、拼多多) */ + platform?: string; + } + + /** 店铺过滤条件 */ + export interface ShopFiltersDTO { + /** 店铺名称(模糊查询) */ + name?: string; + /** 平台 */ + platform?: string; + } +} + +export namespace ProductDTO { + /** 创建商品参数 */ + export interface CreateProductDTO { + /** 商品名称 */ + name: string; + /** 商品编码 */ + specCode?: string; + /** 商品SKU */ + skuCode?: string; + /** 主图URL */ + mainImage?: string; + /** 成本价 */ + costPrice: number; + } + + /** 更新商品参数 */ + export interface UpdateProductDTO { + /** 商品名称 */ + name: string; + /** 商品编码 */ + specCode?: string; + /** 商品SKU */ + skuCode?: string; + /** 主图URL */ + mainImage?: string; + /** 成本价 */ + costPrice: number; + } + + /** 商品过滤条件 */ + export interface ProductFiltersDTO { + /** 商品名称(模糊查询) */ + name?: string; + /** 商品编码(模糊查询) */ + specCode?: string; + /** 商品SKU(模糊查询) */ + skuCode?: string; + /** 成本价范围-最小值 */ + minCostPrice?: number; + /** 成本价范围-最大值 */ + maxCostPrice?: number; + } +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/types.vo.ts new file mode 100644 index 00000000..4fa46e7f --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/types.vo.ts @@ -0,0 +1,55 @@ +/** + * 电商模块VO类型定义 + */ + +export namespace ShopVO { + /** 店铺信息 */ + export interface ShopInfoVO { + /** 店铺ID */ + id: number; + /** 所属公司ID */ + companyId: number; + /** 店铺名称 */ + name: string; + /** logo URL */ + logo?: string; + /** 平台(如淘宝、京东、拼多多) */ + platform?: string; + /** 创建时间 */ + createTime: string; + /** 更新时间 */ + updateTime: string; + /** 创建人ID */ + createBy?: number; + /** 更新人ID */ + updateBy?: number; + } +} + +export namespace ProductVO { + /** 商品信息 */ + export interface ProductInfoVO { + /** 商品ID */ + id: number; + /** 公司ID */ + companyId: number; + /** 商品名称 */ + name: string; + /** 商品编码 */ + specCode?: string; + /** 商品SKU */ + skuCode?: string; + /** 主图URL */ + mainImage?: string; + /** 成本价 */ + costPrice: number; + /** 创建时间 */ + createTime: string; + /** 更新时间 */ + updateTime: string; + /** 创建人ID */ + createBy?: number; + /** 更新人ID */ + updateBy?: number; + } +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/org/apis.ts b/ecom-dmb-frontend/apps/web-antd/src/api/org/apis.ts new file mode 100644 index 00000000..ffb59090 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/org/apis.ts @@ -0,0 +1,100 @@ +import { requestClient } from '#/api/request'; + +import type { PageQueryDTO, PageResultVO } from '#/types/common'; +import type { CompanyDTO, CompanyVO, DepartmentDTO, DepartmentVO, PositionDTO, PositionVO } from './types'; + +/** + * 公司管理API + */ + +/** + * 分页获取公司列表 + */ +export async function getCompanyPageApi(params: PageQueryDTO) { + return requestClient.post>('/company/page', params); +} + +/** + * 创建公司 + */ +export async function createCompanyApi(data: CompanyDTO.CreateCompanyDTO) { + return requestClient.post('/company/create', data); +} + +/** + * 更新公司 + */ +export async function updateCompanyApi(id: number, data: CompanyDTO.UpdateCompanyDTO) { + return requestClient.put(`/company/update/${id}`, data); +} + +/** + * 删除公司 + */ +export async function deleteCompanyApi(id: number) { + return requestClient.delete(`/company/delete/${id}`); +} + +/** + * 部门管理API + */ + +/** + * 分页获取部门列表 + */ +export async function getDepartmentPageApi(params: PageQueryDTO) { + return requestClient.post>('/department/page', params); +} + +/** + * 创建部门 + */ +export async function createDepartmentApi(data: DepartmentDTO.CreateDepartmentDTO) { + return requestClient.post('/department/create', data); +} + +/** + * 更新部门 + */ +export async function updateDepartmentApi(id: number, data: DepartmentDTO.UpdateDepartmentDTO) { + return requestClient.put(`/department/update/${id}`, data); +} + +/** + * 删除部门 + */ +export async function deleteDepartmentApi(id: number) { + return requestClient.delete(`/department/delete/${id}`); +} + +/** + * 岗位管理API + */ + +/** + * 分页获取岗位列表 + */ +export async function getPositionPageApi(params: PageQueryDTO) { + return requestClient.post>('/position/page', params); +} + +/** + * 创建岗位 + */ +export async function createPositionApi(data: PositionDTO.CreatePositionDTO) { + return requestClient.post('/position/create', data); +} + +/** + * 更新岗位 + */ +export async function updatePositionApi(id: number, data: PositionDTO.UpdatePositionDTO) { + return requestClient.put(`/position/update/${id}`, data); +} + +/** + * 删除岗位 + */ +export async function deletePositionApi(id: number) { + return requestClient.delete(`/position/delete/${id}`); +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/org/index.ts b/ecom-dmb-frontend/apps/web-antd/src/api/org/index.ts new file mode 100644 index 00000000..3259a8b4 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/org/index.ts @@ -0,0 +1,6 @@ +/** + * 组织管理模块API导出 + */ + +export * from './apis'; +export * from './types'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/org/types/index.ts b/ecom-dmb-frontend/apps/web-antd/src/api/org/types/index.ts new file mode 100644 index 00000000..df28a751 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/org/types/index.ts @@ -0,0 +1,6 @@ +/** + * 组织管理模块类型定义导出 + */ + +export * from './types.dto'; +export * from './types.vo'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/org/types/types.dto.ts b/ecom-dmb-frontend/apps/web-antd/src/api/org/types/types.dto.ts new file mode 100644 index 00000000..78a0d6f9 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/org/types/types.dto.ts @@ -0,0 +1,131 @@ +/** + * 组织管理模块DTO类型定义 + */ + +export namespace CompanyDTO { + /** 创建公司参数 */ + export interface CreateCompanyDTO { + /** 公司名称 */ + name: string; + /** 公司地址 */ + address?: string; + /** 联系人 */ + contactPerson?: string; + /** 联系电话 */ + contactPhone?: string; + /** 邮箱 */ + email?: string; + /** Logo */ + logo?: string; + /** 状态 */ + status?: number; + /** 订阅到期时间 */ + expireTime?: string; + } + + /** 更新公司参数 */ + export interface UpdateCompanyDTO { + /** 公司名称 */ + name: string; + /** 公司地址 */ + address?: string; + /** 联系人 */ + contactPerson?: string; + /** 联系电话 */ + contactPhone?: string; + /** 邮箱 */ + email?: string; + /** Logo */ + logo?: string; + /** 状态 */ + status?: number; + /** 订阅到期时间 */ + expireTime?: string; + } + + /** 公司过滤条件 */ + export interface CompanyFiltersDTO { + /** 公司名称(模糊查询) */ + name?: string; + /** 状态 */ + status?: number; + } +} + +export namespace DepartmentDTO { + /** 创建部门参数 */ + export interface CreateDepartmentDTO { + /** 部门名称 */ + name: string; + /** 父部门ID */ + parentId?: number; + /** 备注 */ + remark?: string; + /** 状态 */ + status?: number; + } + + /** 更新部门参数 */ + export interface UpdateDepartmentDTO { + /** 部门名称 */ + name: string; + /** 父部门ID */ + parentId?: number; + /** 备注 */ + remark?: string; + /** 状态 */ + status?: number; + } + + /** 部门过滤条件 */ + export interface DepartmentFiltersDTO { + /** 部门名称(模糊查询) */ + name?: string; + /** 公司ID */ + companyId?: number; + /** 状态 */ + status?: number; + } +} + +export namespace PositionDTO { + /** 创建岗位参数 */ + export interface CreatePositionDTO { + /** 岗位名称 */ + name: string; + /** 岗位编码 */ + code?: string; + /** 部门ID */ + departmentId?: number; + /** 备注 */ + remark?: string; + /** 状态 */ + status?: number; + } + + /** 更新岗位参数 */ + export interface UpdatePositionDTO { + /** 岗位名称 */ + name: string; + /** 岗位编码 */ + code?: string; + /** 部门ID */ + departmentId?: number; + /** 备注 */ + remark?: string; + /** 状态 */ + status?: number; + } + + /** 岗位过滤条件 */ + export interface PositionFiltersDTO { + /** 岗位名称(模糊查询) */ + name?: string; + /** 公司ID */ + companyId?: number; + /** 部门ID */ + departmentId?: number; + /** 状态 */ + status?: number; + } +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/org/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/org/types/types.vo.ts new file mode 100644 index 00000000..32141305 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/api/org/types/types.vo.ts @@ -0,0 +1,91 @@ +/** + * 组织管理模块VO类型定义 + */ + +export namespace CompanyVO { + /** 公司信息 */ + export interface CompanyInfoVO { + /** 公司ID */ + id: number; + /** 公司名称 */ + name: string; + /** 过期时间 */ + expiration?: string; + /** 公司地址 */ + address?: string; + /** 联系人 */ + contactPerson?: string; + /** 联系电话 */ + contactPhone?: string; + /** 邮箱 */ + email?: string; + /** Logo */ + logo?: string; + /** 状态 */ + status: number; + /** 订阅到期时间 */ + expireTime?: string; + /** 创建时间 */ + createTime: string; + /** 更新时间 */ + updateTime: string; + /** 是否过期 */ + expired?: boolean; + } +} + +export namespace DepartmentVO { + /** 部门信息 */ + export interface DepartmentInfoVO { + /** 部门ID */ + id: number; + /** 部门名称 */ + name: string; + /** 父部门ID */ + parentId?: number; + /** 公司ID */ + companyId: number; + /** 备注 */ + remark?: string; + /** 状态 */ + status: number; + /** 创建时间 */ + createTime: string; + /** 更新时间 */ + updateTime: string; + /** 创建人ID */ + createBy?: number; + /** 更新人ID */ + updateBy?: number; + /** 子部门 */ + children?: DepartmentInfoVO[]; + } +} + +export namespace PositionVO { + /** 岗位信息 */ + export interface PositionInfoVO { + /** 岗位ID */ + id: number; + /** 岗位名称 */ + name: string; + /** 岗位编码 */ + code?: string; + /** 部门ID */ + departmentId?: number; + /** 备注 */ + remark?: string; + /** 状态 */ + status: number; + /** 公司ID */ + companyId: number; + /** 创建时间 */ + createTime: string; + /** 更新时间 */ + updateTime: string; + /** 创建人ID */ + createBy?: number; + /** 更新人ID */ + updateBy?: number; + } +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/router/routes/modules/ecommerce.ts b/ecom-dmb-frontend/apps/web-antd/src/router/routes/modules/ecommerce.ts index 08958b75..102bbd86 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/router/routes/modules/ecommerce.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/router/routes/modules/ecommerce.ts @@ -39,6 +39,15 @@ const routes: RouteRecordRaw[] = [ title: '店铺管理', }, }, + { + name: 'ProductManagement', + path: '/product-management', + component: () => import('#/views/ecommerce/product-management/index.vue'), + meta: { + icon: 'lucide:package', + title: '商品管理', + }, + }, ], }, ]; diff --git a/ecom-dmb-frontend/apps/web-antd/src/types/common.ts b/ecom-dmb-frontend/apps/web-antd/src/types/common.ts new file mode 100644 index 00000000..50a7a6ad --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/types/common.ts @@ -0,0 +1,51 @@ +/** + * 公用类型定义 + */ + +/** + * 分页查询参数DTO + * 对应后端 PageQueryDTO + */ +export interface PageQueryDTO { + /** 页码,从1开始 */ + page: number; + /** 每页大小 */ + pageSize: number; + /** 查询条件 */ + filters?: T; +} + +/** + * 分页结果VO + * 对应后端 PageResultVO + */ +export interface PageResultVO { + /** 当前页数据 */ + records: T[]; + /** 总条数 */ + total: number; + /** 当前页码 */ + page: number; + /** 每页条数 */ + pageSize: number; + /** 总页数 */ + totalPages: number; + /** 是否有下一页 */ + hasNextPage: boolean; + /** 是否有上一页 */ + hasPrevPage: boolean; +} + +/** + * 通用API响应结构 + */ +export interface ApiResponse { + /** 响应码 */ + code: number; + /** 响应消息 */ + message: string; + /** 响应数据 */ + data: T; + /** 是否成功 */ + success: boolean; +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/types/index.ts b/ecom-dmb-frontend/apps/web-antd/src/types/index.ts new file mode 100644 index 00000000..9f9e715d --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/types/index.ts @@ -0,0 +1,5 @@ +/** + * 类型定义导出 + */ + +export * from './common'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/_core/organization/company-management/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/_core/organization/company-management/index.vue index 5c673698..c78fa943 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/_core/organization/company-management/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/_core/organization/company-management/index.vue @@ -1,5 +1,6 @@