From 179c4d64313c9b7572778da4aaaf6c6584fe457d Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期二, 20 五月 2025 23:48:08 +0800
Subject: [PATCH] 修改文件上传类型限制

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComChangeCarModelSpecsServiceImpl.java |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComChangeCarModelSpecsServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComChangeCarModelSpecsServiceImpl.java
index d62d4e0..d1be23c 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComChangeCarModelSpecsServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComChangeCarModelSpecsServiceImpl.java
@@ -4,7 +4,9 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.panzhihua.common.model.vos.common.ComChangeCarModelSpecsChildrenVo;
 import com.panzhihua.common.model.vos.common.ComChangeCarModelSpecsVo;
+import com.panzhihua.service_community.dao.ComChangeCarModelRelationMapper;
 import com.panzhihua.service_community.dao.ComChangeCarModelSpecsChildrenMapper;
+import com.panzhihua.service_community.entity.ComChangeCarModelRelation;
 import com.panzhihua.service_community.entity.ComChangeCarModelSpecs;
 import com.panzhihua.service_community.dao.ComChangeCarModelSpecsMapper;
 import com.panzhihua.service_community.entity.ComChangeCarModelSpecsChildren;
@@ -35,6 +37,8 @@
 
     @Resource
     private ComChangeCarModelSpecsChildrenMapper carModelSpecsChildrenMapper;
+    @Resource
+    private ComChangeCarModelRelationMapper modelRelationMapper;
 
     /**
      * description  queryByPage  分页查询
@@ -70,7 +74,7 @@
         ComChangeCarModelSpecs entity = new ComChangeCarModelSpecs();
         BeanUtils.copyProperties(comChangeCarModelSpecs, entity);
         if (this.baseMapper.insert(entity) > 0) {
-            return R.ok();
+            return R.ok(entity.getId());
         }
         return R.fail("添加失败");
     }
@@ -106,6 +110,12 @@
      */
     @Override
     public R deleteById(Long id) {
+        //判断当前规格是否有被引用
+        Integer count = modelRelationMapper.selectCount(new QueryWrapper<ComChangeCarModelRelation>().lambda()
+                .eq(ComChangeCarModelRelation::getModelSpecsId,id));
+        if(count > 0){
+            return R.fail("该规格已被引用,不可删除");
+        }
         ComChangeCarModelSpecs entity = new ComChangeCarModelSpecs();
         entity.setId(id);
         entity.setIsDel(ComChangeCarModelSpecs.IsDel.YES);

--
Gitblit v1.7.1