package org.dromara.web.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.web.utils.TxApiSdkUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文本/图片安全验证
 * @author Maosw
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/appletAuth")
@Tag(name = "腾讯云接口")
public class ApiAppletAuthController {


    @PostMapping("/checkContext")
    @Operation(summary = "腾讯云文本内容安全识别" , description = "腾讯云文本内容安全识别")
    public R<String> checkContext(@RequestParam String content) {
        if (StringUtils.isEmpty(content)) {
            return R.fail("-1", "内容不能为空");
        }
        return R.ok(TxApiSdkUtils.checkContext(content));
    }

    @PostMapping("/checkImages")
    @Operation(summary = "腾讯云图片内容安全识别" , description = "腾讯云图片内容安全识别")
    public R<String> checkImages(@RequestParam String content) {
        if (StringUtils.isEmpty(content)) {
            return R.fail("-1", "内容不能为空");
        }
        return R.ok(TxApiSdkUtils.checkImages(content));
    }

}
