From 69c67ae00023fc82c12f67792c8146fd8523a850 Mon Sep 17 00:00:00 2001 From: jaron Date: Thu, 17 Oct 2024 14:14:19 +0800 Subject: [PATCH] feat(docs): update feat(docs): update feat(docs): update --- .template/frame/api/app/.jzero.yaml.tpl | 2 +- docs/src/guide/check.md | 6 +- docs/src/guide/develop/api.md | 74 ++++++++++++++++++++++++- docs/src/guide/new.md | 4 ++ 4 files changed, 83 insertions(+), 3 deletions(-) diff --git a/.template/frame/api/app/.jzero.yaml.tpl b/.template/frame/api/app/.jzero.yaml.tpl index 22e884ab..186d2ec9 100644 --- a/.template/frame/api/app/.jzero.yaml.tpl +++ b/.template/frame/api/app/.jzero.yaml.tpl @@ -5,4 +5,4 @@ gen: after: - jzero gen swagger - spilt-api-types-dir: true \ No newline at end of file + split-api-types-dir: true \ No newline at end of file diff --git a/docs/src/guide/check.md b/docs/src/guide/check.md index 3c87f07c..fc41c9b3 100644 --- a/docs/src/guide/check.md +++ b/docs/src/guide/check.md @@ -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 diff --git a/docs/src/guide/develop/api.md b/docs/src/guide/develop/api.md index 204cdd2f..d64dc8de 100644 --- a/docs/src/guide/develop/api.md +++ b/docs/src/guide/develop/api.md @@ -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 字段校验 @@ -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) +} +``` \ No newline at end of file diff --git a/docs/src/guide/new.md b/docs/src/guide/new.md index 8c143bcb..32d97d77 100644 --- a/docs/src/guide/new.md +++ b/docs/src/guide/new.md @@ -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 @@ -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