package com.eco.common.mapper.core.impl;

import com.eco.common.mapper.core.FieldMapperInterface;
import com.eco.common.mapper.annotation.FieldMapperType;
import com.eco.common.mapper.constant.MapperConstant;
import lombok.AllArgsConstructor;
import org.eco.common.core.service.DeptService;

/**
 * @Description: DeptNameMapperImpl 部门名称映射
 * @Author: GaoKun Wang
 * @Date: 2024/7/1
 */
@AllArgsConstructor
@FieldMapperType(type = MapperConstant.DEPT_ID_TO_NAME)
public class DeptNameMapperImpl implements FieldMapperInterface<String> {
    private final DeptService deptService;

    @Override
    public String fieldMapper(Object key, String other) {
        if (key instanceof String ids) {
            return deptService.selectDeptNameByIds(ids);
        } else if (key instanceof Long id) {
            return deptService.selectDeptNameByIds(id.toString());
        }
        return null;
    }
}
