├── .gitignore
├── README.md
├── SUMMARY.md
├── en
├── README.md
├── admin
│ ├── auth.md
│ ├── cdn.md
│ ├── cli.md
│ ├── file.md
│ ├── form
│ │ ├── basic.md
│ │ └── components.md
│ ├── menus.md
│ ├── module.md
│ ├── rbac.md
│ ├── table
│ │ ├── basic.md
│ │ ├── column_display.md
│ │ └── column_usage.md
│ └── theme.md
├── architecture
│ └── introduction.md
├── development
│ ├── adapter.md
│ ├── code_style.md
│ ├── plugins.md
│ └── template
│ │ ├── components.md
│ │ ├── form.md
│ │ └── template.md
├── install.md
├── pages
│ ├── components.md
│ ├── login.md
│ ├── modules.md
│ └── pages.md
├── plan.md
├── plugins
│ ├── admin.md
│ └── plugins.md
├── quick_start.md
└── tests
│ └── ci.md
├── fr
├── README.md
├── admin
│ ├── cli.md
│ ├── file.md
│ ├── form
│ │ ├── basic.md
│ │ └── components.md
│ ├── menus.md
│ ├── module.md
│ ├── rbac.md
│ ├── table
│ │ ├── basic.md
│ │ └── column_usage.md
│ └── theme.md
├── architecture
│ └── introduction.md
├── development
│ ├── adapter.md
│ ├── code_style.md
│ ├── plugins.md
│ └── template
│ │ ├── components.md
│ │ ├── form.md
│ │ └── template.md
├── install.md
├── pages
│ ├── components.md
│ ├── login.md
│ ├── modules.md
│ └── pages.md
├── plan.md
├── plugins
│ ├── admin.md
│ └── plugins.md
└── quick_start.md
├── tr
├── README.md
├── admin
│ ├── README.md
│ ├── cli.md
│ ├── file.md
│ ├── form
│ │ ├── README.md
│ │ ├── basic.md
│ │ └── components.md
│ ├── menus.md
│ ├── module.md
│ ├── rbac.md
│ ├── table
│ │ ├── README.md
│ │ ├── basic.md
│ │ └── column_usage.md
│ └── theme.md
├── architecture
│ ├── README.md
│ └── introduction.md
├── development
│ ├── README.md
│ ├── adapter.md
│ ├── code_style.md
│ ├── plugins.md
│ └── template
│ │ ├── README.md
│ │ ├── components.md
│ │ ├── form.md
│ │ └── template.md
├── install.md
├── pages
│ ├── README.md
│ ├── components.md
│ ├── login.md
│ ├── modules.md
│ └── pages.md
├── plan.md
├── plugins
│ ├── README.md
│ ├── admin.md
│ └── plugins.md
└── quick_start.md
└── zh
├── README.md
├── admin
├── api.md
├── auth.md
├── cdn.md
├── cli.md
├── file.md
├── form
│ ├── basic.md
│ └── components.md
├── menus.md
├── module.md
├── rbac.md
├── table
│ ├── basic.md
│ ├── column_display.md
│ └── column_usage.md
└── theme.md
├── architecture
└── introduction.md
├── components
├── chartjs.md
├── components.md
├── infobox.md
├── progressbar.md
└── usage.md
├── development
├── adapter.md
├── code_style.md
├── plugins.md
└── template
│ ├── components.md
│ └── template.md
├── install.md
├── monitor
└── monitor.md
├── pages
├── components.md
├── login.md
├── modules.md
└── pages.md
├── plan.md
├── plugins
├── admin.md
└── plugins.md
├── quick_start.md
└── tests
└── ci.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .idea
3 | node_modules
4 | package-lock.json
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GoAdmin Docs
2 |
3 | GoAdmin Documentation
4 |
5 | {% page-ref page="en/" %}
6 |
7 | {% page-ref page="zh/" %}
--------------------------------------------------------------------------------
/SUMMARY.md:
--------------------------------------------------------------------------------
1 | * [English](en/README.md)
2 | * [Get Ready](en/install.md)
3 | * [Quick Start](en/quick_start.md)
4 | * [Plugins]()
5 | * [How To Use Plugins](en/plugins/plugins.md)
6 | * [How To Use Admin Plugin](en/plugins/admin.md)
7 | * [Admin Plugins]()
8 | * [Data Table]()
9 | * [Basic Usage](en/admin/table/basic.md)
10 | * [Column Usage](en/admin/table/column_usage.md)
11 | * [Column Display](zh/admin/table/column_display.md)
12 | * [Data Form]()
13 | * [Basic Usage](en/admin/form/basic.md)
14 | * [Form Components](en/admin/form/components.md)
15 | * [Menus](en/admin/menus.md)
16 | * [Permissions](en/admin/rbac.md)
17 | - [Modules](en/admin/module.md)
18 | * [New Theme](en/admin/theme.md)
19 | * [File Upload](en/admin/file.md)
20 | * [Cli](en/admin/cli.md)
21 | * [Customize auth user table](en/admin/auth.md)
22 | * [Set up CDN](en/admin/cdn.md)
23 | * [Pages]()
24 | * [Page Modules](en/pages/modules.md)
25 | * [Customize Your Page](en/pages/pages.md)
26 | * [Customize Login Page](en/pages/login.md)
27 | * [CI tests]()
28 | * [CI tests](en/tests/ci.md)
29 | * [Architecture]()
30 | * [Introduction](en/architecture/introduction.md)
31 | * [Development]()
32 | * [Code Style](en/development/code_style.md)
33 | * [Adapter Development](en/development/adapter.md)
34 | * [Plugins Development](en/development/plugins.md)
35 | * [Template Development]()
36 | * [Template Introducation](en/development/template/template.md)
37 | * [Components](en/development/template/components.md)
38 | * [Plan](en/plan.md)
39 | * [简体中文](zh/README.md)
40 | - [准备工作](zh/install.md)
41 | - [快速开始](zh/quick_start.md)
42 | - [插件]()
43 | - [插件的使用](zh/plugins/plugins.md)
44 | - [Admin插件使用](zh/plugins/admin.md)
45 | - [Admin插件]()
46 | - [数据表格]()
47 | - [基本使用](zh/admin/table/basic.md)
48 | - [列的使用](zh/admin/table/column_usage.md)
49 | - [列的显示](zh/admin/table/column_display.md)
50 | - [数据表单]()
51 | - [基本使用](zh/admin/form/basic.md)
52 | - [表单组件](zh/admin/form/components.md)
53 | - [设置菜单](zh/admin/menus.md)
54 | - [权限管理](zh/admin/rbac.md)
55 | - [模块](zh/admin/module.md)
56 | - [使用新主题](zh/admin/theme.md)
57 | - [文件上传](zh/admin/file.md)
58 | - [命令行工具](zh/admin/cli.md)
59 | - [自定义管理用户表](zh/admin/auth.md)
60 | - [设置cdn](zh/admin/cdn.md)
61 | - [Monitor插件](zh/monitor/monitor.md)
62 | - [ui组件介绍]()
63 | - [目录](zh/components/components.md)
64 | - [使用介绍](zh/components/usage.md)
65 | - [infobox](zh/components/infobox.md)
66 | - [chartjs](zh/components/chartjs.md)
67 | - [progress-group](zh/components/progressbar.md)
68 | - [页面介绍]()
69 | - [页面模块化](zh/pages/modules.md)
70 | - [自定义页面](zh/pages/pages.md)
71 | - [修改登录界面](zh/pages/login.md)
72 | - [ci测试]()
73 | - [ci测试](zh/tests/ci.md)
74 | - [项目架构]()
75 | - [架构介绍](zh/architecture/introduction.md)
76 | - [项目开发]()
77 | - [代码规范](zh/development/code_style.md)
78 | - [适配器](zh/development/adapter.md)
79 | - [插件](zh/development/plugins.md)
80 | - [模板开发]()
81 | - [模板介绍](zh/development/template/template.md)
82 | - [组件开发](zh/development/template/components.md)
83 | - [发展规划](zh/plan.md)
--------------------------------------------------------------------------------
/en/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 | ------
3 |
4 | GoAdmin is a framework, providing a complete set of visual UI calls to golang programs, and a built-in sql relational database management backend plugin.
5 |
6 |
7 | In the past, when we try to build an administrative platform, we needed at least one backend IT engineer, a front-end IT engineer, taking at least a week work.
8 | Now with GoAdmin, we don't need front-end IT engineers. Our back-end IT engineers don't even need to know the front-end knowledge. We can build a complete administrative platform or a data visualization platform in half an hour.
9 | If your requirements are not so complicated, just simple crud, then all you need are serveral golang files, and all files can be packaged into a single binary file, which is very convenient for distribution and deployment.
10 |
11 | Here is a super simple example which quickly shows you how it works: [https://github.com/GoAdminGroup/example](https://github.com/GoAdminGroup/example)
12 |
13 |
14 | ## Features
15 |
16 | - Build-in RBAC Access Authentication System
17 | - Support most web framework
18 | - Support plug-ins(working on it)
19 | - Provided different ui theme(only Adminlte now, others are coming soon.)
20 |
21 | ## Online Demo
22 |
23 | [https://demo.go-admin.com](https://demo.go-admin.com)
24 |
25 | ## Dependencies
26 |
27 | - [Datetimepicker](http://eonasdan.github.io/bootstrap-datetimepicker/)
28 | - [font-awesome](http://fontawesome.io/)
29 | - [bootstrap-fileinput](https://github.com/kartik-v/bootstrap-fileinput)
30 | - [jquery-pjax](https://github.com/defunkt/jquery-pjax)
31 | - [Nestable](http://dbushell.github.io/Nestable/)
32 | - [toastr](http://codeseven.github.io/toastr/)
33 | - [bootstrap-number-input](https://github.com/wpic/bootstrap-number-input)
34 | - [fontawesome-iconpicker](https://github.com/itsjavi/fontawesome-iconpicker)
35 |
36 | ## Community
37 |
38 | [Community](http://discuss.go-admin.com)
39 |
40 | ## Backers
41 |
42 | Your support will help me do better!
43 |
44 |
45 |
46 | [Support Paypal too](https://www.paypal.me/cg80333)
--------------------------------------------------------------------------------
/en/admin/auth.md:
--------------------------------------------------------------------------------
1 | # Customize authentication user table
2 | ---
3 |
4 | The authentication user table of the framework is the most basic information, if you need to customize a lot of extra information, such as mobile phone/IP/gender, etc. You can custom an authentication user table.
5 |
6 | First, you need to prepare your own user table. Such as: goadmin_super_manager。And then modify configuration item ```auth_user_table``` in the global configuration. Then generate data model file, overwriting the official user table model file:
7 |
8 | **Note: the user table fields remain with the official line, then on the basis of the official user table field extension.**
9 |
10 | ```go
11 | import (
12 | ...
13 | "github.com/GoAdminGroup/go-admin/engine"
14 | ...
15 | )
16 |
17 | func main() {
18 |
19 | ...
20 |
21 | eng := engine.Default()
22 |
23 | cfg := config.Config{
24 | ...
25 | AuthUserTable: "goadmin_super_manager",
26 | ...
27 | }
28 |
29 | if err := eng.AddConfig(cfg).
30 | // Super administrator access, data model logic can refer to the official documents:https://github.com/GoAdminGroup/go-admin/blob/master/plugins/admin/modules/table/generators.go#L40
31 | AddGenerator("manager", GetGoAdminSuperManager).
32 | // Ordinary users to access
33 | AddGenerator("normal_manager", GetGoAdminSuperNormalManager).
34 | ...
35 | Use(r); err != nil {
36 | panic(err)
37 | }
38 |
39 | ...
40 |
41 | }
42 | ```
--------------------------------------------------------------------------------
/en/admin/cdn.md:
--------------------------------------------------------------------------------
1 | # Setting CDN
2 | ---
3 |
4 | For your website set up CDN, static resources need to be placed into your CDN website.
5 |
6 | The official built-in themes of static resources:
7 |
8 | - [adminlte](https://github.com/GoAdminGroup/themes/tree/master/adminlte/resource/assets/dist)
9 | - [sword](https://github.com/GoAdminGroup/themes/tree/master/sword/resource/assets/dist)
10 |
11 | After set up your cdn, you should keep the assets/dist directory. Which means if your cdn address is https://xxxx-cdn.xxxx.com. Then the resource request url is like: https://xxxx-cdn.xxxx.com/assets/dist/css/..../xxxx.css
12 |
13 | To take effect also need to set in the global configuration: asset_url items.
--------------------------------------------------------------------------------
/en/admin/cli.md:
--------------------------------------------------------------------------------
1 | # Cli Introduction
2 | ---
3 |
4 | GoAdmin provides a command line tool to increase development efficiency and streamline the development process.
5 |
6 | ## Install
7 |
8 |
9 | Download the binary of the corresponding system:
10 |
11 | | File name | OS | Arch | Size |
12 | | ---- | ---- | ---- |---- |
13 | | [adm_darwin_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_darwin_x86_64_v1.2.24.zip) | macOs | x86-64 | 4.77 MB
14 | | [adm_linux_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_x86_64_v1.2.24.zip) | Linux | x86-64 | 6.52 MB
15 | | [adm_linux_armel_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_armel_v1.2.24.zip) | Linux | x86 | 6.06 MB
16 | | [adm_windows_i386_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_i386_v1.2.24.zip) | Windows | x86 |6.16 MB
17 | | [adm_windows_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_x86_64_v1.2.24.zip) | Windows | x86-64 |6.38 MB
18 |
19 |
20 | Or use the command to install:
21 |
22 | ```
23 | go install github.com/GoAdminGroup/adm
24 | ```
25 |
26 | ## Usage
27 |
28 | Use
29 |
30 | ```
31 | adm --help
32 | ```
33 |
34 | Will list help information.
35 |
36 | | Command | Subcommand | Options | Function |
37 | | ---- | ---- | ---- | ---- |
38 | | generate | - | - | generate a data model file.
39 | | compile | asset| **-s, --src** front-end resource folder path **-d, --dist** output go file path | compile all resource files into one single go file.
40 | | compile | tpl | **-s, --src** the input golang tmpl template folder path **-d, --dist** output go file path **p, --package** output go file package name | compile all template files into one single go file.
41 | | combine | css| **-s, --src** the input css folder path **-d, --dist** the output css file path **p, --package** output go file package name | combine the css files into one single css file.
42 | | combine | js | **-s, --src** the input js folder path **-d, --dist** the output js file path | combine the js files into one single js file.
43 | | develop | tpl | **-m, --module** golang module name or path under $GOPATH **-n, --name** theme name | fetch remotely theme development templates to local.
44 |
--------------------------------------------------------------------------------
/en/admin/file.md:
--------------------------------------------------------------------------------
1 | # File Upload Engine
2 | ---
3 |
4 | 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.
5 |
6 | ```go
7 | package config
8 |
9 | // Storage directory: store avatar and other uploaded files
10 | type Store struct {
11 | Path string // relative or absolute path, the file will be stored here
12 | Prefix string // access url prefix
13 | }
14 |
15 | type Config struct {
16 |
17 | ...
18 |
19 | // Upload file storage location
20 | Store Store `json:"store"`
21 |
22 | // File upload engine
23 | FileUploadEngine FileUploadEngine `json:"file_upload_engine"`
24 |
25 | ...
26 | }
27 |
28 | type FileUploadEngine struct {
29 | Name string
30 | Config map[string]interface{}
31 | }
32 | ```
33 |
34 | 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:
35 |
36 | ### Type of engine
37 |
38 | ```go
39 | package file
40 |
41 | type Uploader interface {
42 | Upload(*multipart.Form) error
43 | }
44 |
45 | type UploaderGenerator func() Uploader
46 |
47 | func AddUploader(name string, up UploaderGenerator) {
48 | ...
49 | }
50 | ```
51 |
52 | ### How to
53 |
54 | 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.
55 |
56 | Suppose we want to add a aws cloud upload engine, then it can be similar like this:
57 |
58 | ```go
59 | package main
60 |
61 | import (
62 | ...
63 | "github.com/GoAdminGroup/go-admin/modules/file"
64 | ...
65 | )
66 |
67 | type AwsUploader struct {
68 | Bucket string
69 | Region string
70 | SecretId string
71 | SecretKey string
72 |
73 | Prefix string
74 | Path string
75 | }
76 |
77 | func (q AwsUploader) Upload(*multipart.Form) error {
78 | // Receive a form type, for upload logic here
79 | // This invocation framework auxiliary function
80 | file.Upload(func(*multipart.FileHeader, string) (string, error){
81 | // Here for upload logic, return to the file path and error information
82 | }, form)
83 | }
84 |
85 | func main() {
86 |
87 | ...
88 |
89 | file.AddUploader("aws", func() file.Uploader {
90 | return &AwsUploader{
91 | Bucket: config.Get().FileUploadEngine.Config["bucket"].(string),
92 | Region: config.Get().FileUploadEngine.Config["region"].(string),
93 | SecretId: config.Get().FileUploadEngine.Config["secret_id"].(string),
94 | SecretKey: config.Get().FileUploadEngine.Config["secret_key"].(string),
95 | Prefix: config.Get().FileUploadEngine.Config["prefix"].(string),
96 | Path: config.Get().FileUploadEngine.Config["path"].(string),
97 | }
98 | })
99 |
100 | cfg := config.Config{
101 | ...
102 |
103 | FileUploadEngine: config.FileUploadEngine{
104 | Name: "aws",
105 | Config: map[string]interface{}{
106 | "bucket": "xxx",
107 | "region": "xxx",
108 | "secret_id": "xxx",
109 | "secret_key": "xxx",
110 | "prefix": "xxx",
111 | "path": "xxx",
112 | },
113 | }
114 |
115 | ...
116 | }
117 |
118 | ...
119 | }
120 | ```
121 |
122 | Finish a aws cloud upload file engine!🍺🍺
--------------------------------------------------------------------------------
/en/admin/form/basic.md:
--------------------------------------------------------------------------------
1 | # Basic Usage
2 | ---
3 |
4 | Use the cli to generate a data form type for the sql table, such as:
5 |
6 | ```sql
7 | CREATE TABLE `users` (
8 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
9 | `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
10 | `gender` tinyint(4) DEFAULT NULL,
11 | `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
12 | `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
13 | `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
14 | `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
15 | `updated_at` timestamp NULL DEFAULT NULL,
16 | PRIMARY KEY (`id`)
17 | ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
18 | ```
19 |
20 | Generated:
21 |
22 | ```go
23 | package datamodel
24 |
25 | import (
26 | ...
27 | )
28 |
29 | func GetUserTable(ctx *context.Context) (userTable table.Table) {
30 |
31 | // config the table model.
32 | userTable = table.NewDefaultTable(...)
33 |
34 | ...
35 |
36 | formList := userTable.GetForm()
37 |
38 | // set id editable is false.
39 | formList.AddField("ID", "id", db.Int, form.Default).FieldNotAllowEdit()
40 | formList.AddField("Ip", "ip", db.Varchar, form.Text)
41 | formList.AddField("Name", "name", db.Varchar, form.Text)
42 |
43 | ...
44 |
45 | return
46 | }
47 | ```
48 |
49 |
50 | ## Type
51 |
52 | - ```Default```
53 | - ```Text```
54 | - SingleSelection ```SelectSingle```
55 | - ```Password```
56 | - ```RichText```
57 | - ```File```
58 | - ```SelectBox```
59 | - ```Select```
60 | - ```IconPicker```
61 | - ```Datetime```
62 | - ```Radio```
63 | - ```Email```
64 | - ```Url```
65 | - ```Ip```
66 | - ```Color```
67 | - ```Currency```
68 | - ```Number```
69 |
70 | Example:
71 |
72 | ```go
73 |
74 | import (
75 | ...
76 | "github.com/GoAdminGroup/go-admin/template/types/form"
77 | ...
78 | )
79 |
80 | func GetxxxTable(ctx *context.Context) table.Table {
81 | formList.AddField("ID", "id", db.Int, form.Default)
82 | }
83 |
84 | ```
85 |
86 | ## Operations
87 |
88 | ### Add fields
89 |
90 | ```go
91 |
92 | // Add a field with the field title ID, field name id, field type int, form type Default
93 | formList.AddField("ID", "id", db.Int, form.Default)
94 |
95 | // Add a second field with the field title Ip, the field name ip, the field type varchar, and the form type Text
96 | formList.AddField("Ip", "ip", db.Varchar, form.Text)
97 |
98 | // Add a third field, a field that does not exist in the sql table
99 | formList.AddField("Custom", "custom", db.Varchar, form.Text)
100 |
101 | ```
102 |
103 | ### Default value
104 |
105 | ```go
106 | formList.AddField("header", "header", db.Varchar, form.Text).FieldDefault("header")
107 | ```
108 |
109 | ### Required field
110 |
111 | ```go
112 | formList.AddField("header", "header", db.Varchar, form.Text).FieldMust()
113 | ```
114 |
115 | ### Help msg
116 |
117 | ```go
118 | formList.AddField("header", "header", db.Varchar, form.Text).FieldHelpMsg("length should be more than 5")
119 | ```
120 |
121 | ### Prohibit editing
122 |
123 | ```go
124 |
125 | formList.AddField("id", "id", db.Int, form.Default).FieldNotAllowEdit()
126 |
127 | ```
128 |
129 | ### Prohibit creating
130 |
131 | ```go
132 |
133 | formList.AddField("id", "id", db.Int, form.Default).FieldNotAllowAdd()
134 |
135 | ```
136 |
137 | ### Validator
138 |
139 | ```go
140 | formList.SetPostValidator(func(values form2.Values) error {
141 | if values.Get("sex") != "women" && values.Get("sex") != "men" {
142 | return fmt.Errorf("error info")
143 | }
144 | return nil
145 | })
146 | ```
147 |
148 | ### Filter function before update/insert operation
149 |
150 | ```go
151 | formList.AddField("Link", "url", db.Varchar, form.Text).
152 | FieldPostFilterFn(func(value types.PostFieldModel) interface{} {
153 | return "http://xxxx.com/" + value.Get("url")
154 | })
155 | ```
156 |
157 | *If the insert field need to be NULL*
158 |
159 | ```go
160 | formList.AddField("avatar", "avatar", db.Varchar, form.Text).
161 | FieldPostFilterFn(func(value types.PostFieldModel) interface{} {
162 | if value.Value == "" {
163 | return sql.NullString{}
164 | }
165 | return value.Value
166 | })
167 | ```
168 |
169 | ### Display filter procress functions
170 |
171 | ```go
172 |
173 | // Limit length
174 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldLimit(limit int)
175 |
176 | // Trim space
177 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldTrimSpace()
178 |
179 | // Truncate
180 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldSubstr(start int, end int)
181 |
182 | // Title
183 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldToTitle()
184 |
185 | // Upper
186 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldToUpper()
187 |
188 | // Lower
189 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldToLower()
190 |
191 | // xss fliter
192 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldXssFilter()
193 |
194 | ```
195 |
196 | ### Rewrite the insert/update logic functions
197 |
198 | If your form inserts and the update operation is complicated, the framework can not meet you need, then you can rewrite and replace the default logics.
199 |
200 | ```go
201 |
202 | // replace the default insert logic
203 | formList.SetInsertFn(func(values form2.Values) error {
204 | // values are the form parameters
205 | })
206 |
207 | // replace the default update logic
208 | formList.SetUpdateFn(func(values form2.Values) error {
209 | // values are the form parameters
210 | })
211 | ```
212 |
213 | ### Form update process
214 |
215 | In chronological order as follows:
216 |
217 | - FormPanel.Validator data validate
218 | - FormPanel.PreProcessFn data pre process
219 | - FormPanel.UpdateFn/InsertFn update/insert
220 | - FormPanel.PostHook hook
221 |
222 | The corresponding setting APIs:
223 |
224 | ```go
225 |
226 | formList.SetPostValidator()
227 | formList.SetPreProcessFn()
228 | formList.SetPostHook()
229 | formList.SetUpdateFn()
230 | formList.SetInsertFn()
231 |
232 | ```
233 |
234 | In the PostHook callback function, you can get the update/insert resutl by calling```values.PostError()```.
--------------------------------------------------------------------------------
/en/admin/menus.md:
--------------------------------------------------------------------------------
1 | # Setting menu
2 | ---
3 |
4 | GoAdmin has built-in menu management module. After entering the home page as a super administrator, expand the management of the left sidebar, there is a management panel below:
5 |
6 | 
7 |
8 | Click inside to set up the menu you need.
--------------------------------------------------------------------------------
/en/admin/rbac.md:
--------------------------------------------------------------------------------
1 | # Authority management
2 | ---
3 |
4 | GoAdmin has built in [RBAC] (https://www.google.com/search?oq=rbac) permission control module. After entering the home page as a super administrator, expand the management of the left sidebar. There are three management panels for users, roles, and permissions:
5 |
6 | 
7 |
8 |
9 | ## Instructions
10 |
11 | Permission management is the route and method for limit, the route url can use golang regular match rules. As long as the method and route to correspond, permission test will pass. So the need to each route and method for configuration, so as to decide the granularity of its permission.
12 |
13 | On a form of management, the corresponding routing to add and delete, assuming that form called ` ` ` users ` ` `, as follows:
14 |
15 | | Permission | url path | method |
16 | | ---- | ---- | ---- |
17 | | List page | /info/users | GET |
18 | | Edit page of all rows | /info/users/edit | GET |
19 | | Edit page of specify row | /info/users/edit?id=2 | GET |
20 | | Edit operation of all rows | /edit/users | POST |
21 | | Edit operation of specify row | /edit/users?id=2 | POST |
22 | | New page | /info/users/new | GET |
23 | | Create operation | /new/users | POST |
24 | | Export operation | /export/users | POST |
25 | | All permission | * | (empty)
26 |
27 | **Note 1: instructions of route matching rules**
28 |
29 | As you can see, there is such like ```id=2``` parameters in the url of the table above. It is a rule of the admin plugin, that is if the request url has the parameters that are on the match of the parameters of the rule url, it will pass the permission test. In addition, the parameters, **__goadmin_edit_pk**, **__goadmin_detail_pk**,**__goadmin_detail_pk** can be replaced as **id**. For example:
30 |
31 | > verifying request url: /info/users/edit?__page=1&__pageSize=10&__sort=id&__sort_type=desc&__goadmin_edit_pk=3632
32 | > rule url: /info/users/edit?id=3632
33 | > test result: pass
34 |
35 | **Note 2: set up the authority does not mean the left side menu can be seen**
36 |
37 | Set the permissions, if need to display on the left side of the menu, you also need to in the menu editor page set up corresponding role.
38 |
39 | **Note 3: the role of permissions is higher than in the menu configuration**
40 |
41 | That is to say, assuming the menu 1, corresponding operator is the role of, and have all permissions users can still access the menu 1.
42 |
43 | **Note 4: permissions will have affect in the display of the UI component**
44 |
45 | Which means, if you don`t have the permission of edit, you will not see the edit button.
--------------------------------------------------------------------------------
/en/admin/table/column_display.md:
--------------------------------------------------------------------------------
1 | # Column Display
2 | ---
3 |
4 | ## Bool
5 |
6 | Display bool type field value. The first parameter stands for true, the second is false.
7 |
8 | ```go
9 | info.AddField("Pass", "pass", db.Tinyint).FieldBool("1", "0")
10 | ```
11 |
12 | ## Copyable
13 |
14 | Display a copy button.
15 |
16 | ```go
17 | info.AddField("UUID", "uuid", db.Varchar).FieldCopyable()
18 | ```
19 |
20 | ## Carousel
21 |
22 | ```go
23 | info.AddField("Photos", "photos", db.Varchar).FieldCarousel(func(value string) []string {
24 | return strings.Split(value, ",")
25 | }, 150, 100)
26 | ```
27 |
28 | ## Dot
29 |
30 | ```go
31 | info.AddField("State", "finish_state", db.Tinyint).
32 | FieldDisplay(func(value types.FieldModel) interface{} {
33 | if value.Value == "0" {
34 | return "Step 1"
35 | }
36 | if value.Value == "1" {
37 | return "Step 2"
38 | }
39 | if value.Value == "2" {
40 | return "Step 3"
41 | }
42 | return "unknown"
43 | }).
44 | FieldDot(map[string]types.FieldDotColor{
45 | "Step 1": types.FieldDotColorDanger,
46 | "Step 2": types.FieldDotColorInfo,
47 | "Step 3": types.FieldDotColorPrimary,
48 | }, types.FieldDotColorDanger)
49 | ```
50 |
51 | ## Progress Bar
52 |
53 | Display as a progress bar. Optional parameter is types.FieldProgressBarData
54 |
55 | ```go
56 | info.AddField("完成进度", "finish_progress", db.Int).FieldProgressBar()
57 |
58 | type FieldProgressBarData struct {
59 | Style string // style
60 | Size string // size
61 | Max int // max
62 | }
63 | ```
64 |
65 | ## Downloadable Link
66 |
67 | Display as a file downloadable link when field is an url. Optional parameter is url prefix string.
68 |
69 | ```go
70 | info.AddField("Resume", "resume", db.Varchar).
71 | FieldDisplay(func(value types.FieldModel) interface{} {
72 | return filepath.Base(value.Value)
73 | }).
74 | FieldDownLoadable("http://yinyanghu.github.io/files/")
75 | ```
76 |
77 | ## Filesize
78 |
79 | If the field is byte int type, display as human-readable format string.
80 |
81 | ```go
82 | info.AddField("FileSize", "resume_size", db.Int).FieldFileSize()
83 | ```
84 |
85 | ## Loading
86 |
87 | When state is 0/1/2, display as a loading gif.
88 |
89 | ```go
90 | info.AddField("State", "state", db.Int).FieldLoading([]string{"0", "1", "2"})
91 | ```
92 |
93 | ## Label
94 |
95 | Display as a label, optional parameter is types.FieldLabelParam
96 |
97 | ```go
98 | info.AddField("Label", "label", db.Varchar).FieldLabel(types.FieldLabelParam{})
99 |
100 | type FieldLabelParam struct {
101 | Color template.HTML
102 | Type string
103 | }
104 | ```
105 |
106 | ## Image
107 |
108 | If field `avatar` is full path, it will show as a image
109 |
110 | ```go
111 | info.AddField("Avatar", "avatar", db.Varchar).FieldImage("50", "50")
112 | ```
113 |
114 | You can custom the prefix.
115 |
116 | ```go
117 | info.AddField("Avatar", "avatar", db.Varchar).FieldImage("50", "50", "https://prefix.com")
118 | ```
--------------------------------------------------------------------------------
/en/admin/theme.md:
--------------------------------------------------------------------------------
1 | # Use New Theme
2 | ---
3 |
4 | Follow two steps:(Notice:GoAdmin version should be higher than v1.0.2)
5 |
6 | - 1. import the theme package
7 | - 2. set theme name in your config
8 |
9 | Ex:
10 |
11 | ```go
12 | package main
13 |
14 | import (
15 | ...
16 |
17 | _ "github.com/GoAdminGroup/themes/sword"
18 |
19 | ...
20 | )
21 |
22 | func main() {
23 | r := gin.Default()
24 |
25 | gin.SetMode(gin.ReleaseMode)
26 | gin.DefaultWriter = ioutil.Discard
27 |
28 | eng := engine.Default()
29 |
30 | cfg := config.Config{
31 | ...
32 |
33 | Theme: "sword",
34 |
35 | ...
36 | }
37 |
38 | ...
39 | }
40 | ```
41 |
42 | Of course, if you import multi themes, you can switch it in the real-time config center.
--------------------------------------------------------------------------------
/en/architecture/introduction.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 | ---
3 |
4 | The GoAdmin project module is as follows:
5 |
6 | | Name | Function | Path |
7 | | ---- | ---- | ---- |
8 | | engine | Engine is the core module of GoAdmin. The function of this module is to use the web framework adapter to inject the mapping between the plugin's routing and controller methods into the framework. | ./engine/engine.go
9 | | adapter | The function of the adapter is to realize the mutual conversion between the context of the web framework and the context of GoAdmin. | ./adapter/adapter.go
10 | | context | Context is the context of a request, the record includes the routing parameters and method information of the request, the context will be passed to the method of the plugin | ./context/context.go
11 | | plugin | Each plugin has its own routing and controller method. After receiving the context converted by the adapter, it is processed by the controller method and returned to the adapter and then output to the web framework. | ./plugins/plugins.go
12 | | template | Template is the golang materialization corresponding to the front-end code, and the component parts corresponding to the front-end code, such as forms, rows, columns, etc., are instantiated as an interface of golang, so the html code of the component can be obtained by calling the interface method, and this function is provided to Plugin to call | ./template/template.go
13 | | auth | Auth implements the management of cookies, stores and converts the front-end cookie to the logged-in user, and implements the interception of the privilege. | ./modules/auth/auth.go
14 | | config | Config is the global configuration of the system | ./modules/config/config.go
15 | | db | db is a sql connection library, connected to the sql database to provide query and other help methods, support for multiple drivers | ./modules/db/connection.go
16 | | language | Language implements a simple language mapping to support language localization | ./modules/language/language.go
17 | | file | File implements a file upload engine | ./modules/file/file.go
18 | | logger | The logger is the log module of the project | ./modules/logger/logger.go
19 | | menu | Menu is the management of the project menu | ./modules/menu/menu.go
20 | | cli | Cli command line module, including some basic commands for generating files and development | ./adm/cli.go
--------------------------------------------------------------------------------
/en/development/adapter.md:
--------------------------------------------------------------------------------
1 | # Adapter Development
2 | ---
3 |
4 | The role of the adapter is to achieve the conversion of the web framework context and GoAdmin's own context.
5 | To make a Adapter, you need implemente three methods:
6 |
7 | ```go
8 | package adapter
9 |
10 | import (
11 | "github.com/GoAdminGroup/go-admin/plugins"
12 | "github.com/GoAdminGroup/go-admin/template/types"
13 | )
14 | // WebFrameWork is an interface which is used as an adapter of
15 | // framework and goAdmin. It must implement two methods. Use registers
16 | // the routes and the corresponding handlers. Content writes the
17 | // response to the corresponding context of framework.
18 | type WebFrameWork interface {
19 | // Name return the web framework name.
20 | Name() string
21 |
22 | // Use method inject the plugins to the web framework engine which is the
23 | // first parameter.
24 | Use(app interface{}, plugins []plugins.Plugin) error
25 |
26 | // Content add the panel html response of the given callback function to
27 | // the web framework context which is the first parameter.
28 | Content(ctx interface{}, fn types.GetPanelFn, navButtons ...types.Button)
29 |
30 | // User get the auth user model from the given web framework context.
31 | User(ctx interface{}) (models.UserModel, bool)
32 |
33 | // AddHandler inject the route and handlers of GoAdmin to the web framework.
34 | AddHandler(method, path string, handlers context.Handlers)
35 |
36 | DisableLog()
37 |
38 | Static(prefix, path string)
39 |
40 | // Helper functions
41 | // ================================
42 |
43 | SetApp(app interface{}) error
44 | SetConnection(db.Connection)
45 | GetConnection() db.Connection
46 | SetContext(ctx interface{}) WebFrameWork
47 | GetCookie() (string, error)
48 | Path() string
49 | Method() string
50 | FormParam() url.Values
51 | IsPjax() bool
52 | Redirect()
53 | SetContentType()
54 | Write(body []byte)
55 | CookieKey() string
56 | HTMLContentType() string
57 | }
58 | ```
59 |
60 | More: [https://github.com/GoAdminGroup/go-admin/tree/master/adapter](https://github.com/GoAdminGroup/go-admin/tree/master/adapter)
--------------------------------------------------------------------------------
/en/development/code_style.md:
--------------------------------------------------------------------------------
1 | # Code Style
2 | ---
3 |
4 | ```
5 | make lint
6 | ```
--------------------------------------------------------------------------------
/en/development/plugins.md:
--------------------------------------------------------------------------------
1 | # Plugins Development
2 | ---
3 |
4 | A plugin needs to implement the corresponding four interfaces, such as:
5 |
6 | ```go
7 | // Plug-in is an important part of GoAdmin. Different plug-ins have different features.
8 | type Plugin interface {
9 |
10 | // Get handlers
11 | GetHandler() context.HandlerMap
12 |
13 | // Initialize the plug-in
14 | InitPlugin(services service.List)
15 |
16 | // Get plugin name
17 | Name() string
18 |
19 | // Url prefix
20 | Prefix() string
21 | }
22 | ```
23 |
24 | Create a new plug-in must inherit```plugin.Base```. For example:
25 |
26 | ```go
27 | package example
28 |
29 | import (
30 | c "github.com/GoAdminGroup/go-admin/modules/config"
31 | "github.com/GoAdminGroup/go-admin/modules/service"
32 | "github.com/GoAdminGroup/go-admin/plugins"
33 | )
34 |
35 | type Example struct {
36 | *plugins.Base
37 | }
38 |
39 | func NewExample() *Example {
40 | return &Example{
41 | Base: &plugins.Base{PlugName: "example", URLPrefix: "example"},
42 | }
43 | }
44 |
45 | func (e *Example) InitPlugin(srv service.List) {
46 | e.InitBase(srv)
47 | e.App = e.initRouter(c.Prefix(), srv)
48 | }
49 |
50 | func (e *Example) initRouter(prefix, srv service.List) {
51 |
52 | app := context.NewApp()
53 | route := app.Group(prefix)
54 | // Join the certification middleware
55 | route.GET("/show/me/something", auth.Middleware(db.GetConnection(srv)), func(ctx *context.Context){
56 | // Controller logic
57 | })
58 | return app
59 | }
60 | ```
61 |
62 | More:
63 |
64 | - [Develop a source plug-ins](https://github.com/GoAdminGroup/go-admin/blob/master/plugins/example/example.go)
65 | - [Develop a binary plugins](https://github.com/GoAdminGroup/go-admin/blob/master/plugins/example/go_plugin/main.go)
--------------------------------------------------------------------------------
/en/development/template/components.md:
--------------------------------------------------------------------------------
1 | # Components Development
2 | ---
3 |
4 | Component development, taking the image component as an example.
5 |
6 | ## New types and methods of upper interface
7 |
8 | - Create a new ```ImgAttribute``` type
9 |
10 | ```go
11 | type ImgAttribute interface {
12 | SetWidth(value string) ImgAttribute
13 | SetHeight(value string) ImgAttribute
14 | SetSrc(value string) ImgAttribute
15 | GetContent() template.HTML
16 | }
17 | ```
18 |
19 | - In the ```Template``` interface, add a method:
20 |
21 | ```go
22 | type Template interface {
23 | ...
24 | Image() types.ImgAttribute
25 | ...
26 | }
27 | ```
28 |
29 | ## Specific implementation, with ```adminlte``` as an example
30 |
31 | - ```ImgAttribute```
32 |
33 | Create a new ```image.go``` file under ```./template/adminlte/components```, as follows:
34 |
35 | ```go
36 | package components
37 |
38 | import (
39 | "github.com/GoAdminGroup/go-admin/template/types"
40 | "html/template"
41 | )
42 |
43 | type ImgAttribute struct {
44 | Name string
45 | Witdh string
46 | Height string
47 | Src string
48 | }
49 |
50 | func (compo *ImgAttribute) SetWidth(value string) types.ImgAttribute {
51 | compo.Witdh = value
52 | return compo
53 | }
54 |
55 | func (compo *ImgAttribute) SetHeight(value string) types.ImgAttribute {
56 | compo.Height = value
57 | return compo
58 | }
59 |
60 | func (compo *ImgAttribute) SetSrc(value string) types.ImgAttribute {
61 | compo.Src = value
62 | return compo
63 | }
64 |
65 | func (compo *ImgAttribute) GetContent() template.HTML {
66 | return ComposeHtml(compo.TemplateList, *compo, "image")
67 | }
68 | ```
69 |
70 | - ```Image()```
71 |
72 | In ```.template/adminlte/adminlte.go```, add a function:
73 |
74 | ```go
75 | func (*Theme) Image() types.ImgAttribute {
76 | return &components.ImgAttribute{
77 | Name: "image",
78 | Witdh: "50",
79 | Height: "50",
80 | Src: "",
81 | }
82 | }
83 | ```
84 |
85 | Still not completed here, you need to add static resource files.
86 |
87 | - Add the static resource file
88 |
89 | Add ```image.tmpl``` file to ```.template/adminlte/resource/pages/components```
90 |
91 | Annoying, and the last step
92 |
93 | - Execute in the root directory:
94 |
95 | ```shell
96 | adm assets
97 | ```
--------------------------------------------------------------------------------
/en/development/template/form.md:
--------------------------------------------------------------------------------
1 | # Form Development
2 | ---
--------------------------------------------------------------------------------
/en/development/template/template.md:
--------------------------------------------------------------------------------
1 | # Template Introducation
2 | ---
3 |
4 | The theme template is an abstract representation of ui, including a collection of components and static resources that are called in the plugin. The type in go-admin is ```Template```, as follows:
5 |
6 | ```go
7 | type Template interface {
8 | // Components
9 | Form() types.FormAttribute
10 | Col() types.ColAttribute
11 | Table() types.TableAttribute
12 | DataTable() types.DataTableAttribute
13 | Row() types.RowAttribute
14 | Tree() types.TreeAttribute
15 | Paginator() types.PaginatorAttribute
16 | Label() types.LabelAttribute
17 | Image() types.ImgAttribute
18 | Alert() types.AlertAttribute
19 | Tabs() types.TabsAttribute
20 | Popup() types.PopupAttribute
21 |
22 | // Builder methods
23 | GetTmplList() map[string]string
24 | GetAssetList() []string
25 | GetAsset(string) ([]byte, error)
26 | GetTemplate(bool) (*template.Template, string)
27 | }
28 | ```
29 |
30 | To develop a ui theme template, you need to implement the above ```Template``` interface.
--------------------------------------------------------------------------------
/en/install.md:
--------------------------------------------------------------------------------
1 | # Get Ready
2 | ---
3 |
4 | This program is based on ```golang```. It is recommended to use ```golang``` with version higher than 1.11. More infomation, please visit: [https://golang.org](https://golang.org)
5 |
6 | ## Import the program required sql to the corresponding self-built database
7 |
8 | The content of the sql file are the data tables required by the framework. Suppose your business database is: ```database_a```; then you can import the framework sql into ```database_a```, or you can create another database ```database_b``` to import into. Besides, they can be different driver databases, for example, your business database is ```mysql```, the framework database is ```sqlite```. GoAdmin currently supports multiple database connection operations. How to configure, will be described in detail later.
9 |
10 | - [mysql](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.sql)
11 | - [sqlite](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.db)
12 | - [postgresql](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.pgsql)
13 | - [mssql](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.mssql)
14 |
15 | ## Install command line tools
16 |
17 | Download the binary excecute file:
18 |
19 | | File name | OS | Arch | Size |
20 | | ---- | ---- | ---- |---- |
21 | | [adm_darwin_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_darwin_x86_64_v1.2.24.zip) | macOs | x86-64 | 4.77 MB
22 | | [adm_linux_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_x86_64_v1.2.24.zip) | Linux | x86-64 | 6.52 MB
23 | | [adm_linux_armel_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_armel_v1.2.24.zip) | Linux | x86 | 6.06 MB
24 | | [adm_windows_i386_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_i386_v1.2.24.zip) | Windows | x86 |6.16 MB
25 | | [adm_windows_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_x86_64_v1.2.24.zip) | Windows | x86-64 |6.38 MB
26 |
27 |
28 | Or use the command:
29 |
30 | ```
31 | go install github.com/GoAdminGroup/adm
32 | ```
33 |
34 |
35 |
36 | 🍺🍺 Get ready to work here!!
37 |
38 |
39 |
40 | > English is not my main language. If any typo or wrong translation you found, you can help to translate in [github here](https://github.com/GoAdminGroup/docs). I will very appreciate it.
41 |
42 |
43 |
--------------------------------------------------------------------------------
/en/pages/components.md:
--------------------------------------------------------------------------------
1 | # Components
2 | ----
--------------------------------------------------------------------------------
/en/pages/login.md:
--------------------------------------------------------------------------------
1 | # Customize Login Page
2 | ---
3 |
4 | You can modify the login interface by means of components, as in the following example:
5 |
6 | More login interface components [see here](https://github.com/GoAdminGroup/components/blob/master/login/README.md);It can be introduced after loading.
7 |
8 | ```go
9 | package main
10 |
11 | import (
12 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
13 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
14 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
15 | // import the theme2 login theme, if you don`t use, don`t import
16 | _ "github.com/GoAdminGroup/components/login/theme2"
17 |
18 | "github.com/GoAdminGroup/components/login"
19 | "github.com/GoAdminGroup/go-admin/engine"
20 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
21 | "github.com/GoAdminGroup/go-admin/plugins/admin"
22 | "github.com/gin-gonic/gin"
23 | "io/ioutil"
24 | )
25 |
26 | func main() {
27 | r := gin.Default()
28 |
29 | gin.SetMode(gin.ReleaseMode)
30 | gin.DefaultWriter = ioutil.Discard
31 |
32 | eng := engine.Default()
33 | adminPlugin := admin.NewAdmin(datamodel.Generators)
34 | adminPlugin.AddGenerator("user", datamodel.GetUserTable)
35 |
36 | // load the CAPTCHA driver if you use it
37 | adminPlugin.SetCaptcha(map[string]string{"driver": login.CaptchaDriverKeyDefault})
38 |
39 | // use the login theme component
40 | login.Init(login.Config{
41 | Theme: "theme2", // theme name
42 | CaptchaDigits: 5, // Use captcha images, here on behalf of how many authentication code Numbers
43 | // Use tencent verification code, need to offer appID and appSecret
44 | // TencentWaterProofWallData: login.TencentWaterProofWallData{
45 | // AppID:"",
46 | // AppSecret: "",
47 | // }
48 | })
49 |
50 | if err := eng.AddConfigFromJson("./config.json").
51 | AddPlugins(adminPlugin).
52 | Use(r); err != nil {
53 | panic(err)
54 | }
55 |
56 | r.Static("/uploads", "./uploads")
57 |
58 | _ = r.Run(":9033")
59 | }
60 | ```
61 |
--------------------------------------------------------------------------------
/en/pages/modules.md:
--------------------------------------------------------------------------------
1 | # Page Modules
2 | ---
3 |
4 | Page customization needs to call the engine's ```Content``` method, which needs to return an object ```types.Panel```
5 |
6 | The following is the definition of ```types.Panel```:
7 |
8 | ```go
9 | type Panel struct {
10 | Content template.HTML
11 | Title string
12 | Description string
13 | Url string
14 | }
15 | ```
16 |
17 | Corresponding ui, you can see the following picture:
18 |
19 | 
20 |
21 | ## How to use
22 |
23 | ```go
24 | package datamodel
25 |
26 | import (
27 | "github.com/GoAdminGroup/go-admin/modules/config"
28 | template2 "github.com/GoAdminGroup/go-admin/template"
29 | "github.com/GoAdminGroup/go-admin/template/types"
30 | "html/template"
31 | )
32 |
33 | func GetContent() (types.Panel, error) {
34 |
35 | components := template2.Get(config.Get().THEME)
36 | colComp := components.Col()
37 |
38 | infobox := components.InfoBox().
39 | SetText("CPU TRAFFIC").
40 | SetColor("blue").
41 | SetNumber("41,410").
42 | SetIcon("ion-ios-gear-outline").
43 | GetContent()
44 |
45 | var size = map[string]string{"md": "3", "sm": "6", "xs": "12"}
46 | infoboxCol1 := colComp.SetSize(size).SetContent(infobox).GetContent()
47 | row1 := components.Row().SetContent(infoboxCol1).GetContent()
48 |
49 | return types.Panel{
50 | Content: row1,
51 | Title: "Dashboard",
52 | Description: "this is a example",
53 | }, nil
54 | }
55 | ```
56 |
57 | ## Col
58 |
59 | A col is type of ```ColAttribute```, has three methods:
60 |
61 | ```go
62 | type ColAttribute interface {
63 | SetSize(value map[string]string) ColAttribute
64 | SetContent(value template.HTML) ColAttribute
65 | GetContent() template.HTML
66 | }
67 | ```
68 |
69 | About the ```size```,example is ```map[string]string{"md": "3", "sm": "6", "xs": "12"}```
70 |
71 | ## Row
72 |
73 | A row is type of ```RowAttribute```, has two methods:
74 |
75 | ```go
76 | type RowAttribute interface {
77 | SetContent(value template.HTML) RowAttribute
78 | GetContent() template.HTML
79 | }
80 | ```
81 |
--------------------------------------------------------------------------------
/en/pages/pages.md:
--------------------------------------------------------------------------------
1 | # Customize your page
2 | ---
3 |
4 | call the method ```Content```of the engine:
5 |
6 | ```go
7 | package main
8 |
9 | import (
10 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
11 | _ "github.com/GoAdminGroup/themes/adminlte"
12 | "github.com/GoAdminGroup/go-admin/engine"
13 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
14 | "github.com/GoAdminGroup/go-admin/modules/config"
15 | "github.com/GoAdminGroup/go-admin/plugins/example"
16 | "github.com/GoAdminGroup/go-admin/template/types"
17 | ginAdapter "github.com/GoAdminGroup/go-admin/adapter/gin"
18 | "github.com/gin-gonic/gin"
19 | )
20 |
21 | func main() {
22 | r := gin.Default()
23 |
24 | eng := engine.Default()
25 |
26 | cfg := config.Config{}
27 |
28 | if err := eng.AddConfig(cfg).
29 | AddGenerators(datamodel.Generators).
30 | AddPlugins(example.NewExample()).
31 | Use(r); err != nil {
32 | panic(err)
33 | }
34 |
35 | r.Static("/uploads", "./uploads")
36 |
37 | // here to custom a page.
38 |
39 | r.GET("/"+cfg.PREFIX+"/custom", ginAdapter.Content(YourPageFunc))
40 |
41 | r.Run(":9033")
42 | }
43 | ```
44 |
45 | ```Content```will write the contents into the ```context``` of the framework.
46 |
47 | here is the code of ```GetContent```:
48 |
49 | ```go
50 |
51 | import (
52 | "github.com/GoAdminGroup/go-admin/modules/config"
53 | "github.com/GoAdminGroup/go-admin/modules/db"
54 | "github.com/GoAdminGroup/go-admin/modules/language"
55 | form2 "github.com/GoAdminGroup/go-admin/plugins/admin/modules/form"
56 | template2 "github.com/GoAdminGroup/go-admin/template"
57 | "github.com/GoAdminGroup/go-admin/template/icon"
58 | "github.com/GoAdminGroup/go-admin/template/types"
59 | "github.com/GoAdminGroup/go-admin/template/types/form"
60 | "github.com/gin-gonic/gin"
61 | )
62 |
63 | func YourPageFunc(ctx *gin.Context) (types.Panel, error) {
64 |
65 | components := template2.Get(config.Get().Theme)
66 |
67 | col1 := components.Col().GetContent()
68 | btn1 := components.Button().SetType("submit").
69 | SetContent(language.GetFromHtml("Save")).
70 | SetThemePrimary().
71 | SetOrientationRight().
72 | SetLoadingText(icon.Icon("fa-spinner fa-spin", 2) + `Save`).
73 | GetContent()
74 | btn2 := components.Button().SetType("reset").
75 | SetContent(language.GetFromHtml("Reset")).
76 | SetThemeWarning().
77 | SetOrientationLeft().
78 | GetContent()
79 | col2 := components.Col().SetSize(types.SizeMD(8)).
80 | SetContent(btn1 + btn2).GetContent()
81 |
82 | var panel = types.NewFormPanel()
83 | panel.AddField("Name", "name", db.Varchar, form.Text)
84 | panel.AddField("Age", "age", db.Int, form.Number)
85 | panel.AddField("HomePage", "homepage", db.Varchar, form.Url).FieldDefault("http://google.com")
86 | panel.AddField("Email", "email", db.Varchar, form.Email).FieldDefault("xxxx@xxx.com")
87 | panel.AddField("Birthday", "birthday", db.Varchar, form.Datetime).FieldDefault("2010-09-05")
88 | panel.AddField("Password", "password", db.Varchar, form.Password)
89 | panel.AddField("IP", "ip", db.Varchar, form.Ip)
90 | panel.AddField("Certificate", "certificate", db.Varchar, form.Multifile).FieldOptionExt(map[string]interface{}{
91 | "maxFileCount": 10,
92 | })
93 | panel.AddField("Currency", "currency", db.Int, form.Currency)
94 | panel.AddField("Content", "content", db.Text, form.RichText).
95 | FieldDefault(`
343434
34344433434
23234
2342342342
asdfads
3434334
34343343434
44455
343434
434434433434
`)
96 |
97 | panel.AddField("Website", "website", db.Tinyint, form.Switch).
98 | FieldHelpMsg("Help Message").
99 | FieldOptions(types.FieldOptions{
100 | {Value: "0"},
101 | {Value: "1"},
102 | })
103 | panel.AddField("fruit", "fruit", db.Varchar, form.SelectBox).
104 | FieldOptions(types.FieldOptions{
105 | {Text: "apple", Value: "apple"},
106 | {Text: "banana", Value: "banana"},
107 | {Text: "watermelon", Value: "watermelon"},
108 | {Text: "pear Value: ", Value: "pear"},
109 | }).
110 | FieldDisplay(func(value types.FieldModel) interface{} {
111 | return []string{"梨"}
112 | })
113 | panel.AddField("gender", "gender", db.Tinyint, form.Radio).
114 | FieldOptions(types.FieldOptions{
115 | {Text: "male", Value: "0"},
116 | {Text: "female", Value: "1"},
117 | })
118 | panel.AddField("饮料", "drink", db.Tinyint, form.Select).
119 | FieldOptions(types.FieldOptions{
120 | {Text: "bear", Value: "beer"},
121 | {Text: "juice", Value: "juice"},
122 | {Text: "water", Value: "water"},
123 | {Text: "read bull", Value: "red bull"},
124 | }).FieldDefault("beer")
125 | panel.AddField("工作经验", "experience", db.Tinyint, form.SelectSingle).
126 | FieldOptions(types.FieldOptions{
127 | {Text: "Zero", Value: "0"},
128 | {Text: "One year", Value: "1"},
129 | {Text: "Four years", Value: "2"},
130 | {Text: "Five years", Value: "3"},
131 | }).FieldDefault("beer")
132 | panel.SetTabGroups(types.TabGroups{
133 | {"name", "age", "homepage", "email", "birthday", "password", "ip", "certificate", "currency", "content"},
134 | {"website", "fruit", "gender", "drink", "experience"},
135 | })
136 | panel.SetTabHeaders("input", "select")
137 |
138 | fields, headers := panel.GroupField()
139 |
140 | aform := components.Form().
141 | SetTabHeaders(headers).
142 | SetTabContents(fields).
143 | SetPrefix(config.Get().PrefixFixSlash()).
144 | SetUrl("/admin/form/update").
145 | SetTitle("Form").
146 | SetHiddenFields(map[string]string{
147 | form2.PreviousKey: "/admin",
148 | }).
149 | SetOperationFooter(col1 + col2)
150 |
151 | return types.Panel{
152 | Content: components.Box().
153 | SetHeader(aform.GetDefaultBoxHeader()).
154 | WithHeadBorder().
155 | SetBody(aform.GetContent()).
156 | GetContent(),
157 | Title: "Title",
158 | Description: "Description",
159 | }, nil
160 | }
161 | ```
162 |
--------------------------------------------------------------------------------
/en/plan.md:
--------------------------------------------------------------------------------
1 | # Development Plan
2 | ---
3 |
4 | GoAdmin not only aim for a admin panel builder tool. Now the base version of 1.0 has achieved a base framework which can help quickly build a simple crud admin panel with permession manage and other fetures. On this basis, you can also customize the theme and the plugin. The following points after three expounds the project development plan.
5 |
6 | ## Features
7 |
8 | The final purpose of GoAdmin is achieving a no-code or to some extent, no-code operations set. And we will at least build the plugins of two. The one we named admin is help you build a crud admin panel quickly, and the other one is a Grafana like data monitor dashboard builder, which we named monitor.
9 |
10 | ### version 1.0.0
11 |
12 | - Build the basic framework, and at the same time provide a built-in plugin which can satisfy the rapid construction of crud admin panel.
13 | - This basic framework can support theme and plugin customizing.
14 |
15 | ### version 2.0.0
16 |
17 | - On the basis of version 1.0, this version will imporve the admin plugin to provide a ec mall and saas system infrastructure features
18 | - Improve the tool chain of developing themes and plugins, make it easier for developer to get start with developing of themes and plugins.
19 | - Providing more themes and built-in plugins.
20 | - The basic support of monitor system.
21 | - Improve performance of project.
22 |
23 | ### version 3.0.0
24 |
25 | - Support the productive monitor system.
26 | - Achieving a interface which support dragging and dropping in the front-end.
27 |
28 | ### version 4.0.0
29 |
30 | - Support no-code operations.
31 |
32 | ## Community
33 |
34 | GoAdmin project needs more developers to join together.
35 |
36 | Now the project is maintained by [@cg33](https://github.com/chenhg5), who is a two years gopher。
37 |
38 | Work of the projects:
39 |
40 | - [developing](https://github.com/GoAdminGroup/go-admin)
41 | - forum project maintenance(not be a opensource project yet)
42 | - [The maintenance of document improvement and translation](https://github.com/GoAdminGroup/docs)
43 | - Publicity and community culture of the organization of the project
44 |
45 | GoAdmin always adheres to an open and open attitude, and welcomes people with lofty and capable ability to join in the development of a conspiracy project and community. The community and the individual complement each other.
46 |
47 | If you are optimistic about the development of GoAdmin and are willing to gamble for him, use time for future financial or reputational returns, and you have confidence in your own abilities, then you can try to fully read the GoAdmin code and understand GoAdmin's development plan, make your contribution to this. The pre-code flaws are large and can be modified. If you have the ability to make enough contributions, you will become the project's co-founder** or **core developer**. In the later stages, the code is highly sophisticated and there is still room for improvement. You can become a ** contributor by submitting a fix**. The team will remain open and accept new members. Every member of the team who works hard will also receive a certain return in the future based on the proportion of the effort to harvest the project.
48 |
49 | If you don't have enough time and energy, but have a certain amount of money, and are equally optimistic about GoAdmin development, although GoAdmin has not yet planned a plan for this. But as long as you have enough interest, you can bring your plan to negotiate with us.
50 |
51 | ## Commercial Plan
52 |
53 | GoAdmin will be gradually commercialized, but the core infrastructure features are free and open source.
54 | GoAdmin's capital revenue model is mainly:
55 |
56 | - Accept donations
57 | - Selling themes
58 | - Selling plugins
59 | - Provide saas customized development
60 | - Commercial version for a fee
61 |
62 | Revenue funds are mainly used to maintain the development of the community, and the return on compensation of developers, to promote the project to grow better.
--------------------------------------------------------------------------------
/en/plugins/plugins.md:
--------------------------------------------------------------------------------
1 | # How To Use Plugins
2 | ---
3 |
4 | The framework's plugins include: controllers, routing, and views. The specific plug-in development will be discussed in the project development part, here just show you how to use it.
5 |
6 | The example plugin is our demo.
7 |
8 | Using plugins are divided into: using the third package source code plugin and use the dynamic link library plugin (.so file, currently only supports linux and mac platforms)
9 |
10 | You can skip this part, if you just want to build a crud administrative platform.
11 |
12 | ## Using the third package source code plugin
13 |
14 | For example:
15 |
16 | ```go
17 | package main
18 |
19 | import (
20 | _ "github.com/GoAdminGroup/go-admin/adapter/gin" // Import the adapter
21 | _ "github.com/GoAdminGroup/themes/adminlte" // Import the theme
22 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql" // Import the sql driver
23 |
24 | "github.com/gin-gonic/gin"
25 | "github.com/GoAdminGroup/go-admin/engine"
26 | "github.com/GoAdminGroup/go-admin/plugins/admin"
27 | "github.com/GoAdminGroup/go-admin/plugins/example"
28 | "github.com/GoAdminGroup/go-admin/modules/config"
29 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
30 | )
31 |
32 | func main() {
33 | r := gin.Default()
34 | eng := engine.Default()
35 | cfg := config.Config{}
36 |
37 | adminPlugin := admin.NewAdmin(datamodel.Generators)
38 | examplePlugin := example.NewExample()
39 |
40 | eng.AddConfig(cfg).
41 | AddPlugins(adminPlugin, examplePlugin). // loading
42 | Use(r)
43 |
44 | r.Run(":9033")
45 | }
46 | ```
47 |
48 |
49 | ## Using the binary plugin
50 |
51 | Load the ```.so```file, and call```plugins.LoadFromPlugin```.
52 |
53 | 如:
54 |
55 | ```go
56 | package main
57 |
58 | import (
59 | _ "github.com/GoAdminGroup/go-admin/adapter/gin" // Import the adapter
60 | _ "github.com/GoAdminGroup/themes/adminlte" // Import the theme
61 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql" // Import the sql driver
62 |
63 | "github.com/gin-gonic/gin"
64 | "github.com/GoAdminGroup/go-admin/engine"
65 | "github.com/GoAdminGroup/go-admin/plugins/admin"
66 | "github.com/GoAdminGroup/go-admin/plugins"
67 | "github.com/GoAdminGroup/go-admin/modules/config"
68 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
69 | )
70 |
71 | func main() {
72 | r := gin.Default()
73 | eng := engine.Default()
74 | cfg := config.Config{}
75 |
76 | adminPlugin := admin.NewAdmin(datamodel.Generators)
77 |
78 | // load plugin from .so file.
79 | examplePlugin := plugins.LoadFromPlugin("../datamodel/example.so")
80 |
81 | eng.AddConfig(cfg).
82 | AddPlugins(adminPlugin, examplePlugin).
83 | Use(r)
84 |
85 | r.Run(":9033")
86 | }
87 | ```
--------------------------------------------------------------------------------
/en/tests/ci.md:
--------------------------------------------------------------------------------
1 | # CI测试
2 | ---
3 |
4 | Framework provides two external testing apis, one is a black box testing, one is the user's browser integration testing (depend on the chromedriver)
5 |
6 | ```golang
7 | package main
8 |
9 | import (
10 | "github.com/GoAdminGroup/demo/tables"
11 | "github.com/GoAdminGroup/go-admin/modules/config"
12 | "github.com/GoAdminGroup/go-admin/tests"
13 | "github.com/GoAdminGroup/go-admin/tests/common"
14 | "github.com/GoAdminGroup/go-admin/tests/frameworks/gin"
15 | "github.com/GoAdminGroup/go-admin/tests/web"
16 | "github.com/gavv/httpexpect"
17 | "net/http"
18 | "testing"
19 | )
20 |
21 | // Black box testing
22 | func TestDemoBlackBox(t *testing.T) {
23 | tests.BlackBoxTestSuit(t, gin.NewHandler, config.DatabaseList{
24 | "default": config.Database{
25 | Host: "127.0.0.1",
26 | Port: "3306",
27 | User: "root",
28 | Pwd: "root",
29 | Name: "go_admin_demo_test", // WARNING: test database name must contains "test"
30 | Driver: "mysql",
31 | },
32 | }, tables.Generators, func(cfg config.DatabaseList) {
33 | // Data cleaner of the framework
34 | tests.Cleaner(cfg)
35 | // Clean your own data:
36 | // ...
37 | }, func(e *httpexpect.Expect) {
38 | // Test cases of the framework
39 | common.Test(e)
40 | // Write your own API test, for example:
41 | // More usages: https://github.com/gavv/httpexpect
42 | e.POST("/signin").Expect().Status(http.StatusOK)
43 | })
44 | }
45 |
46 | // User acceptance testing
47 | func TestDemoUserAcceptance(t *testing.T) {
48 | web.UserAcceptanceTestSuit(t, func(t *testing.T, page *web.Page) {
49 | // Write test case base on chromedriver, for example:
50 | // More usages: https://github.com/sclevine/agouti
51 | page.NavigateTo("http://127.0.0.1:9033/admin")
52 | page.Contain("username")
53 | page.Click("")
54 | }, func(quit chan struct{}) {
55 | // start the server:
56 | // ....
57 | }, true) // if local parameter is true, it will not be headless, and window not close when finishing tests.
58 | }
59 |
60 |
61 | ```
--------------------------------------------------------------------------------
/fr/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 | ------
3 |
4 | GoAdmin is a data visualization management platform, providing a complete set of visual ui calls to golang programs, and a built-in sql relational database management backend plugin.
5 |
6 |
7 | Before we build a management backend, we needed at least one back office engineer, a front-end engineer, to take at least a week.
8 | Now with GoAdmin, we don't need front-end engineers. Our back-end engineers don't even need to know the front-end knowledge. We can build a complete back-end management system in half an hour.
9 | If your requirements are not complicated, just simple crud, then all you need are serveral golang files, and all files can be packaged into a single binary file, which is very convenient for distribution and deployment.
10 |
11 | here is very simple example which show you how it work: [https://github.com/GoAdminGroup/example](https://github.com/GoAdminGroup/example)
12 |
13 |
14 | ## Features
15 |
16 | - Build-in RBAC Access Authentication System
17 | - Support most web framework
18 | - Support plug-ins(working on it)
19 | - Provided different ui theme(only Adminlte now, others are coming soon.)
20 |
21 | ## Demo
22 |
23 | [https://demo.go-admin.cn/admin](https://demo.go-admin.cn/admin)
24 |
25 | ## Dependencies
26 |
27 | - [Datetimepicker](http://eonasdan.github.io/bootstrap-datetimepicker/)
28 | - [font-awesome](http://fontawesome.io/)
29 | - [bootstrap-fileinput](https://github.com/kartik-v/bootstrap-fileinput)
30 | - [jquery-pjax](https://github.com/defunkt/jquery-pjax)
31 | - [Nestable](http://dbushell.github.io/Nestable/)
32 | - [toastr](http://codeseven.github.io/toastr/)
33 | - [bootstrap-number-input](https://github.com/wpic/bootstrap-number-input)
34 | - [fontawesome-iconpicker](https://github.com/itsjavi/fontawesome-iconpicker)
35 |
36 | ## Community
37 |
38 | [Community](http://forum.go-admin.cn)
39 |
40 | ## Backers
41 |
42 | Your support will help me do better!
43 |
44 |
--------------------------------------------------------------------------------
/fr/admin/cli.md:
--------------------------------------------------------------------------------
1 | # Introduction à l'interface en ligne de commandes
2 | ---
3 |
4 | GoAdmin donne accès à une interface en ligne de commandes pour permettre d'augmenter l'efficacité du développement et le normaliser.
5 |
6 | ## Installation
7 |
8 |
9 | Téléchargez la version correspondante à votre système d'exploitation:
10 |
11 | | File name | OS | Arch | Size |
12 | | ---- | ---- | ---- |---- |
13 | | [adm_darwin_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_darwin_x86_64_v1.2.24.zip) | macOs | x86-64 | 4.77 MB
14 | | [adm_linux_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_x86_64_v1.2.24.zip) | Linux | x86-64 | 6.52 MB
15 | | [adm_linux_armel_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_armel_v1.2.24.zip) | Linux | x86 | 6.06 MB
16 | | [adm_windows_i386_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_i386_v1.2.24.zip) | Windows | x86 |6.16 MB
17 | | [adm_windows_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_x86_64_v1.2.24.zip) | Windows | x86-64 |6.38 MB
18 |
19 |
20 | Ou utilisez la commande pour l'installer:
21 |
22 | ```
23 | go install github.com/GoAdminGroup/adm
24 | ```
25 |
26 | ## Utilisation
27 |
28 | Utilisez
29 |
30 | ```
31 | adm --help
32 | ```
33 |
34 | Cette commande donner les informations suivantes:
35 |
36 | | Command | Subcommand | Options | Function |
37 | | ---- | ---- | ---- | ---- |
38 | | generate | - | - | génère un modèle de fichier de données.
39 | | compile | asset| **-s, --src** chemin d'accès des ressources front-end **-d, --dist** chemin du fichier de sortie go | compile toutes les ressources dans un seul fichier go.
40 | | compile | tpl | **-s, --src** chemin d'accès vers les modèles golang sous forme d'un dossier tmpl **-d, --dist** chemin du fichier go de sortie **-p, --package** nom du fichier de sortie go | compile tous les modèles en seul fichier go.
41 | | combine | css| **-s, --src** chemin d'accès vers le dossier d'entrée css **-d, --dist** chemin vers le fichier css de sortie **-p, --package** nom du fichier de sortie css | combine tous les fichiers css en un fichier css.
42 | | combine | js | **-s, --src** chemin d'accès vers le dossier d'entrée js **-d, --dist** chemin vers le fichier js de sortie | combine tous les fichiers js en un seul.
43 | | develop | tpl | **-m, --module** nom du module golang ou sont chemin d'accès $GOPATH **-n, --name** nom du thème | récupère les modèles et les sauvegardes localement.
44 |
--------------------------------------------------------------------------------
/fr/admin/file.md:
--------------------------------------------------------------------------------
1 | # File Upload Engine
2 | ---
3 |
4 | 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.
5 |
6 | ```go
7 | package config
8 |
9 | // Storage directory: store avatar and other uploaded files
10 | type Store struct {
11 | Path string // relative or absolute path, the file will be stored here
12 | Prefix string // access url prefix
13 | }
14 |
15 | type Config struct {
16 |
17 | ...
18 |
19 | // Upload file storage location
20 | Store Store `json:"store"`
21 |
22 | // File upload engine
23 | FileUploadEngine FileUploadEngine `json:"file_upload_engine"`
24 |
25 | ...
26 | }
27 |
28 | type FileUploadEngine struct {
29 | Name string
30 | Config map[string]interface{}
31 | }
32 | ```
33 |
34 | 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:
35 |
36 | ### Type of engine
37 |
38 | ```go
39 | package file
40 |
41 | type Uploader interface {
42 | Upload(*multipart.Form) error
43 | }
44 |
45 | type UploaderGenerator func() Uploader
46 |
47 | func AddUploader(name string, up UploaderGenerator) {
48 | ...
49 | }
50 | ```
51 |
52 | ### How to
53 |
54 | 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.
55 |
56 | Suppose we want to add a aws cloud upload engine, then it can be similar like this:
57 |
58 | ```go
59 | package main
60 |
61 | import (
62 | ...
63 | "github.com/GoAdminGroup/go-admin/modules/file"
64 | ...
65 | )
66 |
67 | type AwsUploader struct {
68 | Bucket string
69 | Region string
70 | SecretId string
71 | SecretKey string
72 |
73 | Prefix string
74 | Path string
75 | }
76 |
77 | func (q AwsUploader) Upload(*multipart.Form) error {
78 | // 接收一个表单类型,这里实现上传逻辑
79 | }
80 |
81 | func main() {
82 |
83 | ...
84 |
85 | file.AddUploader("aws", func() file.Uploader {
86 | return &AwsUploader{
87 | Bucket: config.Get().FileUploadEngine.Config["bucket"].(string),
88 | Region: config.Get().FileUploadEngine.Config["region"].(string),
89 | SecretId: config.Get().FileUploadEngine.Config["secret_id"].(string),
90 | SecretKey: config.Get().FileUploadEngine.Config["secret_key"].(string),
91 | Prefix: config.Get().FileUploadEngine.Config["prefix"].(string),
92 | Path: config.Get().FileUploadEngine.Config["path"].(string),
93 | }
94 | })
95 |
96 | cfg := config.Config{
97 | ...
98 |
99 | FileUploadEngine: config.FileUploadEngine{
100 | Name: "aws",
101 | Config: map[string]interface{}{
102 | "bucket": "xxx",
103 | "region": "xxx",
104 | "secret_id": "xxx",
105 | "secret_key": "xxx",
106 | "prefix": "xxx",
107 | "path": "xxx",
108 | },
109 | }
110 |
111 | ...
112 | }
113 |
114 | ...
115 | }
116 | ```
117 |
118 | Finish a aws cloud upload file engine!🍺🍺
--------------------------------------------------------------------------------
/fr/admin/form/basic.md:
--------------------------------------------------------------------------------
1 | # Usages basiques
2 | ---
3 |
4 | Utilisez le terminal pour générer un tableau de données type pour le table sql, comme par exemple:
5 |
6 | ```sql
7 | CREATE TABLE `users` (
8 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
9 | `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
10 | `gender` tinyint(4) DEFAULT NULL,
11 | `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
12 | `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
13 | `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
14 | `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
15 | `updated_at` timestamp NULL DEFAULT NULL,
16 | PRIMARY KEY (`id`)
17 | ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
18 | ```
19 |
20 | Généré:
21 |
22 | ```go
23 | package datamodel
24 |
25 | import (
26 | ...
27 | )
28 |
29 | func GetUserTable(ctx *context.Context) (userTable table.Table) {
30 |
31 | // configure le modèle de la table.
32 | userTable = table.NewDefaultTable(...)
33 |
34 | ...
35 |
36 | formList := userTable.GetForm()
37 |
38 | // Le champ id n'est plus éditable.
39 | formList.AddField("ID", "id", db.Int, form.Default).FieldNotAllowEdit()
40 | formList.AddField("Ip", "ip", db.Varchar, form.Text)
41 | formList.AddField("Name", "name", db.Varchar, form.Text)
42 |
43 | ...
44 |
45 | return
46 | }
47 | ```
48 |
49 | ### Ajout de champs
50 |
51 | ```go
52 |
53 | // Ajoute un champ avec son titre ID, son nom id, son type int et son type par défault
54 | formList.AddField("ID", "id", db.Int, form.Default)
55 |
56 | // Ajoute un second champ avec son titre Ip, son nom ip, son type varchar et son type Text
57 | formList.AddField("Ip", "ip", db.Varchar, form.Text)
58 |
59 | // Ajoute un troisième champ, un champ qui n'existe pas dans la table sql
60 | formList.AddField("Custom", "custom", db.Varchar, form.Text)
61 |
62 | ```
63 |
64 | ### Interdire l'édition
65 |
66 | ```go
67 |
68 | formList.AddField("id", "id", db.Int, form.Default).FieldNotAllowEdit()
69 |
70 | ```
71 |
72 | ### Interdire l'ajout de nouveaux champs
73 |
74 | ```go
75 |
76 | formList.AddField("id", "id", db.Int, form.Default).FieldNotAllowAdd()
77 |
78 | ```
79 |
80 | ## Ajouter un bouton
81 |
82 | Si vous voulez ajouter des boutons à la table box header, vous pouvez le faire comme ça:
83 |
84 | ```go
85 | info.AddButton(title template.HTML, icon string, action Action, color ...template.HTML)
86 | ```
87 |
88 | ```title```est le titre du bouton, ```icon```est l'icône du bouton, ```action```est l'action que produit le bouton et ```color``` est la couleur de fond et la couleur du texte
89 |
90 | Par exemple:
91 | ```go
92 |
93 | import (
94 | ...
95 | "github.com/GoAdminGroup/go-admin/template/icon"
96 | "github.com/GoAdminGroup/go-admin/template/types/action"
97 | ...
98 | )
99 |
100 | info.AddButton("Today Data", icon.Save, action.PopUp("/admin/data/analyze", "Data Analyze"))
101 | ```
102 |
103 | On a ajouté un bouton qui va ouvrir une fenêtre quand il sera cliqué. Le contenu de la fenêtre est défini par le chemin "/admin/data/analyze" et "Data Analyze" est le titre de la fenêtre.
104 |
--------------------------------------------------------------------------------
/fr/admin/form/components.md:
--------------------------------------------------------------------------------
1 | # Utilisation d'une table
2 | ---
3 |
4 | ## Default
5 |
6 | ```go
7 | formList.AddField("name", "name", db.Varchar, form.Default)
8 | ```
9 |
10 | ## Text
11 |
12 | ```go
13 | formList.AddField("name", "name", db.Varchar, form.Text)
14 | ```
15 |
16 | ## SelectSingle
17 |
18 | ```go
19 | formList.AddField("sex", "sex", db.Int, form.SelectSingle).
20 | // Une option possibles, le champ représente le contenu et sa valeur correspond à l'option choisie
21 | FieldOptions(types.FieldOptions{
22 | {Text: "man",Value: "0"},
23 | {Text: "women",Value: "1"},
24 | }).
25 | // Ceci retourne []string, la valeur de la chaine de caractère est le texte correspondant, la valeur est donnée lors de l'édition de la table.
26 | FieldDisplay(func(model types.FieldModel) interface{} {
27 | return []string{"0"}
28 | })
29 | ```
30 |
31 | ## Select
32 |
33 | ```go
34 | formList.AddField("drink", "drink", db.Int, form.Select).
35 | // plusieurs options possibles, le champ représente le contenu et sa valeur correspond à l'option choisie
36 | FieldOptions(types.FieldOptions{
37 | {
38 | Text: "beer",
39 | Value: "beer",
40 | }, {
41 | Text: "juice",
42 | Value: "juice",
43 | }, {
44 | Text: "water",
45 | Value: "water",
46 | }, {
47 | Text: "red bull",
48 | Value: "red bull",
49 | },
50 | }).
51 | // Ceci retourne []string, la valeur de la chaine de caractère est le texte correspondant, la valeur est donnée lors de l'édition de la table.
52 | FieldDisplay(func(model types.FieldModel) interface{} {
53 | return []string{"beer"}
54 | })
55 | ```
56 |
57 | ## IconPicker
58 |
59 | ```go
60 | formList.AddField("icon", "icon", db.Varchar, form.IconPicker)
61 | ```
62 |
63 | ## SelectBox
64 |
65 | ```go
66 | formList.AddField("fruit", "fruit", db.Int, form.SelectBox).
67 | // plusieurs options possibles, le champ représente le contenu et sa valeur correspond à l'option choisie
68 | FieldOptions(types.FieldOptions{
69 | {
70 | Text: "apple",
71 | Value: "apple",
72 | }, {
73 | Text: "banana",
74 | Value: "banana",
75 | }, {
76 | Text: "watermelon",
77 | Value: "watermelon",
78 | }, {
79 | Text: "pear",
80 | Value: "pear",
81 | },
82 | }).
83 | // Ceci retourne []string, la valeur de la chaine de caractère est le texte correspondant, la valeur est donnée lors de l'édition de la table.
84 | FieldDisplay(func(model types.FieldModel) interface{} {
85 | return []string{"pear"}
86 | })
87 | ```
88 |
89 | ## File
90 |
91 | ```go
92 | formList.AddField("file", "file", db.Varchar, form.File)
93 | ```
94 |
95 | ## Password
96 |
97 | ```go
98 | formList.AddField("password", "password", db.Varchar, form.Password)
99 | ```
100 |
101 | ## RichText
102 |
103 | ```go
104 | formList.AddField("content", "content", db.Varchar, form.RichText)
105 | ```
106 |
107 | ## Datetime
108 |
109 | ```go
110 | formList.AddField("birthday", "birthday", db.Varchar, form.Datetime)
111 | ```
112 |
113 | ## Radio
114 |
115 | ```go
116 | formList.AddField("gender", "gender", db.Int, form.Radio).
117 | // Options radio, le champ représente le contenu et sa valeur correspond à l'option choisie
118 | FieldOptions(types.FieldOptions{
119 | {Text: "man",Value: "0"},
120 | {Text: "women",Value: "1"},
121 | }).FieldDefault("0") // Donne la valeur par défault
122 | ```
123 |
124 | ## Email
125 |
126 | ```go
127 | formList.AddField("email", "email", db.Varchar, form.Email)
128 | ```
129 |
130 | ## Url
131 |
132 | ```go
133 | formList.AddField("url", "url", db.Varchar, form.Url)
134 | ```
135 |
136 | ## Ip
137 |
138 | ```go
139 | formList.AddField("ip", "ip", db.Varchar, form.Ip)
140 | ```
141 |
142 | ## Color
143 |
144 | ```go
145 | formList.AddField("color", "color", db.Varchar, form.Color)
146 | ```
147 |
148 | ## Currency
149 |
150 | ```go
151 | formList.AddField("money", "money", db.Varchar, form.Currency)
152 | ```
153 |
154 | ## Number
155 |
156 | ```go
157 | formList.AddField("num", "num", db.Varchar, form.Number)
158 | ```
159 |
160 | ## TextArea
161 |
162 | ```go
163 | formList.AddField("content", "content", db.Varchar, form.TextArea)
164 | ```
165 |
166 | ## Personnalisée
167 |
168 | Table personnalisée
169 |
170 | ```go
171 | formList.AddField("content", "content", db.Varchar, form.Custom).
172 | FieldCustomContent(template.HTML(``)).
173 | FieldCustomCss(template.CSS(``)).
174 | FieldCustomJs(template.JS(``))
175 | ```
176 |
177 | Ce qui suit forme le modèle de la structure de fichier personnalisée.
178 | En ajustant les options ` ` ` CustomContent ` ` `, ` ` ` CustomCss ` ` `, ` ` ` CustomJs ` ` `, les paramètres seront insérés dans leurs endroits respectifs.
179 |
180 | ```go
181 | {{define "form_custom"}}
182 | {{if eq .Must true}}
183 |
184 | {{else}}
185 |
186 | {{end}}
187 |
188 |
189 | {{.CustomContent}}
190 |
191 |
192 | {{if .CustomJs}}
193 |
196 | {{end}}
197 | {{if .CustomCss}}
198 |
201 | {{end}}
202 | {{end}}
203 | ```
204 |
--------------------------------------------------------------------------------
/fr/admin/menus.md:
--------------------------------------------------------------------------------
1 | # Setting menu
2 | ---
3 |
4 | GoAdmin has built-in menu management module. After entering the home page as a super administrator, expand the management of the left sidebar, there is a management panel below:
5 |
6 | 
7 |
8 | Click inside to set up the menu you need.
--------------------------------------------------------------------------------
/fr/admin/module.md:
--------------------------------------------------------------------------------
1 | # Modules
2 | ---
3 |
4 | When GoAdmin engine is building, some modules are built. Such as: database module, user authentication module. And this chapter tells you how to reuse the modules.
5 |
6 | ## Database Module
7 |
8 | Database module can be used afrer the engine set the global config. For example:
9 |
10 | ```go
11 |
12 | import (
13 | ...
14 | "github.com/GoAdminGroup/go-admin/engine"
15 | ...
16 | )
17 |
18 | func main() {
19 |
20 | ...
21 |
22 | eng := engine.Default()
23 |
24 | cfg := config.Config{
25 | ...
26 | Databases: config.DatabaseList{
27 | "default": {
28 | Host: "127.0.0.1",
29 | Port: "3306",
30 | User: "root",
31 | Pwd: "root",
32 | Name: "godmin",
33 | MaxIdleCon: 50,
34 | MaxOpenCon: 150,
35 | Driver: config.DriverMysql,
36 | },
37 | },
38 | ...
39 | }
40 |
41 | _ = eng.AddConfig(cfg). // Here the database module built.
42 | AddPlugins(adminPlugin).
43 | Use(r)
44 |
45 | // get mysql connection
46 | conn := eng.MysqlConnection()
47 |
48 | // get postgresql connection
49 | conn := eng.PostgresqlConnection()
50 |
51 | // get sqlite connection
52 | conn := eng.SqliteConnection()
53 |
54 | // Note: you get a pointer here which is point to the global database connection object.
55 | // If you want to reuse in you table models file, then you should call before the .Use(r) method.
56 | // Or it will panic. Like:
57 | //
58 | // _ = eng.AddConfig(cfg).
59 | // ResolveMysqlConnection(tables.SetConn)
60 | // AddPlugins(adminPlugin).
61 | // Use(r)
62 | //
63 | // In your tables.go:
64 | //
65 | // var conn db.Connection
66 | //
67 | // func SetConn(c db.Connection) {
68 | // conn = c
69 | // }
70 | //
71 | // And then you call the conn in your table model file.
72 |
73 | // get connection by setter function
74 | eng.ResolveMysqlConnection(SetConn)
75 |
76 | ...
77 | }
78 |
79 | var globalConn db.Connection
80 |
81 | func SetConn(conn db.Connection) {
82 | globalConn = conn
83 | }
84 | ```
85 |
86 | When you receive ```connection``` object, you can call the built-in sql helper methods:
87 |
88 | ```go
89 |
90 | import (
91 | ...
92 | "github.com/GoAdminGroup/go-admin/modules/db"
93 | "github.com/GoAdminGroup/go-admin/modules/db/dialect"
94 | ...
95 | )
96 |
97 | func main() {
98 |
99 | // query
100 | db.WithDriver(globalConn).Table("users").Select("id", "name").First()
101 |
102 | // update
103 | db.WithDriver(globalConn).Table("users").Where("id", "=", 10).
104 | Update(dialect.H{
105 | "name": "jack",
106 | })
107 |
108 | // insert
109 | db.WithDriver(globalConn).Table("users").
110 | Insert(dialect.H{
111 | "name": "jack",
112 | })
113 |
114 | // delete
115 | db.WithDriver(globalConn).Table("users").Where("id", "=", 10).Delete()
116 |
117 | // and so on...
118 | }
119 |
120 | ```
121 |
122 | ## User Authentication Module
123 |
124 | When we write the page content, need to get the corresponding login user, and to validate its information, need to use user authentication module.
125 |
126 | ```go
127 |
128 | import (
129 | ...
130 | adapter "github.com/GoAdminGroup/go-admin/adapter/gin"
131 | "github.com/GoAdminGroup/go-admin/engine"
132 | ...
133 | )
134 |
135 | func main() {
136 |
137 | ...
138 |
139 | eng := engine.Default()
140 |
141 | cfg := config.Config{
142 | ...
143 | }
144 |
145 | if err := eng.AddConfig(cfg).
146 | AddPlugins(adminPlugin, examplePlugin).
147 | Use(r); err != nil {
148 | panic(err)
149 | }
150 |
151 | r.GET("/admin", adapter.Content(func(ctx *gin.Context) (types.Panel, error) {
152 | // get the auth user
153 | user, _ := engine.User(ctx)
154 |
155 | // Verify the permissions
156 | if !user.CheckPermission("dashboard") {
157 | return types.Panel{}, errors.New("没有权限")
158 | }
159 |
160 | // Verify the roles
161 | if !user.CheckRole("operator") {
162 | return types.Panel{}, errors.New("没有权限")
163 | }
164 | })
165 | ...
166 | }
167 | ```
--------------------------------------------------------------------------------
/fr/admin/rbac.md:
--------------------------------------------------------------------------------
1 | # Authority management
2 | ---
3 |
4 | GoAdmin has built in [RBAC] (https://www.google.com/search?oq=rbac) permission control module. After entering the home page as a super administrator, expand the management of the left sidebar. There are three management panels for users, roles, and permissions:
5 |
6 | 
7 |
8 |
9 | ## Instructions
10 |
11 | On a form of management, the corresponding routing to add and delete, assuming that form called ` ` ` users ` ` `, as follows:
12 |
13 | | Permission | url path | method |
14 | | ---- | ---- | ---- |
15 | | List page | /info/users | GET |
16 | | Edit page of all rows | /info/users/edit | GET |
17 | | Edit page of specify row | /info/users/edit?id=2 | GET |
18 | | Edit operation of all rows | /edit/users | POST |
19 | | Edit operation of specify row | /edit/users?id=2 | POST |
20 | | New page | /info/users/new | GET |
21 | | Create operation | /new/users | POST |
22 | | Export operation | /export/users | POST |
23 | | All permission | * | (empty)
24 |
25 | **Note: the role of permissions is higher than in the menu configuration**
26 |
27 | That is to say, assuming the menu 1, corresponding operator is the role of, and have all permissions users can still access the menu 1.
--------------------------------------------------------------------------------
/fr/admin/table/basic.md:
--------------------------------------------------------------------------------
1 | # Usage basique
2 |
3 | Utilisez cette ligne de commande pour générer un table de données:
4 |
5 | ```sql
6 | CREATE TABLE `users` (
7 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
8 | `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
9 | `gender` tinyint(4) DEFAULT NULL,
10 | `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
11 | `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
12 | `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
13 | `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
14 | `updated_at` timestamp NULL DEFAULT NULL,
15 | PRIMARY KEY (`id`)
16 | ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
17 | ```
18 |
19 | Généré:
20 |
21 | ```go
22 | package datamodel
23 |
24 | import (
25 | ...
26 | )
27 |
28 | func GetUserTable(ctx *context.Context) (userTable table.Table) {
29 |
30 | // configuration du modèle de la table.
31 | userTable = table.NewDefaultTable(table.Config{...})
32 |
33 | info := userTable.GetInfo()
34 |
35 | // id est triable.
36 | info.AddField("ID", "id", db.Int).FieldSortable(true)
37 | info.AddField("Name", "name", db.Varchar)
38 |
39 | ...
40 |
41 | // on donne le titre et la déscription de la page de la table.
42 | info.SetTable("users").SetTitle("Users").SetDescription("Users").
43 | SetAction(template.HTML(``)) // bouton personnalisé
44 |
45 | ...
46 | }
47 | ```
48 |
49 | ### Ajout d'un champ
50 |
51 | ```go
52 | // Ajout d'un champ avec son titre (ID), son nom (id) et son type (int)
53 | info.AddField("ID", "id", db.Int)
54 |
55 | // Ajout d'un second champ avec son titre (Name), son nom (name) et son type (varchar)
56 | info.AddField("Name", "name", db.Varchar)
57 |
58 | // Ajout d'un troisième champ, qui n'existe cependant pas dans la table sql
59 | info.AddField("Custom", "custom", db.Varchar)
60 | ```
61 |
62 | ### Modifications visuelles
63 |
64 | ```go
65 | // La sortie correspond à la valeur du champ
66 | info.AddField("Gender", "gender", db.Tinyint).FieldDisplay(func(model types.FieldModel) interface{} {
67 | if model.Value == "0" {
68 | return "men"
69 | }
70 | if model.Value == "1" {
71 | return "women"
72 | }
73 | return "unknown"
74 | })
75 |
76 | // Sortie html
77 | info.AddField("Name", "name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} {
78 | return "" + model.Value + ""
79 | })
80 | ```
81 |
82 | La sortie inconnue reçue par **FieldDisplay** connecte les données de la ligne actuelle et peut appeler d'autres données en elle.
83 |
84 | ```go
85 | info.AddField("First Name", "first_name", db.Varchar).FieldHide()
86 | info.AddField("Last Name", "last_name", db.Varchar).FieldHide()
87 |
88 | // Colonne du champ non-existante
89 | info.AddField("Full Name", "full_name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} {
90 | return model.Row["first_name"].(string) + " " + model.Row["last_name"].(string)
91 | })
92 | ```
93 |
94 | ### Cacher le bouton créer
95 |
96 | ```go
97 | info.HideNewButton()
98 | ```
99 |
100 | ### Cacher le bouton éditer
101 |
102 | ```go
103 | info.HideEditButton()
104 | ```
105 |
106 | ### Cacher le bouton exporter
107 |
108 | ```go
109 | info.HideExportButton()
110 | ```
111 |
112 | ### Cacher le bouton supprimer
113 |
114 | ```go
115 | info.HideDeleteButton()
116 | ```
117 |
118 | ### Cacher le bouton de détails
119 |
120 | ```go
121 | info.HideDetailButton()
122 | ```
123 |
124 | ### Cacher le filtre par défault
125 |
126 | ```go
127 | info.HideFilterArea()
128 | ```
129 |
130 | ### Pré requête
131 |
132 | ```go
133 | // field, operator, argument
134 | info.Where("type", "=", 0)
135 | ```
136 |
137 | ## Modifier la disposition du filtre
138 |
139 | ```go
140 | info.SetFilterFormLayout(layout form.Layout)
141 | ```
142 |
143 | ## Changer l'ordre par défault
144 |
145 | ```go
146 | // monter
147 | info.SetSortAsc()
148 | // descendre
149 | info.SetSortDesc()
150 | ```
151 |
152 | ## Joindre une table
153 |
154 | La table doit avoir un nom et un champ
155 |
156 | ```go
157 | info.AddField("Role Name", "role_name", db.Varchar).FieldJoin(types.Join{
158 | Table: "role", // nom de la table que l'on veut joindre
159 | Field: "id", // nom du champ à joindre
160 | JoinField: "user_id", // champ de la table que l'on veut joindre
161 | })
162 | ```
163 |
164 | Cela va générer une commande sql comme celle-ci:
165 |
166 | ```sql
167 | select ..., role.`role_name` from users left join role on users.`id` = role.`user_id` where ...
168 | ```
169 |
170 | ## Configurer la page des détails
171 |
172 | Vous pouvez personnaliser l'affichage de la page des détails. Si ce n'est pas fait, les règlages par défaults seront choisis
173 |
174 | ```go
175 | package datamodel
176 |
177 | import (
178 | ...
179 | )
180 |
181 | func GetUserTable(ctx *context.Context) (userTable table.Table) {
182 |
183 | userTable = table.NewDefaultTable(table.Config{...})
184 |
185 | detail := userTable.GetDetail()
186 |
187 | detail.AddField("ID", "id", db.Int)
188 | detail.AddField("Name", "name", db.Varchar)
189 |
190 | ...
191 | }
192 | ```
193 |
--------------------------------------------------------------------------------
/fr/admin/table/column_usage.md:
--------------------------------------------------------------------------------
1 | # Usage de colonnes
2 | ---
3 |
4 | **InfoPanel** a beaucoup d'éléments qui permettent de manipuler les données des colonnes de façon très flexible.
5 |
6 | ### Changer la largeur
7 |
8 | ```go
9 | info.SetTableFixed()
10 | info.AddField("Name", "name", db.Varchar).FieldWidth(100)
11 | ```
12 |
13 | ### Cacher
14 |
15 | ```go
16 | info.AddField("Name", "name", db.Varchar).FieldHide()
17 | ```
18 |
19 | ### Pouvoir être ordonné
20 |
21 | ```go
22 | info.AddField("Name", "name", db.Varchar).FieldSortable()
23 | ```
24 |
25 | ### Est fixe
26 |
27 | ```go
28 | info.AddField("Name", "name", db.Varchar).FieldFixed()
29 | ```
30 |
31 | ### Peut-être filtrable
32 |
33 | ```go
34 | info.AddField("Name", "name", db.Varchar).FieldFilterable()
35 | ```
36 |
37 | ## Aide
38 |
39 | ### Manipulation de chaînes de caractères
40 |
41 | Limiter la taille du champ
42 |
43 | ```go
44 | info.AddField("Name", "name", db.Varchar).FieldLimit(10)
45 | ```
46 |
47 | Titre
48 |
49 | ```go
50 | info.AddField("Name", "name", db.Varchar).FieldToTitle()
51 | ```
52 |
53 | Modifier l'espace
54 |
55 | ```go
56 | info.AddField("Name", "name", db.Varchar).FieldTrimSpace()
57 | ```
58 |
59 | Concaténation
60 |
61 | ```go
62 | info.AddField("Name", "name", db.Varchar).FieldSubstr(0, 3)
63 | ```
64 |
65 | Chaîne de caractères en majuscules
66 |
67 | ```go
68 | info.AddField("Name", "name", db.Varchar).FieldToUpper()
69 | ```
70 |
71 | Chaîne de caractères en minuscules
72 |
73 | ```go
74 | info.AddField("Name", "name", db.Varchar).FieldToLower()
75 | ```
76 |
77 |
78 | **Si vous voulez ajouter des filtres globaux**
79 |
80 | Alors vous pourrez le faire comme ceci:
81 |
82 | ```go
83 | adminPlugin := admin.NewAdmin(...)
84 |
85 | // limiter la sortie
86 | adminPlugin.AddDisplayFilterLimit(limit int)
87 |
88 | // Modifier l'espace
89 | adminPlugin.AddDisplayFilterTrimSpace()
90 |
91 | // Concaténation
92 | adminPlugin.AddDisplayFilterSubstr(start int, end int)
93 |
94 | // Titre
95 | adminPlugin.AddDisplayFilterToTitle()
96 |
97 | // Majuscules
98 | adminPlugin.AddDisplayFilterToUpper()
99 |
100 | // Minuscules
101 | adminPlugin.AddDisplayFilterToLower()
102 |
103 | // Filtre xss
104 | adminPlugin.AddDisplayFilterXssFilter()
105 |
106 | // Filtre JavaScript
107 | adminPlugin.AddDisplayFilterXssJsFilter()
108 |
109 | ```
110 |
111 | **Si vous voulez ajouter un filtre pour une table ou un tableau**
112 |
113 | ```go
114 | info := table.NewDefaultTable(...).GetInfo()
115 |
116 | info.AddLimitFilter(limit int)
117 | info.AddTrimSpaceFilter()
118 | info.AddSubstrFilter(start int, end int)
119 | info.AddToTitleFilter()
120 | info.AddToUpperFilter()
121 | info.AddToLowerFilter()
122 | info.AddXssFilter()
123 | info.AddXssJsFilter()
124 |
125 | form := table.NewDefaultTable(...).GetForm()
126 |
127 | form.AddLimitFilter(limit int)
128 | form.AddTrimSpaceFilter()
129 | form.AddSubstrFilter(start int, end int)
130 | form.AddToTitleFilter()
131 | form.AddToUpperFilter()
132 | form.AddToLowerFilter()
133 | form.AddXssFilter()
134 | form.AddXssJsFilter()
135 | ```
136 |
--------------------------------------------------------------------------------
/fr/admin/theme.md:
--------------------------------------------------------------------------------
1 | # Use New Theme
2 | ---
3 |
4 | Follow two steps:(Notice:GoAdmin version should be higher than v1.0.2)
5 |
6 | - 1. import the theme package
7 | - 2. set theme name in your config
8 |
9 | Ex:
10 |
11 | ```go
12 | package main
13 |
14 | import (
15 | ...
16 |
17 | _ "github.com/GoAdminGroup/themes/sword"
18 |
19 | ...
20 | )
21 |
22 | func main() {
23 | r := gin.Default()
24 |
25 | gin.SetMode(gin.ReleaseMode)
26 | gin.DefaultWriter = ioutil.Discard
27 |
28 | eng := engine.Default()
29 |
30 | cfg := config.Config{
31 | ...
32 |
33 | Theme: "sword",
34 |
35 | ...
36 | }
37 |
38 | ...
39 | }
40 | ```
--------------------------------------------------------------------------------
/fr/architecture/introduction.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 | ---
3 |
4 | The GoAdmin project module is as follows:
5 |
6 | | Name | Function | Path |
7 | | ---- | ---- | ---- |
8 | | engine | Engine is the core module of GoAdmin. The function of this module is to use the web framework adapter to inject the mapping between the plugin's routing and controller methods into the framework. | ./engine/engine.go
9 | | adapter | The function of the adapter is to realize the mutual conversion between the context of the web framework and the context of GoAdmin. | ./adapter/adapter.go
10 | | context | Context is the context of a request, the record includes the routing parameters and method information of the request, the context will be passed to the method of the plugin | ./context/context.go
11 | | plugin | Each plugin has its own routing and controller method. After receiving the context converted by the adapter, it is processed by the controller method and returned to the adapter and then output to the web framework. | ./plugins/plugins.go
12 | | template | Template is the golang materialization corresponding to the front-end code, and the component parts corresponding to the front-end code, such as forms, rows, columns, etc., are instantiated as an interface of golang, so the html code of the component can be obtained by calling the interface method, and this function is provided to Plugin to call | ./template/template.go
13 | | auth | Auth implements the management of cookies, stores and converts the front-end cookie to the logged-in user, and implements the interception of the privilege. | ./modules/auth/auth.go
14 | | config | Config is the global configuration of the system | ./modules/config/config.go
15 | | db | db is a sql connection library, connected to the sql database to provide query and other help methods, support for multiple drivers | ./modules/db/connection.go
16 | | language | Language implements a simple language mapping to support language localization | ./modules/language/language.go
17 | | file | File implements a file upload engine | ./modules/file/file.go
18 | | logger | The logger is the log module of the project | ./modules/logger/logger.go
19 | | menu | Menu is the management of the project menu | ./modules/menu/menu.go
20 | | cli | Cli command line module, including some basic commands for generating files and development | ./adm/cli.go
--------------------------------------------------------------------------------
/fr/development/adapter.md:
--------------------------------------------------------------------------------
1 | # Adapter Development
2 | ---
3 |
4 | The role of the adapter is to achieve the conversion of the web framework context and GoAdmin's own context.
5 | To make a Adapter, you need implemente three methods:
6 |
7 | ```go
8 | package adapter
9 |
10 | import (
11 | "github.com/GoAdminGroup/go-admin/plugins"
12 | "github.com/GoAdminGroup/go-admin/template/types"
13 | )
14 |
15 | // WebFrameWork is a interface which is used as an adapter of
16 | // framework and goAdmin. It must implement two methods. Use registers
17 | // the routes and the corresponding handlers. Content writes the
18 | // response to the corresponding context of framework.
19 | type WebFrameWork interface {
20 | Use(interface{}, []plugins.Plugin) error
21 | Content(interface{}, types.GetPanel)
22 | }
23 | ```
24 |
25 | In addition to ```Use``` and ```Content```, you need to implement ```init```
26 |
27 | ## Use
28 |
29 | **Use** receives two parameters, the first parameter type is **interface{}**, which is the context of the web framework, and the second parameter is the plugin array. The return value is a **error**.
30 | The role of **Use** is to use the incoming plugin array to associate the routing of the web framework with the controller methods in the plugin array to implement the correspondence between the web framework and the GoAdmin plugin method. For example, in the plugin example:
31 |
32 | ```go
33 | "/admin/example" => ShowExample(ctx *context.Context)
34 | ```
35 |
36 | After processing by ```Use```, it will be injected into the web framework.
37 |
38 | ## Content
39 |
40 | The **Content** method takes two arguments, the first argument type is **interface{}**, which is the context of the web framework, and the second argument is the **types.GetPanel** type.
41 |
42 | As follow:
43 |
44 | ```go
45 | type GetPanel func(ctx interface{}) (Panel, error)
46 | ```
47 |
48 | The role of **Content** is to pass the web framework's context when customizing the page, and then write the return of the custom page content to the web framework's context.
49 |
50 | ## init
51 |
52 | The **init** method injects the adapter into the engine so it can be used by others.
53 |
54 | ```go
55 | func init() {
56 | engine.Register(new(Beego))
57 | }
58 | ```
--------------------------------------------------------------------------------
/fr/development/code_style.md:
--------------------------------------------------------------------------------
1 | # Code Style
2 | ---
3 |
4 | ```
5 | make lint
6 | ```
--------------------------------------------------------------------------------
/fr/development/plugins.md:
--------------------------------------------------------------------------------
1 | # Plugins Development
2 | ---
3 |
4 | Example:
5 |
6 | - [develop a plugin used by source code](https://github.com/GoAdminGroup/go-admin/blob/master/plugins/example/example.go)
7 | - [develop a plugin used by golang plugin](https://github.com/GoAdminGroup/go-admin/blob/master/plugins/example/go_plugin/main.go)
8 |
--------------------------------------------------------------------------------
/fr/development/template/components.md:
--------------------------------------------------------------------------------
1 | # Components Development
2 | ---
3 |
4 | Component development, taking the image component as an example.
5 |
6 | ## New types and methods of upper interface
7 |
8 | - Create a new ```ImgAttribute``` type
9 |
10 | ```go
11 | type ImgAttribute interface {
12 | SetWidth(value string) ImgAttribute
13 | SetHeight(value string) ImgAttribute
14 | SetSrc(value string) ImgAttribute
15 | GetContent() template.HTML
16 | }
17 | ```
18 |
19 | - In the ```Template``` interface, add a method:
20 |
21 | ```go
22 | type Template interface {
23 | ...
24 | Image() types.ImgAttribute
25 | ...
26 | }
27 | ```
28 |
29 | ## Specific implementation, with ```adminlte``` as an example
30 |
31 | - ```ImgAttribute```
32 |
33 | Create a new ```image.go``` file under ```./template/adminlte/components```, as follows:
34 |
35 | ```go
36 | package components
37 |
38 | import (
39 | "github.com/GoAdminGroup/go-admin/template/types"
40 | "html/template"
41 | )
42 |
43 | type ImgAttribute struct {
44 | Name string
45 | Witdh string
46 | Height string
47 | Src string
48 | }
49 |
50 | func (compo *ImgAttribute) SetWidth(value string) types.ImgAttribute {
51 | compo.Witdh = value
52 | return compo
53 | }
54 |
55 | func (compo *ImgAttribute) SetHeight(value string) types.ImgAttribute {
56 | compo.Height = value
57 | return compo
58 | }
59 |
60 | func (compo *ImgAttribute) SetSrc(value string) types.ImgAttribute {
61 | compo.Src = value
62 | return compo
63 | }
64 |
65 | func (compo *ImgAttribute) GetContent() template.HTML {
66 | return ComposeHtml(compo.TemplateList, *compo, "image")
67 | }
68 | ```
69 |
70 | - ```Image()```
71 |
72 | In ```.template/adminlte/adminlte.go```, add a function:
73 |
74 | ```go
75 | func (*Theme) Image() types.ImgAttribute {
76 | return &components.ImgAttribute{
77 | Name: "image",
78 | Witdh: "50",
79 | Height: "50",
80 | Src: "",
81 | }
82 | }
83 | ```
84 |
85 | Still not completed here, you need to add static resource files.
86 |
87 | - Add the static resource file
88 |
89 | Add ```image.tmpl``` file to ```.template/adminlte/resource/pages/components```
90 |
91 | Annoying, and the last step
92 |
93 | - Execute in the root directory:
94 |
95 | ```shell
96 | adm assets
97 | ```
--------------------------------------------------------------------------------
/fr/development/template/form.md:
--------------------------------------------------------------------------------
1 | # Form Development
2 | ---
--------------------------------------------------------------------------------
/fr/development/template/template.md:
--------------------------------------------------------------------------------
1 | # Template Introducation
2 | ---
3 |
4 | The theme template is an abstract representation of ui, including a collection of components and static resources that are called in the plugin. The type in go-admin is ```Template```, as follows:
5 |
6 | ```go
7 | type Template interface {
8 | // Components
9 | Form() types.FormAttribute
10 | Col() types.ColAttribute
11 | Table() types.TableAttribute
12 | DataTable() types.DataTableAttribute
13 | Row() types.RowAttribute
14 | Tree() types.TreeAttribute
15 | Paginator() types.PaginatorAttribute
16 | Label() types.LabelAttribute
17 | Image() types.ImgAttribute
18 | Alert() types.AlertAttribute
19 | Tabs() types.TabsAttribute
20 | Popup() types.PopupAttribute
21 |
22 | // Builder methods
23 | GetTmplList() map[string]string
24 | GetAssetList() []string
25 | GetAsset(string) ([]byte, error)
26 | GetTemplate(bool) (*template.Template, string)
27 | }
28 | ```
29 |
30 | To develop a ui theme template, you need to implement the above ```Template``` interface.
--------------------------------------------------------------------------------
/fr/install.md:
--------------------------------------------------------------------------------
1 | # Get Ready
2 | ---
3 |
4 | This program is based on ```golang```. It is recommended to use ```golang``` with version higher than 1.11. Please visit: [https://golang.org](https://golang.org)
5 |
6 | ## Import the program required sql to the corresponding self-built database
7 |
8 | The contents of the sql file are the data tables required by the framework. Suppose your business database is: database_a; then you can import the framework sql into ```database_a```, or you can create another database ```database_b``` Import, can be a different driver database, for example, your business database is ```mysql```, the framework database is ```sqlite```. The framework currently supports multiple database connection operations. How to configure, will be described in detail later.
9 |
10 | - [mysql](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.sql)
11 | - [sqlite](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.db)
12 | - [postgresql](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.pgsql)
13 |
14 | ## Install command line tools
15 |
16 | Download the binary excecute file:
17 |
18 | | File name | OS | Arch | Size |
19 | | ---- | ---- | ---- |---- |
20 | | [adm_darwin_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_darwin_x86_64_v1.2.24.zip) | macOs | x86-64 | 4.77 MB
21 | | [adm_linux_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_x86_64_v1.2.24.zip) | Linux | x86-64 | 6.52 MB
22 | | [adm_linux_armel_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_armel_v1.2.24.zip) | Linux | x86 | 6.06 MB
23 | | [adm_windows_i386_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_i386_v1.2.24.zip) | Windows | x86 |6.16 MB
24 | | [adm_windows_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_x86_64_v1.2.24.zip) | Windows | x86-64 |6.38 MB
25 |
26 |
27 | Or use the command:
28 |
29 | ```
30 | go install github.com/GoAdminGroup/adm
31 | ```
32 |
33 |
34 |
35 | 🍺🍺 Get ready to work here, next to the [Quick start](quick_start)
36 |
37 |
38 |
39 | > English is not my main language. If any typo or wrong translation you found, you can help to translate in [github here](https://github.com/GoAdminGroup/docs). I will very appreciate it.
40 |
41 |
42 |
--------------------------------------------------------------------------------
/fr/pages/components.md:
--------------------------------------------------------------------------------
1 | # Components
2 | ----
--------------------------------------------------------------------------------
/fr/pages/login.md:
--------------------------------------------------------------------------------
1 | # 更改登录界面
2 | ---
3 |
4 | 通过组件的方式可以修改登录界面,如下例子:
5 |
6 | 更多登录界面组件[看这里](https://github.com/GoAdminGroup/components/blob/master/login/README.md);加载后引入即可。
7 |
8 | ```go
9 | package main
10 |
11 | import (
12 | "github.com/GoAdminGroup/demo/login"
13 | "github.com/GoAdminGroup/demo/pages"
14 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
15 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
16 | _ "github.com/GoAdminGroup/themes/adminlte"
17 | "github.com/GoAdminGroup/go-admin/engine"
18 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
19 | "github.com/GoAdminGroup/go-admin/plugins/admin"
20 | "github.com/GoAdminGroup/go-admin/plugins/example"
21 | "github.com/GoAdminGroup/go-admin/template"
22 | "github.com/GoAdminGroup/go-admin/template/types"
23 | "github.com/gin-gonic/gin"
24 | )
25 |
26 | func main() {
27 | r := gin.Default()
28 |
29 | eng := engine.Default()
30 |
31 | // 增加登录组件
32 | template.AddLoginComp(login.GetLoginComponent())
33 |
34 | // you can custom a plugin like:
35 |
36 | examplePlugin := example.NewExample()
37 |
38 | rootPath := "/data/www/go-admin"
39 |
40 | if err := eng.AddConfigFromJson(rootPath+"/config.json").
41 | AddGenerators(datamodel.Generators).
42 | AddGenerator("user", datamodel.GetUserTable).
43 | AddPlugins(examplePlugin).
44 | Use(r); err != nil {
45 | panic(err)
46 | }
47 |
48 | r.Static("/uploads", rootPath+"/uploads")
49 |
50 | _ = r.Run(":9033")
51 | }
52 | ```
53 |
--------------------------------------------------------------------------------
/fr/pages/modules.md:
--------------------------------------------------------------------------------
1 | # Page Modules
2 | ---
3 |
4 | Page customization needs to call the engine's ```Content``` method, which needs to return an object ```types.Panel```
5 |
6 | The following is the definition of ```types.Panel```:
7 |
8 | ```go
9 | type Panel struct {
10 | Content template.HTML
11 | Title string
12 | Description string
13 | Url string
14 | }
15 | ```
16 |
17 | Corresponding ui, you can see the following picture:
18 |
19 | 
20 |
21 | ## How to use
22 |
23 | ```go
24 | package datamodel
25 |
26 | import (
27 | "github.com/GoAdminGroup/go-admin/modules/config"
28 | template2 "github.com/GoAdminGroup/go-admin/template"
29 | "github.com/GoAdminGroup/go-admin/template/types"
30 | "html/template"
31 | )
32 |
33 | func GetContent() (types.Panel, error) {
34 |
35 | components := template2.Get(config.Get().THEME)
36 | colComp := components.Col()
37 |
38 | infobox := components.InfoBox().
39 | SetText("CPU TRAFFIC").
40 | SetColor("blue").
41 | SetNumber("41,410").
42 | SetIcon("ion-ios-gear-outline").
43 | GetContent()
44 |
45 | var size = map[string]string{"md": "3", "sm": "6", "xs": "12"}
46 | infoboxCol1 := colComp.SetSize(size).SetContent(infobox).GetContent()
47 | row1 := components.Row().SetContent(infoboxCol1).GetContent()
48 |
49 | return types.Panel{
50 | Content: row1,
51 | Title: "Dashboard",
52 | Description: "this is a example",
53 | }, nil
54 | }
55 | ```
56 |
57 | ## Col
58 |
59 | A col is type of ```ColAttribute```, has three methods:
60 |
61 | ```go
62 | type ColAttribute interface {
63 | SetSize(value map[string]string) ColAttribute
64 | SetContent(value template.HTML) ColAttribute
65 | GetContent() template.HTML
66 | }
67 | ```
68 |
69 | About the ```size```,example is ```map[string]string{"md": "3", "sm": "6", "xs": "12"}```
70 |
71 | ## Row
72 |
73 | A row is type of ```RowAttribute```, has two methods:
74 |
75 | ```go
76 | type RowAttribute interface {
77 | SetContent(value template.HTML) RowAttribute
78 | GetContent() template.HTML
79 | }
80 | ```
81 |
--------------------------------------------------------------------------------
/fr/pages/pages.md:
--------------------------------------------------------------------------------
1 | # Customize your page
2 | ---
3 |
4 | call the method ```Content```of the engine:
5 |
6 | ```go
7 | package main
8 |
9 | import (
10 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
11 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
12 | _ "github.com/GoAdminGroup/themes/adminlte"
13 | "github.com/GoAdminGroup/go-admin/engine"
14 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
15 | "github.com/GoAdminGroup/go-admin/modules/config"
16 | "github.com/GoAdminGroup/go-admin/plugins/admin"
17 | "github.com/GoAdminGroup/go-admin/plugins/example"
18 | "github.com/GoAdminGroup/go-admin/template/types"
19 | "github.com/gin-gonic/gin"
20 | )
21 |
22 | func main() {
23 | r := gin.Default()
24 |
25 | eng := engine.Default()
26 |
27 | cfg := config.Config{
28 | ...
29 | }
30 |
31 | examplePlugin := example.NewExample()
32 |
33 | if err := eng.AddConfig(cfg).
34 | AddGenerators(datamodel.Generators).
35 | AddPlugins(examplePlugin).
36 | Use(r); err != nil {
37 | panic(err)
38 | }
39 |
40 | r.Static("/uploads", "./uploads")
41 |
42 | // here to custom a page.
43 |
44 | r.GET("/"+cfg.PREFIX+"/custom", func(ctx *gin.Context) {
45 | engine.Content(ctx, func() (types.Panel, error) {
46 | return datamodel.GetContent()
47 | })
48 | })
49 |
50 | r.Run(":9033")
51 | }
52 | ```
53 |
54 | ```Content```will write the contents into the ```context``` of the framework.
55 |
56 | here is the code of ```GetContent```:
57 |
58 | ```go
59 | package datamodel
60 |
61 | import (
62 | "github.com/GoAdminGroup/go-admin/modules/config"
63 | template2 "github.com/GoAdminGroup/go-admin/template"
64 | "github.com/GoAdminGroup/go-admin/template/types"
65 | "html/template"
66 | )
67 |
68 | func GetContent() (types.Panel, error) {
69 |
70 | components := template2.Get(config.Get().THEME)
71 | colComp := components.Col()
72 |
73 | infobox := components.InfoBox().
74 | SetText("CPU TRAFFIC").
75 | SetColor("blue").
76 | SetNumber("41,410").
77 | SetIcon("ion-ios-gear-outline").
78 | GetContent()
79 |
80 | var size = map[string]string{"md": "3", "sm": "6", "xs": "12"}
81 | infoboxCol1 := colComp.SetSize(size).SetContent(infobox).GetContent()
82 | row1 := components.Row().SetContent(infoboxCol1).GetContent()
83 |
84 | return types.Panel{
85 | Content: row1,
86 | Title: "Dashboard",
87 | Description: "this is a example",
88 | }, nil
89 | }
90 | ```
91 |
--------------------------------------------------------------------------------
/fr/plan.md:
--------------------------------------------------------------------------------
1 | # Development Plan
2 | ---
3 |
4 | GoAdmin not only aim for a admin panel builder tool. Now the base version of 1.0 has achieved a base framework which can help quickly build a simple crud admin panel with permession manage and other fetures. On this basis, you can also customize the theme and the plugin. The following points after three expounds the project development plan.
5 |
6 | ## Features
7 |
8 | The final purpose of GoAdmin is achieving a no-code or to some extent, no-code operations set. And we will at least build the plugins of two. The one we named admin is help you build a crud admin panel quickly, and the other one is a Grafana like data monitor dashboard builder, which we named monitor.
9 |
10 | ### version 1.0.0
11 |
12 | - Build the basic framework, and at the same time provide a built-in plugin which can satisfy the rapid construction of crud admin panel.
13 | - This basic framework can support theme and plugin customizing.
14 |
15 | ### version 2.0.0
16 |
17 | - On the basis of version 1.0, this version will imporve the admin plugin to provide a ec mall and saas system infrastructure features
18 | - Improve the tool chain of developing themes and plugins, make it easier for developer to get start with developing of themes and plugins.
19 | - Providing more themes and built-in plugins.
20 | - The basic support of monitor system.
21 | - Improve performance of project.
22 |
23 | ### version 3.0.0
24 |
25 | - Support the productive monitor system.
26 | - Achieving a interface which support dragging and dropping in the front-end.
27 |
28 | ### version 4.0.0
29 |
30 | - Support no-code operations.
31 |
32 | ## Community
33 |
34 | GoAdmin project needs more developers to join together.
35 |
36 | Now the project is maintained by [@cg33](https://github.com/chenhg5), who is a two years gopher。
37 |
38 | Work of the projects:
39 |
40 | - [developing](https://github.com/GoAdminGroup/go-admin)
41 | - forum project maintenance(not be a opensource project yet)
42 | - [The maintenance of document improvement and translation](https://github.com/GoAdminGroup/docs)
43 | - Publicity and community culture of the organization of the project
44 |
45 | GoAdmin always adheres to an open and open attitude, and welcomes people with lofty and capable ability to join in the development of a conspiracy project and community. The community and the individual complement each other.
46 |
47 | If you are optimistic about the development of GoAdmin and are willing to gamble for him, use time for future financial or reputational returns, and you have confidence in your own abilities, then you can try to fully read the GoAdmin code and understand GoAdmin's development plan, make your contribution to this. The pre-code flaws are large and can be modified. If you have the ability to make enough contributions, you will become the project's co-founder** or **core developer**. In the later stages, the code is highly sophisticated and there is still room for improvement. You can become a ** contributor by submitting a fix**. The team will remain open and accept new members. Every member of the team who works hard will also receive a certain return in the future based on the proportion of the effort to harvest the project.
48 |
49 | If you don't have enough time and energy, but have a certain amount of money, and are equally optimistic about GoAdmin development, although GoAdmin has not yet planned a plan for this. But as long as you have enough interest, you can bring your plan to negotiate with us.
50 |
51 | ## Commercial Plan
52 |
53 | GoAdmin will be gradually commercialized, but the core infrastructure features are free and open source.
54 | GoAdmin's capital revenue model is mainly:
55 |
56 | - Accept donations
57 | - Selling themes
58 | - Selling plugins
59 | - Provide saas customized development
60 | - Commercial version for a fee
61 |
62 | Revenue funds are mainly used to maintain the development of the community, and the return on compensation of developers, to promote the project to grow better.
--------------------------------------------------------------------------------
/fr/plugins/plugins.md:
--------------------------------------------------------------------------------
1 | # How To Use Plugins
2 | ---
3 |
4 | The framework's plugins include: controllers, routing, and views. The specific plug-in development will be discussed in the project development part, here just show you how to use it.
5 |
6 | The example plugin is our demo.
7 |
8 | Using plugins are divided into: using the third package source code plugin and use the dynamic link library plugin (.so file, currently only supports linux and mac platforms)
9 |
10 | ## Using the third package source code plugin
11 |
12 | For example:
13 |
14 | ```go
15 | package main
16 |
17 | import (
18 | "github.com/gin-gonic/gin"
19 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
20 | _ "github.com/GoAdminGroup/themes/adminlte"
21 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
22 | "github.com/GoAdminGroup/go-admin/engine"
23 | "github.com/GoAdminGroup/go-admin/plugins/admin"
24 | "github.com/GoAdminGroup/go-admin/plugins/example"
25 | "github.com/GoAdminGroup/go-admin/modules/config"
26 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
27 | )
28 |
29 | func main() {
30 | r := gin.Default()
31 | eng := engine.Default()
32 | cfg := config.Config{}
33 |
34 | adminPlugin := admin.NewAdmin(datamodel.Generators)
35 | examplePlugin := example.NewExample()
36 |
37 | eng.AddConfig(cfg).
38 | AddPlugins(adminPlugin, examplePlugin). // loading
39 | Use(r)
40 |
41 | r.Run(":9033")
42 | }
43 | ```
44 |
45 |
46 | ## Using the binary plugin
47 |
48 | Load the ```.so```file, and call```plugins.LoadFromPlugin```.
49 |
50 | 如:
51 |
52 | ```go
53 | package main
54 |
55 | import (
56 | "github.com/gin-gonic/gin"
57 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
58 | _ "github.com/GoAdminGroup/themes/adminlte" // Import the theme
59 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
60 | "github.com/GoAdminGroup/go-admin/engine"
61 | "github.com/GoAdminGroup/go-admin/plugins/admin"
62 | "github.com/GoAdminGroup/go-admin/plugins"
63 | "github.com/GoAdminGroup/go-admin/modules/config"
64 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
65 | )
66 |
67 | func main() {
68 | r := gin.Default()
69 | eng := engine.Default()
70 | cfg := config.Config{}
71 |
72 | adminPlugin := admin.NewAdmin(datamodel.Generators)
73 |
74 | // load plugin from .so file.
75 | examplePlugin := plugins.LoadFromPlugin("../datamodel/example.so")
76 |
77 | eng.AddConfig(cfg).
78 | AddPlugins(adminPlugin, examplePlugin).
79 | Use(r)
80 |
81 | r.Run(":9033")
82 | }
83 | ```
--------------------------------------------------------------------------------
/tr/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | GoAdmin is a data visualization management platform, providing a complete set of visual ui calls to golang programs, and a built-in sql relational database management backend plugin.
4 |
5 | Before we build a management backend, we needed at least one back office engineer, a front-end engineer, to take at least a week. Now with GoAdmin, we don't need front-end engineers. Our back-end engineers don't even need to know the front-end knowledge. We can build a complete back-end management system in half an hour. If your requirements are not complicated, just simple crud, then all you need are serveral golang files, and all files can be packaged into a single binary file, which is very convenient for distribution and deployment.
6 |
7 | here is very simple example which show you how it work: [https://github.com/GoAdminGroup/example](https://github.com/GoAdminGroup/example)
8 |
9 | ## Features
10 |
11 | * Build-in RBAC Access Authentication System
12 | * Support most web framework
13 | * Support plug-ins\(working on it\)
14 | * Provided different ui theme\(only Adminlte now, others are coming soon.\)
15 |
16 | ## Demo
17 |
18 | [https://demo.go-admin.cn/admin](https://demo.go-admin.cn/admin)
19 |
20 | ## Dependencies
21 |
22 | * [Datetimepicker](http://eonasdan.github.io/bootstrap-datetimepicker/)
23 | * [font-awesome](http://fontawesome.io/)
24 | * [bootstrap-fileinput](https://github.com/kartik-v/bootstrap-fileinput)
25 | * [jquery-pjax](https://github.com/defunkt/jquery-pjax)
26 | * [Nestable](http://dbushell.github.io/Nestable/)
27 | * [toastr](http://codeseven.github.io/toastr/)
28 | * [bootstrap-number-input](https://github.com/wpic/bootstrap-number-input)
29 | * [fontawesome-iconpicker](https://github.com/itsjavi/fontawesome-iconpicker)
30 |
31 | ## Community
32 |
33 | [Community](http://forum.go-admin.cn)
34 |
35 | ## Backers
36 |
37 | Your support will help me do better!
38 |
39 |
--------------------------------------------------------------------------------
/tr/admin/README.md:
--------------------------------------------------------------------------------
1 | # admin
2 |
3 |
--------------------------------------------------------------------------------
/tr/admin/cli.md:
--------------------------------------------------------------------------------
1 | # Cli Introduction
2 |
3 | GoAdmin provides a command line tool to increase development efficiency and streamline the development process.
4 |
5 | ## Install
6 |
7 | Download the binary of the corresponding system:
8 |
9 | | File name | OS | Arch | Size |
10 | | :--- | :--- | :--- | :--- |
11 | | [adm\_darwin\_x86\_64\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_darwin_x86_64_v1.0.6.zip) | macOs | x86-64 | 4.77 MB |
12 | | [adm\_linux\_x86\_64\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_linux_x86_64_v1.0.6.zip) | Linux | x86-64 | 6.52 MB |
13 | | [adm\_linux\_armel\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_linux_armel_v1.0.6.zip) | Linux | x86 | 6.06 MB |
14 | | [adm\_windows\_i386\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_windows_i386_v1.0.6.zip) | Windows | x86 | 6.16 MB |
15 | | [adm\_windows\_x86\_64\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_windows_x86_64_v1.0.6.zip) | Windows | x86-64 | 6.38 MB |
16 |
17 | Or use the command to install:
18 |
19 | ```text
20 | go install github.com/GoAdminGroup/adm
21 | ```
22 |
23 | ## Usage
24 |
25 | Use
26 |
27 | ```text
28 | adm --help
29 | ```
30 |
31 | Will list help information.
32 |
33 | | Command | Subcommand | Options | Function |
34 | | :--- | :--- | :--- | :--- |
35 | | generate | - | - | generate a data model file. |
36 | | compile | asset | **-s, --src** front-end resource folder path **-d, --dist** output go file path | compile all resource files into one single go file. |
37 | | compile | tpl | **-s, --src** the input golang tmpl template folder path **-d, --dist** output go file path **p, --package** output go file package name | compile all template files into one single go file. |
38 | | combine | css | **-s, --src** the input css folder path **-d, --dist** the output css file path **p, --package** output go file package name | combine the css files into one single css file. |
39 | | combine | js | **-s, --src** the input js folder path **-d, --dist** the output js file path | combine the js files into one single js file. |
40 | | develop | tpl | **-m, --module** golang module name or path under $GOPATH **-n, --name** theme name | fetch remotely theme development templates to local. |
41 |
42 |
--------------------------------------------------------------------------------
/tr/admin/file.md:
--------------------------------------------------------------------------------
1 | # File Upload Engine
2 |
3 | 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.
4 |
5 | ```go
6 | package config
7 |
8 | // Storage directory: store avatar and other uploaded files
9 | type Store struct {
10 | Path string // relative or absolute path, the file will be stored here
11 | Prefix string // access url prefix
12 | }
13 |
14 | type Config struct {
15 |
16 | ...
17 |
18 | // Upload file storage location
19 | Store Store `json:"store"`
20 |
21 | // File upload engine
22 | FileUploadEngine FileUploadEngine `json:"file_upload_engine"`
23 |
24 | ...
25 | }
26 |
27 | type FileUploadEngine struct {
28 | Name string
29 | Config map[string]interface{}
30 | }
31 | ```
32 |
33 | 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:
34 |
35 | ## Type of engine
36 |
37 | ```go
38 | package file
39 |
40 | type Uploader interface {
41 | Upload(*multipart.Form) error
42 | }
43 |
44 | type UploaderGenerator func() Uploader
45 |
46 | func AddUploader(name string, up UploaderGenerator) {
47 | ...
48 | }
49 | ```
50 |
51 | ## How to
52 |
53 | 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.
54 |
55 | Suppose we want to add a aws cloud upload engine, then it can be similar like this:
56 |
57 | ```go
58 | package main
59 |
60 | import (
61 | ...
62 | "github.com/GoAdminGroup/go-admin/modules/file"
63 | ...
64 | )
65 |
66 | type AwsUploader struct {
67 | Bucket string
68 | Region string
69 | SecretId string
70 | SecretKey string
71 |
72 | Prefix string
73 | Path string
74 | }
75 |
76 | func (q AwsUploader) Upload(*multipart.Form) error {
77 | // 接收一个表单类型,这里实现上传逻辑
78 | }
79 |
80 | func main() {
81 |
82 | ...
83 |
84 | file.AddUploader("aws", func() file.Uploader {
85 | return &AwsUploader{
86 | Bucket: config.Get().FileUploadEngine.Config["bucket"].(string),
87 | Region: config.Get().FileUploadEngine.Config["region"].(string),
88 | SecretId: config.Get().FileUploadEngine.Config["secret_id"].(string),
89 | SecretKey: config.Get().FileUploadEngine.Config["secret_key"].(string),
90 | Prefix: config.Get().FileUploadEngine.Config["prefix"].(string),
91 | Path: config.Get().FileUploadEngine.Config["path"].(string),
92 | }
93 | })
94 |
95 | cfg := config.Config{
96 | ...
97 |
98 | FileUploadEngine: config.FileUploadEngine{
99 | Name: "aws",
100 | Config: map[string]interface{}{
101 | "bucket": "xxx",
102 | "region": "xxx",
103 | "secret_id": "xxx",
104 | "secret_key": "xxx",
105 | "prefix": "xxx",
106 | "path": "xxx",
107 | },
108 | }
109 |
110 | ...
111 | }
112 |
113 | ...
114 | }
115 | ```
116 |
117 | Finish a aws cloud upload file engine!🍺🍺
118 |
119 |
--------------------------------------------------------------------------------
/tr/admin/form/README.md:
--------------------------------------------------------------------------------
1 | # form
2 |
3 |
--------------------------------------------------------------------------------
/tr/admin/form/basic.md:
--------------------------------------------------------------------------------
1 | # Basic Usage
2 |
3 | Use the cli to generate a data form type for the sql table, such as:
4 |
5 | ```sql
6 | CREATE TABLE `users` (
7 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
8 | `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
9 | `gender` tinyint(4) DEFAULT NULL,
10 | `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
11 | `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
12 | `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
13 | `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
14 | `updated_at` timestamp NULL DEFAULT NULL,
15 | PRIMARY KEY (`id`)
16 | ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
17 | ```
18 |
19 | Generated:
20 |
21 | ```go
22 | package datamodel
23 |
24 | import (
25 | ...
26 | )
27 |
28 | func GetUserTable(ctx *context.Context) (userTable table.Table) {
29 |
30 | // config the table model.
31 | userTable = table.NewDefaultTable(...)
32 |
33 | ...
34 |
35 | formList := userTable.GetForm()
36 |
37 | // set id editable is false.
38 | formList.AddField("ID", "id", db.Int, form.Default).FieldNotAllowEdit()
39 | formList.AddField("Ip", "ip", db.Varchar, form.Text)
40 | formList.AddField("Name", "name", db.Varchar, form.Text)
41 |
42 | ...
43 |
44 | return
45 | }
46 | ```
47 |
48 | ## Add Fields
49 |
50 | ```go
51 | // Add a field with the field title ID, field name id, field type int, form type Default
52 | formList.AddField("ID", "id", db.Int, form.Default)
53 |
54 | // Add a second field with the field title Ip, the field name ip, the field type varchar, and the form type Text
55 | formList.AddField("Ip", "ip", db.Varchar, form.Text)
56 |
57 | // Add a third field, a field that does not exist in the sql table
58 | formList.AddField("Custom", "custom", db.Varchar, form.Text)
59 | ```
60 |
61 | ## Prohibit editing
62 |
63 | ```go
64 | formList.AddField("id", "id", db.Int, form.Default).FieldNotAllowEdit()
65 | ```
66 |
67 | ## No new additions
68 |
69 | ```go
70 | formList.AddField("id", "id", db.Int, form.Default).FieldNotAllowAdd()
71 | ```
72 |
73 |
--------------------------------------------------------------------------------
/tr/admin/form/components.md:
--------------------------------------------------------------------------------
1 | # Usage Of Form Components
2 |
3 | ## Default
4 |
5 | ```go
6 | // usage
7 | ```
8 |
9 | ## Text
10 |
11 | ```go
12 | // usage
13 | ```
14 |
15 | ## SelectSingle
16 |
17 | ```go
18 | // usage
19 | ```
20 |
21 | ## Select
22 |
23 | ```go
24 | // usage
25 | ```
26 |
27 | ## IconPicker
28 |
29 | ```go
30 | // usage
31 | ```
32 |
33 | ## SelectBox
34 |
35 | ```go
36 | // usage
37 | ```
38 |
39 | ## File
40 |
41 | ```go
42 | // usage
43 | ```
44 |
45 | ## Password
46 |
47 | ```go
48 | // usage
49 | ```
50 |
51 | ## RichText
52 |
53 | ```go
54 | // usage
55 | ```
56 |
57 | ## Datetime
58 |
59 | ```go
60 | // usage
61 | ```
62 |
63 | ## Radio
64 |
65 | ```go
66 | // usage
67 | ```
68 |
69 | ## Email
70 |
71 | ```go
72 | // usage
73 | ```
74 |
75 | ## Url
76 |
77 | ```go
78 | // usage
79 | ```
80 |
81 | ## Ip
82 |
83 | ```go
84 | // usage
85 | ```
86 |
87 | ## Color
88 |
89 | ```go
90 | // usage
91 | ```
92 |
93 | ## Currency
94 |
95 | ```go
96 | // usage
97 | ```
98 |
99 | ## Number
100 |
101 | ```go
102 | // usage
103 | ```
104 |
105 | ## TextArea
106 |
107 | ```go
108 | // usage
109 | ```
110 |
111 |
--------------------------------------------------------------------------------
/tr/admin/menus.md:
--------------------------------------------------------------------------------
1 | # Setting menu
2 |
3 | GoAdmin has built-in menu management module. After entering the home page as a super administrator, expand the management of the left sidebar, there is a management panel below:
4 |
5 | 
6 |
7 | Click inside to set up the menu you need.
8 |
9 |
--------------------------------------------------------------------------------
/tr/admin/module.md:
--------------------------------------------------------------------------------
1 | # Modules
2 | ---
3 |
4 | When GoAdmin engine is building, some modules are built. Such as: database module, user authentication module. And this chapter tells you how to reuse the modules.
5 |
6 | ## Database Module
7 |
8 | Database module can be used afrer the engine set the global config. For example:
9 |
10 | ```go
11 |
12 | import (
13 | ...
14 | "github.com/GoAdminGroup/go-admin/engine"
15 | ...
16 | )
17 |
18 | func main() {
19 |
20 | ...
21 |
22 | eng := engine.Default()
23 |
24 | cfg := config.Config{
25 | ...
26 | Databases: config.DatabaseList{
27 | "default": {
28 | Host: "127.0.0.1",
29 | Port: "3306",
30 | User: "root",
31 | Pwd: "root",
32 | Name: "godmin",
33 | MaxIdleCon: 50,
34 | MaxOpenCon: 150,
35 | Driver: config.DriverMysql,
36 | },
37 | },
38 | ...
39 | }
40 |
41 | _ = eng.AddConfig(cfg). // Here the database module built.
42 | AddPlugins(adminPlugin).
43 | Use(r)
44 |
45 | // get mysql connection
46 | conn := eng.MysqlConnection()
47 |
48 | // get postgresql connection
49 | conn := eng.PostgresqlConnection()
50 |
51 | // get sqlite connection
52 | conn := eng.SqliteConnection()
53 |
54 | // Note: you get a pointer here which is point to the global database connection object.
55 | // If you want to reuse in you table models file, then you should call before the .Use(r) method.
56 | // Or it will panic. Like:
57 | //
58 | // _ = eng.AddConfig(cfg).
59 | // ResolveMysqlConnection(tables.SetConn)
60 | // AddPlugins(adminPlugin).
61 | // Use(r)
62 | //
63 | // In your tables.go:
64 | //
65 | // var conn db.Connection
66 | //
67 | // func SetConn(c db.Connection) {
68 | // conn = c
69 | // }
70 | //
71 | // And then you call the conn in your table model file.
72 |
73 | // get connection by setter function
74 | eng.ResolveMysqlConnection(SetConn)
75 |
76 | ...
77 | }
78 |
79 | var globalConn db.Connection
80 |
81 | func SetConn(conn db.Connection) {
82 | globalConn = conn
83 | }
84 | ```
85 |
86 | When you receive ```connection``` object, you can call the built-in sql helper methods:
87 |
88 | ```go
89 |
90 | import (
91 | ...
92 | "github.com/GoAdminGroup/go-admin/modules/db"
93 | "github.com/GoAdminGroup/go-admin/modules/db/dialect"
94 | ...
95 | )
96 |
97 | func main() {
98 |
99 | // query
100 | db.WithDriver(globalConn).Table("users").Select("id", "name").First()
101 |
102 | // update
103 | db.WithDriver(globalConn).Table("users").Where("id", "=", 10).
104 | Update(dialect.H{
105 | "name": "jack",
106 | })
107 |
108 | // insert
109 | db.WithDriver(globalConn).Table("users").
110 | Insert(dialect.H{
111 | "name": "jack",
112 | })
113 |
114 | // delete
115 | db.WithDriver(globalConn).Table("users").Where("id", "=", 10).Delete()
116 |
117 | // and so on...
118 | }
119 |
120 | ```
121 |
122 | ## User Authentication Module
123 |
124 | When we write the page content, need to get the corresponding login user, and to validate its information, need to use user authentication module.
125 |
126 | ```go
127 |
128 | import (
129 | ...
130 | adapter "github.com/GoAdminGroup/go-admin/adapter/gin"
131 | "github.com/GoAdminGroup/go-admin/engine"
132 | ...
133 | )
134 |
135 | func main() {
136 |
137 | ...
138 |
139 | eng := engine.Default()
140 |
141 | cfg := config.Config{
142 | ...
143 | }
144 |
145 | if err := eng.AddConfig(cfg).
146 | AddPlugins(adminPlugin, examplePlugin).
147 | Use(r); err != nil {
148 | panic(err)
149 | }
150 |
151 | r.GET("/admin", adapter.Content(func(ctx *gin.Context) (types.Panel, error) {
152 | // get the auth user
153 | user, _ := engine.User(ctx)
154 |
155 | // Verify the permissions
156 | if !user.CheckPermission("dashboard") {
157 | return types.Panel{}, errors.New("没有权限")
158 | }
159 |
160 | // Verify the roles
161 | if !user.CheckRole("operator") {
162 | return types.Panel{}, errors.New("没有权限")
163 | }
164 | })
165 | ...
166 | }
167 | ```
--------------------------------------------------------------------------------
/tr/admin/rbac.md:
--------------------------------------------------------------------------------
1 | # Authority management
2 |
3 | GoAdmin has built in \[RBAC\] \([https://www.google.com/search?oq=rbac](https://www.google.com/search?oq=rbac)\) permission control module. After entering the home page as a super administrator, expand the management of the left sidebar. There are three management panels for users, roles, and permissions:
4 |
5 | 
6 |
7 |
--------------------------------------------------------------------------------
/tr/admin/table/README.md:
--------------------------------------------------------------------------------
1 | # table
2 |
3 |
--------------------------------------------------------------------------------
/tr/admin/table/basic.md:
--------------------------------------------------------------------------------
1 | # Basic Usage
2 |
3 | Use the command line to generate a data table type for the sql table, such as:
4 |
5 | ```sql
6 | CREATE TABLE `users` (
7 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
8 | `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
9 | `gender` tinyint(4) DEFAULT NULL,
10 | `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
11 | `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
12 | `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
13 | `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
14 | `updated_at` timestamp NULL DEFAULT NULL,
15 | PRIMARY KEY (`id`)
16 | ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
17 | ```
18 |
19 | Generated:
20 |
21 | ```go
22 | package datamodel
23 |
24 | import (
25 | ...
26 | )
27 |
28 | func GetUserTable(ctx *context.Context) (userTable table.Table) {
29 |
30 | // config the table model.
31 | userTable = table.NewDefaultTable(table.Config{...})
32 |
33 | info := userTable.GetInfo()
34 |
35 | // set id sortable.
36 | info.AddField("ID", "id", db.Int).FieldSortable(true)
37 | info.AddField("Name", "name", db.Varchar)
38 |
39 | ...
40 |
41 | // set the title and description of table page.
42 | info.SetTable("users").SetTitle("Users").SetDescription("Users").
43 | SetAction(template.HTML(``)) // custom operation button
44 |
45 | ...
46 | }
47 | ```
48 |
49 | ### Add Field
50 |
51 | ```go
52 | // Add a field with the field title ID, field name id, field type int
53 | info.AddField("ID", "id", db.Int)
54 |
55 | // Add the second field, the field title is Name, the field name is name, and the field type is varchar
56 | info.AddField("Name", "name", db.Varchar)
57 |
58 | // Add a third field, a field that does not exist in the sql table
59 | info.AddField("Custom", "custom", db.Varchar)
60 | ```
61 |
62 | ### Modify display output
63 |
64 | ```go
65 | // Output the corresponding content according to the value of the field
66 | info.AddField("Gender", "gender", db.Tinyint).FieldDisplay(func(model types.FieldModel) interface{} {
67 | if model.Value == "0" {
68 | return "men"
69 | }
70 | if model.Value == "1" {
71 | return "women"
72 | }
73 | return "unknown"
74 | })
75 |
76 | // Output html
77 | info.AddField("Name", "name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} {
78 | return "" + model.Value + ""
79 | })
80 | ```
81 |
82 | The anonymous function received by the **FieldDisplay** method binds the data object of the current row, and can call other field data of the current row in it.
83 |
84 | ```go
85 | info.AddField("First Name", "first_name", db.Varchar).FieldHide()
86 | info.AddField("Last Name", "last_name", db.Varchar).FieldHide()
87 |
88 | // non-existing field columns
89 | info.AddField("Full Name", "full_name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} {
90 | return model.Row["first_name"].(string) + " " + model.Row["last_name"].(string)
91 | })
92 | ```
93 |
94 | ### Hide create button
95 |
96 | ```go
97 | info.HideNewButton()
98 | ```
99 |
100 | ### Hide edit button
101 |
102 | ```go
103 | info.HideEditButton()
104 | ```
105 |
106 | ### Hide export button
107 |
108 | ```go
109 | info.HideExportButton()
110 | ```
111 |
112 | ### Hide delete button
113 |
114 | ```go
115 | info.HideDeleteButton()
116 | ```
117 |
118 | ### Hide detail button
119 |
120 | ```go
121 | info.HideDetailButton()
122 | ```
123 |
124 | ### Hide filter area by default
125 |
126 | ```go
127 | info.HideFilterArea()
128 | ```
129 |
130 | ### Pre query
131 |
132 | ```go
133 | // field, operator, argument
134 | info.Where("type", "=", 0)
135 | ```
136 |
137 | ## Set filter area form layout
138 |
139 | ```go
140 | info.SetFilterFormLayout(layout form.Layout)
141 | ```
142 |
143 | ## Set default order rule
144 |
145 | ```go
146 | // increase
147 | info.SetSortAsc()
148 | // decrease
149 | info.SetSortDesc()
150 | ```
151 |
152 | ## Join Table
153 |
154 | The table needs to set the table name and the table field
155 |
156 | ```go
157 | info.AddField("Role Name", "role_name", db.Varchar).FieldJoin(types.Join{
158 | Table: "role", // table name which you want to join
159 | Field: "id", // table field name of your own
160 | JoinField: "user_id", // table field name of the table which you want to join
161 | })
162 | ```
163 |
164 | It will generate a sql statement like this:
165 |
166 | ```sql
167 | select ..., role.`role_name` from users left join role on users.`id` = role.`user_id` where ...
168 | ```
169 |
170 | ## Configure Detail Page
171 |
172 | You can customize details page display content, if it is not set, the default Settings display using list page
173 |
174 | ```go
175 | package datamodel
176 |
177 | import (
178 | ...
179 | )
180 |
181 | func GetUserTable(ctx *context.Context) (userTable table.Table) {
182 |
183 | userTable = table.NewDefaultTable(table.Config{...})
184 |
185 | detail := userTable.GetDetail()
186 |
187 | detail.AddField("ID", "id", db.Int)
188 | detail.AddField("Name", "name", db.Varchar)
189 |
190 | ...
191 | }
192 | ```
--------------------------------------------------------------------------------
/tr/admin/table/column_usage.md:
--------------------------------------------------------------------------------
1 | # Usage Of Column
2 |
3 | **InfoPanel** has a lot of built-in operation methods for columns, which can be used to manipulate column data very flexibly.
4 |
5 | ### Set Width
6 |
7 | ```go
8 | info.SetTableFixed()
9 | info.AddField("Name", "name", db.Varchar).FieldWidth(100)
10 | ```
11 |
12 | ### Hide
13 |
14 | ```go
15 | info.AddField("Name", "name", db.Varchar).FieldHide()
16 | ```
17 |
18 | ### Be Sortable
19 |
20 | ```go
21 | info.AddField("Name", "name", db.Varchar).FieldSortable()
22 | ```
23 |
24 | ### Be Fixed
25 |
26 | ```go
27 | info.AddField("Name", "name", db.Varchar).FieldFixed()
28 | ```
29 |
30 | ### Be Filterable
31 |
32 | ```go
33 | info.AddField("Name", "name", db.Varchar).FieldFilterable()
34 | ```
35 |
36 | ## Help Methods
37 |
38 | ### String manipulation
39 |
40 | Limit the output length
41 |
42 | ```go
43 | info.AddField("Name", "name", db.Varchar).FieldLimit(10)
44 | ```
45 |
46 | Title
47 |
48 | ```go
49 | info.AddField("Name", "name", db.Varchar).FieldToTitle()
50 | ```
51 |
52 | Trim space
53 |
54 | ```go
55 | info.AddField("Name", "name", db.Varchar).FieldTrimSpace()
56 | ```
57 |
58 | String interception
59 |
60 | ```go
61 | info.AddField("Name", "name", db.Varchar).FieldSubstr(0, 3)
62 | ```
63 |
64 | String to uppercase
65 |
66 | ```go
67 | info.AddField("Name", "name", db.Varchar).FieldToUpper()
68 | ```
69 |
70 | String to lowercase
71 |
72 | ```go
73 | info.AddField("Name", "name", db.Varchar).FieldToLower()
74 | ```
75 |
76 |
--------------------------------------------------------------------------------
/tr/admin/theme.md:
--------------------------------------------------------------------------------
1 | # Use New Theme
2 |
3 | Follow two steps:(Notice:GoAdmin version should be higher than v1.0.2)
4 |
5 | * 1. import the theme package
6 | * 1. set theme name in your config
7 |
8 | Ex:
9 |
10 | ```go
11 | package main
12 |
13 | import (
14 | ...
15 |
16 | _ "github.com/GoAdminGroup/themes/sword"
17 |
18 | ...
19 | )
20 |
21 | func main() {
22 | r := gin.Default()
23 |
24 | gin.SetMode(gin.ReleaseMode)
25 | gin.DefaultWriter = ioutil.Discard
26 |
27 | eng := engine.Default()
28 |
29 | cfg := config.Config{
30 | ...
31 |
32 | Theme: "sword",
33 |
34 | ...
35 | }
36 |
37 | ...
38 | }
39 | ```
40 |
41 |
--------------------------------------------------------------------------------
/tr/architecture/README.md:
--------------------------------------------------------------------------------
1 | # architecture
2 |
3 |
--------------------------------------------------------------------------------
/tr/architecture/introduction.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | The GoAdmin project module is as follows:
4 |
5 | | Name | Function | Path |
6 | | :--- | :--- | :--- |
7 | | engine | Engine is the core module of GoAdmin. The function of this module is to use the web framework adapter to inject the mapping between the plugin's routing and controller methods into the framework. | ./engine/engine.go |
8 | | adapter | The function of the adapter is to realize the mutual conversion between the context of the web framework and the context of GoAdmin. | ./adapter/adapter.go |
9 | | context | Context is the context of a request, the record includes the routing parameters and method information of the request, the context will be passed to the method of the plugin | ./context/context.go |
10 | | plugin | Each plugin has its own routing and controller method. After receiving the context converted by the adapter, it is processed by the controller method and returned to the adapter and then output to the web framework. | ./plugins/plugins.go |
11 | | template | Template is the golang materialization corresponding to the front-end code, and the component parts corresponding to the front-end code, such as forms, rows, columns, etc., are instantiated as an interface of golang, so the html code of the component can be obtained by calling the interface method, and this function is provided to Plugin to call | ./template/template.go |
12 | | auth | Auth implements the management of cookies, stores and converts the front-end cookie to the logged-in user, and implements the interception of the privilege. | ./modules/auth/auth.go |
13 | | config | Config is the global configuration of the system | ./modules/config/config.go |
14 | | db | db is a sql connection library, connected to the sql database to provide query and other help methods, support for multiple drivers | ./modules/db/connection.go |
15 | | language | Language implements a simple language mapping to support language localization | ./modules/language/language.go |
16 | | file | File implements a file upload engine | ./modules/file/file.go |
17 | | logger | The logger is the log module of the project | ./modules/logger/logger.go |
18 | | menu | Menu is the management of the project menu | ./modules/menu/menu.go |
19 | | cli | Cli command line module, including some basic commands for generating files and development | ./adm/cli.go |
20 |
21 |
--------------------------------------------------------------------------------
/tr/development/README.md:
--------------------------------------------------------------------------------
1 | # development
2 |
3 |
--------------------------------------------------------------------------------
/tr/development/adapter.md:
--------------------------------------------------------------------------------
1 | # Adapter Development
2 |
3 | The role of the adapter is to achieve the conversion of the web framework context and GoAdmin's own context. To make a Adapter, you need implemente three methods:
4 |
5 | ```go
6 | package adapter
7 |
8 | import (
9 | "github.com/GoAdminGroup/go-admin/plugins"
10 | "github.com/GoAdminGroup/go-admin/template/types"
11 | )
12 |
13 | // WebFrameWork is a interface which is used as an adapter of
14 | // framework and goAdmin. It must implement two methods. Use registers
15 | // the routes and the corresponding handlers. Content writes the
16 | // response to the corresponding context of framework.
17 | type WebFrameWork interface {
18 | Use(interface{}, []plugins.Plugin) error
19 | Content(interface{}, types.GetPanel)
20 | }
21 | ```
22 |
23 | In addition to `Use` and `Content`, you need to implement `init`
24 |
25 | ## Use
26 |
27 | **Use** receives two parameters, the first parameter type is **interface{}**, which is the context of the web framework, and the second parameter is the plugin array. The return value is a **error**. The role of **Use** is to use the incoming plugin array to associate the routing of the web framework with the controller methods in the plugin array to implement the correspondence between the web framework and the GoAdmin plugin method. For example, in the plugin example:
28 |
29 | ```go
30 | "/admin/example" => ShowExample(ctx *context.Context)
31 | ```
32 |
33 | After processing by `Use`, it will be injected into the web framework.
34 |
35 | ## Content
36 |
37 | The **Content** method takes two arguments, the first argument type is **interface{}**, which is the context of the web framework, and the second argument is the **types.GetPanel** type.
38 |
39 | As follow:
40 |
41 | ```go
42 | type GetPanel func(ctx interface{}) (Panel, error)
43 | ```
44 |
45 | The role of **Content** is to pass the web framework's context when customizing the page, and then write the return of the custom page content to the web framework's context.
46 |
47 | ## init
48 |
49 | The **init** method injects the adapter into the engine so it can be used by others.
50 |
51 | ```go
52 | func init() {
53 | engine.Register(new(Beego))
54 | }
55 | ```
56 |
57 |
--------------------------------------------------------------------------------
/tr/development/code_style.md:
--------------------------------------------------------------------------------
1 | # Code Style
2 |
3 | ```text
4 | make lint
5 | ```
6 |
7 |
--------------------------------------------------------------------------------
/tr/development/plugins.md:
--------------------------------------------------------------------------------
1 | # Plugins Development
2 |
3 | Example:
4 |
5 |
6 | * [develop a plugin used by source code](https://github.com/GoAdminGroup/go-admin/blob/master/plugins/example/example.go)
7 | * [develop a plugin used by golang plugin](https://github.com/GoAdminGroup/go-admin/blob/master/plugins/example/go_plugin/main.go)
8 |
9 |
--------------------------------------------------------------------------------
/tr/development/template/README.md:
--------------------------------------------------------------------------------
1 | # template
2 |
3 |
--------------------------------------------------------------------------------
/tr/development/template/components.md:
--------------------------------------------------------------------------------
1 | # Components Development
2 |
3 | Component development, taking the image component as an example.
4 |
5 | ## New types and methods of upper interface
6 |
7 | * Create a new `ImgAttribute` type
8 |
9 | ```go
10 | type ImgAttribute interface {
11 | SetWidth(value string) ImgAttribute
12 | SetHeight(value string) ImgAttribute
13 | SetSrc(value string) ImgAttribute
14 | GetContent() template.HTML
15 | }
16 | ```
17 |
18 | * In the `Template` interface, add a method:
19 |
20 | ```go
21 | type Template interface {
22 | ...
23 | Image() types.ImgAttribute
24 | ...
25 | }
26 | ```
27 |
28 | ## Specific implementation, with `adminlte` as an example
29 |
30 | * `ImgAttribute`
31 |
32 | Create a new `image.go` file under `./template/adminlte/components`, as follows:
33 |
34 | ```go
35 | package components
36 |
37 | import (
38 | "github.com/GoAdminGroup/go-admin/template/types"
39 | "html/template"
40 | )
41 |
42 | type ImgAttribute struct {
43 | Name string
44 | Witdh string
45 | Height string
46 | Src string
47 | }
48 |
49 | func (compo *ImgAttribute) SetWidth(value string) types.ImgAttribute {
50 | compo.Witdh = value
51 | return compo
52 | }
53 |
54 | func (compo *ImgAttribute) SetHeight(value string) types.ImgAttribute {
55 | compo.Height = value
56 | return compo
57 | }
58 |
59 | func (compo *ImgAttribute) SetSrc(value string) types.ImgAttribute {
60 | compo.Src = value
61 | return compo
62 | }
63 |
64 | func (compo *ImgAttribute) GetContent() template.HTML {
65 | return ComposeHtml(compo.TemplateList, *compo, "image")
66 | }
67 | ```
68 |
69 | * `Image()`
70 |
71 | In `.template/adminlte/adminlte.go`, add a function:
72 |
73 | ```go
74 | func (*Theme) Image() types.ImgAttribute {
75 | return &components.ImgAttribute{
76 | Name: "image",
77 | Witdh: "50",
78 | Height: "50",
79 | Src: "",
80 | }
81 | }
82 | ```
83 |
84 | Still not completed here, you need to add static resource files.
85 |
86 | * Add the static resource file
87 |
88 | Add `image.tmpl` file to `.template/adminlte/resource/pages/components`
89 |
90 | Annoying, and the last step
91 |
92 | * Execute in the root directory:
93 |
94 | ```text
95 | adm assets
96 | ```
97 |
98 |
--------------------------------------------------------------------------------
/tr/development/template/form.md:
--------------------------------------------------------------------------------
1 | # Form Development
2 |
3 |
--------------------------------------------------------------------------------
/tr/development/template/template.md:
--------------------------------------------------------------------------------
1 | # Template Introducation
2 |
3 | The theme template is an abstract representation of ui, including a collection of components and static resources that are called in the plugin. The type in go-admin is `Template`, as follows:
4 |
5 | ```go
6 | type Template interface {
7 | // Components
8 | Form() types.FormAttribute
9 | Col() types.ColAttribute
10 | Table() types.TableAttribute
11 | DataTable() types.DataTableAttribute
12 | Row() types.RowAttribute
13 | Tree() types.TreeAttribute
14 | Paginator() types.PaginatorAttribute
15 | Label() types.LabelAttribute
16 | Image() types.ImgAttribute
17 | Alert() types.AlertAttribute
18 | Tabs() types.TabsAttribute
19 | Popup() types.PopupAttribute
20 |
21 | // Builder methods
22 | GetTmplList() map[string]string
23 | GetAssetList() []string
24 | GetAsset(string) ([]byte, error)
25 | GetTemplate(bool) (*template.Template, string)
26 | }
27 | ```
28 |
29 | To develop a ui theme template, you need to implement the above `Template` interface.
30 |
31 |
--------------------------------------------------------------------------------
/tr/install.md:
--------------------------------------------------------------------------------
1 | # Get Ready
2 |
3 | This program is based on `golang`. It is recommended to use `golang` with version higher than 1.11. Please visit: [https://golang.org](https://golang.org)
4 |
5 | ## Import the program required sql to the corresponding self-built database
6 |
7 | The contents of the sql file are the data tables required by the framework. Suppose your business database is: database\_a; then you can import the framework sql into `database_a`, or you can create another database `database_b` Import, can be a different driver database, for example, your business database is `mysql`, the framework database is `sqlite`. The framework currently supports multiple database connection operations. How to configure, will be described in detail later.
8 |
9 | * [mysql](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.sql)
10 | * [sqlite](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.db)
11 | * [postgresql](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.pgsql)
12 |
13 | ## Install command line tools
14 |
15 | Download the binary excecute file:
16 |
17 | | File name | OS | Arch | Size |
18 | | :--- | :--- | :--- | :--- |
19 | | [adm\_darwin\_x86\_64\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_darwin_x86_64_v1.0.6.zip) | macOs | x86-64 | 4.77 MB |
20 | | [adm\_linux\_x86\_64\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_linux_x86_64_v1.0.6.zip) | Linux | x86-64 | 6.52 MB |
21 | | [adm\_linux\_armel\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_linux_armel_v1.0.6.zip) | Linux | x86 | 6.06 MB |
22 | | [adm\_windows\_i386\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_windows_i386_v1.0.6.zip) | Windows | x86 | 6.16 MB |
23 | | [adm\_windows\_x86\_64\_v1.0.6.zip](http://file.go-admin.cn/go_admin/cli/v1_0_6/adm_windows_x86_64_v1.0.6.zip) | Windows | x86-64 | 6.38 MB |
24 |
25 | Or use the command:
26 |
27 | ```text
28 | go install github.com/GoAdminGroup/adm
29 | ```
30 |
31 | 🍺🍺 Get ready to work here, next to the [Quick start](https://github.com/GoAdminGroup/docs/tree/a7285aeef44a9fc42dbd84723277aec08f27d153/tr/quick_start/README.md)
32 |
33 | > English is not my main language. If any typo or wrong translation you found, you can help to translate in [github here](https://github.com/GoAdminGroup/docs). I will very appreciate it.
34 |
35 |
--------------------------------------------------------------------------------
/tr/pages/README.md:
--------------------------------------------------------------------------------
1 | # pages
2 |
3 |
--------------------------------------------------------------------------------
/tr/pages/components.md:
--------------------------------------------------------------------------------
1 | # Components
2 |
3 |
--------------------------------------------------------------------------------
/tr/pages/login.md:
--------------------------------------------------------------------------------
1 | # 更改登录界面
2 |
3 | 通过组件的方式可以修改登录界面,如下例子:
4 |
5 | 更多登录界面组件[看这里](https://github.com/GoAdminGroup/components/blob/master/login/README.md);加载后引入即可。
6 |
7 | ```go
8 | package main
9 |
10 | import (
11 | "github.com/GoAdminGroup/demo/ecommerce"
12 | "github.com/GoAdminGroup/demo/login"
13 | "github.com/GoAdminGroup/demo/pages"
14 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
15 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
16 | _ "github.com/GoAdminGroup/themes/adminlte"
17 | "github.com/GoAdminGroup/go-admin/engine"
18 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
19 | "github.com/GoAdminGroup/go-admin/plugins/admin"
20 | "github.com/GoAdminGroup/go-admin/plugins/example"
21 | "github.com/GoAdminGroup/go-admin/template"
22 | "github.com/GoAdminGroup/go-admin/template/types"
23 | "github.com/gin-gonic/gin"
24 | )
25 |
26 | func main() {
27 | r := gin.Default()
28 |
29 | eng := engine.Default()
30 |
31 | // 增加登录组件
32 | template.AddLoginComp(login.GetLoginComponent())
33 |
34 | // you can custom a plugin like:
35 |
36 | examplePlugin := example.NewExample()
37 |
38 | rootPath := "/data/www/go-admin"
39 |
40 | if err := eng.AddConfigFromJson(rootPath+"/config.json").
41 | AddGenerators(datamodel.Generators).
42 | AddGenerator("user", datamodel.GetUserTable).
43 | AddPlugins(examplePlugin).
44 | Use(r); err != nil {
45 | panic(err)
46 | }
47 |
48 | r.Static("/uploads", rootPath+"/uploads")
49 |
50 | _ = r.Run(":9033")
51 | }
52 | ```
53 |
54 |
--------------------------------------------------------------------------------
/tr/pages/modules.md:
--------------------------------------------------------------------------------
1 | # Page Modules
2 |
3 | Page customization needs to call the engine's `Content` method, which needs to return an object `types.Panel`
4 |
5 | The following is the definition of `types.Panel`:
6 |
7 | ```go
8 | type Panel struct {
9 | Content template.HTML
10 | Title string
11 | Description string
12 | Url string
13 | }
14 | ```
15 |
16 | Corresponding ui, you can see the following picture:
17 |
18 | 
19 |
20 | ## How to use
21 |
22 | ```go
23 | package datamodel
24 |
25 | import (
26 | "github.com/GoAdminGroup/go-admin/modules/config"
27 | template2 "github.com/GoAdminGroup/go-admin/template"
28 | "github.com/GoAdminGroup/go-admin/template/types"
29 | "html/template"
30 | )
31 |
32 | func GetContent() (types.Panel, error) {
33 |
34 | components := template2.Get(config.Get().THEME)
35 | colComp := components.Col()
36 |
37 | infobox := components.InfoBox().
38 | SetText("CPU TRAFFIC").
39 | SetColor("blue").
40 | SetNumber("41,410").
41 | SetIcon("ion-ios-gear-outline").
42 | GetContent()
43 |
44 | var size = map[string]string{"md": "3", "sm": "6", "xs": "12"}
45 | infoboxCol1 := colComp.SetSize(size).SetContent(infobox).GetContent()
46 | row1 := components.Row().SetContent(infoboxCol1).GetContent()
47 |
48 | return types.Panel{
49 | Content: row1,
50 | Title: "Dashboard",
51 | Description: "this is a example",
52 | }, nil
53 | }
54 | ```
55 |
56 | ## Col
57 |
58 | A col is type of `ColAttribute`, has three methods:
59 |
60 | ```go
61 | type ColAttribute interface {
62 | SetSize(value map[string]string) ColAttribute
63 | SetContent(value template.HTML) ColAttribute
64 | GetContent() template.HTML
65 | }
66 | ```
67 |
68 | About the `size`,example is `map[string]string{"md": "3", "sm": "6", "xs": "12"}`
69 |
70 | ## Row
71 |
72 | A row is type of `RowAttribute`, has two methods:
73 |
74 | ```go
75 | type RowAttribute interface {
76 | SetContent(value template.HTML) RowAttribute
77 | GetContent() template.HTML
78 | }
79 | ```
80 |
81 |
--------------------------------------------------------------------------------
/tr/pages/pages.md:
--------------------------------------------------------------------------------
1 | # Customize your page
2 |
3 | call the method `Content`of the engine:
4 |
5 | ```go
6 | package main
7 |
8 | import (
9 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
10 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
11 | _ "github.com/GoAdminGroup/themes/adminlte"
12 | "github.com/GoAdminGroup/go-admin/engine"
13 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
14 | "github.com/GoAdminGroup/go-admin/modules/config"
15 | "github.com/GoAdminGroup/go-admin/plugins/admin"
16 | "github.com/GoAdminGroup/go-admin/plugins/example"
17 | "github.com/GoAdminGroup/go-admin/template/types"
18 | "github.com/gin-gonic/gin"
19 | )
20 |
21 | func main() {
22 | r := gin.Default()
23 |
24 | eng := engine.Default()
25 |
26 | cfg := config.Config{}
27 |
28 | examplePlugin := example.NewExample()
29 |
30 | if err := eng.AddConfig(cfg).
31 | AddGeneratos(datamodel.Generators).
32 | AddPlugins(examplePlugin).
33 | Use(r); err != nil {
34 | panic(err)
35 | }
36 |
37 | r.Static("/uploads", "./uploads")
38 |
39 | // here to custom a page.
40 |
41 | r.GET("/"+cfg.PREFIX+"/custom", func(ctx *gin.Context) {
42 | engine.Content(ctx, func() (types.Panel, error) {
43 | return datamodel.GetContent()
44 | })
45 | })
46 |
47 | r.Run(":9033")
48 | }
49 | ```
50 |
51 | `Content`will write the contents into the `context` of the framework.
52 |
53 | here is the code of `GetContent`:
54 |
55 | ```go
56 | package datamodel
57 |
58 | import (
59 | "github.com/GoAdminGroup/go-admin/modules/config"
60 | template2 "github.com/GoAdminGroup/go-admin/template"
61 | "github.com/GoAdminGroup/go-admin/template/types"
62 | "html/template"
63 | )
64 |
65 | func GetContent() (types.Panel, error) {
66 |
67 | components := template2.Get(config.Get().THEME)
68 | colComp := components.Col()
69 |
70 | infobox := components.InfoBox().
71 | SetText("CPU TRAFFIC").
72 | SetColor("blue").
73 | SetNumber("41,410").
74 | SetIcon("ion-ios-gear-outline").
75 | GetContent()
76 |
77 | var size = map[string]string{"md": "3", "sm": "6", "xs": "12"}
78 | infoboxCol1 := colComp.SetSize(size).SetContent(infobox).GetContent()
79 | row1 := components.Row().SetContent(infoboxCol1).GetContent()
80 |
81 | return types.Panel{
82 | Content: row1,
83 | Title: "Dashboard",
84 | Description: "this is a example",
85 | }, nil
86 | }
87 | ```
88 |
89 |
--------------------------------------------------------------------------------
/tr/plan.md:
--------------------------------------------------------------------------------
1 | # 发展计划
2 |
3 | GoAdmin的定位不只是一个管理后台中心构建框架,目前在1.0基础版本已经实现了一个能快速构建简单的crud以及有权限管理功能的管理后台的基础构建框架。在此基础上,可以对主题以及插件等进行一定程度的定制。以下分三点阐述这个项目以后的发展计划:
4 |
5 | ## 项目功能规划
6 |
7 | GoAdmin的目标是实现无代码化或某种程度的无代码化可视化操作,内置插件会至少包括:简单与复杂商业化crud管理中心极速构建,支持多数据源的监控体系的搭建等等。以下是对版本的初步规划:
8 |
9 | ### 1.0.0 版本
10 |
11 | * 实现基础的框架,同时提供一个内置插件能够满足快速构建crud管理后台。
12 | * 这个基础框架可以实现前端主题的自由定制,以及对插件的加载。
13 |
14 | ### 2.0.0 版本
15 |
16 | * 在 1.0 版本的基础上,此版本将完善内置插件的功能,基本达到商业化水平(能够提供一个ec商城后台/saas系统的所有功能)
17 | * 完善主题和插件的开发工具链,使得非项目开发人员都能够轻松的上手主题与插件的开发
18 | * 提供更多样化的内置主题与内置插件
19 | * 监控体系的初步支持(实时监控系统,数据前端展示,定制数据源)
20 | * 项目性能的评估与优化
21 |
22 | ### 3.0.0 版本
23 |
24 | * 可生产环境商业化的监控体系支持
25 | * 初步实现界面数据化以及实现一个界面拖拽定制框架
26 |
27 | ### 4.0.0 版本
28 |
29 | * 实现无代码化的界面拖拽框架
30 |
31 | ## 人才社区构建
32 |
33 | GoAdmin项目需要更多的人才一同加入。
34 |
35 | 目前由我 [@cg33](https://github.com/chenhg5) 一人维护此项目,本人是国内某知名985/211大学计算机系本科毕业,两年的gopher。
36 |
37 | 目前项目需要的工作有:
38 |
39 | * [项目开发](https://github.com/GoAdminGroup/go-admin),需掌握一定的`golang`开发能力
40 | * 社区项目开发(暂未开源,暂不对外开放)
41 | * [文档的维护改进与翻译](https://github.com/GoAdminGroup/docs)
42 | * 项目的宣传与社区文化的组织
43 |
44 | GoAdmin始终秉持开放开源的态度,欢迎有志有能力之士加入一块共谋项目和社区的发展,社区与个人相辅相成。
45 |
46 | 如果你看好GoAdmin的发展,并且愿意为他赌一把,用时间换取未来可能的财务或名誉度回报,而且你对你自己的能力有足够信心,那么你可以尝试充分阅读GoAdmin的代码,并理解GoAdmin的发展规划,为此做出你的贡献。前期代码缺陷漏洞大,可修改空间多,如果你有能力做出足够的贡献,将成为项目的**联合创始人**或**核心开发者**。到后期,代码完善度高,也仍然有改进空间,你可以通过提交修复成为**贡献者**。团队将会一直保持开放态度,接纳新成员。团队每一个付出努力的成员也会在将来根据付出比例公平地去收获项目给大家带来的一定的回报。
47 |
48 | 如果你没有足够的时间和精力,但有一定的资金,且同样看好GoAdmin发展,虽然GoAdmin尚未就此加入的方案拟定计划。但只要你有足够大的兴趣,也可以带上你的计划与我们进行洽谈。
49 |
50 | ## 商业项目计划
51 |
52 | GoAdmin会逐步实现商业化,但核心基础功能是免费开源的。 GoAdmin的资金收入模式主要是:
53 |
54 | * 接受捐助
55 | * 售卖主题
56 | * 售卖插件
57 | * 提供saas定制化开发
58 | * 提供收费的商业化版本
59 |
60 | 收入资金主要用于维护社区的发展,与开发人员的薪酬回报,促使项目更好的成长。
61 |
62 |
--------------------------------------------------------------------------------
/tr/plugins/README.md:
--------------------------------------------------------------------------------
1 | # plugins
2 |
3 |
--------------------------------------------------------------------------------
/tr/plugins/plugins.md:
--------------------------------------------------------------------------------
1 | # How To Use Plugins
2 |
3 | The framework's plugins include: controllers, routing, and views. The specific plug-in development will be discussed in the project development part, here just show you how to use it.
4 |
5 | The example plugin is our demo.
6 |
7 | Using plugins are divided into: using the third package source code plugin and use the dynamic link library plugin \(.so file, currently only supports linux and mac platforms\)
8 |
9 | ## Using the third package source code plugin
10 |
11 | For example:
12 |
13 | ```go
14 | package main
15 |
16 | import (
17 | "github.com/gin-gonic/gin"
18 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
19 | _ "github.com/GoAdminGroup/themes/adminlte"
20 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
21 | "github.com/GoAdminGroup/go-admin/engine"
22 | "github.com/GoAdminGroup/go-admin/plugins/admin"
23 | "github.com/GoAdminGroup/go-admin/plugins/example"
24 | "github.com/GoAdminGroup/go-admin/modules/config"
25 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
26 | )
27 |
28 | func main() {
29 | r := gin.Default()
30 | eng := engine.Default()
31 | cfg := config.Config{}
32 |
33 | adminPlugin := admin.NewAdmin(datamodel.Generators)
34 | examplePlugin := example.NewExample()
35 |
36 | eng.AddConfig(cfg).
37 | AddPlugins(adminPlugin, examplePlugin). // loading
38 | Use(r)
39 |
40 | r.Run(":9033")
41 | }
42 | ```
43 |
44 | ## Using the binary plugin
45 |
46 | Load the `.so`file, and call`plugins.LoadFromPlugin`.
47 |
48 | 如:
49 |
50 | ```go
51 | package main
52 |
53 | import (
54 | "github.com/gin-gonic/gin"
55 | _ "github.com/GoAdminGroup/go-admin/adapter/gin"
56 | _ "github.com/GoAdminGroup/themes/adminlte" // Import the theme
57 | _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
58 | "github.com/GoAdminGroup/go-admin/engine"
59 | "github.com/GoAdminGroup/go-admin/plugins/admin"
60 | "github.com/GoAdminGroup/go-admin/plugins"
61 | "github.com/GoAdminGroup/go-admin/modules/config"
62 | "github.com/GoAdminGroup/go-admin/examples/datamodel"
63 | )
64 |
65 | func main() {
66 | r := gin.Default()
67 | eng := engine.Default()
68 | cfg := config.Config{}
69 |
70 | adminPlugin := admin.NewAdmin(datamodel.Generators)
71 |
72 | // load plugin from .so file.
73 | examplePlugin := plugins.LoadFromPlugin("../datamodel/example.so")
74 |
75 | eng.AddConfig(cfg).
76 | AddPlugins(adminPlugin, examplePlugin).
77 | Use(r)
78 |
79 | r.Run(":9033")
80 | }
81 | ```
82 |
83 |
--------------------------------------------------------------------------------
/zh/README.md:
--------------------------------------------------------------------------------
1 | # 介绍
2 | ------
3 |
4 | GoAdmin是一个基于 golang 面向生产的数据可视化管理平台搭建框架,可以让你使用简短的代码在极短时间内搭建起一个管理后台。
5 |
6 | 一般开发一套管理后台需要至少一个后台工程师,一个前端工程师,花费至少一周时间才能搭建完成,搭建完成后我们需要分别去部署前端代码和后端代码。
7 | 而利用 GoAdmin,只需要一名golang后端工程师。在先花一点点时间了解掌握GoAdmin后,即可开发好一个面向生产环境的管理后台。而且所有的框架代码(包括前端文件)都将编译成一个二进制文件,直接部署到正式服务器即可运行,测试分发和部署十分便捷。
8 |
9 | 在功能需求方面,GoAdmin目前内置支持对主流SQL数据库(mysql/postgresql/sqlite/mssql)增删改查的管理插件,更多的[功能插件](https://www.go-admin.cn/plugins)如:服务器文件管理,数据监控系统等等会陆续开发并开放。
10 |
11 | 对于前端个性化需求,GoAdmin目前官方免费支持Adminlte、Sword两个主题,更多[主题](https://www.go-admin.cn/themes)正在制作中以及对应更多的登录界面组件也在制作中,敬请期待。
12 |
13 | ## 特性
14 |
15 | - 内置完善的rbac权限系统
16 | - 支持多个web框架接入
17 | - 本地化支持
18 | - 整个系统可以编译成一个二进制文件
19 | - 提供多个插件(开发中)
20 | - 多个好看的ui主题(更多主题开发中)
21 |
22 | ## 在线Demo
23 |
24 | [https://demo.go-admin.cn](https://demo.go-admin.cn/admin/login)
25 |
26 | ## 依赖
27 |
28 | - [Datetimepicker](http://eonasdan.github.io/bootstrap-datetimepicker/)
29 | - [font-awesome](http://fontawesome.io/)
30 | - [bootstrap-fileinput](https://github.com/kartik-v/bootstrap-fileinput)
31 | - [jquery-pjax](https://github.com/defunkt/jquery-pjax)
32 | - [Nestable](http://dbushell.github.io/Nestable/)
33 | - [toastr](http://codeseven.github.io/toastr/)
34 | - [bootstrap-number-input](https://github.com/wpic/bootstrap-number-input)
35 | - [fontawesome-iconpicker](https://github.com/itsjavi/fontawesome-iconpicker)
36 |
37 | ## 社区
38 |
39 | ⚠️ 为了避免发广告及不看文档用户,请先到Github star此项目,然后附上Github账号(非邮箱)申请入群,没备注不通过。
40 |
41 | 在社区中如有问题提问,请务必清晰描述,包括但不限于**问题详叙/问题代码/复现方法/已经尝试过的方法**,时间生命可贵,请珍惜自己和别人的时间!
42 |
43 | **QQ群**
44 |
45 | 一群:756664859(已满)
46 |
47 | 二群:874825430(已满)
48 |
49 | 三群:641768714(已满)
50 |
51 | 四群:[694446792](https://qm.qq.com/q/bp3hsYyUzS)
52 |
53 | **微信群**
54 |
55 | 添加以下个人微信,并备注加GoAdmin开发交流群。同时如果有意向加入一起开发框架,成为框架的贡献者,也可以联系我(^^)。
56 |
57 |
58 |
59 | **论坛**
60 |
61 | [https://discuss.go-admin.com/](https://discuss.go-admin.com/)
62 |
63 | ## 捐赠
64 |
65 | 开发软件不易,您的支持会帮助我更好的去完善项目,备注或告知我您的 github/gitee 用户名。
66 | 会根据意愿在[网站](http://www.go-admin.cn/donation)中列出捐赠者名单。🙏
67 | 帮忙分享给好友或是在各个在线软件交流平台发布教程也是一种支持!
68 |
69 |
70 |
71 | > 目前GoAdmin项目捐赠达666元,联系作者可进vip用户群,vip群中您的问题将得到优先解答,同时也会根据您的需求进行分析和优先安排,vip群也会提供其他关于golang的福利。
72 | >
73 | > 同时您也可以联系我,雇佣我的时间帮助您干活。
74 |
--------------------------------------------------------------------------------
/zh/admin/api.md:
--------------------------------------------------------------------------------
1 | # API 说明
2 | ---
3 |
4 | admin插件可以通过配置全局配置项```OpenAdminApi```为true,打开JSON API。包括对表格的增删改查,导出。目前仅支持使用Cookie进行认证。
5 |
6 | ## 查询表格信息
7 |
8 | **方法:** GET
9 | **路径:** /api/list/:__prefix
10 | **参数:**
11 |
12 | | 参数名 | 参数解释 | 取值 | 例子 |
13 | | ---- | ---- | ---- | ---- |
14 | | __prefix | 模型路由前缀 | - | user |
15 | | __is_all | 是否获取全部 | true/false | true |
16 | | __page | 当面页码 | 整数 | 1 |
17 | | __pageSize | 页面数据数 | 整数 | 1 |
18 | | __sort | 排序字段 | 字段 | id |
19 | | __sort_type | 排序类型 | desc/asc | asc |
20 | | __columns | 隐藏的字段 | 字段以逗号分割 | name,city |
21 | | name | 不以__开头参数都是筛选字段 | 筛选的值 | jack |
22 | | name__goadmin_operator__ | 字段拼接上__goadmin_operator__为筛选的操作 | like,gr,gq,eq,ne,le,lq,free | like |
23 |
24 | 操作符代表意思:
25 |
26 | | 操作符 | 含义 |
27 | | ---- | ---- |
28 | | like | like |
29 | | gr | > |
30 | | gq | >= |
31 | | eq | = |
32 | | ne | != |
33 | | le | < |
34 | | lq | <= |
35 | | free | free |
36 |
37 | **返回:**
38 |
39 | ```
40 | todo
41 | ```
42 |
43 | **例子:**
44 |
45 | ```
46 | todo
47 | ```
48 |
49 | ## 查询表格详情
50 |
51 | **方法:** GET
52 | **路径:** /api/detail/:__prefix
53 | **参数:**
54 |
55 | | 参数名 | 参数解释 | 取值 | 例子 |
56 | | ---- | ---- | ---- | ---- |
57 | | __prefix | 模型路由前缀 | - | user |
58 | | __goadmin_detail_pk | 主键值 | - | 3 |
59 |
60 | **返回:**
61 |
62 | ```
63 | todo
64 | ```
65 |
66 | **例子:**
67 |
68 | ```
69 | todo
70 | ```
71 |
72 | ## 删除表格内容
73 |
74 | **方法:** POST
75 | **头部:** content-type: multipart/form-data
76 | **路径:** /api/delete/:__prefix
77 | **参数:**
78 |
79 | | 参数名 | 参数解释 | 取值 | 例子 |
80 | | ---- | ---- | ---- | ---- |
81 | | __prefix | 模型路由前缀 | - | user |
82 | | id | 主键值 | - | 3 |
83 |
84 |
85 | **返回:**
86 |
87 | ```
88 | todo
89 | ```
90 |
91 | **例子:**
92 |
93 | ```
94 | todo
95 | ```
96 |
97 | ## 更新表格单个记录内容
98 |
99 | **方法:** GET
100 | **头部:** content-type: multipart/form-data
101 | **路径:** /api/update/:__prefix
102 | **参数:**
103 |
104 | | 参数名 | 参数解释 | 取值 | 例子 |
105 | | ---- | ---- | ---- | ---- |
106 | | __prefix | 模型路由前缀 | - | user |
107 | | pk | 主键值 | - | 3 |
108 | | name | 要更新字段 | - | name |
109 | | value | 要更新字段的值 | - | Jack |
110 |
111 |
112 | **返回:**
113 |
114 | ```
115 | todo
116 | ```
117 |
118 | **例子:**
119 |
120 | ```
121 | todo
122 | ```
123 |
124 |
125 | ## 获取更新表单内容
126 |
127 | **方法:** GET
128 | **路径:** /api/edit/form/:__prefix
129 | **参数:**
130 |
131 | | 参数名 | 参数解释 | 取值 | 例子 |
132 | | ---- | ---- | ---- | ---- |
133 | | __prefix | 模型路由前缀 | - | user |
134 | | __goadmin_edit_pk | 主键值 | - | 3 |
135 |
136 |
137 | **返回:**
138 |
139 | ```
140 | todo
141 | ```
142 |
143 | **例子:**
144 |
145 | ```
146 | todo
147 | ```
148 |
149 |
150 | ## 更新表格
151 |
152 | **方法:** GET
153 | **路径:** /api/edit/:__prefix
154 | **参数:**
155 |
156 | | 参数名 | 参数解释 | 取值 | 例子 |
157 | | ---- | ---- | ---- | ---- |
158 | | __prefix | 模型路由前缀 | - | user |
159 | | __goadmin_edit_pk | 主键值 | - | 3 |
160 |
161 |
162 | **返回:**
163 |
164 | ```
165 | todo
166 | ```
167 |
168 | **例子:**
169 |
170 | ```
171 | todo
172 | ```
173 |
174 |
175 | ## 获取创建表单内容
176 |
177 | **方法:** GET
178 | **路径:** /api/create/form/:__prefix
179 | **参数:**
180 |
181 | | 参数名 | 参数解释 | 取值 | 例子 |
182 | | ---- | ---- | ---- | ---- |
183 | | __prefix | 模型路由前缀 | - | user |
184 |
185 |
186 | **返回:**
187 |
188 | ```
189 | todo
190 | ```
191 |
192 | **例子:**
193 |
194 | ```
195 | todo
196 | ```
197 |
198 |
199 | ## 创建表格
200 |
201 | **方法:** GET
202 | **路径:** /api/create/:__prefix
203 | **参数:**
204 |
205 | | 参数名 | 参数解释 | 取值 | 例子 |
206 | | ---- | ---- | ---- | ---- |
207 | | __prefix | 模型路由前缀 | - | user |
208 |
209 |
210 | **返回:**
211 |
212 | ```
213 | todo
214 | ```
215 |
216 | **例子:**
217 |
218 | ```
219 | todo
220 | ```
221 |
222 |
223 | ## 导出表格内容
224 |
225 | **方法:** GET
226 | **路径:** /api/export/:__prefix
227 | **参数:**
228 |
229 | | 参数名 | 参数解释 | 取值 | 例子 |
230 | | ---- | ---- | ---- | ---- |
231 | | __prefix | 模型路由前缀 | - | user |
232 | | is_all | 是否导出全部 | true/false | true |
233 | | id | 导出记录id,逗号分割 | - | 3,4,5 |
234 |
235 |
236 | **返回:**
237 |
238 | ```
239 | todo
240 | ```
241 |
242 | **例子:**
243 |
244 | ```
245 | todo
246 | ```
--------------------------------------------------------------------------------
/zh/admin/auth.md:
--------------------------------------------------------------------------------
1 | # 自定义认证用户表
2 | ---
3 |
4 | 官方提供的管理用户表是最基本的信息,如果你需要自定义很多信息,比如管理用户的手机/IP/性别等等。那么你可以自定义认证用户表来实现。
5 |
6 | 首先你需要准备好自己的用户表,比方说叫:goadmin_super_manager。然后在全局配置中修改配置```auth_user_table```为goadmin_super_manager,接着生成数据模型文件,覆盖掉官方的用户表模型文件。如下:
7 |
8 | **注意:用户表字段保持跟官方一致,然后在官方用户表基础上进行字段扩展。**
9 |
10 | ```go
11 | import (
12 | ...
13 | "github.com/GoAdminGroup/go-admin/engine"
14 | ...
15 | )
16 |
17 | func main() {
18 |
19 | ...
20 |
21 | eng := engine.Default()
22 |
23 | cfg := config.Config{
24 | ...
25 | AuthUserTable: "goadmin_super_manager",
26 | ...
27 | }
28 |
29 | if err := eng.AddConfig(cfg).
30 | // 超级管理员访问,数据模型文件逻辑可以参考官方:https://github.com/GoAdminGroup/go-admin/blob/master/plugins/admin/modules/table/generators.go#L40
31 | AddGenerator("manager", GetGoAdminSuperManager).
32 | // 普通用户访问
33 | AddGenerator("normal_manager", GetGoAdminSuperNormalManager).
34 | ...
35 | Use(r); err != nil {
36 | panic(err)
37 | }
38 |
39 | ...
40 |
41 | }
42 | ```
--------------------------------------------------------------------------------
/zh/admin/cdn.md:
--------------------------------------------------------------------------------
1 | # 设置cdn
2 | ---
3 |
4 | 为您的网站设置cdn,需要将静态资源放置到您的cdn网站上。
5 |
6 | 官方内置主题的静态资源:
7 |
8 | - [adminlte](https://github.com/GoAdminGroup/themes/tree/master/adminlte/resource/assets/dist)
9 | - [sword](https://github.com/GoAdminGroup/themes/tree/master/sword/resource/assets/dist)
10 |
11 | 放到cdn后,需保留assets/dist文件夹。也就说如果你的cdn地址是:https://xxxx-cdn.xxxx.com,那么资源请求地址就是:https://xxxx-cdn.xxxx.com/assets/dist/css/..../xxxx.css
12 |
13 | 要生效还需要设置全局配置中的:asset_url项。
--------------------------------------------------------------------------------
/zh/admin/cli.md:
--------------------------------------------------------------------------------
1 | # 命令行工具介绍
2 | ---
3 |
4 | GoAdmin提供了一个命令行工具,以提高开发效率,简化开发流程。
5 |
6 | ## 安装
7 |
8 |
9 | 下载对应系统的二进制文件到本地:
10 |
11 | | File name | OS | Arch | Size |
12 | | ---- | ---- | ---- |---- |
13 | | [adm_darwin_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_darwin_x86_64_v1.2.24.zip) | macOs | x86-64 | 4.77 MB
14 | | [adm_linux_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_x86_64_v1.2.24.zip) | Linux | x86-64 | 6.52 MB
15 | | [adm_linux_armel_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_linux_armel_v1.2.24.zip) | Linux | x86 | 6.06 MB
16 | | [adm_windows_i386_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_i386_v1.2.24.zip) | Windows | x86 |6.16 MB
17 | | [adm_windows_x86_64_v1.2.24.zip](http://file.go-admin.cn/go_admin/cli/v1_2_24/adm_windows_x86_64_v1.2.24.zip) | Windows | x86-64 |6.38 MB
18 |
19 |
20 | 或使用命令安装:
21 |
22 | ```
23 | go install github.com/GoAdminGroup/adm
24 | ```
25 |
26 | ## 使用
27 |
28 | ```
29 | adm --help
30 | ```
31 |
32 | 会列出帮助信息。
33 |
34 | | 命令名 | 子命令名 | 选项 | 功能 |
35 | | ---- | ---- | ---- | ---- |
36 | | generate | - | - | 生成数据模型文件
37 | | compile | asset| **-s, --src** 输入前端资源文件夹路径 **-d, --dist** 输出合并go文件路径 **p, --package** 输出go文件包名 | 编译所有资源文件为一个go文件
38 | | compile | tpl | **-s, --src** 输入golang tmpl模板文件夹路径 **-d, --dist** 输出合并模板go文件路径 **p, --package** 输出合并模板go文件包名 | 编译所有模板文件为一个go文件
39 | | combine | css| **-s, --src** 输入css文件夹路径 **-d, --dist** 输出合并css文件路径 | 合并css文件为一个css文件
40 | | combine | js | **-s, --src** 输入js文件夹路径 **-d, --dist** 输出合并js文件路径 | 合并js文件为一个js文件
41 | | develop | tpl | **-m, --module** golang模块名或$GOPATH下的路径 **-n, --name** 主题名 | 远程拉取主题开发模板到本地
42 |
43 | 在命令前加上 -v 选项会开启调试模式,如果出现错误会打印出错误信息。
44 | 在命令后加上 -l=cn 可以设置为中文。如:```adm generate -l cn```
45 |
46 | ## 配置文件
47 |
48 | 设置配置文件,使得不需要每次生成模型或执行别的命令行操作时都输入很多信息,更方便使用。
49 |
50 | adm 使用 ini 文件作为配置文件格式。如:
51 |
52 | ```ini
53 | ; 默认数据库配置
54 | ; 等价于 [database.default]
55 | ; 点之后代表连接名,因此 [database.default] 代表默认连接
56 | [database]
57 | driver = sqlite ; 驱动
58 | file = ./admin.db ; 文件
59 | database = goadmin ; 数据库名
60 | ; 新的待生成的表格
61 | tables = new_table1,new_table2
62 |
63 | ; 指定数据库配置
64 | ; 连接名为 mydb 的数据库配置
65 | ;[database.mydb]
66 |
67 | ; 数据模型文件设置
68 | [model]
69 | package = main ; 包名
70 | connection = default ; 连接
71 | output = ./tables ; 输出文件夹
72 | ```
73 |
74 | 设置好配置文件后,这样子去使用:```adm generate -l=cn -c=./adm.ini```
75 |
76 |
77 |
--------------------------------------------------------------------------------
/zh/admin/file.md:
--------------------------------------------------------------------------------
1 | # 文件上传
2 | ---
3 |
4 | GoAdmin默认提供一个本地文件上传引擎,支持将文件上传到服务器。使用需要在全局配置中设置上传的目录,以及上传文件访问的前缀。
5 |
6 | ```go
7 | package config
8 |
9 | // 存储目录:存储头像等上传文件
10 | type Store struct {
11 | Path string // 相对或绝对路径,文件会存储到这里
12 | Prefix string // 访问前缀
13 | }
14 |
15 | type Config struct {
16 |
17 | ...
18 |
19 | // 上传文件存储的位置
20 | Store Store `json:"store"`
21 |
22 | // 文件上传引擎
23 | FileUploadEngine FileUploadEngine `json:"file_upload_engine"`
24 |
25 | ...
26 | }
27 |
28 | type FileUploadEngine struct {
29 | Name string
30 | Config map[string]interface{}
31 | }
32 |
33 | // UploadFun is a function to process the uploading logic.
34 | type UploadFun func(*multipart.FileHeader, string) (string, error)
35 | ```
36 |
37 | 如果你想要自定义上传位置,比如上传到又拍云,七牛云等云平台,那么你需要自己写一个上传引擎。下面介绍如何自己写引擎:
38 |
39 | ### 引擎的类型
40 |
41 | ```go
42 | package file
43 |
44 | // 上传引擎
45 | type Uploader interface {
46 | Upload(*multipart.Form) error
47 | }
48 |
49 | // 上传引擎生成函数
50 | type UploaderGenerator func() Uploader
51 |
52 | // 增加引擎接口api
53 | func AddUploader(name string, up UploaderGenerator) {
54 | ...
55 | }
56 | ```
57 |
58 | ### 调用
59 |
60 | 我们需要调用**AddUploader**方法来增加一个上传引擎,第一个参数是引擎的名字(将在全局配置中用到),第二参数就是引擎生成函数。
61 |
62 | 假设我们要增加一个七牛云上传引擎,那么可以类似这样:
63 |
64 | ```go
65 | package main
66 |
67 | import (
68 | ...
69 | "github.com/GoAdminGroup/go-admin/modules/file"
70 | ...
71 | )
72 |
73 | type QiNiuUploader struct {
74 | Bucket string
75 | Region string
76 | SecretId string
77 | SecretKey string
78 |
79 | Prefix string
80 | Path string
81 | }
82 |
83 | func (q QiNiuUploader) Upload(form *multipart.Form) error {
84 | // 接收一个表单类型,这里实现上传逻辑
85 | // 这里调用框架的辅助函数
86 | file.Upload(func(*multipart.FileHeader, string) (string, error){
87 | // 这里实现上传逻辑,返回文件路径与错误信息
88 | }, form)
89 | }
90 |
91 | func main() {
92 |
93 | ...
94 |
95 | file.AddUploader("qiniu", func() file.Uploader {
96 | return &QiNiuUploader{
97 | Bucket: config.Get().FileUploadEngine.Config["bucket"].(string),
98 | Region: config.Get().FileUploadEngine.Config["region"].(string),
99 | SecretId: config.Get().FileUploadEngine.Config["secret_id"].(string),
100 | SecretKey: config.Get().FileUploadEngine.Config["secret_key"].(string),
101 | Prefix: config.Get().FileUploadEngine.Config["prefix"].(string),
102 | Path: config.Get().FileUploadEngine.Config["path"].(string),
103 | }
104 | })
105 |
106 | cfg := config.Config{
107 | ...
108 |
109 | FileUploadEngine: config.FileUploadEngine{
110 | Name: "qiniu",
111 | Config: map[string]interface{}{
112 | "bucket": "xxx",
113 | "region": "xxx",
114 | "secret_id": "xxx",
115 | "secret_key": "xxx",
116 | "prefix": "xxx",
117 | "path": "xxx",
118 | },
119 | }
120 |
121 | ...
122 | }
123 |
124 | ...
125 | }
126 | ```
127 |
128 | 这样就实现一个七牛云上传文件引擎了!🍺🍺
--------------------------------------------------------------------------------
/zh/admin/form/basic.md:
--------------------------------------------------------------------------------
1 | # 基本使用
2 | ---
3 |
4 | 使用命令行将sql表生成一个数据表单类型,如:
5 |
6 | ```sql
7 | CREATE TABLE `users` (
8 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
9 | `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
10 | `gender` tinyint(4) DEFAULT NULL,
11 | `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
12 | `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
13 | `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
14 | `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
15 | `updated_at` timestamp NULL DEFAULT NULL,
16 | PRIMARY KEY (`id`)
17 | ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
18 | ```
19 |
20 | 生成了:
21 |
22 | ```go
23 | package datamodel
24 |
25 | import (
26 | ...
27 | )
28 |
29 | func GetUserTable(ctx *context.Context) (userTable table.Table) {
30 |
31 | // config the table model.
32 | userTable = table.NewDefaultTable(...)
33 |
34 | ...
35 |
36 | formList := userTable.GetForm()
37 |
38 | // set id editable is false.
39 | formList.AddField("ID", "id", db.Int, form.Default).FieldNotAllowEdit()
40 | formList.AddField("Ip", "ip", db.Varchar, form.Text)
41 | formList.AddField("Name", "name", db.Varchar, form.Text)
42 |
43 | ...
44 |
45 | return
46 | }
47 | ```
48 |
49 | ## 类型
50 |
51 | - 默认,只显示 ```Default```
52 | - 普通文本 ```Text```
53 | - 单选 ```SelectSingle```
54 | - 密码 ```Password```
55 | - 富文本 ```RichText```
56 | - 文件 ```File```
57 | - 双选择框 ```SelectBox```
58 | - 多选 ```Select```
59 | - icon下拉选择框 ```IconPicker```
60 | - 时间选择框 ```Datetime```
61 | - radio选择框 ```Radio```
62 | - email输入框 ```Email```
63 | - url输入框 ```Url```
64 | - ip输入框 ```Ip```
65 | - 颜色选择框 ```Color```
66 | - 货币输入框 ```Currency```
67 | - 数字输入框 ```Number```
68 |
69 | 例子:
70 |
71 | ```go
72 |
73 | import (
74 | ...
75 | "github.com/GoAdminGroup/go-admin/template/types/form"
76 | ...
77 | )
78 |
79 | func GetxxxTable(ctx *context.Context) table.Table {
80 | formList.AddField("ID", "id", db.Int, form.Default)
81 | }
82 |
83 | ```
84 |
85 | ## 操作
86 |
87 | ### 添加字段
88 |
89 | ```go
90 |
91 | // 添加一个字段,字段标题为 ID,字段名为 id,字段类型为 int,表单类型为 Default
92 | formList.AddField("ID", "id", db.Int, form.Default)
93 |
94 | // 添加第二个字段,字段标题为 Ip,字段名为 ip,字段类型为 varchar,表单类型为 Text
95 | formList.AddField("Ip", "ip", db.Varchar, form.Text)
96 |
97 | // 添加第三个字段,一个sql表不存在的字段
98 | formList.AddField("Custom", "custom", db.Varchar, form.Text)
99 |
100 | ```
101 |
102 | ### 设置默认值
103 |
104 | ```go
105 | formList.AddField("header", "header", db.Varchar, form.Text).FieldDefault("header")
106 | ```
107 |
108 | ### 设置为必须输入
109 |
110 | ```go
111 | formList.AddField("header", "header", db.Varchar, form.Text).FieldMust()
112 | ```
113 |
114 | ### 设置帮助信息
115 |
116 | ```go
117 | formList.AddField("header", "header", db.Varchar, form.Text).FieldHelpMsg("长度应该大于5")
118 | ```
119 |
120 | ### 不允许编辑
121 |
122 | ```go
123 |
124 | formList.AddField("id", "id", db.Int, form.Default).FieldNotAllowEdit()
125 |
126 | ```
127 |
128 | ### 不允许新增
129 |
130 | ```go
131 |
132 | formList.AddField("id", "id", db.Int, form.Default).FieldNotAllowAdd()
133 |
134 | ```
135 |
136 | ### 隐藏继续编辑按钮
137 |
138 | ```go
139 | formList.HideContinueEditCheckBox()
140 | ```
141 |
142 | ### 隐藏继续新增按钮
143 |
144 | ```go
145 | formList.HideContinueNewCheckBox()
146 | ```
147 |
148 | ### 隐藏返回按钮
149 |
150 | ```go
151 | formList.HideBackButton()
152 | ```
153 |
154 | ### 默认重设按钮
155 |
156 | ```go
157 | formList.HideResetButton()
158 | ```
159 |
160 | ### 验证器
161 |
162 | ```go
163 | formList.SetPostValidator(func(values form2.Values) error {
164 | if values.Get("sex") != "women" && values.Get("sex") != "men" {
165 | return fmt.Errorf("error info")
166 | }
167 | return nil
168 | })
169 | ```
170 |
171 | ### 提交前对字段进行过滤处理
172 |
173 | ```go
174 | formList.AddField("链接", "url", db.Varchar, form.Text).
175 | FieldPostFilterFn(func(value types.PostFieldModel) interface{} {
176 | return "http://xxxx.com/" + value.Get("url")
177 | })
178 | ```
179 |
180 | *插入字段如果需要为NULL*
181 |
182 | ```go
183 | formList.AddField("avatar", "avatar", db.Varchar, form.Text).
184 | FieldPostFilterFn(func(value types.PostFieldModel) interface{} {
185 | if value.Value == "" {
186 | return sql.NullString{}
187 | }
188 | return value.Value
189 | })
190 | ```
191 |
192 | ### 内置显示过滤函数
193 |
194 | ```go
195 |
196 | // 限制长度
197 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldLimit(limit int)
198 |
199 | // 去除空格
200 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldTrimSpace()
201 |
202 | // 截取
203 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldSubstr(start int, end int)
204 |
205 | // 标题
206 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldToTitle()
207 |
208 | // 大写
209 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldToUpper()
210 |
211 | // 小写
212 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldToLower()
213 |
214 | // xss过滤
215 | formList.AddField("链接", "url", db.Varchar, form.Text).FieldXssFilter()
216 |
217 | ```
218 |
219 | ### 插入/新增逻辑重写
220 |
221 | 如果你的表单插入操作与新增操作比较复杂,框架不能满足,那么你可以完全重写并取代框架的插入操作。
222 |
223 | ```go
224 |
225 | // 取代新增函数
226 | formList.SetInsertFn(func(values form2.Values) error {
227 | // values 为传入的表单参数
228 | })
229 |
230 | // 取代更新函数
231 | formList.SetUpdateFn(func(values form2.Values) error {
232 | // values 为传入的表单参数
233 | // 这里需要区分是否为一个字段更新的情景(表格字段更新),通过values的参数区分:
234 | // values.IsSingleUpdatePost() 返回 1 则为表格字段更新
235 | })
236 | ```
237 |
238 | ### 表单更新流程
239 |
240 | 按时间顺序如下:
241 |
242 | - FormPanel.Validator 数据验证
243 | - FormPanel.PreProcessFn 数据预处理
244 | - FormPanel.UpdateFn/InsertFn 数据更新/插入
245 | - FormPanel.PostHook Hook函数
246 |
247 | 对应设置接口:
248 |
249 | ```go
250 |
251 | formList.SetPostValidator()
252 | formList.SetPreProcessFn()
253 | formList.SetPostHook()
254 | formList.SetUpdateFn()
255 | formList.SetInsertFn()
256 |
257 | ```
258 |
259 | 在 PostHook 中,通过 ```values.PostError()``` 去拿到更新或插入的结果。
--------------------------------------------------------------------------------
/zh/admin/menus.md:
--------------------------------------------------------------------------------
1 | # 设置菜单
2 | ---
3 |
4 | GoAdmin已经内置了权限管理模块。以超级管理员身份进入主页后,展开左侧边栏的管理,下面有管理的管理面板:
5 |
6 | 
7 |
8 | 点击进去即可设置你所需要的菜单。
--------------------------------------------------------------------------------
/zh/admin/module.md:
--------------------------------------------------------------------------------
1 | # 模块
2 | ---
3 |
4 | GoAdmin在构建中,生成了一些模块,如:数据库模块,用户认证模块;本节介绍如何获取和使用。
5 |
6 | ## 数据库模块
7 |
8 | 数据库在配置后,引擎设置全局配置的时候生成,生成后可以通过引擎获取该模块的控制权。
9 |
10 | ```go
11 |
12 | import (
13 | ...
14 | "github.com/GoAdminGroup/go-admin/engine"
15 | ...
16 | )
17 |
18 | func main() {
19 |
20 | ...
21 |
22 | eng := engine.Default()
23 |
24 | cfg := config.Config{
25 | ...
26 | Databases: config.DatabaseList{
27 | "default": {
28 | Host: "127.0.0.1",
29 | Port: "3306",
30 | User: "root",
31 | Pwd: "root",
32 | Name: "godmin",
33 | MaxIdleCon: 50,
34 | MaxOpenCon: 150,
35 | Driver: config.DriverMysql,
36 | },
37 | },
38 | ...
39 | }
40 |
41 | _ = eng.AddConfig(cfg). // 这里生成了数据库模块,获取连接需要再AddConfig之后
42 | AddPlugins(adminPlugin).
43 | Use(r)
44 |
45 | // 获取mysql连接
46 | conn := eng.MysqlConnection()
47 |
48 | // 获取mssql连接
49 | conn := eng.MssqlConnection()
50 |
51 | // 获取postgresql连接
52 | conn := eng.PostgresqlConnection()
53 |
54 | // 获取sqlite连接
55 | conn := eng.SqliteConnection()
56 |
57 | // 注意,获取到的一个指针,指向的是全局唯一的真正的数据库连接对象。
58 | // 如果你要在数据模型文件中复用,那么你必须在 .Use(r) 调用前对连接对象进行设置
59 | // 否则会报空指针错误。比如:
60 | //
61 | // _ = eng.AddConfig(cfg).
62 | // ResolveMysqlConnection(tables.SetConn)
63 | // AddPlugins(adminPlugin).
64 | // Use(r)
65 | //
66 | // 在tables.go文件中是:
67 | //
68 | // var conn db.Connection
69 | //
70 | // func SetConn(c db.Connection) {
71 | // conn = c
72 | // }
73 | //
74 | // 然后在数据模型文件中调用 conn,进行数据库操作
75 |
76 | // 通过setter函数获取
77 | eng.ResolveMysqlConnection(SetConn)
78 |
79 | ...
80 | }
81 |
82 | var globalConn db.Connection
83 |
84 | func SetConn(conn db.Connection) {
85 | globalConn = conn
86 | }
87 | ```
88 |
89 | 使用,获取到 ```connection``` 后,可以调用内置的数据库sql连接辅助方法库对sql数据库进行操作,如:
90 |
91 | ```go
92 |
93 | import (
94 | ...
95 | "github.com/GoAdminGroup/go-admin/modules/db"
96 | "github.com/GoAdminGroup/go-admin/modules/db/dialect"
97 | ...
98 | )
99 |
100 | func main() {
101 |
102 | // 传入获取的数据库模块,调用sql数据库方法
103 |
104 | // 查询
105 | db.WithDriver(globalConn).Table("users").Select("id", "name").First()
106 |
107 | // 更新
108 | db.WithDriver(globalConn).Table("users").Where("id", "=", 10).
109 | Update(dialect.H{
110 | "name": "张三",
111 | })
112 |
113 | // 插入
114 | db.WithDriver(globalConn).Table("users").
115 | Insert(dialect.H{
116 | "name": "张三",
117 | })
118 |
119 | // 删除
120 | db.WithDriver(globalConn).Table("users").Where("id", "=", 10).Delete()
121 |
122 | // 指定连接,第一个参数为连接名,也就是全局配置config.Config中的Databases的key
123 | db.WithDriverAndConnection(connName string, conn Connection)
124 |
125 | // 等等...
126 | }
127 |
128 | ```
129 |
130 | 也可以直接使用 ```Connection``` 的api,进行操作,定义如下:
131 |
132 | ```go
133 | // Connection is a connection handler of database.
134 | type Connection interface {
135 |
136 | // 初始化
137 | InitDB(cfg map[string]config.Database) Connection
138 |
139 | // 获取驱动名
140 | Name() string
141 |
142 | // 关闭连接
143 | Close() []error
144 |
145 | // 获取分隔符
146 | GetDelimiter() string
147 |
148 | // 获取DB对象
149 | GetDB(key string) *sql.DB
150 |
151 | // 查询方法,使用默认连接
152 | Query(query string, args ...interface{}) ([]map[string]interface{}, error)
153 |
154 | // Exec方法,使用默认连接
155 | Exec(query string, args ...interface{}) (sql.Result, error)
156 |
157 | // 查询方法,使用指定连接,第一个参数为连接名,也就是全局配置config.Config中的Databases的key
158 | QueryWithConnection(conn, query string, args ...interface{}) ([]map[string]interface{}, error)
159 |
160 | // Exec方法,使用指定连接
161 | ExecWithConnection(conn, query string, args ...interface{}) (sql.Result, error)
162 |
163 | // 以下是事务操作:
164 |
165 | // 开始事务
166 | BeginTx() *sql.Tx
167 | QueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error)
168 | ExecWithTx(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error)
169 | BeginTxWithReadUncommitted() *sql.Tx
170 | BeginTxWithReadCommitted() *sql.Tx
171 | BeginTxWithRepeatableRead() *sql.Tx
172 | BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx
173 | BeginTxWithReadUncommittedAndConnection(conn string) *sql.Tx
174 | BeginTxWithReadCommittedAndConnection(conn string) *sql.Tx
175 | BeginTxWithRepeatableReadAndConnection(conn string) *sql.Tx
176 | BeginTxAndConnection(conn string) *sql.Tx
177 | BeginTxWithLevelAndConnection(conn string, level sql.IsolationLevel) *sql.Tx
178 | }
179 | ```
180 |
181 | 当然也可以使用orm,比如```gorm```,如下:
182 |
183 | ```go
184 | package main
185 |
186 | import (
187 | ...
188 | "github.com/jinzhu/gorm"
189 | ...
190 | )
191 |
192 | func initORM() {
193 | // 这里的conn为上面的connection对象
194 | orm, _ := gorm.Open("mysql", conn.GetDB("default"))
195 | // gorm用法,详见:https://gorm.io/zh_CN/docs/index.html
196 | }
197 | ```
198 |
199 | ## 用户认证模块
200 |
201 | 我们编写页面内容时或在数据模型文件中,需要获取对应的登录用户,并对其信息进行验证时,需要用到用户认证模块。
202 |
203 | ```go
204 |
205 | import (
206 | ...
207 | adapter "github.com/GoAdminGroup/go-admin/adapter/gin"
208 | "github.com/GoAdminGroup/go-admin/engine"
209 | ...
210 | )
211 |
212 | func main() {
213 |
214 | ...
215 |
216 | eng := engine.Default()
217 |
218 | cfg := config.Config{
219 | ...
220 | }
221 |
222 | if err := eng.AddConfig(cfg).
223 | AddPlugins(adminPlugin, examplePlugin).
224 | Use(r); err != nil {
225 | panic(err)
226 | }
227 |
228 | r.GET("/admin", adapter.Content(func(ctx *gin.Context) (types.Panel, error) {
229 | // 获取登录用户
230 | user, _ := engine.User(ctx)
231 |
232 | // 验证其权限
233 | if !user.CheckPermission("dashboard") {
234 | return types.Panel{}, errors.New("没有权限")
235 | }
236 |
237 | // 验证其角色
238 | if !user.CheckRole("operator") {
239 | return types.Panel{}, errors.New("没有权限")
240 | }
241 | })
242 | ...
243 | }
244 | ```
245 |
246 | 在数据模型文件中获取登录用户:
247 |
248 | ```go
249 |
250 | import (
251 | ...
252 | "github.com/GoAdminGroup/go-admin/modules/auth"
253 | "github.com/GoAdminGroup/go-admin/plugins/admin/models"
254 | ...
255 | )
256 |
257 | func GetUserTable(ctx *context.Context) table.Table {
258 | // 获取登录用户模型
259 | user = auth.Auth(ctx)
260 | }
261 |
262 | ```
--------------------------------------------------------------------------------
/zh/admin/rbac.md:
--------------------------------------------------------------------------------
1 | # 权限管理
2 | ---
3 |
4 | GoAdmin已经内置了[RBAC](https://www.baidu.com/s?wd=rbac)权限控制模块。以超级管理员身份进入主页后,展开左侧边栏的管理,下面有用户、角色、权限三项的管理面板:
5 |
6 | 
7 |
8 | ## 权限说明
9 |
10 | 权限管理是针对路由和方法进行限制,路由可以 **使用golang的正则匹配**。只要方法和路由能对应上,则权限验证通过。因此需要自己对各个路由和方法进行配置,从而自己决定权限设置的粒度。
11 |
12 | 关于某个表格的管理,假设表格名为```users```,相应的系统增删改查路由如下:
13 |
14 | | 权限 | 路由 | 方法 |
15 | | ---- | ---- | ---- |
16 | | 列表页面 | /info/users | GET |
17 | | 所有记录编辑页面 | /info/users/edit | GET |
18 | | 指定记录编辑页面 | /info/users/edit?id=2 | GET |
19 | | 所有记录编辑操作 | /edit/users | POST |
20 | | 指定记录编辑操作 | /edit/users?id=2 | POST |
21 | | 新增页面 | /info/users/new | GET |
22 | | 新建操作 | /new/users | POST |
23 | | 导出操作 | /export/users | POST |
24 | | 所有权限 | * | (留空)
25 |
26 | **注意1:路由的匹配规则说明**
27 |
28 | 可以看到上表中有```id=2```的参数,系统规定,路由中可带**路由参数**,只要待验证的路由中带有该参数且值匹配得上,则通过验证。而系统规定的主键参数,**__goadmin_edit_pk**, **__goadmin_detail_pk**,**__goadmin_detail_pk**,均可以用**id**来代替,比如:
29 |
30 | > 待验证路由:/info/users/edit?__page=1&__pageSize=10&__sort=id&__sort_type=desc&__goadmin_edit_pk=3632
31 | > 路由规则:/info/users/edit?id=3632
32 | > 验证结果:通过
33 |
34 | 同时,如果是POST方法,需要对表单参数进行限制的话,同样也可以将该参数写在路由规则上,系统会判断是否在请求表单中带有该参数,如有的话,则认为权限验证正确。
35 |
36 | **注意2:设置了权限并不意味着就可以登录或左侧菜单就可以看到了**
37 |
38 | 设置了权限,登录不成功或如果需要左侧菜单显示出来,你还需要在菜单编辑页面中设置 **对应的角色**。
39 |
40 | **注意3:权限设置的高于在菜单配置的角色**
41 |
42 | 也就是说,假设菜单1,对应的角色是operator,而拥有所有权限的用户依然可以访问菜单1。
43 |
44 | **注意4:UI组件的显示跟权限相关**
45 |
46 | 也就是说,如果你没有编辑的权限,则你将看不到编辑的按钮。
--------------------------------------------------------------------------------
/zh/admin/table/column_display.md:
--------------------------------------------------------------------------------
1 | # 列的显示
2 | ---
3 |
4 | ## Bool
5 |
6 | 显示bool类型的值,第一个参数代表为true的值,第二个参数为false的值。
7 |
8 | ```go
9 | info.AddField("通关", "pass", db.Tinyint).FieldBool("1", "0")
10 | ```
11 |
12 | ## 复制
13 |
14 | 显示一个copy按钮。
15 |
16 | ```go
17 | info.AddField("UUID", "uuid", db.Varchar).FieldCopyable()
18 | ```
19 |
20 | ## 轮播
21 |
22 | ```go
23 | info.AddField("照片", "photos", db.Varchar).FieldCarousel(func(value string) []string {
24 | return strings.Split(value, ",")
25 | }, 150, 100)
26 | ```
27 |
28 | ## Dot
29 |
30 | ```go
31 | info.AddField("完成状态", "finish_state", db.Tinyint).
32 | FieldDisplay(func(value types.FieldModel) interface{} {
33 | if value.Value == "0" {
34 | return "第一步"
35 | }
36 | if value.Value == "1" {
37 | return "第二步"
38 | }
39 | if value.Value == "2" {
40 | return "第三步"
41 | }
42 | return "未知"
43 | }).
44 | FieldDot(map[string]types.FieldDotColor{
45 | "第一步": types.FieldDotColorDanger,
46 | "第二步": types.FieldDotColorInfo,
47 | "第三步": types.FieldDotColorPrimary,
48 | }, types.FieldDotColorDanger)
49 | ```
50 |
51 | ## 进度条
52 |
53 | 显示字段为一个进度条。可选参数:types.FieldProgressBarData
54 |
55 | ```go
56 | info.AddField("完成进度", "finish_progress", db.Int).FieldProgressBar()
57 |
58 | type FieldProgressBarData struct {
59 | Style string // 类型
60 | Size string // 大小
61 | Max int // 最大值
62 | }
63 | ```
64 |
65 | ## 下载链接
66 |
67 | 如果字段为文件下载链接URL,可以显示成一个下载链接,参数为前缀,可不传。
68 |
69 | ```go
70 | info.AddField("简历", "resume", db.Varchar).
71 | FieldDisplay(func(value types.FieldModel) interface{} {
72 | return filepath.Base(value.Value)
73 | }).
74 | FieldDownLoadable("http://yinyanghu.github.io/files/")
75 | ```
76 |
77 | ## 文件大小
78 |
79 | 如果字段为字节大小的整数类型,可以转为kb/mb/gb等易理解的单位显示。
80 |
81 | ```go
82 | info.AddField("简历大小", "resume_size", db.Int).FieldFileSize()
83 | ```
84 |
85 | ## Loading
86 |
87 | 参数的意思为:当状态为0,1,2时,显示为loading。
88 |
89 | ```go
90 | info.AddField("状态", "state", db.Int).FieldLoading([]string{"0", "1", "2"})
91 | ```
92 |
93 | ## 标签
94 |
95 | 显示字段为标签,可选参数为:types.FieldLabelParam
96 |
97 | ```go
98 | info.AddField("标签", "label", db.Varchar).FieldLabel(types.FieldLabelParam{})
99 |
100 | type FieldLabelParam struct {
101 | Color template.HTML // 颜色
102 | Type string // 类型
103 | }
104 | ```
105 |
106 | ## 图片
107 |
108 | 如果`avatar`字段保存的是图片的完整地址,或者路径,可以通过下面的方式将该列渲染为图片显示
109 |
110 | ```go
111 | info.AddField("头像", "avatar", db.Varchar).FieldImage("50", "50")
112 | ```
113 |
114 | 当然也可以为图片增加访问前缀
115 |
116 | ```go
117 | info.AddField("头像", "avatar", db.Varchar).FieldImage("50", "50", "https://prefix.com")
118 | ```
--------------------------------------------------------------------------------
/zh/admin/table/column_usage.md:
--------------------------------------------------------------------------------
1 | # 列的使用
2 | ---
3 |
4 | **InfoPanel**内置了很多对于列的操作方法,可以通过这些方法很灵活的操作列数据。
5 |
6 | ### 设置列宽
7 |
8 | 注意需要先设置表格布局类型为fixed
9 |
10 | ```go
11 | info.SetTableFixed()
12 | info.AddField("Name", "name", db.Varchar).FieldWidth(100)
13 | ```
14 |
15 | ### 默认隐藏列
16 |
17 | ```go
18 | info.AddField("Name", "name", db.Varchar).FieldHide()
19 | ```
20 |
21 | ### 设置为可排序
22 |
23 | ```go
24 | info.AddField("Name", "name", db.Varchar).FieldSortable()
25 | ```
26 |
27 | ### 设置为固定
28 |
29 | ```go
30 | info.AddField("Name", "name", db.Varchar).FieldFixed()
31 | ```
32 |
33 | ### 设置为可筛选
34 |
35 | ```go
36 | info.AddField("Name", "name", db.Varchar).FieldFilterable()
37 | ```
38 |
39 | 设置筛选的操作符与操作表单类型:
40 |
41 | ```go
42 |
43 | // 设置操作符为like,模糊查询
44 | info.AddField("Name", "name", db.Varchar).FieldFilterable(types.FilterType{Operator: types.FilterOperatorLike})
45 |
46 | // 设置为单选类型
47 | info.AddField("Gender", "gender", db.Tinyint).
48 | FieldFilterable(types.FilterType{FormType: form.SelectSingle}).
49 | FieldFilterOptions(types.FieldOptions{
50 | {Value: "0", Text: "men"},
51 | {Value: "1", Text: "women"},
52 | }).FieldFilterOptionExt(map[string]interface{}{"allowClear": true})
53 |
54 | // 设置为时间范围类型,范围查询
55 | info.AddField("CreatedAt", "created_at", db.Timestamp).FieldFilterable(types.FilterType{FormType: form.DatetimeRange})
56 |
57 | // 设置过滤字段处理函数
58 | info.AddField("Name", "name", db.Varchar).
59 | FieldFilterable(types.FilterType{Operator: types.FilterOperatorLike}).
60 | FieldFilterProcess(func(s string) string {
61 | // 即使前端错误输入带空格,在这里可以过滤空格进行sql查询
62 | return strings.TrimSpace(s)
63 | })
64 | ```
65 |
66 | ## 列操作按钮
67 |
68 | ```go
69 | // 第一个参数为标题,第二个参数为对应的操作
70 | info.AddActionButton("操作", action.Jump("https://google.com"))
71 | ```
72 |
73 | 操作的类Action为一个接口,如下:
74 |
75 | ```go
76 | type Action interface {
77 | // 返回对应的JS
78 | Js() template.JS
79 | // 获取class
80 | BtnClass() template.HTML
81 | // 返回按钮的属性
82 | BtnAttribute() template.HTML
83 | // 返回额外的HTML
84 | ExtContent() template.HTML
85 | // 设置按钮的ID,供给Js()方法调用
86 | SetBtnId(btnId string)
87 | // 设置数据
88 | SetBtnData(data interface{})
89 | // 返回请求节点,包括路由方法和对应控制器方法
90 | GetCallbacks() context.Node
91 | }
92 | ```
93 |
94 | 可以自己实现一个```Action```,也可以直接使用框架提供的```Action```。系统内置提供以下两个```Action```,一个是popup操作,一个是跳转操作。
95 |
96 | ```go
97 |
98 | import (
99 | "github.com/GoAdminGroup/go-admin/template/types/action"
100 | )
101 |
102 | // 返回一个Jump Action,参数一为url,参数二为额外的html
103 | // Jump Action是一个跳转操作。如果需要跳转url中带上id,可以这样写:
104 | //
105 | action.Jump("/admin/info/manager?id={{.Id}}")
106 | //
107 | // 其中{{.Id}}为id的占位符
108 | action.Jump("/admin/info/manager")
109 | action.JumpInNewTab("/admin/info/manager", "管理员")
110 |
111 | // 如果是行中的action,想要取得同行数据作为参数,比如行中有一列叫name,那么可以这样传:
112 | action.Jump(`/admin/info/manager?name={{(index .Value "name").Value}}`)
113 |
114 | // 这里 (index .Value "name") 取得的对象是:https://godoc.org/github.com/GoAdminGroup/go-admin/template/types#InfoItem
115 |
116 | // 返回一个PopUp Action,参数一为url,参数二为popup标题,参数三为对应的控制器方法。
117 | // 用户点击按钮后会请求对应的方法,带上请求id,请求转发到对应控制器方法后进行处理返回。
118 | action.PopUp("/admin/popup", "Popup Example", func(ctx *context.Context) (success bool, msg string, data interface{}) {
119 | // 获取参数
120 | // ctx.FormValue["id"]
121 | // ctx.FormValue["ids"]
122 | return true, "", "