liusheng
2024-09-18 722fa40345f1fc650eaeae4a721c3ae4106d92a8
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserDeptServiceImpl.java
@@ -1,8 +1,11 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUserDept;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.service.ISysUserDeptService;
import com.smartor.mapper.SysUserDeptMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -19,6 +22,9 @@
public class SysUserDeptServiceImpl implements ISysUserDeptService {
    @Autowired
    private SysUserDeptMapper sysUserDeptMapper;
    @Autowired
    private SysDeptMapper sysDeptMapper;
    /**
     * 查询【请填写功能名称】
@@ -52,6 +58,12 @@
    public int insertSysUserDept(SysUserDept sysUserDept) {
        sysUserDept.setCreateTime(new Date());
        sysUserDept.setUpdateTime(new Date());
        //根据code查询deptName
        SysDept dept = new SysDept();
        dept.setDeptCode(sysUserDept.getDeptCode());
        List<SysDept> sysDepts = sysDeptMapper.selectDeptList(dept);
        if (CollectionUtils.isNotEmpty(sysDepts))
            sysUserDept.setDeptName(sysDepts.get(0).getDeptName());
        return sysUserDeptMapper.insertSysUserDept(sysUserDept);
    }