From 7d57ccc8f602106645c7dd4a19b64b75f133017c Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期六, 18 三月 2023 17:44:31 +0800 Subject: [PATCH] 缺少引用 --- ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 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 267d9a7..7be3c66 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 @@ -5,9 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ycl.dto.UmsDepartDto; 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.Objects; @@ -16,7 +20,17 @@ @Resource private UmsDepartMapper sccgDepartMapper; + @Resource + private DataDictionaryMapper dataDictionaryMapper; +// 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) { @@ -36,7 +50,12 @@ umsDepart.setDepartDes(umsDepartDto.getDepartDes()); // 璁剧疆閮ㄩ棬绫诲瀷 - umsDepart.setDepartType(umsDepartDto.getDepartType()); + DataDictionary dataDictionary = dataDictionaryMapper.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