package com.yhy.module.core.controller.admin.resource;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import com.yhy.module.core.controller.admin.resource.vo.CatalogCreateReqVO;
import com.yhy.module.core.controller.admin.resource.vo.CatalogListReqVO;
import com.yhy.module.core.dal.dataobject.resource.ResourceCatalogDO;
import com.yhy.module.core.service.resource.ResourceCatalogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

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

@Tag(name = "管理后台 - 工料机资源库")
@RestController
@RequestMapping("/core/resource/catalogs")
@Validated
public class ResourceCatalogController {

    @Resource
    private ResourceCatalogService catalogService;

    @PostMapping
    @Operation(summary = "创建资源库版本")
    public CommonResult<Long> create(@Valid @RequestBody CatalogCreateReqVO reqVO) {
        return success(catalogService.createCatalog(reqVO));
    }

    @GetMapping
    @Operation(summary = "查询资源库列表")
    public CommonResult<List<ResourceCatalogDO>> list(@Valid CatalogListReqVO reqVO) {
        return success(catalogService.list(reqVO));
    }
}
