From 7ef4892f9f24f941aca37e6b3991b808a0aca619 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期五, 08 九月 2023 11:16:35 +0800
Subject: [PATCH] 优化

---
 ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java b/ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java
index 4a28b40..8231f81 100644
--- a/ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java
+++ b/ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java
@@ -7,7 +7,7 @@
 import com.ycl.entity.depart.UmsDepart;
 import com.ycl.entity.dict.DataDictionary;
 import com.ycl.mapper.depart.UmsDepartMapper;
-import com.ycl.mapper.dict.DataDictionaryMapper;
+import com.ycl.mapper.dict.DataDictionary2Mapper;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -18,10 +18,17 @@
 
     @Resource
     private UmsDepartMapper sccgDepartMapper;
-
     @Resource
-    DataDictionaryMapper dataDictionaryMapper;
+    private DataDictionary2Mapper dataDictionary2Mapper;
 
+//    private static DepartListener departListener;
+//
+//    @PostConstruct
+//    public void init(){
+//        departListener = this;
+//        departListener.sccgDepartMapper = this.sccgDepartMapper;
+//        departListener.dataDictionaryMapper = this.dataDictionaryMapper;
+//    }
 
     @Override
     public void invoke(UmsDepartDto umsDepartDto, AnalysisContext analysisContext) {
@@ -41,10 +48,12 @@
         umsDepart.setDepartDes(umsDepartDto.getDepartDes());
 
         //  璁剧疆閮ㄩ棬绫诲瀷
-//        LambdaQueryWrapper<DataDictionary> dataDictionaryLambdaQueryWrapper = new LambdaQueryWrapper<DataDictionary>(DataDictionary::getName, umsDepartDto.getDepartTypeName());
-////        DataDictionary dataDictionary = dataDictionaryMapper.selectOne(new LambdaQueryWrapper(DataDictionary));
-////        sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>(UmsDepart::getDepartType))
-////        umsDepart.setDepartType(umsDepartDto.getDepartType());
+        DataDictionary dataDictionary = dataDictionary2Mapper.selectOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getName, umsDepartDto.getDepartType()));
+        if (Objects.isNull(dataDictionary)){
+            throw new RuntimeException("閮ㄩ棬绫诲瀷涓嶅瓨鍦�");
+        }else {
+            umsDepart.setDepartType(new Long(dataDictionary.getId()).intValue());
+        }
 
         //  璁剧疆鐖秈d
         UmsDepart two = sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getDepartName, umsDepartDto.getParentDepartName()));

--
Gitblit v1.8.0