package cd.casic.ci.api;



import cd.casic.ci.process.dto.req.resource.ResourceCreateReq;
import cd.casic.ci.process.dto.req.resource.ResourceListReq;
import cd.casic.ci.process.dto.req.resource.ResourcePageReq;
import cd.casic.ci.process.dto.req.resource.ResourceUpdateReq;
import cd.casic.ci.process.dto.resp.resource.ResourceDetailResp;
import cd.casic.ci.process.dto.resp.resource.ResourceListResp;
import cd.casic.ci.process.process.service.resource.ResourceManagerService;
import cd.casic.framework.commons.pojo.CommonResult;
import cd.casic.framework.commons.pojo.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName ResourceController
 * @Author hopeli
 * @Date 2025/5/10 10:57
 * @Version 1.0
 */

@RestController
@RequestMapping("/resource")
public class ResourceManagerController {

    @Resource
    private ResourceManagerService resourceManagerService;
    @PostMapping("/createResource")
    public CommonResult<String> createResource(@RequestBody ResourceCreateReq req){
        return CommonResult.success(resourceManagerService.createResource(req));
    }
    @PostMapping("/updateResource")
    public CommonResult<String> updateResource(@RequestBody ResourceUpdateReq req){
        return CommonResult.success(resourceManagerService.updateResource(req));
    }
    @GetMapping("/findResourceDetailById/{resourceId}")
    public CommonResult<ResourceDetailResp> findResourceDetailById(@PathVariable String resourceId){
        return CommonResult.success(resourceManagerService.findResourceDetailById(resourceId));
    }
    @PostMapping("/list")
    public CommonResult<List<ResourceListResp>> list(@RequestBody ResourceListReq req){
        return CommonResult.success(resourceManagerService.list(req));
    }
    @PostMapping("/page")
    public CommonResult<PageResult<ResourceListResp>> page(@RequestBody ResourcePageReq req){
        return CommonResult.success(resourceManagerService.page(req));
    }
    @DeleteMapping("/deleteResource/{resourceId}")
    public CommonResult<Void> deleteResource(@PathVariable String resourceId){
        resourceManagerService.deleteResource(resourceId);
        return CommonResult.success();
    }


}
