package com.keao.edu.zuul.web.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

@Component
@Primary
public class SwaggerDocumentConfig implements SwaggerResourcesProvider {
	@Override
	public List<SwaggerResource> get() {
		List<SwaggerResource> resources = new ArrayList<SwaggerResource>();

		// 增加服务信息
		resources.add(swaggerResource("授权服务", "/auth-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("CMS服务", "/cms-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("TASK服务", "/task-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("USER服务", "/user-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("IM服务", "/im-server/v2/api-docs", "2.0"));
		return resources;
	}

	private SwaggerResource swaggerResource(String name, String location, String version) {
		SwaggerResource swaggerResource = new SwaggerResource();
		swaggerResource.setName(name);
		swaggerResource.setLocation(location);
		swaggerResource.setSwaggerVersion(version);
		return swaggerResource;
	}
}
