From ab0637e981ab4c85120ccde35ee24ec4abbe3e24 Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Fri, 17 Oct 2025 17:20:15 +0800
Subject: [PATCH] Merge branch 'refs/heads/master' into xin

---
 oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductServiceImpl.java |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductServiceImpl.java b/oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductServiceImpl.java
index 8be214d..ec8daea 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductServiceImpl.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductServiceImpl.java
@@ -1,8 +1,10 @@
 package com.oying.modules.pc.product.service.impl;
 
+import cn.hutool.core.util.ObjUtil;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.oying.exception.EntityNotFoundException;
 import com.oying.modules.pc.product.domain.Product;
 import com.oying.modules.pc.product.domain.dto.ProductQueryCriteria;
 import com.oying.modules.pc.product.mapper.ProductMapper;
@@ -10,17 +12,13 @@
 import com.oying.utils.FileUtil;
 import com.oying.utils.PageResult;
 import com.oying.utils.PageUtil;
-import com.oying.utils.SecurityUtils;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author lzp
@@ -44,6 +42,15 @@
     }
 
     @Override
+    public Product getProduct(Long productId) {
+        Product existingProduct = getById(productId);
+        if (ObjUtil.isEmpty(existingProduct)) {
+            throw new EntityNotFoundException(Product.class, "id", Optional.ofNullable(productId).map(Object::toString).orElse("null"));
+        }
+        return existingProduct;
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
     public void create(Product resources) {
         productMapper.insert(resources);
@@ -55,6 +62,18 @@
         Product product = getById(resources.getProductId());
         product.copy(resources);
         productMapper.updateById(product);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(Product resources, boolean isDirectUpdate) {
+        if (isDirectUpdate) {
+            productMapper.updateById(resources);
+        } else {
+            Product product = getById(resources.getProductId());
+            product.copy(resources);
+            productMapper.updateById(product);
+        }
     }
 
     @Override
@@ -79,9 +98,9 @@
             map.put("商品名称", product.getName());
             map.put("商品标题", product.getTitle());
             map.put("分类ID", product.getCategoryId());
-            map.put("状态:1000-草稿 1001上架 1002下架", product.getStatus());
-            map.put("主图片", product.getMainImage());
-            map.put("详情图片", product.getDetailImage());
+            map.put("状态", product.getStatus());
+            map.put("主图片", product.getMainImageId());
+            map.put("主图地址", product.getMainImageUrl());
             map.put("商品描述", product.getDescription());
             map.put("销售价格", product.getPrice());
             map.put("库存数量", product.getStockQuantity());

--
Gitblit v1.9.3