package cn.iocoder.yudao.module.smartfactory.api.staff;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
import cn.iocoder.yudao.module.smartfactory.service.staff.StaffService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class StaffApiImpl implements StaffApi {

    @Resource
    private StaffService staffService;

    @Override
    public CommonResult<StaffDTO> getStaff(Long staffId) {
        return success(BeanUtils.toBean(staffService.getStaff(staffId), StaffDTO.class));
    }

    @Override
    public CommonResult<List<StaffDTO>> getStaffList(Collection<Long> staffId) {
        return success(BeanUtils.toBean(staffService.getList(staffId), StaffDTO.class));
    }

    @Override
    public CommonResult<StaffDTO> getStaffByUserId(Long userId) {
        return success(BeanUtils.toBean(staffService.getStaffByUserId(userId), StaffDTO.class));
    }
}
