Skip to content

Commit c23ad98

Browse files
committed
feat: Add readme
1 parent 304edc1 commit c23ad98

File tree

6 files changed

+437
-17
lines changed

6 files changed

+437
-17
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ WORKDIR /go/src/${APP}
1616
COPY --from=builder /go/src/${APP}/${APP} /usr/bin/
1717
COPY --from=builder /go/src/${APP}/build/configs /usr/bin/configs
1818
COPY --from=builder /go/src/${APP}/build/dist /usr/bin/dist
19-
ENTRYPOINT ["ginadmin", "start", "--config-dir", "/usr/bin/configs", "--config", "prod", "--static-dir", "/usr/bin/dist"]
19+
ENTRYPOINT ["ginadmin", "start", "-d", "/usr/bin/configs", "-c", "prod", "-s", "/usr/bin/dist"]
2020
EXPOSE 8040

README.md

+166
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,169 @@
11
# [Gin](https://github.com/gin-gonic/gin)-Admin
22

33
> A lightweight, flexible, elegant and full-featured RBAC scaffolding based on GIN + GORM 2.0 + Casbin 2.0 + Wire DI.
4+
5+
English | [中文](README_CN.md)
6+
7+
[![ReportCard][reportcard-image]][reportcard-url] [![GoDoc][godoc-image]][godoc-url] [![License][license-image]][license-url]
8+
9+
## Features
10+
11+
- :scroll: Follow the `RESTful API` design specification & interface-based programming specification
12+
- :house: More concise project structure, modular design, improve code readability and maintainability
13+
- :toolbox: Based on the `GIN` framework, it provides rich middleware support (JWTAuth, CORS, RequestLogger, RequestRateLimiter, TraceID, Casbin, Recover, GZIP, StaticWebsite)
14+
- :closed_lock_with_key: RBAC access control model based on `Casbin`
15+
- :card_file_box: Database access layer based on `GORM 2.0`
16+
- :electric_plug: Dependency injection based on `WIRE` -- the role of dependency injection itself is to solve the cumbersome initialization process of hierarchical dependencies between modules
17+
- :zap: Log output based on `Zap & Context`, and unified output of key fields such as TraceID/UserID through combination with Context (also supports log hooks written to `GORM`)
18+
- :key: User authentication based on `JWT`
19+
- :microscope: Automatically generate `Swagger` documentation based on `Swaggo` - [Preview](http://101.42.232.163:8040/swagger/index.html)
20+
- :test_tube: Implement API unit testing based on `testify`
21+
- :100: Stateless service, horizontally scalable, improves service availability - dynamic permission management of Casbin is implemented through scheduled tasks and Redis
22+
- :hammer: Complete efficiency tools, can develop complete code modules through configuration - [gin-admin-cli](https://github.com/gin-admin/gin-admin-cli)
23+
24+
![swagger](./swagger.jpeg)
25+
26+
## Frontend
27+
28+
- [Frontend project based on Ant Design React](https://github.com/gin-admin/gin-admin-frontend) - [Preview](http://101.42.232.163:8040/): admin/abc-123
29+
- [Frontend project based on Vue.js](https://github.com/gin-admin/gin-admin-vue) - [Preview](http://101.42.232.163:8080/): admin/abc-123
30+
31+
## Dependencies
32+
33+
- [Go](https://golang.org/) 1.19+
34+
- [Wire](github.com/google/wire) `go install github.com/google/wire/cmd/wire@latest`
35+
- [Swag](github.com/swaggo/swag) `go install github.com/swaggo/swag/cmd/swag@latest`
36+
- [GIN-ADMIN-CLI](https://github.com/gin-admin/gin-admin-cli) `go install github.com/gin-admin/gin-admin-cli/v10@latest`
37+
38+
## Quick Start
39+
40+
### Create a new project
41+
42+
```bash
43+
gin-admin-cli new -d ~/go/src --name testapp --desc 'A test API service based on golang.' --pkg 'github.com/xxx/testapp'
44+
```
45+
46+
### Start the service
47+
48+
```bash
49+
cd ~/go/src/testapp
50+
make start
51+
# or
52+
go run main.go start
53+
```
54+
55+
### Generate a new module
56+
57+
> For more detailed usage instructions, please refer to [gin-admin-cli](https://github.com/gin-admin/gin-admin-cli)
58+
59+
```bash
60+
gin-admin-cli gen -d . -m CMS -s Article --structs-comment 'Article management'
61+
```
62+
63+
### Remove a module
64+
65+
```bash
66+
gin-admin-cli rm -d . -m CMS -s Article
67+
```
68+
69+
### Build the service
70+
71+
```bash
72+
make build
73+
# or
74+
go build -ldflags "-w -s -X main.VERSION=v1.0.0" -o ginadmin
75+
```
76+
77+
### Generate swagger docs
78+
79+
```bash
80+
make swagger
81+
# or
82+
swag init --parseDependency --generalInfo ./main.go --output ./internal/swagger
83+
```
84+
85+
### Generate wire inject
86+
87+
```bash
88+
make wire
89+
# or
90+
wire gen ./internal/wirex
91+
```
92+
93+
## Project Layout
94+
95+
```text
96+
├── cmd
97+
│   ├── start.go
98+
│   ├── stop.go
99+
│   └── version.go
100+
├── configs
101+
│   ├── dev
102+
│   │   ├── logging.toml
103+
│   │   ├── middleware.toml
104+
│   │   └── server.toml
105+
│   ├── menu.json
106+
│   └── rbac_model.conf
107+
├── internal
108+
│   ├── bootstrap
109+
│   │   ├── bootstrap.go
110+
│   │   ├── http.go
111+
│   │   └── logger.go
112+
│   ├── config
113+
│   │   ├── config.go
114+
│   │   ├── consts.go
115+
│   │   ├── middleware.go
116+
│   │   └── parse.go
117+
│   ├── mods
118+
│   │   ├── rbac
119+
│   │   │   ├── api
120+
│   │   │   ├── biz
121+
│   │   │   ├── dal
122+
│   │   │   ├── schema
123+
│   │   │   ├── casbin.go
124+
│   │   │   ├── main.go
125+
│   │   │   └── wire.go
126+
│   │   ├── sys
127+
│   │   │   ├── api
128+
│   │   │   ├── biz
129+
│   │   │   ├── dal
130+
│   │   │   ├── schema
131+
│   │   │   ├── main.go
132+
│   │   │   └── wire.go
133+
│   │   └── mods.go
134+
│   ├── utility
135+
│   │   └── prom
136+
│   │   └── prom.go
137+
│   └── wirex
138+
│   ├── injector.go
139+
│   ├── wire.go
140+
│   └── wire_gen.go
141+
├── test
142+
│   ├── menu_test.go
143+
│   ├── role_test.go
144+
│   ├── test.go
145+
│   └── user_test.go
146+
├── Dockerfile
147+
├── Makefile
148+
├── README.md
149+
├── go.mod
150+
├── go.sum
151+
└── main.go
152+
```
153+
154+
## Community
155+
156+
- [Discord](https://discord.gg/UCnpActY)
157+
158+
## MIT License
159+
160+
```text
161+
Copyright (c) 2023 Lyric
162+
```
163+
164+
[reportcard-url]: https://goreportcard.com/report/github.com/LyricTian/gin-admin
165+
[reportcard-image]: https://goreportcard.com/badge/github.com/LyricTian/gin-admin
166+
[godoc-url]: https://pkg.go.dev/github.com/LyricTian/gin-admin/v10
167+
[godoc-image]: https://godoc.org/github.com/LyricTian/gin-admin?status.svg
168+
[license-url]: http://opensource.org/licenses/MIT
169+
[license-image]: https://img.shields.io/npm/l/express.svg

README_CN.md

+171
Original file line numberDiff line numberDiff line change
@@ -1 +1,172 @@
11
# [Gin](https://github.com/gin-gonic/gin)-Admin
2+
3+
> 基于 GIN + GORM 2.0 + Casbin 2.0 + Wire DI 的轻量级、灵活、优雅且功能齐全的 RBAC 脚手架。
4+
5+
[English](README.md) | 中文
6+
7+
[![ReportCard][reportcard-image]][reportcard-url] [![GoDoc][godoc-image]][godoc-url] [![License][license-image]][license-url]
8+
9+
## Features
10+
11+
- :scroll: 遵循 `RESTful API` 设计规范 & 基于接口的编程规范
12+
- :house: 更加简洁的项目结构,模块化的设计,提高代码的可读性和可维护性
13+
- :toolbox: 基于 `GIN` 框架,提供了丰富的中间件支持(JWTAuth、CORS、RequestLogger、RequestRateLimiter、TraceID、Casbin、Recover、GZIP、StaticWebsite)
14+
- :closed_lock_with_key: 基于 `Casbin` 的 RBAC 访问控制模型
15+
- :card_file_box: 基于 `GORM 2.0` 的数据库访问层
16+
- :electric_plug: 基于 `WIRE` 的依赖注入 -- 依赖注入本身的作用是解决了各个模块间层级依赖繁琐的初始化过程
17+
- :zap: 基于 `Zap & Context` 实现了日志输出,通过结合 Context 实现了统一的 TraceID/UserID 等关键字段的输出(同时支持日志钩子写入到`GORM`)
18+
- :key: 基于 `JWT` 的用户认证
19+
- :microscope: 基于 `Swaggo` 自动生成 `Swagger` 文档 - [Preview](http://101.42.232.163:8040/swagger/index.html)
20+
- :test_tube: 基于 `testify` 实现了 API 的单元测试
21+
- :100: 无状态服务,可水平扩展,提高服务的可用性 - 通过定时任务和 Redis 实现了 Casbin 的动态权限管理
22+
- :hammer: 完善的效率工具,通过配置可以开发完整的代码模块 - [gin-admin-cli](https://github.com/gin-admin/gin-admin-cli)
23+
24+
![swagger](./swagger.jpeg)
25+
26+
## Frontend
27+
28+
- [基于 Ant Design React 实现的前端项目](https://github.com/gin-admin/gin-admin-frontend) - [Preview](http://101.42.232.163:8040/): admin/abc-123
29+
- [基于 Vue.js 实现的前端项目](https://github.com/gin-admin/gin-admin-vue) - [Preview](http://101.42.232.163:8080/): admin/abc-123
30+
31+
## Dependencies
32+
33+
- [Go](https://golang.org/) 1.19+
34+
- [Wire](github.com/google/wire) `go install github.com/google/wire/cmd/wire@latest`
35+
- [Swag](github.com/swaggo/swag) `go install github.com/swaggo/swag/cmd/swag@latest`
36+
- [GIN-ADMIN-CLI](https://github.com/gin-admin/gin-admin-cli) `go install github.com/gin-admin/gin-admin-cli/v10@latest`
37+
38+
## Quick Start
39+
40+
### Create a new project
41+
42+
```bash
43+
gin-admin-cli new -d ~/go/src --name testapp --desc 'A test API service based on golang.' --pkg 'github.com/xxx/testapp'
44+
```
45+
46+
### Start the service
47+
48+
```bash
49+
cd ~/go/src/testapp
50+
make start
51+
# or
52+
go run main.go start
53+
```
54+
55+
### Generate a new module
56+
57+
> 更加详细的使用说明请参考 [gin-admin-cli](https://github.com/gin-admin/gin-admin-cli)
58+
59+
```bash
60+
gin-admin-cli gen -d . -m CMS -s Article --structs-comment 'Article management'
61+
```
62+
63+
### Remove a module
64+
65+
```bash
66+
gin-admin-cli rm -d . -m CMS -s Article
67+
```
68+
69+
### Build the service
70+
71+
```bash
72+
make build
73+
# or
74+
go build -ldflags "-w -s -X main.VERSION=v1.0.0" -o ginadmin
75+
```
76+
77+
### Generate swagger docs
78+
79+
```bash
80+
make swagger
81+
# or
82+
swag init --parseDependency --generalInfo ./main.go --output ./internal/swagger
83+
```
84+
85+
### Generate wire inject
86+
87+
```bash
88+
make wire
89+
# or
90+
wire gen ./internal/wirex
91+
```
92+
93+
## Project Layout
94+
95+
```text
96+
├── cmd
97+
│   ├── start.go
98+
│   ├── stop.go
99+
│   └── version.go
100+
├── configs
101+
│   ├── dev
102+
│   │   ├── logging.toml
103+
│   │   ├── middleware.toml
104+
│   │   └── server.toml
105+
│   ├── menu.json
106+
│   └── rbac_model.conf
107+
├── internal
108+
│   ├── bootstrap
109+
│   │   ├── bootstrap.go
110+
│   │   ├── http.go
111+
│   │   └── logger.go
112+
│   ├── config
113+
│   │   ├── config.go
114+
│   │   ├── consts.go
115+
│   │   ├── middleware.go
116+
│   │   └── parse.go
117+
│   ├── mods
118+
│   │   ├── rbac
119+
│   │   │   ├── api
120+
│   │   │   ├── biz
121+
│   │   │   ├── dal
122+
│   │   │   ├── schema
123+
│   │   │   ├── casbin.go
124+
│   │   │   ├── main.go
125+
│   │   │   └── wire.go
126+
│   │   ├── sys
127+
│   │   │   ├── api
128+
│   │   │   ├── biz
129+
│   │   │   ├── dal
130+
│   │   │   ├── schema
131+
│   │   │   ├── main.go
132+
│   │   │   └── wire.go
133+
│   │   └── mods.go
134+
│   ├── utility
135+
│   │   └── prom
136+
│   │   └── prom.go
137+
│   └── wirex
138+
│   ├── injector.go
139+
│   ├── wire.go
140+
│   └── wire_gen.go
141+
├── test
142+
│   ├── menu_test.go
143+
│   ├── role_test.go
144+
│   ├── test.go
145+
│   └── user_test.go
146+
├── Dockerfile
147+
├── Makefile
148+
├── README.md
149+
├── go.mod
150+
├── go.sum
151+
└── main.go
152+
```
153+
154+
## Contact Us
155+
156+
<div>
157+
<img src="https://store.zixinwangluo.cn/screenshots/gin-admin/wechat.jpeg" width="256"alt="wechat" />
158+
<img src="https://store.zixinwangluo.cn/screenshots/gin-admin/qqgroup.jpeg" width="256" alt="qqgroup" />
159+
</div>
160+
161+
## MIT License
162+
163+
```text
164+
Copyright (c) 2023 Lyric
165+
```
166+
167+
[reportcard-url]: https://goreportcard.com/report/github.com/LyricTian/gin-admin
168+
[reportcard-image]: https://goreportcard.com/badge/github.com/LyricTian/gin-admin
169+
[godoc-url]: https://pkg.go.dev/github.com/LyricTian/gin-admin/v10
170+
[godoc-image]: https://godoc.org/github.com/LyricTian/gin-admin?status.svg
171+
[license-url]: http://opensource.org/licenses/MIT
172+
[license-image]: https://img.shields.io/npm/l/express.svg

cmd/start.go

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func StartCmd() *cli.Command {
2626
Usage: "Working directory",
2727
DefaultText: "configs",
2828
Value: "configs",
29-
Required: true,
3029
},
3130
&cli.StringFlag{
3231
Name: "config",

0 commit comments

Comments
 (0)