package com.jeesharp.business.contentsecurity.controller;

import com.jeesharp.business.modules.contentsecurity.api.ContentSecurityApi;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信小程序消息推送回调：接收 {@code wxa_media_check} 异步图片检测结果。
 *
 * @author jeesharp
 * @since 2026-06-27
 */
@Slf4j
@RestController
@Tag(name = "小程序-内容安全回调")
@AllArgsConstructor
public class ContentSecurityWechatCallbackMobileController {

    private final ContentSecurityApi contentSecurityApi;

    @Operation(summary = "微信异步图片检测回调")
    @PostMapping("${jeesharp.web.mobilePath}/noAuth/contentSecurity/wechat/mediaCallback")
    public String mediaCallback(@RequestBody String rawBody) {
        log.debug("wxa_media_check callback received, bodyLength={}", rawBody != null ? rawBody.length() : 0);
        contentSecurityApi.handleWechatMediaCallback(rawBody);
        return "success";
    }
}
