Skip to content

Commit be0bcc8

Browse files
author
cg33
committed
update english docs
1 parent d8932e3 commit be0bcc8

File tree

21 files changed

+707
-245
lines changed

21 files changed

+707
-245
lines changed

SUMMARY.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
* [New Theme](en/admin/theme.md)
1818
* [File Upload](en/admin/file.md)
1919
* [Cli](en/admin/cli.md)
20+
* [Customize auth user table](en/admin/auth.md)
21+
* [Set up CDN](en/admin/cdn.md)
2022
* [Pages]()
2123
* [Page Modules](en/pages/modules.md)
2224
* [Customize Your Page](en/pages/pages.md)
2325
* [Customize Login Page](en/pages/login.md)
26+
* [CI tests]()
27+
* [CI tests](en/tests/ci.md)
2428
* [Architecture]()
2529
* [Introduction](en/architecture/introduction.md)
2630
* [Development]()
@@ -29,7 +33,6 @@
2933
* [Plugins Development](en/development/plugins.md)
3034
* [Template Development]()
3135
* [Template Introducation](en/development/template/template.md)
32-
* [Form Development](en/development/template/form.md)
3336
* [Components](en/development/template/components.md)
3437
* [Plan](en/plan.md)
3538
* [简体中文](zh/README.md)
@@ -63,15 +66,15 @@
6366
- [页面模块化](zh/pages/modules.md)
6467
- [自定义页面](zh/pages/pages.md)
6568
- [修改登录界面](zh/pages/login.md)
66-
- [ci测试]
69+
- [ci测试]()
6770
- [ci测试](zh/tests/ci.md)
6871
- [项目架构]()
6972
- [架构介绍](zh/architecture/introduction.md)
7073
- [项目开发]()
7174
- [代码规范](zh/development/code_style.md)
7275
- [适配器](zh/development/adapter.md)
7376
- [插件](zh/development/plugins.md)
74-
- [模板开发](zh/development/template/template.md)
77+
- [模板开发]()
7578
- [模板介绍](zh/development/template/template.md)
7679
- [组件开发](zh/development/template/components.md)
7780
- [发展规划](zh/plan.md)

en/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Introduction
22
------
33

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.
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.
55
<br>
66
<br>
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.
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.
1010

