1. 升级swagger版本

2. 接入graylog 轻量级elk
pull/4/head
3y 3 years ago
parent 35b653a9d1
commit 644d439ba8

@ -1,6 +1,5 @@
package com.java3y.austin.receiver;
import cn.monitor4all.logRecord.annotation.OperationLog;
import com.alibaba.fastjson.JSON;
import com.java3y.austin.domain.AnchorInfo;
import com.java3y.austin.domain.LogParam;

@ -22,7 +22,7 @@ public class MessageParam {
private String receiver;
/**
* @Description:
* @Description: ()
*
*/
private Map<String, String> variables;

@ -17,7 +17,7 @@ import lombok.experimental.Accessors;
public class SendRequest {
/**
*
* ( "send")
*/
private String code;

@ -73,6 +73,11 @@
<groupId>cn.monitor4all</groupId>
<artifactId>log-record-starter</artifactId>
</dependency>
<dependency>
<groupId>de.siegmar</groupId>
<artifactId>logback-gelf</artifactId>
</dependency>
</dependencies>
</project>

@ -44,15 +44,9 @@
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
</dependencies>
<build>

@ -1,52 +0,0 @@
package com.java3y.austin.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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;
/**
* @program: austin
* @description: swagger
* @author: YorickGu
* @create: 2022-01-09 17:22
**/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
// 指定构建api文档的详细信息的方法apiInfo()
.apiInfo(apiInfo())
.select()
// 指定要生成api接口的包路径
.apis(RequestHandlerSelectors.basePackage("com.java3y.austin.controller"))
//使用了 @ApiOperation 注解的方法生成api接口文档
//.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
//可以根据url路径设置哪些请求加入文档忽略哪些请求
.build();
}
/**
* api
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
// 标题
.title("Austin")
// 接口描述
.description("Austin")
// 版本信息
.version("1.0")
// 构建
.build();
}
}

@ -0,0 +1,48 @@
package com.java3y.austin.config;
import io.swagger.annotations.ApiModel;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
@Component
@EnableOpenApi
@ApiModel
public class SwaggerConfiguration {
/**
* C
*
* @return
*/
@Bean
public Docket webApiDoc() {
return new Docket(DocumentationType.OAS_30)
.groupName("用户端接口文档")
.pathMapping("/")
//定义是否开启Swaggerfalse是关闭可以通过变量去控制线上关闭
.enable(true)
//配置文档的元信息
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.java3y.austin.controller"))
//正则匹配请求路径,并分配到当前项目组
//.paths(PathSelectors.ant("/api/**"))
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("austin平台")
.description("消息推送接口接口文档")
.contact(new Contact("3y", "http://gitee.com/zhongfucheng/austin", "403686131@qq.com"))
.version("v1.0")
.build();
}
}

@ -23,13 +23,12 @@ public class SendController {
/**
*
* curl -XPOST "127.0.0.1:8080/send" -H 'Content-Type: application/json' -d '{"code":"send","messageParam":{"receiver":"13788888888","variables":{"title":"yyyyyy","contentValue":"6666164180"}},"messageTemplateId":1}'
* curl -XPOST "127.0.0.1:8080/send" -H 'Content-Type: application/json' -d '{"code":"send","messageParam":{"receiver":"13788888888","variables":{"title":"yyyyyy","contentValue":"6666164180"}},"messageTemplateId":1}'
* @return
*/
@ApiOperation(value = "下发接口",notes = "多渠道多类型下发消息,目前支持邮件和短信,类型支持:验证码、通知类、营销类")
@ApiOperation(value = "下发接口",notes = "多渠道多类型下发消息,目前支持邮件和短信,类型支持:验证码、通知类、营销类")
@PostMapping("/send")
public SendResponse send(@ApiParam(value = "下发消息参数",required = true, examples = @Example(@ExampleProperty(mediaType = "application/json", value = "{\"code\":\"send\",\"messageParam\":{\"receiver\":\"13788888888\",\"variables\":{\"title\":\"yyyyyy\",\"contentValue\":\"6666164180\"}},\"messageTemplateId\":1}")),example = "{\"code\":\"send\",\"messageParam\":{\"receiver\":\"13788888888\",\"variables\":{\"title\":\"yyyyyy\",\"contentValue\":\"6666164180\"}},\"messageTemplateId\":1}")
@RequestBody SendRequest sendRequest) {
public SendResponse send(@RequestBody SendRequest sendRequest) {
return sendService.send(sendRequest);
}
}

@ -71,11 +71,42 @@
</filter>
</appender>
<appender name="GELF" class="de.siegmar.logbackgelf.GelfUdpAppender">
<!-- Graylog服务的地址 -->
<graylogHost>120.48.13.113</graylogHost>
<!-- UDP Input端口 -->
<graylogPort>12201</graylogPort>
<!-- 最大GELF数据块大小单位字节508为建议最小值最大值为65467 -->
<maxChunkSize>508</maxChunkSize>
<!-- 是否使用压缩 -->
<useCompression>true</useCompression>
<encoder class="de.siegmar.logbackgelf.GelfEncoder">
<!-- 是否发送原生的日志信息 -->
<includeRawMessage>false</includeRawMessage>
<includeMarker>true</includeMarker>
<includeMdcData>true</includeMdcData>
<includeCallerData>false</includeCallerData>
<includeRootCauseData>false</includeRootCauseData>
<!-- 是否发送日志级别的名称,否则默认以数字代表日志级别 -->
<includeLevelName>true</includeLevelName>
<shortPatternLayout class="ch.qos.logback.classic.PatternLayout">
<pattern>%m%nopex</pattern>
</shortPatternLayout>
<fullPatternLayout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d - [%thread] %-5level %logger{35} - %msg%n</pattern>
</fullPatternLayout>
<!-- 配置应用名称服务名称通过staticField标签可以自定义一些固定的日志字段 -->
<staticField>app_name:austin</staticField>
</encoder>
</appender>
<root level="info">
<!-- TODO console打印后面可以只针对dev环境的 -->
<appender-ref ref="CONSOLE"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="ERROR_FILE"/>
<appender-ref ref="GELF"/>
</root>
</configuration>

@ -96,15 +96,19 @@
<version>1.6.2</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<!--graylog-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
<groupId>de.siegmar</groupId>
<artifactId>logback-gelf</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>

Loading…
Cancel
Save