Skip to content

Commit

Permalink
修复一些数据同步问题,更新文档,取消在配置文件读取值作为同步数据的标志,改为方法注释的方式
Browse files Browse the repository at this point in the history
  • Loading branch information
SliverHorn committed Aug 25, 2020
1 parent 4b94184 commit 90e11a4
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 38 deletions.
28 changes: 28 additions & 0 deletions server/GORMV2接口测试文档.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,31 @@
| /simpleUploader/checkFileMd5 | 文件完整度验证 | |
| /simpleUploader/mergeFileMd5 | 上传完成合并文件 | |

- 视图sql使用gorm执行失败
- 但是使用DataGrip执行是成功的
```sql
2020/08/25 18:13:03 /Users/sliverhorn/Go/src/github.com/flipped-aurora/gin-vue-admin/server/service/initialize.go:79 Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `authority_menu` AS
selec' at line 2
[0.080ms] [rows:0] DROP VIEW IF EXISTS `authority_menu`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `authority_menu` AS
select `sys_base_menus`.`id` AS `id`,
`sys_base_menus`.`created_at` AS `created_at`,
`sys_base_menus`.`updated_at` AS `updated_at`,
`sys_base_menus`.`deleted_at` AS `deleted_at`,
`sys_base_menus`.`menu_level` AS `menu_level`,
`sys_base_menus`.`parent_id` AS `parent_id`,
`sys_base_menus`.`path` AS `path`,
`sys_base_menus`.`name` AS `name`,
`sys_base_menus`.`hidden` AS `hidden`,
`sys_base_menus`.`component` AS `component`,
`sys_base_menus`.`title` AS `title`,
`sys_base_menus`.`icon` AS `icon`,
`sys_base_menus`.`sort` AS `sort`,
`sys_authority_menus`.`sys_authority_authority_id` AS `authority_id`,
`sys_authority_menus`.`sys_base_menu_id` AS `menu_id`,
`sys_base_menus`.`keep_alive` AS `keep_alive`,
`sys_base_menus`.`default_menu` AS `default_menu`
from (`sys_authority_menus`
join `sys_base_menus` on ((`sys_authority_menus`.`sys_base_menu_id` = `sys_base_menus`.`id`)));

```
1 change: 0 additions & 1 deletion server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ system:
env: 'public' # Change to "develop" to skip authentication for development mode
addr: 8888
db-type: "mysql" # support mysql/sqlite
data: false

# captcha configuration
captcha:
Expand Down
1 change: 0 additions & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type System struct {
Env string `mapstructure:"env" json:"env" yaml:"env"`
Addr int `mapstructure:"addr" json:"addr" yaml:"addr"`
DbType string `mapstructure:"db-type" json:"dbType" yaml:"db-type"`
Data bool `mapstructure:"data" json:"data" yaml:"data"`
}

