package com.yonge.gateway.web.config;

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

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

@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("STUDENT服务", "/student-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("TEACHER服务", "/teacher-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("ADMIN服务", "/admin-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("WEBSITE服务", "/website-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("MALL_ADMIN服务", "/mall-admin-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("MALL_PORTAL服务", "/mall-portal-server/v2/api-docs", "2.0"));
		resources.add(swaggerResource("网络教室", "/classroom-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;
	}
}
