后端
A. maven管理依赖 聚合项目
B. 基础框架 spring boot
C. 引入spring cloud微服务提供 版本netfilx
1.注册中心使用nacos
2.接口调用feign
3.熔断Hystrix Htxon.SR3
4.搜索引擎 es7
Welcome to Elastic Docs | Elastic
5.接口文档swagger
添加依赖
<!-- swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
添加配置类
@EnableSwagger2
@Configuration
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
// 自行修改为自己的包路径
.apis(RequestHandlerSelectors.basePackage("com.zhanggm.controller"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("深度应用后台api接口文档")
.description("restful 风格接口")
.version("1.0")
.build();
}
}
访问地址:http://ip:port/swagger-ui.html
注解使用说明
@Api 类说明
@Api:用在请求的类上,说明该类的作用
tags="说明该类的作用"
value="该参数没什么意义,所以不需要配置"
@Api("APP用户注册Controller")
public class UserController {
}
属性名称 | 数据类型 | 默认值 | 说明 |
---|---|---|---|
value | String | “” | 隐式设置操作的标记,遗留支持(读取 description) |
tags | String[] | “” | 对接口进行分组 |
produces | String | “” | |
consumes | String | “” | 采用逗号分隔的 content types,例如: application/json,application/xml 会接收JSON和XML的输入 |
protocols | String | “” | 采用逗号分隔的可用协议,例如:http,https,ws,wss |
authorizations | Authorization[] | “” | 授权列表 |
hidden | boolean | false | 隐藏此资源下的操作, 和 @ApiOperation 注解中的 hidden 组合使用可以隐藏改接口 |
@ApiOperation 方法说明
@ApiOperation:"用在请求的方法上,说明方法的作用"
value="说明方法的作用"
notes="方法的备注说明"
@Api("APP用户注册Controller")
public class UserController {
@ApiOperation(value="用户注册",notes="手机号、密码都是必输项,年龄随边填,但必须是数字")
@RequestMapping("register")
public Object register(){
}
}
属性名称 | 数据类型 | 默认值 | 说明 |
---|---|---|---|
value | String | 接口简要说明,120字符或更少 | |
notes | String | “” | 接口详细描述 |
tags | String[] | “” | tag 列表,可用于按自愿或任何其它限定符对操作进行逻辑分组 |
response | Class<?> | Void.class | 接口返回类型 |
responseContainer | String | “” | 声明包装响应的容器。有效值为 List,Set,Map,任何其它值都将被忽略 |
responseReference | String | “” | 指定对响应类型的引用,本地/远程引用,并将覆盖任何其它指定的response()类 |
httpMethod | String | “” | 请求方式:“GET”, “HEAD”, “POST”, “PUT”, “DELETE”, “OPTIONS” and “PATCH”,如果未指定则使用除"PATH"之外的其它所有 |
nickname | String | “” | 第三方工具使用operationId来唯一表示此操作 |
produces | String | “” | 采用逗号分隔的 content types 类型的返回数据,例如:application/json,application/xml |
consumes | String | “” | 采用逗号分隔的 content types 类型的入参数据类型,例如:application/json,application/xml |
protocols | String | “” | 指定协议类型:http,https,ws,wss,多个协议使用逗号进行分隔 |
authorizations | Authorization[] | @Authorization(value = “”) | 获取此操作的授权列表 |
hidden | boolean | false | 是否隐藏操作列表中的操作 |
responseHeaders | ResponseHeader[] | @ResponseHeader(name = “”, response = Void.class) | 指定 response header 信息列表 |
code | int | 200 | HTTP返回状态码 |
extensions | Extension[] | @Extension(properties = @ExtensionProperty(name = “”, value = “”)) | 可选的扩展数组 |
@ApiImplicitParams**参数说明
用在请求的方法上,包含一组参数说明
@ApiImplicitParams:用在请求的方法上,包含一组参数说明
@ApiImplicitParam:用在 @ApiImplicitParams 注解中,指定一个请求参数的配置信息
name:参数名
value:参数的汉字说明、解释
required:参数是否必须传
paramType:参数放在哪个地方
· header --> 请求参数的获取:@RequestHeader
· query --> 请求参数的获取:@RequestParam
· path(用于restful接口)--> 请求参数的获取:@PathVariable
· body(不常用)
· form(不常用)
dataType:参数类型,默认String,其它值dataType="Integer"
defaultValue:参数的默认值
@Api("APP用户注册Controller")
public class UserController {
@ApiImplicitParams({
@ApiImplicitParam(name="mobile",value="手机号",required=true),
@ApiImplicitParam(name="password",value="密码",required=true),
@ApiImplicitParam(name="age",value="年龄",required=true,paramType="form",dataType="Integer")
})
@RequestMapping("register")
public Object register(){
}
}
属性名称 | 数据类型 | 默认值 | 说明 |
---|---|---|---|
name | String | “” | 参数名称,参数名称将从 filed/method/parameter 名称中派生, 但你可以覆盖它,路径参数必须始终命名为它们所代表的路径部分 |
value | String | “” | 参数简单描述 |
defaultValue | String | “” | 描述参数默认值 |
allowableValues | String | “” | 可接收参数值限制,有三种方式,取值列表,取值范围 |
required | boolean | false | 是否为必传参数, false:非必传; true:必传 |
access | String | “” | 参数过滤,请参阅:io.swagger.core.filter.SwaggerSpecFilter |
allowMultiple | boolean | false | 指定参数是否可以通过多次出现来接收多个值 |
hidden | boolean | false | 隐藏参数列表中的参数 |
example | String | “” | 非请求体(body)类型的单个参数示例 |
examples | Example | @Example(value = @ExampleProperty(mediaType = “”, value = “”)) 参数示例,仅适用于请求体类型的请求 | |
type | String | “” | 添加覆盖检测到类型的功能 |
format | String | “” | 添加提供自定义format格式的功能 |
allowEmptyValue | boolean | false | 添加将格式设置为空的功能 |
readOnly | boolean | false | 添加被指定为只读的能力 |
collectionFormat | String | “” | 添加使用 array 类型覆盖 collectionFormat 的功能 |
@ApiResponses方法返回说明
@ApiResponses:用于请求的方法上,表示一组响应
@ApiResponse:用在@ApiResponses中,一般用于表达一个错误的响应信息
code:数字,例如400
message:信息,例如"请求参数没填好"
response:抛出异常的类
@Api("APP用户注册Controller")
public class UserController {
@ApiResponses({
@ApiResponse(code=400,message="请求参数没填好"),
@ApiResponse(code=404,message="请求路径没有或页面跳转路径不对")
})
@RequestMapping("register")
public Object register(){
}
}
属性名称 | 数据类型 | 默认值 | 说明 |
---|---|---|---|
code | int | 响应的HTTP状态码 | |
message | String | 伴随响应的人类可读的消息 | |
response | Class<?> | Void.class | 用于描述消息有效负载的可选响应类,对应于响应消息对象的 schema 字段 |
reference | String | “” | 指定对响应类型的引用,指定的应用可以使本地引用,也可以是远程引用, 将按原样使用,并将覆盖任何指定的response()类 |
responseHeaders | ResponseHeader[] | @ResponseHeader(name = “”, response = Void.class) | 可能响应的 header 列表 |
responseContainer | String | “” | 声明响应的容器,有效值为List,Set,Map,任何其他值都将被忽略 |
@ApiModel 模型说明
@ApiModel:用于响应类上,表示一个返回响应数据的信息
(这种一般用在post创建的时候,使用@RequestBody这样的场景,
请求参数无法使用@ApiImplicitParam注解进行描述的时候)
@ApiModelProperty:用在属性上,描述响应类的属性
@ApiModel(description= "返回响应数据")
public class RestMessage implements Serializable{
@ApiModelProperty(value = "是否成功")
private boolean success=true;
@ApiModelProperty(value = "返回对象")
private Object data;
@ApiModelProperty(value = "错误编号")
private Integer errCode;
@ApiModelProperty(value = "错误信息")
private String message;
/* getter/setter */
}
属性名称 | 数据类型 | 默认值 | 说明 |
---|---|---|---|
value | String | 类名 | 为模型提供备用名称 |
description | String | “” | 提供详细的类描述 |
parent | Class<?> | Void.class | 为模型提供父类以允许描述继承关系 |
discriminatory | String | “” | 支持模型继承和多态,使用鉴别器的字段的名称,可以断言需要使用哪个子类型 |
subTypes | Class<?>[] | {} | 从此模型继承的子类型数组 |
reference | String | “” | 指定对应类型定义的引用,覆盖指定的任何其他元数据 |
@ApiModelProperty
属性名称 | 数据类型 | 默认值 | 说明 |
---|---|---|---|
value | String | “” | 属性简要说明 |
name | String | “” | 运行覆盖属性的名称。重写属性名称 |
allowableValues | String | “” | 限制参数可接收的值,三种方法,固定取值,固定范围 |
access | String | “” | 过滤属性,参阅:io.swagger.core.filter.SwaggerSpecFilter |
notes | String | “” | 目前尚未使用 |
dataType | String | “” | 参数的数据类型,可以是类名或原始数据类型,此值将覆盖从类属性读取的数据类型 |
required | boolean | false | 是否为必传参数,false:非必传参数; true:必传参数 |
position | int | 0 | 允许在模型中显示排序属性 |
hidden | boolean | false | 隐藏模型属性,false:不隐藏; true:隐藏 |
example | String | “” | 属性的示例值 |
readOnly | boolean | false | 指定模型属性为只读,false:非只读; true:只读 |
reference | String | “” | 指定对应类型定义的引用,覆盖指定的任何其他元数据 |
allowEmptyValue | boolean | false | 允许传空值,false:不允许传空值; true:允许传空值 |
6.sql监控
SQL监控_HaoFather_father的博客-优快云博客
7.安全登录security
Spring——Security安全框架使用详解(基于内存认证)_专注写bug的博客-优快云博客_security安全框架
8.缓存机制redis 限流
9.网关 gateway
10.全局令牌token采用jwt生成
11.阿里云短信集成
12.aop+Kafka日志存储
13.七牛云oss文件存储
Spring Boot集成七牛云对象存储oss_dreaming9420的博客-优快云博客_springboot集成七牛云
14.quartz定时任务
前端
vue vuex element-ui axios echarte图表 quill富文本
api 公共模块