Markdown lint (#58)
* markdown linter * format markdown docs * format exiting markdown docs
This commit is contained in:
@@ -1,31 +1,34 @@
|
||||
# goctl使用说明
|
||||
# goctl使用
|
||||
|
||||
## goctl用途
|
||||
|
||||
* 定义api请求
|
||||
* 根据定义的api自动生成golang(后端), java(iOS & Android), typescript(web & 晓程序),dart(flutter)
|
||||
* 生成MySQL CURD 详情见[goctl model模块](model/sql)
|
||||
|
||||
## goctl使用说明
|
||||
#### goctl参数说明
|
||||
|
||||
### goctl 参数说明
|
||||
|
||||
`goctl api [go/java/ts] [-api user/user.api] [-dir ./src]`
|
||||
|
||||
> api 后面接生成的语言,现支持go/java/typescript
|
||||
|
||||
>
|
||||
> -api 自定义api所在路径
|
||||
|
||||
>
|
||||
> -dir 自定义生成目录
|
||||
|
||||
#### 保持goctl总是最新版
|
||||
|
||||
第一次运行会在~/.goctl里增加下面两行:
|
||||
|
||||
```
|
||||
```Plain Text
|
||||
url = http://47.97.184.41:7777/
|
||||
```
|
||||
|
||||
#### API 语法说明
|
||||
|
||||
```
|
||||
```Plain Text
|
||||
info(
|
||||
title: doc title
|
||||
desc: >
|
||||
@@ -122,6 +125,7 @@ service user-api {
|
||||
head /api/ping()
|
||||
}
|
||||
```
|
||||
|
||||
1. info部分:描述了api基本信息,比如Auth,api是哪个用途。
|
||||
2. type部分:type类型声明和golang语法兼容。
|
||||
3. service部分:service代表一组服务,一个服务可以由多组名称相同的service组成,可以针对每一组service配置jwt和auth认证,另外通过folder属性可以指定service生成所在子目录。
|
||||
@@ -130,6 +134,7 @@ service user-api {
|
||||
请求getRequest里面的属性赋值,getResponse为返回的结构体,这两个类型都定义在2描述的类型中。
|
||||
|
||||
#### api vscode插件
|
||||
|
||||
开发者可以在vscode中搜索goctl的api插件,它提供了api语法高亮,语法检测和格式化相关功能。
|
||||
|
||||
1. 支持语法高亮和类型导航。
|
||||
@@ -141,7 +146,7 @@ service user-api {
|
||||
命令如下:
|
||||
`goctl api go -api user/user.api -dir user`
|
||||
|
||||
```
|
||||
```Plain Text
|
||||
|
||||
.
|
||||
├── internal
|
||||
@@ -171,20 +176,28 @@ service user-api {
|
||||
└── user.go
|
||||
|
||||
```
|
||||
|
||||
生成的代码可以直接跑,有几个地方需要改:
|
||||
|
||||
* 在`servicecontext.go`里面增加需要传递给logic的一些资源,比如mysql, redis,rpc等
|
||||
* 在定义的get/post/put/delete等请求的handler和logic里增加处理业务逻辑的代码
|
||||
* 在`servicecontext.go`里面增加需要传递给logic的一些资源,比如mysql, redis,rpc等
|
||||
* 在定义的get/post/put/delete等请求的handler和logic里增加处理业务逻辑的代码
|
||||
|
||||
#### 根据定义好的api文件生成java代码
|
||||
`goctl api java -api user/user.api -dir ./src`
|
||||
|
||||
```Plain Text
|
||||
goctl api java -api user/user.api -dir ./src
|
||||
```
|
||||
|
||||
#### 根据定义好的api文件生成typescript代码
|
||||
`goctl api ts -api user/user.api -dir ./src -webapi ***`
|
||||
|
||||
ts需要指定webapi所在目录
|
||||
|
||||
```Plain Text
|
||||
goctl api ts -api user/user.api -dir ./src -webapi ***
|
||||
```
|
||||
|
||||
ts需要指定webapi所在目录
|
||||
|
||||
#### 根据定义好的api文件生成Dart代码
|
||||
`goctl api dart -api user/user.api -dir ./src`
|
||||
|
||||
* 如有不理解的地方,随时问Kim/Kevin
|
||||
|
||||
```Plain Text
|
||||
goctl api dart -api user/user.api -dir ./src
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user