From e9a91f382a5c93970f029bad625381c4d4788608 Mon Sep 17 00:00:00 2001 From: cg33 Date: Fri, 18 Oct 2019 08:05:44 +0800 Subject: [PATCH 1/2] copy zh => en; ready to translate zh into en --- en/_sidebar.md | 27 ++++- en/admin/cli.md | 43 ++++++++ en/admin/file.md | 121 +++++++++++++++++++++ en/admin/form/basic.md | 74 +++++++++++++ en/admin/form/components.md | 111 +++++++++++++++++++ en/admin/menus.md | 8 ++ en/admin/rbac.md | 6 ++ en/admin/table/basic.md | 141 +++++++++++++++++++++++++ en/admin/table/column_usage.md | 74 +++++++++++++ en/architecture/introduction.md | 20 ++++ en/development/code_style.md | 6 ++ en/pages/login.md | 50 +++++++++ en/plan.md | 62 +++++++++++ en/{init-project.md => quick_start.md} | 0 zh/admin/form/basic.md | 12 +++ 15 files changed, 750 insertions(+), 5 deletions(-) create mode 100644 en/admin/cli.md create mode 100644 en/admin/file.md create mode 100644 en/admin/form/basic.md create mode 100644 en/admin/form/components.md create mode 100644 en/admin/menus.md create mode 100644 en/admin/rbac.md create mode 100644 en/admin/table/basic.md create mode 100644 en/admin/table/column_usage.md create mode 100644 en/architecture/introduction.md create mode 100644 en/development/code_style.md create mode 100644 en/pages/login.md create mode 100644 en/plan.md rename en/{init-project.md => quick_start.md} (100%) diff --git a/en/_sidebar.md b/en/_sidebar.md index a4bacba..19f977e 100644 --- a/en/_sidebar.md +++ b/en/_sidebar.md @@ -2,20 +2,39 @@ * [Get Ready](install) -* [Quick Start](init-project) +* [Quick Start](quick_start) * Plugins * [How To Use Plugins](plugins/plugins) * [How To Use Admin Plugin](plugins/admin) +* Admin Plugins + + * Data Table + * [Basic Usage](admin/table/basic) + * [Column Usage](admin/table/column_usage) + * Data Form + * [Basic Usage](admin/form/basic) + * [Form Components](admin/form/components) + * [Menus](admin/menus) + * [Permissions](admin/rbac) + * [File Upload](admin/file) + * [Cli](admin/cli) + * Pages * [Page Modules](pages/modules) - * [Customize your page](pages/pages) + * [Customize Your Page](pages/pages) + * [Customize Login Page](pages/login) + +* Architecture + + * [Introduction](architecture/introduction) * Development + * [Code Style](development/code_style) * [Adapter Development](development/adapter) * [Plugins Development](development/plugins) * Template Development @@ -24,6 +43,4 @@ * [Form Development](development/template/form) * [Components](development/template/components) -* [Menus](menu) - -* [Permissions](rbac) \ No newline at end of file +* [Plan](plan) \ No newline at end of file diff --git a/en/admin/cli.md b/en/admin/cli.md new file mode 100644 index 0000000..218249a --- /dev/null +++ b/en/admin/cli.md @@ -0,0 +1,43 @@ +# 命令行工具介绍 +--- + +GoAdmin提供了一个命令行工具,以提高开发效率,简化开发流程。 + +## 安装 + + +下载对应系统的二进制文件到本地: + +| File name | OS | Arch | Size | +| ---- | ---- | ---- |---- | +| [admincli_darwin_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_darwin_x86_64_v1.0.1.zip) | macOs | x86-64 | 4.77 MB +| [admincli_linux_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_linux_x86_64_v1.0.1.zip) | Linux | x86-64 | 6.52 MB +| [admincli_linux_armel_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_linux_armel_v1.0.1.zip) | Linux | x86 | 6.06 MB +| [admincli_windows_i386_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_windows_i386_v1.0.1.zip) | Windows | x86 |6.16 MB +| [admincli_windows_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_windows_x86_64_v1.0.1.zip) | Windows | x86-64 |6.38 MB + + +或使用命令安装: + +``` +go install github.com/GoAdminGroup/go-admin/admincli +``` + +## 使用 + +使用 + +``` +admincli --help +``` + +会列出帮助信息。 + +| 命令名 | 子命令名 | 选项 | 功能 | +| ---- | ---- | ---- | ---- | +| generate | - | - | 生成数据模型文件 +| compile | asset| **-s, --src** 输入前端资源文件夹路径
**-o, --out** 输出合并go文件路径 | 编译所有资源文件为一个go文件 +| compile | tpl | **-s, --src** 输入golang tmpl模板文件夹路径
**-o, --out** 输出合并模板go文件路径 | 编译所有模板文件为一个go文件 +| combine | css| **-s, --src** 输入css文件夹路径
**-o, --out** 输出合并css文件路径 | 合并css文件为一个css文件 +| combine | js | **-s, --src** 输入js文件夹路径
**-o, --out** 输出合并js文件路径 | 合并js文件为一个js文件 +| develop | tpl | **-m, --module** golang模块名或$GOPATH下的路径
**-n, --name** 主题名 | 远程拉取主题开发模板到本地 diff --git a/en/admin/file.md b/en/admin/file.md new file mode 100644 index 0000000..c080437 --- /dev/null +++ b/en/admin/file.md @@ -0,0 +1,121 @@ +# 文件上传 +--- + +GoAdmin默认提供一个本地文件上传引擎,支持将文件上传到服务器。使用需要在全局配置中设置上传的目录,以及上传文件访问的前缀。 + +```go +package config + +// 存储目录:存储头像等上传文件 +type Store struct { + Path string // 相对或绝对路径,文件会存储到这里 + Prefix string // 访问前缀 +} + +type Config struct { + + ... + + // 上传文件存储的位置 + Store Store `json:"store"` + + // 文件上传引擎 + FileUploadEngine FileUploadEngine `json:"file_upload_engine"` + + ... +} + +type FileUploadEngine struct { + Name string + Config map[string]interface{} +} +``` + +如果你想要自定义上传位置,比如上传到又拍云,七牛云等云平台,那么你需要自己写一个上传引擎。下面介绍如何自己写引擎: + +### 引擎的类型 + +```go +package file + +// 上传引擎 +type Uploader interface { + Upload(*multipart.Form) error +} + +// 上传引擎生成函数 +type UploaderGenerator func() Uploader + +// 增加引擎接口api +func AddUploader(name string, up UploaderGenerator) { + ... +} +``` + +### 调用 + +我们需要调用**AddUploader**方法来增加一个上传引擎,第一个参数是引擎的名字(将在全局配置中用到),第二参数就是引擎生成函数。 + +假设我们要增加一个七牛云上传引擎,那么可以类似这样: + +```go +package main + +import ( + ... + "github.com/GoAdminGroup/go-admin/modules/file" + ... +) + +type QiNiuUploader struct { + Bucket string + Region string + SecretId string + SecretKey string + + Prefix string + Path string +} + +func (q QiNiuUploader) Upload(*multipart.Form) error { + // 接收一个表单类型,这里实现上传逻辑 +} + +func main() { + + ... + + file.AddUploader("qiniu", func() file.Uploader { + return &QiNiuUploader{ + Bucket: config.Get().FileUploadEngine.Config["bucket"].(string), + Region: config.Get().FileUploadEngine.Config["region"].(string), + SecretId: config.Get().FileUploadEngine.Config["secret_id"].(string), + SecretKey: config.Get().FileUploadEngine.Config["secret_key"].(string), + Prefix: config.Get().FileUploadEngine.Config["prefix"].(string), + Path: config.Get().FileUploadEngine.Config["path"].(string), + } + }) + + cfg := config.Config{ + ... + + FileUploadEngine: config.FileUploadEngine{ + Name: "qiniu", + Config: map[string]interface{}{ + "bucket": "xxx", + "region": "xxx", + "secret_id": "xxx", + "secret_key": "xxx", + "prefix": "xxx", + "path": "xxx", + }, + } + + ... + } + + ... +} +``` + +这样就实现一个七牛云上传文件引擎了!🍺🍺 \ No newline at end of file diff --git a/en/admin/form/basic.md b/en/admin/form/basic.md new file mode 100644 index 0000000..183f60c --- /dev/null +++ b/en/admin/form/basic.md @@ -0,0 +1,74 @@ +# 基本使用 +--- + +使用命令行将sql表生成一个数据表单类型,如: + +```sql +CREATE TABLE `users` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `gender` tinyint(4) DEFAULT NULL, + `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +``` + +生成了: + +```go +package datamodel + +import ( + ... +) + +func GetUserTable() (userTable table.Table) { + + // config the table model. + userTable = table.NewDefaultTable(...) + + ... + + formList := userTable.GetForm() + + // set id editable is false. + formList.AddField("ID", "id", db.Int, form.Default).FieldNotAllowEdit() + formList.AddField("Ip", "ip", db.Varchar, form.Text) + formList.AddField("Name", "name", db.Varchar, form.Text) + + ... + + return +} +``` + +### 添加字段 + +```go + +// 添加一个字段,字段标题为 ID,字段名为 id,字段类型为 int,表单类型为 Default +formList.AddField("ID", "id", db.Int, form.Default) + +// 添加第二个字段,字段标题为 Ip,字段名为 ip,字段类型为 varchar,表单类型为 Text +formList.AddField("Ip", "ip", db.Varchar, form.Text) + +// 添加第三个字段,一个sql表不存在的字段 +formList.AddField("Custom", "custom", db.Varchar, form.Text) + +``` + +### 不允许编辑 + +```go + +``` + +### 不允许新增 + +```go + +``` \ No newline at end of file diff --git a/en/admin/form/components.md b/en/admin/form/components.md new file mode 100644 index 0000000..e6d6ad6 --- /dev/null +++ b/en/admin/form/components.md @@ -0,0 +1,111 @@ +# 表单组件使用 +--- + +## Default + +```go +// 使用 +``` + +## Text + +```go +// 使用 +``` + +## SelectSingle + +```go +// 使用 +``` + +## Select + +```go +// 使用 +``` + +## IconPicker + +```go +// 使用 +``` + +## SelectBox + +```go +// 使用 +``` + +## File + +```go +// 使用 +``` + +## Password + +```go +// 使用 +``` + +## RichText + +```go +// 使用 +``` + +## Datetime + +```go +// 使用 +``` + +## Radio + +```go +// 使用 +``` + +## Email + +```go +// 使用 +``` + +## Url + +```go +// 使用 +``` + +## Ip + +```go +// 使用 +``` + +## Color + +```go +// 使用 +``` + +## Currency + +```go +// 使用 +``` + +## Number + +```go +// 使用 +``` + +## TextArea + +```go +// 使用 +``` + diff --git a/en/admin/menus.md b/en/admin/menus.md new file mode 100644 index 0000000..08e6acb --- /dev/null +++ b/en/admin/menus.md @@ -0,0 +1,8 @@ +# 设置菜单 +--- + +GoAdmin已经内置了权限管理模块。以超级管理员身份进入主页后,展开左侧边栏的管理,下面有管理的管理面板: + +![rbac](http://quick.go-admin.cn/docs/menus.png) + +点击进去即可设置你所需要的菜单。 \ No newline at end of file diff --git a/en/admin/rbac.md b/en/admin/rbac.md new file mode 100644 index 0000000..761e2ac --- /dev/null +++ b/en/admin/rbac.md @@ -0,0 +1,6 @@ +# 权限管理 +--- + +GoAdmin已经内置了[RBAC](https://www.baidu.com/s?wd=rbac)权限控制模块。以超级管理员身份进入主页后,展开左侧边栏的管理,下面有用户、角色、权限三项的管理面板: + +![rbac](http://quick.go-admin.cn/docs/rbac.png) \ No newline at end of file diff --git a/en/admin/table/basic.md b/en/admin/table/basic.md new file mode 100644 index 0000000..44b08fc --- /dev/null +++ b/en/admin/table/basic.md @@ -0,0 +1,141 @@ +# 基本使用 +--- + +使用命令行将sql表生成一个数据表格类型,如: + +```sql +CREATE TABLE `users` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `gender` tinyint(4) DEFAULT NULL, + `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +``` + +生成了: + +```go +package datamodel + +import ( + ... +) + +func GetUserTable() (userTable table.Table) { + + // config the table model. + userTable = table.NewDefaultTable(table.Config{...}) + + info := userTable.GetInfo() + + // set id sortable. + info.AddField("ID", "id", db.Int).FieldSortable(true) + info.AddField("Name", "name", db.Varchar) + + ... + + // set the title and description of table page. + info.SetTable("users").SetTitle("Users").SetDescription("Users"). + SetAction(template.HTML(``)) // custom operation button + + ... +} +``` + +### 添加列 + +```go + +// 添加一个字段,字段标题为 ID,字段名为 id,字段类型为 int +info.AddField("ID", "id", db.Int) + +// 添加第二个字段,字段标题为 Name,字段名为 name,字段类型为 varchar +info.AddField("Name", "name", db.Varchar) + +// 添加第三个字段,一个sql表不存在的字段 +info.AddField("Custom", "custom", db.Varchar) + +``` + +### 修改显示输出 + +```go + +// 根据字段的值输出对应的内容 +info.AddField("Gender", "gender", db.Tinyint).FieldDisplay(func(model types.FieldModel) interface{} { + if model.Value == "0" { + return "men" + } + if model.Value == "1" { + return "women" + } + return "unknown" +}) + +// 输出html +info.AddField("Name", "name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} { + return "" + model.Value + "" +}) +``` + +**FieldDisplay**方法接收的匿名函数绑定了当前行的数据对象,可以在里面调用当前行的其它字段数据 + +```go +info.AddField("First Name", "first_name", db.Varchar).FieldHide() +info.AddField("Last Name", "last_name", db.Varchar).FieldHide() + +// 不存的字段列 +info.AddField("Full Name", "full_name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} { + return model.Row["first_name"].(string) + " " + model.Row["last_name"].(string) +}) +``` + +### 禁用创建按钮 + +```go +info.HideNewButton() +``` + +### 禁用编辑按钮 + +```go +info.HideEditButton() +``` + +### 禁用导出按钮 + +```go +info.HideExportButton() +``` + +### 禁用删除按钮 + +```go +info.HideDeleteButton() +``` + +## 连表 + +连表需要设置连表表名与连表字段 + +```go + +// 增加字段名 +info.AddField("Role Name", "role_name", db.Varchar).FieldJoin(types.Join{ + Table: "role", // 连表的表名 + Field: "id", // 要连表的字段 + JoinField: "user_id", // 连表的表的字段 +}) + +``` + +这将会生成类似这样的sql语句: + +```sql +select ..., role.`role_name` from users left join role on users.`id` = role.`user_id` where ... +``` \ No newline at end of file diff --git a/en/admin/table/column_usage.md b/en/admin/table/column_usage.md new file mode 100644 index 0000000..04f0f53 --- /dev/null +++ b/en/admin/table/column_usage.md @@ -0,0 +1,74 @@ +# 列的使用 +--- + +**InfoPanel**内置了很多对于列的操作方法,可以通过这些方法很灵活的操作列数据。 + +### 设置列宽 + +```go +info.AddField("Name", "name", db.Varchar).FieldWidth(100) +``` + +### 默认隐藏列 + +```go +info.AddField("Name", "name", db.Varchar).FieldHide() +``` + +### 设置为可排序 + +```go +info.AddField("Name", "name", db.Varchar).FieldSortable() +``` + +### 设置为固定 + +```go +info.AddField("Name", "name", db.Varchar).FieldFixed() +``` + +### 设置为可过滤 + +```go +info.AddField("Name", "name", db.Varchar).FieldFilterable() +``` + +## 帮助方法 + +### 字符串操作 + +限制输出长度 + +```go +info.AddField("Name", "name", db.Varchar).FieldLimit(10) +``` + +首字母大写 + +```go +info.AddField("Name", "name", db.Varchar).FieldToTitle() +``` + +去除空格 + +```go +info.AddField("Name", "name", db.Varchar).FieldTrimSpace() +``` + +字符串截取 + +```go +info.AddField("Name", "name", db.Varchar).FieldSubstr(0, 3) +``` + +字符串转大写 + +```go +info.AddField("Name", "name", db.Varchar).FieldToUpper() +``` + +字符串转小写 + +```go +info.AddField("Name", "name", db.Varchar).FieldToLower() +``` \ No newline at end of file diff --git a/en/architecture/introduction.md b/en/architecture/introduction.md new file mode 100644 index 0000000..30d1dda --- /dev/null +++ b/en/architecture/introduction.md @@ -0,0 +1,20 @@ +# 项目架构 +--- + +GoAdmin的项目模块如下: + +| 模块名 | 模块功能 | 模块位置 | +| ---- | ---- | ---- | +| engine | engine是GoAdmin最核心的模块,此模块的功能是利用web框架适配器将插件的路由与控制器方法的映射关系注入到框架中 | ./engine/engine.go +| adapter | adapter的功能是实现web框架的context与GoAdmin的context的相互转换 | ./adapter/adapter.go +| context | context是一个请求的上下文,记录包括了请求的路由参数与方法信息,context会被传入到插件的方法中 | ./context/context.go +| plugin | plugin有自己的路由与控制器方法,在接收由adapter转换过来的context后经控制器方法处理返回给adapter再输出到web框架中去 | ./plugins/plugins.go +| template | template是前端代码对应的golang实体化,前端代码对应的组件部分,比如表单,行,列等实体化为golang的一个接口,因此可以通过调用接口方法获取到该组件的html代码,此功能提供给插件去调用 | ./template/template.go +| auth | auth实现了对cookie的管理,将前端的cookie存储并转换为登录的用户,同时实现了对权限的拦截 | ./modules/auth/auth.go +| config | config是系统的全局配置 | ./modules/config/config.go +| db | db是一个sql连接库,连接了sql数据库提供查询等帮助方法,支持多个driver | ./modules/db/connection.go +| language | language实现了简单的语言映射,从而支持语言本地化 | ./modules/language/language.go +| file | file实现了一个文件上传引擎 | ./modules/file/file.go +| logger | logger是项目的日志模块 | ./modules/logger/logger.go +| menu | menu是对项目菜单的管理 | ./modules/menu/menu.go +| cli | cli命令行模块,包括生成文件和开发的一些基本命令 | ./admincli/cli.go \ No newline at end of file diff --git a/en/development/code_style.md b/en/development/code_style.md new file mode 100644 index 0000000..8228425 --- /dev/null +++ b/en/development/code_style.md @@ -0,0 +1,6 @@ +# 代码规范 +--- + +``` +make lint +``` \ No newline at end of file diff --git a/en/pages/login.md b/en/pages/login.md new file mode 100644 index 0000000..dff77c0 --- /dev/null +++ b/en/pages/login.md @@ -0,0 +1,50 @@ +# 更改登录界面 +--- + +通过组件的方式可以修改登录界面,如下例子: + +更多登录界面组件[看这里](https://github.com/GoAdminGroup/components/blob/master/login/README.md);加载后引入即可。 + +```go +package main + +import ( + "github.com/GoAdminGroup/demo/ecommerce" + "github.com/GoAdminGroup/demo/login" + "github.com/GoAdminGroup/demo/pages" + _ "github.com/GoAdminGroup/go-admin/adapter/gin" + "github.com/GoAdminGroup/go-admin/engine" + "github.com/GoAdminGroup/go-admin/examples/datamodel" + "github.com/GoAdminGroup/go-admin/plugins/admin" + "github.com/GoAdminGroup/go-admin/plugins/example" + "github.com/GoAdminGroup/go-admin/template" + "github.com/GoAdminGroup/go-admin/template/types" + "github.com/gin-gonic/gin" +) + +func main() { + r := gin.Default() + + eng := engine.Default() + + adminPlugin := admin.NewAdmin(datamodel.Generators) + adminPlugin.AddGenerator("user", datamodel.GetUserTable) + + // 增加登录组件 + template.AddLoginComp(login.GetLoginComponent()) + + // you can custom a plugin like: + + examplePlugin := example.NewExample() + + rootPath := "/data/www/go-admin" + + if err := eng.AddConfigFromJson(rootPath+"/config.json").AddPlugins(adminPlugin, examplePlugin).Use(r); err != nil { + panic(err) + } + + r.Static("/uploads", rootPath+"/uploads") + + _ = r.Run(":9033") +} +``` diff --git a/en/plan.md b/en/plan.md new file mode 100644 index 0000000..b90d467 --- /dev/null +++ b/en/plan.md @@ -0,0 +1,62 @@ +# 发展计划 +--- + +GoAdmin的定位不只是一个管理后台中心构建框架,目前在1.0基础版本已经实现了一个能快速构建简单的crud以及有权限管理功能的管理后台的基础构建框架。在此基础上,可以对主题以及插件等进行一定程度的定制。以下分三点阐述这个项目以后的发展计划: + +## 项目功能规划 + +GoAdmin的目标是实现无代码化或某种程度的无代码化可视化操作,内置插件会至少包括:简单与复杂商业化crud管理中心极速构建,支持多数据源的监控体系的搭建等等。以下是对版本的初步规划: + +### 1.0.0 版本 + +- 实现基础的框架,同时提供一个内置插件能够满足快速构建crud管理后台。 +- 这个基础框架可以实现前端主题的自由定制,以及对插件的加载。 + +### 2.0.0 版本 + +- 在 1.0 版本的基础上,此版本将完善内置插件的功能,基本达到商业化水平(能够提供一个ec商城后台/saas系统的所有功能) +- 完善主题和插件的开发工具链,使得非项目开发人员都能够轻松的上手主题与插件的开发 +- 提供更多样化的内置主题与内置插件 +- 监控体系的初步支持(实时监控系统,数据前端展示,定制数据源) +- 项目性能的评估与优化 + +### 3.0.0 版本 + +- 可生产环境商业化的监控体系支持 +- 初步实现界面数据化以及实现一个界面拖拽定制框架 + +### 4.0.0 版本 + +- 实现无代码化的界面拖拽框架 + +## 人才社区构建 + +GoAdmin项目需要更多的人才一同加入。 + +目前由我 [@cg33](https://github.com/chenhg5) 一人维护此项目,本人是国内某知名985/211大学计算机系本科毕业,两年的gopher。 + +目前项目需要的工作有: + +- [项目开发](https://github.com/GoAdminGroup/go-admin),需掌握一定的```golang```开发能力 +- 社区项目开发(暂未开源,暂不对外开放) +- [文档的维护改进与翻译](https://github.com/GoAdminGroup/docs) +- 项目的宣传与社区文化的组织 + +GoAdmin始终秉持开放开源的态度,欢迎有志有能力之士加入一块共谋项目和社区的发展,社区与个人相辅相成。 + +如果你看好GoAdmin的发展,并且愿意为他赌一把,用时间换取未来可能的财务或名誉度回报,而且你对你自己的能力有足够信心,那么你可以尝试充分阅读GoAdmin的代码,并理解GoAdmin的发展规划,为此做出你的贡献。前期代码缺陷漏洞大,可修改空间多,如果你有能力做出足够的贡献,将成为项目的**联合创始人**或**核心开发者**。到后期,代码完善度高,也仍然有改进空间,你可以通过提交修复成为**贡献者**。团队将会一直保持开放态度,接纳新成员。团队每一个付出努力的成员也会在将来根据付出比例公平地去收获项目给大家带来的一定的回报。 + +如果你没有足够的时间和精力,但有一定的资金,且同样看好GoAdmin发展,虽然GoAdmin尚未就此加入的方案拟定计划。但只要你有足够大的兴趣,也可以带上你的计划与我们进行洽谈。 + +## 商业项目计划 + +GoAdmin会逐步实现商业化,但核心基础功能是免费开源的。 +GoAdmin的资金收入模式主要是: + +- 接受捐助 +- 售卖主题 +- 售卖插件 +- 提供saas定制化开发 +- 提供收费的商业化版本 + +收入资金主要用于维护社区的发展,与开发人员的薪酬回报,促使项目更好的成长。 \ No newline at end of file diff --git a/en/init-project.md b/en/quick_start.md similarity index 100% rename from en/init-project.md rename to en/quick_start.md diff --git a/zh/admin/form/basic.md b/zh/admin/form/basic.md index 61e3d44..183f60c 100644 --- a/zh/admin/form/basic.md +++ b/zh/admin/form/basic.md @@ -59,4 +59,16 @@ formList.AddField("Ip", "ip", db.Varchar, form.Text) // 添加第三个字段,一个sql表不存在的字段 formList.AddField("Custom", "custom", db.Varchar, form.Text) +``` + +### 不允许编辑 + +```go + +``` + +### 不允许新增 + +```go + ``` \ No newline at end of file From 0261404de7e7bf7b584612e8ee5f21cb575b2b4f Mon Sep 17 00:00:00 2001 From: cg33 Date: Fri, 18 Oct 2019 08:41:58 +0800 Subject: [PATCH 2/2] update --- en/admin/cli.md | 30 +- en/admin/file.md | 39 +- en/admin/form/basic.md | 18 +- en/admin/form/components.md | 38 +- en/admin/menus.md | 6 +- en/admin/rbac.md | 4 +- en/admin/table/basic.md | 45 ++- en/admin/table/column_usage.md | 30 +- en/architecture/introduction.md | 32 +- en/development/adapter.md | 58 ++- en/development/code_style.md | 2 +- fr/README.md | 44 +++ fr/_sidebar.md | 46 +++ fr/admin/cli.md | 43 +++ fr/admin/file.md | 118 ++++++ fr/admin/form/basic.md | 74 ++++ fr/admin/form/components.md | 111 ++++++ fr/admin/menus.md | 8 + fr/admin/rbac.md | 6 + fr/admin/table/basic.md | 140 +++++++ fr/admin/table/column_usage.md | 74 ++++ fr/architecture/introduction.md | 20 + fr/development/adapter.md | 58 +++ fr/development/code_style.md | 6 + fr/development/plugins.md | 7 + fr/development/template/components.md | 97 +++++ fr/development/template/form.md | 2 + fr/development/template/template.md | 41 ++ fr/index.html | 46 +++ fr/install.md | 41 ++ fr/pages/components.md | 2 + fr/pages/login.md | 50 +++ fr/pages/modules.md | 80 ++++ fr/pages/pages.md | 85 ++++ fr/plan.md | 62 +++ fr/plugins/admin.md | 536 ++++++++++++++++++++++++++ fr/plugins/plugins.md | 81 ++++ fr/quick_start.md | 234 +++++++++++ 38 files changed, 2289 insertions(+), 125 deletions(-) create mode 100644 fr/README.md create mode 100644 fr/_sidebar.md create mode 100644 fr/admin/cli.md create mode 100644 fr/admin/file.md create mode 100644 fr/admin/form/basic.md create mode 100644 fr/admin/form/components.md create mode 100644 fr/admin/menus.md create mode 100644 fr/admin/rbac.md create mode 100644 fr/admin/table/basic.md create mode 100644 fr/admin/table/column_usage.md create mode 100644 fr/architecture/introduction.md create mode 100644 fr/development/adapter.md create mode 100644 fr/development/code_style.md create mode 100644 fr/development/plugins.md create mode 100644 fr/development/template/components.md create mode 100644 fr/development/template/form.md create mode 100644 fr/development/template/template.md create mode 100644 fr/index.html create mode 100644 fr/install.md create mode 100644 fr/pages/components.md create mode 100644 fr/pages/login.md create mode 100644 fr/pages/modules.md create mode 100644 fr/pages/pages.md create mode 100644 fr/plan.md create mode 100644 fr/plugins/admin.md create mode 100644 fr/plugins/plugins.md create mode 100644 fr/quick_start.md diff --git a/en/admin/cli.md b/en/admin/cli.md index 218249a..c00ad7a 100644 --- a/en/admin/cli.md +++ b/en/admin/cli.md @@ -1,12 +1,12 @@ -# 命令行工具介绍 +# Cli Introduction --- -GoAdmin提供了一个命令行工具,以提高开发效率,简化开发流程。 +GoAdmin provides a command line tool to increase development efficiency and streamline the development process. -## 安装 +## Install -下载对应系统的二进制文件到本地: +Download the binary of the corresponding system: | File name | OS | Arch | Size | | ---- | ---- | ---- |---- | @@ -17,27 +17,27 @@ GoAdmin提供了一个命令行工具,以提高开发效率,简化开发流 | [admincli_windows_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_windows_x86_64_v1.0.1.zip) | Windows | x86-64 |6.38 MB -或使用命令安装: +Or use the command to install: ``` go install github.com/GoAdminGroup/go-admin/admincli ``` -## 使用 +## Usage -使用 +Use ``` admincli --help ``` -会列出帮助信息。 +Will list help information. -| 命令名 | 子命令名 | 选项 | 功能 | +| Command | Subcommand | Options | Function | | ---- | ---- | ---- | ---- | -| generate | - | - | 生成数据模型文件 -| compile | asset| **-s, --src** 输入前端资源文件夹路径
**-o, --out** 输出合并go文件路径 | 编译所有资源文件为一个go文件 -| compile | tpl | **-s, --src** 输入golang tmpl模板文件夹路径
**-o, --out** 输出合并模板go文件路径 | 编译所有模板文件为一个go文件 -| combine | css| **-s, --src** 输入css文件夹路径
**-o, --out** 输出合并css文件路径 | 合并css文件为一个css文件 -| combine | js | **-s, --src** 输入js文件夹路径
**-o, --out** 输出合并js文件路径 | 合并js文件为一个js文件 -| develop | tpl | **-m, --module** golang模块名或$GOPATH下的路径
**-n, --name** 主题名 | 远程拉取主题开发模板到本地 +| generate | - | - | generate a data model file. +| compile | asset| **-s, --src** front-end resource folder path
**-o, --out** output go file path | compile all resource files into one single go file. +| compile | tpl | **-s, --src** the input golang tmpl template folder path
**-o, --out** output go file path | compile all template files into one single go file. +| combine | css| **-s, --src** the input css folder path
**-o, --out** the output css file path | combine the css files into one single css file. +| combine | js | **-s, --src** the input js folder path
**-o, --out** the output js file path | combine the js files into one single js file. +| develop | tpl | **-m, --module** golang module name or path under $GOPATH
**-n, --name** theme name | fetch remotely theme development templates to local. diff --git a/en/admin/file.md b/en/admin/file.md index c080437..84e5373 100644 --- a/en/admin/file.md +++ b/en/admin/file.md @@ -1,25 +1,25 @@ -# 文件上传 +# File Upload Engine --- -GoAdmin默认提供一个本地文件上传引擎,支持将文件上传到服务器。使用需要在全局配置中设置上传的目录,以及上传文件访问的前缀。 +By default, GoAdmin provides a local file upload engine that supports uploading files to the server. Use the directory that needs to be set up in the global configuration and the prefix for uploading file access. ```go package config -// 存储目录:存储头像等上传文件 +// Storage directory: store avatar and other uploaded files type Store struct { - Path string // 相对或绝对路径,文件会存储到这里 - Prefix string // 访问前缀 + Path string // relative or absolute path, the file will be stored here + Prefix string // access url prefix } type Config struct { ... - // 上传文件存储的位置 + // Upload file storage location Store Store `json:"store"` - // 文件上传引擎 + // File upload engine FileUploadEngine FileUploadEngine `json:"file_upload_engine"` ... @@ -31,32 +31,29 @@ type FileUploadEngine struct { } ``` -如果你想要自定义上传位置,比如上传到又拍云,七牛云等云平台,那么你需要自己写一个上传引擎。下面介绍如何自己写引擎: +If you want to customize the upload location, such as uploading to cloud, aws cloud and other cloud platforms, then you need to write an upload engine yourself. Here's how to write your own engine: -### 引擎的类型 +### Type of engine ```go package file -// 上传引擎 type Uploader interface { Upload(*multipart.Form) error } -// 上传引擎生成函数 type UploaderGenerator func() Uploader -// 增加引擎接口api func AddUploader(name string, up UploaderGenerator) { ... } ``` -### 调用 +### How to -我们需要调用**AddUploader**方法来增加一个上传引擎,第一个参数是引擎的名字(将在全局配置中用到),第二参数就是引擎生成函数。 +We need to call the **AddUploader** method to add an upload engine. The first parameter is the name of the engine (which will be used in the global configuration) and the second parameter is the engine generation function. -假设我们要增加一个七牛云上传引擎,那么可以类似这样: +Suppose we want to add a aws cloud upload engine, then it can be similar like this: ```go package main @@ -67,7 +64,7 @@ import ( ... ) -type QiNiuUploader struct { +type AwsUploader struct { Bucket string Region string SecretId string @@ -77,7 +74,7 @@ type QiNiuUploader struct { Path string } -func (q QiNiuUploader) Upload(*multipart.Form) error { +func (q AwsUploader) Upload(*multipart.Form) error { // 接收一个表单类型,这里实现上传逻辑 } @@ -85,8 +82,8 @@ func main() { ... - file.AddUploader("qiniu", func() file.Uploader { - return &QiNiuUploader{ + file.AddUploader("aws", func() file.Uploader { + return &AwsUploader{ Bucket: config.Get().FileUploadEngine.Config["bucket"].(string), Region: config.Get().FileUploadEngine.Config["region"].(string), SecretId: config.Get().FileUploadEngine.Config["secret_id"].(string), @@ -100,7 +97,7 @@ func main() { ... FileUploadEngine: config.FileUploadEngine{ - Name: "qiniu", + Name: "aws", Config: map[string]interface{}{ "bucket": "xxx", "region": "xxx", @@ -118,4 +115,4 @@ func main() { } ``` -这样就实现一个七牛云上传文件引擎了!🍺🍺 \ No newline at end of file +Finish a aws cloud upload file engine!🍺🍺 \ No newline at end of file diff --git a/en/admin/form/basic.md b/en/admin/form/basic.md index 183f60c..6d9cbc0 100644 --- a/en/admin/form/basic.md +++ b/en/admin/form/basic.md @@ -1,7 +1,7 @@ -# 基本使用 +# Basic Usage --- -使用命令行将sql表生成一个数据表单类型,如: +Use the cli to generate a data form type for the sql table, such as: ```sql CREATE TABLE `users` ( @@ -17,7 +17,7 @@ CREATE TABLE `users` ( ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ``` -生成了: +Generated: ```go package datamodel @@ -46,28 +46,28 @@ func GetUserTable() (userTable table.Table) { } ``` -### 添加字段 +### Add Fields ```go -// 添加一个字段,字段标题为 ID,字段名为 id,字段类型为 int,表单类型为 Default +// Add a field with the field title ID, field name id, field type int, form type Default formList.AddField("ID", "id", db.Int, form.Default) -// 添加第二个字段,字段标题为 Ip,字段名为 ip,字段类型为 varchar,表单类型为 Text +// Add a second field with the field title Ip, the field name ip, the field type varchar, and the form type Text formList.AddField("Ip", "ip", db.Varchar, form.Text) -// 添加第三个字段,一个sql表不存在的字段 +// Add a third field, a field that does not exist in the sql table formList.AddField("Custom", "custom", db.Varchar, form.Text) ``` -### 不允许编辑 +### Prohibit editing ```go ``` -### 不允许新增 +### No new additions ```go diff --git a/en/admin/form/components.md b/en/admin/form/components.md index e6d6ad6..62cda91 100644 --- a/en/admin/form/components.md +++ b/en/admin/form/components.md @@ -1,111 +1,111 @@ -# 表单组件使用 +# Usage Of Form Components --- ## Default ```go -// 使用 +// usage ``` ## Text ```go -// 使用 +// usage ``` ## SelectSingle ```go -// 使用 +// usage ``` ## Select ```go -// 使用 +// usage ``` ## IconPicker ```go -// 使用 +// usage ``` ## SelectBox ```go -// 使用 +// usage ``` ## File ```go -// 使用 +// usage ``` ## Password ```go -// 使用 +// usage ``` ## RichText ```go -// 使用 +// usage ``` ## Datetime ```go -// 使用 +// usage ``` ## Radio ```go -// 使用 +// usage ``` ## Email ```go -// 使用 +// usage ``` ## Url ```go -// 使用 +// usage ``` ## Ip ```go -// 使用 +// usage ``` ## Color ```go -// 使用 +// usage ``` ## Currency ```go -// 使用 +// usage ``` ## Number ```go -// 使用 +// usage ``` ## TextArea ```go -// 使用 +// usage ``` diff --git a/en/admin/menus.md b/en/admin/menus.md index 08e6acb..b441c88 100644 --- a/en/admin/menus.md +++ b/en/admin/menus.md @@ -1,8 +1,8 @@ -# 设置菜单 +# Setting menu --- -GoAdmin已经内置了权限管理模块。以超级管理员身份进入主页后,展开左侧边栏的管理,下面有管理的管理面板: +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: ![rbac](http://quick.go-admin.cn/docs/menus.png) -点击进去即可设置你所需要的菜单。 \ No newline at end of file +Click inside to set up the menu you need. \ No newline at end of file diff --git a/en/admin/rbac.md b/en/admin/rbac.md index 761e2ac..8c4d8f6 100644 --- a/en/admin/rbac.md +++ b/en/admin/rbac.md @@ -1,6 +1,6 @@ -# 权限管理 +# Authority management --- -GoAdmin已经内置了[RBAC](https://www.baidu.com/s?wd=rbac)权限控制模块。以超级管理员身份进入主页后,展开左侧边栏的管理,下面有用户、角色、权限三项的管理面板: +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: ![rbac](http://quick.go-admin.cn/docs/rbac.png) \ No newline at end of file diff --git a/en/admin/table/basic.md b/en/admin/table/basic.md index 44b08fc..57d9d48 100644 --- a/en/admin/table/basic.md +++ b/en/admin/table/basic.md @@ -1,7 +1,7 @@ -# 基本使用 +# Basic Usage --- -使用命令行将sql表生成一个数据表格类型,如: +Use the command line to generate a data table type for the sql table, such as: ```sql CREATE TABLE `users` ( @@ -17,7 +17,7 @@ CREATE TABLE `users` ( ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ``` -生成了: +Generated: ```go package datamodel @@ -47,26 +47,26 @@ func GetUserTable() (userTable table.Table) { } ``` -### 添加列 +### Add Field ```go -// 添加一个字段,字段标题为 ID,字段名为 id,字段类型为 int +// Add a field with the field title ID, field name id, field type int info.AddField("ID", "id", db.Int) -// 添加第二个字段,字段标题为 Name,字段名为 name,字段类型为 varchar +// Add the second field, the field title is Name, the field name is name, and the field type is varchar info.AddField("Name", "name", db.Varchar) -// 添加第三个字段,一个sql表不存在的字段 +// Add a third field, a field that does not exist in the sql table info.AddField("Custom", "custom", db.Varchar) ``` -### 修改显示输出 +### Modify display output ```go -// 根据字段的值输出对应的内容 +// Output the corresponding content according to the value of the field info.AddField("Gender", "gender", db.Tinyint).FieldDisplay(func(model types.FieldModel) interface{} { if model.Value == "0" { return "men" @@ -77,64 +77,63 @@ info.AddField("Gender", "gender", db.Tinyint).FieldDisplay(func(model types.Fiel return "unknown" }) -// 输出html +// Output html info.AddField("Name", "name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} { return "" + model.Value + "" }) ``` -**FieldDisplay**方法接收的匿名函数绑定了当前行的数据对象,可以在里面调用当前行的其它字段数据 +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. ```go info.AddField("First Name", "first_name", db.Varchar).FieldHide() info.AddField("Last Name", "last_name", db.Varchar).FieldHide() -// 不存的字段列 +// non-existing field columns info.AddField("Full Name", "full_name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} { return model.Row["first_name"].(string) + " " + model.Row["last_name"].(string) }) ``` -### 禁用创建按钮 +### Hide create button ```go info.HideNewButton() ``` -### 禁用编辑按钮 +### Hide edit button ```go info.HideEditButton() ``` -### 禁用导出按钮 +### Hide export button ```go info.HideExportButton() ``` -### 禁用删除按钮 +### Hide delete button ```go info.HideDeleteButton() ``` -## 连表 +## Join Table -连表需要设置连表表名与连表字段 +The table needs to set the table name and the table field ```go -// 增加字段名 info.AddField("Role Name", "role_name", db.Varchar).FieldJoin(types.Join{ - Table: "role", // 连表的表名 - Field: "id", // 要连表的字段 - JoinField: "user_id", // 连表的表的字段 + Table: "role", // table name which you want to join + Field: "id", // table field name of your own + JoinField: "user_id", // table field name of the table which you want to join }) ``` -这将会生成类似这样的sql语句: +It will generate a sql statement like this: ```sql select ..., role.`role_name` from users left join role on users.`id` = role.`user_id` where ... diff --git a/en/admin/table/column_usage.md b/en/admin/table/column_usage.md index 04f0f53..11f6e24 100644 --- a/en/admin/table/column_usage.md +++ b/en/admin/table/column_usage.md @@ -1,73 +1,73 @@ -# 列的使用 +# Usage Of Column --- -**InfoPanel**内置了很多对于列的操作方法,可以通过这些方法很灵活的操作列数据。 +**InfoPanel** has a lot of built-in operation methods for columns, which can be used to manipulate column data very flexibly. -### 设置列宽 +### Set Width ```go info.AddField("Name", "name", db.Varchar).FieldWidth(100) ``` -### 默认隐藏列 +### Hide ```go info.AddField("Name", "name", db.Varchar).FieldHide() ``` -### 设置为可排序 +### Be Sortable ```go info.AddField("Name", "name", db.Varchar).FieldSortable() ``` -### 设置为固定 +### Be Fixed ```go info.AddField("Name", "name", db.Varchar).FieldFixed() ``` -### 设置为可过滤 +### Be Filterable ```go info.AddField("Name", "name", db.Varchar).FieldFilterable() ``` -## 帮助方法 +## Help Methods -### 字符串操作 +### String manipulation -限制输出长度 +Limit the output length ```go info.AddField("Name", "name", db.Varchar).FieldLimit(10) ``` -首字母大写 +Title ```go info.AddField("Name", "name", db.Varchar).FieldToTitle() ``` -去除空格 +Trim space ```go info.AddField("Name", "name", db.Varchar).FieldTrimSpace() ``` -字符串截取 +String interception ```go info.AddField("Name", "name", db.Varchar).FieldSubstr(0, 3) ``` -字符串转大写 +String to uppercase ```go info.AddField("Name", "name", db.Varchar).FieldToUpper() ``` -字符串转小写 +String to lowercase ```go info.AddField("Name", "name", db.Varchar).FieldToLower() diff --git a/en/architecture/introduction.md b/en/architecture/introduction.md index 30d1dda..8beda42 100644 --- a/en/architecture/introduction.md +++ b/en/architecture/introduction.md @@ -1,20 +1,20 @@ -# 项目架构 +# Introduction --- -GoAdmin的项目模块如下: +The GoAdmin project module is as follows: -| 模块名 | 模块功能 | 模块位置 | +| Name | Function | Path | | ---- | ---- | ---- | -| engine | engine是GoAdmin最核心的模块,此模块的功能是利用web框架适配器将插件的路由与控制器方法的映射关系注入到框架中 | ./engine/engine.go -| adapter | adapter的功能是实现web框架的context与GoAdmin的context的相互转换 | ./adapter/adapter.go -| context | context是一个请求的上下文,记录包括了请求的路由参数与方法信息,context会被传入到插件的方法中 | ./context/context.go -| plugin | plugin有自己的路由与控制器方法,在接收由adapter转换过来的context后经控制器方法处理返回给adapter再输出到web框架中去 | ./plugins/plugins.go -| template | template是前端代码对应的golang实体化,前端代码对应的组件部分,比如表单,行,列等实体化为golang的一个接口,因此可以通过调用接口方法获取到该组件的html代码,此功能提供给插件去调用 | ./template/template.go -| auth | auth实现了对cookie的管理,将前端的cookie存储并转换为登录的用户,同时实现了对权限的拦截 | ./modules/auth/auth.go -| config | config是系统的全局配置 | ./modules/config/config.go -| db | db是一个sql连接库,连接了sql数据库提供查询等帮助方法,支持多个driver | ./modules/db/connection.go -| language | language实现了简单的语言映射,从而支持语言本地化 | ./modules/language/language.go -| file | file实现了一个文件上传引擎 | ./modules/file/file.go -| logger | logger是项目的日志模块 | ./modules/logger/logger.go -| menu | menu是对项目菜单的管理 | ./modules/menu/menu.go -| cli | cli命令行模块,包括生成文件和开发的一些基本命令 | ./admincli/cli.go \ No newline at end of file +| 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 +| 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 +| 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 +| 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 +| 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 +| 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 +| config | Config is the global configuration of the system | ./modules/config/config.go +| 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 +| language | Language implements a simple language mapping to support language localization | ./modules/language/language.go +| file | File implements a file upload engine | ./modules/file/file.go +| logger | The logger is the log module of the project | ./modules/logger/logger.go +| menu | Menu is the management of the project menu | ./modules/menu/menu.go +| cli | Cli command line module, including some basic commands for generating files and development | ./admincli/cli.go \ No newline at end of file diff --git a/en/development/adapter.md b/en/development/adapter.md index eaf6636..4301e00 100644 --- a/en/development/adapter.md +++ b/en/development/adapter.md @@ -1,2 +1,58 @@ # Adapter Development ---- \ No newline at end of file +--- + +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: + +```go +package adapter + +import ( + "github.com/GoAdminGroup/go-admin/plugins" + "github.com/GoAdminGroup/go-admin/template/types" +) + +// WebFrameWork is a interface which is used as an adapter of +// framework and goAdmin. It must implement two methods. Use registers +// the routes and the corresponding handlers. Content writes the +// response to the corresponding context of framework. +type WebFrameWork interface { + Use(interface{}, []plugins.Plugin) error + Content(interface{}, types.GetPanel) +} +``` + +In addition to ```Use``` and ```Content```, you need to implement ```init``` + +## Use + +**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: + +```go +"/admin/example" => ShowExample(ctx *context.Context) +``` + +After processing by ```Use```, it will be injected into the web framework. + +## Content + +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. + +As follow: + +```go +type GetPanel func(ctx interface{}) (Panel, error) +``` + +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. + +## init + +The **init** method injects the adapter into the engine so it can be used by others. + +```go +func init() { + engine.Register(new(Beego)) +} +``` \ No newline at end of file diff --git a/en/development/code_style.md b/en/development/code_style.md index 8228425..bb81769 100644 --- a/en/development/code_style.md +++ b/en/development/code_style.md @@ -1,4 +1,4 @@ -# 代码规范 +# Code Style --- ``` diff --git a/fr/README.md b/fr/README.md new file mode 100644 index 0000000..647f035 --- /dev/null +++ b/fr/README.md @@ -0,0 +1,44 @@ +# Introduction +------ + +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. +
+
+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. + +here is very simple example which show you how it work: [https://github.com/GoAdminGroup/example](https://github.com/GoAdminGroup/example) + + +## Features + +- Build-in RBAC Access Authentication System +- Support most web framework +- Support plug-ins(working on it) +- Provided different ui theme(only Adminlte now, others are coming soon.) + +## Demo + +[http://demo.go-admin.cn/admin](http://demo.go-admin.cn/admin) + +## Dependencies + +- [Datetimepicker](http://eonasdan.github.io/bootstrap-datetimepicker/) +- [font-awesome](http://fontawesome.io/) +- [bootstrap-fileinput](https://github.com/kartik-v/bootstrap-fileinput) +- [jquery-pjax](https://github.com/defunkt/jquery-pjax) +- [Nestable](http://dbushell.github.io/Nestable/) +- [toastr](http://codeseven.github.io/toastr/) +- [bootstrap-number-input](https://github.com/wpic/bootstrap-number-input) +- [fontawesome-iconpicker](https://github.com/itsjavi/fontawesome-iconpicker) + +## Community + +[Community](http://forum.go-admin.cn) + +## Backers + +Your support will help me do better! + + \ No newline at end of file diff --git a/fr/_sidebar.md b/fr/_sidebar.md new file mode 100644 index 0000000..19f977e --- /dev/null +++ b/fr/_sidebar.md @@ -0,0 +1,46 @@ +* [Introducation](README) + +* [Get Ready](install) + +* [Quick Start](quick_start) + +* Plugins + + * [How To Use Plugins](plugins/plugins) + * [How To Use Admin Plugin](plugins/admin) + +* Admin Plugins + + * Data Table + * [Basic Usage](admin/table/basic) + * [Column Usage](admin/table/column_usage) + * Data Form + * [Basic Usage](admin/form/basic) + * [Form Components](admin/form/components) + * [Menus](admin/menus) + * [Permissions](admin/rbac) + * [File Upload](admin/file) + * [Cli](admin/cli) + +* Pages + + * [Page Modules](pages/modules) + * [Customize Your Page](pages/pages) + * [Customize Login Page](pages/login) + +* Architecture + + * [Introduction](architecture/introduction) + +* Development + + * [Code Style](development/code_style) + * [Adapter Development](development/adapter) + * [Plugins Development](development/plugins) + * Template Development + + * [Template Introducation](development/template/template) + * [Form Development](development/template/form) + * [Components](development/template/components) + +* [Plan](plan) \ No newline at end of file diff --git a/fr/admin/cli.md b/fr/admin/cli.md new file mode 100644 index 0000000..c00ad7a --- /dev/null +++ b/fr/admin/cli.md @@ -0,0 +1,43 @@ +# Cli Introduction +--- + +GoAdmin provides a command line tool to increase development efficiency and streamline the development process. + +## Install + + +Download the binary of the corresponding system: + +| File name | OS | Arch | Size | +| ---- | ---- | ---- |---- | +| [admincli_darwin_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_darwin_x86_64_v1.0.1.zip) | macOs | x86-64 | 4.77 MB +| [admincli_linux_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_linux_x86_64_v1.0.1.zip) | Linux | x86-64 | 6.52 MB +| [admincli_linux_armel_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_linux_armel_v1.0.1.zip) | Linux | x86 | 6.06 MB +| [admincli_windows_i386_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_windows_i386_v1.0.1.zip) | Windows | x86 |6.16 MB +| [admincli_windows_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_windows_x86_64_v1.0.1.zip) | Windows | x86-64 |6.38 MB + + +Or use the command to install: + +``` +go install github.com/GoAdminGroup/go-admin/admincli +``` + +## Usage + +Use + +``` +admincli --help +``` + +Will list help information. + +| Command | Subcommand | Options | Function | +| ---- | ---- | ---- | ---- | +| generate | - | - | generate a data model file. +| compile | asset| **-s, --src** front-end resource folder path
**-o, --out** output go file path | compile all resource files into one single go file. +| compile | tpl | **-s, --src** the input golang tmpl template folder path
**-o, --out** output go file path | compile all template files into one single go file. +| combine | css| **-s, --src** the input css folder path
**-o, --out** the output css file path | combine the css files into one single css file. +| combine | js | **-s, --src** the input js folder path
**-o, --out** the output js file path | combine the js files into one single js file. +| develop | tpl | **-m, --module** golang module name or path under $GOPATH
**-n, --name** theme name | fetch remotely theme development templates to local. diff --git a/fr/admin/file.md b/fr/admin/file.md new file mode 100644 index 0000000..84e5373 --- /dev/null +++ b/fr/admin/file.md @@ -0,0 +1,118 @@ +# File Upload Engine +--- + +By default, GoAdmin provides a local file upload engine that supports uploading files to the server. Use the directory that needs to be set up in the global configuration and the prefix for uploading file access. + +```go +package config + +// Storage directory: store avatar and other uploaded files +type Store struct { + Path string // relative or absolute path, the file will be stored here + Prefix string // access url prefix +} + +type Config struct { + + ... + + // Upload file storage location + Store Store `json:"store"` + + // File upload engine + FileUploadEngine FileUploadEngine `json:"file_upload_engine"` + + ... +} + +type FileUploadEngine struct { + Name string + Config map[string]interface{} +} +``` + +If you want to customize the upload location, such as uploading to cloud, aws cloud and other cloud platforms, then you need to write an upload engine yourself. Here's how to write your own engine: + +### Type of engine + +```go +package file + +type Uploader interface { + Upload(*multipart.Form) error +} + +type UploaderGenerator func() Uploader + +func AddUploader(name string, up UploaderGenerator) { + ... +} +``` + +### How to + +We need to call the **AddUploader** method to add an upload engine. The first parameter is the name of the engine (which will be used in the global configuration) and the second parameter is the engine generation function. + +Suppose we want to add a aws cloud upload engine, then it can be similar like this: + +```go +package main + +import ( + ... + "github.com/GoAdminGroup/go-admin/modules/file" + ... +) + +type AwsUploader struct { + Bucket string + Region string + SecretId string + SecretKey string + + Prefix string + Path string +} + +func (q AwsUploader) Upload(*multipart.Form) error { + // 接收一个表单类型,这里实现上传逻辑 +} + +func main() { + + ... + + file.AddUploader("aws", func() file.Uploader { + return &AwsUploader{ + Bucket: config.Get().FileUploadEngine.Config["bucket"].(string), + Region: config.Get().FileUploadEngine.Config["region"].(string), + SecretId: config.Get().FileUploadEngine.Config["secret_id"].(string), + SecretKey: config.Get().FileUploadEngine.Config["secret_key"].(string), + Prefix: config.Get().FileUploadEngine.Config["prefix"].(string), + Path: config.Get().FileUploadEngine.Config["path"].(string), + } + }) + + cfg := config.Config{ + ... + + FileUploadEngine: config.FileUploadEngine{ + Name: "aws", + Config: map[string]interface{}{ + "bucket": "xxx", + "region": "xxx", + "secret_id": "xxx", + "secret_key": "xxx", + "prefix": "xxx", + "path": "xxx", + }, + } + + ... + } + + ... +} +``` + +Finish a aws cloud upload file engine!🍺🍺 \ No newline at end of file diff --git a/fr/admin/form/basic.md b/fr/admin/form/basic.md new file mode 100644 index 0000000..6d9cbc0 --- /dev/null +++ b/fr/admin/form/basic.md @@ -0,0 +1,74 @@ +# Basic Usage +--- + +Use the cli to generate a data form type for the sql table, such as: + +```sql +CREATE TABLE `users` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `gender` tinyint(4) DEFAULT NULL, + `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +``` + +Generated: + +```go +package datamodel + +import ( + ... +) + +func GetUserTable() (userTable table.Table) { + + // config the table model. + userTable = table.NewDefaultTable(...) + + ... + + formList := userTable.GetForm() + + // set id editable is false. + formList.AddField("ID", "id", db.Int, form.Default).FieldNotAllowEdit() + formList.AddField("Ip", "ip", db.Varchar, form.Text) + formList.AddField("Name", "name", db.Varchar, form.Text) + + ... + + return +} +``` + +### Add Fields + +```go + +// Add a field with the field title ID, field name id, field type int, form type Default +formList.AddField("ID", "id", db.Int, form.Default) + +// Add a second field with the field title Ip, the field name ip, the field type varchar, and the form type Text +formList.AddField("Ip", "ip", db.Varchar, form.Text) + +// Add a third field, a field that does not exist in the sql table +formList.AddField("Custom", "custom", db.Varchar, form.Text) + +``` + +### Prohibit editing + +```go + +``` + +### No new additions + +```go + +``` \ No newline at end of file diff --git a/fr/admin/form/components.md b/fr/admin/form/components.md new file mode 100644 index 0000000..62cda91 --- /dev/null +++ b/fr/admin/form/components.md @@ -0,0 +1,111 @@ +# Usage Of Form Components +--- + +## Default + +```go +// usage +``` + +## Text + +```go +// usage +``` + +## SelectSingle + +```go +// usage +``` + +## Select + +```go +// usage +``` + +## IconPicker + +```go +// usage +``` + +## SelectBox + +```go +// usage +``` + +## File + +```go +// usage +``` + +## Password + +```go +// usage +``` + +## RichText + +```go +// usage +``` + +## Datetime + +```go +// usage +``` + +## Radio + +```go +// usage +``` + +## Email + +```go +// usage +``` + +## Url + +```go +// usage +``` + +## Ip + +```go +// usage +``` + +## Color + +```go +// usage +``` + +## Currency + +```go +// usage +``` + +## Number + +```go +// usage +``` + +## TextArea + +```go +// usage +``` + diff --git a/fr/admin/menus.md b/fr/admin/menus.md new file mode 100644 index 0000000..b441c88 --- /dev/null +++ b/fr/admin/menus.md @@ -0,0 +1,8 @@ +# Setting menu +--- + +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: + +![rbac](http://quick.go-admin.cn/docs/menus.png) + +Click inside to set up the menu you need. \ No newline at end of file diff --git a/fr/admin/rbac.md b/fr/admin/rbac.md new file mode 100644 index 0000000..8c4d8f6 --- /dev/null +++ b/fr/admin/rbac.md @@ -0,0 +1,6 @@ +# Authority management +--- + +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: + +![rbac](http://quick.go-admin.cn/docs/rbac.png) \ No newline at end of file diff --git a/fr/admin/table/basic.md b/fr/admin/table/basic.md new file mode 100644 index 0000000..57d9d48 --- /dev/null +++ b/fr/admin/table/basic.md @@ -0,0 +1,140 @@ +# Basic Usage +--- + +Use the command line to generate a data table type for the sql table, such as: + +```sql +CREATE TABLE `users` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `gender` tinyint(4) DEFAULT NULL, + `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +``` + +Generated: + +```go +package datamodel + +import ( + ... +) + +func GetUserTable() (userTable table.Table) { + + // config the table model. + userTable = table.NewDefaultTable(table.Config{...}) + + info := userTable.GetInfo() + + // set id sortable. + info.AddField("ID", "id", db.Int).FieldSortable(true) + info.AddField("Name", "name", db.Varchar) + + ... + + // set the title and description of table page. + info.SetTable("users").SetTitle("Users").SetDescription("Users"). + SetAction(template.HTML(``)) // custom operation button + + ... +} +``` + +### Add Field + +```go + +// Add a field with the field title ID, field name id, field type int +info.AddField("ID", "id", db.Int) + +// Add the second field, the field title is Name, the field name is name, and the field type is varchar +info.AddField("Name", "name", db.Varchar) + +// Add a third field, a field that does not exist in the sql table +info.AddField("Custom", "custom", db.Varchar) + +``` + +### Modify display output + +```go + +// Output the corresponding content according to the value of the field +info.AddField("Gender", "gender", db.Tinyint).FieldDisplay(func(model types.FieldModel) interface{} { + if model.Value == "0" { + return "men" + } + if model.Value == "1" { + return "women" + } + return "unknown" +}) + +// Output html +info.AddField("Name", "name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} { + return "" + model.Value + "" +}) +``` + +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. + +```go +info.AddField("First Name", "first_name", db.Varchar).FieldHide() +info.AddField("Last Name", "last_name", db.Varchar).FieldHide() + +// non-existing field columns +info.AddField("Full Name", "full_name", db.Varchar).FieldDisplay(func(model types.FieldModel) interface{} { + return model.Row["first_name"].(string) + " " + model.Row["last_name"].(string) +}) +``` + +### Hide create button + +```go +info.HideNewButton() +``` + +### Hide edit button + +```go +info.HideEditButton() +``` + +### Hide export button + +```go +info.HideExportButton() +``` + +### Hide delete button + +```go +info.HideDeleteButton() +``` + +## Join Table + +The table needs to set the table name and the table field + +```go + +info.AddField("Role Name", "role_name", db.Varchar).FieldJoin(types.Join{ + Table: "role", // table name which you want to join + Field: "id", // table field name of your own + JoinField: "user_id", // table field name of the table which you want to join +}) + +``` + +It will generate a sql statement like this: + +```sql +select ..., role.`role_name` from users left join role on users.`id` = role.`user_id` where ... +``` \ No newline at end of file diff --git a/fr/admin/table/column_usage.md b/fr/admin/table/column_usage.md new file mode 100644 index 0000000..11f6e24 --- /dev/null +++ b/fr/admin/table/column_usage.md @@ -0,0 +1,74 @@ +# Usage Of Column +--- + +**InfoPanel** has a lot of built-in operation methods for columns, which can be used to manipulate column data very flexibly. + +### Set Width + +```go +info.AddField("Name", "name", db.Varchar).FieldWidth(100) +``` + +### Hide + +```go +info.AddField("Name", "name", db.Varchar).FieldHide() +``` + +### Be Sortable + +```go +info.AddField("Name", "name", db.Varchar).FieldSortable() +``` + +### Be Fixed + +```go +info.AddField("Name", "name", db.Varchar).FieldFixed() +``` + +### Be Filterable + +```go +info.AddField("Name", "name", db.Varchar).FieldFilterable() +``` + +## Help Methods + +### String manipulation + +Limit the output length + +```go +info.AddField("Name", "name", db.Varchar).FieldLimit(10) +``` + +Title + +```go +info.AddField("Name", "name", db.Varchar).FieldToTitle() +``` + +Trim space + +```go +info.AddField("Name", "name", db.Varchar).FieldTrimSpace() +``` + +String interception + +```go +info.AddField("Name", "name", db.Varchar).FieldSubstr(0, 3) +``` + +String to uppercase + +```go +info.AddField("Name", "name", db.Varchar).FieldToUpper() +``` + +String to lowercase + +```go +info.AddField("Name", "name", db.Varchar).FieldToLower() +``` \ No newline at end of file diff --git a/fr/architecture/introduction.md b/fr/architecture/introduction.md new file mode 100644 index 0000000..8beda42 --- /dev/null +++ b/fr/architecture/introduction.md @@ -0,0 +1,20 @@ +# Introduction +--- + +The GoAdmin project module is as follows: + +| Name | Function | Path | +| ---- | ---- | ---- | +| 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 +| 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 +| 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 +| 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 +| 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 +| 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 +| config | Config is the global configuration of the system | ./modules/config/config.go +| 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 +| language | Language implements a simple language mapping to support language localization | ./modules/language/language.go +| file | File implements a file upload engine | ./modules/file/file.go +| logger | The logger is the log module of the project | ./modules/logger/logger.go +| menu | Menu is the management of the project menu | ./modules/menu/menu.go +| cli | Cli command line module, including some basic commands for generating files and development | ./admincli/cli.go \ No newline at end of file diff --git a/fr/development/adapter.md b/fr/development/adapter.md new file mode 100644 index 0000000..4301e00 --- /dev/null +++ b/fr/development/adapter.md @@ -0,0 +1,58 @@ +# Adapter Development +--- + +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: + +```go +package adapter + +import ( + "github.com/GoAdminGroup/go-admin/plugins" + "github.com/GoAdminGroup/go-admin/template/types" +) + +// WebFrameWork is a interface which is used as an adapter of +// framework and goAdmin. It must implement two methods. Use registers +// the routes and the corresponding handlers. Content writes the +// response to the corresponding context of framework. +type WebFrameWork interface { + Use(interface{}, []plugins.Plugin) error + Content(interface{}, types.GetPanel) +} +``` + +In addition to ```Use``` and ```Content```, you need to implement ```init``` + +## Use + +**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: + +```go +"/admin/example" => ShowExample(ctx *context.Context) +``` + +After processing by ```Use```, it will be injected into the web framework. + +## Content + +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. + +As follow: + +```go +type GetPanel func(ctx interface{}) (Panel, error) +``` + +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. + +## init + +The **init** method injects the adapter into the engine so it can be used by others. + +```go +func init() { + engine.Register(new(Beego)) +} +``` \ No newline at end of file diff --git a/fr/development/code_style.md b/fr/development/code_style.md new file mode 100644 index 0000000..bb81769 --- /dev/null +++ b/fr/development/code_style.md @@ -0,0 +1,6 @@ +# Code Style +--- + +``` +make lint +``` \ No newline at end of file diff --git a/fr/development/plugins.md b/fr/development/plugins.md new file mode 100644 index 0000000..8b0fec9 --- /dev/null +++ b/fr/development/plugins.md @@ -0,0 +1,7 @@ +# Plugins Development +--- + +Example:
+ +- [develop a plugin used by source code](https://github.com/GoAdminGroup/go-admin/blob/master/plugins/example/example.go) +- [develop a plugin used by golang plugin](https://github.com/GoAdminGroup/go-admin/blob/master/plugins/example/go_plugin/main.go) diff --git a/fr/development/template/components.md b/fr/development/template/components.md new file mode 100644 index 0000000..eb63087 --- /dev/null +++ b/fr/development/template/components.md @@ -0,0 +1,97 @@ +# Components Development +--- + +Component development, taking the image component as an example. + +## New types and methods of upper interface + +- Create a new ```ImgAttribute``` type + +```go +type ImgAttribute interface { + SetWidth(value string) ImgAttribute + SetHeight(value string) ImgAttribute + SetSrc(value string) ImgAttribute + GetContent() template.HTML +} +``` + +- In the ```Template``` interface, add a method: + +```go +type Template interface { + ... + Image() types.ImgAttribute + ... +} +``` + +## Specific implementation, with ```adminlte``` as an example + +- ```ImgAttribute``` + +Create a new ```image.go``` file under ```./template/adminlte/components```, as follows: + +```go +package components + +import ( + "github.com/GoAdminGroup/go-admin/template/types" + "html/template" +) + +type ImgAttribute struct { + Name string + Witdh string + Height string + Src string +} + +func (compo *ImgAttribute) SetWidth(value string) types.ImgAttribute { + compo.Witdh = value + return compo +} + +func (compo *ImgAttribute) SetHeight(value string) types.ImgAttribute { + compo.Height = value + return compo +} + +func (compo *ImgAttribute) SetSrc(value string) types.ImgAttribute { + compo.Src = value + return compo +} + +func (compo *ImgAttribute) GetContent() template.HTML { + return ComposeHtml(compo.TemplateList, *compo, "image") +} +``` + +- ```Image()``` + +In ```.template/adminlte/adminlte.go```, add a function: + +```go +func (*Theme) Image() types.ImgAttribute { + return &components.ImgAttribute{ + Name: "image", + Witdh: "50", + Height: "50", + Src: "", + } +} +``` + +Still not completed here, you need to add static resource files. + +- Add the static resource file + +Add ```image.tmpl``` file to ```.template/adminlte/resource/pages/components``` + +Annoying, and the last step + +- Execute in the root directory: + +```shell +admincli assets +``` \ No newline at end of file diff --git a/fr/development/template/form.md b/fr/development/template/form.md new file mode 100644 index 0000000..7323cb4 --- /dev/null +++ b/fr/development/template/form.md @@ -0,0 +1,2 @@ +# Form Development +--- \ No newline at end of file diff --git a/fr/development/template/template.md b/fr/development/template/template.md new file mode 100644 index 0000000..97c9160 --- /dev/null +++ b/fr/development/template/template.md @@ -0,0 +1,41 @@ +# Template Introducation +--- + +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: + +```go +type Template interface { + // Components + Form() types.FormAttribute + Box() types.BoxAttribute + Col() types.ColAttribute + Image() types.ImgAttribute + SmallBox() types.SmallBoxAttribute + Label() types.LabelAttribute + Row() types.RowAttribute + Table() types.TableAttribute + DataTable() types.DataTableAttribute + Tree() types.TreeAttribute + InfoBox() types.InfoBoxAttribute + Paginator() types.PaginatorAttribute + AreaChart() types.AreaChartAttribute + ProgressGroup() types.ProgressGroupAttribute + LineChart() types.LineChartAttribute + BarChart() types.BarChartAttribute + ProductList() types.ProductListAttribute + Description() types.DescriptionAttribute + Alert() types.AlertAttribute + PieChart() types.PieChartAttribute + ChartLegend() types.ChartLegendAttribute + Tabs() types.TabsAttribute + Popup() types.PopupAttribute + + // Builder methods + GetTmplList() map[string]string + GetAssetList() []string + GetAsset(string) ([]byte, error) + GetTemplate(bool) (*template.Template, string) +} +``` + +To develop a ui theme template, you need to implement the above ```Template``` interface. \ No newline at end of file diff --git a/fr/index.html b/fr/index.html new file mode 100644 index 0000000..c17f286 --- /dev/null +++ b/fr/index.html @@ -0,0 +1,46 @@ + + + + + GoAdmin Document + + + + + + +
+ + + + + + + + + + diff --git a/fr/install.md b/fr/install.md new file mode 100644 index 0000000..c4bbccc --- /dev/null +++ b/fr/install.md @@ -0,0 +1,41 @@ +# Get Ready +--- + +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) + +## Import the program required sql to the corresponding self-built database + +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. + +- [mysql](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.sql) +- [sqlite](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.db) +- [postgresql](https://raw.githubusercontent.com/GoAdminGroup/go-admin/master/data/admin.pgsql) + +## Install command line tools + +Download the binary excecute file: + +| File name | OS | Arch | Size | +| ---- | ---- | ---- |---- | +| [admincli_darwin_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_darwin_x86_64_v1.0.1.zip) | macOs | x86-64 | 4.77 MB +| [admincli_linux_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_linux_x86_64_v1.0.1.zip) | Linux | x86-64 | 6.52 MB +| [admincli_linux_armel_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_linux_armel_v1.0.1.zip) | Linux | x86 | 6.06 MB +| [admincli_windows_i386_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_windows_i386_v1.0.1.zip) | Windows | x86 |6.16 MB +| [admincli_windows_x86_64_v1.0.1.zip](http://file.go-admin.cn/go_admin/cli/v1_0_1/admincli_windows_x86_64_v1.0.1.zip) | Windows | x86-64 |6.38 MB + + +Or Use the command: + +``` +go install github.com/GoAdminGroup/go-admin/admincli +``` + +
+ +🍺🍺 Get ready to work here, next to the [Quick start](init-project) + +
+ +> 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. + + diff --git a/fr/pages/components.md b/fr/pages/components.md new file mode 100644 index 0000000..a293caf --- /dev/null +++ b/fr/pages/components.md @@ -0,0 +1,2 @@ +# Components +---- \ No newline at end of file diff --git a/fr/pages/login.md b/fr/pages/login.md new file mode 100644 index 0000000..dff77c0 --- /dev/null +++ b/fr/pages/login.md @@ -0,0 +1,50 @@ +# 更改登录界面 +--- + +通过组件的方式可以修改登录界面,如下例子: + +更多登录界面组件[看这里](https://github.com/GoAdminGroup/components/blob/master/login/README.md);加载后引入即可。 + +```go +package main + +import ( + "github.com/GoAdminGroup/demo/ecommerce" + "github.com/GoAdminGroup/demo/login" + "github.com/GoAdminGroup/demo/pages" + _ "github.com/GoAdminGroup/go-admin/adapter/gin" + "github.com/GoAdminGroup/go-admin/engine" + "github.com/GoAdminGroup/go-admin/examples/datamodel" + "github.com/GoAdminGroup/go-admin/plugins/admin" + "github.com/GoAdminGroup/go-admin/plugins/example" + "github.com/GoAdminGroup/go-admin/template" + "github.com/GoAdminGroup/go-admin/template/types" + "github.com/gin-gonic/gin" +) + +func main() { + r := gin.Default() + + eng := engine.Default() + + adminPlugin := admin.NewAdmin(datamodel.Generators) + adminPlugin.AddGenerator("user", datamodel.GetUserTable) + + // 增加登录组件 + template.AddLoginComp(login.GetLoginComponent()) + + // you can custom a plugin like: + + examplePlugin := example.NewExample() + + rootPath := "/data/www/go-admin" + + if err := eng.AddConfigFromJson(rootPath+"/config.json").AddPlugins(adminPlugin, examplePlugin).Use(r); err != nil { + panic(err) + } + + r.Static("/uploads", rootPath+"/uploads") + + _ = r.Run(":9033") +} +``` diff --git a/fr/pages/modules.md b/fr/pages/modules.md new file mode 100644 index 0000000..80eb238 --- /dev/null +++ b/fr/pages/modules.md @@ -0,0 +1,80 @@ +# Page Modules +--- + +Page customization needs to call the engine's ```Content``` method, which needs to return an object ```types.Panel``` + +The following is the definition of ```types.Panel```: + +```go +type Panel struct { + Content template.HTML + Title string + Description string + Url string +} +``` + +Corresponding ui, you can see the following picture: + +![](http://quizfile.dadadaa.cn/everyday/app/jlds/img/006tNbRwly1fxoz5bm02oj31ek0u0wtz.jpg) + +## How to use + +```go +package datamodel + +import ( + "github.com/GoAdminGroup/go-admin/modules/config" + template2 "github.com/GoAdminGroup/go-admin/template" + "github.com/GoAdminGroup/go-admin/template/types" + "html/template" +) + +func GetContent() (types.Panel, error) { + + components := template2.Get(config.Get().THEME) + colComp := components.Col() + + infobox := components.InfoBox(). + SetText("CPU TRAFFIC"). + SetColor("blue"). + SetNumber("41,410"). + SetIcon("ion-ios-gear-outline"). + GetContent() + + var size = map[string]string{"md": "3", "sm": "6", "xs": "12"} + infoboxCol1 := colComp.SetSize(size).SetContent(infobox).GetContent() + row1 := components.Row().SetContent(infoboxCol1).GetContent() + + return types.Panel{ + Content: row1, + Title: "Dashboard", + Description: "this is a example", + }, nil +} +``` + +## Col + +A col is type of ```ColAttribute```, has three methods: + +```go +type ColAttribute interface { + SetSize(value map[string]string) ColAttribute + SetContent(value template.HTML) ColAttribute + GetContent() template.HTML +} +``` + +About the ```size```,example is ```map[string]string{"md": "3", "sm": "6", "xs": "12"}``` + +## Row + +A row is type of ```RowAttribute```, has two methods: + +```go +type RowAttribute interface { + SetContent(value template.HTML) RowAttribute + GetContent() template.HTML +} +``` diff --git a/fr/pages/pages.md b/fr/pages/pages.md new file mode 100644 index 0000000..66db8a0 --- /dev/null +++ b/fr/pages/pages.md @@ -0,0 +1,85 @@ +# Customize your page +--- + +call the method ```Content```of the engine: + +```go +package main + +import ( + _ "github.com/GoAdminGroup/go-admin/adapter/gin" + "github.com/GoAdminGroup/go-admin/engine" + "github.com/GoAdminGroup/go-admin/examples/datamodel" + "github.com/GoAdminGroup/go-admin/modules/config" + "github.com/GoAdminGroup/go-admin/plugins/admin" + "github.com/GoAdminGroup/go-admin/plugins/example" + "github.com/GoAdminGroup/go-admin/template/types" + "github.com/gin-gonic/gin" +) + +func main() { + r := gin.Default() + + eng := engine.Default() + + cfg := config.Config{} + + adminPlugin := admin.NewAdmin(datamodel.Generators) + + examplePlugin := example.NewExample() + + if err := eng.AddConfig(cfg).AddPlugins(adminPlugin, examplePlugin).Use(r); err != nil { + panic(err) + } + + r.Static("/uploads", "./uploads") + + // here to custom a page. + + r.GET("/"+cfg.PREFIX+"/custom", func(ctx *gin.Context) { + engine.Content(ctx, func() (types.Panel, error) { + return datamodel.GetContent() + }) + }) + + r.Run(":9033") +} +``` + +```Content```will write the contents into the ```context``` of the framework. + +here is the code of ```GetContent```: + +```go +package datamodel + +import ( + "github.com/GoAdminGroup/go-admin/modules/config" + template2 "github.com/GoAdminGroup/go-admin/template" + "github.com/GoAdminGroup/go-admin/template/types" + "html/template" +) + +func GetContent() (types.Panel, error) { + + components := template2.Get(config.Get().THEME) + colComp := components.Col() + + infobox := components.InfoBox(). + SetText("CPU TRAFFIC"). + SetColor("blue"). + SetNumber("41,410"). + SetIcon("ion-ios-gear-outline"). + GetContent() + + var size = map[string]string{"md": "3", "sm": "6", "xs": "12"} + infoboxCol1 := colComp.SetSize(size).SetContent(infobox).GetContent() + row1 := components.Row().SetContent(infoboxCol1).GetContent() + + return types.Panel{ + Content: row1, + Title: "Dashboard", + Description: "this is a example", + }, nil +} +``` diff --git a/fr/plan.md b/fr/plan.md new file mode 100644 index 0000000..b90d467 --- /dev/null +++ b/fr/plan.md @@ -0,0 +1,62 @@ +# 发展计划 +--- + +GoAdmin的定位不只是一个管理后台中心构建框架,目前在1.0基础版本已经实现了一个能快速构建简单的crud以及有权限管理功能的管理后台的基础构建框架。在此基础上,可以对主题以及插件等进行一定程度的定制。以下分三点阐述这个项目以后的发展计划: + +## 项目功能规划 + +GoAdmin的目标是实现无代码化或某种程度的无代码化可视化操作,内置插件会至少包括:简单与复杂商业化crud管理中心极速构建,支持多数据源的监控体系的搭建等等。以下是对版本的初步规划: + +### 1.0.0 版本 + +- 实现基础的框架,同时提供一个内置插件能够满足快速构建crud管理后台。 +- 这个基础框架可以实现前端主题的自由定制,以及对插件的加载。 + +### 2.0.0 版本 + +- 在 1.0 版本的基础上,此版本将完善内置插件的功能,基本达到商业化水平(能够提供一个ec商城后台/saas系统的所有功能) +- 完善主题和插件的开发工具链,使得非项目开发人员都能够轻松的上手主题与插件的开发 +- 提供更多样化的内置主题与内置插件 +- 监控体系的初步支持(实时监控系统,数据前端展示,定制数据源) +- 项目性能的评估与优化 + +### 3.0.0 版本 + +- 可生产环境商业化的监控体系支持 +- 初步实现界面数据化以及实现一个界面拖拽定制框架 + +### 4.0.0 版本 + +- 实现无代码化的界面拖拽框架 + +## 人才社区构建 + +GoAdmin项目需要更多的人才一同加入。 + +目前由我 [@cg33](https://github.com/chenhg5) 一人维护此项目,本人是国内某知名985/211大学计算机系本科毕业,两年的gopher。 + +目前项目需要的工作有: + +- [项目开发](https://github.com/GoAdminGroup/go-admin),需掌握一定的```golang```开发能力 +- 社区项目开发(暂未开源,暂不对外开放) +- [文档的维护改进与翻译](https://github.com/GoAdminGroup/docs) +- 项目的宣传与社区文化的组织 + +GoAdmin始终秉持开放开源的态度,欢迎有志有能力之士加入一块共谋项目和社区的发展,社区与个人相辅相成。 + +如果你看好GoAdmin的发展,并且愿意为他赌一把,用时间换取未来可能的财务或名誉度回报,而且你对你自己的能力有足够信心,那么你可以尝试充分阅读GoAdmin的代码,并理解GoAdmin的发展规划,为此做出你的贡献。前期代码缺陷漏洞大,可修改空间多,如果你有能力做出足够的贡献,将成为项目的**联合创始人**或**核心开发者**。到后期,代码完善度高,也仍然有改进空间,你可以通过提交修复成为**贡献者**。团队将会一直保持开放态度,接纳新成员。团队每一个付出努力的成员也会在将来根据付出比例公平地去收获项目给大家带来的一定的回报。 + +如果你没有足够的时间和精力,但有一定的资金,且同样看好GoAdmin发展,虽然GoAdmin尚未就此加入的方案拟定计划。但只要你有足够大的兴趣,也可以带上你的计划与我们进行洽谈。 + +## 商业项目计划 + +GoAdmin会逐步实现商业化,但核心基础功能是免费开源的。 +GoAdmin的资金收入模式主要是: + +- 接受捐助 +- 售卖主题 +- 售卖插件 +- 提供saas定制化开发 +- 提供收费的商业化版本 + +收入资金主要用于维护社区的发展,与开发人员的薪酬回报,促使项目更好的成长。 \ No newline at end of file diff --git a/fr/plugins/admin.md b/fr/plugins/admin.md new file mode 100644 index 0000000..ed12ba8 --- /dev/null +++ b/fr/plugins/admin.md @@ -0,0 +1,536 @@ +# How To Use Admin Plugin +--- + +The Admin plugin can help you to quickly generate a database data table for adding, deleting, and changing database data tables. + +## Quick Start + +Following the steps: + +- Generate a configuration file corresponding to the data table +- Set access routing +- Initialize and load in the engine +- Set access menu + +### Generate configuration file + +Suppose you have a data table users in your database, such as: + +```sql +CREATE TABLE `users` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `gender` tinyint(4) DEFAULT NULL, + `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `ip` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +``` + +Use the command line tools - admincli to help you quickly generate configuration files: + +- install + +```bash +go install github.com/GoAdminGroup/go-admin/admincli +``` + +- generate + +
+Execute in the project folder + +```bash +admincli generate +``` + +Fill in the information according to the prompts. After the run, a file ```users.go``` will be generated. This is the configuration file corresponding to the data table. How to configure it is described in detail later. + +### Set access url + +After the configuration file is generated, a routing configuration file ```tables.go``` will also be generated : + +```go +package main + +import "github.com/GoAdminGroup/go-admin/plugins/admin/models" + +// The key of Generators is the prefix of table info url. +// The corresponding value is the Form and Table data. +// +// http://{{config.DOMAIN}}:{{PORT}}/{{config.PREFIX}}/info/{{key}} +// +// example: +// +// "user" => http://localhost:9033/admin/info/user +// +var Generators = map[string]models.TableGenerator{ + "user": GetUserTable, +} +``` + +```"user"``` is the corresponding access route prefix, ```GetUserTable``` is the table data generation method. +The corresponding access routing address is: http://localhost:9033/admin/info/users + +### Initialize and load in the engine + +To initialize, you need to call the ```NewAdmin``` method, and then pass the ```Generators``` above. Then call the engine's ```AddPlugins``` method to load the engine. + +```go +package main + +import ( + "github.com/gin-gonic/gin" + _ "github.com/GoAdminGroup/go-admin/adapter/gin" + _ "github.com/GoAdminGroup/themes/adminlte" + "github.com/GoAdminGroup/go-admin/engine" + "github.com/GoAdminGroup/go-admin/plugins/admin" + "github.com/GoAdminGroup/go-admin/modules/config" + "github.com/GoAdminGroup/go-admin/modules/language" +) + +func main() { + r := gin.Default() + eng := engine.Default() + cfg := config.Config{ + Databases: config.DatabaseList{ + "default": { + Host: "127.0.0.1", + Port: "3306", + User: "root", + Pwd: "root", + Name: "godmin", + MaxIdleCon: 50, + MaxOpenCon: 150, + Driver: config.DriverMysql, + }, + }, + UrlPrefix: "admin", + Store: config.Store{ + Path: "./uploads", + Prefix: "uploads", + }, + Language: language.CN, + } + + adminPlugin := admin.NewAdmin(Generators) + + // AddGenerator can also be used to load the Generator, like: + // adminPlugin.AddGenerator("user", GetUserTable) + + eng.AddConfig(cfg). + AddPlugins(adminPlugin). // 加载插件 + Use(r) + + r.Run(":9033") +} +``` + +### Set access menu + +After running, access the login URL, enter the menu management page, and set the management menu of the data table to enter in the sidebar. + +> PS: +> +> In the above example, the login URL is http://localhost:9033/admin/login +> +> The menu management page is http://localhost:9033/admin/menu + +## Introduction to the business data table generation method file + +```go +package datamodel + +import ( + "fmt" + "github.com/GoAdminGroup/go-admin/modules/db" + form2 "github.com/GoAdminGroup/go-admin/plugins/admin/modules/form" + "github.com/GoAdminGroup/go-admin/plugins/admin/modules/table" + "github.com/GoAdminGroup/go-admin/template/types" + "github.com/GoAdminGroup/go-admin/template/types/form" +) + +func GetUserTable() (userTable table.Table) { + + // config the table model. + userTable = table.NewDefaultTable(table.Config{ + Driver: db.DriverMysql, + CanAdd: true, + Editable: true, + Deletable: true, + Exportable: true, + Connection: table.DefaultConnectionName, + PrimaryKey: table.PrimaryKey{ + Type: db.Int, + Name: table.DefaultPrimaryKeyName, + }, + }) + + info := userTable.GetInfo() + + // set id sortable. + info.AddField("ID", "id", db.Int).FieldSortable(true) + info.AddField("Name", "name", db.Varchar) + + // use FieldDisplay. + info.AddField("Gender", "gender", db.Tinyint).FieldDisplay(func(model types.FieldModel) interface{} { + if model.Value == "0" { + return "men" + } + if model.Value == "1" { + return "women" + } + return "unknown" + }) + + info.AddField("Phone", "phone", db.Varchar) + info.AddField("City", "city", db.Varchar) + info.AddField("CreatedAt", "created_at", db.Timestamp) + info.AddField("UpdatedAt", "updated_at", db.Timestamp) + + // set the title and description of table page. + info.SetTable("users").SetTitle("Users").SetDescription("Users"). + SetAction(template.HTML(``)) // custom operation button + + formList := userTable.GetForm() + + // set id editable is false. + formList.AddField("ID", "id", db.Int, form.Default).FieldNotAllowEdit() + formList.AddField("Ip", "ip", db.Varchar, form.Text) + formList.AddField("Name", "name", db.Varchar, form.Text) + + // use FieldOptions. + formList.AddField("Gender", "gender", db.Tinyint, form.Radio). + FieldOptions([]map[string]string{ + { + "field": "gender", + "label": "male", + "value": "0", + "selected": "true", + }, { + "field": "gender", + "label": "female", + "value": "1", + "selected": "false", + }, + }) + formList.AddField("Phone", "phone", db.Varchar, form.Text) + formList.AddField("City", "city", db.Varchar, form.Text) + + // add a custom field and use FieldPostFilterFn to do more things. + formList.AddField("Custom Field", "role", db.Varchar, form.Text). + FieldPostFilterFn(func(value types.PostFieldModel) string { + fmt.Println("user custom field", value) + return "" + }) + + formList.AddField("UpdatedAt", "updated_at", db.Timestamp, form.Default).FieldNotAllowAdd(true) + formList.AddField("CreatedAt", "created_at", db.Timestamp, form.Default).FieldNotAllowAdd(true) + + // use SetTabGroups to group a form into tabs. + formList.SetTabGroups(types. + NewTabGroups("id", "ip", "name", "gender", "city"). + AddGroup("phone", "role", "created_at", "updated_at")). + SetTabHeaders("profile1", "profile2") + + // set the title and description of form page. + formList.SetTable("users").SetTitle("Users").SetDescription("Users") + + // use SetPostHook to add operation when form posted. + formList.SetPostHook(func(values form2.Values) { + fmt.Println("userTable.GetForm().PostHook", values) + }) + + return +} +``` + +Initialize by calling ```models.NewDefaultTable(models.DefaultTableConfig)``` method to pass data table model configuration. The data table model is configured as: + +```go +type Config struct { + Driver string // database driver + Connection string // database connection name, defined in the global configuration + CanAdd bool // Can I add data + Editable bool // Can I edit + Deletable bool // Can I delete it + Exportable bool // Whether it can be exported + PrimaryKey PrimaryKey // primary key of the data table +} + +type PrimaryKey struct { + Type db.DatabaseType // primary key type + Name string // primary key name +} +``` + +The business data table generation method is a function that returns a type object of ```models.Table```. The following is the definition of ```models.Table```: + +```go +type Table interface { + GetInfo() *types.InfoPanel + GetForm() *types.FormPanel + GetCanAdd() bool + GetEditable() bool + GetDeletable() bool + GetFiltersMap() []map[string]string + GetDataFromDatabase(path string, params *Parameters) PanelInfo + GetDataFromDatabaseWithId(id string) ([]types.Form, string, string) + UpdateDataFromDatabase(dataList map[string][]string) + InsertDataFromDatabase(dataList map[string][]string) + DeleteDataFromDatabase(id string) +} +``` + +It mainly includes ```GetInfo()``` and ```GetForm()```. The ui corresponding to the type returned by these two functions is the table for displaying data and the form for editing new data. The screenshots are as follows: + +- This is the ```Info```. + +
+ +![](http://quizfile.dadadaa.cn/everyday/app/jlds/img/006tNbRwly1fxoy26qnc5j31y60u0q91.jpg) + +- This is the ```Form```. + +
+ +![](http://quizfile.dadadaa.cn/everyday/app/jlds/img/006tNbRwly1fxoy2w3cobj318k0ooabv.jpg) + +### Info + +```go +type InfoPanel struct { + FieldList []Field + curFieldListIndex int + + Table string + Title string + Description string + + // Warn: may be deprecated future. + TabGroups TabGroups // tabs contents + TabHeaders TabHeadersq // tabs headers + + Sort Sort + + Action template.HTML + HeaderHtml template.HTML + FooterHtml template.HTML +} + +type Field struct { + FilterFn FieldFilterFn // filter function + Field string // field name + TypeName db.DatabaseType // field type + Head string // title + Width int // width, unit is px + Join Join // join table setting + Sortable bool // can be sorted or not + Filterable bool // can be filtered or not + Hide bool // hide or not +} + +// Field is the table field. +type Field struct { + Head string // title + Field string // field name + TypeName db.DatabaseType // field type + + Join Join // join table setting + + Width int // width, unit is px + Sortable bool // can be sorted or not + Fixed bool // can be sorted or not + Filterable bool // can be filtered or not + Hide bool // hide or not + + Display FieldFilterFn // field display filter function + DisplayProcessChains DisplayProcessFnChains // field value process function list +} + + +// join table setting +// example: left join Table on Table.JoinField = Field +type Join struct { + Table string + Field string + JoinField string +} +``` + +### Form + +```go +type FormPanel struct { + FieldList FormFields // form field list + curFieldListIndex int + + // Warn: may be deprecated future. + TabGroups TabGroups // tabs, [example](https://github.com/GoAdminGroup/go-admin/blob/master/examples/datamodel/user.go#L76) + TabHeaders TabHeaders // tabs headers, [example](https://github.com/GoAdminGroup/go-admin/blob/master/examples/datamodel/user.go#L78) + + Table string + Title string + Description string + + Validator FormValidator // form post validator function + PostHook FormPostHookFn // form post hook function + + HeaderHtml template.HTML // header custom html content + FooterHtml template.HTML // footer custom html content +} + +// form validator function type +type PostValidator func(values form.Values) error + +// form hook function type +type PostHookFn func(values form.Values) + +type FormField struct { + Field string + TypeName db.DatabaseType + Head string + FormType form.Type + + Default string + Value string + Options []map[string]string + DefaultOptionDelimiter string + + Editable bool + NotAllowAdd bool + Must bool + + Display FieldFilterFn // field display filter function + DisplayProcessChains DisplayProcessFnChains // field value process function list + PostFilterFn PostFieldFilterFn +} +``` + +The currently supported form types are: + +- default +- normal text +- Single selection +- Password +- rich text +- File +- double selection box +- Multiple choices +- icon drop-down selection box +- time selection box +- radio selection box +- email input box +- url input box +- ip input box +- color selection box +- Currency input box +- Digital input box + +
+ +Can be used like this: + +``` + +import "github.com/GoAdminGroup/go-admin/template/types/form" + +... +FormType: form.File, +... + +``` + +For the selection type: single selection, multiple selection, selection box, you need to specify the Options value. The format is: + +``` +... +Options: []map[string]string{ + { + "field": "name", + "value": "joe", + },{ + "field": "name", + "value": "jane", + }, +} +... +``` + +Where field is the name of the field and value is the value corresponding to the selection. + +### Filter function FilterFn and processing function PostFn description + +```go +// FieldModel contains ID and value of the single query result. +type FieldModel struct { + ID string + Value string +} + +// FieldFilterFn determines the value that is retrieved from the database +// and passes to the format displayed by the front end. +// +// The type currently accepted for return is: template.HTML, string, []string +// +// For tables, you can return the template.HTML type, including html and css +// styles, so that the fields in the table can be personalized, such as: +// +// FilterFn: func(model types.FieldModel) interface{} { +// return template.Get("adminlte").Label().SetContent(template2.HTML(model.Value)).GetContent() +// }, +// +// For forms, note that if it is a select box type: Select/SelectSingle/SelectBox, +// you need to return an array: []string, such as: +// +// FilterFn: func(model types.FieldModel) interface{} { +// return strings.Split(model.Value, ",") +// }, +// +// For other form types, return the string type +// +type FieldFilterFn func(value FieldModel) interface{} + +// PostFieldModel contains ID and value of the single query result. +type PostFieldModel struct { + ID string + Value FieldModelValue + Row map[string]interface{} +} + +type FieldModelValue []string + +// PostFieldFilterFn is used to process the form data when submitting the form. +// The form data is passed over, processed by the form submission filter +// function and then stored in the database. +// +// If it is for the select type: Select/SelectSingle/SelectBox,you need to +// convert the array type to a string type, such as: +// +// PostFilterFn: func(model types.PostFieldModel) string { +// return strings.Join(model.Value, ",") +// }, +// +// Also it can be used for the processing of non-form fields, which can be used to update +// or insert data with tables. +// +// Custom fields, such as the role of the user table, need to be updated. +// Here, the table update can be performed based on the passed primary key +// ID and the form data Value. Such as: +// +// PostFilterFn: func(model types.PostFieldModel) { +// db.Table("role").Insert(dialect.H{ +// "user_id": model.ID, +// "role_id": model.Value.Value(), +// }) +// }, +// +type PostFieldFilterFn func(value PostFieldModel) string + +
+ +> 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. + diff --git a/fr/plugins/plugins.md b/fr/plugins/plugins.md new file mode 100644 index 0000000..a32fc1e --- /dev/null +++ b/fr/plugins/plugins.md @@ -0,0 +1,81 @@ +# How To Use Plugins +--- + +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. + +The example plugin is our demo. + +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) + +## Using the third package source code plugin + +For example: + +```go +package main + +import ( + "github.com/gin-gonic/gin" + _ "github.com/GoAdminGroup/go-admin/adapter/gin" + _ "github.com/GoAdminGroup/themes/adminlte" + "github.com/GoAdminGroup/go-admin/engine" + "github.com/GoAdminGroup/go-admin/plugins/admin" + "github.com/GoAdminGroup/go-admin/plugins/example" + "github.com/GoAdminGroup/go-admin/modules/config" + "github.com/GoAdminGroup/go-admin/examples/datamodel" +) + +func main() { + r := gin.Default() + eng := engine.Default() + cfg := config.Config{} + + adminPlugin := admin.NewAdmin(datamodel.Generators) + examplePlugin := example.NewExample() + + eng.AddConfig(cfg). + AddPlugins(adminPlugin, examplePlugin). // loading + Use(r) + + r.Run(":9033") +} +``` + + +## Using the binary plugin + +Load the ```.so```file, and call```plugins.LoadFromPlugin```. + +如: + +```go +package main + +import ( + "github.com/gin-gonic/gin" + _ "github.com/GoAdminGroup/go-admin/adapter/gin" + _ "github.com/GoAdminGroup/themes/adminlte" // Import the theme + "github.com/GoAdminGroup/go-admin/engine" + "github.com/GoAdminGroup/go-admin/plugins/admin" + "github.com/GoAdminGroup/go-admin/plugins" + "github.com/GoAdminGroup/go-admin/modules/config" + "github.com/GoAdminGroup/go-admin/examples/datamodel" +) + +func main() { + r := gin.Default() + eng := engine.Default() + cfg := config.Config{} + + adminPlugin := admin.NewAdmin(datamodel.Generators) + + // load plugin from .so file. + examplePlugin := plugins.LoadFromPlugin("../datamodel/example.so") + + eng.AddConfig(cfg). + AddPlugins(adminPlugin, examplePlugin). + Use(r) + + r.Run(":9033") +} +``` \ No newline at end of file diff --git a/fr/quick_start.md b/fr/quick_start.md new file mode 100644 index 0000000..9bfbb2e --- /dev/null +++ b/fr/quick_start.md @@ -0,0 +1,234 @@ +# Quick Start +--- + +go-admin makes it easy to use in various web frameworks through various adapters. Currently supported web frameworks are: + +- [gin](http://github.com/gin-gonic/gin) +- [beego](https://github.com/astaxie/beego) +- [fasthttp](https://github.com/valyala/fasthttp) +- [buffalo](https://github.com/gobuffalo/buffalo) +- [echo](https://github.com/labstack/echo) +- [gorilla/mux](http://github.com/gorilla/mux) +- [iris](https://github.com/kataras/iris) +- [chi](https://github.com/go-chi/chi) + +
+ +You can choose the framework you are using or the business project is using. If there is no framework you like, please feel free to give us an issue or pr! + +Let's take the gin framework as an example to demonstrate the build process. + +## main.go + +Create a new ```main.go``` file in your project folder with the following contents: + +```go +package main + +import ( + _ "github.com/GoAdminGroup/go-admin/adapter/gin" // Import the adapter, it must be imported. If it is not imported, you need to define it yourself. + _ "github.com/GoAdminGroup/themes/adminlte" // Import the theme + "github.com/GoAdminGroup/go-admin/engine" + "github.com/GoAdminGroup/go-admin/examples/datamodel" + "github.com/GoAdminGroup/go-admin/modules/config" + "github.com/GoAdminGroup/go-admin/modules/language" + "github.com/GoAdminGroup/go-admin/plugins/admin" + "github.com/gin-gonic/gin" +) + +func main() { + r := gin.Default() + + // Instantiate a go-admin engine object. + eng := engine.Default() + + // go-admin global configuration, can also be written as a json, imported by json. + cfg := config.Config{ + Databases: []config.Database{ + { + Host: "127.0.0.1", + Port: "3306", + User: "root", + Pwd: "root", + Name: "godmin", + MaxIdleCon: 50, + MaxOpenCon: 150, + Driver: "mysql", + }, + }, + UrlPrefix: "admin", // The url prefix of the website. + // Store must be set and guaranteed to have write access, otherwise new administrator users cannot be added. + Store: config.Store{ + Path: "./uploads", + Prefix: "uploads", + }, + Language: language.EN, + } + + // Import the business table configuration you need to manage here. + // About Generators,see: https://github.com/GoAdminGroup/go-admin/blob/master/examples/datamodel/tables.go + adminPlugin := admin.NewAdmin(datamodel.Generators) + + // Add configuration and plugins, use the Use method to mount to the web framework. + _ = eng.AddConfig(cfg).AddPlugins(adminPlugin).Use(r) + + _ = r.Run(":9033") +} +``` + +Please pay attention to the above code and comments, the corresponding steps are added to the comments, it is simple to use, the following steps: + +- Introducing an adapter +- Set global configuration items +- Initialize the plugin +- Set up plugins and configurations +- Mounted to the web framework + +
+ +Then execute ```go run main.go``` to run the code and access: [http://localhost:9033/admin/login](http://localhost:9033/admin/login)
+
+default account: admin
+default password: admin + +more web framework example: [https://github.com/GoAdminGroup/go-admin/tree/master/examples](https://github.com/GoAdminGroup/go-admin/tree/master/examples) + +## Add your own business table for management + +See:

+1 [How To Use Plugins](plugins/plugins)
+2 [How To Use Admin Plugin](plugins/admin) + +## Global configuration item description + +[https://github.com/GoAdminGroup/go-admin/blob/master/modules/config/config.go](https://github.com/GoAdminGroup/go-admin/blob/master/modules/config/config.go) + +```go +package config + +import ( + "html/template" +) + +// Database is a type of database connection config. +// Because a little difference of different database driver. +// The Config has multiple options but may be not used. +// Such as the sqlite driver only use the FILE option which +// can be ignored when the driver is mysql. +type Database struct { + Host string + Port string + User string + Pwd string + Name string + MaxIdleCon int + MaxOpenCon int + Driver string + File string +} + +// Database configuration +// which is a map where key is the name of the database connection and +// value is the corresponding data configuration. +// The key is the default database is the default database, but also +// the database used by the framework, and you can configure multiple +// databases to be used by your business tables to manage different databases. +type DatabaseList map[string]Database + +// Store is the file store config. Path is the local store path. +// and prefix is the url prefix used to visit it. +type Store struct { + Path string + Prefix string +} + + +// Config type is the global config of goAdmin. It will be +// initialized in the engine. +type Config struct { + // An map supports multi database connection. The first + // element of Databases is the default connection. See the + // file connection.go. + Databases DatabaseList `json:"database"` + + // The cookie domain used in the auth modules. see + // the session.go. + Domain string `json:"domain"` + + // Used to set as the localize language which show in the + // interface. + Language string `json:"language"` + + // The global url prefix. + UrlPrefix string `json:"prefix"` + + // The theme name of template. + Theme string `json:"theme"` + + // The path where files will be stored into. + Store Store `json:"store"` + + // The title of web page. + Title string `json:"title"` + + // Logo is the top text in the sidebar. + Logo template.HTML `json:"logo"` + + // Mini-logo is the top text in the sidebar when folding. + MiniLogo template.HTML `json:"mini_logo"` + + // The url redirect to after login + IndexUrl string `json:"index"` + + // Debug mode + Debug bool `json:"debug"` + + // Env is the environment, which maybe local, test, prod. + Env string + + // Info log path + InfoLogPath string `json:"info_log"` + + // Error log path + ErrorLogPath string `json:"error_log"` + + // Access log path + AccessLogPath string `json:"access_log"` + + // Sql operator record log switch + SqlLog bool `json:"sql_log"` + + AccessLogOff bool + InfoLogOff bool + ErrorLogOff bool + + // Color scheme + ColorScheme string `json:"color_scheme"` + + // Session life time, unit is second. + SessionLifeTime int `json:"session_life_time"` + + // Cdn link of assets + AssetUrl string `json:"asset_url"` + + // File upload engine, default "local" + FileUploadEngine FileUploadEngine `json:"file_upload_engine"` + + // Custom html in the tag head. + CustomHeadHtml template.HTML `json:"custom_head_html"` + + // Custom html after body. + CustomFootHtml template.HTML `json:"custom_foot_html"` + + // Login page title + LoginTitle string `json:"login_title"` + + // Login page logo + LoginLogo template.HTML `json:"login_logo"` +} + +``` + +
+ +> 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. \ No newline at end of file