Skip to content

Commit 7ac7992

Browse files
committed
Fix conf and usage
1 parent 1a5dc43 commit 7ac7992

File tree

9 files changed

+230
-181
lines changed

9 files changed

+230
-181
lines changed

.air.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tmp_dir = "tmp"
99

1010
[build]
1111
# Just plain old shell command. You could use `make` as well.
12-
cmd = "wire gen ./internal/app/injector && swag init --generalInfo ./internal/app/swagger.go --output ./internal/app/swagger && go build -o ./cmd/gin-admin/gin-admin ./cmd/gin-admin"
12+
cmd = "wire gen ./internal/app && go build -o ./cmd/gin-admin/gin-admin ./cmd/gin-admin"
1313
# Binary file yields from `cmd`.
1414
bin = "./cmd/gin-admin/gin-admin"
1515
# Customize binary.
@@ -19,7 +19,7 @@ log = "air_errors.log"
1919
# Watch these filename extensions.
2020
include_ext = ["go", "toml"]
2121
# Ignore these filename extensions or directories.
22-
exclude_dir = ["assets", "tmp", "data", "docs", "scripts", "vendor", "internal/app/swagger"]
22+
exclude_dir = ["assets", "tmp", "data", "docs", "scripts", "vendor", "internal/app/swagger" ,"internal/app/test"]
2323
# Ignore files
2424
exclude_file = ["internal/app/wire_gen.go"]
2525
# There's no necessary to trigger build each time file changes if it's too frequency.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Lyric
3+
Copyright (c) 2021 Lyric
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ build:
1818
@go build -ldflags "-w -s -X main.VERSION=$(RELEASE_TAG)" -o $(SERVER_BIN) ./cmd/${APP}
1919

2020
start:
21-
go run -ldflags "-X main.VERSION=$(RELEASE_TAG)" ./cmd/${APP}/main.go web -c ./configs/config.toml -m ./configs/model.conf --menu ./configs/menu.yaml
21+
@go run -ldflags "-X main.VERSION=$(RELEASE_TAG)" ./cmd/${APP}/main.go web -c ./configs/config.toml -m ./configs/model.conf --menu ./configs/menu.yaml
2222

2323
swagger:
24-
swag init --parseDependency --generalInfo ./cmd/${APP}/main.go --output ./internal/app/swagger
24+
@swag init --parseDependency --generalInfo ./cmd/${APP}/main.go --output ./internal/app/swagger
2525

2626
wire:
27-
wire gen ./internal/app
27+
@wire gen ./internal/app
2828

2929
test:
30-
@go test -v $(shell go list ./...)
30+
cd ./internal/app/test && go test -v
3131

3232
clean:
3333
rm -rf data release $(SERVER_BIN) internal/app/test/data cmd/${APP}/data

README.md

+63-3
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,88 @@ $ go run cmd/gin-admin/main.go web -c ./configs/config.toml -m ./configs/model.c
6363
6464
## 生成`swagger`文档
6565

66-
```
66+
```bash
6767
# 基于Makefile
6868
make swagger
6969

7070
# OR 使用swag命令
71-
swag init --generalInfo ./cmd/gin-admin/main.go --output ./internal/app/swagger
71+
swag init --parseDependency --generalInfo ./cmd/${APP}/main.go --output ./internal/app/swagger
7272
```
7373

7474
## 重新生成依赖注入文件
7575

76-
```
76+
```bash
7777
# 基于Makefile
7878
make wire
7979

8080
# OR 使用wire命令
8181
wire gen ./internal/app
8282
```
8383

84+
## [gin-admin-cli](https://github.com/gin-admin/gin-admin-cli) 工具使用
85+
86+
### 创建项目
87+
88+
```bash
89+
gin-admin-cli new -d test-gin-admin -p test-gin-admin -m
90+
```
91+
92+
### 快速生成业务模块
93+
94+
#### 创建模板 task.yaml
95+
96+
```bash
97+
name: Task
98+
comment: 任务管理
99+
fields:
100+
- name: Code
101+
type: string
102+
comment: 任务编号
103+
required: true
104+
binding_options: ""
105+
gorm_options: "size:50;index;"
106+
- name: Name
107+
type: string
108+
comment: 任务名称
109+
required: true
110+
binding_options: ""
111+
gorm_options: "size:50;index;"
112+
- name: Memo
113+
type: string
114+
comment: 任务备注
115+
required: false
116+
binding_options: ""
117+
gorm_options: "size:1024;"
118+
```
119+
120+
#### 执行生成命令并运行
121+
122+
```bash
123+
cd test-gin-admin
124+
gin-admin-cli g -d . -p test-gin-admin -f ./task.yaml
125+
126+
# 生成 swagger
127+
make swagger
128+
129+
# 生成依赖项
130+
make wire
131+
132+
# 运行服务
133+
make start
134+
```
135+
84136
## 前端工程
85137

86138
- 基于[Ant Design React](https://ant.design/index-cn)版本的实现:[gin-admin-react](https://github.com/gin-admin/gin-admin-react)(也可使用国内源:[https://gitee.com/lyric/gin-admin-react](https://gitee.com/lyric/gin-admin-react))
87139

140+
## Questions
141+
142+
### OSX 下基于 `sqlite3` 运行出现:`'stdlib.h' file not found`
143+
144+
```bash
145+
export CGO_ENABLED=1; export CC=gcc; go get -v -x github.com/mattn/go-sqlite3
146+
```
147+
88148
## 互动交流
89149

90150
<div>

go.mod

+11-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ require (
88
github.com/LyricTian/queue v1.2.0
99
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
1010
github.com/casbin/casbin/v2 v2.11.3
11+
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
1112
github.com/dgrijalva/jwt-go v3.2.0+incompatible
1213
github.com/fatih/camelcase v1.0.0 // indirect
1314
github.com/fatih/structs v1.1.0 // indirect
1415
github.com/gin-contrib/cors v1.3.1
1516
github.com/gin-gonic/gin v1.6.3
17+
github.com/go-openapi/spec v0.20.3 // indirect
1618
github.com/go-redis/redis v6.15.9+incompatible
1719
github.com/go-redis/redis_rate v6.5.0+incompatible
1820
github.com/google/gops v0.3.12
@@ -22,13 +24,19 @@ require (
2224
github.com/jinzhu/gorm v1.9.16
2325
github.com/json-iterator/go v1.1.10
2426
github.com/koding/multiconfig v0.0.0-20171124222453-69c27309b2d7
27+
github.com/mailru/easyjson v0.7.7 // indirect
28+
github.com/mattn/go-sqlite3 v1.14.6 // indirect
2529
github.com/pkg/errors v0.9.1
30+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
2631
github.com/sirupsen/logrus v1.6.0
2732
github.com/stretchr/testify v1.6.1
2833
github.com/swaggo/gin-swagger v1.2.0
29-
github.com/swaggo/swag v1.6.7
34+
github.com/swaggo/swag v1.7.0
3035
github.com/tidwall/buntdb v1.1.2
31-
github.com/urfave/cli/v2 v2.2.0
36+
github.com/urfave/cli/v2 v2.3.0
37+
golang.org/x/net v0.0.0-20210326220855-61e056675ecf // indirect
38+
golang.org/x/sys v0.0.0-20210326220804-49726bf1d181 // indirect
3239
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
33-
gopkg.in/yaml.v2 v2.3.0
40+
golang.org/x/tools v0.1.0 // indirect
41+
gopkg.in/yaml.v2 v2.4.0
3442
)

0 commit comments

Comments
 (0)