Compare commits

...
467 Commits
Author SHA1 Message Date
奇淼(piexlmax d3fee1bf3e Merge pull request #496 from flipped-aurora/gva_gormv2_dev
修复casbin map占用问题
2021-05-29 11:26:45 +08:00
奇淼(piexlmax d1009704d8 Merge pull request #493 from qinmin328/master
定时任务配置问题
2021-05-29 11:25:07 +08:00
pixel 4d00bb9d21 2.4.2版本号发布 2021-05-28 19:18:48 +08:00
qinmin328 1dff8eb945 定时任务配置问题
定时任务文档跟使用版本不一致, 导致时间配置上有点差异
2021-05-25 09:50:54 +08:00
SliverHorn 8eef4717cc fix: Restore config.yaml File 2021-05-21 18:49:35 +08:00
SliverHorn 1de437dc5a fix: Enforcer => SyncedEnforcer Solve Map Preemption 2021-05-21 18:48:26 +08:00
SliverHorn 8f1885f56e fix: remove casbin init single case 2021-05-20 16:54:56 +08:00
奇淼(piexlmax eeac49157f Merge pull request #484 from flipped-aurora/gva_gormv2_dev
修复map竞争问题
2021-05-20 11:29:51 +08:00
奇淼(piexlmax ffc19c7fbf Merge branch 'master' into gva_gormv2_dev 2021-05-20 11:26:24 +08:00
pixel e03f0cc4b0 修复map竞争问题 2021-05-20 11:23:30 +08:00
奇淼(piexlmax 70044a88a0 Merge pull request #483 from flipped-aurora/revert-482-gva_gormv2_dev
Revert "Gva gormv2 dev"
2021-05-20 11:05:53 +08:00
奇淼(piexlmax 4a279ffa29 Revert "Gva gormv2 dev" 2021-05-20 11:05:44 +08:00
奇淼(piexlmax 979c9c193f Merge pull request #482 from flipped-aurora/gva_gormv2_dev
Gva gormv2 dev
2021-05-20 10:56:48 +08:00
奇淼(piexlmax f603ebb09f Merge pull request #481 from songzhibin97/gva_gormv2_dev
fix casbin datarace
2021-05-20 10:56:24 +08:00
songzhibin97 7d93bc7256 fix casbin datarace 2021-05-20 10:49:00 +08:00
奇淼(piexlmax 89fa2c1061 Update README.md 2021-05-20 10:13:33 +08:00
奇淼(piexlmax 5a0aa6422f Merge pull request #476 from flipped-aurora/gva_gormv2_dev
Gva gormv2 dev
2021-05-18 16:47:17 +08:00
pixel b59f068c7d 媒体库样式优化 2021-05-18 16:38:20 +08:00
pixel ad6311d244 Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-05-18 16:30:27 +08:00
奇淼(piexlmax 645d6799b2 Merge pull request #469 from bstdn/master
modified 增加结构体描述,完善自动化文档
2021-05-18 16:30:07 +08:00
pixel 758c1f8306 Merge branch 'develop' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev
 Conflicts:
	server/service/sys_casbin.go
2021-05-18 16:26:53 +08:00
pixel 905297907a Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-05-18 16:25:45 +08:00
奇淼(piexlmax 6fb241af4b Merge pull request #475 from snowlyg/master
修复删除最后一个列表数据,重新加载数据报错
2021-05-18 16:23:55 +08:00
奇淼(piexlmax 0cf29d7488 Merge pull request #472 from closetool/develop
service/sys_casbin.go: fix casbin runs slowly
2021-05-18 13:58:10 +08:00
snowlyg 615aa3ad23 修复删除最后一个列表数据,重新加载数据报错 2021-05-17 15:38:31 +08:00
closetool c756d26592 service/sys_casbin.go: fix casbin runs slowly 2021-05-15 13:46:34 +08:00
何秀钢 0f45d3830a modified 增加结构体描述,完善自动化文档 2021-05-14 11:33:14 +08:00
奇淼(piexlmax c37ea861eb Merge pull request #463 from mlsjla/master
Update index.vue
2021-05-12 17:53:50 +08:00
奇淼(piexlmax aaa53d9a35 新增自动迁移创建路由后重启
新增自动迁移创建路由后重启
2021-05-12 17:39:15 +08:00
奇淼(piexlmax 3d59181d2a 修复后端重启前端白屏的bug
修复后端重启前端白屏的bug
2021-05-12 17:37:58 +08:00
奇淼(piexlmax ef11b6caa7 Merge pull request #465 from bstdn/master
modified 增加结构体描述,完善自动化文档
2021-05-12 17:37:16 +08:00
奇淼(piexlmax 563a1fc1a4 Merge pull request #466 from WangLeonard/fix-system-config
修复在线修改系统配置的bug
2021-05-12 17:36:12 +08:00
pixel 5625444fbc 修复重启后断后页面白屏问题 2021-05-12 17:13:53 +08:00
songzhibin97 169205f132 新增自动迁移创建路由后重启
修改
- server/api/v1/sys_system.go
- server/config.yaml
- server/config/auto_code.go
- server/service/sys_auto_code.go
新增
- server/utils/reload.go
2021-05-12 11:53:52 +08:00
Leonard Wang 447d824da6 修复在线修改系统配置的bug 2021-05-12 00:54:07 +08:00
何秀钢 c3ad90dde5 modified 增加结构体描述,完善自动化文档 2021-05-11 17:26:06 +08:00
mlsjla f218695bef Update index.vue
修复生产环境部署后,图片路径错误,错误细节: 图路径会变为 /apiuploads/file...  而实际需要的是 /api/uploads/file...
2021-05-10 14:17:57 +08:00
奇淼(piexlmax 9b758084bf 修复了已知bug casbin版本降级提升兼容性
Gva gormv2 dev
2021-05-09 19:29:49 +08:00
蒋吉兆 8159aa1a88 统一登录校验 误删用户登陆菜单后不再白屏 2021-05-09 19:26:08 +08:00
蒋吉兆 18cf39529e Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-05-09 18:49:15 +08:00
pixel a54e7a5654 修改casbin版本 防止用户报错 2021-05-07 17:48:19 +08:00
奇淼(piexlmax 4392f0ffac 优化配置 提升新手友好度
优化配置 提升新手友好度
2021-05-06 04:29:33 -05:00
pixel 732cd54578 Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev
 Conflicts:
	server/model/request/common.go
2021-05-06 13:21:51 +08:00
奇淼(piexlmax 0de1fe1132 增加结构体描述,完善自动化文档
modified 增加结构体描述,完善自动化文档
2021-04-30 01:19:00 -05:00
何秀钢 3e85645e44 modified 增加结构体描述,完善自动化文档 2021-04-30 14:14:00 +08:00
pixel 39fdc43ada 前端配置提取 让开发和上线更加简便 2021-04-26 14:33:47 +08:00
pixel acda4470bc 修复api.vue编辑未变化标题的bug 2021-04-26 11:39:00 +08:00
pixel 0fb3d16c49 修复main.js的包引用问题 2021-04-23 18:09:29 +08:00
pixel 228882d8c4 Merge branch 'develop' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev
 Conflicts:
	web/src/view/systemTools/formCreate/index.vue
2021-04-23 17:45:40 +08:00
pixel 186aa89476 将配置提取 2021-04-23 15:47:42 +08:00
奇淼(piexlmax f9296d90d4 Merge pull request #445 from flipped-aurora/gva_gormv2_dev
Gva gormv2 dev
2021-04-22 03:01:33 -05:00
奇淼(piexlmax 258c2afa32 Update config.yaml 2021-04-22 15:59:52 +08:00
奇淼(piexlmax 105adfe7e9 Merge pull request #442 from hzliangbin/patch-1
fix typo in README
2021-04-22 02:11:04 -05:00
pixel d2104fade2 修复casbin导致连接泄露问题 2021-04-22 14:54:52 +08:00
Bin Liang 739eed6a01 fix typo in README
fix some typo for better reading
2021-04-22 14:17:49 +08:00
奇淼(piexlmax bffe222e1b Merge pull request #396 from joewan/test_branch
端口统一配置
2021-04-20 04:20:12 -05:00
奇淼(piexlmax ceb5b9e4d6 Merge branch 'develop' into test_branch 2021-04-20 04:18:22 -05:00
奇淼(piexlmax e49bd514f7 Merge pull request #418 from RoseKissYou/develop
api/v1/sys_api.go api/v1/sys_menu.go api/v1/sys_user.go model/request…
2021-04-20 04:16:49 -05:00
奇淼(piexlmax 39fb8b7c5d Merge pull request #438 from songzhibin97/gva_gormv2_dev
新增定时任务封装以及配置自动清理数据库功能
2021-04-20 04:14:25 -05:00
songzhibin97 2b0a565120 新增定时任务封装以及配置自动清理数据库功能
新增
- server/config/timer.go
- server/initialize/timer.go
- server/utils/db_automation.go
- server/utils/timer/timed_task.go
修改
- server/config.yaml
- server/config/config/go
- server/global/global.go
- server/main.go
2021-04-17 14:50:44 +08:00
奇淼(piexlmax 2399c97c51 Update README.md 2021-04-16 19:08:08 +08:00
songzhibin97 eb1911232b Merge remote-tracking branch 'upstream/gva_gormv2_dev' into gva_gormv2_dev 2021-04-16 17:52:27 +08:00
pixel 0fe70c5e1c Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-04-16 10:47:18 +08:00
pixel 483da629e9 修复前端needInit报错导致的逻辑问题 2021-04-16 10:29:32 +08:00
蒋吉兆 129f4e6281 废弃七牛云配置 2021-04-14 23:19:25 +08:00
pixel 683355d773 版本号更改 2021-04-13 11:47:30 +08:00
奇淼(piexlmax cb28f6f438 Merge pull request #433 from A-Zee029/develop
fix:fail to start with docker-compose
2021-04-12 22:27:44 -05:00
奇淼(piexlmax c9f2301335 Merge pull request #432 from closetool/develop
fix: using official casbin gorm-adapter
2021-04-12 22:27:06 -05:00
huangjunwei 751a10d91e fix:fail to start with docker-compose 2021-04-12 16:03:49 +08:00
closetool 7c821bf673 fix: using official casbin gorm-adapter 2021-04-12 14:52:54 +08:00
pixel be2b584cee 修复指令绑定时效问题 修复Image组件未注册问题 2021-04-10 10:28:48 +08:00
pixel f39048fad0 清理 debugger 2021-04-10 09:51:22 +08:00
v_anxiong 4e9ce0de7e 前后端都加入了代码结构,方便学习和理解,也欢迎各位大佬进行补充,方便我这个菜鸟进行学习 2021-04-09 17:10:49 +08:00
SliverHorn 6e78abb34e Update sys_casbin.go 2021-04-08 18:14:21 +08:00
pixel ae5ec006ba 将gorm适配器调整至本地避免windows没有gcc的情况导致系统无法启动 2021-04-06 17:12:51 +08:00
pixel c9d1e424e9 更新表单生成器 2021-04-06 16:41:59 +08:00
pixel f48f39e024 Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into develop 2021-04-06 14:21:25 +08:00
奇淼(piexlmax 3dde9cfdc6 Merge pull request #426 from closetool/master
fix: casbin gorm-adapter has no sqlite3 support
2021-04-06 14:19:15 +08:00
pixel 85d6e954ae 同步swagger 2021-04-06 11:56:49 +08:00
closetool 146b0b2925 fix: casbin gorm-adapter has no sqlite3 support
Signed-off-by: closetool <c299999999@qq.com>
2021-04-04 21:42:22 +08:00
pixel 4faa807c53 增加批量删除功能 调节分页器样式 2021-04-01 17:15:24 +08:00
v_anxiong ea998db824 api/v1/sys_api.go api/v1/sys_menu.go api/v1/sys_user.go model/request/common.go 其中的参数校验代码Id改成ID,修复参数校验的bug 2021-04-01 16:45:18 +08:00
pixel 7334ad9f33 标签代码优化 字典历史bug修复 2021-03-30 14:42:22 +08:00
pixel f32d725773 Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-03-30 12:15:13 +08:00
songzhibin97 fb9bec8623 Merge remote-tracking branch 'upstream/gva_gormv2_dev' into gva_gormv2_dev 2021-03-29 16:49:32 +08:00
奇淼(piexlmax b7847e6198 Merge pull request #411 from songzhibin97/gva_gormv2_dev
#409 bug修复
2021-03-29 11:54:56 +08:00
奇淼(piexlmax 4307abf274 Merge pull request #413 from WangLeonard/gva_gormv2_dev-fix-automodelcode
修复代码生成中对gorm的重复检查
2021-03-29 11:54:21 +08:00
LeonardWang 8206e5cbad 修复代码生成中对gorm的重复检查 2021-03-25 23:35:35 +08:00
songzhibin97 73cc49448e #409 bug修复
- 修改
server/model/sys_auto_code.go
server/service/sys_auto_code.go
server/utils/file_operations.go
2021-03-24 14:12:07 +08:00
pixel a2f4d58648 紧急修复初始化会导致config配置文件错误的bug 2021-03-22 16:56:13 +08:00
蒋吉兆 5b290ef0b1 修复已知bug 2021-03-21 22:57:18 +08:00
蒋吉兆 b9a9c5d917 Merge branches 'gva_gormv2_dev' and 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-03-21 22:35:47 +08:00
奇淼(piexlmax 3112f0afe8 Merge pull request #404 from WangLeonard/gva_gormv2_dev-automodelcode
添加代码生成中route和gorm的自动注入
2021-03-21 22:33:16 +08:00
LeonardWang 0a3696ee01 添加代码生成中route和gorm的自动注入 2021-03-19 23:56:40 +08:00
joewan 03431dee58 Merge branch 'develop' into test_branch 2021-03-18 16:52:34 +08:00
奇淼(piexlmax 8f33b3de5e Update README.md 2021-03-18 14:31:28 +08:00
pixel 9e0f95ec48 清理工作流功能 2021-03-18 14:28:52 +08:00
pixel 7668e7fdde 清理工作流功能 2021-03-18 14:27:39 +08:00
pixel 0df2b3ea1c Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-03-18 12:21:30 +08:00
pixel 4f726f1eb8 修复 canshowBug 2021-03-18 12:20:20 +08:00
pixel 752e9f917e 前端优化减少体积 2021-03-18 12:19:27 +08:00
pixel a4493021e2 清理多余包 element按需加载 2021-03-18 12:19:27 +08:00
SliverHorn 13d823ec57 swagger 错误修复, swagger文档更新 2021-03-18 12:19:27 +08:00
SliverHorn a6736e6e30 修复v2.4.0的docker-compose的启动异常问题 2021-03-18 12:19:27 +08:00
蒋吉兆 9b26947849 修改form跳转出现的bug 2021-03-18 12:19:27 +08:00
奇淼(piexlmax 0af29cfcae Merge pull request #397 from songzhibin97/gva_gormv2_dev
代码自动迁移动态适配
2021-03-16 19:32:12 +08:00
songzhibin97 c63904aedf 修改动态迁移的一个小bug 2021-03-10 12:00:32 +08:00
pixel 076538a6b6 前端优化减少体积 2021-03-09 19:40:40 +08:00
pixel 8deefff08a 清理多余包 element按需加载 2021-03-09 19:40:40 +08:00
pixel 1cae92b119 修复检测是否初始化时的判断 2021-03-09 19:40:40 +08:00
songzhibin97 b5dbde8ad1 更新测试的mysql mysql配置 2021-03-09 15:17:57 +08:00
songzhibin97 45d552ac8c 代码自动迁移动态适配
修改
- server/config.yaml
- server/config/config.go
- server/config/viper.go
- server/service/sys_auto_code.go
新增
- server/config/auto_code.go
2021-03-09 14:59:20 +08:00
东邪黄药师 bdce16a582 fix error 2021-03-08 23:50:14 +08:00
东邪黄药师 7bf3294113 集中配置端口 2021-03-08 23:43:17 +08:00
SliverHorn 26dbd1446c Merge pull request #393 from SliverHorn/gva_gormv2_dev
修复v2.4.0的docker-compose的启动异常问题, swagger错误修复
2021-03-08 15:33:51 +08:00
SliverHorn 74796f3546 swagger 错误修复, swagger文档更新 2021-03-08 15:23:38 +08:00
pixel 48bb3b6452 修复检测是否初始化时的判断 2021-03-08 13:43:25 +08:00
SliverHorn c4ec7f562a 修复v2.4.0的docker-compose的启动异常问题 2021-03-08 12:53:48 +08:00
蒋吉兆 733874316a 修改form跳转出现的bug 2021-03-07 13:19:16 +08:00
pixel b5efcd251a Merge remote-tracking branch 'origin/master' 2021-03-05 20:33:58 +08:00
pixel b74ea58172 版本号更改提交 2021-03-05 20:30:02 +08:00
pixel 707dbac2ca 自动初始化中间件拦截 防止误操作无法进入初始化功能 2021-03-04 19:48:38 +08:00
pixel 184b1a903f 自动初始化整体调试完成 2021-03-04 19:38:07 +08:00
pixel 4a995a1c56 修复初始apibug 2021-03-04 16:02:17 +08:00
pixel e6768d5e17 cmd剔除 初始数据结构转移 修复初始携带apibug 2021-03-04 16:02:09 +08:00
pixel e3057c4bd9 自动初始化数据库功能后端部分完成 2021-03-04 15:57:07 +08:00
pixel 87f101a7bf 包位置调整 2021-03-02 19:53:26 +08:00
奇淼(piexlmax ab435d131c Merge pull request #387 from songzhibin97/gva_gormv2_dev
新增功能-api生成数据库并初始化回写配置
2021-03-02 19:29:34 +08:00
songzhibin97 674ae4c4a0 补充修改 2021-03-02 16:20:42 +08:00
songzhibin97 f3a84e2ca8 补充修改 2021-03-02 12:33:28 +08:00
songzhibin97 835dd15c47 订正了swagger
修改了
- server/api/v1/sys_initdb.go
- server/api/v1/sys_system.go
迁移了模型
- server/model/sys_init.go -> sysver/model/request/sys_init.go
2021-03-02 12:32:47 +08:00
pixel c983370162 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-03-01 10:33:26 +08:00
songzhibin97 00b5024f20 新增功能-api生成数据库并初始化回写配置
修改gva initdb 判断是否已经创建的一些小问题
新增api生成数据库并初始化回写配置
修改文件:
server/cmd/gva/initdb.go
server/cmd/information/data_authorities.go
server/cmd/information/workflow.go
server/initialize/gorm
server/main.go

新增文件:
server/api/v1/sys.initdb.go
server/middleware/init.go
server/model/sys_init.go
server/service/sys_initdb.go
servcer/utils/init_db.go

迁移文件
server/cmd/gva/mysql.go->server/utils/mysql.go
2021-02-27 17:32:41 +08:00
pixel ae0af55d17 字典样式修改 2021-02-27 12:48:18 +08:00
奇淼(piexlmax f19b398c93 Merge pull request #386 from songzhibin97/gva_gormv2_dev
新增api 重启服务(非windows)
2021-02-27 12:11:36 +08:00
songzhibin97 8743b63869 Update sys_system.go 2021-02-27 12:05:24 +08:00
songzhibin97 4af1627116 新增api重启系统(支持非windows)
修改
- server/api/v1/sys_system.go
- server/router/sys_system.go
2021-02-27 12:03:28 +08:00
pixel 5d4c4d53fc 前端系统配置增加 tencent-cos aliyun-oss 配置 2021-02-27 10:59:53 +08:00
pixel 62bc8092e2 对合并代码进行微调 2021-02-27 10:48:51 +08:00
pixel 4cea6f9f5d 更新了某些文本 让提示更加友好
根据scuxiatian提供的方案 修改了workflow前端组件的一些bug
2021-02-27 10:29:28 +08:00
奇淼(piexlmax decee13bf1 Merge pull request #384 from lauyang/develop
增加阿里云OSS
2021-02-27 10:26:15 +08:00
奇淼(piexlmax 60bfe48307 Merge branch 'develop' into develop 2021-02-27 10:26:00 +08:00
奇淼(piexlmax bca54282c9 Merge pull request #381 from MUHM/develop
为OSS增加腾讯云对象存储支持
2021-02-27 10:23:09 +08:00
pixel db933cecb6 更新了某些文本 让提示更加友好
根据scuxiatian提供的方案 修改了workflow前端组件的一些bug
2021-02-26 12:14:28 +08:00
yang.liu06 3f06c8ba7d add aliyun oss support 2021-02-24 22:07:50 +08:00
pixel f7fb34ec16 Merge remote-tracking branch 'origin/master' 2021-02-24 09:54:03 +08:00
pixel b691d53523 增加快速设置父级菜单功能 修复本地上传文件用户使用头像存在问题的bug 2021-02-24 09:53:45 +08:00
奇淼(piexlmax 5396aa40cb Update FUNDING.yml 2021-02-23 15:50:10 +08:00
pixel 1a43b89674 Merge remote-tracking branch 'origin/master' 2021-02-23 15:00:22 +08:00
奇淼(piexlmax fb570acf7c Merge pull request #376 from xiaoweihong/patch-1
NavigationDuplicated error
2021-02-23 15:00:03 +08:00
pixel 8c5d0ad64b Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin 2021-02-23 14:48:47 +08:00
pixel 74a92b08d8 更改 捐赠地址 2021-02-23 14:47:39 +08:00
klausY 3e6a3d97bb 提供一二级路由模板 2021-02-23 14:43:12 +08:00
pixel b3e4666108 Merge remote-tracking branch 'origin/master' 2021-02-23 11:00:56 +08:00
pixel a344f2bdb7 github.com/shirou/gopsutil 包版本修改为 v3.21.1 2021-02-23 10:39:03 +08:00
MUHM 4b6eb80ddb add TencentCOS support to OSS 2021-02-22 16:37:00 +08:00
奇淼(piexlmax 5226a2a26f Update FUNDING.yml 2021-02-20 11:00:04 +08:00
奇淼(piexlmax e8bb532cdc Update FUNDING.yml 2021-02-20 10:59:11 +08:00
pixel 171be652eb excel导入导出功能合并并且细节修改完成 2021-02-19 15:45:55 +08:00
xiaowei c410125c8f NavigationDuplicated error
NavigationDuplicated: Avoided redundant navigation to current location
![](https://img-blog.csdnimg.cn/20200901093646588.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjQwMjg0NQ==,size_16,color_FFFFFF,t_70)
2021-02-19 13:00:07 +08:00
pixel 0f6613c4a1 Merge branch 'develop' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev
 Conflicts:
	web/package.json
2021-02-14 21:41:34 +08:00
奇淼(piexlmax d278344dd4 Merge pull request #370 from hwb2017/develop-feature-excel
增加Excel导入导出示例功能
2021-02-14 21:40:04 +08:00
pixel c47b3eee2c 修复预览代码和生成代码均成为预览的问题 2021-02-14 12:54:17 +08:00
pixel 162b8df569 修复路径分割不同系统分隔符不同导致的panic 2021-02-14 12:53:47 +08:00
pixel 55e2109091 代码自动化生成支持预览功能 2021-02-13 16:24:38 +08:00
pixel 11efbe7699 initdb默认string长度改为191 2021-02-13 16:22:50 +08:00
pixel 329d094e2a Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-02-13 14:52:33 +08:00
奇淼(piexlmax 414766001b Merge pull request #374 from songzhibin97/gva_gormv2_dev
提供自动化代码预览功能
2021-02-13 14:51:28 +08:00
songzhibin97 e05e16dce4 抽出重复的内容优化PreviewTemp和CreateTemp 2021-02-11 19:33:11 +08:00
songzhibin97 3549f4cf1f 自动生成代码新增预览接口 2021-02-11 19:00:06 +08:00
pixel bedbd3c872 修复了子路由模式下两个keepalive相互切换 keepalive失效的问题 2021-02-09 19:25:56 +08:00
pixel 296110f969 修复了子路由模式下两个keepalive相互切换 keepalive失效的问题 2021-02-09 19:25:14 +08:00
hwb2017 f60b0f1750 增加Excel导入导出示例功能 2021-01-28 00:48:47 +08:00
SliverHorn 6ad13c5930 添加基础路由 返回错误后,仍然执行创建创建代码bug, 修复bug, #367 2021-01-26 17:12:51 +08:00
SliverHorn 6a1b53e3d4 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-01-26 17:10:07 +08:00
蒋吉兆 21ef7bdcc0 修改版本号 2021-01-24 17:44:00 +08:00
蒋吉兆 718574cdf3 修复了登陆时首页蓝点未点亮的bug 2021-01-24 17:36:38 +08:00
蒋吉兆 18571ca224 修复多次切换菜单后会出现路由地址改变,页面不变的情况 2021-01-24 17:08:35 +08:00
蒋吉兆 41c164a8ef Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin 2021-01-24 17:02:01 +08:00
蒋吉兆 f82acdb478 增加menu可配置是否自动关闭功能 增加单页面刷新功能 2021-01-24 17:01:43 +08:00
SliverHorn 40b56b6bf5 Merge pull request #364 from SliverHorn/gva_gormv2_dev
升级gva 工具 支持创建数据库与utf8mb4的sql修正功能, 版本迭代为v0.0.4
2021-01-21 22:54:33 +08:00
SliverHorn f259d69910 升级gva 工具 支持创建数据库与utf8mb4的sql修正功能, 版本迭代为v0.0.4 2021-01-21 19:44:55 +08:00
pixel 3952d5ec14 Merge branch 'develop' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev
 Conflicts:
	server/Makefile
	web/src/view/superAdmin/operation/sysOperationRecord.vue
2021-01-14 14:38:25 +08:00
pixel c1745f6f40 Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-01-14 14:33:59 +08:00
pixel 0940a70d86 支持默认首页 2021-01-14 12:37:49 +08:00
pixel 7abe6987a5 支持不同角色自定义首页 2021-01-14 12:28:13 +08:00
SliverHorn 7baa2c84a3 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2021-01-13 12:22:58 +08:00
songzhibin97 6867eb2c05 修复了在代码生成特殊情况下自动迁移文件移动错位置的情况
修改了services/sys_auto_code.go/addAutoMoveFile
修改了
services/sys_auto_code.go/CreateTemp
2021-01-13 12:03:11 +08:00
QM303176530 3d01706fb6 增加文件上传仓库配置注释说明 2021-01-10 23:48:50 +08:00
QM303176530 7707d4c99d 修复了媒体库中本地图片不显示的bug 2021-01-10 23:45:36 +08:00
QM303176530 b66d7a4e7a 解决了权限放在public组也会走权限控制的bug 2021-01-10 23:03:09 +08:00
pixel 8a67795faf 代码规范化整理 2021-01-08 17:34:17 +08:00
pixel 64299e6912 清理多余代码 2021-01-08 17:32:39 +08:00
pixel fdd522e56a 无用代码清理 2021-01-08 16:54:09 +08:00
奇淼(piexlmax 1c257fa830 Merge pull request #344 from 7beCn/master
修复table数据大于50条时页面卡死
2021-01-08 16:33:42 +08:00
SliverHorn 3d9fbbac63 Merge pull request #351 from flipped-aurora/gva_gormv2_dev
紧急修复bug
2021-01-05 23:13:55 +08:00
SliverHorn f83332b2c8 docker-compose shell 脚本更新 2021-01-05 23:02:11 +08:00
SliverHorn b8d187bb35 Makefile修改 4个空格 --> tab 2021-01-05 22:57:42 +08:00
SliverHorn 9567564bf4 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-12-30 20:58:01 +08:00
zzZ007 d05bf07db8 Update table.vue.tpl
修改自动生成代码,当table数据大于50条时,页面会卡死,替换掉 el-popover即可。
2020-12-30 17:20:35 +08:00
奇淼(piexlmax 5adb89694b Merge pull request #339 from flipped-aurora/revert-338-develop
Revert "修复了swag文档自动化生成失败的bug;完善了自动生成代码的swag部分"
2020-12-27 17:47:54 +08:00
奇淼(piexlmax e21146d048 Revert "修复了swag文档自动化生成失败的bug;完善了自动生成代码的swag部分" 2020-12-27 17:46:53 +08:00
QM303176530 4c7f04536d 修复了在当前表格当前页删除为空的情况下页面被锁死的bug 2020-12-27 17:46:11 +08:00
SliverHorn 71d0883c3d 优化gorm的自定义logger代码, 升级gorm的版本为1.20.9, Makefile 添加goproxy代理 2020-12-27 17:46:11 +08:00
pixel ee9022f9e3 user新建用户 bug处理 2020-12-27 17:46:11 +08:00
奇淼(piexlmax cc0a894162 Update README.md 2020-12-27 17:46:11 +08:00
奇淼(piexlmax d27f2ec966 Update README.md 2020-12-27 17:46:11 +08:00
pixel 83b7927c4b 登陆成功不再调用验证码接口 2020-12-27 17:46:11 +08:00
pixel e1975682a9 将JWT过期时间 刷新时间 放置进入config 2020-12-27 17:46:10 +08:00
pixel f914f96b9a 消除初始化时间0值报错 2020-12-27 17:46:10 +08:00
QM303176530 35a21d4e24 清理图标 form table 富文本 示例 2020-12-27 17:46:10 +08:00
奇淼(piexlmax 3e58190112 Update README.md 2020-12-27 17:46:10 +08:00
pixel 39150b2b2b 添加个人中心遮罩,添加自动更改title功能 2020-12-27 17:46:10 +08:00
SliverHorn f2b287f933 自定义logger保留gorm的格式输出控制台, 修改SetUserInfo的校验规则为IdVerify 2020-12-27 17:46:10 +08:00
QM303176530 e458e583ee 修复了在当前表格当前页删除为空的情况下页面被锁死的bug 2020-12-27 17:33:44 +08:00
奇淼(piexlmax 74c1fd5b7d Merge pull request #338 from ljj6218/develop
修复了swag文档自动化生成失败的bug;完善了自动生成代码的swag部分
2020-12-27 17:27:09 +08:00
QM303176530 2547ba88ae 修复了在当前表格当前页删除为空的情况下页面被锁死的bug 2020-12-27 17:20:54 +08:00
QM303176530 5c78ecc2d3 Merge branches 'develop' and 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-12-27 16:47:03 +08:00
奇淼(piexlmax 9c934917d0 Merge pull request #337 from SliverHorn/sliver_develop
优化gorm的自定义logger代码, 升级gorm的版本为1.20.9, Makefile 添加goproxy代理
2020-12-27 16:46:35 +08:00
奇淼(piexlmax 1132723355 Merge pull request #336 from JunIce/develop
chore: 增加自动扫描package.json, 从cdn引入资源
2020-12-27 16:44:29 +08:00
梁俊景 26261001f5 fix bug 2020-12-26 23:59:28 +08:00
梁俊景 2e3a1582ab 完善 2020-12-26 23:51:52 +08:00
梁俊景 5d1bcb3575 autocode 修复swag相关功能 2020-12-26 20:35:26 +08:00
SliverHorn 6c7d49b323 优化gorm的自定义logger代码, 升级gorm的版本为1.20.9, Makefile 添加goproxy代理 2020-12-26 00:52:18 +08:00
volcan0 843a585b7f chore: 增加自动扫描package.json, 从cdn引入资源 2020-12-25 14:03:49 +08:00
pixel 8df6fa6a33 user新建用户 bug处理 2020-12-19 16:05:52 +08:00
pixel 9ccb5439df Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin 2020-12-19 15:43:56 +08:00
奇淼(piexlmax 928d816c68 Update README.md 2020-12-16 15:51:25 +08:00
奇淼(piexlmax 27df9862ea Update README.md 2020-12-16 15:50:25 +08:00
pixel d428ed6876 登陆成功不再调用验证码接口 2020-12-16 15:44:37 +08:00
pixel 72fd7beec0 将JWT过期时间 刷新时间 放置进入config 2020-12-16 13:17:00 +08:00
pixel 7613b85271 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin 2020-12-16 11:43:45 +08:00
pixel 23eac98551 消除初始化时间0值报错 2020-12-16 11:43:22 +08:00
SliverHorn 8bd245b1f1 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-12-16 10:40:21 +08:00
QM303176530 b13bbfced1 清理图标 form table 富文本 示例 2020-12-13 12:42:38 +08:00
奇淼(piexlmax 645c788512 Update README.md 2020-12-11 15:12:28 +08:00
pixel 9f6c8f5e22 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-12-09 16:30:17 +08:00
pixel 9a4667fa46 添加个人中心遮罩,添加自动更改title功能 2020-12-09 16:30:06 +08:00
奇淼(piexlmax 338d81e101 Merge pull request #306 from SliverHorn/sliverhorn_dev
自定义logger保留gorm的格式输出控制台, 修改SetUserInfo的校验规则为IdVerify
2020-12-08 23:18:33 -06:00
SliverHorn 336d7473f7 自定义logger保留gorm的格式输出控制台, 修改SetUserInfo的校验规则为IdVerify 2020-12-07 12:11:50 +08:00
SliverHorn 265cd4d885 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-12-07 11:19:08 +08:00
QM303176530 cab8de721f 添加首字母小写方法 增加自动填充按键 2020-12-06 16:23:43 +08:00
QM303176530 4030cd325c Merge branches 'develop', 'gva_gormv2_dev' and 'master' of https://github.com/flipped-aurora/gin-vue-admin into develop 2020-12-06 15:37:36 +08:00
奇淼(piexlmax d796a39aa7 Merge pull request #299 from tingfeng-key/patch-1
Update image.vue
2020-12-06 01:24:42 -06:00
奇淼(piexlmax 04d8303f28 Merge pull request #304 from songzhibin97/gva_gormv2_dev
修改了热更正在运行时重启信号的丢弃
2020-12-06 01:21:10 -06:00
奇淼(piexlmax 5eec28a964 Merge pull request #302 from tingfeng-key/patch-3
添加自动填充功能
2020-12-06 01:20:49 -06:00
songzhibin97 a5e5c588ba Update cmd_Task.go 2020-12-05 22:49:57 +08:00
SliverHorn 34e6ccc6e2 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-12-04 23:20:45 +08:00
奇淼(piexlmax 6a028e13cb Merge pull request #303 from tingfeng-key/patch-4
修复提示权限不足和图片显示问题
2020-12-04 08:50:28 -06:00
听风 176e9d09b6 修复提示权限不足和图片显示问题
修复提示权限不足和图片显示问题
2020-12-04 22:35:25 +08:00
听风 7ddcf97efd 添加自动填充功能
添加自动填充功能。field字段填充json、数据库表,中文填充数据库表字段描述字段
2020-12-04 22:33:12 +08:00
听风 e19bda949b Update image.vue 2020-12-03 19:05:26 +08:00
听风 b09d142091 Update image.vue
修复上传图片组件bug
2020-12-03 18:16:03 +08:00
QM303176530 e102f820c1 修复了流程终止依然显示进行中的bug 2020-11-29 22:12:51 +08:00
QM303176530 36627e4ca5 操作人参数错误 2020-11-28 19:24:08 +08:00
QM303176530 9c6e6ca1b2 Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin 2020-11-28 19:04:19 +08:00
QM303176530 f32fdbf543 增加自审批节点,修改待办查询bug,修改角色查询bug 2020-11-28 18:59:02 +08:00
奇淼(piexlmax 7342788339 Update README.md 2020-11-28 11:58:51 +08:00
QM303176530 15d6ff0144 Merge branches 'develop' and 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-28 11:47:18 +08:00
QM303176530 9718b16e39 增加首页教学入口 2020-11-28 11:43:54 +08:00
QM303176530 e80842207f 更新版本号 2020-11-28 11:07:54 +08:00
QM303176530 58585afdf6 默认丢出false 防止前端warnning 2020-11-28 11:06:44 +08:00
QM303176530 a3eee91cef 修复几个模板错误 2020-11-28 10:34:30 +08:00
QM303176530 9098eaf22e Merge branches 'gva_gormv2_dev' and 'gva_workflow' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-28 10:10:48 +08:00
pixel 2d3b039f71 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into develop 2020-11-25 17:18:35 +08:00
pixel 864c468440 命名修复 2020-11-25 17:18:07 +08:00
pixel cc295fad32 文件名更改 2020-11-25 17:11:11 +08:00
奇淼(piexlmax b4e0dc800d Merge pull request #290 from songzhibin97/develop
优化基础库的一些错误处理
2020-11-25 03:09:50 -06:00
奇淼(piexlmax 5e7078e3a6 Merge branch 'develop' into develop 2020-11-25 02:55:43 -06:00
songzhibin97 2829d7b653 优化基础库的一些错误处理 2020-11-25 16:24:20 +08:00
songzhibin97 ba834592a7 修改了zipfiles.go中ZipFiles函数可能会造成的goroutine泄露 2020-11-25 15:50:28 +08:00
奇淼(piexlmax 1607e6a0a9 Merge pull request #284 from xiaopenggithub/master
前端发布优化,部分组件使用cdn资源,不打包
2020-11-24 23:21:00 -06:00
奇淼(piexlmax f936029d59 Merge pull request #283 from SliverHorn/sliverhorn_dev
gorm日志收集进log功能
2020-11-24 23:09:16 -06:00
曾阿牛 9f1552f508 前端发布优化,部分组件使用cdn资源,不打包 2020-11-25 02:38:39 +08:00
SliverHorn c00d465709 新增切片越界的检查 2020-11-24 21:17:07 +08:00
SliverHorn c2a55931bb 自定义gorm的logger 2020-11-24 19:27:16 +08:00
SliverHorn e957e5ebc9 Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-24 19:10:21 +08:00
1319612909 1357e22330 手机端ui 2020-11-24 18:11:32 +08:00
pixel 8a282cd743 增加工作流步骤查看 2020-11-24 18:07:14 +08:00
1319612909 6ca7f62ce6 手机端ui 2020-11-24 17:20:12 +08:00
pixel 6ee7ad8069 隐藏0.01未完成功能 2020-11-24 16:59:31 +08:00
pixel 307b1bf496 工作流前端垃圾代码剔除 2020-11-24 16:08:40 +08:00
pixel 61f50980e1 增加自动化产生的工作流form页面 2020-11-24 16:07:55 +08:00
pixel 5293222ac0 包容网关 流转参数模式设定 2020-11-24 14:57:30 +08:00
奇淼(piexlmax 411a21d0f7 Merge pull request #282 from golyu/master
[utils/zipfiles.go]: 解决for循环中使用defer可能会造成的内存泄露问题
2020-11-23 21:46:11 -06:00
pixel 8a5d788e73 增加排他网关和包容网关 2020-11-24 11:33:16 +08:00
golyu 3e48fa55c7 [utils/zipfiles.go]: 解决for循环中使用defer可能会造成的内存泄露问题 2020-11-23 20:45:15 +08:00
pixel cd735e727e 普通工作流流动完成 2020-11-23 18:15:51 +08:00
pixel 1eb69c696a 普通工作流流动完成 2020-11-23 18:15:23 +08:00
pixel 8208ccf5a3 Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow
 Conflicts:
	server/initialize/router.go
	server/router/sys_workflow.go
2020-11-23 18:14:43 +08:00
pixel 1591944756 普通工作流流动完成 2020-11-23 18:13:46 +08:00
songzhibin97 8e87ae55a9 Revert "pointChange"
This reverts commit fb4dba1616.
2020-11-23 12:02:18 +08:00
QM303176530 85fce8f01e 中间件包导入 2020-11-22 23:27:33 +08:00
QM303176530 7475bc56c9 中间件不再记录二进制文件类型日志 2020-11-22 23:19:36 +08:00
QM303176530 7af2dffb7a 日志记录中间件位置转移 2020-11-22 23:12:50 +08:00
QM303176530 15f2d149df 修改了自动化代码自动化创建api会被禁止的bug 2020-11-22 23:09:34 +08:00
QM303176530 c09924dbdc 修改了自动化代码自动化创建api会被禁止的bug 2020-11-22 23:09:20 +08:00
songzhibin97 1ddd6dac4f pointChange 2020-11-22 18:05:51 +08:00
SliverHorn b45afe9669 当用户不存在时,拉黑前端的token 2020-11-21 11:18:13 +08:00
SliverHorn 1e85e03713 utils备注统一化, 删除多余的函数 2020-11-21 11:07:05 +08:00
SliverHorn 43eef673bc 修复自杀操作bug 2020-11-21 01:26:01 +08:00
SliverHorn 41ce276dbd 添加utils函数注释 2020-11-21 01:15:26 +08:00
SliverHorn d6e078f3d6 路由组鉴权优化 2020-11-20 23:26:17 +08:00
pixel a487266f5b 数据动态查找以及动态赋值方法变更 2020-11-19 17:24:05 +08:00
pixel 0286d56e9c 增加获取工作流详细页面信息的接口和对应调用 2020-11-18 18:06:31 +08:00
songzhibin97 4c2f43b4cf f 2020-11-17 21:20:18 +08:00
songzhibin97 9bbcb62505 热更++ 2020-11-17 20:50:14 +08:00
pixel 5bb840c1ce 调整初始化数据 2020-11-17 18:05:22 +08:00
pixel 8f221b6b0b Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow
 Conflicts:
	server/cmd/datas/init.go
2020-11-17 17:41:12 +08:00
pixel ac4398873b 增加初始化参数 2020-11-17 17:35:23 +08:00
pixel 2fad9035d3 增加工作流使用方法 接口
增加工作流通用完成方法
增加查询待办
查询我发起的工作流功能
增加测试示例
2020-11-17 16:41:43 +08:00
SliverHorn ef03c95f40 锁定gorm-adapter/v3的版本为v3.0.2 2020-11-17 11:50:19 +08:00
songzhibin97 eb7a6411d1 bug log++ 2020-11-16 22:12:44 +08:00
songzhibin97 e02e70ff26 c2 2020-11-16 21:31:38 +08:00
songzhibin97 b6843e04d5 Update cmd_Task.go 2020-11-16 21:07:57 +08:00
songzhibin97 5e4c82b94a 热更新
修改bug 优化增加回显
2020-11-16 20:55:47 +08:00
SliverHorn 1f411ec6e0 From->Form 2020-11-16 20:40:51 +08:00
SliverHorn a890bd2d38 解决err覆盖问题 2020-11-16 18:38:20 +08:00
1319612909 7a47f59945 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-16 14:11:19 +08:00
1319612909 830c2cf29b menu 三级菜单样式 2020-11-16 14:11:10 +08:00
SliverHorn 86593943d3 更新获取工作路径代码,修改go.mod的go版本为1.14 2020-11-16 00:11:21 +08:00
songzhibin97 7c188fa7ce 热更新
缺少具体配置 监控文件以及防抖
2020-11-15 15:51:16 +08:00
SliverHorn a9432b5d9c 更新自动化代码api层代码混入service层代码 2020-11-14 23:15:57 +08:00
songzhibin97 0bebb7f65b Update cmd_Task.go
c2
2020-11-14 19:36:22 +08:00
songzhibin97 6536caed75 Hotreload
Hotreload1
2020-11-14 19:21:06 +08:00
pixel 4863b2c5be 添加流转接口 设计流转表 2020-11-12 18:21:03 +08:00
pixel 86afc0ddf4 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow 2020-11-11 11:34:19 +08:00
pixel bf6f469dad 修复可能产生数据库锁死的事务错误
修复菜单参数无法修改的错误
2020-11-11 10:59:46 +08:00
pixel 68677e1b5b 增加友好提示 2020-11-11 09:59:18 +08:00
pixel f4709f00ab 工作流起始接口以及动态获取view功能 2020-11-10 17:39:29 +08:00
1319612909 8392398b1c Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-10 14:06:19 +08:00
1319612909 b4355b4399 css整理 2020-11-10 14:06:03 +08:00
pixel b12bbc74ff 更新workflow函数说明 清理无用workflow文件 2020-11-10 11:50:24 +08:00
pixel d3dbca0e00 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow
 Conflicts:
	server/api/v1/sys_work_flow.go
	server/service/sys_workflow.go
2020-11-10 11:43:56 +08:00
pixel 81e0e4dde7 menu携带参数问题修复 2020-11-10 11:33:28 +08:00
SliverHorn fba9ab0ae6 删除FindSysDictionary的校验 2020-11-09 21:24:23 +08:00
QM303176530 e18518b4d3 版本号更新 2020-11-08 14:47:04 +08:00
QM303176530 074a7145d2 Merge branches 'gva_gormv2_dev' and 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-08 14:42:47 +08:00
QM303176530 46372f0e6c Merge remote-tracking branch 'origin/gva_gormv2_dev' into gva_gormv2_dev 2020-11-08 14:20:19 +08:00
QM303176530 1acd2e3238 前端代码优化 修改密码迁移至个人中心内部 2020-11-08 14:15:06 +08:00
SliverHorn a2e7827aa8 模板文件server/sevice层备注的规范化 2020-11-08 14:02:07 +08:00
SliverHorn ac71aafe83 service层注释规范化 2020-11-08 13:34:17 +08:00
SliverHorn 0b1cc913d9 service层注释规范化 2020-11-08 13:30:12 +08:00
QM303176530 84b967ae82 增强自动化代码使用体验 2020-11-08 13:01:28 +08:00
QM303176530 cf9002a377 自动化代码体验优化 2020-11-08 12:47:55 +08:00
songzhibin97 829fa4dac5 re 2020-11-08 11:08:02 +08:00
songzhibin97 5529d5f46d change2 2020-11-08 10:58:17 +08:00
songzhibin97 08e9c6b38a 优化auto 2020-11-08 07:52:15 +08:00
SliverHorn 5c94c73004 修改模板文件,规范化代码 2020-11-08 03:15:27 +08:00
SliverHorn 8ebb1fda77 修复中间件导包错误及代码优化,更新swagger文档 2020-11-08 02:54:14 +08:00
SliverHorn 96380bd031 server/api/v1层代码swagger备注错误修改及代码优化 2020-11-08 02:43:11 +08:00
SliverHorn c342e63e63 修复一些问题 2020-11-07 22:50:01 +08:00
SliverHorn 4fa43c232d Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-07 18:28:19 +08:00
SliverHorn d07cbc8783 修复bug 2020-11-07 18:28:04 +08:00
SliverHorn f7667ad3e1 修复bug 2020-11-07 18:24:07 +08:00
krank666 5fe66b7abc Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-07 18:22:32 +08:00
krank666 856c09c38d 个人中心优化 2020-11-07 18:22:26 +08:00
v_zhibsong b947f043ee change2 2020-11-07 18:03:23 +08:00
SliverHorn ebd515f057 add addAutoMoveFile 2020-11-07 17:32:58 +08:00
v_zhibsong 636faaf93b Update file_operations.go 2020-11-07 16:00:55 +08:00
v_zhibsong ed1c6c7a47 change filepath 2020-11-07 16:00:09 +08:00
v_zhibsong e4340641ad change filemove 2020-11-07 15:35:12 +08:00
SliverHorn 35738cfda8 add autoMoveFilePath 字段,修改utils的fileoperations.go-> file_operations.go 2020-11-07 15:09:11 +08:00
SliverHorn e749adaa10 修改初始化数据时的colume->column 2020-11-07 11:54:04 +08:00
SliverHorn 26a1a89d60 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-07 11:38:41 +08:00
SliverHorn 2daa65f00d 修复错别单词colume -> column, 删除tag中多余的; 2020-11-07 11:38:36 +08:00
v_zhibsong d2579d390c add filemove
add filemove
2020-11-07 11:32:45 +08:00
SliverHorn 261e34a5c2 添加自动移动文件的boo; 2020-11-07 11:04:54 +08:00
SliverHorn b4bad21e35 修改v1/sys_menu.go的备注错误及代码优化 2020-11-07 10:40:00 +08:00
SliverHorn 699f53e8b2 修复配置文件设置 zap: show-line: true 没有打印文件及行号的bug 2020-11-07 09:07:57 +08:00
SliverHorn 820c9f733f 优化server/api/v1/exa_customer.go的代码及备注错误 2020-11-07 00:32:31 +08:00
SliverHorn 99bd217080 修改错误单词,新增从gin.Context获取用户id,uuid,authority_id的函数 2020-11-07 00:14:36 +08:00
SliverHorn c86c05f380 修改server/api/v1/sys_user.go的备注错误 2020-11-06 23:45:33 +08:00
pixel 544901bf45 Merge remote-tracking branch 'origin/gva_gormv2_dev' into gva_gormv2_dev 2020-11-06 18:51:51 +08:00
pixel 8db0e2fb06 连接池最大链接数修改为100 2020-11-06 16:54:23 +08:00
pixel c5ed47192e 自动化代码中 批量删除功能增加未选择条目时提醒功能 2020-11-06 16:52:06 +08:00
klausY 3d56cb7eb2 修改scrollBar样式 2020-11-06 16:09:30 +08:00
pixel ada8818960 增加自动化生成表单功能,修改自动化生成文件的文件夹名称更加规范化,css样式调整。 2020-11-06 16:01:09 +08:00
pixel 2f97f4b979 自动填充API功能不再需要手动清理垃圾数据 2020-11-06 14:42:26 +08:00
pixel 0a4e81138a css增加悬浮效果 2020-11-05 17:25:10 +08:00
1319612909 c61350643a index css 2020-11-03 22:28:04 +08:00
1319612909 9f59275652 css 2020-11-05 10:03:01 +08:00
1319612909 1da644b96a css 2020-11-04 18:23:32 +08:00
1319612909 1de825ee43 css 2020-11-04 17:58:14 +08:00
1319612909 2e18f3f5e1 css aside 2020-11-04 11:55:23 +08:00
1319612909 653f73b989 更换ip 2020-11-03 18:12:23 +08:00
1319612909 9c5b9729d8 aside + header css 2020-11-03 18:05:44 +08:00
1319612909 6950e493f2 aside + header css 2020-11-03 18:04:59 +08:00
1319612909 286f0b74da css 整理 2020-11-02 21:59:13 +08:00
pixel a1191abc43 自动化代码不再记录日志 2020-11-02 11:19:29 +08:00
pixel 75799b81e8 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-02 11:02:51 +08:00
pixel 511a187f49 当自动化代码报错时不下载 2020-11-02 11:02:25 +08:00
QM303176530 01ecfcdf8d Merge branches 'gva_gormv2_dev' and 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-11-01 19:58:29 +08:00
SliverHorn 14a55fcb83 修改断点续传的提交方式代码 2020-11-01 19:50:34 +08:00
奇淼(piexlmax 49c146b3dc Update README.md 2020-10-31 16:17:03 +08:00
QM303176530 e2c5988bea 修复自动化代码bug 2020-10-31 15:09:13 +08:00
QM303176530 4828dc3dae 增加节点视图配置 2020-10-31 14:00:12 +08:00
QM303176530 8413f0e8d3 Merge branches 'gva_gormv2_dev' and 'gva_workflow' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow 2020-10-31 00:11:55 +08:00
QM303176530 3d2e9ef063 Merge branches 'develop' and 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into develop 2020-10-31 00:09:09 +08:00
QM303176530 28c7d178c4 模板按钮美化 2020-10-31 00:08:05 +08:00
QM303176530 5bfc5563b3 工作流增删改查功能完善 2020-10-31 00:04:42 +08:00
QM303176530 d6bc0572c2 工作流增删改查功能完善 2020-10-31 00:03:49 +08:00
QM303176530 32abd69c16 Merge branches 'gva_gormv2_dev', 'gva_workflow' and 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow
 Conflicts:
	server/cmd/datas/init.go
2020-10-29 22:30:04 +08:00
QM303176530 024f461e94 date 错别字修复 2020-10-29 22:12:42 +08:00
QM303176530 a25823f5b5 修复minxs路径,调整前端结构 2020-10-29 22:08:21 +08:00
QM303176530 4d4d8e4955 修复mixins路径,调整目录结构 2020-10-29 22:08:08 +08:00
SliverHorn 7488db81c1 add err := and delete postgresql initdb 2020-10-29 22:13:24 +08:00
QM303176530 e8c6d388f2 自动化代码可以自动创建form,前端样式修复,前端mixin位置转移 2020-10-29 22:06:09 +08:00
pixel 02f155f497 整体结构变更 新增方法数据错乱问题修复 2020-10-29 17:57:29 +08:00
pixel c570c095b9 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow
 Conflicts:
	server/cmd/datas/apis.go
	server/cmd/datas/menus.go
	server/model/sys_workflow.go
	server/model/sys_workflow_process.go
2020-10-29 11:41:38 +08:00
pixel 10d8d7f28a 修改gorm.Model为自定义的全局global.GVA_MODEL 方便自定义基础参数 2020-10-29 11:23:34 +08:00
pixel 0e1a820c3a 工作流入库功能 2020-10-29 09:37:02 +08:00
pixel bf21fec50e 工作流录入 根据id查询方法增加 2020-10-27 18:59:51 +08:00
pixel 4e514dc83e 自动化接口填充以及初始化数据制作 2020-10-27 17:38:13 +08:00
pixel 3f52783b30 Merge branch 'gva_workflow' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow 2020-10-27 16:39:56 +08:00
pixel 16bab848e1 增加description 2020-10-27 16:39:48 +08:00
奇淼(piexlmax 986406a880 Merge pull request #261 from Enginebeck/develop
jwt.go: fix localStorage spell error
2020-10-27 14:53:23 +08:00
奇淼(piexlmax 2946c8ce34 Merge pull request #262 from Zh1Cheung/master
[fix] Unhandled error
2020-10-27 14:51:58 +08:00
奇淼(piexlmax fef12cb747 Merge pull request #257 from Junvary/own_dev
多了一个转义,后端跨域不生效
2020-10-26 21:22:40 +08:00
QM303176530 b710f6a5df 增加快捷键复制粘贴 2020-10-26 20:57:48 +08:00
QM303176530 840723c592 Merge branch 'gva_workflow' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow 2020-10-26 20:45:28 +08:00
QM303176530 6f63290e74 取消无用节点 2020-10-26 20:44:55 +08:00
张子恒 4d8d4b77c1 Update jwt.go 2020-10-26 20:15:30 +08:00
pixel 10b009bb7e 增加ctrl+z ctrl+y 2020-10-26 18:52:41 +08:00
SliverHorn 7cb172d60a rename data->date 2020-10-26 18:33:45 +08:00
pixel 8350dfe2c9 增加delete删除node功能 2020-10-26 18:21:01 +08:00
SliverHorn 970b2d21a9 add server/api/v1/exa_breakpoint_continue.go error response message 2020-10-26 17:30:23 +08:00
pixel e9c5ac6ec0 修改 workflow数据结构 2020-10-26 16:51:24 +08:00
SliverHorn f7804b627e add gva error message 2020-10-26 15:55:55 +08:00
pixel 247487529b 设计workflow数据结构 2020-10-26 13:37:55 +08:00
pixel 5ef5af4723 侧边更新 2020-10-26 13:31:11 +08:00
pixel 2188f79e77 Merge branch 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow 2020-10-26 12:44:43 +08:00
pixel a7bb4a7ac4 Merge remote-tracking branch 'origin/gva_gormv2_dev' into gva_gormv2_dev 2020-10-26 12:39:27 +08:00
pixel 06c67c1024 修改 注册接口地址 2020-10-26 12:37:20 +08:00
SliverHorn 03024f192a Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-10-26 11:33:28 +08:00
SliverHorn b1baccf0a5 update docker-compose related and update server/Dockerfile 2020-10-26 11:33:17 +08:00
pixel ad047f4c06 gorm 版本升级为 1.20.5 2020-10-26 11:22:40 +08:00
pixel dc1cc2ec10 前端添加默认数据 2020-10-26 11:19:04 +08:00
Beck Qin 6f589d7af9 jwt.go: fix localStorage spell error 2020-10-26 09:27:52 +08:00
SliverHorn eeaaa40259 add Makefile help information 2020-10-25 11:37:15 +08:00
QM303176530 e394a3afdf 忽略某些js文件的eslint 2020-10-25 11:27:38 +08:00
QM303176530 45cc0aec93 版本号更新 2020-10-25 10:42:34 +08:00
QM303176530 0bd80ad900 Merge branches 'gva_gormv2_dev' and 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev 2020-10-25 10:36:53 +08:00
QM303176530 1214241dab 版本号更新发版 2020-10-25 10:36:23 +08:00
QM303176530 28dbad6c1f Merge branches 'gva_gormv2_dev' and 'gva_workflow' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow 2020-10-24 17:05:13 +08:00
QM303176530 84e35753cf 工作流插件参与进入项目本体 2020-10-24 17:04:04 +08:00
QM303176530 6a03008ac9 修改bat文件名 表达正确含义 2020-10-24 16:20:20 +08:00
奇淼(piexlmax cc215d6ad0 Update README.md 2020-10-23 21:14:19 +08:00
Junvary e28217e5ec Update cors.go
多了一个转义,后端跨域不生效
2020-10-23 16:08:50 +08:00
pixel cebb9b3002 修改默认数据 2020-10-23 14:29:09 +08:00
SliverHorn 0d8edbbb64 update initdb 2020-10-23 14:05:36 +08:00
pixel 4abcbeb420 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow 2020-10-23 14:02:47 +08:00
pixel 77aea09d5f 修改目录结构 2020-10-23 13:58:48 +08:00
SliverHorn 2baf392129 system add middleware, update markfile, add data 2020-10-23 13:57:41 +08:00
pixel c56e0416f2 Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow
 Conflicts:
	server/gva/init_data/init_data.go
2020-10-23 13:27:06 +08:00
pixel d478246edc Merge branch 'master' of https://github.com/piexlmax/QMPlus into gva_gormv2_dev 2020-10-23 13:20:41 +08:00
SliverHorn ea375a026d add windows bat and change mysql password 2020-10-23 13:18:43 +08:00
奇淼(piexlmax 9101d5bdb8 Update README.md 2020-10-23 13:13:59 +08:00
SliverHorn 811df12524 Fix the error that windows cannot create soft connection 2020-10-23 11:04:29 +08:00
SliverHorn 3ee469aef3 add Makefile 2020-10-22 18:18:40 +08:00
SliverHorn 7b503337b1 add .gitignore ignore gva files, and optimization zap.go:Repair split file is windows error 2020-10-22 16:50:20 +08:00
SliverHorn dd65a4a716 Migrate the gva project to the cmd folder, delete other redundant database configurations, optimize the initialization method of viper, zap, and gorm 2020-10-22 16:28:51 +08:00
QM303176530 9865d53ea7 Merge branches 'gva_workflow' and 'master' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow
 Conflicts:
	web/package.json
2020-10-11 12:24:11 +08:00
QM303176530 213d1a700f 更新gva-wfd的前端版本 2020-10-10 20:29:58 +08:00
pixel e18f0cae1a 修改工作流基础功能 2020-10-09 17:42:11 +08:00
pixel 973da4df7e Merge branch 'gva_gormv2_dev' of https://github.com/piexlmax/QMPlus into gva_workflow 2020-10-09 16:16:36 +08:00
pixel b9f7783878 增加工作流前端页面 2020-10-09 16:11:46 +08:00
361 changed files with 14208 additions and 7377 deletions
+9 -38
View File
@@ -10,6 +10,8 @@ cat>"${filename}"<<EOF
# jwt configuration
jwt:
signing-key: 'qmPlus'
expires-time: 604800
buffer-time: 86400
# zap logger configuration
zap:
@@ -49,8 +51,6 @@ system:
addr: 8888
db-type: 'mysql'
oss-type: 'local'
config-env: 'GVA_CONFIG'
need-init-data: true
use-multipoint: false
# captcha configuration
@@ -61,44 +61,15 @@ captcha:
# mysql connect configuration
mysql:
path: '177.7.0.13:3306'
config: 'charset=utf8mb4&parseTime=True&loc=Local'
db-name: 'qmPlus'
username: 'root'
password: 'Aa@6447985'
path: ''
config: ''
db-name: ''
username: ''
password: ''
max-idle-conns: 10
max-open-conns: 10
max-open-conns: 100
log-mode: false
# sqlite connect configuration (sqlite需要gcc支持 windows用户需要自行安装gcc)
sqlite:
path: 'db.db'
max-idle-conns: 10
max-open-conns: 10
logger: true
# Sqlserver connect configuration
sqlserver:
path: 'localhost:9930'
db-name: 'gorm'
username: 'gorm'
password: 'LoremIpsum86'
max-idle-conns: 10
max-open-conns: 10
logger: true
# Postgresql connect configuration
postgresql:
host: '127.0.0.1'
port: '9920'
config: 'sslmode=disable TimeZone=Asia/Shanghai'
db-name: 'gorm'
username: 'gorm'
password: 'gorm'
max-idle-conns: 10
max-open-conns: 10
prefer-simple-protocol: true
logger: false
log-zap: ""
# local configuration
local:
+1 -1
View File
@@ -2,7 +2,7 @@
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
open_collective: gin-vue-admin
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+1
View File
@@ -24,6 +24,7 @@ yarn-error.log*
go.sum
/server/log/
/server/gva
/server/latest_log
*.iml
+17 -5
View File
@@ -12,9 +12,19 @@
[English](./README-en.md) | 简体中文
[gitee地址:https://gitee.com/pixelmax/gin-vue-admin](https://gitee.com/pixelmax/gin-vue-admin)
[github地址:https://github.com/flipped-aurora/gin-vue-admin](https://github.com/flipped-aurora/gin-vue-admin)
[vue3版本分支地址:https://github.com/flipped-aurora/gin-vue-admin/tree/vue3Develop](https://github.com/flipped-aurora/gin-vue-admin/tree/vue3Develop)
[审批流分支:https://github.com/flipped-aurora/gin-vue-admin/tree/gva_workflow](https://github.com/flipped-aurora/gin-vue-admin/tree/gva_workflow)
# 项目文档
[在线文档](https://www.gin-vue-admin.com/) : https://www.gin-vue-admin.com/
[从环境到部署教学视频](https://www.bilibili.com/video/BV1fV411y7dT)
[开发教学](https://www.gin-vue-admin.com/docs/help) (贡献者: <a href="https://github.com/LLemonGreen">LLemonGreen</a> And <a href="https://github.com/fkk0509">Fann</a>)
- 前端UI框架:[element-ui](https://github.com/ElemeFE/element)
- 后台框架:[gin](https://github.com/gin-gonic/gin)
@@ -67,7 +77,7 @@ Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-adm
- node版本 > v8.6.0
- golang版本 >= v1.14
- IDE推荐:Goland
- gormv2版本初始化数据库可以利用批量创建功能,这里已经写好初始化代码,需要在main.go内打开 initialize.Data() 的注释即可
- 初始化项目: 不同版本数据库初始化不通 参见https://www.gin-vue-admin.com/docs/server#1-%E5%88%9D%E5%A7%8B%E5%8C%96server%E9%A1%B9%E7%9B%AE
- 替换掉项目中的七牛云公钥,私钥,仓名和默认url地址,以免发生测试文件数据错乱
```
@@ -131,6 +141,7 @@ Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-adm
> <font color=red>**使用docker-compose进行部署本项目需注意的问题**</font>
- dockerfile_server使用了多阶段构建,这是docker 17.05后引入的,因此安装的docker版本需要高于17.05
- mysql数据库请使用装在服务器磁盘的本地数据库.
- 避免使用docker容器内的mysql,可能会出现写入的问题, io比宿主机低 docker的持久化机制问题
- [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql)是给docker-compose进行<font color=red>体验本项目</font>的, 禁止[init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql)使用进行项目数据的初始化, 数据库初始化[请使用此方法](https://www.gin-vue-admin.com/docs/help#step1%EF%BC%9A%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%9D%E5%A7%8B%E5%8C%96)
@@ -155,6 +166,8 @@ npm run serve
### 2.2 server端
使用 goland等编辑工具,打开server目录,不可以打开 gin-vue-admin 根目录
```bash
# 使用 go.mod
@@ -210,12 +223,12 @@ zap:
#### 2.3.1 安装 swagger
##### (1)可以翻墙
##### (1)可以访问外国网站
````
go get -u github.com/swaggo/swag/cmd/swag
````
##### (2)无法翻墙
##### (2)无法访问外国网站
由于国内没法安装 go.org/x 包下面的东西,推荐使用 [goproxy.io](https://goproxy.io/zh/)
@@ -236,7 +249,7 @@ go get -u github.com/swaggo/swag/cmd/swag
cd server
swag init
````
执行上面的命令后,server目录下会出现docs文件夹,登录http://localhost:8888/swagger/index.html,即可查看swagger文档
执行上面的命令后,server目录下会出现docs文件夹,登录 http://localhost:8888/swagger/index.html ,即可查看swagger文档
## 3. 技术选型
@@ -315,7 +328,6 @@ swag init
- [ ] 导入,导出Excel
- [ ] Echart图表支持
- [ ] 工作流,任务交接功能开发
- [ ] 单独前端使用模式以及数据模拟
## 7. 知识库
+1 -1
View File
@@ -1,4 +1,4 @@
version: "3.8"
version: "3"
networks:
network:
+1 -16
View File
@@ -12,8 +12,7 @@ RUN sh ./server-handle.sh
RUN rm -f server-handle.sh
RUN cat ./config.yaml
RUN go env && go build -o server .
RUN go env && go mod tidy && go build -o server .
FROM alpine:latest
LABEL MAINTAINER="SliverHorn@sliver_horn@qq.com"
@@ -27,17 +26,3 @@ COPY --from=0 /go/src/gin-vue-admin/resource ./resource
EXPOSE 8888
ENTRYPOINT ./server
# 根据Dockerfile生成Docker镜像
# docker build -t gva-server:1.0 .
#- 根据Docker镜像启动Docker容器
# - 后台运行
# - ```
# docker run -d -p 8888:8888 --name gva-server-v1 gva-server:1.0
# ```
# - 以可交互模式运行, Ctrl + p + q
# - ```
# docker run -it -p 8888:8888 --name gva-server-v1 gva-server:1.0
# ```
+15 -14
View File
@@ -1,19 +1,20 @@
FROM golang:alpine as builder
FROM golang:alpine
# 设置go mod proxy 国内代理
# 设置golang path
ENV GOPROXY=https://goproxy.cn,https://goproxy.io,direct \
GO111MODULE=on \
CGO_ENABLED=1
WORKDIR /ginvue
RUN go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.io,direct
WORKDIR /go/src/gin-vue-admin
COPY . .
RUN go env && go list && go build -o app main.go
RUN go env && go build -o server .
FROM alpine:latest
LABEL MAINTAINER="SliverHorn@sliver_horn@qq.com"
WORKDIR /go/src/gin-vue-admin
COPY --from=0 /go/src/gin-vue-admin/server ./
COPY --from=0 /go/src/gin-vue-admin/config.yaml ./
COPY --from=0 /go/src/gin-vue-admin/resource ./resource
EXPOSE 8888
ENTRYPOINT /ginvue/app
# 根据Dockerfile生成Docker镜像
# docker build -t ginvue .
# 根据Docker镜像启动Docker容器
# docker run -itd -p 8888:8888 --name ginvue ginvue
ENTRYPOINT ./server
+44
View File
@@ -0,0 +1,44 @@
整理代码结构
``` lua
web
├── api/v1 -- 主要API
| ├── sys_initdb.go -- ico
| └── sys_user.go --
├── config -- 配置文件 设定操作的结构体
| ├── auto_code.go -- ico captcha.go
| ├── ... -- ico captcha.go
| └── zap.go -- core
├── core -- 主要结构代码
| ├── server_other.go -- ico captcha.go
| ├── ... -- ico captcha.go
| └── zap.go --
├── docs -- 文档系统
| ├── docs.go -- ico captcha.go
| ├── swagger.json -- json
| └── swagger.yaml -- yaml
├── global -- global
├── initialize -- initialize
├── middleware -- 中间键
├── model -- global
│ ├── request -- 所有请求model结构体
| | ├── common.go
| | ├── ...
| | └── sys_user.go -- yaml
| ├── response -- 返回数据
| | ├── common.go
| | ├── ...
| | └── sys_user.go -- yaml
├── packfile -- 文件写入
├── resource -- 资源文件
├── router -- 路由
├── service -- service层
├── source -- 文件目录操作
├── utils
├── config.yaml --
├── Dockerfile -- docker配置
├── go.mod -- mod 配置
├── go.sum -- sum
├── latest_log -- vue-cli 配置
└── main.go -- package.json
```
+27 -17
View File
@@ -1,12 +1,12 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
resp "gin-vue-admin/model/response"
"gin-vue-admin/global"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"io/ioutil"
"strconv"
)
@@ -17,7 +17,7 @@ import (
// @accept multipart/form-data
// @Produce application/json
// @Param file formData file true "an example for breakpoint resume, 断点续传示例"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"上传成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"切片创建成功"}"
// @Router /fileUploadAndDownload/breakpointContinue [post]
func BreakpointContinue(c *gin.Context) {
fileMd5 := c.Request.FormValue("fileMd5")
@@ -27,32 +27,39 @@ func BreakpointContinue(c *gin.Context) {
chunkTotal, _ := strconv.Atoi(c.Request.FormValue("chunkTotal"))
_, FileHeader, err := c.Request.FormFile("file")
if err != nil {
response.FailWithMessage(err.Error(), c)
global.GVA_LOG.Error("接收文件失败!", zap.Any("err", err))
response.FailWithMessage("接收文件失败", c)
return
}
f, err := FileHeader.Open()
if err != nil {
response.FailWithMessage(err.Error(), c)
global.GVA_LOG.Error("文件读取失败!", zap.Any("err", err))
response.FailWithMessage("文件读取失败", c)
return
}
defer f.Close()
cen, _ := ioutil.ReadAll(f)
if flag := utils.CheckMd5(cen, chunkMd5); !flag {
if !utils.CheckMd5(cen, chunkMd5) {
global.GVA_LOG.Error("检查md5失败!", zap.Any("err", err))
response.FailWithMessage("检查md5失败", c)
return
}
err, file := service.FindOrCreateFile(fileMd5, fileName, chunkTotal)
if err != nil {
response.FailWithMessage(err.Error(), c)
global.GVA_LOG.Error("查找或创建记录失败!", zap.Any("err", err))
response.FailWithMessage("查找或创建记录失败", c)
return
}
err, pathc := utils.BreakPointContinue(cen, fileName, chunkNumber, chunkTotal, fileMd5)
if err != nil {
response.FailWithMessage(err.Error(), c)
global.GVA_LOG.Error("断点续传失败!", zap.Any("err", err))
response.FailWithMessage("断点续传失败", c)
return
}
if err = service.CreateFileChunk(file.ID, pathc, chunkNumber); err != nil {
response.FailWithMessage(err.Error(), c)
global.GVA_LOG.Error("创建文件记录失败!", zap.Any("err", err))
response.FailWithMessage("创建文件记录失败", c)
return
}
response.OkWithMessage("切片创建成功", c)
@@ -72,14 +79,15 @@ func FindFile(c *gin.Context) {
chunkTotal, _ := strconv.Atoi(c.Query("chunkTotal"))
err, file := service.FindOrCreateFile(fileMd5, fileName, chunkTotal)
if err != nil {
global.GVA_LOG.Error("查找失败!", zap.Any("err", err))
response.FailWithMessage("查找失败", c)
} else {
response.OkWithData(resp.FileResponse{File: file}, c)
response.OkWithDetailed(response.FileResponse{File: file}, "查找成功", c)
}
}
// @Tags ExaFileUploadAndDownload
// @Summary 查找文件
// @Summary 创建文件
// @Security ApiKeyAuth
// @accept multipart/form-data
// @Produce application/json
@@ -91,9 +99,10 @@ func BreakpointContinueFinish(c *gin.Context) {
fileName := c.Query("fileName")
err, filePath := utils.MakeFile(fileName, fileMd5)
if err != nil {
response.FailWithDetailed(response.ERROR, resp.FilePathResponse{FilePath: filePath}, fmt.Sprintf("文件创建失败:%v", err), c)
global.GVA_LOG.Error("文件创建失败!", zap.Any("err", err))
response.FailWithDetailed(response.FilePathResponse{FilePath: filePath}, "文件创建失败", c)
} else {
response.OkDetailed(resp.FilePathResponse{FilePath: filePath}, "文件创建成功", c)
response.OkWithDetailed(response.FilePathResponse{FilePath: filePath}, "文件创建成功", c)
}
}
@@ -103,7 +112,7 @@ func BreakpointContinueFinish(c *gin.Context) {
// @accept multipart/form-data
// @Produce application/json
// @Param file formData file true "删除缓存切片"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查找成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"缓存切片删除成功"}"
// @Router /fileUploadAndDownload/removeChunk [post]
func RemoveChunk(c *gin.Context) {
fileMd5 := c.Query("fileMd5")
@@ -112,8 +121,9 @@ func RemoveChunk(c *gin.Context) {
err := utils.RemoveChunk(fileMd5)
err = service.DeleteFileChunk(fileMd5, fileName, filePath)
if err != nil {
response.FailWithDetailed(response.ERROR, resp.FilePathResponse{FilePath: filePath}, fmt.Sprintf("缓存切片删除失败:%v", err), c)
global.GVA_LOG.Error("缓存切片删除失败!", zap.Any("err", err))
response.FailWithDetailed(response.FilePathResponse{FilePath: filePath}, "缓存切片删除失败", c)
} else {
response.OkDetailed(resp.FilePathResponse{FilePath: filePath}, "缓存切片删除成功", c)
response.OkWithDetailed(response.FilePathResponse{FilePath: filePath}, "缓存切片删除成功", c)
}
}
+56 -80
View File
@@ -2,164 +2,140 @@ package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags SysApi
// @Tags ExaCustomer
// @Summary 创建客户
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.ExaCustomer true "创建客户"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.ExaCustomer true "客户用户名, 客户手机号码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /customer/customer [post]
func CreateExaCustomer(c *gin.Context) {
var cu model.ExaCustomer
_ = c.ShouldBindJSON(&cu)
CustomerVerify := utils.Rules{
"CustomerName": {utils.NotEmpty()},
"CustomerPhoneData": {utils.NotEmpty()},
}
CustomerVerifyErr := utils.Verify(cu, CustomerVerify)
if CustomerVerifyErr != nil {
response.FailWithMessage(CustomerVerifyErr.Error(), c)
var customer model.ExaCustomer
_ = c.ShouldBindJSON(&customer)
if err := utils.Verify(customer, utils.CustomerVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
claims, _ := c.Get("claims")
waitUse := claims.(*request.CustomClaims)
cu.SysUserID = waitUse.ID
cu.SysUserAuthorityID = waitUse.AuthorityId
err := service.CreateExaCustomer(cu)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败:%v", err), c)
customer.SysUserID = getUserID(c)
customer.SysUserAuthorityID = getUserAuthorityId(c)
if err := service.CreateExaCustomer(customer); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithMessage("创建成功", c)
}
}
// @Tags SysApi
// @Tags ExaCustomer
// @Summary 删除客户
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.ExaCustomer true "删除客户"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.ExaCustomer true "客户ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /customer/customer [delete]
func DeleteExaCustomer(c *gin.Context) {
var cu model.ExaCustomer
_ = c.ShouldBindJSON(&cu)
CustomerVerify := utils.Rules{
"ID": {utils.NotEmpty()},
}
CustomerVerifyErr := utils.Verify(cu.Model, CustomerVerify)
if CustomerVerifyErr != nil {
response.FailWithMessage(CustomerVerifyErr.Error(), c)
var customer model.ExaCustomer
_ = c.ShouldBindJSON(&customer)
if err := utils.Verify(customer.GVA_MODEL, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.DeleteExaCustomer(cu)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败:%v", err), c)
if err := service.DeleteExaCustomer(customer); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
}
// @Tags SysApi
// @Tags ExaCustomer
// @Summary 更新客户信息
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.ExaCustomer true "创建客户"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.ExaCustomer true "客户ID, 客户信息"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /customer/customer [put]
func UpdateExaCustomer(c *gin.Context) {
var cu model.ExaCustomer
_ = c.ShouldBindJSON(&cu)
IdCustomerVerify := utils.Rules{
"ID": {utils.NotEmpty()},
}
IdCustomerVerifyErr := utils.Verify(cu.Model, IdCustomerVerify)
if IdCustomerVerifyErr != nil {
response.FailWithMessage(IdCustomerVerifyErr.Error(), c)
var customer model.ExaCustomer
_ = c.ShouldBindJSON(&customer)
if err := utils.Verify(customer.GVA_MODEL, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
CustomerVerify := utils.Rules{
"CustomerName": {utils.NotEmpty()},
"CustomerPhoneData": {utils.NotEmpty()},
}
CustomerVerifyErr := utils.Verify(cu, CustomerVerify)
if CustomerVerifyErr != nil {
response.FailWithMessage(CustomerVerifyErr.Error(), c)
if err := utils.Verify(customer, utils.CustomerVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.UpdateExaCustomer(&cu)
if err != nil {
response.FailWithMessage(fmt.Sprintf("更新失败:%v", err), c)
if err := service.UpdateExaCustomer(&customer); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
response.FailWithMessage("更新失败!", c)
} else {
response.OkWithMessage("更新成功", c)
}
}
// @Tags SysApi
// @Tags ExaCustomer
// @Summary 获取单一客户信息
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.ExaCustomer true "获取单一客户信息"
// @Param data body model.ExaCustomer true "客户ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /customer/customer [get]
func GetExaCustomer(c *gin.Context) {
var cu model.ExaCustomer
_ = c.ShouldBindQuery(&cu)
IdCustomerVerify := utils.Rules{
"ID": {utils.NotEmpty()},
}
IdCustomerVerifyErr := utils.Verify(cu.Model, IdCustomerVerify)
if IdCustomerVerifyErr != nil {
response.FailWithMessage(IdCustomerVerifyErr.Error(), c)
var customer model.ExaCustomer
_ = c.ShouldBindQuery(&customer)
if err := utils.Verify(customer.GVA_MODEL, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, customer := service.GetExaCustomer(cu.ID)
err, data := service.GetExaCustomer(customer.ID)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.ExaCustomerResponse{Customer: customer}, c)
response.OkWithDetailed(response.ExaCustomerResponse{Customer: data}, "获取成功", c)
}
}
// @Tags SysApi
// @Summary 获取权限客户列表
// @Tags ExaCustomer
// @Summary 分页获取权限客户列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.PageInfo true "获取权限客户列表"
// @Param data body request.PageInfo true "页码, 每页大小"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /customer/customerList [get]
func GetExaCustomerList(c *gin.Context) {
claims, _ := c.Get("claims")
waitUse := claims.(*request.CustomClaims)
var pageInfo request.PageInfo
_ = c.ShouldBindQuery(&pageInfo)
PageVerifyErr := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"])
if PageVerifyErr != nil {
response.FailWithMessage(PageVerifyErr.Error(), c)
if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, customerList, total := service.GetCustomerInfoList(waitUse.AuthorityId, pageInfo)
err, customerList, total := service.GetCustomerInfoList(getUserAuthorityId(c), pageInfo)
if err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
} else {
response.OkWithData(resp.PageResult{
response.OkWithDetailed(response.PageResult{
List: customerList,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, c)
}, "获取成功", c)
}
}
+99
View File
@@ -0,0 +1,99 @@
package v1
import (
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// /excel/importExcel 接口,与upload接口作用类似,只是把文件存到resource/excel目录下,用于导入Excel时存放Excel文件(ExcelImport.xlsx)
// /excel/loadExcel接口,用于读取resource/excel目录下的文件((ExcelImport.xlsx)并加载为[]model.SysBaseMenu类型的示例数据
// /excel/exportExcel 接口,用于读取前端传来的tableData,生成Excel文件并返回
// /excel/downloadTemplate 接口,用于下载resource/excel目录下的 ExcelTemplate.xlsx 文件,作为导入的模板
// @Tags excel
// @Summary 导出Excel
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/octet-stream
// @Param data body model.ExcelInfo true "导出Excel文件信息"
// @Success 200
// @Router /excel/exportExcel [post]
func ExportExcel(c *gin.Context) {
var excelInfo model.ExcelInfo
_ = c.ShouldBindJSON(&excelInfo)
filePath := global.GVA_CONFIG.Excel.Dir + excelInfo.FileName
err := service.ParseInfoList2Excel(excelInfo.InfoList, filePath)
if err != nil {
global.GVA_LOG.Error("转换Excel失败!", zap.Any("err", err))
response.FailWithMessage("转换Excel失败", c)
return
}
c.Writer.Header().Add("success", "true")
c.File(filePath)
}
// @Tags excel
// @Summary 导入Excel文件
// @Security ApiKeyAuth
// @accept multipart/form-data
// @Produce application/json
// @Param file formData file true "导入Excel文件"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"导入成功"}"
// @Router /excel/importExcel [post]
func ImportExcel(c *gin.Context) {
_, header, err := c.Request.FormFile("file")
if err != nil {
global.GVA_LOG.Error("接收文件失败!", zap.Any("err", err))
response.FailWithMessage("接收文件失败", c)
return
}
_ = c.SaveUploadedFile(header, global.GVA_CONFIG.Excel.Dir+"ExcelImport.xlsx")
response.OkWithMessage("导入成功", c)
}
// @Tags excel
// @Summary 加载Excel数据
// @Security ApiKeyAuth
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"加载数据成功"}"
// @Router /excel/loadExcel [get]
func LoadExcel(c *gin.Context) {
menus, err := service.ParseExcel2InfoList()
if err != nil {
global.GVA_LOG.Error("加载数据失败", zap.Any("err", err))
response.FailWithMessage("加载数据失败", c)
return
}
response.OkWithDetailed(response.PageResult{
List: menus,
Total: int64(len(menus)),
Page: 1,
PageSize: 999,
}, "加载数据成功", c)
}
// @Tags excel
// @Summary 下载模板
// @Security ApiKeyAuth
// @accept multipart/form-data
// @Produce application/json
// @Param fileName query string true "模板名称"
// @Success 200
// @Router /excel/downloadTemplate [get]
func DownloadTemplate(c *gin.Context) {
fileName := c.Query("fileName")
filePath := global.GVA_CONFIG.Excel.Dir + fileName
ok, err := utils.PathExists(filePath)
if !ok || err != nil {
global.GVA_LOG.Error("文件不存在", zap.Any("err", err))
response.FailWithMessage("文件不存在", c)
return
}
c.Writer.Header().Add("success", "true")
c.File(filePath)
}
+16 -12
View File
@@ -1,13 +1,13 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags ExaFileUploadAndDownload
@@ -23,15 +23,17 @@ func UploadFile(c *gin.Context) {
noSave := c.DefaultQuery("noSave", "0")
_, header, err := c.Request.FormFile("file")
if err != nil {
response.FailWithMessage(fmt.Sprintf("上传文件失败,%v", err), c)
global.GVA_LOG.Error("接收文件失败!", zap.Any("err", err))
response.FailWithMessage("接收文件失败", c)
return
}
err, file = service.UploadFile(header, noSave) // 文件上传后拿到文件路径
if err != nil {
response.FailWithMessage(fmt.Sprintf("修改数据库链接失败,%v", err), c)
global.GVA_LOG.Error("修改数据库链接失败!", zap.Any("err", err))
response.FailWithMessage("修改数据库链接失败", c)
return
}
response.OkDetailed(resp.ExaFileResponse{File: file}, "上传成功", c)
response.OkWithDetailed(response.ExaFileResponse{File: file}, "上传成功", c)
}
// @Tags ExaFileUploadAndDownload
@@ -39,13 +41,14 @@ func UploadFile(c *gin.Context) {
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body model.ExaFileUploadAndDownload true "传入文件里面id即可"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /fileUploadAndDownload/deleteFile [post]
func DeleteFile(c *gin.Context) {
var file model.ExaFileUploadAndDownload
_ = c.ShouldBindJSON(&file)
if err := service.DeleteFile(file); err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
return
}
response.OkWithMessage("删除成功", c)
@@ -56,7 +59,7 @@ func DeleteFile(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.PageInfo true "分页获取文件户列表"
// @Param data body request.PageInfo true "页码, 每页大小"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /fileUploadAndDownload/getFileList [post]
func GetFileList(c *gin.Context) {
@@ -64,13 +67,14 @@ func GetFileList(c *gin.Context) {
_ = c.ShouldBindJSON(&pageInfo)
err, list, total := service.GetFileRecordInfoList(pageInfo)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.PageResult{
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, c)
}, "获取成功", c)
}
}
+21 -15
View File
@@ -1,12 +1,13 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags SimpleUploader
@@ -15,7 +16,7 @@ import (
// @accept multipart/form-data
// @Produce application/json
// @Param file formData file true "断点续传插件版示例"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"上传成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"切片创建成功"}"
// @Router /simpleUploader/upload [post]
func SimpleUploaderUpload(c *gin.Context) {
var chunk model.ExaSimpleUploader
@@ -29,42 +30,46 @@ func SimpleUploaderUpload(c *gin.Context) {
var chunkDir = "./chunk/" + chunk.Identifier + "/"
hasDir, _ := utils.PathExists(chunkDir)
if !hasDir {
utils.CreateDir(chunkDir)
if err := utils.CreateDir(chunkDir); err != nil {
global.GVA_LOG.Error("创建目录失败!", zap.Any("err", err))
}
}
chunkPath := chunkDir + chunk.Filename + chunk.ChunkNumber
err = c.SaveUploadedFile(header, chunkPath)
if err != nil {
response.FailWithMessage(fmt.Sprintf("切片创建失败,%v", err), c)
global.GVA_LOG.Error("切片创建失败!", zap.Any("err", err))
response.FailWithMessage("切片创建失败", c)
return
}
chunk.CurrentChunkPath = chunkPath
err = service.SaveChunk(chunk)
if err != nil {
response.FailWithMessage(fmt.Sprintf("切片创建失败,%v", err), c)
global.GVA_LOG.Error("切片创建失败!", zap.Any("err", err))
response.FailWithMessage("切片创建失败", c)
return
} else {
response.Ok(c)
response.OkWithMessage("切片创建成功", c)
}
}
// @Tags SimpleUploader
// @Summary 断点续传插件版示例
// @Security ApiKeyAuth
// @Produce application/json
// @Param md5 query string true "测试文件是否已经存在和判断已经上传过的切片"
// @Param md5 query string true "md5"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /simpleUploader/checkFileMd5 [get]
func CheckFileMd5(c *gin.Context) {
md5 := c.Query("md5")
err, chunks, isDone := service.CheckFileMd5(md5)
if err != nil {
response.FailWithMessage(fmt.Sprintf("md5读取失败,%v", err), c)
global.GVA_LOG.Error("md5读取失败!", zap.Any("err", err))
response.FailWithMessage("md5读取失败", c)
} else {
response.OkWithData(gin.H{
response.OkWithDetailed(gin.H{
"chunks": chunks,
"isDone": isDone,
}, c)
}, "查询成功", c)
}
}
@@ -72,7 +77,7 @@ func CheckFileMd5(c *gin.Context) {
// @Summary 合并文件
// @Security ApiKeyAuth
// @Produce application/json
// @Param md5 query string true "合并文件"
// @Param md5 query string true "md5"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"合并成功"}"
// @Router /simpleUploader/mergeFileMd5 [get]
func MergeFileMd5(c *gin.Context) {
@@ -80,8 +85,9 @@ func MergeFileMd5(c *gin.Context) {
fileName := c.Query("fileName")
err := service.MergeFileMd5(md5, fileName)
if err != nil {
response.FailWithMessage(fmt.Sprintf("md5读取失败,%v", err), c)
global.GVA_LOG.Error("md5读取失败!", zap.Any("err", err))
response.FailWithMessage("md5读取失败", c)
} else {
response.OkWithData(gin.H{}, c)
response.OkWithMessage("合并成功", c)
}
}
+69 -71
View File
@@ -1,14 +1,15 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags SysApi
@@ -16,60 +17,47 @@ import (
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysApi true "创建api"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.SysApi true "api路径, api中文描述, api组, 方法"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /api/createApi [post]
func CreateApi(c *gin.Context) {
var api model.SysApi
_ = c.ShouldBindJSON(&api)
ApiVerify := utils.Rules{
"Path": {utils.NotEmpty()},
"Description": {utils.NotEmpty()},
"ApiGroup": {utils.NotEmpty()},
"Method": {utils.NotEmpty()},
}
ApiVerifyErr := utils.Verify(api, ApiVerify)
if ApiVerifyErr != nil {
response.FailWithMessage(ApiVerifyErr.Error(), c)
if err := utils.Verify(api, utils.ApiVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.CreateApi(api)
if err != nil {
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
if err := service.CreateApi(api); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithMessage("创建成功", c)
}
}
// @Tags SysApi
// @Summary 删除指定api
// @Summary 删除api
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysApi true "删除api"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.SysApi true "ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /api/deleteApi [post]
func DeleteApi(c *gin.Context) {
var a model.SysApi
_ = c.ShouldBindJSON(&a)
ApiVerify := utils.Rules{
"ID": {utils.NotEmpty()},
}
ApiVerifyErr := utils.Verify(a.Model, ApiVerify)
if ApiVerifyErr != nil {
response.FailWithMessage(ApiVerifyErr.Error(), c)
var api model.SysApi
_ = c.ShouldBindJSON(&api)
if err := utils.Verify(api.GVA_MODEL, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.DeleteApi(a)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
if err := service.DeleteApi(api); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
}
// 条件搜索后端看此api
// @Tags SysApi
// @Summary 分页获取API列表
// @Security ApiKeyAuth
@@ -79,24 +67,22 @@ func DeleteApi(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /api/getApiList [post]
func GetApiList(c *gin.Context) {
// 此结构体仅本方法使用
var sp request.SearchApiParams
_ = c.ShouldBindJSON(&sp)
PageVerifyErr := utils.Verify(sp.PageInfo, utils.CustomizeMap["PageVerify"])
if PageVerifyErr != nil {
response.FailWithMessage(PageVerifyErr.Error(), c)
var pageInfo request.SearchApiParams
_ = c.ShouldBindJSON(&pageInfo)
if err := utils.Verify(pageInfo.PageInfo, utils.PageInfoVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, list, total := service.GetAPIInfoList(sp.SysApi, sp.PageInfo, sp.OrderKey, sp.Desc)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
if err, list, total := service.GetAPIInfoList(pageInfo.SysApi, pageInfo.PageInfo, pageInfo.OrderKey, pageInfo.Desc); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.PageResult{
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: sp.PageInfo.Page,
PageSize: sp.PageInfo.PageSize,
}, c)
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, "获取成功", c)
}
}
@@ -111,16 +97,16 @@ func GetApiList(c *gin.Context) {
func GetApiById(c *gin.Context) {
var idInfo request.GetById
_ = c.ShouldBindJSON(&idInfo)
IdVerifyErr := utils.Verify(idInfo, utils.CustomizeMap["IdVerify"])
if IdVerifyErr != nil {
response.FailWithMessage(IdVerifyErr.Error(), c)
if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, api := service.GetApiById(idInfo.Id)
err, api := service.GetApiById(idInfo.ID)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.SysAPIResponse{Api: api}, c)
response.OkWithData(response.SysAPIResponse{Api: api}, c)
}
}
@@ -129,28 +115,21 @@ func GetApiById(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysApi true "创建api"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.SysApi true "api路径, api中文描述, api组, 方法"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /api/updateApi [post]
func UpdateApi(c *gin.Context) {
var api model.SysApi
_ = c.ShouldBindJSON(&api)
ApiVerify := utils.Rules{
"Path": {utils.NotEmpty()},
"Description": {utils.NotEmpty()},
"ApiGroup": {utils.NotEmpty()},
"Method": {utils.NotEmpty()},
}
ApiVerifyErr := utils.Verify(api, ApiVerify)
if ApiVerifyErr != nil {
response.FailWithMessage(ApiVerifyErr.Error(), c)
if err := utils.Verify(api, utils.ApiVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.UpdateApi(api)
if err != nil {
response.FailWithMessage(fmt.Sprintf("修改数据失败,%v", err), c)
if err := service.UpdateApi(api); err != nil {
global.GVA_LOG.Error("修改失败!", zap.Any("err", err))
response.FailWithMessage("修改失败", c)
} else {
response.OkWithMessage("修改数据成功", c)
response.OkWithMessage("修改成功", c)
}
}
@@ -162,10 +141,29 @@ func UpdateApi(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /api/getAllApis [post]
func GetAllApis(c *gin.Context) {
err, apis := service.GetAllApis()
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
if err, apis := service.GetAllApis(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.SysAPIListResponse{Apis: apis}, c)
response.OkWithDetailed(response.SysAPIListResponse{Apis: apis}, "获取成功", c)
}
}
// @Tags SysApi
// @Summary 删除选中Api
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /api/deleteApisByIds [delete]
func DeleteApisByIds(c *gin.Context) {
var ids request.IdsReq
_ = c.ShouldBindJSON(&ids)
if err := service.DeleteApisByIds(ids); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
}
+60 -86
View File
@@ -1,166 +1,141 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags authority
// @Tags Authority
// @Summary 创建角色
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysAuthority true "创建角色"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.SysAuthority true "权限id, 权限名, 父角色id"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /authority/createAuthority [post]
func CreateAuthority(c *gin.Context) {
var auth model.SysAuthority
_ = c.ShouldBindJSON(&auth)
AuthorityVerify := utils.Rules{
"AuthorityId": {utils.NotEmpty()},
"AuthorityName": {utils.NotEmpty()},
"ParentId": {utils.NotEmpty()},
}
AuthorityVerifyErr := utils.Verify(auth, AuthorityVerify)
if AuthorityVerifyErr != nil {
response.FailWithMessage(AuthorityVerifyErr.Error(), c)
var authority model.SysAuthority
_ = c.ShouldBindJSON(&authority)
if err := utils.Verify(authority, utils.AuthorityVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, authBack := service.CreateAuthority(auth)
if err != nil {
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
if err, authBack := service.CreateAuthority(authority); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
response.FailWithMessage("创建失败"+err.Error(), c)
} else {
response.OkWithData(resp.SysAuthorityResponse{Authority: authBack}, c)
response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "创建成功", c)
}
}
// @Tags authority
// @Tags Authority
// @Summary 拷贝角色
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body response.SysAuthorityCopyResponse true "拷贝角色"
// @Param data body response.SysAuthorityCopyResponse true "旧角色id, 新权限id, 新权限名, 新父角色id"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"拷贝成功"}"
// @Router /authority/copyAuthority [post]
func CopyAuthority(c *gin.Context) {
var copyInfo resp.SysAuthorityCopyResponse
var copyInfo response.SysAuthorityCopyResponse
_ = c.ShouldBindJSON(&copyInfo)
OldAuthorityVerify := utils.Rules{
"OldAuthorityId": {utils.NotEmpty()},
}
OldAuthorityVerifyErr := utils.Verify(copyInfo, OldAuthorityVerify)
if OldAuthorityVerifyErr != nil {
response.FailWithMessage(OldAuthorityVerifyErr.Error(), c)
if err := utils.Verify(copyInfo, utils.OldAuthorityVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
AuthorityVerify := utils.Rules{
"AuthorityId": {utils.NotEmpty()},
"AuthorityName": {utils.NotEmpty()},
"ParentId": {utils.NotEmpty()},
}
AuthorityVerifyErr := utils.Verify(copyInfo.Authority, AuthorityVerify)
if AuthorityVerifyErr != nil {
response.FailWithMessage(AuthorityVerifyErr.Error(), c)
if err := utils.Verify(copyInfo.Authority, utils.AuthorityVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, authBack := service.CopyAuthority(copyInfo)
if err != nil {
response.FailWithMessage(fmt.Sprintf("拷贝失败,%v", err), c)
if err, authBack := service.CopyAuthority(copyInfo); err != nil {
global.GVA_LOG.Error("拷贝失败!", zap.Any("err", err))
response.FailWithMessage("拷贝失败"+err.Error(), c)
} else {
response.OkWithData(resp.SysAuthorityResponse{Authority: authBack}, c)
response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "拷贝成功", c)
}
}
// @Tags authority
// @Tags Authority
// @Summary 删除角色
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysAuthority true "删除角色"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /authority/deleteAuthority [post]
func DeleteAuthority(c *gin.Context) {
var a model.SysAuthority
_ = c.ShouldBindJSON(&a)
AuthorityIdVerifyErr := utils.Verify(a, utils.CustomizeMap["AuthorityIdVerify"])
if AuthorityIdVerifyErr != nil {
response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
var authority model.SysAuthority
_ = c.ShouldBindJSON(&authority)
if err := utils.Verify(authority, utils.AuthorityIdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
// 删除角色之前需要判断是否有用户正在使用此角色
err := service.DeleteAuthority(&a)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
if err := service.DeleteAuthority(&authority); err != nil { // 删除角色之前需要判断是否有用户正在使用此角色
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败"+err.Error(), c)
} else {
response.OkWithMessage("删除成功", c)
}
}
// @Tags authority
// @Summary 设置角色资源权限
// @Tags Authority
// @Summary 更新角色信息
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysAuthority true "设置角色资源权限"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}"
// @Param data body model.SysAuthority true "权限id, 权限名, 父角色id"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /authority/updateAuthority [post]
func UpdateAuthority(c *gin.Context) {
var auth model.SysAuthority
_ = c.ShouldBindJSON(&auth)
AuthorityVerify := utils.Rules{
"AuthorityId": {utils.NotEmpty()},
"AuthorityName": {utils.NotEmpty()},
"ParentId": {utils.NotEmpty()},
}
AuthorityVerifyErr := utils.Verify(auth, AuthorityVerify)
if AuthorityVerifyErr != nil {
response.FailWithMessage(AuthorityVerifyErr.Error(), c)
if err := utils.Verify(auth, utils.AuthorityVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, authority := service.UpdateAuthority(auth)
if err != nil {
response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
if err, authority := service.UpdateAuthority(auth); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
response.FailWithMessage("更新失败"+err.Error(), c)
} else {
response.OkWithData(resp.SysAuthorityResponse{Authority: authority}, c)
response.OkWithDetailed(response.SysAuthorityResponse{Authority: authority}, "更新成功", c)
}
}
// @Tags authority
// @Tags Authority
// @Summary 分页获取角色列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.PageInfo true "分页获取用户列表"
// @Param data body request.PageInfo true "页码, 每页大小"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /authority/getAuthorityList [post]
func GetAuthorityList(c *gin.Context) {
var pageInfo request.PageInfo
_ = c.ShouldBindJSON(&pageInfo)
PageVerifyErr := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"])
if PageVerifyErr != nil {
response.FailWithMessage(PageVerifyErr.Error(), c)
if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, list, total := service.GetAuthorityInfoList(pageInfo)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
if err, list, total := service.GetAuthorityInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败"+err.Error(), c)
} else {
response.OkWithData(resp.PageResult{
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, c)
}, "获取成功", c)
}
}
// @Tags authority
// @Tags Authority
// @Summary 设置角色资源权限
// @Security ApiKeyAuth
// @accept application/json
@@ -171,15 +146,14 @@ func GetAuthorityList(c *gin.Context) {
func SetDataAuthority(c *gin.Context) {
var auth model.SysAuthority
_ = c.ShouldBindJSON(&auth)
AuthorityIdVerifyErr := utils.Verify(auth, utils.CustomizeMap["AuthorityIdVerify"])
if AuthorityIdVerifyErr != nil {
response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
if err := utils.Verify(auth, utils.AuthorityIdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.SetDataAuthority(auth)
if err != nil {
response.FailWithMessage(fmt.Sprintf("设置关联失败,%v", err), c)
if err := service.SetDataAuthority(auth); err != nil {
global.GVA_LOG.Error("设置失败!", zap.Any("err", err))
response.FailWithMessage("设置失败"+err.Error(), c)
} else {
response.Ok(c)
response.OkWithMessage("设置成功", c)
}
}
+67 -85
View File
@@ -1,18 +1,45 @@
package v1
import (
"errors"
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/global/response"
"gin-vue-admin/model"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"net/url"
"os"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags SysApi
// @Tags AutoCode
// @Summary 预览创建后的代码
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.AutoCodeStruct true "预览创建代码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /autoCode/preview [post]
func PreviewTemp(c *gin.Context) {
var a model.AutoCodeStruct
_ = c.ShouldBindJSON(&a)
if err := utils.Verify(a, utils.AutoCodeVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
autoCode, err := service.PreviewTemp(a)
if err != nil {
global.GVA_LOG.Error("预览失败!", zap.Any("err", err))
response.FailWithMessage("预览失败", c)
} else {
response.OkWithDetailed(gin.H{"autoCode": autoCode}, "预览成功", c)
}
}
// @Tags AutoCode
// @Summary 自动代码模板
// @Security ApiKeyAuth
// @accept application/json
@@ -23,132 +50,87 @@ import (
func CreateTemp(c *gin.Context) {
var a model.AutoCodeStruct
_ = c.ShouldBindJSON(&a)
AutoCodeVerify := utils.Rules{
"Abbreviation": {utils.NotEmpty()},
"StructName": {utils.NotEmpty()},
"PackageName": {utils.NotEmpty()},
"Fields": {utils.NotEmpty()},
}
WKVerifyErr := utils.Verify(a, AutoCodeVerify)
if WKVerifyErr != nil {
response.FailWithMessage(WKVerifyErr.Error(), c)
if err := utils.Verify(a, utils.AutoCodeVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if a.AutoCreateApiToSql {
apiList := [6]model.SysApi{
{
Path: "/" + a.Abbreviation + "/" + "create" + a.StructName,
Description: "新增" + a.Description,
ApiGroup: a.Abbreviation,
Method: "POST",
},
{
Path: "/" + a.Abbreviation + "/" + "delete" + a.StructName,
Description: "删除" + a.Description,
ApiGroup: a.Abbreviation,
Method: "DELETE",
},
{
Path: "/" + a.Abbreviation + "/" + "delete" + a.StructName+"ByIds",
Description: "批量删除" + a.Description,
ApiGroup: a.Abbreviation,
Method: "DELETE",
},
{
Path: "/" + a.Abbreviation + "/" + "update" + a.StructName,
Description: "更新" + a.Description,
ApiGroup: a.Abbreviation,
Method: "PUT",
},
{
Path: "/" + a.Abbreviation + "/" + "find" + a.StructName,
Description: "根据ID获取" + a.Description,
ApiGroup: a.Abbreviation,
Method: "GET",
},
{
Path: "/" + a.Abbreviation + "/" + "get" + a.StructName + "List",
Description: "获取" + a.Description + "列表",
ApiGroup: a.Abbreviation,
Method: "GET",
},
}
for _, v := range apiList {
errC := service.CreateApi(v)
if errC != nil {
c.Writer.Header().Add("success", "false")
c.Writer.Header().Add("msg", url.QueryEscape(fmt.Sprintf("自动化创建失败,%v,请自行清空垃圾数据", errC)))
return
}
if err := service.AutoCreateApi(&a); err != nil {
global.GVA_LOG.Error("自动化创建失败!请自行清空垃圾数据!", zap.Any("err", err))
c.Writer.Header().Add("success", "false")
c.Writer.Header().Add("msg", url.QueryEscape("自动化创建失败!请自行清空垃圾数据!"))
return
}
}
err := service.CreateTemp(a)
if err != nil {
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
os.Remove("./ginvueadmin.zip")
if errors.Is(err, model.AutoMoveErr) {
c.Writer.Header().Add("success", "false")
c.Writer.Header().Add("msgtype", "success")
c.Writer.Header().Add("msg", url.QueryEscape(err.Error()))
} else {
c.Writer.Header().Add("success", "false")
c.Writer.Header().Add("msg", url.QueryEscape(err.Error()))
_ = os.Remove("./ginvueadmin.zip")
}
} else {
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "ginvueadmin.zip")) // fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
c.Writer.Header().Add("Content-Type", "application/json")
c.Writer.Header().Add("success", "true")
c.File("./ginvueadmin.zip")
os.Remove("./ginvueadmin.zip")
_ = os.Remove("./ginvueadmin.zip")
}
}
// @Tags SysApi
// @Tags AutoCode
// @Summary 获取当前数据库所有表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /autoCode/getTables [get]
func GetTables(c *gin.Context) {
dbName := c.DefaultQuery("dbName", global.GVA_CONFIG.Mysql.Dbname)
err, tables := service.GetTables(dbName)
if err != nil {
response.FailWithMessage(fmt.Sprintf("查询table失败,%v", err), c)
global.GVA_LOG.Error("查询table失败!", zap.Any("err", err))
response.FailWithMessage("查询table失败", c)
} else {
response.OkWithData(gin.H{
"tables": tables,
}, c)
response.OkWithDetailed(gin.H{"tables": tables}, "获取成功", c)
}
}
// @Tags SysApi
// @Tags AutoCode
// @Summary 获取当前所有数据库
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /autoCode/getDatabase [get]
func GetDB(c *gin.Context) {
err, dbs := service.GetDB()
if err != nil {
response.FailWithMessage(fmt.Sprintf("查询table失败,%v", err), c)
if err, dbs := service.GetDB(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(gin.H{
"dbs": dbs,
}, c)
response.OkWithDetailed(gin.H{"dbs": dbs}, "获取成功", c)
}
}
// @Tags SysApi
// @Tags AutoCode
// @Summary 获取当前表所有字段
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /autoCode/getDatabase [get]
func GetColume(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /autoCode/getColumn [get]
func GetColumn(c *gin.Context) {
dbName := c.DefaultQuery("dbName", global.GVA_CONFIG.Mysql.Dbname)
tableName := c.Query("tableName")
err, columes := service.GetColume(tableName, dbName)
if err != nil {
response.FailWithMessage(fmt.Sprintf("查询table失败,%v", err), c)
if err, columns := service.GetColumn(tableName, dbName); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(gin.H{
"columes": columes,
}, c)
response.OkWithDetailed(gin.H{"columns": columns}, "获取成功", c)
}
}
+8 -9
View File
@@ -1,33 +1,32 @@
package v1
import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/global/response"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"github.com/gin-gonic/gin"
"github.com/mojocn/base64Captcha"
"go.uber.org/zap"
)
var store = base64Captcha.DefaultMemStore
// @Tags base
// @Tags Base
// @Summary 生成验证码
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"验证码获取成功"}"
// @Router /base/captcha [post]
func Captcha(c *gin.Context) {
//字符,公式,验证码配置
// 生成默认数字的driver
driver := base64Captcha.NewDriverDigit(global.GVA_CONFIG.Captcha.ImgHeight, global.GVA_CONFIG.Captcha.ImgWidth, global.GVA_CONFIG.Captcha.KeyLong, 0.7, 80)
cp := base64Captcha.NewCaptcha(driver, store)
id, b64s, err := cp.Generate()
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
if id, b64s, err := cp.Generate(); err != nil {
global.GVA_LOG.Error("验证码获取失败!", zap.Any("err", err))
response.FailWithMessage("验证码获取失败", c)
} else {
response.OkDetailed(resp.SysCaptchaResponse{
response.OkWithDetailed(response.SysCaptchaResponse{
CaptchaId: id,
PicPath: b64s,
}, "验证码获取成功", c)
+21 -24
View File
@@ -1,56 +1,53 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags casbin
// @Summary 更改角色api权限
// @Tags Casbin
// @Summary 更新角色api权限
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.CasbinInReceive true "更改角色api权限"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body request.CasbinInReceive true "权限id, 权限模型列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /casbin/UpdateCasbin [post]
func UpdateCasbin(c *gin.Context) {
var cmr request.CasbinInReceive
_ = c.ShouldBindJSON(&cmr)
AuthorityIdVerifyErr := utils.Verify(cmr, utils.CustomizeMap["AuthorityIdVerify"])
if AuthorityIdVerifyErr != nil {
response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
if err := utils.Verify(cmr, utils.AuthorityIdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.UpdateCasbin(cmr.AuthorityId, cmr.CasbinInfos)
if err != nil {
response.FailWithMessage(fmt.Sprintf("添加规则失败,%v", err), c)
if err := service.UpdateCasbin(cmr.AuthorityId, cmr.CasbinInfos); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
response.FailWithMessage("更新失败", c)
} else {
response.OkWithMessage("添加规则成功", c)
response.OkWithMessage("更新成功", c)
}
}
// @Tags casbin
// @Tags Casbin
// @Summary 获取权限列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.CasbinInReceive true "获取权限列表"
// @Param data body request.CasbinInReceive true "权限id, 权限模型列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /casbin/getPolicyPathByAuthorityId [post]
func GetPolicyPathByAuthorityId(c *gin.Context) {
var cmr request.CasbinInReceive
_ = c.ShouldBindJSON(&cmr)
AuthorityIdVerifyErr := utils.Verify(cmr, utils.CustomizeMap["AuthorityIdVerify"])
if AuthorityIdVerifyErr != nil {
response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
var casbin request.CasbinInReceive
_ = c.ShouldBindJSON(&casbin)
if err := utils.Verify(casbin, utils.AuthorityIdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
paths := service.GetPolicyPathByAuthorityId(cmr.AuthorityId)
response.OkWithData(resp.PolicyPathResponse{Paths: paths}, c)
paths := service.GetPolicyPathByAuthorityId(casbin.AuthorityId)
response.OkWithDetailed(response.PolicyPathResponse{Paths: paths}, "获取成功", c)
}
+40 -35
View File
@@ -1,13 +1,14 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags SysDictionary
@@ -15,15 +16,15 @@ import (
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysDictionary true "创建SysDictionary"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.SysDictionary true "SysDictionary模型"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /sysDictionary/createSysDictionary [post]
func CreateSysDictionary(c *gin.Context) {
var sysDictionary model.SysDictionary
_ = c.ShouldBindJSON(&sysDictionary)
err := service.CreateSysDictionary(sysDictionary)
if err != nil {
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
var dictionary model.SysDictionary
_ = c.ShouldBindJSON(&dictionary)
if err := service.CreateSysDictionary(dictionary); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithMessage("创建成功", c)
}
@@ -34,15 +35,15 @@ func CreateSysDictionary(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysDictionary true "删除SysDictionary"
// @Param data body model.SysDictionary true "SysDictionary模型"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /sysDictionary/deleteSysDictionary [delete]
func DeleteSysDictionary(c *gin.Context) {
var sysDictionary model.SysDictionary
_ = c.ShouldBindJSON(&sysDictionary)
err := service.DeleteSysDictionary(sysDictionary)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
var dictionary model.SysDictionary
_ = c.ShouldBindJSON(&dictionary)
if err := service.DeleteSysDictionary(dictionary); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
@@ -53,15 +54,15 @@ func DeleteSysDictionary(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysDictionary true "更新SysDictionary"
// @Param data body model.SysDictionary true "SysDictionary模型"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /sysDictionary/updateSysDictionary [put]
func UpdateSysDictionary(c *gin.Context) {
var sysDictionary model.SysDictionary
_ = c.ShouldBindJSON(&sysDictionary)
err := service.UpdateSysDictionary(&sysDictionary)
if err != nil {
response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
var dictionary model.SysDictionary
_ = c.ShouldBindJSON(&dictionary)
if err := service.UpdateSysDictionary(&dictionary); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
response.FailWithMessage("更新失败", c)
} else {
response.OkWithMessage("更新成功", c)
}
@@ -72,17 +73,17 @@ func UpdateSysDictionary(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysDictionary true "用id查询SysDictionary"
// @Param data body model.SysDictionary true "ID或字典英名"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /sysDictionary/findSysDictionary [get]
func FindSysDictionary(c *gin.Context) {
var sysDictionary model.SysDictionary
_ = c.ShouldBindQuery(&sysDictionary)
err, resysDictionary := service.GetSysDictionary(sysDictionary.Type, sysDictionary.ID)
if err != nil {
response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
var dictionary model.SysDictionary
_ = c.ShouldBindQuery(&dictionary)
if err, sysDictionary := service.GetSysDictionary(dictionary.Type, dictionary.ID); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithData(gin.H{"resysDictionary": resysDictionary}, c)
response.OkWithDetailed(gin.H{"resysDictionary": sysDictionary}, "查询成功", c)
}
}
@@ -91,21 +92,25 @@ func FindSysDictionary(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysDictionarySearch true "分页获取SysDictionary列表"
// @Param data body request.SysDictionarySearch true "页码, 每页大小, 搜索条件"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /sysDictionary/getSysDictionaryList [get]
func GetSysDictionaryList(c *gin.Context) {
var pageInfo request.SysDictionarySearch
_ = c.ShouldBindQuery(&pageInfo)
err, list, total := service.GetSysDictionaryInfoList(pageInfo)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
if err := utils.Verify(pageInfo.PageInfo, utils.PageInfoVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err, list, total := service.GetSysDictionaryInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.PageResult{
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, c)
}, "获取成功", c)
}
}
+38 -33
View File
@@ -1,13 +1,14 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags SysDictionaryDetail
@@ -15,15 +16,15 @@ import (
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysDictionaryDetail true "创建SysDictionaryDetail"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.SysDictionaryDetail true "SysDictionaryDetail模型"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /sysDictionaryDetail/createSysDictionaryDetail [post]
func CreateSysDictionaryDetail(c *gin.Context) {
var sysDictionaryDetail model.SysDictionaryDetail
_ = c.ShouldBindJSON(&sysDictionaryDetail)
err := service.CreateSysDictionaryDetail(sysDictionaryDetail)
if err != nil {
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
var detail model.SysDictionaryDetail
_ = c.ShouldBindJSON(&detail)
if err := service.CreateSysDictionaryDetail(detail); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithMessage("创建成功", c)
}
@@ -34,15 +35,15 @@ func CreateSysDictionaryDetail(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysDictionaryDetail true "删除SysDictionaryDetail"
// @Param data body model.SysDictionaryDetail true "SysDictionaryDetail模型"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /sysDictionaryDetail/deleteSysDictionaryDetail [delete]
func DeleteSysDictionaryDetail(c *gin.Context) {
var sysDictionaryDetail model.SysDictionaryDetail
_ = c.ShouldBindJSON(&sysDictionaryDetail)
err := service.DeleteSysDictionaryDetail(sysDictionaryDetail)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
var detail model.SysDictionaryDetail
_ = c.ShouldBindJSON(&detail)
if err := service.DeleteSysDictionaryDetail(detail); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
@@ -57,11 +58,11 @@ func DeleteSysDictionaryDetail(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /sysDictionaryDetail/updateSysDictionaryDetail [put]
func UpdateSysDictionaryDetail(c *gin.Context) {
var sysDictionaryDetail model.SysDictionaryDetail
_ = c.ShouldBindJSON(&sysDictionaryDetail)
err := service.UpdateSysDictionaryDetail(&sysDictionaryDetail)
if err != nil {
response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
var detail model.SysDictionaryDetail
_ = c.ShouldBindJSON(&detail)
if err := service.UpdateSysDictionaryDetail(&detail); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
response.FailWithMessage("更新失败", c)
} else {
response.OkWithMessage("更新成功", c)
}
@@ -76,13 +77,17 @@ func UpdateSysDictionaryDetail(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /sysDictionaryDetail/findSysDictionaryDetail [get]
func FindSysDictionaryDetail(c *gin.Context) {
var sysDictionaryDetail model.SysDictionaryDetail
_ = c.ShouldBindQuery(&sysDictionaryDetail)
err, resysDictionaryDetail := service.GetSysDictionaryDetail(sysDictionaryDetail.ID)
if err != nil {
response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
var detail model.SysDictionaryDetail
_ = c.ShouldBindQuery(&detail)
if err := utils.Verify(detail, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err, resysDictionaryDetail := service.GetSysDictionaryDetail(detail.ID); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithData(gin.H{"resysDictionaryDetail": resysDictionaryDetail}, c)
response.OkWithDetailed(gin.H{"resysDictionaryDetail": resysDictionaryDetail}, "查询成功", c)
}
}
@@ -91,21 +96,21 @@ func FindSysDictionaryDetail(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysDictionaryDetailSearch true "分页获取SysDictionaryDetail列表"
// @Param data body request.SysDictionaryDetailSearch true "页码, 每页大小, 搜索条件"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /sysDictionaryDetail/getSysDictionaryDetailList [get]
func GetSysDictionaryDetailList(c *gin.Context) {
var pageInfo request.SysDictionaryDetailSearch
_ = c.ShouldBindQuery(&pageInfo)
err, list, total := service.GetSysDictionaryDetailInfoList(pageInfo)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
if err, list, total := service.GetSysDictionaryDetailInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.PageResult{
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, c)
}, "获取成功", c)
}
}
+8 -7
View File
@@ -1,22 +1,23 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags system
// @Tags System
// @Summary 发送测试邮件
// @Security ApiKeyAuth
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}"
// @Router /email/emailTest [post]
func EmailTest(c *gin.Context) {
err := service.EmailTest()
if err != nil {
response.FailWithMessage(fmt.Sprintf("发送失败,%v", err), c)
if err := service.EmailTest(); err != nil {
global.GVA_LOG.Error("发送失败!", zap.Any("err", err))
response.FailWithMessage("发送失败", c)
} else {
response.OkWithData("发送成功", c)
}
+58
View File
@@ -0,0 +1,58 @@
package v1
import (
"gin-vue-admin/global"
"gin-vue-admin/model/request"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"go.uber.org/zap"
"github.com/gin-gonic/gin"
)
// @Tags InitDB
// @Summary 初始化用户数据库
// @Produce application/json
// @Param data body request.InitDB true "初始化数据库参数"
// @Success 200 {string} string "{"code":0,"data":{},"msg":"自动创建数据库成功"}"
// @Router /init/initdb [post]
func InitDB(c *gin.Context) {
if global.GVA_DB != nil {
global.GVA_LOG.Error("非法访问")
response.FailWithMessage("非法访问", c)
return
}
var dbInfo request.InitDB
if err := c.ShouldBindJSON(&dbInfo); err != nil {
global.GVA_LOG.Error("参数校验不通过", zap.Any("err", err))
response.FailWithMessage("参数校验不通过", c)
return
}
if err := service.InitDB(dbInfo); err != nil {
global.GVA_LOG.Error("自动创建数据库失败", zap.Any("err", err))
response.FailWithMessage("自动创建数据库失败,请查看后台日志", c)
return
}
response.OkWithData("自动创建数据库成功", c)
}
// @Tags CheckDB
// @Summary 初始化用户数据库
// @Produce application/json
// @Success 200 {string} string "{"code":0,"data":{},"msg":"探测完成"}"
// @Router /init/checkdb [post]
func CheckDB(c *gin.Context) {
if global.GVA_DB != nil {
global.GVA_LOG.Info("数据库无需初始化")
response.OkWithDetailed(gin.H{
"needInit": false,
}, "数据库无需初始化", c)
return
} else {
global.GVA_LOG.Info("前往初始化数据库")
response.OkWithDetailed(gin.H{
"needInit": true,
}, "前往初始化数据库", c)
return
}
}
+8 -9
View File
@@ -1,14 +1,15 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags jwt
// @Tags Jwt
// @Summary jwt加入黑名单
// @Security ApiKeyAuth
// @accept application/json
@@ -17,12 +18,10 @@ import (
// @Router /jwt/jsonInBlacklist [post]
func JsonInBlacklist(c *gin.Context) {
token := c.Request.Header.Get("x-token")
modelJwt := model.JwtBlacklist{
Jwt: token,
}
err := service.JsonInBlacklist(modelJwt)
if err != nil {
response.FailWithMessage(fmt.Sprintf("jwt作废失败,%v", err), c)
jwt := model.JwtBlacklist{Jwt: token}
if err := service.JsonInBlacklist(jwt); err != nil {
global.GVA_LOG.Error("jwt作废失败!", zap.Any("err", err))
response.FailWithMessage("jwt作废失败", c)
} else {
response.OkWithMessage("jwt作废成功", c)
}
+123 -162
View File
@@ -1,259 +1,220 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags authorityAndMenu
// @Tags AuthorityMenu
// @Summary 获取用户动态路由
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body request.RegisterAndLoginStruct true "可以什么都不填"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
// @Param data body request.Empty true "空"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/getMenu [post]
func GetMenu(c *gin.Context) {
claims, _ := c.Get("claims")
waitUse := claims.(*request.CustomClaims)
err, menus := service.GetMenuTree(waitUse.AuthorityId)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
if err, menus := service.GetMenuTree(getUserAuthorityId(c)); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.SysMenusResponse{Menus: menus}, c)
response.OkWithDetailed(response.SysMenusResponse{Menus: menus}, "获取成功", c)
}
}
// @Tags menu
// @Summary 分页获取基础menu列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.PageInfo true "分页获取基础menu列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/getMenuList [post]
func GetMenuList(c *gin.Context) {
var pageInfo request.PageInfo
_ = c.ShouldBindJSON(&pageInfo)
PageVerifyErr := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"])
if PageVerifyErr != nil {
response.FailWithMessage(PageVerifyErr.Error(), c)
return
}
err, menuList, total := service.GetInfoList()
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
} else {
response.OkWithData(resp.PageResult{
List: menuList,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, c)
}
}
// @Tags menu
// @Summary 新增菜单
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysBaseMenu true "新增菜单"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/addBaseMenu [post]
func AddBaseMenu(c *gin.Context) {
var menu model.SysBaseMenu
_ = c.ShouldBindJSON(&menu)
MenuVerify := utils.Rules{
"Path": {utils.NotEmpty()},
"ParentId": {utils.NotEmpty()},
"Name": {utils.NotEmpty()},
"Component": {utils.NotEmpty()},
"Sort": {utils.Ge("0")},
}
MenuVerifyErr := utils.Verify(menu, MenuVerify)
if MenuVerifyErr != nil {
response.FailWithMessage(MenuVerifyErr.Error(), c)
return
}
MetaVerify := utils.Rules{
"Title": {utils.NotEmpty()},
}
MetaVerifyErr := utils.Verify(menu.Meta, MetaVerify)
if MetaVerifyErr != nil {
response.FailWithMessage(MetaVerifyErr.Error(), c)
return
}
err := service.AddBaseMenu(menu)
if err != nil {
response.FailWithMessage(fmt.Sprintf("添加失败,%v", err), c)
} else {
response.OkWithMessage("添加成功", c)
}
}
// @Tags authorityAndMenu
// @Tags AuthorityMenu
// @Summary 获取用户动态路由
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body request.RegisterAndLoginStruct true "可以什么都不填"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
// @Param data body request.Empty true "空"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/getBaseMenuTree [post]
func GetBaseMenuTree(c *gin.Context) {
err, menus := service.GetBaseMenuTree()
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
if err, menus := service.GetBaseMenuTree(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.SysBaseMenusResponse{Menus: menus}, c)
response.OkWithDetailed(response.SysBaseMenusResponse{Menus: menus}, "获取成功", c)
}
}
// @Tags authorityAndMenu
// @Tags AuthorityMenu
// @Summary 增加menu和角色关联关系
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.AddMenuAuthorityInfo true "增加menu和角色关联关系"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body request.AddMenuAuthorityInfo true "角色ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
// @Router /menu/addMenuAuthority [post]
func AddMenuAuthority(c *gin.Context) {
var addMenuAuthorityInfo request.AddMenuAuthorityInfo
_ = c.ShouldBindJSON(&addMenuAuthorityInfo)
MenuVerify := utils.Rules{
"AuthorityId": {"notEmpty"},
}
MenuVerifyErr := utils.Verify(addMenuAuthorityInfo, MenuVerify)
if MenuVerifyErr != nil {
response.FailWithMessage(MenuVerifyErr.Error(), c)
var authorityMenu request.AddMenuAuthorityInfo
_ = c.ShouldBindJSON(&authorityMenu)
if err := utils.Verify(authorityMenu, utils.AuthorityIdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.AddMenuAuthority(addMenuAuthorityInfo.Menus, addMenuAuthorityInfo.AuthorityId)
if err != nil {
response.FailWithMessage(fmt.Sprintf("添加失败,%v", err), c)
if err := service.AddMenuAuthority(authorityMenu.Menus, authorityMenu.AuthorityId); err != nil {
global.GVA_LOG.Error("添加失败!", zap.Any("err", err))
response.FailWithMessage("添加失败", c)
} else {
response.OkWithMessage("添加成功", c)
}
}
// @Tags authorityAndMenu
// @Tags AuthorityMenu
// @Summary 获取指定角色menu
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.AuthorityIdInfo true "增加menu和角色关联关系"
// @Param data body request.GetAuthorityId true "角色ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/GetMenuAuthority [post]
func GetMenuAuthority(c *gin.Context) {
var authorityIdInfo request.AuthorityIdInfo
_ = c.ShouldBindJSON(&authorityIdInfo)
MenuVerify := utils.Rules{
"AuthorityId": {"notEmpty"},
}
MenuVerifyErr := utils.Verify(authorityIdInfo, MenuVerify)
if MenuVerifyErr != nil {
response.FailWithMessage(MenuVerifyErr.Error(), c)
var param request.GetAuthorityId
_ = c.ShouldBindJSON(&param)
if err := utils.Verify(param, utils.AuthorityIdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, menus := service.GetMenuAuthority(authorityIdInfo.AuthorityId)
if err != nil {
response.FailWithDetailed(response.ERROR, resp.SysMenusResponse{Menus: menus}, fmt.Sprintf("添加失败,%v", err), c)
if err, menus := service.GetMenuAuthority(&param); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithDetailed(response.SysMenusResponse{Menus: menus}, "获取失败", c)
} else {
response.Result(response.SUCCESS, gin.H{"menus": menus}, "获取成功", c)
response.OkWithDetailed(gin.H{"menus": menus}, "获取成功", c)
}
}
// @Tags menu
// @Tags Menu
// @Summary 新增菜单
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
// @Router /menu/addBaseMenu [post]
func AddBaseMenu(c *gin.Context) {
var menu model.SysBaseMenu
_ = c.ShouldBindJSON(&menu)
if err := utils.Verify(menu, utils.MenuVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err := utils.Verify(menu.Meta, utils.MenuMetaVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err := service.AddBaseMenu(menu); err != nil {
global.GVA_LOG.Error("添加失败!", zap.Any("err", err))
response.FailWithMessage("添加失败", c)
} else {
response.OkWithMessage("添加成功", c)
}
}
// @Tags Menu
// @Summary 删除菜单
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.GetById true "删除菜单"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body request.GetById true "菜单id"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /menu/deleteBaseMenu [post]
func DeleteBaseMenu(c *gin.Context) {
var idInfo request.GetById
_ = c.ShouldBindJSON(&idInfo)
IdVerifyErr := utils.Verify(idInfo, utils.CustomizeMap["IdVerify"])
if IdVerifyErr != nil {
response.FailWithMessage(IdVerifyErr.Error(), c)
var menu request.GetById
_ = c.ShouldBindJSON(&menu)
if err := utils.Verify(menu, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.DeleteBaseMenu(idInfo.Id)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败:%v", err), c)
if err := service.DeleteBaseMenu(menu.ID); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
}
// @Tags menu
// @Tags Menu
// @Summary 更新菜单
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysBaseMenu true "更新菜单"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Param data body model.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /menu/updateBaseMenu [post]
func UpdateBaseMenu(c *gin.Context) {
var menu model.SysBaseMenu
_ = c.ShouldBindJSON(&menu)
MenuVerify := utils.Rules{
"Path": {"notEmpty"},
"ParentId": {utils.NotEmpty()},
"Name": {utils.NotEmpty()},
"Component": {utils.NotEmpty()},
"Sort": {utils.Ge("0")},
}
MenuVerifyErr := utils.Verify(menu, MenuVerify)
if MenuVerifyErr != nil {
response.FailWithMessage(MenuVerifyErr.Error(), c)
if err := utils.Verify(menu, utils.MenuVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
MetaVerify := utils.Rules{
"Title": {utils.NotEmpty()},
}
MetaVerifyErr := utils.Verify(menu.Meta, MetaVerify)
if MetaVerifyErr != nil {
response.FailWithMessage(MetaVerifyErr.Error(), c)
if err := utils.Verify(menu.Meta, utils.MenuMetaVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.UpdateBaseMenu(menu)
if err != nil {
response.FailWithMessage(fmt.Sprintf("修改失败:%v", err), c)
if err := service.UpdateBaseMenu(menu); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
response.FailWithMessage("更新失败", c)
} else {
response.OkWithMessage("修改成功", c)
response.OkWithMessage("更新成功", c)
}
}
// @Tags menu
// @Tags Menu
// @Summary 根据id获取菜单
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.GetById true "根据id获取菜单"
// @Param data body request.GetById true "菜单id"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/getBaseMenuById [post]
func GetBaseMenuById(c *gin.Context) {
var idInfo request.GetById
_ = c.ShouldBindJSON(&idInfo)
MenuVerify := utils.Rules{
"Id": {"notEmpty"},
}
MenuVerifyErr := utils.Verify(idInfo, MenuVerify)
if MenuVerifyErr != nil {
response.FailWithMessage(MenuVerifyErr.Error(), c)
if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, menu := service.GetBaseMenuById(idInfo.Id)
if err != nil {
response.FailWithMessage(fmt.Sprintf("查询失败:%v", err), c)
if err, menu := service.GetBaseMenuById(idInfo.ID); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.SysBaseMenuResponse{Menu: menu}, c)
response.OkWithDetailed(response.SysBaseMenuResponse{Menu: menu}, "获取成功", c)
}
}
// @Tags Menu
// @Summary 分页获取基础menu列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.PageInfo true "页码, 每页大小"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/getMenuList [post]
func GetMenuList(c *gin.Context) {
var pageInfo request.PageInfo
_ = c.ShouldBindJSON(&pageInfo)
if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err, menuList, total := service.GetInfoList(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithDetailed(response.PageResult{
List: menuList,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, "获取成功", c)
}
}
+31 -26
View File
@@ -1,13 +1,14 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags SysOperationRecord
@@ -21,9 +22,9 @@ import (
func CreateSysOperationRecord(c *gin.Context) {
var sysOperationRecord model.SysOperationRecord
_ = c.ShouldBindJSON(&sysOperationRecord)
err := service.CreateSysOperationRecord(sysOperationRecord)
if err != nil {
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
if err := service.CreateSysOperationRecord(sysOperationRecord); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithMessage("创建成功", c)
}
@@ -34,15 +35,15 @@ func CreateSysOperationRecord(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysOperationRecord true "删除SysOperationRecord"
// @Param data body model.SysOperationRecord true "SysOperationRecord模型"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /sysOperationRecord/deleteSysOperationRecord [delete]
func DeleteSysOperationRecord(c *gin.Context) {
var sysOperationRecord model.SysOperationRecord
_ = c.ShouldBindJSON(&sysOperationRecord)
err := service.DeleteSysOperationRecord(sysOperationRecord)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
if err := service.DeleteSysOperationRecord(sysOperationRecord); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
@@ -54,16 +55,16 @@ func DeleteSysOperationRecord(c *gin.Context) {
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除SysOperationRecord"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /sysOperationRecord/deleteSysOperationRecordByIds [delete]
func DeleteSysOperationRecordByIds(c *gin.Context) {
var IDS request.IdsReq
_ = c.ShouldBindJSON(&IDS)
err := service.DeleteSysOperationRecordByIds(IDS)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
if err := service.DeleteSysOperationRecordByIds(IDS); err != nil {
global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
response.FailWithMessage("批量删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
response.OkWithMessage("批量删除成功", c)
}
}
@@ -72,17 +73,21 @@ func DeleteSysOperationRecordByIds(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysOperationRecord true "用id查询SysOperationRecord"
// @Param data body model.SysOperationRecord true "Id"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /sysOperationRecord/findSysOperationRecord [get]
func FindSysOperationRecord(c *gin.Context) {
var sysOperationRecord model.SysOperationRecord
_ = c.ShouldBindQuery(&sysOperationRecord)
err, resysOperationRecord := service.GetSysOperationRecord(sysOperationRecord.ID)
if err != nil {
response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
if err := utils.Verify(sysOperationRecord, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err, resysOperationRecord := service.GetSysOperationRecord(sysOperationRecord.ID); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithData(gin.H{"resysOperationRecord": resysOperationRecord}, c)
response.OkWithDetailed(gin.H{"resysOperationRecord": resysOperationRecord}, "查询成功", c)
}
}
@@ -91,21 +96,21 @@ func FindSysOperationRecord(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysOperationRecordSearch true "分页获取SysOperationRecord列表"
// @Param data body request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /sysOperationRecord/getSysOperationRecordList [get]
func GetSysOperationRecordList(c *gin.Context) {
var pageInfo request.SysOperationRecordSearch
_ = c.ShouldBindQuery(&pageInfo)
err, list, total := service.GetSysOperationRecordInfoList(pageInfo)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
if err, list, total := service.GetSysOperationRecordInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.PageResult{
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, c)
}, "获取成功", c)
}
}
+33 -32
View File
@@ -1,78 +1,79 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/global"
"gin-vue-admin/model"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Tags system
// @Tags System
// @Summary 获取配置文件内容
// @Security ApiKeyAuth
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /system/getSystemConfig [post]
func GetSystemConfig(c *gin.Context) {
err, config := service.GetSystemConfig()
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
if err, config := service.GetSystemConfig(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.SysConfigResponse{Config: config}, c)
response.OkWithDetailed(response.SysConfigResponse{Config: config}, "获取成功", c)
}
}
// @Tags system
// @Tags System
// @Summary 设置配置文件内容
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body model.System true "设置配置文件内容"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}"
// @Router /system/setSystemConfig [post]
func SetSystemConfig(c *gin.Context) {
var sys model.System
_ = c.ShouldBindJSON(&sys)
err := service.SetSystemConfig(sys)
if err != nil {
response.FailWithMessage(fmt.Sprintf("设置失败,%v", err), c)
if err := service.SetSystemConfig(sys); err != nil {
global.GVA_LOG.Error("设置失败!", zap.Any("err", err))
response.FailWithMessage("设置失败", c)
} else {
response.OkWithData("设置成功", c)
}
}
// 本方法开发中 开发者windows系统 缺少linux系统所需的包 因此搁置
// @Tags system
// @Summary 设置配置文件内容
// @Tags System
// @Summary 重启系统
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body model.System true "设置配置文件内容"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
// @Router /system/ReloadSystem [post]
// @Success 200 {string} string "{"code":0,"data":{},"msg":"重启系统成功"}"
// @Router /system/reloadSystem [post]
func ReloadSystem(c *gin.Context) {
var sys model.System
_ = c.ShouldBindJSON(&sys)
err := service.SetSystemConfig(sys)
err := utils.Reload()
if err != nil {
response.FailWithMessage(fmt.Sprintf("设置失败,%v", err), c)
} else {
response.OkWithMessage("设置成功", c)
global.GVA_LOG.Error("重启系统失败!", zap.Any("err", err))
response.FailWithMessage("重启系统失败", c)
return
}
response.OkWithMessage("重启系统成功", c)
return
}
// @Tags system
// @Tags System
// @Summary 获取服务器信息
// @Security ApiKeyAuth
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /system/getServerInfo [post]
func GetServerInfo(c *gin.Context) {
server, err := service.GetServerInfo()
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
if server, err := service.GetServerInfo(); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
return
} else {
response.OkWithDetailed(gin.H{"server": server}, "获取成功", c)
}
response.OkDetailed(gin.H{"server":server}, "获取成功",c)
}
}
+133 -123
View File
@@ -1,128 +1,91 @@
package v1
import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/global/response"
"gin-vue-admin/middleware"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
resp "gin-vue-admin/model/response"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"time"
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis"
"mime/multipart"
"time"
"go.uber.org/zap"
)
// @Tags Base
// @Summary 用户注册账号
// @Produce application/json
// @Param data body model.SysUser true "用户注册接口"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}"
// @Router /user/register [post]
func Register(c *gin.Context) {
var R request.RegisterStruct
_ = c.ShouldBindJSON(&R)
UserVerify := utils.Rules{
"Username": {utils.NotEmpty()},
"NickName": {utils.NotEmpty()},
"Password": {utils.NotEmpty()},
"AuthorityId": {utils.NotEmpty()},
}
UserVerifyErr := utils.Verify(R, UserVerify)
if UserVerifyErr != nil {
response.FailWithMessage(UserVerifyErr.Error(), c)
return
}
user := &model.SysUser{Username: R.Username, NickName: R.NickName, Password: R.Password, HeaderImg: R.HeaderImg, AuthorityId: R.AuthorityId}
err, userReturn := service.Register(*user)
if err != nil {
response.FailWithDetailed(response.ERROR, resp.SysUserResponse{User: userReturn}, fmt.Sprintf("%v", err), c)
} else {
response.OkDetailed(resp.SysUserResponse{User: userReturn}, "注册成功", c)
}
}
// @Tags Base
// @Summary 用户登录
// @Produce application/json
// @Param data body request.RegisterAndLoginStruct true "用户登录接口"
// @Param data body request.Login true "用户名, 密码, 验证码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}"
// @Router /base/login [post]
func Login(c *gin.Context) {
var L request.RegisterAndLoginStruct
var L request.Login
_ = c.ShouldBindJSON(&L)
UserVerify := utils.Rules{
"CaptchaId": {utils.NotEmpty()},
"Captcha": {utils.NotEmpty()},
"Username": {utils.NotEmpty()},
"Password": {utils.NotEmpty()},
}
UserVerifyErr := utils.Verify(L, UserVerify)
if UserVerifyErr != nil {
response.FailWithMessage(UserVerifyErr.Error(), c)
if err := utils.Verify(L, utils.LoginVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if store.Verify(L.CaptchaId, L.Captcha, true) {
U := &model.SysUser{Username: L.Username, Password: L.Password}
if err, user := service.Login(U); err != nil {
response.FailWithMessage(fmt.Sprintf("用户名密码错误或%v", err), c)
global.GVA_LOG.Error("登陆失败! 用户名不存在或者密码错误", zap.Any("err", err))
response.FailWithMessage("用户名不存在或者密码错误", c)
} else {
tokenNext(c, *user)
}
} else {
response.FailWithMessage("验证码错误", c)
}
}
// 登录以后签发jwt
func tokenNext(c *gin.Context, user model.SysUser) {
j := &middleware.JWT{
SigningKey: []byte(global.GVA_CONFIG.JWT.SigningKey), // 唯一签名
}
clams := request.CustomClaims{
j := &middleware.JWT{SigningKey: []byte(global.GVA_CONFIG.JWT.SigningKey)} // 唯一签名
claims := request.CustomClaims{
UUID: user.UUID,
ID: user.ID,
NickName: user.NickName,
Username: user.Username,
AuthorityId: user.AuthorityId,
BufferTime: 60 * 60 * 24, // 缓冲时间1天 缓冲时间内会获得新的token刷新令牌 此时一个用户会存在两个有效令牌 但是前端只留一个 另一个会丢失
BufferTime: global.GVA_CONFIG.JWT.BufferTime, // 缓冲时间1天 缓冲时间内会获得新的token刷新令牌 此时一个用户会存在两个有效令牌 但是前端只留一个 另一个会丢失
StandardClaims: jwt.StandardClaims{
NotBefore: time.Now().Unix() - 1000, // 签名生效时间
ExpiresAt: time.Now().Unix() + 60*60*24*7, // 过期时间 7天
Issuer: "qmPlus", // 签名的发行者
NotBefore: time.Now().Unix() - 1000, // 签名生效时间
ExpiresAt: time.Now().Unix() + global.GVA_CONFIG.JWT.ExpiresTime, // 过期时间 7天 配置文件
Issuer: "qmPlus", // 签名的发行者
},
}
token, err := j.CreateToken(clams)
token, err := j.CreateToken(claims)
if err != nil {
global.GVA_LOG.Error("获取token失败", zap.Any("err", err))
response.FailWithMessage("获取token失败", c)
return
}
if !global.GVA_CONFIG.System.UseMultipoint {
response.OkWithData(resp.LoginResponse{
response.OkWithDetailed(response.LoginResponse{
User: user,
Token: token,
ExpiresAt: clams.StandardClaims.ExpiresAt * 1000,
}, c)
ExpiresAt: claims.StandardClaims.ExpiresAt * 1000,
}, "登录成功", c)
return
}
err, jwtStr := service.GetRedisJWT(user.Username)
if err == redis.Nil {
if err, jwtStr := service.GetRedisJWT(user.Username); err == redis.Nil {
if err := service.SetRedisJWT(token, user.Username); err != nil {
global.GVA_LOG.Error("设置登录状态失败", zap.Any("err", err))
response.FailWithMessage("设置登录状态失败", c)
return
}
response.OkWithData(resp.LoginResponse{
response.OkWithDetailed(response.LoginResponse{
User: user,
Token: token,
ExpiresAt: clams.StandardClaims.ExpiresAt * 1000,
}, c)
ExpiresAt: claims.StandardClaims.ExpiresAt * 1000,
}, "登录成功", c)
} else if err != nil {
response.FailWithMessage(fmt.Sprintf("%v", err), c)
global.GVA_LOG.Error("设置登录状态失败", zap.Any("err", err))
response.FailWithMessage("设置登录状态失败", c)
} else {
var blackJWT model.JwtBlacklist
blackJWT.Jwt = jwtStr
@@ -134,11 +97,34 @@ func tokenNext(c *gin.Context, user model.SysUser) {
response.FailWithMessage("设置登录状态失败", c)
return
}
response.OkWithData(resp.LoginResponse{
response.OkWithDetailed(response.LoginResponse{
User: user,
Token: token,
ExpiresAt: clams.StandardClaims.ExpiresAt * 1000,
}, c)
ExpiresAt: claims.StandardClaims.ExpiresAt * 1000,
}, "登录成功", c)
}
}
// @Tags SysUser
// @Summary 用户注册账号
// @Produce application/json
// @Param data body model.SysUser true "用户名, 昵称, 密码, 角色ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}"
// @Router /user/register [post]
func Register(c *gin.Context) {
var R request.Register
_ = c.ShouldBindJSON(&R)
if err := utils.Verify(R, utils.RegisterVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
user := &model.SysUser{Username: R.Username, NickName: R.NickName, Password: R.Password, HeaderImg: R.HeaderImg, AuthorityId: R.AuthorityId}
err, userReturn := service.Register(*user)
if err != nil {
global.GVA_LOG.Error("注册失败", zap.Any("err", err))
response.FailWithDetailed(response.SysUserResponse{User: userReturn}, "注册失败", c)
} else {
response.OkWithDetailed(response.SysUserResponse{User: userReturn}, "注册成功", c)
}
}
@@ -146,60 +132,50 @@ func tokenNext(c *gin.Context, user model.SysUser) {
// @Summary 用户修改密码
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body request.ChangePasswordStruct true "用户修改密码"
// @Param data body request.ChangePasswordStruct true "用户名, 原密码, 新密码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /user/changePassword [put]
func ChangePassword(c *gin.Context) {
var params request.ChangePasswordStruct
_ = c.ShouldBindJSON(&params)
UserVerify := utils.Rules{
"Username": {utils.NotEmpty()},
"Password": {utils.NotEmpty()},
"NewPassword": {utils.NotEmpty()},
}
UserVerifyErr := utils.Verify(params, UserVerify)
if UserVerifyErr != nil {
response.FailWithMessage(UserVerifyErr.Error(), c)
var user request.ChangePasswordStruct
_ = c.ShouldBindJSON(&user)
if err := utils.Verify(user, utils.ChangePasswordVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
U := &model.SysUser{Username: params.Username, Password: params.Password}
if err, _ := service.ChangePassword(U, params.NewPassword); err != nil {
response.FailWithMessage("修改失败,请检查用户名密码", c)
U := &model.SysUser{Username: user.Username, Password: user.Password}
if err, _ := service.ChangePassword(U, user.NewPassword); err != nil {
global.GVA_LOG.Error("修改失败", zap.Any("err", err))
response.FailWithMessage("修改失败,原密码与当前账户不符", c)
} else {
response.OkWithMessage("修改成功", c)
}
}
type UserHeaderImg struct {
HeaderImg multipart.File `json:"headerImg"`
}
// @Tags SysUser
// @Summary 分页获取用户列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.PageInfo true "分页获取用户列表"
// @Param data body request.PageInfo true "页码, 每页大小"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /user/getUserList [post]
func GetUserList(c *gin.Context) {
var pageInfo request.PageInfo
_ = c.ShouldBindJSON(&pageInfo)
PageVerifyErr := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"])
if PageVerifyErr != nil {
response.FailWithMessage(PageVerifyErr.Error(), c)
if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err, list, total := service.GetUserInfoList(pageInfo)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
if err, list, total := service.GetUserInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败", zap.Any("err", err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithData(resp.PageResult{
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, c)
}, "获取成功", c)
}
}
@@ -208,24 +184,19 @@ func GetUserList(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SetUserAuth true "设置用户权限"
// @Param data body request.SetUserAuth true "用户UUID, 角色ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /user/setUserAuthority [post]
func SetUserAuthority(c *gin.Context) {
var sua request.SetUserAuth
_ = c.ShouldBindJSON(&sua)
UserVerify := utils.Rules{
"UUID": {utils.NotEmpty()},
"AuthorityId": {utils.NotEmpty()},
}
UserVerifyErr := utils.Verify(sua, UserVerify)
if UserVerifyErr != nil {
if UserVerifyErr := utils.Verify(sua, utils.SetUserAuthorityVerify); UserVerifyErr != nil {
response.FailWithMessage(UserVerifyErr.Error(), c)
return
}
err := service.SetUserAuthority(sua.UUID, sua.AuthorityId)
if err != nil {
response.FailWithMessage(fmt.Sprintf("修改失败,%v", err), c)
if err := service.SetUserAuthority(sua.UUID, sua.AuthorityId); err != nil {
global.GVA_LOG.Error("修改失败", zap.Any("err", err))
response.FailWithMessage("修改失败", c)
} else {
response.OkWithMessage("修改成功", c)
}
@@ -236,42 +207,81 @@ func SetUserAuthority(c *gin.Context) {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.GetById true "删除用户"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Param data body request.GetById true "用户ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /user/deleteUser [delete]
func DeleteUser(c *gin.Context) {
var reqId request.GetById
_ = c.ShouldBindJSON(&reqId)
IdVerifyErr := utils.Verify(reqId, utils.CustomizeMap["IdVerify"])
if IdVerifyErr != nil {
response.FailWithMessage(IdVerifyErr.Error(), c)
if err := utils.Verify(reqId, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err := service.DeleteUser(reqId.Id)
if err != nil {
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
jwtId := getUserID(c)
if jwtId == uint(reqId.ID) {
response.FailWithMessage("删除失败, 自杀失败", c)
return
}
if err := service.DeleteUser(reqId.ID); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
}
// @Tags SysUser
// @Summary 删除用户
// @Summary 设置用户信息
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysUser true "删除用户"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Param data body model.SysUser true "ID, 用户名, 昵称, 头像链接"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}"
// @Router /user/setUserInfo [put]
func SetUserInfo(c *gin.Context) {
var user model.SysUser
c.ShouldBindJSON(&user)
err, ReqUser := service.SetUserInfo(user)
if err != nil {
response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
_ = c.ShouldBindJSON(&user)
if err := utils.Verify(user, utils.IdVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err, ReqUser := service.SetUserInfo(user); err != nil {
global.GVA_LOG.Error("设置失败", zap.Any("err", err))
response.FailWithMessage("设置失败", c)
} else {
response.OkWithData(gin.H{
"userInfo": ReqUser,
}, c)
response.OkWithDetailed(gin.H{"userInfo": ReqUser}, "设置成功", c)
}
}
// 从Gin的Context中获取从jwt解析出来的用户ID
func getUserID(c *gin.Context) uint {
if claims, exists := c.Get("claims"); !exists {
global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件")
return 0
} else {
waitUse := claims.(*request.CustomClaims)
return waitUse.ID
}
}
// 从Gin的Context中获取从jwt解析出来的用户UUID
func getUserUuid(c *gin.Context) string {
if claims, exists := c.Get("claims"); !exists {
global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户UUID失败, 请检查路由是否使用jwt中间件")
return ""
} else {
waitUse := claims.(*request.CustomClaims)
return waitUse.UUID.String()
}
}
// 从Gin的Context中获取从jwt解析出来的用户角色id
func getUserAuthorityId(c *gin.Context) string {
if claims, exists := c.Get("claims"); !exists {
global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户UUID失败, 请检查路由是否使用jwt中间件")
return ""
} else {
waitUse := claims.(*request.CustomClaims)
return waitUse.AuthorityId
}
}
-38
View File
@@ -1,38 +0,0 @@
package v1
import (
"fmt"
"gin-vue-admin/global/response"
"gin-vue-admin/model"
"gin-vue-admin/service"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
)
// @Tags workflow
// @Summary 注册工作流
// @Produce application/json
// @Param data body model.SysWorkflow true "注册工作流接口"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}"
// @Router /workflow/createWorkFlow [post]
func CreateWorkFlow(c *gin.Context) {
var wk model.SysWorkflow
_ = c.ShouldBindJSON(&wk)
WKVerify := utils.Rules{
"WorkflowNickName": {utils.NotEmpty()},
"WorkflowName": {utils.NotEmpty()},
"WorkflowDescription": {utils.NotEmpty()},
"WorkflowStepInfo": {utils.NotEmpty()},
}
WKVerifyErr := utils.Verify(wk, WKVerify)
if WKVerifyErr != nil {
response.FailWithMessage(WKVerifyErr.Error(), c)
return
}
err := service.Create(wk)
if err != nil {
response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
} else {
response.OkWithMessage("获取成功", c)
}
}
+69 -44
View File
@@ -3,6 +3,8 @@
# jwt configuration
jwt:
signing-key: 'qmPlus'
expires-time: 604800
buffer-time: 86400
# zap logger configuration
zap:
@@ -41,8 +43,7 @@ system:
env: 'public' # Change to "develop" to skip authentication for development mode
addr: 8888
db-type: 'mysql'
oss-type: 'local'
need-init-data: false
oss-type: 'local' # 控制oss选择走本期还是 七牛等其他仓 自行增加其他oss仓可以在 server/utils/upload/upload.go 中 NewOss函数配置
use-multipoint: false
# captcha configuration
@@ -53,55 +54,79 @@ captcha:
# mysql connect configuration
mysql:
path: '127.0.0.1:3306'
config: 'charset=utf8mb4&parseTime=True&loc=Local'
db-name: 'qmPlus'
username: 'root'
password: 'Aa@6447985'
path: ''
config: ''
db-name: ''
username: ''
password: ''
max-idle-conns: 10
max-open-conns: 10
max-open-conns: 100
log-mode: false
# sqlite connect configuration (sqlite需要gcc支持 windows用户需要自行安装gcc)
sqlite:
path: 'db.db'
max-idle-conns: 10
max-open-conns: 10
logger: true
# Sqlserver connect configuration
sqlserver:
path: 'localhost:9930'
db-name: 'gorm'
username: 'gorm'
password: 'LoremIpsum86'
max-idle-conns: 10
max-open-conns: 10
logger: true
# Postgresql connect configuration
postgresql:
host: '127.0.0.1'
port: '9920'
config: 'sslmode=disable TimeZone=Asia/Shanghai'
db-name: 'gorm'
username: 'gorm'
password: 'gorm'
max-idle-conns: 10
max-open-conns: 10
prefer-simple-protocol: true
logger: false
log-zap: ""
# local configuration
local:
path: 'uploads/file'
# autocode configuration
autocode:
transfer-restart: true
root: ""
server: /server
server-api: /api/v1
server-initialize: /initialize
server-model: /model
server-request: /model/request/
server-router: /router
server-service: /service
web: /web/src
web-api: /api
web-flow: /view
web-form: /view
web-table: /view
# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket 和 域名地址)
qiniu:
zone: 'ZoneHuadong'
bucket: 'qm-plus-img'
img-path: 'http://qmplusimg.henrongyi.top'
zone: 'ZoneHuaDong'
bucket: ''
img-path: ''
use-https: false
access-key: '25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ'
secret-key: 'pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY'
use-cdn-domains: false
access-key: ''
secret-key: ''
use-cdn-domains: false
# aliyun oss configuration
aliyun-oss:
endpoint: 'yourEndpoint'
access-key-id: 'yourAccessKeyId'
access-key-secret: 'yourAccessKeySecret'
bucket-name: 'yourBucketName'
bucket-url: 'yourBucketUrl'
# tencent cos configuration
tencent-cos:
bucket: 'xxxxx-10005608'
region: 'ap-shanghai'
secret-id: 'xxxxxxxx'
secret-key: 'xxxxxxxx'
base-url: 'https://gin.vue.admin'
path-prefix: 'gin-vue-admin'
# excel configuration
excel:
dir: './resource/excel/'
# timer task db clear table
Timer:
start: true
spec: "@daily" # 定时任务详细配置参考 https://pkg.go.dev/github.com/robfig/cron/v3
detail: [
# tableName: 需要清理的表名
# compareField: 需要比较时间的字段
# interval: 时间间隔, 具体配置详看 time.ParseDuration() 中字符串表示 且不能为负数
# 2160h = 24 * 30 * 3 -> 三个月
{ tableName: "sys_operation_records" , compareField: "created_at", interval: "2160h" },
#{ tableName: "log2" , compareField: "created_at", interval: "2160h" }
]
+18
View File
@@ -0,0 +1,18 @@
package config
type Autocode struct {
TransferRestart bool `mapstructure:"transfer-restart" json:"transferRestart" yaml:"transfer-restart"`
Root string `mapstructure:"root" json:"root" yaml:"root"`
Server string `mapstructure:"server" json:"server" yaml:"server"`
SApi string `mapstructure:"server-api" json:"serverApi" yaml:"server-api"`
SInitialize string `mapstructure:"server-initialize" json:"serverInitialize" yaml:"server-initialize"`
SModel string `mapstructure:"server-model" json:"serverModel" yaml:"server-model"`
SRequest string `mapstructure:"server-request" json:"serverRequest" yaml:"server-request"`
SRouter string `mapstructure:"server-router" json:"serverRouter" yaml:"server-router"`
SService string `mapstructure:"server-service" json:"serverService" yaml:"server-service"`
Web string `mapstructure:"web" json:"web" yaml:"web"`
WApi string `mapstructure:"web-api" json:"webApi" yaml:"web-api"`
WForm string `mapstructure:"web-form" json:"webForm" yaml:"web-form"`
WTable string `mapstructure:"web-table" json:"webTable" yaml:"web-table"`
WFlow string `mapstructure:"web-flow" json:"webFlow" yaml:"web-flow"`
}
+3 -3
View File
@@ -1,7 +1,7 @@
package config
type Captcha struct {
KeyLong int `mapstructure:"key-long" json:"keyLong" yaml:"key-long"`
ImgWidth int `mapstructure:"img-width" json:"imgWidth" yaml:"img-width"`
ImgHeight int `mapstructure:"img-height" json:"imgHeight" yaml:"img-height"`
KeyLong int `mapstructure:"key-long" json:"keyLong" yaml:"key-long"` // 验证码长度
ImgWidth int `mapstructure:"img-width" json:"imgWidth" yaml:"img-width"` // 验证码宽度
ImgHeight int `mapstructure:"img-height" json:"imgHeight" yaml:"img-height"` // 验证码高度
}
+1 -1
View File
@@ -1,5 +1,5 @@
package config
type Casbin struct {
ModelPath string `mapstructure:"model-path" json:"modelPath" yaml:"model-path"`
ModelPath string `mapstructure:"model-path" json:"modelPath" yaml:"model-path"` // 存放casbin模型的相对路径
}
+9 -6
View File
@@ -8,12 +8,15 @@ type Server struct {
Casbin Casbin `mapstructure:"casbin" json:"casbin" yaml:"casbin"`
System System `mapstructure:"system" json:"system" yaml:"system"`
Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
// auto
AutoCode Autocode `mapstructure:"autoCode" json:"autoCode" yaml:"autoCode"`
// gorm
Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
Sqlite Sqlite `mapstructure:"sqlite" json:"sqlite" yaml:"sqlite"`
Sqlserver Sqlserver `mapstructure:"sqlserver" json:"sqlserver" yaml:"sqlserver"`
Postgresql Postgresql `mapstructure:"postgresql" json:"postgresql" yaml:"postgresql"`
Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
// oss
Local Local `mapstructure:"local" json:"local" yaml:"local"`
Qiniu Qiniu `mapstructure:"qiniu" json:"qiniu" yaml:"qiniu"`
Local Local `mapstructure:"local" json:"local" yaml:"local"`
Qiniu Qiniu `mapstructure:"qiniu" json:"qiniu" yaml:"qiniu"`
AliyunOSS AliyunOSS `mapstructure:"aliyun-oss" json:"aliyunOSS" yaml:"aliyun-oss"`
TencentCOS TencentCOS `mapstructure:"tencent-cos" json:"tencentCOS" yaml:"tencent-cos"`
Excel Excel `mapstructure:"excel" json:"excel" yaml:"excel"`
Timer Timer `mapstructure:"timer" json:"timer" yaml:"timer"`
}
+7 -7
View File
@@ -1,11 +1,11 @@
package config
type Email struct {
To string `mapstructure:"to" json:"to" yaml:"to"`
Port int `mapstructure:"port" json:"port" yaml:"port"`
From string `mapstructure:"from" json:"from" yaml:"from"`
Host string `mapstructure:"host" json:"host" yaml:"host"`
IsSSL bool `mapstructure:"is-ssl" json:"isSSL" yaml:"is-ssl"`
Secret string `mapstructure:"secret" json:"secret" yaml:"secret"`
Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"`
To string `mapstructure:"to" json:"to" yaml:"to"` // 收件人:多个以英文逗号分隔
Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口
From string `mapstructure:"from" json:"from" yaml:"from"` // 收件人
Host string `mapstructure:"host" json:"host" yaml:"host"` // 服务器地址
IsSSL bool `mapstructure:"is-ssl" json:"isSSL" yaml:"is-ssl"` // 是否SSL
Secret string `mapstructure:"secret" json:"secret" yaml:"secret"` // 密钥
Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"` // 昵称
}
+5
View File
@@ -0,0 +1,5 @@
package config
type Excel struct {
Dir string `mapstructure:"dir" json:"dir" yaml:"dir"`
}
+11 -37
View File
@@ -1,43 +1,17 @@
package config
type Mysql struct {
Path string `mapstructure:"path" json:"path" yaml:"path"`
Config string `mapstructure:"config" json:"config" yaml:"config"`
Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
Username string `mapstructure:"username" json:"username" yaml:"username"`
Password string `mapstructure:"password" json:"password" yaml:"password"`
MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
LogMode bool `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"`
Path string `mapstructure:"path" json:"path" yaml:"path"` // 服务器地址:端口
Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置
Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"` // 数据库名
Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名
Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码
MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` // 空闲中的最大连接数
MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
LogMode bool `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"` // 是否开启Gorm全局日志
LogZap string `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"`
}
type Sqlite struct {
Path string `mapstructure:"path" json:"path" yaml:"path"`
MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
Logger bool `mapstructure:"logger" json:"logger" yaml:"logger"`
func (m *Mysql) Dsn() string {
return m.Username + ":" + m.Password + "@tcp(" + m.Path + ")/" + m.Dbname + "?" + m.Config
}
type Sqlserver struct {
Path string `mapstructure:"path" json:"path" yaml:"path"`
Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
Username string `mapstructure:"username" json:"username" yaml:"username"`
Password string `mapstructure:"password" json:"password" yaml:"password"`
MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
Logger bool `mapstructure:"logger" json:"logger" yaml:"logger"`
}
type Postgresql struct {
Host string `mapstructure:"host" json:"host" yaml:"host"`
Port string `mapstructure:"port" json:"port" yaml:"port"`
Config string `mapstructure:"config" json:"config" yaml:"config"`
Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
Username string `mapstructure:"username" json:"username" yaml:"username"`
Password string `mapstructure:"password" json:"password" yaml:"password"`
MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
PreferSimpleProtocol bool `mapstructure:"prefer-simple-protocol" json:"preferSimpleProtocol" yaml:"prefer-simple-protocol"`
Logger bool `mapstructure:"logger" json:"logger" yaml:"logger"`
}
+3 -1
View File
@@ -1,5 +1,7 @@
package config
type JWT struct {
SigningKey string `mapstructure:"signing-key" json:"signingKey" yaml:"signing-key"`
SigningKey string `mapstructure:"signing-key" json:"signingKey" yaml:"signing-key"` // jwt签名
ExpiresTime int64 `mapstructure:"expires-time" json:"expiresTime" yaml:"expires-time"` // 过期时间
BufferTime int64 `mapstructure:"buffer-time" json:"bufferTime" yaml:"buffer-time"` // 缓冲时间
}
+24 -8
View File
@@ -1,15 +1,31 @@
package config
type Local struct {
Path string `mapstructure:"path" json:"path" yaml:"path" `
Path string `mapstructure:"path" json:"path" yaml:"path"` // 本地文件路径
}
type Qiniu struct {
Zone string `mapstructure:"zone" json:"zone" yaml:"zone"`
Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"`
ImgPath string `mapstructure:"img-path" json:"imgPath" yaml:"img-path"`
UseHTTPS bool `mapstructure:"use-https" json:"useHttps" yaml:"use-https"`
AccessKey string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"`
SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"`
UseCdnDomains bool `mapstructure:"use-cdn-domains" json:"useCdnDomains" yaml:"use-cdn-domains"`
Zone string `mapstructure:"zone" json:"zone" yaml:"zone"` // 存储区域
Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` // 空间名称
ImgPath string `mapstructure:"img-path" json:"imgPath" yaml:"img-path"` // CDN加速域名
UseHTTPS bool `mapstructure:"use-https" json:"useHttps" yaml:"use-https"` // 是否使用https
AccessKey string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"` // 秘钥AK
SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"` // 秘钥SK
UseCdnDomains bool `mapstructure:"use-cdn-domains" json:"useCdnDomains" yaml:"use-cdn-domains"` // 上传是否使用CDN上传加速
}
type AliyunOSS struct {
Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint"`
AccessKeyId string `mapstructure:"access-key-id" json:"accessKeyId" yaml:"access-key-id"`
AccessKeySecret string `mapstructure:"access-key-secret" json:"accessKeySecret" yaml:"access-key-secret"`
BucketName string `mapstructure:"bucket-name" json:"bucketName" yaml:"bucket-name"`
BucketUrl string `mapstructure:"bucket-url" json:"bucketUrl" yaml:"bucket-url"`
}
type TencentCOS struct {
Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"`
Region string `mapstructure:"region" json:"region" yaml:"region"`
SecretID string `mapstructure:"secret-id" json:"secretID" yaml:"secret-id"`
SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"`
BaseURL string `mapstructure:"base-url" json:"baseURL" yaml:"base-url"`
PathPrefix string `mapstructure:"path-prefix" json:"pathPrefix" yaml:"path-prefix"`
}
+4 -4
View File
@@ -1,7 +1,7 @@
package config
type Redis struct {
DB int `mapstructure:"db" json:"db" yaml:"db"`
Addr string `mapstructure:"addr" json:"addr" yaml:"addr"`
Password string `mapstructure:"password" json:"password" yaml:"password"`
}
DB int `mapstructure:"db" json:"db" yaml:"db"` // redis的哪个数据库
Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` // 服务器地址:端口
Password string `mapstructure:"password" json:"password" yaml:"password"` // 密码
}
+5 -6
View File
@@ -1,10 +1,9 @@
package config
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"`
OssType string `mapstructure:"oss-type" json:"ossType" yaml:"oss-type"`
NeedInitData bool `mapstructure:"need-init-data" json:"needInitData" yaml:"need-init-data"`
UseMultipoint bool `mapstructure:"use-multipoint" json:"useMultipoint" yaml:"use-multipoint"`
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"` // 数据库类型:mysql(默认)|sqlite|sqlserver|postgresql
OssType string `mapstructure:"oss-type" json:"ossType" yaml:"oss-type"` // Oss类型
UseMultipoint bool `mapstructure:"use-multipoint" json:"useMultipoint" yaml:"use-multipoint"` // 多点登录拦截
}
+13
View File
@@ -0,0 +1,13 @@
package config
type Timer struct {
Start bool `mapstructure:"start" json:"start" yaml:"start"` // 是否启用
Spec string `mapstructure:"spec" json:"spec" yaml:"spec"` // CRON表达式
Detail []Detail `mapstructure:"detail" json:"detail" yaml:"detail"`
}
type Detail struct {
TableName string `mapstructure:"tableName" json:"tableName" yaml:"tableName"` // 需要清理的表名
CompareField string `mapstructure:"compareField" json:"compareField" yaml:"compareField"` // 需要比较时间的字段
Interval string `mapstructure:"interval" json:"interval" yaml:"interval"` // 时间间隔
}
+9 -9
View File
@@ -1,13 +1,13 @@
package config
type Zap struct {
Level string `mapstructure:"level" json:"level" yaml:"level"`
Format string `mapstructure:"format" json:"format" yaml:"format"`
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
Director string `mapstructure:"director" json:"director" yaml:"director"`
LinkName string `mapstructure:"link-name" json:"linkName" yaml:"link-name"`
ShowLine bool `mapstructure:"show-line" json:"showLine" yaml:"showLine"`
EncodeLevel string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"`
StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"`
LogInConsole bool `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"`
Level string `mapstructure:"level" json:"level" yaml:"level"` // 级别
Format string `mapstructure:"format" json:"format" yaml:"format"` // 输出
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 日志前缀
Director string `mapstructure:"director" json:"director" yaml:"director"` // 日志文件夹
LinkName string `mapstructure:"link-name" json:"linkName" yaml:"link-name"` // 软链接名称
ShowLine bool `mapstructure:"show-line" json:"showLine" yaml:"showLine"` // 显示行
EncodeLevel string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"` // 编码级
StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"` // 栈名
LogInConsole bool `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"` // 输出控制台
}
-48
View File
@@ -1,48 +0,0 @@
package core
import (
"flag"
"fmt"
"gin-vue-admin/global"
_ "gin-vue-admin/packfile"
"gin-vue-admin/utils"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
"os"
)
var config string
func init() {
flag.StringVar(&config, "c", "", "choose config file.")
flag.Parse()
if config == "" { // 优先级: 命令行 > 环境变量 > 默认值
if configEnv := os.Getenv(utils.ConfigEnv); configEnv == "" {
config = utils.ConfigFile
fmt.Printf("您正在使用config的默认值,config的路径为%v\n", utils.ConfigFile)
} else {
config = configEnv
fmt.Printf("您正在使用GVA_CONFIG环境变量,config的路径为%v\n", config)
}
} else {
fmt.Printf("您正在使用命令行的-c参数传递的值,config的路径为%v\n", config)
}
v := viper.New()
v.SetConfigFile(config)
err := v.ReadInConfig()
if err != nil {
panic(fmt.Errorf("Fatal error config file: %s \n", err))
}
v.WatchConfig()
v.OnConfigChange(func(e fsnotify.Event) {
fmt.Println("config file changed:", e.Name)
if err := v.Unmarshal(&global.GVA_CONFIG); err != nil {
fmt.Println(err)
}
})
if err := v.Unmarshal(&global.GVA_CONFIG); err != nil {
fmt.Println(err)
}
global.GVA_VP = v
}
+3 -1
View File
@@ -29,9 +29,11 @@ func RunWindowsServer() {
fmt.Printf(`
欢迎使用 Gin-Vue-Admin
当前版本:V2.3.3
当前版本:V2.4.2
加群方式:微信号:shouzi_1994 QQ群:622360840
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
默认前端文件运行地址:http://127.0.0.1:8080
如果项目让您获得了收益,希望您能请团队喝杯可乐:https://www.gin-vue-admin.com/docs/coffee
`, address)
global.GVA_LOG.Error(s.ListenAndServe().Error())
}
+1 -1
View File
@@ -14,4 +14,4 @@ func initServer(address string, router *gin.Engine) server {
s.WriteTimeout = 10 * time.Second
s.MaxHeaderBytes = 1 << 20
return s
}
}
+1 -1
View File
@@ -16,4 +16,4 @@ func initServer(address string, router *gin.Engine) server {
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
}
}
+57
View File
@@ -0,0 +1,57 @@
package core
import (
"flag"
"fmt"
"gin-vue-admin/global"
_ "gin-vue-admin/packfile"
"gin-vue-admin/utils"
"os"
"path/filepath"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
)
func Viper(path ...string) *viper.Viper {
var config string
if len(path) == 0 {
flag.StringVar(&config, "c", "", "choose config file.")
flag.Parse()
if config == "" { // 优先级: 命令行 > 环境变量 > 默认值
if configEnv := os.Getenv(utils.ConfigEnv); configEnv == "" {
config = utils.ConfigFile
fmt.Printf("您正在使用config的默认值,config的路径为%v\n", utils.ConfigFile)
} else {
config = configEnv
fmt.Printf("您正在使用GVA_CONFIG环境变量,config的路径为%v\n", config)
}
} else {
fmt.Printf("您正在使用命令行的-c参数传递的值,config的路径为%v\n", config)
}
} else {
config = path[0]
fmt.Printf("您正在使用func Viper()传递的值,config的路径为%v\n", config)
}
v := viper.New()
v.SetConfigFile(config)
v.SetConfigType("yaml")
err := v.ReadInConfig()
if err != nil {
panic(fmt.Errorf("Fatal error config file: %s \n", err))
}
v.WatchConfig()
v.OnConfigChange(func(e fsnotify.Event) {
fmt.Println("config file changed:", e.Name)
if err := v.Unmarshal(&global.GVA_CONFIG); err != nil {
fmt.Println(err)
}
})
if err := v.Unmarshal(&global.GVA_CONFIG); err != nil {
fmt.Println(err)
}
global.GVA_CONFIG.AutoCode.Root, _ = filepath.Abs("..")
return v
}
+14 -31
View File
@@ -4,20 +4,15 @@ import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/utils"
zaprotatelogs "github.com/lestrrat-go/file-rotatelogs"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"os"
"time"
)
var (
err error
level zapcore.Level
writer zapcore.WriteSyncer
)
var level zapcore.Level
func init() {
func Zap() (logger *zap.Logger) {
if ok, _ := utils.PathExists(global.GVA_CONFIG.Zap.Director); !ok { // 判断是否有Director文件夹
fmt.Printf("create %v directory\n", global.GVA_CONFIG.Zap.Director)
_ = os.Mkdir(global.GVA_CONFIG.Zap.Director, os.ModePerm)
@@ -42,34 +37,15 @@ func init() {
level = zap.InfoLevel
}
writer, err = getWriteSyncer() // 使用file-rotatelogs进行日志分割
if err != nil {
fmt.Printf("Get Write Syncer Failed err:%v", err.Error())
return
}
if level == zap.DebugLevel || level == zap.ErrorLevel {
global.GVA_LOG = zap.New(getEncoderCore(), zap.AddStacktrace(level))
logger = zap.New(getEncoderCore(), zap.AddStacktrace(level))
} else {
global.GVA_LOG = zap.New(getEncoderCore())
logger = zap.New(getEncoderCore())
}
if global.GVA_CONFIG.Zap.ShowLine {
global.GVA_LOG.WithOptions(zap.AddCaller())
logger = logger.WithOptions(zap.AddCaller())
}
}
// getWriteSyncer zap logger中加入file-rotatelogs
func getWriteSyncer() (zapcore.WriteSyncer, error) {
fileWriter, err := zaprotatelogs.New(
global.GVA_CONFIG.Zap.Director+string(os.PathSeparator)+"%Y-%m-%d.log",
zaprotatelogs.WithLinkName(global.GVA_CONFIG.Zap.LinkName),
zaprotatelogs.WithMaxAge(7*24*time.Hour),
zaprotatelogs.WithRotationTime(24*time.Hour),
)
if global.GVA_CONFIG.Zap.LogInConsole {
return zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout), zapcore.AddSync(fileWriter)), err
}
return zapcore.AddSync(fileWriter), err
return logger
}
// getEncoderConfig 获取zapcore.EncoderConfig
@@ -87,7 +63,7 @@ func getEncoderConfig() (config zapcore.EncoderConfig) {
EncodeDuration: zapcore.SecondsDurationEncoder,
EncodeCaller: zapcore.FullCallerEncoder,
}
switch {
switch {
case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseLevelEncoder": // 小写编码器(默认)
config.EncodeLevel = zapcore.LowercaseLevelEncoder
case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseColorLevelEncoder": // 小写编码器带颜色
@@ -96,6 +72,8 @@ func getEncoderConfig() (config zapcore.EncoderConfig) {
config.EncodeLevel = zapcore.CapitalLevelEncoder
case global.GVA_CONFIG.Zap.EncodeLevel == "CapitalColorLevelEncoder": // 大写编码器带颜色
config.EncodeLevel = zapcore.CapitalColorLevelEncoder
default:
config.EncodeLevel = zapcore.LowercaseLevelEncoder
}
return config
}
@@ -110,6 +88,11 @@ func getEncoder() zapcore.Encoder {
// getEncoderCore 获取Encoder的zapcore.Core
func getEncoderCore() (core zapcore.Core) {
writer, err := utils.GetWriteSyncer() // 使用file-rotatelogs进行日志分割
if err != nil {
fmt.Printf("Get Write Syncer Failed err:%v", err.Error())
return
}
return zapcore.NewCore(getEncoder(), writer, level)
}
+1023 -371
View File
File diff suppressed because it is too large Load Diff
+1022 -370
View File
File diff suppressed because it is too large Load Diff
+786 -306
View File
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -1,9 +1,12 @@
package global
import (
"gin-vue-admin/utils/timer"
"go.uber.org/zap"
"gin-vue-admin/config"
"github.com/go-redis/redis"
"github.com/spf13/viper"
"gorm.io/gorm"
@@ -15,5 +18,6 @@ var (
GVA_CONFIG config.Server
GVA_VP *viper.Viper
//GVA_LOG *oplogging.Logger
GVA_LOG *zap.Logger
GVA_LOG *zap.Logger
GVA_Timer timer.Timer = timer.NewTimerTask()
)
+13
View File
@@ -0,0 +1,13 @@
package global
import (
"gorm.io/gorm"
"time"
)
type GVA_MODEL struct {
ID uint `gorm:"primarykey"` // 主键ID
CreatedAt time.Time // 创建时间
UpdatedAt time.Time // 更新时间
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间
}
+13 -10
View File
@@ -1,11 +1,13 @@
module gin-vue-admin
go 1.12
go 1.14
require (
github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.2
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/casbin/casbin v1.9.1
github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/casbin/casbin/v2 v2.11.0
github.com/casbin/gorm-adapter/v3 v3.0.2
github.com/dgrijalva/jwt-go v3.2.0+incompatible
@@ -20,6 +22,7 @@ require (
github.com/go-redis/redis v6.15.7+incompatible
github.com/go-sql-driver/mysql v1.5.0
github.com/golang/protobuf v1.4.2 // indirect
github.com/gookit/color v1.3.1
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect
github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84
github.com/json-iterator/go v1.1.10 // indirect
@@ -33,25 +36,25 @@ require (
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/qiniu/api.v7/v7 v7.4.1
github.com/robfig/cron/v3 v3.0.1
github.com/satori/go.uuid v1.2.0
github.com/shirou/gopsutil v2.20.8+incompatible
github.com/shirou/gopsutil v3.21.1+incompatible
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.6.2
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.0
github.com/swaggo/gin-swagger v1.2.0
github.com/swaggo/swag v1.6.7
github.com/tebeka/strftime v0.1.3 // indirect
github.com/tencentyun/cos-go-sdk-v5 v0.7.19
github.com/unrolled/secure v1.0.7
go.uber.org/zap v1.10.0
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
golang.org/x/sys v0.0.0-20200610111108-226ff32320da // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
golang.org/x/tools v0.0.0-20200324003944-a576cf524670 // indirect
google.golang.org/protobuf v1.24.0 // indirect
gopkg.in/ini.v1 v1.55.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gorm.io/driver/mysql v0.3.0
gorm.io/driver/postgres v0.2.6
gorm.io/driver/sqlserver v0.2.4
gorm.io/gorm v1.20.1
gorm.io/driver/mysql v1.0.1
gorm.io/gorm v1.20.7
)
-497
View File
@@ -1,497 +0,0 @@
package init_data
import (
"gin-vue-admin/global"
"gin-vue-admin/model"
gormadapter "github.com/casbin/gorm-adapter/v3"
"github.com/satori/go.uuid"
"go.uber.org/zap"
"gorm.io/gorm"
"time"
)
type SysAuthorityMenus struct {
SysAuthorityAuthorityId string
SysBaseMenuId uint
}
type SysDataAuthorityId struct {
SysAuthorityAuthorityId string
DataAuthorityIdAuthorityId string
}
func InitSysApi() (err error) {
tx := global.GVA_DB.Begin() // 开始事务
insert := []model.SysApi{
{gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/base/login", "用户登录", "base", "POST"},
{gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/register", "用户注册", "user", "POST"},
{gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/createApi", "创建api", "api", "POST"},
{gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getApiList", "获取api列表", "api", "POST"},
{gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getApiById", "获取api详细信息", "api", "POST"},
{gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/deleteApi", "删除Api", "api", "POST"},
{gorm.Model{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/updateApi", "更新Api", "api", "POST"},
{gorm.Model{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getAllApis", "获取所有api", "api", "POST"},
{gorm.Model{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/createAuthority", "创建角色", "authority", "POST"},
{gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/deleteAuthority", "删除角色", "authority", "POST"},
{gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/getAuthorityList", "获取角色列表", "authority", "POST"},
{gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenu", "获取菜单树", "menu", "POST"},
{gorm.Model{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenuList", "分页获取基础menu列表", "menu", "POST"},
{gorm.Model{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/addBaseMenu", "新增菜单", "menu", "POST"},
{gorm.Model{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getBaseMenuTree", "获取用户动态路由", "menu", "POST"},
{gorm.Model{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/addMenuAuthority", "增加menu和角色关联关系", "menu", "POST"},
{gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenuAuthority", "获取指定角色menu", "menu", "POST"},
{gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/deleteBaseMenu", "删除菜单", "menu", "POST"},
{gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/updateBaseMenu", "更新菜单", "menu", "POST"},
{gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getBaseMenuById", "根据id获取菜单", "menu", "POST"},
{gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/changePassword", "修改密码", "user", "POST"},
{gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/getUserList", "获取用户列表", "user", "POST"},
{gorm.Model{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserAuthority", "修改用户角色", "user", "POST"},
{gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/upload", "文件上传示例", "fileUploadAndDownload", "POST"},
{gorm.Model{ID: 26, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/getFileList", "获取上传文件列表", "fileUploadAndDownload", "POST"},
{gorm.Model{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/updateCasbin", "更改角色api权限", "casbin", "POST"},
{gorm.Model{ID: 28, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/getPolicyPathByAuthorityId", "获取权限列表", "casbin", "POST"},
{gorm.Model{ID: 29, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/deleteFile", "删除文件", "fileUploadAndDownload", "POST"},
{gorm.Model{ID: 30, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/jwt/jsonInBlacklist", "jwt加入黑名单", "jwt", "POST"},
{gorm.Model{ID: 31, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/setDataAuthority", "设置角色资源权限", "authority", "POST"},
{gorm.Model{ID: 32, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getSystemConfig", "获取配置文件内容", "system", "POST"},
{gorm.Model{ID: 33, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/setSystemConfig", "设置配置文件内容", "system", "POST"},
{gorm.Model{ID: 34, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "创建客户", "customer", "POST"},
{gorm.Model{ID: 35, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "更新客户", "customer", "PUT"},
{gorm.Model{ID: 36, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "删除客户", "customer", "DELETE"},
{gorm.Model{ID: 37, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "获取单一客户", "customer", "GET"},
{gorm.Model{ID: 38, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customerList", "获取客户列表", "customer", "GET"},
{gorm.Model{ID: 39, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/casbinTest/:pathParam", "RESTFUL模式测试", "casbin", "GET"},
{gorm.Model{ID: 40, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/createTemp", "自动化代码", "autoCode", "POST"},
{gorm.Model{ID: 41, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/updateAuthority", "更新角色信息", "authority", "PUT"},
{gorm.Model{ID: 42, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/copyAuthority", "拷贝角色", "authority", "POST"},
{gorm.Model{ID: 43, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/deleteUser", "删除用户", "user", "DELETE"},
{gorm.Model{ID: 44, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/createSysDictionaryDetail", "新增字典内容", "sysDictionaryDetail", "POST"},
{gorm.Model{ID: 45, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/deleteSysDictionaryDetail", "删除字典内容", "sysDictionaryDetail", "DELETE"},
{gorm.Model{ID: 46, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/updateSysDictionaryDetail", "更新字典内容", "sysDictionaryDetail", "PUT"},
{gorm.Model{ID: 47, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/findSysDictionaryDetail", "根据ID获取字典内容", "sysDictionaryDetail", "GET"},
{gorm.Model{ID: 48, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/getSysDictionaryDetailList", "获取字典内容列表", "sysDictionaryDetail", "GET"},
{gorm.Model{ID: 49, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/createSysDictionary", "新增字典", "sysDictionary", "POST"},
{gorm.Model{ID: 50, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/deleteSysDictionary", "删除字典", "sysDictionary", "DELETE"},
{gorm.Model{ID: 51, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/updateSysDictionary", "更新字典", "sysDictionary", "PUT"},
{gorm.Model{ID: 52, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/findSysDictionary", "根据ID获取字典", "sysDictionary", "GET"},
{gorm.Model{ID: 53, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/getSysDictionaryList", "获取字典列表", "sysDictionary", "GET"},
{gorm.Model{ID: 54, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/createSysOperationRecord", "新增操作记录", "sysOperationRecord", "POST"},
{gorm.Model{ID: 55, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecord", "删除操作记录", "sysOperationRecord", "DELETE"},
{gorm.Model{ID: 56, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/findSysOperationRecord", "根据ID获取操作记录", "sysOperationRecord", "GET"},
{gorm.Model{ID: 57, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/getSysOperationRecordList", "获取操作记录列表", "sysOperationRecord", "GET"},
{gorm.Model{ID: 58, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getTables", "获取数据库表", "autoCode", "GET"},
{gorm.Model{ID: 59, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getDB", "获取所有数据库", "autoCode", "GET"},
{gorm.Model{ID: 60, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getColume", "获取所选table的所有字段", "autoCode", "GET"},
{gorm.Model{ID: 61, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecordByIds", "批量删除操作历史", "sysOperationRecord", "DELETE"},
{gorm.Model{ID: 62, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/upload", "插件版分片上传", "simpleUploader", "POST"},
{gorm.Model{ID: 63, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/checkFileMd5", "文件完整度验证", "simpleUploader", "GET"},
{gorm.Model{ID: 64, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/mergeFileMd5", "上传完成合并文件", "simpleUploader", "GET"},
{gorm.Model{ID: 65, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserInfo", "设置用户信息", "user", "PUT"},
{gorm.Model{ID: 66, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getServerInfo", "获取服务器信息", "system", "POST"},
{gorm.Model{ID: 67, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/email/emailTest", "发送测试邮件", "email", "POST"},
}
if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitSysUser() (err error) {
tx := global.GVA_DB.Begin() // 开始事务
insert := []model.SysUser{
{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "http://qmplusimg.henrongyi.top/1571627762timg.jpg", AuthorityId: "888"},
{Model: gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "http://qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"},
}
if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitExaCustomer() (err error) {
tx := global.GVA_DB.Begin() // 开始事务
insert := []model.ExaCustomer{
{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, CustomerName: "测试客户", CustomerPhoneData: "1761111111", SysUserID: 1, SysUserAuthorityID: "888"},
}
if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitCasbinModel() (err error) {
if !global.GVA_DB.Migrator().HasTable("casbin_rule") {
if err := global.GVA_DB.Migrator().CreateTable(&gormadapter.CasbinRule{}); err != nil {
return err
}
}
tx := global.GVA_DB.Begin() // 开始事务
insert := []model.CasbinModel{
{"p", "888", "/base/login", "POST"},
{"p", "888", "/user/register", "POST"},
{"p", "888", "/api/createApi", "POST"},
{"p", "888", "/api/getApiList", "POST"},
{"p", "888", "/api/getApiById", "POST"},
{"p", "888", "/api/deleteApi", "POST"},
{"p", "888", "/api/updateApi", "POST"},
{"p", "888", "/api/getAllApis", "POST"},
{"p", "888", "/authority/createAuthority", "POST"},
{"p", "888", "/authority/deleteAuthority", "POST"},
{"p", "888", "/authority/getAuthorityList", "POST"},
{"p", "888", "/authority/setDataAuthority", "POST"},
{"p", "888", "/authority/updateAuthority", "PUT"},
{"p", "888", "/authority/copyAuthority", "POST"},
{"p", "888", "/menu/getMenu", "POST"},
{"p", "888", "/menu/getMenuList", "POST"},
{"p", "888", "/menu/addBaseMenu", "POST"},
{"p", "888", "/menu/getBaseMenuTree", "POST"},
{"p", "888", "/menu/addMenuAuthority", "POST"},
{"p", "888", "/menu/getMenuAuthority", "POST"},
{"p", "888", "/menu/deleteBaseMenu", "POST"},
{"p", "888", "/menu/updateBaseMenu", "POST"},
{"p", "888", "/menu/getBaseMenuById", "POST"},
{"p", "888", "/user/changePassword", "POST"},
{"p", "888", "/user/getUserList", "POST"},
{"p", "888", "/user/setUserAuthority", "POST"},
{"p", "888", "/user/deleteUser", "DELETE"},
{"p", "888", "/fileUploadAndDownload/upload", "POST"},
{"p", "888", "/fileUploadAndDownload/getFileList", "POST"},
{"p", "888", "/fileUploadAndDownload/deleteFile", "POST"},
{"p", "888", "/casbin/updateCasbin", "POST"},
{"p", "888", "/casbin/getPolicyPathByAuthorityId", "POST"},
{"p", "888", "/casbin/casbinTest/:pathParam", "GET"},
{"p", "888", "/jwt/jsonInBlacklist", "POST"},
{"p", "888", "/system/getSystemConfig", "POST"},
{"p", "888", "/system/setSystemConfig", "POST"},
{"p", "888", "/system/getServerInfo", "POST"},
{"p", "888", "/customer/customer", "POST"},
{"p", "888", "/customer/customer", "PUT"},
{"p", "888", "/customer/customer", "DELETE"},
{"p", "888", "/customer/customer", "GET"},
{"p", "888", "/customer/customerList", "GET"},
{"p", "888", "/autoCode/createTemp", "POST"},
{"p", "888", "/autoCode/getTables", "GET"},
{"p", "888", "/autoCode/getDB", "GET"},
{"p", "888", "/autoCode/getColume", "GET"},
{"p", "888", "/sysDictionaryDetail/createSysDictionaryDetail", "POST"},
{"p", "888", "/sysDictionaryDetail/deleteSysDictionaryDetail", "DELETE"},
{"p", "888", "/sysDictionaryDetail/updateSysDictionaryDetail", "PUT"},
{"p", "888", "/sysDictionaryDetail/findSysDictionaryDetail", "GET"},
{"p", "888", "/sysDictionaryDetail/getSysDictionaryDetailList", "GET"},
{"p", "888", "/sysDictionary/createSysDictionary", "POST"},
{"p", "888", "/sysDictionary/deleteSysDictionary", "DELETE"},
{"p", "888", "/sysDictionary/updateSysDictionary", "PUT"},
{"p", "888", "/sysDictionary/findSysDictionary", "GET"},
{"p", "888", "/sysDictionary/getSysDictionaryList", "GET"},
{"p", "888", "/sysOperationRecord/createSysOperationRecord", "POST"},
{"p", "888", "/sysOperationRecord/deleteSysOperationRecord", "DELETE"},
{"p", "888", "/sysOperationRecord/updateSysOperationRecord", "PUT"},
{"p", "888", "/sysOperationRecord/findSysOperationRecord", "GET"},
{"p", "888", "/sysOperationRecord/getSysOperationRecordList", "GET"},
{"p", "888", "/sysOperationRecord/deleteSysOperationRecordByIds", "DELETE"},
{"p", "888", "/user/setUserInfo", "PUT"},
{"p", "888", "/email/emailTest", "POST"},
{"p", "8881", "/base/login", "POST"},
{"p", "8881", "/user/register", "POST"},
{"p", "8881", "/api/createApi", "POST"},
{"p", "8881", "/api/getApiList", "POST"},
{"p", "8881", "/api/getApiById", "POST"},
{"p", "8881", "/api/deleteApi", "POST"},
{"p", "8881", "/api/updateApi", "POST"},
{"p", "8881", "/api/getAllApis", "POST"},
{"p", "8881", "/authority/createAuthority", "POST"},
{"p", "8881", "/authority/deleteAuthority", "POST"},
{"p", "8881", "/authority/getAuthorityList", "POST"},
{"p", "8881", "/authority/setDataAuthority", "POST"},
{"p", "8881", "/menu/getMenu", "POST"},
{"p", "8881", "/menu/getMenuList", "POST"},
{"p", "8881", "/menu/addBaseMenu", "POST"},
{"p", "8881", "/menu/getBaseMenuTree", "POST"},
{"p", "8881", "/menu/addMenuAuthority", "POST"},
{"p", "8881", "/menu/getMenuAuthority", "POST"},
{"p", "8881", "/menu/deleteBaseMenu", "POST"},
{"p", "8881", "/menu/updateBaseMenu", "POST"},
{"p", "8881", "/menu/getBaseMenuById", "POST"},
{"p", "8881", "/user/changePassword", "POST"},
{"p", "8881", "/user/getUserList", "POST"},
{"p", "8881", "/user/setUserAuthority", "POST"},
{"p", "8881", "/fileUploadAndDownload/upload", "POST"},
{"p", "8881", "/fileUploadAndDownload/getFileList", "POST"},
{"p", "8881", "/fileUploadAndDownload/deleteFile", "POST"},
{"p", "8881", "/casbin/updateCasbin", "POST"},
{"p", "8881", "/casbin/getPolicyPathByAuthorityId", "POST"},
{"p", "8881", "/jwt/jsonInBlacklist", "POST"},
{"p", "8881", "/system/getSystemConfig", "POST"},
{"p", "8881", "/system/setSystemConfig", "POST"},
{"p", "8881", "/customer/customer", "POST"},
{"p", "8881", "/customer/customer", "PUT"},
{"p", "8881", "/customer/customer", "DELETE"},
{"p", "8881", "/customer/customer", "GET"},
{"p", "8881", "/customer/customerList", "GET"},
{"p", "9528", "/base/login", "POST"},
{"p", "9528", "/user/register", "POST"},
{"p", "9528", "/api/createApi", "POST"},
{"p", "9528", "/api/getApiList", "POST"},
{"p", "9528", "/api/getApiById", "POST"},
{"p", "9528", "/api/deleteApi", "POST"},
{"p", "9528", "/api/updateApi", "POST"},
{"p", "9528", "/api/getAllApis", "POST"},
{"p", "9528", "/authority/createAuthority", "POST"},
{"p", "9528", "/authority/deleteAuthority", "POST"},
{"p", "9528", "/authority/getAuthorityList", "POST"},
{"p", "9528", "/authority/setDataAuthority", "POST"},
{"p", "9528", "/menu/getMenu", "POST"},
{"p", "9528", "/menu/getMenuList", "POST"},
{"p", "9528", "/menu/addBaseMenu", "POST"},
{"p", "9528", "/menu/getBaseMenuTree", "POST"},
{"p", "9528", "/menu/addMenuAuthority", "POST"},
{"p", "9528", "/menu/getMenuAuthority", "POST"},
{"p", "9528", "/menu/deleteBaseMenu", "POST"},
{"p", "9528", "/menu/updateBaseMenu", "POST"},
{"p", "9528", "/menu/getBaseMenuById", "POST"},
{"p", "9528", "/user/changePassword", "POST"},
{"p", "9528", "/user/getUserList", "POST"},
{"p", "9528", "/user/setUserAuthority", "POST"},
{"p", "9528", "/fileUploadAndDownload/upload", "POST"},
{"p", "9528", "/fileUploadAndDownload/getFileList", "POST"},
{"p", "9528", "/fileUploadAndDownload/deleteFile", "POST"},
{"p", "9528", "/casbin/updateCasbin", "POST"},
{"p", "9528", "/casbin/getPolicyPathByAuthorityId", "POST"},
{"p", "9528", "/jwt/jsonInBlacklist", "POST"},
{"p", "9528", "/system/getSystemConfig", "POST"},
{"p", "9528", "/system/setSystemConfig", "POST"},
{"p", "9528", "/customer/customer", "POST"},
{"p", "9528", "/customer/customer", "PUT"},
{"p", "9528", "/customer/customer", "DELETE"},
{"p", "9528", "/customer/customer", "GET"},
{"p", "9528", "/customer/customerList", "GET"},
{"p", "9528", "/autoCode/createTemp", "POST"},
}
if tx.Table("casbin_rule").Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitSysAuthority() (err error) {
tx := global.GVA_DB.Begin() // 开始事务
insert := []model.SysAuthority{
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0"},
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888"},
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0"},
}
if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitSysBaseMenus() (err error) {
tx := global.GVA_DB.Begin() // 开始事务
insert := []model.SysBaseMenu{
{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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.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: model.Meta{Title: "断点续传(插件版)", Icon: "upload"}},
{Model: gorm.Model{ID: 26, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "https://www.gin-vue-admin.com", Name: "https://www.gin-vue-admin.com", Hidden: false, Component: "/", Sort: 0, Meta: model.Meta{Title: "官方网站", Icon: "s-home"}},
{Model: gorm.Model{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "state", Name: "state", Hidden: false, Component: "view/system/state.vue", Sort: 6, Meta: model.Meta{Title: "服务器状态", Icon: "cloudy"}},
}
if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitAuthorityMenu() (err error) {
return global.GVA_DB.Exec("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`)))").Error
}
func InitSysDictionary() (err error) {
status := new(bool)
*status = true
tx := global.GVA_DB.Begin() // 开始事务
insert := []model.SysDictionary{
{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "性别", Type: "sex", Status: status, Desc: "性别字典"},
{Model: gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库int类型", Type: "int", Status: status, Desc: "int类型对应的数据库类型"},
{Model: gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库时间日期类型", Type: "time.Time", Status: status, Desc: "数据库时间日期类型"},
{Model: gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库浮点型", Type: "float64", Status: status, Desc: "数据库浮点型"},
{Model: gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库字符串", Type: "string", Status: status, Desc: "数据库字符串"},
{Model: gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库bool类型", Type: "bool", Status: status, Desc: "数据库bool类型"},
}
if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitSysAuthorityMenus() (err error) {
tx := global.GVA_DB.Begin() // 开始事务
insert := []SysAuthorityMenus{
{"888", 1},
{"888", 2},
{"888", 3},
{"888", 4},
{"888", 5},
{"888", 6},
{"888", 7},
{"888", 8},
{"888", 9},
{"888", 10},
{"888", 11},
{"888", 12},
{"888", 13},
{"888", 14},
{"888", 15},
{"888", 16},
{"888", 17},
{"888", 18},
{"888", 19},
{"888", 20},
{"888", 21},
{"888", 22},
{"888", 23},
{"888", 24},
{"888", 25},
{"888", 26},
{"888", 27},
{"8881", 1},
{"8881", 2},
{"8881", 8},
{"8881", 17},
{"8881", 18},
{"8881", 19},
{"8881", 20},
{"9528", 1},
{"9528", 2},
{"9528", 3},
{"9528", 4},
{"9528", 5},
{"9528", 6},
{"9528", 7},
{"9528", 8},
{"9528", 9},
{"9528", 10},
{"9528", 11},
{"9528", 12},
{"9528", 13},
{"9528", 14},
{"9528", 15},
{"9528", 17},
{"9528", 18},
{"9528", 19},
{"9528", 20},
}
if tx.Table("sys_authority_menus").Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitSysDataAuthorityId() (err error) {
tx := global.GVA_DB.Begin() // 开始事务
insert := []SysDataAuthorityId{
{"888", "888"},
{"888", "8881"},
{"888", "9528"},
{"9528", "8881"},
{"9528", "9528"},
}
if global.GVA_DB.Migrator().HasTable("sys_data_authority_ids") {
if tx.Table("sys_data_authority_ids").Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
if tx.Table("sys_data_authority_id").Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitSysDictionaryDetail() (err error) {
status := new(bool)
*status = true
tx := global.GVA_DB.Begin() // 开始事务
insert := []model.SysDictionaryDetail{
{gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "smallint", 1, status, 1, 2},
{gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumint", 2, status, 2, 2},
{gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "int", 3, status, 3, 2},
{gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "bigint", 4, status, 4, 2},
{gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "data", 0, status, 0, 3},
{gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "time", 1, status, 1, 3},
{gorm.Model{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "year", 2, status, 2, 3},
{gorm.Model{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "datetime", 3, status, 3, 3},
{gorm.Model{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "timestamp", 5, status, 5, 3},
{gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "float", 0, status, 0, 4},
{gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "double", 1, status, 1, 4},
{gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "decimal", 2, status, 2, 4},
{gorm.Model{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "char", 0, status, 0, 5},
{gorm.Model{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "varchar", 1, status, 1, 5},
{gorm.Model{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyblob", 2, status, 2, 5},
{gorm.Model{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinytext", 3, status, 3, 5},
{gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "text", 4, status, 4, 5},
{gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "blob", 5, status, 5, 5},
{gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumblob", 6, status, 6, 5},
{gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumtext", 7, status, 7, 5},
{gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "longblob", 8, status, 8, 5},
{gorm.Model{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "longtext", 9, status, 9, 5},
{gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyint", 0, status, 0, 6},
}
if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitExaFileUploadAndDownload() (err error) {
tx := global.GVA_DB.Begin() // 开始事务
insert := []model.ExaFileUploadAndDownload{
{gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "10.png", "http://qmplusimg.henrongyi.top/gvalogo.png", "png", "158787308910.png"},
{gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "logo.png", "http://qmplusimg.henrongyi.top/1576554439myAvatar.png", "png", "1587973709logo.png"},
}
if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
func InitData() {
var err error
err = InitSysApi()
err = InitSysUser()
err = InitExaCustomer()
err = InitCasbinModel()
err = InitSysAuthority()
err = InitSysBaseMenus()
err = InitAuthorityMenu()
err = InitSysDictionary()
err = InitSysAuthorityMenus()
err = InitSysDataAuthorityId()
err = InitSysDictionaryDetail()
err = InitExaFileUploadAndDownload()
if err != nil {
global.GVA_LOG.Error("initialize data failed", zap.Any("err", err))
}
global.GVA_LOG.Info("initialize data success")
}
+61 -87
View File
@@ -2,36 +2,37 @@ package initialize
import (
"gin-vue-admin/global"
"gin-vue-admin/initialize/internal"
"gin-vue-admin/model"
"os"
"go.uber.org/zap"
"gorm.io/driver/mysql"
"gorm.io/driver/postgres"
"gorm.io/driver/sqlserver"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"os"
)
var err error
//@author: SliverHorn
//@function: Gorm
//@description: 初始化数据库并产生数据库全局变量
//@return: *gorm.DB
// Gorm 初始化数据库并产生数据库全局变量
func Gorm() {
func Gorm() *gorm.DB {
switch global.GVA_CONFIG.System.DbType {
case "mysql":
GormMysql()
case "postgresql":
GormPostgreSql()
//case "sqlite": // sqlite需要gcc支持 windows用户需要自行安装gcc 如需使用打开注释即可
// GormSqlite()
case "sqlserver":
GormSqlServer()
return GormMysql()
default:
GormMysql()
return GormMysql()
}
}
// GormDBTables 注册数据库表专用
func GormDBTables(db *gorm.DB) {
// MysqlTables
//@author: SliverHorn
//@function: MysqlTables
//@description: 注册数据库表专用
//@param: db *gorm.DB
func MysqlTables(db *gorm.DB) {
err := db.AutoMigrate(
model.SysUser{},
model.SysAuthority{},
@@ -39,8 +40,6 @@ func GormDBTables(db *gorm.DB) {
model.SysBaseMenu{},
model.SysBaseMenuParameter{},
model.JwtBlacklist{},
model.SysWorkflow{},
model.SysWorkflowStepInfo{},
model.SysDictionary{},
model.SysDictionaryDetail{},
model.ExaFileUploadAndDownload{},
@@ -49,6 +48,9 @@ func GormDBTables(db *gorm.DB) {
model.ExaSimpleUploader{},
model.ExaCustomer{},
model.SysOperationRecord{},
// Code generated by gin-vue-admin Begin; DO NOT EDIT.
// Code generated by gin-vue-admin End; DO NOT EDIT.
)
if err != nil {
global.GVA_LOG.Error("register table failed", zap.Any("err", err))
@@ -57,9 +59,17 @@ func GormDBTables(db *gorm.DB) {
global.GVA_LOG.Info("register table success")
}
// GormMysql 初始化Mysql数据库
func GormMysql() {
//
//@author: SliverHorn
//@function: GormMysql
//@description: 初始化Mysql数据库
//@return: *gorm.DB
func GormMysql() *gorm.DB {
m := global.GVA_CONFIG.Mysql
if m.Dbname == "" {
return nil
}
dsn := m.Username + ":" + m.Password + "@tcp(" + m.Path + ")/" + m.Dbname + "?" + m.Config
mysqlConfig := mysql.Config{
DSN: dsn, // DSN data source name
@@ -69,80 +79,44 @@ func GormMysql() {
DontSupportRenameColumn: true, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列
SkipInitializeWithVersion: false, // 根据版本自动配置
}
gormConfig := config(m.LogMode)
if global.GVA_DB, err = gorm.Open(mysql.New(mysqlConfig), gormConfig); err != nil {
global.GVA_LOG.Error("MySQL启动异常", zap.Any("err", err))
os.Exit(0)
if db, err := gorm.Open(mysql.New(mysqlConfig), gormConfig(m.LogMode)); err != nil {
//global.GVA_LOG.Error("MySQL启动异常", zap.Any("err", err))
//os.Exit(0)
//return nil
return nil
} else {
GormDBTables(global.GVA_DB)
sqlDB, _ := global.GVA_DB.DB()
sqlDB, _ := db.DB()
sqlDB.SetMaxIdleConns(m.MaxIdleConns)
sqlDB.SetMaxOpenConns(m.MaxOpenConns)
return db
}
}
// GormPostgreSql 初始化PostgreSql数据库
func GormPostgreSql() {
p := global.GVA_CONFIG.Postgresql
dsn := "host="+ p.Host + " user=" + p.Username + " password=" + p.Password + " dbname=" + p.Dbname + " port=" + p.Port + " " + p.Config
postgresConfig := postgres.Config{
DSN: dsn, // DSN data source name
PreferSimpleProtocol: p.PreferSimpleProtocol, // 禁用隐式 prepared statement
}
gormConfig := config(p.Logger)
if global.GVA_DB, err = gorm.Open(postgres.New(postgresConfig), gormConfig); err != nil {
global.GVA_LOG.Error("PostgreSql启动异常", zap.Any("err", err))
os.Exit(0)
} else {
GormDBTables(global.GVA_DB)
sqlDB, _ := global.GVA_DB.DB()
sqlDB.SetMaxIdleConns(p.MaxIdleConns)
sqlDB.SetMaxOpenConns(p.MaxOpenConns)
}
}
//@author: SliverHorn
//@function: gormConfig
//@description: 根据配置决定是否开启日志
//@param: mod bool
//@return: *gorm.Config
// GormSqlite 初始化Sqlite数据库 sqlite需要gcc支持 windows用户需要自行安装gcc 如需使用打开注释即可
//func GormSqlite() {
// s := global.GVA_CONFIG.Sqlite
// gormConfig := config(s.Logger)
// if global.GVA_DB, err = gorm.Open(sqlite.Open(s.Path), gormConfig); err != nil {
// global.GVA_LOG.Error("Sqlite启动异常", zap.Any("err", err))
// os.Exit(0)
// } else {
// GormDBTables(global.GVA_DB)
// sqlDB, _ := global.GVA_DB.DB()
// sqlDB.SetMaxIdleConns(s.MaxIdleConns)
// sqlDB.SetMaxOpenConns(s.MaxOpenConns)
// }
//}
// GormSqlServer 初始化SqlServer数据库
func GormSqlServer() {
ss := global.GVA_CONFIG.Sqlserver
dsn := "sqlserver://" + ss.Username + ":" + ss.Password + "@" + ss.Path + "?database=" + ss.Dbname
if global.GVA_DB, err = gorm.Open(sqlserver.Open(dsn), &gorm.Config{}); err != nil {
global.GVA_LOG.Error("SqlServer启动异常", zap.Any("err", err))
os.Exit(0)
} else {
GormDBTables(global.GVA_DB)
sqlDB, _ := global.GVA_DB.DB()
sqlDB.SetMaxIdleConns(ss.MaxIdleConns)
sqlDB.SetMaxOpenConns(ss.MaxOpenConns)
}
}
// config 根据配置决定是否开启日志
func config(mod bool) (c *gorm.Config) {
if mod {
c = &gorm.Config{
Logger: logger.Default.LogMode(logger.Info),
DisableForeignKeyConstraintWhenMigrating: true,
}
} else {
c = &gorm.Config{
Logger: logger.Default.LogMode(logger.Silent),
DisableForeignKeyConstraintWhenMigrating: true,
func gormConfig(mod bool) *gorm.Config {
var config = &gorm.Config{DisableForeignKeyConstraintWhenMigrating: true}
switch global.GVA_CONFIG.Mysql.LogZap {
case "silent", "Silent":
config.Logger = internal.Default.LogMode(logger.Silent)
case "error", "Error":
config.Logger = internal.Default.LogMode(logger.Error)
case "warn", "Warn":
config.Logger = internal.Default.LogMode(logger.Warn)
case "info", "Info":
config.Logger = internal.Default.LogMode(logger.Info)
case "zap", "Zap":
config.Logger = internal.Default.LogMode(logger.Info)
default:
if mod {
config.Logger = internal.Default.LogMode(logger.Info)
break
}
config.Logger = internal.Default.LogMode(logger.Silent)
}
return
return config
}
+182
View File
@@ -0,0 +1,182 @@
package internal
import (
"context"
"fmt"
"gin-vue-admin/global"
"go.uber.org/zap"
"gorm.io/gorm/logger"
"gorm.io/gorm/utils"
"io/ioutil"
"log"
"os"
"time"
)
// writer log writer interface
type writer interface {
Printf(string, ...interface{})
}
type config struct {
SlowThreshold time.Duration
Colorful bool
LogLevel logger.LogLevel
}
var (
Discard = New(log.New(ioutil.Discard, "", log.LstdFlags), config{})
Default = New(log.New(os.Stdout, "\r\n", log.LstdFlags), config{
SlowThreshold: 200 * time.Millisecond,
LogLevel: logger.Warn,
Colorful: true,
})
Recorder = traceRecorder{Interface: Default, BeginAt: time.Now()}
)
func New(writer writer, config config) logger.Interface {
var (
infoStr = "%s\n[info] "
warnStr = "%s\n[warn] "
errStr = "%s\n[error] "
traceStr = "%s\n[%.3fms] [rows:%v] %s"
traceWarnStr = "%s %s\n[%.3fms] [rows:%v] %s"
traceErrStr = "%s %s\n[%.3fms] [rows:%v] %s"
)
if config.Colorful {
infoStr = logger.Green + "%s\n" + logger.Reset + logger.Green + "[info] " + logger.Reset
warnStr = logger.BlueBold + "%s\n" + logger.Reset + logger.Magenta + "[warn] " + logger.Reset
errStr = logger.Magenta + "%s\n" + logger.Reset + logger.Red + "[error] " + logger.Reset
traceStr = logger.Green + "%s\n" + logger.Reset + logger.Yellow + "[%.3fms] " + logger.BlueBold + "[rows:%v]" + logger.Reset + " %s"
traceWarnStr = logger.Green + "%s " + logger.Yellow + "%s\n" + logger.Reset + logger.RedBold + "[%.3fms] " + logger.Yellow + "[rows:%v]" + logger.Magenta + " %s" + logger.Reset
traceErrStr = logger.RedBold + "%s " + logger.MagentaBold + "%s\n" + logger.Reset + logger.Yellow + "[%.3fms] " + logger.BlueBold + "[rows:%v]" + logger.Reset + " %s"
}
return &customLogger{
writer: writer,
config: config,
infoStr: infoStr,
warnStr: warnStr,
errStr: errStr,
traceStr: traceStr,
traceWarnStr: traceWarnStr,
traceErrStr: traceErrStr,
}
}
type customLogger struct {
writer
config
infoStr, warnStr, errStr string
traceStr, traceErrStr, traceWarnStr string
}
// LogMode log mode
func (c *customLogger) LogMode(level logger.LogLevel) logger.Interface {
newLogger := *c
newLogger.LogLevel = level
return &newLogger
}
// Info print info
func (c *customLogger) Info(ctx context.Context, message string, data ...interface{}) {
if c.LogLevel >= logger.Info {
c.Printf(c.infoStr+message, append([]interface{}{utils.FileWithLineNum()}, data...)...)
}
}
// Warn print warn messages
func (c *customLogger) Warn(ctx context.Context, message string, data ...interface{}) {
if c.LogLevel >= logger.Warn {
c.Printf(c.warnStr+message, append([]interface{}{utils.FileWithLineNum()}, data...)...)
}
}
// Error print error messages
func (c *customLogger) Error(ctx context.Context, message string, data ...interface{}) {
if c.LogLevel >= logger.Error {
c.Printf(c.errStr+message, append([]interface{}{utils.FileWithLineNum()}, data...)...)
}
}
// Trace print sql message
func (c *customLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) {
if c.LogLevel > 0 {
elapsed := time.Since(begin)
switch {
case err != nil && c.LogLevel >= logger.Error:
sql, rows := fc()
if rows == -1 {
c.Printf(c.traceErrStr, utils.FileWithLineNum(), err, float64(elapsed.Nanoseconds())/1e6, "-", sql)
} else {
c.Printf(c.traceErrStr, utils.FileWithLineNum(), err, float64(elapsed.Nanoseconds())/1e6, rows, sql)
}
case elapsed > c.SlowThreshold && c.SlowThreshold != 0 && c.LogLevel >= logger.Warn:
sql, rows := fc()
slowLog := fmt.Sprintf("SLOW SQL >= %v", c.SlowThreshold)
if rows == -1 {
c.Printf(c.traceWarnStr, utils.FileWithLineNum(), slowLog, float64(elapsed.Nanoseconds())/1e6, "-", sql)
} else {
c.Printf(c.traceWarnStr, utils.FileWithLineNum(), slowLog, float64(elapsed.Nanoseconds())/1e6, rows, sql)
}
case c.LogLevel >= logger.Info:
sql, rows := fc()
if rows == -1 {
c.Printf(c.traceStr, utils.FileWithLineNum(), float64(elapsed.Nanoseconds())/1e6, "-", sql)
} else {
c.Printf(c.traceStr, utils.FileWithLineNum(), float64(elapsed.Nanoseconds())/1e6, rows, sql)
}
}
}
}
func (c *customLogger) Printf(message string, data ...interface{}) {
if global.GVA_CONFIG.Mysql.LogZap != "" {
switch len(data) {
case 0:
global.GVA_LOG.Info(message)
case 1:
global.GVA_LOG.Info("gorm", zap.Any("src", data[0]))
case 2:
global.GVA_LOG.Info("gorm", zap.Any("src", data[0]), zap.Any("duration", data[1]))
case 3:
global.GVA_LOG.Info("gorm", zap.Any("src", data[0]), zap.Any("duration", data[1]), zap.Any("rows", data[2]))
case 4:
global.GVA_LOG.Info("gorm", zap.Any("src", data[0]), zap.Any("duration", data[1]), zap.Any("rows", data[2]), zap.Any("sql", data[3]))
}
return
}
switch len(data) {
case 0:
c.writer.Printf(message, "")
case 1:
c.writer.Printf(message, data[0])
case 2:
c.writer.Printf(message, data[0], data[1])
case 3:
c.writer.Printf(message, data[0], data[1], data[2])
case 4:
c.writer.Printf(message, data[0], data[1], data[2], data[3])
case 5:
c.writer.Printf(message, data[0], data[1], data[2], data[3], data[4])
}
}
type traceRecorder struct {
logger.Interface
BeginAt time.Time
SQL string
RowsAffected int64
Err error
}
func (t traceRecorder) New() *traceRecorder {
return &traceRecorder{Interface: t.Interface, BeginAt: time.Now()}
}
func (t *traceRecorder) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) {
t.BeginAt = begin
t.SQL, t.RowsAffected = fc()
t.Err = err
}
+1 -1
View File
@@ -17,7 +17,7 @@ func Redis() {
if err != nil {
global.GVA_LOG.Error("redis connect ping failed, err:", zap.Any("err", err))
} else {
global.GVA_LOG.Info("redis connect ping response:", zap.String("pong",pong))
global.GVA_LOG.Info("redis connect ping response:", zap.String("pong", pong))
global.GVA_REDIS = client
}
}
+30 -20
View File
@@ -5,10 +5,11 @@ import (
"gin-vue-admin/global"
"gin-vue-admin/middleware"
"gin-vue-admin/router"
"net/http"
"github.com/gin-gonic/gin"
"github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
"net/http"
)
// 初始化总路由
@@ -19,30 +20,39 @@ func Routers() *gin.Engine {
// Router.Use(middleware.LoadTls()) // 打开就能玩https了
global.GVA_LOG.Info("use middleware logger")
// 跨域
Router.Use(middleware.Cors())
//Router.Use(middleware.Cors()) // 如需跨域可以打开
global.GVA_LOG.Info("use middleware cors")
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
global.GVA_LOG.Info("register swagger handler")
// 方便统一添加路由组前缀 多服务器上线使用
ApiGroup := Router.Group("")
router.InitUserRouter(ApiGroup) // 注册用户路由
router.InitBaseRouter(ApiGroup) // 注册基础功能路由 不做鉴权
router.InitMenuRouter(ApiGroup) // 注册menu路由
router.InitAuthorityRouter(ApiGroup) // 注册角色路由
router.InitApiRouter(ApiGroup) // 注册功能api路由
router.InitFileUploadAndDownloadRouter(ApiGroup) // 文件上传下载功能路由
router.InitSimpleUploaderRouter(ApiGroup) // 断点续传(插件版)
router.InitWorkflowRouter(ApiGroup) // 工作流相关路由
router.InitCasbinRouter(ApiGroup) // 权限相关路由
router.InitJwtRouter(ApiGroup) // jwt相关路由
router.InitSystemRouter(ApiGroup) // system相关路由
router.InitCustomerRouter(ApiGroup) // 客户路由
router.InitAutoCodeRouter(ApiGroup) // 创建自动化代码
router.InitSysDictionaryDetailRouter(ApiGroup) // 字典详情管理
router.InitSysDictionaryRouter(ApiGroup) // 字典管理
router.InitSysOperationRecordRouter(ApiGroup) // 操作记录
router.InitEmailRouter(ApiGroup) // 邮件相关路由
PublicGroup := Router.Group("")
{
router.InitBaseRouter(PublicGroup) // 注册基础功能路由 不做鉴权
router.InitInitRouter(PublicGroup) // 自动初始化相关
}
PrivateGroup := Router.Group("")
PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
{
router.InitApiRouter(PrivateGroup) // 注册功能api路由
router.InitJwtRouter(PrivateGroup) // jwt相关路由
router.InitUserRouter(PrivateGroup) // 注册用户路由
router.InitMenuRouter(PrivateGroup) // 注册menu路由
router.InitEmailRouter(PrivateGroup) // 邮件相关路由
router.InitSystemRouter(PrivateGroup) // system相关路由
router.InitCasbinRouter(PrivateGroup) // 权限相关路由
router.InitCustomerRouter(PrivateGroup) // 客户路由
router.InitAutoCodeRouter(PrivateGroup) // 创建自动化代码
router.InitAuthorityRouter(PrivateGroup) // 注册角色路由
router.InitSimpleUploaderRouter(PrivateGroup) // 断点续传(插件版)
router.InitSysDictionaryRouter(PrivateGroup) // 字典管理
router.InitSysOperationRecordRouter(PrivateGroup) // 操作记录
router.InitSysDictionaryDetailRouter(PrivateGroup) // 字典详情管理
router.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由
router.InitExcelRouter(PrivateGroup) // 表格导入导出
// Code generated by gin-vue-admin Begin; DO NOT EDIT.
// Code generated by gin-vue-admin End; DO NOT EDIT.
}
global.GVA_LOG.Info("router register success")
return Router
}
+24
View File
@@ -0,0 +1,24 @@
package initialize
import (
"fmt"
"gin-vue-admin/config"
"gin-vue-admin/global"
"gin-vue-admin/utils"
)
func Timer() {
if global.GVA_CONFIG.Timer.Start {
for _, detail := range global.GVA_CONFIG.Timer.Detail {
fmt.Println(detail)
go func(detail config.Detail) {
global.GVA_Timer.AddTaskByFunc("ClearDB", global.GVA_CONFIG.Timer.Spec, func() {
err := utils.ClearTable(global.GVA_DB, detail.TableName, detail.CompareField, detail.Interval)
if err != nil {
fmt.Println("timer error:", err)
}
})
}(detail)
}
}
}
+9 -8
View File
@@ -3,7 +3,6 @@ package main
import (
"gin-vue-admin/core"
"gin-vue-admin/global"
"gin-vue-admin/gva/init_data"
"gin-vue-admin/initialize"
)
@@ -15,13 +14,15 @@ import (
// @name x-token
// @BasePath /
func main() {
initialize.Gorm()
if global.GVA_CONFIG.System.NeedInitData {
init_data.InitData() // 通过配置文件初始化数据 默认为 false 首次运行需要将 ./config.yaml中 system下的 need-init-data 修改为true
global.GVA_VP = core.Viper() // 初始化Viper
global.GVA_LOG = core.Zap() // 初始化zap日志库
global.GVA_DB = initialize.Gorm() // gorm连接数据库
initialize.Timer()
if global.GVA_DB != nil {
initialize.MysqlTables(global.GVA_DB) // 初始化表
// 程序结束前关闭数据库链接
db, _ := global.GVA_DB.DB()
defer db.Close()
}
// 程序结束前关闭数据库链接
db, _ := global.GVA_DB.DB()
defer db.Close()
core.RunWindowsServer()
}
@@ -2,8 +2,8 @@ package middleware
import (
"gin-vue-admin/global"
"gin-vue-admin/global/response"
"gin-vue-admin/model/request"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"github.com/gin-gonic/gin"
)
@@ -25,7 +25,7 @@ func CasbinHandler() gin.HandlerFunc {
if global.GVA_CONFIG.System.Env == "develop" || success {
c.Next()
} else {
response.Result(response.ERROR, gin.H{}, "权限不足", c)
response.FailWithDetailed(gin.H{}, "权限不足", c)
c.Abort()
return
}
+1 -1
View File
@@ -11,7 +11,7 @@ func Cors() gin.HandlerFunc {
method := c.Request.Method
origin := c.Request.Header.Get("Origin")
c.Header("Access-Control-Allow-Origin", origin)
c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id\"")
c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id")
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS,DELETE,PUT")
c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")
c.Header("Access-Control-Allow-Credentials", "true")
+21 -31
View File
@@ -3,9 +3,9 @@ package middleware
import (
"errors"
"gin-vue-admin/global"
"gin-vue-admin/global/response"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
@@ -16,19 +16,15 @@ import (
func JWTAuth() gin.HandlerFunc {
return func(c *gin.Context) {
// 我们这里jwt鉴权取头部信息 x-token 登录时回返回token信息 这里前端需要把token存储到cookie或者本地localSstorage中 不过需要跟后端协商过期时间 可以约定刷新令牌或者重新登录
// 我们这里jwt鉴权取头部信息 x-token 登录时回返回token信息 这里前端需要把token存储到cookie或者本地localStorage中 不过需要跟后端协商过期时间 可以约定刷新令牌或者重新登录
token := c.Request.Header.Get("x-token")
if token == "" {
response.Result(response.ERROR, gin.H{
"reload": true,
}, "未登录或非法访问", c)
response.FailWithDetailed(gin.H{"reload": true}, "未登录或非法访问", c)
c.Abort()
return
}
if service.IsBlacklist(token) {
response.Result(response.ERROR, gin.H{
"reload": true,
}, "您的帐户异地登陆或令牌失效", c)
response.FailWithDetailed(gin.H{"reload": true}, "您的帐户异地登陆或令牌失效", c)
c.Abort()
return
}
@@ -37,40 +33,34 @@ func JWTAuth() gin.HandlerFunc {
claims, err := j.ParseToken(token)
if err != nil {
if err == TokenExpired {
response.Result(response.ERROR, gin.H{
"reload": true,
}, "授权已过期", c)
response.FailWithDetailed(gin.H{"reload": true}, "授权已过期", c)
c.Abort()
return
}
response.Result(response.ERROR, gin.H{
"reload": true,
}, err.Error(), c)
response.FailWithDetailed(gin.H{"reload": true}, err.Error(), c)
c.Abort()
return
}
if err, _ = service.FindUserByUuid(claims.UUID.String()); err != nil{
response.Result(response.ERROR, gin.H{
"reload": true,
}, err.Error(), c)
if err, _ = service.FindUserByUuid(claims.UUID.String()); err != nil {
_ = service.JsonInBlacklist(model.JwtBlacklist{Jwt: token})
response.FailWithDetailed(gin.H{"reload": true}, err.Error(), c)
c.Abort()
}
if claims.ExpiresAt - time.Now().Unix()<claims.BufferTime {
claims.ExpiresAt = time.Now().Unix() + 60*60*24*7
newToken,_ := j.CreateToken(*claims)
newClaims,_ := j.ParseToken(newToken)
c.Header("new-token",newToken)
c.Header("new-expires-at",strconv.FormatInt(newClaims.ExpiresAt,10))
if claims.ExpiresAt-time.Now().Unix() < claims.BufferTime {
claims.ExpiresAt = time.Now().Unix() + global.GVA_CONFIG.JWT.ExpiresTime
newToken, _ := j.CreateToken(*claims)
newClaims, _ := j.ParseToken(newToken)
c.Header("new-token", newToken)
c.Header("new-expires-at", strconv.FormatInt(newClaims.ExpiresAt, 10))
if global.GVA_CONFIG.System.UseMultipoint {
err,RedisJwtToken := service.GetRedisJWT(newClaims.Username)
if err!=nil {
global.GVA_LOG.Error("get redis jwt failed", zap.Any("err", err))
}else{
service.JsonInBlacklist(model.JwtBlacklist{Jwt: RedisJwtToken})
//当之前的取成功时才进行拉黑操作
err, RedisJwtToken := service.GetRedisJWT(newClaims.Username)
if err != nil {
global.GVA_LOG.Error("get redis jwt failed", zap.Any("err", err))
} else { // 当之前的取成功时才进行拉黑操作
_ = service.JsonInBlacklist(model.JwtBlacklist{Jwt: RedisJwtToken})
}
// 无论如何都要记录当前的活跃状态
_ = service.SetRedisJWT(newToken,newClaims.Username)
_ = service.SetRedisJWT(newToken, newClaims.Username)
}
}
c.Set("claims", claims)
+22
View File
@@ -0,0 +1,22 @@
package middleware
import (
"gin-vue-admin/global"
"gin-vue-admin/model/response"
"github.com/gin-gonic/gin"
)
// 处理跨域请求,支持options访问
func NeedInit() gin.HandlerFunc {
return func(c *gin.Context) {
if global.GVA_DB == nil {
response.OkWithDetailed(gin.H{
"needInit": true,
}, "前往初始化数据库", c)
c.Abort()
} else {
c.Next()
}
// 处理请求
}
}
+6 -6
View File
@@ -11,7 +11,6 @@ import (
"io/ioutil"
"net/http"
"strconv"
"strings"
"time"
)
@@ -31,7 +30,7 @@ func OperationRecord() gin.HandlerFunc {
if claims, ok := c.Get("claims"); ok {
waitUse := claims.(*request.CustomClaims)
userId = int(waitUse.ID)
}else {
} else {
id, err := strconv.Atoi(c.Request.Header.Get("x-user-id"))
if err != nil {
userId = 0
@@ -46,10 +45,11 @@ func OperationRecord() gin.HandlerFunc {
Body: string(body),
UserID: userId,
}
values := c.Request.Header.Values("content-type")
if len(values) >0 && strings.Contains(values[0], "boundary") {
record.Body = "file"
}
// 存在某些未知错误 TODO
//values := c.Request.Header.Values("content-type")
//if len(values) >0 && strings.Contains(values[0], "boundary") {
// record.Body = "file"
//}
writer := responseBodyWriter{
ResponseWriter: c.Writer,
body: &bytes.Buffer{},
+3 -3
View File
@@ -1,12 +1,12 @@
package model
import (
"gorm.io/gorm"
"gin-vue-admin/global"
)
// file struct, 文件结构体
type ExaFile struct {
gorm.Model
global.GVA_MODEL
FileName string
FileMd5 string
FilePath string
@@ -17,7 +17,7 @@ type ExaFile struct {
// file chunk struct, 切片结构体
type ExaFileChunk struct {
gorm.Model
global.GVA_MODEL
ExaFileID uint
FileChunkNumber int
FileChunkPath string
+7 -7
View File
@@ -1,14 +1,14 @@
package model
import (
"gorm.io/gorm"
"gin-vue-admin/global"
)
type ExaCustomer struct {
gorm.Model
CustomerName string `json:"customerName" form:"customerName" gorm:"comment:客户名"`
CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData" gorm:"comment:客户手机号"`
SysUserID uint `json:"sysUserId" form:"sysUserId" gorm:"comment:管理ID"`
SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:管理角色ID"`
SysUser SysUser `json:"sysUser" form:"sysUser" gorm:"comment:管理详情"`
global.GVA_MODEL
CustomerName string `json:"customerName" form:"customerName" gorm:"comment:客户名"` // 客户名
CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData" gorm:"comment:客户手机号"` // 客户手机号
SysUserID uint `json:"sysUserId" form:"sysUserId" gorm:"comment:管理ID"` // 管理ID
SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:管理角色ID"` // 管理角色ID
SysUser SysUser `json:"sysUser" form:"sysUser" gorm:"comment:管理详情"` // 管理详情
}
+6
View File
@@ -0,0 +1,6 @@
package model
type ExcelInfo struct {
FileName string `json:"fileName"` // 文件名
InfoList []SysBaseMenu `json:"infoList"`
}
+6 -6
View File
@@ -1,13 +1,13 @@
package model
import (
"gorm.io/gorm"
"gin-vue-admin/global"
)
type ExaFileUploadAndDownload struct {
gorm.Model
Name string `json:"name" gorm:"comment:文件名"`
Url string `json:"url" gorm:"comment:文件地址"`
Tag string `json:"tag" gorm:"comment:文件标签"`
Key string `json:"key" gorm:"comment:编号"`
global.GVA_MODEL
Name string `json:"name" gorm:"comment:文件名"` // 文件名
Url string `json:"url" gorm:"comment:文件地址"` // 文件地址
Tag string `json:"tag" gorm:"comment:文件标签"` // 文件标签
Key string `json:"key" gorm:"comment:编号"` // 编号
}
+11 -4
View File
@@ -2,15 +2,22 @@ package request
// Paging common input parameter structure
type PageInfo struct {
Page int `json:"page" form:"page"`
PageSize int `json:"pageSize" form:"pageSize"`
Page int `json:"page" form:"page"` // 页码
PageSize int `json:"pageSize" form:"pageSize"` // 每页大小
}
// Find by id structure
type GetById struct {
Id float64 `json:"id" form:"id"`
ID float64 `json:"id" form:"id"` // 主键ID
}
type IdsReq struct {
Ids []int `json:"ids" form:"ids"`
}
}
// Get role by id structure
type GetAuthorityId struct {
AuthorityId string // 角色ID
}
type Empty struct{}
+2 -2
View File
@@ -6,6 +6,6 @@ import "gin-vue-admin/model"
type SearchApiParams struct {
model.SysApi
PageInfo
OrderKey string `json:"orderKey"`
Desc bool `json:"desc"`
OrderKey string `json:"orderKey"` // 排序
Desc bool `json:"desc"` // 排序方式:升序false(默认)|降序true
}
+6 -6
View File
@@ -1,16 +1,16 @@
package request
type DBReq struct {
Database string `json:"database";gorm:"column:database"`
Database string `json:"database" gorm:"column:database"`
}
type TableReq struct {
TableName string `json:"tableName"`
}
type ColumeReq struct {
ColumeName string `json:"columeName";gorm:"column:colume_name"`
DataType string `json:"dataType";gorm:"column:data_type"`
DataTypeLong string `json:"dataTypeLong";gorm:"column:data_type_long"`
ColumeComment string `json:"columeComment";gorm:"column:colume_comment"`
type ColumnReq struct {
ColumnName string `json:"columnName" gorm:"column:column_name"`
DataType string `json:"dataType" gorm:"column:data_type"`
DataTypeLong string `json:"dataTypeLong" gorm:"column:data_type_long"`
ColumnComment string `json:"columnComment" gorm:"column:column_comment"`
}
+3 -3
View File
@@ -2,12 +2,12 @@ package request
// Casbin info structure
type CasbinInfo struct {
Path string `json:"path"`
Method string `json:"method"`
Path string `json:"path"` // 路径
Method string `json:"method"` // 方法
}
// Casbin structure for input parameters
type CasbinInReceive struct {
AuthorityId string `json:"authorityId"`
AuthorityId string `json:"authorityId"` // 权限id
CasbinInfos []CasbinInfo `json:"casbinInfos"`
}
+4 -4
View File
@@ -2,7 +2,7 @@ package request
import "gin-vue-admin/model"
type SysDictionarySearch struct{
model.SysDictionary
PageInfo
}
type SysDictionarySearch struct {
model.SysDictionary
PageInfo
}
@@ -2,7 +2,7 @@ package request
import "gin-vue-admin/model"
type SysDictionaryDetailSearch struct{
model.SysDictionaryDetail
PageInfo
}
type SysDictionaryDetailSearch struct {
model.SysDictionaryDetail
PageInfo
}
+9
View File
@@ -0,0 +1,9 @@
package request
type InitDB struct {
Host string `json:"host"` // 服务器地址
Port string `json:"port"` // 数据库连接端口
UserName string `json:"userName" binding:"required"` // 数据库用户名
Password string `json:"password"` // 数据库密码
DBName string `json:"dbName" binding:"required"` // 数据库名
}
+1 -6
View File
@@ -5,10 +5,5 @@ import "gin-vue-admin/model"
// Add menu authority info structure
type AddMenuAuthorityInfo struct {
Menus []model.SysBaseMenu
AuthorityId string
}
// Get role by id structure
type AuthorityIdInfo struct {
AuthorityId string
AuthorityId string // 角色ID
}
+11 -11
View File
@@ -3,7 +3,7 @@ package request
import uuid "github.com/satori/go.uuid"
// User register structure
type RegisterStruct struct {
type Register struct {
Username string `json:"userName"`
Password string `json:"passWord"`
NickName string `json:"nickName" gorm:"default:'QMPlusUser'"`
@@ -12,22 +12,22 @@ type RegisterStruct struct {
}
// User login structure
type RegisterAndLoginStruct struct {
Username string `json:"username"`
Password string `json:"password"`
Captcha string `json:"captcha"`
CaptchaId string `json:"captchaId"`
type Login struct {
Username string `json:"username"` // 用户名
Password string `json:"password"` // 密码
Captcha string `json:"captcha"` // 验证码
CaptchaId string `json:"captchaId"` // 验证码ID
}
// Modify password structure
type ChangePasswordStruct struct {
Username string `json:"username"`
Password string `json:"password"`
NewPassword string `json:"newPassword"`
Username string `json:"username"` // 用户名
Password string `json:"password"` // 密码
NewPassword string `json:"newPassword"` // 新密码
}
// Modify user's auth structure
type SetUserAuth struct {
UUID uuid.UUID `json:"uuid"`
AuthorityId string `json:"authorityId"`
UUID uuid.UUID `json:"uuid"` // 用户UUID
AuthorityId string `json:"authorityId"` // 角色ID
}
@@ -37,7 +37,7 @@ func OkWithData(data interface{}, c *gin.Context) {
Result(SUCCESS, data, "操作成功", c)
}
func OkDetailed(data interface{}, message string, c *gin.Context) {
func OkWithDetailed(data interface{}, message string, c *gin.Context) {
Result(SUCCESS, data, message, c)
}
@@ -49,6 +49,6 @@ func FailWithMessage(message string, c *gin.Context) {
Result(ERROR, map[string]interface{}{}, message, c)
}
func FailWithDetailed(code int, data interface{}, message string, c *gin.Context) {
Result(code, data, message, c)
func FailWithDetailed(data interface{}, message string, c *gin.Context) {
Result(ERROR, data, message, c)
}
+1 -1
View File
@@ -8,5 +8,5 @@ type SysAuthorityResponse struct {
type SysAuthorityCopyResponse struct {
Authority model.SysAuthority `json:"authority"`
OldAuthorityId string `json:"oldAuthorityId"`
OldAuthorityId string `json:"oldAuthorityId"` // 旧角色ID
}
+6 -6
View File
@@ -1,13 +1,13 @@
package model
import (
"gorm.io/gorm"
"gin-vue-admin/global"
)
type SysApi struct {
gorm.Model
Path string `json:"path" gorm:"comment:api路径"`
Description string `json:"description" gorm:"comment:api中文描述"`
ApiGroup string `json:"apiGroup" gorm:"comment:api组"`
Method string `json:"method" gorm:"default:POST" gorm:"comment:方法"`
global.GVA_MODEL
Path string `json:"path" gorm:"comment:api路径"` // api路径
Description string `json:"description" gorm:"comment:api中文描述"` // api中文描述
ApiGroup string `json:"apiGroup" gorm:"comment:api组"` // api组
Method string `json:"method" gorm:"default:POST" gorm:"comment:方法"` // 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE
}
+6 -5
View File
@@ -5,13 +5,14 @@ import (
)
type SysAuthority struct {
CreatedAt time.Time
UpdatedAt time.Time
CreatedAt time.Time // 创建时间
UpdatedAt time.Time // 更新时间
DeletedAt *time.Time `sql:"index"`
AuthorityId string `json:"authorityId" gorm:"not null;unique;primary_key;comment:角色ID;size:90"`
AuthorityName string `json:"authorityName" gorm:"comment:角色名"`
ParentId string `json:"parentId" gorm:"comment:父角色ID"`
AuthorityId string `json:"authorityId" gorm:"not null;unique;primary_key;comment:角色ID;size:90"` // 角色ID
AuthorityName string `json:"authorityName" gorm:"comment:角色名"` // 角色名
ParentId string `json:"parentId" gorm:"comment:父角色ID"` // 父角色ID
DataAuthorityId []SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id"`
Children []SysAuthority `json:"children" gorm:"-"`
SysBaseMenus []SysBaseMenu `json:"menus" gorm:"many2many:sys_authority_menus;"`
DefaultRouter string `json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"` // 默认菜单(默认dashboard)
}
+22 -17
View File
@@ -1,25 +1,30 @@
package model
import "errors"
// 初始版本自动化代码工具
type AutoCodeStruct struct {
StructName string `json:"structName"`
TableName string `json:"tableName"`
PackageName string `json:"packageName"`
Abbreviation string `json:"abbreviation"`
Description string `json:"description"`
AutoCreateApiToSql bool `json:"autoCreateApiToSql"`
Fields []Field `json:"fields"`
StructName string `json:"structName"` // Struct名称
TableName string `json:"tableName"` // 表名
PackageName string `json:"packageName"` // 文件名称
Abbreviation string `json:"abbreviation"` // Struct简称
Description string `json:"description"` // Struct中文名称
AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api
AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件
Fields []*Field `json:"fields"`
}
type Field struct {
FieldName string `json:"fieldName"`
FieldDesc string `json:"fieldDesc"`
FieldType string `json:"fieldType"`
FieldJson string `json:"fieldJson"`
DataType string `json:"dataType"`
DataTypeLong string `json:"dataTypeLong"`
Comment string `json:"comment"`
ColumnName string `json:"columnName"`
FieldSearchType string `json:"fieldSearchType"`
DictType string `json:"dictType"`
FieldName string `json:"fieldName"` // Field名
FieldDesc string `json:"fieldDesc"` // 中文名
FieldType string `json:"fieldType"` // Field数据类型
FieldJson string `json:"fieldJson"` // FieldJson
DataType string `json:"dataType"` // 数据库字段类型
DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度
Comment string `json:"comment"` // 数据库字段描述
ColumnName string `json:"columnName"` // 数据库字段
FieldSearchType string `json:"fieldSearchType"` // 搜索条件
DictType string `json:"dictType"` // 字典
}
var AutoMoveErr error = errors.New("创建代码成功并移动文件成功")
+19 -18
View File
@@ -1,35 +1,36 @@
package model
import (
"gorm.io/gorm"
"gin-vue-admin/global"
)
type SysBaseMenu struct {
gorm.Model
MenuLevel uint `json:"-"`
ParentId string `json:"parentId" gorm:"comment:父菜单ID"`
Path string `json:"path" gorm:"comment:路由path"`
Name string `json:"name" gorm:"comment:路由name"`
Hidden bool `json:"hidden" gorm:"comment:是否在列表隐藏"`
Component string `json:"component" gorm:"comment:对应前端文件路径"`
Sort int `json:"sort" gorm:"comment:排序标记"`
Meta `json:"meta" gorm:"comment:附加属性"`
global.GVA_MODEL
MenuLevel uint `json:"-"`
ParentId string `json:"parentId" gorm:"comment:父菜单ID"` // 父菜单ID
Path string `json:"path" gorm:"comment:路由path"` // 路由path
Name string `json:"name" gorm:"comment:路由name"` // 路由name
Hidden bool `json:"hidden" gorm:"comment:是否在列表隐藏"` // 是否在列表隐藏
Component string `json:"component" gorm:"comment:对应前端文件路径"` // 对应前端文件路径
Sort int `json:"sort" gorm:"comment:排序标记"` // 排序标记
Meta `json:"meta" gorm:"comment:附加属性"` // 附加属性
SysAuthoritys []SysAuthority `json:"authoritys" gorm:"many2many:sys_authority_menus;"`
Children []SysBaseMenu `json:"children" gorm:"-"`
Parameters []SysBaseMenuParameter `json:"parameters"`
}
type Meta struct {
KeepAlive bool `json:"keepAlive" gorm:"comment:是否缓存"`
DefaultMenu bool `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"`
Title string `json:"title" gorm:"comment:菜单名"`
Icon string `json:"icon" gorm:"comment:菜单图标"`
KeepAlive bool `json:"keepAlive" gorm:"comment:是否缓存"` // 是否缓存
DefaultMenu bool `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"` // 是否是基础路由(开发中)
Title string `json:"title" gorm:"comment:菜单名"` // 菜单名
Icon string `json:"icon" gorm:"comment:菜单图标"` // 菜单图标
CloseTab bool `json:"closeTab" gorm:"comment:自动关闭tab"` // 自动关闭tab
}
type SysBaseMenuParameter struct {
gorm.Model
global.GVA_MODEL
SysBaseMenuID uint
Type string `json:"type" gorm:"commit:'地址栏携带参数为params还是query'"`
Key string `json:"key" gorm:"commit:'地址栏携带参数的key'"`
Value string `json:"value" gorm:"commit:'地址栏携带参数的值'"`
Type string `json:"type" gorm:"comment:地址栏携带参数为params还是query"` // 地址栏携带参数为params还是query
Key string `json:"key" gorm:"comment:地址栏携带参数的key"` // 地址栏携带参数的key
Value string `json:"value" gorm:"comment:地址栏携带参数的值"` // 地址栏携带参数的值
}
+1 -1
View File
@@ -1,7 +1,7 @@
package model
type CasbinModel struct {
Ptype string `json:"ptype" gorm:"column:p_type"`
Ptype string `json:"ptype" gorm:"column:ptype"`
AuthorityId string `json:"rolename" gorm:"column:v0"`
Path string `json:"path" gorm:"column:v1"`
Method string `json:"method" gorm:"column:v2"`
+6 -6
View File
@@ -2,15 +2,15 @@
package model
import (
"gorm.io/gorm"
"gin-vue-admin/global"
)
// 如果含有time.Time 请自行import time包
type SysDictionary struct {
gorm.Model
Name string `json:"name" form:"name" gorm:"column:name;comment:字典名(中)"`
Type string `json:"type" form:"type" gorm:"column:type;comment:字典名(英)"`
Status *bool `json:"status" form:"status" gorm:"column:status;comment:状态"`
Desc string `json:"desc" form:"desc" gorm:"column:desc;comment:描述"`
global.GVA_MODEL
Name string `json:"name" form:"name" gorm:"column:name;comment:字典名(中)"` // 字典名(中)
Type string `json:"type" form:"type" gorm:"column:type;comment:字典名(英)"` // 字典名(英)
Status *bool `json:"status" form:"status" gorm:"column:status;comment:状态"` // 状态
Desc string `json:"desc" form:"desc" gorm:"column:desc;comment:描述"` // 描述
SysDictionaryDetails []SysDictionaryDetail `json:"sysDictionaryDetails" form:"sysDictionaryDetails"`
}
+7 -7
View File
@@ -2,15 +2,15 @@
package model
import (
"gorm.io/gorm"
"gin-vue-admin/global"
)
// 如果含有time.Time 请自行import time包
type SysDictionaryDetail struct {
gorm.Model
Label string `json:"label" form:"label" gorm:"column:label;comment:展示值"`
Value int `json:"value" form:"value" gorm:"column:value;comment:字典值"`
Status *bool `json:"status" form:"status" gorm:"column:status;comment:启用状态"`
Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:排序标记"`
SysDictionaryID int `json:"sysDictionaryID" form:"sysDictionaryID" gorm:"column:sys_dictionary_id;comment:关联标记"`
global.GVA_MODEL
Label string `json:"label" form:"label" gorm:"column:label;comment:展示值"` // 展示值
Value int `json:"value" form:"value" gorm:"column:value;comment:字典值"` // 字典值
Status *bool `json:"status" form:"status" gorm:"column:status;comment:启用状态"` // 启用状态
Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:排序标记"` // 排序标记
SysDictionaryID int `json:"sysDictionaryID" form:"sysDictionaryID" gorm:"column:sys_dictionary_id;comment:关联标记"` // 关联标记
}
+5
View File
@@ -0,0 +1,5 @@
package model
type InitDBFunc interface {
Init() (err error)
}
+2 -2
View File
@@ -1,10 +1,10 @@
package model
import (
"gorm.io/gorm"
"gin-vue-admin/global"
)
type JwtBlacklist struct {
gorm.Model
global.GVA_MODEL
Jwt string `gorm:"type:text;comment:jwt"`
}
+12 -12
View File
@@ -2,22 +2,22 @@
package model
import (
"gorm.io/gorm"
"gin-vue-admin/global"
"time"
)
// 如果含有time.Time 请自行import time包
type SysOperationRecord struct {
gorm.Model
Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"`
Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"`
Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"`
Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"`
Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟"`
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:"type:longtext;column:body;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:用户id"`
global.GVA_MODEL
Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"` // 请求ip
Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"` // 请求方法
Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"` // 请求路径
Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"` // 请求状态
Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟" swaggertype:"string"` // 延迟
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:"type:longtext;column:body;comment:请求Body"` // 请求Body
Resp string `json:"resp" form:"resp" gorm:"type:longtext;column:resp;comment:响应Body"` // 响应Body
UserID int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"` // 用户id
User SysUser `json:"user"`
}
+8 -8
View File
@@ -1,17 +1,17 @@
package model
import (
"gin-vue-admin/global"
"github.com/satori/go.uuid"
"gorm.io/gorm"
)
type SysUser struct {
gorm.Model
UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"`
Username string `json:"userName" gorm:"comment:用户登录名"`
Password string `json:"-" gorm:"comment:用户登录密码"`
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称" `
HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像"`
global.GVA_MODEL
UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"` // 用户UUID
Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名
Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像"` // 用户头像
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"`
AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
}
-25
View File
@@ -1,25 +0,0 @@
package model
import (
"gorm.io/gorm"
)
// 工作流属性表
type SysWorkflow struct {
gorm.Model
WorkflowNickName string `json:"workflowNickName" gorm:"comment:工作流中文名称"` // 工作流名称
WorkflowName string `json:"workflowName" gorm:"comment:工作流英文名称"` // 工作流英文id
WorkflowDescription string `json:"workflowDescription" gorm:"comment:工作流描述"` // 工作流描述
WorkflowStepInfo []SysWorkflowStepInfo `json:"workflowStep" gorm:"comment:工作流步骤"` // 工作流步骤
}
// 工作流状态表
type SysWorkflowStepInfo struct {
gorm.Model
SysWorkflowID uint `json:"workflowID" gorm:"comment:所属工作流ID"` // 所属工作流ID
IsStart bool `json:"isStart" gorm:"comment:是否是开始流节点"` // 是否是开始流节点
StepName string `json:"stepName" gorm:"comment:工作流节点名称"` // 工作流名称
StepNo float64 `json:"stepNo" gorm:"comment:步骤id (第几步)"` // 步骤id (第几步)
StepAuthorityID string `json:"stepAuthorityID" gorm:"comment:操作者级别id"` // 操作者级别id
IsEnd bool `json:"isEnd" gorm:"comment:是否是完结流节点"` // 是否是完结流节点
}
-14
View File
@@ -1,14 +0,0 @@
package model
import "gorm.io/gorm"
// 工作流流转表
type SysWorkFlowProcess struct {
gorm.Model
ApplicationID uint `json:"applicationID" gorm:"comment:当前工作流所属申请的ID"` // 当前工作流所属申请的ID
CurrentNode string `json:"currentNode" gorm:"comment:当前进度节点"` // 当前进度节点
HistoricalNode string `json:"historicalNode" gorm:"comment:上一个进度节点"` // 上一个进度节点
CurrentUser string `json:"currentUser" gorm:"comment:当前进度操作人"` // 当前进度操作人
HistoricalUser string `json:"historicalUser" gorm:"comment:上一个进度的操作人"` // 上一个进度的操作人
State bool `json:"state" gorm:"comment:是否是正在进行的状态"` // 状态 是否是正在进行的状态
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
.test-form[data-v-77b1aafa]{margin:15px auto;width:800px;padding:15px}

Some files were not shown because too many files have changed in this diff Show More