diff --git a/escheduler-alert/pom.xml b/escheduler-alert/pom.xml index 13958c1b37..0cb4cc4e37 100644 --- a/escheduler-alert/pom.xml +++ b/escheduler-alert/pom.xml @@ -90,10 +90,6 @@ commons-io - - org.apache.commons - commons-collections4 - diff --git a/escheduler-alert/src/main/java/cn/escheduler/alert/utils/MailUtils.java b/escheduler-alert/src/main/java/cn/escheduler/alert/utils/MailUtils.java index d97d9d9d57..b8a315a492 100644 --- a/escheduler-alert/src/main/java/cn/escheduler/alert/utils/MailUtils.java +++ b/escheduler-alert/src/main/java/cn/escheduler/alert/utils/MailUtils.java @@ -36,6 +36,7 @@ import java.io.*; import java.security.Security; import java.util.*; +import static cn.escheduler.alert.utils.PropertyUtils.getBoolean; import static cn.escheduler.alert.utils.PropertyUtils.getInt; import static cn.escheduler.alert.utils.PropertyUtils.getString; @@ -57,6 +58,10 @@ public class MailUtils { public static final String mailPasswd = getString(Constants.MAIL_PASSWD); + public static final Boolean mailUseStartTLS = getBoolean(Constants.MAIL_SMTP_STARTTLS_ENABLE); + + public static final Boolean mailUseSSL = getBoolean(Constants.MAIL_SMTP_SSL_ENABLE); + public static final String xlsFilePath = getString(Constants.XLS_FILE_PATH); public static final String starttlsEnable = getString(Constants.MAIL_SMTP_STARTTLS_ENABLE); diff --git a/escheduler-api/pom.xml b/escheduler-api/pom.xml index 759942dbbe..11f42601a1 100644 --- a/escheduler-api/pom.xml +++ b/escheduler-api/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 cn.analysys @@ -10,13 +11,10 @@ + cn.analysys - escheduler-dao - - - cn.analysys - escheduler-common + escheduler-server io.netty @@ -42,14 +40,6 @@ - - org.springframework.boot - spring-boot-starter-parent - ${spring.boot.version} - pom - import - - org.springframework.boot spring-boot-starter-web @@ -58,10 +48,6 @@ org.springframework.boot spring-boot-starter-tomcat - - org.springframework.boot - spring-boot-starter - @@ -157,6 +143,24 @@ quartz-jobs + + io.springfox + springfox-swagger2 + 2.9.2 + + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + + com.github.xiaoymin + swagger-bootstrap-ui + 1.9.3 + + cn.analysys escheduler-rpc @@ -168,7 +172,6 @@ 4.12 test - @@ -202,4 +205,4 @@ - + \ No newline at end of file diff --git a/escheduler-api/src/main/java/cn/escheduler/api/ApiApplicationServer.java b/escheduler-api/src/main/java/cn/escheduler/api/ApiApplicationServer.java index 1c66e2d4ed..9b84c7f2f7 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/ApiApplicationServer.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/ApiApplicationServer.java @@ -19,13 +19,19 @@ package cn.escheduler.api; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; +import springfox.documentation.swagger2.annotations.EnableSwagger2; @SpringBootApplication @ServletComponentScan @ComponentScan("cn.escheduler") -public class ApiApplicationServer { +@EnableSwagger2 +public class ApiApplicationServer extends SpringBootServletInitializer { + public static void main(String[] args) { SpringApplication.run(ApiApplicationServer.class, args); } + + } 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 491da0821e..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,31 +19,73 @@ 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.ContentNegotiationConfigurer; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +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; + +import java.util.Locale; + /** * application configuration */ @Configuration -public class AppConfiguration extends WebMvcConfigurerAdapter { +public class AppConfiguration implements WebMvcConfigurer { public static final String LOGIN_INTERCEPTOR_PATH_PATTERN = "/**/*"; public static final String LOGIN_PATH_PATTERN = "/login"; public static final String PATH_PATTERN = "/**"; + public static final String LOCALE_LANGUAGE_COOKIE = "language"; + public static final int COOKIE_MAX_AGE = 3600; - @Override - public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(loginInterceptor()).addPathPatterns(LOGIN_INTERCEPTOR_PATH_PATTERN).excludePathPatterns(LOGIN_PATH_PATTERN); - } @Bean public LoginHandlerInterceptor loginInterceptor() { return new LoginHandlerInterceptor(); } + + /** + * Cookie + */ + @Bean(name = "localeResolver") + public LocaleResolver localeResolver() { + CookieLocaleResolver localeResolver = new CookieLocaleResolver(); + localeResolver.setCookieName(LOCALE_LANGUAGE_COOKIE); + /** set default locale **/ + localeResolver.setDefaultLocale(Locale.US); + /** set cookie max age **/ + localeResolver.setCookieMaxAge(COOKIE_MAX_AGE); + return localeResolver; + } + + @Bean + public LocaleChangeInterceptor localeChangeInterceptor() { + LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); + /** **/ + lci.setParamName("language"); + + return lci; + } + + + @Override + public void addInterceptors(InterceptorRegistry registry) { + //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/"); + } + @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping(PATH_PATTERN).allowedOrigins("*").allowedMethods("*"); @@ -59,4 +101,8 @@ public class AppConfiguration extends WebMvcConfigurerAdapter { public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false); } + + + + } diff --git a/escheduler-api/src/main/java/cn/escheduler/api/configuration/ServiceModelToSwagger2MapperImpl.java b/escheduler-api/src/main/java/cn/escheduler/api/configuration/ServiceModelToSwagger2MapperImpl.java new file mode 100644 index 0000000000..e9c001cc95 --- /dev/null +++ b/escheduler-api/src/main/java/cn/escheduler/api/configuration/ServiceModelToSwagger2MapperImpl.java @@ -0,0 +1,509 @@ +/* + * 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.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import io.swagger.models.*; +import io.swagger.models.parameters.Parameter; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Primary; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.ApiListing; +import springfox.documentation.service.Documentation; +import springfox.documentation.service.ResourceListing; +import springfox.documentation.swagger2.mappers.*; + +import java.util.*; + +import static com.google.common.collect.Maps.newTreeMap; + +/** + * application configuration + */ +@Component(value = "ServiceModelToSwagger2Mapper") +@Primary +public class ServiceModelToSwagger2MapperImpl extends ServiceModelToSwagger2Mapper { + + + @Autowired + private ModelMapper modelMapper; + @Autowired + private ParameterMapper parameterMapper; + @Autowired + private SecurityMapper securityMapper; + @Autowired + private LicenseMapper licenseMapper; + @Autowired + private VendorExtensionsMapper vendorExtensionsMapper; + + @Autowired + private MessageSource messageSource; + + @Override + public Swagger mapDocumentation(Documentation from) { + + if (from == null) { + return null; + } + + Swagger swagger = new Swagger(); + + swagger.setVendorExtensions(vendorExtensionsMapper.mapExtensions(from.getVendorExtensions())); + swagger.setSchemes(mapSchemes(from.getSchemes())); + swagger.setPaths(mapApiListings(from.getApiListings())); + swagger.setHost(from.getHost()); + swagger.setDefinitions(modelsFromApiListings( from.getApiListings() ) ); + swagger.setSecurityDefinitions(securityMapper.toSecuritySchemeDefinitions(from.getResourceListing())); + ApiInfo info = fromResourceListingInfo(from); + if (info != null) { + swagger.setInfo(mapApiInfo(info)); + } + swagger.setBasePath(from.getBasePath()); + swagger.setTags(tagSetToTagList(from.getTags())); + List list2 = from.getConsumes(); + if (list2 != null) { + swagger.setConsumes(new ArrayList(list2)); + } else { + swagger.setConsumes(null); + } + List list3 = from.getProduces(); + if (list3 != null) { + swagger.setProduces(new ArrayList(list3)); + } else { + swagger.setProduces(null); + } + + return swagger; + } + + + @Override + protected Info mapApiInfo(ApiInfo from) { + + if (from == null) { + return null; + } + + Info info = new Info(); + + info.setLicense(licenseMapper.apiInfoToLicense(from)); + info.setVendorExtensions(vendorExtensionsMapper.mapExtensions(from.getVendorExtensions())); + info.setTermsOfService(from.getTermsOfServiceUrl()); + info.setContact(map(from.getContact())); + info.setDescription(from.getDescription()); + info.setVersion(from.getVersion()); + info.setTitle(from.getTitle()); + + return info; + } + + @Override + protected Contact map(springfox.documentation.service.Contact from) { + + if (from == null) { + return null; + } + + Contact contact = new Contact(); + + contact.setName(from.getName()); + contact.setUrl(from.getUrl()); + contact.setEmail(from.getEmail()); + + return contact; + } + + @Override + protected io.swagger.models.Operation mapOperation(springfox.documentation.service.Operation from) { + + if (from == null) { + return null; + } + + Locale locale = LocaleContextHolder.getLocale(); + + io.swagger.models.Operation operation = new io.swagger.models.Operation(); + + operation.setSecurity(mapAuthorizations(from.getSecurityReferences())); + operation.setVendorExtensions(vendorExtensionsMapper.mapExtensions(from.getVendorExtensions())); + operation.setDescription(messageSource.getMessage(from.getNotes(), null, from.getNotes(), locale)); + operation.setOperationId(from.getUniqueId()); + operation.setResponses(mapResponseMessages(from.getResponseMessages())); + operation.setSchemes(stringSetToSchemeList(from.getProtocol())); + Set tagsSet = new HashSet<>(1); + + if(from.getTags() != null && from.getTags().size() > 0){ + + List list = new ArrayList(tagsSet.size()); + + Iterator it = from.getTags().iterator(); + while(it.hasNext()) + { + String tag = it.next(); + list.add(StringUtils.isNotBlank(tag) ? messageSource.getMessage(tag, null, tag, locale) : " "); + } + + operation.setTags(list); + }else { + operation.setTags(null); + } + + operation.setSummary(from.getSummary()); + Set set1 = from.getConsumes(); + if (set1 != null) { + operation.setConsumes(new ArrayList(set1)); + } else { + operation.setConsumes(null); + } + + Set set2 = from.getProduces(); + if (set2 != null) { + operation.setProduces(new ArrayList(set2)); + } else { + operation.setProduces(null); + } + + + operation.setParameters(parameterListToParameterList(from.getParameters())); + if (from.getDeprecated() != null) { + operation.setDeprecated(Boolean.parseBoolean(from.getDeprecated())); + } + + return operation; + } + + @Override + protected Tag mapTag(springfox.documentation.service.Tag from) { + + if (from == null) { + return null; + } + + Locale locale = LocaleContextHolder.getLocale(); + + Tag tag = new Tag(); + + tag.setVendorExtensions(vendorExtensionsMapper.mapExtensions(from.getVendorExtensions())); + tag.setName(messageSource.getMessage(from.getName(), null, from.getName(), locale)); + tag.setDescription(from.getDescription()); + + return tag; + } + + + private ApiInfo fromResourceListingInfo(Documentation documentation) { + + if (documentation == null) { + return null; + } + ResourceListing resourceListing = documentation.getResourceListing(); + if (resourceListing == null) { + return null; + } + ApiInfo info = resourceListing.getInfo(); + if (info == null) { + return null; + } + return info; + } + + protected List tagSetToTagList(Set set) { + + if (set == null) { + return null; + } + + List list = new ArrayList(set.size()); + for (springfox.documentation.service.Tag tag : set) { + list.add(mapTag(tag)); + } + + return list; + } + + protected List stringSetToSchemeList(Set set) { + if (set == null) { + return null; + } + + List list = new ArrayList(set.size()); + for (String string : set) { + list.add(Enum.valueOf(Scheme.class, string)); + } + + return list; + } + + protected List parameterListToParameterList(List list) { + if (list == null) { + return null; + } + + List list1 = new ArrayList(list.size()); + + Locale locale = LocaleContextHolder.getLocale(); + + for (springfox.documentation.service.Parameter param : list) { + String description = messageSource.getMessage(param.getDescription(), null, param.getDescription(), locale); + + springfox.documentation.service.Parameter parameter = new springfox.documentation.service.Parameter(param.getName(),description,param.getDefaultValue(),param.isRequired(),param.isAllowMultiple(),param.isAllowEmptyValue(),param.getModelRef(),param.getType(),param.getAllowableValues(),param.getParamType(),param.getParamAccess(),param.isHidden(),param.getPattern(),param.getCollectionFormat(),param.getOrder(),param.getScalarExample(),param.getExamples() ,param.getVendorExtentions()); + list1.add(parameterMapper.mapParameter(parameter)); + } + + return list1; + } + + + Map modelsFromApiListings(Multimap apiListings) { + Map definitions = newTreeMap(); + for (ApiListing each : apiListings.values()) { + definitions.putAll(each.getModels()); + } + return modelMapper.mapModels(definitions); + } + + + + + + +// +// +// +// private static final VendorExtensionsMapper vendorMapper = new VendorExtensionsMapper(); +// +// +// +// public Parameter mapParameter(springfox.documentation.service.Parameter source) { +// Parameter bodyParameter = bodyParameter(source); +// return SerializableParameterFactories.create(source).or(bodyParameter); +// } +// +// private Parameter bodyParameter(springfox.documentation.service.Parameter source) { +// BodyParameter parameter = new BodyParameter() +// .description(source.getDescription()) +// .name(source.getName()) +// .schema(fromModelRef(source.getModelRef())); +// parameter.setIn(source.getParamType()); +// parameter.setAccess(source.getParamAccess()); +// parameter.setPattern(source.getPattern()); +// parameter.setRequired(source.isRequired()); +// parameter.getVendorExtensions().putAll(vendorMapper.mapExtensions(source.getVendorExtentions())); +// for (Map.Entry> each : source.getExamples().asMap().entrySet()) { +// Optional example = FluentIterable.from(each.getValue()).first(); +// if (example.isPresent() && example.get().getValue() != null) { +// parameter.addExample(each.getKey(), String.valueOf(example.get().getValue())); +// } +// } +// +// //TODO: swagger-core Body parameter does not have an enum property +// return parameter; +// } +// +// Model fromModelRef(ModelReference modelRef) { +// if (modelRef.isCollection()) { +// if (modelRef.getItemType().equals("byte")) { +// ModelImpl baseModel = new ModelImpl(); +// baseModel.setType("string"); +// baseModel.setFormat("byte"); +// return maybeAddAllowableValuesToParameter(baseModel, modelRef.getAllowableValues()); +// } else if (modelRef.getItemType().equals("file")) { +// ArrayModel files = new ArrayModel(); +// files.items(new FileProperty()); +// return files; +// } +// ModelReference itemModel = modelRef.itemModel().get(); +// return new ArrayModel() +// .items(maybeAddAllowableValues(itemTypeProperty(itemModel), itemModel.getAllowableValues())); +// } +// if (modelRef.isMap()) { +// ModelImpl baseModel = new ModelImpl(); +// ModelReference itemModel = modelRef.itemModel().get(); +// baseModel.additionalProperties( +// maybeAddAllowableValues( +// itemTypeProperty(itemModel), +// itemModel.getAllowableValues())); +// return baseModel; +// } +// if (isBaseType(modelRef.getType())) { +// Property property = property(modelRef.getType()); +// ModelImpl baseModel = new ModelImpl(); +// baseModel.setType(property.getType()); +// baseModel.setFormat(property.getFormat()); +// return maybeAddAllowableValuesToParameter(baseModel, modelRef.getAllowableValues()); +// +// } +// return new RefModel(modelRef.getType()); +// } +// +// +// private static class Properties { +// private static final Map> typeFactory +// = ImmutableMap.>builder() +// .put("int", newInstanceOf(IntegerProperty.class)) +// .put("long", newInstanceOf(LongProperty.class)) +// .put("float", newInstanceOf(FloatProperty.class)) +// .put("double", newInstanceOf(DoubleProperty.class)) +// .put("string", newInstanceOf(StringProperty.class)) +// .put("boolean", newInstanceOf(BooleanProperty.class)) +// .put("date", newInstanceOf(DateProperty.class)) +// .put("date-time", newInstanceOf(DateTimeProperty.class)) +// .put("bigdecimal", newInstanceOf(DecimalProperty.class)) +// .put("biginteger", newInstanceOf(BaseIntegerProperty.class)) +// .put("uuid", newInstanceOf(UUIDProperty.class)) +// .put("object", newInstanceOf(ObjectProperty.class)) +// .put("byte", bytePropertyFactory()) +// .put("__file", filePropertyFactory()) +// .build(); +// +// private Properties() { +// throw new UnsupportedOperationException(); +// } +// +// public static Property property(final String typeName) { +// String safeTypeName = nullToEmpty(typeName); +// Function> propertyLookup +// = forMap(typeFactory, voidOrRef(safeTypeName)); +// return propertyLookup.apply(safeTypeName.toLowerCase()).apply(safeTypeName); +// } +// +// public static Property property(final ModelReference modelRef) { +// if (modelRef.isMap()) { +// return new MapProperty(property(modelRef.itemModel().get())); +// } else if (modelRef.isCollection()) { +// if ("byte".equals(modelRef.itemModel().transform(toTypeName()).or(""))) { +// return new ByteArrayProperty(); +// } +// return new ArrayProperty( +// maybeAddAllowableValues(itemTypeProperty(modelRef.itemModel().get()), modelRef.getAllowableValues())); +// } +// return property(modelRef.getType()); +// } +// +// private static Function toTypeName() { +// return new Function() { +// @Override +// public String apply(ModelReference input) { +// return input.getType(); +// } +// }; +// } +// +// public static Property itemTypeProperty(ModelReference paramModel) { +// if (paramModel.isCollection()) { +// return new ArrayProperty( +// maybeAddAllowableValues(itemTypeProperty(paramModel.itemModel().get()), paramModel.getAllowableValues())); +// } +// return property(paramModel.getType()); +// } +// +// private static Function newInstanceOf(final Class clazz) { +// return new Function() { +// @Override +// public T apply(String input) { +// try { +// return clazz.newInstance(); +// } catch (Exception e) { +// //This is bad! should never come here +// throw new IllegalStateException(e); +// } +// } +// }; +// } +// +// static Ordering defaultOrdering(Map properties) { +// return Ordering.from(byPosition(properties)).compound(byName()); +// } +// +// private static Function voidOrRef(final String typeName) { +// return new Function() { +// @Override +// public Property apply(String input) { +// if (typeName.equalsIgnoreCase("void")) { +// return null; +// } +// return new RefProperty(typeName); +// } +// }; +// } +// +// private static Function bytePropertyFactory() { +// return new Function() { +// @Override +// public Property apply(String input) { +// final IntegerProperty integerProperty = new IntegerProperty(); +// integerProperty.setFormat("int32"); +// integerProperty.setMaximum(BigDecimal.valueOf(Byte.MAX_VALUE)); +// integerProperty.setMinimum(BigDecimal.valueOf(Byte.MIN_VALUE)); +// return integerProperty; +// } +// }; +// } +// +// private static Function filePropertyFactory() { +// return new Function() { +// @Override +// public Property apply(String input) { +// return new FileProperty(); +// } +// }; +// } +// +// private static Comparator byName() { +// return new Comparator() { +// @Override +// public int compare(String first, String second) { +// return first.compareTo(second); +// } +// }; +// } +// +// private static Comparator byPosition(final Map modelProperties) { +// return new Comparator() { +// @Override +// public int compare(String first, String second) { +// ModelProperty p1 = modelProperties.get(first); +// ModelProperty p2 = modelProperties.get(second); +// return Ints.compare(p1.getPosition(), p2.getPosition()); +// } +// }; +// } +// +// static Predicate> voidProperties() { +// return new Predicate>() { +// @Override +// public boolean apply(Map.Entry input) { +// return isVoid(input.getValue().getType()) +// || collectionOfVoid(input.getValue().getType()) +// || arrayTypeOfVoid(input.getValue().getType().getArrayElementType()); +// } +// }; +// } +// +// private static boolean arrayTypeOfVoid(ResolvedType arrayElementType) { +// return arrayElementType != null && isVoid(arrayElementType); +// } +// +// private static boolean collectionOfVoid(ResolvedType type) { +// return isContainerType(type) && isVoid(collectionElementType(type)); +// } +} 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 new file mode 100644 index 0000000000..fb332c5ac9 --- /dev/null +++ b/escheduler-api/src/main/java/cn/escheduler/api/configuration/SwaggerConfig.java @@ -0,0 +1,55 @@ +/* + * 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.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * + * swager2 config class
+ * + */ +@Configuration +@EnableSwagger2 +@EnableSwaggerBootstrapUI +public class SwaggerConfig implements WebMvcConfigurer { + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() + .apis(RequestHandlerSelectors.basePackage("cn.escheduler.api.controller")).paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder().title("Easy Scheduler Api Docs").description("Easy Scheduler Api Docs") + .build(); + } + + +} 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 103709c502..4b608071ae 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 @@ -24,11 +24,16 @@ import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.common.utils.ParameterUtils; 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,8 +41,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{ @@ -54,9 +60,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){ @@ -77,6 +84,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, @@ -101,9 +109,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){ @@ -129,6 +143,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, @@ -149,6 +164,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 bf61cf76e3..f678cb5e82 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 @@ -22,17 +22,26 @@ import cn.escheduler.api.utils.Result; import cn.escheduler.common.enums.AlertType; import cn.escheduler.common.utils.ParameterUtils; 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.HashMap; import java.util.Map; import static cn.escheduler.api.enums.Status.*; +/** + * alert group controller + */ +@Api(tags = "ALERT_GROUP_TAG", position = 1) @RestController @RequestMapping("alert-group") public class AlertGroupController extends BaseController{ @@ -51,9 +60,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) { @@ -73,9 +88,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{ @@ -96,9 +112,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){ @@ -128,9 +150,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, @@ -153,9 +182,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 { @@ -175,9 +208,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: {}", @@ -193,9 +230,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 568af1f173..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,11 +21,16 @@ 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; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; @@ -34,6 +39,7 @@ import static cn.escheduler.api.enums.Status.*; /** * data analysis controller */ +@Api(tags = "DATA_ANALYSIS_TAG", position = 1) @RestController @RequestMapping("projects/analysis") public class DataAnalysisController extends BaseController{ @@ -52,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){ @@ -76,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){ @@ -100,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", @@ -123,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){ @@ -147,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 fcaf2beae9..5a0b911581 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 @@ -23,11 +23,16 @@ import cn.escheduler.api.utils.Result; import cn.escheduler.common.enums.DbType; import cn.escheduler.common.utils.ParameterUtils; 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; @@ -37,6 +42,7 @@ import static cn.escheduler.api.enums.Status.*; /** * data source controller */ +@Api(tags = "DATA_SOURCE_TAG", position = 3) @RestController @RequestMapping("datasources") public class DataSourceController extends BaseController { @@ -57,9 +63,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, @@ -93,9 +111,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, @@ -127,9 +158,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); @@ -150,9 +186,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()); @@ -172,9 +212,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) { @@ -202,9 +248,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, @@ -239,9 +297,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); @@ -269,9 +331,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); @@ -289,9 +355,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: {}", @@ -314,9 +384,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:{}", @@ -337,9 +411,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 a3c1e40cfd..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 @@ -24,11 +24,13 @@ import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.common.enums.*; import cn.escheduler.dao.model.User; +import io.swagger.annotations.Api; 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; @@ -38,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 603dced013..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 @@ -21,6 +21,10 @@ import cn.escheduler.api.service.LoggerService; 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; @@ -28,6 +32,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import static cn.escheduler.api.enums.Status.DOWNLOAD_TASK_INSTANCE_LOG_FILE_ERROR; import static cn.escheduler.api.enums.Status.QUERY_TASK_INSTANCE_LOG_ERROR; @@ -36,6 +41,7 @@ import static cn.escheduler.api.enums.Status.QUERY_TASK_INSTANCE_LOG_ERROR; /** * log controller */ +@Api(tags = "LOGGER_TAG", position = 13) @RestController @RequestMapping("/log") public class LoggerController extends BaseController { @@ -49,9 +55,15 @@ public class LoggerController extends BaseController { /** * query task log */ + @ApiOperation(value = "queryLog", notes= "QUERY_TASK_INSTANCE_LOG_NOTES") + @ApiImplicitParams({ + @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) - public Result queryLog(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryLog(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "taskInstId") int taskInstanceId, @RequestParam(value = "skipLineNum") int skipNum, @RequestParam(value = "limit") int limit) { @@ -73,9 +85,13 @@ public class LoggerController extends BaseController { * @param loginUser * @param taskInstanceId */ + @ApiOperation(value = "downloadTaskLog", notes= "DOWNLOAD_TASK_INSTANCE_LOG_NOTES") + @ApiImplicitParams({ + @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 60530c5376..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 @@ -23,34 +23,44 @@ 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.*; import org.apache.commons.httpclient.HttpStatus; 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; 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.*; /** * user login controller + * + * swagger bootstrap ui docs refer : https://doc.xiaominfo.com/guide/enh-func.html */ +@Api(tags = "LOGIN_TAG", position = 1) @RestController @RequestMapping("") public class LoginController extends BaseController { private static final Logger logger = LoggerFactory.getLogger(LoginController.class); + @Autowired private SessionService sessionService; @Autowired private UsersService userService; + /** * login * @@ -60,13 +70,17 @@ public class LoginController extends BaseController { * @param response * @return */ - @RequestMapping(value = "/login") + @ApiOperation(value = "login", notes= "LOGIN_NOTES") + @ApiImplicitParams({ + @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, @RequestParam(value = "userPassword") String userPassword, HttpServletRequest request, HttpServletResponse response) { - try { logger.info("login user name: {} ", userName); @@ -76,7 +90,6 @@ public class LoginController extends BaseController { Status.USER_NAME_NULL.getMsg()); } - // user ip check String ip = getClientIpAddress(request); if (StringUtils.isEmpty(ip)) { @@ -117,8 +130,9 @@ public class LoginController extends BaseController { * @param loginUser * @return */ + @ApiOperation(value = "signOut", notes = "SIGNOUT_NOTES") @PostMapping(value = "/signOut") - public Result signOut(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result signOut(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, HttpServletRequest request) { try { 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 8b28925a43..aa7615fe74 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 @@ -22,11 +22,13 @@ import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.common.utils.ParameterUtils; import cn.escheduler.dao.model.User; +import io.swagger.annotations.*; 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 +38,7 @@ import static cn.escheduler.api.enums.Status.*; /** * process definition controller */ +@Api(tags = "PROCESS_DEFINITION_TAG", position = 2) @RestController @RequestMapping("projects/{projectName}/process") public class ProcessDefinitionController extends BaseController{ @@ -55,28 +58,36 @@ public class ProcessDefinitionController extends BaseController{ * @param desc * @return */ - @PostMapping(value = "/save") - @ResponseStatus(HttpStatus.CREATED) - public Result createProcessDefinition(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, - @RequestParam(value = "name", required = true) String name, - @RequestParam(value = "processDefinitionJson", required = true) String json, - @RequestParam(value = "locations", required = false) String locations, - @RequestParam(value = "connects", required = false) String connects, - @RequestParam(value = "desc", required = false) String desc) { + @ApiOperation(value = "save", notes= "CREATE_PROCESS_DEFINITION_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "PROCESS_DEFINITION_NAME", required = true, type = "String"), + @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"), + @ApiImplicitParam(name = "desc", value = "PROCESS_DEFINITION_DESC", required = false, type ="String"), + }) + @PostMapping(value = "/save") + @ResponseStatus(HttpStatus.CREATED) + public Result createProcessDefinition(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "processDefinitionJson", required = true) String json, + @RequestParam(value = "locations", required = true) String locations, + @RequestParam(value = "connects", required = true) String connects, + @RequestParam(value = "desc", required = false) String desc) { - try { - logger.info("login user {}, create process definition, project name: {}, process definition name: {}, " + - "process_definition_json: {}, desc: {} locations:{}, connects:{}", - loginUser.getUserName(), projectName, name, json,desc, locations, connects); - Map result = processDefinitionService.createProcessDefinition(loginUser, projectName, name, json, - desc, locations, connects ); - return returnDataList(result); - }catch (Exception e){ - logger.error(CREATE_PROCESS_DEFINITION.getMsg(),e); - return error(CREATE_PROCESS_DEFINITION.getCode(), CREATE_PROCESS_DEFINITION.getMsg()); + try { + logger.info("login user {}, create process definition, project name: {}, process definition name: {}, " + + "process_definition_json: {}, desc: {} locations:{}, connects:{}", + loginUser.getUserName(), projectName, name, json, desc, locations, connects); + Map result = processDefinitionService.createProcessDefinition(loginUser, projectName, name, json, + desc, locations, connects); + return returnDataList(result); + } catch (Exception e) { + logger.error(CREATE_PROCESS_DEFINITION.getMsg(), e); + return error(CREATE_PROCESS_DEFINITION.getCode(), CREATE_PROCESS_DEFINITION.getMsg()); + } } - } /** * verify process definition name unique @@ -86,10 +97,14 @@ public class ProcessDefinitionController extends BaseController{ * @param name * @return */ + @ApiOperation(value = "verify-name", notes = "VERIFY_PROCCESS_DEFINITION_NAME_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "PROCESS_DEFINITION_NAME", required = true, type = "String") + }) @GetMapping(value = "/verify-name") @ResponseStatus(HttpStatus.OK) - public Result verifyProccessDefinitionName(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result verifyProccessDefinitionName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME",required = true) @PathVariable String projectName, @RequestParam(value = "name", required = true) String name){ try { logger.info("verify process definition name unique, user:{}, project name:{}, process definition name:{}", @@ -103,7 +118,7 @@ public class ProcessDefinitionController extends BaseController{ } /** - * update process definition + * update process definition * * @param loginUser * @param projectName @@ -113,10 +128,19 @@ public class ProcessDefinitionController extends BaseController{ * @param desc * @return */ + @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, 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"), + @ApiImplicitParam(name = "desc", value = "PROCESS_DEFINITION_DESC", required = false, type ="String"), + }) @PostMapping(value = "/update") @ResponseStatus(HttpStatus.OK) - public Result updateProccessDefinition(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result updateProccessDefinition(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME",required = true) @PathVariable String projectName, @RequestParam(value = "name", required = true) String name, @RequestParam(value = "id", required = true) int id, @RequestParam(value = "processDefinitionJson", required = true) String processDefinitionJson, @@ -146,10 +170,16 @@ public class ProcessDefinitionController extends BaseController{ * @param releaseState * @return */ + @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, dataType = "Int", example = "100"), + @ApiImplicitParam(name = "releaseState", value = "PROCESS_DEFINITION_CONNECTS", required = true, dataType = "Int", example = "100"), + }) @PostMapping(value = "/release") @ResponseStatus(HttpStatus.OK) - public Result releaseProccessDefinition(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result releaseProccessDefinition(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME",required = true) @PathVariable String projectName, @RequestParam(value = "processId", required = true) int processId, @RequestParam(value = "releaseState", required = true) int releaseState) { @@ -173,10 +203,14 @@ public class ProcessDefinitionController extends BaseController{ * @param processId * @return */ + @ApiOperation(value = "queryProccessDefinitionById", notes= "QUERY_PROCCESS_DEFINITION_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "processId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100") + }) @GetMapping(value="/select-by-id") @ResponseStatus(HttpStatus.OK) - public Result queryProccessDefinitionById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result queryProccessDefinitionById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME",required = true) @PathVariable String projectName, @RequestParam("processId") Integer processId ){ try{ @@ -198,10 +232,11 @@ public class ProcessDefinitionController extends BaseController{ * @param projectName * @return */ + @ApiOperation(value = "queryProccessDefinitionList", notes= "QUERY_PROCCESS_DEFINITION_LIST_NOTES") @GetMapping(value="/list") @ResponseStatus(HttpStatus.OK) - public Result queryProccessDefinitionList(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName + public Result queryProccessDefinitionList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME",required = true) @PathVariable String projectName ){ try{ logger.info("query proccess definition list, login user:{}, project name:{}", @@ -222,10 +257,17 @@ public class ProcessDefinitionController extends BaseController{ * @param pageSize * @return */ + @ApiOperation(value = "queryProcessDefinitionListPaging", notes= "QUERY_PROCCESS_DEFINITION_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @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, dataType = "Int", example = "100"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "100") + }) @GetMapping(value="/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryProcessDefinitionListPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result queryProcessDefinitionListPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME",required = true) @PathVariable String projectName, @RequestParam("pageNo") Integer pageNo, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam(value = "userId", required = false, defaultValue = "0") Integer userId, @@ -254,10 +296,15 @@ public class ProcessDefinitionController extends BaseController{ * @param id * @return */ + @ApiOperation(value = "viewTree", notes= "VIEW_TREE_NOTES") + @ApiImplicitParams({ + @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) - public Result viewTree(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result viewTree(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME",required = true) @PathVariable String projectName, @RequestParam("processId") Integer id, @RequestParam("limit") Integer limit){ try{ @@ -280,11 +327,15 @@ public class ProcessDefinitionController extends BaseController{ * @param processDefinitionId * @return */ + @ApiOperation(value = "getNodeListByDefinitionId", notes= "GET_NODE_LIST_BY_DEFINITION_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100") + }) @GetMapping(value="gen-task-list") @ResponseStatus(HttpStatus.OK) public Result getNodeListByDefinitionId( - @RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + @ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME",required = true) @PathVariable String projectName, @RequestParam("processDefinitionId") Integer processDefinitionId){ try { logger.info("query task node name list by definitionId, login user:{}, project name:{}, id : {}", @@ -307,11 +358,15 @@ public class ProcessDefinitionController extends BaseController{ * @param processDefinitionIdList * @return */ + @ApiOperation(value = "getNodeListByDefinitionIdList", notes= "GET_NODE_LIST_BY_DEFINITION_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "processDefinitionIdList", value = "PROCESS_DEFINITION_ID_LIST", required = true, type = "String") + }) @GetMapping(value="get-task-list") @ResponseStatus(HttpStatus.OK) public Result getNodeListByDefinitionIdList( - @RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + @ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME",required = true) @PathVariable String projectName, @RequestParam("processDefinitionIdList") String processDefinitionIdList){ try { 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 cea47be2c6..2a08eac714 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 @@ -26,11 +26,13 @@ import cn.escheduler.common.queue.ITaskQueue; import cn.escheduler.common.queue.TaskQueueFactory; import cn.escheduler.common.utils.ParameterUtils; import cn.escheduler.dao.model.User; +import io.swagger.annotations.*; 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; @@ -39,6 +41,7 @@ import static cn.escheduler.api.enums.Status.*; /** * process instance controller */ +@Api(tags = "PROCESS_INSTANCE_TAG", position = 10) @RestController @RequestMapping("projects/{projectName}/instance") public class ProcessInstanceController extends BaseController{ @@ -58,10 +61,21 @@ public class ProcessInstanceController extends BaseController{ * @param pageSize * @return */ + @ApiOperation(value = "queryProcessInstanceList", notes= "QUERY_PROCESS_INSTANCE_LIST_NOTES") + @ApiImplicitParams({ + @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", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100") + }) @GetMapping(value="list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryProcessInstanceList(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result queryProcessInstanceList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam(value = "processDefinitionId", required = false, defaultValue = "0") Integer processDefinitionId, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam(value = "stateType", required = false) ExecutionStatus stateType, @@ -90,19 +104,23 @@ public class ProcessInstanceController extends BaseController{ * * @param loginUser * @param projectName - * @param workflowId + * @param processInstanceId * @return */ + @ApiOperation(value = "queryTaskListByProcessId", notes= "QUERY_TASK_LIST_BY_PROCESS_INSTANCE_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") + }) @GetMapping(value="/task-list-by-process-id") @ResponseStatus(HttpStatus.OK) - public Result queryTaskListByProcessId(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, - @RequestParam("processInstanceId") Integer workflowId + public Result queryTaskListByProcessId(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, + @RequestParam("processInstanceId") Integer processInstanceId ) { try{ - logger.info("query task instance list by process instance id, login user:{}, project name:{}, work instance id:{}", - loginUser.getUserName(), projectName, workflowId); - Map result = processInstanceService.queryTaskListByProcessId(loginUser, projectName, workflowId); + logger.info("query task instance list by process instance id, login user:{}, project name:{}, process instance id:{}", + loginUser.getUserName(), projectName, processInstanceId); + Map result = processInstanceService.queryTaskListByProcessId(loginUser, projectName, processInstanceId); return returnDataList(result); }catch (Exception e){ logger.error(QUERY_TASK_LIST_BY_PROCESS_INSTANCE_ID_ERROR.getMsg(),e); @@ -122,10 +140,20 @@ public class ProcessInstanceController extends BaseController{ * @param flag * @return */ + @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", 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"), + @ApiImplicitParam(name = "connects", value = "PROCESS_INSTANCE_CONNECTS", type = "String"), + @ApiImplicitParam(name = "flag", value = "RECOVERY_PROCESS_INSTANCE_FLAG", type = "Flag"), + }) @PostMapping(value="/update") @ResponseStatus(HttpStatus.OK) - public Result updateProcessInstance(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result updateProcessInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam( value = "processInstanceJson", required = false) String processInstanceJson, @RequestParam( value = "processInstanceId") Integer processInstanceId, @RequestParam( value = "scheduleTime", required = false) String scheduleTime, @@ -156,10 +184,14 @@ public class ProcessInstanceController extends BaseController{ * @param processInstanceId * @return */ + @ApiOperation(value = "queryProcessInstanceById", notes= "QUERY_PROCESS_INSTANCE_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") + }) @GetMapping(value="/select-by-id") @ResponseStatus(HttpStatus.OK) - public Result queryProcessInstanceById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result queryProcessInstanceById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam("processInstanceId") Integer processInstanceId ){ try{ @@ -182,10 +214,14 @@ public class ProcessInstanceController extends BaseController{ * @param processInstanceId * @return */ + @ApiOperation(value = "deleteProcessInstanceById", notes= "DELETE_PROCESS_INSTANCE_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") + }) @GetMapping(value="/delete") @ResponseStatus(HttpStatus.OK) - public Result deleteProcessInstanceById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result deleteProcessInstanceById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam("processInstanceId") Integer processInstanceId ){ try{ @@ -209,10 +245,14 @@ public class ProcessInstanceController extends BaseController{ * @param taskId * @return */ + @ApiOperation(value = "querySubProcessInstanceByTaskId", notes= "QUERY_SUBPROCESS_INSTANCE_BY_TASK_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "taskId", value = "TASK_ID", dataType = "Int", example = "100") + }) @GetMapping(value="/select-sub-process") @ResponseStatus(HttpStatus.OK) - public Result querySubProcessInstanceByTaskId(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result querySubProcessInstanceByTaskId(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam("taskId") Integer taskId){ try{ Map result = processInstanceService.querySubProcessInstanceByTaskId(loginUser, projectName, taskId); @@ -231,10 +271,14 @@ public class ProcessInstanceController extends BaseController{ * @param subId * @return */ + @ApiOperation(value = "queryParentInstanceBySubId", notes= "QUERY_PARENT_PROCESS_INSTANCE_BY_SUB_PROCESS_INSTANCE_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "subId", value = "SUB_PROCESS_INSTANCE_ID", dataType = "Int", example = "100") + }) @GetMapping(value="/select-parent-process") @ResponseStatus(HttpStatus.OK) - public Result queryParentInstanceBySubId(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result queryParentInstanceBySubId(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam("subId") Integer subId){ try{ Map result = processInstanceService.queryParentInstanceBySubId(loginUser, projectName, subId); @@ -252,9 +296,13 @@ public class ProcessInstanceController extends BaseController{ * @param processInstanceId * @return */ + @ApiOperation(value = "viewVariables", notes= "QUERY_PROCESS_INSTANCE_GLOBAL_VARIABLES_AND_LOCAL_VARIABLES_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") + }) @GetMapping(value="/view-variables") @ResponseStatus(HttpStatus.OK) - public Result viewVariables(@RequestAttribute(value = Constants.SESSION_USER) User loginUser + public Result viewVariables(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser , @RequestParam("processInstanceId") Integer processInstanceId){ try{ Map result = processInstanceService.viewVariables(processInstanceId); @@ -273,10 +321,14 @@ public class ProcessInstanceController extends BaseController{ * @param processInstanceId * @return */ + @ApiOperation(value = "vieGanttTree", notes= "VIEW_GANTT_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", dataType = "Int", example = "100") + }) @GetMapping(value="/view-gantt") @ResponseStatus(HttpStatus.OK) - public Result viewTree(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result viewTree(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam("processInstanceId") Integer processInstanceId){ try{ Map result = processInstanceService.viewGantt(processInstanceId); 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 1a4b30c889..fbb650c42d 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 @@ -23,11 +23,16 @@ import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.common.utils.ParameterUtils; 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.*; /** * project controller */ +@Api(tags = "PROJECT_TAG", position = 1) @RestController @RequestMapping("projects") public class ProjectController extends BaseController { @@ -53,9 +59,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) { @@ -78,9 +89,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) { @@ -101,9 +118,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); @@ -125,9 +146,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 @@ -151,9 +178,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 ) { @@ -174,9 +205,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); @@ -196,9 +231,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 89ac8f05c1..d2b7c14075 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 @@ -23,11 +23,16 @@ import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.common.utils.ParameterUtils; 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; @@ -37,6 +42,7 @@ import static cn.escheduler.api.enums.Status.*; /** * queue controller */ +@Api(tags = "QUEUE_TAG", position = 1) @RestController @RequestMapping("/queue") public class QueueController extends BaseController{ @@ -52,9 +58,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); @@ -70,9 +77,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){ @@ -100,9 +113,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: {}", @@ -125,9 +143,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) { @@ -151,9 +175,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 1574012d19..6de3a75272 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 @@ -25,6 +25,10 @@ import cn.escheduler.common.enums.ResourceType; import cn.escheduler.common.enums.UdfType; import cn.escheduler.common.utils.ParameterUtils; 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; @@ -35,6 +39,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; @@ -43,6 +48,7 @@ import static cn.escheduler.api.enums.Status.*; /** * resources controller */ +@Api(tags = "RESOURCES_TAG", position = 1) @RestController @RequestMapping("resources") public class ResourcesController extends BaseController{ @@ -63,8 +69,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, @@ -86,8 +99,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, @@ -108,10 +129,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()); @@ -131,10 +156,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 @@ -163,9 +195,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{ @@ -187,11 +223,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: {}", @@ -210,8 +251,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 @@ -238,8 +285,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, @@ -266,8 +321,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 ) { @@ -291,9 +351,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 : {}", @@ -324,9 +388,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, @@ -353,9 +428,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(); @@ -382,8 +462,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, @@ -411,9 +502,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 @@ -435,14 +532,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()); @@ -461,9 +562,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: {}", @@ -484,9 +590,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{ @@ -506,9 +616,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); @@ -528,9 +642,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); @@ -550,9 +668,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); @@ -573,9 +695,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 b0b7412dd8..82fe7cb727 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 @@ -26,11 +26,13 @@ import cn.escheduler.common.enums.ReleaseState; import cn.escheduler.common.enums.WarningType; import cn.escheduler.common.utils.ParameterUtils; import cn.escheduler.dao.model.User; +import io.swagger.annotations.*; 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; @@ -40,9 +42,10 @@ import static cn.escheduler.api.utils.Constants.SESSION_USER; /** * schedule controller */ +@Api(tags = "SCHEDULER_TAG", position = 13) @RestController @RequestMapping("/projects/{projectName}/schedule") -public class SchedulerController extends BaseController{ +public class SchedulerController extends BaseController { private static final Logger logger = LoggerFactory.getLogger(SchedulerController.class); public static final String DEFAULT_WARNING_TYPE = "NONE"; @@ -66,33 +69,45 @@ public class SchedulerController extends BaseController{ * @param failureStrategy * @return */ - @PostMapping("/create") - @ResponseStatus(HttpStatus.CREATED) - public Result createSchedule(@RequestAttribute(value = SESSION_USER) User loginUser, - @PathVariable String projectName, - @RequestParam(value = "processDefinitionId") Integer processDefinitionId, - @RequestParam(value = "schedule") String schedule, - @RequestParam(value = "warningType", required = false,defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType, - @RequestParam(value = "warningGroupId", required = false,defaultValue = DEFAULT_NOTIFY_GROUP_ID) int warningGroupId, - @RequestParam(value = "failureStrategy", required = false, defaultValue = DEFAULT_FAILURE_POLICY) FailureStrategy failureStrategy, - @RequestParam(value = "receivers", required = false) String receivers, - @RequestParam(value = "receiversCc", required = false) String receiversCc, - @RequestParam(value = "workerGroupId", required = false, defaultValue = "-1") int workerGroupId, - @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) { - logger.info("login user {}, project name: {}, process name: {}, create schedule: {}, warning type: {}, warning group id: {}," + - "failure policy: {},receivers : {},receiversCc : {},processInstancePriority : {}, workGroupId:{}", - loginUser.getUserName(), projectName, processDefinitionId, schedule, warningType, warningGroupId, - failureStrategy,receivers,receiversCc,processInstancePriority,workerGroupId); - try { - Map result = schedulerService.insertSchedule(loginUser, projectName, processDefinitionId, schedule, - warningType, warningGroupId, failureStrategy, receivers,receiversCc,processInstancePriority,workerGroupId); + @ApiOperation(value = "createSchedule", notes= "CREATE_SCHEDULE_NOTES") + @ApiImplicitParams({ + @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", 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", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type ="Priority"), + }) + @PostMapping("/create") + @ResponseStatus(HttpStatus.CREATED) + public Result createSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, + @RequestParam(value = "processDefinitionId") Integer processDefinitionId, + @RequestParam(value = "schedule") String schedule, + @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType, + @RequestParam(value = "warningGroupId", required = false, defaultValue = DEFAULT_NOTIFY_GROUP_ID) int warningGroupId, + @RequestParam(value = "failureStrategy", required = false, defaultValue = DEFAULT_FAILURE_POLICY) FailureStrategy failureStrategy, + @RequestParam(value = "receivers", required = false) String receivers, + @RequestParam(value = "receiversCc", required = false) String receiversCc, + @RequestParam(value = "workerGroupId", required = false, defaultValue = "-1") int workerGroupId, + @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) { + logger.info("login user {}, project name: {}, process name: {}, create schedule: {}, warning type: {}, warning group id: {}," + + "failure policy: {},receivers : {},receiversCc : {},processInstancePriority : {}, workGroupId:{}", + loginUser.getUserName(), projectName, processDefinitionId, schedule, warningType, warningGroupId, + failureStrategy, receivers, receiversCc, processInstancePriority, workerGroupId); + try { + Map result = schedulerService.insertSchedule(loginUser, projectName, processDefinitionId, schedule, + warningType, warningGroupId, failureStrategy, receivers, receiversCc, processInstancePriority, workerGroupId); - return returnDataList(result); - }catch (Exception e){ - logger.error(CREATE_SCHEDULE_ERROR.getMsg(),e); - return error(CREATE_SCHEDULE_ERROR.getCode(), CREATE_SCHEDULE_ERROR.getMsg()); - } - } + return returnDataList(result); + } catch (Exception e) { + logger.error(CREATE_SCHEDULE_ERROR.getMsg(), e); + return error(CREATE_SCHEDULE_ERROR.getCode(), CREATE_SCHEDULE_ERROR.getMsg()); + } + } /** * updateProcessInstance schedule @@ -106,33 +121,45 @@ public class SchedulerController extends BaseController{ * @param failureStrategy * @return */ - @PostMapping("/update") - public Result updateSchedule(@RequestAttribute(value = SESSION_USER) User loginUser, - @PathVariable String projectName, - @RequestParam(value = "id") Integer id, - @RequestParam(value = "schedule") String schedule, - @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType, - @RequestParam(value = "warningGroupId", required = false) int warningGroupId, - @RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy, - @RequestParam(value = "receivers", required = false) String receivers, - @RequestParam(value = "receiversCc", required = false) String receiversCc, - @RequestParam(value = "workerGroupId", required = false, defaultValue = "-1") int workerGroupId, - @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) { - logger.info("login user {}, project name: {},id: {}, updateProcessInstance schedule: {}, notify type: {}, notify mails: {}, " + - "failure policy: {},receivers : {},receiversCc : {},processInstancePriority : {},workerGroupId:{}", - loginUser.getUserName(), projectName, id, schedule, warningType, warningGroupId, failureStrategy, - receivers,receiversCc,processInstancePriority,workerGroupId); + @ApiOperation(value = "updateSchedule", notes= "UPDATE_SCHEDULE_NOTES") + @ApiImplicitParams({ + @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", 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", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type ="Priority"), + }) + @PostMapping("/update") + public Result updateSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, + @RequestParam(value = "id") Integer id, + @RequestParam(value = "schedule") String schedule, + @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType, + @RequestParam(value = "warningGroupId", required = false) int warningGroupId, + @RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy, + @RequestParam(value = "receivers", required = false) String receivers, + @RequestParam(value = "receiversCc", required = false) String receiversCc, + @RequestParam(value = "workerGroupId", required = false, defaultValue = "-1") int workerGroupId, + @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) { + logger.info("login user {}, project name: {},id: {}, updateProcessInstance schedule: {}, notify type: {}, notify mails: {}, " + + "failure policy: {},receivers : {},receiversCc : {},processInstancePriority : {},workerGroupId:{}", + loginUser.getUserName(), projectName, id, schedule, warningType, warningGroupId, failureStrategy, + receivers, receiversCc, processInstancePriority, workerGroupId); - try { - Map result = schedulerService.updateSchedule(loginUser, projectName, id, schedule, - warningType, warningGroupId, failureStrategy, receivers,receiversCc,null,processInstancePriority, workerGroupId); - return returnDataList(result); + try { + Map result = schedulerService.updateSchedule(loginUser, projectName, id, schedule, + warningType, warningGroupId, failureStrategy, receivers, receiversCc, null, processInstancePriority, workerGroupId); + return returnDataList(result); - }catch (Exception e){ - logger.error(UPDATE_SCHEDULE_ERROR.getMsg(),e); - return error(Status.UPDATE_SCHEDULE_ERROR.getCode(), Status.UPDATE_SCHEDULE_ERROR.getMsg()); - } - } + } catch (Exception e) { + logger.error(UPDATE_SCHEDULE_ERROR.getMsg(), e); + return error(Status.UPDATE_SCHEDULE_ERROR.getCode(), Status.UPDATE_SCHEDULE_ERROR.getMsg()); + } + } /** * publish schedule setScheduleState @@ -143,21 +170,25 @@ public class SchedulerController extends BaseController{ * @return * @throws Exception */ - @PostMapping("/online") - public Result online(@RequestAttribute(value = SESSION_USER) User loginUser, - @PathVariable("projectName") String projectName, - @RequestParam("id") Integer id) { - logger.info("login user {}, schedule setScheduleState, project name: {}, id: {}", - loginUser.getUserName(), projectName, id); - try { - Map result = schedulerService.setScheduleState(loginUser, projectName, id, ReleaseState.ONLINE); - return returnDataList(result); + @ApiOperation(value = "online", notes= "ONLINE_SCHEDULE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100") + }) + @PostMapping("/online") + public Result online(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable("projectName") String projectName, + @RequestParam("id") Integer id) { + logger.info("login user {}, schedule setScheduleState, project name: {}, id: {}", + loginUser.getUserName(), projectName, id); + try { + Map result = schedulerService.setScheduleState(loginUser, projectName, id, ReleaseState.ONLINE); + return returnDataList(result); - }catch (Exception e){ - logger.error(PUBLISH_SCHEDULE_ONLINE_ERROR.getMsg(),e); - return error(Status.PUBLISH_SCHEDULE_ONLINE_ERROR.getCode(), Status.PUBLISH_SCHEDULE_ONLINE_ERROR.getMsg()); - } - } + } catch (Exception e) { + logger.error(PUBLISH_SCHEDULE_ONLINE_ERROR.getMsg(), e); + return error(Status.PUBLISH_SCHEDULE_ONLINE_ERROR.getCode(), Status.PUBLISH_SCHEDULE_ONLINE_ERROR.getMsg()); + } + } /** * offline schedule @@ -167,22 +198,26 @@ public class SchedulerController extends BaseController{ * @param id * @return */ - @PostMapping("/offline") - public Result offline(@RequestAttribute(value = SESSION_USER) User loginUser, - @PathVariable("projectName") String projectName, - @RequestParam("id") Integer id) { - logger.info("login user {}, schedule offline, project name: {}, process definition id: {}", - loginUser.getUserName(), projectName, id); + @ApiOperation(value = "offline", notes= "OFFLINE_SCHEDULE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100") + }) + @PostMapping("/offline") + public Result offline(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable("projectName") String projectName, + @RequestParam("id") Integer id) { + logger.info("login user {}, schedule offline, project name: {}, process definition id: {}", + loginUser.getUserName(), projectName, id); - try { - Map result = schedulerService.setScheduleState(loginUser, projectName, id, ReleaseState.OFFLINE); - return returnDataList(result); + try { + Map result = schedulerService.setScheduleState(loginUser, projectName, id, ReleaseState.OFFLINE); + return returnDataList(result); - }catch (Exception e){ - logger.error(OFFLINE_SCHEDULE_ERROR.getMsg(),e); - return error(Status.OFFLINE_SCHEDULE_ERROR.getCode(), Status.OFFLINE_SCHEDULE_ERROR.getMsg()); - } - } + } catch (Exception e) { + logger.error(OFFLINE_SCHEDULE_ERROR.getMsg(), e); + return error(Status.OFFLINE_SCHEDULE_ERROR.getCode(), Status.OFFLINE_SCHEDULE_ERROR.getMsg()); + } + } /** * query schedule list paging @@ -192,8 +227,17 @@ public class SchedulerController extends BaseController{ * @param processDefinitionId * @return */ + @ApiOperation(value = "queryScheduleListPaging", notes= "QUERY_SCHEDULE_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @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", dataType = "Int", example = "100"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100") + + }) @GetMapping("/list-paging") - public Result querySchedule(@RequestAttribute(value = SESSION_USER) User loginUser, + public Result queryScheduleListPaging(@RequestAttribute(value = SESSION_USER) User loginUser, @PathVariable String projectName, @RequestParam Integer processDefinitionId, @RequestParam(value = "searchVal", required = false) String searchVal, @@ -210,28 +254,7 @@ public class SchedulerController extends BaseController{ return error(Status.QUERY_SCHEDULE_LIST_PAGING_ERROR.getCode(), Status.QUERY_SCHEDULE_LIST_PAGING_ERROR.getMsg()); } - } - - /** - * query schedule list - * - * @param loginUser - * @param projectName - * @return - */ - @PostMapping("/list") - public Result queryScheduleList(@RequestAttribute(value = SESSION_USER) User loginUser, - @PathVariable String projectName) { - try{ - logger.info("login user {}, query schedule list, project name: {}", - loginUser.getUserName(), projectName); - Map result = schedulerService.queryScheduleList(loginUser, projectName); - return returnDataList(result); - }catch (Exception e){ - logger.error(QUERY_SCHEDULE_LIST_ERROR.getMsg(),e); - return error(Status.QUERY_SCHEDULE_LIST_ERROR.getCode(), Status.QUERY_SCHEDULE_LIST_ERROR.getMsg()); - } - } + } /** * delete schedule by id @@ -257,4 +280,25 @@ public class SchedulerController extends BaseController{ return error(Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR.getCode(), Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR.getMsg()); } } + /** + * query schedule list + * + * @param loginUser + * @param projectName + * @return + */ + @ApiOperation(value = "queryScheduleList", notes= "QUERY_SCHEDULE_LIST_NOTES") + @PostMapping("/list") + public Result queryScheduleList(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName) { + try { + logger.info("login user {}, query schedule list, project name: {}", + loginUser.getUserName(), projectName); + Map result = schedulerService.queryScheduleList(loginUser, projectName); + return returnDataList(result); + } catch (Exception e) { + logger.error(QUERY_SCHEDULE_LIST_ERROR.getMsg(), e); + return error(Status.QUERY_SCHEDULE_LIST_ERROR.getCode(), Status.QUERY_SCHEDULE_LIST_ERROR.getMsg()); + } + } } 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 401f5e8f0a..ebe4e86995 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 @@ -23,11 +23,13 @@ import cn.escheduler.api.utils.Result; import cn.escheduler.common.enums.ExecutionStatus; import cn.escheduler.common.utils.ParameterUtils; import cn.escheduler.dao.model.User; +import io.swagger.annotations.*; 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 +38,7 @@ import static cn.escheduler.api.enums.Status.QUERY_TASK_LIST_PAGING_ERROR; /** * task instance controller */ +@Api(tags = "TASK_INSTANCE_TAG", position = 11) @RestController @RequestMapping("/projects/{projectName}/task-instance") public class TaskInstanceController extends BaseController{ @@ -52,10 +55,22 @@ public class TaskInstanceController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "queryTaskListPaging", notes= "QUERY_TASK_INSTANCE_LIST_PAGING_NOTES") + @ApiImplicitParams({ + @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", dataType = "Int", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "20") + }) @GetMapping("/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryTaskListPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable String projectName, + public Result queryTaskListPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam(value = "processInstanceId", required = false, defaultValue = "0") Integer processInstanceId, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam(value = "taskName", required = false) String taskName, 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 46e5b2961d..1dc74bce48 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 @@ -24,11 +24,16 @@ import cn.escheduler.api.utils.Result; import cn.escheduler.common.utils.ParameterUtils; import cn.escheduler.dao.model.User; import org.apache.commons.lang3.StringUtils; +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; @@ -38,6 +43,7 @@ import static cn.escheduler.api.enums.Status.*; /** * tenant controller */ +@Api(tags = "TENANT_TAG", position = 1) @RestController @RequestMapping("/tenant") public class TenantController extends BaseController{ @@ -58,9 +64,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, @@ -87,9 +101,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){ @@ -116,9 +136,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); @@ -141,9 +162,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, @@ -167,9 +197,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 { @@ -189,9 +224,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 41a6a63bb1..21c5e6f491 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 @@ -23,11 +23,16 @@ import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.Result; import cn.escheduler.common.utils.ParameterUtils; 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; @@ -37,14 +42,13 @@ import static cn.escheduler.api.enums.Status.*; /** * user controller */ +@Api(tags = "USERS_TAG" , position = 14) @RestController @RequestMapping("/users") public class UsersController extends BaseController{ - private static final Logger logger = LoggerFactory.getLogger(UsersController.class); - @Autowired private UsersService usersService; @@ -59,9 +63,18 @@ public class UsersController extends BaseController{ * @param phone * @return */ + @ApiOperation(value = "createUser", notes= "CREATE_USER_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userName", value = "USER_NAME",type = "String"), + @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", type ="String"), + @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) - public Result createUser(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result createUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userName") String userName, @RequestParam(value = "userPassword") String userPassword, @RequestParam(value = "tenantId") int tenantId, @@ -89,9 +102,15 @@ public class UsersController extends BaseController{ * @param pageSize * @return */ + @ApiOperation(value = "queryUserList", notes= "QUERY_USER_LIST_NOTES") + @ApiImplicitParams({ + @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") + }) @GetMapping(value="/list-paging") @ResponseStatus(HttpStatus.OK) - public Result queryUserList(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result queryUserList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("pageNo") Integer pageNo, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize){ @@ -113,7 +132,7 @@ public class UsersController extends BaseController{ /** - * updateProcessInstance user + * update user * * @param loginUser * @param id @@ -124,9 +143,19 @@ public class UsersController extends BaseController{ * @param phone * @return */ + @ApiOperation(value = "updateUser", notes= "UPDATE_USER_NOTES") + @ApiImplicitParams({ + @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", 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) - public Result updateUser(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result updateUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int id, @RequestParam(value = "userName") String userName, @RequestParam(value = "userPassword") String userPassword, @@ -151,9 +180,13 @@ public class UsersController extends BaseController{ * @param id * @return */ + @ApiOperation(value = "delUserById", notes= "DELETE_USER_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "USER_ID",dataType = "Int", example = "100") + }) @PostMapping(value = "/delete") @ResponseStatus(HttpStatus.OK) - public Result delUserById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result delUserById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int id) { logger.info("login user {}, delete user, userId: {},", loginUser.getUserName(), id); try { @@ -172,9 +205,14 @@ public class UsersController extends BaseController{ * @param userId * @return */ + @ApiOperation(value = "grantProject", notes= "GRANT_PROJECT_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID",dataType = "Int", example = "100"), + @ApiImplicitParam(name = "projectIds", value = "PROJECT_IDS",type = "String") + }) @PostMapping(value = "/grant-project") @ResponseStatus(HttpStatus.OK) - public Result grantProject(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result grantProject(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userId") int userId, @RequestParam(value = "projectIds") String projectIds) { logger.info("login user {}, grant project, userId: {},projectIds : {}", loginUser.getUserName(), userId,projectIds); @@ -194,9 +232,14 @@ public class UsersController extends BaseController{ * @param userId * @return */ + @ApiOperation(value = "grantResource", notes= "GRANT_RESOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID",dataType = "Int", example = "100"), + @ApiImplicitParam(name = "resourceIds", value = "RESOURCE_IDS",type = "String") + }) @PostMapping(value = "/grant-file") @ResponseStatus(HttpStatus.OK) - public Result grantResource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result grantResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userId") int userId, @RequestParam(value = "resourceIds") String resourceIds) { logger.info("login user {}, grant project, userId: {},resourceIds : {}", loginUser.getUserName(), userId,resourceIds); @@ -217,9 +260,14 @@ public class UsersController extends BaseController{ * @param userId * @return */ + @ApiOperation(value = "grantUDFFunc", notes= "GRANT_UDF_FUNC_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID",dataType = "Int", example = "100"), + @ApiImplicitParam(name = "udfIds", value = "UDF_IDS",type = "String") + }) @PostMapping(value = "/grant-udf-func") @ResponseStatus(HttpStatus.OK) - public Result grantUDFFunc(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result grantUDFFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userId") int userId, @RequestParam(value = "udfIds") String udfIds) { logger.info("login user {}, grant project, userId: {},resourceIds : {}", loginUser.getUserName(), userId,udfIds); @@ -241,9 +289,14 @@ public class UsersController extends BaseController{ * @param userId * @return */ + @ApiOperation(value = "grantDataSource", notes= "GRANT_DATASOURCE_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "USER_ID",dataType = "Int", example = "100"), + @ApiImplicitParam(name = "datasourceIds", value = "DATASOURCE_IDS",type = "String") + }) @PostMapping(value = "/grant-datasource") @ResponseStatus(HttpStatus.OK) - public Result grantDataSource(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result grantDataSource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userId") int userId, @RequestParam(value = "datasourceIds") String datasourceIds) { logger.info("login user {}, grant project, userId: {},projectIds : {}", loginUser.getUserName(),userId,datasourceIds); @@ -263,9 +316,10 @@ public class UsersController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "getUserInfo", notes= "GET_USER_INFO_NOTES") @GetMapping(value="/get-user-info") @ResponseStatus(HttpStatus.OK) - public Result getUserInfo(@RequestAttribute(value = Constants.SESSION_USER) User loginUser){ + public Result getUserInfo(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser){ logger.info("login user {},get user info : {}", loginUser.getUserName()); try{ Map result = usersService.getUserInfo(loginUser); @@ -282,9 +336,10 @@ public class UsersController extends BaseController{ * @param loginUser * @return */ + @ApiOperation(value = "listUser", notes= "LIST_USER_NOTES") @GetMapping(value="/list") @ResponseStatus(HttpStatus.OK) - public Result listUser(@RequestAttribute(value = Constants.SESSION_USER) User loginUser){ + public Result listUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser){ logger.info("login user {}, user list"); try{ Map result = usersService.queryAllGeneralUsers(loginUser); @@ -323,9 +378,13 @@ public class UsersController extends BaseController{ * @param userName * @return */ + @ApiOperation(value = "verifyUserName", notes= "VERIFY_USER_NAME_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userName", value = "USER_NAME",type = "String") + }) @GetMapping(value = "/verify-user-name") @ResponseStatus(HttpStatus.OK) - public Result verifyUserName(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result verifyUserName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value ="userName") String userName ) { try{ @@ -347,9 +406,13 @@ public class UsersController extends BaseController{ * @param alertgroupId * @return */ + @ApiOperation(value = "unauthorizedUser", notes= "UNAUTHORIZED_USER_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "alertgroupId", value = "ALERT_GROUP_ID",type = "String") + }) @GetMapping(value = "/unauth-user") @ResponseStatus(HttpStatus.OK) - public Result unauthorizedUser(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result unauthorizedUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("alertgroupId") Integer alertgroupId) { try{ logger.info("unauthorized user, login user:{}, alert group id:{}", @@ -370,9 +433,13 @@ public class UsersController extends BaseController{ * @param alertgroupId * @return */ + @ApiOperation(value = "authorizedUser", notes= "AUTHORIZED_USER_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "alertgroupId", value = "ALERT_GROUP_ID",type = "String") + }) @GetMapping(value = "/authed-user") @ResponseStatus(HttpStatus.OK) - public Result authorizedUser(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + public Result authorizedUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("alertgroupId") Integer alertgroupId) { try{ logger.info("authorized user , login user:{}, alert group id:{}", 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 93ca2dfa3c..68774e7bc6 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,21 +19,28 @@ 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.common.utils.ParameterUtils; 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.utils.Constants.SESSION_USER; + /** * worker group controller */ +@Api(tags = "WORKER_GROUP_TAG", position = 1) @RestController @RequestMapping("/worker-group") public class WorkerGroupController extends BaseController{ @@ -53,9 +60,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 @@ -80,9 +93,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 +124,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 +147,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/java/cn/escheduler/api/service/SchedulerService.java b/escheduler-api/src/main/java/cn/escheduler/api/service/SchedulerService.java index 5ea5faf83d..5006573702 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/service/SchedulerService.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/service/SchedulerService.java @@ -19,8 +19,8 @@ package cn.escheduler.api.service; import cn.escheduler.api.dto.ScheduleParam; import cn.escheduler.api.enums.Status; -import cn.escheduler.api.quartz.ProcessScheduleJob; -import cn.escheduler.api.quartz.QuartzExecutors; +import cn.escheduler.server.quartz.ProcessScheduleJob; +import cn.escheduler.server.quartz.QuartzExecutors; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.PageInfo; import cn.escheduler.common.enums.FailureStrategy; diff --git a/escheduler-api/src/main/resources/application.properties b/escheduler-api/src/main/resources/application.properties index bf003bfdda..b817c18a4a 100644 --- a/escheduler-api/src/main/resources/application.properties +++ b/escheduler-api/src/main/resources/application.properties @@ -2,15 +2,18 @@ server.port=12345 # session config -server.session.timeout=7200 +server.servlet.session.timeout=7200 - -server.context-path=/escheduler/ +server.servlet.context-path=/escheduler/ # file size limit for upload -spring.http.multipart.max-file-size=1024MB -spring.http.multipart.max-request-size=1024MB +spring.servlet.multipart.max-file-size=1024MB +spring.servlet.multipart.max-request-size=1024MB #post content -server.max-http-post-size=5000000 +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=i18n/messages diff --git a/escheduler-api/src/main/resources/i18n/messages.properties b/escheduler-api/src/main/resources/i18n/messages.properties new file mode 100644 index 0000000000..db1111ad78 --- /dev/null +++ b/escheduler-api/src/main/resources/i18n/messages.properties @@ -0,0 +1,216 @@ +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 +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 +FAILURE_STRATEGY=failure strategy +RECEIVERS=receivers +RECEIVERS_CC=receivers cc +WORKER_GROUP_ID=worker server group id +PROCESS_INSTANCE_PRIORITY=process instance priority +UPDATE_SCHEDULE_NOTES=update schedule +SCHEDULE_ID=schedule id +ONLINE_SCHEDULE_NOTES=online schedule +OFFLINE_SCHEDULE_NOTES=offline schedule +QUERY_SCHEDULE_NOTES=query schedule +QUERY_SCHEDULE_LIST_PAGING_NOTES=query schedule list paging +LOGIN_TAG=User login related operations +USER_NAME=user name +PROJECT_NAME=project name +CREATE_PROCESS_DEFINITION_NOTES=create process definition +PROCESS_DEFINITION_NAME=process definition name +PROCESS_DEFINITION_JSON=process definition detail info (json format) +PROCESS_DEFINITION_LOCATIONS=process definition node locations info (json format) +PROCESS_INSTANCE_LOCATIONS=process instance node locations info (json format) +PROCESS_DEFINITION_CONNECTS=process definition node connects info (json format) +PROCESS_INSTANCE_CONNECTS=process instance node connects info (json format) +PROCESS_DEFINITION_DESC=process definition desc +PROCESS_DEFINITION_TAG=process definition related opertation +SIGNOUT_NOTES=logout +USER_PASSWORD=user password +UPDATE_PROCESS_INSTANCE_NOTES=update process instance +QUERY_PROCESS_INSTANCE_LIST_NOTES=query process instance list +VERIFY_PROCCESS_DEFINITION_NAME_NOTES=verify proccess definition name +LOGIN_NOTES=user login +UPDATE_PROCCESS_DEFINITION_NOTES=update proccess definition +PROCESS_DEFINITION_ID=process definition id +RELEASE_PROCCESS_DEFINITION_NOTES=release proccess definition +QUERY_PROCCESS_DEFINITION_BY_ID_NOTES=query proccess definition by id +QUERY_PROCCESS_DEFINITION_LIST_NOTES=query proccess definition list +QUERY_PROCCESS_DEFINITION_LIST_PAGING_NOTES=query proccess definition list paging +PAGE_NO=page no +PROCESS_INSTANCE_ID=process instance id +PROCESS_INSTANCE_JSON=process instance info(json format) +SCHEDULE_TIME=schedule time +SYNC_DEFINE=update the information of the process instance to the process definition\ + +RECOVERY_PROCESS_INSTANCE_FLAG=whether to recovery process instance +SEARCH_VAL=search val +USER_ID=user id +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 +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 +SKIP_LINE_NUM=skip line num +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_USER_NOTES=create user +TENANT_ID=tenant id +QUEUE=queue +EMAIL=email +PHONE=phone +QUERY_USER_LIST_NOTES=query user list +UPDATE_USER_NOTES=update user +DELETE_USER_BY_ID_NOTES=delete user by id +GRANT_PROJECT_NOTES=GRANT PROJECT +PROJECT_IDS=project ids(string format, multiple projects separated by ",") +GRANT_RESOURCE_NOTES=grant resource file +RESOURCE_IDS=resource ids(string format, multiple resources separated by ",") +GET_USER_INFO_NOTES=get user info +LIST_USER_NOTES=list user +VERIFY_USER_NAME_NOTES=verify user name +UNAUTHORIZED_USER_NOTES=cancel authorization +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 +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 +QUERY_PROCESS_INSTANCE_GLOBAL_VARIABLES_AND_LOCAL_VARIABLES_NOTES=query process instance global variables and local variables +VIEW_GANTT_NOTES=view gantt +SUB_PROCESS_INSTANCE_ID=sub process instance id +TASK_NAME=task instance name +TASK_INSTANCE_TAG=task instance related operation +LOGGER_TAG=log related operation +PROCESS_INSTANCE_TAG=process instance related operation +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 +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/i18n/messages_en_US.properties b/escheduler-api/src/main/resources/i18n/messages_en_US.properties new file mode 100644 index 0000000000..db1111ad78 --- /dev/null +++ b/escheduler-api/src/main/resources/i18n/messages_en_US.properties @@ -0,0 +1,216 @@ +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 +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 +FAILURE_STRATEGY=failure strategy +RECEIVERS=receivers +RECEIVERS_CC=receivers cc +WORKER_GROUP_ID=worker server group id +PROCESS_INSTANCE_PRIORITY=process instance priority +UPDATE_SCHEDULE_NOTES=update schedule +SCHEDULE_ID=schedule id +ONLINE_SCHEDULE_NOTES=online schedule +OFFLINE_SCHEDULE_NOTES=offline schedule +QUERY_SCHEDULE_NOTES=query schedule +QUERY_SCHEDULE_LIST_PAGING_NOTES=query schedule list paging +LOGIN_TAG=User login related operations +USER_NAME=user name +PROJECT_NAME=project name +CREATE_PROCESS_DEFINITION_NOTES=create process definition +PROCESS_DEFINITION_NAME=process definition name +PROCESS_DEFINITION_JSON=process definition detail info (json format) +PROCESS_DEFINITION_LOCATIONS=process definition node locations info (json format) +PROCESS_INSTANCE_LOCATIONS=process instance node locations info (json format) +PROCESS_DEFINITION_CONNECTS=process definition node connects info (json format) +PROCESS_INSTANCE_CONNECTS=process instance node connects info (json format) +PROCESS_DEFINITION_DESC=process definition desc +PROCESS_DEFINITION_TAG=process definition related opertation +SIGNOUT_NOTES=logout +USER_PASSWORD=user password +UPDATE_PROCESS_INSTANCE_NOTES=update process instance +QUERY_PROCESS_INSTANCE_LIST_NOTES=query process instance list +VERIFY_PROCCESS_DEFINITION_NAME_NOTES=verify proccess definition name +LOGIN_NOTES=user login +UPDATE_PROCCESS_DEFINITION_NOTES=update proccess definition +PROCESS_DEFINITION_ID=process definition id +RELEASE_PROCCESS_DEFINITION_NOTES=release proccess definition +QUERY_PROCCESS_DEFINITION_BY_ID_NOTES=query proccess definition by id +QUERY_PROCCESS_DEFINITION_LIST_NOTES=query proccess definition list +QUERY_PROCCESS_DEFINITION_LIST_PAGING_NOTES=query proccess definition list paging +PAGE_NO=page no +PROCESS_INSTANCE_ID=process instance id +PROCESS_INSTANCE_JSON=process instance info(json format) +SCHEDULE_TIME=schedule time +SYNC_DEFINE=update the information of the process instance to the process definition\ + +RECOVERY_PROCESS_INSTANCE_FLAG=whether to recovery process instance +SEARCH_VAL=search val +USER_ID=user id +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 +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 +SKIP_LINE_NUM=skip line num +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_USER_NOTES=create user +TENANT_ID=tenant id +QUEUE=queue +EMAIL=email +PHONE=phone +QUERY_USER_LIST_NOTES=query user list +UPDATE_USER_NOTES=update user +DELETE_USER_BY_ID_NOTES=delete user by id +GRANT_PROJECT_NOTES=GRANT PROJECT +PROJECT_IDS=project ids(string format, multiple projects separated by ",") +GRANT_RESOURCE_NOTES=grant resource file +RESOURCE_IDS=resource ids(string format, multiple resources separated by ",") +GET_USER_INFO_NOTES=get user info +LIST_USER_NOTES=list user +VERIFY_USER_NAME_NOTES=verify user name +UNAUTHORIZED_USER_NOTES=cancel authorization +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 +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 +QUERY_PROCESS_INSTANCE_GLOBAL_VARIABLES_AND_LOCAL_VARIABLES_NOTES=query process instance global variables and local variables +VIEW_GANTT_NOTES=view gantt +SUB_PROCESS_INSTANCE_ID=sub process instance id +TASK_NAME=task instance name +TASK_INSTANCE_TAG=task instance related operation +LOGGER_TAG=log related operation +PROCESS_INSTANCE_TAG=process instance related operation +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 +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/i18n/messages_zh_CN.properties b/escheduler-api/src/main/resources/i18n/messages_zh_CN.properties new file mode 100644 index 0000000000..73d62a8839 --- /dev/null +++ b/escheduler-api/src/main/resources/i18n/messages_zh_CN.properties @@ -0,0 +1,216 @@ +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服务列表 +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 +FAILURE_STRATEGY=失败策略 +RECEIVERS=收件人 +RECEIVERS_CC=收件人(抄送) +WORKER_GROUP_ID=Worker Server分组ID +PROCESS_INSTANCE_PRIORITY=流程实例优先级 +UPDATE_SCHEDULE_NOTES=更新定时 +SCHEDULE_ID=定时ID +ONLINE_SCHEDULE_NOTES=定时上线 +OFFLINE_SCHEDULE_NOTES=定时下线 +QUERY_SCHEDULE_NOTES=查询定时 +QUERY_SCHEDULE_LIST_PAGING_NOTES=分页查询定时 +LOGIN_TAG=用户登录相关操作 +USER_NAME=用户名 +PROJECT_NAME=项目名称 +CREATE_PROCESS_DEFINITION_NOTES=创建流程定义 +PROCESS_DEFINITION_NAME=流程定义名称 +PROCESS_DEFINITION_JSON=流程定义详细信息(json格式) +PROCESS_DEFINITION_LOCATIONS=流程定义节点坐标位置信息(json格式) +PROCESS_INSTANCE_LOCATIONS=流程实例节点坐标位置信息(json格式) +PROCESS_DEFINITION_CONNECTS=流程定义节点图标连接信息(json格式) +PROCESS_INSTANCE_CONNECTS=流程实例节点图标连接信息(json格式) +PROCESS_DEFINITION_DESC=流程定义描述信息 +PROCESS_DEFINITION_TAG=流程定义相关操作 +SIGNOUT_NOTES=退出登录 +USER_PASSWORD=用户密码 +UPDATE_PROCESS_INSTANCE_NOTES=更新流程实例 +QUERY_PROCESS_INSTANCE_LIST_NOTES=查询流程实例列表 +VERIFY_PROCCESS_DEFINITION_NAME_NOTES=验证流程定义名字 +LOGIN_NOTES=用户登录 +UPDATE_PROCCESS_DEFINITION_NOTES=更新流程定义 +PROCESS_DEFINITION_ID=流程定义ID +RELEASE_PROCCESS_DEFINITION_NOTES=发布流程定义 +QUERY_PROCCESS_DEFINITION_BY_ID_NOTES=查询流程定义通过流程定义ID +QUERY_PROCCESS_DEFINITION_LIST_NOTES=查询流程定义列表 +QUERY_PROCCESS_DEFINITION_LIST_PAGING_NOTES=分页查询流程定义列表 +PAGE_NO=页码号 +PROCESS_INSTANCE_ID=流程实例ID +PROCESS_INSTANCE_JSON=流程实例信息(json格式) +SCHEDULE_TIME=定时时间 +SYNC_DEFINE=更新流程实例的信息是否同步到流程定义 +RECOVERY_PROCESS_INSTANCE_FLAG=是否恢复流程实例 +SEARCH_VAL=搜索值 +USER_ID=用户ID +PAGE_SIZE=页大小 +LIMIT=显示多少条 +VIEW_TREE_NOTES=树状图 +GET_NODE_LIST_BY_DEFINITION_ID_NOTES=获得任务节点列表通过流程定义ID +PROCESS_DEFINITION_ID_LIST=流程定义id列表 +QUERY_PROCESS_INSTANCE_BY_ID_NOTES=查询流程实例通过流程实例ID +DELETE_PROCESS_INSTANCE_BY_ID_NOTES=删除流程实例通过流程实例ID +TASK_ID=任务实例ID +SKIP_LINE_NUM=忽略行数 +QUERY_TASK_INSTANCE_LOG_NOTES=查询任务实例日志 +DOWNLOAD_TASK_INSTANCE_LOG_NOTES=下载任务实例日志 +USERS_TAG=用户相关操作 +SCHEDULER_TAG=定时相关操作 +CREATE_SCHEDULE_NOTES=创建定时 +CREATE_USER_NOTES=创建用户 +TENANT_ID=租户ID +QUEUE=使用的队列 +EMAIL=邮箱 +PHONE=手机号 +QUERY_USER_LIST_NOTES=查询用户列表 +UPDATE_USER_NOTES=更新用户 +DELETE_USER_BY_ID_NOTES=删除用户通过ID +GRANT_PROJECT_NOTES=授权项目 +PROJECT_IDS=项目IDS(字符串格式,多个项目以","分割) +GRANT_RESOURCE_NOTES=授权资源文件 +RESOURCE_IDS=资源ID列表(字符串格式,多个资源ID以","分割) +GET_USER_INFO_NOTES=获取用户信息 +LIST_USER_NOTES=用户列表 +VERIFY_USER_NAME_NOTES=验证用户名 +UNAUTHORIZED_USER_NOTES=取消授权 +ALERT_GROUP_ID=报警组ID +AUTHORIZED_USER_NOTES=授权用户 +GRANT_UDF_FUNC_NOTES=授权udf函数 +UDF_IDS=udf函数id列表(字符串格式,多个udf函数ID以","分割) +GRANT_DATASOURCE_NOTES=授权数据源 +DATASOURCE_IDS=数据源ID列表(字符串格式,多个数据源ID以","分割) +QUERY_SUBPROCESS_INSTANCE_BY_TASK_ID_NOTES=查询子流程实例通过任务实例ID +QUERY_PARENT_PROCESS_INSTANCE_BY_SUB_PROCESS_INSTANCE_ID_NOTES=查询父流程实例信息通过子流程实例ID +QUERY_PROCESS_INSTANCE_GLOBAL_VARIABLES_AND_LOCAL_VARIABLES_NOTES=查询流程实例全局变量和局部变量 +VIEW_GANTT_NOTES=浏览Gantt图 +SUB_PROCESS_INSTANCE_ID=子流程是咧ID +TASK_NAME=任务实例名 +TASK_INSTANCE_TAG=任务实例相关操作 +LOGGER_TAG=日志相关操作 +PROCESS_INSTANCE_TAG=流程实例相关操作 +EXECUTION_STATUS=工作流和任务节点的运行状态 +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=授权的数据源 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 diff --git a/escheduler-common/pom.xml b/escheduler-common/pom.xml index 2b92694564..9e3add4896 100644 --- a/escheduler-common/pom.xml +++ b/escheduler-common/pom.xml @@ -263,10 +263,6 @@ postgresql - - org.apache.httpcomponents - httpclient - org.apache.hive hive-jdbc diff --git a/escheduler-common/src/main/java/cn/escheduler/common/enums/ExecutionStatus.java b/escheduler-common/src/main/java/cn/escheduler/common/enums/ExecutionStatus.java index e2a727636d..4efcc09d6c 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/enums/ExecutionStatus.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/enums/ExecutionStatus.java @@ -18,7 +18,7 @@ package cn.escheduler.common.enums; /** - * runing status for work flow and task nodes + * runing status for workflow and task nodes * */ public enum ExecutionStatus { diff --git a/escheduler-common/src/main/java/cn/escheduler/common/queue/ITaskQueue.java b/escheduler-common/src/main/java/cn/escheduler/common/queue/ITaskQueue.java index 42629324a2..106d6ff915 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/queue/ITaskQueue.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/queue/ITaskQueue.java @@ -54,7 +54,7 @@ public interface ITaskQueue { * an element pops out of the queue * * @param key queue name - * @param remove where remove the element + * @param remove whether remove the element * @return */ String poll(String key, boolean remove); diff --git a/escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java b/escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java index 11dc6bfbf6..045db346c6 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java @@ -20,8 +20,10 @@ import cn.escheduler.common.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.text.ParseException; -import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; @@ -30,145 +32,182 @@ import java.util.Date; */ public class DateUtils { - private static final Logger logger = LoggerFactory.getLogger(DateUtils.class); - - /** - * @return get the formatted date string for the current time - */ - public static String getCurrentTime() { - return getCurrentTime(Constants.YYYY_MM_DD_HH_MM_SS); - } - - /** - * @param format - * @return get the date string in the specified format of the current time - */ - public static String getCurrentTime(String format) { - return new SimpleDateFormat(format).format(new Date()); - } - - /** - * @param date - * @param format e.g. yyyy-MM-dd HH:mm:ss - * @return get the formatted date string - */ - public static String format(Date date, String format) { - return new SimpleDateFormat(format).format(date); - } - - /** - * @param date - * @return convert time to yyyy-MM-dd HH:mm:ss format - */ - public static String dateToString(Date date){ - return format(date,Constants.YYYY_MM_DD_HH_MM_SS); - } - - - /** - * @param date - * @return convert string to date and time - */ - public static Date parse(String date,String format){ - try { - return new SimpleDateFormat(format).parse(date); - } catch (Exception e) { - logger.error("error while parse date:" + date, e); - } - return null; - } - - /** - * convert date str to yyyy-MM-dd HH:mm:ss format - * @param str - * @return - */ - public static Date stringToDate(String str){ - return parse(str,Constants.YYYY_MM_DD_HH_MM_SS); - } - - /** - * get seconds between two dates - * - * @param d1 - * @param d2 - * @return - */ - public static long differSec(Date d1, Date d2) { - return (long) Math.ceil(differMs(d1, d2) / 1000.0); - } - - /** - * get ms between two dates - * - * @param d1 - * @param d2 - * @return - */ - public static long differMs(Date d1, Date d2) { - return Math.abs(d1.getTime() - d2.getTime()); - } - - - /** - * get hours between two dates - * - * @param d1 - * @param d2 - * @return - */ - public static long diffHours(Date d1, Date d2) { - return (long) Math.ceil(diffMin(d1, d2) / 60.0); - } - - /** - * get minutes between two dates - * - * @param d1 - * @param d2 - * @return - */ - public static long diffMin(Date d1, Date d2) { - return (long) Math.ceil(differSec(d1, d2) / 60.0); - } - - - /** + private static final Logger logger = LoggerFactory.getLogger(DateUtils.class); + + /** + * java.util.Date to java.time.LocalDateTime + * use default zone + * @param date + * @return + */ + private static LocalDateTime date2LocalDateTime(Date date) { + return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); + } + + /** + * java.time.LocalDateTime to java.util.Date + * use default zone + * @param localDateTime + * @return + */ + private static Date localDateTime2Date(LocalDateTime localDateTime) { + Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant(); + return Date.from(instant); + } + + /** + * @return get the formatted date string for the current time + */ + public static String getCurrentTime() { + return getCurrentTime(Constants.YYYY_MM_DD_HH_MM_SS); + } + + /** + * @param format + * @return get the date string in the specified format of the current time + */ + public static String getCurrentTime(String format) { +// return new SimpleDateFormat(format).format(new Date()); + return LocalDateTime.now().format(DateTimeFormatter.ofPattern(format)); + } + + /** + * @param date + * @param format e.g. yyyy-MM-dd HH:mm:ss + * @return get the formatted date string + */ + public static String format(Date date, String format) { +// return new SimpleDateFormat(format).format(date); + return format(date2LocalDateTime(date), format); + } + + /** + * @param localDateTime + * @param format e.g. yyyy-MM-dd HH:mm:ss + * @return get the formatted date string + */ + public static String format(LocalDateTime localDateTime, String format) { + return localDateTime.format(DateTimeFormatter.ofPattern(format)); + } + + /** + * @param date + * @return convert time to yyyy-MM-dd HH:mm:ss format + */ + public static String dateToString(Date date) { + return format(date, Constants.YYYY_MM_DD_HH_MM_SS); + } + + + /** + * @param date + * @return convert string to date and time + */ + public static Date parse(String date, String format) { + try { + // return new SimpleDateFormat(format).parse(date); + LocalDateTime ldt = LocalDateTime.parse(date, DateTimeFormatter.ofPattern(format)); + return localDateTime2Date(ldt); + } catch (Exception e) { + logger.error("error while parse date:" + date, e); + } + return null; + } + + /** + * convert date str to yyyy-MM-dd HH:mm:ss format + * + * @param str + * @return + */ + public static Date stringToDate(String str) { + return parse(str, Constants.YYYY_MM_DD_HH_MM_SS); + } + + /** + * get seconds between two dates + * + * @param d1 + * @param d2 + * @return + */ + public static long differSec(Date d1, Date d2) { + return (long) Math.ceil(differMs(d1, d2) / 1000.0); + } + + /** + * get ms between two dates + * + * @param d1 + * @param d2 + * @return + */ + public static long differMs(Date d1, Date d2) { + return Math.abs(d1.getTime() - d2.getTime()); + } + + + /** + * get hours between two dates + * + * @param d1 + * @param d2 + * @return + */ + public static long diffHours(Date d1, Date d2) { + return (long) Math.ceil(diffMin(d1, d2) / 60.0); + } + + /** + * get minutes between two dates + * + * @param d1 + * @param d2 + * @return + */ + public static long diffMin(Date d1, Date d2) { + return (long) Math.ceil(differSec(d1, d2) / 60.0); + } + + + /** * get the date of the specified date in the days before and after - * @param date - * @param day - * @return - */ - public static Date getSomeDay(Date date, int day) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.DATE, day); - return calendar.getTime(); - } - - /** + * + * @param date + * @param day + * @return + */ + public static Date getSomeDay(Date date, int day) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.DATE, day); + return calendar.getTime(); + } + + /** * compare two dates - * - * @param future - * @param old - * @return - */ - public static boolean compare(Date future, Date old) { - return future.getTime() > old.getTime(); - } - - /** - * convert schedule string to date - * @param schedule - * @return - */ - public static Date getScheduleDate(String schedule){ - return stringToDate(schedule); - } + * + * @param future + * @param old + * @return + */ + public static boolean compare(Date future, Date old) { + return future.getTime() > old.getTime(); + } + + /** + * convert schedule string to date + * + * @param schedule + * @return + */ + public static Date getScheduleDate(String schedule) { + return stringToDate(schedule); + } /** * format time to readable - * + * * @param ms * @return */ @@ -183,131 +222,135 @@ public class DateUtils { } - /** - * get monday - * - * note: Set the first day of the week to Monday, the default is Sunday - */ - public static Date getMonday(Date date) { - Calendar cal = Calendar.getInstance(); - - cal.setTime(date); - - cal.setFirstDayOfWeek(Calendar.MONDAY); - cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); - - return cal.getTime(); - } - - /** - * get sunday - * - * note: Set the first day of the week to Monday, the default is Sunday - */ - public static Date getSunday(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - - cal.setFirstDayOfWeek(Calendar.MONDAY); - cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); - - return cal.getTime(); - } - - /** - * get first day of month - */ - public static Date getFirstDayOfMonth(Date date) { - Calendar cal = Calendar.getInstance(); - - cal.setTime(date); - cal.set(Calendar.DAY_OF_MONTH, 1); - - return cal.getTime(); - } - - /** - * get first day of month - */ - public static Date getSomeHourOfDay(Date date, int hours) { - Calendar cal = Calendar.getInstance(); - - cal.setTime(date); - cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - hours); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - - return cal.getTime(); - } - - /** - * get last day of month - */ - public static Date getLastDayOfMonth(Date date) { - Calendar cal = Calendar.getInstance(); - - cal.setTime(date); - - cal.add(Calendar.MONTH, 1); - cal.set(Calendar.DAY_OF_MONTH, 1); - cal.add(Calendar.DAY_OF_MONTH, -1); - - return cal.getTime(); - } - - /** - * return YYYY-MM-DD 00:00:00 - * @param inputDay - * @return - */ - public static Date getStartOfDay(Date inputDay){ - Calendar cal = Calendar.getInstance(); - cal.setTime(inputDay); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - return cal.getTime(); - } - - /** - * return YYYY-MM-DD 23:59:59 - * @param inputDay - * @return - */ - public static Date getEndOfDay(Date inputDay){ - Calendar cal = Calendar.getInstance(); - cal.setTime(inputDay); - cal.set(Calendar.HOUR_OF_DAY, 23); - cal.set(Calendar.MINUTE, 59); - cal.set(Calendar.SECOND, 59); - return cal.getTime(); - } - - /** - * return YYYY-MM-DD 00:00:00 - * @param inputDay - * @return - */ - public static Date getStartOfHour(Date inputDay){ - Calendar cal = Calendar.getInstance(); - cal.setTime(inputDay); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - return cal.getTime(); - } - - /** - * return YYYY-MM-DD 23:59:59 - * @param inputDay - * @return - */ - public static Date getEndOfHour(Date inputDay){ - Calendar cal = Calendar.getInstance(); - cal.setTime(inputDay); - cal.set(Calendar.MINUTE, 59); - cal.set(Calendar.SECOND, 59); - return cal.getTime(); - } + /** + * get monday + *

+ * note: Set the first day of the week to Monday, the default is Sunday + */ + public static Date getMonday(Date date) { + Calendar cal = Calendar.getInstance(); + + cal.setTime(date); + + cal.setFirstDayOfWeek(Calendar.MONDAY); + cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); + + return cal.getTime(); + } + + /** + * get sunday + *

+ * note: Set the first day of the week to Monday, the default is Sunday + */ + public static Date getSunday(Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + + cal.setFirstDayOfWeek(Calendar.MONDAY); + cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); + + return cal.getTime(); + } + + /** + * get first day of month + */ + public static Date getFirstDayOfMonth(Date date) { + Calendar cal = Calendar.getInstance(); + + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, 1); + + return cal.getTime(); + } + + /** + * get first day of month + */ + public static Date getSomeHourOfDay(Date date, int hours) { + Calendar cal = Calendar.getInstance(); + + cal.setTime(date); + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - hours); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + + return cal.getTime(); + } + + /** + * get last day of month + */ + public static Date getLastDayOfMonth(Date date) { + Calendar cal = Calendar.getInstance(); + + cal.setTime(date); + + cal.add(Calendar.MONTH, 1); + cal.set(Calendar.DAY_OF_MONTH, 1); + cal.add(Calendar.DAY_OF_MONTH, -1); + + return cal.getTime(); + } + + /** + * return YYYY-MM-DD 00:00:00 + * + * @param inputDay + * @return + */ + public static Date getStartOfDay(Date inputDay) { + Calendar cal = Calendar.getInstance(); + cal.setTime(inputDay); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + return cal.getTime(); + } + + /** + * return YYYY-MM-DD 23:59:59 + * + * @param inputDay + * @return + */ + public static Date getEndOfDay(Date inputDay) { + Calendar cal = Calendar.getInstance(); + cal.setTime(inputDay); + cal.set(Calendar.HOUR_OF_DAY, 23); + cal.set(Calendar.MINUTE, 59); + cal.set(Calendar.SECOND, 59); + return cal.getTime(); + } + + /** + * return YYYY-MM-DD 00:00:00 + * + * @param inputDay + * @return + */ + public static Date getStartOfHour(Date inputDay) { + Calendar cal = Calendar.getInstance(); + cal.setTime(inputDay); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + return cal.getTime(); + } + + /** + * return YYYY-MM-DD 23:59:59 + * + * @param inputDay + * @return + */ + public static Date getEndOfHour(Date inputDay) { + Calendar cal = Calendar.getInstance(); + cal.setTime(inputDay); + cal.set(Calendar.MINUTE, 59); + cal.set(Calendar.SECOND, 59); + return cal.getTime(); + } } diff --git a/escheduler-common/src/main/java/cn/escheduler/common/utils/MysqlUtil.java b/escheduler-common/src/main/java/cn/escheduler/common/utils/MysqlUtils.java similarity index 87% rename from escheduler-common/src/main/java/cn/escheduler/common/utils/MysqlUtil.java rename to escheduler-common/src/main/java/cn/escheduler/common/utils/MysqlUtils.java index d2d1ef203d..3520527c1a 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/utils/MysqlUtil.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/utils/MysqlUtils.java @@ -21,16 +21,16 @@ import org.slf4j.LoggerFactory; import java.sql.*; -public class MysqlUtil { +public class MysqlUtils { - public static final Logger logger = LoggerFactory.getLogger(MysqlUtil.class); + public static final Logger logger = LoggerFactory.getLogger(MysqlUtils.class); - private static MysqlUtil instance; + private static MysqlUtils instance; - MysqlUtil() { + MysqlUtils() { } - public static MysqlUtil getInstance() { + public static MysqlUtils getInstance() { if (null == instance) { syncInit(); } @@ -39,7 +39,7 @@ public class MysqlUtil { private static synchronized void syncInit() { if (instance == null) { - instance = new MysqlUtil(); + instance = new MysqlUtils(); } } @@ -75,8 +75,8 @@ public class MysqlUtil { } } - public static void realeaseResource(ResultSet rs, PreparedStatement ps, Connection conn) { - MysqlUtil.getInstance().release(rs,ps,conn); + public static void releaseResource(ResultSet rs, PreparedStatement ps, Connection conn) { + MysqlUtils.getInstance().release(rs,ps,conn); if (null != rs) { try { rs.close(); diff --git a/escheduler-dao/pom.xml b/escheduler-dao/pom.xml index b2898adce3..f9da24ec7e 100644 --- a/escheduler-dao/pom.xml +++ b/escheduler-dao/pom.xml @@ -137,8 +137,14 @@ spring-test test + + io.swagger + swagger-annotations + 1.5.20 + compile + - + diff --git a/escheduler-dao/src/main/java/cn/escheduler/dao/model/User.java b/escheduler-dao/src/main/java/cn/escheduler/dao/model/User.java index 6f831fbd96..bad6b6313e 100644 --- a/escheduler-dao/src/main/java/cn/escheduler/dao/model/User.java +++ b/escheduler-dao/src/main/java/cn/escheduler/dao/model/User.java @@ -17,12 +17,15 @@ package cn.escheduler.dao.model; import cn.escheduler.common.enums.UserType; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.Date; /** * user */ +@ApiModel(description = "UserModelDesc") public class User { /** @@ -33,21 +36,25 @@ public class User { /** * user name */ + @ApiModelProperty(name = "userName", notes = "USER_NAME",dataType = "String",required = true) private String userName; /** * user password */ + @ApiModelProperty(name = "userPassword", notes = "USER_PASSWORD",dataType = "String",required = true) private String userPassword; /** * mail */ + @ApiModelProperty(name = "email", notes = "email",dataType = "String",required = true) private String email; /** * phone */ + @ApiModelProperty(name = "phone", notes = "phone",dataType = "String",required = true) private String phone; /** diff --git a/escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/UpgradeDao.java b/escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/UpgradeDao.java index 96199b0725..6fc8a61417 100644 --- a/escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/UpgradeDao.java +++ b/escheduler-dao/src/main/java/cn/escheduler/dao/upgrade/UpgradeDao.java @@ -16,7 +16,7 @@ */ package cn.escheduler.dao.upgrade; -import cn.escheduler.common.utils.MysqlUtil; +import cn.escheduler.common.utils.MysqlUtils; import cn.escheduler.common.utils.ScriptRunner; import cn.escheduler.dao.AbstractBaseDao; import cn.escheduler.dao.datasource.ConnectionFactory; @@ -98,7 +98,7 @@ public class UpgradeDao extends AbstractBaseDao { logger.error(e.getMessage(),e); throw new RuntimeException(e.getMessage(),e); } finally { - MysqlUtil.realeaseResource(null, null, conn); + MysqlUtils.releaseResource(null, null, conn); } @@ -126,7 +126,7 @@ public class UpgradeDao extends AbstractBaseDao { logger.error(e.getMessage(),e); throw new RuntimeException(e.getMessage(),e); } finally { - MysqlUtil.realeaseResource(null, null, conn); + MysqlUtils.releaseResource(null, null, conn); } @@ -152,7 +152,7 @@ public class UpgradeDao extends AbstractBaseDao { logger.error(e.getMessage(),e); throw new RuntimeException(e.getMessage(),e); } finally { - MysqlUtil.realeaseResource(null, null, conn); + MysqlUtils.releaseResource(null, null, conn); } @@ -179,7 +179,7 @@ public class UpgradeDao extends AbstractBaseDao { logger.error(e.getMessage(),e); throw new RuntimeException(e.getMessage(),e); } finally { - MysqlUtil.realeaseResource(null, null, conn); + MysqlUtils.releaseResource(null, null, conn); } @@ -207,7 +207,7 @@ public class UpgradeDao extends AbstractBaseDao { logger.error(e.getMessage(),e); throw new RuntimeException("sql: " + sql, e); } finally { - MysqlUtil.realeaseResource(rs, pstmt, conn); + MysqlUtils.releaseResource(rs, pstmt, conn); } } @@ -277,7 +277,7 @@ public class UpgradeDao extends AbstractBaseDao { logger.error(e.getMessage(),e); throw new RuntimeException(e.getMessage(),e); } finally { - MysqlUtil.realeaseResource(null, pstmt, conn); + MysqlUtils.releaseResource(null, pstmt, conn); } } @@ -316,7 +316,7 @@ public class UpgradeDao extends AbstractBaseDao { logger.error(e.getMessage(),e); throw new RuntimeException(e.getMessage(),e); } finally { - MysqlUtil.realeaseResource(null, pstmt, conn); + MysqlUtils.releaseResource(null, pstmt, conn); } } @@ -338,7 +338,7 @@ public class UpgradeDao extends AbstractBaseDao { logger.error(e.getMessage(),e); throw new RuntimeException("sql: " + upgradeSQL, e); } finally { - MysqlUtil.realeaseResource(null, pstmt, conn); + MysqlUtils.releaseResource(null, pstmt, conn); } } diff --git a/escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java b/escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java index adede0c329..d85a25f175 100644 --- a/escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java +++ b/escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java @@ -72,4 +72,10 @@ public class UserMapperTest { Assert.assertEquals(user.getUserName(), "qiaozhanwei"); } + @Test + public void test(){ + User user = userMapper.queryDetailsById(19); + System.out.println(user); + } + } diff --git a/escheduler-server/pom.xml b/escheduler-server/pom.xml index f6390264e0..9dcff53078 100644 --- a/escheduler-server/pom.xml +++ b/escheduler-server/pom.xml @@ -50,10 +50,7 @@ - - cn.analysys - escheduler-api - + cn.analysys escheduler-rpc diff --git a/escheduler-server/src/main/java/cn/escheduler/server/master/MasterServer.java b/escheduler-server/src/main/java/cn/escheduler/server/master/MasterServer.java index 95705dd017..e137824814 100644 --- a/escheduler-server/src/main/java/cn/escheduler/server/master/MasterServer.java +++ b/escheduler-server/src/main/java/cn/escheduler/server/master/MasterServer.java @@ -16,8 +16,8 @@ */ package cn.escheduler.server.master; -import cn.escheduler.api.quartz.ProcessScheduleJob; -import cn.escheduler.api.quartz.QuartzExecutors; +import cn.escheduler.server.quartz.ProcessScheduleJob; +import cn.escheduler.server.quartz.QuartzExecutors; import cn.escheduler.common.Constants; import cn.escheduler.common.IStoppable; import cn.escheduler.common.thread.Stopper; @@ -189,7 +189,6 @@ public class MasterServer implements CommandLineRunner, IStoppable { public static void main(String[] args) { SpringApplication app = new SpringApplication(MasterServer.class); - app.setWebEnvironment(false); app.run(args); } diff --git a/escheduler-api/src/main/java/cn/escheduler/api/quartz/ProcessScheduleJob.java b/escheduler-server/src/main/java/cn/escheduler/server/quartz/ProcessScheduleJob.java similarity index 96% rename from escheduler-api/src/main/java/cn/escheduler/api/quartz/ProcessScheduleJob.java rename to escheduler-server/src/main/java/cn/escheduler/server/quartz/ProcessScheduleJob.java index 96e283d7d5..3e546bea7c 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/quartz/ProcessScheduleJob.java +++ b/escheduler-server/src/main/java/cn/escheduler/server/quartz/ProcessScheduleJob.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package cn.escheduler.api.quartz; +package cn.escheduler.server.quartz; import cn.escheduler.common.Constants; @@ -31,8 +31,8 @@ import org.springframework.util.Assert; import java.util.Date; -import static cn.escheduler.api.quartz.QuartzExecutors.buildJobGroupName; -import static cn.escheduler.api.quartz.QuartzExecutors.buildJobName; +import static cn.escheduler.server.quartz.QuartzExecutors.buildJobGroupName; +import static cn.escheduler.server.quartz.QuartzExecutors.buildJobName; /** * process schedule job diff --git a/escheduler-api/src/main/java/cn/escheduler/api/quartz/QuartzExecutors.java b/escheduler-server/src/main/java/cn/escheduler/server/quartz/QuartzExecutors.java similarity index 99% rename from escheduler-api/src/main/java/cn/escheduler/api/quartz/QuartzExecutors.java rename to escheduler-server/src/main/java/cn/escheduler/server/quartz/QuartzExecutors.java index 5cb3b33853..d7e0c5a3ad 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/quartz/QuartzExecutors.java +++ b/escheduler-server/src/main/java/cn/escheduler/server/quartz/QuartzExecutors.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package cn.escheduler.api.quartz; +package cn.escheduler.server.quartz; import cn.escheduler.common.Constants; import cn.escheduler.common.utils.JSONUtils; diff --git a/escheduler-server/src/main/java/cn/escheduler/server/worker/runner/FetchTaskThread.java b/escheduler-server/src/main/java/cn/escheduler/server/worker/runner/FetchTaskThread.java index f163364b06..3ecafde57a 100644 --- a/escheduler-server/src/main/java/cn/escheduler/server/worker/runner/FetchTaskThread.java +++ b/escheduler-server/src/main/java/cn/escheduler/server/worker/runner/FetchTaskThread.java @@ -134,7 +134,6 @@ public class FetchTaskThread implements Runnable{ public void run() { while (Stopper.isRunning()){ - InterProcessMutex mutex = null; try { if(OSUtils.checkResource(this.conf, false)) { @@ -221,7 +220,9 @@ public class FetchTaskThread implements Runnable{ logger.info("task : {} ready to submit to task scheduler thread",taskId); // submit task workerExecService.submit(new TaskScheduleThread(taskInstance, processDao)); + } + } } diff --git a/pom.xml b/pom.xml index 89d7de8acf..e993636be4 100644 --- a/pom.xml +++ b/pom.xml @@ -8,31 +8,44 @@ escheduler http://maven.apache.org + UTF-8 UTF-8 2.12.0 - 4.3.7.RELEASE - 1.4.5.RELEASE + 5.1.5.RELEASE + 2.1.3.RELEASE 1.8 1.2.3 2.7.3 2.2.3 + 2.9.8 + + org.mybatis + mybatis + 3.5.1 + + + org.mybatis + mybatis-spring + 2.0.1 + org.mybatis.spring.boot mybatis-spring-boot-autoconfigure - 1.2.0 + 2.0.1 org.mybatis.spring.boot mybatis-spring-boot-starter - 1.2.0 + 2.0.1 + org.quartz-scheduler @@ -49,36 +62,26 @@ cron-utils 5.0.5 - - org.mybatis - mybatis - 3.4.2 - - - org.mybatis - mybatis-spring - 1.3.1 - - - org.springframework - spring-tx - ${spring.version} - - - org.springframework - spring-jdbc - ${spring.version} - + com.alibaba fastjson 1.2.29 + + com.alibaba + druid + 1.1.14 + + org.springframework.boot - spring-boot-starter-jetty + spring-boot-starter-parent ${spring.boot.version} + pom + import + org.springframework spring-core @@ -96,31 +99,26 @@ org.springframework - spring-test + spring-tx ${spring.version} - org.springframework.boot - spring-boot-starter-parent - ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-web - ${spring.boot.version} + org.springframework + spring-jdbc + ${spring.version} - org.springframework.boot - spring-boot-starter-test - ${spring.boot.version} - test + org.springframework + spring-test + ${spring.version} + + - org.springframework.boot - spring-boot-starter-aop - ${spring.boot.version} + cn.analysys + escheduler-server + ${project.version} - cn.analysys escheduler-common @@ -146,6 +144,7 @@ escheduler-alert ${project.version} + org.apache.curator curator-framework @@ -170,27 +169,27 @@ org.apache.httpcomponents httpclient - 4.3.2 + 4.4.1 org.apache.httpcomponents httpcore - 4.3.2 + 4.4.1 com.fasterxml.jackson.core jackson-annotations - 2.8.6 + ${jackson.version} com.fasterxml.jackson.core jackson-databind - 2.8.6 + ${jackson.version} com.fasterxml.jackson.core jackson-core - 2.8.6 + ${jackson.version} @@ -248,13 +247,6 @@ 1.10 - - - com.alibaba - druid - 1.1.14 - - ch.qos.logback logback-classic @@ -344,7 +336,7 @@ com.google.guava guava - 19.0 + 20.0 @@ -390,8 +382,8 @@ scm:git:https://github.com/analysys/EasyScheduler.git scm:git:https://github.com/analysys/EasyScheduler.git https://github.com/analysys/EasyScheduler.git - HEAD - + HEAD + @@ -452,7 +444,7 @@ - +