feat: 忘记干嘛了

This commit is contained in:
ah--desktop
2026-03-18 00:16:34 +08:00
parent 53daaa8c6b
commit a0fa113c40
11 changed files with 836 additions and 31 deletions
@@ -2,6 +2,10 @@ package top.xyquan.ecomdmbbackend.modules.ecom.order.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.xyquan.ecomdmbbackend.modules.ecom.orderstatus.model.vo.OrderStatusVO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductSpecVO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopVO;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@@ -162,4 +166,28 @@ public class OrderVO {
*/
@Schema(description = "确认", example = "1")
private Integer confirm;
/**
* 关联商品信息
*/
@Schema(description = "关联商品信息")
private ProductVO product;
/**
* 关联商品规格信息
*/
@Schema(description = "关联商品规格信息")
private ProductSpecVO productSpec;
/**
* 关联订单状态信息
*/
@Schema(description = "关联订单状态信息")
private OrderStatusVO orderStatus;
/**
* 关联店铺信息
*/
@Schema(description = "关联店铺信息")
private ShopVO shop;
}
@@ -22,7 +22,11 @@ import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.po.ShopPO;
import top.xyquan.ecomdmbbackend.modules.ecom.order.model.vo.BatchImportResultVO;
import top.xyquan.ecomdmbbackend.modules.ecom.order.model.vo.OrderVO;
import top.xyquan.ecomdmbbackend.modules.ecom.orderstatus.model.po.OrderStatusPO;
import top.xyquan.ecomdmbbackend.modules.ecom.orderstatus.model.vo.OrderStatusVO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductSpecVO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductVO;
import top.xyquan.ecomdmbbackend.modules.ecom.order.service.OrderService;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopVO;
import top.xyquan.ecomdmbbackend.modules.ecom.orderstatus.service.OrderStatusService;
import top.xyquan.ecomdmbbackend.modules.ecom.product.service.ProductService;
import top.xyquan.ecomdmbbackend.modules.ecom.product.service.ProductSpecService;
@@ -398,11 +402,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderPO> implemen
OrderVO orderVO = new OrderVO();
BeanUtils.copyProperties(order, orderVO);
// 设置状态名称
// 设置状态信息
if (order.getStatusId() != null) {
OrderStatusPO orderStatus = orderStatusService.getById(order.getStatusId());
if (orderStatus != null) {
orderVO.setStatusName(orderStatus.getStatusName());
OrderStatusVO orderStatusVO = new OrderStatusVO();
BeanUtils.copyProperties(orderStatus, orderStatusVO);
orderVO.setOrderStatus(orderStatusVO);
}
}
@@ -410,6 +417,29 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderPO> implemen
ShopPO shop = shopService.getById(order.getShopId());
if (shop != null) {
orderVO.setShopName(shop.getName());
ShopVO shopVO = new ShopVO();
BeanUtils.copyProperties(shop, shopVO);
orderVO.setShop(shopVO);
}
// 设置关联商品信息
if (order.getProductId() != null) {
ProductPO product = productService.getById(order.getProductId());
if (product != null) {
ProductVO productVO = new ProductVO();
BeanUtils.copyProperties(product, productVO);
orderVO.setProduct(productVO);
}
}
// 设置关联商品规格信息
if (order.getProductSpecId() != null) {
ProductSpecPO productSpec = productSpecService.getById(order.getProductSpecId());
if (productSpec != null) {
ProductSpecVO productSpecVO = new ProductSpecVO();
BeanUtils.copyProperties(productSpec, productSpecVO);
orderVO.setProductSpec(productSpecVO);
}
}
return orderVO;
@@ -15,6 +15,8 @@ import top.xyquan.ecomdmbbackend.modules.org.department.model.vo.DepartmentVO;
import top.xyquan.ecomdmbbackend.modules.org.department.service.DepartmentService;
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
import java.util.List;
/**
* 部门管理控制器
*/
@@ -63,4 +65,20 @@ public class DepartmentController {
PageResultVO<DepartmentVO> result = departmentService.getDepartmentPage(pageQueryDTO);
return ApiResponse.success(result);
}
@Operation(summary = "获取全部部门", description = "获取当前公司全部部门列表")
@GetMapping("/all")
@RequireRole(description = "查询全部部门", allowUser = true)
public ApiResponse<List<DepartmentVO>> getAllDepartments() {
List<DepartmentVO> result = departmentService.getAllDepartments();
return ApiResponse.success(result);
}
@Operation(summary = "获取部门树", description = "获取当前公司部门树形结构")
@GetMapping("/tree")
@RequireRole(description = "查询部门树", allowUser = true)
public ApiResponse<List<DepartmentVO>> getDepartmentTree() {
List<DepartmentVO> result = departmentService.getDepartmentTree();
return ApiResponse.success(result);
}
}
@@ -9,6 +9,8 @@ import top.xyquan.ecomdmbbackend.modules.org.department.model.dto.DepartmentFilt
import top.xyquan.ecomdmbbackend.modules.org.department.model.po.DepartmentPO;
import top.xyquan.ecomdmbbackend.modules.org.department.model.vo.DepartmentVO;
import java.util.List;
/**
* 部门服务接口
*/
@@ -46,6 +48,20 @@ public interface DepartmentService extends IService<DepartmentPO> {
*/
PageResultVO<DepartmentVO> getDepartmentPage(PageQueryDTO<DepartmentFilterDTO> pageQueryDTO);
/**
* 获取当前公司全部部门
*
* @return 部门列表
*/
List<DepartmentVO> getAllDepartments();
/**
* 获取当前公司部门树
*
* @return 部门树
*/
List<DepartmentVO> getDepartmentTree();
/**
* 为指定公司创建部门(用于初始化)
*
@@ -20,7 +20,11 @@ import top.xyquan.ecomdmbbackend.modules.org.department.model.vo.DepartmentVO;
import top.xyquan.ecomdmbbackend.modules.org.department.service.DepartmentService;
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 部门服务实现类
@@ -200,6 +204,55 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
return result;
}
/**
* 获取当前公司全部部门
*
* @return 部门列表
*/
@Override
public List<DepartmentVO> getAllDepartments() {
Long companyId = currentUserContext.getCurrentCompanyId();
LambdaQueryWrapper<DepartmentPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DepartmentPO::getCompanyId, companyId)
.orderByAsc(DepartmentPO::getCreateTime);
return this.list(wrapper).stream()
.map(this::convertToVO)
.collect(Collectors.toList());
}
/**
* 获取当前公司部门树
*
* @return 部门树
*/
@Override
public List<DepartmentVO> getDepartmentTree() {
List<DepartmentVO> allDepartments = getAllDepartments();
if (allDepartments.isEmpty()) {
return new ArrayList<>();
}
Map<Long, DepartmentVO> departmentMap = new HashMap<>();
for (DepartmentVO department : allDepartments) {
department.setChildren(new ArrayList<>());
departmentMap.put(department.getId(), department);
}
List<DepartmentVO> roots = new ArrayList<>();
for (DepartmentVO department : allDepartments) {
Long parentId = department.getParentId();
if (parentId == null || parentId == 0 || !departmentMap.containsKey(parentId)) {
roots.add(department);
continue;
}
departmentMap.get(parentId).getChildren().add(department);
}
return roots;
}
/**
* 为指定公司创建部门
* @param createDepartmentDTO 创建部门DTO