package com.bio.bio_backend.domain.base.resource.controller;

import com.bio.bio_backend.domain.base.resource.dto.ResourceDto;
import com.bio.bio_backend.domain.base.resource.service.ResourceService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;
import io.swagger.v3.oas.annotations.tags.Tag;

import java.util.List;

@RestController
@RequestMapping("/resource")
@RequiredArgsConstructor
@Tag(name = "Resource", description = "")
@Slf4j
public class ResourceController {

    private final ResourceService service;

    @PostMapping("")
    public ResourceDto create(@RequestBody ResourceDto dto) {
        return service.createResource(dto);
    }

    @PostMapping("/list")
    public List<ResourceDto> createList(@RequestBody List<ResourceDto> list) {
        return service.createResourceList(list);
    }

    @GetMapping("/{id}")
    public ResourceDto getById(@PathVariable Long id) {
        return service.getById(id);
    }

    @GetMapping
    public List<ResourceDto> getAll() {
        return service.getAll();
    }

    @PutMapping("/{id}")
    public ResourceDto update(@PathVariable Long id, @RequestBody ResourceDto dto) {
        return service.update(id, dto);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        service.delete(id);
    }
}
