From 0f1ac1d72f2cbe296d259265b4e8afac0bf3c89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=B0=8F=E5=86=9B?= <346944475@qq.com> Date: Sat, 11 Jan 2020 22:52:14 +0800 Subject: [PATCH] reade --- README.md | 35 ++++++++++++++++++++++++++++++----- README_zh_cn.md | 33 +++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 055fe6b..e363597 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Flags: ``` ## 3. Can be updated configuration items using command line tools ``` -./gormt -H=127.0.0.1 -d=oauth_db -p=qwer -u=root --port=3306 +./gormt -H=127.0.0.1 -d=oauth_db -p=qwer -u=root --port=3306 -F=true ``` ## 4. Support for gorm attributes @@ -121,7 +121,32 @@ type UserAccountTbl struct { ### [more>>>](doc/export.md) -## 6. build +## 6. support func export +### The exported function is only the auxiliary class function of Gorm, and calls Gorm completely +``` +// FetchByPrimaryKey primay or index 获取唯一内容 +func (obj *_UserAccountTblMgr) FetchByPrimaryKey(ID int) (result UserAccountTbl, err error) { + err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error + if err == nil && obj.isRelated { + { + var info UserInfoTbl // 用户信息 + err = obj.DB.Table("user_info_tbl").Where("id = ?", result.UserInfoTblID).Find(&info).Error + if err != nil { + return + } + result.UserInfoTbl = info + } + } + + return +} + +``` + +### [more多>>>](https://github.com/xxjwxc/gormt/tree/master/data/view/genfunc/model) +### [how to use call style>>>](https://github.com/xxjwxc/gormt/blob/master/data/view/genfunc/genfunc_test.go) + +## 7. build ``` make windows make linux @@ -133,11 +158,11 @@ or go generate ``` -## 7. Next step +## 8. Next step -- Add common function (ormfunc) +- revew -## 8. one windows gui tools +## 9. one windows gui tools ![1](/image/gormt/1.png) diff --git a/README_zh_cn.md b/README_zh_cn.md index 37838ce..7c7d859 100644 --- a/README_zh_cn.md +++ b/README_zh_cn.md @@ -120,7 +120,32 @@ type UserAccountTbl struct { ### [更多>>>](https://github.com/xxjwxc/gormt/tree/master/doc/export_cn.md) -## 6. 构建 +## 6. 支持函数导出(导出函数只是 gorm 的辅助类函数,完全兼调用 gorm) + +``` +// FetchByPrimaryKey primay or index 获取唯一内容 +func (obj *_UserAccountTblMgr) FetchByPrimaryKey(ID int) (result UserAccountTbl, err error) { + err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error + if err == nil && obj.isRelated { + { + var info UserInfoTbl // 用户信息 + err = obj.DB.Table("user_info_tbl").Where("id = ?", result.UserInfoTblID).Find(&info).Error + if err != nil { + return + } + result.UserInfoTbl = info + } + } + + return +} + +``` + +### [更多>>>](https://github.com/xxjwxc/gormt/tree/master/data/view/genfunc/model) +### [函数调用说明>>>](https://github.com/xxjwxc/gormt/blob/master/data/view/genfunc/genfunc_test.go) + +## 7. 构建 ``` make windows make linux @@ -132,11 +157,11 @@ or go generate ``` -## 7. 下一步计划 +## 8. 下一步计划 -- 加入相关快捷函数(OrmFunc) +- 优化 -## 8. 提供一个windows 可视化工具 +## 9. 提供一个windows 可视化工具 ![图片描述](/image/gormt/1.png)