Skip to content

Commit b1945a9

Browse files
committed
feat(docs): update
feat(docs): update feat(docs): update
1 parent f37932a commit b1945a9

File tree

7 files changed

+439
-12
lines changed

7 files changed

+439
-12
lines changed

cmd/new.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ import (
2929

3030
// newCmd represents the new command
3131
var newCmd = &cobra.Command{
32-
Use: "new",
33-
Short: `Used to create project from templates`,
32+
Use: "new",
33+
Short: `Used to create project from templates`,
34+
SilenceUsage: true,
3435
RunE: func(cmd *cobra.Command, args []string) error {
3536
if config.C.New.Output == "" {
3637
config.C.New.Output = args[0]
@@ -109,6 +110,7 @@ var newCmd = &cobra.Command{
109110
base = filepath.Join("frame", "api", "app")
110111
}
111112

113+
// 没有设置 home,则使用内置模板持久化的默认路径 ~/.jzero/templates/$version
112114
if !pathx.FileExists(embeded.Home) {
113115
embeded.Home = filepath.Join(home, ".jzero", "templates", Version)
114116
}

config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ type GenDocsConfig struct {
141141
}
142142

143143
type GenCrudConfig struct {
144+
// todo: add flag
144145
}
145146

146147
type IvmConfig struct {

docs/src/guide/check.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ docker tag registry.cn-hangzhou.aliyuncs.com/ghcr.io/jaronnie/jzero:latest ghcr.
3737

3838
## 不同姿势使用 jzero
3939

40-
:::important 必看!!!
40+
:::important 涨知识的小技巧
4141
:::
4242

4343
* 支持通过配置文件 .jzero.yaml 控制各种参数(**强烈推荐在每个项目的根目录新建该文件**)

docs/src/guide/develop/api.md

+31-5
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,43 @@ tag:
1010

1111
## 前言
1212

13+
通过 go-zero 自研的 api 文件定义, 称为 api 可描述语言, 可用于
1314

15+
* 自动生成多语言服务端代码
16+
* 自动生成文档(json/html/swagger)
17+
* 自动生成多语言客户端代码
18+
19+
与 proto 文件有异曲同工之妙, 但是比 proto 更简单易用
20+
21+
[go-zero api 教程](https://go-zero.dev/docs/tutorials)
22+
23+
![](http://oss.jaronnie.com/image-20250120232337438.png)
1424

1525
## api 字段校验
1626

17-
> jzero 集成 [https://github.com/go-playground/validator](https://github.com/go-playground/validator) 进行字段校验
27+
> jzero 默认集成 [https://github.com/go-playground/validator](https://github.com/go-playground/validator) 进行字段校验
1828
19-
```api
29+
```shell
2030
syntax = "v1"
2131

2232
type CreateRequest {
2333
name string `json:"name" validate:"gte=2,lte=30"` // 名称
2434
}
2535
```
2636

27-
## api types 文件分组分文件夹
37+
## 将 types 文件夹按照 go_package 进行分组
38+
39+
:::important go_package 的选项, 参考自 proto 文件, 能将 message 生成的结构体分组
40+
41+
在 api 文件中同理, go_package 选项能将定义的 type 生成的结构体分组
42+
43+
两大优点:
44+
1. 避免默认生成的 types/types.go 爆炸
2845

29-
```api
46+
2. 提升开发体验, 不同 group 下的 type 命名不会冲突
47+
:::
48+
49+
```shell
3050
syntax = "v1"
3151

3252
info (
@@ -36,7 +56,7 @@ info (
3656

3757
## 合并同一个 group 的 handler 为同一个文件
3858

39-
```api
59+
```shell
4060
@server (
4161
prefix: /api/v1
4262
group: system/user
@@ -55,4 +75,10 @@ service simpleapi {
5575

5676
```shell
5777
jzero ivm add api --name user
78+
```
79+
80+
完整命令如下:
81+
82+
```shell
83+
jzero ivm add api --name user --handlers get:List,get:Get,post:Edit,get:Delete
5884
```

0 commit comments

Comments
 (0)