mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
wip: 新增电商模块
This commit is contained in:
+5
@@ -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;
|
||||
|
||||
|
||||
@@ -43,6 +43,11 @@ public class RoleAspect {
|
||||
|
||||
log.debug("角色权限验证 - 用户角色: {}, 注解配置: {}", role, annotation.description());
|
||||
|
||||
// 检查角色是否为空
|
||||
if (role == null) {
|
||||
throw new BusinessException("用户角色信息缺失");
|
||||
}
|
||||
|
||||
// 根据角色进行权限验证
|
||||
boolean hasPermission = false;
|
||||
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PageResultVO<T> implements Serializable {
|
||||
private List<T> list; // 当前页数据
|
||||
private List<T> records; // 当前页数据
|
||||
private Long total; // 总条数
|
||||
private Integer page; // 当前页码
|
||||
private Integer pageSize; // 每页条数
|
||||
@@ -20,8 +20,8 @@ public class PageResultVO<T> implements Serializable {
|
||||
private Boolean hasPrevPage; // 是否有上一页
|
||||
|
||||
// 构造函数
|
||||
public PageResultVO(List<T> list, Long total, Integer page, Integer pageSize) {
|
||||
this.list = list;
|
||||
public PageResultVO(List<T> records, Long total, Integer page, Integer pageSize) {
|
||||
this.records = records;
|
||||
this.total = total;
|
||||
this.page = page;
|
||||
this.pageSize = pageSize;
|
||||
|
||||
+75
@@ -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<OrderVO> 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<OrderVO> 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<Void> deleteOrder(
|
||||
@Parameter(description = "订单ID") @PathVariable Long id) {
|
||||
orderService.deleteOrder(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取订单列表", description = "分页获取订单列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询订单列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<OrderVO>> getOrderPage(
|
||||
@Valid @RequestBody PageQueryDTO<OrderFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<OrderVO> result = orderService.getOrderPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取订单详情", description = "根据ID获取订单详情")
|
||||
@GetMapping("/detail/{id}")
|
||||
@RequireRole(description = "查询订单详情", allowUser = true)
|
||||
public ApiResponse<OrderVO> getOrderById(
|
||||
@Parameter(description = "订单ID") @PathVariable Long id) {
|
||||
OrderVO orderVO = orderService.getOrderById(id);
|
||||
return ApiResponse.success(orderVO);
|
||||
}
|
||||
}
|
||||
+66
@@ -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<ProductVO> 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<ProductVO> 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<Void> deleteProduct(
|
||||
@Parameter(description = "商品ID") @PathVariable Long id) {
|
||||
productService.deleteProduct(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取商品列表", description = "分页获取商品列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询商品列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<ProductVO>> getProductPage(
|
||||
@Valid @RequestBody PageQueryDTO<ProductFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<ProductVO> result = productService.getProductPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
+66
@@ -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<ShopVO> 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<ShopVO> 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<Void> deleteShop(
|
||||
@Parameter(description = "店铺ID") @PathVariable Long id) {
|
||||
shopService.deleteShop(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取店铺列表", description = "分页获取店铺列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询店铺列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<ShopVO>> getShopPage(
|
||||
@Valid @RequestBody PageQueryDTO<ShopFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<ShopVO> result = shopService.getShopPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
+12
@@ -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<OrderItemPO> {
|
||||
}
|
||||
+12
@@ -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<OrderPO> {
|
||||
}
|
||||
+12
@@ -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<ProductPO> {
|
||||
}
|
||||
+12
@@ -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<ShopPO> {
|
||||
}
|
||||
+68
@@ -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<CreateOrderItemDTO> orderItems;
|
||||
}
|
||||
+53
@@ -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;
|
||||
}
|
||||
+57
@@ -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;
|
||||
}
|
||||
+57
@@ -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;
|
||||
}
|
||||
+48
@@ -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;
|
||||
}
|
||||
+44
@@ -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;
|
||||
}
|
||||
+48
@@ -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;
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
+24
@@ -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;
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
+95
@@ -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;
|
||||
}
|
||||
+101
@@ -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;
|
||||
}
|
||||
+95
@@ -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;
|
||||
}
|
||||
+82
@@ -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;
|
||||
}
|
||||
+75
@@ -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;
|
||||
}
|
||||
+106
@@ -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<OrderItemVO> orderItems;
|
||||
}
|
||||
+81
@@ -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;
|
||||
}
|
||||
+68
@@ -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;
|
||||
}
|
||||
+56
@@ -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<OrderPO> {
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
* @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<OrderVO> getOrderPage(PageQueryDTO<OrderFilterDTO> pageQueryDTO);
|
||||
|
||||
/**
|
||||
* 根据ID获取订单详情
|
||||
*
|
||||
* @param id 订单ID
|
||||
* @return 订单VO
|
||||
*/
|
||||
OrderVO getOrderById(Long id);
|
||||
}
|
||||
+48
@@ -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<ProductPO> {
|
||||
|
||||
/**
|
||||
* 创建商品
|
||||
*
|
||||
* @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<ProductVO> getProductPage(PageQueryDTO<ProductFilterDTO> pageQueryDTO);
|
||||
}
|
||||
+48
@@ -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<ShopPO> {
|
||||
|
||||
/**
|
||||
* 创建店铺
|
||||
*
|
||||
* @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<ShopVO> getShopPage(PageQueryDTO<ShopFilterDTO> pageQueryDTO);
|
||||
}
|
||||
+311
@@ -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<OrderMapper, OrderPO> 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<OrderPO> 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<OrderPO> 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<OrderItemPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrderItemPO::getOrderId, id)
|
||||
.isNull(OrderItemPO::getDeleteTime);
|
||||
List<OrderItemPO> orderItems = orderItemMapper.selectList(wrapper);
|
||||
for (OrderItemPO orderItem : orderItems) {
|
||||
orderItem.setDeleteTime(LocalDateTime.now());
|
||||
orderItem.setDeleteBy(currentUserContext.getCurrentUserId());
|
||||
orderItemMapper.updateById(orderItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResultVO<OrderVO> getOrderPage(PageQueryDTO<OrderFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 创建分页对象
|
||||
Page<OrderPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<OrderPO> 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<OrderPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<OrderVO> 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<OrderItemPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrderItemPO::getOrderId, id)
|
||||
.isNull(OrderItemPO::getDeleteTime)
|
||||
.orderByAsc(OrderItemPO::getCreateTime);
|
||||
List<OrderItemPO> orderItems = orderItemMapper.selectList(wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<OrderItemVO> 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 "未知";
|
||||
}
|
||||
}
|
||||
}
|
||||
+208
@@ -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<ProductMapper, ProductPO> 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<ProductPO> 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<ProductPO> 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<ProductPO> 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<ProductPO> 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<ProductVO> getProductPage(PageQueryDTO<ProductFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 创建分页对象
|
||||
Page<ProductPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<ProductPO> 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<ProductPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<ProductVO> 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;
|
||||
}
|
||||
}
|
||||
+177
@@ -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<ShopMapper, ShopPO> 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<ShopPO> 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<ShopPO> 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<ShopVO> getShopPage(PageQueryDTO<ShopFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 创建分页对象
|
||||
Page<ShopPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<ShopPO> 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<ShopPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<ShopVO> 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;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class MediaFilePO {
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class MediaImagePO {
|
||||
/**
|
||||
* 图片ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class CompanyMenuPO {
|
||||
/**
|
||||
* 关联ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class CompanyPO {
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class DepartmentPO {
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class PositionPO {
|
||||
/**
|
||||
* 岗位ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -115,16 +115,16 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> 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) {
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
// 添加过滤条件
|
||||
DepartmentFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
if (queryDTO != null) {
|
||||
if (StringUtils.hasText(queryDTO.getName())) {
|
||||
if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) {
|
||||
wrapper.like(DepartmentPO::getName, queryDTO.getName());
|
||||
}
|
||||
if (queryDTO.getParentId() != null) {
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
||||
// 添加过滤条件
|
||||
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) {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class PlanPO {
|
||||
/**
|
||||
* 套餐ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public class SubscriptionPO {
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
-19
@@ -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<PermissionPO> {
|
||||
|
||||
/**
|
||||
* 分页查询权限列表
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param code 权限码
|
||||
* @param name 权限名称
|
||||
* @param type 权限类型
|
||||
* @param status 状态
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<PermissionPO> selectPermissionPage(Page<PermissionPO> page,
|
||||
@Param("code") String code,
|
||||
@Param("name") String name,
|
||||
@Param("type") String type,
|
||||
@Param("status") Integer status);
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class MenuPO {
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("rel_menu_permission")
|
||||
@TableName("sys_menu_permission_map")
|
||||
public class MenuPermissionPO {
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class UserPO {
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+27
-7
@@ -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<PermissionMapper, PermissionPO> implements PermissionService {
|
||||
|
||||
private final PermissionMapper permissionMapper;
|
||||
private final CurrentUserContext currentUserContext;
|
||||
@@ -102,12 +103,31 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
public PageResultVO<PermissionVO> getPermissionPage(PageQueryDTO<PermissionFilterDTO> filterDTO) {
|
||||
Page<PermissionPO> page = new Page<>(filterDTO.getPage(), filterDTO.getPageSize());
|
||||
|
||||
IPage<PermissionPO> permissionPage = permissionMapper.selectPermissionPage(
|
||||
page,
|
||||
filterDTO.getFilters().getCode(),
|
||||
filterDTO.getFilters().getName(),
|
||||
filterDTO.getFilters().getType(),
|
||||
filterDTO.getFilters().getStatus());
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<PermissionPO> 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<PermissionPO> permissionPage = this.page(page, wrapper);
|
||||
|
||||
List<PermissionVO> permissionVOList = permissionPage.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
|
||||
+9
-2
@@ -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<UserMapper, UserPO> 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);
|
||||
|
||||
// 转换用户信息
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="top.xyquan.ecomdmbbackend.modules.sys.mapper.PermissionMapper">
|
||||
|
||||
<!-- 权限结果映射 -->
|
||||
<resultMap id="PermissionResultMap" type="top.xyquan.ecomdmbbackend.modules.sys.model.po.PermissionPO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="code" property="code"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="create_by" property="createBy"/>
|
||||
<result column="update_by" property="updateBy"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 分页查询权限列表 -->
|
||||
<select id="selectPermissionPage" resultMap="PermissionResultMap">
|
||||
SELECT
|
||||
id,
|
||||
code,
|
||||
name,
|
||||
type,
|
||||
status,
|
||||
remark,
|
||||
create_time,
|
||||
update_time,
|
||||
create_by,
|
||||
update_by
|
||||
FROM sys_permission
|
||||
<where>
|
||||
<if test="code != null and code != ''">
|
||||
AND code LIKE CONCAT('%', #{code}, '%')
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
AND type = #{type}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,20 +1,6 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
// 分页查询参数
|
||||
export interface PageQuery {
|
||||
page: number;
|
||||
size: number;
|
||||
filter?: any;
|
||||
}
|
||||
|
||||
// 分页结果
|
||||
export interface PageResult<T> {
|
||||
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<PageResult<CompanyApi.CompanyInfo>>('/company/page', params);
|
||||
export async function getCompanyPageApi(params: PageQueryDTO<CompanyApi.CompanyFilter>) {
|
||||
return requestClient.post<PageResultVO<CompanyApi.CompanyInfo>>('/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<PageResult<DepartmentApi.DepartmentInfo>>('/department/page', params);
|
||||
export async function getDepartmentPageApi(params: PageQueryDTO<DepartmentApi.DepartmentFilter>) {
|
||||
return requestClient.post<PageResultVO<DepartmentApi.DepartmentInfo>>('/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<PageResult<PositionApi.PositionInfo>>('/position/page', params);
|
||||
export async function getPositionPageApi(params: PageQueryDTO<PositionApi.PositionFilter>) {
|
||||
return requestClient.post<PageResultVO<PositionApi.PositionInfo>>('/position/page', params);
|
||||
}
|
||||
|
||||
export async function createPositionApi(data: PositionApi.CreatePositionParams) {
|
||||
|
||||
@@ -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<ShopDTO.ShopFiltersDTO>) {
|
||||
return requestClient.post<PageResultVO<ShopVO.ShopInfoVO>>('/ec/shop/page', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建店铺
|
||||
*/
|
||||
export async function createShopApi(data: ShopDTO.CreateShopDTO) {
|
||||
return requestClient.post<ShopVO.ShopInfoVO>('/ec/shop/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新店铺
|
||||
*/
|
||||
export async function updateShopApi(id: number, data: ShopDTO.UpdateShopDTO) {
|
||||
return requestClient.put<ShopVO.ShopInfoVO>(`/ec/shop/update/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店铺
|
||||
*/
|
||||
export async function deleteShopApi(id: number) {
|
||||
return requestClient.delete<void>(`/ec/shop/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取商品列表
|
||||
*/
|
||||
export async function getProductPageApi(params: PageQueryDTO<ProductDTO.ProductFiltersDTO>) {
|
||||
return requestClient.post<PageResultVO<ProductVO.ProductInfoVO>>('/ec/product/page', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品
|
||||
*/
|
||||
export async function createProductApi(data: ProductDTO.CreateProductDTO) {
|
||||
return requestClient.post<ProductVO.ProductInfoVO>('/ec/product/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品
|
||||
*/
|
||||
export async function updateProductApi(id: number, data: ProductDTO.UpdateProductDTO) {
|
||||
return requestClient.put<ProductVO.ProductInfoVO>(`/ec/product/update/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*/
|
||||
export async function deleteProductApi(id: number) {
|
||||
return requestClient.delete<void>(`/ec/product/delete/${id}`);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 电商模块API导出
|
||||
*/
|
||||
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 电商模块类型定义导出
|
||||
*/
|
||||
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<CompanyDTO.CompanyFiltersDTO>) {
|
||||
return requestClient.post<PageResultVO<CompanyVO.CompanyInfoVO>>('/company/page', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建公司
|
||||
*/
|
||||
export async function createCompanyApi(data: CompanyDTO.CreateCompanyDTO) {
|
||||
return requestClient.post<CompanyVO.CompanyInfoVO>('/company/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新公司
|
||||
*/
|
||||
export async function updateCompanyApi(id: number, data: CompanyDTO.UpdateCompanyDTO) {
|
||||
return requestClient.put<CompanyVO.CompanyInfoVO>(`/company/update/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除公司
|
||||
*/
|
||||
export async function deleteCompanyApi(id: number) {
|
||||
return requestClient.delete<void>(`/company/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取部门列表
|
||||
*/
|
||||
export async function getDepartmentPageApi(params: PageQueryDTO<DepartmentDTO.DepartmentFiltersDTO>) {
|
||||
return requestClient.post<PageResultVO<DepartmentVO.DepartmentInfoVO>>('/department/page', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
export async function createDepartmentApi(data: DepartmentDTO.CreateDepartmentDTO) {
|
||||
return requestClient.post<DepartmentVO.DepartmentInfoVO>('/department/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新部门
|
||||
*/
|
||||
export async function updateDepartmentApi(id: number, data: DepartmentDTO.UpdateDepartmentDTO) {
|
||||
return requestClient.put<DepartmentVO.DepartmentInfoVO>(`/department/update/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*/
|
||||
export async function deleteDepartmentApi(id: number) {
|
||||
return requestClient.delete<void>(`/department/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取岗位列表
|
||||
*/
|
||||
export async function getPositionPageApi(params: PageQueryDTO<PositionDTO.PositionFiltersDTO>) {
|
||||
return requestClient.post<PageResultVO<PositionVO.PositionInfoVO>>('/position/page', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建岗位
|
||||
*/
|
||||
export async function createPositionApi(data: PositionDTO.CreatePositionDTO) {
|
||||
return requestClient.post<PositionVO.PositionInfoVO>('/position/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新岗位
|
||||
*/
|
||||
export async function updatePositionApi(id: number, data: PositionDTO.UpdatePositionDTO) {
|
||||
return requestClient.put<PositionVO.PositionInfoVO>(`/position/update/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位
|
||||
*/
|
||||
export async function deletePositionApi(id: number) {
|
||||
return requestClient.delete<void>(`/position/delete/${id}`);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 组织管理模块API导出
|
||||
*/
|
||||
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 组织管理模块类型定义导出
|
||||
*/
|
||||
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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: '商品管理',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 公用类型定义
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页查询参数DTO
|
||||
* 对应后端 PageQueryDTO<T>
|
||||
*/
|
||||
export interface PageQueryDTO<T = any> {
|
||||
/** 页码,从1开始 */
|
||||
page: number;
|
||||
/** 每页大小 */
|
||||
pageSize: number;
|
||||
/** 查询条件 */
|
||||
filters?: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页结果VO
|
||||
* 对应后端 PageResultVO<T>
|
||||
*/
|
||||
export interface PageResultVO<T = any> {
|
||||
/** 当前页数据 */
|
||||
records: T[];
|
||||
/** 总条数 */
|
||||
total: number;
|
||||
/** 当前页码 */
|
||||
page: number;
|
||||
/** 每页条数 */
|
||||
pageSize: number;
|
||||
/** 总页数 */
|
||||
totalPages: number;
|
||||
/** 是否有下一页 */
|
||||
hasNextPage: boolean;
|
||||
/** 是否有上一页 */
|
||||
hasPrevPage: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用API响应结构
|
||||
*/
|
||||
export interface ApiResponse<T = any> {
|
||||
/** 响应码 */
|
||||
code: number;
|
||||
/** 响应消息 */
|
||||
message: string;
|
||||
/** 响应数据 */
|
||||
data: T;
|
||||
/** 是否成功 */
|
||||
success: boolean;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* 类型定义导出
|
||||
*/
|
||||
|
||||
export * from './common';
|
||||
+120
-51
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { h, ref } from 'vue';
|
||||
import { h, ref, onUnmounted } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { Button, DatePicker, Form, Input, Modal, Select, Table, message } from 'ant-design-vue';
|
||||
@@ -9,14 +10,16 @@ import {
|
||||
deleteCompanyApi,
|
||||
getCompanyPageApi,
|
||||
updateCompanyApi,
|
||||
type CompanyApi as CompanyApiType
|
||||
} from '#/api/core/organization';
|
||||
type CompanyVO,
|
||||
type CompanyDTO
|
||||
} from '#/api/org';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
defineOptions({ name: 'CompanyManagement' });
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const companyList = ref<CompanyApiType.CompanyInfo[]>([]);
|
||||
const companyList = ref<CompanyVO.CompanyInfoVO[]>([]);
|
||||
const total = ref(0);
|
||||
const current = ref(1);
|
||||
const pageSize = ref(10);
|
||||
@@ -33,7 +36,7 @@ const searchForm = ref({
|
||||
});
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<CompanyApiType.CreateCompanyParams>({
|
||||
const formData = ref({
|
||||
name: '',
|
||||
address: '',
|
||||
contactPerson: '',
|
||||
@@ -41,7 +44,7 @@ const formData = ref<CompanyApiType.CreateCompanyParams>({
|
||||
email: '',
|
||||
logo: '',
|
||||
status: 1,
|
||||
expireTime: '',
|
||||
expireTime: null as any,
|
||||
});
|
||||
|
||||
// 状态选项
|
||||
@@ -82,12 +85,28 @@ const columns = [
|
||||
key: 'email',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: 'Logo',
|
||||
dataIndex: 'logo',
|
||||
key: 'logo',
|
||||
width: 100,
|
||||
customRender: ({ record }: { record: CompanyVO.CompanyInfoVO }) => {
|
||||
if (record.logo) {
|
||||
return h('img', {
|
||||
src: record.logo,
|
||||
alt: record.name,
|
||||
style: { width: '40px', height: '40px', objectFit: 'cover', borderRadius: '4px' },
|
||||
});
|
||||
}
|
||||
return h('span', { style: { color: '#999' } }, '暂无Logo');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 100,
|
||||
customRender: ({ record }: { record: CompanyApiType.CompanyInfo }) => {
|
||||
customRender: ({ record }: { record: CompanyVO.CompanyInfoVO }) => {
|
||||
return h('span', {
|
||||
style: { color: record.status === 1 ? '#52c41a' : '#ff4d4f' },
|
||||
}, record.status === 1 ? '正常' : '禁用');
|
||||
@@ -98,6 +117,15 @@ const columns = [
|
||||
dataIndex: 'expireTime',
|
||||
key: 'expireTime',
|
||||
width: 180,
|
||||
customRender: ({ record }: { record: CompanyVO.CompanyInfoVO }) => {
|
||||
if (!record.expireTime) {
|
||||
return h('span', { style: { color: '#999' } }, '未设置');
|
||||
}
|
||||
const isExpired = record.expired;
|
||||
return h('span', {
|
||||
style: { color: isExpired ? '#ff4d4f' : '#52c41a' },
|
||||
}, record.expireTime);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
@@ -110,44 +138,22 @@ const columns = [
|
||||
key: 'action',
|
||||
width: 200,
|
||||
fixed: 'right' as const,
|
||||
customRender: ({ record }: { record: CompanyApiType.CompanyInfo }) => {
|
||||
customRender: ({ record }: { record: CompanyVO.CompanyInfoVO }) => {
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, [
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
onClick: () => handleEdit(record),
|
||||
}, '编辑'),
|
||||
}, { default: () => '编辑' }),
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
danger: true,
|
||||
onClick: () => handleDelete(record),
|
||||
}, '删除'),
|
||||
}, { default: () => '删除' }),
|
||||
]);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 获取公司列表
|
||||
async function fetchCompanyList() {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params = {
|
||||
page: current.value,
|
||||
size: pageSize.value,
|
||||
filter: {
|
||||
name: searchForm.value.name || undefined,
|
||||
status: searchForm.value.status,
|
||||
},
|
||||
};
|
||||
const data = await getCompanyPageApi(params);
|
||||
companyList.value = data.records;
|
||||
total.value = data.total;
|
||||
} catch (error) {
|
||||
console.error('获取公司列表失败:', error);
|
||||
message.error('获取公司列表失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
function handleSearch() {
|
||||
@@ -185,13 +191,13 @@ function handleAdd() {
|
||||
email: '',
|
||||
logo: '',
|
||||
status: 1,
|
||||
expireTime: '',
|
||||
expireTime: null,
|
||||
};
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
// 处理编辑公司
|
||||
function handleEdit(record: CompanyApiType.CompanyInfo) {
|
||||
function handleEdit(record: CompanyVO.CompanyInfoVO) {
|
||||
modalTitle.value = '编辑公司';
|
||||
isEdit.value = true;
|
||||
currentCompanyId.value = record.id;
|
||||
@@ -203,18 +209,65 @@ function handleEdit(record: CompanyApiType.CompanyInfo) {
|
||||
email: record.email || '',
|
||||
logo: record.logo || '',
|
||||
status: record.status,
|
||||
expireTime: record.expireTime || '',
|
||||
expireTime: record.expireTime ? dayjs(record.expireTime) : null,
|
||||
};
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 组件卸载标志
|
||||
let isUnmounted = false;
|
||||
|
||||
// 组件卸载时设置标志
|
||||
onUnmounted(() => {
|
||||
isUnmounted = true;
|
||||
});
|
||||
|
||||
// 获取公司列表
|
||||
async function fetchCompanyList() {
|
||||
if (isUnmounted) return;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<CompanyDTO.CompanyFiltersDTO> = {
|
||||
page: current.value,
|
||||
pageSize: pageSize.value,
|
||||
filters: {
|
||||
name: searchForm.value.name || undefined,
|
||||
status: searchForm.value.status,
|
||||
},
|
||||
};
|
||||
const data = await getCompanyPageApi(params);
|
||||
|
||||
if (isUnmounted) return;
|
||||
|
||||
companyList.value = data.records;
|
||||
total.value = data.total;
|
||||
} catch (error) {
|
||||
if (isUnmounted) return;
|
||||
|
||||
console.error('获取公司列表失败:', error);
|
||||
message.error('获取公司列表失败');
|
||||
} finally {
|
||||
if (!isUnmounted) {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理删除公司
|
||||
async function handleDelete(record: CompanyApiType.CompanyInfo) {
|
||||
async function handleDelete(record: CompanyVO.CompanyInfoVO) {
|
||||
try {
|
||||
await deleteCompanyApi(record.id);
|
||||
|
||||
if (isUnmounted) return;
|
||||
|
||||
message.success('删除成功');
|
||||
await fetchCompanyList();
|
||||
} catch (error) {
|
||||
if (isUnmounted) return;
|
||||
|
||||
console.error('删除公司失败:', error);
|
||||
message.error('删除公司失败');
|
||||
}
|
||||
@@ -225,17 +278,31 @@ async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
|
||||
// 准备提交数据,转换日期格式
|
||||
const submitData = {
|
||||
...formData.value,
|
||||
expireTime: formData.value.expireTime ? formData.value.expireTime.format('YYYY-MM-DD HH:mm:ss') : undefined,
|
||||
};
|
||||
|
||||
if (isEdit.value && currentCompanyId.value) {
|
||||
await updateCompanyApi(currentCompanyId.value, formData.value);
|
||||
await updateCompanyApi(currentCompanyId.value, submitData);
|
||||
|
||||
if (isUnmounted) return;
|
||||
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await createCompanyApi(formData.value);
|
||||
await createCompanyApi(submitData);
|
||||
|
||||
if (isUnmounted) return;
|
||||
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
modalVisible.value = false;
|
||||
await fetchCompanyList();
|
||||
} catch (error) {
|
||||
if (isUnmounted) return;
|
||||
|
||||
console.error('保存公司失败:', error);
|
||||
message.error('保存公司失败');
|
||||
}
|
||||
@@ -261,16 +328,18 @@ fetchCompanyList();
|
||||
|
||||
<!-- 搜索表单 -->
|
||||
<div class="mb-4 p-4 bg-gray-50 rounded-lg">
|
||||
<Form layout="inline" :model="searchForm">
|
||||
<Form.Item label="公司名称" name="name">
|
||||
<div style="display: flex; gap: 16px; align-items: center; flex-wrap: wrap;">
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">公司名称</label>
|
||||
<Input
|
||||
v-model:value="searchForm.name"
|
||||
placeholder="请输入公司名称"
|
||||
style="width: 200px;"
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="状态" name="status">
|
||||
</div>
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">状态</label>
|
||||
<Select
|
||||
v-model:value="searchForm.status"
|
||||
placeholder="请选择状态"
|
||||
@@ -278,12 +347,12 @@ fetchCompanyList();
|
||||
:options="statusOptions"
|
||||
allow-clear
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; align-items: end;">
|
||||
<Button type="primary" @click="handleSearch">搜索</Button>
|
||||
<Button @click="handleReset" class="ml-2">重置</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Button @click="handleReset">重置</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
@@ -328,19 +397,19 @@ fetchCompanyList();
|
||||
<Input v-model:value="formData.contactPerson" placeholder="请输入联系人" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="联系电话" name="contactPhone">
|
||||
<Form.Item label="联系电话" name="contactPhone" :rules="[{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' }]">
|
||||
<Input v-model:value="formData.contactPhone" placeholder="请输入联系电话" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="邮箱" name="email">
|
||||
<Form.Item label="邮箱" name="email" :rules="[{ type: 'email', message: '请输入正确的邮箱地址' }]">
|
||||
<Input v-model:value="formData.email" placeholder="请输入邮箱" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="Logo" name="logo">
|
||||
<Form.Item label="Logo" name="logo" :rules="[{ type: 'url', message: '请输入正确的URL地址' }]">
|
||||
<Input v-model:value="formData.logo" placeholder="请输入Logo地址" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="状态" name="status">
|
||||
<Form.Item label="状态" name="status" :rules="[{ required: true, message: '请选择状态' }]">
|
||||
<Select
|
||||
v-model:value="formData.status"
|
||||
placeholder="请选择状态"
|
||||
|
||||
+29
-25
@@ -9,14 +9,16 @@ import {
|
||||
deleteDepartmentApi,
|
||||
getDepartmentPageApi,
|
||||
updateDepartmentApi,
|
||||
type DepartmentApi as DepartmentApiType
|
||||
} from '#/api/core/organization';
|
||||
type DepartmentVO,
|
||||
type DepartmentDTO
|
||||
} from '#/api/org';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
defineOptions({ name: 'DepartmentManagement' });
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const departmentList = ref<DepartmentApiType.DepartmentInfo[]>([]);
|
||||
const departmentList = ref<DepartmentVO.DepartmentInfoVO[]>([]);
|
||||
const total = ref(0);
|
||||
const current = ref(1);
|
||||
const pageSize = ref(10);
|
||||
@@ -33,7 +35,7 @@ const searchForm = ref({
|
||||
});
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<DepartmentApiType.CreateDepartmentParams>({
|
||||
const formData = ref<DepartmentDTO.CreateDepartmentDTO>({
|
||||
name: '',
|
||||
parentId: undefined,
|
||||
remark: '',
|
||||
@@ -50,7 +52,7 @@ const statusOptions = [
|
||||
const parentDepartmentOptions = computed(() => {
|
||||
const options: Array<{ label: string; value: number | undefined }> = [{ label: '根部门', value: undefined }];
|
||||
|
||||
const addDepartmentOptions = (departments: DepartmentApiType.DepartmentInfo[], level = 0) => {
|
||||
const addDepartmentOptions = (departments: DepartmentVO.DepartmentInfoVO[], level = 0) => {
|
||||
departments.forEach(dept => {
|
||||
const prefix = ' '.repeat(level);
|
||||
options.push({
|
||||
@@ -80,7 +82,7 @@ const columns = [
|
||||
dataIndex: 'parentId',
|
||||
key: 'parentId',
|
||||
width: 150,
|
||||
customRender: ({ record }: { record: DepartmentApiType.DepartmentInfo }) => {
|
||||
customRender: ({ record }: { record: DepartmentVO.DepartmentInfoVO }) => {
|
||||
if (!record.parentId) return '根部门';
|
||||
const parent = findParentDepartment(departmentList.value, record.parentId);
|
||||
return parent ? parent.name : '未知';
|
||||
@@ -97,7 +99,7 @@ const columns = [
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 100,
|
||||
customRender: ({ record }: { record: DepartmentApiType.DepartmentInfo }) => {
|
||||
customRender: ({ record }: { record: DepartmentVO.DepartmentInfoVO }) => {
|
||||
return h('span', {
|
||||
style: { color: record.status === 1 ? '#52c41a' : '#ff4d4f' },
|
||||
}, record.status === 1 ? '启用' : '禁用');
|
||||
@@ -114,24 +116,24 @@ const columns = [
|
||||
key: 'action',
|
||||
width: 200,
|
||||
fixed: 'right' as const,
|
||||
customRender: ({ record }: { record: DepartmentApiType.DepartmentInfo }) => {
|
||||
customRender: ({ record }: { record: DepartmentVO.DepartmentInfoVO }) => {
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, [
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
onClick: () => handleEdit(record),
|
||||
}, '编辑'),
|
||||
}, { default: () => '编辑' }),
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
danger: true,
|
||||
onClick: () => handleDelete(record),
|
||||
}, '删除'),
|
||||
}, { default: () => '删除' }),
|
||||
]);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 查找父部门
|
||||
function findParentDepartment(departments: DepartmentApiType.DepartmentInfo[], parentId: number): DepartmentApiType.DepartmentInfo | null {
|
||||
function findParentDepartment(departments: DepartmentVO.DepartmentInfoVO[], parentId: number): DepartmentVO.DepartmentInfoVO | null {
|
||||
for (const dept of departments) {
|
||||
if (dept.id === parentId) {
|
||||
return dept;
|
||||
@@ -148,10 +150,10 @@ function findParentDepartment(departments: DepartmentApiType.DepartmentInfo[], p
|
||||
async function fetchDepartmentList() {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params = {
|
||||
const params: PageQueryDTO<DepartmentDTO.DepartmentFiltersDTO> = {
|
||||
page: current.value,
|
||||
size: pageSize.value,
|
||||
filter: {
|
||||
pageSize: pageSize.value,
|
||||
filters: {
|
||||
name: searchForm.value.name || undefined,
|
||||
status: searchForm.value.status,
|
||||
},
|
||||
@@ -205,7 +207,7 @@ function handleAdd() {
|
||||
}
|
||||
|
||||
// 处理编辑部门
|
||||
function handleEdit(record: DepartmentApiType.DepartmentInfo) {
|
||||
function handleEdit(record: DepartmentVO.DepartmentInfoVO) {
|
||||
modalTitle.value = '编辑部门';
|
||||
isEdit.value = true;
|
||||
currentDepartmentId.value = record.id;
|
||||
@@ -219,7 +221,7 @@ function handleEdit(record: DepartmentApiType.DepartmentInfo) {
|
||||
}
|
||||
|
||||
// 处理删除部门
|
||||
async function handleDelete(record: DepartmentApiType.DepartmentInfo) {
|
||||
async function handleDelete(record: DepartmentVO.DepartmentInfoVO) {
|
||||
try {
|
||||
await deleteDepartmentApi(record.id);
|
||||
message.success('删除成功');
|
||||
@@ -271,16 +273,18 @@ fetchDepartmentList();
|
||||
|
||||
<!-- 搜索表单 -->
|
||||
<div class="mb-4 p-4 bg-gray-50 rounded-lg">
|
||||
<Form layout="inline" :model="searchForm">
|
||||
<Form.Item label="部门名称" name="name">
|
||||
<div style="display: flex; gap: 16px; align-items: center; flex-wrap: wrap;">
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">部门名称</label>
|
||||
<Input
|
||||
v-model:value="searchForm.name"
|
||||
placeholder="请输入部门名称"
|
||||
style="width: 200px;"
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="状态" name="status">
|
||||
</div>
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">状态</label>
|
||||
<Select
|
||||
v-model:value="searchForm.status"
|
||||
placeholder="请选择状态"
|
||||
@@ -288,12 +292,12 @@ fetchDepartmentList();
|
||||
:options="statusOptions"
|
||||
allow-clear
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; align-items: end;">
|
||||
<Button type="primary" @click="handleSearch">搜索</Button>
|
||||
<Button @click="handleReset" class="ml-2">重置</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Button @click="handleReset">重置</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
|
||||
+27
-23
@@ -9,14 +9,16 @@ import {
|
||||
deletePositionApi,
|
||||
getPositionPageApi,
|
||||
updatePositionApi,
|
||||
type PositionApi as PositionApiType
|
||||
} from '#/api/core/organization';
|
||||
type PositionVO,
|
||||
type PositionDTO
|
||||
} from '#/api/org';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
defineOptions({ name: 'PositionManagement' });
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const positionList = ref<PositionApiType.PositionInfo[]>([]);
|
||||
const positionList = ref<PositionVO.PositionInfoVO[]>([]);
|
||||
const total = ref(0);
|
||||
const current = ref(1);
|
||||
const pageSize = ref(10);
|
||||
@@ -33,7 +35,7 @@ const searchForm = ref({
|
||||
});
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<PositionApiType.CreatePositionParams>({
|
||||
const formData = ref<PositionDTO.CreatePositionDTO>({
|
||||
name: '',
|
||||
code: '',
|
||||
departmentId: undefined,
|
||||
@@ -74,7 +76,7 @@ const columns = [
|
||||
dataIndex: 'departmentId',
|
||||
key: 'departmentId',
|
||||
width: 150,
|
||||
customRender: ({ record }: { record: PositionApiType.PositionInfo }) => {
|
||||
customRender: ({ record }: { record: PositionVO.PositionInfoVO }) => {
|
||||
if (!record.departmentId) return '-';
|
||||
const dept = departmentOptions.value.find(d => d.value === record.departmentId);
|
||||
return dept ? dept.label : '未知部门';
|
||||
@@ -91,7 +93,7 @@ const columns = [
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 100,
|
||||
customRender: ({ record }: { record: PositionApiType.PositionInfo }) => {
|
||||
customRender: ({ record }: { record: PositionVO.PositionInfoVO }) => {
|
||||
return h('span', {
|
||||
style: { color: record.status === 1 ? '#52c41a' : '#ff4d4f' },
|
||||
}, record.status === 1 ? '启用' : '禁用');
|
||||
@@ -108,17 +110,17 @@ const columns = [
|
||||
key: 'action',
|
||||
width: 200,
|
||||
fixed: 'right' as const,
|
||||
customRender: ({ record }: { record: PositionApiType.PositionInfo }) => {
|
||||
customRender: ({ record }: { record: PositionVO.PositionInfoVO }) => {
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, [
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
onClick: () => handleEdit(record),
|
||||
}, '编辑'),
|
||||
}, { default: () => '编辑' }),
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
danger: true,
|
||||
onClick: () => handleDelete(record),
|
||||
}, '删除'),
|
||||
}, { default: () => '删除' }),
|
||||
]);
|
||||
},
|
||||
},
|
||||
@@ -128,10 +130,10 @@ const columns = [
|
||||
async function fetchPositionList() {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params = {
|
||||
const params: PageQueryDTO<PositionDTO.PositionFiltersDTO> = {
|
||||
page: current.value,
|
||||
size: pageSize.value,
|
||||
filter: {
|
||||
pageSize: pageSize.value,
|
||||
filters: {
|
||||
name: searchForm.value.name || undefined,
|
||||
status: searchForm.value.status,
|
||||
},
|
||||
@@ -186,7 +188,7 @@ function handleAdd() {
|
||||
}
|
||||
|
||||
// 处理编辑岗位
|
||||
function handleEdit(record: PositionApiType.PositionInfo) {
|
||||
function handleEdit(record: PositionVO.PositionInfoVO) {
|
||||
modalTitle.value = '编辑岗位';
|
||||
isEdit.value = true;
|
||||
currentPositionId.value = record.id;
|
||||
@@ -201,7 +203,7 @@ function handleEdit(record: PositionApiType.PositionInfo) {
|
||||
}
|
||||
|
||||
// 处理删除岗位
|
||||
async function handleDelete(record: PositionApiType.PositionInfo) {
|
||||
async function handleDelete(record: PositionVO.PositionInfoVO) {
|
||||
try {
|
||||
await deletePositionApi(record.id);
|
||||
message.success('删除成功');
|
||||
@@ -253,16 +255,18 @@ fetchPositionList();
|
||||
|
||||
<!-- 搜索表单 -->
|
||||
<div class="mb-4 p-4 bg-gray-50 rounded-lg">
|
||||
<Form layout="inline" :model="searchForm">
|
||||
<Form.Item label="岗位名称" name="name">
|
||||
<div style="display: flex; gap: 16px; align-items: center; flex-wrap: wrap;">
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">岗位名称</label>
|
||||
<Input
|
||||
v-model:value="searchForm.name"
|
||||
placeholder="请输入岗位名称"
|
||||
style="width: 200px;"
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="状态" name="status">
|
||||
</div>
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">状态</label>
|
||||
<Select
|
||||
v-model:value="searchForm.status"
|
||||
placeholder="请选择状态"
|
||||
@@ -270,12 +274,12 @@ fetchPositionList();
|
||||
:options="statusOptions"
|
||||
allow-clear
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; align-items: end;">
|
||||
<Button type="primary" @click="handleSearch">搜索</Button>
|
||||
<Button @click="handleReset" class="ml-2">重置</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Button @click="handleReset">重置</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
|
||||
@@ -20,7 +20,20 @@
|
||||
|
||||
### 3. 店铺管理 (Shop Management)
|
||||
|
||||
- 店铺信息管理功能(开发中)
|
||||
- **店铺信息管理**: 支持店铺的增删改查操作
|
||||
- **平台管理**: 支持淘宝、京东、拼多多、天猫等主流电商平台
|
||||
- **Logo管理**: 支持店铺Logo的URL设置和预览
|
||||
- **搜索过滤**: 支持按店铺名称和平台进行搜索过滤
|
||||
- **分页展示**: 支持分页展示店铺列表
|
||||
|
||||
### 4. 商品管理 (Product Management)
|
||||
|
||||
- **商品信息管理**: 支持商品的增删改查操作
|
||||
- **商品编码管理**: 支持商品编码和SKU管理
|
||||
- **价格管理**: 支持成本价设置和价格范围搜索
|
||||
- **图片管理**: 支持商品主图URL设置和预览
|
||||
- **高级搜索**: 支持按商品名称、编码、SKU和价格范围进行搜索过滤
|
||||
- **分页展示**: 支持分页展示商品列表
|
||||
|
||||
## 使用流程
|
||||
|
||||
@@ -127,6 +140,8 @@ src/views/ecommerce/
|
||||
│ └── index.vue # 数据分析页面
|
||||
├── shop-management/
|
||||
│ └── index.vue # 店铺管理页面
|
||||
├── product-management/
|
||||
│ └── index.vue # 商品管理页面
|
||||
└── README.md # 说明文档
|
||||
```
|
||||
|
||||
|
||||
+6
-8
@@ -15,7 +15,7 @@
|
||||
|
||||
<!-- 字段映射表格 -->
|
||||
<div class="border rounded-lg">
|
||||
<VbenTable
|
||||
<Table
|
||||
:columns="mappingColumns"
|
||||
:data-source="mappingData"
|
||||
:pagination="false"
|
||||
@@ -26,7 +26,7 @@
|
||||
<!-- 数据预览 -->
|
||||
<div v-if="previewData.length > 0">
|
||||
<h4 class="text-md font-medium mb-3">映射后数据预览</h4>
|
||||
<VbenTable
|
||||
<Table
|
||||
:columns="previewColumns"
|
||||
:data-source="previewData.slice(0, 5)"
|
||||
:pagination="false"
|
||||
@@ -51,8 +51,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { ref, computed, watch, h } from 'vue'
|
||||
import { message, Table } from 'ant-design-vue'
|
||||
import { transformDataWithMapping, generateExportData, downloadJSON } from '#/utils/csv-utils'
|
||||
|
||||
// Props
|
||||
@@ -114,7 +114,7 @@ const mappingColumns = [
|
||||
key: 'standardField',
|
||||
width: 200,
|
||||
customRender: ({ record }: any) => {
|
||||
return h('VbenSelect', {
|
||||
return h('Select', {
|
||||
value: record.standardField,
|
||||
placeholder: '选择标准字段',
|
||||
allowClear: true,
|
||||
@@ -131,7 +131,7 @@ const mappingColumns = [
|
||||
key: 'customName',
|
||||
width: 200,
|
||||
customRender: ({ record }: any) => {
|
||||
return h('VbenInput', {
|
||||
return h('Input', {
|
||||
value: record.customName,
|
||||
placeholder: '可选:自定义字段名',
|
||||
onChange: (e: any) => {
|
||||
@@ -198,8 +198,6 @@ const handleExport = () => {
|
||||
emit('confirm', exportData)
|
||||
}
|
||||
|
||||
// 导入h函数
|
||||
import { h } from 'vue'
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
<script lang="ts" setup>
|
||||
import { h, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { Button, Form, Input, InputNumber, Modal, Table, message } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createProductApi,
|
||||
deleteProductApi,
|
||||
getProductPageApi,
|
||||
updateProductApi,
|
||||
type ProductVO,
|
||||
type ProductDTO
|
||||
} from '#/api/ecommerce';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
defineOptions({ name: 'ProductManagement' });
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const productList = ref<ProductVO.ProductInfoVO[]>([]);
|
||||
const total = ref(0);
|
||||
const current = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const modalVisible = ref(false);
|
||||
const modalTitle = ref('');
|
||||
const isEdit = ref(false);
|
||||
const currentProductId = ref<number | null>(null);
|
||||
const formRef = ref();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
name: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
minCostPrice: undefined as number | undefined,
|
||||
maxCostPrice: undefined as number | undefined,
|
||||
});
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<ProductDTO.CreateProductDTO>({
|
||||
name: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
mainImage: '',
|
||||
costPrice: 0,
|
||||
});
|
||||
|
||||
// 表格列配置
|
||||
const columns = [
|
||||
{
|
||||
title: '商品名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '商品编码',
|
||||
dataIndex: 'specCode',
|
||||
key: 'specCode',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '商品SKU',
|
||||
dataIndex: 'skuCode',
|
||||
key: 'skuCode',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '主图',
|
||||
dataIndex: 'mainImage',
|
||||
key: 'mainImage',
|
||||
width: 100,
|
||||
customRender: ({ record }: { record: ProductVO.ProductInfoVO }) => {
|
||||
if (record.mainImage) {
|
||||
return h('img', {
|
||||
src: record.mainImage,
|
||||
alt: record.name,
|
||||
style: { width: '40px', height: '40px', objectFit: 'cover', borderRadius: '4px' },
|
||||
});
|
||||
}
|
||||
return h('span', { style: { color: '#999' } }, '暂无图片');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '成本价',
|
||||
dataIndex: 'costPrice',
|
||||
key: 'costPrice',
|
||||
width: 120,
|
||||
customRender: ({ record }: { record: ProductVO.ProductInfoVO }) => {
|
||||
return h('span', { style: { color: '#f50' } }, `¥${record.costPrice.toFixed(2)}`);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '更新时间',
|
||||
dataIndex: 'updateTime',
|
||||
key: 'updateTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
fixed: 'right' as const,
|
||||
customRender: ({ record }: { record: ProductVO.ProductInfoVO }) => {
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, [
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
onClick: () => handleEdit(record),
|
||||
}, { default: () => '编辑' }),
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
danger: true,
|
||||
onClick: () => handleDelete(record),
|
||||
}, { default: () => '删除' }),
|
||||
]);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 获取商品列表
|
||||
async function fetchProductList() {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<ProductDTO.ProductFiltersDTO> = {
|
||||
page: current.value,
|
||||
pageSize: pageSize.value,
|
||||
filters: {
|
||||
name: searchForm.value.name || undefined,
|
||||
specCode: searchForm.value.specCode || undefined,
|
||||
skuCode: searchForm.value.skuCode || undefined,
|
||||
minCostPrice: searchForm.value.minCostPrice,
|
||||
maxCostPrice: searchForm.value.maxCostPrice,
|
||||
},
|
||||
};
|
||||
const data = await getProductPageApi(params);
|
||||
productList.value = data.records;
|
||||
total.value = data.total;
|
||||
} catch (error) {
|
||||
console.error('获取商品列表失败:', error);
|
||||
message.error('获取商品列表失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
function handleSearch() {
|
||||
current.value = 1;
|
||||
fetchProductList();
|
||||
}
|
||||
|
||||
// 处理重置
|
||||
function handleReset() {
|
||||
searchForm.value = {
|
||||
name: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
minCostPrice: undefined,
|
||||
maxCostPrice: undefined,
|
||||
};
|
||||
current.value = 1;
|
||||
fetchProductList();
|
||||
}
|
||||
|
||||
// 处理分页变化
|
||||
function handleTableChange(pagination: any) {
|
||||
current.value = pagination.current;
|
||||
pageSize.value = pagination.pageSize;
|
||||
fetchProductList();
|
||||
}
|
||||
|
||||
// 处理添加商品
|
||||
function handleAdd() {
|
||||
modalTitle.value = '添加商品';
|
||||
isEdit.value = false;
|
||||
currentProductId.value = null;
|
||||
formData.value = {
|
||||
name: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
mainImage: '',
|
||||
costPrice: 0,
|
||||
};
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
// 处理编辑商品
|
||||
function handleEdit(record: ProductVO.ProductInfoVO) {
|
||||
modalTitle.value = '编辑商品';
|
||||
isEdit.value = true;
|
||||
currentProductId.value = record.id;
|
||||
formData.value = {
|
||||
name: record.name,
|
||||
specCode: record.specCode || '',
|
||||
skuCode: record.skuCode || '',
|
||||
mainImage: record.mainImage || '',
|
||||
costPrice: record.costPrice,
|
||||
};
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
// 处理删除商品
|
||||
async function handleDelete(record: ProductVO.ProductInfoVO) {
|
||||
try {
|
||||
await deleteProductApi(record.id);
|
||||
message.success('删除成功');
|
||||
await fetchProductList();
|
||||
} catch (error) {
|
||||
console.error('删除商品失败:', error);
|
||||
message.error('删除商品失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 处理表单提交
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
|
||||
if (isEdit.value && currentProductId.value) {
|
||||
await updateProductApi(currentProductId.value, formData.value);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await createProductApi(formData.value);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
modalVisible.value = false;
|
||||
await fetchProductList();
|
||||
} catch (error) {
|
||||
console.error('保存商品失败:', error);
|
||||
message.error('保存商品失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
fetchProductList();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="商品管理">
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理商品信息,包括商品基本信息、编码、SKU和价格设置
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
添加商品
|
||||
</Button>
|
||||
</template>
|
||||
|
||||
<!-- 搜索表单 -->
|
||||
<div class="mb-4 p-4 bg-gray-50 rounded-lg">
|
||||
<div style="display: flex; gap: 16px; align-items: center; flex-wrap: wrap;">
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">商品名称</label>
|
||||
<Input
|
||||
v-model:value="searchForm.name"
|
||||
placeholder="请输入商品名称"
|
||||
style="width: 200px;"
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">商品编码</label>
|
||||
<Input
|
||||
v-model:value="searchForm.specCode"
|
||||
placeholder="请输入商品编码"
|
||||
style="width: 150px;"
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">商品SKU</label>
|
||||
<Input
|
||||
v-model:value="searchForm.skuCode"
|
||||
placeholder="请输入商品SKU"
|
||||
style="width: 150px;"
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">成本价范围</label>
|
||||
<div style="display: flex; gap: 8px; align-items: center;">
|
||||
<InputNumber
|
||||
v-model:value="searchForm.minCostPrice"
|
||||
placeholder="最小值"
|
||||
style="width: 100px;"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
<span>-</span>
|
||||
<InputNumber
|
||||
v-model:value="searchForm.maxCostPrice"
|
||||
placeholder="最大值"
|
||||
style="width: 100px;"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; align-items: end;">
|
||||
<Button type="primary" @click="handleSearch">搜索</Button>
|
||||
<Button @click="handleReset">重置</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data-source="productList"
|
||||
:loading="loading"
|
||||
:pagination="{
|
||||
current: current,
|
||||
pageSize: pageSize,
|
||||
total: total,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条/共 ${total} 条`,
|
||||
}"
|
||||
row-key="id"
|
||||
@change="handleTableChange"
|
||||
/>
|
||||
|
||||
<!-- 添加/编辑模态框 -->
|
||||
<Modal
|
||||
v-model:open="modalVisible"
|
||||
:title="modalTitle"
|
||||
width="600px"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="商品名称" name="name" :rules="[{ required: true, message: '请输入商品名称' }]">
|
||||
<Input v-model:value="formData.name" placeholder="请输入商品名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品编码" name="specCode">
|
||||
<Input v-model:value="formData.specCode" placeholder="请输入商品编码" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品SKU" name="skuCode">
|
||||
<Input v-model:value="formData.skuCode" placeholder="请输入商品SKU" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="主图URL" name="mainImage">
|
||||
<Input v-model:value="formData.mainImage" placeholder="请输入主图URL" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="成本价" name="costPrice" :rules="[{ required: true, message: '请输入成本价' }]">
|
||||
<InputNumber
|
||||
v-model:value="formData.costPrice"
|
||||
placeholder="请输入成本价"
|
||||
style="width: 100%;"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -1,15 +1,316 @@
|
||||
<template>
|
||||
<div class="p-6">
|
||||
<VbenCard title="店铺管理">
|
||||
<div class="text-center py-12">
|
||||
<VbenIcon icon="lucide:store" class="w-16 h-16 mx-auto text-gray-400 mb-4" />
|
||||
<h3 class="text-lg font-medium text-gray-700 mb-2">店铺管理功能</h3>
|
||||
<p class="text-gray-500">此功能正在开发中,敬请期待...</p>
|
||||
</div>
|
||||
</VbenCard>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { h, ref } from 'vue';
|
||||
|
||||
<script setup lang="ts">
|
||||
// 店铺管理页面占位
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { Button, Form, Input, Modal, Select, Table, message } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createShopApi,
|
||||
deleteShopApi,
|
||||
getShopPageApi,
|
||||
updateShopApi,
|
||||
type ShopVO ,
|
||||
type ShopDTO
|
||||
} from '#/api/ecommerce';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
defineOptions({ name: 'ShopManagement' });
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const shopList = ref<ShopVO.ShopInfoVO[]>([]);
|
||||
const total = ref(0);
|
||||
const current = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const modalVisible = ref(false);
|
||||
const modalTitle = ref('');
|
||||
const isEdit = ref(false);
|
||||
const currentShopId = ref<number | null>(null);
|
||||
const formRef = ref();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
name: '',
|
||||
platform: undefined as string | undefined,
|
||||
});
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<ShopDTO.CreateShopDTO>({
|
||||
name: '',
|
||||
logo: '',
|
||||
platform: '',
|
||||
});
|
||||
|
||||
// 平台选项
|
||||
const platformOptions = [
|
||||
{ label: '淘宝', value: '淘宝' },
|
||||
{ label: '京东', value: '京东' },
|
||||
{ label: '拼多多', value: '拼多多' },
|
||||
{ label: '天猫', value: '天猫' },
|
||||
];
|
||||
|
||||
// 表格列配置
|
||||
const columns = [
|
||||
{
|
||||
title: '店铺名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '平台',
|
||||
dataIndex: 'platform',
|
||||
key: 'platform',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
title: 'Logo',
|
||||
dataIndex: 'logo',
|
||||
key: 'logo',
|
||||
width: 200,
|
||||
customRender: ({ record }: { record: ShopVO.ShopInfoVO }) => {
|
||||
if (record.logo) {
|
||||
return h('img', {
|
||||
src: record.logo,
|
||||
alt: record.name,
|
||||
style: { width: '40px', height: '40px', objectFit: 'cover', borderRadius: '4px' },
|
||||
});
|
||||
}
|
||||
return h('span', { style: { color: '#999' } }, '暂无Logo');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '更新时间',
|
||||
dataIndex: 'updateTime',
|
||||
key: 'updateTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
fixed: 'right' as const,
|
||||
customRender: ({ record }: { record: ShopVO.ShopInfoVO }) => {
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, [
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
onClick: () => handleEdit(record),
|
||||
}, { default: () => '编辑' }),
|
||||
h(Button, {
|
||||
size: 'small',
|
||||
danger: true,
|
||||
onClick: () => handleDelete(record),
|
||||
}, { default: () => '删除' }),
|
||||
]);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 获取店铺列表
|
||||
async function fetchShopList() {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<ShopDTO.ShopFiltersDTO> = {
|
||||
page: current.value,
|
||||
pageSize: pageSize.value,
|
||||
filters: {
|
||||
name: searchForm.value.name || undefined,
|
||||
platform: searchForm.value.platform,
|
||||
},
|
||||
};
|
||||
const data = await getShopPageApi(params);
|
||||
shopList.value = data.records;
|
||||
total.value = data.total;
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败:', error);
|
||||
message.error('获取店铺列表失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
function handleSearch() {
|
||||
current.value = 1;
|
||||
fetchShopList();
|
||||
}
|
||||
|
||||
// 处理重置
|
||||
function handleReset() {
|
||||
searchForm.value = {
|
||||
name: '',
|
||||
platform: undefined,
|
||||
};
|
||||
current.value = 1;
|
||||
fetchShopList();
|
||||
}
|
||||
|
||||
// 处理分页变化
|
||||
function handleTableChange(pagination: any) {
|
||||
current.value = pagination.current;
|
||||
pageSize.value = pagination.pageSize;
|
||||
fetchShopList();
|
||||
}
|
||||
|
||||
// 处理添加店铺
|
||||
function handleAdd() {
|
||||
modalTitle.value = '添加店铺';
|
||||
isEdit.value = false;
|
||||
currentShopId.value = null;
|
||||
formData.value = {
|
||||
name: '',
|
||||
logo: '',
|
||||
platform: '',
|
||||
};
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
// 处理编辑店铺
|
||||
function handleEdit(record: ShopVO.ShopInfoVO) {
|
||||
modalTitle.value = '编辑店铺';
|
||||
isEdit.value = true;
|
||||
currentShopId.value = record.id;
|
||||
formData.value = {
|
||||
name: record.name,
|
||||
logo: record.logo || '',
|
||||
platform: record.platform || '',
|
||||
};
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
// 处理删除店铺
|
||||
async function handleDelete(record: ShopVO.ShopInfoVO) {
|
||||
try {
|
||||
await deleteShopApi(record.id);
|
||||
message.success('删除成功');
|
||||
await fetchShopList();
|
||||
} catch (error) {
|
||||
console.error('删除店铺失败:', error);
|
||||
message.error('删除店铺失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 处理表单提交
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
|
||||
if (isEdit.value && currentShopId.value) {
|
||||
await updateShopApi(currentShopId.value, formData.value);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await createShopApi(formData.value);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
modalVisible.value = false;
|
||||
await fetchShopList();
|
||||
} catch (error) {
|
||||
console.error('保存店铺失败:', error);
|
||||
message.error('保存店铺失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
fetchShopList();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="店铺管理">
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理电商店铺信息,包括店铺基本信息、平台信息和Logo设置
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
添加店铺
|
||||
</Button>
|
||||
</template>
|
||||
|
||||
<!-- 搜索表单 -->
|
||||
<div class="mb-4 p-4 bg-gray-50 rounded-lg">
|
||||
<div style="display: flex; gap: 16px; align-items: center; flex-wrap: wrap;">
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">店铺名称</label>
|
||||
<Input
|
||||
v-model:value="searchForm.name"
|
||||
placeholder="请输入店铺名称"
|
||||
style="width: 200px;"
|
||||
@press-enter="handleSearch"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label style="display: block; margin-bottom: 4px; font-weight: 500;">平台</label>
|
||||
<Select
|
||||
v-model:value="searchForm.platform"
|
||||
placeholder="请选择平台"
|
||||
style="width: 120px;"
|
||||
:options="platformOptions"
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; align-items: end;">
|
||||
<Button type="primary" @click="handleSearch">搜索</Button>
|
||||
<Button @click="handleReset">重置</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data-source="shopList"
|
||||
:loading="loading"
|
||||
:pagination="{
|
||||
current: current,
|
||||
pageSize: pageSize,
|
||||
total: total,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条/共 ${total} 条`,
|
||||
}"
|
||||
row-key="id"
|
||||
@change="handleTableChange"
|
||||
/>
|
||||
|
||||
<!-- 添加/编辑模态框 -->
|
||||
<Modal
|
||||
v-model:open="modalVisible"
|
||||
:title="modalTitle"
|
||||
width="600px"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="店铺名称" name="name" :rules="[{ required: true, message: '请输入店铺名称' }]">
|
||||
<Input v-model:value="formData.name" placeholder="请输入店铺名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="平台" name="platform">
|
||||
<Select
|
||||
v-model:value="formData.platform"
|
||||
placeholder="请选择平台"
|
||||
:options="platformOptions"
|
||||
allow-clear
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="Logo URL" name="logo">
|
||||
<Input v-model:value="formData.logo" placeholder="请输入Logo URL" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</Page>
|
||||
</template>
|
||||
Reference in New Issue
Block a user