type JWT struct {
Expand Down
4 changes: 0 additions & 4 deletions server/initialize/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import (

func Data() {
var err error
if global.GVA_CONFIG.System.Data {
return
}
err = service.InitSysApi()
err = service.InitSysUser()
err = service.InitExaCustomer()
Expand All @@ -25,6 +22,5 @@ func Data() {
if err != nil {
global.GVA_LOG.Error("initialize data failed", err)
}
global.GVA_VP.Set("data", true)
global.GVA_LOG.Debug("initialize data success")
}
1 change: 1 addition & 0 deletions server/initialize/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func Mysql() {
if admin.LogMode { //根据配置决定是否开启日志
gormConfig = &gorm.Config{
Logger: logger.Default.LogMode(logger.Info),
DisableForeignKeyConstraintWhenMigrating: true,
}
} else {
gormConfig = &gorm.Config{
Expand Down
2 changes: 1 addition & 1 deletion server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
initialize.Mysql()
}
initialize.DBTables()
//initialize.Data()
initialize.Data() // 打开注释即可初始化数据
// 程序结束前关闭数据库链接
db, _ := global.GVA_DB.DB()
defer db.Close()
Expand Down
50 changes: 25 additions & 25 deletions server/model/sys_base_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@ type SysBaseMenuParameter struct {

func SysBaseMenusData() []SysBaseMenu {
return []SysBaseMenu{
{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "0", Path: "dashboard", Name: "dashboard", Component: "view/dashboard/index.vue", Sort: 1, Meta: Meta{Title: "仪表盘", Icon: "setting"}},
{Model: gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "0", Path: "about", Name: "about", Component: "view/about/index.vue", Sort: 7, Meta: Meta{Title: "关于我们", Icon: "info"}},
{Model: gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "0", Path: "adm in", Name: "superAdmin", Component: "view/superAdmin/authority/authority.vue", Sort: 3, Meta: Meta{Title: "关于我们", Icon: "info"}},
{Model: gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "3", Path: "authority", Name: "authority", Component: "view/superAdmin/menu/menu.vue", Sort: 1, Meta: Meta{Title: "角色管理", Icon: "s-custom"}},
{Model: gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "3", Path: "menu", Name: "menu", Component: "view/superAdmin/api/api.vue", Sort: 2, Meta: Meta{Title: "菜单管理", Icon: "s-order"}},
{Model: gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "3", Path: "api", Name: "api", Component: "view/superAdmin/user/user.vue", Sort: 3, Meta: Meta{Title: "api管理", Icon: "s-platform"}},
{Model: gorm.Model{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "3", Path: "user", Name: "user", Component: "view/person/person.vue", Sort: 4, Meta: Meta{Title: "用户管理", Icon: "coordinate"}},
{Model: gorm.Model{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "0", Path: "person", Name: "person", Component: "view/example/index.vue", Sort: 4, Meta: Meta{Title: "个人信息", Icon: "message-solid"}},
{Model: gorm.Model{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "0", Path: "example", Name: "example", Component: "view/example/table/table.vue", Sort: 6, Meta: Meta{Title: "示例文件", Icon: "s-management"}},
{Model: gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "9", Path: "table", Name: "table", Component: "view/example/form/form.vue", Sort: 1, Meta: Meta{Title: "表格示例", Icon: "s-order"}},
{Model: gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "9", Path: "form", Name: "form", Component: "view/example/rte/rte.vue", Sort: 2, Meta: Meta{Title: "表单示例", Icon: "document"}},
{Model: gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "9", Path: "rte", Name: "rte", Component: "view/example/excel/excel.vue", Sort: 3, Meta: Meta{Title: "富文本编辑器", Icon: "reading"}},
{Model: gorm.Model{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "9", Path: "excel", Name: "excel", Component: "view/example/upload/upload.vue", Sort: 4, Meta: Meta{Title: "excel导入导出", Icon: "s-marketing"}},
{Model: gorm.Model{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "9", Path: "upload", Name: "upload", Component: "view/example/breakpoint/breakpoint.vue", Sort: 5, Meta: Meta{Title: "上传下载", Icon: "upload"}},
{Model: gorm.Model{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "9", Path: "breakpoint", Name: "breakpoint", Component: "view/example/customer/customer.vue", Sort: 6, Meta: Meta{Title: "断点续传", Icon: "upload"}},
{Model: gorm.Model{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "9", Path: "customer", Name: "customer", Component: "view/systemTools/index.vue", Sort: 7, Meta: Meta{Title: "客户列表(资源示例)", Icon: "s-custom"}},
{Model: gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "0", Path: "systemTools", Name: "systemTools", Component: "view/systemTools/autoCode/index.vue", Sort: 5, Meta: Meta{Title: "系统工具", Icon: "s-cooperation"}},
{Model: gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "17", Path: "autoCode", Name: "autoCode", Component: "view/systemTools/formCreate/index.vue", Sort: 1, Meta: Meta{Title: "代码生成器", Icon: "cpu"}},
{Model: gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "17", Path: "formCreate", Name: "formCreate", Component: "view/systemTools/system/system.vue", Sort: 2, Meta: Meta{Title: "表单生成器", Icon: "magic-stick"}},
{Model: gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "17", Path: "system", Name: "system", Component: "view/iconList/index.vue", Sort: 3, Meta: Meta{Title: "系统配置", Icon: "s-operation"}},
{Model: gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "0", Path: "iconList", Name: "iconList", Component: "view/superAdmin/dictionary/sysDictionary.vue", Sort: 2, Meta: Meta{Title: "图标集合", Icon: "star-on"}},
{Model: gorm.Model{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "3", Path: "dictionary", Name: "dictionary", Component: "view/superAdmin/dictionary/sysDictionaryDetail.vue", Sort: 5, Meta: Meta{Title: "字典管理", Icon: "notebook-2"}},
{Model: gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "3", Path: "dictionaryDetail/:id", Name: "dictionaryDetail", Component: "view/superAdmin/operation/sysOperationRecord.vue", Sort: 1, Meta: Meta{Title: "字典详情", Icon: "s-order"}},
{Model: gorm.Model{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "3", Path: "operation", Name: "operation", Component: "view/example/simpleUploader/simpleUploader", Sort: 6, Meta: Meta{Title: "操作历史", Icon: "time"}},
{Model: gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "", Sort: 6, Meta: Meta{Title: "断点续传(插件版)", Icon: "upload"}},
{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "dashboard", Name: "dashboard", Hidden: false, Component: "view/dashboard/index.vue", Sort: 1, Meta: Meta{Title: "仪表盘", Icon: "setting"}},
{Model: gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "about", Name: "about", Component: "view/about/index.vue", Sort: 7,Meta:Meta{Title: "关于我们", Icon: "info"}},
{Model: gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "admin", Name: "superAdmin", Component: "view/superAdmin/index.vue", Sort: 3,Meta:Meta{Title: "超级管理员", Icon: "user-solid"}},
{Model: gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "authority", Name: "authority", Component: "view/superAdmin/authority/authority.vue", Sort: 1,Meta:Meta{Title: "角色管理", Icon: "s-custom"}},
{Model: gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "menu", Name: "menu", Component: "view/superAdmin/menu/menu.vue", Sort: 2,Meta:Meta{Title: "菜单管理", Icon: "s-order", KeepAlive: true}},
{Model: gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "api", Name: "api", Component: "view/superAdmin/api/api.vue", Sort: 3,Meta:Meta{Title: "api管理", Icon: "s-platform", KeepAlive: true}},
{Model: gorm.Model{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "user", Name: "user", Component: "view/superAdmin/user/user.vue", Sort: 4,Meta:Meta{Title: "用户管理", Icon: "coordinate"}},
{Model: gorm.Model{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: true, ParentId: "0", Path: "person", Name: "person", Component: "view/person/person.vue", Sort: 4,Meta:Meta{Title: "个人信息", Icon: "message-solid"}},
{Model: gorm.Model{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "example", Name: "example", Component: "view/example/index.vue", Sort: 6,Meta:Meta{Title: "示例文件", Icon: "s-management"}},
{Model: gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "table", Name: "table", Component: "view/example/table/table.vue", Sort: 1,Meta:Meta{Title: "表格示例", Icon: "s-order"}},
{Model: gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "form", Name: "form", Component: "view/example/form/form.vue", Sort: 2,Meta:Meta{Title: "表单示例", Icon: "document"}},
{Model: gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "rte", Name: "rte", Component: "view/example/rte/rte.vue", Sort: 3,Meta:Meta{Title: "富文本编辑器", Icon: "reading"}},
{Model: gorm.Model{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "excel", Name: "excel", Component: "view/example/excel/excel.vue", Sort: 4,Meta:Meta{Title: "excel导入导出", Icon: "s-marketing"}},
{Model: gorm.Model{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "upload", Name: "upload", Component: "view/example/upload/upload.vue", Sort: 5,Meta:Meta{Title: "上传下载", Icon: "upload"}},
{Model: gorm.Model{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "breakpoint", Name: "breakpoint", Component: "view/example/breakpoint/breakpoint.vue", Sort: 6,Meta:Meta{Title: "断点续传", Icon: "upload"}},
{Model: gorm.Model{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "customer", Name: "customer", Component: "view/example/customer/customer.vue", Sort: 7,Meta:Meta{Title: "客户列表(资源示例)", Icon: "s-custom"}},
{Model: gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "systemTools", Name: "systemTools", Component: "view/systemTools/index.vue", Sort: 5,Meta:Meta{Title: "系统工具", Icon: "s-cooperation"}},
{Model: gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "17",Path: "autoCode", Name: "autoCode", Component: "view/systemTools/autoCode/index.vue", Sort: 1,Meta:Meta{Title: "代码生成器", Icon: "cpu", KeepAlive: true}},
{Model: gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "17",Path: "formCreate", Name: "formCreate", Component: "view/systemTools/formCreate/index.vue", Sort: 2,Meta:Meta{Title: "表单生成器", Icon: "magic-stick", KeepAlive: true}},
{Model: gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "17",Path: "system", Name: "system", Component: "view/systemTools/system/system.vue", Sort: 3,Meta:Meta{Title: "系统配置", Icon: "s-operation"}},
{Model: gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "iconList", Name: "iconList", Component: "view/iconList/index.vue", Sort: 2,Meta:Meta{Title: "图标集合", Icon: "star-on"}},
{Model: gorm.Model{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "dictionary", Name: "dictionary", Component: "view/superAdmin/dictionary/sysDictionary.vue", Sort: 5,Meta:Meta{Title: "字典管理", Icon: "notebook-2"}},
{Model: gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: true, ParentId: "3", Path: "dictionaryDetail/:id", Name: "dictionaryDetail", Component: "view/superAdmin/dictionary/sysDictionaryDetail.vue", Sort: 1,Meta:Meta{Title: "字典详情", Icon: "s-order"}},
{Model: gorm.Model{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "operation", Name: "operation", Component: "view/superAdmin/operation/sysOperationRecord.vue", Sort: 6,Meta:Meta{Title: "操作历史", Icon: "time"}},
{Model: gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "view/example/simpleUploader/simpleUploader", Sort: 6,Meta:Meta{Title: "断点续传(插件版)", Icon: "upload"}},
}
}
2 changes: 1 addition & 1 deletion server/model/sys_casbin.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package model

type CasbinModel struct {
Ptype string `json:"ptype" gorm:"column:ptype"`
Ptype string `json:"ptype" gorm:"column:p_type"`
AuthorityId string `json:"rolename" gorm:"column:v0"`
Path string `json:"path" gorm:"column:v1"`
Method string `json:"method" gorm:"column:v2"`
Expand Down
2 changes: 1 addition & 1 deletion server/model/sys_operation_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type SysOperationRecord struct {
Agent string `json:"agent" form:"agent" gorm:"column:agent;comment:''"`
ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:''"`
Body string `json:"body" form:"body" gorm:"column:body;comment:'请求Body'"`
Resp string `json:"resp" form:"resp" gorm:"column:resp;comment:'响应Body'"`
Resp string `json:"resp" form:"resp" gorm:"type:longtext;column:resp;comment:'响应Body'"`
UserID int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:''"`
User SysUser `json:"user"`
}
Loading

0 comments on commit 90e11a4

Please sign in to comment.