package cn.iocoder.yudao.module.system.api.assetreceive;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.api.assetreceive.dto.AssetReceiveSaveDTO;
import cn.iocoder.yudao.module.system.controller.admin.assetreceive.vo.AssetReceiveSaveReqVO;
import cn.iocoder.yudao.module.system.service.assetreceive.AssetReceiveService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

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

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

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

    @Resource
    private AssetReceiveService assetReceiveService;

    @Override
    public CommonResult<Boolean> createReceive(List<AssetReceiveSaveDTO> saveDTO) {

        List<AssetReceiveSaveReqVO> assetReceives = BeanUtils.toBean(saveDTO, AssetReceiveSaveReqVO.class);
        return success(assetReceiveService.createAssetReceives(assetReceives));
    }
}
