package cn.iocoder.yudao.module.employee.api.employeeinfo;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.employee.api.EmployeeApi;
import cn.iocoder.yudao.module.employee.api.dto.EmployeeCreateReqDTO;
import cn.iocoder.yudao.module.employee.api.dto.EmployeeQueryReqDTO;
import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
import cn.iocoder.yudao.module.employee.controller.admin.employeeinfo.vo.EmployeeInfoQueryReqVO;
import cn.iocoder.yudao.module.employee.controller.admin.employeeinfo.vo.EmployeeInfoSaveReqVO;
import cn.iocoder.yudao.module.employee.dal.dataobject.employeeinfo.EmployeeInfoDO;
import cn.iocoder.yudao.module.employee.service.employeeinfo.EmployeeInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 员工 API 实现类
 *
 * @author 芋道源码
 */
@Service
public class EmployeeApiImpl implements EmployeeApi {

    @Resource
    private EmployeeInfoService infoService;

    @Override
    public Long createEmployee(EmployeeCreateReqDTO reqDTO) {
        EmployeeInfoSaveReqVO reqVO = BeanUtils.toBean(reqDTO, EmployeeInfoSaveReqVO.class);
        return infoService.createInfo(reqVO);
    }

    @Override
    public EmployeeRespDTO getEmployee(EmployeeQueryReqDTO reqDTO) {
        EmployeeInfoQueryReqVO reqVO = BeanUtils.toBean(reqDTO, EmployeeInfoQueryReqVO.class);
        EmployeeInfoDO employeeInfoDO = infoService.getInfo(reqVO);
        EmployeeRespDTO respDTO = BeanUtils.toBean(employeeInfoDO, EmployeeRespDTO.class);
        return respDTO;
    }

}
