package com.sonic.shark.controller.api;

import com.sonic.common.auth.IgnoreAuth;
import com.sonic.common.rpc.Result;
import com.sonic.shark.lib.input.ImageCheckInput;
import com.sonic.shark.service.ImageCheckService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * S3文件检查接口
 *
 * @Author code
 */
@RestController
@Slf4j
public class S3CheckApi {

    @Autowired
    private ImageCheckService imageCheckService;

    @IgnoreAuth
    @ApiOperation(value = "校验图片是否鉴黄通过，防止篡改绕过", tags = {"API-文件校验"})
    @PostMapping(value = "/api/s3-check/check-image")
    public Result<Void> checkImage(@Validated @RequestBody ImageCheckInput input) {
        imageCheckService.checkImageIsPassed(input.getUrls());
        return Result.success();
    }

}
