Skip to content

Commit

Permalink
feat(docs): update
Browse files Browse the repository at this point in the history
feat(docs): update

feat(docs): update
  • Loading branch information
jaronnie committed Oct 17, 2024
1 parent a8c7c08 commit 69c67ae
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .template/frame/api/app/.jzero.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ gen:
after:
- jzero gen swagger

spilt-api-types-dir: true
split-api-types-dir: true
6 changes: 5 additions & 1 deletion docs/src/guide/check.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ order: 2

## 安装 golang

:::tip 推荐采用 go 1.21 版本以及以上
:::tip 推荐采用 go 1.21 及以上版本
:::

使用 gvm 工具安装 golang, 并能管理 golang 的版本.

[gvm Release](https://github.com/jaronnie/gvm/releases)

**注意该工具暂不支持 windows 版本**

**如果你已经有 go 环境, 可以跳过该步骤**

```shell
# 以 linux 为例子, 下载 tar.gz 后
tar -zxvf gvm_1.4.2_Linux_x86_64.tar.gz
Expand Down
74 changes: 73 additions & 1 deletion docs/src/guide/develop/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ tag:
- Guide
---

:::tip 基于 go-zero api 框架: https://go-zero.dev/docs/tutorials
:::tip
[go-zero api 文档](https://go-zero.dev/docs/tutorials)
:::

## api 字段校验
Expand All @@ -22,3 +23,74 @@ type CreateRequest {
name string `json:"name" validate:"gte=2,lte=30"` // 名称
}
```

## api types 文件分组分文件夹

:::tip
保证 .jzero.yaml 文件中的 gen.split-api-types-dir 配置为 true, 否则不生效
:::

```api
syntax = "v1"
info (
go_package: "version"
)
```

jzero 脚手架推荐的 api 文件内容如下:

可以通过如下命令生成改文件:

```shell
jzero ivm add api --name user
```

```api
syntax = "v1"
info (
go_package: "user"
)
type CreateRequest {}
type CreateResponse {}
type ListRequest {}
type ListResponse {}
type GetRequest {}
type GetResponse {}
type EditRequest {}
type EditResponse {}
type DeleteRequest {}
type DeleteResponse {}
@server (
prefix: /api/v1
group: user
)
service ntls {
@handler CreateHandler
post /user/create (CreateRequest) returns (CreateResponse)
@handler ListHandler
get /user/list (ListRequest) returns (ListResponse)
@handler GetHandler
get /user/get (GetRequest) returns (GetResponse)
@handler EditHandler
post /user/edit (EditRequest) returns (EditResponse)
@handler DeleteHandler
get /user/delete (DeleteRequest) returns (DeleteResponse)
}
```
4 changes: 4 additions & 0 deletions docs/src/guide/new.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ order: 3

:::tip
[点击了解 go-zero api 的特性以及如何使用](https://go-zero.dev/docs/tutorials)

[点击了解在 jzero 脚手架中 api 使用教程](https://jzero.jaronnie.com/guide/develop/api.html)
:::

::: code-tabs#shell
Expand Down Expand Up @@ -54,6 +56,8 @@ docker run --rm -v ${PWD}:/app ghcr.io/jzero-io/jzero:latest new your_project --

:::tip
[点击了解 go-zero zrpc 的特性以及如何使用](https://go-zero.dev/docs/tutorials/grpc/server/configuration)

[点击了解在 jzero 脚手架中 proto 使用教程](https://jzero.jaronnie.com/guide/develop/proto.html)
:::

::: code-tabs#shell
Expand Down

0 comments on commit 69c67ae

Please sign in to comment.