package com.seer.teach.openapi.controller;

import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.openapi.service.SignatureService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Captain
 * @Description: Ai批改
 * @Date: 2025-05-12 14:28
 */
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@Tag(name = "API - 认证")
@RequestMapping("/sign")
public class SignatureController {

    private final SignatureService signatureService;

    @LogPrint
    @Operation(summary = "验签并返回")
    @GetMapping
    public ResultBean<String> sn(@RequestParam("appId") String appId,
                                      @RequestParam("sign") String sign,
                                      @RequestParam("timestamp") String timestamp,
                                      @RequestParam("body") String body) {
        String decrypt = signatureService.verification(appId, sign, timestamp, body);
        return ResultBean.success(decrypt);
    }

}
