├── .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:/[=>form-generator-preview
-------------------------------------------------------------------------------- /server/resource/rbac_model.conf: -------------------------------------------------------------------------------- 1 | [request_definition] 2 | r = sub, obj, act 3 | 4 | [policy_definition] 5 | p = sub, obj, act 6 | 7 | [role_definition] 8 | g = _, _ 9 | 10 | [policy_effect] 11 | e = some(where (p.eft == allow)) 12 | 13 | [matchers] 14 | m = r.sub == p.sub && keyMatch2(r.obj,p.obj) && r.act == p.act 15 | -------------------------------------------------------------------------------- /server/resource/template/readme.txt.tpl: -------------------------------------------------------------------------------- 1 | 代码解压后把fe的api文件内容粘贴进前端api文件夹下并修改为自己想要的名字即可 2 | 3 | 后端代码解压后同理,放到自己想要的 mvc对应路径 并且到 initRouter中注册自动生成的路由 到registerTable中注册自动生成的model 4 | 5 | 项目github:"https://github.com/piexlmax/raptor/server" 6 | 7 | 希望大家给个star多多鼓励 8 | -------------------------------------------------------------------------------- /server/resource/template/server/model.go.tpl: -------------------------------------------------------------------------------- 1 | // 自动生成模板{{.StructName}} 2 | package autocode 3 | 4 | import ( 5 | "raptor/server/global" 6 | ) 7 | 8 | // {{.StructName}} 结构体 9 | // 如果含有time.Time 请自行import time包 10 | type {{.StructName}} struct { 11 | global.GVA_MODEL {{- range .Fields}} 12 | {{- if ne .FieldType "string" }} 13 | {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"` 14 | {{- else }} 15 | {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"` 16 | {{- end }} {{- end }} 17 | } 18 | 19 | {{ if .TableName }} 20 | // TableName {{.StructName}} 表名 21 | func ({{.StructName}}) TableName() string { 22 | return "{{.TableName}}" 23 | } 24 | {{ end }} 25 | -------------------------------------------------------------------------------- /server/resource/template/server/request.go.tpl: -------------------------------------------------------------------------------- 1 | package request 2 | 3 | import ( 4 | "raptor/server/model/autocode" 5 | "raptor/server/model/common/request" 6 | ) 7 | 8 | type {{.StructName}}Search struct{ 9 | autocode.{{.StructName}} 10 | request.PageInfo 11 | } -------------------------------------------------------------------------------- /server/resource/template/server/router.go.tpl: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | import ( 4 | "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type {{.StructName}}Router struct { 10 | } 11 | 12 | // Init{{.StructName}}Router 初始化 {{.StructName}} 路由信息 13 | func (s *{{.StructName}}Router) Init{{.StructName}}Router(Router *gin.RouterGroup) { 14 | {{.Abbreviation}}Router := Router.Group("{{.Abbreviation}}").Use(middleware.OperationRecord()) 15 | {{.Abbreviation}}RouterWithoutRecord := Router.Group("{{.Abbreviation}}") 16 | var {{.Abbreviation}}Api = v1.ApiGroupApp.AutoCodeApiGroup.{{.StructName}}Api 17 | { 18 | {{.Abbreviation}}Router.POST("create{{.StructName}}", {{.Abbreviation}}Api.Create{{.StructName}}) // 新建{{.StructName}} 19 | {{.Abbreviation}}Router.DELETE("delete{{.StructName}}", {{.Abbreviation}}Api.Delete{{.StructName}}) // 删除{{.StructName}} 20 | {{.Abbreviation}}Router.DELETE("delete{{.StructName}}ByIds", {{.Abbreviation}}Api.Delete{{.StructName}}ByIds) // 批量删除{{.StructName}} 21 | {{.Abbreviation}}Router.PUT("update{{.StructName}}", {{.Abbreviation}}Api.Update{{.StructName}}) // 更新{{.StructName}} 22 | } 23 | { 24 | {{.Abbreviation}}RouterWithoutRecord.GET("find{{.StructName}}", {{.Abbreviation}}Api.Find{{.StructName}}) // 根据ID获取{{.StructName}} 25 | {{.Abbreviation}}RouterWithoutRecord.GET("get{{.StructName}}List", {{.Abbreviation}}Api.Get{{.StructName}}List) // 获取{{.StructName}}列表 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/router/autocode/asset.go: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | "raptor/server/api/v1" 6 | "raptor/server/middleware" 7 | ) 8 | 9 | type AssetRouter struct { 10 | } 11 | 12 | // InitAssetRouter 初始化 Asset 路由信息 13 | func (s *AssetRouter) InitAssetRouter(Router *gin.RouterGroup) { 14 | assetRouter := Router.Group("asset").Use(middleware.OperationRecord()) 15 | assetRouterWithoutRecord := Router.Group("asset") 16 | var assetApi = v1.ApiGroupApp.AutoCodeApiGroup.AssetApi 17 | { 18 | assetRouter.POST("createAsset", assetApi.CreateAsset) // 新建Asset 19 | assetRouter.DELETE("deleteAsset", assetApi.DeleteAsset) // 删除Asset 20 | assetRouter.DELETE("deleteAssetByIds", assetApi.DeleteAssetByIds) // 批量删除Asset 21 | assetRouter.PUT("updateAsset", assetApi.UpdateAsset) // 更新Asset 22 | } 23 | { 24 | assetRouterWithoutRecord.GET("findAsset", assetApi.FindAsset) // 根据ID获取Asset 25 | assetRouterWithoutRecord.GET("getAssetList", assetApi.GetAssetList) // 获取Asset列表 26 | assetRouterWithoutRecord.GET("syncAsset", assetApi.SyncAsset) // 同步更新 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /server/router/autocode/auto_code_example.go: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type AutoCodeExampleRouter struct{} 10 | 11 | func (s *AutoCodeExampleRouter) InitSysAutoCodeExampleRouter(Router *gin.RouterGroup) { 12 | autoCodeExampleRouter := Router.Group("autoCodeExample").Use(middleware.OperationRecord()) 13 | autoCodeExampleRouterWithoutRecord := Router.Group("autoCodeExample") 14 | autoCodeExampleApi := v1.ApiGroupApp.AutoCodeApiGroup.AutoCodeExampleApi 15 | { 16 | autoCodeExampleRouter.POST("createSysAutoCodeExample", autoCodeExampleApi.CreateAutoCodeExample) // 新建AutoCodeExample 17 | autoCodeExampleRouter.DELETE("deleteSysAutoCodeExample", autoCodeExampleApi.DeleteAutoCodeExample) // 删除AutoCodeExample 18 | autoCodeExampleRouter.PUT("updateSysAutoCodeExample", autoCodeExampleApi.UpdateAutoCodeExample) // 更新AutoCodeExample 19 | } 20 | { 21 | autoCodeExampleRouterWithoutRecord.GET("findSysAutoCodeExample", autoCodeExampleApi.FindAutoCodeExample) // 根据ID获取AutoCodeExample 22 | autoCodeExampleRouterWithoutRecord.GET("getSysAutoCodeExampleList", autoCodeExampleApi.GetAutoCodeExampleList) // 获取AutoCodeExample列表 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /server/router/autocode/build.go: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | import ( 4 | "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type BuildRouter struct { 10 | } 11 | 12 | // InitBuildRouter 初始化 Build 路由信息 13 | func (s *BuildRouter) InitBuildRouter(Router *gin.RouterGroup) { 14 | buildRouter := Router.Group("build").Use(middleware.OperationRecord()) 15 | buildRouterWithoutRecord := Router.Group("build") 16 | var buildApi = v1.ApiGroupApp.AutoCodeApiGroup.BuildApi 17 | { 18 | buildRouter.POST("createBuild", buildApi.CreateBuild) // 新建Build 19 | buildRouter.DELETE("deleteBuild", buildApi.DeleteBuild) // 删除Build 20 | buildRouter.DELETE("deleteBuildByIds", buildApi.DeleteBuildByIds) // 批量删除Build 21 | buildRouter.PUT("updateBuild", buildApi.UpdateBuild) // 更新Build 22 | } 23 | { 24 | buildRouterWithoutRecord.GET("findBuild", buildApi.FindBuild) // 根据ID获取Build 25 | buildRouterWithoutRecord.GET("getBuildList", buildApi.GetBuildList) // 获取Build列表 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/router/autocode/enter.go: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | type RouterGroup struct { 4 | // Code generated by raptor/server Begin; DO NOT EDIT. 5 | AutoCodeExampleRouter 6 | KeyRouter 7 | AssetRouter 8 | ProductRouter 9 | ServiceRouter 10 | BuildRouter 11 | // Code generated by raptor/server End; DO NOT EDIT. 12 | } 13 | -------------------------------------------------------------------------------- /server/router/autocode/key.go: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | "raptor/server/api/v1" 6 | "raptor/server/middleware" 7 | ) 8 | 9 | type KeyRouter struct { 10 | } 11 | 12 | // InitKeyRouter 初始化 Key 路由信息 13 | func (s *KeyRouter) InitKeyRouter(Router *gin.RouterGroup) { 14 | keyRouter := Router.Group("key").Use(middleware.OperationRecord()) 15 | keyRouterWithoutRecord := Router.Group("key") 16 | var keyApi = v1.ApiGroupApp.AutoCodeApiGroup.KeyApi 17 | { 18 | keyRouter.POST("createKey", keyApi.CreateKey) // 新建Key 19 | keyRouter.DELETE("deleteKey", keyApi.DeleteKey) // 删除Key 20 | keyRouter.DELETE("deleteKeyByIds", keyApi.DeleteKeyByIds) // 批量删除Key 21 | keyRouter.PUT("updateKey", keyApi.UpdateKey) // 更新Key 22 | } 23 | { 24 | keyRouterWithoutRecord.GET("findKey", keyApi.FindKey) // 根据ID获取Key 25 | keyRouterWithoutRecord.GET("getKeyList", keyApi.GetKeyList) // 获取Key列表 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/router/autocode/product.go: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | import ( 4 | "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type ProductRouter struct { 10 | } 11 | 12 | // InitProductRouter 初始化 Product 路由信息 13 | func (s *ProductRouter) InitProductRouter(Router *gin.RouterGroup) { 14 | productRouter := Router.Group("product").Use(middleware.OperationRecord()) 15 | productRouterWithoutRecord := Router.Group("product") 16 | var productApi = v1.ApiGroupApp.AutoCodeApiGroup.ProductApi 17 | { 18 | productRouter.POST("createProduct", productApi.CreateProduct) // 新建Product 19 | productRouter.DELETE("deleteProduct", productApi.DeleteProduct) // 删除Product 20 | productRouter.DELETE("deleteProductByIds", productApi.DeleteProductByIds) // 批量删除Product 21 | productRouter.PUT("updateProduct", productApi.UpdateProduct) // 更新Product 22 | } 23 | { 24 | productRouterWithoutRecord.GET("findProduct", productApi.FindProduct) // 根据ID获取Product 25 | productRouterWithoutRecord.GET("getProductList", productApi.GetProductList) // 获取Product列表 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/router/autocode/service.go: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | import ( 4 | "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type ServiceRouter struct { 10 | } 11 | 12 | // InitServiceRouter 初始化 Service 路由信息 13 | func (s *ServiceRouter) InitServiceRouter(Router *gin.RouterGroup) { 14 | serviceRouter := Router.Group("service").Use(middleware.OperationRecord()) 15 | serviceRouterWithoutRecord := Router.Group("service") 16 | var serviceApi = v1.ApiGroupApp.AutoCodeApiGroup.ServiceApi 17 | { 18 | serviceRouter.POST("createService", serviceApi.CreateService) // 新建Service 19 | serviceRouter.DELETE("deleteService", serviceApi.DeleteService) // 删除Service 20 | serviceRouter.DELETE("deleteServiceByIds", serviceApi.DeleteServiceByIds) // 批量删除Service 21 | serviceRouter.PUT("updateService", serviceApi.UpdateService) // 更新Service 22 | } 23 | { 24 | serviceRouterWithoutRecord.GET("findService", serviceApi.FindService) // 根据ID获取Service 25 | serviceRouterWithoutRecord.GET("getServiceList", serviceApi.GetServiceList) // 获取Service列表 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/router/enter.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "raptor/server/router/autocode" 5 | "raptor/server/router/example" 6 | "raptor/server/router/system" 7 | ) 8 | 9 | type RouterGroup struct { 10 | System system.RouterGroup 11 | Example example.RouterGroup 12 | Autocode autocode.RouterGroup 13 | } 14 | 15 | var RouterGroupApp = new(RouterGroup) 16 | -------------------------------------------------------------------------------- /server/router/example/enter.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | type RouterGroup struct { 4 | ExcelRouter 5 | CustomerRouter 6 | FileUploadAndDownloadRouter 7 | } 8 | -------------------------------------------------------------------------------- /server/router/example/exa_customer.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type CustomerRouter struct{} 10 | 11 | func (e *CustomerRouter) InitCustomerRouter(Router *gin.RouterGroup) { 12 | customerRouter := Router.Group("customer").Use(middleware.OperationRecord()) 13 | customerRouterWithoutRecord := Router.Group("customer") 14 | exaCustomerApi := v1.ApiGroupApp.ExampleApiGroup.CustomerApi 15 | { 16 | customerRouter.POST("customer", exaCustomerApi.CreateExaCustomer) // 创建客户 17 | customerRouter.PUT("customer", exaCustomerApi.UpdateExaCustomer) // 更新客户 18 | customerRouter.DELETE("customer", exaCustomerApi.DeleteExaCustomer) // 删除客户 19 | } 20 | { 21 | customerRouterWithoutRecord.GET("customer", exaCustomerApi.GetExaCustomer) // 获取单一客户信息 22 | customerRouterWithoutRecord.GET("customerList", exaCustomerApi.GetExaCustomerList) // 获取客户列表 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /server/router/example/exa_excel.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | type ExcelRouter struct{} 9 | 10 | func (e *ExcelRouter) InitExcelRouter(Router *gin.RouterGroup) { 11 | excelRouter := Router.Group("excel") 12 | exaExcelApi := v1.ApiGroupApp.ExampleApiGroup.ExcelApi 13 | { 14 | excelRouter.POST("importExcel", exaExcelApi.ImportExcel) // 导入Excel 15 | excelRouter.GET("loadExcel", exaExcelApi.LoadExcel) // 加载Excel数据 16 | excelRouter.POST("exportExcel", exaExcelApi.ExportExcel) // 导出Excel 17 | excelRouter.GET("downloadTemplate", exaExcelApi.DownloadTemplate) // 下载模板文件 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /server/router/example/exa_file_upload_and_download.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | type FileUploadAndDownloadRouter struct{} 9 | 10 | func (e *FileUploadAndDownloadRouter) InitFileUploadAndDownloadRouter(Router *gin.RouterGroup) { 11 | fileUploadAndDownloadRouter := Router.Group("fileUploadAndDownload") 12 | exaFileUploadAndDownloadApi := v1.ApiGroupApp.ExampleApiGroup.FileUploadAndDownloadApi 13 | { 14 | fileUploadAndDownloadRouter.POST("upload", exaFileUploadAndDownloadApi.UploadFile) // 上传文件 15 | fileUploadAndDownloadRouter.POST("getFileList", exaFileUploadAndDownloadApi.GetFileList) // 获取上传文件列表 16 | fileUploadAndDownloadRouter.POST("deleteFile", exaFileUploadAndDownloadApi.DeleteFile) // 删除指定文件 17 | fileUploadAndDownloadRouter.POST("breakpointContinue", exaFileUploadAndDownloadApi.BreakpointContinue) // 断点续传 18 | fileUploadAndDownloadRouter.GET("findFile", exaFileUploadAndDownloadApi.FindFile) // 查询当前文件成功的切片 19 | fileUploadAndDownloadRouter.POST("breakpointContinueFinish", exaFileUploadAndDownloadApi.BreakpointContinueFinish) // 查询当前文件成功的切片 20 | fileUploadAndDownloadRouter.POST("removeChunk", exaFileUploadAndDownloadApi.RemoveChunk) // 查询当前文件成功的切片 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /server/router/system/enter.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | type RouterGroup struct { 4 | ApiRouter 5 | JwtRouter 6 | SysRouter 7 | BaseRouter 8 | InitRouter 9 | MenuRouter 10 | UserRouter 11 | CasbinRouter 12 | AutoCodeRouter 13 | AuthorityRouter 14 | DictionaryRouter 15 | OperationRecordRouter 16 | DictionaryDetailRouter 17 | AuthorityBtnRouter 18 | } 19 | -------------------------------------------------------------------------------- /server/router/system/sys_api.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type ApiRouter struct{} 10 | 11 | func (s *ApiRouter) InitApiRouter(Router *gin.RouterGroup) { 12 | apiRouter := Router.Group("api").Use(middleware.OperationRecord()) 13 | apiRouterWithoutRecord := Router.Group("api") 14 | apiRouterApi := v1.ApiGroupApp.SystemApiGroup.SystemApiApi 15 | { 16 | apiRouter.POST("createApi", apiRouterApi.CreateApi) // 创建Api 17 | apiRouter.POST("deleteApi", apiRouterApi.DeleteApi) // 删除Api 18 | apiRouter.POST("getApiById", apiRouterApi.GetApiById) // 获取单条Api消息 19 | apiRouter.POST("updateApi", apiRouterApi.UpdateApi) // 更新api 20 | apiRouter.DELETE("deleteApisByIds", apiRouterApi.DeleteApisByIds) // 删除选中api 21 | } 22 | { 23 | apiRouterWithoutRecord.POST("getAllApis", apiRouterApi.GetAllApis) // 获取所有api 24 | apiRouterWithoutRecord.POST("getApiList", apiRouterApi.GetApiList) // 获取Api列表 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /server/router/system/sys_authority.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type AuthorityRouter struct{} 10 | 11 | func (s *AuthorityRouter) InitAuthorityRouter(Router *gin.RouterGroup) { 12 | authorityRouter := Router.Group("authority").Use(middleware.OperationRecord()) 13 | authorityRouterWithoutRecord := Router.Group("authority") 14 | authorityApi := v1.ApiGroupApp.SystemApiGroup.AuthorityApi 15 | { 16 | authorityRouter.POST("createAuthority", authorityApi.CreateAuthority) // 创建角色 17 | authorityRouter.POST("deleteAuthority", authorityApi.DeleteAuthority) // 删除角色 18 | authorityRouter.PUT("updateAuthority", authorityApi.UpdateAuthority) // 更新角色 19 | authorityRouter.POST("copyAuthority", authorityApi.CopyAuthority) // 拷贝角色 20 | authorityRouter.POST("setDataAuthority", authorityApi.SetDataAuthority) // 设置角色资源权限 21 | } 22 | { 23 | authorityRouterWithoutRecord.POST("getAuthorityList", authorityApi.GetAuthorityList) // 获取角色列表 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /server/router/system/sys_authority_btn.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | type AuthorityBtnRouter struct{} 9 | 10 | func (s *AuthorityBtnRouter) InitAuthorityBtnRouterRouter(Router *gin.RouterGroup) { 11 | //authorityRouter := Router.Group("authorityBtn").Use(middleware.OperationRecord()) 12 | authorityRouterWithoutRecord := Router.Group("authorityBtn") 13 | authorityBtnApi := v1.ApiGroupApp.SystemApiGroup.AuthorityBtnApi 14 | { 15 | authorityRouterWithoutRecord.POST("getAuthorityBtn", authorityBtnApi.GetAuthorityBtn) 16 | authorityRouterWithoutRecord.POST("setAuthorityBtn", authorityBtnApi.SetAuthorityBtn) 17 | authorityRouterWithoutRecord.POST("canRemoveAuthorityBtn", authorityBtnApi.CanRemoveAuthorityBtn) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /server/router/system/sys_auto_code.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | type AutoCodeRouter struct{} 9 | 10 | func (s *AutoCodeRouter) InitAutoCodeRouter(Router *gin.RouterGroup) { 11 | autoCodeRouter := Router.Group("autoCode") 12 | autoCodeApi := v1.ApiGroupApp.SystemApiGroup.AutoCodeApi 13 | { 14 | autoCodeRouter.GET("getDB", autoCodeApi.GetDB) // 获取数据库 15 | autoCodeRouter.GET("getTables", autoCodeApi.GetTables) // 获取对应数据库的表 16 | autoCodeRouter.GET("getColumn", autoCodeApi.GetColumn) // 获取指定表所有字段信息 17 | autoCodeRouter.POST("preview", autoCodeApi.PreviewTemp) // 获取自动创建代码预览 18 | autoCodeRouter.POST("createTemp", autoCodeApi.CreateTemp) // 创建自动化代码 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /server/router/system/sys_auto_code_history.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | type AutoCodeHistoryRouter struct{} 9 | 10 | func (s *AutoCodeRouter) InitAutoCodeHistoryRouter(Router *gin.RouterGroup) { 11 | autoCodeHistoryRouter := Router.Group("autoCode") 12 | autoCodeHistoryApi := v1.ApiGroupApp.SystemApiGroup.AutoCodeHistoryApi 13 | { 14 | autoCodeHistoryRouter.POST("getMeta", autoCodeHistoryApi.First) // 根据id获取meta信息 15 | autoCodeHistoryRouter.POST("rollback", autoCodeHistoryApi.RollBack) // 回滚 16 | autoCodeHistoryRouter.POST("delSysHistory", autoCodeHistoryApi.Delete) // 删除回滚记录 17 | autoCodeHistoryRouter.POST("getSysHistory", autoCodeHistoryApi.GetList) // 获取回滚记录分页 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /server/router/system/sys_base.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | v1 "raptor/server/api/v1" 6 | ) 7 | 8 | type BaseRouter struct{} 9 | 10 | func (s *BaseRouter) InitBaseRouter(Router *gin.RouterGroup) (R gin.IRoutes) { 11 | baseRouter := Router.Group("base") 12 | baseApi := v1.ApiGroupApp.SystemApiGroup.BaseApi 13 | { 14 | baseRouter.POST("login", baseApi.Login) 15 | baseRouter.POST("captcha", baseApi.Captcha) 16 | baseRouter.POST("dingLogin", baseApi.DingLogin) 17 | } 18 | return baseRouter 19 | } 20 | -------------------------------------------------------------------------------- /server/router/system/sys_casbin.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type CasbinRouter struct{} 10 | 11 | func (s *CasbinRouter) InitCasbinRouter(Router *gin.RouterGroup) { 12 | casbinRouter := Router.Group("casbin").Use(middleware.OperationRecord()) 13 | casbinRouterWithoutRecord := Router.Group("casbin") 14 | casbinApi := v1.ApiGroupApp.SystemApiGroup.CasbinApi 15 | { 16 | casbinRouter.POST("updateCasbin", casbinApi.UpdateCasbin) 17 | } 18 | { 19 | casbinRouterWithoutRecord.POST("getPolicyPathByAuthorityId", casbinApi.GetPolicyPathByAuthorityId) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /server/router/system/sys_dictionary.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type DictionaryRouter struct{} 10 | 11 | func (s *DictionaryRouter) InitSysDictionaryRouter(Router *gin.RouterGroup) { 12 | sysDictionaryRouter := Router.Group("sysDictionary").Use(middleware.OperationRecord()) 13 | sysDictionaryRouterWithoutRecord := Router.Group("sysDictionary") 14 | sysDictionaryApi := v1.ApiGroupApp.SystemApiGroup.DictionaryApi 15 | { 16 | sysDictionaryRouter.POST("createSysDictionary", sysDictionaryApi.CreateSysDictionary) // 新建SysDictionary 17 | sysDictionaryRouter.DELETE("deleteSysDictionary", sysDictionaryApi.DeleteSysDictionary) // 删除SysDictionary 18 | sysDictionaryRouter.PUT("updateSysDictionary", sysDictionaryApi.UpdateSysDictionary) // 更新SysDictionary 19 | } 20 | { 21 | sysDictionaryRouterWithoutRecord.GET("findSysDictionary", sysDictionaryApi.FindSysDictionary) // 根据ID获取SysDictionary 22 | sysDictionaryRouterWithoutRecord.GET("getSysDictionaryList", sysDictionaryApi.GetSysDictionaryList) // 获取SysDictionary列表 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /server/router/system/sys_dictionary_detail.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type DictionaryDetailRouter struct{} 10 | 11 | func (s *DictionaryDetailRouter) InitSysDictionaryDetailRouter(Router *gin.RouterGroup) { 12 | dictionaryDetailRouter := Router.Group("sysDictionaryDetail").Use(middleware.OperationRecord()) 13 | dictionaryDetailRouterWithoutRecord := Router.Group("sysDictionaryDetail") 14 | sysDictionaryDetailApi := v1.ApiGroupApp.SystemApiGroup.DictionaryDetailApi 15 | { 16 | dictionaryDetailRouter.POST("createSysDictionaryDetail", sysDictionaryDetailApi.CreateSysDictionaryDetail) // 新建SysDictionaryDetail 17 | dictionaryDetailRouter.DELETE("deleteSysDictionaryDetail", sysDictionaryDetailApi.DeleteSysDictionaryDetail) // 删除SysDictionaryDetail 18 | dictionaryDetailRouter.PUT("updateSysDictionaryDetail", sysDictionaryDetailApi.UpdateSysDictionaryDetail) // 更新SysDictionaryDetail 19 | } 20 | { 21 | dictionaryDetailRouterWithoutRecord.GET("findSysDictionaryDetail", sysDictionaryDetailApi.FindSysDictionaryDetail) // 根据ID获取SysDictionaryDetail 22 | dictionaryDetailRouterWithoutRecord.GET("getSysDictionaryDetailList", sysDictionaryDetailApi.GetSysDictionaryDetailList) // 获取SysDictionaryDetail列表 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /server/router/system/sys_initdb.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | type InitRouter struct{} 9 | 10 | func (s *InitRouter) InitInitRouter(Router *gin.RouterGroup) { 11 | initRouter := Router.Group("init") 12 | dbApi := v1.ApiGroupApp.SystemApiGroup.DBApi 13 | { 14 | initRouter.POST("initdb", dbApi.InitDB) // 创建Api 15 | initRouter.POST("checkdb", dbApi.CheckDB) // 创建Api 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /server/router/system/sys_jwt.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | type JwtRouter struct{} 9 | 10 | func (s *JwtRouter) InitJwtRouter(Router *gin.RouterGroup) { 11 | jwtRouter := Router.Group("jwt") 12 | jwtApi := v1.ApiGroupApp.SystemApiGroup.JwtApi 13 | { 14 | jwtRouter.POST("jsonInBlacklist", jwtApi.JsonInBlacklist) // jwt加入黑名单 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /server/router/system/sys_menu.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type MenuRouter struct{} 10 | 11 | func (s *MenuRouter) InitMenuRouter(Router *gin.RouterGroup) (R gin.IRoutes) { 12 | menuRouter := Router.Group("menu").Use(middleware.OperationRecord()) 13 | menuRouterWithoutRecord := Router.Group("menu") 14 | authorityMenuApi := v1.ApiGroupApp.SystemApiGroup.AuthorityMenuApi 15 | { 16 | menuRouter.POST("addBaseMenu", authorityMenuApi.AddBaseMenu) // 新增菜单 17 | menuRouter.POST("addMenuAuthority", authorityMenuApi.AddMenuAuthority) // 增加menu和角色关联关系 18 | menuRouter.POST("deleteBaseMenu", authorityMenuApi.DeleteBaseMenu) // 删除菜单 19 | menuRouter.POST("updateBaseMenu", authorityMenuApi.UpdateBaseMenu) // 更新菜单 20 | } 21 | { 22 | menuRouterWithoutRecord.POST("getMenu", authorityMenuApi.GetMenu) // 获取菜单树 23 | menuRouterWithoutRecord.POST("getMenuList", authorityMenuApi.GetMenuList) // 分页获取基础menu列表 24 | menuRouterWithoutRecord.POST("getBaseMenuTree", authorityMenuApi.GetBaseMenuTree) // 获取用户动态路由 25 | menuRouterWithoutRecord.POST("getMenuAuthority", authorityMenuApi.GetMenuAuthority) // 获取指定角色menu 26 | menuRouterWithoutRecord.POST("getBaseMenuById", authorityMenuApi.GetBaseMenuById) // 根据id获取菜单 27 | } 28 | return menuRouter 29 | } 30 | -------------------------------------------------------------------------------- /server/router/system/sys_operation_record.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | type OperationRecordRouter struct{} 9 | 10 | func (s *OperationRecordRouter) InitSysOperationRecordRouter(Router *gin.RouterGroup) { 11 | operationRecordRouter := Router.Group("sysOperationRecord") 12 | authorityMenuApi := v1.ApiGroupApp.SystemApiGroup.OperationRecordApi 13 | { 14 | operationRecordRouter.POST("createSysOperationRecord", authorityMenuApi.CreateSysOperationRecord) // 新建SysOperationRecord 15 | operationRecordRouter.DELETE("deleteSysOperationRecord", authorityMenuApi.DeleteSysOperationRecord) // 删除SysOperationRecord 16 | operationRecordRouter.DELETE("deleteSysOperationRecordByIds", authorityMenuApi.DeleteSysOperationRecordByIds) // 批量删除SysOperationRecord 17 | operationRecordRouter.GET("findSysOperationRecord", authorityMenuApi.FindSysOperationRecord) // 根据ID获取SysOperationRecord 18 | operationRecordRouter.GET("getSysOperationRecordList", authorityMenuApi.GetSysOperationRecordList) // 获取SysOperationRecord列表 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /server/router/system/sys_system.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type SysRouter struct{} 10 | 11 | func (s *SysRouter) InitSystemRouter(Router *gin.RouterGroup) { 12 | sysRouter := Router.Group("system").Use(middleware.OperationRecord()) 13 | systemApi := v1.ApiGroupApp.SystemApiGroup.SystemApi 14 | { 15 | sysRouter.POST("getSystemConfig", systemApi.GetSystemConfig) // 获取配置文件内容 16 | sysRouter.POST("setSystemConfig", systemApi.SetSystemConfig) // 设置配置文件内容 17 | sysRouter.POST("getServerInfo", systemApi.GetServerInfo) // 获取服务器信息 18 | sysRouter.POST("reloadSystem", systemApi.ReloadSystem) // 重启服务 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /server/router/system/sys_user.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | v1 "raptor/server/api/v1" 5 | "raptor/server/middleware" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type UserRouter struct{} 10 | 11 | func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup) { 12 | userRouter := Router.Group("user").Use(middleware.OperationRecord()) 13 | userRouterWithoutRecord := Router.Group("user") 14 | baseApi := v1.ApiGroupApp.SystemApiGroup.BaseApi 15 | { 16 | userRouter.POST("admin_register", baseApi.Register) // 管理员注册账号 17 | userRouter.POST("changePassword", baseApi.ChangePassword) // 用户修改密码 18 | userRouter.POST("setUserAuthority", baseApi.SetUserAuthority) // 设置用户权限 19 | userRouter.DELETE("deleteUser", baseApi.DeleteUser) // 删除用户 20 | userRouter.PUT("setUserInfo", baseApi.SetUserInfo) // 设置用户信息 21 | userRouter.PUT("setSelfInfo", baseApi.SetSelfInfo) // 设置自身信息 22 | userRouter.POST("setUserAuthorities", baseApi.SetUserAuthorities) // 设置用户权限组 23 | userRouter.POST("resetPassword", baseApi.ResetPassword) // 设置用户权限组 24 | } 25 | { 26 | userRouterWithoutRecord.POST("getUserList", baseApi.GetUserList) // 分页获取用户列表 27 | userRouterWithoutRecord.GET("getUserInfo", baseApi.GetUserInfo) // 获取自身信息 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /server/service/autocode/enter.go: -------------------------------------------------------------------------------- 1 | package autocode 2 | 3 | type ServiceGroup struct { 4 | // Code generated by raptor/server Begin; DO NOT EDIT. 5 | AutoCodeExampleService 6 | KeyService 7 | AssetService 8 | ProductService 9 | ServiceService 10 | BuildService 11 | // Code generated by raptor/server End; DO NOT EDIT. 12 | } 13 | -------------------------------------------------------------------------------- /server/service/enter.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "raptor/server/service/autocode" 5 | "raptor/server/service/example" 6 | "raptor/server/service/system" 7 | ) 8 | 9 | type ServiceGroup struct { 10 | SystemServiceGroup system.ServiceGroup 11 | ExampleServiceGroup example.ServiceGroup 12 | AutoCodeServiceGroup autocode.ServiceGroup 13 | } 14 | 15 | var ServiceGroupApp = new(ServiceGroup) 16 | -------------------------------------------------------------------------------- /server/service/example/enter.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | type ServiceGroup struct { 4 | ExcelService 5 | CustomerService 6 | FileUploadAndDownloadService 7 | } 8 | -------------------------------------------------------------------------------- /server/service/system/enter.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | type ServiceGroup struct { 4 | JwtService 5 | ApiService 6 | MenuService 7 | UserService 8 | CasbinService 9 | InitDBService 10 | AutoCodeService 11 | BaseMenuService 12 | AuthorityService 13 | DictionaryService 14 | SystemConfigService 15 | AutoCodeHistoryService 16 | OperationRecordService 17 | DictionaryDetailService 18 | AuthorityBtnService 19 | } 20 | -------------------------------------------------------------------------------- /server/service/system/sys_authority_btn.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "errors" 5 | "raptor/server/global" 6 | "raptor/server/model/system" 7 | "raptor/server/model/system/request" 8 | "raptor/server/model/system/response" 9 | "gorm.io/gorm" 10 | ) 11 | 12 | type AuthorityBtnService struct{} 13 | 14 | func (a *AuthorityBtnService) GetAuthorityBtn(req request.SysAuthorityBtnReq) (err error, res response.SysAuthorityBtnRes) { 15 | var authorityBtn []system.SysAuthorityBtn 16 | err = global.GVA_DB.Find(&authorityBtn, "authority_id = ? and sys_menu_id = ?", req.AuthorityId, req.MenuID).Error 17 | if err != nil { 18 | return 19 | } 20 | var selected []uint 21 | for _, v := range authorityBtn { 22 | selected = append(selected, v.SysBaseMenuBtnID) 23 | } 24 | res.Selected = selected 25 | return err, res 26 | } 27 | 28 | func (a *AuthorityBtnService) SetAuthorityBtn(req request.SysAuthorityBtnReq) (err error) { 29 | return global.GVA_DB.Transaction(func(tx *gorm.DB) error { 30 | var authorityBtn []system.SysAuthorityBtn 31 | err = tx.Delete(&[]system.SysAuthorityBtn{}, "authority_id = ? and sys_menu_id = ?", req.AuthorityId, req.MenuID).Error 32 | if err != nil { 33 | return err 34 | } 35 | for _, v := range req.Selected { 36 | authorityBtn = append(authorityBtn, system.SysAuthorityBtn{ 37 | AuthorityId: req.AuthorityId, 38 | SysMenuID: req.MenuID, 39 | SysBaseMenuBtnID: v, 40 | }) 41 | } 42 | if len(authorityBtn) > 0 { 43 | err = tx.Create(&authorityBtn).Error 44 | } 45 | if err != nil { 46 | return err 47 | } 48 | return err 49 | }) 50 | } 51 | 52 | func (a *AuthorityBtnService) CanRemoveAuthorityBtn(ID string) (err error) { 53 | fErr := global.GVA_DB.First(&system.SysAuthorityBtn{}, "sys_base_menu_btn_id = ?", ID).Error 54 | if errors.Is(fErr, gorm.ErrRecordNotFound) { 55 | return nil 56 | } 57 | return errors.New("此按钮正在被使用无法删除") 58 | } 59 | -------------------------------------------------------------------------------- /server/service/system/sys_auto_code_interface.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/system/response" 6 | ) 7 | 8 | type Database interface { 9 | GetDB() (data []response.Db, err error) 10 | GetTables(dbName string) (data []response.Table, err error) 11 | GetColumn(tableName string, dbName string) (data []response.Column, err error) 12 | } 13 | 14 | func (autoCodeService *AutoCodeService) Database() Database { 15 | switch global.GVA_CONFIG.System.DbType { 16 | case "mysql": 17 | return AutoCodeMysql 18 | case "pgsql": 19 | return AutoCodePgsql 20 | default: 21 | return AutoCodeMysql 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /server/source/example/file_mysql.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/example" 6 | "github.com/pkg/errors" 7 | "gorm.io/gorm" 8 | ) 9 | 10 | var FileMysql = new(fileMysql) 11 | 12 | type fileMysql struct{} 13 | 14 | func (f *fileMysql) TableName() string { 15 | return "exa_file_upload_and_downloads" 16 | } 17 | 18 | func (f *fileMysql) Initialize() error { 19 | entities := []example.ExaFileUploadAndDownload{ 20 | {Name: "10.png", Url: "https://qmplusimg.henrongyi.top/gvalogo.png", Tag: "png", Key: "158787308910.png"}, 21 | {Name: "logo.png", Url: "https://qmplusimg.henrongyi.top/1576554439myAvatar.png", Tag: "png", Key: "1587973709logo.png"}, 22 | } 23 | if err := global.GVA_DB.Create(&entities).Error; err != nil { 24 | return errors.Wrap(err, f.TableName()+"表数据初始化失败!") 25 | } 26 | return nil 27 | } 28 | 29 | func (f *fileMysql) CheckDataExist() bool { 30 | if errors.Is(global.GVA_DB.Where("`name` = ? AND `key` = ?", "logo.png", "1587973709logo.png").First(&example.ExaFileUploadAndDownload{}).Error, gorm.ErrRecordNotFound) { 31 | return false 32 | } 33 | return true 34 | } 35 | -------------------------------------------------------------------------------- /server/source/example/file_pgsql.go: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/example" 6 | "github.com/pkg/errors" 7 | "gorm.io/gorm" 8 | ) 9 | 10 | var FilePgsql = new(filePgsql) 11 | 12 | type filePgsql struct{} 13 | 14 | func (f *filePgsql) TableName() string { 15 | return "exa_file_upload_and_downloads" 16 | } 17 | 18 | func (f *filePgsql) Initialize() error { 19 | entities := []example.ExaFileUploadAndDownload{ 20 | {Name: "10.png", Url: "https://qmplusimg.henrongyi.top/gvalogo.png", Tag: "png", Key: "158787308910.png"}, 21 | {Name: "logo.png", Url: "https://qmplusimg.henrongyi.top/1576554439myAvatar.png", Tag: "png", Key: "1587973709logo.png"}, 22 | } 23 | if err := global.GVA_DB.Create(&entities).Error; err != nil { 24 | return errors.Wrap(err, f.TableName()+"表数据初始化失败!") 25 | } 26 | return nil 27 | } 28 | 29 | func (f *filePgsql) CheckDataExist() bool { 30 | if errors.Is(global.GVA_DB.Where("name = ? AND key = ?", "logo.png", "1587973709logo.png").First(&example.ExaFileUploadAndDownload{}).Error, gorm.ErrRecordNotFound) { 31 | return false 32 | } 33 | return true 34 | } 35 | -------------------------------------------------------------------------------- /server/source/system/authority.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/system" 6 | "github.com/pkg/errors" 7 | "gorm.io/gorm" 8 | ) 9 | 10 | var Authority = new(authority) 11 | 12 | type authority struct{} 13 | 14 | func (a *authority) TableName() string { 15 | return "sys_authorities" 16 | } 17 | 18 | func (a *authority) Initialize() error { 19 | entities := []system.SysAuthority{ 20 | {AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0", DefaultRouter: "dashboard"}, 21 | {AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0", DefaultRouter: "dashboard"}, 22 | {AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888", DefaultRouter: "dashboard"}, 23 | } 24 | if err := global.GVA_DB.Create(&entities).Error; err != nil { 25 | return errors.Wrapf(err, "%s表数据初始化失败!", a.TableName()) 26 | } 27 | return nil 28 | } 29 | 30 | func (a *authority) CheckDataExist() bool { 31 | if errors.Is(global.GVA_DB.Where("authority_id = ?", "8881").First(&system.SysAuthority{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据 32 | return false 33 | } 34 | return true 35 | } 36 | -------------------------------------------------------------------------------- /server/source/system/data_authorities.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "reflect" 5 | 6 | "raptor/server/global" 7 | "raptor/server/model/system" 8 | "github.com/pkg/errors" 9 | "gorm.io/gorm" 10 | "gorm.io/gorm/schema" 11 | ) 12 | 13 | var DataAuthorities = new(dataAuthorities) 14 | 15 | type dataAuthorities struct{} 16 | 17 | func (a *dataAuthorities) TableName() string { 18 | var entity AuthoritiesResources 19 | return entity.TableName() 20 | } 21 | 22 | func (a *dataAuthorities) Initialize() error { 23 | entities := []AuthoritiesResources{ 24 | {AuthorityId: "888", ResourcesId: "888"}, 25 | {AuthorityId: "888", ResourcesId: "8881"}, 26 | {AuthorityId: "888", ResourcesId: "9528"}, 27 | {AuthorityId: "9528", ResourcesId: "8881"}, 28 | {AuthorityId: "9528", ResourcesId: "9528"}, 29 | } 30 | if err := global.GVA_DB.Create(&entities).Error; err != nil { 31 | return errors.Wrap(err, a.TableName()+"表数据初始化失败!") 32 | } 33 | return nil 34 | } 35 | 36 | func (a *dataAuthorities) CheckDataExist() bool { 37 | if errors.Is(global.GVA_DB.Where("sys_authority_authority_id = ? AND data_authority_id_authority_id = ?", "9528", "9528").First(&AuthoritiesResources{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据 38 | return false 39 | } 40 | return true 41 | } 42 | 43 | // AuthoritiesResources 角色资源表 44 | type AuthoritiesResources struct { 45 | AuthorityId string `gorm:"column:sys_authority_authority_id"` 46 | ResourcesId string `gorm:"column:data_authority_id_authority_id"` 47 | } 48 | 49 | func (a *AuthoritiesResources) TableName() string { 50 | var entity system.SysAuthority 51 | types := reflect.TypeOf(entity) 52 | if s, o := types.FieldByName("DataAuthorityId"); o { 53 | m1 := schema.ParseTagSetting(s.Tag.Get("gorm"), ";") 54 | return m1["MANY2MANY"] 55 | } 56 | return "" 57 | } 58 | -------------------------------------------------------------------------------- /server/source/system/dictionary.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/system" 6 | "github.com/pkg/errors" 7 | "gorm.io/gorm" 8 | ) 9 | 10 | var Dictionary = new(dictionary) 11 | 12 | type dictionary struct{} 13 | 14 | func (d *dictionary) TableName() string { 15 | return "sys_dictionaries" 16 | } 17 | 18 | func (d *dictionary) Initialize() error { 19 | status := new(bool) 20 | *status = true 21 | entities := []system.SysDictionary{ 22 | {GVA_MODEL: global.GVA_MODEL{ID: 1}, Name: "性别", Type: "gender", Status: status, Desc: "性别字典"}, 23 | {GVA_MODEL: global.GVA_MODEL{ID: 2}, Name: "数据库int类型", Type: "int", Status: status, Desc: "int类型对应的数据库类型"}, 24 | {GVA_MODEL: global.GVA_MODEL{ID: 3}, Name: "数据库时间日期类型", Type: "time.Time", Status: status, Desc: "数据库时间日期类型"}, 25 | {GVA_MODEL: global.GVA_MODEL{ID: 4}, Name: "数据库浮点型", Type: "float64", Status: status, Desc: "数据库浮点型"}, 26 | {GVA_MODEL: global.GVA_MODEL{ID: 5}, Name: "数据库字符串", Type: "string", Status: status, Desc: "数据库字符串"}, 27 | {GVA_MODEL: global.GVA_MODEL{ID: 6}, Name: "数据库bool类型", Type: "bool", Status: status, Desc: "数据库bool类型"}, 28 | } 29 | if err := global.GVA_DB.Create(&entities).Error; err != nil { 30 | return errors.Wrap(err, d.TableName()+"表数据初始化失败!") 31 | } 32 | return nil 33 | } 34 | 35 | func (d *dictionary) CheckDataExist() bool { 36 | if errors.Is(global.GVA_DB.Where("type = ?", "bool").First(&system.SysDictionary{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据 37 | return false 38 | } 39 | return true 40 | } 41 | -------------------------------------------------------------------------------- /server/source/system/user.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/system" 6 | "github.com/pkg/errors" 7 | uuid "github.com/satori/go.uuid" 8 | "gorm.io/gorm" 9 | ) 10 | 11 | var User = new(user) 12 | 13 | type user struct{} 14 | 15 | func (u *user) TableName() string { 16 | return "sys_users" 17 | } 18 | 19 | func (u *user) Initialize() error { 20 | entities := []system.SysUser{ 21 | {UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "https://qmplusimg.henrongyi.top/gva_header.jpg", AuthorityId: "888", Phone: "17611111111", Email: "333333333@qq.com"}, 22 | {UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "https:///qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528", Phone: "17611111111", Email: "333333333@qq.com"}, 23 | } 24 | if err := global.GVA_DB.Create(&entities).Error; err != nil { 25 | return errors.Wrap(err, u.TableName()+"表数据初始化失败!") 26 | } 27 | return nil 28 | } 29 | 30 | func (u *user) CheckDataExist() bool { 31 | if errors.Is(global.GVA_DB.Where("username = ?", "a303176530").First(&system.SysUser{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据 32 | return false 33 | } 34 | return true 35 | } 36 | -------------------------------------------------------------------------------- /server/source/system/user_authority.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "raptor/server/global" 5 | "raptor/server/model/system" 6 | "github.com/pkg/errors" 7 | "gorm.io/gorm" 8 | ) 9 | 10 | var UserAuthority = new(userAuthority) 11 | 12 | type userAuthority struct{} 13 | 14 | func (a *userAuthority) TableName() string { 15 | var entity system.SysUseAuthority 16 | return entity.TableName() 17 | } 18 | 19 | func (a *userAuthority) Initialize() error { 20 | entities := []system.SysUseAuthority{ 21 | {SysUserId: 1, SysAuthorityAuthorityId: "888"}, 22 | {SysUserId: 1, SysAuthorityAuthorityId: "8881"}, 23 | {SysUserId: 1, SysAuthorityAuthorityId: "9528"}, 24 | {SysUserId: 2, SysAuthorityAuthorityId: "888"}, 25 | } 26 | if err := global.GVA_DB.Create(&entities).Error; err != nil { 27 | return errors.Wrap(err, a.TableName()+"表数据初始化失败!") 28 | } 29 | return nil 30 | } 31 | 32 | func (a *userAuthority) CheckDataExist() bool { 33 | if errors.Is(global.GVA_DB.Where("sys_user_id = ? AND sys_authority_authority_id = ?", 2, "888").First(&system.SysUseAuthority{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据 34 | return false 35 | } 36 | return true 37 | } 38 | -------------------------------------------------------------------------------- /server/task/dingding.go: -------------------------------------------------------------------------------- 1 | package task 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "io/ioutil" 8 | "net/http" 9 | ) 10 | 11 | // 钉钉报警 12 | 13 | func DingToInfo(accessToken,info string) bool { 14 | content, data := make(map[string]string), make(map[string]interface{}) 15 | content["content"] = info 16 | data["msgtype"] = "text" 17 | data["text"] = content 18 | b, _ := json.Marshal(data) 19 | 20 | resp, err := http.Post("https://oapi.dingtalk.com/robot/send?access_token="+accessToken, 21 | "application/json", 22 | bytes.NewBuffer(b)) 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | defer resp.Body.Close() 27 | body, _ := ioutil.ReadAll(resp.Body) 28 | fmt.Println(string(body)) 29 | return true 30 | } 31 | -------------------------------------------------------------------------------- /server/utils/captcha/redis.go: -------------------------------------------------------------------------------- 1 | package captcha 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "raptor/server/global" 8 | "github.com/mojocn/base64Captcha" 9 | "go.uber.org/zap" 10 | ) 11 | 12 | func NewDefaultRedisStore() *RedisStore { 13 | return &RedisStore{ 14 | Expiration: time.Second * 180, 15 | PreKey: "CAPTCHA_", 16 | } 17 | } 18 | 19 | type RedisStore struct { 20 | Expiration time.Duration 21 | PreKey string 22 | Context context.Context 23 | } 24 | 25 | func (rs *RedisStore) UseWithCtx(ctx context.Context) base64Captcha.Store { 26 | rs.Context = ctx 27 | return rs 28 | } 29 | 30 | func (rs *RedisStore) Set(id string, value string) { 31 | err := global.GVA_REDIS.Set(rs.Context, rs.PreKey+id, value, rs.Expiration).Err() 32 | if err != nil { 33 | global.GVA_LOG.Error("RedisStoreSetError!", zap.Error(err)) 34 | } 35 | } 36 | 37 | func (rs *RedisStore) Get(key string, clear bool) string { 38 | val, err := global.GVA_REDIS.Get(rs.Context, key).Result() 39 | if err != nil { 40 | global.GVA_LOG.Error("RedisStoreGetError!", zap.Error(err)) 41 | return "" 42 | } 43 | if clear { 44 | err := global.GVA_REDIS.Del(rs.Context, key).Err() 45 | if err != nil { 46 | global.GVA_LOG.Error("RedisStoreClearError!", zap.Error(err)) 47 | return "" 48 | } 49 | } 50 | return val 51 | } 52 | 53 | func (rs *RedisStore) Verify(id, answer string, clear bool) bool { 54 | key := rs.PreKey + id 55 | v := rs.Get(key, clear) 56 | return v == answer 57 | } 58 | -------------------------------------------------------------------------------- /server/utils/constant.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | const ( 4 | ConfigEnv = "GVA_CONFIG" 5 | ConfigFile = "config.yaml" 6 | ) 7 | -------------------------------------------------------------------------------- /server/utils/db_automation.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "time" 7 | 8 | "gorm.io/gorm" 9 | ) 10 | 11 | //@author: [songzhibin97](https://github.com/songzhibin97) 12 | //@function: ClearTable 13 | //@description: 清理数据库表数据 14 | //@param: db(数据库对象) *gorm.DB, tableName(表名) string, compareField(比较字段) string, interval(间隔) string 15 | //@return: error 16 | 17 | func ClearTable(db *gorm.DB, tableName string, compareField string, interval string) error { 18 | if db == nil { 19 | return errors.New("db Cannot be empty") 20 | } 21 | duration, err := time.ParseDuration(interval) 22 | if err != nil { 23 | return err 24 | } 25 | if duration < 0 { 26 | return errors.New("parse duration < 0") 27 | } 28 | return db.Debug().Exec(fmt.Sprintf("DELETE FROM %s WHERE %s < ?", tableName, compareField), time.Now().Add(-duration)).Error 29 | } 30 | -------------------------------------------------------------------------------- /server/utils/directory.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | 7 | "raptor/server/global" 8 | "go.uber.org/zap" 9 | ) 10 | 11 | //@author: [piexlmax](https://github.com/piexlmax) 12 | //@function: PathExists 13 | //@description: 文件目录是否存在 14 | //@param: path string 15 | //@return: bool, error 16 | 17 | func PathExists(path string) (bool, error) { 18 | fi, err := os.Stat(path) 19 | if err == nil { 20 | if fi.IsDir() { 21 | return true, nil 22 | } 23 | return false, errors.New("存在同名文件") 24 | } 25 | if os.IsNotExist(err) { 26 | return false, nil 27 | } 28 | return false, err 29 | } 30 | 31 | //@author: [piexlmax](https://github.com/piexlmax) 32 | //@function: CreateDir 33 | //@description: 批量创建文件夹 34 | //@param: dirs ...string 35 | //@return: err error 36 | 37 | func CreateDir(dirs ...string) (err error) { 38 | for _, v := range dirs { 39 | exist, err := PathExists(v) 40 | if err != nil { 41 | return err 42 | } 43 | if !exist { 44 | global.GVA_LOG.Debug("create directory" + v) 45 | if err := os.MkdirAll(v, os.ModePerm); err != nil { 46 | global.GVA_LOG.Error("create directory"+v, zap.Any(" error:", err)) 47 | return err 48 | } 49 | } 50 | } 51 | return err 52 | } 53 | -------------------------------------------------------------------------------- /server/utils/file_operations.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "reflect" 7 | "strings" 8 | ) 9 | 10 | //@author: [songzhibin97](https://github.com/songzhibin97) 11 | //@function: FileMove 12 | //@description: 文件移动供外部调用 13 | //@param: src string, dst string(src: 源位置,绝对路径or相对路径, dst: 目标位置,绝对路径or相对路径,必须为文件夹) 14 | //@return: err error 15 | 16 | func FileMove(src string, dst string) (err error) { 17 | if dst == "" { 18 | return nil 19 | } 20 | src, err = filepath.Abs(src) 21 | if err != nil { 22 | return err 23 | } 24 | dst, err = filepath.Abs(dst) 25 | if err != nil { 26 | return err 27 | } 28 | revoke := false 29 | dir := filepath.Dir(dst) 30 | Redirect: 31 | _, err = os.Stat(dir) 32 | if err != nil { 33 | err = os.MkdirAll(dir, 0o755) 34 | if err != nil { 35 | return err 36 | } 37 | if !revoke { 38 | revoke = true 39 | goto Redirect 40 | } 41 | } 42 | return os.Rename(src, dst) 43 | } 44 | 45 | func DeLFile(filePath string) error { 46 | return os.RemoveAll(filePath) 47 | } 48 | 49 | //@author: [songzhibin97](https://github.com/songzhibin97) 50 | //@function: TrimSpace 51 | //@description: 去除结构体空格 52 | //@param: target interface (target: 目标结构体,传入必须是指针类型) 53 | //@return: null 54 | 55 | func TrimSpace(target interface{}) { 56 | t := reflect.TypeOf(target) 57 | if t.Kind() != reflect.Ptr { 58 | return 59 | } 60 | t = t.Elem() 61 | v := reflect.ValueOf(target).Elem() 62 | for i := 0; i < t.NumField(); i++ { 63 | switch v.Field(i).Kind() { 64 | case reflect.String: 65 | v.Field(i).SetString(strings.TrimSpace(v.Field(i).String())) 66 | } 67 | } 68 | } 69 | 70 | // FileExist 判断文件是否存在 71 | func FileExist(path string) bool { 72 | fi, err := os.Lstat(path) 73 | if err == nil { 74 | return !fi.IsDir() 75 | } 76 | return !os.IsNotExist(err) 77 | } 78 | -------------------------------------------------------------------------------- /server/utils/fmt_plus.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "strings" 7 | ) 8 | 9 | //@author: [piexlmax](https://github.com/piexlmax) 10 | //@function: StructToMap 11 | //@description: 利用反射将结构体转化为map 12 | //@param: obj interface{} 13 | //@return: map[string]interface{} 14 | 15 | func StructToMap(obj interface{}) map[string]interface{} { 16 | obj1 := reflect.TypeOf(obj) 17 | obj2 := reflect.ValueOf(obj) 18 | 19 | data := make(map[string]interface{}) 20 | for i := 0; i < obj1.NumField(); i++ { 21 | if obj1.Field(i).Tag.Get("mapstructure") != "" { 22 | data[obj1.Field(i).Tag.Get("mapstructure")] = obj2.Field(i).Interface() 23 | } else { 24 | data[obj1.Field(i).Name] = obj2.Field(i).Interface() 25 | } 26 | } 27 | return data 28 | } 29 | 30 | //@author: [piexlmax](https://github.com/piexlmax) 31 | //@function: ArrayToString 32 | //@description: 将数组格式化为字符串 33 | //@param: array []interface{} 34 | //@return: string 35 | 36 | func ArrayToString(array []interface{}) string { 37 | return strings.Replace(strings.Trim(fmt.Sprint(array), "[]"), " ", ",", -1) 38 | } 39 | -------------------------------------------------------------------------------- /server/utils/md5.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "crypto/md5" 5 | "encoding/hex" 6 | ) 7 | 8 | //@author: [piexlmax](https://github.com/piexlmax) 9 | //@function: MD5V 10 | //@description: md5加密 11 | //@param: str []byte 12 | //@return: string 13 | 14 | func MD5V(str []byte, b ...byte) string { 15 | h := md5.New() 16 | h.Write(str) 17 | return hex.EncodeToString(h.Sum(b)) 18 | } 19 | -------------------------------------------------------------------------------- /server/utils/plugin/plugin.go: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | ) 6 | 7 | const ( 8 | OnlyFuncName = "Plugin" 9 | ) 10 | 11 | // Plugin 插件模式接口化 12 | type Plugin interface { 13 | // Register 注册路由 14 | Register(group *gin.RouterGroup) 15 | 16 | // RouterPath 用户返回注册路由 17 | RouterPath() string 18 | } 19 | -------------------------------------------------------------------------------- /server/utils/reload.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "os/exec" 7 | "runtime" 8 | "strconv" 9 | ) 10 | 11 | func Reload() error { 12 | if runtime.GOOS == "windows" { 13 | return errors.New("系统不支持") 14 | } 15 | pid := os.Getpid() 16 | cmd := exec.Command("kill", "-1", strconv.Itoa(pid)) 17 | return cmd.Run() 18 | } 19 | -------------------------------------------------------------------------------- /server/utils/rotatelogs.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "os" 5 | 6 | "raptor/server/global" 7 | "github.com/natefinch/lumberjack" 8 | "go.uber.org/zap/zapcore" 9 | ) 10 | 11 | //@author: [SliverHorn](https://github.com/SliverHorn) 12 | //@function: GetWriteSyncer 13 | //@description: zap logger中加入file-rotatelogs 14 | //@return: zapcore.WriteSyncer, error 15 | 16 | func GetWriteSyncer(file string) zapcore.WriteSyncer { 17 | lumberJackLogger := &lumberjack.Logger{ 18 | Filename: file, // 日志文件的位置 19 | MaxSize: 10, // 在进行切割之前,日志文件的最大大小(以MB为单位) 20 | MaxBackups: 200, // 保留旧文件的最大个数 21 | MaxAge: 30, // 保留旧文件的最大天数 22 | Compress: true, // 是否压缩/归档旧文件 23 | } 24 | 25 | if global.GVA_CONFIG.Zap.LogInConsole { 26 | return zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout), zapcore.AddSync(lumberJackLogger)) 27 | } 28 | return zapcore.AddSync(lumberJackLogger) 29 | } 30 | -------------------------------------------------------------------------------- /server/utils/timer/timed_task_test.go: -------------------------------------------------------------------------------- 1 | package timer 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | "time" 7 | 8 | "github.com/stretchr/testify/assert" 9 | ) 10 | 11 | var job = mockJob{} 12 | 13 | type mockJob struct{} 14 | 15 | func (job mockJob) Run() { 16 | mockFunc() 17 | } 18 | 19 | func mockFunc() { 20 | time.Sleep(time.Second) 21 | fmt.Println("1s...") 22 | } 23 | 24 | func TestNewTimerTask(t *testing.T) { 25 | tm := NewTimerTask() 26 | _tm := tm.(*timer) 27 | 28 | { 29 | _, err := tm.AddTaskByFunc("func", "@every 1s", mockFunc) 30 | assert.Nil(t, err) 31 | _, ok := _tm.taskList["func"] 32 | if !ok { 33 | t.Error("no find func") 34 | } 35 | } 36 | 37 | { 38 | _, err := tm.AddTaskByJob("job", "@every 1s", job) 39 | assert.Nil(t, err) 40 | _, ok := _tm.taskList["job"] 41 | if !ok { 42 | t.Error("no find job") 43 | } 44 | } 45 | 46 | { 47 | _, ok := tm.FindCron("func") 48 | if !ok { 49 | t.Error("no find func") 50 | } 51 | _, ok = tm.FindCron("job") 52 | if !ok { 53 | t.Error("no find job") 54 | } 55 | _, ok = tm.FindCron("none") 56 | if ok { 57 | t.Error("find none") 58 | } 59 | } 60 | { 61 | tm.Clear("func") 62 | _, ok := tm.FindCron("func") 63 | if ok { 64 | t.Error("find func") 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /server/utils/upload/upload.go: -------------------------------------------------------------------------------- 1 | package upload 2 | 3 | import ( 4 | "mime/multipart" 5 | 6 | "raptor/server/global" 7 | ) 8 | 9 | // OSS 对象存储接口 10 | // Author [SliverHorn](https://github.com/SliverHorn) 11 | // Author [ccfish86](https://github.com/ccfish86) 12 | type OSS interface { 13 | UploadFile(file *multipart.FileHeader) (string, string, error) 14 | DeleteFile(key string) error 15 | } 16 | 17 | // NewOss OSS的实例化方法 18 | // Author [SliverHorn](https://github.com/SliverHorn) 19 | // Author [ccfish86](https://github.com/ccfish86) 20 | func NewOss() OSS { 21 | switch global.GVA_CONFIG.System.OssType { 22 | case "local": 23 | return &Local{} 24 | case "qiniu": 25 | return &Qiniu{} 26 | case "tencent-cos": 27 | return &TencentCOS{} 28 | case "aliyun-oss": 29 | return &AliyunOSS{} 30 | case "huawei-obs": 31 | return HuaWeiObs 32 | case "aws-s3": 33 | return &AwsS3{} 34 | default: 35 | return &Local{} 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /server/utils/verify.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | var ( 4 | IdVerify = Rules{"ID": {NotEmpty()}} 5 | ApiVerify = Rules{"Path": {NotEmpty()}, "Description": {NotEmpty()}, "ApiGroup": {NotEmpty()}, "Method": {NotEmpty()}} 6 | MenuVerify = Rules{"Path": {NotEmpty()}, "ParentId": {NotEmpty()}, "Name": {NotEmpty()}, "Component": {NotEmpty()}, "Sort": {Ge("0")}} 7 | MenuMetaVerify = Rules{"Title": {NotEmpty()}} 8 | LoginVerify = Rules{"CaptchaId": {NotEmpty()}, "Captcha": {NotEmpty()}, "Username": {NotEmpty()}, "Password": {NotEmpty()}} 9 | RegisterVerify = Rules{"Username": {NotEmpty()}, "NickName": {NotEmpty()}, "Password": {NotEmpty()}, "AuthorityId": {NotEmpty()}} 10 | PageInfoVerify = Rules{"Page": {NotEmpty()}, "PageSize": {NotEmpty()}} 11 | CustomerVerify = Rules{"CustomerName": {NotEmpty()}, "CustomerPhoneData": {NotEmpty()}} 12 | AutoCodeVerify = Rules{"Abbreviation": {NotEmpty()}, "StructName": {NotEmpty()}, "PackageName": {NotEmpty()}, "Fields": {NotEmpty()}} 13 | AuthorityVerify = Rules{"AuthorityId": {NotEmpty()}, "AuthorityName": {NotEmpty()}, "ParentId": {NotEmpty()}} 14 | AuthorityIdVerify = Rules{"AuthorityId": {NotEmpty()}} 15 | OldAuthorityVerify = Rules{"OldAuthorityId": {NotEmpty()}} 16 | ChangePasswordVerify = Rules{"Username": {NotEmpty()}, "Password": {NotEmpty()}, "NewPassword": {NotEmpty()}} 17 | SetUserAuthorityVerify = Rules{"AuthorityId": {NotEmpty()}} 18 | ) 19 | -------------------------------------------------------------------------------- /server/utils/zipfiles.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "archive/zip" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | //@author: [piexlmax](https://github.com/piexlmax) 11 | //@function: ZipFiles 12 | //@description: 压缩文件 13 | //@param: filename string, files []string, oldForm, newForm string 14 | //@return: error 15 | 16 | func ZipFiles(filename string, files []string, oldForm, newForm string) error { 17 | newZipFile, err := os.Create(filename) 18 | if err != nil { 19 | return err 20 | } 21 | defer func() { 22 | _ = newZipFile.Close() 23 | }() 24 | 25 | zipWriter := zip.NewWriter(newZipFile) 26 | defer func() { 27 | _ = zipWriter.Close() 28 | }() 29 | 30 | // 把files添加到zip中 31 | for _, file := range files { 32 | 33 | err = func(file string) error { 34 | zipFile, err := os.Open(file) 35 | if err != nil { 36 | return err 37 | } 38 | defer zipFile.Close() 39 | // 获取file的基础信息 40 | info, err := zipFile.Stat() 41 | if err != nil { 42 | return err 43 | } 44 | 45 | header, err := zip.FileInfoHeader(info) 46 | if err != nil { 47 | return err 48 | } 49 | 50 | // 使用上面的FileInforHeader() 就可以把文件保存的路径替换成我们自己想要的了,如下面 51 | header.Name = strings.Replace(file, oldForm, newForm, -1) 52 | 53 | // 优化压缩 54 | // 更多参考see http://golang.org/pkg/archive/zip/#pkg-constants 55 | header.Method = zip.Deflate 56 | 57 | writer, err := zipWriter.CreateHeader(header) 58 | if err != nil { 59 | return err 60 | } 61 | if _, err = io.Copy(writer, zipFile); err != nil { 62 | return err 63 | } 64 | return nil 65 | }(file) 66 | if err != nil { 67 | return err 68 | } 69 | } 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /web/.docker-compose/nginx/conf.d/my.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8080; 3 | server_name localhost; 4 | 5 | #charset koi8-r; 6 | #access_log logs/host.access.log main; 7 | 8 | location / { 9 | root /usr/share/nginx/html; 10 | add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; 11 | try_files $uri $uri/ /index.html; 12 | } 13 | 14 | location /api { 15 | proxy_set_header Host $http_host; 16 | proxy_set_header X-Real-IP $remote_addr; 17 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 18 | proxy_set_header X-Forwarded-Proto $scheme; 19 | rewrite ^/api/(.*)$ /$1 break; #重写 20 | proxy_pass http://177.7.0.12:8888; # 设置代理服务器的协议和地址 21 | } 22 | 23 | location /api/swagger/index.html { 24 | proxy_pass http://127.0.0.1:8888/swagger/index.html; 25 | } 26 | } -------------------------------------------------------------------------------- /web/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /web/.env.development: -------------------------------------------------------------------------------- 1 | ENV = 'development' 2 | VITE_CLI_PORT = 8080 3 | VITE_SERVER_PORT = 8888 4 | VITE_BASE_API = /api 5 | VITE_BASE_PATH = http://127.0.0.1 6 | // 如果使用docker-compose开发模式,设置为下面的地址 7 | //VITE_BASE_PATH = http://177.7.0.12 8 | -------------------------------------------------------------------------------- /web/.env.production: -------------------------------------------------------------------------------- 1 | ENV = 'production' 2 | 3 | VITE_CLI_PORT = 8080 4 | VITE_SERVER_PORT = 8888 5 | VITE_BASE_API = /api 6 | #下方修改为你的线上ip 7 | VITE_BASE_PATH = https://demo.gin-vue-admin.com 8 | -------------------------------------------------------------------------------- /web/.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | src/assets 3 | public 4 | dist 5 | -------------------------------------------------------------------------------- /web/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | package-lock.json 3 | yarn.lock -------------------------------------------------------------------------------- /web/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16 2 | 3 | WORKDIR /gva_web/ 4 | COPY . . 5 | 6 | RUN yarn && yarn build 7 | 8 | FROM nginx:alpine 9 | LABEL MAINTAINER="" 10 | 11 | COPY .docker-compose/nginx/conf.d/my.conf /etc/nginx/conf.d/my.conf 12 | COPY --from=0 /gva_web/dist /usr/share/nginx/html 13 | RUN cat /etc/nginx/nginx.conf 14 | RUN cat /etc/nginx/conf.d/my.conf 15 | RUN ls -al /usr/share/nginx/html 16 | -------------------------------------------------------------------------------- /web/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ], 5 | 'plugins': [ 6 | 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/favicon.ico -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /web/limit.js: -------------------------------------------------------------------------------- 1 | // 运行项目前通过node执行此脚本 (此脚本与 node_modules 目录同级) 2 | const fs = require('fs') 3 | const path = require('path') 4 | const wfPath = path.resolve(__dirname, './node_modules/.bin') 5 | 6 | fs.readdir(wfPath, (err, files) => { 7 | if (err) { 8 | console.log(err) 9 | } else { 10 | if (files.length != 0) { 11 | files.forEach((item) => { 12 | if (item.split('.')[1] === 'cmd') { 13 | replaceStr(`${wfPath}/${item}`, /"%_prog%"/, '%_prog%') 14 | } 15 | }) 16 | } 17 | } 18 | }) 19 | 20 | // 参数:[文件路径、 需要修改的字符串、修改后的字符串] (替换对应文件内字符串的公共函数) 21 | function replaceStr(filePath, sourceRegx, targetSrt) { 22 | fs.readFile(filePath, (err, data) => { 23 | if (err) { 24 | console.log(err) 25 | } else { 26 | let str = data.toString() 27 | str = str.replace(sourceRegx, targetSrt) 28 | fs.writeFile(filePath, str, (err) => { 29 | if(err){ 30 | console.log(err) 31 | }else{ 32 | console.log("\x1B[42m%s\x1B[0m","文件修改成功") 33 | } 34 | }) 35 | } 36 | }) 37 | } -------------------------------------------------------------------------------- /web/openDocument.js: -------------------------------------------------------------------------------- 1 | // /* 2 | // 商用代码公司自用产品无需授权 3 | // 若作为代码出售的产品(任何涉及代码交付第三方作为后续开发)必须保留此脚本 4 | // 或标注原作者信息 5 | // 否则将依法维权 6 | // */ 7 | // 8 | // var child_process = require('child_process') 9 | // 10 | // var url = 'https://www.raptor.com' 11 | // var cmd = '' 12 | // console.log(process.platform) 13 | // switch (process.platform) { 14 | // case 'win32': 15 | // // cmd = 'start' 16 | // // child_process.exec(cmd + ' ' + url) 17 | // break 18 | // 19 | // case 'darwin': 20 | // cmd = 'open' 21 | // child_process.exec(cmd + ' ' + url) 22 | // break 23 | // } 24 | -------------------------------------------------------------------------------- /web/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 28 | -------------------------------------------------------------------------------- /web/src/api/authorityBtn.js: -------------------------------------------------------------------------------- 1 | 2 | import service from '@/utils/request' 3 | 4 | export const getAuthorityBtnApi = (data) => { 5 | return service({ 6 | url: '/authorityBtn/getAuthorityBtn', 7 | method: 'post', 8 | data 9 | }) 10 | } 11 | 12 | export const setAuthorityBtnApi = (data) => { 13 | return service({ 14 | url: '/authorityBtn/setAuthorityBtn', 15 | method: 'post', 16 | data 17 | }) 18 | } 19 | 20 | export const canRemoveAuthorityBtnApi = (params) => { 21 | return service({ 22 | url: '/authorityBtn/canRemoveAuthorityBtn', 23 | method: 'post', 24 | params 25 | }) 26 | } 27 | 28 | -------------------------------------------------------------------------------- /web/src/api/breakpoint.js: -------------------------------------------------------------------------------- 1 | import service from '@/utils/request' 2 | // @Summary 设置角色资源权限 3 | // @Security ApiKeyAuth 4 | // @accept application/json 5 | // @Produce application/json 6 | // @Param data body sysModel.SysAuthority true "设置角色资源权限" 7 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}" 8 | // @Router /authority/setDataAuthority [post] 9 | 10 | export const findFile = (params) => { 11 | return service({ 12 | url: '/fileUploadAndDownload/findFile', 13 | method: 'get', 14 | params 15 | }) 16 | } 17 | 18 | export const breakpointContinue = (data) => { 19 | return service({ 20 | url: '/fileUploadAndDownload/breakpointContinue', 21 | method: 'post', 22 | headers: { 'Content-Type': 'multipart/form-data' }, 23 | data 24 | }) 25 | } 26 | 27 | export const breakpointContinueFinish = (params) => { 28 | return service({ 29 | url: '/fileUploadAndDownload/breakpointContinueFinish', 30 | method: 'post', 31 | params 32 | }) 33 | } 34 | 35 | export const removeChunk = (data, params) => { 36 | return service({ 37 | url: '/fileUploadAndDownload/removeChunk', 38 | method: 'post', 39 | data, 40 | params 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /web/src/api/casbin.js: -------------------------------------------------------------------------------- 1 | import service from '@/utils/request' 2 | // @Tags authority 3 | // @Summary 更改角色api权限 4 | // @Security ApiKeyAuth 5 | // @accept application/json 6 | // @Produce application/json 7 | // @Param data body api.CreateAuthorityPatams true "更改角色api权限" 8 | // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" 9 | // @Router /casbin/UpdateCasbin [post] 10 | export const UpdateCasbin = (data) => { 11 | return service({ 12 | url: '/casbin/updateCasbin', 13 | method: 'post', 14 | data 15 | }) 16 | } 17 | 18 | // @Tags casbin 19 | // @Summary 获取权限列表 20 | // @Security ApiKeyAuth 21 | // @accept application/json 22 | // @Produce application/json 23 | // @Param data body api.CreateAuthorityPatams true "获取权限列表" 24 | // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" 25 | // @Router /casbin/getPolicyPathByAuthorityId [post] 26 | export const getPolicyPathByAuthorityId = (data) => { 27 | return service({ 28 | url: '/casbin/getPolicyPathByAuthorityId', 29 | method: 'post', 30 | data 31 | }) 32 | } 33 | -------------------------------------------------------------------------------- /web/src/api/email.js: -------------------------------------------------------------------------------- 1 | import service from '@/utils/request' 2 | // @Tags email 3 | // @Summary 发送测试邮件 4 | // @Security ApiKeyAuth 5 | // @Produce application/json 6 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" 7 | // @Router /email/emailTest [post] 8 | export const emailTest = (data) => { 9 | return service({ 10 | url: '/email/emailTest', 11 | method: 'post', 12 | data 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /web/src/api/fileUploadAndDownload.js: -------------------------------------------------------------------------------- 1 | import service from '@/utils/request' 2 | // @Tags FileUploadAndDownload 3 | // @Summary 分页文件列表 4 | // @Security ApiKeyAuth 5 | // @accept application/json 6 | // @Produce application/json 7 | // @Param data body modelInterface.PageInfo true "分页获取文件户列表" 8 | // @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" 9 | // @Router /fileUploadAndDownload/getFileList [post] 10 | export const getFileList = (data) => { 11 | return service({ 12 | url: '/fileUploadAndDownload/getFileList', 13 | method: 'post', 14 | data 15 | }) 16 | } 17 | 18 | // @Tags FileUploadAndDownload 19 | // @Summary 删除文件 20 | // @Security ApiKeyAuth 21 | // @Produce application/json 22 | // @Param data body dbModel.FileUploadAndDownload true "传入文件里面id即可" 23 | // @Success 200 {string} json "{"success":true,"data":{},"msg":"返回成功"}" 24 | // @Router /fileUploadAndDownload/deleteFile [post] 25 | export const deleteFile = (data) => { 26 | return service({ 27 | url: '/fileUploadAndDownload/deleteFile', 28 | method: 'post', 29 | data 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /web/src/api/github.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | const service = axios.create() 4 | 5 | export function Commits(page) { 6 | return service({ 7 | url: 'https://api.github.com/repos/flipped-aurora/raptor/commits?page=' + page, 8 | method: 'get' 9 | }) 10 | } 11 | 12 | export function Members() { 13 | return service({ 14 | url: 'https://api.github.com/orgs/FLIPPED-AURORA/members', 15 | method: 'get' 16 | }) 17 | } 18 | -------------------------------------------------------------------------------- /web/src/api/initdb.js: -------------------------------------------------------------------------------- 1 | import service from '@/utils/request' 2 | // @Tags InitDB 3 | // @Summary 初始化用户数据库 4 | // @Produce application/json 5 | // @Param data body request.InitDB true "初始化数据库参数" 6 | // @Success 200 {string} string "{"code":0,"data":{},"msg":"自动创建数据库成功"}" 7 | // @Router /init/initdb [post] 8 | export const initDB = (data) => { 9 | return service({ 10 | url: '/init/initdb', 11 | method: 'post', 12 | data 13 | }) 14 | } 15 | 16 | // @Tags CheckDB 17 | // @Summary 初始化用户数据库 18 | // @Produce application/json 19 | // @Success 200 {string} string "{"code":0,"data":{},"msg":"探测完成"}" 20 | // @Router /init/checkdb [post] 21 | export const checkDB = () => { 22 | return service({ 23 | url: '/init/checkdb', 24 | method: 'post' 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /web/src/api/jwt.js: -------------------------------------------------------------------------------- 1 | import service from '@/utils/request' 2 | // @Tags jwt 3 | // @Summary jwt加入黑名单 4 | // @Security ApiKeyAuth 5 | // @accept application/json 6 | // @Produce application/json 7 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"拉黑成功"}" 8 | // @Router /jwt/jsonInBlacklist [post] 9 | export const jsonInBlacklist = () => { 10 | return service({ 11 | url: '/jwt/jsonInBlacklist', 12 | method: 'post' 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /web/src/api/sysOperationRecord.js: -------------------------------------------------------------------------------- 1 | import service from '@/utils/request' 2 | // @Tags SysOperationRecord 3 | // @Summary 删除SysOperationRecord 4 | // @Security ApiKeyAuth 5 | // @accept application/json 6 | // @Produce application/json 7 | // @Param data body model.SysOperationRecord true "删除SysOperationRecord" 8 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" 9 | // @Router /sysOperationRecord/deleteSysOperationRecord [delete] 10 | export const deleteSysOperationRecord = (data) => { 11 | return service({ 12 | url: '/sysOperationRecord/deleteSysOperationRecord', 13 | method: 'delete', 14 | data 15 | }) 16 | } 17 | 18 | // @Tags SysOperationRecord 19 | // @Summary 删除SysOperationRecord 20 | // @Security ApiKeyAuth 21 | // @accept application/json 22 | // @Produce application/json 23 | // @Param data body request.IdsReq true "删除SysOperationRecord" 24 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" 25 | // @Router /sysOperationRecord/deleteSysOperationRecord [delete] 26 | export const deleteSysOperationRecordByIds = (data) => { 27 | return service({ 28 | url: '/sysOperationRecord/deleteSysOperationRecordByIds', 29 | method: 'delete', 30 | data 31 | }) 32 | } 33 | 34 | // @Tags SysOperationRecord 35 | // @Summary 分页获取SysOperationRecord列表 36 | // @Security ApiKeyAuth 37 | // @accept application/json 38 | // @Produce application/json 39 | // @Param data body request.PageInfo true "分页获取SysOperationRecord列表" 40 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" 41 | // @Router /sysOperationRecord/getSysOperationRecordList [get] 42 | export const getSysOperationRecordList = (params) => { 43 | return service({ 44 | url: '/sysOperationRecord/getSysOperationRecordList', 45 | method: 'get', 46 | params 47 | }) 48 | } 49 | -------------------------------------------------------------------------------- /web/src/api/system.js: -------------------------------------------------------------------------------- 1 | import service from '@/utils/request' 2 | // @Tags systrm 3 | // @Summary 获取配置文件内容 4 | // @Security ApiKeyAuth 5 | // @Produce application/json 6 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" 7 | // @Router /system/getSystemConfig [post] 8 | export const getSystemConfig = () => { 9 | return service({ 10 | url: '/system/getSystemConfig', 11 | method: 'post' 12 | }) 13 | } 14 | 15 | // @Tags system 16 | // @Summary 设置配置文件内容 17 | // @Security ApiKeyAuth 18 | // @Produce application/json 19 | // @Param data body sysModel.System true 20 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" 21 | // @Router /system/setSystemConfig [post] 22 | export const setSystemConfig = (data) => { 23 | return service({ 24 | url: '/system/setSystemConfig', 25 | method: 'post', 26 | data 27 | }) 28 | } 29 | 30 | // @Tags system 31 | // @Summary 获取服务器运行状态 32 | // @Security ApiKeyAuth 33 | // @Produce application/json 34 | // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" 35 | // @Router /system/getServerInfo [post] 36 | export const getSystemState = () => { 37 | return service({ 38 | url: '/system/getServerInfo', 39 | method: 'post', 40 | donNotShowLoading: true 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /web/src/assets/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/dashboard.png -------------------------------------------------------------------------------- /web/src/assets/docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/docs.png -------------------------------------------------------------------------------- /web/src/assets/flipped-aurora.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/flipped-aurora.png -------------------------------------------------------------------------------- /web/src/assets/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/github.png -------------------------------------------------------------------------------- /web/src/assets/kefu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/kefu.png -------------------------------------------------------------------------------- /web/src/assets/login_background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/login_background.jpg -------------------------------------------------------------------------------- /web/src/assets/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/logo.jpg -------------------------------------------------------------------------------- /web/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/logo.png -------------------------------------------------------------------------------- /web/src/assets/logo_login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/logo_login.png -------------------------------------------------------------------------------- /web/src/assets/nav_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/nav_logo.png -------------------------------------------------------------------------------- /web/src/assets/noBody.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/noBody.png -------------------------------------------------------------------------------- /web/src/assets/notFound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/notFound.png -------------------------------------------------------------------------------- /web/src/assets/qm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/qm.png -------------------------------------------------------------------------------- /web/src/assets/video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/assets/video.png -------------------------------------------------------------------------------- /web/src/components/chooseImg/index.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 57 | 58 | 76 | -------------------------------------------------------------------------------- /web/src/components/warningBar/warningBar.vue: -------------------------------------------------------------------------------- 1 | 13 | 22 | 42 | -------------------------------------------------------------------------------- /web/src/core/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 网站配置文件 3 | */ 4 | 5 | const config = { 6 | appName: 'raptor', 7 | appLogo: 'https://www.raptor.com/img/logo.png', 8 | showViteLogo: true 9 | } 10 | 11 | export const viteLogo = (env) => { 12 | if (config.showViteLogo) { 13 | const chalk = require('chalk') 14 | console.log( 15 | chalk.green( 16 | `> 欢迎使用raptor,开源地址` 17 | ) 18 | ) 19 | console.log( 20 | chalk.green( 21 | `> 当前版本:V2.5.0` 22 | ) 23 | ) 24 | console.log( 25 | chalk.green( 26 | `> ` 27 | ) 28 | ) 29 | console.log( 30 | chalk.green( 31 | `> ` 32 | ) 33 | ) 34 | console.log( 35 | chalk.green( 36 | `> 默认自动化文档地址:http://127.0.0.1:${env.VITE_SERVER_PORT}/swagger/index.html` 37 | ) 38 | ) 39 | console.log( 40 | chalk.green( 41 | `> 默认自动化文档地址:http://127.0.0.1:${env.VITE_SERVER_PORT}/swagger/index.html` 42 | ) 43 | ) 44 | console.log( 45 | chalk.green( 46 | `> 默认前端文件运行地址:http://127.0.0.1:${env.VITE_CLI_PORT}` 47 | ) 48 | ) 49 | console.log('\n') 50 | } 51 | } 52 | 53 | export default config 54 | -------------------------------------------------------------------------------- /web/src/core/global.js: -------------------------------------------------------------------------------- 1 | import config from './config' 2 | import { emitter } from '@/utils/bus.js' 3 | 4 | // 统一导入el-icon图标 5 | import * as ElIconModules from '@element-plus/icons-vue' 6 | // 导入转换图标名称的函数 7 | 8 | export const closeThisPage = () => { 9 | emitter.emit('closeThisPage') 10 | } 11 | 12 | export const register = (app) => { 13 | // 统一注册el-icon图标 14 | for (const iconName in ElIconModules) { 15 | app.component(iconName, ElIconModules[iconName]) 16 | } 17 | app.config.globalProperties.$GIN_VUE_ADMIN = config 18 | } 19 | -------------------------------------------------------------------------------- /web/src/core/raptor.js: -------------------------------------------------------------------------------- 1 | /* 2 | * raptor web框架组 3 | * 4 | * */ 5 | // 加载网站配置文件夹 6 | import { register } from './global' 7 | 8 | export default { 9 | install: (app) => { 10 | register(app) 11 | console.log(` 12 | 欢迎使用 raptor 13 | 当前版本:V0.1 14 | 默认自动化文档地址:http://127.0.0.1:${import.meta.env.VITE_SERVER_PORT}/swagger/index.html 15 | 默认前端文件运行地址:http://127.0.0.1:${import.meta.env.VITE_CLI_PORT} 16 | 17 | `) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /web/src/directive/auth.js: -------------------------------------------------------------------------------- 1 | // 权限按钮展示指令 2 | import { useUserStore } from '@/pinia/modules/user' 3 | export default { 4 | install: (app) => { 5 | const userStore = useUserStore() 6 | app.directive('auth', { 7 | // 当被绑定的元素插入到 DOM 中时…… 8 | mounted: function(el, binding) { 9 | const userInfo = userStore.userInfo 10 | let type = '' 11 | switch (Object.prototype.toString.call(binding.value)) { 12 | case '[object Array]': 13 | type = 'Array' 14 | break 15 | case '[object String]': 16 | type = 'String' 17 | break 18 | case '[object Number]': 19 | type = 'Number' 20 | break 21 | default: 22 | type = '' 23 | break 24 | } 25 | if (type === '') { 26 | el.parentNode.removeChild(el) 27 | return 28 | } 29 | const waitUse = binding.value.toString().split(',') 30 | let flag = waitUse.some(item => item === userInfo.authorityId) 31 | if (binding.modifiers.not) { 32 | flag = !flag 33 | } 34 | if (!flag) { 35 | el.parentNode.removeChild(el) 36 | } 37 | } 38 | }) 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /web/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import 'element-plus/dist/index.css' 3 | import './style/element_visiable.scss' 4 | import ElementPlus from 'element-plus' 5 | import zhCn from 'element-plus/es/locale/lang/zh-cn' 6 | // 引入raptor前端初始化相关内容 7 | import './core/raptor' 8 | // 引入封装的router 9 | import router from '@/router/index' 10 | import '@/permission' 11 | import run from '@/core/raptor.js' 12 | import auth from '@/directive/auth' 13 | import { store } from '@/pinia' 14 | import App from './App.vue' 15 | const app = createApp(App) 16 | app.config.productionTip = false 17 | 18 | app 19 | .use(run) 20 | .use(store) 21 | .use(auth) 22 | .use(router) 23 | .use(ElementPlus, { locale: zhCn }) 24 | .mount('#app') 25 | 26 | export default app 27 | -------------------------------------------------------------------------------- /web/src/pinia/index.js: -------------------------------------------------------------------------------- 1 | import { createPinia } from 'pinia' 2 | 3 | const store = createPinia() 4 | 5 | export { 6 | store 7 | } 8 | -------------------------------------------------------------------------------- /web/src/pinia/modules/dictionary.js: -------------------------------------------------------------------------------- 1 | import { findSysDictionary } from '@/api/sysDictionary' 2 | 3 | import { defineStore } from 'pinia' 4 | import { ref } from 'vue' 5 | 6 | export const useDictionaryStore = defineStore('dictionary', () => { 7 | const dictionaryMap = ref({}) 8 | 9 | const setDictionaryMap = (dictionaryRes) => { 10 | dictionaryMap.value = { ...dictionaryMap.value, ...dictionaryRes } 11 | } 12 | 13 | const getDictionary = async(type) => { 14 | if (dictionaryMap.value[type] && dictionaryMap.value[type].length) { 15 | return dictionaryMap.value[type] 16 | } else { 17 | const res = await findSysDictionary({ type }) 18 | if (res.code === 0) { 19 | const dictionaryRes = {} 20 | const dict = [] 21 | res.data.resysDictionary.sysDictionaryDetails && res.data.resysDictionary.sysDictionaryDetails.forEach(item => { 22 | dict.push({ 23 | label: item.label, 24 | value: item.value 25 | }) 26 | }) 27 | dictionaryRes[res.data.resysDictionary.type] = dict 28 | setDictionaryMap(dictionaryRes) 29 | return dictionaryMap.value[type] 30 | } 31 | } 32 | } 33 | 34 | return { 35 | dictionaryMap, 36 | setDictionaryMap, 37 | getDictionary 38 | } 39 | }) 40 | -------------------------------------------------------------------------------- /web/src/router/index.js: -------------------------------------------------------------------------------- 1 | import { createRouter, createWebHashHistory } from 'vue-router' 2 | 3 | const routes = [{ 4 | path: '/', 5 | redirect: '/login' 6 | }, 7 | { 8 | path: '/init', 9 | name: 'Init', 10 | component: () => import('@/view/init/index.vue') 11 | }, 12 | { 13 | path: '/login', 14 | name: 'Login', 15 | component: () => import('@/view/login/index.vue') 16 | } 17 | ] 18 | 19 | const router = createRouter({ 20 | history: createWebHashHistory(), 21 | routes 22 | }) 23 | 24 | export default router 25 | -------------------------------------------------------------------------------- /web/src/style/base.scss: -------------------------------------------------------------------------------- 1 | .clearflex { 2 | *zoom: 1; 3 | } 4 | 5 | .clearflex:after { 6 | content: ''; 7 | display: block; 8 | height: 0; 9 | visibility: hidden; 10 | clear: both; 11 | } 12 | 13 | .fl-left { 14 | float: left; 15 | } 16 | 17 | .fl-right { 18 | float: right; 19 | } 20 | 21 | .mg { 22 | margin: 10px !important; 23 | } 24 | 25 | .left-mg-xs { 26 | margin-left: 6px !important; 27 | } 28 | 29 | .left-mg-sm { 30 | margin-left: 10px !important; 31 | } 32 | 33 | .left-mg-md { 34 | margin-left: 14px !important; 35 | } 36 | 37 | .top-mg-lg { 38 | margin-top: 20px !important; 39 | } 40 | 41 | .tb-mg-lg { 42 | margin: 20px 0 !important; 43 | } 44 | 45 | .bottom-mg-lg { 46 | margin-bottom: 20px !important; 47 | } 48 | 49 | .left-mg-lg { 50 | margin-left: 18px !important; 51 | } 52 | 53 | .title-1 { 54 | text-align: center; 55 | font-size: 32px; 56 | } 57 | 58 | .title-3 { 59 | text-align: center; 60 | } 61 | -------------------------------------------------------------------------------- /web/src/style/basics.scss: -------------------------------------------------------------------------------- 1 | // basice 2 | $font-size: 14px; 3 | $icon-size:18px; 4 | $active-color:#1890ff; 5 | $bg-main:#f0f2f5; 6 | $border-color: #f4f4f4; 7 | $white-bg:#fff; 8 | $el-icon-small:30px; 9 | $el-icon-mini:24px; 10 | // aside 11 | $width-aside:220px; 12 | $width-hideside-aside:54px; 13 | $width-mobile-aside:210px; 14 | $color-aside:rgba(255, 255, 255, .9); 15 | $icon-arrow-size-aside:12px; 16 | $width-submenu-aside:55px; 17 | $height-aside-tilte:60px; 18 | $height-aside-img:30px; 19 | $width-aside-img:30px; 20 | // header 21 | $height-header: 60px; 22 | // nav-scroll 23 | $height-nav-scroll:40px; 24 | $active-bg-tabs-item-nav-scroll:#409eff; 25 | $bg-tabs-item-nav-scroll:#ddd; 26 | // table 27 | $bg-color-table-thead:#fafafa; 28 | $border-color-table:#ededed; 29 | $height-table-cell:45px; 30 | $color-table-tbody:#595959; 31 | $color-table-thead:#262626; 32 | // dashboard 33 | $height-car:68px; 34 | // mobile 35 | $padding-xs: 5px; 36 | $margin-xs: 5px; -------------------------------------------------------------------------------- /web/src/style/init.sass: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hequan2017/raptor/21b0af0277c5940efb1bcccfdb880e258a712f96/web/src/style/init.sass -------------------------------------------------------------------------------- /web/src/utils/asyncRouter.js: -------------------------------------------------------------------------------- 1 | const modules = import.meta.glob('../view/**/*.vue') 2 | 3 | export const asyncRouterHandle = (asyncRouter) => { 4 | asyncRouter.forEach(item => { 5 | if (item.component) { 6 | item.component = dynamicImport(modules, item.component) 7 | } else { 8 | delete item['component'] 9 | } 10 | if (item.children) { 11 | asyncRouterHandle(item.children) 12 | } 13 | }) 14 | } 15 | 16 | function dynamicImport( 17 | dynamicViewsModules, 18 | component 19 | ) { 20 | const keys = Object.keys(dynamicViewsModules) 21 | const matchKeys = keys.filter((key) => { 22 | const k = key.replace('../', '') 23 | return k === component 24 | }) 25 | const matchKey = matchKeys[0] 26 | 27 | return dynamicViewsModules[matchKey] 28 | } 29 | -------------------------------------------------------------------------------- /web/src/utils/btnAuth.js: -------------------------------------------------------------------------------- 1 | import { useRoute } from 'vue-router' 2 | import {reactive }from 'vue' 3 | export const useBtnAuth = () => { 4 | const route = useRoute() 5 | return route.meta.btns || reactive({}) 6 | } 7 | -------------------------------------------------------------------------------- /web/src/utils/bus.js: -------------------------------------------------------------------------------- 1 | 2 | // using ES6 modules 3 | import mitt from 'mitt' 4 | 5 | export const emitter = mitt() 6 | 7 | -------------------------------------------------------------------------------- /web/src/utils/date.js: -------------------------------------------------------------------------------- 1 | // 对Date的扩展,将 Date 转化为指定格式的String 2 | // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, 3 | // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) 4 | // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 5 | // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 6 | // eslint-disable-next-line no-extend-native 7 | Date.prototype.Format = function(fmt) { 8 | var o = { 9 | 'M+': this.getMonth() + 1, // 月份 10 | 'd+': this.getDate(), // 日 11 | 'h+': this.getHours(), // 小时 12 | 'm+': this.getMinutes(), // 分 13 | 's+': this.getSeconds(), // 秒 14 | 'q+': Math.floor((this.getMonth() + 3) / 3), // 季度 15 | 'S': this.getMilliseconds() // 毫秒 16 | } 17 | if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) } 18 | for (var k in o) { 19 | if (new RegExp('(' + k + ')').test(fmt)) { fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) } 20 | } 21 | return fmt 22 | } 23 | 24 | export function formatTimeToStr(times, pattern) { 25 | var d = new Date(times).Format('yyyy-MM-dd hh:mm:ss') 26 | if (pattern) { 27 | d = new Date(times).Format(pattern) 28 | } 29 | return d.toLocaleString() 30 | } 31 | -------------------------------------------------------------------------------- /web/src/utils/dictionary.js: -------------------------------------------------------------------------------- 1 | import { useDictionaryStore } from '@/pinia/modules/dictionary' 2 | // 获取字典方法 使用示例 getDict('sex').then(res) 或者 async函数下 const res = await getDict('sex') 3 | export const getDict = async(type) => { 4 | const dictionaryStore = useDictionaryStore() 5 | await dictionaryStore.getDictionary(type) 6 | return dictionaryStore.dictionaryMap[type] 7 | } 8 | -------------------------------------------------------------------------------- /web/src/utils/downloadImg.js: -------------------------------------------------------------------------------- 1 | export const downloadImage = (imgsrc, name) => { // 下载图片地址和图片名 2 | var image = new Image() 3 | image.setAttribute('crossOrigin', 'anonymous') 4 | image.onload = function() { 5 | var canvas = document.createElement('canvas') 6 | canvas.width = image.width 7 | canvas.height = image.height 8 | var context = canvas.getContext('2d') 9 | context.drawImage(image, 0, 0, image.width, image.height) 10 | var url = canvas.toDataURL('image/png') // 得到图片的base64编码数据 11 | 12 | var a = document.createElement('a') // 生成一个a元素 13 | var event = new MouseEvent('click') // 创建一个单击事件 14 | a.download = name || 'photo' // 设置图片名称 15 | a.href = url // 将生成的URL设置为a.href属性 16 | a.dispatchEvent(event) // 触发a的单击事件 17 | } 18 | image.src = imgsrc 19 | } 20 | -------------------------------------------------------------------------------- /web/src/utils/format.js: -------------------------------------------------------------------------------- 1 | import { formatTimeToStr } from '@/utils/date' 2 | import { getDict } from '@/utils/dictionary' 3 | 4 | export const formatBoolean = (bool) => { 5 | if (bool !== null) { 6 | return bool ? '是' : '否' 7 | } else { 8 | return '' 9 | } 10 | } 11 | export const formatDate = (time) => { 12 | if (time !== null && time !== '') { 13 | var date = new Date(time) 14 | return formatTimeToStr(date, 'yyyy-MM-dd hh:mm:ss') 15 | } else { 16 | return '' 17 | } 18 | } 19 | 20 | export const filterDict = (value, options) => { 21 | const rowLabel = options && options.filter(item => item.value === value) 22 | return rowLabel && rowLabel[0] && rowLabel[0].label 23 | } 24 | 25 | export const getDictFunc = async(type) => { 26 | const dicts = await getDict(type) 27 | return dicts 28 | } 29 | 30 | export const formatProduct = (product) => { 31 | if (product !== null && product !== '') { 32 | var p = [] 33 | product.forEach(function(val, index, arr){ 34 | p.push(val["name"]) 35 | }); 36 | return p.join(" ") 37 | } else { 38 | return '' 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /web/src/utils/page.js: -------------------------------------------------------------------------------- 1 | import config from '@/core/config' 2 | export default function getPageTitle(pageTitle) { 3 | if (pageTitle) { 4 | return `${pageTitle} - ${config.appName}` 5 | } 6 | return `${config.appName}` 7 | } 8 | -------------------------------------------------------------------------------- /web/src/utils/stringFun.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const toUpperCase = (str) => { 3 | if (str[0]) { 4 | return str.replace(str[0], str[0].toUpperCase()) 5 | } else { 6 | return '' 7 | } 8 | } 9 | 10 | export const toLowerCase = (str) => { 11 | if (str[0]) { 12 | return str.replace(str[0], str[0].toLowerCase()) 13 | } else { 14 | return '' 15 | } 16 | } 17 | 18 | // 驼峰转换下划线 19 | export const toSQLLine = (str) => { 20 | if (str === 'ID') return 'ID' 21 | return str.replace(/([A-Z])/g, "_$1").toLowerCase(); 22 | } 23 | 24 | // 下划线转换驼峰 25 | export const toHump = (name) => { 26 | return name.replace(/\_(\w)/g, function(all, letter) { 27 | return letter.toUpperCase(); 28 | }); 29 | } -------------------------------------------------------------------------------- /web/src/view/cmdb/index.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 18 | 22 | -------------------------------------------------------------------------------- /web/src/view/error/index.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 21 | 22 | 46 | -------------------------------------------------------------------------------- /web/src/view/error/reload.vue: -------------------------------------------------------------------------------- 1 | 4 | 10 | 11 | 15 | -------------------------------------------------------------------------------- /web/src/view/example/index.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 18 | 22 | -------------------------------------------------------------------------------- /web/src/view/layout/aside/asideComponent/asyncSubmenu.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 18 | 19 | 29 | -------------------------------------------------------------------------------- /web/src/view/layout/aside/asideComponent/index.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 14 | 15 | 35 | 36 | -------------------------------------------------------------------------------- /web/src/view/layout/aside/asideComponent/menuItem.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 17 | 18 | 28 | 29 | 34 | -------------------------------------------------------------------------------- /web/src/view/layout/bottomInfo/bottomInfo.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 23 | 24 | 41 | -------------------------------------------------------------------------------- /web/src/view/routerHolder.vue: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 19 | 20 | 24 | -------------------------------------------------------------------------------- /web/src/view/serve/index.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 18 | 22 | -------------------------------------------------------------------------------- /web/src/view/superAdmin/index.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 18 | 22 | -------------------------------------------------------------------------------- /web/src/view/systemTools/formCreate/index.vue: -------------------------------------------------------------------------------- 1 |