Browse Source

修复视图执行失败的bug

main
SliverHorn 4 years ago
parent
commit
6bf98ec3ba
  1. 29
      server/GORMV2接口测试文档.md
  2. 6
      server/config.yaml
  3. 22
      server/initialize/data.go
  4. 2
      server/service/initialize.go

29
server/GORMV2接口测试文档.md

@ -66,32 +66,3 @@
| /simpleUploader/upload | 插件版分片上传 | |
| /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`)));
```

6
server/config.yaml

@ -11,13 +11,13 @@ jwt:
# mysql connect configuration
mysql:
username: root
password: 'gdkid,,..'
password: 'Aa@6447985'
path: '127.0.0.1:3306'
db-name: 'test'
db-name: 'qmPlus'
config: 'charset=utf8&parseTime=True&loc=Local'
max-idle-conns: 10
max-open-conns: 10
log-mode: true
log-mode: false
#sqlite 配置
sqlite:

22
server/initialize/data.go

@ -7,18 +7,18 @@ import (
func Data() {
var err error
err = service.InitSysApi()
err = service.InitSysUser()
err = service.InitExaCustomer()
err = service.InitCasbinModel()
err = service.InitSysAuthority()
err = service.InitSysBaseMenus()
//err = service.InitSysApi()
//err = service.InitSysUser()
//err = service.InitExaCustomer()
//err = service.InitCasbinModel()
//err = service.InitSysAuthority()
//err = service.InitSysBaseMenus()
err = service.InitAuthorityMenu()
err = service.InitSysDictionary()
err = service.InitSysAuthorityMenus()
err = service.InitSysDataAuthorityId()
err = service.InitSysDictionaryDetail()
err = service.InitExaFileUploadAndDownload()
//err = service.InitSysDictionary()
//err = service.InitSysAuthorityMenus()
//err = service.InitSysDataAuthorityId()
//err = service.InitSysDictionaryDetail()
//err = service.InitExaFileUploadAndDownload()
if err != nil {
global.GVA_LOG.Error("initialize data failed", err)
}

2
server/service/initialize.go

@ -76,7 +76,7 @@ func InitSysBaseMenus() (err error) {
}
func InitAuthorityMenu() (err error) {
return global.GVA_DB.Exec("DROP VIEW IF EXISTS `authority_menu`;\nCREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `authority_menu` AS\nselect `sys_base_menus`.`id` AS `id`,\n `sys_base_menus`.`created_at` AS `created_at`,\n `sys_base_menus`.`updated_at` AS `updated_at`,\n `sys_base_menus`.`deleted_at` AS `deleted_at`,\n `sys_base_menus`.`menu_level` AS `menu_level`,\n `sys_base_menus`.`parent_id` AS `parent_id`,\n `sys_base_menus`.`path` AS `path`,\n `sys_base_menus`.`name` AS `name`,\n `sys_base_menus`.`hidden` AS `hidden`,\n `sys_base_menus`.`component` AS `component`,\n `sys_base_menus`.`title` AS `title`,\n `sys_base_menus`.`icon` AS `icon`,\n `sys_base_menus`.`sort` AS `sort`,\n `sys_authority_menus`.`sys_authority_authority_id` AS `authority_id`,\n `sys_authority_menus`.`sys_base_menu_id` AS `menu_id`,\n `sys_base_menus`.`keep_alive` AS `keep_alive`,\n `sys_base_menus`.`default_menu` AS `default_menu`\nfrom (`sys_authority_menus`\n join `sys_base_menus` on ((`sys_authority_menus`.`sys_base_menu_id` = `sys_base_menus`.`id`)));").Error
return global.GVA_DB.Exec("CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `authority_menu` AS\nselect `sys_base_menus`.`id` AS `id`,\n `sys_base_menus`.`created_at` AS `created_at`,\n `sys_base_menus`.`updated_at` AS `updated_at`,\n `sys_base_menus`.`deleted_at` AS `deleted_at`,\n `sys_base_menus`.`menu_level` AS `menu_level`,\n `sys_base_menus`.`parent_id` AS `parent_id`,\n `sys_base_menus`.`path` AS `path`,\n `sys_base_menus`.`name` AS `name`,\n `sys_base_menus`.`hidden` AS `hidden`,\n `sys_base_menus`.`component` AS `component`,\n `sys_base_menus`.`title` AS `title`,\n `sys_base_menus`.`icon` AS `icon`,\n `sys_base_menus`.`sort` AS `sort`,\n `sys_authority_menus`.`sys_authority_authority_id` AS `authority_id`,\n `sys_authority_menus`.`sys_base_menu_id` AS `menu_id`,\n `sys_base_menus`.`keep_alive` AS `keep_alive`,\n `sys_base_menus`.`default_menu` AS `default_menu`\nfrom (`sys_authority_menus`\n join `sys_base_menus` on ((`sys_authority_menus`.`sys_base_menu_id` = `sys_base_menus`.`id`)));").Error
}
func InitSysDictionary() (err error) {

Loading…
Cancel
Save