11-
here is very simple example which show you how it work: [https://github.com/GoAdminGroup/example](https://github.com/GoAdminGroup/example)
11+
Here is a super simple example which quickly shows you how it works: [https://github.com/GoAdminGroup/example](https://github.com/GoAdminGroup/example)
1212

1313

1414
## Features
@@ -18,9 +18,9 @@ here is very simple example which show you how it work: [https://github.com/GoAd
1818
- Support plug-ins(working on it)
1919
- Provided different ui theme(only Adminlte now, others are coming soon.)
2020

21-
## Demo
21+
## Online Demo
2222

23-
[https://demo.go-admin.com](https://demo.go-admin.com/admin/login)
23+
[https://demo.go-admin.com](https://demo.go-admin.com)
2424

2525
## Dependencies
2626

@@ -35,10 +35,12 @@ here is very simple example which show you how it work: [https://github.com/GoAd
3535

3636
## Community
3737

38-
[Community](http://forum.go-admin.cn)
38+
[Community](http://discuss.go-admin.com)
3939

4040
## Backers
4141

4242
Your support will help me do better!
4343

44-
<a href="https://opencollective.com/go-admin#backers" target="_blank"><img src="https://opencollective.com/go-admin/backers.svg?width=890"></a>
44+
<a href="https://opencollective.com/go-admin#backers" target="_blank"><img src="https://opencollective.com/go-admin/backers.svg?width=890"></a>
45+
46+
[Support Paypal too](https://www.paypal.me/cg80333)

en/admin/auth.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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/form/basic.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,27 @@ formList.SetInsertFn(func(values form2.Values) error {
208208
formList.SetUpdateFn(func(values form2.Values) error {
209209
// values are the form parameters
210210
})
211-
```
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/form/components.md

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ formList.AddField("url", "url", db.Varchar, form.Url)
6464
formList.AddField("ip", "ip", db.Varchar, form.Ip)
6565
```
6666

67+
### Code
68+
```go
69+
formList.AddField("code", "code", db.Text, form.Code)
70+
formList.AddField("code", "code", db.Text, form.Code).FieldOptionExt(map[string]interface{}{
71+
"theme": "monokai",
72+
"font_size": 14,
73+
"language": "php",
74+
"options": "{useWorker: false}",
75+
})
76+
```
77+
6778
### Color
6879

6980
```go
@@ -107,21 +118,6 @@ formList.AddField("sex", "sex", db.Int, form.SelectSingle).
107118

108119
### Select
109120

110-
### SelectSingle
111-
112-
```go
113-
formList.AddField("sex", "sex", db.Int, form.SelectSingle).
114-
// Options, Text is the display content, Value is the corresponding value.
115-
FieldOptions(types.FieldOptions{
116-
{Text: "man",Value: "0"},
117-
{Text: "women",Value: "1"},
118-
}).
119-
// Default option.
120-
FieldDefault("0")
121-
```
122-
123-
### Select
124-
125121
```go
126122
formList.AddField("drink", "drink", db.Int, form.Select).
127123
// Options, Text is the display content, Value is the corresponding value.
@@ -139,6 +135,10 @@ formList.AddField("drink", "drink", db.Int, form.Select).
139135
Text: "red bull",
140136
Value: "red bull",
141137
},
138+
}).
139+
// returns a []string here, the corresponding value is ultimately responds field values of this column, the corresponding value is displayed when edit form
140+
FieldDisplay(func(model types.FieldModel) interface{} {
141+
return []string{"beer"}
142142
})
143143
```
144144

@@ -154,6 +154,18 @@ formList.AddField("gender", "gender", db.Int, form.Radio).
154154
FieldDefault("0")
155155
```
156156

157+
### Switch
158+
159+
```go
160+
formList.AddField("site", "site", db.Int, form.Switch).
161+
// // Options, Text is the display content, Value is the corresponding value.
162+
FieldOptions(types.FieldOptions{
163+
{Text: trueStr, Value: "true"},
164+
{Text: falseStr, Value: "false"},
165+
})
166+
FieldDefault("0") // Set default value
167+
```
168+
157169
### SelectBox
158170

159171
```go
@@ -173,6 +185,10 @@ formList.AddField("fruit", "fruit", db.Int, form.SelectBox).
173185
Text: "pear",
174186
Value: "pear",
175187
},
188+
}).
189+
// returns a []string here, the corresponding value is ultimately responds field values of this column, the corresponding value is displayed when edit form
190+
FieldDisplay(func(model types.FieldModel) interface{} {
191+
return []string{"pear"}
176192
})
177193
```
178194

en/admin/module.md

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func main() {
4444

4545
// get mysql connection
4646
conn := eng.MysqlConnection()
47+
48+
// get mssql connection
49+
conn := eng.MssqlConnection()
4750

4851
// get postgresql connection
4952
conn := eng.PostgresqlConnection()
@@ -96,6 +99,8 @@ import (
9699

97100
func main() {
98101

102+
// pass the global connection object, then call the helper methods
103+
99104
// query
100105
db.WithDriver(globalConn).Table("users").Select("id", "name").First()
101106

@@ -119,6 +124,76 @@ func main() {
119124

120125
```
121126

127+
You can use APIs of the ```Connection``` too.
128+
129+
```go
130+
// Connection is a connection handler of database.
131+
type Connection interface {
132+
133+
// Initialize
134+
InitDB(cfg map[string]config.Database) Connection
135+
136+
// Get the driver name
137+
Name() string
138+
139+
// Close the connection
140+
Close() []error
141+
142+
// Get the default delimiter
143+
GetDelimiter() string
144+
145+
// Get the sql.DB
146+
GetDB(key string) *sql.DB
147+
148+
// Query with the default connection
149+
Query(query string, args ...interface{}) ([]map[string]interface{}, error)
150+
151+
// Exec with the default connection
152+
Exec(query string, args ...interface{}) (sql.Result, error)
153+
154+
// Query with the specify connection which is the key of Databases of config.Config.
155+
QueryWithConnection(conn, query string, args ...interface{}) ([]map[string]interface{}, error)
156+
157+
// Exec with the specify connection which is the key of Databases of config.Config.
158+
ExecWithConnection(conn, query string, args ...interface{}) (sql.Result, error)
159+
160+
// Transaction operations:
161+
162+
// begin the transaction
163+
BeginTx() *sql.Tx
164+
QueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error)
165+
ExecWithTx(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error)
166+
BeginTxWithReadUncommitted() *sql.Tx
167+
BeginTxWithReadCommitted() *sql.Tx
168+
BeginTxWithRepeatableRead() *sql.Tx
169+
BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx
170+
BeginTxWithReadUncommittedAndConnection(conn string) *sql.Tx
171+
BeginTxWithReadCommittedAndConnection(conn string) *sql.Tx
172+
BeginTxWithRepeatableReadAndConnection(conn string) *sql.Tx
173+
BeginTxAndConnection(conn string) *sql.Tx
174+
BeginTxWithLevelAndConnection(conn string, level sql.IsolationLevel) *sql.Tx
175+
}
176+
```
177+
178+
Also you can use the orm, for example, ```gorm``
179+
180+
```go
181+
package main
182+
183+
import (
184+
...
185+
"github.com/jinzhu/gorm"
186+
...
187+
)
188+
189+
func initORM() {
190+
// conn is the global connection object
191+
orm, _ := gorm.Open("mysql", conn.GetDB("default"))
192+
// See more about gorm: https://gorm.io
193+
}
194+
```
195+
196+
122197
## User Authentication Module
123198

124199
When we write the page content, need to get the corresponding login user, and to validate its information, need to use user authentication module.
@@ -154,14 +229,32 @@ func main() {
154229

155230
// Verify the permissions
156231
if !user.CheckPermission("dashboard") {
157-
return types.Panel{}, errors.New("没有权限")
232+
return types.Panel{}, errors.New("no permission")
158233
}
159234

160235
// Verify the roles
161236
if !user.CheckRole("operator") {
162-
return types.Panel{}, errors.New("没有权限")
237+
return types.Panel{}, errors.New("no permission")
163238
}
164239
})
165240
...
166241
}
242+
```
243+
244+
Retrieve the auth user model in the data model functions:
245+
246+
```go
247+
248+
import (
249+
...
250+
"github.com/GoAdminGroup/go-admin/modules/auth"
251+
"github.com/GoAdminGroup/go-admin/plugins/admin/models"
252+
...
253+
)
254+
255+
func GetUserTable(ctx *context.Context) table.Table {
256+
// retrieve the auth user.
257+
user = auth.Auth(ctx)
258+
}
259+
167260
```

0 commit comments

Comments
 (0)