package cn.sikey.mcdisk.controller.app.passthrough;

import cn.sikey.framework.common.pojo.CommonResult;
import cn.sikey.mcdisk.controller.app.passthrough.vo.PassThroughProxyReqVO;
import cn.sikey.mcdisk.enums.RateLimit;
import cn.sikey.mcdisk.service.PassThroughProxyService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: nelson
 * @Date: 2025/6/5
 * @Description: 透传代理
 */
@RestController
@RequestMapping("/mcdisk/passThrough")
@Slf4j
public class PassThroughController {

    @Resource
    private PassThroughProxyService passThroughProxyService;

    /**
     * 透传代理
     *
     * @param passThroughProxyReqVO 透传代理
     * @return
     */
    @RateLimit(key = "proxy",type = RateLimit.LimitType.GLOBAL)
    @PostMapping("/proxy")
    public CommonResult proxy(@RequestBody @Validated PassThroughProxyReqVO passThroughProxyReqVO) {
        return passThroughProxyService.passThroughProxy(passThroughProxyReqVO);
    }
}
