package com.zksy.system.convert;

import com.zksy.common.convert.BaseCovert;
import com.zksy.common.core.domain.entity.SysDept;
import com.zksy.common.core.domain.entity.SysDictData;
import com.zksy.common.utils.spring.SpringUtils;
import com.zksy.system.service.ISysDeptService;
import com.zksy.system.service.ISysDictTypeService;
import org.springframework.util.ObjectUtils;

import java.util.List;
import java.util.Map;

/**
 * @author ：BIN.LI
 * @date ：2022/6/15 15:49
 * @description：
 */
public class DictTypeConvertValue extends BaseCovert {
    public List<SysDictData> getDictData(String dictType) {
        ISysDictTypeService dictTypeService = SpringUtils.getBean(ISysDictTypeService.class);
        List<SysDictData> sysDictData = dictTypeService.selectDictDataByType(dictType);
        return sysDictData;
    }

    @Override
    public Object transferValue(Map<String, Object> param) {
        ISysDeptService deptService = SpringUtils.getBean(ISysDeptService.class);
        SysDept dept = new SysDept();
        dept.setStatus("0");
        dept.setDelFlag("0");
        dept.setDeptName(param.get("deptName") + "");
        List<SysDept> sysDepts = deptService.selectDeptList(dept);
        if (!ObjectUtils.isEmpty(sysDepts) && sysDepts.size() == 1) {
            return sysDepts.get(0).getDeptId();
        }
        return null;
    }
}
