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

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.module.system.api.assets.dto.AssetsTypeDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.assets.AssetsTypeDO;
import cn.iocoder.yudao.module.system.service.assets.AssetsTypeService;
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
@DataPermission(enable = false)
public class AssetsTypeApiImpl implements AssetsTypeApi {

    @Resource
    private AssetsTypeService assetsTypeService;

    @Override
    public CommonResult<List<Long>> getAssetsTypeIdsByCode(String code) {
        List<Long> ids = assetsTypeService.getAssetsTypeIdsByCode(code);
        return success(ids);
    }

    @Override
    public CommonResult<AssetsTypeDTO> get(Long id) {

        AssetsTypeDO assetsTypeDO = assetsTypeService.getAssetsType(id);
        return success(BeanUtils.toBean(assetsTypeDO, AssetsTypeDTO.class));
    }

    @Override
    public CommonResult<List<AssetsTypeDTO>> getList(Collection<Long> ids) {

        return null;
    }
}
