From d9bf06d804c9663d887348546afde5678365d8ec Mon Sep 17 00:00:00 2001 From: lidongdai Date: Thu, 23 May 2019 18:30:33 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0api=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- escheduler-api/pom.xml | 6 - .../api/configuration/AppConfiguration.java | 12 +- .../SwaggerApiImplicitParamPlugin.java | 109 --------- .../SwaggerApiImplicitParamsPlugin.java | 71 ------ .../configuration/SwaggerApiModelPlugin.java | 74 ------ .../SwaggerApiModelPropertyPlugin.java | 219 ------------------ .../SwaggerApiOperationPlugin.java | 141 ----------- .../configuration/SwaggerApiParamPlugin.java | 115 --------- .../api/configuration/SwaggerApiPlugin.java | 74 ------ .../api/controller/AccessTokenController.java | 22 +- .../api/controller/AlertGroupController.java | 5 + .../controller/DataAnalysisController.java | 2 + .../api/controller/DataSourceController.java | 100 +++++++- .../api/controller/ExecutorController.java | 2 + .../api/controller/LoggerController.java | 10 +- .../api/controller/LoginController.java | 9 +- .../api/controller/MonitorController.java | 18 +- .../ProcessDefinitionController.java | 20 +- .../controller/ProcessInstanceController.java | 22 +- .../api/controller/ProjectController.java | 53 ++++- .../api/controller/QueueController.java | 40 +++- .../api/controller/ResourcesController.java | 176 ++++++++++++-- .../api/controller/SchedulerController.java | 28 +-- .../api/controller/ServerController.java | 85 ------- .../controller/TaskInstanceController.java | 6 +- .../api/controller/TaskRecordController.java | 12 +- .../api/controller/TenantController.java | 51 +++- .../api/controller/UsersController.java | 30 +-- .../api/controller/WorkerGroupController.java | 2 + .../src/main/resources/messages.properties | 105 ++++++++- .../main/resources/messages_en_US.properties | 103 +++++++- .../main/resources/messages_zh_CN.properties | 93 ++++++++ 32 files changed, 780 insertions(+), 1035 deletions(-) delete mode 100644 escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiImplicitParamPlugin.java delete mode 100644 escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiImplicitParamsPlugin.java delete mode 100644 escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiModelPlugin.java delete mode 100644 escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiModelPropertyPlugin.java delete mode 100644 escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiOperationPlugin.java delete mode 100644 escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiParamPlugin.java delete mode 100644 escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiPlugin.java delete mode 100644 escheduler-api/src/main/java/cn/escheduler/api/controller/ServerController.java diff --git a/escheduler-api/pom.xml b/escheduler-api/pom.xml index 31120c3883..70135ad9b2 100644 --- a/escheduler-api/pom.xml +++ b/escheduler-api/pom.xml @@ -168,12 +168,6 @@ 4.12 test - - io.swagger - swagger-jaxrs - 1.5.12 - - diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/AppConfiguration.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/AppConfiguration.java index 77066386e8..b9b69c0a9c 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/configuration/AppConfiguration.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/configuration/AppConfiguration.java @@ -19,8 +19,8 @@ package cn.escheduler.api.configuration; import cn.escheduler.api.interceptor.LoginHandlerInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.*; import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.config.annotation.*; import org.springframework.web.servlet.i18n.CookieLocaleResolver; import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; @@ -49,12 +49,12 @@ public class AppConfiguration implements WebMvcConfigurer { /** * Cookie */ - @Bean + @Bean(name = "localeResolver") public LocaleResolver localeResolver() { CookieLocaleResolver localeResolver = new CookieLocaleResolver(); localeResolver.setCookieName(LOCALE_LANGUAGE_COOKIE); /** set default locale **/ - localeResolver.setDefaultLocale(Locale.ENGLISH); + localeResolver.setDefaultLocale(Locale.US); /** set cookie max age **/ localeResolver.setCookieMaxAge(COOKIE_MAX_AGE); return localeResolver; @@ -64,7 +64,7 @@ public class AppConfiguration implements WebMvcConfigurer { public LocaleChangeInterceptor localeChangeInterceptor() { LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); /** **/ - lci.setParamName("lang"); + lci.setParamName("language"); return lci; } @@ -72,14 +72,16 @@ public class AppConfiguration implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(loginInterceptor()).addPathPatterns(LOGIN_INTERCEPTOR_PATH_PATTERN).excludePathPatterns(LOGIN_PATH_PATTERN,"/swagger-resources/**", "/webjars/**", "/v2/**", "/doc.html", "*.html"); //i18n registry.addInterceptor(localeChangeInterceptor()); + + registry.addInterceptor(loginInterceptor()).addPathPatterns(LOGIN_INTERCEPTOR_PATH_PATTERN).excludePathPatterns(LOGIN_PATH_PATTERN,"/swagger-resources/**", "/webjars/**", "/v2/**", "/doc.html", "*.html"); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); } diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiImplicitParamPlugin.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiImplicitParamPlugin.java deleted file mode 100644 index 0bb3733dd5..0000000000 --- a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiImplicitParamPlugin.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package cn.escheduler.api.configuration; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Optional; -import com.google.common.collect.Lists; -import io.swagger.annotations.ApiImplicitParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ParameterBuilder; -import springfox.documentation.schema.ModelRef; -import springfox.documentation.service.AllowableValues; -import springfox.documentation.service.Parameter; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.OperationBuilderPlugin; -import springfox.documentation.spi.service.contexts.OperationContext; -import springfox.documentation.spring.web.DescriptionResolver; -import springfox.documentation.swagger.common.SwaggerPluginSupport; - -import java.util.List; -import java.util.Locale; - -import static com.google.common.base.Strings.emptyToNull; -import static springfox.documentation.schema.Types.isBaseType; -import static springfox.documentation.swagger.common.SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER; -import static springfox.documentation.swagger.readers.parameter.Examples.examples; -import static springfox.documentation.swagger.schema.ApiModelProperties.allowableValueFromString; - -@Component -@Order(Ordered.HIGHEST_PRECEDENCE - 10) -public class SwaggerApiImplicitParamPlugin implements OperationBuilderPlugin { - - @Autowired - private DescriptionResolver descriptions; - - @Autowired - private MessageSource messageSource; - - static Parameter implicitParameter(MessageSource messageSource, DescriptionResolver descriptions, ApiImplicitParam param) { - Locale locale = LocaleContextHolder.getLocale(); - - ModelRef modelRef = maybeGetModelRef(param); - return new ParameterBuilder() - .name(param.name()) - .description(descriptions.resolve(messageSource.getMessage(param.value(), null, locale))) - .defaultValue(param.defaultValue()) - .required(param.required()) - .allowMultiple(param.allowMultiple()) - .modelRef(modelRef) - .allowableValues(allowableValueFromString(param.allowableValues())) - .parameterType(emptyToNull(param.paramType())) - .parameterAccess(param.access()) - .order(SWAGGER_PLUGIN_ORDER) - .scalarExample(param.example()) - .complexExamples(examples(param.examples())) - .build(); - } - - private static ModelRef maybeGetModelRef(ApiImplicitParam param) { - String dataType = MoreObjects.firstNonNull(emptyToNull(param.dataType()), "string"); - AllowableValues allowableValues = null; - if (isBaseType(dataType)) { - allowableValues = allowableValueFromString(param.allowableValues()); - } - if (param.allowMultiple()) { - return new ModelRef("", new ModelRef(dataType, allowableValues)); - } - return new ModelRef(dataType, allowableValues); - } - - @Override - public void apply(OperationContext context) { - context.operationBuilder().parameters(readParameters(context)); - } - - @Override - public boolean supports(DocumentationType delimiter) { - return SwaggerPluginSupport.pluginDoesApply(delimiter); - } - - private List readParameters(OperationContext context) { - Optional annotation = context.findAnnotation(ApiImplicitParam.class); - List parameters = Lists.newArrayList(); - if (annotation.isPresent()) { - parameters.add(implicitParameter(messageSource, descriptions, annotation.get())); - } - return parameters; - } - -} \ No newline at end of file diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiImplicitParamsPlugin.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiImplicitParamsPlugin.java deleted file mode 100644 index a1a0b41dda..0000000000 --- a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiImplicitParamsPlugin.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package cn.escheduler.api.configuration; - -import com.google.common.base.Optional; -import com.google.common.collect.Lists; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import springfox.documentation.service.Parameter; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.OperationBuilderPlugin; -import springfox.documentation.spi.service.contexts.OperationContext; -import springfox.documentation.spring.web.DescriptionResolver; - -import java.util.List; - -import static springfox.documentation.swagger.common.SwaggerPluginSupport.pluginDoesApply; - -@Component -@Order(Ordered.HIGHEST_PRECEDENCE - 10) -public class SwaggerApiImplicitParamsPlugin implements OperationBuilderPlugin { - - @Autowired - private DescriptionResolver descriptions; - @Autowired - private MessageSource messageSource; - - @Override - public void apply(OperationContext context) { - context.operationBuilder().parameters(readParameters(context)); - } - - @Override - public boolean supports(DocumentationType delimiter) { - return pluginDoesApply(delimiter); - } - - private List readParameters(OperationContext context) { - Optional annotation = context.findAnnotation(ApiImplicitParams.class); - - List parameters = Lists.newArrayList(); - if (annotation.isPresent()) { - for (ApiImplicitParam param : annotation.get().value()) { - parameters.add(SwaggerApiImplicitParamPlugin.implicitParameter(messageSource, descriptions, param)); - } - } - - return parameters; - } - - -} \ No newline at end of file diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiModelPlugin.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiModelPlugin.java deleted file mode 100644 index 157d5d9581..0000000000 --- a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiModelPlugin.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.escheduler.api.configuration; - - - -import com.fasterxml.classmate.TypeResolver; -import io.swagger.annotations.ApiModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import springfox.documentation.schema.ModelReference; -import springfox.documentation.schema.TypeNameExtractor; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.schema.ModelBuilderPlugin; -import springfox.documentation.spi.schema.contexts.ModelContext; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import static springfox.documentation.schema.ResolvedTypes.*; -import static springfox.documentation.swagger.common.SwaggerPluginSupport.*; - -/** - * NOTE : not useful - */ -@Component -@Order(Ordered.HIGHEST_PRECEDENCE - 10) -public class SwaggerApiModelPlugin implements ModelBuilderPlugin { - - @Autowired - private TypeResolver typeResolver; - @Autowired - private TypeNameExtractor typeNameExtractor; - @Autowired - private MessageSource messageSource; - - @Override - public void apply(ModelContext context) { - ApiModel annotation = AnnotationUtils.findAnnotation(forClass(context), ApiModel.class); - if (annotation != null) { - List modelRefs = new ArrayList(); - for (Class each : annotation.subTypes()) { - modelRefs.add(modelRefFactory(context, typeNameExtractor) - .apply(typeResolver.resolve(each))); - } - Locale locale = LocaleContextHolder.getLocale(); - - context.getBuilder() - .description(messageSource.getMessage(annotation.description(), null, locale)) - .discriminator(annotation.discriminator()) - .subTypes(modelRefs); - } - } - - private Class forClass(ModelContext context) { - return typeResolver.resolve(context.getType()).getErasedType(); - } - - -// @Override -// public boolean supports(DocumentationType delimiter) { -// return pluginDoesApply(delimiter); -// } - - @Override - public boolean supports(DocumentationType delimiter) { - return true; - } -} - diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiModelPropertyPlugin.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiModelPropertyPlugin.java deleted file mode 100644 index 9b40eed6fd..0000000000 --- a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiModelPropertyPlugin.java +++ /dev/null @@ -1,219 +0,0 @@ -package cn.escheduler.api.configuration; - - -import com.fasterxml.classmate.ResolvedType; -import com.fasterxml.classmate.TypeResolver; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Splitter; -import com.google.common.base.Strings; -import com.google.common.collect.Lists; -import io.swagger.annotations.ApiModelProperty; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import springfox.documentation.service.AllowableListValues; -import springfox.documentation.service.AllowableRangeValues; -import springfox.documentation.service.AllowableValues; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.schema.ModelPropertyBuilderPlugin; -import springfox.documentation.spi.schema.contexts.ModelPropertyContext; -import springfox.documentation.spring.web.DescriptionResolver; -import springfox.documentation.swagger.common.SwaggerPluginSupport; -import springfox.documentation.swagger.schema.ApiModelProperties; - -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static com.google.common.collect.Lists.newArrayList; -import static org.springframework.util.StringUtils.hasText; -import static springfox.documentation.schema.Annotations.*; -import static springfox.documentation.swagger.schema.ApiModelProperties.*; - -@Component -@Order(Ordered.HIGHEST_PRECEDENCE - 10) -public class SwaggerApiModelPropertyPlugin implements ModelPropertyBuilderPlugin { - private static final Logger LOGGER = LoggerFactory.getLogger(ApiModelProperties.class); - private static final Pattern RANGE_PATTERN = Pattern.compile("range([\\[(])(.*),(.*)([])])$"); - - @Autowired - private DescriptionResolver descriptions; - @Autowired - private MessageSource messageSource; - - - @Override - public void apply(ModelPropertyContext context) { - Optional annotation = Optional.absent(); - - if (context.getAnnotatedElement().isPresent()) { - annotation = annotation.or(findApiModePropertyAnnotation(context.getAnnotatedElement().get())); - } - if (context.getBeanPropertyDefinition().isPresent()) { - annotation = annotation.or(findPropertyAnnotation( - context.getBeanPropertyDefinition().get(), - ApiModelProperty.class)); - } - if (annotation.isPresent()) { - context.getBuilder() - .allowableValues(annotation.transform(toAllowableValues()).orNull()) - .required(annotation.transform(toIsRequired()).or(false)) - .readOnly(annotation.transform(toIsReadOnly()).or(false)) - .description(annotation.transform(toDescription(descriptions)).orNull()) - .isHidden(annotation.transform(toHidden()).or(false)) - .type(annotation.transform(toType(context.getResolver())).orNull()) - .position(annotation.transform(toPosition()).or(0)) - .example(annotation.transform(toExample()).orNull()); - } - } - - - static Function toAllowableValues() { - return new Function() { - @Override - public AllowableValues apply(ApiModelProperty annotation) { - return allowableValueFromString(annotation.allowableValues()); - } - }; - } - - public static AllowableValues allowableValueFromString(String allowableValueString) { - AllowableValues allowableValues = new AllowableListValues(Lists.newArrayList(), "LIST"); - String trimmed = allowableValueString.trim(); - Matcher matcher = RANGE_PATTERN.matcher(trimmed.replaceAll(" ", "")); - if (matcher.matches()) { - if (matcher.groupCount() != 4) { - LOGGER.warn("Unable to parse range specified {} correctly", trimmed); - } else { - allowableValues = new AllowableRangeValues( - matcher.group(2).contains("infinity") ? null : matcher.group(2), - matcher.group(1).equals("("), - matcher.group(3).contains("infinity") ? null : matcher.group(3), - matcher.group(4).equals(")")); - } - } else if (trimmed.contains(",")) { - Iterable split = Splitter.on(',').trimResults().omitEmptyStrings().split(trimmed); - allowableValues = new AllowableListValues(newArrayList(split), "LIST"); - } else if (hasText(trimmed)) { - List singleVal = Collections.singletonList(trimmed); - allowableValues = new AllowableListValues(singleVal, "LIST"); - } - return allowableValues; - } - - static Function toIsRequired() { - return new Function() { - @Override - public Boolean apply(ApiModelProperty annotation) { - return annotation.required(); - } - }; - } - - static Function toPosition() { - return new Function() { - @Override - public Integer apply(ApiModelProperty annotation) { - return annotation.position(); - } - }; - } - - static Function toIsReadOnly() { - return new Function() { - @Override - public Boolean apply(ApiModelProperty annotation) { - return annotation.readOnly(); - } - }; - } - - static Function toAllowEmptyValue() { - return new Function() { - @Override - public Boolean apply(ApiModelProperty annotation) { - return annotation.allowEmptyValue(); - } - }; - } - - Function toDescription( - final DescriptionResolver descriptions) { - Locale locale = LocaleContextHolder.getLocale(); - - return new Function() { - @Override - public String apply(ApiModelProperty annotation) { - String description = ""; - if (!Strings.isNullOrEmpty(annotation.value())) { - description = messageSource.getMessage(annotation.value(), null, "" ,locale); - } else if (!Strings.isNullOrEmpty(annotation.notes())) { - description = messageSource.getMessage(annotation.notes(), null, "" ,locale); - } - return descriptions.resolve(description); - } - }; - } - - static Function toType(final TypeResolver resolver) { - return new Function() { - @Override - public ResolvedType apply(ApiModelProperty annotation) { - try { - return resolver.resolve(Class.forName(annotation.dataType())); - } catch (ClassNotFoundException e) { - return resolver.resolve(Object.class); - } - } - }; - } - - public static Optional findApiModePropertyAnnotation(AnnotatedElement annotated) { - Optional annotation = Optional.absent(); - - if (annotated instanceof Method) { - // If the annotated element is a method we can use this information to check superclasses as well - annotation = Optional.fromNullable(AnnotationUtils.findAnnotation(((Method) annotated), ApiModelProperty.class)); - } - - return annotation.or(Optional.fromNullable(AnnotationUtils.getAnnotation(annotated, ApiModelProperty.class))); - } - - static Function toHidden() { - return new Function() { - @Override - public Boolean apply(ApiModelProperty annotation) { - return annotation.hidden(); - } - }; - } - - static Function toExample() { - return new Function() { - @Override - public String apply(ApiModelProperty annotation) { - String example = ""; - if (!Strings.isNullOrEmpty(annotation.example())) { - example = annotation.example(); - } - return example; - } - }; - } - - @Override - public boolean supports(DocumentationType delimiter) { - return SwaggerPluginSupport.pluginDoesApply(delimiter); - } -} diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiOperationPlugin.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiOperationPlugin.java deleted file mode 100644 index 0ff4de15c3..0000000000 --- a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiOperationPlugin.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.escheduler.api.configuration; - -import java.util.List; -import java.util.Locale; -import java.util.Set; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Splitter; -import com.google.common.collect.Sets; -import io.swagger.annotations.Api; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import io.swagger.annotations.ApiOperation; -import org.springframework.util.StringUtils; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.OperationBuilderPlugin; -import springfox.documentation.spi.service.contexts.OperationContext; -import springfox.documentation.spring.web.DescriptionResolver; -import springfox.documentation.spring.web.readers.operation.DefaultTagsProvider; -import springfox.documentation.swagger.common.SwaggerPluginSupport; - -import static com.google.common.base.Strings.nullToEmpty; -import static com.google.common.collect.FluentIterable.from; -import static com.google.common.collect.Lists.newArrayList; -import static com.google.common.collect.Sets.*; -import static springfox.documentation.service.Tags.emptyTags; - - -@Component -@Order(Ordered.HIGHEST_PRECEDENCE - 10) -public class SwaggerApiOperationPlugin implements OperationBuilderPlugin { - - private static final Logger logger = LoggerFactory.getLogger(SwaggerApiOperationPlugin.class); - - @Autowired - private DescriptionResolver descriptions; - @Autowired - private DefaultTagsProvider tagsProvider; - - @Autowired - private MessageSource messageSource; - - @Override - public void apply(OperationContext context) { - - Locale locale = LocaleContextHolder.getLocale(); - - Set defaultTags = tagsProvider.tags(context); - Sets.SetView tags = union(operationTags(context), controllerTags(context)); - if (tags.isEmpty()) { - context.operationBuilder().tags(defaultTags); - } else { - context.operationBuilder().tags(tags); - } - - - Optional apiOperationAnnotation = context.findAnnotation(ApiOperation.class); - if (apiOperationAnnotation.isPresent()) { - ApiOperation operation = apiOperationAnnotation.get(); - - if (StringUtils.hasText(operation.nickname())) { - // Populate the value of nickname annotation into uniqueId - context.operationBuilder().uniqueId(operation.nickname()); - context.operationBuilder().codegenMethodNameStem(operation.nickname()); - } - - if (StringUtils.hasText(apiOperationAnnotation.get().notes())) { - context.operationBuilder().notes(descriptions.resolve(messageSource.getMessage(apiOperationAnnotation.get().notes(), null, "", locale))); - } - - if (apiOperationAnnotation.get().position() > 0) { - context.operationBuilder().position(apiOperationAnnotation.get().position()); - } - - if (StringUtils.hasText(apiOperationAnnotation.get().value())) { - context.operationBuilder().summary(descriptions.resolve(apiOperationAnnotation.get().value())); - } - - context.operationBuilder().consumes(asSet(nullToEmpty(apiOperationAnnotation.get().consumes()))); - context.operationBuilder().produces(asSet(nullToEmpty(apiOperationAnnotation.get().produces()))); - } - - - - - } - - - private Set controllerTags(OperationContext context) { - Optional controllerAnnotation = context.findControllerAnnotation(Api.class); - return controllerAnnotation.transform(tagsFromController()).or(Sets.newHashSet()); - } - - private Set operationTags(OperationContext context) { - Optional annotation = context.findAnnotation(ApiOperation.class); - return annotation.transform(tagsFromOperation()).or(Sets.newHashSet()); - } - - private Function> tagsFromOperation() { - return new Function>() { - @Override - public Set apply(ApiOperation input) { - Set tags = newTreeSet(); - tags.addAll(from(newArrayList(input.tags())).filter(emptyTags()).toSet()); - return tags; - } - }; - } - - private Function> tagsFromController() { - return new Function>() { - @Override - public Set apply(Api input) { - Set tags = newTreeSet(); - tags.addAll(from(newArrayList(input.tags())).filter(emptyTags()).toSet()); - return tags; - } - }; - } - private Set asSet(String mediaTypes) { - return newHashSet(Splitter.on(',') - .trimResults() - .omitEmptyStrings() - .splitToList(mediaTypes)); - } - - @Override - public boolean supports(DocumentationType delimiter) { - return SwaggerPluginSupport.pluginDoesApply(delimiter); -// return true; - } - -} diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiParamPlugin.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiParamPlugin.java deleted file mode 100644 index 9fbdc1ce66..0000000000 --- a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiParamPlugin.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * Copyright 2015-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ -package cn.escheduler.api.configuration; - -import com.fasterxml.classmate.ResolvedType; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import io.swagger.annotations.ApiParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import springfox.documentation.schema.Collections; -import springfox.documentation.schema.Enums; -import springfox.documentation.schema.Example; -import springfox.documentation.service.AllowableValues; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.schema.EnumTypeDeterminer; -import springfox.documentation.spi.service.ParameterBuilderPlugin; -import springfox.documentation.spi.service.contexts.ParameterContext; -import springfox.documentation.spring.web.DescriptionResolver; -import springfox.documentation.swagger.schema.ApiModelProperties; - -import java.util.Locale; - -import static com.google.common.base.Strings.emptyToNull; -import static com.google.common.base.Strings.isNullOrEmpty; -import static springfox.documentation.swagger.common.SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER; -import static springfox.documentation.swagger.common.SwaggerPluginSupport.pluginDoesApply; -import static springfox.documentation.swagger.readers.parameter.Examples.examples; - -@Component -@Order(Ordered.HIGHEST_PRECEDENCE - 10) -public class SwaggerApiParamPlugin implements ParameterBuilderPlugin { - @Autowired - private DescriptionResolver descriptions; - @Autowired - private EnumTypeDeterminer enumTypeDeterminer; - @Autowired - private MessageSource messageSource; - - @Override - public void apply(ParameterContext context) { - Optional apiParam = context.resolvedMethodParameter().findAnnotation(ApiParam.class); - context.parameterBuilder() - .allowableValues(allowableValues( - context.alternateFor(context.resolvedMethodParameter().getParameterType()), - apiParam.transform(toAllowableValue()).or(""))); - if (apiParam.isPresent()) { - Locale locale = LocaleContextHolder.getLocale(); - - ApiParam annotation = apiParam.get(); - context.parameterBuilder().name(emptyToNull(annotation.name())) - .description(emptyToNull(descriptions.resolve(messageSource.getMessage(annotation.value(), null, "",locale)))) - .parameterAccess(emptyToNull(annotation.access())) - .defaultValue(emptyToNull(annotation.defaultValue())) - .allowMultiple(annotation.allowMultiple()) - .allowEmptyValue(annotation.allowEmptyValue()) - .required(annotation.required()) - .scalarExample(new Example(annotation.example())) - .complexExamples(examples(annotation.examples())) - .hidden(annotation.hidden()) - .collectionFormat(annotation.collectionFormat()) - .order(SWAGGER_PLUGIN_ORDER); - } - } - - private Function toAllowableValue() { - return new Function() { - @Override - public String apply(ApiParam input) { - return input.allowableValues(); - } - }; - } - - private AllowableValues allowableValues(ResolvedType parameterType, String allowableValueString) { - AllowableValues allowableValues = null; - if (!isNullOrEmpty(allowableValueString)) { - allowableValues = ApiModelProperties.allowableValueFromString(allowableValueString); - } else { - if (enumTypeDeterminer.isEnum(parameterType.getErasedType())) { - allowableValues = Enums.allowableValues(parameterType.getErasedType()); - } - if (Collections.isContainerType(parameterType)) { - allowableValues = Enums.allowableValues(Collections.collectionElementType(parameterType).getErasedType()); - } - } - return allowableValues; - } - - @Override - public boolean supports(DocumentationType delimiter) { - return pluginDoesApply(delimiter); - } -} - diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiPlugin.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiPlugin.java deleted file mode 100644 index abc466cb54..0000000000 --- a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerApiPlugin.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package cn.escheduler.api.configuration; - -import io.swagger.annotations.Api; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.OperationBuilderPlugin; -import springfox.documentation.spi.service.contexts.OperationContext; - -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; - -@Component -@Order(Ordered.HIGHEST_PRECEDENCE - 10) -public class SwaggerApiPlugin implements OperationBuilderPlugin { - - private static final Logger logger = LoggerFactory.getLogger(SwaggerApiPlugin.class); - - @Autowired - private MessageSource messageSource; - - @Override - public void apply(OperationContext context) { - Locale locale = LocaleContextHolder.getLocale(); - - List list = context.findAllAnnotations(Api.class); - if (list.size() > 0) { - Api api = list.get(0); - - Set tagsSet = new HashSet<>(1); - - if(api.tags() != null && api.tags().length > 0){ - tagsSet.add(StringUtils.isNotBlank(api.tags()[0]) ? messageSource.getMessage(api.tags()[0], null, locale) : " "); - } - - context.operationBuilder().hidden(api.hidden()) - .tags(tagsSet).build(); - - } - - } - - - @Override - public boolean supports(DocumentationType delimiter) { - return true; - } - -} diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/AccessTokenController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/AccessTokenController.java index 27ac1772a0..f4aa138045 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/AccessTokenController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/AccessTokenController.java @@ -23,11 +23,16 @@ import cn.escheduler.api.service.UsersService; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -35,8 +40,9 @@ import static cn.escheduler.api.enums.Status.*; /** - * user controller + * access token controller */ +@Api(tags = "ACCESS_TOKEN_TAG", position = 1) @RestController @RequestMapping("/access-token") public class AccessTokenController extends BaseController{ @@ -53,9 +59,10 @@ public class AccessTokenController extends BaseController{ * @param loginUser * @return */ + @ApiIgnore @PostMapping(value = "/create") @ResponseStatus(HttpStatus.CREATED) - public Result createToken(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result createToken(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userId") int userId, @RequestParam(value = "expireTime") String expireTime, @RequestParam(value = "token") String token){ @@ -76,6 +83,7 @@ public class AccessTokenController extends BaseController{ * @param loginUser * @return */ + @ApiIgnore @PostMapping(value = "/generate") @ResponseStatus(HttpStatus.CREATED) public Result generateToken(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, @@ -100,9 +108,15 @@ public class AccessTokenController extends BaseController{ * @param pageSize * @return */ + @ApiOperation(value = "queryAccessTokenList", notes= "QUERY_ACCESS_TOKEN_LIST_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType ="String"), + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType ="Int",example = "20") + }) @GetMapping(value="/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryAccessTokenList(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryAccessTokenList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("pageNo") Integer pageNo, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize){ @@ -127,6 +141,7 @@ public class AccessTokenController extends BaseController{ * @param id * @return */ + @ApiIgnore @PostMapping(value = "/delete") @ResponseStatus(HttpStatus.OK) public Result delAccessTokenById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, @@ -147,6 +162,7 @@ public class AccessTokenController extends BaseController{ * @param loginUser * @return */ + @ApiIgnore @PostMapping(value = "/update") @ResponseStatus(HttpStatus.CREATED) public Result updateToken(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/AlertGroupController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/AlertGroupController.java index 759f9009e2..1dfb6a6cd9 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/AlertGroupController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/AlertGroupController.java @@ -26,12 +26,17 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.HashMap; import java.util.Map; import static cn.escheduler.api.enums.Status.*; +/** + * alert group controller + */ +@ApiIgnore @RestController @RequestMapping("alert-group") public class AlertGroupController extends BaseController{ diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/DataAnalysisController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/DataAnalysisController.java index 568af1f173..37a84f26cf 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/DataAnalysisController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/DataAnalysisController.java @@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -34,6 +35,7 @@ import static cn.escheduler.api.enums.Status.*; /** * data analysis controller */ +@ApiIgnore @RestController @RequestMapping("projects/analysis") public class DataAnalysisController extends BaseController{ diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/DataSourceController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/DataSourceController.java index be8149b18a..d13da8b117 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/DataSourceController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/DataSourceController.java @@ -22,11 +22,16 @@ import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.common.enums.DbType; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -36,6 +41,7 @@ import static cn.escheduler.api.enums.Status.*; /** * data source controller */ +@Api(tags = "DATA_SOURCE_TAG", position = 1) @RestController @RequestMapping("datasources") public class DataSourceController extends BaseController { @@ -56,9 +62,21 @@ public class DataSourceController extends BaseController { * @param other * @return */ + @ApiOperation(value = "createDataSource", notes= "CREATE_DATA_SOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "DATA_SOURCE_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "note", value = "DATA_SOURCE_NOTE", dataType = "String"), + @ApiImplicitParam(name = "type", value = "DB_TYPE", required = true,dataType ="DbType"), + @ApiImplicitParam(name = "host", value = "DATA_SOURCE_HOST",required = true, dataType ="String"), + @ApiImplicitParam(name = "port", value = "DATA_SOURCE_PORT",required = true, dataType ="String"), + @ApiImplicitParam(name = "database", value = "DATABASE_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "userName", value = "USER_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "password", value = "PASSWORD", dataType ="String"), + @ApiImplicitParam(name = "other", value = "DATA_SOURCE_OTHER", dataType ="String") + }) @PostMapping(value = "/create") @ResponseStatus(HttpStatus.CREATED) - public Result createDataSource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result createDataSource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("name") String name, @RequestParam(value = "note", required = false) String note, @RequestParam(value = "type") DbType type, @@ -92,9 +110,22 @@ public class DataSourceController extends BaseController { * @param other * @return */ + @ApiOperation(value = "updateDataSource", notes= "UPDATE_DATA_SOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "DATA_SOURCE_ID", required = true, dataType ="Int", example = "100"), + @ApiImplicitParam(name = "name", value = "DATA_SOURCE_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "note", value = "DATA_SOURCE_NOTE", dataType = "String"), + @ApiImplicitParam(name = "type", value = "DB_TYPE", required = true,dataType ="DbType"), + @ApiImplicitParam(name = "host", value = "DATA_SOURCE_HOST",required = true, dataType ="String"), + @ApiImplicitParam(name = "port", value = "DATA_SOURCE_PORT",required = true, dataType ="String"), + @ApiImplicitParam(name = "database", value = "DATABASE_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "userName", value = "USER_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "password", value = "PASSWORD", dataType ="String"), + @ApiImplicitParam(name = "other", value = "DATA_SOURCE_OTHER", dataType ="String") + }) @PostMapping(value = "/update") @ResponseStatus(HttpStatus.OK) - public Result updateDataSource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result updateDataSource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("id") int id, @RequestParam("name") String name, @RequestParam(value = "note", required = false) String note, @@ -126,9 +157,14 @@ public class DataSourceController extends BaseController { * @param id * @return */ + @ApiOperation(value = "queryDataSource", notes= "QUERY_DATA_SOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "DATA_SOURCE_ID", required = true, dataType ="Int", example = "100") + + }) @PostMapping(value = "/update-ui") @ResponseStatus(HttpStatus.OK) - public Result queryDataSource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryDataSource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("id") int id) { logger.info("login user {}, query datasource: {}", loginUser.getUserName(), id); @@ -149,9 +185,13 @@ public class DataSourceController extends BaseController { * @param loginUser * @return */ + @ApiOperation(value = "queryDataSourceList", notes= "QUERY_DATA_SOURCE_LIST_BY_TYPE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "DB_TYPE", required = true,dataType ="DbType") + }) @GetMapping(value = "/list") @ResponseStatus(HttpStatus.OK) - public Result queryDataSourceList(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryDataSourceList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("type") DbType type) { try { Map result = dataSourceService.queryDataSourceList(loginUser, type.ordinal()); @@ -171,9 +211,15 @@ public class DataSourceController extends BaseController { * @param pageSize * @return */ + @ApiOperation(value = "queryDataSourceListPaging", notes= "QUERY_DATA_SOURCE_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType ="String"), + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType ="Int",example = "20") + }) @GetMapping(value = "/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryDataSourceListPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryDataSourceListPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) { @@ -200,9 +246,21 @@ public class DataSourceController extends BaseController { * @param other * @return */ + @ApiOperation(value = "connectDataSource", notes= "CONNECT_DATA_SOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "DATA_SOURCE_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "note", value = "DATA_SOURCE_NOTE", dataType = "String"), + @ApiImplicitParam(name = "type", value = "DB_TYPE", required = true,dataType ="DbType"), + @ApiImplicitParam(name = "host", value = "DATA_SOURCE_HOST",required = true, dataType ="String"), + @ApiImplicitParam(name = "port", value = "DATA_SOURCE_PORT",required = true, dataType ="String"), + @ApiImplicitParam(name = "database", value = "DATABASE_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "userName", value = "USER_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "password", value = "PASSWORD", dataType ="String"), + @ApiImplicitParam(name = "other", value = "DATA_SOURCE_OTHER", dataType ="String") + }) @PostMapping(value = "/connect") @ResponseStatus(HttpStatus.OK) - public Result connectDataSource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result connectDataSource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("name") String name, @RequestParam(value = "note", required = false) String note, @RequestParam(value = "type") DbType type, @@ -237,9 +295,13 @@ public class DataSourceController extends BaseController { * @param loginUser * @return */ + @ApiOperation(value = "connectionTest", notes= "CONNECT_DATA_SOURCE_TEST_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "DATA_SOURCE_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/connect-by-id") @ResponseStatus(HttpStatus.OK) - public Result connectionTest(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result connectionTest(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("id") int id) { logger.info("connection test, login user:{}, id:{}", loginUser.getUserName(), id); @@ -267,9 +329,13 @@ public class DataSourceController extends BaseController { * @param id datasource id * @return */ + @ApiOperation(value = "delete", notes= "DELETE_DATA_SOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "DATA_SOURCE_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/delete") @ResponseStatus(HttpStatus.OK) - public Result delete(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result delete(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("id") int id) { try { logger.info("delete datasource,login user:{}, id:{}", loginUser.getUserName(), id); @@ -287,9 +353,13 @@ public class DataSourceController extends BaseController { * @param name * @return */ + @ApiOperation(value = "verifyDataSourceName", notes= "VERIFY_DATA_SOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "DATA_SOURCE_NAME", required = true, dataType ="String") + }) @GetMapping(value = "/verify-name") @ResponseStatus(HttpStatus.OK) - public Result verifyDataSourceName(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result verifyDataSourceName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "name") String name ) { logger.info("login user {}, verfiy datasource name: {}", @@ -312,9 +382,13 @@ public class DataSourceController extends BaseController { * @param userId * @return */ + @ApiOperation(value = "unauthDatasource", notes= "UNAUTHORIZED_DATA_SOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/unauth-datasource") @ResponseStatus(HttpStatus.OK) - public Result unauthDatasource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result unauthDatasource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { try { logger.info("unauthorized datasource, login user:{}, unauthorized userId:{}", @@ -335,9 +409,13 @@ public class DataSourceController extends BaseController { * @param userId * @return */ + @ApiOperation(value = "authedDatasource", notes= "AUTHORIZED_DATA_SOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/authed-datasource") @ResponseStatus(HttpStatus.OK) - public Result authedDatasource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result authedDatasource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { try { logger.info("authorized data source, login user:{}, authorized useId:{}", diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/ExecutorController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/ExecutorController.java index 6830e3c72d..d6872a278c 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/ExecutorController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/ExecutorController.java @@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -39,6 +40,7 @@ import static cn.escheduler.api.enums.Status.*; /** * execute task controller */ +@ApiIgnore @RestController @RequestMapping("projects/{projectName}/executors") public class ExecutorController extends BaseController { diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/LoggerController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/LoggerController.java index 00bc99df52..24d28b5473 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/LoggerController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/LoggerController.java @@ -57,9 +57,9 @@ public class LoggerController extends BaseController { */ @ApiOperation(value = "queryLog", notes= "QUERY_TASK_INSTANCE_LOG_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "taskInstId", value = "TASK_ID",type = "Int"), - @ApiImplicitParam(name = "skipLineNum", value = "SKIP_LINE_NUM", type ="Int"), - @ApiImplicitParam(name = "limit", value = "LIMIT", type ="Int") + @ApiImplicitParam(name = "taskInstId", value = "TASK_ID", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "skipLineNum", value = "SKIP_LINE_NUM", dataType ="Int", example = "100"), + @ApiImplicitParam(name = "limit", value = "LIMIT", dataType ="Int", example = "100") }) @GetMapping(value = "/detail") @ResponseStatus(HttpStatus.OK) @@ -87,11 +87,11 @@ public class LoggerController extends BaseController { */ @ApiOperation(value = "downloadTaskLog", notes= "DOWNLOAD_TASK_INSTANCE_LOG_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "taskInstId", value = "TASK_ID",type = "Int") + @ApiImplicitParam(name = "taskInstId", value = "TASK_ID",dataType = "Int", example = "100") }) @GetMapping(value = "/download-log") @ResponseBody - public ResponseEntity downloadTaskLog(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public ResponseEntity downloadTaskLog(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "taskInstId") int taskInstanceId) { try { byte[] logBytes = loggerService.getLogBytes(taskInstanceId); diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/LoginController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/LoginController.java index 1855800ea5..f5521c6293 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/LoginController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/LoginController.java @@ -29,6 +29,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; @@ -36,6 +37,8 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.Locale; + import static cn.escheduler.api.enums.Status.*; /** @@ -43,9 +46,9 @@ import static cn.escheduler.api.enums.Status.*; * * swagger bootstrap ui docs refer : https://doc.xiaominfo.com/guide/enh-func.html */ +@Api(tags = "LOGIN_TAG", position = 1) @RestController @RequestMapping("") -@Api(tags = "LOGIN_TAG", position = 1) public class LoginController extends BaseController { private static final Logger logger = LoggerFactory.getLogger(LoginController.class); @@ -69,8 +72,8 @@ public class LoginController extends BaseController { */ @ApiOperation(value = "login", notes= "LOGIN_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, type = "String"), - @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", required = true, type ="String") + @ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, dataType = "String"), + @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", required = true, dataType ="String") }) @PostMapping(value = "/login") public Result login(@RequestParam(value = "userName") String userName, diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/MonitorController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/MonitorController.java index 602dd4f270..666126c0c9 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/MonitorController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/MonitorController.java @@ -22,11 +22,16 @@ import cn.escheduler.api.service.ServerService; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -36,6 +41,7 @@ import static cn.escheduler.api.enums.Status.*; /** * monitor controller */ +@Api(tags = "MONITOR_TAG", position = 1) @RestController @RequestMapping("/monitor") public class MonitorController extends BaseController{ @@ -53,9 +59,10 @@ public class MonitorController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "listMaster", notes= "MASTER_LIST_NOTES") @GetMapping(value = "/master/list") @ResponseStatus(HttpStatus.OK) - public Result listMaster(@RequestAttribute(value = Constants.SESSION_USER) User loginUser) { + public Result listMaster(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { logger.info("login user: {}, query all master", loginUser.getUserName()); try{ logger.info("list master, user:{}", loginUser.getUserName()); @@ -73,9 +80,10 @@ public class MonitorController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "listWorker", notes= "WORKER_LIST_NOTES") @GetMapping(value = "/worker/list") @ResponseStatus(HttpStatus.OK) - public Result listWorker(@RequestAttribute(value = Constants.SESSION_USER) User loginUser) { + public Result listWorker(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { logger.info("login user: {}, query all workers", loginUser.getUserName()); try{ Map result = serverService.queryWorker(loginUser); @@ -92,9 +100,10 @@ public class MonitorController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "queryDatabaseState", notes= "QUERY_DATABASE_STATE_NOTES") @GetMapping(value = "/database") @ResponseStatus(HttpStatus.OK) - public Result queryDatabaseState(@RequestAttribute(value = Constants.SESSION_USER) User loginUser) { + public Result queryDatabaseState(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { logger.info("login user: {}, query database state", loginUser.getUserName()); try{ @@ -112,9 +121,10 @@ public class MonitorController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "queryZookeeperState", notes= "QUERY_ZOOKEEPER_STATE_NOTES") @GetMapping(value = "/zookeeper/list") @ResponseStatus(HttpStatus.OK) - public Result queryZookeeperState(@RequestAttribute(value = Constants.SESSION_USER) User loginUser) { + public Result queryZookeeperState(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { logger.info("login user: {}, query zookeeper state", loginUser.getUserName()); try{ Map result = monitorService.queryZookeeperState(loginUser); diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java index f928b257c1..74b77d6d72 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java @@ -130,7 +130,7 @@ public class ProcessDefinitionController extends BaseController{ @ApiOperation(value = "updateProccessDefinition", notes= "UPDATE_PROCCESS_DEFINITION_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "name", value = "PROCESS_DEFINITION_NAME", required = true, type = "String"), - @ApiImplicitParam(name = "id", value = "PROCESS_DEFINITION_ID", required = true, type = "Int"), + @ApiImplicitParam(name = "id", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "processDefinitionJson", value = "PROCESS_DEFINITION_JSON", required = true, type ="String"), @ApiImplicitParam(name = "locations", value = "PROCESS_DEFINITION_LOCATIONS", required = true, type ="String"), @ApiImplicitParam(name = "connects", value = "PROCESS_DEFINITION_CONNECTS", required = true, type ="String"), @@ -172,8 +172,8 @@ public class ProcessDefinitionController extends BaseController{ @ApiOperation(value = "releaseProccessDefinition", notes= "RELEASE_PROCCESS_DEFINITION_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "name", value = "PROCESS_DEFINITION_NAME", required = true, type = "String"), - @ApiImplicitParam(name = "processId", value = "PROCESS_DEFINITION_ID", required = true, type = "Int"), - @ApiImplicitParam(name = "releaseState", value = "PROCESS_DEFINITION_CONNECTS", required = true, type ="Int"), + @ApiImplicitParam(name = "processId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"), + @ApiImplicitParam(name = "releaseState", value = "PROCESS_DEFINITION_CONNECTS", required = true, dataType = "Int", example = "100"), }) @PostMapping(value = "/release") @ResponseStatus(HttpStatus.OK) @@ -204,7 +204,7 @@ public class ProcessDefinitionController extends BaseController{ */ @ApiOperation(value = "queryProccessDefinitionById", notes= "QUERY_PROCCESS_DEFINITION_BY_ID_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processId", value = "PROCESS_DEFINITION_ID", required = true, type = "Int") + @ApiImplicitParam(name = "processId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100") }) @GetMapping(value="/select-by-id") @ResponseStatus(HttpStatus.OK) @@ -258,10 +258,10 @@ public class ProcessDefinitionController extends BaseController{ */ @ApiOperation(value = "queryProcessDefinitionListPaging", notes= "QUERY_PROCCESS_DEFINITION_LIST_PAGING_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, type = "Int"), + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", required = false, type = "String"), - @ApiImplicitParam(name = "userId", value = "USER_ID", required = false, type = "Int"), - @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, type = "Int") + @ApiImplicitParam(name = "userId", value = "USER_ID", required = false, dataType = "Int", example = "100"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "100") }) @GetMapping(value="/list-paging") @ResponseStatus(HttpStatus.OK) @@ -296,8 +296,8 @@ public class ProcessDefinitionController extends BaseController{ */ @ApiOperation(value = "viewTree", notes= "VIEW_TREE_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processId", value = "PROCESS_DEFINITION_ID", required = true, type = "Int"), - @ApiImplicitParam(name = "limit", value = "LIMIT", required = true, type = "Int") + @ApiImplicitParam(name = "processId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"), + @ApiImplicitParam(name = "limit", value = "LIMIT", required = true, dataType = "Int", example = "100") }) @GetMapping(value="/view-tree") @ResponseStatus(HttpStatus.OK) @@ -327,7 +327,7 @@ public class ProcessDefinitionController extends BaseController{ */ @ApiOperation(value = "getNodeListByDefinitionId", notes= "GET_NODE_LIST_BY_DEFINITION_ID_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, type = "Int") + @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100") }) @GetMapping(value="gen-task-list") @ResponseStatus(HttpStatus.OK) diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessInstanceController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessInstanceController.java index 1c36e7ca3e..e05565c90f 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessInstanceController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessInstanceController.java @@ -60,14 +60,14 @@ public class ProcessInstanceController extends BaseController{ */ @ApiOperation(value = "queryProcessInstanceList", notes= "QUERY_PROCESS_INSTANCE_LIST_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", type = "Int"), + @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type ="String"), @ApiImplicitParam(name = "stateType", value = "EXECUTION_STATUS", type ="ExecutionStatus"), @ApiImplicitParam(name = "host", value = "HOST", type ="String"), @ApiImplicitParam(name = "startDate", value = "START_DATE", type ="String"), @ApiImplicitParam(name = "endDate", value = "END_DATE", type ="String"), - @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", type ="Int"), - @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", type ="Int") + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100") }) @GetMapping(value="list-paging") @ResponseStatus(HttpStatus.OK) @@ -105,7 +105,7 @@ public class ProcessInstanceController extends BaseController{ */ @ApiOperation(value = "queryTaskListByProcessId", notes= "QUERY_TASK_LIST_BY_PROCESS_INSTANCE_ID_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", type = "Int") + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") }) @GetMapping(value="/task-list-by-process-id") @ResponseStatus(HttpStatus.OK) @@ -139,7 +139,7 @@ public class ProcessInstanceController extends BaseController{ @ApiOperation(value = "updateProcessInstance", notes= "UPDATE_PROCESS_INSTANCE_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "processInstanceJson", value = "PROCESS_INSTANCE_JSON", type = "String"), - @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", type = "Int"), + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "scheduleTime", value = "SCHEDULE_TIME", type = "String"), @ApiImplicitParam(name = "syncDefine", value = "SYNC_DEFINE", type = "Boolean"), @ApiImplicitParam(name = "locations", value = "PROCESS_INSTANCE_LOCATIONS", type = "String"), @@ -182,7 +182,7 @@ public class ProcessInstanceController extends BaseController{ */ @ApiOperation(value = "queryProcessInstanceById", notes= "QUERY_PROCESS_INSTANCE_BY_ID_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", type = "Int") + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") }) @GetMapping(value="/select-by-id") @ResponseStatus(HttpStatus.OK) @@ -212,7 +212,7 @@ public class ProcessInstanceController extends BaseController{ */ @ApiOperation(value = "deleteProcessInstanceById", notes= "DELETE_PROCESS_INSTANCE_BY_ID_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", type = "Int") + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") }) @GetMapping(value="/delete") @ResponseStatus(HttpStatus.OK) @@ -241,7 +241,7 @@ public class ProcessInstanceController extends BaseController{ */ @ApiOperation(value = "querySubProcessInstanceByTaskId", notes= "QUERY_SUBPROCESS_INSTANCE_BY_TASK_ID_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "taskId", value = "TASK_ID", type = "Int") + @ApiImplicitParam(name = "taskId", value = "TASK_ID", dataType = "Int", example = "100") }) @GetMapping(value="/select-sub-process") @ResponseStatus(HttpStatus.OK) @@ -267,7 +267,7 @@ public class ProcessInstanceController extends BaseController{ */ @ApiOperation(value = "queryParentInstanceBySubId", notes= "QUERY_PARENT_PROCESS_INSTANCE_BY_SUB_PROCESS_INSTANCE_ID_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "subId", value = "SUB_PROCESS_INSTANCE_ID", type = "Int") + @ApiImplicitParam(name = "subId", value = "SUB_PROCESS_INSTANCE_ID", dataType = "Int", example = "100") }) @GetMapping(value="/select-parent-process") @ResponseStatus(HttpStatus.OK) @@ -292,7 +292,7 @@ public class ProcessInstanceController extends BaseController{ */ @ApiOperation(value = "viewVariables", notes= "QUERY_PROCESS_INSTANCE_GLOBAL_VARIABLES_AND_LOCAL_VARIABLES_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", type = "Int") + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") }) @GetMapping(value="/view-variables") @ResponseStatus(HttpStatus.OK) @@ -317,7 +317,7 @@ public class ProcessInstanceController extends BaseController{ */ @ApiOperation(value = "vieGanttTree", notes= "VIEW_GANTT_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", type = "Int") + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") }) @GetMapping(value="/view-gantt") @ResponseStatus(HttpStatus.OK) diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProjectController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProjectController.java index b6ca222adc..5ecb16d740 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/ProjectController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/ProjectController.java @@ -22,11 +22,16 @@ import cn.escheduler.api.service.ProjectService; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -35,6 +40,7 @@ import static cn.escheduler.api.enums.Status.*; /** * project controller */ +@Api(tags = "PROJECT_TAG", position = 1) @RestController @RequestMapping("projects") public class ProjectController extends BaseController { @@ -52,9 +58,14 @@ public class ProjectController extends BaseController { * @param desc * @return returns an error if it exists */ + @ApiOperation(value = "createProject", notes= "CREATE_PROJECT_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectName", value = "PROJECT_NAME", dataType ="String"), + @ApiImplicitParam(name = "desc", value = "PROJECT_DESC", dataType = "String") + }) @PostMapping(value = "/create") @ResponseStatus(HttpStatus.CREATED) - public Result createProject(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result createProject(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("projectName") String projectName, @RequestParam(value = "desc", required = false) String desc) { @@ -77,9 +88,15 @@ public class ProjectController extends BaseController { * @param desc * @return */ + @ApiOperation(value = "updateProject", notes= "UPDATE_PROJECT_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType ="Int", example = "100"), + @ApiImplicitParam(name = "projectName",value = "PROJECT_NAME",dataType = "String"), + @ApiImplicitParam(name = "desc", value = "PROJECT_DESC", dataType = "String") + }) @PostMapping(value = "/update") @ResponseStatus(HttpStatus.OK) - public Result updateProject(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result updateProject(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("projectId") Integer projectId, @RequestParam("projectName") String projectName, @RequestParam(value = "desc", required = false) String desc) { @@ -100,9 +117,13 @@ public class ProjectController extends BaseController { * @param projectId * @return */ + @ApiOperation(value = "queryProjectById", notes= "QUERY_PROJECT_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType ="Int", example = "100") + }) @GetMapping(value = "/query-by-id") @ResponseStatus(HttpStatus.OK) - public Result queryProjectById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryProjectById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("projectId") Integer projectId) { logger.info("login user {}, query project by id: {}", loginUser.getUserName(), projectId); @@ -124,9 +145,15 @@ public class ProjectController extends BaseController { * @param pageNo * @return */ + @ApiOperation(value = "queryProjectListPaging", notes= "QUERY_PROJECT_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType ="String"), + @ApiImplicitParam(name = "projectId", value = "PAGE_SIZE", dataType ="Int", example = "20"), + @ApiImplicitParam(name = "projectId", value = "PAGE_NO", dataType ="Int", example = "1") + }) @GetMapping(value = "/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryProjectListPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryProjectListPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize, @RequestParam("pageNo") Integer pageNo @@ -149,9 +176,13 @@ public class ProjectController extends BaseController { * @param projectId * @return */ + @ApiOperation(value = "deleteProjectById", notes= "DELETE_PROJECT_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType ="Int", example = "100") + }) @GetMapping(value = "/delete") @ResponseStatus(HttpStatus.OK) - public Result deleteProject(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result deleteProject(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("projectId") Integer projectId ) { @@ -172,9 +203,13 @@ public class ProjectController extends BaseController { * @param userId * @return */ + @ApiOperation(value = "queryUnauthorizedProject", notes= "QUERY_UNAUTHORIZED_PROJECT_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID", dataType ="Int", example = "100") + }) @GetMapping(value = "/unauth-project") @ResponseStatus(HttpStatus.OK) - public Result queryUnauthorizedProject(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryUnauthorizedProject(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { try { logger.info("login user {}, query unauthorized project by user id: {}.", loginUser.getUserName(), userId); @@ -194,9 +229,13 @@ public class ProjectController extends BaseController { * @param userId * @return */ + @ApiOperation(value = "queryAuthorizedProject", notes= "QUERY_AUTHORIZED_PROJECT_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID", dataType ="Int", example = "100") + }) @GetMapping(value = "/authed-project") @ResponseStatus(HttpStatus.OK) - public Result queryAuthorizedProject(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryAuthorizedProject(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { try { logger.info("login user {}, query authorized project by user id: {}.", loginUser.getUserName(), userId); diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/QueueController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/QueueController.java index 29c01a1483..3f0a02b07e 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/QueueController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/QueueController.java @@ -22,11 +22,16 @@ import cn.escheduler.api.service.QueueService; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -36,6 +41,7 @@ import static cn.escheduler.api.enums.Status.*; /** * queue controller */ +@Api(tags = "QUEUE_TAG", position = 1) @RestController @RequestMapping("/queue") public class QueueController extends BaseController{ @@ -51,9 +57,10 @@ public class QueueController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "queryList", notes= "QUERY_QUEUE_LIST_NOTES") @GetMapping(value="/list") @ResponseStatus(HttpStatus.OK) - public Result queryList(@RequestAttribute(value = Constants.SESSION_USER) User loginUser){ + public Result queryList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser){ try{ logger.info("login user {}, query queue list", loginUser.getUserName()); Map result = queueService.queryList(loginUser); @@ -69,9 +76,15 @@ public class QueueController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "queryQueueListPaging", notes= "QUERY_QUEUE_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType ="String"), + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType ="Int",example = "20") + }) @GetMapping(value="/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryQueueListPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryQueueListPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("pageNo") Integer pageNo, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize){ @@ -98,9 +111,14 @@ public class QueueController extends BaseController{ * @param queueName * @return */ + @ApiOperation(value = "createQueue", notes= "CREATE_QUEUE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "queue", value = "YARN_QUEUE_NAME", required = true,dataType ="String"), + @ApiImplicitParam(name = "queueName", value = "QUEUE_NAME",required = true, dataType ="String") + }) @PostMapping(value = "/create") @ResponseStatus(HttpStatus.CREATED) - public Result createQueue(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result createQueue(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "queue") String queue, @RequestParam(value = "queueName") String queueName) { logger.info("login user {}, create queue, queue: {}, queueName: {}", @@ -123,9 +141,15 @@ public class QueueController extends BaseController{ * @param queueName * @return */ + @ApiOperation(value = "updateQueue", notes= "UPDATE_QUEUE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "QUEUE_ID", required = true, dataType ="Int", example = "100"), + @ApiImplicitParam(name = "queue", value = "YARN_QUEUE_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "queueName", value = "QUEUE_NAME",required = true, dataType ="String") + }) @PostMapping(value = "/update") @ResponseStatus(HttpStatus.CREATED) - public Result updateQueue(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result updateQueue(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int id, @RequestParam(value = "queue") String queue, @RequestParam(value = "queueName") String queueName) { @@ -149,9 +173,15 @@ public class QueueController extends BaseController{ * @param queueName * @return */ + @ApiOperation(value = "verifyQueue", notes= "VERIFY_QUEUE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "QUEUE_ID", required = true, dataType ="Int", example = "100"), + @ApiImplicitParam(name = "queue", value = "YARN_QUEUE_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "queueName", value = "QUEUE_NAME",required = true, dataType ="String") + }) @PostMapping(value = "/verify-queue") @ResponseStatus(HttpStatus.OK) - public Result verifyQueue(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result verifyQueue(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value ="queue") String queue, @RequestParam(value ="queueName") String queueName ) { diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/ResourcesController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/ResourcesController.java index 12a03ca319..1ad481f0f1 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/ResourcesController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/ResourcesController.java @@ -24,6 +24,10 @@ import cn.escheduler.api.utils.Result; import cn.escheduler.common.enums.ResourceType; import cn.escheduler.common.enums.UdfType; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +38,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -42,6 +47,7 @@ import static cn.escheduler.api.enums.Status.*; /** * resources controller */ +@Api(tags = "RESOURCES_TAG", position = 1) @RestController @RequestMapping("resources") public class ResourcesController extends BaseController{ @@ -62,8 +68,15 @@ public class ResourcesController extends BaseController{ * @param desc * @param file */ + @ApiOperation(value = "createResource", notes= "CREATE_RESOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"), + @ApiImplicitParam(name = "name", value = "RESOURCE_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "des", value = "RESOURCE_DESC", dataType ="String"), + @ApiImplicitParam(name = "file", value = "RESOURCE_FILE", required = true, dataType = "MultipartFile") + }) @PostMapping(value = "/create") - public Result createResource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result createResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "type") ResourceType type, @RequestParam(value ="name")String alias, @RequestParam(value = "desc", required = false) String desc, @@ -85,8 +98,16 @@ public class ResourcesController extends BaseController{ * @param alias * @param desc */ + @ApiOperation(value = "createResource", notes= "CREATE_RESOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100"), + @ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"), + @ApiImplicitParam(name = "name", value = "RESOURCE_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "des", value = "RESOURCE_DESC", dataType ="String"), + @ApiImplicitParam(name = "file", value = "RESOURCE_FILE", required = true,dataType = "MultipartFile") + }) @PostMapping(value = "/update") - public Result updateResource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result updateResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value ="id") int resourceId, @RequestParam(value = "type") ResourceType type, @RequestParam(value ="name")String alias, @@ -107,10 +128,14 @@ public class ResourcesController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "querytResourceList", notes= "QUERY_RESOURCE_LIST_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType") + }) @GetMapping(value="/list") @ResponseStatus(HttpStatus.OK) - public Result querytResourceList(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @RequestParam(value ="type")ResourceType type + public Result querytResourceList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @RequestParam(value ="type") ResourceType type ){ try{ logger.info("query resource list, login user:{}, resource type:{}", loginUser.getUserName(), type.toString()); @@ -130,10 +155,17 @@ public class ResourcesController extends BaseController{ * @param pageSize * @return */ + @ApiOperation(value = "querytResourceListPaging", notes= "QUERY_RESOURCE_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"), + @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType ="String"), + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType ="Int",example = "20") + }) @GetMapping(value="/list-paging") @ResponseStatus(HttpStatus.OK) - public Result querytResourceListPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @RequestParam(value ="type")ResourceType type, + public Result querytResourceListPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @RequestParam(value ="type") ResourceType type, @RequestParam("pageNo") Integer pageNo, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize @@ -161,9 +193,13 @@ public class ResourcesController extends BaseController{ * @param loginUser * @param resourceId */ + @ApiOperation(value = "deleteResource", notes= "DELETE_RESOURCE_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/delete") @ResponseStatus(HttpStatus.OK) - public Result deleteResource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result deleteResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value ="id") int resourceId ) { try{ @@ -185,11 +221,16 @@ public class ResourcesController extends BaseController{ * @param type * @return */ + @ApiOperation(value = "verifyResourceName", notes= "VERIFY_RESOURCE_NAME_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"), + @ApiImplicitParam(name = "name", value = "RESOURCE_NAME", required = true, dataType ="String") + }) @GetMapping(value = "/verify-name") @ResponseStatus(HttpStatus.OK) - public Result verifyResourceName(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result verifyResourceName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value ="name") String alias, - @RequestParam(value ="type")ResourceType type + @RequestParam(value ="type") ResourceType type ) { try { logger.info("login user {}, verfiy resource alias: {},resource type: {}", @@ -208,8 +249,14 @@ public class ResourcesController extends BaseController{ * @param loginUser * @param resourceId */ + @ApiOperation(value = "viewResource", notes= "VIEW_RESOURCE_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100"), + @ApiImplicitParam(name = "skipLineNum", value = "SKIP_LINE_NUM", required = true, dataType ="Int", example = "100"), + @ApiImplicitParam(name = "limit", value = "LIMIT", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/view") - public Result viewResource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result viewResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int resourceId, @RequestParam(value = "skipLineNum") int skipLineNum, @RequestParam(value = "limit") int limit @@ -236,8 +283,16 @@ public class ResourcesController extends BaseController{ * @param content * @return */ + @ApiOperation(value = "onlineCreateResource", notes= "ONLINE_CREATE_RESOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = true, dataType ="ResourceType"), + @ApiImplicitParam(name = "fileName", value = "RESOURCE_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "suffix", value = "SUFFIX", required = true, dataType ="String"), + @ApiImplicitParam(name = "des", value = "RESOURCE_DESC", dataType ="String"), + @ApiImplicitParam(name = "content", value = "CONTENT",required = true, dataType ="String") + }) @PostMapping(value = "/online-create") - public Result onlineCreateResource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result onlineCreateResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "type") ResourceType type, @RequestParam(value ="fileName")String fileName, @RequestParam(value ="suffix")String fileSuffix, @@ -264,8 +319,13 @@ public class ResourcesController extends BaseController{ * @param loginUser * @param resourceId */ + @ApiOperation(value = "updateResourceContent", notes= "UPDATE_RESOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100"), + @ApiImplicitParam(name = "content", value = "CONTENT",required = true, dataType ="String") + }) @PostMapping(value = "/update-content") - public Result updateResourceContent(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result updateResourceContent(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int resourceId, @RequestParam(value = "content") String content ) { @@ -289,9 +349,13 @@ public class ResourcesController extends BaseController{ * @param loginUser * @param resourceId */ + @ApiOperation(value = "downloadResource", notes= "DOWNLOAD_RESOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/download") @ResponseBody - public ResponseEntity downloadResource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public ResponseEntity downloadResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int resourceId) { try{ logger.info("login user {}, download resource : {}", @@ -322,9 +386,20 @@ public class ResourcesController extends BaseController{ * @param resourceId * @return */ + @ApiOperation(value = "createUdfFunc", notes= "CREATE_UDF_FUNCTION_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "UDF_TYPE", required = true, dataType ="UdfType"), + @ApiImplicitParam(name = "funcName", value = "FUNC_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "suffix", value = "CLASS_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "argTypes", value = "ARG_TYPES", dataType ="String"), + @ApiImplicitParam(name = "database", value = "DATABASE_NAME", dataType ="String"), + @ApiImplicitParam(name = "desc", value = "UDF_DESC", dataType ="String"), + @ApiImplicitParam(name = "resourceId", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100") + + }) @PostMapping(value = "/udf-func/create") @ResponseStatus(HttpStatus.CREATED) - public Result createUdfFunc(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result createUdfFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "type") UdfType type, @RequestParam(value ="funcName")String funcName, @RequestParam(value ="className")String className, @@ -351,9 +426,14 @@ public class ResourcesController extends BaseController{ * @param id * @return */ + @ApiOperation(value = "viewUIUdfFunction", notes= "VIEW_UDF_FUNCTION_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "resourceId", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100") + + }) @GetMapping(value = "/udf-func/update-ui") @ResponseStatus(HttpStatus.OK) - public Result updateUIUdfFunction(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result viewUIUdfFunction(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("id") int id) { Result result = new Result(); @@ -380,8 +460,19 @@ public class ResourcesController extends BaseController{ * @param resourceId * @return */ + @ApiOperation(value = "updateUdfFunc", notes= "UPDATE_UDF_FUNCTION_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "UDF_TYPE", required = true, dataType ="UdfType"), + @ApiImplicitParam(name = "funcName", value = "FUNC_NAME",required = true, dataType ="String"), + @ApiImplicitParam(name = "suffix", value = "CLASS_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "argTypes", value = "ARG_TYPES", dataType ="String"), + @ApiImplicitParam(name = "database", value = "DATABASE_NAME", dataType ="String"), + @ApiImplicitParam(name = "desc", value = "UDF_DESC", dataType ="String"), + @ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100") + + }) @PostMapping(value = "/udf-func/update") - public Result updateUdfFunc(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result updateUdfFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int udfFuncId, @RequestParam(value = "type") UdfType type, @RequestParam(value ="funcName")String funcName, @@ -409,9 +500,15 @@ public class ResourcesController extends BaseController{ * @param pageSize * @return */ + @ApiOperation(value = "queryUdfFuncListPaging", notes= "QUERY_UDF_FUNCTION_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType ="String"), + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType ="Int",example = "20") + }) @GetMapping(value="/udf-func/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryUdfFuncList(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryUdfFuncList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("pageNo") Integer pageNo, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize @@ -433,14 +530,18 @@ public class ResourcesController extends BaseController{ } /** - * query data resource by type + * query resource list by type * * @param loginUser * @return */ + @ApiOperation(value = "queryResourceList", notes= "QUERY_RESOURCE_LIST_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "UDF_TYPE", required = true, dataType ="UdfType") + }) @GetMapping(value="/udf-func/list") @ResponseStatus(HttpStatus.OK) - public Result queryResourceList(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryResourceList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("type") UdfType type){ try{ logger.info("query datasource list, user:{}, type:{}", loginUser.getUserName(), type.toString()); @@ -459,9 +560,14 @@ public class ResourcesController extends BaseController{ * @param name * @return */ + @ApiOperation(value = "verifyUdfFuncName", notes= "VERIFY_UDF_FUNCTION_NAME_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "FUNC_NAME",required = true, dataType ="String") + + }) @GetMapping(value = "/udf-func/verify-name") @ResponseStatus(HttpStatus.OK) - public Result verifyUdfFuncName(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result verifyUdfFuncName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value ="name") String name ) { logger.info("login user {}, verfiy udf function name: {}", @@ -482,9 +588,13 @@ public class ResourcesController extends BaseController{ * @param loginUser * @param udfFuncId */ + @ApiOperation(value = "deleteUdfFunc", notes= "DELETE_UDF_FUNCTION_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/udf-func/delete") @ResponseStatus(HttpStatus.OK) - public Result deleteUdfFunc(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result deleteUdfFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value ="id") int udfFuncId ) { try{ @@ -504,9 +614,13 @@ public class ResourcesController extends BaseController{ * @param userId * @return */ + @ApiOperation(value = "authorizedFile", notes= "AUTHORIZED_FILE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/authed-file") @ResponseStatus(HttpStatus.CREATED) - public Result authorizedFile(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result authorizedFile(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { try{ logger.info("authorized file resource, user: {}, user id:{}", loginUser.getUserName(), userId); @@ -526,9 +640,13 @@ public class ResourcesController extends BaseController{ * @param userId * @return */ + @ApiOperation(value = "unauthorizedFile", notes= "UNAUTHORIZED_FILE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/unauth-file") @ResponseStatus(HttpStatus.CREATED) - public Result unauthorizedFile(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result unauthorizedFile(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { try{ logger.info("resource unauthorized file, user:{}, unauthorized user id:{}", loginUser.getUserName(), userId); @@ -548,9 +666,13 @@ public class ResourcesController extends BaseController{ * @param userId * @return */ + @ApiOperation(value = "unauthUDFFunc", notes= "UNAUTHORIZED_UDF_FUNC_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/unauth-udf-func") @ResponseStatus(HttpStatus.CREATED) - public Result unauthUDFFunc(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result unauthUDFFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { try{ logger.info("unauthorized udf function, login user:{}, unauthorized user id:{}", loginUser.getUserName(), userId); @@ -571,9 +693,13 @@ public class ResourcesController extends BaseController{ * @param userId * @return */ + @ApiOperation(value = "authUDFFunc", notes= "AUTHORIZED_UDF_FUNC_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType ="Int", example = "100") + }) @GetMapping(value = "/authed-udf-func") @ResponseStatus(HttpStatus.CREATED) - public Result authorizedUDFFunction(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result authorizedUDFFunction(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("userId") Integer userId) { try{ logger.info("auth udf function, login user:{}, auth user id:{}", loginUser.getUserName(), userId); diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/SchedulerController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/SchedulerController.java index d860979d62..e7b602bf4b 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/SchedulerController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/SchedulerController.java @@ -70,14 +70,14 @@ public class SchedulerController extends BaseController { */ @ApiOperation(value = "createSchedule", notes= "CREATE_SCHEDULE_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, type = "Int"), - @ApiImplicitParam(name = "schedule", value = "SCHEDULE", type = "Int"), + @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"), + @ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "Int", example = "100"), @ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type ="WarningType"), - @ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", type ="Int"), + @ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type ="FailureStrategy"), @ApiImplicitParam(name = "receivers", value = "RECEIVERS", type ="String"), @ApiImplicitParam(name = "receiversCc", value = "RECEIVERS_CC", type ="String"), - @ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", type ="Int"), + @ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type ="Priority"), }) @PostMapping("/create") @@ -122,14 +122,14 @@ public class SchedulerController extends BaseController { */ @ApiOperation(value = "updateSchedule", notes= "UPDATE_SCHEDULE_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, type = "Int"), - @ApiImplicitParam(name = "schedule", value = "SCHEDULE", type = "Int"), + @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100"), + @ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "Int", example = "100"), @ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type ="WarningType"), - @ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", type ="Int"), + @ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type ="FailureStrategy"), @ApiImplicitParam(name = "receivers", value = "RECEIVERS", type ="String"), @ApiImplicitParam(name = "receiversCc", value = "RECEIVERS_CC", type ="String"), - @ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", type ="Int"), + @ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type ="Priority"), }) @PostMapping("/update") @@ -171,7 +171,7 @@ public class SchedulerController extends BaseController { */ @ApiOperation(value = "online", notes= "ONLINE_SCHEDULE_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, type = "Int") + @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100") }) @PostMapping("/online") public Result online(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @@ -199,7 +199,7 @@ public class SchedulerController extends BaseController { */ @ApiOperation(value = "offline", notes= "OFFLINE_SCHEDULE_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, type = "Int") + @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100") }) @PostMapping("/offline") public Result offline(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @@ -228,11 +228,11 @@ public class SchedulerController extends BaseController { */ @ApiOperation(value = "queryScheduleListPaging", notes= "QUERY_SCHEDULE_LIST_PAGING_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, type = "Int"), - @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true,type = "Int"), + @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100"), + @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true,dataType = "Int", example = "100"), @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type = "String"), - @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", type = "Int"), - @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", type = "Int") + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100") }) @GetMapping("/list-paging") diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/ServerController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/ServerController.java deleted file mode 100644 index 7362e43283..0000000000 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/ServerController.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package cn.escheduler.api.controller; - -import cn.escheduler.api.service.ServerService; -import cn.escheduler.api.utils.Constants; -import cn.escheduler.api.utils.Result; -import cn.escheduler.dao.model.User; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.*; - -import java.util.Map; - -import static cn.escheduler.api.enums.Status.LIST_MASTERS_ERROR; -import static cn.escheduler.api.enums.Status.LIST_WORKERS_ERROR; - -/** - * server controller - */ -@RestController -@RequestMapping("process") -public class ServerController extends BaseController{ - - private static final Logger logger = LoggerFactory.getLogger(ExecutorController.class); - - @Autowired - private ServerService serverService; - - /** - * master list - * @param loginUser - * @return - */ - @GetMapping(value = "/master/list") - @ResponseStatus(HttpStatus.OK) - public Result listMaster(@RequestAttribute(value = Constants.SESSION_USER) User loginUser) { - logger.info("login user: {}, query all master", loginUser.getUserName()); - try{ - logger.info("list master, user:{}", loginUser.getUserName()); - Map result = serverService.queryMaster(loginUser); - return returnDataList(result); - }catch (Exception e){ - logger.error(LIST_MASTERS_ERROR.getMsg(),e); - return error(LIST_MASTERS_ERROR.getCode(), - LIST_MASTERS_ERROR.getMsg()); - } - } - - - /** - * worker list - * @param loginUser - * @return - */ - @GetMapping(value = "/worker/list") - @ResponseStatus(HttpStatus.OK) - public Result listWorker(@RequestAttribute(value = Constants.SESSION_USER) User loginUser) { - logger.info("login user: {}, query all workers", loginUser.getUserName()); - try{ - Map result = serverService.queryWorker(loginUser); - return returnDataList(result); - }catch (Exception e){ - logger.error(LIST_WORKERS_ERROR.getMsg(),e); - return error(LIST_WORKERS_ERROR.getCode(), - LIST_WORKERS_ERROR.getMsg()); - } - } -} diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskInstanceController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskInstanceController.java index b249bf8e04..5b60b2326b 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskInstanceController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskInstanceController.java @@ -56,15 +56,15 @@ public class TaskInstanceController extends BaseController{ */ @ApiOperation(value = "queryTaskListPaging", notes= "QUERY_TASK_INSTANCE_LIST_PAGING_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID",required = false, type = "Int"), + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID",required = false, dataType = "Int", example = "100"), @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type ="String"), @ApiImplicitParam(name = "taskName", value = "TASK_NAME", type ="String"), @ApiImplicitParam(name = "stateType", value = "EXECUTION_STATUS", type ="ExecutionStatus"), @ApiImplicitParam(name = "host", value = "HOST", type ="String"), @ApiImplicitParam(name = "startDate", value = "START_DATE", type ="String"), @ApiImplicitParam(name = "endDate", value = "END_DATE", type ="String"), - @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", type ="Int"), - @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", type ="Int") + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100") }) @GetMapping("/list-paging") @ResponseStatus(HttpStatus.OK) diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskRecordController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskRecordController.java index 72d7c8dbfd..46afa1a814 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskRecordController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskRecordController.java @@ -21,19 +21,25 @@ import cn.escheduler.api.service.TaskRecordService; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; import static cn.escheduler.api.enums.Status.QUERY_TASK_RECORD_LIST_PAGING_ERROR; /** - * task record controller + * data quality controller */ +@ApiIgnore @RestController @RequestMapping("/projects/task-record") public class TaskRecordController extends BaseController{ @@ -53,7 +59,7 @@ public class TaskRecordController extends BaseController{ */ @GetMapping("/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryTaskRecordListPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryTaskRecordListPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "taskName", required = false) String taskName, @RequestParam(value = "state", required = false) String state, @RequestParam(value = "sourceTable", required = false) String sourceTable, @@ -85,7 +91,7 @@ public class TaskRecordController extends BaseController{ */ @GetMapping("/history-list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryHistoryTaskRecordListPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryHistoryTaskRecordListPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "taskName", required = false) String taskName, @RequestParam(value = "state", required = false) String state, @RequestParam(value = "sourceTable", required = false) String sourceTable, diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/TenantController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/TenantController.java index 2feb68783d..2db09c9a5d 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/TenantController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/TenantController.java @@ -22,11 +22,16 @@ import cn.escheduler.api.service.TenantService; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -36,6 +41,7 @@ import static cn.escheduler.api.enums.Status.*; /** * tenant controller */ +@Api(tags = "TENANT_TAG", position = 1) @RestController @RequestMapping("/tenant") public class TenantController extends BaseController{ @@ -56,9 +62,17 @@ public class TenantController extends BaseController{ * @param desc * @return */ + @ApiOperation(value = "createTenant", notes= "CREATE_TENANT_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "tenantCode", value = "TENANT_CODE", required = true, dataType = "String"), + @ApiImplicitParam(name = "tenantName", value = "TENANT_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "queueId", value = "QUEUE_ID", required = true, dataType ="Int",example = "100"), + @ApiImplicitParam(name = "desc", value = "TENANT_DESC", dataType ="String") + + }) @PostMapping(value = "/create") @ResponseStatus(HttpStatus.CREATED) - public Result createTenant(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result createTenant(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "tenantCode") String tenantCode, @RequestParam(value = "tenantName") String tenantName, @RequestParam(value = "queueId") int queueId, @@ -85,9 +99,15 @@ public class TenantController extends BaseController{ * @param pageSize * @return */ + @ApiOperation(value = "queryTenantlistPaging", notes= "QUERY_TENANT_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType ="String"), + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType ="Int",example = "20") + }) @GetMapping(value="/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryTenantlistPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryTenantlistPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("pageNo") Integer pageNo, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize){ @@ -113,9 +133,10 @@ public class TenantController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "queryTenantlist", notes= "QUERY_TENANT_LIST_NOTES") @GetMapping(value="/list") @ResponseStatus(HttpStatus.OK) - public Result queryTenantlist(@RequestAttribute(value = Constants.SESSION_USER) User loginUser){ + public Result queryTenantlist(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser){ logger.info("login user {}, query tenant list"); try{ Map result = tenantService.queryTenantList(loginUser); @@ -138,9 +159,18 @@ public class TenantController extends BaseController{ * @param desc * @return */ + @ApiOperation(value = "updateTenant", notes= "UPDATE_TENANT_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ID", value = "TENANT_ID", required = true, dataType ="Int", example = "100"), + @ApiImplicitParam(name = "tenantCode", value = "TENANT_CODE", required = true, dataType = "String"), + @ApiImplicitParam(name = "tenantName", value = "TENANT_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "queueId", value = "QUEUE_ID", required = true, dataType ="Int", example = "100"), + @ApiImplicitParam(name = "desc", value = "TENANT_DESC", type ="String") + + }) @PostMapping(value = "/update") @ResponseStatus(HttpStatus.OK) - public Result updateTenant(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result updateTenant(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int id, @RequestParam(value = "tenantCode") String tenantCode, @RequestParam(value = "tenantName") String tenantName, @@ -164,9 +194,14 @@ public class TenantController extends BaseController{ * @param id * @return */ + @ApiOperation(value = "deleteTenantById", notes= "DELETE_TENANT_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ID", value = "TENANT_ID", required = true, dataType ="Int", example = "100") + + }) @PostMapping(value = "/delete") @ResponseStatus(HttpStatus.OK) - public Result deleteTenantById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result deleteTenantById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int id) { logger.info("login user {}, delete tenant, tenantCode: {},", loginUser.getUserName(), id); try { @@ -186,9 +221,13 @@ public class TenantController extends BaseController{ * @param tenantCode * @return */ + @ApiOperation(value = "verifyTenantCode", notes= "VERIFY_TENANT_CODE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "tenantCode", value = "TENANT_CODE", required = true, dataType = "String") + }) @GetMapping(value = "/verify-tenant-code") @ResponseStatus(HttpStatus.OK) - public Result verifyTenantCode(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result verifyTenantCode(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value ="tenantCode") String tenantCode ) { diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/UsersController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/UsersController.java index ee2d564e88..6aa91651a0 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/UsersController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/UsersController.java @@ -66,10 +66,10 @@ public class UsersController extends BaseController{ @ApiImplicitParams({ @ApiImplicitParam(name = "userName", value = "USER_NAME",type = "String"), @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", type ="String"), - @ApiImplicitParam(name = "tenantId", value = "TENANT_ID", type ="Int"), - @ApiImplicitParam(name = "queue", value = "QUEUE", type ="Int"), - @ApiImplicitParam(name = "email", value = "EMAIL", type ="Int"), - @ApiImplicitParam(name = "phone", value = "PHONE", type ="Int") + @ApiImplicitParam(name = "tenantId", value = "TENANT_ID", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "queue", value = "QUEUE", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "email", value = "EMAIL", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "phone", value = "PHONE", dataType = "Int", example = "100") }) @PostMapping(value = "/create") @ResponseStatus(HttpStatus.CREATED) @@ -103,7 +103,7 @@ public class UsersController extends BaseController{ */ @ApiOperation(value = "queryUserList", notes= "QUERY_USER_LIST_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "pageNo", value = "PAGE_NO",type = "Int"), + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO",dataType = "Int", example = "100"), @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", type ="String"), @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type ="String") }) @@ -143,13 +143,13 @@ public class UsersController extends BaseController{ */ @ApiOperation(value = "updateUser", notes= "UPDATE_USER_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "USER_ID",type = "Int"), + @ApiImplicitParam(name = "id", value = "USER_ID",dataType = "Int", example = "100"), @ApiImplicitParam(name = "userName", value = "USER_NAME",type = "String"), @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", type ="String"), - @ApiImplicitParam(name = "tenantId", value = "TENANT_ID", type ="Int"), - @ApiImplicitParam(name = "queue", value = "QUEUE", type ="Int"), - @ApiImplicitParam(name = "email", value = "EMAIL", type ="Int"), - @ApiImplicitParam(name = "phone", value = "PHONE", type ="Int") + @ApiImplicitParam(name = "tenantId", value = "TENANT_ID", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "queue", value = "QUEUE", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "email", value = "EMAIL", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "phone", value = "PHONE", dataType = "Int", example = "100") }) @PostMapping(value = "/update") @ResponseStatus(HttpStatus.OK) @@ -180,7 +180,7 @@ public class UsersController extends BaseController{ */ @ApiOperation(value = "delUserById", notes= "DELETE_USER_BY_ID_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "USER_ID",type = "Int") + @ApiImplicitParam(name = "id", value = "USER_ID",dataType = "Int", example = "100") }) @PostMapping(value = "/delete") @ResponseStatus(HttpStatus.OK) @@ -205,7 +205,7 @@ public class UsersController extends BaseController{ */ @ApiOperation(value = "grantProject", notes= "GRANT_PROJECT_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", value = "USER_ID",type = "Int"), + @ApiImplicitParam(name = "userId", value = "USER_ID",dataType = "Int", example = "100"), @ApiImplicitParam(name = "projectIds", value = "PROJECT_IDS",type = "String") }) @PostMapping(value = "/grant-project") @@ -232,7 +232,7 @@ public class UsersController extends BaseController{ */ @ApiOperation(value = "grantResource", notes= "GRANT_RESOURCE_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", value = "USER_ID",type = "Int"), + @ApiImplicitParam(name = "userId", value = "USER_ID",dataType = "Int", example = "100"), @ApiImplicitParam(name = "resourceIds", value = "RESOURCE_IDS",type = "String") }) @PostMapping(value = "/grant-file") @@ -260,7 +260,7 @@ public class UsersController extends BaseController{ */ @ApiOperation(value = "grantUDFFunc", notes= "GRANT_UDF_FUNC_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", value = "USER_ID",type = "Int"), + @ApiImplicitParam(name = "userId", value = "USER_ID",dataType = "Int", example = "100"), @ApiImplicitParam(name = "udfIds", value = "UDF_IDS",type = "String") }) @PostMapping(value = "/grant-udf-func") @@ -289,7 +289,7 @@ public class UsersController extends BaseController{ */ @ApiOperation(value = "grantDataSource", notes= "GRANT_DATASOURCE_NOTES") @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", value = "USER_ID",type = "Int"), + @ApiImplicitParam(name = "userId", value = "USER_ID",dataType = "Int", example = "100"), @ApiImplicitParam(name = "datasourceIds", value = "DATASOURCE_IDS",type = "String") }) @PostMapping(value = "/grant-datasource") diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java index 4843a8083e..6a8b7a79dc 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java @@ -27,12 +27,14 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; /** * worker group controller */ +@ApiIgnore @RestController @RequestMapping("/worker-group") public class WorkerGroupController extends BaseController{ diff --git a/escheduler-api/src/main/resources/messages.properties b/escheduler-api/src/main/resources/messages.properties index e3a80c0e32..d83dd10de3 100644 --- a/escheduler-api/src/main/resources/messages.properties +++ b/escheduler-api/src/main/resources/messages.properties @@ -1,4 +1,86 @@ QUERY_SCHEDULE_LIST_NOTES=query schedule list +ACCESS_TOKEN_TAG=access token related operation +MONITOR_TAG=monitor related operation +MASTER_LIST_NOTES=master server list +WORKER_LIST_NOTES=worker server list +QUERY_DATABASE_STATE_NOTES=query database state +QUERY_ZOOKEEPER_STATE_NOTES=QUERY ZOOKEEPER STATE +TASK_STATE=task instance state +SOURCE_TABLE=SOURCE TABLE +DEST_TABLE=dest table +TASK_DATE=task date +QUERY_HISTORY_TASK_RECORD_LIST_PAGING_NOTES=query history task record list paging +DATA_SOURCE_TAG=data source related operation +CREATE_DATA_SOURCE_NOTES=create data source +DATA_SOURCE_NAME=data source name +DATA_SOURCE_NOTE=data source desc +DB_TYPE=database type +DATA_SOURCE_HOST=DATA SOURCE HOST +DATA_SOURCE_PORT=data source port +DATABASE_NAME=database name +QUEUE_TAG= +QUERY_QUEUE_LIST_NOTES= +QUERY_QUEUE_LIST_PAGING_NOTES= +CREATE_QUEUE_NOTES= +YARN_QUEUE_NAME= +QUEUE_ID= +TENANT_DESC= +QUERY_TENANT_LIST_PAGING_NOTES= +QUERY_TENANT_LIST_NOTES= +UPDATE_TENANT_NOTES= +DELETE_TENANT_NOTES= +RESOURCES_TAG= +CREATE_RESOURCE_NOTES= +RESOURCE_TYPE= +RESOURCE_NAME= +RESOURCE_DESC= +RESOURCE_FILE= +RESOURCE_ID= +QUERY_RESOURCE_LIST_NOTES= +DELETE_RESOURCE_BY_ID_NOTES= +VIEW_RESOURCE_BY_ID_NOTES= +ONLINE_CREATE_RESOURCE_NOTES= +SUFFIX= +CONTENT= +UPDATE_RESOURCE_NOTES= +DOWNLOAD_RESOURCE_NOTES= +CREATE_UDF_FUNCTION_NOTES= +UDF_TYPE= +FUNC_NAME= +CLASS_NAME= +ARG_TYPES= +UDF_DESC= +VIEW_UDF_FUNCTION_NOTES= +UPDATE_UDF_FUNCTION_NOTES= +QUERY_UDF_FUNCTION_LIST_PAGING_NOTES= +VERIFY_UDF_FUNCTION_NAME_NOTES= +DELETE_UDF_FUNCTION_NOTES= +AUTHORIZED_FILE_NOTES= +UNAUTHORIZED_FILE_NOTES= +AUTHORIZED_UDF_FUNC_NOTES= +UNAUTHORIZED_UDF_FUNC_NOTES= +VERIFY_QUEUE_NOTES= +TENANT_TAG= +CREATE_TENANT_NOTES= +TENANT_CODE= +TENANT_NAME= +QUEUE_NAME= +PASSWORD=password +DATA_SOURCE_OTHER=jdbc connection params, format:{"key1":"value1",...} +PROJECT_TAG=project related operation +CREATE_PROJECT_NOTES=create project +PROJECT_DESC=project description +UPDATE_PROJECT_NOTES=update project +PROJECT_ID=project id +QUERY_PROJECT_BY_ID_NOTES=query project info by project id +QUERY_PROJECT_LIST_PAGING_NOTES=QUERY PROJECT LIST PAGING +DELETE_PROJECT_BY_ID_NOTES=delete project by id +QUERY_UNAUTHORIZED_PROJECT_NOTES=query unauthorized project +QUERY_AUTHORIZED_PROJECT_NOTES=query authorized project +TASK_RECORD_TAG=task record related operation +QUERY_TASK_RECORD_LIST_PAGING_NOTES=query task record list paging +CREATE_TOKEN_NOTES=create token ,note: please login first +QUERY_ACCESS_TOKEN_LIST_NOTES=query access token list paging SCHEDULE=schedule WARNING_TYPE=warning type(sending strategy) WARNING_GROUP_ID=warning group id @@ -50,16 +132,16 @@ PAGE_SIZE=page size LIMIT=limit VIEW_TREE_NOTES=view tree GET_NODE_LIST_BY_DEFINITION_ID_NOTES=get task node list by process definition id -PROCESS_DEFINITION_ID_LIST=PROCESS DEFINITION ID LIST +PROCESS_DEFINITION_ID_LIST=process definition id list QUERY_PROCESS_INSTANCE_BY_ID_NOTES=query process instance by process instance id DELETE_PROCESS_INSTANCE_BY_ID_NOTES=delete process instance by process instance id -TASK_ID=TASK INSTANCE ID +TASK_ID=task instance id SKIP_LINE_NUM=skip line num -QUERY_TASK_INSTANCE_LOG_NOTES=QUERY TASK INSTANCE LOG +QUERY_TASK_INSTANCE_LOG_NOTES=query task instance log DOWNLOAD_TASK_INSTANCE_LOG_NOTES=download task instance log USERS_TAG=users related operation SCHEDULER_TAG=scheduler related operation -CREATE_SCHEDULE_NOTES=CREATE SCHEDULE +CREATE_SCHEDULE_NOTES=create schedule CREATE_USER_NOTES=create user TENANT_ID=tenant id QUEUE=queue @@ -80,7 +162,7 @@ ALERT_GROUP_ID=alert group id AUTHORIZED_USER_NOTES=authorized user GRANT_UDF_FUNC_NOTES=grant udf function UDF_IDS=udf ids(string format, multiple udf functions separated by ",") -GRANT_DATASOURCE_NOTES=GRANT DATASOURCE +GRANT_DATASOURCE_NOTES=grant datasource DATASOURCE_IDS=datasource ids(string format, multiple datasources separated by ",") QUERY_SUBPROCESS_INSTANCE_BY_TASK_ID_NOTES=query subprocess instance by task instance id QUERY_PARENT_PROCESS_INSTANCE_BY_SUB_PROCESS_INSTANCE_ID_NOTES=query parent process instance info by sub process instance id @@ -95,4 +177,15 @@ EXECUTION_STATUS=runing status for workflow and task nodes HOST=ip address of running task START_DATE=start date END_DATE=end date -QUERY_TASK_LIST_BY_PROCESS_INSTANCE_ID_NOTES=query task list by process instance id \ No newline at end of file +QUERY_TASK_LIST_BY_PROCESS_INSTANCE_ID_NOTES=query task list by process instance id +UPDATE_DATA_SOURCE_NOTES= +DATA_SOURCE_ID= +QUERY_DATA_SOURCE_NOTES= +QUERY_DATA_SOURCE_LIST_BY_TYPE_NOTES= +QUERY_DATA_SOURCE_LIST_PAGING_NOTES= +CONNECT_DATA_SOURCE_NOTES= +CONNECT_DATA_SOURCE_TEST_NOTES= +DELETE_DATA_SOURCE_NOTES= +VERIFY_DATA_SOURCE_NOTES= +UNAUTHORIZED_DATA_SOURCE_NOTES= +AUTHORIZED_DATA_SOURCE_NOTES= diff --git a/escheduler-api/src/main/resources/messages_en_US.properties b/escheduler-api/src/main/resources/messages_en_US.properties index a378223636..45a2e793df 100644 --- a/escheduler-api/src/main/resources/messages_en_US.properties +++ b/escheduler-api/src/main/resources/messages_en_US.properties @@ -1,4 +1,86 @@ QUERY_SCHEDULE_LIST_NOTES=query schedule list +ACCESS_TOKEN_TAG=access token related operation +MONITOR_TAG=monitor related operation +MASTER_LIST_NOTES=master server list +WORKER_LIST_NOTES=worker server list +QUERY_DATABASE_STATE_NOTES=query database state +QUERY_ZOOKEEPER_STATE_NOTES=QUERY ZOOKEEPER STATE +TASK_STATE=task instance state +SOURCE_TABLE=SOURCE TABLE +DEST_TABLE=dest table +TASK_DATE=task date +QUERY_HISTORY_TASK_RECORD_LIST_PAGING_NOTES=query history task record list paging +DATA_SOURCE_TAG=data source related operation +CREATE_DATA_SOURCE_NOTES=create data source +DATA_SOURCE_NAME=data source name +DATA_SOURCE_NOTE=data source desc +DB_TYPE=database type +DATA_SOURCE_HOST=DATA SOURCE HOST +DATA_SOURCE_PORT=data source port +DATABASE_NAME=database name +QUEUE_TAG=queue related operation +QUERY_QUEUE_LIST_NOTES=query queue list +QUERY_QUEUE_LIST_PAGING_NOTES=query queue list paging +CREATE_QUEUE_NOTES=create queue +YARN_QUEUE_NAME=yarn(hadoop) queue name +QUEUE_ID=queue id +TENANT_DESC=tenant desc +QUERY_TENANT_LIST_PAGING_NOTES=query tenant list paging +QUERY_TENANT_LIST_NOTES=query tenant list +UPDATE_TENANT_NOTES=update tenant +DELETE_TENANT_NOTES=delete tenant +RESOURCES_TAG=resource center related operation +CREATE_RESOURCE_NOTES=create resource +RESOURCE_TYPE=resource file type +RESOURCE_NAME=resource name +RESOURCE_DESC=resource file desc +RESOURCE_FILE=resource file +RESOURCE_ID=resource id +QUERY_RESOURCE_LIST_NOTES=query resource list +DELETE_RESOURCE_BY_ID_NOTES=delete resource by id +VIEW_RESOURCE_BY_ID_NOTES=view resource by id +ONLINE_CREATE_RESOURCE_NOTES=online create resource +SUFFIX=resource file suffix +CONTENT=resource file content +UPDATE_RESOURCE_NOTES=edit resource file online +DOWNLOAD_RESOURCE_NOTES=download resource file +CREATE_UDF_FUNCTION_NOTES=create udf function +UDF_TYPE=UDF type +FUNC_NAME=function name +CLASS_NAME=package and class name +ARG_TYPES=arguments +UDF_DESC=udf desc +VIEW_UDF_FUNCTION_NOTES=view udf function +UPDATE_UDF_FUNCTION_NOTES=update udf function +QUERY_UDF_FUNCTION_LIST_PAGING_NOTES=query udf function list paging +VERIFY_UDF_FUNCTION_NAME_NOTES=verify udf function name +DELETE_UDF_FUNCTION_NOTES=delete udf function +AUTHORIZED_FILE_NOTES=authorized file +UNAUTHORIZED_FILE_NOTES=unauthorized file +AUTHORIZED_UDF_FUNC_NOTES=authorized udf func +UNAUTHORIZED_UDF_FUNC_NOTES=unauthorized udf func +VERIFY_QUEUE_NOTES=verify queue +TENANT_TAG=tenant related operation +CREATE_TENANT_NOTES=create tenant +TENANT_CODE=tenant code +TENANT_NAME=tenant name +QUEUE_NAME=queue name +PASSWORD=password +DATA_SOURCE_OTHER=jdbc connection params, format:{"key1":"value1",...} +PROJECT_TAG=project related operation +CREATE_PROJECT_NOTES=create project +PROJECT_DESC=project description +UPDATE_PROJECT_NOTES=update project +PROJECT_ID=project id +QUERY_PROJECT_BY_ID_NOTES=query project info by project id +QUERY_PROJECT_LIST_PAGING_NOTES=QUERY PROJECT LIST PAGING +DELETE_PROJECT_BY_ID_NOTES=delete project by id +QUERY_UNAUTHORIZED_PROJECT_NOTES=query unauthorized project +QUERY_AUTHORIZED_PROJECT_NOTES=query authorized project +TASK_RECORD_TAG=task record related operation +QUERY_TASK_RECORD_LIST_PAGING_NOTES=query task record list paging +CREATE_TOKEN_NOTES=create token ,note: please login first +QUERY_ACCESS_TOKEN_LIST_NOTES=query access token list paging SCHEDULE=schedule WARNING_TYPE=warning type(sending strategy) WARNING_GROUP_ID=warning group id @@ -50,16 +132,16 @@ PAGE_SIZE=page size LIMIT=limit VIEW_TREE_NOTES=view tree GET_NODE_LIST_BY_DEFINITION_ID_NOTES=get task node list by process definition id -PROCESS_DEFINITION_ID_LIST=PROCESS DEFINITION ID LIST +PROCESS_DEFINITION_ID_LIST=process definition id list QUERY_PROCESS_INSTANCE_BY_ID_NOTES=query process instance by process instance id DELETE_PROCESS_INSTANCE_BY_ID_NOTES=delete process instance by process instance id -TASK_ID=TASK INSTANCE ID +TASK_ID=task instance id SKIP_LINE_NUM=skip line num -QUERY_TASK_INSTANCE_LOG_NOTES=QUERY TASK INSTANCE LOG +QUERY_TASK_INSTANCE_LOG_NOTES=query task instance log DOWNLOAD_TASK_INSTANCE_LOG_NOTES=download task instance log USERS_TAG=users related operation SCHEDULER_TAG=scheduler related operation -CREATE_SCHEDULE_NOTES=CREATE SCHEDULE +CREATE_SCHEDULE_NOTES=create schedule CREATE_USER_NOTES=create user TENANT_ID=tenant id QUEUE=queue @@ -80,7 +162,7 @@ ALERT_GROUP_ID=alert group id AUTHORIZED_USER_NOTES=authorized user GRANT_UDF_FUNC_NOTES=grant udf function UDF_IDS=udf ids(string format, multiple udf functions separated by ",") -GRANT_DATASOURCE_NOTES=GRANT DATASOURCE +GRANT_DATASOURCE_NOTES=grant datasource DATASOURCE_IDS=datasource ids(string format, multiple datasources separated by ",") QUERY_SUBPROCESS_INSTANCE_BY_TASK_ID_NOTES=query subprocess instance by task instance id QUERY_PARENT_PROCESS_INSTANCE_BY_SUB_PROCESS_INSTANCE_ID_NOTES=query parent process instance info by sub process instance id @@ -96,3 +178,14 @@ HOST=ip address of running task START_DATE=start date END_DATE=end date QUERY_TASK_LIST_BY_PROCESS_INSTANCE_ID_NOTES=query task list by process instance id +UPDATE_DATA_SOURCE_NOTES=update data source +DATA_SOURCE_ID=DATA SOURCE ID +QUERY_DATA_SOURCE_NOTES=query data source by id +QUERY_DATA_SOURCE_LIST_BY_TYPE_NOTES=query data source list by database type +QUERY_DATA_SOURCE_LIST_PAGING_NOTES=query data source list paging +CONNECT_DATA_SOURCE_NOTES=CONNECT DATA SOURCE +CONNECT_DATA_SOURCE_TEST_NOTES=connect data source test +DELETE_DATA_SOURCE_NOTES=delete data source +VERIFY_DATA_SOURCE_NOTES=verify data source +UNAUTHORIZED_DATA_SOURCE_NOTES=unauthorized data source +AUTHORIZED_DATA_SOURCE_NOTES=authorized data source diff --git a/escheduler-api/src/main/resources/messages_zh_CN.properties b/escheduler-api/src/main/resources/messages_zh_CN.properties index f55574a7f4..dc0ffb705f 100644 --- a/escheduler-api/src/main/resources/messages_zh_CN.properties +++ b/escheduler-api/src/main/resources/messages_zh_CN.properties @@ -1,4 +1,86 @@ QUERY_SCHEDULE_LIST_NOTES=查询定时列表 +ACCESS_TOKEN_TAG=access token相关操作,需要先登录 +MONITOR_TAG=监控相关操作 +MASTER_LIST_NOTES=master服务列表 +WORKER_LIST_NOTES=worker服务列表 +QUERY_DATABASE_STATE_NOTES=查询数据库状态 +QUERY_ZOOKEEPER_STATE_NOTES=查询Zookeeper状态 +TASK_STATE=任务实例状态 +SOURCE_TABLE=源表 +DEST_TABLE=目标表 +TASK_DATE=任务时间 +QUERY_HISTORY_TASK_RECORD_LIST_PAGING_NOTES=分页查询历史任务记录列表 +DATA_SOURCE_TAG=数据源相关操作 +CREATE_DATA_SOURCE_NOTES=创建数据源 +DATA_SOURCE_NAME=数据源名称 +DATA_SOURCE_NOTE=数据源描述 +DB_TYPE=数据源类型 +DATA_SOURCE_HOST=IP主机名 +DATA_SOURCE_PORT=数据源端口 +DATABASE_NAME=数据库名 +QUEUE_TAG=队列相关操作 +QUERY_QUEUE_LIST_NOTES=查询队列列表 +QUERY_QUEUE_LIST_PAGING_NOTES=分页查询队列列表 +CREATE_QUEUE_NOTES=创建队列 +YARN_QUEUE_NAME=hadoop yarn队列名 +QUEUE_ID=队列ID +TENANT_DESC=租户描述 +QUERY_TENANT_LIST_PAGING_NOTES=分页查询租户列表 +QUERY_TENANT_LIST_NOTES=查询租户列表 +UPDATE_TENANT_NOTES=更新租户 +DELETE_TENANT_NOTES=删除租户 +RESOURCES_TAG=资源中心相关操作 +CREATE_RESOURCE_NOTES=创建资源 +RESOURCE_TYPE=资源文件类型 +RESOURCE_NAME=资源文件名称 +RESOURCE_DESC=资源文件描述 +RESOURCE_FILE=资源文件 +RESOURCE_ID=资源ID +QUERY_RESOURCE_LIST_NOTES=查询资源列表 +DELETE_RESOURCE_BY_ID_NOTES=删除资源通过ID +VIEW_RESOURCE_BY_ID_NOTES=浏览资源通通过ID +ONLINE_CREATE_RESOURCE_NOTES=在线创建资源 +SUFFIX=资源文件后缀 +CONTENT=资源文件内容 +UPDATE_RESOURCE_NOTES=在线更新资源文件 +DOWNLOAD_RESOURCE_NOTES=下载资源文件 +CREATE_UDF_FUNCTION_NOTES=创建UDF函数 +UDF_TYPE=UDF类型 +FUNC_NAME=函数名称 +CLASS_NAME=包名类名 +ARG_TYPES=参数 +UDF_DESC=udf描述,使用说明 +VIEW_UDF_FUNCTION_NOTES=查看udf函数 +UPDATE_UDF_FUNCTION_NOTES=更新udf函数 +QUERY_UDF_FUNCTION_LIST_PAGING_NOTES=分页查询udf函数列表 +VERIFY_UDF_FUNCTION_NAME_NOTES=验证udf函数名 +DELETE_UDF_FUNCTION_NOTES=删除UDF函数 +AUTHORIZED_FILE_NOTES=授权文件 +UNAUTHORIZED_FILE_NOTES=取消授权文件 +AUTHORIZED_UDF_FUNC_NOTES=授权udf函数 +UNAUTHORIZED_UDF_FUNC_NOTES=取消udf函数授权 +VERIFY_QUEUE_NOTES=验证队列 +TENANT_TAG=租户相关操作 +CREATE_TENANT_NOTES=创建租户 +TENANT_CODE=租户编码 +TENANT_NAME=租户名称 +QUEUE_NAME=队列名 +PASSWORD=密码 +DATA_SOURCE_OTHER=jdbc连接参数,格式为:{"key1":"value1",...} +PROJECT_TAG=项目相关操作 +CREATE_PROJECT_NOTES=创建项目 +PROJECT_DESC=项目描述 +UPDATE_PROJECT_NOTES=更新项目 +PROJECT_ID=项目ID +QUERY_PROJECT_BY_ID_NOTES=通过项目ID查询项目信息 +QUERY_PROJECT_LIST_PAGING_NOTES=分页查询项目列表 +DELETE_PROJECT_BY_ID_NOTES=删除项目通过ID +QUERY_UNAUTHORIZED_PROJECT_NOTES=查询未授权的项目 +QUERY_AUTHORIZED_PROJECT_NOTES=查询授权项目 +TASK_RECORD_TAG=任务记录相关操作 +QUERY_TASK_RECORD_LIST_PAGING_NOTES=分页查询任务记录列表 +CREATE_TOKEN_NOTES=创建token,注意需要先登录 +QUERY_ACCESS_TOKEN_LIST_NOTES=分页查询access token列表 SCHEDULE=定时 WARNING_TYPE=发送策略 WARNING_GROUP_ID=发送组ID @@ -95,3 +177,14 @@ HOST=运行任务的主机IP地址 START_DATE=开始时间 END_DATE=结束时间 QUERY_TASK_LIST_BY_PROCESS_INSTANCE_ID_NOTES=通过流程实例ID查询任务列表 +UPDATE_DATA_SOURCE_NOTES=更新数据源 +DATA_SOURCE_ID=数据源ID +QUERY_DATA_SOURCE_NOTES=查询数据源通过ID +QUERY_DATA_SOURCE_LIST_BY_TYPE_NOTES=查询数据源列表通过数据源类型 +QUERY_DATA_SOURCE_LIST_PAGING_NOTES=分页查询数据源列表 +CONNECT_DATA_SOURCE_NOTES=连接数据源 +CONNECT_DATA_SOURCE_TEST_NOTES=连接数据源测试 +DELETE_DATA_SOURCE_NOTES=删除数据源 +VERIFY_DATA_SOURCE_NOTES=验证数据源 +UNAUTHORIZED_DATA_SOURCE_NOTES=未授权的数据源 +AUTHORIZED_DATA_SOURCE_NOTES=授权的数据源 From 20734d3ceab3cb98e2337e760b8bdf1a96d57b93 Mon Sep 17 00:00:00 2001 From: lidongdai Date: Sat, 25 May 2019 18:20:46 +0800 Subject: [PATCH 2/3] update api docs --- conf/escheduler.conf | 31 -- conf/install.sh | 310 ------------------ conf/run.sh | 105 ------ conf/zoo.cfg | 30 -- .../api/configuration/SwaggerConfig.java | 2 +- .../api/controller/AlertGroupController.java | 53 ++- .../controller/DataAnalysisController.java | 44 ++- .../api/controller/DataSourceController.java | 2 +- .../controller/TaskInstanceController.java | 4 +- .../api/controller/WorkerGroupController.java | 35 +- .../resources/{ => i18n}/messages.properties | 141 ++++---- .../{ => i18n}/messages_en_US.properties | 25 ++ .../{ => i18n}/messages_zh_CN.properties | 26 ++ escheduler-api/src/main/resources/logback.xml | 42 +++ 14 files changed, 292 insertions(+), 558 deletions(-) delete mode 100644 conf/escheduler.conf delete mode 100644 conf/install.sh delete mode 100644 conf/run.sh delete mode 100644 conf/zoo.cfg rename escheduler-api/src/main/resources/{ => i18n}/messages.properties (63%) rename escheduler-api/src/main/resources/{ => i18n}/messages_en_US.properties (87%) rename escheduler-api/src/main/resources/{ => i18n}/messages_zh_CN.properties (88%) create mode 100644 escheduler-api/src/main/resources/logback.xml diff --git a/conf/escheduler.conf b/conf/escheduler.conf deleted file mode 100644 index fa331e62f5..0000000000 --- a/conf/escheduler.conf +++ /dev/null @@ -1,31 +0,0 @@ -server { - listen 8888;# 访问端口 - server_name localhost; - #charset koi8-r; - #access_log /var/log/nginx/host.access.log main; - location / { - root /opt/escheduler/front/server; # 静态文件目录 - index index.html index.html; - } - location /escheduler { - proxy_pass http://127.0.0.1:12345; # 接口地址 - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header x_real_ipP $remote_addr; - proxy_set_header remote_addr $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_http_version 1.1; - proxy_connect_timeout 4s; - proxy_read_timeout 30s; - proxy_send_timeout 12s; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } - #error_page 404 /404.html; - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } -} diff --git a/conf/install.sh b/conf/install.sh deleted file mode 100644 index 10419b8f84..0000000000 --- a/conf/install.sh +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh - -workDir=`/opt/easyscheduler` -workDir=`cd ${workDir};pwd` - -#To be compatible with MacOS and Linux -txt="" -if [[ "$OSTYPE" == "darwin"* ]]; then - # Mac OSX - txt="''" -elif [[ "$OSTYPE" == "linux-gnu" ]]; then - # linux - txt="" -elif [[ "$OSTYPE" == "cygwin" ]]; then - # POSIX compatibility layer and Linux environment emulation for Windows - echo "Easy Scheduler not support Windows operating system" - exit 1 -elif [[ "$OSTYPE" == "msys" ]]; then - # Lightweight shell and GNU utilities compiled for Windows (part of MinGW) - echo "Easy Scheduler not support Windows operating system" - exit 1 -elif [[ "$OSTYPE" == "win32" ]]; then - echo "Easy Scheduler not support Windows operating system" - exit 1 -elif [[ "$OSTYPE" == "freebsd"* ]]; then - # ... - txt="" -else - # Unknown. - echo "Operating system unknown, please tell us(submit issue) for better service" - exit 1 -fi - -source ${workDir}/conf/config/run_config.conf -source ${workDir}/conf/config/install_config.conf - -# mysql配置 -# mysql 地址,端口 -mysqlHost="127.0.0.1:3306" - -# mysql 数据库名称 -mysqlDb="easyscheduler" - -# mysql 用户名 -mysqlUserName="easyscheduler" - -# mysql 密码 -mysqlPassword="easyschedulereasyscheduler" - -# conf/config/install_config.conf配置 -# 安装路径,不要当前路径(pwd)一样 -installPath="/opt/easyscheduler" - -# 部署用户 -deployUser="escheduler" - -# zk集群 -zkQuorum="192.168.xx.xx:2181,192.168.xx.xx:2181,192.168.xx.xx:2181" - -# 安装hosts -ips="ark0,ark1,ark2,ark3,ark4" - -# conf/config/run_config.conf配置 -# 运行Master的机器 -masters="ark0,ark1" - -# 运行Worker的机器 -workers="ark2,ark3,ark4" - -# 运行Alert的机器 -alertServer="ark3" - -# 运行Api的机器 -apiServers="ark1" - -# alert配置 -# 邮件协议 -mailProtocol="SMTP" - -# 邮件服务host -mailServerHost="smtp.exmail.qq.com" - -# 邮件服务端口 -mailServerPort="25" - -# 发送人 -mailSender="xxxxxxxxxx" - -# 发送人密码 -mailPassword="xxxxxxxxxx" - -# 下载Excel路径 -xlsFilePath="/tmp/xls" - - -# hadoop 配置 -# 是否启动hdfs,如果启动则为true,需要配置以下hadoop相关参数; -# 不启动设置为false,如果为false,以下配置不需要修改 -hdfsStartupSate="false" - -# namenode地址,支持HA,需要将core-site.xml和hdfs-site.xml放到conf目录下 -namenodeFs="hdfs://mycluster:8020" - -# resourcemanager HA配置,如果是单resourcemanager,这里为空即可 -yarnHaIps="192.168.xx.xx,192.168.xx.xx" - -# 如果是单 resourcemanager,只需要配置一个主机名称,如果是resourcemanager HA,则默认配置就好 -singleYarnIp="ark1" - -# hdfs根路径,根路径的owner必须是部署用户 -hdfsPath="/escheduler" - -# common 配置 -# 程序路径 -programPath="/tmp/escheduler" - -#下载路径 -downloadPath="/tmp/escheduler/download" - -# 任务执行路径 -execPath="/tmp/escheduler/exec" - -# SHELL环境变量路径 -shellEnvPath="$installPath/conf/env/.escheduler_env.sh" - -# Python换将变量路径 -pythonEnvPath="$installPath/conf/env/escheduler_env.py" - -# 资源文件的后缀 -resSuffixs="txt,log,sh,conf,cfg,py,java,sql,hql,xml" - -# 开发状态,如果是true,对于SHELL脚本可以在execPath目录下查看封装后的SHELL脚本,如果是false则执行完成直接删除 -devState="true" - -# zk 配置 -# zk根目录 -zkRoot="/escheduler" - -# 用来记录挂掉机器的zk目录 -zkDeadServers="/escheduler/dead-servers" - -# masters目录 -zkMasters="/escheduler/masters" - -# workers目录 -zkWorkers="/escheduler/workers" - -# zk master分布式锁 -mastersLock="/escheduler/lock/masters" - -# zk worker分布式锁 -workersLock="/escheduler/lock/workers" - -# zk master容错分布式锁 -mastersFailover="/escheduler/lock/failover/masters" - -# zk worker容错分布式锁 -workersFailover="/escheduler/lock/failover/masters" - -# zk session 超时 -zkSessionTimeout="300" - -# zk 连接超时 -zkConnectionTimeout="300" - -# zk 重试间隔 -zkRetrySleep="100" - -# zk重试最大次数 -zkRetryMaxtime="5" - - -# master 配置 -# master执行线程最大数,流程实例的最大并行度 -masterExecThreads="100" - -# master任务执行线程最大数,每一个流程实例的最大并行度 -masterExecTaskNum="20" - -# master心跳间隔 -masterHeartbeatInterval="10" - -# master任务提交重试次数 -masterTaskCommitRetryTimes="5" - -# master任务提交重试时间间隔 -masterTaskCommitInterval="100" - -# master最大cpu平均负载,用来判断master是否还有执行能力 -masterMaxCupLoadAvg="10" - -# master预留内存,用来判断master是否还有执行能力 -masterReservedMemory="1" - - -# worker 配置 -# worker执行线程 -workerExecThreads="100" - -# worker心跳间隔 -workerHeartbeatInterval="10" - -# worker一次抓取任务数 -workerFetchTaskNum="10" - -# worker最大cpu平均负载,用来判断master是否还有执行能力 -workerMaxCupLoadAvg="10" - -# worker预留内存,用来判断master是否还有执行能力 -workerReservedMemory="1" - -# api 配置 -# api 服务端口 -apiServerPort="12345" - -# api session 超时 -apiServerSessionTimeout="7200" - -# api 上下文路径 -apiServerContextPath="/escheduler/" - -# spring 最大文件大小 -springMaxFileSize="1024MB" - -# spring 最大请求文件大小 -springMaxRequestSize="1024MB" - -# api 最大post请求大小 -apiMaxHttpPostSize="5000000" - -# 1,替换文件 -echo "1,替换文件" -sed -i ${txt} "s#spring.datasource.url.*#spring.datasource.url=jdbc:mysql://${mysqlHost}/${mysqlDb}?characterEncoding=UTF-8#g" conf/dao/data_source.properties -sed -i ${txt} "s#spring.datasource.username.*#spring.datasource.username=${mysqlUserName}#g" conf/dao/data_source.properties -sed -i ${txt} "s#spring.datasource.password.*#spring.datasource.password=${mysqlPassword}#g" conf/dao/data_source.properties - -sed -i ${txt} "s#org.quartz.dataSource.myDs.URL.*#org.quartz.dataSource.myDs.URL=jdbc:mysql://${mysqlHost}/${mysqlDb}?characterEncoding=UTF-8#g" conf/quartz.properties -sed -i ${txt} "s#org.quartz.dataSource.myDs.user.*#org.quartz.dataSource.myDs.user=${mysqlUserName}#g" conf/quartz.properties -sed -i ${txt} "s#org.quartz.dataSource.myDs.password.*#org.quartz.dataSource.myDs.password=${mysqlPassword}#g" conf/quartz.properties - - -sed -i ${txt} "s#fs.defaultFS.*#fs.defaultFS=${namenodeFs}#g" conf/common/hadoop/hadoop.properties -sed -i ${txt} "s#yarn.resourcemanager.ha.rm.ids.*#yarn.resourcemanager.ha.rm.ids=${yarnHaIps}#g" conf/common/hadoop/hadoop.properties -sed -i ${txt} "s#yarn.application.status.address.*#yarn.application.status.address=http://${singleYarnIp}:8088/ws/v1/cluster/apps/%s#g" conf/common/hadoop/hadoop.properties - -sed -i ${txt} "s#data.basedir.path.*#data.basedir.path=${programPath}#g" conf/common/common.properties -sed -i ${txt} "s#data.download.basedir.path.*#data.download.basedir.path=${downloadPath}#g" conf/common/common.properties -sed -i ${txt} "s#process.exec.basepath.*#process.exec.basepath=${execPath}#g" conf/common/common.properties -sed -i ${txt} "s#data.store2hdfs.basepath.*#data.store2hdfs.basepath=${hdfsPath}#g" conf/common/common.properties -sed -i ${txt} "s#hdfs.startup.state.*#hdfs.startup.state=${hdfsStartupSate}#g" conf/common/common.properties -sed -i ${txt} "s#escheduler.env.path.*#escheduler.env.path=${shellEnvPath}#g" conf/common/common.properties -sed -i ${txt} "s#escheduler.env.py.*#escheduler.env.py=${pythonEnvPath}#g" conf/common/common.properties -sed -i ${txt} "s#resource.view.suffixs.*#resource.view.suffixs=${resSuffixs}#g" conf/common/common.properties -sed -i ${txt} "s#development.state.*#development.state=${devState}#g" conf/common/common.properties - -sed -i ${txt} "s#zookeeper.quorum.*#zookeeper.quorum=${zkQuorum}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.escheduler.root.*#zookeeper.escheduler.root=${zkRoot}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.escheduler.dead.servers.*#zookeeper.escheduler.dead.servers=${zkDeadServers}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.escheduler.masters.*#zookeeper.escheduler.masters=${zkMasters}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.escheduler.workers.*#zookeeper.escheduler.workers=${zkWorkers}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.escheduler.lock.masters.*#zookeeper.escheduler.lock.masters=${mastersLock}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.escheduler.lock.workers.*#zookeeper.escheduler.lock.workers=${workersLock}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.escheduler.lock.failover.masters.*#zookeeper.escheduler.lock.failover.masters=${mastersFailover}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.escheduler.lock.failover.workers.*#zookeeper.escheduler.lock.failover.workers=${workersFailover}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.session.timeout.*#zookeeper.session.timeout=${zkSessionTimeout}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.connection.timeout.*#zookeeper.connection.timeout=${zkConnectionTimeout}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.retry.sleep.*#zookeeper.retry.sleep=${zkRetrySleep}#g" conf/zookeeper.properties -sed -i ${txt} "s#zookeeper.retry.maxtime.*#zookeeper.retry.maxtime=${zkRetryMaxtime}#g" conf/zookeeper.properties - -sed -i ${txt} "s#master.exec.threads.*#master.exec.threads=${masterExecThreads}#g" conf/master.properties -sed -i ${txt} "s#master.exec.task.number.*#master.exec.task.number=${masterExecTaskNum}#g" conf/master.properties -sed -i ${txt} "s#master.heartbeat.interval.*#master.heartbeat.interval=${masterHeartbeatInterval}#g" conf/master.properties -sed -i ${txt} "s#master.task.commit.retryTimes.*#master.task.commit.retryTimes=${masterTaskCommitRetryTimes}#g" conf/master.properties -sed -i ${txt} "s#master.task.commit.interval.*#master.task.commit.interval=${masterTaskCommitInterval}#g" conf/master.properties -sed -i ${txt} "s#master.max.cpuload.avg.*#master.max.cpuload.avg=${masterMaxCupLoadAvg}#g" conf/master.properties -sed -i ${txt} "s#master.reserved.memory.*#master.reserved.memory=${masterReservedMemory}#g" conf/master.properties - - -sed -i ${txt} "s#worker.exec.threads.*#worker.exec.threads=${workerExecThreads}#g" conf/worker.properties -sed -i ${txt} "s#worker.heartbeat.interval.*#worker.heartbeat.interval=${workerHeartbeatInterval}#g" conf/worker.properties -sed -i ${txt} "s#worker.fetch.task.num.*#worker.fetch.task.num=${workerFetchTaskNum}#g" conf/worker.properties -sed -i ${txt} "s#worker.max.cpuload.avg.*#worker.max.cpuload.avg=${workerMaxCupLoadAvg}#g" conf/worker.properties -sed -i ${txt} "s#worker.reserved.memory.*#worker.reserved.memory=${workerReservedMemory}#g" conf/worker.properties - - -sed -i ${txt} "s#server.port.*#server.port=${apiServerPort}#g" conf/application.properties -sed -i ${txt} "s#server.session.timeout.*#server.session.timeout=${apiServerSessionTimeout}#g" conf/application.properties -sed -i ${txt} "s#server.context-path.*#server.context-path=${apiServerContextPath}#g" conf/application.properties -sed -i ${txt} "s#spring.http.multipart.max-file-size.*#spring.http.multipart.max-file-size=${springMaxFileSize}#g" conf/application.properties -sed -i ${txt} "s#spring.http.multipart.max-request-size.*#spring.http.multipart.max-request-size=${springMaxRequestSize}#g" conf/application.properties -sed -i ${txt} "s#server.max-http-post-size.*#server.max-http-post-size=${apiMaxHttpPostSize}#g" conf/application.properties - - -sed -i ${txt} "s#mail.protocol.*#mail.protocol=${mailProtocol}#g" conf/alert.properties -sed -i ${txt} "s#mail.server.host.*#mail.server.host=${mailServerHost}#g" conf/alert.properties -sed -i ${txt} "s#mail.server.port.*#mail.server.port=${mailServerPort}#g" conf/alert.properties -sed -i ${txt} "s#mail.sender.*#mail.sender=${mailSender}#g" conf/alert.properties -sed -i ${txt} "s#mail.passwd.*#mail.passwd=${mailPassword}#g" conf/alert.properties -sed -i ${txt} "s#xls.file.path.*#xls.file.path=${xlsFilePath}#g" conf/alert.properties - - -sed -i ${txt} "s#installPath.*#installPath=${installPath}#g" conf/config/install_config.conf -sed -i ${txt} "s#deployUser.*#deployUser=${deployUser}#g" conf/config/install_config.conf -sed -i ${txt} "s#ips.*#ips=${ips}#g" conf/config/install_config.conf - - -sed -i ${txt} "s#masters.*#masters=${masters}#g" conf/config/run_config.conf -sed -i ${txt} "s#workers.*#workers=${workers}#g" conf/config/run_config.conf -sed -i ${txt} "s#alertServer.*#alertServer=${alertServer}#g" conf/config/run_config.conf -sed -i ${txt} "s#apiServers.*#apiServers=${apiServers}#g" conf/config/run_config.conf diff --git a/conf/run.sh b/conf/run.sh deleted file mode 100644 index 3257b0e194..0000000000 --- a/conf/run.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh - -# execute any pre-init scripts -for i in /scripts/pre-init.d/*sh -do - if [ -e "${i}" ]; then - echo "[i] pre-init.d - processing $i" - . "${i}" - fi -done - -if [ -d "/run/mysqld" ]; then - echo "[i] mysqld already present, skipping creation" - chown -R mysql:mysql /run/mysqld -else - echo "[i] mysqld not found, creating...." - mkdir -p /run/mysqld - chown -R mysql:mysql /run/mysqld -fi - -if [ -d /var/lib/mysql/mysql ]; then - echo "[i] MySQL directory already present, skipping creation" - chown -R mysql:mysql /var/lib/mysql -else - echo "[i] MySQL data directory not found, creating initial DBs" - - chown -R mysql:mysql /var/lib/mysql - - mysql_install_db --user=mysql --ldata=/var/lib/mysql > /dev/null - - if [ "$MYSQL_ROOT_PASSWORD" = "" ]; then - MYSQL_ROOT_PASSWORD=`pwgen 16 1` - echo "[i] MySQL root Password: $MYSQL_ROOT_PASSWORD" - fi - - MYSQL_DATABASE="easyscheduler" - MYSQL_USER="easyscheduler" - MYSQL_PASSWORD="easyschedulereasyscheduler" - - tfile=`mktemp` - if [ ! -f "$tfile" ]; then - return 1 - fi - - cat << EOF > $tfile -USE mysql; -FLUSH PRIVILEGES ; -GRANT ALL ON *.* TO 'root'@'%' identified by '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION ; -GRANT ALL ON *.* TO 'root'@'localhost' identified by '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION ; -SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}') ; -DROP DATABASE IF EXISTS test ; -FLUSH PRIVILEGES ; -EOF - - if [ "$MYSQL_DATABASE" != "" ]; then - echo "[i] Creating database: $MYSQL_DATABASE" - echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET utf8 COLLATE utf8_general_ci;" >> $tfile - - if [ "$MYSQL_USER" != "" ]; then - echo "[i] Creating user: $MYSQL_USER with password $MYSQL_PASSWORD" - echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* to '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" >> $tfile - fi - fi - - /usr/bin/mysqld --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < $tfile - rm -f $tfile - - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sql) echo "$0: running $f"; /usr/bin/mysqld --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$f"; echo ;; - *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | /usr/bin/mysqld --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$f"; echo ;; - *) echo "$0: ignoring or entrypoint initdb empty $f" ;; - esac - echo - done - - echo - echo 'MySQL init process done. Ready for start up.' - echo - - echo "exec /usr/bin/mysqld --user=mysql --console --skip-name-resolve --skip-networking=0" "$@" -fi - -# execute any pre-exec scripts -for i in /scripts/pre-exec.d/*sh -do - if [ -e "${i}" ]; then - echo "[i] pre-exec.d - processing $i" - . ${i} - fi -done - -mysql -ueasyscheduler -peasyschedulereasyscheduler --one-database easyscheduler -h127.0.0.1 < /opt/easyscheduler/sql/escheduler.sql -mysql -ueasyscheduler -peasyschedulereasyscheduler --one-database easyscheduler -h127.0.0.1 < /opt/easyscheduler/sql/quartz.sql -source /etc/profile -zkServer.sh start -cd /opt/easyscheduler -rm -rf /etc/nginx/conf.d/default.conf -sh ./bin/escheduler-daemon.sh start master-server -sh ./bin/escheduler-daemon.sh start worker-server -sh ./bin/escheduler-daemon.sh start api-server -sh ./bin/escheduler-daemon.sh start logger-server -sh ./bin/escheduler-daemon.sh start alert-server -nginx -c /etc/nginx/nginx.conf -exec /usr/bin/mysqld --user=mysql --console --skip-name-resolve --skip-networking=0 $@ diff --git a/conf/zoo.cfg b/conf/zoo.cfg deleted file mode 100644 index 228b7224a0..0000000000 --- a/conf/zoo.cfg +++ /dev/null @@ -1,30 +0,0 @@ -# The number of milliseconds of each tick -tickTime=2000 -# The number of ticks that the initial -# synchronization phase can take -initLimit=10 -# The number of ticks that can pass between -# sending a request and getting an acknowledgement -syncLimit=5 -# the directory where the snapshot is stored. -# do not use /tmp for storage, /tmp here is just -# example sakes. -dataDir=/tmp/zookeeper -# the port at which the clients will connect -clientPort=2181 -# the maximum number of client connections. -# increase this if you need to handle more clients -#maxClientCnxns=60 -# -# Be sure to read the maintenance section of the -# administrator guide before turning on autopurge. -# -# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance -# -# The number of snapshots to retain in dataDir -#autopurge.snapRetainCount=3 -# Purge task interval in hours -# Set to "0" to disable auto purge feature -#autopurge.purgeInterval=1 -dataDir=/opt/zookeeper/data -dataLogDir=/opt/zookeeper/logs diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerConfig.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerConfig.java index f55d04ab92..fb332c5ac9 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerConfig.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerConfig.java @@ -48,7 +48,7 @@ public class SwaggerConfig implements WebMvcConfigurer { private ApiInfo apiInfo() { return new ApiInfoBuilder().title("Easy Scheduler Api Docs").description("Easy Scheduler Api Docs") - .version("1.0.0").build(); + .build(); } diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/AlertGroupController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/AlertGroupController.java index 1dfb6a6cd9..1feb310646 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/AlertGroupController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/AlertGroupController.java @@ -21,6 +21,10 @@ import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.common.enums.AlertType; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -36,7 +40,7 @@ import static cn.escheduler.api.enums.Status.*; /** * alert group controller */ -@ApiIgnore +@Api(tags = "ALERT_GROUP_TAG", position = 1) @RestController @RequestMapping("alert-group") public class AlertGroupController extends BaseController{ @@ -55,9 +59,15 @@ public class AlertGroupController extends BaseController{ * @param desc * @return */ + @ApiOperation(value = "createAlertgroup", notes= "CREATE_ALERT_GROUP_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"), + @ApiImplicitParam(name = "groupType", value = "GROUP_TYPE", required = true, dataType ="AlertType"), + @ApiImplicitParam(name = "desc", value = "DESC", dataType ="String") + }) @PostMapping(value = "/create") @ResponseStatus(HttpStatus.CREATED) - public Result createAlertgroup(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result createAlertgroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "groupName") String groupName, @RequestParam(value = "groupType") AlertType groupType, @RequestParam(value = "desc",required = false) String desc) { @@ -77,9 +87,10 @@ public class AlertGroupController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "list", notes= "QUERY_ALERT_GROUP_LIST_NOTES") @GetMapping(value = "/list") @ResponseStatus(HttpStatus.OK) - public Result list(@RequestAttribute(value = Constants.SESSION_USER) User loginUser) { + public Result list(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { logger.info("login user {}, query all alertGroup", loginUser.getUserName()); try{ @@ -100,9 +111,15 @@ public class AlertGroupController extends BaseController{ * @param pageSize * @return */ + @ApiOperation(value = "queryTaskListPaging", notes= "QUERY_TASK_INSTANCE_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type ="String"), + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "20") + }) @GetMapping(value="/list-paging") @ResponseStatus(HttpStatus.OK) - public Result listPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result listPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("pageNo") Integer pageNo, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize){ @@ -131,9 +148,16 @@ public class AlertGroupController extends BaseController{ * @param desc * @return */ + @ApiOperation(value = "updateAlertgroup", notes= "UPDATE_ALERT_GROUP_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "ALERT_GROUP_ID", required = true, dataType = "Int",example = "100"), + @ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"), + @ApiImplicitParam(name = "groupType", value = "GROUP_TYPE", required = true, dataType ="AlertType"), + @ApiImplicitParam(name = "desc", value = "DESC", dataType ="String") + }) @PostMapping(value = "/update") @ResponseStatus(HttpStatus.OK) - public Result updateAlertgroup(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result updateAlertgroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int id, @RequestParam(value = "groupName") String groupName, @RequestParam(value = "groupType") AlertType groupType, @@ -156,9 +180,13 @@ public class AlertGroupController extends BaseController{ * @param id * @return */ + @ApiOperation(value = "delAlertgroupById", notes= "DELETE_ALERT_GROUP_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "ALERT_GROUP_ID", required = true, dataType = "Int",example = "100") + }) @PostMapping(value = "/delete") @ResponseStatus(HttpStatus.OK) - public Result delAlertgroupById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result delAlertgroupById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int id) { logger.info("login user {}, delete AlertGroup, id: {},", loginUser.getUserName(), id); try { @@ -178,9 +206,13 @@ public class AlertGroupController extends BaseController{ * @param groupName * @return */ + @ApiOperation(value = "verifyGroupName", notes= "VERIFY_ALERT_GROUP_NAME_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"), + }) @GetMapping(value = "/verify-group-name") @ResponseStatus(HttpStatus.OK) - public Result verifyGroupName(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result verifyGroupName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value ="groupName") String groupName ) { logger.info("login user {}, verfiy group name: {}", @@ -196,9 +228,14 @@ public class AlertGroupController extends BaseController{ * @param userIds * @return */ + @ApiOperation(value = "grantUser", notes= "GRANT_ALERT_GROUP_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "ALERT_GROUP_ID", required = true, dataType = "Int",example = "100"), + @ApiImplicitParam(name = "userIds", value = "USER_IDS", required = true, dataType = "String") + }) @PostMapping(value = "/grant-user") @ResponseStatus(HttpStatus.OK) - public Result grantUser(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result grantUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "alertgroupId") int alertgroupId, @RequestParam(value = "userIds") String userIds) { logger.info("login user {}, grant user, alertGroupId: {},userIds : {}", loginUser.getUserName(), alertgroupId,userIds); diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/DataAnalysisController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/DataAnalysisController.java index 37a84f26cf..be256a9db6 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/DataAnalysisController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/DataAnalysisController.java @@ -21,6 +21,10 @@ import cn.escheduler.api.service.DataAnalysisService; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -35,7 +39,7 @@ import static cn.escheduler.api.enums.Status.*; /** * data analysis controller */ -@ApiIgnore +@Api(tags = "DATA_ANALYSIS_TAG", position = 1) @RestController @RequestMapping("projects/analysis") public class DataAnalysisController extends BaseController{ @@ -54,9 +58,15 @@ public class DataAnalysisController extends BaseController{ * @param projectId * @return */ + @ApiOperation(value = "countTaskState", notes= "COUNT_TASK_STATE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "START_DATE", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "END_DATE", dataType ="String"), + @ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType ="Int", example = "100") + }) @GetMapping(value="/task-state-count") @ResponseStatus(HttpStatus.OK) - public Result countTaskState(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result countTaskState(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value="startDate", required=false) String startDate, @RequestParam(value="endDate", required=false) String endDate, @RequestParam(value="projectId", required=false, defaultValue = "0") int projectId){ @@ -78,9 +88,15 @@ public class DataAnalysisController extends BaseController{ * @param projectId * @return */ + @ApiOperation(value = "countProcessInstanceState", notes= "COUNT_PROCESS_INSTANCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "START_DATE", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "END_DATE", dataType ="String"), + @ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType ="Int", example = "100") + }) @GetMapping(value="/process-state-count") @ResponseStatus(HttpStatus.OK) - public Result countProcessInstanceState(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result countProcessInstanceState(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value="startDate", required=false) String startDate, @RequestParam(value="endDate", required=false) String endDate, @RequestParam(value="projectId", required=false, defaultValue = "0") int projectId){ @@ -102,9 +118,13 @@ public class DataAnalysisController extends BaseController{ * @param projectId * @return */ + @ApiOperation(value = "countDefinitionByUser", notes= "COUNT_PROCESS_DEFINITION_BY_USER_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType ="Int", example = "100") + }) @GetMapping(value="/define-user-count") @ResponseStatus(HttpStatus.OK) - public Result countDefinitionByUser(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result countDefinitionByUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value="projectId", required=false, defaultValue = "0") int projectId){ try{ logger.info("count process definition , user:{}, project id", @@ -125,9 +145,15 @@ public class DataAnalysisController extends BaseController{ * @param projectId * @return */ + @ApiOperation(value = "countCommandState", notes= "COUNT_COMMAND_STATE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "START_DATE", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "END_DATE", dataType ="String"), + @ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType ="Int", example = "100") + }) @GetMapping(value="/command-state-count") @ResponseStatus(HttpStatus.OK) - public Result countCommandState(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result countCommandState(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value="startDate", required=false) String startDate, @RequestParam(value="endDate", required=false) String endDate, @RequestParam(value="projectId", required=false, defaultValue = "0") int projectId){ @@ -149,9 +175,15 @@ public class DataAnalysisController extends BaseController{ * @param projectId * @return */ + @ApiOperation(value = "countQueueState", notes= "COUNT_QUEUE_STATE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "START_DATE", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "END_DATE", dataType ="String"), + @ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType ="Int", example = "100") + }) @GetMapping(value="/queue-count") @ResponseStatus(HttpStatus.OK) - public Result countQueueState(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result countQueueState(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value="projectId", required=false, defaultValue = "0") int projectId){ try{ logger.info("count command state, user:{}, start date: {}, end date:{}, project id {}", diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/DataSourceController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/DataSourceController.java index d13da8b117..a4b1b1606b 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/DataSourceController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/DataSourceController.java @@ -41,7 +41,7 @@ import static cn.escheduler.api.enums.Status.*; /** * data source controller */ -@Api(tags = "DATA_SOURCE_TAG", position = 1) +@Api(tags = "DATA_SOURCE_TAG", position = 3) @RestController @RequestMapping("datasources") public class DataSourceController extends BaseController { diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskInstanceController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskInstanceController.java index 5b60b2326b..86b40687d9 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskInstanceController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/TaskInstanceController.java @@ -63,8 +63,8 @@ public class TaskInstanceController extends BaseController{ @ApiImplicitParam(name = "host", value = "HOST", type ="String"), @ApiImplicitParam(name = "startDate", value = "START_DATE", type ="String"), @ApiImplicitParam(name = "endDate", value = "END_DATE", type ="String"), - @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "100"), - @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100") + @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "20") }) @GetMapping("/list-paging") @ResponseStatus(HttpStatus.OK) diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java index 6a8b7a79dc..875082098a 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java @@ -19,9 +19,12 @@ package cn.escheduler.api.controller; import cn.escheduler.api.enums.Status; import cn.escheduler.api.service.WorkerGroupService; -import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -31,10 +34,12 @@ import springfox.documentation.annotations.ApiIgnore; import java.util.Map; +import static cn.escheduler.api.utils.Constants.SESSION_USER; + /** * worker group controller */ -@ApiIgnore +@Api(tags = "WORKER_GROUP_TAG", position = 1) @RestController @RequestMapping("/worker-group") public class WorkerGroupController extends BaseController{ @@ -54,9 +59,15 @@ public class WorkerGroupController extends BaseController{ * @param ipList * @return */ + @ApiOperation(value = "saveWorkerGroup", notes= "CREATE_WORKER_GROUP_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "WORKER_GROUP_ID", dataType = "Int", example = "10", defaultValue = "0"), + @ApiImplicitParam(name = "name", value = "WORKER_GROUP_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "ipList", value = "WORKER_IP_LIST", required = true, dataType ="String") + }) @PostMapping(value = "/save") @ResponseStatus(HttpStatus.OK) - public Result saveWorkerGroup(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result saveWorkerGroup(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @RequestParam(value = "id", required = false, defaultValue = "0") int id, @RequestParam(value = "name") String name, @RequestParam(value = "ipList") String ipList @@ -81,9 +92,15 @@ public class WorkerGroupController extends BaseController{ * @param pageSize * @return */ + @ApiOperation(value = "queryAllWorkerGroupsPaging", notes= "QUERY_WORKER_GROUP_PAGING_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "WORKER_GROUP_ID", dataType = "Int", example = "10", defaultValue = "0"), + @ApiImplicitParam(name = "name", value = "WORKER_GROUP_NAME", required = true, dataType ="String"), + @ApiImplicitParam(name = "ipList", value = "WORKER_IP_LIST", required = true, dataType ="String") + }) @GetMapping(value = "/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryAllWorkerGroupsPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryAllWorkerGroupsPaging(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @RequestParam("pageNo") Integer pageNo, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize @@ -105,9 +122,10 @@ public class WorkerGroupController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "queryAllWorkerGroups", notes= "QUERY_WORKER_GROUP_LIST_NOTES") @GetMapping(value = "/all-groups") @ResponseStatus(HttpStatus.OK) - public Result queryAllWorkerGroups(@RequestAttribute(value = Constants.SESSION_USER) User loginUser + public Result queryAllWorkerGroups(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser ) { logger.info("query all worker group: login user {}", loginUser.getUserName() ); @@ -127,9 +145,14 @@ public class WorkerGroupController extends BaseController{ * @param id * @return */ + @ApiOperation(value = "deleteById", notes= "DELETE_WORKER_GROUP_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "WORKER_GROUP_ID", required = true, dataType = "Int", example = "10"), + + }) @GetMapping(value = "/delete-by-id") @ResponseStatus(HttpStatus.OK) - public Result deleteById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result deleteById(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @RequestParam("id") Integer id ) { logger.info("delete worker group: login user {}, id:{} ", diff --git a/escheduler-api/src/main/resources/messages.properties b/escheduler-api/src/main/resources/i18n/messages.properties similarity index 63% rename from escheduler-api/src/main/resources/messages.properties rename to escheduler-api/src/main/resources/i18n/messages.properties index d83dd10de3..db1111ad78 100644 --- a/escheduler-api/src/main/resources/messages.properties +++ b/escheduler-api/src/main/resources/i18n/messages.properties @@ -1,4 +1,29 @@ QUERY_SCHEDULE_LIST_NOTES=query schedule list +DESC=description +GROUP_NAME=group name +GROUP_TYPE=group type +QUERY_ALERT_GROUP_LIST_NOTES=query alert group list +UPDATE_ALERT_GROUP_NOTES=update alert group +DELETE_ALERT_GROUP_BY_ID_NOTES=delete alert group by id +VERIFY_ALERT_GROUP_NAME_NOTES=verify alert group name, check alert group exist or not +GRANT_ALERT_GROUP_NOTES=grant alert group +USER_IDS=user id list +ALERT_GROUP_TAG=alert group related operation +CREATE_ALERT_GROUP_NOTES=create alert group +WORKER_GROUP_TAG=worker group related operation +SAVE_WORKER_GROUP_NOTES=create worker group +WORKER_GROUP_NAME=worker group name +WORKER_IP_LIST=worker ip list, eg. 192.168.1.1,192.168.1.2 +QUERY_WORKER_GROUP_PAGING_NOTES=query worker group paging +QUERY_WORKER_GROUP_LIST_NOTES=query worker group list +DELETE_WORKER_GROUP_BY_ID_NOTES=delete worker group by id +DATA_ANALYSIS_TAG=analysis related operation of task state +COUNT_TASK_STATE_NOTES=count task state +COUNT_PROCESS_INSTANCE_NOTES=count process instance state +COUNT_PROCESS_DEFINITION_BY_USER_NOTES=count process definition by user +COUNT_COMMAND_STATE_NOTES=count command state +COUNT_QUEUE_STATE_NOTES=count the running status of the task in the queue\ + ACCESS_TOKEN_TAG=access token related operation MONITOR_TAG=monitor related operation MASTER_LIST_NOTES=master server list @@ -18,53 +43,53 @@ DB_TYPE=database type DATA_SOURCE_HOST=DATA SOURCE HOST DATA_SOURCE_PORT=data source port DATABASE_NAME=database name -QUEUE_TAG= -QUERY_QUEUE_LIST_NOTES= -QUERY_QUEUE_LIST_PAGING_NOTES= -CREATE_QUEUE_NOTES= -YARN_QUEUE_NAME= -QUEUE_ID= -TENANT_DESC= -QUERY_TENANT_LIST_PAGING_NOTES= -QUERY_TENANT_LIST_NOTES= -UPDATE_TENANT_NOTES= -DELETE_TENANT_NOTES= -RESOURCES_TAG= -CREATE_RESOURCE_NOTES= -RESOURCE_TYPE= -RESOURCE_NAME= -RESOURCE_DESC= -RESOURCE_FILE= -RESOURCE_ID= -QUERY_RESOURCE_LIST_NOTES= -DELETE_RESOURCE_BY_ID_NOTES= -VIEW_RESOURCE_BY_ID_NOTES= -ONLINE_CREATE_RESOURCE_NOTES= -SUFFIX= -CONTENT= -UPDATE_RESOURCE_NOTES= -DOWNLOAD_RESOURCE_NOTES= -CREATE_UDF_FUNCTION_NOTES= -UDF_TYPE= -FUNC_NAME= -CLASS_NAME= -ARG_TYPES= -UDF_DESC= -VIEW_UDF_FUNCTION_NOTES= -UPDATE_UDF_FUNCTION_NOTES= -QUERY_UDF_FUNCTION_LIST_PAGING_NOTES= -VERIFY_UDF_FUNCTION_NAME_NOTES= -DELETE_UDF_FUNCTION_NOTES= -AUTHORIZED_FILE_NOTES= -UNAUTHORIZED_FILE_NOTES= -AUTHORIZED_UDF_FUNC_NOTES= -UNAUTHORIZED_UDF_FUNC_NOTES= -VERIFY_QUEUE_NOTES= -TENANT_TAG= -CREATE_TENANT_NOTES= -TENANT_CODE= -TENANT_NAME= -QUEUE_NAME= +QUEUE_TAG=queue related operation +QUERY_QUEUE_LIST_NOTES=query queue list +QUERY_QUEUE_LIST_PAGING_NOTES=query queue list paging +CREATE_QUEUE_NOTES=create queue +YARN_QUEUE_NAME=yarn(hadoop) queue name +QUEUE_ID=queue id +TENANT_DESC=tenant desc +QUERY_TENANT_LIST_PAGING_NOTES=query tenant list paging +QUERY_TENANT_LIST_NOTES=query tenant list +UPDATE_TENANT_NOTES=update tenant +DELETE_TENANT_NOTES=delete tenant +RESOURCES_TAG=resource center related operation +CREATE_RESOURCE_NOTES=create resource +RESOURCE_TYPE=resource file type +RESOURCE_NAME=resource name +RESOURCE_DESC=resource file desc +RESOURCE_FILE=resource file +RESOURCE_ID=resource id +QUERY_RESOURCE_LIST_NOTES=query resource list +DELETE_RESOURCE_BY_ID_NOTES=delete resource by id +VIEW_RESOURCE_BY_ID_NOTES=view resource by id +ONLINE_CREATE_RESOURCE_NOTES=online create resource +SUFFIX=resource file suffix +CONTENT=resource file content +UPDATE_RESOURCE_NOTES=edit resource file online +DOWNLOAD_RESOURCE_NOTES=download resource file +CREATE_UDF_FUNCTION_NOTES=create udf function +UDF_TYPE=UDF type +FUNC_NAME=function name +CLASS_NAME=package and class name +ARG_TYPES=arguments +UDF_DESC=udf desc +VIEW_UDF_FUNCTION_NOTES=view udf function +UPDATE_UDF_FUNCTION_NOTES=update udf function +QUERY_UDF_FUNCTION_LIST_PAGING_NOTES=query udf function list paging +VERIFY_UDF_FUNCTION_NAME_NOTES=verify udf function name +DELETE_UDF_FUNCTION_NOTES=delete udf function +AUTHORIZED_FILE_NOTES=authorized file +UNAUTHORIZED_FILE_NOTES=unauthorized file +AUTHORIZED_UDF_FUNC_NOTES=authorized udf func +UNAUTHORIZED_UDF_FUNC_NOTES=unauthorized udf func +VERIFY_QUEUE_NOTES=verify queue +TENANT_TAG=tenant related operation +CREATE_TENANT_NOTES=create tenant +TENANT_CODE=tenant code +TENANT_NAME=tenant name +QUEUE_NAME=queue name PASSWORD=password DATA_SOURCE_OTHER=jdbc connection params, format:{"key1":"value1",...} PROJECT_TAG=project related operation @@ -178,14 +203,14 @@ HOST=ip address of running task START_DATE=start date END_DATE=end date QUERY_TASK_LIST_BY_PROCESS_INSTANCE_ID_NOTES=query task list by process instance id -UPDATE_DATA_SOURCE_NOTES= -DATA_SOURCE_ID= -QUERY_DATA_SOURCE_NOTES= -QUERY_DATA_SOURCE_LIST_BY_TYPE_NOTES= -QUERY_DATA_SOURCE_LIST_PAGING_NOTES= -CONNECT_DATA_SOURCE_NOTES= -CONNECT_DATA_SOURCE_TEST_NOTES= -DELETE_DATA_SOURCE_NOTES= -VERIFY_DATA_SOURCE_NOTES= -UNAUTHORIZED_DATA_SOURCE_NOTES= -AUTHORIZED_DATA_SOURCE_NOTES= +UPDATE_DATA_SOURCE_NOTES=update data source +DATA_SOURCE_ID=DATA SOURCE ID +QUERY_DATA_SOURCE_NOTES=query data source by id +QUERY_DATA_SOURCE_LIST_BY_TYPE_NOTES=query data source list by database type +QUERY_DATA_SOURCE_LIST_PAGING_NOTES=query data source list paging +CONNECT_DATA_SOURCE_NOTES=CONNECT DATA SOURCE +CONNECT_DATA_SOURCE_TEST_NOTES=connect data source test +DELETE_DATA_SOURCE_NOTES=delete data source +VERIFY_DATA_SOURCE_NOTES=verify data source +UNAUTHORIZED_DATA_SOURCE_NOTES=unauthorized data source +AUTHORIZED_DATA_SOURCE_NOTES=authorized data source diff --git a/escheduler-api/src/main/resources/messages_en_US.properties b/escheduler-api/src/main/resources/i18n/messages_en_US.properties similarity index 87% rename from escheduler-api/src/main/resources/messages_en_US.properties rename to escheduler-api/src/main/resources/i18n/messages_en_US.properties index 45a2e793df..db1111ad78 100644 --- a/escheduler-api/src/main/resources/messages_en_US.properties +++ b/escheduler-api/src/main/resources/i18n/messages_en_US.properties @@ -1,4 +1,29 @@ QUERY_SCHEDULE_LIST_NOTES=query schedule list +DESC=description +GROUP_NAME=group name +GROUP_TYPE=group type +QUERY_ALERT_GROUP_LIST_NOTES=query alert group list +UPDATE_ALERT_GROUP_NOTES=update alert group +DELETE_ALERT_GROUP_BY_ID_NOTES=delete alert group by id +VERIFY_ALERT_GROUP_NAME_NOTES=verify alert group name, check alert group exist or not +GRANT_ALERT_GROUP_NOTES=grant alert group +USER_IDS=user id list +ALERT_GROUP_TAG=alert group related operation +CREATE_ALERT_GROUP_NOTES=create alert group +WORKER_GROUP_TAG=worker group related operation +SAVE_WORKER_GROUP_NOTES=create worker group +WORKER_GROUP_NAME=worker group name +WORKER_IP_LIST=worker ip list, eg. 192.168.1.1,192.168.1.2 +QUERY_WORKER_GROUP_PAGING_NOTES=query worker group paging +QUERY_WORKER_GROUP_LIST_NOTES=query worker group list +DELETE_WORKER_GROUP_BY_ID_NOTES=delete worker group by id +DATA_ANALYSIS_TAG=analysis related operation of task state +COUNT_TASK_STATE_NOTES=count task state +COUNT_PROCESS_INSTANCE_NOTES=count process instance state +COUNT_PROCESS_DEFINITION_BY_USER_NOTES=count process definition by user +COUNT_COMMAND_STATE_NOTES=count command state +COUNT_QUEUE_STATE_NOTES=count the running status of the task in the queue\ + ACCESS_TOKEN_TAG=access token related operation MONITOR_TAG=monitor related operation MASTER_LIST_NOTES=master server list diff --git a/escheduler-api/src/main/resources/messages_zh_CN.properties b/escheduler-api/src/main/resources/i18n/messages_zh_CN.properties similarity index 88% rename from escheduler-api/src/main/resources/messages_zh_CN.properties rename to escheduler-api/src/main/resources/i18n/messages_zh_CN.properties index dc0ffb705f..73d62a8839 100644 --- a/escheduler-api/src/main/resources/messages_zh_CN.properties +++ b/escheduler-api/src/main/resources/i18n/messages_zh_CN.properties @@ -1,4 +1,30 @@ QUERY_SCHEDULE_LIST_NOTES=查询定时列表 +DESC=备注(描述) +GROUP_NAME=组名称 +GROUP_TYPE=组类型 +QUERY_ALERT_GROUP_LIST_NOTES=告警组列表\ + +UPDATE_ALERT_GROUP_NOTES=编辑(更新)告警组 +DELETE_ALERT_GROUP_BY_ID_NOTES=删除告警组通过ID +VERIFY_ALERT_GROUP_NAME_NOTES=检查告警组是否存在 +GRANT_ALERT_GROUP_NOTES=授权告警组 +USER_IDS=用户ID列表 +ALERT_GROUP_TAG=告警组相关操作 +WORKER_GROUP_TAG=Worker分组管理 +SAVE_WORKER_GROUP_NOTES=创建Worker分组\ + +WORKER_GROUP_NAME=Worker分组名称 +WORKER_IP_LIST=Worker ip列表,注意:多个IP地址以逗号分割\ + +QUERY_WORKER_GROUP_PAGING_NOTES=Worker分组管理 +QUERY_WORKER_GROUP_LIST_NOTES=查询worker group分组 +DELETE_WORKER_GROUP_BY_ID_NOTES=删除worker group通过ID +DATA_ANALYSIS_TAG=任务状态分析相关操作 +COUNT_TASK_STATE_NOTES=任务状态统计 +COUNT_PROCESS_INSTANCE_NOTES=统计流程实例状态 +COUNT_PROCESS_DEFINITION_BY_USER_NOTES=统计用户创建的流程定义 +COUNT_COMMAND_STATE_NOTES=统计命令状态 +COUNT_QUEUE_STATE_NOTES=统计队列里任务状态 ACCESS_TOKEN_TAG=access token相关操作,需要先登录 MONITOR_TAG=监控相关操作 MASTER_LIST_NOTES=master服务列表 diff --git a/escheduler-api/src/main/resources/logback.xml b/escheduler-api/src/main/resources/logback.xml new file mode 100644 index 0000000000..2e27d70ef3 --- /dev/null +++ b/escheduler-api/src/main/resources/logback.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + + UTF-8 + + + + + + + INFO + + ${log.base}/escheduler-api-server.log + + ${log.base}/escheduler-api-server.%d{yyyy-MM-dd_HH}.%i.log + 168 + 64MB + + + + + [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n + + UTF-8 + + + + + + + + \ No newline at end of file From 85a66588cd63a495cecec9c2b188c6fd7a8cc0bf Mon Sep 17 00:00:00 2001 From: lidongdai Date: Sat, 25 May 2019 18:50:48 +0800 Subject: [PATCH 3/3] update api docs --- escheduler-api/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/escheduler-api/src/main/resources/application.properties b/escheduler-api/src/main/resources/application.properties index 118b70e616..b817c18a4a 100644 --- a/escheduler-api/src/main/resources/application.properties +++ b/escheduler-api/src/main/resources/application.properties @@ -16,4 +16,4 @@ server.jetty.max-http-post-size=5000000 spring.messages.encoding=UTF-8 #i18n classpath folder , file prefix messages, if have many files, use "," seperator -spring.messages.basename=messages +spring.messages.basename=i18n/messages