-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from chenhg5/master
complete the English docs and add fr directory
- Loading branch information
Showing
43 changed files
with
2,915 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Cli Introduction | ||
--- | ||
|
||
GoAdmin provides a command line tool to increase development efficiency and streamline the development process. | ||
|
||
## Install | ||
|
||
|
||
Download the binary of the corresponding system: | ||
|
||
| File name | OS | Arch | Size | | ||
| ---- | ---- | ---- |---- | | ||
| [admincli_darwin_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_darwin_x86_64_v1.0.1.zip) | macOs | x86-64 | 4.77 MB | ||
| [admincli_linux_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_linux_x86_64_v1.0.1.zip) | Linux | x86-64 | 6.52 MB | ||
| [admincli_linux_armel_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_linux_armel_v1.0.1.zip) | Linux | x86 | 6.06 MB | ||
| [admincli_windows_i386_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_windows_i386_v1.0.1.zip) | Windows | x86 |6.16 MB | ||
| [admincli_windows_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_windows_x86_64_v1.0.1.zip) | Windows | x86-64 |6.38 MB | ||
|
||
|
||
Or use the command to install: | ||
|
||
``` | ||
go install github.com/GoAdminGroup/go-admin/admincli | ||
``` | ||
|
||
## Usage | ||
|
||
Use | ||
|
||
``` | ||
admincli --help | ||
``` | ||
|
||
Will list help information. | ||
|
||
| Command | Subcommand | Options | Function | | ||
| ---- | ---- | ---- | ---- | | ||
| generate | - | - | generate a data model file. | ||
| compile | asset| **-s, --src** front-end resource folder path<br>**-o, --out** output go file path | compile all resource files into one single go file. | ||
| compile | tpl | **-s, --src** the input golang tmpl template folder path<br>**-o, --out** output go file path | compile all template files into one single go file. | ||
| combine | css| **-s, --src** the input css folder path<br>**-o, --out** the output css file path | combine the css files into one single css file. | ||
| combine | js | **-s, --src** the input js folder path<br>**-o, --out** the output js file path | combine the js files into one single js file. | ||
| develop | tpl | **-m, --module** golang module name or path under $GOPATH<br>**-n, --name** theme name | fetch remotely theme development templates to local. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# File Upload Engine | ||
--- | ||
|
||
By default, GoAdmin provides a local file upload engine that supports uploading files to the server. Use the directory that needs to be set up in the global configuration and the prefix for uploading file access. | ||
|
||
```go | ||
package config | ||
|
||
// Storage directory: store avatar and other uploaded files | ||
type Store struct { | ||
Path string // relative or absolute path, the file will be stored here | ||
Prefix string // access url prefix | ||
} | ||
|
||
type Config struct { | ||
|
||
... | ||
|
||
// Upload file storage location | ||
Store Store `json:"store"` | ||
|
||
// File upload engine | ||
FileUploadEngine FileUploadEngine `json:"file_upload_engine"` | ||
|
||
... | ||
} | ||
|
||
type FileUploadEngine struct { | ||
Name string | ||
Config map[string]interface{} | ||
} | ||
``` | ||
|
||
If you want to customize the upload location, such as uploading to cloud, aws cloud and other cloud platforms, then you need to write an upload engine yourself. Here's how to write your own engine: | ||
|
||
### Type of engine | ||
|
||
```go | ||
package file | ||
|
||
type Uploader interface { | ||
Upload(*multipart.Form) error | ||
} | ||
|
||
type UploaderGenerator func() Uploader | ||
|
||
func AddUploader(name string, up UploaderGenerator) { | ||
... | ||
} | ||
``` | ||
|
||
### How to | ||
|
||
We need to call the **AddUploader** method to add an upload engine. The first parameter is the name of the engine (which will be used in the global configuration) and the second parameter is the engine generation function. | ||
|
||
Suppose we want to add a aws cloud upload engine, then it can be similar like this: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
... | ||
"github.com/GoAdminGroup/go-admin/modules/file" | ||
... | ||
) | ||
|
||
type AwsUploader struct { | ||
Bucket string | ||
Region string | ||
SecretId string | ||
SecretKey string | ||
|
||
Prefix string | ||
Path string | ||
} | ||
|
||
func (q AwsUploader) Upload(*multipart.Form) error { | ||
// 接收一个表单类型,这里实现上传逻辑 | ||
} | ||
|
||
func main() { | ||
|
||
... | ||
|
||
file.AddUploader("aws", func() file.Uploader { | ||
return &AwsUploader{ | ||
Bucket: config.Get().FileUploadEngine.Config["bucket"].(string), | ||
Region: config.Get().FileUploadEngine.Config["region"].(string), | ||
SecretId: config.Get().FileUploadEngine.Config["secret_id"].(string), | ||
SecretKey: config.Get().FileUploadEngine.Config["secret_key"].(string), | ||
Prefix: config.Get().FileUploadEngine.Config["prefix"].(string), | ||
Path: config.Get().FileUploadEngine.Config["path"].(string), | ||
} | ||
}) | ||
|
||
cfg := config.Config{ | ||
... | ||
|
||
FileUploadEngine: config.FileUploadEngine{ | ||
Name: "aws", | ||
Config: map[string]interface{}{ | ||
"bucket": "xxx", | ||
"region": "xxx", | ||
"secret_id": "xxx", | ||
"secret_key": "xxx", | ||
"prefix": "xxx", | ||
"path": "xxx", | ||
}, | ||
} | ||
|
||
... | ||
} | ||
|
||
... | ||
} | ||
``` | ||
|
||
Finish a aws cloud upload file engine!🍺🍺 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Basic Usage | ||
--- | ||
|
||
Use the cli to generate a data form type for the sql table, such as: | ||
|
||
```sql | ||
CREATE TABLE `users` ( | ||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | ||
`name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | ||
`gender` tinyint(4) DEFAULT NULL, | ||
`city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | ||
`ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | ||
`phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | ||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`updated_at` timestamp NULL DEFAULT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
``` | ||
|
||
Generated: | ||
|
||
```go | ||
package datamodel | ||
|
||
import ( | ||
... | ||
) | ||
|
||
func GetUserTable() (userTable table.Table) { | ||
|
||
// config the table model. | ||
userTable = table.NewDefaultTable(...) | ||
|
||
... | ||
|
||
formList := userTable.GetForm() | ||
|
||
// set id editable is false. | ||
formList.AddField("ID", "id", db.Int, form.Default).FieldNotAllowEdit() | ||
formList.AddField("Ip", "ip", db.Varchar, form.Text) | ||
formList.AddField("Name", "name", db.Varchar, form.Text) | ||
|
||
... | ||
|
||
return | ||
} | ||
``` | ||
|
||
### Add Fields | ||
|
||
```go | ||
|
||
// Add a field with the field title ID, field name id, field type int, form type Default | ||
formList.AddField("ID", "id", db.Int, form.Default) | ||
|
||
// Add a second field with the field title Ip, the field name ip, the field type varchar, and the form type Text | ||
formList.AddField("Ip", "ip", db.Varchar, form.Text) | ||
|
||
// Add a third field, a field that does not exist in the sql table | ||
formList.AddField("Custom", "custom", db.Varchar, form.Text) | ||
|
||
``` | ||
|
||
### Prohibit editing | ||
|
||
```go | ||
|
||
``` | ||
|
||
### No new additions | ||
|
||
```go | ||
|
||
``` |
Oops, something went wrong.