package cn.meowrain.aioj.backend.fileservice.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Swagger配置类
 *
 * @author meowrain
 * @since 2026-01-10
 */
@Slf4j
@Configuration
@EnableKnife4j
public class SwaggerConfiguration implements ApplicationRunner {

    @Value("${server.port:8080}")
    private String serverPort;

    @Value("${server.servlet.context-path:}")
    private String contextPath;

    @Bean
    public OpenAPI customerOpenAPI() {
        return new OpenAPI().info(new Info().title("AIOJ-文件服务✨")
                .description("文件上传、下载、存储管理等功能")
                .version("v1.0.0")
                .contact(new Contact().name("meowrain").email("meowrain@126.com"))
                .license(new License().name("MeowRain").url("https://meowrain.cn")));
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("✨API Document: http://127.0.0.1:{}{}/doc.html", serverPort, contextPath);
    }
}
