zhanghua
2023-09-08 7ef4892f9f24f941aca37e6b3991b808a0aca619
ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java
@@ -5,7 +5,9 @@
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.DataDictionary2Mapper;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@@ -16,7 +18,17 @@
    @Resource
    private UmsDepartMapper sccgDepartMapper;
    @Resource
    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) {
@@ -36,7 +48,12 @@
        umsDepart.setDepartDes(umsDepartDto.getDepartDes());
        //  设置部门类型
        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());
        }
        //  设置父id
        UmsDepart two = sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getDepartName, umsDepartDto.getParentDepartName()));