├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── deployment ├── server │ ├── gva-server-configmap.yaml │ ├── gva-server-deployment.yaml │ └── gva-server-service.yaml └── web │ ├── gva-web-configmap.yaml │ ├── gva-web-deploymemt.yaml │ └── gva-web-service.yaml ├── docker-compose.yaml ├── docs └── gin-vue-admin.png ├── package-lock.json ├── raptor.sql ├── server ├── Dockerfile ├── README.md ├── api │ └── v1 │ │ ├── autocode │ │ ├── asset.go │ │ ├── auto_code_example.go │ │ ├── build.go │ │ ├── enter.go │ │ ├── key.go │ │ ├── product.go │ │ └── service.go │ │ ├── enter.go │ │ ├── example │ │ ├── enter.go │ │ ├── exa_breakpoint_continue.go │ │ ├── exa_customer.go │ │ ├── exa_excel.go │ │ └── exa_file_upload_download.go │ │ └── system │ │ ├── enter.go │ │ ├── sys_api.go │ │ ├── sys_authority.go │ │ ├── sys_authority_btn.go │ │ ├── sys_auto_code.go │ │ ├── sys_auto_code_history.go │ │ ├── sys_captcha.go │ │ ├── sys_casbin.go │ │ ├── sys_dictionary.go │ │ ├── sys_dictionary_detail.go │ │ ├── sys_initdb.go │ │ ├── sys_jwt_blacklist.go │ │ ├── sys_menu.go │ │ ├── sys_operation_record.go │ │ ├── sys_system.go │ │ └── sys_user.go ├── config.yaml ├── config │ ├── auto_code.go │ ├── captcha.go │ ├── casbin.go │ ├── config.go │ ├── cors.go │ ├── db_list.go │ ├── ding.go │ ├── email.go │ ├── excel.go │ ├── gorm_mysql.go │ ├── gorm_pgsql.go │ ├── jwt.go │ ├── oss_aliyun.go │ ├── oss_aws.go │ ├── oss_huawei.go │ ├── oss_local.go │ ├── oss_qiniu.go │ ├── oss_tencent.go │ ├── redis.go │ ├── system.go │ ├── timer.go │ └── zap.go ├── core │ ├── server.go │ ├── server_other.go │ ├── server_win.go │ ├── viper.go │ └── zap.go ├── docs │ ├── docs.go │ ├── swagger.json │ └── swagger.yaml ├── global │ ├── global.go │ └── model.go ├── go.mod ├── go.sum ├── initialize │ ├── db_list.go │ ├── gorm.go │ ├── gorm_mysql.go │ ├── gorm_pgsql.go │ ├── internal │ │ ├── gorm.go │ │ └── logger.go │ ├── plugin.go │ ├── redis.go │ ├── router.go │ ├── timer.go │ └── validator.go ├── main.go ├── middleware │ ├── casbin_rbac.go │ ├── cors.go │ ├── email.go │ ├── error.go │ ├── jwt.go │ ├── limit_ip.go │ ├── loadtls.go │ ├── logger.go │ ├── need_init.go │ └── operation.go ├── model │ ├── autocode │ │ ├── asset.go │ │ ├── autocodeExample.go │ │ ├── build.go │ │ ├── key.go │ │ ├── product.go │ │ ├── request │ │ │ ├── asset.go │ │ │ ├── autocodeExample.go │ │ │ ├── build.go │ │ │ ├── key.go │ │ │ ├── product.go │ │ │ └── service.go │ │ └── service.go │ ├── common │ │ ├── request │ │ │ └── common.go │ │ └── response │ │ │ ├── common.go │ │ │ └── response.go │ ├── example │ │ ├── exa_breakpoint_continue.go │ │ ├── exa_customer.go │ │ ├── exa_excel.go │ │ ├── exa_file_upload_download.go │ │ └── response │ │ │ ├── exa_breakpoint_continue.go │ │ │ ├── exa_customer.go │ │ │ └── exa_file_upload_download.go │ └── system │ │ ├── request │ │ ├── jwt.go │ │ ├── sys_api.go │ │ ├── sys_authority_btn.go │ │ ├── sys_auto_history.go │ │ ├── sys_casbin.go │ │ ├── sys_dictionary.go │ │ ├── sys_dictionary_detail.go │ │ ├── sys_init.go │ │ ├── sys_menu.go │ │ ├── sys_operation_record.go │ │ └── sys_user.go │ │ ├── response │ │ ├── sys_api.go │ │ ├── sys_authority.go │ │ ├── sys_authority_btn.go │ │ ├── sys_auto_code.go │ │ ├── sys_auto_code_history.go │ │ ├── sys_captcha.go │ │ ├── sys_casbin.go │ │ ├── sys_menu.go │ │ ├── sys_system.go │ │ └── sys_user.go │ │ ├── sys_api.go │ │ ├── sys_authority.go │ │ ├── sys_authority_btn.go │ │ ├── sys_authority_menu.go │ │ ├── sys_auto_code.go │ │ ├── sys_autocode_history.go │ │ ├── sys_base_menu.go │ │ ├── sys_dictionary.go │ │ ├── sys_dictionary_detail.go │ │ ├── sys_initdb.go │ │ ├── sys_jwt_blacklist.go │ │ ├── sys_menu_btn.go │ │ ├── sys_operation_record.go │ │ ├── sys_system.go │ │ ├── sys_user.go │ │ └── sys_user_authority.go ├── packfile │ ├── notUsePackFile.go │ └── usePackFile.go ├── plugin │ ├── email │ │ ├── README.MD │ │ ├── api │ │ │ ├── enter.go │ │ │ └── sys_email.go │ │ ├── config │ │ │ └── email.go │ │ ├── global │ │ │ └── gloabl.go │ │ ├── main.go │ │ ├── model │ │ │ └── response │ │ │ │ └── email.go │ │ ├── router │ │ │ ├── enter.go │ │ │ └── sys_email.go │ │ ├── service │ │ │ ├── enter.go │ │ │ └── sys_email.go │ │ └── utils │ │ │ └── email.go │ ├── example_plugin │ │ └── main.go │ └── ws │ │ └── ws.go ├── resource │ ├── excel │ │ ├── ExcelExport.xlsx │ │ ├── ExcelImport.xlsx │ │ └── ExcelTemplate.xlsx │ ├── page │ │ ├── css │ │ │ ├── index.f05c41c6.css │ │ │ └── parser-example.69e16e51.css │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── js │ │ │ ├── chunk-vendors.9ae0d8fb.js │ │ │ ├── index.94d8e405.js │ │ │ ├── parser-example.c1051310.js │ │ │ ├── preview.d8d06dfd.js │ │ │ └── tinymce-example.5a756246.js │ │ ├── libs │ │ │ └── monaco-editor │ │ │ │ └── vs │ │ │ │ ├── base │ │ │ │ ├── browser │ │ │ │ │ └── ui │ │ │ │ │ │ └── codicons │ │ │ │ │ │ └── codicon │ │ │ │ │ │ └── codicon.ttf │ │ │ │ └── worker │ │ │ │ │ └── workerMain.js │ │ │ │ ├── basic-languages │ │ │ │ ├── abap │ │ │ │ │ └── abap.js │ │ │ │ ├── apex │ │ │ │ │ └── apex.js │ │ │ │ ├── azcli │ │ │ │ │ └── azcli.js │ │ │ │ ├── bat │ │ │ │ │ └── bat.js │ │ │ │ ├── cameligo │ │ │ │ │ └── cameligo.js │ │ │ │ ├── clojure │ │ │ │ │ └── clojure.js │ │ │ │ ├── coffee │ │ │ │ │ └── coffee.js │ │ │ │ ├── cpp │ │ │ │ │ └── cpp.js │ │ │ │ ├── csharp │ │ │ │ │ └── csharp.js │ │ │ │ ├── csp │ │ │ │ │ └── csp.js │ │ │ │ ├── css │ │ │ │ │ └── css.js │ │ │ │ ├── dart │ │ │ │ │ └── dart.js │ │ │ │ ├── dockerfile │ │ │ │ │ └── dockerfile.js │ │ │ │ ├── ecl │ │ │ │ │ └── ecl.js │ │ │ │ ├── fsharp │ │ │ │ │ └── fsharp.js │ │ │ │ ├── go │ │ │ │ │ └── go.js │ │ │ │ ├── graphql │ │ │ │ │ └── graphql.js │ │ │ │ ├── handlebars │ │ │ │ │ └── handlebars.js │ │ │ │ ├── hcl │ │ │ │ │ └── hcl.js │ │ │ │ ├── html │ │ │ │ │ └── html.js │ │ │ │ ├── ini │ │ │ │ │ └── ini.js │ │ │ │ ├── java │ │ │ │ │ └── java.js │ │ │ │ ├── javascript │ │ │ │ │ └── javascript.js │ │ │ │ ├── julia │ │ │ │ │ └── julia.js │ │ │ │ ├── kotlin │ │ │ │ │ └── kotlin.js │ │ │ │ ├── less │ │ │ │ │ └── less.js │ │ │ │ ├── lexon │ │ │ │ │ └── lexon.js │ │ │ │ ├── lua │ │ │ │ │ └── lua.js │ │ │ │ ├── m3 │ │ │ │ │ └── m3.js │ │ │ │ ├── markdown │ │ │ │ │ └── markdown.js │ │ │ │ ├── mips │ │ │ │ │ └── mips.js │ │ │ │ ├── msdax │ │ │ │ │ └── msdax.js │ │ │ │ ├── mysql │ │ │ │ │ └── mysql.js │ │ │ │ ├── objective-c │ │ │ │ │ └── objective-c.js │ │ │ │ ├── pascal │ │ │ │ │ └── pascal.js │ │ │ │ ├── pascaligo │ │ │ │ │ └── pascaligo.js │ │ │ │ ├── perl │ │ │ │ │ └── perl.js │ │ │ │ ├── pgsql │ │ │ │ │ └── pgsql.js │ │ │ │ ├── php │ │ │ │ │ └── php.js │ │ │ │ ├── postiats │ │ │ │ │ └── postiats.js │ │ │ │ ├── powerquery │ │ │ │ │ └── powerquery.js │ │ │ │ ├── powershell │ │ │ │ │ └── powershell.js │ │ │ │ ├── pug │ │ │ │ │ └── pug.js │ │ │ │ ├── python │ │ │ │ │ └── python.js │ │ │ │ ├── r │ │ │ │ │ └── r.js │ │ │ │ ├── razor │ │ │ │ │ └── razor.js │ │ │ │ ├── redis │ │ │ │ │ └── redis.js │ │ │ │ ├── redshift │ │ │ │ │ └── redshift.js │ │ │ │ ├── restructuredtext │ │ │ │ │ └── restructuredtext.js │ │ │ │ ├── ruby │ │ │ │ │ └── ruby.js │ │ │ │ ├── rust │ │ │ │ │ └── rust.js │ │ │ │ ├── sb │ │ │ │ │ └── sb.js │ │ │ │ ├── scala │ │ │ │ │ └── scala.js │ │ │ │ ├── scheme │ │ │ │ │ └── scheme.js │ │ │ │ ├── scss │ │ │ │ │ └── scss.js │ │ │ │ ├── shell │ │ │ │ │ └── shell.js │ │ │ │ ├── solidity │ │ │ │ │ └── solidity.js │ │ │ │ ├── sophia │ │ │ │ │ └── sophia.js │ │ │ │ ├── sql │ │ │ │ │ └── sql.js │ │ │ │ ├── st │ │ │ │ │ └── st.js │ │ │ │ ├── swift │ │ │ │ │ └── swift.js │ │ │ │ ├── systemverilog │ │ │ │ │ └── systemverilog.js │ │ │ │ ├── tcl │ │ │ │ │ └── tcl.js │ │ │ │ ├── twig │ │ │ │ │ └── twig.js │ │ │ │ ├── typescript │ │ │ │ │ └── typescript.js │ │ │ │ ├── vb │ │ │ │ │ └── vb.js │ │ │ │ ├── xml │ │ │ │ │ └── xml.js │ │ │ │ └── yaml │ │ │ │ │ └── yaml.js │ │ │ │ ├── editor │ │ │ │ ├── editor.main.css │ │ │ │ ├── editor.main.js │ │ │ │ ├── editor.main.nls.de.js │ │ │ │ ├── editor.main.nls.es.js │ │ │ │ ├── editor.main.nls.fr.js │ │ │ │ ├── editor.main.nls.it.js │ │ │ │ ├── editor.main.nls.ja.js │ │ │ │ ├── editor.main.nls.js │ │ │ │ ├── editor.main.nls.ko.js │ │ │ │ ├── editor.main.nls.ru.js │ │ │ │ ├── editor.main.nls.zh-cn.js │ │ │ │ └── editor.main.nls.zh-tw.js │ │ │ │ ├── language │ │ │ │ ├── css │ │ │ │ │ ├── cssMode.js │ │ │ │ │ └── cssWorker.js │ │ │ │ ├── html │ │ │ │ │ ├── htmlMode.js │ │ │ │ │ └── htmlWorker.js │ │ │ │ ├── json │ │ │ │ │ ├── jsonMode.js │ │ │ │ │ └── jsonWorker.js │ │ │ │ └── typescript │ │ │ │ │ ├── tsMode.js │ │ │ │ │ └── tsWorker.js │ │ │ │ └── loader.js │ │ └── preview.html │ ├── rbac_model.conf │ └── template │ │ ├── readme.txt.tpl │ │ ├── server │ │ ├── api.go.tpl │ │ ├── model.go.tpl │ │ ├── request.go.tpl │ │ ├── router.go.tpl │ │ └── service.go.tpl │ │ └── web │ │ ├── api.js.tpl │ │ ├── form.vue.tpl │ │ └── table.vue.tpl ├── router │ ├── autocode │ │ ├── asset.go │ │ ├── auto_code_example.go │ │ ├── build.go │ │ ├── enter.go │ │ ├── key.go │ │ ├── product.go │ │ └── service.go │ ├── enter.go │ ├── example │ │ ├── enter.go │ │ ├── exa_customer.go │ │ ├── exa_excel.go │ │ └── exa_file_upload_and_download.go │ └── system │ │ ├── enter.go │ │ ├── sys_api.go │ │ ├── sys_authority.go │ │ ├── sys_authority_btn.go │ │ ├── sys_auto_code.go │ │ ├── sys_auto_code_history.go │ │ ├── sys_base.go │ │ ├── sys_casbin.go │ │ ├── sys_dictionary.go │ │ ├── sys_dictionary_detail.go │ │ ├── sys_initdb.go │ │ ├── sys_jwt.go │ │ ├── sys_menu.go │ │ ├── sys_operation_record.go │ │ ├── sys_system.go │ │ └── sys_user.go ├── service │ ├── autocode │ │ ├── asset.go │ │ ├── auto_code_example.go │ │ ├── build.go │ │ ├── enter.go │ │ ├── key.go │ │ ├── product.go │ │ └── service.go │ ├── enter.go │ ├── example │ │ ├── enter.go │ │ ├── exa_breakpoint_continue.go │ │ ├── exa_customer.go │ │ ├── exa_excel_parse.go │ │ └── exa_file_upload_download.go │ └── system │ │ ├── enter.go │ │ ├── jwt_black_list.go │ │ ├── sys_api.go │ │ ├── sys_authority.go │ │ ├── sys_authority_btn.go │ │ ├── sys_auto_code.go │ │ ├── sys_auto_code_interface.go │ │ ├── sys_auto_code_mysql.go │ │ ├── sys_auto_code_pgsql.go │ │ ├── sys_autocode_history.go │ │ ├── sys_base_menu.go │ │ ├── sys_casbin.go │ │ ├── sys_dictionary.go │ │ ├── sys_dictionary_detail.go │ │ ├── sys_initdb.go │ │ ├── sys_initdb_mysql.go │ │ ├── sys_initdb_pgsql.go │ │ ├── sys_menu.go │ │ ├── sys_operation_record.go │ │ ├── sys_system.go │ │ └── sys_user.go ├── source │ ├── example │ │ ├── file_mysql.go │ │ └── file_pgsql.go │ └── system │ │ ├── api.go │ │ ├── authorities_menus.go │ │ ├── authority.go │ │ ├── casbin.go │ │ ├── data_authorities.go │ │ ├── dictionary.go │ │ ├── dictionary_detail.go │ │ ├── menu.go │ │ ├── user.go │ │ ├── user_authority.go │ │ ├── view_authority_menu_mysql.go │ │ └── view_authority_menu_postgres.go ├── task │ ├── asset.go │ ├── ding.go │ └── dingding.go └── utils │ ├── breakpoint_continue.go │ ├── captcha │ └── redis.go │ ├── clamis.go │ ├── constant.go │ ├── db_automation.go │ ├── directory.go │ ├── file_operations.go │ ├── fmt_plus.go │ ├── injectionCode.go │ ├── jwt.go │ ├── md5.go │ ├── plugin │ ├── plugin.go │ └── plugin_uinx.go │ ├── reload.go │ ├── rotatelogs.go │ ├── server.go │ ├── timer │ ├── timed_task.go │ └── timed_task_test.go │ ├── upload │ ├── aliyun_oss.go │ ├── aws_s3.go │ ├── local.go │ ├── obs.go │ ├── qiniu.go │ ├── tencent_cos.go │ └── upload.go │ ├── validator.go │ ├── verify.go │ └── zipfiles.go └── web ├── .docker-compose └── nginx │ └── conf.d │ └── my.conf ├── .dockerignore ├── .env.development ├── .env.production ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── Dockerfile ├── README.md ├── babel.config.js ├── favicon.ico ├── index.html ├── limit.js ├── openDocument.js ├── package.json ├── src ├── App.vue ├── api │ ├── api.js │ ├── asset.js │ ├── authority.js │ ├── authorityBtn.js │ ├── autoCode.js │ ├── breakpoint.js │ ├── build.js │ ├── casbin.js │ ├── customer.js │ ├── email.js │ ├── excel.js │ ├── fileUploadAndDownload.js │ ├── github.js │ ├── initdb.js │ ├── jwt.js │ ├── key.js │ ├── menu.js │ ├── product.js │ ├── service.js │ ├── sysDictionary.js │ ├── sysDictionaryDetail.js │ ├── sysOperationRecord.js │ ├── system.js │ └── user.js ├── assets │ ├── background.svg │ ├── dashboard.png │ ├── docs.png │ ├── flipped-aurora.png │ ├── github.png │ ├── kefu.png │ ├── login_background.jpg │ ├── login_background.svg │ ├── login_left.svg │ ├── logo.jpg │ ├── logo.png │ ├── logo_login.png │ ├── nav_logo.png │ ├── noBody.png │ ├── notFound.png │ ├── qm.png │ └── video.png ├── components │ ├── chooseImg │ │ └── index.vue │ ├── customPic │ │ └── index.vue │ ├── upload │ │ └── image.vue │ └── warningBar │ │ └── warningBar.vue ├── core │ ├── config.js │ ├── global.js │ └── raptor.js ├── directive │ └── auth.js ├── main.js ├── permission.js ├── pinia │ ├── index.js │ └── modules │ │ ├── dictionary.js │ │ ├── router.js │ │ └── user.js ├── router │ └── index.js ├── style │ ├── base.scss │ ├── basics.scss │ ├── element_visiable.scss │ ├── init.sass │ ├── main.scss │ ├── mobile.scss │ └── newLogin.scss ├── utils │ ├── asyncRouter.js │ ├── btnAuth.js │ ├── bus.js │ ├── date.js │ ├── dictionary.js │ ├── downloadImg.js │ ├── format.js │ ├── image.js │ ├── page.js │ ├── request.js │ └── stringFun.js └── view │ ├── about │ └── index.vue │ ├── cmdb │ ├── asset │ │ └── asset.vue │ ├── index.vue │ ├── key │ │ └── key.vue │ └── product │ │ └── product.vue │ ├── dashboard │ ├── dashboardCharts │ │ └── echartsLine.vue │ ├── dashboardTable │ │ └── dashboardTable.vue │ └── index.vue │ ├── error │ ├── index.vue │ └── reload.vue │ ├── example │ ├── breakpoint │ │ └── breakpoint.vue │ ├── customer │ │ └── customer.vue │ ├── excel │ │ └── excel.vue │ ├── index.vue │ └── upload │ │ └── upload.vue │ ├── init │ └── index.vue │ ├── layout │ ├── aside │ │ ├── asideComponent │ │ │ ├── asyncSubmenu.vue │ │ │ ├── index.vue │ │ │ └── menuItem.vue │ │ ├── historyComponent │ │ │ └── history.vue │ │ └── index.vue │ ├── bottomInfo │ │ └── bottomInfo.vue │ ├── index.vue │ ├── screenfull │ │ └── index.vue │ ├── search │ │ └── search.vue │ └── setting │ │ └── index.vue │ ├── login │ └── index.vue │ ├── person │ └── person.vue │ ├── routerHolder.vue │ ├── serve │ ├── build │ │ └── build.vue │ ├── index.vue │ └── service │ │ ├── service.vue │ │ └── serviceBuildCreate.vue │ ├── superAdmin │ ├── api │ │ └── api.vue │ ├── authority │ │ ├── authority.vue │ │ └── components │ │ │ ├── apis.vue │ │ │ ├── datas.vue │ │ │ └── menus.vue │ ├── dictionary │ │ ├── sysDictionary.vue │ │ └── sysDictionaryDetail.vue │ ├── index.vue │ ├── menu │ │ ├── icon.vue │ │ └── menu.vue │ ├── operation │ │ └── sysOperationRecord.vue │ └── user │ │ └── user.vue │ ├── system │ └── state.vue │ └── systemTools │ ├── autoCode │ ├── component │ │ ├── fieldDialog.vue │ │ └── previewCodeDialg.vue │ └── index.vue │ ├── autoCodeAdmin │ └── index.vue │ ├── formCreate │ └── index.vue │ ├── index.vue │ └── system │ └── system.vue └── vite.config.js /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sql linguist-language=GO -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | /web/node_modules 3 | /web/dist 4 | 5 | .DS_Store 6 | 7 | # local env files 8 | .env.local 9 | .env.*.local 10 | 11 | # Log files 12 | npm-debug.log* 13 | yarn-debug.log* 14 | yarn-error.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | 25 | /server/log/ 26 | /server/gva 27 | /server/latest_log 28 | 29 | *.iml 30 | /server/server.exe 31 | /server/*.exe 32 | /server/server.exe~ 33 | server/*.exe~ -------------------------------------------------------------------------------- /deployment/server/gva-server-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: gva-server 5 | annotations: 6 | flipped-aurora/gin-vue-admin: backend 7 | github: "https://github.com/flipped-aurora/gin-vue-admin.git" 8 | app.kubernetes.io/version: 0.0.1 9 | labels: 10 | app: gva-server 11 | version: gva-vue3 12 | spec: 13 | selector: 14 | app: gva-server 15 | version: gva-vue3 16 | ports: 17 | - port: 8888 18 | name: http 19 | targetPort: 8888 20 | type: ClusterIP 21 | # type: NodePort 22 | -------------------------------------------------------------------------------- /deployment/web/gva-web-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: my.conf 5 | data: 6 | my.conf: | 7 | server { 8 | listen 8080; 9 | server_name localhost; 10 | 11 | #charset koi8-r; 12 | #access_log logs/host.access.log main; 13 | 14 | location / { 15 | root /usr/share/nginx/html; 16 | add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; 17 | try_files $uri $uri/ /index.html; 18 | } 19 | 20 | location /api { 21 | proxy_set_header Host $http_host; 22 | proxy_set_header X-Real-IP $remote_addr; 23 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 24 | proxy_set_header X-Forwarded-Proto $scheme; 25 | rewrite ^/api/(.*)$ /$1 break; #重写 26 | proxy_pass http://gva-server:8888; # 设置代理服务器的协议和地址 27 | } 28 | 29 | location /api/swagger/index.html { 30 | proxy_pass http://gva-server:8888/swagger/index.html; 31 | } 32 | } -------------------------------------------------------------------------------- /deployment/web/gva-web-deploymemt.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: gva-web 5 | annotations: 6 | flipped-aurora/gin-vue-admin: ui 7 | github: "https://github.com/flipped-aurora/gin-vue-admin.git" 8 | app.kubernetes.io/version: 0.0.1 9 | labels: 10 | app: gva-web 11 | version: gva-vue3 12 | spec: 13 | replicas: 1 14 | selector: 15 | matchLabels: 16 | app: gva-web 17 | version: gva-vue3 18 | template: 19 | metadata: 20 | labels: 21 | app: gva-web 22 | version: gva-vue3 23 | spec: 24 | containers: 25 | - name: gin-vue-admin-nginx-container 26 | image: registry.cn-hangzhou.aliyuncs.com/gin-vue-admin/web:40fc3aa6 27 | imagePullPolicy: IfNotPresent 28 | ports: 29 | - containerPort: 8080 30 | name: http 31 | readinessProbe: 32 | tcpSocket: 33 | port: 8080 34 | initialDelaySeconds: 10 35 | periodSeconds: 10 36 | successThreshold: 1 37 | failureThreshold: 3 38 | resources: 39 | limits: 40 | cpu: 500m 41 | memory: 1000Mi 42 | requests: 43 | cpu: 100m 44 | memory: 100Mi 45 | volumeMounts: 46 | - mountPath: /etc/nginx/conf.d/ 47 | name: nginx-config 48 | volumes: 49 | - name: nginx-config 50 | configMap: 51 | name: my.conf 52 | -------------------------------------------------------------------------------- /deployment/web/gva-web-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: gva-web 5 | annotations: 6 | flipped-aurora/gin-vue-admin: ui 7 | github: "https://github.com/flipped-aurora/gin-vue-admin.git" 8 | app.kubernetes.io/version: 0.0.1 9 | labels: 10 | app: gva-web 11 | version: gva-vue3 12 | spec: 13 | type: NodePort 14 | # type: ClusterIP 15 | ports: 16 | - name: http 17 | port: 8080 18 | targetPort: 8080 19 | selector: 20 | app: gva-web 21 | version: gva-vue3 22 | -------------------------------------------------------------------------------- /docs/gin-vue-admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/docs/gin-vue-admin.png -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "raptor", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:alpine as builder 2 | 3 | WORKDIR /go/src/raptor/server 4 | COPY . . 5 | 6 | RUN go env -w GO111MODULE=on \ 7 | && go env -w GOPROXY=https://goproxy.cn,direct \ 8 | && go env -w CGO_ENABLED=0 \ 9 | && go env \ 10 | && go mod tidy \ 11 | && go build -o server . 12 | 13 | FROM alpine:latest 14 | 15 | LABEL MAINTAINER="" 16 | 17 | WORKDIR /go/src/raptor/server 18 | 19 | COPY --from=0 /go/src/raptor/server/server ./ 20 | COPY --from=0 /go/src/raptor/server/resource ./resource/ 21 | COPY --from=0 /go/src/raptor/server/config.yaml ./ 22 | 23 | EXPOSE 8888 24 | ENTRYPOINT ./server -c config.yaml 25 | -------------------------------------------------------------------------------- /server/README.md: -------------------------------------------------------------------------------- 1 | ## server项目结构 2 | 3 | ```shell 4 | ├── api 5 | │ └── v1 6 | ├── config 7 | ├── core 8 | ├── docs 9 | ├── global 10 | ├── initialize 11 | │ └── internal 12 | ├── middleware 13 | ├── model 14 | │ ├── request 15 | │ └── response 16 | ├── packfile 17 | ├── resource 18 | │ ├── excel 19 | │ ├── page 20 | │ └── template 21 | ├── router 22 | ├── service 23 | ├── source 24 | └── utils 25 | ├── timer 26 | └── upload 27 | ``` 28 | 29 | | 文件夹 | 说明 | 描述 | 30 | | ------------ | ----------------------- | --------------------------- | 31 | | `api` | api层 | api层 | 32 | | `--v1` | v1版本接口 | v1版本接口 | 33 | | `config` | 配置包 | config.yaml对应的配置结构体 | 34 | | `core` | 核心文件 | 核心组件(zap, viper, server)的初始化 | 35 | | `docs` | swagger文档目录 | swagger文档目录 | 36 | | `global` | 全局对象 | 全局对象 | 37 | | `initialize` | 初始化 | router,redis,gorm,validator, timer的初始化 | 38 | | `--internal` | 初始化内部函数 | gorm 的 longger 自定义,在此文件夹的函数只能由 `initialize` 层进行调用 | 39 | | `middleware` | 中间件层 | 用于存放 `gin` 中间件代码 | 40 | | `model` | 模型层 | 模型对应数据表 | 41 | | `--request` | 入参结构体 | 接收前端发送到后端的数据。 | 42 | | `--response` | 出参结构体 | 返回给前端的数据结构体 | 43 | | `packfile` | 静态文件打包 | 静态文件打包 | 44 | | `resource` | 静态资源文件夹 | 负责存放静态文件 | 45 | | `--excel` | excel导入导出默认路径 | excel导入导出默认路径 | 46 | | `--page` | 表单生成器 | 表单生成器 打包后的dist | 47 | | `--template` | 模板 | 模板文件夹,存放的是代码生成器的模板 | 48 | | `router` | 路由层 | 路由层 | 49 | | `service` | service层 | 存放业务逻辑问题 | 50 | | `source` | source层 | 存放初始化数据的函数 | 51 | | `utils` | 工具包 | 工具函数封装 | 52 | | `--timer` | timer | 定时器接口封装 | 53 | | `--upload` | oss | oss接口封装 | 54 | 55 | -------------------------------------------------------------------------------- /server/api/v1/autocode/enter.go: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | type ApiGroup struct { 4 | // Code generated by raptor/server Begin; DO NOT EDIT. 5 | AutoCodeExampleApi 6 | KeyApi 7 | AssetApi 8 | ProductApi 9 | ServiceApi 10 | BuildApi 11 | // Code generated by raptor/server End; DO NOT EDIT. 12 | } 13 | -------------------------------------------------------------------------------- /server/api/v1/enter.go: -------------------------------------------------------------------------------- 1 | package v1 2 | 3 | import ( 4 | "raptor/server/api/v1/autocode" 5 | "raptor/server/api/v1/example" 6 | "raptor/server/api/v1/system" 7 | ) 8 | 9 | type ApiGroup struct { 10 | SystemApiGroup system.ApiGroup 11 | ExampleApiGroup example.ApiGroup 12 | AutoCodeApiGroup autocode.ApiGroup 13 | } 14 | 15 | var ApiGroupApp = new(ApiGroup) 16 | -------------------------------------------------------------------------------- /server/api/v1/example/enter.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import "raptor/server/service" 4 | 5 | type ApiGroup struct { 6 | ExcelApi 7 | CustomerApi 8 | FileUploadAndDownloadApi 9 | } 10 | 11 | var ( 12 | excelService = service.ServiceGroupApp.ExampleServiceGroup.ExcelService 13 | customerService = service.ServiceGroupApp.ExampleServiceGroup.CustomerService 14 | fileUploadAndDownloadService = service.ServiceGroupApp.ExampleServiceGroup.FileUploadAndDownloadService 15 | ) 16 | -------------------------------------------------------------------------------- /server/api/v1/system/enter.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import "raptor/server/service" 4 | 5 | type ApiGroup struct { 6 | DBApi 7 | JwtApi 8 | BaseApi 9 | SystemApi 10 | CasbinApi 11 | AutoCodeApi 12 | SystemApiApi 13 | AuthorityApi 14 | DictionaryApi 15 | AuthorityMenuApi 16 | OperationRecordApi 17 | AutoCodeHistoryApi 18 | DictionaryDetailApi 19 | AuthorityBtnApi 20 | } 21 | 22 | var ( 23 | apiService = service.ServiceGroupApp.SystemServiceGroup.ApiService 24 | jwtService = service.ServiceGroupApp.SystemServiceGroup.JwtService 25 | menuService = service.ServiceGroupApp.SystemServiceGroup.MenuService 26 | userService = service.ServiceGroupApp.SystemServiceGroup.UserService 27 | initDBService = service.ServiceGroupApp.SystemServiceGroup.InitDBService 28 | casbinService = service.ServiceGroupApp.SystemServiceGroup.CasbinService 29 | autoCodeService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeService 30 | baseMenuService = service.ServiceGroupApp.SystemServiceGroup.BaseMenuService 31 | authorityService = service.ServiceGroupApp.SystemServiceGroup.AuthorityService 32 | dictionaryService = service.ServiceGroupApp.SystemServiceGroup.DictionaryService 33 | systemConfigService = service.ServiceGroupApp.SystemServiceGroup.SystemConfigService 34 | operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService 35 | autoCodeHistoryService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeHistoryService 36 | dictionaryDetailService = service.ServiceGroupApp.SystemServiceGroup.DictionaryDetailService 37 | authorityBtnService = service.ServiceGroupApp.SystemServiceGroup.AuthorityBtnService 38 | ) 39 | -------------------------------------------------------------------------------- /server/api/v1/system/sys_initdb.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/common/response" 6 | "raptor/server/model/system/request" 7 | "go.uber.org/zap" 8 | 9 | "github.com/gin-gonic/gin" 10 | ) 11 | 12 | type DBApi struct{} 13 | 14 | // InitDB 15 | // @Tags InitDB 16 | // @Summary 初始化用户数据库 17 | // @Produce application/json 18 | // @Param data body request.InitDB true "初始化数据库参数" 19 | // @Success 200 {object} response.Response{data=string} "初始化用户数据库" 20 | // @Router /init/initdb [post] 21 | func (i *DBApi) InitDB(c *gin.Context) { 22 | if global.GVA_DB != nil { 23 | global.GVA_LOG.Error("已存在数据库配置!") 24 | response.FailWithMessage("已存在数据库配置", c) 25 | return 26 | } 27 | var dbInfo request.InitDB 28 | if err := c.ShouldBindJSON(&dbInfo); err != nil { 29 | global.GVA_LOG.Error("参数校验不通过!", zap.Error(err)) 30 | response.FailWithMessage("参数校验不通过", c) 31 | return 32 | } 33 | if err := initDBService.InitDB(dbInfo); err != nil { 34 | global.GVA_LOG.Error("自动创建数据库失败!", zap.Error(err)) 35 | response.FailWithMessage("自动创建数据库失败,请查看后台日志,检查后在进行初始化", c) 36 | return 37 | } 38 | response.OkWithData("自动创建数据库成功", c) 39 | } 40 | 41 | // CheckDB 42 | // @Tags CheckDB 43 | // @Summary 初始化用户数据库 44 | // @Produce application/json 45 | // @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "初始化用户数据库" 46 | // @Router /init/checkdb [post] 47 | func (i *DBApi) CheckDB(c *gin.Context) { 48 | var ( 49 | message = "前往初始化数据库" 50 | needInit = true 51 | ) 52 | 53 | if global.GVA_DB != nil { 54 | message = "数据库无需初始化" 55 | needInit = false 56 | } 57 | global.GVA_LOG.Info(message) 58 | response.OkWithDetailed(gin.H{"needInit": needInit}, message, c) 59 | return 60 | } 61 | -------------------------------------------------------------------------------- /server/api/v1/system/sys_jwt_blacklist.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/common/response" 6 | "raptor/server/model/system" 7 | "github.com/gin-gonic/gin" 8 | "go.uber.org/zap" 9 | ) 10 | 11 | type JwtApi struct{} 12 | 13 | // @Tags Jwt 14 | // @Summary jwt加入黑名单 15 | // @Security ApiKeyAuth 16 | // @accept application/json 17 | // @Produce application/json 18 | // @Success 200 {object} response.Response{msg=string} "jwt加入黑名单" 19 | // @Router /jwt/jsonInBlacklist [post] 20 | func (j *JwtApi) JsonInBlacklist(c *gin.Context) { 21 | token := c.Request.Header.Get("x-token") 22 | jwt := system.JwtBlacklist{Jwt: token} 23 | if err := jwtService.JsonInBlacklist(jwt); err != nil { 24 | global.GVA_LOG.Error("jwt作废失败!", zap.Error(err)) 25 | response.FailWithMessage("jwt作废失败", c) 26 | } else { 27 | response.OkWithMessage("jwt作废成功", c) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /server/config/auto_code.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Autocode struct { 4 | TransferRestart bool `mapstructure:"transfer-restart" json:"transferRestart" yaml:"transfer-restart"` 5 | Root string `mapstructure:"root" json:"root" yaml:"root"` 6 | Server string `mapstructure:"server" json:"server" yaml:"server"` 7 | SApi string `mapstructure:"server-api" json:"serverApi" yaml:"server-api"` 8 | SInitialize string `mapstructure:"server-initialize" json:"serverInitialize" yaml:"server-initialize"` 9 | SModel string `mapstructure:"server-model" json:"serverModel" yaml:"server-model"` 10 | SRequest string `mapstructure:"server-request" json:"serverRequest" yaml:"server-request"` 11 | SRouter string `mapstructure:"server-router" json:"serverRouter" yaml:"server-router"` 12 | SService string `mapstructure:"server-service" json:"serverService" yaml:"server-service"` 13 | Web string `mapstructure:"web" json:"web" yaml:"web"` 14 | WApi string `mapstructure:"web-api" json:"webApi" yaml:"web-api"` 15 | WForm string `mapstructure:"web-form" json:"webForm" yaml:"web-form"` 16 | WTable string `mapstructure:"web-table" json:"webTable" yaml:"web-table"` 17 | } 18 | -------------------------------------------------------------------------------- /server/config/captcha.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Captcha struct { 4 | KeyLong int `mapstructure:"key-long" json:"keyLong" yaml:"key-long"` // 验证码长度 5 | ImgWidth int `mapstructure:"img-width" json:"imgWidth" yaml:"img-width"` // 验证码宽度 6 | ImgHeight int `mapstructure:"img-height" json:"imgHeight" yaml:"img-height"` // 验证码高度 7 | } 8 | -------------------------------------------------------------------------------- /server/config/casbin.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Casbin struct { 4 | ModelPath string `mapstructure:"model-path" json:"modelPath" yaml:"model-path"` // 存放casbin模型的相对路径 5 | } 6 | -------------------------------------------------------------------------------- /server/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Server struct { 4 | JWT JWT `mapstructure:"jwt" json:"jwt" yaml:"jwt"` 5 | Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"` 6 | Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"` 7 | Email Email `mapstructure:"email" json:"email" yaml:"email"` 8 | Casbin Casbin `mapstructure:"casbin" json:"casbin" yaml:"casbin"` 9 | System System `mapstructure:"system" json:"system" yaml:"system"` 10 | Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"` 11 | // auto 12 | AutoCode Autocode `mapstructure:"autoCode" json:"autoCode" yaml:"autoCode"` 13 | // gorm 14 | Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"` 15 | MysqlProd Mysql `mapstructure:"mysqlprod" json:"mysqlprod" yaml:"mysqlprod"` 16 | Pgsql Pgsql `mapstructure:"pgsql" json:"pgsql" yaml:"pgsql"` 17 | DBList []DB `mapstructure:"db-list" json:"db-list" yaml:"db-list"` 18 | // oss 19 | Local Local `mapstructure:"local" json:"local" yaml:"local"` 20 | Qiniu Qiniu `mapstructure:"qiniu" json:"qiniu" yaml:"qiniu"` 21 | AliyunOSS AliyunOSS `mapstructure:"aliyun-oss" json:"aliyunOSS" yaml:"aliyun-oss"` 22 | HuaWeiObs HuaWeiObs `mapstructure:"hua-wei-obs" json:"huaWeiObs" yaml:"hua-wei-obs"` 23 | TencentCOS TencentCOS `mapstructure:"tencent-cos" json:"tencentCOS" yaml:"tencent-cos"` 24 | AwsS3 AwsS3 `mapstructure:"aws-s3" json:"awsS3" yaml:"aws-s3"` 25 | 26 | Excel Excel `mapstructure:"excel" json:"excel" yaml:"excel"` 27 | Timer Timer `mapstructure:"timer" json:"timer" yaml:"timer"` 28 | 29 | // 跨域配置 30 | Cors CORS `mapstructure:"cors" json:"cors" yaml:"cors"` 31 | Ding Ding `mapstructure:"ding" json:"ding" yaml:"ding"` 32 | } 33 | -------------------------------------------------------------------------------- /server/config/cors.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type CORS struct { 4 | Mode string `mapstructure:"mode" json:"mode" yaml:"mode"` 5 | Whitelist []CORSWhitelist `mapstructure:"whitelist" json:"whitelist" yaml:"whitelist"` 6 | } 7 | 8 | type CORSWhitelist struct { 9 | AllowOrigin string `mapstructure:"allow-origin" json:"allow-origin" yaml:"allow-origin"` 10 | AllowMethods string `mapstructure:"allow-methods" json:"allow-methods" yaml:"allow-methods"` 11 | AllowHeaders string `mapstructure:"allow-headers" json:"allow-headers" yaml:"allow-headers"` 12 | ExposeHeaders string `mapstructure:"expose-headers" json:"expose-headers" yaml:"expose-headers"` 13 | AllowCredentials bool `mapstructure:"allow-credentials" json:"allow-credentials" yaml:"allow-credentials"` 14 | } 15 | -------------------------------------------------------------------------------- /server/config/db_list.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type DB struct { 4 | Disable bool `mapstructure:"disable" json:"disable" yaml:"disable"` 5 | Type string `mapstructure:"type" json:"type" yaml:"type"` 6 | AliasName string `mapstructure:"alias-name" json:"alias-name" yaml:"alias-name"` 7 | Path string `mapstructure:"path" json:"path" yaml:"path"` // 服务器地址:端口 8 | Port string `mapstructure:"port" json:"port" yaml:"port"` //:端口 9 | Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置 10 | Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"` // 数据库名 11 | Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名 12 | Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码 13 | MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` // 空闲中的最大连接数 14 | MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` // 打开到数据库的最大连接数 15 | LogMode string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"` // 是否开启Gorm全局日志 16 | LogZap bool `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"` 17 | } 18 | 19 | func (m *DB) Dsn() string { 20 | return m.Username + ":" + m.Password + "@tcp(" + m.Path + ":" + m.Port + ")/" + m.Dbname + "?" + m.Config 21 | } 22 | -------------------------------------------------------------------------------- /server/config/ding.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Ding struct { 4 | Key string `mapstructure:"appkey" json:"appkey" yaml:"appkey"` 5 | Secret string `mapstructure:"appsecret" json:"appsecret" yaml:"appsecret"` 6 | } 7 | -------------------------------------------------------------------------------- /server/config/email.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Email struct { 4 | To string `mapstructure:"to" json:"to" yaml:"to"` // 收件人:多个以英文逗号分隔 5 | Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口 6 | From string `mapstructure:"from" json:"from" yaml:"from"` // 收件人 7 | Host string `mapstructure:"host" json:"host" yaml:"host"` // 服务器地址 8 | IsSSL bool `mapstructure:"is-ssl" json:"isSSL" yaml:"is-ssl"` // 是否SSL 9 | Secret string `mapstructure:"secret" json:"secret" yaml:"secret"` // 密钥 10 | Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"` // 昵称 11 | } 12 | -------------------------------------------------------------------------------- /server/config/excel.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Excel struct { 4 | Dir string `mapstructure:"dir" json:"dir" yaml:"dir"` 5 | } 6 | -------------------------------------------------------------------------------- /server/config/gorm_mysql.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Mysql struct { 4 | Path string `mapstructure:"path" json:"path" yaml:"path"` // 服务器地址 5 | Port string `mapstructure:"port" json:"port" yaml:"port"` // 端口 6 | Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置 7 | Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"` // 数据库名 8 | Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名 9 | Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码 10 | MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` // 空闲中的最大连接数 11 | MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` // 打开到数据库的最大连接数 12 | LogMode string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"` // 是否开启Gorm全局日志 13 | LogZap bool `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"` // 是否通过zap写入日志文件 14 | } 15 | 16 | func (m *Mysql) Dsn() string { 17 | return m.Username + ":" + m.Password + "@tcp(" + m.Path + ":" + m.Port + ")/" + m.Dbname + "?" + m.Config 18 | } 19 | 20 | func (m *Mysql) GetLogMode() string { 21 | return m.LogMode 22 | } 23 | -------------------------------------------------------------------------------- /server/config/gorm_pgsql.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Pgsql struct { 4 | Path string `mapstructure:"path" json:"path" yaml:"path"` // 服务器地址:端口 5 | Port string `mapstructure:"port" json:"port" yaml:"port"` //:端口 6 | Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置 7 | Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"` // 数据库名 8 | Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名 9 | Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码 10 | MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` // 空闲中的最大连接数 11 | MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` // 打开到数据库的最大连接数 12 | LogMode string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"` // 是否开启Gorm全局日志 13 | LogZap bool `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"` // 是否通过zap写入日志文件 14 | } 15 | 16 | // Dsn 基于配置文件获取 dsn 17 | // Author [SliverHorn](https://github.com/SliverHorn) 18 | func (p *Pgsql) Dsn() string { 19 | return "host=" + p.Path + " user=" + p.Username + " password=" + p.Password + " dbname=" + p.Dbname + " port=" + p.Port + " " + p.Config 20 | } 21 | 22 | // LinkDsn 根据 dbname 生成 dsn 23 | // Author [SliverHorn](https://github.com/SliverHorn) 24 | func (p *Pgsql) LinkDsn(dbname string) string { 25 | return "host=" + p.Path + " user=" + p.Username + " password=" + p.Password + " dbname=" + dbname + " port=" + p.Port + " " + p.Config 26 | } 27 | 28 | func (m *Pgsql) GetLogMode() string { 29 | return m.LogMode 30 | } 31 | -------------------------------------------------------------------------------- /server/config/jwt.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type JWT struct { 4 | SigningKey string `mapstructure:"signing-key" json:"signingKey" yaml:"signing-key"` // jwt签名 5 | ExpiresTime int64 `mapstructure:"expires-time" json:"expiresTime" yaml:"expires-time"` // 过期时间 6 | BufferTime int64 `mapstructure:"buffer-time" json:"bufferTime" yaml:"buffer-time"` // 缓冲时间 7 | Issuer string `mapstructure:"issuer" json:"issuer" yaml:"issuer"` // 签发者 8 | } 9 | -------------------------------------------------------------------------------- /server/config/oss_aliyun.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type AliyunOSS struct { 4 | Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint"` 5 | AccessKeyId string `mapstructure:"access-key-id" json:"accessKeyId" yaml:"access-key-id"` 6 | AccessKeySecret string `mapstructure:"access-key-secret" json:"accessKeySecret" yaml:"access-key-secret"` 7 | BucketName string `mapstructure:"bucket-name" json:"bucketName" yaml:"bucket-name"` 8 | BucketUrl string `mapstructure:"bucket-url" json:"bucketUrl" yaml:"bucket-url"` 9 | BasePath string `mapstructure:"base-path" json:"basePath" yaml:"base-path"` 10 | } 11 | -------------------------------------------------------------------------------- /server/config/oss_aws.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type AwsS3 struct { 4 | Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` 5 | Region string `mapstructure:"region" json:"region" yaml:"region"` 6 | Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint"` 7 | S3ForcePathStyle bool `mapstructure:"s3-force-path-style" json:"s3ForcePathStyle" yaml:"s3-force-path-style"` 8 | DisableSSL bool `mapstructure:"disable-ssl" json:"disableSSL" yaml:"disable-ssl"` 9 | SecretID string `mapstructure:"secret-id" json:"secretID" yaml:"secret-id"` 10 | SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"` 11 | BaseURL string `mapstructure:"base-url" json:"baseURL" yaml:"base-url"` 12 | PathPrefix string `mapstructure:"path-prefix" json:"pathPrefix" yaml:"path-prefix"` 13 | } 14 | -------------------------------------------------------------------------------- /server/config/oss_huawei.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type HuaWeiObs struct { 4 | Path string `mapstructure:"path" json:"path" yaml:"path"` 5 | Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` 6 | Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint"` 7 | AccessKey string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"` 8 | SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"` 9 | } 10 | -------------------------------------------------------------------------------- /server/config/oss_local.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Local struct { 4 | Path string `mapstructure:"path" json:"path" yaml:"path"` // 本地文件路径 5 | } 6 | -------------------------------------------------------------------------------- /server/config/oss_qiniu.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Qiniu struct { 4 | Zone string `mapstructure:"zone" json:"zone" yaml:"zone"` // 存储区域 5 | Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` // 空间名称 6 | ImgPath string `mapstructure:"img-path" json:"imgPath" yaml:"img-path"` // CDN加速域名 7 | UseHTTPS bool `mapstructure:"use-https" json:"useHttps" yaml:"use-https"` // 是否使用https 8 | AccessKey string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"` // 秘钥AK 9 | SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"` // 秘钥SK 10 | UseCdnDomains bool `mapstructure:"use-cdn-domains" json:"useCdnDomains" yaml:"use-cdn-domains"` // 上传是否使用CDN上传加速 11 | } 12 | -------------------------------------------------------------------------------- /server/config/oss_tencent.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type TencentCOS struct { 4 | Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` 5 | Region string `mapstructure:"region" json:"region" yaml:"region"` 6 | SecretID string `mapstructure:"secret-id" json:"secretID" yaml:"secret-id"` 7 | SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"` 8 | BaseURL string `mapstructure:"base-url" json:"baseURL" yaml:"base-url"` 9 | PathPrefix string `mapstructure:"path-prefix" json:"pathPrefix" yaml:"path-prefix"` 10 | } 11 | -------------------------------------------------------------------------------- /server/config/redis.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Redis struct { 4 | DB int `mapstructure:"db" json:"db" yaml:"db"` // redis的哪个数据库 5 | Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` // 服务器地址:端口 6 | Password string `mapstructure:"password" json:"password" yaml:"password"` // 密码 7 | } 8 | -------------------------------------------------------------------------------- /server/config/system.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type System struct { 4 | Env string `mapstructure:"env" json:"env" yaml:"env"` // 环境值 5 | Addr int `mapstructure:"addr" json:"addr" yaml:"addr"` // 端口值 6 | DbType string `mapstructure:"db-type" json:"dbType" yaml:"db-type"` // 数据库类型:mysql(默认)|sqlite|sqlserver|postgresql 7 | OssType string `mapstructure:"oss-type" json:"ossType" yaml:"oss-type"` // Oss类型 8 | UseMultipoint bool `mapstructure:"use-multipoint" json:"useMultipoint" yaml:"use-multipoint"` // 多点登录拦截 9 | UseRedis bool `mapstructure:"use-redis" json:"useRedis" yaml:"use-redis"` // 使用redis 10 | LimitCountIP int `mapstructure:"iplimit-count" json:"iplimitCount" yaml:"iplimit-count"` 11 | LimitTimeIP int `mapstructure:"iplimit-time" json:"iplimitTime" yaml:"iplimit-time"` 12 | } 13 | -------------------------------------------------------------------------------- /server/config/timer.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Timer struct { 4 | Start bool `mapstructure:"start" json:"start" yaml:"start"` // 是否启用 5 | Spec string `mapstructure:"spec" json:"spec" yaml:"spec"` // CRON表达式 6 | Detail []Detail `mapstructure:"detail" json:"detail" yaml:"detail"` 7 | } 8 | 9 | type Detail struct { 10 | TableName string `mapstructure:"tableName" json:"tableName" yaml:"tableName"` // 需要清理的表名 11 | CompareField string `mapstructure:"compareField" json:"compareField" yaml:"compareField"` // 需要比较时间的字段 12 | Interval string `mapstructure:"interval" json:"interval" yaml:"interval"` // 时间间隔 13 | } 14 | -------------------------------------------------------------------------------- /server/config/zap.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Zap struct { 4 | Level string `mapstructure:"level" json:"level" yaml:"level"` // 级别 5 | Format string `mapstructure:"format" json:"format" yaml:"format"` // 输出 6 | Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 日志前缀 7 | Director string `mapstructure:"director" json:"director" yaml:"director"` // 日志文件夹 8 | ShowLine bool `mapstructure:"show-line" json:"showLine" yaml:"showLine"` // 显示行 9 | EncodeLevel string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"` // 编码级 10 | StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"` // 栈名 11 | LogInConsole bool `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"` // 输出控制台 12 | } 13 | -------------------------------------------------------------------------------- /server/core/server.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "fmt" 5 | "github.com/gogf/gf/frame/g" 6 | "raptor/server/task" 7 | "time" 8 | 9 | "github.com/gogf/gf/os/gcron" 10 | "go.uber.org/zap" 11 | "raptor/server/global" 12 | "raptor/server/initialize" 13 | "raptor/server/service/system" 14 | ) 15 | 16 | type server interface { 17 | ListenAndServe() error 18 | } 19 | 20 | func RunWindowsServer() { 21 | if global.GVA_CONFIG.System.UseMultipoint || global.GVA_CONFIG.System.UseRedis { 22 | // 初始化redis服务 23 | initialize.Redis() 24 | } 25 | 26 | // 从db加载jwt数据 27 | if global.GVA_DB != nil { 28 | system.LoadAll() 29 | } 30 | 31 | Router := initialize.Routers() 32 | Router.Static("/form-generator", "./resource/page") 33 | 34 | address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr) 35 | s := initServer(address, Router) 36 | // 保证文本顺序输出 37 | // In order to ensure that the text order output can be deleted 38 | time.Sleep(10 * time.Microsecond) 39 | global.GVA_LOG.Info("server run success on ", zap.String("address", address)) 40 | 41 | fmt.Printf(` 42 | 欢迎使用 raptor/server 43 | 当前版本:V0.1 44 | 默认自动化文档地址:http://127.0.0.1%s/swagger/index.html 45 | 默认前端文件运行地址:http://127.0.0.1:8080 46 | 定时任务在 core/server.go 里面设置 ,会定时更新 钉钉部门用户信息,同步阿里云资产 47 | `, address) 48 | 49 | _, err := gcron.Add("0 10 16 * * *", func() { task.DingUpdate() }) 50 | _, err = gcron.Add("0 10 16 * * *", func() { task.AssetUpdate() }) 51 | if err != nil { 52 | fmt.Println(err.Error()) 53 | } 54 | g.Dump(gcron.Entries()) 55 | 56 | global.GVA_LOG.Error(s.ListenAndServe().Error()) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /server/core/server_other.go: -------------------------------------------------------------------------------- 1 | //go:build !windows 2 | // +build !windows 3 | 4 | package core 5 | 6 | import ( 7 | "time" 8 | 9 | "github.com/fvbock/endless" 10 | "github.com/gin-gonic/gin" 11 | ) 12 | 13 | func initServer(address string, router *gin.Engine) server { 14 | s := endless.NewServer(address, router) 15 | s.ReadHeaderTimeout = 20 * time.Second 16 | s.WriteTimeout = 20 * time.Second 17 | s.MaxHeaderBytes = 1 << 20 18 | return s 19 | } 20 | -------------------------------------------------------------------------------- /server/core/server_win.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | // +build windows 3 | 4 | package core 5 | 6 | import ( 7 | "net/http" 8 | "time" 9 | 10 | "github.com/gin-gonic/gin" 11 | ) 12 | 13 | func initServer(address string, router *gin.Engine) server { 14 | return &http.Server{ 15 | Addr: address, 16 | Handler: router, 17 | ReadTimeout: 20 * time.Second, 18 | WriteTimeout: 20 * time.Second, 19 | MaxHeaderBytes: 1 << 20, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /server/core/viper.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | "path/filepath" 8 | "time" 9 | 10 | "github.com/songzhibin97/gkit/cache/local_cache" 11 | 12 | "raptor/server/global" 13 | _ "raptor/server/packfile" 14 | "raptor/server/utils" 15 | 16 | "github.com/fsnotify/fsnotify" 17 | "github.com/spf13/viper" 18 | ) 19 | 20 | func Viper(path ...string) *viper.Viper { 21 | var config string 22 | if len(path) == 0 { 23 | flag.StringVar(&config, "c", "", "choose config file.") 24 | flag.Parse() 25 | if config == "" { // 优先级: 命令行 > 环境变量 > 默认值 26 | if configEnv := os.Getenv(utils.ConfigEnv); configEnv == "" { 27 | config = utils.ConfigFile 28 | fmt.Printf("您正在使用config的默认值,config的路径为%v\n", utils.ConfigFile) 29 | } else { 30 | config = configEnv 31 | fmt.Printf("您正在使用GVA_CONFIG环境变量,config的路径为%v\n", config) 32 | } 33 | } else { 34 | fmt.Printf("您正在使用命令行的-c参数传递的值,config的路径为%v\n", config) 35 | } 36 | } else { 37 | config = path[0] 38 | fmt.Printf("您正在使用func Viper()传递的值,config的路径为%v\n", config) 39 | } 40 | 41 | v := viper.New() 42 | v.SetConfigFile(config) 43 | v.SetConfigType("yaml") 44 | err := v.ReadInConfig() 45 | if err != nil { 46 | panic(fmt.Errorf("Fatal error config file: %s \n", err)) 47 | } 48 | v.WatchConfig() 49 | 50 | v.OnConfigChange(func(e fsnotify.Event) { 51 | fmt.Println("config file changed:", e.Name) 52 | if err := v.Unmarshal(&global.GVA_CONFIG); err != nil { 53 | fmt.Println(err) 54 | } 55 | }) 56 | if err := v.Unmarshal(&global.GVA_CONFIG); err != nil { 57 | fmt.Println(err) 58 | } 59 | // root 适配性 60 | // 根据root位置去找到对应迁移位置,保证root路径有效 61 | global.GVA_CONFIG.AutoCode.Root, _ = filepath.Abs("..") 62 | global.BlackCache = local_cache.NewCache( 63 | local_cache.SetDefaultExpire(time.Second * time.Duration(global.GVA_CONFIG.JWT.ExpiresTime)), 64 | ) 65 | return v 66 | } 67 | -------------------------------------------------------------------------------- /server/global/global.go: -------------------------------------------------------------------------------- 1 | package global 2 | 3 | import ( 4 | "sync" 5 | 6 | "raptor/server/utils/timer" 7 | "github.com/songzhibin97/gkit/cache/local_cache" 8 | 9 | "golang.org/x/sync/singleflight" 10 | 11 | "go.uber.org/zap" 12 | 13 | "raptor/server/config" 14 | 15 | "github.com/go-redis/redis/v8" 16 | "github.com/spf13/viper" 17 | "gorm.io/gorm" 18 | ) 19 | 20 | var ( 21 | GVA_DB *gorm.DB 22 | GVA_DBList map[string]*gorm.DB 23 | GVA_REDIS *redis.Client 24 | GVA_CONFIG config.Server 25 | GVA_VP *viper.Viper 26 | // GVA_LOG *oplogging.Logger 27 | GVA_LOG *zap.Logger 28 | GVA_Timer timer.Timer = timer.NewTimerTask() 29 | GVA_Concurrency_Control = &singleflight.Group{} 30 | 31 | BlackCache local_cache.Cache 32 | lock sync.RWMutex 33 | ) 34 | 35 | // GetGlobalDBByDBName 通过名称获取db list中的db 36 | func GetGlobalDBByDBName(dbname string) *gorm.DB { 37 | lock.RLock() 38 | defer lock.RUnlock() 39 | return GVA_DBList[dbname] 40 | } 41 | 42 | // MustGetGlobalDBByDBName 通过名称获取db 如果不存在则panic 43 | func MustGetGlobalDBByDBName(dbname string) *gorm.DB { 44 | lock.RLock() 45 | defer lock.RUnlock() 46 | db, ok := GVA_DBList[dbname] 47 | if !ok || db == nil { 48 | panic("db no init") 49 | } 50 | return db 51 | } 52 | -------------------------------------------------------------------------------- /server/global/model.go: -------------------------------------------------------------------------------- 1 | package global 2 | 3 | import ( 4 | "time" 5 | 6 | "gorm.io/gorm" 7 | ) 8 | 9 | type GVA_MODEL struct { 10 | ID uint `gorm:"primarykey"` // 主键ID 11 | CreatedAt time.Time // 创建时间 12 | UpdatedAt time.Time // 更新时间 13 | DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间 14 | } 15 | -------------------------------------------------------------------------------- /server/initialize/db_list.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import ( 4 | "raptor/server/global" 5 | "gorm.io/gorm" 6 | ) 7 | 8 | const sys = "system" 9 | 10 | func DBList() { 11 | dbMap := make(map[string]*gorm.DB) 12 | for _, info := range global.GVA_CONFIG.DBList { 13 | if info.Disable { 14 | continue 15 | } 16 | switch info.Type { 17 | case "mysql": 18 | dbMap[info.Dbname] = GormMysqlByConfig(info) 19 | case "pgsql": 20 | dbMap[info.Dbname] = GormPgSqlByConfig(info) 21 | default: 22 | continue 23 | } 24 | } 25 | // 做特殊判断,是否有迁移 26 | // 适配低版本迁移多数据库版本 27 | if sysDB, ok := dbMap[sys]; ok { 28 | global.GVA_DB = sysDB 29 | } 30 | global.GVA_DBList = dbMap 31 | } 32 | -------------------------------------------------------------------------------- /server/initialize/gorm.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import ( 4 | "os" 5 | 6 | "raptor/server/global" 7 | "raptor/server/model/autocode" 8 | "raptor/server/model/example" 9 | "raptor/server/model/system" 10 | 11 | "go.uber.org/zap" 12 | "gorm.io/gorm" 13 | ) 14 | 15 | // Gorm 初始化数据库并产生数据库全局变量 16 | // Author SliverHorn 17 | func Gorm() *gorm.DB { 18 | switch global.GVA_CONFIG.System.DbType { 19 | case "mysql": 20 | return GormMysql() 21 | case "pgsql": 22 | return GormPgSql() 23 | default: 24 | return GormMysql() 25 | } 26 | } 27 | 28 | // RegisterTables 注册数据库表专用 29 | // Author SliverHorn 30 | func RegisterTables(db *gorm.DB) { 31 | err := db.AutoMigrate( 32 | // 系统模块表 33 | system.SysApi{}, 34 | system.SysUser{}, 35 | system.SysBaseMenu{}, 36 | system.JwtBlacklist{}, 37 | system.SysAuthority{}, 38 | system.SysDictionary{}, 39 | system.SysOperationRecord{}, 40 | system.SysAutoCodeHistory{}, 41 | system.SysDictionaryDetail{}, 42 | system.SysBaseMenuParameter{}, 43 | system.SysBaseMenuBtn{}, 44 | system.SysAuthorityBtn{}, 45 | // 示例模块表 46 | example.ExaFile{}, 47 | example.ExaCustomer{}, 48 | example.ExaFileChunk{}, 49 | example.ExaFileUploadAndDownload{}, 50 | 51 | // 自动化模块表 52 | // Code generated by raptor/server Begin; DO NOT EDIT. 53 | autocode.AutoCodeExample{}, 54 | autocode.Key{}, 55 | autocode.Asset{}, 56 | autocode.Product{}, 57 | autocode.Service{}, 58 | autocode.Build{}, 59 | // Code generated by raptor/server End; DO NOT EDIT. 60 | ) 61 | if err != nil { 62 | global.GVA_LOG.Error("register table failed", zap.Error(err)) 63 | os.Exit(0) 64 | } 65 | global.GVA_LOG.Info("register table success") 66 | } 67 | -------------------------------------------------------------------------------- /server/initialize/gorm_mysql.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import ( 4 | "fmt" 5 | "gorm.io/driver/mysql" 6 | "gorm.io/gorm" 7 | "os" 8 | "raptor/server/config" 9 | "raptor/server/global" 10 | "raptor/server/initialize/internal" 11 | ) 12 | 13 | // GormMysql 初始化Mysql数据库 14 | // Author [piexlmax](https://github.com/piexlmax) 15 | // Author [SliverHorn](https://github.com/SliverHorn) 16 | func GormMysql() *gorm.DB { 17 | m := global.GVA_CONFIG.Mysql 18 | if name, _ := os.Hostname(); name == "raptor" { 19 | fmt.Println("线上环境") 20 | m = global.GVA_CONFIG.MysqlProd 21 | } else { 22 | fmt.Println("测试环境") 23 | } 24 | 25 | if m.Dbname == "" { 26 | return nil 27 | } 28 | mysqlConfig := mysql.Config{ 29 | DSN: m.Dsn(), // DSN data source name 30 | DefaultStringSize: 191, // string 类型字段的默认长度 31 | SkipInitializeWithVersion: false, // 根据版本自动配置 32 | } 33 | if db, err := gorm.Open(mysql.New(mysqlConfig), internal.Gorm.Config()); err != nil { 34 | return nil 35 | } else { 36 | sqlDB, _ := db.DB() 37 | sqlDB.SetMaxIdleConns(m.MaxIdleConns) 38 | sqlDB.SetMaxOpenConns(m.MaxOpenConns) 39 | return db 40 | } 41 | } 42 | 43 | // GormMysqlByConfig 初始化Mysql数据库用过传入配置 44 | func GormMysqlByConfig(m config.DB) *gorm.DB { 45 | if m.Dbname == "" { 46 | return nil 47 | } 48 | mysqlConfig := mysql.Config{ 49 | DSN: m.Dsn(), // DSN data source name 50 | DefaultStringSize: 191, // string 类型字段的默认长度 51 | SkipInitializeWithVersion: false, // 根据版本自动配置 52 | } 53 | if db, err := gorm.Open(mysql.New(mysqlConfig), internal.Gorm.Config()); err != nil { 54 | panic(err) 55 | } else { 56 | sqlDB, _ := db.DB() 57 | sqlDB.SetMaxIdleConns(m.MaxIdleConns) 58 | sqlDB.SetMaxOpenConns(m.MaxOpenConns) 59 | return db 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /server/initialize/gorm_pgsql.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import ( 4 | "raptor/server/config" 5 | "raptor/server/global" 6 | "raptor/server/initialize/internal" 7 | "gorm.io/driver/postgres" 8 | "gorm.io/gorm" 9 | ) 10 | 11 | // GormPgSql 初始化 Postgresql 数据库 12 | // Author [piexlmax](https://github.com/piexlmax) 13 | // Author [SliverHorn](https://github.com/SliverHorn) 14 | func GormPgSql() *gorm.DB { 15 | p := global.GVA_CONFIG.Pgsql 16 | if p.Dbname == "" { 17 | return nil 18 | } 19 | pgsqlConfig := postgres.Config{ 20 | DSN: p.Dsn(), // DSN data source name 21 | PreferSimpleProtocol: false, 22 | } 23 | if db, err := gorm.Open(postgres.New(pgsqlConfig), internal.Gorm.Config()); err != nil { 24 | return nil 25 | } else { 26 | sqlDB, _ := db.DB() 27 | sqlDB.SetMaxIdleConns(p.MaxIdleConns) 28 | sqlDB.SetMaxOpenConns(p.MaxOpenConns) 29 | return db 30 | } 31 | } 32 | 33 | // GormPgSqlByConfig 初始化 Postgresql 数据库 通过参数 34 | func GormPgSqlByConfig(p config.DB) *gorm.DB { 35 | if p.Dbname == "" { 36 | return nil 37 | } 38 | pgsqlConfig := postgres.Config{ 39 | DSN: p.Dsn(), // DSN data source name 40 | PreferSimpleProtocol: false, 41 | } 42 | if db, err := gorm.Open(postgres.New(pgsqlConfig), internal.Gorm.Config()); err != nil { 43 | panic(err) 44 | } else { 45 | sqlDB, _ := db.DB() 46 | sqlDB.SetMaxIdleConns(p.MaxIdleConns) 47 | sqlDB.SetMaxOpenConns(p.MaxOpenConns) 48 | return db 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /server/initialize/internal/gorm.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "log" 5 | "os" 6 | "time" 7 | 8 | "raptor/server/global" 9 | "gorm.io/gorm" 10 | "gorm.io/gorm/logger" 11 | ) 12 | 13 | type DBBASE interface { 14 | GetLogMode() string 15 | } 16 | 17 | var Gorm = new(_gorm) 18 | 19 | type _gorm struct{} 20 | 21 | // Config gorm 自定义配置 22 | // Author [SliverHorn](https://github.com/SliverHorn) 23 | func (g *_gorm) Config() *gorm.Config { 24 | config := &gorm.Config{DisableForeignKeyConstraintWhenMigrating: true} 25 | _default := logger.New(NewWriter(log.New(os.Stdout, "\r\n", log.LstdFlags)), logger.Config{ 26 | SlowThreshold: 200 * time.Millisecond, 27 | LogLevel: logger.Warn, 28 | Colorful: true, 29 | }) 30 | var logMode DBBASE 31 | switch global.GVA_CONFIG.System.DbType { 32 | case "mysql": 33 | logMode = &global.GVA_CONFIG.Mysql 34 | break 35 | case "pgsql": 36 | logMode = &global.GVA_CONFIG.Pgsql 37 | break 38 | default: 39 | logMode = &global.GVA_CONFIG.Mysql 40 | } 41 | 42 | switch logMode.GetLogMode() { 43 | case "silent", "Silent": 44 | config.Logger = _default.LogMode(logger.Silent) 45 | case "error", "Error": 46 | config.Logger = _default.LogMode(logger.Error) 47 | case "warn", "Warn": 48 | config.Logger = _default.LogMode(logger.Warn) 49 | case "info", "Info": 50 | config.Logger = _default.LogMode(logger.Info) 51 | default: 52 | config.Logger = _default.LogMode(logger.Info) 53 | } 54 | return config 55 | } 56 | -------------------------------------------------------------------------------- /server/initialize/internal/logger.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "fmt" 5 | 6 | "raptor/server/global" 7 | "gorm.io/gorm/logger" 8 | ) 9 | 10 | type writer struct { 11 | logger.Writer 12 | } 13 | 14 | // NewWriter writer 构造函数 15 | // Author [SliverHorn](https://github.com/SliverHorn) 16 | func NewWriter(w logger.Writer) *writer { 17 | return &writer{Writer: w} 18 | } 19 | 20 | // Printf 格式化打印日志 21 | // Author [SliverHorn](https://github.com/SliverHorn) 22 | func (w *writer) Printf(message string, data ...interface{}) { 23 | var logZap bool 24 | switch global.GVA_CONFIG.System.DbType { 25 | case "mysql": 26 | logZap = global.GVA_CONFIG.Mysql.LogZap 27 | case "pgsql": 28 | logZap = global.GVA_CONFIG.Pgsql.LogZap 29 | } 30 | if logZap { 31 | global.GVA_LOG.Info(fmt.Sprintf(message+"\n", data...)) 32 | } else { 33 | w.Writer.Printf(message, data...) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /server/initialize/plugin.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import ( 4 | "raptor/server/global" 5 | email "github.com/flipped-aurora/gva-plugins/email" // 在线仓库模式go 6 | //"raptor/server/plugin/email" // 本地插件仓库地址模式 7 | "raptor/server/plugin/example_plugin" 8 | "raptor/server/utils/plugin" 9 | "github.com/gin-gonic/gin" 10 | ) 11 | 12 | func PluginInit(group *gin.RouterGroup, Plugin ...plugin.Plugin) { 13 | for i := range Plugin { 14 | PluginGroup := group.Group(Plugin[i].RouterPath()) 15 | Plugin[i].Register(PluginGroup) 16 | } 17 | } 18 | 19 | func InstallPlugin(PublicGroup *gin.RouterGroup, PrivateGroup *gin.RouterGroup) { 20 | // 添加开放权限的插件 示例 21 | PluginInit(PublicGroup, 22 | example_plugin.ExamplePlugin) 23 | 24 | // 添加跟角色挂钩权限的插件 示例 本地示例模式于在线仓库模式注意上方的import 可以自行切换 效果相同 25 | PluginInit(PrivateGroup, email.CreateEmailPlug( 26 | global.GVA_CONFIG.Email.To, 27 | global.GVA_CONFIG.Email.From, 28 | global.GVA_CONFIG.Email.Host, 29 | global.GVA_CONFIG.Email.Secret, 30 | global.GVA_CONFIG.Email.Nickname, 31 | global.GVA_CONFIG.Email.Port, 32 | global.GVA_CONFIG.Email.IsSSL, 33 | )) 34 | } 35 | -------------------------------------------------------------------------------- /server/initialize/redis.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import ( 4 | "context" 5 | 6 | "raptor/server/global" 7 | 8 | "github.com/go-redis/redis/v8" 9 | "go.uber.org/zap" 10 | ) 11 | 12 | func Redis() { 13 | redisCfg := global.GVA_CONFIG.Redis 14 | client := redis.NewClient(&redis.Options{ 15 | Addr: redisCfg.Addr, 16 | Password: redisCfg.Password, // no password set 17 | DB: redisCfg.DB, // use default DB 18 | }) 19 | pong, err := client.Ping(context.Background()).Result() 20 | if err != nil { 21 | global.GVA_LOG.Error("redis connect ping failed, err:", zap.Error(err)) 22 | } else { 23 | global.GVA_LOG.Info("redis connect ping response:", zap.String("pong", pong)) 24 | global.GVA_REDIS = client 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /server/initialize/timer.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import ( 4 | "fmt" 5 | 6 | "raptor/server/config" 7 | "raptor/server/global" 8 | "raptor/server/utils" 9 | ) 10 | 11 | func Timer() { 12 | if global.GVA_CONFIG.Timer.Start { 13 | for i := range global.GVA_CONFIG.Timer.Detail { 14 | go func(detail config.Detail) { 15 | global.GVA_Timer.AddTaskByFunc("ClearDB", global.GVA_CONFIG.Timer.Spec, func() { 16 | err := utils.ClearTable(global.GVA_DB, detail.TableName, detail.CompareField, detail.Interval) 17 | if err != nil { 18 | fmt.Println("timer error:", err) 19 | } 20 | }) 21 | }(global.GVA_CONFIG.Timer.Detail[i]) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /server/initialize/validator.go: -------------------------------------------------------------------------------- 1 | package initialize 2 | 3 | import "raptor/server/utils" 4 | 5 | func init() { 6 | _ = utils.RegisterRule("PageVerify", 7 | utils.Rules{ 8 | "Page": {utils.NotEmpty()}, 9 | "PageSize": {utils.NotEmpty()}, 10 | }, 11 | ) 12 | _ = utils.RegisterRule("IdVerify", 13 | utils.Rules{ 14 | "Id": {utils.NotEmpty()}, 15 | }, 16 | ) 17 | _ = utils.RegisterRule("AuthorityIdVerify", 18 | utils.Rules{ 19 | "AuthorityId": {utils.NotEmpty()}, 20 | }, 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "go.uber.org/zap" 5 | "raptor/server/core" 6 | "raptor/server/global" 7 | "raptor/server/initialize" 8 | ) 9 | 10 | //go:generate go env -w GO111MODULE=on 11 | //go:generate go env -w GOPROXY=https://goproxy.cn,direct 12 | //go:generate go mod tidy 13 | //go:generate go mod download 14 | 15 | // @title Swagger Example API 16 | // @version 0.0.1 17 | // @description This is a sample Server pets 18 | // @securityDefinitions.apikey ApiKeyAuth 19 | // @in header 20 | // @name x-token 21 | // @BasePath / 22 | func main() { 23 | global.GVA_VP = core.Viper() // 初始化Viper 24 | global.GVA_LOG = core.Zap() // 初始化zap日志库 25 | zap.ReplaceGlobals(global.GVA_LOG) 26 | global.GVA_DB = initialize.Gorm() // gorm连接数据库 27 | initialize.Timer() 28 | initialize.DBList() 29 | if global.GVA_DB != nil { 30 | initialize.RegisterTables(global.GVA_DB) // 初始化表 31 | // 程序结束前关闭数据库链接 32 | db, _ := global.GVA_DB.DB() 33 | defer db.Close() 34 | } 35 | core.RunWindowsServer() 36 | } 37 | -------------------------------------------------------------------------------- /server/middleware/casbin_rbac.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/common/response" 6 | "raptor/server/service" 7 | "raptor/server/utils" 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | var casbinService = service.ServiceGroupApp.SystemServiceGroup.CasbinService 12 | 13 | // 拦截器 14 | func CasbinHandler() gin.HandlerFunc { 15 | return func(c *gin.Context) { 16 | waitUse, _ := utils.GetClaims(c) 17 | // 获取请求的PATH 18 | obj := c.Request.URL.Path 19 | // 获取请求方法 20 | act := c.Request.Method 21 | // 获取用户的角色 22 | sub := waitUse.AuthorityId 23 | e := casbinService.Casbin() 24 | // 判断策略中是否存在 25 | success, _ := e.Enforce(sub, obj, act) 26 | if global.GVA_CONFIG.System.Env == "develop" || success { 27 | c.Next() 28 | } else { 29 | response.FailWithDetailed(gin.H{}, "权限不足", c) 30 | c.Abort() 31 | return 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /server/middleware/email.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "io/ioutil" 5 | "strconv" 6 | "time" 7 | 8 | "raptor/server/plugin/email/utils" 9 | utils2 "raptor/server/utils" 10 | 11 | "raptor/server/global" 12 | "raptor/server/model/system" 13 | "raptor/server/service" 14 | "github.com/gin-gonic/gin" 15 | "go.uber.org/zap" 16 | ) 17 | 18 | var userService = service.ServiceGroupApp.SystemServiceGroup.UserService 19 | 20 | func ErrorToEmail() gin.HandlerFunc { 21 | return func(c *gin.Context) { 22 | var username string 23 | claims, _ := utils2.GetClaims(c) 24 | if claims.Username != "" { 25 | username = claims.Username 26 | } else { 27 | id, _ := strconv.Atoi(c.Request.Header.Get("x-user-id")) 28 | err, user := userService.FindUserById(id) 29 | if err != nil { 30 | username = "Unknown" 31 | } 32 | username = user.Username 33 | } 34 | body, _ := ioutil.ReadAll(c.Request.Body) 35 | record := system.SysOperationRecord{ 36 | Ip: c.ClientIP(), 37 | Method: c.Request.Method, 38 | Path: c.Request.URL.Path, 39 | Agent: c.Request.UserAgent(), 40 | Body: string(body), 41 | } 42 | now := time.Now() 43 | 44 | c.Next() 45 | 46 | latency := time.Since(now) 47 | status := c.Writer.Status() 48 | record.ErrorMessage = c.Errors.ByType(gin.ErrorTypePrivate).String() 49 | str := "接收到的请求为" + record.Body + "\n" + "请求方式为" + record.Method + "\n" + "报错信息如下" + record.ErrorMessage + "\n" + "耗时" + latency.String() + "\n" 50 | if status != 200 { 51 | subject := username + "" + record.Ip + "调用了" + record.Path + "报错了" 52 | if err := utils.ErrorToEmail(subject, str); err != nil { 53 | global.GVA_LOG.Error("ErrorToEmail Failed, err:", zap.Error(err)) 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /server/middleware/error.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "net" 5 | "net/http" 6 | "net/http/httputil" 7 | "os" 8 | "runtime/debug" 9 | "strings" 10 | 11 | "raptor/server/global" 12 | "github.com/gin-gonic/gin" 13 | "go.uber.org/zap" 14 | ) 15 | 16 | // GinRecovery recover掉项目可能出现的panic,并使用zap记录相关日志 17 | func GinRecovery(stack bool) gin.HandlerFunc { 18 | return func(c *gin.Context) { 19 | defer func() { 20 | if err := recover(); err != nil { 21 | // Check for a broken connection, as it is not really a 22 | // condition that warrants a panic stack trace. 23 | var brokenPipe bool 24 | if ne, ok := err.(*net.OpError); ok { 25 | if se, ok := ne.Err.(*os.SyscallError); ok { 26 | if strings.Contains(strings.ToLower(se.Error()), "broken pipe") || strings.Contains(strings.ToLower(se.Error()), "connection reset by peer") { 27 | brokenPipe = true 28 | } 29 | } 30 | } 31 | 32 | httpRequest, _ := httputil.DumpRequest(c.Request, false) 33 | if brokenPipe { 34 | global.GVA_LOG.Error(c.Request.URL.Path, 35 | zap.Any("error", err), 36 | zap.String("request", string(httpRequest)), 37 | ) 38 | // If the connection is dead, we can't write a status to it. 39 | _ = c.Error(err.(error)) // nolint: errcheck 40 | c.Abort() 41 | return 42 | } 43 | 44 | if stack { 45 | global.GVA_LOG.Error("[Recovery from panic]", 46 | zap.Any("error", err), 47 | zap.String("request", string(httpRequest)), 48 | zap.String("stack", string(debug.Stack())), 49 | ) 50 | } else { 51 | global.GVA_LOG.Error("[Recovery from panic]", 52 | zap.Any("error", err), 53 | zap.String("request", string(httpRequest)), 54 | ) 55 | } 56 | c.AbortWithStatus(http.StatusInternalServerError) 57 | } 58 | }() 59 | c.Next() 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /server/middleware/loadtls.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/gin-gonic/gin" 7 | "github.com/unrolled/secure" 8 | ) 9 | 10 | // 用https把这个中间件在router里面use一下就好 11 | 12 | func LoadTls() gin.HandlerFunc { 13 | return func(c *gin.Context) { 14 | middleware := secure.New(secure.Options{ 15 | SSLRedirect: true, 16 | SSLHost: "localhost:443", 17 | }) 18 | err := middleware.Process(c.Writer, c.Request) 19 | if err != nil { 20 | // 如果出现错误,请不要继续 21 | fmt.Println(err) 22 | return 23 | } 24 | // 继续往下处理 25 | c.Next() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/middleware/need_init.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/common/response" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | // 处理跨域请求,支持options访问 10 | func NeedInit() gin.HandlerFunc { 11 | return func(c *gin.Context) { 12 | if global.GVA_DB == nil { 13 | response.OkWithDetailed(gin.H{ 14 | "needInit": true, 15 | }, "前往初始化数据库", c) 16 | c.Abort() 17 | } else { 18 | c.Next() 19 | } 20 | // 处理请求 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /server/model/autocode/autocodeExample.go: -------------------------------------------------------------------------------- 1 | // 自动生成模板SysDictionaryDetail 2 | package autocode 3 | 4 | import ( 5 | "raptor/server/global" 6 | ) 7 | 8 | // 如果含有time.Time 请自行import time包 9 | type AutoCodeExample struct { 10 | global.GVA_MODEL 11 | AutoCodeExampleField string `json:"autoCodeExampleField" form:"autoCodeExampleField" gorm:"column:auto_code_example_field;comment:仅作示例条目无实际作用"` // 展示值 12 | } 13 | -------------------------------------------------------------------------------- /server/model/autocode/build.go: -------------------------------------------------------------------------------- 1 | // 自动生成模板Build 2 | package autocode 3 | 4 | import ( 5 | "raptor/server/global" 6 | ) 7 | 8 | // Build 结构体 9 | // 如果含有time.Time 请自行import time包 10 | type Build struct { 11 | global.GVA_MODEL 12 | Name string `json:"name" form:"name" gorm:"column:name;comment:构建名称;size:255;"` 13 | Static string `json:"static" form:"static" gorm:"column:static;comment:构建状态;size:255;"` 14 | Version string `json:"version" form:"version" gorm:"column:version;comment:版本号;size:255;"` 15 | Info string `json:"info" form:"info" gorm:"column:info;comment:构建信息;"` 16 | History string `json:"history" form:"history" gorm:"column:history;comment:执行历史;"` 17 | Other string `json:"other" form:"other" gorm:"column:other;comment:其他;"` 18 | } 19 | 20 | 21 | // TableName Build 表名 22 | func (Build) TableName() string { 23 | return "build" 24 | } 25 | 26 | -------------------------------------------------------------------------------- /server/model/autocode/key.go: -------------------------------------------------------------------------------- 1 | // 自动生成模板Key 2 | package autocode 3 | 4 | import ( 5 | "raptor/server/global" 6 | ) 7 | 8 | // Key 结构体 9 | // 如果含有time.Time 请自行import time包 10 | type Key struct { 11 | global.GVA_MODEL 12 | Type string `json:"type" form:"type" gorm:"column:type;comment:类型;size:255;"` 13 | Region string `json:"region" form:"region" gorm:"column:region;comment:区域/地址;size:255;"` 14 | Keyid string `json:"keyid" form:"keyid" gorm:"column:keyid;comment:钥匙;size:255;"` 15 | Secret string `json:"secret" form:"secret" gorm:"column:secret;comment:密钥;size:255;"` 16 | Other string `json:"other" form:"other" gorm:"column:other;comment:其他;size:255;"` 17 | } 18 | 19 | 20 | // TableName Key 表名 21 | func (Key) TableName() string { 22 | return "key" 23 | } 24 | 25 | -------------------------------------------------------------------------------- /server/model/autocode/product.go: -------------------------------------------------------------------------------- 1 | // 自动生成模板Product 2 | package autocode 3 | 4 | import ( 5 | "raptor/server/global" 6 | ) 7 | 8 | // Product 结构体 9 | // 如果含有time.Time 请自行import time包 10 | type Product struct { 11 | global.GVA_MODEL 12 | Name string `json:"name" form:"name" gorm:"column:name;comment:名称;size:255;"` 13 | Other string `json:"other" form:"other" gorm:"column:other;comment:其他;size:255;"` 14 | } 15 | 16 | 17 | // TableName Product 表名 18 | func (Product) TableName() string { 19 | return "product" 20 | } 21 | 22 | -------------------------------------------------------------------------------- /server/model/autocode/request/asset.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/autocode" 5 | "raptor/server/model/common/request" 6 | ) 7 | 8 | type AssetSearch struct{ 9 | autocode.Asset 10 | request.PageInfo 11 | } -------------------------------------------------------------------------------- /server/model/autocode/request/autocodeExample.go: -------------------------------------------------------------------------------- 1 | // 自动生成模板SysDictionaryDetail 2 | package request 3 | 4 | import ( 5 | "raptor/server/model/autocode" 6 | "raptor/server/model/common/request" 7 | ) 8 | 9 | // 如果含有time.Time 请自行import time包 10 | type AutoCodeExampleSearch struct { 11 | autocode.AutoCodeExample 12 | request.PageInfo 13 | } 14 | -------------------------------------------------------------------------------- /server/model/autocode/request/build.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/autocode" 5 | "raptor/server/model/common/request" 6 | ) 7 | 8 | type BuildSearch struct{ 9 | autocode.Build 10 | request.PageInfo 11 | } -------------------------------------------------------------------------------- /server/model/autocode/request/key.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/autocode" 5 | "raptor/server/model/common/request" 6 | ) 7 | 8 | type KeySearch struct{ 9 | autocode.Key 10 | request.PageInfo 11 | } -------------------------------------------------------------------------------- /server/model/autocode/request/product.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/autocode" 5 | "raptor/server/model/common/request" 6 | ) 7 | 8 | type ProductSearch struct{ 9 | autocode.Product 10 | request.PageInfo 11 | } -------------------------------------------------------------------------------- /server/model/autocode/request/service.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/autocode" 5 | "raptor/server/model/common/request" 6 | ) 7 | 8 | type ServiceSearch struct{ 9 | autocode.Service 10 | request.PageInfo 11 | } -------------------------------------------------------------------------------- /server/model/autocode/service.go: -------------------------------------------------------------------------------- 1 | // 自动生成模板Service 2 | package autocode 3 | 4 | import ( 5 | "raptor/server/global" 6 | ) 7 | 8 | // Service 结构体 9 | // 如果含有time.Time 请自行import time包 10 | type Service struct { 11 | global.GVA_MODEL 12 | Name string `json:"name" form:"name" gorm:"column:name;comment:项目名称;size:255;"` 13 | Type string `json:"type" form:"type" gorm:"column:type;comment:类型;size:255;"` 14 | Url string `json:"url" form:"url" gorm:"column:url;comment:库地址;size:255;"` 15 | Branch string `json:"branch" form:"branch" gorm:"column:branch;comment:分支;size:255;"` 16 | Start string `json:"start" form:"start" gorm:"column:start;comment:启动命令;size:255;"` 17 | Stop string `json:"stop" form:"stop" gorm:"column:stop;comment:关闭命令;size:255;"` 18 | Activity string `json:"activity" form:"activity" gorm:"column:activity;comment:探活地址;size:255;"` 19 | Env string `json:"env" form:"env" gorm:"column:env;comment:环境变量;"` 20 | Shell string `json:"shell" form:"shell" gorm:"column:shell;comment:打包命令;"` 21 | Other string `json:"other" form:"other" gorm:"column:other;comment:其他;"` 22 | Products []Product `json:"products" gorm:"many2many:service_product_id;"` 23 | } 24 | 25 | 26 | // TableName Service 表名 27 | func (Service) TableName() string { 28 | return "service" 29 | } 30 | 31 | -------------------------------------------------------------------------------- /server/model/common/request/common.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | // PageInfo Paging common input parameter structure 4 | type PageInfo struct { 5 | Page int `json:"page" form:"page"` // 页码 6 | PageSize int `json:"pageSize" form:"pageSize"` // 每页大小 7 | } 8 | 9 | // GetById Find by id structure 10 | type GetById struct { 11 | ID int `json:"id" form:"id"` // 主键ID 12 | } 13 | 14 | func (r *GetById) Uint() uint { 15 | return uint(r.ID) 16 | } 17 | 18 | type IdsReq struct { 19 | Ids []int `json:"ids" form:"ids"` 20 | } 21 | 22 | // GetAuthorityId Get role by id structure 23 | type GetAuthorityId struct { 24 | AuthorityId string `json:"authorityId" form:"authorityId"` // 角色ID 25 | } 26 | 27 | type Empty struct{} 28 | -------------------------------------------------------------------------------- /server/model/common/response/common.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | type PageResult struct { 4 | List interface{} `json:"list"` 5 | Total int64 `json:"total"` 6 | Page int `json:"page"` 7 | PageSize int `json:"pageSize"` 8 | } 9 | -------------------------------------------------------------------------------- /server/model/common/response/response.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type Response struct { 10 | Code int `json:"code"` 11 | Data interface{} `json:"data"` 12 | Msg string `json:"msg"` 13 | } 14 | 15 | const ( 16 | ERROR = 7 17 | SUCCESS = 0 18 | ) 19 | 20 | func Result(code int, data interface{}, msg string, c *gin.Context) { 21 | // 开始时间 22 | c.JSON(http.StatusOK, Response{ 23 | code, 24 | data, 25 | msg, 26 | }) 27 | } 28 | 29 | func Ok(c *gin.Context) { 30 | Result(SUCCESS, map[string]interface{}{}, "操作成功", c) 31 | } 32 | 33 | func OkWithMessage(message string, c *gin.Context) { 34 | Result(SUCCESS, map[string]interface{}{}, message, c) 35 | } 36 | 37 | func OkWithData(data interface{}, c *gin.Context) { 38 | Result(SUCCESS, data, "操作成功", c) 39 | } 40 | 41 | func OkWithDetailed(data interface{}, message string, c *gin.Context) { 42 | Result(SUCCESS, data, message, c) 43 | } 44 | 45 | func Fail(c *gin.Context) { 46 | Result(ERROR, map[string]interface{}{}, "操作失败", c) 47 | } 48 | 49 | func FailWithMessage(message string, c *gin.Context) { 50 | Result(ERROR, map[string]interface{}{}, message, c) 51 | } 52 | 53 | func FailWithDetailed(data interface{}, message string, c *gin.Context) { 54 | Result(ERROR, data, message, c) 55 | } 56 | -------------------------------------------------------------------------------- /server/model/example/exa_breakpoint_continue.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import ( 4 | "raptor/server/global" 5 | ) 6 | 7 | // file struct, 文件结构体 8 | type ExaFile struct { 9 | global.GVA_MODEL 10 | FileName string 11 | FileMd5 string 12 | FilePath string 13 | ExaFileChunk []ExaFileChunk 14 | ChunkTotal int 15 | IsFinish bool 16 | } 17 | 18 | // file chunk struct, 切片结构体 19 | type ExaFileChunk struct { 20 | global.GVA_MODEL 21 | ExaFileID uint 22 | FileChunkNumber int 23 | FileChunkPath string 24 | } 25 | -------------------------------------------------------------------------------- /server/model/example/exa_customer.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/system" 6 | ) 7 | 8 | type ExaCustomer struct { 9 | global.GVA_MODEL 10 | CustomerName string `json:"customerName" form:"customerName" gorm:"comment:客户名"` // 客户名 11 | CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData" gorm:"comment:客户手机号"` // 客户手机号 12 | SysUserID uint `json:"sysUserId" form:"sysUserId" gorm:"comment:管理ID"` // 管理ID 13 | SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:管理角色ID"` // 管理角色ID 14 | SysUser system.SysUser `json:"sysUser" form:"sysUser" gorm:"comment:管理详情"` // 管理详情 15 | } 16 | -------------------------------------------------------------------------------- /server/model/example/exa_excel.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import "raptor/server/model/system" 4 | 5 | type ExcelInfo struct { 6 | FileName string `json:"fileName"` // 文件名 7 | InfoList []system.SysBaseMenu `json:"infoList"` 8 | } 9 | -------------------------------------------------------------------------------- /server/model/example/exa_file_upload_download.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import ( 4 | "raptor/server/global" 5 | ) 6 | 7 | type ExaFileUploadAndDownload struct { 8 | global.GVA_MODEL 9 | Name string `json:"name" gorm:"comment:文件名"` // 文件名 10 | Url string `json:"url" gorm:"comment:文件地址"` // 文件地址 11 | Tag string `json:"tag" gorm:"comment:文件标签"` // 文件标签 12 | Key string `json:"key" gorm:"comment:编号"` // 编号 13 | } 14 | -------------------------------------------------------------------------------- /server/model/example/response/exa_breakpoint_continue.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import "raptor/server/model/example" 4 | 5 | type FilePathResponse struct { 6 | FilePath string `json:"filePath"` 7 | } 8 | 9 | type FileResponse struct { 10 | File example.ExaFile `json:"file"` 11 | } 12 | -------------------------------------------------------------------------------- /server/model/example/response/exa_customer.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import "raptor/server/model/example" 4 | 5 | type ExaCustomerResponse struct { 6 | Customer example.ExaCustomer `json:"customer"` 7 | } 8 | -------------------------------------------------------------------------------- /server/model/example/response/exa_file_upload_download.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import "raptor/server/model/example" 4 | 5 | type ExaFileResponse struct { 6 | File example.ExaFileUploadAndDownload `json:"file"` 7 | } 8 | -------------------------------------------------------------------------------- /server/model/system/request/jwt.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "github.com/golang-jwt/jwt/v4" 5 | uuid "github.com/satori/go.uuid" 6 | ) 7 | 8 | // Custom claims structure 9 | type CustomClaims struct { 10 | BaseClaims 11 | BufferTime int64 12 | jwt.StandardClaims 13 | } 14 | 15 | type BaseClaims struct { 16 | UUID uuid.UUID 17 | ID uint 18 | Username string 19 | NickName string 20 | AuthorityId string 21 | } 22 | -------------------------------------------------------------------------------- /server/model/system/request/sys_api.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/common/request" 5 | "raptor/server/model/system" 6 | ) 7 | 8 | // api分页条件查询及排序结构体 9 | type SearchApiParams struct { 10 | system.SysApi 11 | request.PageInfo 12 | OrderKey string `json:"orderKey"` // 排序 13 | Desc bool `json:"desc"` // 排序方式:升序false(默认)|降序true 14 | } 15 | -------------------------------------------------------------------------------- /server/model/system/request/sys_authority_btn.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | type SysAuthorityBtnReq struct { 4 | MenuID uint `json:"menuID"` 5 | AuthorityId string `json:"authorityId"` 6 | Selected []uint `json:"selected"` 7 | } 8 | -------------------------------------------------------------------------------- /server/model/system/request/sys_auto_history.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import "raptor/server/model/common/request" 4 | 5 | type SysAutoHistory struct { 6 | request.PageInfo 7 | } 8 | -------------------------------------------------------------------------------- /server/model/system/request/sys_casbin.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | // Casbin info structure 4 | type CasbinInfo struct { 5 | Path string `json:"path"` // 路径 6 | Method string `json:"method"` // 方法 7 | } 8 | 9 | // Casbin structure for input parameters 10 | type CasbinInReceive struct { 11 | AuthorityId string `json:"authorityId"` // 权限id 12 | CasbinInfos []CasbinInfo `json:"casbinInfos"` 13 | } 14 | 15 | func DefaultCasbin() []CasbinInfo { 16 | return []CasbinInfo{ 17 | {Path: "/menu/getMenu", Method: "POST"}, 18 | {Path: "/jwt/jsonInBlacklist", Method: "POST"}, 19 | {Path: "/base/login", Method: "POST"}, 20 | {Path: "/user/admin_register", Method: "POST"}, 21 | {Path: "/user/changePassword", Method: "POST"}, 22 | {Path: "/user/setUserAuthority", Method: "POST"}, 23 | {Path: "/user/setUserInfo", Method: "PUT"}, 24 | {Path: "/user/getUserInfo", Method: "GET"}, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /server/model/system/request/sys_dictionary.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/common/request" 5 | "raptor/server/model/system" 6 | ) 7 | 8 | type SysDictionarySearch struct { 9 | system.SysDictionary 10 | request.PageInfo 11 | } 12 | -------------------------------------------------------------------------------- /server/model/system/request/sys_dictionary_detail.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/common/request" 5 | "raptor/server/model/system" 6 | ) 7 | 8 | type SysDictionaryDetailSearch struct { 9 | system.SysDictionaryDetail 10 | request.PageInfo 11 | } 12 | -------------------------------------------------------------------------------- /server/model/system/request/sys_menu.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/system" 6 | ) 7 | 8 | // Add menu authority info structure 9 | type AddMenuAuthorityInfo struct { 10 | Menus []system.SysBaseMenu `json:"menus"` 11 | AuthorityId string `json:"authorityId"` // 角色ID 12 | } 13 | 14 | func DefaultMenu() []system.SysBaseMenu { 15 | return []system.SysBaseMenu{{ 16 | GVA_MODEL: global.GVA_MODEL{ID: 1}, 17 | ParentId: "0", 18 | Path: "dashboard", 19 | Name: "dashboard", 20 | Component: "view/dashboard/index.vue", 21 | Sort: 1, 22 | Meta: system.Meta{ 23 | Title: "仪表盘", 24 | Icon: "setting", 25 | }, 26 | }} 27 | } 28 | -------------------------------------------------------------------------------- /server/model/system/request/sys_operation_record.go: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/common/request" 5 | "raptor/server/model/system" 6 | ) 7 | 8 | type SysOperationRecordSearch struct { 9 | system.SysOperationRecord 10 | request.PageInfo 11 | } 12 | -------------------------------------------------------------------------------- /server/model/system/response/sys_api.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import "raptor/server/model/system" 4 | 5 | type SysAPIResponse struct { 6 | Api system.SysApi `json:"api"` 7 | } 8 | 9 | type SysAPIListResponse struct { 10 | Apis []system.SysApi `json:"apis"` 11 | } 12 | -------------------------------------------------------------------------------- /server/model/system/response/sys_authority.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import "raptor/server/model/system" 4 | 5 | type SysAuthorityResponse struct { 6 | Authority system.SysAuthority `json:"authority"` 7 | } 8 | 9 | type SysAuthorityCopyResponse struct { 10 | Authority system.SysAuthority `json:"authority"` 11 | OldAuthorityId string `json:"oldAuthorityId"` // 旧角色ID 12 | } 13 | -------------------------------------------------------------------------------- /server/model/system/response/sys_authority_btn.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | type SysAuthorityBtnRes struct { 4 | Selected []uint `json:"selected"` 5 | } 6 | -------------------------------------------------------------------------------- /server/model/system/response/sys_auto_code.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | type Db struct { 4 | Database string `json:"database" gorm:"column:database"` 5 | } 6 | 7 | type Table struct { 8 | TableName string `json:"tableName" gorm:"column:table_name"` 9 | } 10 | 11 | type Column struct { 12 | DataType string `json:"dataType" gorm:"column:data_type"` 13 | ColumnName string `json:"columnName" gorm:"column:column_name"` 14 | DataTypeLong string `json:"dataTypeLong" gorm:"column:data_type_long"` 15 | ColumnComment string `json:"columnComment" gorm:"column:column_comment"` 16 | } 17 | -------------------------------------------------------------------------------- /server/model/system/response/sys_auto_code_history.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import "time" 4 | 5 | type AutoCodeHistory struct { 6 | ID uint `json:"ID" gorm:"column:id"` 7 | CreatedAt time.Time `json:"CreatedAt" gorm:"column:created_at"` 8 | UpdatedAt time.Time `json:"UpdatedAt" gorm:"column:updated_at"` 9 | TableName string `json:"tableName" gorm:"column:table_name"` 10 | StructName string `json:"structName" gorm:"column:struct_name"` 11 | StructCNName string `json:"structCNName" gorm:"column:struct_cn_name"` 12 | Flag int `json:"flag" gorm:"column:flag"` 13 | } 14 | -------------------------------------------------------------------------------- /server/model/system/response/sys_captcha.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | type SysCaptchaResponse struct { 4 | CaptchaId string `json:"captchaId"` 5 | PicPath string `json:"picPath"` 6 | CaptchaLength int `json:"captchaLength""` 7 | } 8 | -------------------------------------------------------------------------------- /server/model/system/response/sys_casbin.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import ( 4 | "raptor/server/model/system/request" 5 | ) 6 | 7 | type PolicyPathResponse struct { 8 | Paths []request.CasbinInfo `json:"paths"` 9 | } 10 | -------------------------------------------------------------------------------- /server/model/system/response/sys_menu.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import "raptor/server/model/system" 4 | 5 | type SysMenusResponse struct { 6 | Menus []system.SysMenu `json:"menus"` 7 | } 8 | 9 | type SysBaseMenusResponse struct { 10 | Menus []system.SysBaseMenu `json:"menus"` 11 | } 12 | 13 | type SysBaseMenuResponse struct { 14 | Menu system.SysBaseMenu `json:"menu"` 15 | } 16 | -------------------------------------------------------------------------------- /server/model/system/response/sys_system.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import "raptor/server/config" 4 | 5 | type SysConfigResponse struct { 6 | Config config.Server `json:"config"` 7 | } 8 | -------------------------------------------------------------------------------- /server/model/system/response/sys_user.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | import ( 4 | "raptor/server/model/system" 5 | ) 6 | 7 | type SysUserResponse struct { 8 | User system.SysUser `json:"user"` 9 | } 10 | 11 | type LoginResponse struct { 12 | User system.SysUser `json:"user"` 13 | Token string `json:"token"` 14 | ExpiresAt int64 `json:"expiresAt"` 15 | } 16 | -------------------------------------------------------------------------------- /server/model/system/sys_api.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/global" 5 | ) 6 | 7 | type SysApi struct { 8 | global.GVA_MODEL 9 | Path string `json:"path" gorm:"comment:api路径"` // api路径 10 | Description string `json:"description" gorm:"comment:api中文描述"` // api中文描述 11 | ApiGroup string `json:"apiGroup" gorm:"comment:api组"` // api组 12 | Method string `json:"method" gorm:"default:POST;comment:方法"` // 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE 13 | } 14 | -------------------------------------------------------------------------------- /server/model/system/sys_authority.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | type SysAuthority struct { 8 | CreatedAt time.Time // 创建时间 9 | UpdatedAt time.Time // 更新时间 10 | DeletedAt *time.Time `sql:"index"` 11 | AuthorityId string `json:"authorityId" gorm:"not null;unique;primary_key;comment:角色ID;size:90"` // 角色ID 12 | AuthorityName string `json:"authorityName" gorm:"comment:角色名"` // 角色名 13 | ParentId string `json:"parentId" gorm:"comment:父角色ID"` // 父角色ID 14 | DataAuthorityId []SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id"` 15 | Children []SysAuthority `json:"children" gorm:"-"` 16 | SysBaseMenus []SysBaseMenu `json:"menus" gorm:"many2many:sys_authority_menus;"` 17 | Users []SysUser `json:"-" gorm:"many2many:sys_user_authority;"` 18 | DefaultRouter string `json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"` // 默认菜单(默认dashboard) 19 | } 20 | -------------------------------------------------------------------------------- /server/model/system/sys_authority_btn.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | type SysAuthorityBtn struct { 4 | AuthorityId string `gorm:"comment:角色ID"` 5 | SysMenuID uint `gorm:"comment:菜单ID"` 6 | SysBaseMenuBtnID uint `gorm:"comment:菜单按钮ID"` 7 | SysBaseMenuBtn SysBaseMenuBtn ` gorm:"comment:按钮详情"` 8 | } 9 | -------------------------------------------------------------------------------- /server/model/system/sys_authority_menu.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | type SysMenu struct { 4 | SysBaseMenu 5 | MenuId string `json:"menuId" gorm:"comment:菜单ID"` 6 | AuthorityId string `json:"-" gorm:"comment:角色ID"` 7 | Children []SysMenu `json:"children" gorm:"-"` 8 | Parameters []SysBaseMenuParameter `json:"parameters" gorm:"foreignKey:SysBaseMenuID;references:MenuId"` 9 | Btns map[string]string `json:"btns" gorm:"-"` 10 | } 11 | 12 | func (s SysMenu) TableName() string { 13 | return "authority_menu" 14 | } 15 | -------------------------------------------------------------------------------- /server/model/system/sys_auto_code.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import "errors" 4 | 5 | // AutoCodeStruct 初始版本自动化代码工具 6 | type AutoCodeStruct struct { 7 | StructName string `json:"structName"` // Struct名称 8 | TableName string `json:"tableName"` // 表名 9 | PackageName string `json:"packageName"` // 文件名称 10 | HumpPackageName string `json:"humpPackageName"` // go文件名称 11 | Abbreviation string `json:"abbreviation"` // Struct简称 12 | Description string `json:"description"` // Struct中文名称 13 | AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api 14 | AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件 15 | Fields []*Field `json:"fields"` 16 | DictTypes []string `json:"-"` 17 | } 18 | 19 | type Field struct { 20 | FieldName string `json:"fieldName"` // Field名 21 | FieldDesc string `json:"fieldDesc"` // 中文名 22 | FieldType string `json:"fieldType"` // Field数据类型 23 | FieldJson string `json:"fieldJson"` // FieldJson 24 | DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度 25 | Comment string `json:"comment"` // 数据库字段描述 26 | ColumnName string `json:"columnName"` // 数据库字段 27 | FieldSearchType string `json:"fieldSearchType"` // 搜索条件 28 | DictType string `json:"dictType"` // 字典 29 | } 30 | 31 | var AutoMoveErr error = errors.New("创建代码成功并移动文件成功") 32 | -------------------------------------------------------------------------------- /server/model/system/sys_autocode_history.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "strconv" 5 | "strings" 6 | 7 | "raptor/server/global" 8 | "raptor/server/model/common/request" 9 | ) 10 | 11 | // SysAutoCodeHistory 自动迁移代码记录,用于回滚,重放使用 12 | type SysAutoCodeHistory struct { 13 | global.GVA_MODEL 14 | TableName string `json:"tableName"` 15 | RequestMeta string `gorm:"type:text" json:"requestMeta,omitempty"` // 前端传入的结构化信息 16 | AutoCodePath string `gorm:"type:text" json:"autoCodePath,omitempty"` // 其他meta信息 path;path 17 | InjectionMeta string `gorm:"type:text" json:"injectionMeta,omitempty"` // 注入的内容 RouterPath@functionName@RouterString; 18 | StructName string `json:"structName"` 19 | StructCNName string `json:"structCNName"` 20 | ApiIDs string `json:"apiIDs,omitempty"` // api表注册内容 21 | Flag int `json:"flag"` // 表示对应状态 0 代表创建, 1 代表回滚 ... 22 | } 23 | 24 | // ToRequestIds ApiIDs 转换 request.IdsReq 25 | // Author [SliverHorn](https://github.com/SliverHorn) 26 | func (m *SysAutoCodeHistory) ToRequestIds() request.IdsReq { 27 | if m.ApiIDs == "" { 28 | return request.IdsReq{} 29 | } 30 | slice := strings.Split(m.ApiIDs, ";") 31 | ids := make([]int, 0, len(slice)) 32 | length := len(slice) 33 | for i := 0; i < length; i++ { 34 | id, _ := strconv.ParseInt(slice[i], 10, 32) 35 | ids = append(ids, int(id)) 36 | } 37 | return request.IdsReq{Ids: ids} 38 | } 39 | -------------------------------------------------------------------------------- /server/model/system/sys_dictionary.go: -------------------------------------------------------------------------------- 1 | // 自动生成模板SysDictionary 2 | package system 3 | 4 | import ( 5 | "raptor/server/global" 6 | ) 7 | 8 | // 如果含有time.Time 请自行import time包 9 | type SysDictionary struct { 10 | global.GVA_MODEL 11 | Name string `json:"name" form:"name" gorm:"column:name;comment:字典名(中)"` // 字典名(中) 12 | Type string `json:"type" form:"type" gorm:"column:type;comment:字典名(英)"` // 字典名(英) 13 | Status *bool `json:"status" form:"status" gorm:"column:status;comment:状态"` // 状态 14 | Desc string `json:"desc" form:"desc" gorm:"column:desc;comment:描述"` // 描述 15 | SysDictionaryDetails []SysDictionaryDetail `json:"sysDictionaryDetails" form:"sysDictionaryDetails"` 16 | } 17 | -------------------------------------------------------------------------------- /server/model/system/sys_dictionary_detail.go: -------------------------------------------------------------------------------- 1 | // 自动生成模板SysDictionaryDetail 2 | package system 3 | 4 | import ( 5 | "raptor/server/global" 6 | ) 7 | 8 | // 如果含有time.Time 请自行import time包 9 | type SysDictionaryDetail struct { 10 | global.GVA_MODEL 11 | Label string `json:"label" form:"label" gorm:"column:label;comment:展示值"` // 展示值 12 | Value int `json:"value" form:"value" gorm:"column:value;comment:字典值"` // 字典值 13 | Status *bool `json:"status" form:"status" gorm:"column:status;comment:启用状态"` // 启用状态 14 | Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:排序标记"` // 排序标记 15 | SysDictionaryID int `json:"sysDictionaryID" form:"sysDictionaryID" gorm:"column:sys_dictionary_id;comment:关联标记"` // 关联标记 16 | } 17 | -------------------------------------------------------------------------------- /server/model/system/sys_jwt_blacklist.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/global" 5 | ) 6 | 7 | type JwtBlacklist struct { 8 | global.GVA_MODEL 9 | Jwt string `gorm:"type:text;comment:jwt"` 10 | } 11 | -------------------------------------------------------------------------------- /server/model/system/sys_menu_btn.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import "raptor/server/global" 4 | 5 | type SysBaseMenuBtn struct { 6 | global.GVA_MODEL 7 | Name string `json:"name" gorm:"comment:按钮关键key"` 8 | Desc string `json:"desc" gorm:"按钮备注"` 9 | SysBaseMenuID uint `json:"sysBaseMenuID" gorm:"comment:菜单ID"` 10 | } 11 | -------------------------------------------------------------------------------- /server/model/system/sys_operation_record.go: -------------------------------------------------------------------------------- 1 | // 自动生成模板SysOperationRecord 2 | package system 3 | 4 | import ( 5 | "time" 6 | 7 | "raptor/server/global" 8 | ) 9 | 10 | // 如果含有time.Time 请自行import time包 11 | type SysOperationRecord struct { 12 | global.GVA_MODEL 13 | Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"` // 请求ip 14 | Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"` // 请求方法 15 | Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"` // 请求路径 16 | Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"` // 请求状态 17 | Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟" swaggertype:"string"` // 延迟 18 | Agent string `json:"agent" form:"agent" gorm:"column:agent;comment:代理"` // 代理 19 | ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"` // 错误信息 20 | Body string `json:"body" form:"body" gorm:"type:text;column:body;comment:请求Body"` // 请求Body 21 | Resp string `json:"resp" form:"resp" gorm:"type:text;column:resp;comment:响应Body"` // 响应Body 22 | UserID int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"` // 用户id 23 | User SysUser `json:"user"` 24 | } 25 | -------------------------------------------------------------------------------- /server/model/system/sys_system.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/config" 5 | ) 6 | 7 | // 配置文件结构体 8 | type System struct { 9 | Config config.Server `json:"config"` 10 | } 11 | -------------------------------------------------------------------------------- /server/model/system/sys_user.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/satori/go.uuid" 5 | "raptor/server/global" 6 | ) 7 | 8 | type SysUser struct { 9 | global.GVA_MODEL 10 | UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"` // 用户UUID 11 | Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名 12 | Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码 13 | Unionid string `json:"unionid" gorm:"comment:unionid"` // 用户登录名 14 | NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称 15 | SideMode string `json:"sideMode" gorm:"default:dark;comment:用户侧边主题"` // 用户侧边主题 16 | HeaderImg string `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像 17 | BaseColor string `json:"baseColor" gorm:"default:#fff;comment:基础颜色"` // 基础颜色 18 | ActiveColor string `json:"activeColor" gorm:"default:#1890ff;comment:活跃颜色"` // 活跃颜色 19 | AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID 20 | Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"` 21 | Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"` 22 | Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户角色ID 23 | Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱 24 | } 25 | -------------------------------------------------------------------------------- /server/model/system/sys_user_authority.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | type SysUseAuthority struct { 4 | SysUserId uint `gorm:"column:sys_user_id"` 5 | SysAuthorityAuthorityId string `gorm:"column:sys_authority_authority_id"` 6 | } 7 | 8 | func (s *SysUseAuthority) TableName() string { 9 | return "sys_user_authority" 10 | } 11 | -------------------------------------------------------------------------------- /server/packfile/notUsePackFile.go: -------------------------------------------------------------------------------- 1 | //go:build !packfile 2 | // +build !packfile 3 | 4 | package packfile 5 | -------------------------------------------------------------------------------- /server/packfile/usePackFile.go: -------------------------------------------------------------------------------- 1 | //go:build packfile 2 | // +build packfile 3 | 4 | package packfile 5 | 6 | import ( 7 | "fmt" 8 | "io/ioutil" 9 | "os" 10 | "path/filepath" 11 | "strings" 12 | ) 13 | 14 | //go:generate go-bindata -o=staticFile.go -pkg=packfile -tags=packfile ../resource/... ../config.yaml 15 | 16 | func writeFile(path string, data []byte) { 17 | // 如果文件夹不存在,预先创建文件夹 18 | if lastSeparator := strings.LastIndex(path, "/"); lastSeparator != -1 { 19 | dirPath := path[:lastSeparator] 20 | if _, err := os.Stat(dirPath); err != nil && os.IsNotExist(err) { 21 | os.MkdirAll(dirPath, os.ModePerm) 22 | } 23 | } 24 | 25 | // 已存在的文件,不应该覆盖重写,可能在前端更改了配置文件等 26 | if _, err := os.Stat(path); os.IsNotExist(err) { 27 | if err2 := ioutil.WriteFile(path, data, os.ModePerm); err2 != nil { 28 | fmt.Printf("Write file failed: %s\n", path) 29 | } 30 | } else { 31 | fmt.Printf("File exist, skip: %s\n", path) 32 | } 33 | } 34 | 35 | func init() { 36 | for key := range _bindata { 37 | filePath, _ := filepath.Abs(strings.TrimPrefix(key, ".")) 38 | data, err := Asset(key) 39 | if err != nil { 40 | // Asset was not found. 41 | fmt.Printf("Fail to find: %s\n", filePath) 42 | } else { 43 | writeFile(filePath, data) 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /server/plugin/email/api/enter.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | type ApiGroup struct { 4 | EmailApi 5 | } 6 | 7 | var ApiGroupApp = new(ApiGroup) 8 | -------------------------------------------------------------------------------- /server/plugin/email/api/sys_email.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/common/response" 6 | email_response "raptor/server/plugin/email/model/response" 7 | "raptor/server/plugin/email/service" 8 | "github.com/gin-gonic/gin" 9 | "go.uber.org/zap" 10 | ) 11 | 12 | type EmailApi struct{} 13 | 14 | // @Tags System 15 | // @Summary 发送测试邮件 16 | // @Security ApiKeyAuth 17 | // @Produce application/json 18 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}" 19 | // @Router /email/emailTest [post] 20 | func (s *EmailApi) EmailTest(c *gin.Context) { 21 | if err := service.ServiceGroupApp.EmailTest(); err != nil { 22 | global.GVA_LOG.Error("发送失败!", zap.Error(err)) 23 | response.FailWithMessage("发送失败", c) 24 | } else { 25 | response.OkWithData("发送成功", c) 26 | } 27 | } 28 | 29 | // @Tags System 30 | // @Summary 发送邮件 31 | // @Security ApiKeyAuth 32 | // @Produce application/json 33 | // @Param data body email_response.Email true "发送邮件必须的参数" 34 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}" 35 | // @Router /email/sendEmail [post] 36 | func (s *EmailApi) SendEmail(c *gin.Context) { 37 | var email email_response.Email 38 | _ = c.ShouldBindJSON(&email) 39 | if err := service.ServiceGroupApp.SendEmail(email.To, email.Subject, email.Body); err != nil { 40 | global.GVA_LOG.Error("发送失败!", zap.Error(err)) 41 | response.FailWithMessage("发送失败", c) 42 | } else { 43 | response.OkWithData("发送成功", c) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/plugin/email/config/email.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | type Email struct { 4 | To string `mapstructure:"to" json:"to" yaml:"to"` // 收件人:多个以英文逗号分隔 例:a@qq.com b@qq.com 正式开发中请把此项目作为参数使用 5 | From string `mapstructure:"from" json:"from" yaml:"from"` // 发件人 你自己要发邮件的邮箱 6 | Host string `mapstructure:"host" json:"host" yaml:"host"` // 服务器地址 例如 smtp.qq.com 请前往QQ或者你要发邮件的邮箱查看其smtp协议 7 | Secret string `mapstructure:"secret" json:"secret" yaml:"secret"` // 密钥 用于登录的密钥 最好不要用邮箱密码 去邮箱smtp申请一个用于登录的密钥 8 | Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"` // 昵称 发件人昵称 通常为自己的邮箱 9 | Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口 请前往QQ或者你要发邮件的邮箱查看其smtp协议 大多为 465 10 | IsSSL bool `mapstructure:"is-ssl" json:"isSSL" yaml:"is-ssl"` // 是否SSL 是否开启SSL 11 | } 12 | -------------------------------------------------------------------------------- /server/plugin/email/global/gloabl.go: -------------------------------------------------------------------------------- 1 | package global 2 | 3 | import "raptor/server/plugin/email/config" 4 | 5 | var GlobalConfig = new(config.Email) 6 | -------------------------------------------------------------------------------- /server/plugin/email/main.go: -------------------------------------------------------------------------------- 1 | package email 2 | 3 | import ( 4 | "raptor/server/plugin/email/global" 5 | "raptor/server/plugin/email/router" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type emailPlugin struct{} 10 | 11 | func CreateEmailPlug(To, From, Host, Secret, Nickname string, Port int, IsSSL bool) *emailPlugin { 12 | global.GlobalConfig.To = To 13 | global.GlobalConfig.From = From 14 | global.GlobalConfig.Host = Host 15 | global.GlobalConfig.Secret = Secret 16 | global.GlobalConfig.Nickname = Nickname 17 | global.GlobalConfig.Port = Port 18 | global.GlobalConfig.IsSSL = IsSSL 19 | return &emailPlugin{} 20 | } 21 | 22 | func (*emailPlugin) Register(group *gin.RouterGroup) { 23 | router.RouterGroupApp.InitEmailRouter(group) 24 | } 25 | 26 | func (*emailPlugin) RouterPath() string { 27 | return "email" 28 | } 29 | -------------------------------------------------------------------------------- /server/plugin/email/model/response/email.go: -------------------------------------------------------------------------------- 1 | package response 2 | 3 | type Email struct { 4 | To string `json:"to"` // 邮件发送给谁 5 | Subject string `json:"subject"` // 邮件标题 6 | Body string `json:"body"` // 邮件内容 7 | } 8 | -------------------------------------------------------------------------------- /server/plugin/email/router/enter.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | type RouterGroup struct { 4 | EmailRouter 5 | } 6 | 7 | var RouterGroupApp = new(RouterGroup) 8 | -------------------------------------------------------------------------------- /server/plugin/email/router/sys_email.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "raptor/server/middleware" 5 | "raptor/server/plugin/email/api" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type EmailRouter struct{} 10 | 11 | func (s *EmailRouter) InitEmailRouter(Router *gin.RouterGroup) { 12 | emailRouter := Router.Use(middleware.OperationRecord()) 13 | EmailApi := api.ApiGroupApp.EmailApi.EmailTest 14 | SendEmail := api.ApiGroupApp.EmailApi.SendEmail 15 | { 16 | emailRouter.POST("emailTest", EmailApi) // 发送测试邮件 17 | emailRouter.POST("sendEmail", SendEmail) // 发送邮件 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /server/plugin/email/service/enter.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | type ServiceGroup struct { 4 | EmailService 5 | } 6 | 7 | var ServiceGroupApp = new(ServiceGroup) 8 | -------------------------------------------------------------------------------- /server/plugin/email/service/sys_email.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "raptor/server/plugin/email/utils" 5 | ) 6 | 7 | type EmailService struct{} 8 | 9 | //@author: [maplepie](https://github.com/maplepie) 10 | //@function: EmailTest 11 | //@description: 发送邮件测试 12 | //@return: err error 13 | 14 | func (e *EmailService) EmailTest() (err error) { 15 | subject := "test" 16 | body := "test" 17 | err = utils.EmailTest(subject, body) 18 | return err 19 | } 20 | 21 | //@author: [maplepie](https://github.com/maplepie) 22 | //@function: EmailTest 23 | //@description: 发送邮件测试 24 | //@return: err error 25 | //@params to string 收件人 26 | //@params subject string 标题(主题) 27 | //@params body string 邮件内容 28 | 29 | func (e *EmailService) SendEmail(to, subject, body string) (err error) { 30 | err = utils.Email(to, subject, body) 31 | return err 32 | } 33 | -------------------------------------------------------------------------------- /server/plugin/example_plugin/main.go: -------------------------------------------------------------------------------- 1 | package example_plugin 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | ) 6 | 7 | var ExamplePlugin = new(pluginExample) 8 | 9 | type pluginExample struct{} 10 | 11 | func (*pluginExample) Register(group *gin.RouterGroup) { 12 | //如需细分权限 可以在此处use中间件 gva项目包名已改为github模式 13 | //所以整个plugin可以直接独立到外层开启为新的项目 然后用包的形式导入也是可以完整运行的 14 | // 例: 15 | /* 16 | group.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()).GET("hello", func(context *gin.Context) { 17 | context.JSON(200, "hello world") 18 | }) 19 | */ 20 | group.GET("hello", func(context *gin.Context) { 21 | context.JSON(200, "hello world") 22 | }) 23 | } 24 | 25 | func (*pluginExample) RouterPath() string { 26 | return "group" 27 | } 28 | -------------------------------------------------------------------------------- /server/resource/excel/ExcelExport.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/server/resource/excel/ExcelExport.xlsx -------------------------------------------------------------------------------- /server/resource/excel/ExcelImport.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/server/resource/excel/ExcelImport.xlsx -------------------------------------------------------------------------------- /server/resource/excel/ExcelTemplate.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/server/resource/excel/ExcelTemplate.xlsx -------------------------------------------------------------------------------- /server/resource/page/css/parser-example.69e16e51.css: -------------------------------------------------------------------------------- 1 | .test-form[data-v-77b1aafa]{margin:15px auto;width:800px;padding:15px} -------------------------------------------------------------------------------- /server/resource/page/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/server/resource/page/favicon.ico -------------------------------------------------------------------------------- /server/resource/page/js/tinymce-example.5a756246.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["tinymce-example"],{a5aa:function(e,t,n){"use strict";n.r(t);var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("Tinymce",{attrs:{height:300,placeholder:"在这里输入文字"},model:{value:e.defaultValue,callback:function(t){e.defaultValue=t},expression:"defaultValue"}})],1)},c=[],u=n("31c6"),l={components:{Tinymce:u["a"]},props:{},data:function(){return{defaultValue:"
配置文档参阅:http://tinymce.ax-z.cn
"}},computed:{},watch:{},created:function(){},mounted:function(){},methods:{}},o=l,i=n("5d22"),d=Object(i["a"])(o,a,c,!1,null,null,null);t["default"]=d.exports}}]); -------------------------------------------------------------------------------- /server/resource/page/libs/monaco-editor/vs/base/browser/ui/codicons/codicon/codicon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/server/resource/page/libs/monaco-editor/vs/base/browser/ui/codicons/codicon/codicon.ttf -------------------------------------------------------------------------------- /server/resource/page/libs/monaco-editor/vs/basic-languages/azcli/azcli.js: -------------------------------------------------------------------------------- 1 | /*!----------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * monaco-languages version: 2.3.0(57af10ae0184db4e0f7f9a92ff972629c39ccb53) 4 | * Released under the MIT license 5 | * https://github.com/Microsoft/monaco-languages/blob/master/LICENSE.md 6 | *-----------------------------------------------------------------------------*/ 7 | define("vs/basic-languages/azcli/azcli",["require","exports"],(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.language=t.conf=void 0,t.conf={comments:{lineComment:"#"}},t.language={defaultToken:"keyword",ignoreCase:!0,tokenPostfix:".azcli",str:/[^#\s]/,tokenizer:{root:[{include:"@comment"},[/\s-+@str*\s*/,{cases:{"@eos":{token:"key.identifier",next:"@popall"},"@default":{token:"key.identifier",next:"@type"}}}],[/^-+@str*\s*/,{cases:{"@eos":{token:"key.identifier",next:"@popall"},"@default":{token:"key.identifier",next:"@type"}}}]],type:[{include:"@comment"},[/-+@str*\s*/,{cases:{"@eos":{token:"key.identifier",next:"@popall"},"@default":"key.identifier"}}],[/@str+\s*/,{cases:{"@eos":{token:"string",next:"@popall"},"@default":"string"}}]],comment:[[/#.*$/,{cases:{"@eos":{token:"comment",next:"@popall"}}}]]}}})); -------------------------------------------------------------------------------- /server/resource/page/libs/monaco-editor/vs/basic-languages/csp/csp.js: -------------------------------------------------------------------------------- 1 | /*!----------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * monaco-languages version: 2.3.0(57af10ae0184db4e0f7f9a92ff972629c39ccb53) 4 | * Released under the MIT license 5 | * https://github.com/Microsoft/monaco-languages/blob/master/LICENSE.md 6 | *-----------------------------------------------------------------------------*/ 7 | define("vs/basic-languages/csp/csp",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.language=e.conf=void 0,e.conf={brackets:[],autoClosingPairs:[],surroundingPairs:[]},e.language={keywords:[],typeKeywords:[],tokenPostfix:".csp",operators:[],symbols:/[=>页面被神秘力量吸走了(如果您是开源版请联系我们修复)
7 |常见问题为当前此角色无当前路由,如果确定要使用本路由,请到角色管理进行分配
8 |↓
9 |