package com.yueqian.xingyun.api;

import com.lframework.starter.web.core.annotations.locker.EnableLock;
import com.lframework.starter.web.core.annotations.locker.LockType;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.mybatis.spring.annotation.MapperScan;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@EnableLock(type = LockType.REDIS)
@ServletComponentScan(basePackages = {"com.yueqian.xingyun"})
@SpringBootApplication(scanBasePackages = {"com.yueqian.xingyun"})
@MapperScan({"com.yueqian.xingyun.**.mappers"})
public class XingYunApiApplication {

  public static void main(String[] args) {
    SpringApplication.run(XingYunApiApplication.class, args);
  }

  @Configuration
  public static class OpenApiConfiguration {

    @Bean("xingyunApi")
    public GroupedOpenApi xingyunApi() {
      return GroupedOpenApi.builder()
          .group("星云ERP")
          .packagesToScan(
              "com.yueqian.xingyun.api",
              "com.yueqian.xingyun.basedata",
              "com.yueqian.xingyun.chart",
              "com.yueqian.xingyun.comp",
              "com.yueqian.xingyun.sc",
              "com.yueqian.xingyun.settle")
          .build();
    }

    @Bean
    public OpenAPI openAPI() {
      return new OpenAPI().info(new Info()
          .title("星云ERP接口文档")
          .description("# 星云ERP接口文档")
          .version("v1.0.0"));
    }
  }
}
