Explorar o código

Merge branch 'test'

yumeng %!s(int64=4) %!d(string=hai) anos
pai
achega
1b9e0c3964

+ 16 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProductController.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.service.IProductService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+
 import cn.com.ctop.common.module.vo.ProductInfoDto;
 import cn.com.ctop.common.module.vo.ProductVO;
 import cn.com.ctop.common.module.vo.ProjectVO;
@@ -21,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -146,6 +148,20 @@ public class ProductController {
         log.info("/ctop/product/insertOrUpdateProduct 方法开始");
         Result result = new Result();
 
+        //if(vo==null || vo.getId() == null){
+        //    if(StringUtils.isBlank(vo.getProductName())){
+        //        result.setSuccess(false);
+        //        result.setMessage("产品不能为空");
+        //        return result;
+        //    }
+        //    Integer count = productService.getProductNameCount(vo.getProductName());
+        //    if(count != 0){
+        //        result.setSuccess(false);
+        //        result.setMessage("产品名字已存在");
+        //        return result;
+        //    }
+        //}
+
         try {
             productService.insertOrUpdateProduct(vo);
         }catch (Exception e){

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.xml

@@ -468,7 +468,7 @@
                         AND a.advertiser_id = #{advertiserId}
                     </if>
                     <if test="companyId != null and companyId != ''">
-                        AND a.company_id = #{companyId}
+                        AND d.company_id = #{companyId}
                     </if>
                     <if test="productId != null and productId != ''">
                         AND a.id = #{productId}

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/ProductMapper.java

@@ -28,6 +28,8 @@ public interface ProductMapper extends BaseMapper<Product> {
 
     void insertProductProjectMap(@Param("projectIds")List<Long> projectIds, @Param("productId")Long productId);
 
+    Integer getProductNameCount(@Param("productName")String productName);
+
     void updateProduct(@Param("product")ProductVO product);
 
     Product getProductInfo(@Param("id")Long id);

+ 10 - 3
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProductMapper.xml

@@ -58,9 +58,7 @@
 
     <select id="getSaleListByProjectIds" resultType="cn.com.ctop.common.module.vo.ProductDto">
         select
-        a.id as projectId,
-        a.project_name as projectName,
-        a.sale_id as saleId,
+        distinct a.sale_id as saleId,
         b.realname as saleName
         from
         ctop_project a
@@ -105,6 +103,15 @@
         </foreach>
     </insert>
 
+    <select id="getProductNameCount" resultType="integer">
+        select
+        count(1)
+        from
+        ctop_product
+        where
+        product_name = #{productName}
+    </select>
+
     <update id="updateProduct">
         update
         ctop_product

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IProductService.java

@@ -7,6 +7,7 @@ import cn.com.ctop.common.module.vo.ProductVO;
 import cn.com.ctop.common.module.vo.ProjectVO;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.github.pagehelper.PageInfo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -30,6 +31,8 @@ public interface IProductService extends IService<Product> {
 
     void insertOrUpdateProduct(ProductVO product);
 
+    Integer getProductNameCount(String productName);
+
     void insertProductProjectMap(Long productId, List<Long> projectIds);
 
     Map<String, Object> getProductInfo(Long productId);

+ 6 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/ProductServiceImpl.java

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.vo.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import org.apache.ibatis.annotations.Param;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -75,6 +76,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
     }
 
     @Override
+    public Integer getProductNameCount(String productName){
+        return productMapper.getProductNameCount(productName);
+    }
+
+    @Override
     public void insertProductProjectMap(Long productId, List<Long> projectIds){
         productMapper.insertProductProjectMap(projectIds, productId);
     }