Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions en/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,39 @@

* [Get Ready](install)

* [Quick Start](init-project)
* [Quick Start](quick_start)

* Plugins

* [How To Use Plugins](plugins/plugins)
* [How To Use Admin Plugin](plugins/admin)

* Admin Plugins

* Data Table
* [Basic Usage](admin/table/basic)
* [Column Usage](admin/table/column_usage)
* Data Form
* [Basic Usage](admin/form/basic)
* [Form Components](admin/form/components)
* [Menus](admin/menus)
* [Permissions](admin/rbac)
* [File Upload](admin/file)
* [Cli](admin/cli)

* Pages

* [Page Modules](pages/modules)
* [Customize your page](pages/pages)
* [Customize Your Page](pages/pages)
* [Customize Login Page](pages/login)

* Architecture

* [Introduction](architecture/introduction)

* Development

* [Code Style](development/code_style)
* [Adapter Development](development/adapter)
* [Plugins Development](development/plugins)
* Template Development
Expand All @@ -24,6 +43,4 @@
* [Form Development](development/template/form)
* [Components](development/template/components)

* [Menus](menu)

* [Permissions](rbac)
* [Plan](plan)
43 changes: 43 additions & 0 deletions en/admin/cli.md
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.
118 changes: 118 additions & 0 deletions en/admin/file.md
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!🍺🍺
74 changes: 74 additions & 0 deletions en/admin/form/basic.md
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

```
Loading