package cn.cslg.report.controller;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.entity.References;
import cn.cslg.report.service.business.ReferencesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Tag(name = "其他参考资料")
@RestController
@RequestMapping(Constants.REPORT_API + "/References")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class ReferencesController {
    public final ReferencesService referencesService;
    @RequestMapping(value = "/addReferences", method = RequestMethod.POST)
    @Operation(summary = "增加参考资料")
    public  String addReferences(@RequestBody References references) throws IOException{
        return referencesService.addReferences(references);
    }
    @RequestMapping(value = "/updateReferences", method = RequestMethod.POST)
    @Operation(summary = "修改参考资料")
    @Transactional(rollbackFor = Exception.class)
    public String updateReferences( @RequestBody References references)throws IOException{
        return referencesService.updateReferences(references);

    }
    @GetMapping(value = "/deleReferences")
    @Operation(summary = "删除参考资料")
    public String deleReferences(int id)throws IOException{
        return referencesService.deleteReferences(id);
    }
    @PostMapping(value = "/queryReferences")
    @Operation(summary = "查询参考资料")
    @Transactional(rollbackFor = Exception.class)
    public String queryReferences(@RequestBody References references)throws IOException{
        return referencesService.queryReferences(references);
    }


}
