Skip to content

Commit

Permalink
Fix conf and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
LyricTian committed Mar 28, 2021
1 parent 1a5dc43 commit 7ac7992
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 181 deletions.
4 changes: 2 additions & 2 deletions .air.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tmp_dir = "tmp"

[build]
# Just plain old shell command. You could use `make` as well.
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"
cmd = "wire gen ./internal/app && go build -o ./cmd/gin-admin/gin-admin ./cmd/gin-admin"
# Binary file yields from `cmd`.
bin = "./cmd/gin-admin/gin-admin"
# Customize binary.
Expand All @@ -19,7 +19,7 @@ log = "air_errors.log"
# Watch these filename extensions.
include_ext = ["go", "toml"]
# Ignore these filename extensions or directories.
exclude_dir = ["assets", "tmp", "data", "docs", "scripts", "vendor", "internal/app/swagger"]
exclude_dir = ["assets", "tmp", "data", "docs", "scripts", "vendor", "internal/app/swagger" ,"internal/app/test"]
# Ignore files
exclude_file = ["internal/app/wire_gen.go"]
# There's no necessary to trigger build each time file changes if it's too frequency.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Lyric
Copyright (c) 2021 Lyric

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ build:
@go build -ldflags "-w -s -X main.VERSION=$(RELEASE_TAG)" -o $(SERVER_BIN) ./cmd/${APP}

start:
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
@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

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

wire:
wire gen ./internal/app
@wire gen ./internal/app

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

clean:
rm -rf data release $(SERVER_BIN) internal/app/test/data cmd/${APP}/data
Expand Down
66 changes: 63 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,88 @@ $ go run cmd/gin-admin/main.go web -c ./configs/config.toml -m ./configs/model.c
## 生成`swagger`文档

```
```bash
# 基于Makefile
make swagger

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

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

```
```bash
# 基于Makefile
make wire

# OR 使用wire命令
wire gen ./internal/app
```

## [gin-admin-cli](https://github.com/gin-admin/gin-admin-cli) 工具使用

### 创建项目

```bash
gin-admin-cli new -d test-gin-admin -p test-gin-admin -m
```

### 快速生成业务模块

#### 创建模板 task.yaml

```bash
name: Task
comment: 任务管理
fields:
- name: Code
type: string
comment: 任务编号
required: true
binding_options: ""
gorm_options: "size:50;index;"
- name: Name
type: string
comment: 任务名称
required: true
binding_options: ""
gorm_options: "size:50;index;"
- name: Memo
type: string
comment: 任务备注
required: false
binding_options: ""
gorm_options: "size:1024;"
```

#### 执行生成命令并运行

```bash
cd test-gin-admin
gin-admin-cli g -d . -p test-gin-admin -f ./task.yaml

# 生成 swagger
make swagger

# 生成依赖项
make wire

# 运行服务
make start
```

## 前端工程

- 基于[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))

## Questions

### OSX 下基于 `sqlite3` 运行出现:`'stdlib.h' file not found`

```bash
export CGO_ENABLED=1; export CC=gcc; go get -v -x github.com/mattn/go-sqlite3
```

## 互动交流

<div>
Expand Down
14 changes: 11 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ require (
github.com/LyricTian/queue v1.2.0
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/casbin/casbin/v2 v2.11.3
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/gin-contrib/cors v1.3.1
github.com/gin-gonic/gin v1.6.3
github.com/go-openapi/spec v0.20.3 // indirect
github.com/go-redis/redis v6.15.9+incompatible
github.com/go-redis/redis_rate v6.5.0+incompatible
github.com/google/gops v0.3.12
Expand All @@ -22,13 +24,19 @@ require (
github.com/jinzhu/gorm v1.9.16
github.com/json-iterator/go v1.1.10
github.com/koding/multiconfig v0.0.0-20171124222453-69c27309b2d7
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-sqlite3 v1.14.6 // indirect
github.com/pkg/errors v0.9.1
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.6.1
github.com/swaggo/gin-swagger v1.2.0
github.com/swaggo/swag v1.6.7
github.com/swaggo/swag v1.7.0
github.com/tidwall/buntdb v1.1.2
github.com/urfave/cli/v2 v2.2.0
github.com/urfave/cli/v2 v2.3.0
golang.org/x/net v0.0.0-20210326220855-61e056675ecf // indirect
golang.org/x/sys v0.0.0-20210326220804-49726bf1d181 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
gopkg.in/yaml.v2 v2.3.0
golang.org/x/tools v0.1.0 // indirect
gopkg.in/yaml.v2 v2.4.0
)
Loading

0 comments on commit 7ac7992

Please sign in to comment.