package cd.casic.ci.api;

import cd.casic.ci.process.dto.req.vulInfo.SearchDto;
import cd.casic.ci.process.dto.req.vulInfo.VulInfoDto;
import cd.casic.ci.process.process.dataObject.volumnInfo.VulInfo;
import cd.casic.ci.process.process.service.vulInfo.VulInfoService;
import cd.casic.framework.commons.pojo.CommonResult;
import cd.casic.framework.commons.pojo.PageResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/vulInfo")
public class VulInfoController {
    @Resource
    private VulInfoService vulInfoService;

    /**
     *上传漏洞信息
     */
    @PostMapping("/upload")
    public CommonResult<Void> uploadVulInfo(@RequestBody VulInfo vulInfo) {
        vulInfoService.upload(vulInfo);
        return CommonResult.success();
    }

    /**
     *分页模糊查询漏洞信息
     */
    @PostMapping("/search")
    public CommonResult<PageResult<VulInfoDto>> getVulInfoSearch(@RequestBody SearchDto searchDto) {
        return CommonResult.success(vulInfoService.getSearch(searchDto));
    }
}
