From a37d088360ed901f52592d5613c275c47ad69cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E5=B8=85?= <133814250@qq.com> Date: Sun, 21 Jul 2024 22:21:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83v2.15.7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9=E8=AF=B7=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=EF=BC=9Ahttps://github.com/bufanyun/hotgo/tree/v2.0/d?= =?UTF-8?q?ocs/guide-zh-CN/addon-version-upgrade.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/guide-zh-CN/start-update-log.md | 11 + server/Makefile | 1 + server/api/admin/attachment/attachment.go | 18 -- server/api/admin/curddemo/curddemo.go | 12 +- server/api/admin/monitor/monitor.go | 3 +- .../admin/normaltreedemo/normaltreedemo.go | 2 +- .../admin/optiontreedemo/optiontreedemo.go | 2 +- server/api/admin/testcategory/testcategory.go | 2 +- server/go.mod | 62 ++-- server/go.sum | 130 +++++---- server/internal/consts/ems.go | 6 - server/internal/consts/servelicense.go | 18 +- server/internal/consts/sms.go | 7 - server/internal/consts/status.go | 33 +++ server/internal/consts/version.go | 2 +- .../controller/admin/admin/monitor.go | 10 - .../controller/admin/sys/attachment.go | 38 --- .../controller/admin/sys/curd_demo.go | 10 +- .../controller/admin/sys/normal_tree_demo.go | 2 +- .../controller/admin/sys/option_tree_demo.go | 2 +- .../controller/admin/sys/test_category.go | 2 +- server/internal/dao/addon_hgexample_table.go | 0 .../dao/addon_hgexample_tenant_order.go | 0 server/internal/dao/admin_cash.go | 0 server/internal/dao/admin_credits_log.go | 0 server/internal/dao/admin_dept.go | 0 server/internal/dao/admin_member.go | 0 server/internal/dao/admin_member_post.go | 0 server/internal/dao/admin_member_role.go | 0 server/internal/dao/admin_menu.go | 0 server/internal/dao/admin_notice.go | 0 server/internal/dao/admin_notice_read.go | 0 server/internal/dao/admin_oauth.go | 0 server/internal/dao/admin_order.go | 0 server/internal/dao/admin_post.go | 0 server/internal/dao/admin_role.go | 0 server/internal/dao/admin_role_casbin.go | 0 server/internal/dao/admin_role_menu.go | 0 .../dao/internal/addon_hgexample_table.go | 0 .../internal/addon_hgexample_tenant_order.go | 0 server/internal/dao/internal/admin_cash.go | 0 .../dao/internal/admin_credits_log.go | 0 server/internal/dao/internal/admin_dept.go | 0 server/internal/dao/internal/admin_member.go | 0 .../dao/internal/admin_member_post.go | 0 .../dao/internal/admin_member_role.go | 0 server/internal/dao/internal/admin_menu.go | 0 server/internal/dao/internal/admin_notice.go | 0 .../dao/internal/admin_notice_read.go | 0 server/internal/dao/internal/admin_oauth.go | 0 server/internal/dao/internal/admin_order.go | 0 server/internal/dao/internal/admin_post.go | 0 server/internal/dao/internal/admin_role.go | 0 .../dao/internal/admin_role_casbin.go | 0 .../internal/dao/internal/admin_role_menu.go | 0 server/internal/dao/internal/pay_log.go | 0 server/internal/dao/internal/pay_refund.go | 0 .../dao/internal/sys_addons_config.go | 0 .../internal/dao/internal/sys_attachment.go | 0 server/internal/dao/internal/sys_blacklist.go | 0 server/internal/dao/internal/sys_config.go | 0 server/internal/dao/internal/sys_cron.go | 0 .../internal/dao/internal/sys_cron_group.go | 0 server/internal/dao/internal/sys_dict_data.go | 0 server/internal/dao/internal/sys_dict_type.go | 0 server/internal/dao/internal/sys_ems_log.go | 0 server/internal/dao/internal/sys_gen_codes.go | 0 .../dao/internal/sys_gen_curd_demo.go | 0 .../dao/internal/sys_gen_tree_demo.go | 0 server/internal/dao/internal/sys_log.go | 0 server/internal/dao/internal/sys_login_log.go | 0 server/internal/dao/internal/sys_provinces.go | 0 .../dao/internal/sys_serve_license.go | 0 server/internal/dao/internal/sys_serve_log.go | 0 server/internal/dao/internal/sys_sms_log.go | 0 server/internal/dao/internal/test_category.go | 0 server/internal/dao/pay_log.go | 0 server/internal/dao/pay_refund.go | 0 server/internal/dao/sys_addons_config.go | 0 server/internal/dao/sys_attachment.go | 0 server/internal/dao/sys_blacklist.go | 0 server/internal/dao/sys_config.go | 0 server/internal/dao/sys_cron.go | 0 server/internal/dao/sys_cron_group.go | 0 server/internal/dao/sys_dict_data.go | 0 server/internal/dao/sys_dict_type.go | 0 server/internal/dao/sys_ems_log.go | 0 server/internal/dao/sys_gen_codes.go | 0 server/internal/dao/sys_gen_curd_demo.go | 0 server/internal/dao/sys_gen_tree_demo.go | 0 server/internal/dao/sys_log.go | 0 server/internal/dao/sys_login_log.go | 0 server/internal/dao/sys_provinces.go | 0 server/internal/dao/sys_serve_license.go | 0 server/internal/dao/sys_serve_log.go | 0 server/internal/dao/sys_sms_log.go | 0 server/internal/dao/test_category.go | 0 server/internal/library/dict/dict_option.go | 65 ++++- .../library/hggen/internal/cmd/cmd_doc.go | 177 ++++++++++++ .../library/hggen/internal/cmd/cmd_gen_dao.go | 1 + .../library/hggen/internal/cmd/cmd_init.go | 38 ++- .../library/hggen/internal/cmd/cmd_pack.go | 2 +- .../library/hggen/internal/cmd/cmd_run.go | 63 ++-- .../library/hggen/internal/cmd/cmd_tpl.go | 2 +- .../library/hggen/internal/cmd/cmd_up.go | 7 +- .../internal/cmd/cmd_z_unit_gen_ctrl_test.go | 229 ++++++++++++++- .../internal/cmd/cmd_z_unit_gen_dao_test.go | 259 +++++++++++++++-- .../cmd/cmd_z_unit_gen_pbentity_test.go | 178 ++++++++++-- .../cmd/cmd_z_unit_gen_service_test.go | 8 +- .../hggen/internal/cmd/genctrl/genctrl.go | 9 +- .../internal/cmd/genctrl/genctrl_ast_parse.go | 78 +++++ .../cmd/genctrl/genctrl_ast_parse_clear.go | 43 +++ .../internal/cmd/genctrl/genctrl_calculate.go | 42 ++- .../cmd/genctrl/genctrl_generate_ctrl.go | 83 +++++- .../genctrl/genctrl_generate_ctrl_clear.go | 11 +- .../cmd/genctrl/genctrl_generate_sdk.go | 2 + .../hggen/internal/cmd/gendao/gendao.go | 26 +- .../hggen/internal/cmd/gendao/gendao_dao.go | 9 +- .../hggen/internal/cmd/gendao/gendao_do.go | 5 +- .../internal/cmd/gendao/gendao_entity.go | 5 +- .../internal/cmd/gendao/gendao_structure.go | 10 +- .../internal/cmd/genpbentity/genpbentity.go | 17 +- .../internal/cmd/genservice/genservice.go | 143 +++------ .../cmd/genservice/genservice_ast_parse.go | 186 ++++++++++++ .../cmd/genservice/genservice_ast_utils.go | 48 ++++ .../cmd/genservice/genservice_calculate.go | 271 ++++++++---------- .../cmd/genservice/genservice_generate.go | 143 +-------- .../genservice_generate_template.go | 104 +++++++ .../cmd/testdata/build/multiple/multiple.go | 5 + .../cmd/testdata/build/single/main.go | 5 + .../internal/cmd/testdata/build/varmap/go.mod | 12 + .../internal/cmd/testdata/build/varmap/go.sum | 27 ++ .../cmd/testdata/build/varmap/main.go | 13 + .../cmd/testdata/fix/fix25_content.go | 30 ++ .../api/dict/dict_add_new_ctrl_expect.gotest | 17 ++ .../add_new_ctrl/api/dict/dict_expect.go | 15 + .../add_new_ctrl/api/dict/v1/dict_type.go | 17 ++ .../add_new_ctrl/controller/dict/dict.go | 5 + .../add_new_ctrl/controller/dict/dict_new.go | 15 + .../controller/dict/dict_v1_dict_type.go | 14 + .../controller/dict/dict_v1_test_new.gotest | 17 ++ .../api/dict/dict_add_new_ctrl_expect.gotest | 17 ++ .../add_new_file/api/dict/dict_expect.go | 15 + .../add_new_file/api/dict/v1/dict_type.go | 17 ++ .../add_new_file/controller/dict/dict.go | 5 + .../add_new_file/controller/dict/dict_new.go | 15 + .../controller/dict/dict_v1_dict_type.go | 14 + .../controller/dict/dict_v1_test_new.gotest | 14 + .../genctrl/api/article/article_expect.go | 24 ++ .../testdata/genctrl/api/article/v1/edit.go | 27 ++ .../testdata/genctrl/api/article/v1/get.go | 25 ++ .../testdata/genctrl/api/article/v2/edit.go | 31 ++ .../genctrl/controller/article/article.go | 5 + .../genctrl/controller/article/article_new.go | 21 ++ .../controller/article/article_v1_create.go | 14 + .../controller/article/article_v1_get_list.go | 14 + .../controller/article/article_v1_get_one.go | 14 + .../controller/article/article_v1_update.go | 14 + .../controller/article/article_v2_create.go | 14 + .../controller/article/article_v2_update.go | 14 + .../generated_user/dao/internal/table_user.go | 85 ++++++ .../gendao/generated_user/dao/table_user.go | 27 ++ .../generated_user/model/do/table_user.go | 22 ++ .../generated_user/model/entity/table_user.go | 20 ++ .../dao/internal/table_user.go | 85 ++++++ .../dao/table_user.go | 27 ++ .../model/do/table_user.go | 22 ++ .../model/entity/table_user.go | 21 ++ .../dao/internal/table_user.go | 85 ++++++ .../dao/table_user.go | 27 ++ .../model/do/table_user.go | 22 ++ .../model/entity/table_user.go | 21 ++ .../internal/cmd/testdata/gendao/go.mod.txt | 32 +++ .../internal/cmd/testdata/gendao/user.tpl.sql | 10 + .../genpbentity/generated/table_user.proto | 21 ++ .../table_user_snake_screaming.proto | 21 ++ .../cmd/testdata/genpbentity/user.tpl.sql | 10 + .../genservice/logic/article/article.go | 47 +++ .../genservice/logic/article/article_extra.go | 75 +++++ .../genservice/logic/delivery/delivery_app.go | 38 +++ .../logic/delivery/delivery_cluster.go | 32 +++ .../testdata/genservice/logic/logic_expect.go | 11 + .../testdata/genservice/logic/user/user.go | 49 ++++ .../testdata/genservice/service/article.go | 58 ++++ .../testdata/genservice/service/delivery.go | 55 ++++ .../cmd/testdata/genservice/service/user.go | 40 +++ .../cmd/testdata/issue/2572/config.yaml | 20 ++ .../issue/2572/dao/internal/user_3.go | 85 ++++++ .../issue/2572/dao/internal/user_4.go | 85 ++++++ .../cmd/testdata/issue/2572/dao/user_3.go | 27 ++ .../cmd/testdata/issue/2572/dao/user_4.go | 27 ++ .../testdata/issue/2572/model/do/user_3.go | 22 ++ .../testdata/issue/2572/model/do/user_4.go | 22 ++ .../issue/2572/model/entity/user_3.go | 20 ++ .../issue/2572/model/entity/user_4.go | 20 ++ .../internal/cmd/testdata/issue/2572/sql1.sql | 10 + .../internal/cmd/testdata/issue/2572/sql2.sql | 10 + .../cmd/testdata/issue/2616/config.yaml | 20 ++ .../issue/2616/dao/internal/user_1.go | 85 ++++++ .../issue/2616/dao/internal/user_2.go | 85 ++++++ .../issue/2616/dao/internal/user_3.go | 85 ++++++ .../issue/2616/dao/internal/user_4.go | 85 ++++++ .../cmd/testdata/issue/2616/dao/user_1.go | 29 ++ .../cmd/testdata/issue/2616/dao/user_2.go | 29 ++ .../cmd/testdata/issue/2616/dao/user_3.go | 27 ++ .../cmd/testdata/issue/2616/dao/user_4.go | 27 ++ .../testdata/issue/2616/model/do/user_3.go | 22 ++ .../testdata/issue/2616/model/do/user_4.go | 22 ++ .../issue/2616/model/entity/user_3.go | 20 ++ .../issue/2616/model/entity/user_4.go | 20 ++ .../internal/cmd/testdata/issue/2616/sql1.sql | 10 + .../internal/cmd/testdata/issue/2616/sql2.sql | 10 + .../cmd/testdata/issue/2746/issue_2746.go | 18 ++ .../internal/cmd/testdata/issue/2746/sql.sql | 9 + .../cmd/testdata/issue/3459/config.yaml | 5 + .../testdata/issue/3460/api/hello/hello.go | 26 ++ .../testdata/issue/3460/api/hello/v1/req.go | 37 +++ .../testdata/issue/3460/api/hello/v2/req.go | 37 +++ .../issue/3460/controller/hello/hello.go | 5 + .../issue/3460/controller/hello/hello_new.go | 21 ++ .../3460/controller/hello/hello_v1_req.go | 23 ++ .../3460/controller/hello/hello_v2_req.go | 23 ++ .../cmd/testdata/issue/3545/table_user.proto | 21 ++ .../consts/consts_gen_ctrl_template.go | 14 + .../consts/consts_gen_ctrl_template_sdk.go | 6 - .../consts/consts_gen_dao_template_dao.go | 2 +- .../consts/consts_gen_dao_template_do.go | 2 +- .../consts/consts_gen_dao_template_entity.go | 2 +- .../internal/packed/template-mono-app.go | 9 + .../utility/utils/utils_http_download.go | 10 +- .../library/hggen/views/column_default.go | 2 + .../hggen/views/curd_generate_input.go | 30 +- .../hggen/views/curd_generate_web_edit.go | 15 +- .../hggen/views/curd_generate_web_index.go | 7 +- .../hggen/views/curd_generate_web_model.go | 66 ++--- .../hggen/views/curd_generate_web_view.go | 6 +- server/internal/library/hggen/views/utils.go | 3 +- server/internal/library/storager/upload.go | 6 +- server/internal/logic/sys/attachment.go | 15 + server/internal/logic/sys/curd_demo.go | 28 +- server/internal/logic/sys/ems_log.go | 6 +- server/internal/logic/sys/log.go | 33 ++- server/internal/logic/sys/normal_tree_demo.go | 4 +- server/internal/logic/sys/option_tree_demo.go | 4 +- server/internal/logic/sys/serve_log.go | 7 + server/internal/logic/sys/sms_log.go | 6 +- server/internal/logic/sys/test_category.go | 6 +- .../logic/tcpclient/cron_interceptor.go | 4 +- server/internal/model/dict.go | 1 + .../model/do/addon_hgexample_table.go | 0 .../model/do/addon_hgexample_tenant_order.go | 0 server/internal/model/do/admin_cash.go | 0 server/internal/model/do/admin_credits_log.go | 0 server/internal/model/do/admin_dept.go | 0 server/internal/model/do/admin_member.go | 0 server/internal/model/do/admin_member_post.go | 0 server/internal/model/do/admin_member_role.go | 0 server/internal/model/do/admin_menu.go | 0 server/internal/model/do/admin_notice.go | 0 server/internal/model/do/admin_notice_read.go | 0 server/internal/model/do/admin_oauth.go | 0 server/internal/model/do/admin_order.go | 0 server/internal/model/do/admin_post.go | 0 server/internal/model/do/admin_role.go | 0 server/internal/model/do/admin_role_casbin.go | 0 server/internal/model/do/admin_role_menu.go | 0 server/internal/model/do/pay_log.go | 0 server/internal/model/do/pay_refund.go | 0 server/internal/model/do/sys_addons_config.go | 0 server/internal/model/do/sys_attachment.go | 0 server/internal/model/do/sys_blacklist.go | 0 server/internal/model/do/sys_config.go | 0 server/internal/model/do/sys_cron.go | 0 server/internal/model/do/sys_cron_group.go | 0 server/internal/model/do/sys_dict_data.go | 0 server/internal/model/do/sys_dict_type.go | 0 server/internal/model/do/sys_ems_log.go | 0 server/internal/model/do/sys_gen_codes.go | 0 server/internal/model/do/sys_gen_curd_demo.go | 0 server/internal/model/do/sys_gen_tree_demo.go | 0 server/internal/model/do/sys_log.go | 0 server/internal/model/do/sys_login_log.go | 0 server/internal/model/do/sys_provinces.go | 0 server/internal/model/do/sys_serve_license.go | 0 server/internal/model/do/sys_serve_log.go | 0 server/internal/model/do/sys_sms_log.go | 0 server/internal/model/do/test_category.go | 0 .../model/entity/addon_hgexample_table.go | 0 .../entity/addon_hgexample_tenant_order.go | 0 server/internal/model/entity/admin_cash.go | 0 .../model/entity/admin_credits_log.go | 0 server/internal/model/entity/admin_dept.go | 0 server/internal/model/entity/admin_member.go | 0 .../model/entity/admin_member_post.go | 0 .../model/entity/admin_member_role.go | 0 server/internal/model/entity/admin_menu.go | 0 server/internal/model/entity/admin_notice.go | 0 .../model/entity/admin_notice_read.go | 0 server/internal/model/entity/admin_oauth.go | 0 server/internal/model/entity/admin_order.go | 0 server/internal/model/entity/admin_post.go | 0 server/internal/model/entity/admin_role.go | 0 .../model/entity/admin_role_casbin.go | 0 .../internal/model/entity/admin_role_menu.go | 0 server/internal/model/entity/pay_log.go | 0 server/internal/model/entity/pay_refund.go | 0 .../model/entity/sys_addons_config.go | 0 .../internal/model/entity/sys_attachment.go | 0 server/internal/model/entity/sys_blacklist.go | 0 server/internal/model/entity/sys_config.go | 0 server/internal/model/entity/sys_cron.go | 0 .../internal/model/entity/sys_cron_group.go | 0 server/internal/model/entity/sys_dict_data.go | 0 server/internal/model/entity/sys_dict_type.go | 0 server/internal/model/entity/sys_ems_log.go | 0 server/internal/model/entity/sys_gen_codes.go | 0 .../model/entity/sys_gen_curd_demo.go | 0 .../model/entity/sys_gen_tree_demo.go | 0 server/internal/model/entity/sys_log.go | 0 server/internal/model/entity/sys_login_log.go | 0 server/internal/model/entity/sys_provinces.go | 0 .../model/entity/sys_serve_license.go | 0 server/internal/model/entity/sys_serve_log.go | 0 server/internal/model/entity/sys_sms_log.go | 0 server/internal/model/entity/test_category.go | 0 .../internal/model/input/sysin/curd_demo.go | 48 ++-- server/internal/model/input/sysin/log.go | 1 + .../model/input/sysin/normal_tree_demo.go | 2 +- .../model/input/sysin/option_tree_demo.go | 6 +- .../internal/model/input/sysin/serve_log.go | 2 +- .../model/input/sysin/test_category.go | 2 +- server/internal/router/genrouter/curd_demo.go | 4 +- .../router/genrouter/normal_tree_demo.go | 2 +- .../router/genrouter/option_tree_demo.go | 2 +- .../router/genrouter/test_category.go | 2 +- server/internal/service/admin.go | 2 +- server/internal/service/common.go | 2 +- server/internal/service/hook.go | 2 +- server/internal/service/middleware.go | 4 +- server/internal/service/sys.go | 7 + server/internal/service/tcpserver.go | 2 +- server/internal/service/view.go | 7 +- server/manifest/config/config.example.yaml | 1 - .../default/curd/web.edit.vue.template | 54 ++-- .../default/curd/web.index.vue.template | 18 +- .../default/curd/web.model.ts.template | 20 +- .../default/curd/web.view.vue.template | 11 +- web/package.json | 4 +- web/src/App.vue | 4 +- web/src/api/apply/attachment.ts | 7 - web/src/api/curdDemo/index.ts | 11 +- .../components/FileChooser/src/Chooser.vue | 55 ++-- web/src/components/FileChooser/src/model.ts | 6 - web/src/enums/localDictEnum.ts | 124 ++++++++ web/src/enums/systemMessageEnum.ts | 69 +---- web/src/router/index.ts | 2 +- web/src/store/modules/dict.ts | 181 ++++++++++++ web/src/store/modules/index.ts | 4 + web/src/store/modules/user.ts | 2 + web/src/store/mutation-types.ts | 1 + web/src/store/types.ts | 2 + web/src/utils/hotgo.ts | 30 +- web/src/utils/index.ts | 30 +- web/src/utils/urlUtils.ts | 14 + web/src/utils/validateUtil.ts | 49 ++-- web/src/views/addons/hgexample/table/edit.vue | 19 +- .../views/addons/hgexample/table/index.vue | 24 +- web/src/views/addons/hgexample/table/model.ts | 115 ++------ web/src/views/addons/hgexample/table/view.vue | 21 +- .../addons/hgexample/tenantOrder/edit.vue | 9 +- .../addons/hgexample/tenantOrder/model.ts | 47 +-- .../views/addons/hgexample/treeTable/edit.vue | 21 +- .../addons/hgexample/treeTable/index.vue | 14 +- .../views/addons/hgexample/treeTable/list.vue | 12 +- .../views/addons/hgexample/treeTable/model.ts | 119 ++------ web/src/views/apply/attachment/columns.ts | 55 +--- web/src/views/apply/attachment/index.vue | 16 +- web/src/views/apply/notice/columns.ts | 39 +-- web/src/views/apply/notice/index.vue | 25 +- web/src/views/apply/provinces/edit.vue | 6 +- web/src/views/apply/provinces/index.vue | 17 +- web/src/views/apply/provinces/list.vue | 3 - web/src/views/apply/provinces/model.ts | 38 +-- web/src/views/asset/cash/list.vue | 31 +- web/src/views/asset/creditsLog/index.vue | 10 +- web/src/views/asset/creditsLog/model.ts | 114 +------- web/src/views/asset/payRefund/index.vue | 26 +- web/src/views/asset/payRefund/model.ts | 90 +----- .../views/asset/rechargeLog/acceptRefund.vue | 9 +- .../views/asset/rechargeLog/applyRefund.vue | 13 +- web/src/views/asset/rechargeLog/index.vue | 15 +- web/src/views/asset/rechargeLog/list.vue | 11 +- web/src/views/asset/rechargeLog/model.ts | 73 +---- web/src/views/curdDemo/edit.vue | 31 +- web/src/views/curdDemo/index.vue | 35 ++- web/src/views/curdDemo/model.ts | 116 +------- web/src/views/curdDemo/view.vue | 123 -------- .../console/components/FluxTrend.vue | 2 - web/src/views/develop/addons/index.vue | 14 +- web/src/views/develop/addons/model.ts | 42 +-- web/src/views/develop/code/index.vue | 43 +-- web/src/views/log/log/model.ts | 78 +++-- web/src/views/log/log/view.vue | 21 +- web/src/views/log/login-log/index.vue | 2 +- web/src/views/log/login-log/model.ts | 80 +----- web/src/views/log/sms-log/index.vue | 78 ++--- web/src/views/monitor/netconn/columns.ts | 18 +- web/src/views/monitor/netconn/index.vue | 16 +- web/src/views/monitor/netconn/modal/edit.vue | 14 +- web/src/views/monitor/netconn/modal/index.vue | 32 ++- web/src/views/monitor/netconn/modal/model.ts | 73 +---- web/src/views/monitor/serve-log/index.vue | 13 +- web/src/views/monitor/serve-log/model.ts | 103 ++----- web/src/views/normalTreeDemo/edit.vue | 23 +- web/src/views/normalTreeDemo/index.vue | 15 +- web/src/views/normalTreeDemo/model.ts | 39 +-- web/src/views/normalTreeDemo/view.vue | 92 ------ web/src/views/optionTreeDemo/edit.vue | 62 ++-- web/src/views/optionTreeDemo/index.vue | 9 +- web/src/views/optionTreeDemo/model.ts | 77 +---- web/src/views/optionTreeDemo/view.vue | 92 ------ web/src/views/org/dept/edit.vue | 8 +- web/src/views/org/dept/model.ts | 64 +---- web/src/views/org/user/list.vue | 73 ++--- web/src/views/org/user/model.ts | 65 +++-- web/src/views/org/user/user.vue | 11 +- web/src/views/permission/menu/editForm.vue | 18 +- web/src/views/permission/menu/menuModal.vue | 4 +- web/src/views/permission/menu/model.ts | 31 +- web/src/views/system/blacklist/index.vue | 69 +---- web/src/views/system/config/PaySetting.vue | 53 ++-- web/src/views/system/config/SmsSetting.vue | 91 +++--- web/src/views/system/config/UploadSetting.vue | 74 ++--- web/src/views/system/dict/CreateDrawer.vue | 175 +++++------ web/src/views/system/dict/index.vue | 38 +-- web/src/views/system/dict/list.vue | 106 +++---- web/src/views/system/dict/model.ts | 18 ++ web/src/views/testCategory/edit.vue | 21 +- web/src/views/testCategory/index.vue | 9 +- web/src/views/testCategory/model.ts | 34 +-- 440 files changed, 6303 insertions(+), 3339 deletions(-) mode change 100644 => 100755 server/internal/dao/addon_hgexample_table.go mode change 100644 => 100755 server/internal/dao/addon_hgexample_tenant_order.go mode change 100644 => 100755 server/internal/dao/admin_cash.go mode change 100644 => 100755 server/internal/dao/admin_credits_log.go mode change 100644 => 100755 server/internal/dao/admin_dept.go mode change 100644 => 100755 server/internal/dao/admin_member.go mode change 100644 => 100755 server/internal/dao/admin_member_post.go mode change 100644 => 100755 server/internal/dao/admin_member_role.go mode change 100644 => 100755 server/internal/dao/admin_menu.go mode change 100644 => 100755 server/internal/dao/admin_notice.go mode change 100644 => 100755 server/internal/dao/admin_notice_read.go mode change 100644 => 100755 server/internal/dao/admin_oauth.go mode change 100644 => 100755 server/internal/dao/admin_order.go mode change 100644 => 100755 server/internal/dao/admin_post.go mode change 100644 => 100755 server/internal/dao/admin_role.go mode change 100644 => 100755 server/internal/dao/admin_role_casbin.go mode change 100644 => 100755 server/internal/dao/admin_role_menu.go mode change 100644 => 100755 server/internal/dao/internal/addon_hgexample_table.go mode change 100644 => 100755 server/internal/dao/internal/addon_hgexample_tenant_order.go mode change 100644 => 100755 server/internal/dao/internal/admin_cash.go mode change 100644 => 100755 server/internal/dao/internal/admin_credits_log.go mode change 100644 => 100755 server/internal/dao/internal/admin_dept.go mode change 100644 => 100755 server/internal/dao/internal/admin_member.go mode change 100644 => 100755 server/internal/dao/internal/admin_member_post.go mode change 100644 => 100755 server/internal/dao/internal/admin_member_role.go mode change 100644 => 100755 server/internal/dao/internal/admin_menu.go mode change 100644 => 100755 server/internal/dao/internal/admin_notice.go mode change 100644 => 100755 server/internal/dao/internal/admin_notice_read.go mode change 100644 => 100755 server/internal/dao/internal/admin_oauth.go mode change 100644 => 100755 server/internal/dao/internal/admin_order.go mode change 100644 => 100755 server/internal/dao/internal/admin_post.go mode change 100644 => 100755 server/internal/dao/internal/admin_role.go mode change 100644 => 100755 server/internal/dao/internal/admin_role_casbin.go mode change 100644 => 100755 server/internal/dao/internal/admin_role_menu.go mode change 100644 => 100755 server/internal/dao/internal/pay_log.go mode change 100644 => 100755 server/internal/dao/internal/pay_refund.go mode change 100644 => 100755 server/internal/dao/internal/sys_addons_config.go mode change 100644 => 100755 server/internal/dao/internal/sys_attachment.go mode change 100644 => 100755 server/internal/dao/internal/sys_blacklist.go mode change 100644 => 100755 server/internal/dao/internal/sys_config.go mode change 100644 => 100755 server/internal/dao/internal/sys_cron.go mode change 100644 => 100755 server/internal/dao/internal/sys_cron_group.go mode change 100644 => 100755 server/internal/dao/internal/sys_dict_data.go mode change 100644 => 100755 server/internal/dao/internal/sys_dict_type.go mode change 100644 => 100755 server/internal/dao/internal/sys_ems_log.go mode change 100644 => 100755 server/internal/dao/internal/sys_gen_codes.go mode change 100644 => 100755 server/internal/dao/internal/sys_gen_curd_demo.go mode change 100644 => 100755 server/internal/dao/internal/sys_gen_tree_demo.go mode change 100644 => 100755 server/internal/dao/internal/sys_log.go mode change 100644 => 100755 server/internal/dao/internal/sys_login_log.go mode change 100644 => 100755 server/internal/dao/internal/sys_provinces.go mode change 100644 => 100755 server/internal/dao/internal/sys_serve_license.go mode change 100644 => 100755 server/internal/dao/internal/sys_serve_log.go mode change 100644 => 100755 server/internal/dao/internal/sys_sms_log.go mode change 100644 => 100755 server/internal/dao/internal/test_category.go mode change 100644 => 100755 server/internal/dao/pay_log.go mode change 100644 => 100755 server/internal/dao/pay_refund.go mode change 100644 => 100755 server/internal/dao/sys_addons_config.go mode change 100644 => 100755 server/internal/dao/sys_attachment.go mode change 100644 => 100755 server/internal/dao/sys_blacklist.go mode change 100644 => 100755 server/internal/dao/sys_config.go mode change 100644 => 100755 server/internal/dao/sys_cron.go mode change 100644 => 100755 server/internal/dao/sys_cron_group.go mode change 100644 => 100755 server/internal/dao/sys_dict_data.go mode change 100644 => 100755 server/internal/dao/sys_dict_type.go mode change 100644 => 100755 server/internal/dao/sys_ems_log.go mode change 100644 => 100755 server/internal/dao/sys_gen_codes.go mode change 100644 => 100755 server/internal/dao/sys_gen_curd_demo.go mode change 100644 => 100755 server/internal/dao/sys_gen_tree_demo.go mode change 100644 => 100755 server/internal/dao/sys_log.go mode change 100644 => 100755 server/internal/dao/sys_login_log.go mode change 100644 => 100755 server/internal/dao/sys_provinces.go mode change 100644 => 100755 server/internal/dao/sys_serve_license.go mode change 100644 => 100755 server/internal/dao/sys_serve_log.go mode change 100644 => 100755 server/internal/dao/sys_sms_log.go mode change 100644 => 100755 server/internal/dao/test_category.go create mode 100644 server/internal/library/hggen/internal/cmd/cmd_doc.go create mode 100644 server/internal/library/hggen/internal/cmd/genctrl/genctrl_ast_parse.go create mode 100644 server/internal/library/hggen/internal/cmd/genctrl/genctrl_ast_parse_clear.go create mode 100644 server/internal/library/hggen/internal/cmd/genservice/genservice_ast_parse.go create mode 100644 server/internal/library/hggen/internal/cmd/genservice/genservice_ast_utils.go create mode 100644 server/internal/library/hggen/internal/cmd/genservice/genservice_generate_template.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/build/multiple/multiple.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/build/single/main.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/build/varmap/go.mod create mode 100644 server/internal/library/hggen/internal/cmd/testdata/build/varmap/go.sum create mode 100644 server/internal/library/hggen/internal/cmd/testdata/build/varmap/main.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/fix/fix25_content.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/dict_add_new_ctrl_expect.gotest create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/dict_expect.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/v1/dict_type.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_new.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_v1_dict_type.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_v1_test_new.gotest create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/dict_add_new_ctrl_expect.gotest create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/dict_expect.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/v1/dict_type.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_new.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_v1_dict_type.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_v1_test_new.gotest create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/article_expect.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1/edit.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1/get.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v2/edit.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_new.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_create.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_get_list.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_get_one.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_update.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v2_create.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v2_update.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/dao/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/model/do/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/model/entity/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/model/do/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/model/entity/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/model/do/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/model/entity/table_user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/go.mod.txt create mode 100644 server/internal/library/hggen/internal/cmd/testdata/gendao/user.tpl.sql create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated/table_user.proto create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated/table_user_snake_screaming.proto create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genpbentity/user.tpl.sql create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genservice/logic/article/article.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genservice/logic/article/article_extra.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genservice/logic/delivery/delivery_app.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genservice/logic/delivery/delivery_cluster.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genservice/logic/logic_expect.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genservice/logic/user/user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genservice/service/article.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genservice/service/delivery.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/genservice/service/user.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/config.yaml create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/internal/user_3.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/internal/user_4.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/user_3.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/user_4.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/do/user_3.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/do/user_4.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/entity/user_3.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/entity/user_4.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/sql1.sql create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2572/sql2.sql create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/config.yaml create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_1.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_2.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_3.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_4.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_1.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_2.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_3.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_4.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/do/user_3.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/do/user_4.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/entity/user_3.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/entity/user_4.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/sql1.sql create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2616/sql2.sql create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2746/issue_2746.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/2746/sql.sql create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/3459/config.yaml create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/hello.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v1/req.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v2/req.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_new.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_v1_req.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_v2_req.go create mode 100644 server/internal/library/hggen/internal/cmd/testdata/issue/3545/table_user.proto create mode 100644 server/internal/library/hggen/internal/packed/template-mono-app.go mode change 100644 => 100755 server/internal/model/do/addon_hgexample_table.go mode change 100644 => 100755 server/internal/model/do/addon_hgexample_tenant_order.go mode change 100644 => 100755 server/internal/model/do/admin_cash.go mode change 100644 => 100755 server/internal/model/do/admin_credits_log.go mode change 100644 => 100755 server/internal/model/do/admin_dept.go mode change 100644 => 100755 server/internal/model/do/admin_member.go mode change 100644 => 100755 server/internal/model/do/admin_member_post.go mode change 100644 => 100755 server/internal/model/do/admin_member_role.go mode change 100644 => 100755 server/internal/model/do/admin_menu.go mode change 100644 => 100755 server/internal/model/do/admin_notice.go mode change 100644 => 100755 server/internal/model/do/admin_notice_read.go mode change 100644 => 100755 server/internal/model/do/admin_oauth.go mode change 100644 => 100755 server/internal/model/do/admin_order.go mode change 100644 => 100755 server/internal/model/do/admin_post.go mode change 100644 => 100755 server/internal/model/do/admin_role.go mode change 100644 => 100755 server/internal/model/do/admin_role_casbin.go mode change 100644 => 100755 server/internal/model/do/admin_role_menu.go mode change 100644 => 100755 server/internal/model/do/pay_log.go mode change 100644 => 100755 server/internal/model/do/pay_refund.go mode change 100644 => 100755 server/internal/model/do/sys_addons_config.go mode change 100644 => 100755 server/internal/model/do/sys_attachment.go mode change 100644 => 100755 server/internal/model/do/sys_blacklist.go mode change 100644 => 100755 server/internal/model/do/sys_config.go mode change 100644 => 100755 server/internal/model/do/sys_cron.go mode change 100644 => 100755 server/internal/model/do/sys_cron_group.go mode change 100644 => 100755 server/internal/model/do/sys_dict_data.go mode change 100644 => 100755 server/internal/model/do/sys_dict_type.go mode change 100644 => 100755 server/internal/model/do/sys_ems_log.go mode change 100644 => 100755 server/internal/model/do/sys_gen_codes.go mode change 100644 => 100755 server/internal/model/do/sys_gen_curd_demo.go mode change 100644 => 100755 server/internal/model/do/sys_gen_tree_demo.go mode change 100644 => 100755 server/internal/model/do/sys_log.go mode change 100644 => 100755 server/internal/model/do/sys_login_log.go mode change 100644 => 100755 server/internal/model/do/sys_provinces.go mode change 100644 => 100755 server/internal/model/do/sys_serve_license.go mode change 100644 => 100755 server/internal/model/do/sys_serve_log.go mode change 100644 => 100755 server/internal/model/do/sys_sms_log.go mode change 100644 => 100755 server/internal/model/do/test_category.go mode change 100644 => 100755 server/internal/model/entity/addon_hgexample_table.go mode change 100644 => 100755 server/internal/model/entity/addon_hgexample_tenant_order.go mode change 100644 => 100755 server/internal/model/entity/admin_cash.go mode change 100644 => 100755 server/internal/model/entity/admin_credits_log.go mode change 100644 => 100755 server/internal/model/entity/admin_dept.go mode change 100644 => 100755 server/internal/model/entity/admin_member.go mode change 100644 => 100755 server/internal/model/entity/admin_member_post.go mode change 100644 => 100755 server/internal/model/entity/admin_member_role.go mode change 100644 => 100755 server/internal/model/entity/admin_menu.go mode change 100644 => 100755 server/internal/model/entity/admin_notice.go mode change 100644 => 100755 server/internal/model/entity/admin_notice_read.go mode change 100644 => 100755 server/internal/model/entity/admin_oauth.go mode change 100644 => 100755 server/internal/model/entity/admin_order.go mode change 100644 => 100755 server/internal/model/entity/admin_post.go mode change 100644 => 100755 server/internal/model/entity/admin_role.go mode change 100644 => 100755 server/internal/model/entity/admin_role_casbin.go mode change 100644 => 100755 server/internal/model/entity/admin_role_menu.go mode change 100644 => 100755 server/internal/model/entity/pay_log.go mode change 100644 => 100755 server/internal/model/entity/pay_refund.go mode change 100644 => 100755 server/internal/model/entity/sys_addons_config.go mode change 100644 => 100755 server/internal/model/entity/sys_attachment.go mode change 100644 => 100755 server/internal/model/entity/sys_blacklist.go mode change 100644 => 100755 server/internal/model/entity/sys_config.go mode change 100644 => 100755 server/internal/model/entity/sys_cron.go mode change 100644 => 100755 server/internal/model/entity/sys_cron_group.go mode change 100644 => 100755 server/internal/model/entity/sys_dict_data.go mode change 100644 => 100755 server/internal/model/entity/sys_dict_type.go mode change 100644 => 100755 server/internal/model/entity/sys_ems_log.go mode change 100644 => 100755 server/internal/model/entity/sys_gen_codes.go mode change 100644 => 100755 server/internal/model/entity/sys_gen_curd_demo.go mode change 100644 => 100755 server/internal/model/entity/sys_gen_tree_demo.go mode change 100644 => 100755 server/internal/model/entity/sys_log.go mode change 100644 => 100755 server/internal/model/entity/sys_login_log.go mode change 100644 => 100755 server/internal/model/entity/sys_provinces.go mode change 100644 => 100755 server/internal/model/entity/sys_serve_license.go mode change 100644 => 100755 server/internal/model/entity/sys_serve_log.go mode change 100644 => 100755 server/internal/model/entity/sys_sms_log.go mode change 100644 => 100755 server/internal/model/entity/test_category.go create mode 100644 web/src/enums/localDictEnum.ts create mode 100644 web/src/store/modules/dict.ts delete mode 100644 web/src/views/curdDemo/view.vue delete mode 100644 web/src/views/normalTreeDemo/view.vue delete mode 100644 web/src/views/optionTreeDemo/view.vue create mode 100644 web/src/views/system/dict/model.ts diff --git a/docs/guide-zh-CN/start-update-log.md b/docs/guide-zh-CN/start-update-log.md index a307e3e..6235ca9 100644 --- a/docs/guide-zh-CN/start-update-log.md +++ b/docs/guide-zh-CN/start-update-log.md @@ -11,6 +11,17 @@ > 如果升级(覆盖)代码后打开会出现 sql 报错, 请检查更新的数据库格式或自行调整 +### v2.15.7 +updated 2024.7.21 + +- 增加:访问日志、服务日志增加关键词搜索 +- 增加:web端增加字典状态管理,重构字典选项使用方式,大幅减少冗余代码 +- 修复:修复生成代码选项式树表已知的一些小bug +- 优化:gf版本升级到v2.7.2 +- 优化:naive-ui版本升级到2.39.0 +- 优化:访问日志不再记录过大的请求头参数,减少日志大小 + + ### v2.15.1 updated 2024.4.22 diff --git a/server/Makefile b/server/Makefile index 5765cb1..ad00cc0 100644 --- a/server/Makefile +++ b/server/Makefile @@ -10,6 +10,7 @@ build: @rm -rf ./$(ADMIN_RESOURCE_PATH) @mkdir ./$(ADMIN_RESOURCE_PATH) @cd ../web && yarn build && \cp -rf ./dist/* ../server$(ADMIN_RESOURCE_PATH) + @cd ../server @echo "y" | gf build # 通过热编译启动所有服务 diff --git a/server/api/admin/attachment/attachment.go b/server/api/admin/attachment/attachment.go index cc9277e..df58a31 100644 --- a/server/api/admin/attachment/attachment.go +++ b/server/api/admin/attachment/attachment.go @@ -47,21 +47,3 @@ type ClearKindReq struct { } type ClearKindRes struct{} - -// ChooserOptionReq 获取选择器选项 -type ChooserOptionReq struct { - g.Meta `path:"/attachment/chooserOption" method:"get" tags:"附件" summary:"获取选择器选项"` -} - -type ChooserOptionRes struct { - Drive sysin.DataSelectModel `json:"drive" dc:"驱动"` - Kind []KindSelect `json:"kind" dc:"上传类型"` -} - -type KindSelect struct { - Key string `json:"key"` - Value string `json:"value"` - Tag string `json:"listClass"` - Label string `json:"label"` - Icon string `json:"icon"` -} diff --git a/server/api/admin/curddemo/curddemo.go b/server/api/admin/curddemo/curddemo.go index 5d7423b..733a5e5 100644 --- a/server/api/admin/curddemo/curddemo.go +++ b/server/api/admin/curddemo/curddemo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package curddemo import ( @@ -68,10 +68,18 @@ type MaxSortRes struct { *sysin.CurdDemoMaxSortModel } +// StatusReq 更新CURD列表状态 +type StatusReq struct { + g.Meta `path:"/curdDemo/status" method:"post" tags:"CURD列表" summary:"更新CURD列表状态"` + sysin.CurdDemoStatusInp +} + +type StatusRes struct{} + // SwitchReq 更新CURD列表开关状态 type SwitchReq struct { g.Meta `path:"/curdDemo/switch" method:"post" tags:"CURD列表" summary:"更新CURD列表状态"` sysin.CurdDemoSwitchInp } -type SwitchRes struct{} +type SwitchRes struct{} \ No newline at end of file diff --git a/server/api/admin/monitor/monitor.go b/server/api/admin/monitor/monitor.go index 63501e1..d86a812 100644 --- a/server/api/admin/monitor/monitor.go +++ b/server/api/admin/monitor/monitor.go @@ -87,8 +87,7 @@ type NetOptionReq struct { } type NetOptionRes struct { - LicenseGroup form.Selects `json:"licenseGroup" dc:"授权分组"` - Routes []*RouteSelect `json:"routes" dc:"路由选项"` + Routes []*RouteSelect `json:"routes" dc:"路由选项"` } type RouteSelect struct { diff --git a/server/api/admin/normaltreedemo/normaltreedemo.go b/server/api/admin/normaltreedemo/normaltreedemo.go index 37dc525..e6543df 100644 --- a/server/api/admin/normaltreedemo/normaltreedemo.go +++ b/server/api/admin/normaltreedemo/normaltreedemo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package normaltreedemo import ( diff --git a/server/api/admin/optiontreedemo/optiontreedemo.go b/server/api/admin/optiontreedemo/optiontreedemo.go index 0caf3cb..34d2e0a 100644 --- a/server/api/admin/optiontreedemo/optiontreedemo.go +++ b/server/api/admin/optiontreedemo/optiontreedemo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package optiontreedemo import ( diff --git a/server/api/admin/testcategory/testcategory.go b/server/api/admin/testcategory/testcategory.go index e4b9dbc..75bf06b 100644 --- a/server/api/admin/testcategory/testcategory.go +++ b/server/api/admin/testcategory/testcategory.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package testcategory import ( diff --git a/server/go.mod b/server/go.mod index f2c9f78..e5deb26 100644 --- a/server/go.mod +++ b/server/go.mod @@ -6,22 +6,22 @@ toolchain go1.22.1 require ( github.com/Shopify/sarama v1.34.1 - github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.2 + github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.8 github.com/alibabacloud-go/dysmsapi-20170525/v3 v3.0.5 - github.com/alibabacloud-go/tea v1.1.20 - github.com/alibabacloud-go/tea-utils/v2 v2.0.1 + github.com/alibabacloud-go/tea v1.2.1 + github.com/alibabacloud-go/tea-utils/v2 v2.0.5 github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible github.com/apache/rocketmq-client-go/v2 v2.1.2 github.com/casbin/casbin/v2 v2.55.0 github.com/forgoer/openssl v1.4.0 github.com/go-pay/gopay v1.5.91 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.7.0 - github.com/gogf/gf/contrib/nosql/redis/v2 v2.7.0 - github.com/gogf/gf/contrib/trace/jaeger/v2 v2.7.0 - github.com/gogf/gf/v2 v2.7.0 + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.7.2 + github.com/gogf/gf/contrib/nosql/redis/v2 v2.7.2 + github.com/gogf/gf/contrib/trace/jaeger/v2 v2.7.2 + github.com/gogf/gf/v2 v2.7.2 github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f - github.com/golang-jwt/jwt/v5 v5.0.0 - github.com/gorilla/websocket v1.5.1 + github.com/golang-jwt/jwt/v5 v5.2.0 + github.com/gorilla/websocket v1.5.3 github.com/kayon/iploc v0.0.0-20200312105652-bda3e968a794 github.com/minio/minio-go/v7 v7.0.63 github.com/mojocn/base64Captcha v1.3.6 @@ -34,25 +34,25 @@ require ( github.com/tencentyun/cos-go-sdk-v5 v0.7.45 github.com/ufilesdk-dev/ufile-gosdk v1.0.3 github.com/xuri/excelize/v2 v2.6.0 - go.opentelemetry.io/otel v1.25.0 - golang.org/x/mod v0.9.0 - golang.org/x/net v0.24.0 - golang.org/x/tools v0.7.0 + go.opentelemetry.io/otel v1.28.0 + golang.org/x/mod v0.17.0 + golang.org/x/net v0.27.0 + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d gopkg.in/yaml.v3 v3.0.1 ) require ( aead.dev/minisign v0.2.0 // indirect filippo.io/edwards25519 v1.1.0 // indirect - github.com/BurntSushi/toml v1.3.2 // indirect + github.com/BurntSushi/toml v1.4.0 // indirect github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 // indirect github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect github.com/alibabacloud-go/openapi-util v0.1.0 // indirect github.com/alibabacloud-go/tea-utils v1.3.1 // indirect - github.com/alibabacloud-go/tea-xml v1.1.2 // indirect - github.com/aliyun/credentials-go v1.1.2 // indirect + github.com/alibabacloud-go/tea-xml v1.1.3 // indirect + github.com/aliyun/credentials-go v1.3.1 // indirect github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj v1.8.4 // indirect @@ -63,11 +63,11 @@ require ( github.com/eapache/go-resiliency v1.2.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect github.com/eapache/queue v1.1.0 // indirect - github.com/emirpasic/gods v1.12.0 // indirect - github.com/fatih/color v1.16.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/fatih/color v1.17.0 // indirect github.com/fatih/structs v1.1.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-redis/redis/v8 v8.11.5 // indirect @@ -77,15 +77,15 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/go-querystring v1.0.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-uuid v1.0.2 // indirect + github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect - github.com/jcmturner/gofork v1.0.0 // indirect - github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect + github.com/jcmturner/gofork v1.7.6 // indirect + github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect github.com/jcmturner/rpc/v2 v2.0.3 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.2 // indirect @@ -107,7 +107,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/redis/go-redis/v9 v9.5.1 // indirect + github.com/redis/go-redis/v9 v9.6.0 // indirect github.com/richardlehane/mscfb v1.0.4 // indirect github.com/richardlehane/msoleps v1.0.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect @@ -125,15 +125,15 @@ require ( github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect - go.opentelemetry.io/otel/metric v1.25.0 // indirect - go.opentelemetry.io/otel/sdk v1.25.0 // indirect - go.opentelemetry.io/otel/trace v1.25.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/sdk v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect go.uber.org/atomic v1.7.0 // indirect - golang.org/x/crypto v0.22.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/image v0.13.0 // indirect - golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect diff --git a/server/go.sum b/server/go.sum index 3547699..9d7c087 100644 --- a/server/go.sum +++ b/server/go.sum @@ -37,8 +37,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= @@ -54,8 +54,9 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 h1:iC9YFYKDGEy3n/FtqJnOkZsene9olVspKmkX5A2YBEo= github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4/go.mod h1:sCavSAvdzOjul4cEqeVtvlSaSScfNsTQ+46HwlTL1hc= -github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.2 h1:2kR1YkvQloHUstmPcG0Sjk24zTKbza7izzJfJNwBFSs= github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.2/go.mod h1:5JHVmnHvGzR2wNdgaW1zDLQG8kOC4Uec8ubkMogW7OQ= +github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.8 h1:benoD0QHDrylMzEQVpX/6uKtrN8LohT66ZlKXVJh7pM= +github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.8/go.mod h1:CzQnh+94WDnJOnKZH5YRyouL+OOcdBnXY5VWAf0McgI= github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 h1:NqugFkGxx1TXSh/pBcU00Y6bljgDPaFdh5MUSeJ7e50= github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY= github.com/alibabacloud-go/dysmsapi-20170525/v3 v3.0.5 h1:/c+eQK0o7Lf8EIZ0ovB0cU+L82rVu1r3v91icUYnsdM= @@ -70,19 +71,22 @@ github.com/alibabacloud-go/tea v1.1.7/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeG github.com/alibabacloud-go/tea v1.1.8/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4= github.com/alibabacloud-go/tea v1.1.17/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A= github.com/alibabacloud-go/tea v1.1.19/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A= -github.com/alibabacloud-go/tea v1.1.20 h1:wFK4xEbvGYMtzTyHhIju9D7ecWxvSUdoLO6y4vDLFik= -github.com/alibabacloud-go/tea v1.1.20/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A= +github.com/alibabacloud-go/tea v1.2.1 h1:rFF1LnrAdhaiPmKwH5xwYOKlMh66CqRwPUTzIK74ask= +github.com/alibabacloud-go/tea v1.2.1/go.mod h1:qbzof29bM/IFhLMtJPrgTGK3eauV5J2wSyEUo4OEmnA= github.com/alibabacloud-go/tea-utils v1.3.1 h1:iWQeRzRheqCMuiF3+XkfybB3kTgUXkXX+JMrqfLeB2I= github.com/alibabacloud-go/tea-utils v1.3.1/go.mod h1:EI/o33aBfj3hETm4RLiAxF/ThQdSngxrpF8rKUDJjPE= github.com/alibabacloud-go/tea-utils/v2 v2.0.0/go.mod h1:U5MTY10WwlquGPS34DOeomUGBB0gXbLueiq5Trwu0C4= -github.com/alibabacloud-go/tea-utils/v2 v2.0.1 h1:K6kwgo+UiYx+/kr6CO0PN5ACZDzE3nnn9d77215AkTs= github.com/alibabacloud-go/tea-utils/v2 v2.0.1/go.mod h1:U5MTY10WwlquGPS34DOeomUGBB0gXbLueiq5Trwu0C4= -github.com/alibabacloud-go/tea-xml v1.1.2 h1:oLxa7JUXm2EDFzMg+7oRsYc+kutgCVwm+bZlhhmvW5M= +github.com/alibabacloud-go/tea-utils/v2 v2.0.5 h1:EUakYEUAwr6L3wLT0vejIw2rc0IA1RSXDwLnIb3f2vU= +github.com/alibabacloud-go/tea-utils/v2 v2.0.5/go.mod h1:dL6vbUT35E4F4bFTHL845eUloqaerYBYPsdWR2/jhe4= github.com/alibabacloud-go/tea-xml v1.1.2/go.mod h1:Rq08vgCcCAjHyRi/M7xlHKUykZCEtyBy9+DPF6GgEu8= +github.com/alibabacloud-go/tea-xml v1.1.3 h1:7LYnm+JbOq2B+T/B0fHC4Ies4/FofC4zHzYtqw7dgt0= +github.com/alibabacloud-go/tea-xml v1.1.3/go.mod h1:Rq08vgCcCAjHyRi/M7xlHKUykZCEtyBy9+DPF6GgEu8= github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible h1:KXeJoM1wo9I/6xPTyt6qCxoSZnmASiAjlrr0dyTUKt8= github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= -github.com/aliyun/credentials-go v1.1.2 h1:qU1vwGIBb3UJ8BwunHDRFtAhS6jnQLnde/yk0+Ih2GY= github.com/aliyun/credentials-go v1.1.2/go.mod h1:ozcZaMR5kLM7pwtCMEpVmQ242suV6qTJya2bDq4X1Tw= +github.com/aliyun/credentials-go v1.3.1 h1:uq/0v7kWrxmoLGpqjx7vtQ/s03f0zR//0br/xWDTE28= +github.com/aliyun/credentials-go v1.3.1/go.mod h1:8jKYhQuDawt8x2+fusqa1Y6mPxemTsBEN04dgcAcYz0= github.com/apache/rocketmq-client-go/v2 v2.1.2 h1:yt73olKe5N6894Dbm+ojRf/JPiP0cxfDNNffKwhpJVg= github.com/apache/rocketmq-client-go/v2 v2.1.2/go.mod h1:6I6vgxHR3hzrvn+6n/4mrhS+UTulzK/X9LB2Vk1U5gE= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -127,14 +131,15 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8 github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= -github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/forgoer/openssl v1.4.0 h1:rPMnQ92OKuBsKnfY/GmUDunnP72Cy+zviAompWMdC9U= @@ -155,8 +160,8 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= @@ -175,19 +180,19 @@ github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpv github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gogf/gf/contrib/drivers/mysql/v2 v2.7.0 h1:5Igvtz4gy5UMvH+Ut4kLIpwSzggV9ZgDVBsIiOctH5E= -github.com/gogf/gf/contrib/drivers/mysql/v2 v2.7.0/go.mod h1:0+flZ0clMKjtH1sTI7YD2KG4FPr8xz0L9h1WMd5M2Z8= -github.com/gogf/gf/contrib/nosql/redis/v2 v2.7.0 h1:hJxshC0gZyFZaGo2HItXd5XMzIMbCRcgShr1ljMYwUc= -github.com/gogf/gf/contrib/nosql/redis/v2 v2.7.0/go.mod h1:is3Q3ItZSPMZ1RBJ3xIcEasyGZnOg8eNeG9dubOx/zc= -github.com/gogf/gf/contrib/trace/jaeger/v2 v2.7.0 h1:P75Jfq5rP8TUUTyobAooULJDDCaSOkgL14gnXudgY1E= -github.com/gogf/gf/contrib/trace/jaeger/v2 v2.7.0/go.mod h1:hRnwcGAFG8c6+9rg//zbr0Ve3XZVzAuALfzfbz3xBBk= -github.com/gogf/gf/v2 v2.7.0 h1:CjxhbMiE7oqf6K8ZtGuKt3dQEwK4vL6LhiI+dI7tJGU= -github.com/gogf/gf/v2 v2.7.0/go.mod h1:Qu8nimKt9aupJQcdUL85tWF4Mfxocz97zUt8UC4abVI= +github.com/gogf/gf/contrib/drivers/mysql/v2 v2.7.2 h1:GpE2JuHVoNJD4lNP1omC1+TKXNCSvXr5oil1bNULYd0= +github.com/gogf/gf/contrib/drivers/mysql/v2 v2.7.2/go.mod h1:0h3UmNAmA8hnjvTyozZelSWWxiAjGDQttzZqMhkCkJo= +github.com/gogf/gf/contrib/nosql/redis/v2 v2.7.2 h1:V1hdGnyjU9kT0I3DDDFDl6Ll8yC6aAIFJa/lMQwB8V4= +github.com/gogf/gf/contrib/nosql/redis/v2 v2.7.2/go.mod h1:XzkPv3G8TdKczqoB/ydR3bxvBRdQLQNCOCEgxso/c3o= +github.com/gogf/gf/contrib/trace/jaeger/v2 v2.7.2 h1:YKMJMhJJjbaPhgjpH9veZpn80mwkPgPAIatSvUFTt38= +github.com/gogf/gf/contrib/trace/jaeger/v2 v2.7.2/go.mod h1:kzxWAaY5Livk2SNPNrs9PJJvxK8A7uVwd8UGwjdMEfU= +github.com/gogf/gf/v2 v2.7.2 h1:uZDfyblasI12lZUtFd1mfxsIr8b14cd/F88DJUTCSDM= +github.com/gogf/gf/v2 v2.7.2/go.mod h1:EBXneAg/wes86rfeh68XC0a2JBNQylmT7Sp6/8Axk88= github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f h1:7xfXR/BhG3JDqO1s45n65Oyx9t4E/UqDOXep6jXdLCM= github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f/go.mod h1:HnYoio6S7VaFJdryKcD/r9HgX+4QzYfr00XiXUo/xz0= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= -github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -253,8 +258,9 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -263,8 +269,8 @@ github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORR github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= @@ -273,8 +279,9 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -284,12 +291,14 @@ github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFK github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= -github.com/jcmturner/gofork v1.0.0 h1:J7uCkflzTEhUZ64xqKnkDxq3kzc96ajM1Gli5ktUem8= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= +github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg= +github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo= github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o= github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg= -github.com/jcmturner/gokrb5/v8 v8.4.2 h1:6ZIM6b/JJN0X8UM43ZOM6Z4SJzla+a/u7scXFJzodkA= github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc= +github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8= +github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs= github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY= github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= @@ -417,8 +426,8 @@ github.com/qiniu/go-sdk/v7 v7.14.0/go.mod h1:btsaOc8CA3hdVloULfFdDgDc+g4f3TDZEFs github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= -github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/redis/go-redis/v9 v9.6.0 h1:NLck+Rab3AOTHw21CGRpvQpgTrAU4sgdCswqGtlhGRA= +github.com/redis/go-redis/v9 v9.6.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM= github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o= @@ -471,6 +480,7 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -521,16 +531,16 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k= -go.opentelemetry.io/otel v1.25.0/go.mod h1:Wa2ds5NOXEMkCmUou1WA7ZBfLTHWIsp034OVD7AO+Vg= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4= go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI= -go.opentelemetry.io/otel/metric v1.25.0 h1:LUKbS7ArpFL/I2jJHdJcqMGxkRdxpPHE0VU/D4NuEwA= -go.opentelemetry.io/otel/metric v1.25.0/go.mod h1:rkDLUSd2lC5lq2dFNrX9LGAbINP5B7WBkC78RXCpH5s= -go.opentelemetry.io/otel/sdk v1.25.0 h1:PDryEJPC8YJZQSyLY5eqLeafHtG+X7FWnf3aXMtxbqo= -go.opentelemetry.io/otel/sdk v1.25.0/go.mod h1:oFgzCM2zdsxKzz6zwpTZYLLQsFwc+K0daArPdIhuxkw= -go.opentelemetry.io/otel/trace v1.25.0 h1:tqukZGLwQYRIFtSQM2u2+yfMVTgGVeqRLPUYx1Dq6RM= -go.opentelemetry.io/otel/trace v1.25.0/go.mod h1:hCCs70XM/ljO+BeQkyFnbK28SBIJ/Emuha+ccrCRT7I= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= go.uber.org/atomic v1.5.1/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -549,8 +559,11 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220408190544-5352b0902921/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -587,8 +600,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= -golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -629,8 +642,12 @@ golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -649,8 +666,9 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -711,12 +729,18 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -725,9 +749,11 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= @@ -779,8 +805,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/server/internal/consts/ems.go b/server/internal/consts/ems.go index cf109e2..5191153 100644 --- a/server/internal/consts/ems.go +++ b/server/internal/consts/ems.go @@ -18,12 +18,6 @@ const ( EmsTemplateCash = "cash" // 申请提现 ) -// 验证码状态 -const ( - EmsStatusNotUsed = 1 // 未使用 - EmsStatusUsed = 2 // 已使用 -) - var EmsSubjectMap = g.MapStrStr{ EmsTemplateText: "这是一封来自HotGo的邮件", EmsTemplateCode: "验证码", diff --git a/server/internal/consts/servelicense.go b/server/internal/consts/servelicense.go index c3f2791..96e9dc8 100644 --- a/server/internal/consts/servelicense.go +++ b/server/internal/consts/servelicense.go @@ -5,6 +5,15 @@ // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package consts +import ( + "hotgo/internal/library/dict" + "hotgo/internal/model" +) + +func init() { + dict.RegisterEnums("ServerLicenseGroupOptions", "服务授权分组选项", ServerLicenseGroupOptions) +} + // 授权分组 const ( LicenseGroupDefault = "default" // 默认组 @@ -12,8 +21,9 @@ const ( LicenseGroupAuth = "auth" // 服务授权 ) -var LicenseGroupNameMap = map[string]string{ - LicenseGroupDefault: "默认组", - LicenseGroupCron: "定时任务", - LicenseGroupAuth: "服务授权", +// ServerLicenseGroupOptions 服务授权分组选项 +var ServerLicenseGroupOptions = []*model.Option{ + dict.GenWarningOption(LicenseGroupDefault, "默认组"), + dict.GenSuccessOption(LicenseGroupCron, "定时任务"), + dict.GenSuccessOption(LicenseGroupAuth, "服务授权"), } diff --git a/server/internal/consts/sms.go b/server/internal/consts/sms.go index d76a063..2836e24 100644 --- a/server/internal/consts/sms.go +++ b/server/internal/consts/sms.go @@ -6,7 +6,6 @@ package consts // 短信驱动 - const ( SmsDriveAliYun = "aliyun" // 阿里云 SmsDriveTencent = "tencent" // 腾讯云 @@ -32,9 +31,3 @@ var ( SmsTemplateCash: "申请提现", } ) - -// 验证码状态 -const ( - SmsStatusNotUsed = 1 // 未使用 - SmsStatusUsed = 2 // 已使用 -) diff --git a/server/internal/consts/status.go b/server/internal/consts/status.go index 274fe9d..eb379f9 100644 --- a/server/internal/consts/status.go +++ b/server/internal/consts/status.go @@ -5,6 +5,16 @@ // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package consts +import ( + "hotgo/internal/library/dict" + "hotgo/internal/model" +) + +func init() { + dict.RegisterEnums("CodeStatusOptions", "验证码状态选项", CodeStatusOptions) + dict.RegisterEnums("BlacklistStatusOptions", "黑名单拉黑状态选项", BlacklistStatusOptions) +} + // 状态码 const ( StatusALL int = -1 // 全部状态 @@ -14,3 +24,26 @@ const ( ) var StatusSlice = []int{StatusALL, StatusEnabled, StatusDisable, StatusDelete} + +// 验证码状态 +const ( + CodeStatusNotUsed = 1 // 未使用 + CodeStatusUsed = 2 // 已使用 +) + +// CodeStatusOptions 验证码状态选项 +var CodeStatusOptions = []*model.Option{ + dict.GenWarningOption(CodeStatusNotUsed, "未使用"), + dict.GenSuccessOption(CodeStatusUsed, "已使用"), +} + +const ( + BlacklistStatusDisable = 1 // 封禁中 + BlacklistStatusEnabled = 2 // 已解封 +) + +// BlacklistStatusOptions 黑名单拉黑状态选项 +var BlacklistStatusOptions = []*model.Option{ + dict.GenWarningOption(BlacklistStatusDisable, "封禁中"), + dict.GenSuccessOption(BlacklistStatusEnabled, "已解封"), +} diff --git a/server/internal/consts/version.go b/server/internal/consts/version.go index ed5c34e..d0ed678 100644 --- a/server/internal/consts/version.go +++ b/server/internal/consts/version.go @@ -7,5 +7,5 @@ package consts // VersionApp HotGo版本 const ( - VersionApp = "2.15.1" + VersionApp = "2.15.7" ) diff --git a/server/internal/controller/admin/admin/monitor.go b/server/internal/controller/admin/admin/monitor.go index ea8657a..2a8a936 100644 --- a/server/internal/controller/admin/admin/monitor.go +++ b/server/internal/controller/admin/admin/monitor.go @@ -204,16 +204,6 @@ func (c *cMonitor) NetOnlineList(ctx context.Context, req *monitor.NetOnlineList func (c *cMonitor) NetOption(ctx context.Context, req *monitor.NetOptionReq) (res *monitor.NetOptionRes, err error) { res = new(monitor.NetOptionRes) - // 授权分组 - for k, v := range consts.LicenseGroupNameMap { - res.LicenseGroup = append(res.LicenseGroup, &form.Select{ - Value: k, - Name: v, - Label: v, - }) - } - sort.Sort(res.LicenseGroup) - for _, v := range service.TCPServer().Instance().GetRoutes() { // 无需勾选的路由 disabled := false diff --git a/server/internal/controller/admin/sys/attachment.go b/server/internal/controller/admin/sys/attachment.go index 0236466..9380887 100644 --- a/server/internal/controller/admin/sys/attachment.go +++ b/server/internal/controller/admin/sys/attachment.go @@ -8,8 +8,6 @@ package sys import ( "context" "hotgo/api/admin/attachment" - "hotgo/internal/library/storager" - "hotgo/internal/model/input/sysin" "hotgo/internal/service" ) @@ -50,42 +48,6 @@ func (c *cAttachment) List(ctx context.Context, req *attachment.ListReq) (res *a return } -// ChooserOption 获取选择器选项 -func (c *cAttachment) ChooserOption(ctx context.Context, req *attachment.ChooserOptionReq) (res *attachment.ChooserOptionRes, err error) { - res = new(attachment.ChooserOptionRes) - - res.Drive, err = service.SysDictData().Select(ctx, &sysin.DataSelectInp{Type: "config_upload_drive"}) - if err != nil { - return - } - - var kinds = []attachment.KindSelect{ - { - Label: "全部", Key: "", Value: "", - }, - { - Label: "图片", Key: storager.KindImg, Value: storager.KindImg, Icon: "PictureOutlined", Tag: "success", - }, - { - Label: "文档", Key: storager.KindDoc, Value: storager.KindDoc, Icon: "FileWordOutlined", Tag: "primary", - }, - { - Label: "音频", Key: storager.KindAudio, Value: storager.KindAudio, Icon: "CustomerServiceOutlined", Tag: "info", - }, - { - Label: "视频", Key: storager.KindVideo, Value: storager.KindVideo, Icon: "PlaySquareOutlined", Tag: "warning", - }, - { - Label: "压缩包", Key: storager.KindZip, Value: storager.KindZip, Icon: "FileZipOutlined", Tag: "error", - }, - { - Label: "其他", Key: storager.KindOther, Value: storager.KindOther, Icon: "PlusOutlined", Tag: "default", - }, - } - res.Kind = append(res.Kind, kinds...) - return -} - // ClearKind 清空上传类型 func (c *cAttachment) ClearKind(ctx context.Context, req *attachment.ClearKindReq) (res *attachment.ClearKindRes, err error) { err = service.SysAttachment().ClearKind(ctx, &req.AttachmentClearKindInp) diff --git a/server/internal/controller/admin/sys/curd_demo.go b/server/internal/controller/admin/sys/curd_demo.go index 38b1b8b..416263a 100644 --- a/server/internal/controller/admin/sys/curd_demo.go +++ b/server/internal/controller/admin/sys/curd_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sys import ( @@ -78,8 +78,14 @@ func (c *cCurdDemo) Delete(ctx context.Context, req *curddemo.DeleteReq) (res *c return } +// Status 更新CURD列表状态 +func (c *cCurdDemo) Status(ctx context.Context, req *curddemo.StatusReq) (res *curddemo.StatusRes, err error) { + err = service.SysCurdDemo().Status(ctx, &req.CurdDemoStatusInp) + return +} + // Switch 更新CURD列表开关状态 func (c *cCurdDemo) Switch(ctx context.Context, req *curddemo.SwitchReq) (res *curddemo.SwitchRes, err error) { err = service.SysCurdDemo().Switch(ctx, &req.CurdDemoSwitchInp) return -} +} \ No newline at end of file diff --git a/server/internal/controller/admin/sys/normal_tree_demo.go b/server/internal/controller/admin/sys/normal_tree_demo.go index 0a91fb9..29841e3 100644 --- a/server/internal/controller/admin/sys/normal_tree_demo.go +++ b/server/internal/controller/admin/sys/normal_tree_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sys import ( diff --git a/server/internal/controller/admin/sys/option_tree_demo.go b/server/internal/controller/admin/sys/option_tree_demo.go index 00b003f..f0e94a6 100644 --- a/server/internal/controller/admin/sys/option_tree_demo.go +++ b/server/internal/controller/admin/sys/option_tree_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sys import ( diff --git a/server/internal/controller/admin/sys/test_category.go b/server/internal/controller/admin/sys/test_category.go index ac68ee1..d761e0f 100644 --- a/server/internal/controller/admin/sys/test_category.go +++ b/server/internal/controller/admin/sys/test_category.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sys import ( diff --git a/server/internal/dao/addon_hgexample_table.go b/server/internal/dao/addon_hgexample_table.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/addon_hgexample_tenant_order.go b/server/internal/dao/addon_hgexample_tenant_order.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_cash.go b/server/internal/dao/admin_cash.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_credits_log.go b/server/internal/dao/admin_credits_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_dept.go b/server/internal/dao/admin_dept.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_member.go b/server/internal/dao/admin_member.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_member_post.go b/server/internal/dao/admin_member_post.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_member_role.go b/server/internal/dao/admin_member_role.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_menu.go b/server/internal/dao/admin_menu.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_notice.go b/server/internal/dao/admin_notice.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_notice_read.go b/server/internal/dao/admin_notice_read.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_oauth.go b/server/internal/dao/admin_oauth.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_order.go b/server/internal/dao/admin_order.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_post.go b/server/internal/dao/admin_post.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_role.go b/server/internal/dao/admin_role.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_role_casbin.go b/server/internal/dao/admin_role_casbin.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/admin_role_menu.go b/server/internal/dao/admin_role_menu.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/addon_hgexample_table.go b/server/internal/dao/internal/addon_hgexample_table.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/addon_hgexample_tenant_order.go b/server/internal/dao/internal/addon_hgexample_tenant_order.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_cash.go b/server/internal/dao/internal/admin_cash.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_credits_log.go b/server/internal/dao/internal/admin_credits_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_dept.go b/server/internal/dao/internal/admin_dept.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_member.go b/server/internal/dao/internal/admin_member.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_member_post.go b/server/internal/dao/internal/admin_member_post.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_member_role.go b/server/internal/dao/internal/admin_member_role.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_menu.go b/server/internal/dao/internal/admin_menu.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_notice.go b/server/internal/dao/internal/admin_notice.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_notice_read.go b/server/internal/dao/internal/admin_notice_read.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_oauth.go b/server/internal/dao/internal/admin_oauth.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_order.go b/server/internal/dao/internal/admin_order.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_post.go b/server/internal/dao/internal/admin_post.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_role.go b/server/internal/dao/internal/admin_role.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_role_casbin.go b/server/internal/dao/internal/admin_role_casbin.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/admin_role_menu.go b/server/internal/dao/internal/admin_role_menu.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/pay_log.go b/server/internal/dao/internal/pay_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/pay_refund.go b/server/internal/dao/internal/pay_refund.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_addons_config.go b/server/internal/dao/internal/sys_addons_config.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_attachment.go b/server/internal/dao/internal/sys_attachment.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_blacklist.go b/server/internal/dao/internal/sys_blacklist.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_config.go b/server/internal/dao/internal/sys_config.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_cron.go b/server/internal/dao/internal/sys_cron.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_cron_group.go b/server/internal/dao/internal/sys_cron_group.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_dict_data.go b/server/internal/dao/internal/sys_dict_data.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_dict_type.go b/server/internal/dao/internal/sys_dict_type.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_ems_log.go b/server/internal/dao/internal/sys_ems_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_gen_codes.go b/server/internal/dao/internal/sys_gen_codes.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_gen_curd_demo.go b/server/internal/dao/internal/sys_gen_curd_demo.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_gen_tree_demo.go b/server/internal/dao/internal/sys_gen_tree_demo.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_log.go b/server/internal/dao/internal/sys_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_login_log.go b/server/internal/dao/internal/sys_login_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_provinces.go b/server/internal/dao/internal/sys_provinces.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_serve_license.go b/server/internal/dao/internal/sys_serve_license.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_serve_log.go b/server/internal/dao/internal/sys_serve_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/sys_sms_log.go b/server/internal/dao/internal/sys_sms_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/internal/test_category.go b/server/internal/dao/internal/test_category.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/pay_log.go b/server/internal/dao/pay_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/pay_refund.go b/server/internal/dao/pay_refund.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_addons_config.go b/server/internal/dao/sys_addons_config.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_attachment.go b/server/internal/dao/sys_attachment.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_blacklist.go b/server/internal/dao/sys_blacklist.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_config.go b/server/internal/dao/sys_config.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_cron.go b/server/internal/dao/sys_cron.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_cron_group.go b/server/internal/dao/sys_cron_group.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_dict_data.go b/server/internal/dao/sys_dict_data.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_dict_type.go b/server/internal/dao/sys_dict_type.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_ems_log.go b/server/internal/dao/sys_ems_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_gen_codes.go b/server/internal/dao/sys_gen_codes.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_gen_curd_demo.go b/server/internal/dao/sys_gen_curd_demo.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_gen_tree_demo.go b/server/internal/dao/sys_gen_tree_demo.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_log.go b/server/internal/dao/sys_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_login_log.go b/server/internal/dao/sys_login_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_provinces.go b/server/internal/dao/sys_provinces.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_serve_license.go b/server/internal/dao/sys_serve_license.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_serve_log.go b/server/internal/dao/sys_serve_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/sys_sms_log.go b/server/internal/dao/sys_sms_log.go old mode 100644 new mode 100755 diff --git a/server/internal/dao/test_category.go b/server/internal/dao/test_category.go old mode 100644 new mode 100755 diff --git a/server/internal/library/dict/dict_option.go b/server/internal/library/dict/dict_option.go index b52070b..d14bbe8 100644 --- a/server/internal/library/dict/dict_option.go +++ b/server/internal/library/dict/dict_option.go @@ -12,63 +12,111 @@ import ( ) // GenDefaultOption 生成默认表格回显样式 -func GenDefaultOption(key interface{}, label string) *model.Option { +func GenDefaultOption(key interface{}, label string, extra ...any) *model.Option { + e := interface{}(nil) + if len(extra) > 0 { + e = extra[0] + } return &model.Option{ Key: key, Label: label, Value: key, ListClass: "default", + Extra: e, } } -func GenSuccessOption(key interface{}, label string) *model.Option { +func GenSuccessOption(key interface{}, label string, extra ...any) *model.Option { + e := interface{}(nil) + if len(extra) > 0 { + e = extra[0] + } return &model.Option{ Key: key, Label: label, Value: key, ListClass: "success", + Extra: e, } } -func GenWarningOption(key interface{}, label string) *model.Option { +func GenWarningOption(key interface{}, label string, extra ...any) *model.Option { + e := interface{}(nil) + if len(extra) > 0 { + e = extra[0] + } return &model.Option{ Key: key, Label: label, Value: key, ListClass: "warning", + Extra: e, } } -func GenErrorOption(key interface{}, label string) *model.Option { +func GenErrorOption(key interface{}, label string, extra ...any) *model.Option { + e := interface{}(nil) + if len(extra) > 0 { + e = extra[0] + } return &model.Option{ Key: key, Label: label, Value: key, ListClass: "error", + Extra: e, } } -func GenInfoOption(key interface{}, label string) *model.Option { +func GenInfoOption(key interface{}, label string, extra ...any) *model.Option { + e := interface{}(nil) + if len(extra) > 0 { + e = extra[0] + } return &model.Option{ Key: key, Label: label, Value: key, ListClass: "info", + Extra: e, + } +} + +func GenPrimaryOption(key interface{}, label string, extra ...any) *model.Option { + e := interface{}(nil) + if len(extra) > 0 { + e = extra[0] + } + return &model.Option{ + Key: key, + Label: label, + Value: key, + ListClass: "primary", + Extra: e, } } // GenCustomOption 生成自定义表格回显样式 -func GenCustomOption(key interface{}, label string, custom string) *model.Option { +func GenCustomOption(key interface{}, label string, custom string, extra ...any) *model.Option { + e := interface{}(nil) + if len(extra) > 0 { + e = extra[0] + } return &model.Option{ Key: key, Label: label, Value: key, ListClass: custom, + Extra: e, } } // GenHashOption 根据不同label以hash算法生成表格回显样式 -func GenHashOption(key interface{}, label string) *model.Option { +func GenHashOption(key interface{}, label string, extra ...any) *model.Option { + e := interface{}(nil) + if len(extra) > 0 { + e = extra[0] + } strings := []string{"default", "primary", "info", "success", "warning", "error"} hash := fnv.New32() @@ -84,6 +132,7 @@ func GenHashOption(key interface{}, label string) *model.Option { Label: label, Value: key, ListClass: tag, + Extra: e, } } @@ -94,7 +143,7 @@ func GetOptionLabel(ses []*model.Option, key interface{}) string { return v.Label } } - return `Unknown` + return `` } // HasOptionKey 是否存在指定key diff --git a/server/internal/library/hggen/internal/cmd/cmd_doc.go b/server/internal/library/hggen/internal/cmd/cmd_doc.go new file mode 100644 index 0000000..9b0ba9d --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/cmd_doc.go @@ -0,0 +1,177 @@ +// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package cmd + +import ( + "context" + "io" + "net/http" + "os" + "path" + "path/filepath" + "time" + + "github.com/gogf/gf/v2/encoding/gcompress" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gfile" + "hotgo/internal/library/hggen/internal/utility/mlog" +) + +const ( + // DocURL is the download address of the document + DocURL = "https://github.com/gogf/gf/archive/refs/heads/gh-pages.zip" +) + +var ( + Doc = cDoc{} +) + +type cDoc struct { + g.Meta `name:"doc" brief:"download https://pages.goframe.org/ to run locally"` +} + +type cDocInput struct { + g.Meta `name:"doc" config:"gfcli.doc"` + Path string `short:"p" name:"path" brief:"download docs directory path, default is \"%temp%/goframe\""` + Port int `short:"o" name:"port" brief:"http server port, default is 8080" d:"8080"` + Update bool `short:"u" name:"update" brief:"clean docs directory and update docs"` + Clean bool `short:"c" name:"clean" brief:"clean docs directory"` + Proxy string `short:"x" name:"proxy" brief:"proxy for download, such as https://hub.gitmirror.com/;https://ghproxy.com/;https://ghproxy.net/;https://ghps.cc/"` +} + +type cDocOutput struct{} + +func (c cDoc) Index(ctx context.Context, in cDocInput) (out *cDocOutput, err error) { + docs := NewDocSetting(ctx, in) + mlog.Print("Directory where the document is downloaded:", docs.TempDir) + if in.Clean { + mlog.Print("Cleaning document directory") + err = docs.Clean() + if err != nil { + mlog.Print("Failed to clean document directory:", err) + return + } + return + } + if in.Update { + mlog.Print("Cleaning old document directory") + err = docs.Clean() + if err != nil { + mlog.Print("Failed to clean old document directory:", err) + return + } + } + err = docs.DownloadDoc() + if err != nil { + mlog.Print("Failed to download document:", err) + return + } + s := g.Server() + s.SetServerRoot(docs.DocDir) + s.SetPort(in.Port) + s.SetDumpRouterMap(false) + mlog.Printf("Access address http://127.0.0.1:%d", in.Port) + s.Run() + return +} + +// DocSetting doc setting +type DocSetting struct { + TempDir string + DocURL string + DocDir string + DocZipFile string +} + +// NewDocSetting new DocSetting +func NewDocSetting(ctx context.Context, in cDocInput) *DocSetting { + fileName := "gf-doc-md.zip" + tempDir := in.Path + if tempDir == "" { + tempDir = gfile.Temp("goframe/docs") + } else { + tempDir = gfile.Abs(path.Join(tempDir, "docs")) + } + + return &DocSetting{ + TempDir: filepath.FromSlash(tempDir), + DocDir: filepath.FromSlash(path.Join(tempDir, "gf-gh-pages")), + DocURL: in.Proxy + DocURL, + DocZipFile: filepath.FromSlash(path.Join(tempDir, fileName)), + } + +} + +// Clean clean the temporary directory +func (d *DocSetting) Clean() error { + if _, err := os.Stat(d.TempDir); err == nil { + err = gfile.Remove(d.TempDir) + if err != nil { + mlog.Print("Failed to delete temporary directory:", err) + return err + } + } + return nil +} + +// DownloadDoc download the document +func (d *DocSetting) DownloadDoc() error { + if _, err := os.Stat(d.TempDir); err != nil { + err = gfile.Mkdir(d.TempDir) + if err != nil { + mlog.Print("Failed to create temporary directory:", err) + return nil + } + } + // Check if the file exists + if _, err := os.Stat(d.DocDir); err == nil { + mlog.Print("Document already exists, no need to download and unzip") + return nil + } + + if _, err := os.Stat(d.DocZipFile); err == nil { + mlog.Print("File already exists, no need to download") + } else { + mlog.Printf("File does not exist, start downloading: %s", d.DocURL) + startTime := time.Now() + // Download the file + resp, err := http.Get(d.DocURL) + if err != nil { + mlog.Print("Failed to download file:", err) + return err + } + defer resp.Body.Close() + + // Create the file + out, err := os.Create(d.DocZipFile) + if err != nil { + mlog.Print("Failed to create file:", err) + return err + } + defer out.Close() + + // Write the response body to the file + _, err = io.Copy(out, resp.Body) + if err != nil { + mlog.Print("Failed to write file:", err) + return err + } + mlog.Printf("Download successful, time-consuming: %v", time.Since(startTime)) + } + + mlog.Print("Start unzipping the file...") + // Unzip the file + err := gcompress.UnZipFile(d.DocZipFile, d.TempDir) + if err != nil { + mlog.Print("Failed to unzip the file, please run again:", err) + gfile.Remove(d.DocZipFile) + return err + } + + mlog.Print("Download and unzip successful") + return nil +} diff --git a/server/internal/library/hggen/internal/cmd/cmd_gen_dao.go b/server/internal/library/hggen/internal/cmd/cmd_gen_dao.go index 71f92d6..c5e445e 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_gen_dao.go +++ b/server/internal/library/hggen/internal/cmd/cmd_gen_dao.go @@ -8,6 +8,7 @@ package cmd import ( //_ "github.com/gogf/gf/contrib/drivers/clickhouse/v2" + // _ "github.com/gogf/gf/contrib/drivers/dm/v2" // precompilation does not support certain target platforms. //_ "github.com/gogf/gf/contrib/drivers/mssql/v2" _ "github.com/gogf/gf/contrib/drivers/mysql/v2" //_ "github.com/gogf/gf/contrib/drivers/oracle/v2" diff --git a/server/internal/library/hggen/internal/cmd/cmd_init.go b/server/internal/library/hggen/internal/cmd/cmd_init.go index db93862..7ad160e 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_init.go +++ b/server/internal/library/hggen/internal/cmd/cmd_init.go @@ -19,9 +19,9 @@ import ( "github.com/gogf/gf/v2/os/gres" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gtag" - "hotgo/internal/library/hggen/internal/utility/allyes" "hotgo/internal/library/hggen/internal/utility/mlog" + "hotgo/internal/library/hggen/internal/utility/utils" ) var ( @@ -34,13 +34,15 @@ type cInit struct { } const ( - cInitRepoPrefix = `github.com/gogf/` - cInitMonoRepo = `template-mono` - cInitSingleRepo = `template-single` - cInitBrief = `create and initialize an empty GoFrame project` - cInitEg = ` + cInitRepoPrefix = `github.com/gogf/` + cInitMonoRepo = `template-mono` + cInitMonoRepoApp = `template-mono-app` + cInitSingleRepo = `template-single` + cInitBrief = `create and initialize an empty GoFrame project` + cInitEg = ` gf init my-project gf init my-mono-repo -m +gf init my-mono-repo -a ` cInitNameBrief = ` name for the project. It will create a folder with NAME in current directory. @@ -61,11 +63,12 @@ func init() { } type cInitInput struct { - g.Meta `name:"init"` - Name string `name:"NAME" arg:"true" v:"required" brief:"{cInitNameBrief}"` - Mono bool `name:"mono" short:"m" brief:"initialize a mono-repo instead a single-repo" orphan:"true"` - Update bool `name:"update" short:"u" brief:"update to the latest goframe version" orphan:"true"` - Module string `name:"module" short:"g" brief:"custom go module"` + g.Meta `name:"init"` + Name string `name:"NAME" arg:"true" v:"required" brief:"{cInitNameBrief}"` + Mono bool `name:"mono" short:"m" brief:"initialize a mono-repo instead a single-repo" orphan:"true"` + MonoApp bool `name:"monoApp" short:"a" brief:"initialize a mono-repo-app instead a single-repo" orphan:"true"` + Update bool `name:"update" short:"u" brief:"update to the latest goframe version" orphan:"true"` + Module string `name:"module" short:"g" brief:"custom go module"` } type cInitOutput struct{} @@ -86,11 +89,15 @@ func (c cInit) Index(ctx context.Context, in cInitInput) (out *cInitOutput, err templateRepoName string gitignoreFile = in.Name + "/" + cInitGitignore ) + if in.Mono { templateRepoName = cInitMonoRepo + } else if in.MonoApp { + templateRepoName = cInitMonoRepoApp } else { templateRepoName = cInitSingleRepo } + err = gres.Export(templateRepoName, in.Name, gres.ExportOption{ RemovePrefix: templateRepoName, }) @@ -101,7 +108,8 @@ func (c cInit) Index(ctx context.Context, in cInitInput) (out *cInitOutput, err // build ignoreFiles from the .gitignore file ignoreFiles := make([]string, 0, 10) ignoreFiles = append(ignoreFiles, cInitGitDir) - if overwrote { + // in.MonoApp is a mono-repo-app, it should ignore the .gitignore file + if overwrote && !in.MonoApp { err = gfile.ReadLines(gitignoreFile, func(line string) error { // Add only hidden files or directories // If other directories are added, it may cause the entire directory to be ignored @@ -118,10 +126,14 @@ func (c cInit) Index(ctx context.Context, in cInitInput) (out *cInitOutput, err } } - // Replace module name. + // Get template name and module name. if in.Module == "" { in.Module = gfile.Basename(gfile.RealPath(in.Name)) } + if in.MonoApp { + pwd := gfile.Pwd() + string(os.PathSeparator) + in.Name + in.Module = utils.GetImportPath(pwd) + } // Replace template name to project name. err = gfile.ReplaceDirFunc(func(path, content string) string { diff --git a/server/internal/library/hggen/internal/cmd/cmd_pack.go b/server/internal/library/hggen/internal/cmd/cmd_pack.go index 10f157b..b6addd0 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_pack.go +++ b/server/internal/library/hggen/internal/cmd/cmd_pack.go @@ -63,7 +63,7 @@ func init() { } type cPackInput struct { - g.Meta `name:"pack"` + g.Meta `name:"pack" config:"gfcli.pack"` Src string `name:"SRC" arg:"true" v:"required" brief:"{cPackSrcBrief}"` Dst string `name:"DST" arg:"true" v:"required" brief:"{cPackDstBrief}"` Name string `name:"name" short:"n" brief:"{cPackNameBrief}"` diff --git a/server/internal/library/hggen/internal/cmd/cmd_run.go b/server/internal/library/hggen/internal/cmd/cmd_run.go index f934266..4d274ca 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_run.go +++ b/server/internal/library/hggen/internal/cmd/cmd_run.go @@ -9,6 +9,7 @@ package cmd import ( "context" "fmt" + "os" "path/filepath" "runtime" "strings" @@ -55,7 +56,7 @@ The "run" command is used for running go codes with hot-compiled-like feature, which compiles and runs the go codes asynchronously when codes change. ` cRunFileBrief = `building file path.` - cRunPathBrief = `output directory path for built binary file. it's "manifest/output" in default` + cRunPathBrief = `output directory path for built binary file. it's "./" in default` cRunExtraBrief = `the same options as "go run"/"go build" except some options as follows defined` cRunArgsBrief = `custom arguments for your process` cRunWatchPathsBrief = `watch additional paths for live reload, separated by ",". i.e. "manifest/config/*.yaml"` @@ -81,7 +82,7 @@ func init() { type ( cRunInput struct { - g.Meta `name:"run"` + g.Meta `name:"run" config:"gfcli.run"` File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"` Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"` Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"` @@ -104,13 +105,14 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err app := &cRunApp{ File: in.File, - Path: in.Path, + Path: filepath.FromSlash(in.Path), Options: in.Extra, Args: in.Args, WatchPaths: in.WatchPaths, } dirty := gtype.NewBool() + var outputPath = app.genOutputPath() callbackFunc := func(event *gfsnotify.Event) { if gfile.ExtName(event.Path) != "go" { return @@ -125,7 +127,7 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err gtimer.SetTimeout(ctx, 1500*gtime.MS, func(ctx context.Context) { defer dirty.Set(false) mlog.Printf(`watched file changes: %s`, event.String()) - app.Run(ctx) + app.Run(ctx, outputPath) }) } @@ -143,24 +145,21 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err } } - go app.Run(ctx) + go app.Run(ctx, outputPath) + + gproc.AddSigHandlerShutdown(func(sig os.Signal) { + app.End(ctx, sig, outputPath) + os.Exit(0) + }) + gproc.Listen() + select {} } -func (app *cRunApp) Run(ctx context.Context) { +func (app *cRunApp) Run(ctx context.Context, outputPath string) { // Rebuild and run the codes. - renamePath := "" mlog.Printf("build: %s", app.File) - outputPath := gfile.Join(app.Path, gfile.Name(app.File)) - if runtime.GOOS == "windows" { - outputPath += ".exe" - if gfile.Exists(outputPath) { - renamePath = outputPath + "~" - if err := gfile.Rename(outputPath, renamePath); err != nil { - mlog.Print(err) - } - } - } + // In case of `pipe: too many open files` error. // Build the app. buildCommand := fmt.Sprintf( @@ -198,6 +197,36 @@ func (app *cRunApp) Run(ctx context.Context) { } } +func (app *cRunApp) End(ctx context.Context, sig os.Signal, outputPath string) { + // Delete the binary file. + // firstly, kill the process. + if process != nil { + if err := process.Kill(); err != nil { + mlog.Debugf("kill process error: %s", err.Error()) + } + } + if err := gfile.Remove(outputPath); err != nil { + mlog.Printf("delete binary file error: %s", err.Error()) + } else { + mlog.Printf("deleted binary file: %s", outputPath) + } +} + +func (app *cRunApp) genOutputPath() (outputPath string) { + var renamePath string + outputPath = gfile.Join(app.Path, gfile.Name(app.File)) + if runtime.GOOS == "windows" { + outputPath += ".exe" + if gfile.Exists(outputPath) { + renamePath = outputPath + "~" + if err := gfile.Rename(outputPath, renamePath); err != nil { + mlog.Print(err) + } + } + } + return filepath.FromSlash(outputPath) +} + func matchWatchPaths(watchPaths []string, eventPath string) bool { for _, path := range watchPaths { absPath, err := filepath.Abs(path) diff --git a/server/internal/library/hggen/internal/cmd/cmd_tpl.go b/server/internal/library/hggen/internal/cmd/cmd_tpl.go index df1931b..4c132e5 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_tpl.go +++ b/server/internal/library/hggen/internal/cmd/cmd_tpl.go @@ -47,7 +47,7 @@ gf tpl parse -p ./template -v values.json -o ./template.parsed type ( cTplParseInput struct { - g.Meta `name:"parse" brief:"{cTplParseBrief}" eg:"{cTplParseEg}"` + g.Meta `name:"parse" config:"gfcli.tpl.parse" brief:"{cTplParseBrief}" eg:"{cTplParseEg}"` Path string `name:"path" short:"p" brief:"template file or folder path" v:"required"` Pattern string `name:"pattern" short:"n" brief:"template file pattern when path is a folder, default is:*" d:"*"` Recursive bool `name:"recursive" short:"c" brief:"recursively parsing files if path is folder, default is:true" d:"true"` diff --git a/server/internal/library/hggen/internal/cmd/cmd_up.go b/server/internal/library/hggen/internal/cmd/cmd_up.go index af97007..aa49d1d 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_up.go +++ b/server/internal/library/hggen/internal/cmd/cmd_up.go @@ -48,7 +48,7 @@ func init() { } type cUpInput struct { - g.Meta `name:"up" config:"gfcli.up"` + g.Meta `name:"up" config:"gfcli.up"` All bool `name:"all" short:"a" brief:"upgrade both version and cli, auto fix codes" orphan:"true"` Cli bool `name:"cli" short:"c" brief:"also upgrade CLI tool" orphan:"true"` Fix bool `name:"fix" short:"f" brief:"auto fix codes(it only make sense if cli is to be upgraded)" orphan:"true"` @@ -142,8 +142,9 @@ func (c cUp) doUpgradeVersion(ctx context.Context, in cUpInput) (out *doUpgradeV } for _, pkg := range packages { mlog.Printf(`upgrading "%s" from "%s" to "latest"`, pkg.Name, pkg.Version) - // go get -u - command := fmt.Sprintf(`cd %s && go get -u %s@latest`, dirPath, pkg.Name) + mlog.Printf(`running command: go get %s@latest`, pkg.Name) + // go get @latest + command := fmt.Sprintf(`cd %s && go get %s@latest`, dirPath, pkg.Name) if err = gproc.ShellRun(ctx, command); err != nil { return } diff --git a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_ctrl_test.go b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_ctrl_test.go index f6d8d0d..2d4dff4 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_ctrl_test.go +++ b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_ctrl_test.go @@ -41,9 +41,7 @@ func Test_Gen_Ctrl_Default(t *testing.T) { defer gfile.Remove(path) _, err = genctrl.CGenCtrl{}.Ctrl(ctx, in) - if err != nil { - panic(err) - } + t.AssertNil(err) // apiInterface file var ( @@ -84,3 +82,228 @@ func Test_Gen_Ctrl_Default(t *testing.T) { } }) } + +func expectFilesContent(t *gtest.T, paths []string, expectPaths []string) { + for i, expectFile := range expectPaths { + val := gfile.GetContents(paths[i]) + expect := gfile.GetContents(expectFile) + t.Assert(val, expect) + } +} + +// gf gen ctrl -m +// In the same module, different API files are added +func Test_Gen_Ctrl_UseMerge_AddNewFile(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + ctrlPath = gfile.Temp(guid.S()) + //ctrlPath = gtest.DataPath("issue", "3460", "controller") + apiFolder = gtest.DataPath("genctrl-merge", "add_new_file", "api") + in = genctrl.CGenCtrlInput{ + SrcFolder: apiFolder, + DstFolder: ctrlPath, + Merge: true, + } + ) + const testNewApiFile = ` +package v1 +import "github.com/gogf/gf/v2/frame/g" +type DictTypeAddReq struct { + g.Meta +} +type DictTypeAddRes struct { +} +` + + err := gfile.Mkdir(ctrlPath) + t.AssertNil(err) + defer gfile.Remove(ctrlPath) + + _, err = genctrl.CGenCtrl{}.Ctrl(ctx, in) + t.AssertNil(err) + + var ( + genApi = filepath.Join(apiFolder, "/dict/dict.go") + genApiExpect = filepath.Join(apiFolder, "/dict/dict_expect.go") + ) + defer gfile.Remove(genApi) + t.Assert(gfile.GetContents(genApi), gfile.GetContents(genApiExpect)) + + genCtrlFiles, err := gfile.ScanDir(ctrlPath, "*.go", true) + t.AssertNil(err) + t.Assert(genCtrlFiles, []string{ + filepath.Join(ctrlPath, "/dict/dict.go"), + filepath.Join(ctrlPath, "/dict/dict_new.go"), + filepath.Join(ctrlPath, "/dict/dict_v1_dict_type.go"), + }) + + expectCtrlPath := gtest.DataPath("genctrl-merge", "add_new_file", "controller") + expectFiles := []string{ + filepath.Join(expectCtrlPath, "/dict/dict.go"), + filepath.Join(expectCtrlPath, "/dict/dict_new.go"), + filepath.Join(expectCtrlPath, "/dict/dict_v1_dict_type.go"), + } + + // Line Feed maybe \r\n or \n + expectFilesContent(t, genCtrlFiles, expectFiles) + + // Add a new API file + newApiFilePath := filepath.Join(apiFolder, "/dict/v1/test_new.go") + err = gfile.PutContents(newApiFilePath, testNewApiFile) + t.AssertNil(err) + defer gfile.Remove(newApiFilePath) + + // Then execute the command + _, err = genctrl.CGenCtrl{}.Ctrl(ctx, in) + t.AssertNil(err) + + genApi = filepath.Join(apiFolder, "/dict.go") + genApiExpect = filepath.Join(apiFolder, "/dict_add_new_ctrl_expect.gotest") + + t.Assert(gfile.GetContents(genApi), gfile.GetContents(genApiExpect)) + + genCtrlFiles = append(genCtrlFiles, filepath.Join(ctrlPath, "/dict/dict_v1_test_new.go")) + // Use the gotest suffix, otherwise the IDE will delete the import + expectFiles = append(expectFiles, filepath.Join(expectCtrlPath, "/dict/dict_v1_test_new.gotest")) + // Line Feed maybe \r\n or \n + expectFilesContent(t, genCtrlFiles, expectFiles) + + }) + +} + +// gf gen ctrl -m +// In the same module, Add the same file to the API +func Test_Gen_Ctrl_UseMerge_AddNewCtrl(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + ctrlPath = gfile.Temp(guid.S()) + //ctrlPath = gtest.DataPath("issue", "3460", "controller") + apiFolder = gtest.DataPath("genctrl-merge", "add_new_ctrl", "api") + in = genctrl.CGenCtrlInput{ + SrcFolder: apiFolder, + DstFolder: ctrlPath, + Merge: true, + } + ) + + err := gfile.Mkdir(ctrlPath) + t.AssertNil(err) + defer gfile.Remove(ctrlPath) + + _, err = genctrl.CGenCtrl{}.Ctrl(ctx, in) + t.AssertNil(err) + + var ( + genApi = filepath.Join(apiFolder, "/dict/dict.go") + genApiExpect = filepath.Join(apiFolder, "/dict/dict_expect.go") + ) + defer gfile.Remove(genApi) + t.Assert(gfile.GetContents(genApi), gfile.GetContents(genApiExpect)) + + genCtrlFiles, err := gfile.ScanDir(ctrlPath, "*.go", true) + t.AssertNil(err) + t.Assert(genCtrlFiles, []string{ + filepath.Join(ctrlPath, "/dict/dict.go"), + filepath.Join(ctrlPath, "/dict/dict_new.go"), + filepath.Join(ctrlPath, "/dict/dict_v1_dict_type.go"), + }) + + expectCtrlPath := gtest.DataPath("genctrl-merge", "add_new_ctrl", "controller") + expectFiles := []string{ + filepath.Join(expectCtrlPath, "/dict/dict.go"), + filepath.Join(expectCtrlPath, "/dict/dict_new.go"), + filepath.Join(expectCtrlPath, "/dict/dict_v1_dict_type.go"), + } + + // Line Feed maybe \r\n or \n + expectFilesContent(t, genCtrlFiles, expectFiles) + + const testNewApiFile = ` + +type DictTypeAddReq struct { + g.Meta +} +type DictTypeAddRes struct { +} +` + dictModuleFileName := filepath.Join(apiFolder, "/dict/v1/dict_type.go") + // Save the contents of the file before the changes + apiFileContents := gfile.GetContents(dictModuleFileName) + + // Add a new API file + err = gfile.PutContentsAppend(dictModuleFileName, testNewApiFile) + t.AssertNil(err) + + //================================== + // Then execute the command + _, err = genctrl.CGenCtrl{}.Ctrl(ctx, in) + t.AssertNil(err) + + genApi = filepath.Join(apiFolder, "/dict.go") + genApiExpect = filepath.Join(apiFolder, "/dict_add_new_ctrl_expect.gotest") + t.Assert(gfile.GetContents(genApi), gfile.GetContents(genApiExpect)) + + // Use the gotest suffix, otherwise the IDE will delete the import + expectFiles[2] = filepath.Join(expectCtrlPath, "/dict/dict_v1_test_new.gotest") + // Line Feed maybe \r\n or \n + expectFilesContent(t, genCtrlFiles, expectFiles) + + // Restore the contents of the original API file + err = gfile.PutContents(dictModuleFileName, apiFileContents) + t.AssertNil(err) + }) + +} + +// https://github.com/gogf/gf/issues/3460 +func Test_Gen_Ctrl_UseMerge_Issue3460(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + ctrlPath = gfile.Temp(guid.S()) + //ctrlPath = gtest.DataPath("issue", "3460", "controller") + apiFolder = gtest.DataPath("issue", "3460", "api") + in = genctrl.CGenCtrlInput{ + SrcFolder: apiFolder, + DstFolder: ctrlPath, + WatchFile: "", + SdkPath: "", + SdkStdVersion: false, + SdkNoV1: false, + Clear: false, + Merge: true, + } + ) + + err := gfile.Mkdir(ctrlPath) + t.AssertNil(err) + defer gfile.Remove(ctrlPath) + + _, err = genctrl.CGenCtrl{}.Ctrl(ctx, in) + t.AssertNil(err) + + files, err := gfile.ScanDir(ctrlPath, "*.go", true) + t.AssertNil(err) + t.Assert(files, []string{ + filepath.Join(ctrlPath, "/hello/hello.go"), + filepath.Join(ctrlPath, "/hello/hello_new.go"), + filepath.Join(ctrlPath, "/hello/hello_v1_req.go"), + filepath.Join(ctrlPath, "/hello/hello_v2_req.go"), + }) + + expectCtrlPath := gtest.DataPath("issue", "3460", "controller") + expectFiles := []string{ + filepath.Join(expectCtrlPath, "/hello/hello.go"), + filepath.Join(expectCtrlPath, "/hello/hello_new.go"), + filepath.Join(expectCtrlPath, "/hello/hello_v1_req.go"), + filepath.Join(expectCtrlPath, "/hello/hello_v2_req.go"), + } + + // Line Feed maybe \r\n or \n + for i, expectFile := range expectFiles { + val := gfile.GetContents(files[i]) + expect := gfile.GetContents(expectFile) + t.Assert(val, expect) + } + }) +} diff --git a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_dao_test.go b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_dao_test.go index 1f5c854..6525dc2 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_dao_test.go +++ b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_dao_test.go @@ -12,6 +12,8 @@ import ( "testing" "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gcfg" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" @@ -69,6 +71,7 @@ func Test_Gen_Dao_Default(t *testing.T) { NoModelComment: false, Clear: false, TypeMapping: nil, + FieldMapping: nil, } ) err = gutil.FillStructWithDefault(&in) @@ -169,6 +172,7 @@ func Test_Gen_Dao_TypeMapping(t *testing.T) { Import: "github.com/shopspring/decimal", }, }, + FieldMapping: nil, } ) err = gutil.FillStructWithDefault(&in) @@ -211,6 +215,108 @@ func Test_Gen_Dao_TypeMapping(t *testing.T) { }) } +func Test_Gen_Dao_FieldMapping(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table = "table_user" + sqlContent = fmt.Sprintf( + gtest.DataContent(`gendao`, `user.tpl.sql`), + table, + ) + ) + defer dropTableWithDb(db, table) + array := gstr.SplitAndTrim(sqlContent, ";") + for _, v := range array { + if _, err = db.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + defer dropTableWithDb(db, table) + + var ( + path = gfile.Temp(guid.S()) + group = "test" + in = gendao.CGenDaoInput{ + Path: path, + Link: link, + Tables: "", + TablesEx: "", + Group: group, + Prefix: "", + RemovePrefix: "", + JsonCase: "", + ImportPrefix: "", + DaoPath: "", + DoPath: "", + EntityPath: "", + TplDaoIndexPath: "", + TplDaoInternalPath: "", + TplDaoDoPath: "", + TplDaoEntityPath: "", + StdTime: false, + WithTime: false, + GJsonSupport: false, + OverwriteDao: false, + DescriptionTag: false, + NoJsonTag: false, + NoModelComment: false, + Clear: false, + TypeMapping: map[gendao.DBFieldTypeName]gendao.CustomAttributeType{ + "int": { + Type: "int64", + Import: "", + }, + }, + FieldMapping: map[gendao.DBTableFieldName]gendao.CustomAttributeType{ + "table_user.score": { + Type: "decimal.Decimal", + Import: "github.com/shopspring/decimal", + }, + }, + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + + // for go mod import path auto retrieve. + err = gfile.Copy( + gtest.DataPath("gendao", "go.mod.txt"), + gfile.Join(path, "go.mod"), + ) + t.AssertNil(err) + + _, err = gendao.CGenDao{}.Dao(ctx, in) + t.AssertNil(err) + defer gfile.Remove(path) + + // files + files, err := gfile.ScanDir(path, "*.go", true) + t.AssertNil(err) + t.Assert(files, []string{ + filepath.FromSlash(path + "/dao/internal/table_user.go"), + filepath.FromSlash(path + "/dao/table_user.go"), + filepath.FromSlash(path + "/model/do/table_user.go"), + filepath.FromSlash(path + "/model/entity/table_user.go"), + }) + // content + testPath := gtest.DataPath("gendao", "generated_user_field_mapping") + expectFiles := []string{ + filepath.FromSlash(testPath + "/dao/internal/table_user.go"), + filepath.FromSlash(testPath + "/dao/table_user.go"), + filepath.FromSlash(testPath + "/model/do/table_user.go"), + filepath.FromSlash(testPath + "/model/entity/table_user.go"), + } + for i, _ := range files { + t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) + } + }) +} + func execSqlFile(db gdb.DB, filePath string, args ...any) error { sqlContent := fmt.Sprintf( gfile.GetContents(filePath), @@ -225,6 +331,7 @@ func execSqlFile(db gdb.DB, filePath string, args ...any) error { return nil } +// https://github.com/gogf/gf/issues/2572 func Test_Gen_Dao_Issue2572(t *testing.T) { gtest.C(t, func(t *gtest.T) { var ( @@ -244,7 +351,7 @@ func Test_Gen_Dao_Issue2572(t *testing.T) { group = "test" in = gendao.CGenDaoInput{ Path: path, - Link: link, + Link: "", Tables: "", TablesEx: "", Group: group, @@ -268,6 +375,7 @@ func Test_Gen_Dao_Issue2572(t *testing.T) { NoModelComment: false, Clear: false, TypeMapping: nil, + FieldMapping: nil, } ) err = gutil.FillStructWithDefault(&in) @@ -293,17 +401,26 @@ func Test_Gen_Dao_Issue2572(t *testing.T) { for i, generatedFile := range generatedFiles { generatedFiles[i] = gstr.TrimLeftStr(generatedFile, path) } - t.Assert(gstr.InArray(generatedFiles, "/dao/internal/user_1.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/dao/internal/user_2.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/dao/user_1.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/dao/user_2.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/model/do/user_1.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/model/do/user_2.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/model/entity/user_1.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/model/entity/user_2.go"), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/internal/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/internal/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/do/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/do/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/entity/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/entity/user_2.go")), true) }) } +// https://github.com/gogf/gf/issues/2616 func Test_Gen_Dao_Issue2616(t *testing.T) { gtest.C(t, func(t *gtest.T) { var ( @@ -323,7 +440,7 @@ func Test_Gen_Dao_Issue2616(t *testing.T) { group = "test" in = gendao.CGenDaoInput{ Path: path, - Link: link, + Link: "", Tables: "", TablesEx: "", Group: group, @@ -347,6 +464,7 @@ func Test_Gen_Dao_Issue2616(t *testing.T) { NoModelComment: false, Clear: false, TypeMapping: nil, + FieldMapping: nil, } ) err = gutil.FillStructWithDefault(&in) @@ -372,14 +490,22 @@ func Test_Gen_Dao_Issue2616(t *testing.T) { for i, generatedFile := range generatedFiles { generatedFiles[i] = gstr.TrimLeftStr(generatedFile, path) } - t.Assert(gstr.InArray(generatedFiles, "/dao/internal/user_1.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/dao/internal/user_2.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/dao/user_1.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/dao/user_2.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/model/do/user_1.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/model/do/user_2.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/model/entity/user_1.go"), true) - t.Assert(gstr.InArray(generatedFiles, "/model/entity/user_2.go"), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/internal/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/internal/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/do/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/do/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/entity/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/entity/user_2.go")), true) // Key string to check if overwrite the dao files. // dao user1 is not be overwritten as configured in config.yaml. @@ -449,6 +575,7 @@ func Test_Gen_Dao_Issue2746(t *testing.T) { NoModelComment: false, Clear: false, TypeMapping: nil, + FieldMapping: nil, } ) err = gutil.FillStructWithDefault(&in) @@ -468,3 +595,99 @@ func Test_Gen_Dao_Issue2746(t *testing.T) { t.Assert(expectContent, gfile.GetContents(file)) }) } + +// https://github.com/gogf/gf/issues/3459 +func Test_Gen_Dao_Issue3459(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table = "table_user" + sqlContent = fmt.Sprintf( + gtest.DataContent(`gendao`, `user.tpl.sql`), + table, + ) + ) + dropTableWithDb(db, table) + array := gstr.SplitAndTrim(sqlContent, ";") + for _, v := range array { + if _, err = db.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + defer dropTableWithDb(db, table) + + var ( + confDir = gtest.DataPath("issue", "3459") + path = gfile.Temp(guid.S()) + group = "test" + in = gendao.CGenDaoInput{ + Path: path, + Link: link, + Tables: "", + TablesEx: "", + Group: group, + Prefix: "", + RemovePrefix: "", + JsonCase: "SnakeScreaming", + ImportPrefix: "", + DaoPath: "", + DoPath: "", + EntityPath: "", + TplDaoIndexPath: "", + TplDaoInternalPath: "", + TplDaoDoPath: "", + TplDaoEntityPath: "", + StdTime: false, + WithTime: false, + GJsonSupport: false, + OverwriteDao: false, + DescriptionTag: false, + NoJsonTag: false, + NoModelComment: false, + Clear: false, + TypeMapping: nil, + } + ) + err = g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetPath(confDir) + t.AssertNil(err) + + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + + // for go mod import path auto retrieve. + err = gfile.Copy( + gtest.DataPath("gendao", "go.mod.txt"), + gfile.Join(path, "go.mod"), + ) + t.AssertNil(err) + + _, err = gendao.CGenDao{}.Dao(ctx, in) + t.AssertNil(err) + defer gfile.Remove(path) + + // files + files, err := gfile.ScanDir(path, "*.go", true) + t.AssertNil(err) + t.Assert(files, []string{ + filepath.FromSlash(path + "/dao/internal/table_user.go"), + filepath.FromSlash(path + "/dao/table_user.go"), + filepath.FromSlash(path + "/model/do/table_user.go"), + filepath.FromSlash(path + "/model/entity/table_user.go"), + }) + // content + testPath := gtest.DataPath("gendao", "generated_user") + expectFiles := []string{ + filepath.FromSlash(testPath + "/dao/internal/table_user.go"), + filepath.FromSlash(testPath + "/dao/table_user.go"), + filepath.FromSlash(testPath + "/model/do/table_user.go"), + filepath.FromSlash(testPath + "/model/entity/table_user.go"), + } + for i, _ := range files { + t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) + } + }) +} diff --git a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_pbentity_test.go b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_pbentity_test.go index 48ebdb9..6516645 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_pbentity_test.go +++ b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_pbentity_test.go @@ -8,18 +8,18 @@ package cmd import ( "fmt" - "os" "path/filepath" "testing" - "github.com/gogf/gf/v2/os/gcmd" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/guid" + "github.com/gogf/gf/v2/util/gutil" + "hotgo/internal/library/hggen/internal/cmd/genpbentity" ) -func Test_Gen_Pbentity_NameCase(t *testing.T) { +func Test_Gen_Pbentity_Default(t *testing.T) { gtest.C(t, func(t *gtest.T) { var ( err error @@ -38,31 +38,171 @@ func Test_Gen_Pbentity_NameCase(t *testing.T) { } } defer dropTableWithDb(db, table) - var path = gfile.Temp(guid.S()) + + var ( + path = gfile.Temp(guid.S()) + in = genpbentity.CGenPbEntityInput{ + Path: path, + Package: "unittest", + Link: link, + Tables: "", + Prefix: "", + RemovePrefix: "", + RemoveFieldPrefix: "", + NameCase: "", + JsonCase: "", + Option: "", + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + err = gfile.Mkdir(path) t.AssertNil(err) defer gfile.Remove(path) - root, err := gcmd.NewFromObject(GF) - t.AssertNil(err) - err = root.AddObject( - Gen, - ) - t.AssertNil(err) - os.Args = []string{"gf", "gen", "pbentity", "-l", link, "-p", path, "-package=unittest", "-nameCase=SnakeScreaming"} - - err = root.RunWithError(ctx) + _, err = genpbentity.CGenPbEntity{}.PbEntity(ctx, in) t.AssertNil(err) - files := []string{ - filepath.FromSlash(path + "/table_user.proto"), - } + // files + files, err := gfile.ScanDir(path, "*.proto", false) + t.AssertNil(err) + t.Assert(files, []string{ + path + filepath.FromSlash("/table_user.proto"), + }) - testPath := gtest.DataPath("genpbentity", "generated_user") + // contents + testPath := gtest.DataPath("genpbentity", "generated") expectFiles := []string{ - filepath.FromSlash(testPath + "/table_user.proto"), + testPath + filepath.FromSlash("/table_user.proto"), + } + for i := range files { + t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) + } + }) +} + +func Test_Gen_Pbentity_NameCase_SnakeScreaming(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table = "table_user" + sqlContent = fmt.Sprintf( + gtest.DataContent(`genpbentity`, `user.tpl.sql`), + table, + ) + ) + dropTableWithDb(db, table) + array := gstr.SplitAndTrim(sqlContent, ";") + for _, v := range array { + if _, err = db.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + defer dropTableWithDb(db, table) + + var ( + path = gfile.Temp(guid.S()) + in = genpbentity.CGenPbEntityInput{ + Path: path, + Package: "unittest", + Link: link, + Tables: "", + Prefix: "", + RemovePrefix: "", + RemoveFieldPrefix: "", + NameCase: "SnakeScreaming", + JsonCase: "", + Option: "", + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + defer gfile.Remove(path) + + _, err = genpbentity.CGenPbEntity{}.PbEntity(ctx, in) + t.AssertNil(err) + + // files + files, err := gfile.ScanDir(path, "*.proto", false) + t.AssertNil(err) + t.Assert(files, []string{ + path + filepath.FromSlash("/table_user.proto"), + }) + + // contents + testPath := gtest.DataPath("genpbentity", "generated") + expectFiles := []string{ + testPath + filepath.FromSlash("/table_user_snake_screaming.proto"), + } + for i := range files { + t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) + } + }) +} + +// https://github.com/gogf/gf/issues/3545 +func Test_Issue_3545(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table = "table_user" + sqlContent = fmt.Sprintf( + gtest.DataContent(`genpbentity`, `user.tpl.sql`), + table, + ) + ) + dropTableWithDb(db, table) + array := gstr.SplitAndTrim(sqlContent, ";") + for _, v := range array { + if _, err = db.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + defer dropTableWithDb(db, table) + + var ( + path = gfile.Temp(guid.S()) + in = genpbentity.CGenPbEntityInput{ + Path: path, + Package: "", + Link: link, + Tables: "", + Prefix: "", + RemovePrefix: "", + RemoveFieldPrefix: "", + NameCase: "", + JsonCase: "", + Option: "", + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + defer gfile.Remove(path) + + _, err = genpbentity.CGenPbEntity{}.PbEntity(ctx, in) + t.AssertNil(err) + + // files + files, err := gfile.ScanDir(path, "*.proto", false) + t.AssertNil(err) + t.Assert(files, []string{ + path + filepath.FromSlash("/table_user.proto"), + }) + + // contents + testPath := gtest.DataPath("issue", "3545") + expectFiles := []string{ + testPath + filepath.FromSlash("/table_user.proto"), } - // check files content for i := range files { t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) } diff --git a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_service_test.go b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_service_test.go index 0b326ee..47f9fcf 100644 --- a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_service_test.go +++ b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_service_test.go @@ -42,9 +42,7 @@ func Test_Gen_Service_Default(t *testing.T) { defer gfile.Remove(path) _, err = genservice.CGenService{}.Service(ctx, in) - if err != nil { - panic(err) - } + t.AssertNil(err) // logic file var ( @@ -59,12 +57,16 @@ func Test_Gen_Service_Default(t *testing.T) { t.AssertNil(err) t.Assert(files, []string{ dstFolder + filepath.FromSlash("/article.go"), + dstFolder + filepath.FromSlash("/delivery.go"), + dstFolder + filepath.FromSlash("/user.go"), }) // contents testPath := gtest.DataPath("genservice", "service") expectFiles := []string{ testPath + filepath.FromSlash("/article.go"), + testPath + filepath.FromSlash("/delivery.go"), + testPath + filepath.FromSlash("/user.go"), } for i := range files { t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) diff --git a/server/internal/library/hggen/internal/cmd/genctrl/genctrl.go b/server/internal/library/hggen/internal/cmd/genctrl/genctrl.go index 990ed8f..e477c3f 100644 --- a/server/internal/library/hggen/internal/cmd/genctrl/genctrl.go +++ b/server/internal/library/hggen/internal/cmd/genctrl/genctrl.go @@ -13,10 +13,8 @@ import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gtag" - "hotgo/internal/library/hggen/internal/utility/mlog" ) @@ -38,7 +36,6 @@ gf gen ctrl ) const ( - PatternApiDefinition = `type[\s\(]+(\w+)Req\s+struct\s+{([\s\S]+?)}` PatternCtrlDefinition = `func\s+\(.+?\)\s+\w+\(.+?\*(\w+)\.(\w+)Req\)\s+\(.+?\*(\w+)\.(\w+)Res,\s+\w+\s+error\)\s+{` ) @@ -146,7 +143,11 @@ func (c CGenCtrl) generateByWatchFile(watchFile, sdkPath string, sdkStdVersion, } // watch file should have api definitions. if gfile.Exists(watchFile) { - if !gregex.IsMatchString(PatternApiDefinition, gfile.GetContents(watchFile)) { + structsInfo, err := c.getStructsNameInSrc(watchFile) + if err != nil { + return err + } + if len(structsInfo) == 0 { return nil } } diff --git a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_ast_parse.go b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_ast_parse.go new file mode 100644 index 0000000..cf27089 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_ast_parse.go @@ -0,0 +1,78 @@ +// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package genctrl + +import ( + "bytes" + "go/ast" + "go/parser" + "go/printer" + "go/token" + + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/text/gstr" +) + +// getStructsNameInSrc retrieves all struct names +// that end in "Req" and have "g.Meta" in their body. +func (c CGenCtrl) getStructsNameInSrc(filePath string) (structsName []string, err error) { + var ( + fileContent = gfile.GetContents(filePath) + fileSet = token.NewFileSet() + ) + + node, err := parser.ParseFile(fileSet, "", fileContent, parser.ParseComments) + if err != nil { + return + } + + ast.Inspect(node, func(n ast.Node) bool { + if typeSpec, ok := n.(*ast.TypeSpec); ok { + methodName := typeSpec.Name.Name + if !gstr.HasSuffix(methodName, "Req") { + // ignore struct name that do not end in "Req" + return true + } + if structType, ok := typeSpec.Type.(*ast.StructType); ok { + var buf bytes.Buffer + if err := printer.Fprint(&buf, fileSet, structType); err != nil { + return false + } + // ignore struct name that match a request, but has no g.Meta in its body. + if !gstr.Contains(buf.String(), `g.Meta`) { + return true + } + structsName = append(structsName, methodName) + } + } + return true + }) + + return +} + +// getImportsInDst retrieves all import paths in the file. +func (c CGenCtrl) getImportsInDst(filePath string) (imports []string, err error) { + var ( + fileContent = gfile.GetContents(filePath) + fileSet = token.NewFileSet() + ) + + node, err := parser.ParseFile(fileSet, "", fileContent, parser.ParseComments) + if err != nil { + return + } + + ast.Inspect(node, func(n ast.Node) bool { + if imp, ok := n.(*ast.ImportSpec); ok { + imports = append(imports, imp.Path.Value) + } + return true + }) + + return +} diff --git a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_ast_parse_clear.go b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_ast_parse_clear.go new file mode 100644 index 0000000..a1bd739 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_ast_parse_clear.go @@ -0,0 +1,43 @@ +// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package genctrl + +import ( + "bytes" + "go/ast" + "go/parser" + "go/printer" + "go/token" + + "github.com/gogf/gf/v2/os/gfile" +) + +// getFuncInDst retrieves all function declarations and bodies in the file. +func (c *controllerClearer) getFuncInDst(filePath string) (funcs []string, err error) { + var ( + fileContent = gfile.GetContents(filePath) + fileSet = token.NewFileSet() + ) + + node, err := parser.ParseFile(fileSet, "", fileContent, parser.ParseComments) + if err != nil { + return + } + + ast.Inspect(node, func(n ast.Node) bool { + if fun, ok := n.(*ast.FuncDecl); ok { + var buf bytes.Buffer + if err := printer.Fprint(&buf, fileSet, fun); err != nil { + return false + } + funcs = append(funcs, buf.String()) + } + return true + }) + + return +} diff --git a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_calculate.go b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_calculate.go index 79d823c..841e49a 100644 --- a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_calculate.go +++ b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_calculate.go @@ -14,10 +14,7 @@ import ( ) func (c CGenCtrl) getApiItemsInSrc(apiModuleFolderPath string) (items []apiItem, err error) { - var ( - fileContent string - importPath string - ) + var importPath string // The second level folders: versions. apiVersionFolderPaths, err := gfile.ScanDir(apiModuleFolderPath, "*", false) if err != nil { @@ -37,20 +34,13 @@ func (c CGenCtrl) getApiItemsInSrc(apiModuleFolderPath string) (items []apiItem, if gfile.IsDir(apiFileFolderPath) { continue } - fileContent = gfile.GetContents(apiFileFolderPath) - matches, err := gregex.MatchAllString(PatternApiDefinition, fileContent) + structsInfo, err := c.getStructsNameInSrc(apiFileFolderPath) if err != nil { return nil, err } - for _, match := range matches { - var ( - methodName = match[1] - structBody = match[2] - ) - // ignore struct name that match a request, but has no g.Meta in its body. - if !gstr.Contains(structBody, `g.Meta`) { - continue - } + for _, methodName := range structsInfo { + // remove end "Req" + methodName = gstr.TrimRightStr(methodName, "Req", 1) item := apiItem{ Import: gstr.Trim(importPath, `"`), FileName: gfile.Name(apiFileFolderPath), @@ -73,26 +63,22 @@ func (c CGenCtrl) getApiItemsInDst(dstFolder string) (items []apiItem, err error Path string Alias string } - var fileContent string filePaths, err := gfile.ScanDir(dstFolder, "*.go", true) if err != nil { return nil, err } for _, filePath := range filePaths { - fileContent = gfile.GetContents(filePath) - match, err := gregex.MatchString(`import\s+\(([\s\S]+?)\)`, fileContent) - if err != nil { - return nil, err - } - if len(match) < 2 { - continue - } var ( array []string importItems []importItem - importLines = gstr.SplitAndTrim(match[1], "\n") + importLines []string module = gfile.Basename(gfile.Dir(filePath)) ) + importLines, err = c.getImportsInDst(filePath) + if err != nil { + return nil, err + } + // retrieve all imports. for _, importLine := range importLines { array = gstr.SplitAndTrim(importLine, " ") @@ -108,11 +94,15 @@ func (c CGenCtrl) getApiItemsInDst(dstFolder string) (items []apiItem, err error } } // retrieve all api usages. + // retrieve it without using AST, but use regular expressions to retrieve. + // It's because the api definition is simple and regular. + // Use regular expressions to get better performance. + fileContent := gfile.GetContents(filePath) matches, err := gregex.MatchAllString(PatternCtrlDefinition, fileContent) if err != nil { return nil, err } - for _, match = range matches { + for _, match := range matches { // try to find the import path of the api. var ( importPath string diff --git a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_ctrl.go b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_ctrl.go index a53baf2..29e548e 100644 --- a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_ctrl.go +++ b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_ctrl.go @@ -9,6 +9,7 @@ package genctrl import ( "fmt" "path/filepath" + "strings" "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/frame/g" @@ -42,8 +43,16 @@ func (c *controllerGenerator) Generate(dstModuleFolderPath string, apiModuleApiI ); err != nil { return } + + // use -merge + if merge { + err = c.doGenerateCtrlMergeItem(dstModuleFolderPath, subItems, doneApiItemSet) + continue + } + for _, subItem := range subItems { - if err = c.doGenerateCtrlItem(dstModuleFolderPath, subItem, merge); err != nil { + err = c.doGenerateCtrlItem(dstModuleFolderPath, subItem) + if err != nil { return } doneApiItemSet.Add(subItem.String()) @@ -116,7 +125,7 @@ func (c *controllerGenerator) doGenerateCtrlNewByModuleAndVersion( return } -func (c *controllerGenerator) doGenerateCtrlItem(dstModuleFolderPath string, item apiItem, merge bool) (err error) { +func (c *controllerGenerator) doGenerateCtrlItem(dstModuleFolderPath string, item apiItem) (err error) { var ( methodNameSnake = gstr.CaseSnake(item.MethodName) ctrlName = fmt.Sprintf(`Controller%s`, gstr.UcFirst(item.Version)) @@ -126,13 +135,6 @@ func (c *controllerGenerator) doGenerateCtrlItem(dstModuleFolderPath string, ite ) var content string - if merge { - methodFilePath = gfile.Join(dstModuleFolderPath, fmt.Sprintf( - `%s_%s_%s.go`, item.Module, item.Version, item.FileName, - )) - - } - if gfile.Exists(methodFilePath) { content = gstr.ReplaceByMap(consts.TemplateGenCtrlControllerMethodFuncMerge, g.MapStrStr{ "{Module}": item.Module, @@ -141,7 +143,7 @@ func (c *controllerGenerator) doGenerateCtrlItem(dstModuleFolderPath string, ite "{MethodName}": item.MethodName, }) - if gstr.Contains(gfile.GetContents(methodFilePath), fmt.Sprintf(`func (c *%v) %v`, ctrlName, item.MethodName)) { + if gstr.Contains(gfile.GetContents(methodFilePath), fmt.Sprintf(`func (c *%v) %v(`, ctrlName, item.MethodName)) { return } if err = gfile.PutContentsAppend(methodFilePath, gstr.TrimLeft(content)); err != nil { @@ -162,3 +164,64 @@ func (c *controllerGenerator) doGenerateCtrlItem(dstModuleFolderPath string, ite mlog.Printf(`generated: %s`, methodFilePath) return } + +// use -merge +func (c *controllerGenerator) doGenerateCtrlMergeItem(dstModuleFolderPath string, apiItems []apiItem, doneApiSet *gset.StrSet) (err error) { + + type controllerFileItem struct { + module string + version string + importPath string + // Each ctrlFileItem has multiple CTRLs + controllers strings.Builder + } + // It is possible that there are multiple files under one module + ctrlFileItemMap := make(map[string]*controllerFileItem) + + for _, api := range apiItems { + ctrlFileItem, found := ctrlFileItemMap[api.FileName] + if !found { + ctrlFileItem = &controllerFileItem{ + module: api.Module, + version: api.Version, + controllers: strings.Builder{}, + importPath: api.Import, + } + ctrlFileItemMap[api.FileName] = ctrlFileItem + } + + ctrl := gstr.TrimLeft(gstr.ReplaceByMap(consts.TemplateGenCtrlControllerMethodFuncMerge, g.MapStrStr{ + "{Module}": api.Module, + "{CtrlName}": fmt.Sprintf(`Controller%s`, gstr.UcFirst(api.Version)), + "{Version}": api.Version, + "{MethodName}": api.MethodName, + })) + ctrlFileItem.controllers.WriteString(ctrl) + doneApiSet.Add(api.String()) + } + + for ctrlFileName, ctrlFileItem := range ctrlFileItemMap { + ctrlFilePath := gfile.Join(dstModuleFolderPath, fmt.Sprintf( + `%s_%s_%s.go`, ctrlFileItem.module, ctrlFileItem.version, ctrlFileName, + )) + + // This logic is only followed when a new ctrlFileItem is generated + // Most of the rest of the time, the following logic is followed + if !gfile.Exists(ctrlFilePath) { + ctrlFileHeader := gstr.TrimLeft(gstr.ReplaceByMap(consts.TemplateGenCtrlControllerHeader, g.MapStrStr{ + "{Module}": ctrlFileItem.module, + "{ImportPath}": ctrlFileItem.importPath, + })) + err = gfile.PutContents(ctrlFilePath, ctrlFileHeader) + if err != nil { + return err + } + } + + if err = gfile.PutContentsAppend(ctrlFilePath, ctrlFileItem.controllers.String()); err != nil { + return err + } + mlog.Printf(`generated: %s`, ctrlFilePath) + } + return +} diff --git a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_ctrl_clear.go b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_ctrl_clear.go index af59ada..ee63270 100644 --- a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_ctrl_clear.go +++ b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_ctrl_clear.go @@ -10,7 +10,6 @@ import ( "fmt" "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" "hotgo/internal/library/hggen/internal/utility/mlog" ) @@ -36,16 +35,16 @@ func (c *controllerClearer) doClear(dstModuleFolderPath string, item apiItem) (e methodFilePath = gfile.Join(dstModuleFolderPath, fmt.Sprintf( `%s_%s_%s.go`, item.Module, item.Version, methodNameSnake, )) - fileContent = gstr.Trim(gfile.GetContents(methodFilePath)) ) - match, err := gregex.MatchString(`.+?Req.+?Res.+?{([\s\S]+?)}`, fileContent) + + funcs, err := c.getFuncInDst(methodFilePath) if err != nil { return err } - if len(match) > 1 { - implements := gstr.Trim(match[1]) + + if len(funcs) > 1 { // One line. - if !gstr.Contains(implements, "\n") && gstr.Contains(implements, `CodeNotImplemented`) { + if !gstr.Contains(funcs[0], "\n") && gstr.Contains(funcs[0], `CodeNotImplemented`) { mlog.Printf( `remove unimplemented and of no api definitions controller file: %s`, methodFilePath, diff --git a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_sdk.go b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_sdk.go index e4fdbb5..b5d4e49 100644 --- a/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_sdk.go +++ b/server/internal/library/hggen/internal/cmd/genctrl/genctrl_generate_sdk.go @@ -103,6 +103,7 @@ func (c *apiSdkGenerator) doGenerateSdkIClient( // append the import path to current import paths. if !gstr.Contains(fileContent, moduleImportPath) { isDirty = true + // It is without using AST, because it is from a template. fileContent, err = gregex.ReplaceString( `(import \([\s\S]*?)\)`, fmt.Sprintf("$1\t%s\n)", moduleImportPath), @@ -116,6 +117,7 @@ func (c *apiSdkGenerator) doGenerateSdkIClient( // append the function definition to interface definition. if !gstr.Contains(fileContent, interfaceFuncDefinition) { isDirty = true + // It is without using AST, because it is from a template. fileContent, err = gregex.ReplaceString( `(type IClient interface {[\s\S]*?)}`, fmt.Sprintf("$1\t%s\n}", interfaceFuncDefinition), diff --git a/server/internal/library/hggen/internal/cmd/gendao/gendao.go b/server/internal/library/hggen/internal/cmd/gendao/gendao.go index 6605055..cefe31e 100644 --- a/server/internal/library/hggen/internal/cmd/gendao/gendao.go +++ b/server/internal/library/hggen/internal/cmd/gendao/gendao.go @@ -58,6 +58,10 @@ CONFIGURATION SUPPORT import: github.com/shopspring/decimal numeric: type: string + fieldMapping: + table_name.field_name: + type: decimal.Decimal + import: github.com/shopspring/decimal ` CGenDaoBriefPath = `directory path for generated files` CGenDaoBriefLink = `database configuration, the same as the ORM configuration of GoFrame` @@ -81,6 +85,7 @@ CONFIGURATION SUPPORT CGenDaoBriefNoModelComment = `no model comment will be added for each field` CGenDaoBriefClear = `delete all generated go files that do not exist in database` CGenDaoBriefTypeMapping = `custom local type mapping for generated struct attributes relevant to fields of table` + CGenDaoBriefFieldMapping = `custom local type mapping for generated struct attributes relevant to specific fields of table` CGenDaoBriefGroup = ` specifying the configuration group name of database for generated ORM instance, it's not necessary and the default value is "default" @@ -113,6 +118,7 @@ generated json tag case for model struct, cases are as follows: tplVarGroupName = `{TplGroupName}` tplVarDatetimeStr = `{TplDatetimeStr}` tplVarCreatedAtDatetimeStr = `{TplCreatedAtDatetimeStr}` + tplVarPackageName = `{TplPackageName}` ) var ( @@ -162,6 +168,7 @@ func init() { `CGenDaoBriefNoModelComment`: CGenDaoBriefNoModelComment, `CGenDaoBriefClear`: CGenDaoBriefClear, `CGenDaoBriefTypeMapping`: CGenDaoBriefTypeMapping, + `CGenDaoBriefFieldMapping`: CGenDaoBriefFieldMapping, `CGenDaoBriefGroup`: CGenDaoBriefGroup, `CGenDaoBriefJsonCase`: CGenDaoBriefJsonCase, `CGenDaoBriefTplDaoIndexPath`: CGenDaoBriefTplDaoIndexPath, @@ -201,8 +208,9 @@ type ( NoModelComment bool `name:"noModelComment" short:"m" brief:"{CGenDaoBriefNoModelComment}" orphan:"true"` Clear bool `name:"clear" short:"a" brief:"{CGenDaoBriefClear}" orphan:"true"` - TypeMapping map[DBFieldTypeName]CustomAttributeType `name:"typeMapping" short:"y" brief:"{CGenDaoBriefTypeMapping}" orphan:"true"` - genItems *CGenDaoInternalGenItems + TypeMapping map[DBFieldTypeName]CustomAttributeType `name:"typeMapping" short:"y" brief:"{CGenDaoBriefTypeMapping}" orphan:"true"` + FieldMapping map[DBTableFieldName]CustomAttributeType `name:"fieldMapping" short:"fm" brief:"{CGenDaoBriefFieldMapping}" orphan:"true"` + genItems *CGenDaoInternalGenItems } CGenDaoOutput struct{} @@ -212,7 +220,7 @@ type ( TableNames []string NewTableNames []string } - + DBTableFieldName = string DBFieldTypeName = string CustomAttributeType struct { Type string `brief:"custom attribute type name"` @@ -222,7 +230,9 @@ type ( func (c CGenDao) Dao(ctx context.Context, in CGenDaoInput) (out *CGenDaoOutput, err error) { in.genItems = newCGenDaoInternalGenItems() - if g.Cfg().Available(ctx) { + if in.Link != "" { + doGenDaoForArray(ctx, -1, in) + } else if g.Cfg().Available(ctx) { v := g.Cfg().MustGet(ctx, CGenDaoConfig) if v.IsSlice() { for i := 0; i < len(v.Interfaces()); i++ { @@ -244,6 +254,7 @@ func doGenDaoForArray(ctx context.Context, index int, in CGenDaoInput) { if in.genItems == nil { in.genItems = newCGenDaoInternalGenItems() } + var ( err error db gdb.DB @@ -364,7 +375,7 @@ func getImportPartContent(ctx context.Context, source string, isDo bool, appendI } // Check and update imports in go.mod - if appendImports != nil && len(appendImports) > 0 { + if len(appendImports) > 0 { goModPath := utils.GetModPath() if goModPath == "" { mlog.Fatal("go.mod not found in current project") @@ -382,8 +393,9 @@ func getImportPartContent(ctx context.Context, source string, isDo bool, appendI } } if !found { - err = gproc.ShellRun(ctx, `go get `+appendImport) - mlog.Fatalf(`%+v`, err) + if err = gproc.ShellRun(ctx, `go get `+appendImport); err != nil { + mlog.Fatalf(`%+v`, err) + } } packageImportsArray.Append(fmt.Sprintf(`"%s"`, appendImport)) } diff --git a/server/internal/library/hggen/internal/cmd/gendao/gendao_dao.go b/server/internal/library/hggen/internal/cmd/gendao/gendao_dao.go index 5ab1810..bc9d388 100644 --- a/server/internal/library/hggen/internal/cmd/gendao/gendao_dao.go +++ b/server/internal/library/hggen/internal/cmd/gendao/gendao_dao.go @@ -58,8 +58,8 @@ func generateDaoSingle(ctx context.Context, in generateDaoSingleInput) { mlog.Fatalf(`fetching tables fields failed for table "%s": %+v`, in.TableName, err) } var ( - tableNameCamelCase = gstr.CaseCamel(in.NewTableName) - tableNameCamelLowerCase = gstr.CaseCamelLower(in.NewTableName) + tableNameCamelCase = gstr.CaseCamel(strings.ToLower(in.NewTableName)) + tableNameCamelLowerCase = gstr.CaseCamelLower(strings.ToLower(in.NewTableName)) tableNameSnakeCase = gstr.CaseSnake(in.NewTableName) importPrefix = in.ImportPrefix ) @@ -116,6 +116,7 @@ func generateDaoIndex(in generateDaoIndexInput) { tplVarTableName: in.TableName, tplVarTableNameCamelCase: in.TableNameCamelCase, tplVarTableNameCamelLowerCase: in.TableNameCamelLowerCase, + tplVarPackageName: filepath.Base(in.DaoPath), }) indexContent = replaceDefaultVar(in.CGenDaoInternalInput, indexContent) if err := gfile.PutContents(path, strings.TrimSpace(indexContent)); err != nil { @@ -178,7 +179,7 @@ func generateColumnNamesForDao(fieldMap map[string]*gdb.TableField, removeFieldP } array[index] = []string{ - " #" + gstr.CaseCamel(newFiledName) + ":", + " #" + gstr.CaseCamel(strings.ToLower(newFiledName)) + ":", fmt.Sprintf(` #"%s",`, field.Name), } } @@ -218,7 +219,7 @@ func generateColumnDefinitionForDao(fieldMap map[string]*gdb.TableField, removeF newFiledName = gstr.TrimLeftStr(newFiledName, v, 1) } array[index] = []string{ - " #" + gstr.CaseCamel(newFiledName), + " #" + gstr.CaseCamel(strings.ToLower(newFiledName)), " # " + "string", " #" + fmt.Sprintf(`// %s`, comment), } diff --git a/server/internal/library/hggen/internal/cmd/gendao/gendao_do.go b/server/internal/library/hggen/internal/cmd/gendao/gendao_do.go index b72f857..cb1be25 100644 --- a/server/internal/library/hggen/internal/cmd/gendao/gendao_do.go +++ b/server/internal/library/hggen/internal/cmd/gendao/gendao_do.go @@ -40,7 +40,7 @@ func generateDo(ctx context.Context, in CGenDaoInternalInput) { structDefinition, _ = generateStructDefinition(ctx, generateStructDefinitionInput{ CGenDaoInternalInput: in, TableName: tableName, - StructName: gstr.CaseCamel(newTableName), + StructName: gstr.CaseCamel(strings.ToLower(newTableName)), FieldMap: fieldMap, IsDo: true, }) @@ -61,7 +61,7 @@ func generateDo(ctx context.Context, in CGenDaoInternalInput) { ctx, in, tableName, - gstr.CaseCamel(newTableName), + gstr.CaseCamel(strings.ToLower(newTableName)), structDefinition, ) in.genItems.AppendGeneratedFilePath(doFilePath) @@ -85,6 +85,7 @@ func generateDoContent( tplVarPackageImports: getImportPartContent(ctx, structDefine, true, nil), tplVarTableNameCamelCase: tableNameCamelCase, tplVarStructDefine: structDefine, + tplVarPackageName: filepath.Base(in.DoPath), }, ) doContent = replaceDefaultVar(in, doContent) diff --git a/server/internal/library/hggen/internal/cmd/gendao/gendao_entity.go b/server/internal/library/hggen/internal/cmd/gendao/gendao_entity.go index c78e3e7..9062979 100644 --- a/server/internal/library/hggen/internal/cmd/gendao/gendao_entity.go +++ b/server/internal/library/hggen/internal/cmd/gendao/gendao_entity.go @@ -36,7 +36,7 @@ func generateEntity(ctx context.Context, in CGenDaoInternalInput) { structDefinition, appendImports = generateStructDefinition(ctx, generateStructDefinitionInput{ CGenDaoInternalInput: in, TableName: tableName, - StructName: gstr.CaseCamel(newTableName), + StructName: gstr.CaseCamel(strings.ToLower(newTableName)), FieldMap: fieldMap, IsDo: false, }) @@ -44,7 +44,7 @@ func generateEntity(ctx context.Context, in CGenDaoInternalInput) { ctx, in, newTableName, - gstr.CaseCamel(newTableName), + gstr.CaseCamel(strings.ToLower(newTableName)), structDefinition, appendImports, ) @@ -70,6 +70,7 @@ func generateEntityContent( tplVarPackageImports: getImportPartContent(ctx, structDefine, false, appendImports), tplVarTableNameCamelCase: tableNameCamelCase, tplVarStructDefine: structDefine, + tplVarPackageName: filepath.Base(in.EntityPath), }, ) entityContent = replaceDefaultVar(in, entityContent) diff --git a/server/internal/library/hggen/internal/cmd/gendao/gendao_structure.go b/server/internal/library/hggen/internal/cmd/gendao/gendao_structure.go index f6c585e..e9acc8b 100644 --- a/server/internal/library/hggen/internal/cmd/gendao/gendao_structure.go +++ b/server/internal/library/hggen/internal/cmd/gendao/gendao_structure.go @@ -131,8 +131,16 @@ func generateStructFieldDefinition( for _, v := range removeFieldPrefixArray { newFiledName = gstr.TrimLeftStr(newFiledName, v, 1) } + + if in.FieldMapping != nil && len(in.FieldMapping) > 0 { + if typeMapping, ok := in.FieldMapping[fmt.Sprintf("%s.%s", in.TableName, newFiledName)]; ok { + localTypeNameStr = typeMapping.Type + appendImport = typeMapping.Import + } + } + attrLines = []string{ - " #" + gstr.CaseCamel(newFiledName), + " #" + gstr.CaseCamel(strings.ToLower(newFiledName)), " #" + localTypeNameStr, } attrLines = append(attrLines, fmt.Sprintf(` #%sjson:"%s"`, tagKey, jsonTag)) diff --git a/server/internal/library/hggen/internal/cmd/genpbentity/genpbentity.go b/server/internal/library/hggen/internal/cmd/genpbentity/genpbentity.go index 1f598e7..b7088cb 100644 --- a/server/internal/library/hggen/internal/cmd/genpbentity/genpbentity.go +++ b/server/internal/library/hggen/internal/cmd/genpbentity/genpbentity.go @@ -14,6 +14,7 @@ import ( "strings" "github.com/olekukonko/tablewriter" + "hotgo/internal/library/hggen/internal/utility/utils" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" @@ -176,20 +177,8 @@ func doGenPbEntityForArray(ctx context.Context, index int, in CGenPbEntityInput) } if in.Package == "" { mlog.Debug(`package parameter is empty, trying calculating the package path using go.mod`) - if !gfile.Exists("go.mod") { - mlog.Fatal("go.mod does not exist in current working directory") - } - var ( - modName string - goModContent = gfile.GetContents("go.mod") - match, _ = gregex.MatchString(`^module\s+(.+)\s*`, goModContent) - ) - if len(match) > 1 { - modName = gstr.Trim(match[1]) - in.Package = modName + "/" + defaultPackageSuffix - } else { - mlog.Fatal("module name does not found in go.mod") - } + modName := utils.GetImportPath(gfile.Pwd()) + in.Package = modName + "/" + defaultPackageSuffix } removePrefixArray := gstr.SplitAndTrim(in.RemovePrefix, ",") // It uses user passed database configuration. diff --git a/server/internal/library/hggen/internal/cmd/genservice/genservice.go b/server/internal/library/hggen/internal/cmd/genservice/genservice.go index ff53271..16d0c38 100644 --- a/server/internal/library/hggen/internal/cmd/genservice/genservice.go +++ b/server/internal/library/hggen/internal/cmd/genservice/genservice.go @@ -10,6 +10,8 @@ import ( "context" "fmt" "path/filepath" + "sync" + "sync/atomic" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" @@ -21,7 +23,6 @@ import ( "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gtag" - "hotgo/internal/library/hggen/internal/utility/mlog" "hotgo/internal/library/hggen/internal/utility/utils" ) @@ -147,19 +148,22 @@ func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGe } var ( - isDirty bool // Temp boolean. + isDirty atomic.Value // Temp boolean. files []string // Temp file array. - fileContent string // Temp file content for handling go file. initImportSrcPackages []string // Used for generating logic.go. inputPackages = in.Packages // Custom packages. dstPackageName = gstr.ToLower(gfile.Basename(in.DstFolder)) // Package name for generated go files. generatedDstFilePathSet = gset.NewStrSet() // All generated file path set. ) + isDirty.Store(false) + // The first level folders. srcFolderPaths, err := gfile.ScanDir(in.SrcFolder, "*", false) if err != nil { return nil, err } + // it will use goroutine to generate service files for each package. + var wg = sync.WaitGroup{} for _, srcFolderPath := range srcFolderPaths { if !gfile.IsDir(srcFolderPath) { continue @@ -173,111 +177,30 @@ func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGe } // Parse single logic package folder. var ( - // StructName => FunctionDefinitions - srcPkgInterfaceMap = gmap.NewListMap() - srcImportedPackages = garray.NewSortedStrArray().SetUnique(true) - importAliasToPathMap = gmap.NewStrStrMap() // for conflict imports check. alias => import path(with `"`) - importPathToAliasMap = gmap.NewStrStrMap() // for conflict imports check. import path(with `"`) => alias - srcPackageName = gfile.Basename(srcFolderPath) - ok bool - dstFilePath = gfile.Join(in.DstFolder, + srcPackageName = gfile.Basename(srcFolderPath) + srcImportedPackages = garray.NewSortedStrArray().SetUnique(true) + srcStructFunctions = gmap.NewListMap() + dstFilePath = gfile.Join(in.DstFolder, c.getDstFileNameCase(srcPackageName, in.DstFileNameCase)+".go", ) - srcCodeCommentedMap = make(map[string]string) ) generatedDstFilePathSet.Add(dstFilePath) + // if it were to use goroutine, + // it would cause the order of the generated functions in the file to be disordered. for _, file := range files { - var packageItems []packageItem - fileContent = gfile.GetContents(file) - // Calculate code comments in source Go files. - err = c.calculateCodeCommented(in, fileContent, srcCodeCommentedMap) - if err != nil { - return nil, err - } - // remove all comments. - fileContent, err = gregex.ReplaceString(`(//.*)|((?s)/\*.*?\*/)`, "", fileContent) + pkgItems, funcItems, err := c.parseItemsInSrc(file) if err != nil { return nil, err } - // Calculate imported packages of source go files. - packageItems, err = c.calculateImportedPackages(fileContent) + // Calculate imported packages for service generating. + err = c.calculateImportedItems(in, pkgItems, funcItems, srcImportedPackages) if err != nil { return nil, err } - // try finding the conflicts imports between files. - for _, item := range packageItems { - var alias = item.Alias - if alias == "" { - alias = gfile.Basename(gstr.Trim(item.Path, `"`)) - } - - // ignore unused import paths, which do not exist in function definitions. - if !gregex.IsMatchString(fmt.Sprintf(`func .+?([^\w])%s(\.\w+).+?{`, alias), fileContent) { - mlog.Debugf(`ignore unused package: %s`, item.RawImport) - continue - } - - // find the exist alias with the same import path. - var existAlias = importPathToAliasMap.Get(item.Path) - if existAlias != "" { - fileContent, err = gregex.ReplaceStringFuncMatch( - fmt.Sprintf(`([^\w])%s(\.\w+)`, alias), fileContent, - func(match []string) string { - return match[1] + existAlias + match[2] - }, - ) - if err != nil { - return nil, err - } - continue - } - - // resolve alias conflicts. - var importPath = importAliasToPathMap.Get(alias) - if importPath == "" { - importAliasToPathMap.Set(alias, item.Path) - importPathToAliasMap.Set(item.Path, alias) - srcImportedPackages.Add(item.RawImport) - continue - } - if importPath != item.Path { - // update the conflicted alias for import path with suffix. - // eg: - // v1 -> v10 - // v11 -> v110 - for aliasIndex := 0; ; aliasIndex++ { - item.Alias = fmt.Sprintf(`%s%d`, alias, aliasIndex) - var existPathForAlias = importAliasToPathMap.Get(item.Alias) - if existPathForAlias != "" { - if existPathForAlias == item.Path { - break - } - continue - } - break - } - importPathToAliasMap.Set(item.Path, item.Alias) - importAliasToPathMap.Set(item.Alias, item.Path) - // reformat the import path with alias. - item.RawImport = fmt.Sprintf(`%s %s`, item.Alias, item.Path) - - // update the file content with new alias import. - fileContent, err = gregex.ReplaceStringFuncMatch( - fmt.Sprintf(`([^\w])%s(\.\w+)`, alias), fileContent, - func(match []string) string { - return match[1] + item.Alias + match[2] - }, - ) - if err != nil { - return nil, err - } - srcImportedPackages.Add(item.RawImport) - } - } // Calculate functions and interfaces for service generating. - err = c.calculateInterfaceFunctions(in, fileContent, srcPkgInterfaceMap) + err = c.calculateFuncItems(in, funcItems, srcStructFunctions) if err != nil { return nil, err } @@ -295,22 +218,28 @@ func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGe ) continue } + // Generating service go file for single logic package. - if ok, err = c.generateServiceFile(generateServiceFilesInput{ + wg.Add(1) + go func(generateServiceFilesInput generateServiceFilesInput) { + defer wg.Done() + ok, err := c.generateServiceFile(generateServiceFilesInput) + if err != nil { + mlog.Printf(`error generating service file "%s": %v`, generateServiceFilesInput.DstFilePath, err) + } + if !isDirty.Load().(bool) && ok { + isDirty.Store(true) + } + }(generateServiceFilesInput{ CGenServiceInput: in, - SrcStructFunctions: srcPkgInterfaceMap, - SrcImportedPackages: srcImportedPackages.Slice(), SrcPackageName: srcPackageName, + SrcImportedPackages: srcImportedPackages.Slice(), + SrcStructFunctions: srcStructFunctions, DstPackageName: dstPackageName, DstFilePath: dstFilePath, - SrcCodeCommentedMap: srcCodeCommentedMap, - }); err != nil { - return - } - if ok { - isDirty = true - } + }) } + wg.Wait() if in.Clear { files, err = gfile.ScanDirFile(in.DstFolder, "*.go", false) @@ -320,7 +249,9 @@ func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGe var relativeFilePath string for _, file := range files { relativeFilePath = gstr.SubStrFromR(file, in.DstFolder) - if !generatedDstFilePathSet.Contains(relativeFilePath) && utils.IsFileDoNotEdit(relativeFilePath) { + if !generatedDstFilePathSet.Contains(relativeFilePath) && + utils.IsFileDoNotEdit(relativeFilePath) { + mlog.Printf(`remove no longer used service file: %s`, relativeFilePath) if err = gfile.Remove(file); err != nil { return nil, err @@ -329,7 +260,7 @@ func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGe } } - if isDirty { + if isDirty.Load().(bool) { // Generate initialization go file. if len(initImportSrcPackages) > 0 { if err = c.generateInitializationFile(in, initImportSrcPackages); err != nil { diff --git a/server/internal/library/hggen/internal/cmd/genservice/genservice_ast_parse.go b/server/internal/library/hggen/internal/cmd/genservice/genservice_ast_parse.go new file mode 100644 index 0000000..6a7785f --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/genservice/genservice_ast_parse.go @@ -0,0 +1,186 @@ +// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package genservice + +import ( + "go/ast" + "go/parser" + "go/token" + + "github.com/gogf/gf/v2/os/gfile" +) + +type pkgItem struct { + Alias string `eg:"gdbas"` + Path string `eg:"github.com/gogf/gf/v2/database/gdb"` + RawImport string `eg:"gdbas github.com/gogf/gf/v2/database/gdb"` +} + +type funcItem struct { + Receiver string `eg:"sUser"` + MethodName string `eg:"GetList"` + Params []map[string]string `eg:"ctx: context.Context, cond: *SearchInput"` + Results []map[string]string `eg:"list: []*User, err: error"` + Comment string `eg:"Get user list"` +} + +// parseItemsInSrc parses the pkgItem and funcItem from the specified file. +// It can't skip the private methods. +// It can't skip the imported packages of import alias equal to `_`. +func (c CGenService) parseItemsInSrc(filePath string) (pkgItems []pkgItem, funcItems []funcItem, err error) { + var ( + fileContent = gfile.GetContents(filePath) + fileSet = token.NewFileSet() + ) + + node, err := parser.ParseFile(fileSet, "", fileContent, parser.ParseComments) + if err != nil { + return + } + + ast.Inspect(node, func(n ast.Node) bool { + switch x := n.(type) { + case *ast.ImportSpec: + // parse the imported packages. + pkgItems = append(pkgItems, c.parseImportPackages(x)) + + case *ast.FuncDecl: + // parse the function items. + if x.Recv == nil { + return true + } + + var funcName = x.Name.Name + funcItems = append(funcItems, funcItem{ + Receiver: c.parseFuncReceiverTypeName(x), + MethodName: funcName, + Params: c.parseFuncParams(x), + Results: c.parseFuncResults(x), + Comment: c.parseFuncComment(x), + }) + } + return true + }) + return +} + +// parseImportPackages retrieves the imported packages from the specified ast.ImportSpec. +func (c CGenService) parseImportPackages(node *ast.ImportSpec) (packages pkgItem) { + if node.Path == nil { + return + } + var ( + alias string + path = node.Path.Value + rawImport string + ) + if node.Name != nil { + alias = node.Name.Name + rawImport = alias + " " + path + } else { + rawImport = path + } + return pkgItem{ + Alias: alias, + Path: path, + RawImport: rawImport, + } +} + +// parseFuncReceiverTypeName retrieves the receiver type of the function. +// For example: +// +// func(s *sArticle) -> *sArticle +// func(s sArticle) -> sArticle +func (c CGenService) parseFuncReceiverTypeName(node *ast.FuncDecl) (receiverType string) { + if node.Recv == nil { + return "" + } + receiverType, err := c.astExprToString(node.Recv.List[0].Type) + if err != nil { + return "" + } + return +} + +// parseFuncParams retrieves the input parameters of the function. +// It returns the name and type of the input parameters. +// For example: +// +// []map[string]string{paramName:ctx paramType:context.Context, paramName:info paramType:struct{}} +func (c CGenService) parseFuncParams(node *ast.FuncDecl) (params []map[string]string) { + if node.Type.Params == nil { + return + } + for _, param := range node.Type.Params.List { + if param.Names == nil { + // No name for the return value. + resultType, err := c.astExprToString(param.Type) + if err != nil { + continue + } + params = append(params, map[string]string{ + "paramName": "", + "paramType": resultType, + }) + continue + } + for _, name := range param.Names { + paramType, err := c.astExprToString(param.Type) + if err != nil { + continue + } + params = append(params, map[string]string{ + "paramName": name.Name, + "paramType": paramType, + }) + } + } + return +} + +// parseFuncResults retrieves the output parameters of the function. +// It returns the name and type of the output parameters. +// For example: +// +// []map[string]string{resultName:list resultType:[]*User, resultName:err resultType:error} +// []map[string]string{resultName: "", resultType: error} +func (c CGenService) parseFuncResults(node *ast.FuncDecl) (results []map[string]string) { + if node.Type.Results == nil { + return + } + for _, result := range node.Type.Results.List { + if result.Names == nil { + // No name for the return value. + resultType, err := c.astExprToString(result.Type) + if err != nil { + continue + } + results = append(results, map[string]string{ + "resultName": "", + "resultType": resultType, + }) + continue + } + for _, name := range result.Names { + resultType, err := c.astExprToString(result.Type) + if err != nil { + continue + } + results = append(results, map[string]string{ + "resultName": name.Name, + "resultType": resultType, + }) + } + } + return +} + +// parseFuncComment retrieves the comment of the function. +func (c CGenService) parseFuncComment(node *ast.FuncDecl) string { + return c.astCommentToString(node.Doc) +} diff --git a/server/internal/library/hggen/internal/cmd/genservice/genservice_ast_utils.go b/server/internal/library/hggen/internal/cmd/genservice/genservice_ast_utils.go new file mode 100644 index 0000000..8fc12e2 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/genservice/genservice_ast_utils.go @@ -0,0 +1,48 @@ +// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package genservice + +import ( + "bytes" + "go/ast" + "go/format" + "go/token" + "strings" +) + +// exprToString converts ast.Expr to string. +// For example: +// +// ast.Expr -> "context.Context" +// ast.Expr -> "*v1.XxxReq" +// ast.Expr -> "error" +// ast.Expr -> "int" +func (c CGenService) astExprToString(expr ast.Expr) (string, error) { + var ( + buf bytes.Buffer + err error + ) + err = format.Node(&buf, token.NewFileSet(), expr) + if err != nil { + return "", err + } + return buf.String(), nil +} + +// astCommentToString returns the raw (original) text of the comment. +// It includes the comment markers (//, /*, and */). +// It adds a newline at the end of the comment. +func (c CGenService) astCommentToString(node *ast.CommentGroup) string { + if node == nil { + return "" + } + var b strings.Builder + for _, c := range node.List { + b.WriteString(c.Text + "\n") + } + return b.String() +} diff --git a/server/internal/library/hggen/internal/cmd/genservice/genservice_calculate.go b/server/internal/library/hggen/internal/cmd/genservice/genservice_calculate.go index 4312a6b..95b42da 100644 --- a/server/internal/library/hggen/internal/cmd/genservice/genservice_calculate.go +++ b/server/internal/library/hggen/internal/cmd/genservice/genservice_calculate.go @@ -8,168 +8,145 @@ package genservice import ( "fmt" - "go/parser" - "go/token" + "strings" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + "hotgo/internal/library/hggen/internal/utility/mlog" ) -type packageItem struct { - Alias string - Path string - RawImport string -} - -func (c CGenService) calculateImportedPackages(fileContent string) (packages []packageItem, err error) { - f, err := parser.ParseFile(token.NewFileSet(), "", fileContent, parser.ImportsOnly) - if err != nil { - return nil, err - } - packages = make([]packageItem, 0) - for _, s := range f.Imports { - if s.Path != nil { - if s.Name != nil { - // If it has alias, and it is not `_`. - if pkgAlias := s.Name.String(); pkgAlias != "_" { - packages = append(packages, packageItem{ - Alias: pkgAlias, - Path: s.Path.Value, - RawImport: pkgAlias + " " + s.Path.Value, - }) - } - } else { - // no alias - packages = append(packages, packageItem{ - Alias: "", - Path: s.Path.Value, - RawImport: s.Path.Value, - }) - } - } - } - return packages, nil -} - -func (c CGenService) calculateCodeCommented(in CGenServiceInput, fileContent string, srcCodeCommentedMap map[string]string) error { - matches, err := gregex.MatchAllString(`((((//.*)|(/\*[\s\S]*?\*/))\s)+)func \((.+?)\) ([\s\S]+?) {`, fileContent) - if err != nil { - return err - } - for _, match := range matches { - var ( - structName string - structMatch []string - funcReceiver = gstr.Trim(match[1+5]) - receiverArray = gstr.SplitAndTrim(funcReceiver, " ") - functionHead = gstr.Trim(gstr.Replace(match[2+5], "\n", "")) - commentedInfo = "" - ) - if len(receiverArray) > 1 { - structName = receiverArray[1] - } else if len(receiverArray) == 1 { - structName = receiverArray[0] - } - structName = gstr.Trim(structName, "*") - - // Case of: - // Xxx(\n ctx context.Context, req *v1.XxxReq,\n) -> Xxx(ctx context.Context, req *v1.XxxReq) - functionHead = gstr.Replace(functionHead, `,)`, `)`) - functionHead, _ = gregex.ReplaceString(`\(\s+`, `(`, functionHead) - functionHead, _ = gregex.ReplaceString(`\s{2,}`, ` `, functionHead) - if !gstr.IsLetterUpper(functionHead[0]) { - continue - } - // Match and pick the struct name from receiver. - if structMatch, err = gregex.MatchString(in.StPattern, structName); err != nil { - return err - } - if len(structMatch) < 1 { - continue - } - structName = gstr.CaseCamel(structMatch[1]) - - commentedInfo = match[1] - if len(commentedInfo) > 0 { - srcCodeCommentedMap[fmt.Sprintf("%s-%s", structName, functionHead)] = commentedInfo - } - } - return nil -} - -func (c CGenService) calculateInterfaceFunctions( - in CGenServiceInput, fileContent string, srcPkgInterfaceMap *gmap.ListMap, +func (c CGenService) calculateImportedItems( + in CGenServiceInput, + pkgItems []pkgItem, funcItems []funcItem, + srcImportedPackages *garray.SortedStrArray, ) (err error) { - var ( - matches [][]string - srcPkgInterfaceFuncArray *garray.StrArray - ) - // calculate struct name and its functions according function definitions. - matches, err = gregex.MatchAllString(`func \((.+?)\) ([\s\S]+?) {`, fileContent) - if err != nil { - return err - } - for _, match := range matches { - var ( - structName string - structMatch []string - funcReceiver = gstr.Trim(match[1]) - receiverArray = gstr.SplitAndTrim(funcReceiver, " ") - functionHead = gstr.Trim(gstr.Replace(match[2], "\n", "")) - ) - if len(receiverArray) > 1 { - structName = receiverArray[1] - } else if len(receiverArray) == 1 { - structName = receiverArray[0] - } - structName = gstr.Trim(structName, "*") + // allFuncParamType saves all the param and result types of the functions. + var allFuncParamType strings.Builder - // Case of: - // Xxx(\n ctx context.Context, req *v1.XxxReq,\n) -> Xxx(ctx context.Context, req *v1.XxxReq) - functionHead = gstr.Replace(functionHead, `,)`, `)`) - functionHead, _ = gregex.ReplaceString(`\(\s+`, `(`, functionHead) - functionHead, _ = gregex.ReplaceString(`\s{2,}`, ` `, functionHead) - if !gstr.IsLetterUpper(functionHead[0]) { - continue + for _, item := range funcItems { + for _, param := range item.Params { + allFuncParamType.WriteString(param["paramType"] + ",") } - // Match and pick the struct name from receiver. - if structMatch, err = gregex.MatchString(in.StPattern, structName); err != nil { - return err + for _, result := range item.Results { + allFuncParamType.WriteString(result["resultType"] + ",") } - if len(structMatch) < 1 { - continue - } - structName = gstr.CaseCamel(structMatch[1]) - if !srcPkgInterfaceMap.Contains(structName) { - srcPkgInterfaceFuncArray = garray.NewStrArray() - srcPkgInterfaceMap.Set(structName, srcPkgInterfaceFuncArray) - } else { - srcPkgInterfaceFuncArray = srcPkgInterfaceMap.Get(structName).(*garray.StrArray) - } - srcPkgInterfaceFuncArray.Append(functionHead) } - // calculate struct name according type definitions. - matches, err = gregex.MatchAllString(`type (.+) struct\s*{`, fileContent) - if err != nil { - return err - } - for _, match := range matches { - var ( - structName string - structMatch []string - ) - if structMatch, err = gregex.MatchString(in.StPattern, match[1]); err != nil { - return err - } - if len(structMatch) < 1 { + + for _, item := range pkgItems { + alias := item.Alias + + // If the alias is _, it means that the package is not generated. + if alias == "_" { + mlog.Debugf(`ignore anonymous package: %s`, item.RawImport) continue } - structName = gstr.CaseCamel(structMatch[1]) - if !srcPkgInterfaceMap.Contains(structName) { - srcPkgInterfaceMap.Set(structName, garray.NewStrArray()) + // If the alias is empty, it will use the package name as the alias. + if alias == "" { + alias = gfile.Basename(gstr.Trim(item.Path, `"`)) } + if !gstr.Contains(allFuncParamType.String(), alias) { + mlog.Debugf(`ignore unused package: %s`, item.RawImport) + continue + } + srcImportedPackages.Add(item.RawImport) } return nil } + +func (c CGenService) calculateFuncItems( + in CGenServiceInput, + funcItems []funcItem, + srcPkgInterfaceMap *gmap.ListMap, +) (err error) { + var srcPkgInterfaceFunc []map[string]string + + for _, item := range funcItems { + var ( + // eg: "sArticle" + receiverName string + receiverMatch []string + + // eg: "GetList(ctx context.Context, req *v1.ArticleListReq) (list []*v1.Article, err error)" + funcHead string + ) + + // handle the receiver name. + if item.Receiver == "" { + continue + } + receiverName = item.Receiver + receiverName = gstr.Trim(receiverName, "*") + // Match and pick the struct name from receiver. + if receiverMatch, err = gregex.MatchString(in.StPattern, receiverName); err != nil { + return err + } + if len(receiverMatch) < 1 { + continue + } + receiverName = gstr.CaseCamel(receiverMatch[1]) + + // check if the func name is public. + if !gstr.IsLetterUpper(item.MethodName[0]) { + continue + } + + if !srcPkgInterfaceMap.Contains(receiverName) { + srcPkgInterfaceFunc = make([]map[string]string, 0) + srcPkgInterfaceMap.Set(receiverName, srcPkgInterfaceFunc) + } else { + srcPkgInterfaceFunc = srcPkgInterfaceMap.Get(receiverName).([]map[string]string) + } + + // make the func head. + paramsStr := c.tidyParam(item.Params) + resultsStr := c.tidyResult(item.Results) + funcHead = fmt.Sprintf("%s(%s) (%s)", item.MethodName, paramsStr, resultsStr) + + srcPkgInterfaceFunc = append(srcPkgInterfaceFunc, map[string]string{ + "funcHead": funcHead, + "funcComment": item.Comment, + }) + srcPkgInterfaceMap.Set(receiverName, srcPkgInterfaceFunc) + } + return nil +} + +// tidyParam tidies the input parameters. +// For example: +// +// []map[string]string{paramName:ctx paramType:context.Context, paramName:info paramType:struct{}} +// -> ctx context.Context, info struct{} +func (c CGenService) tidyParam(paramSlice []map[string]string) (paramStr string) { + for i, param := range paramSlice { + if i > 0 { + paramStr += ", " + } + paramStr += fmt.Sprintf("%s %s", param["paramName"], param["paramType"]) + } + return +} + +// tidyResult tidies the output parameters. +// For example: +// +// []map[string]string{resultName:list resultType:[]*User, resultName:err resultType:error} +// -> list []*User, err error +// +// []map[string]string{resultName: "", resultType: error} +// -> error +func (c CGenService) tidyResult(resultSlice []map[string]string) (resultStr string) { + for i, result := range resultSlice { + if i > 0 { + resultStr += ", " + } + if result["resultName"] != "" { + resultStr += fmt.Sprintf("%s %s", result["resultName"], result["resultType"]) + } else { + resultStr += result["resultType"] + } + } + return +} diff --git a/server/internal/library/hggen/internal/cmd/genservice/genservice_generate.go b/server/internal/library/hggen/internal/cmd/genservice/genservice_generate.go index ca2b75a..8b50bc7 100644 --- a/server/internal/library/hggen/internal/cmd/genservice/genservice_generate.go +++ b/server/internal/library/hggen/internal/cmd/genservice/genservice_generate.go @@ -7,15 +7,13 @@ package genservice import ( + "bytes" "fmt" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" - "hotgo/internal/library/hggen/internal/consts" "hotgo/internal/library/hggen/internal/utility/mlog" "hotgo/internal/library/hggen/internal/utility/utils" @@ -23,96 +21,20 @@ import ( type generateServiceFilesInput struct { CGenServiceInput - DstFilePath string // Absolute file path for generated service go file. - SrcStructFunctions *gmap.ListMap - SrcImportedPackages []string SrcPackageName string + SrcImportedPackages []string + SrcStructFunctions *gmap.ListMap DstPackageName string - SrcCodeCommentedMap map[string]string + DstFilePath string // Absolute file path for generated service go file. } func (c CGenService) generateServiceFile(in generateServiceFilesInput) (ok bool, err error) { - var ( - generatedContent string - allFuncArray = garray.NewStrArray() // Used for check whether interface dirty, going to change file content. - importedPackagesContent = fmt.Sprintf( - "import (\n%s\n)", gstr.Join(in.SrcImportedPackages, "\n"), - ) - ) - generatedContent += gstr.ReplaceByMap(consts.TemplateGenServiceContentHead, g.MapStrStr{ - "{Imports}": importedPackagesContent, - "{PackageName}": in.DstPackageName, - }) + var generatedContent bytes.Buffer - // Type definitions. - generatedContent += "type(" - generatedContent += "\n" - in.SrcStructFunctions.Iterator(func(key, value interface{}) bool { - structName, funcArray := key.(string), value.(*garray.StrArray) - allFuncArray.Append(funcArray.Slice()...) - // Add comments to a method. - for index, funcName := range funcArray.Slice() { - if commentedInfo, exist := in.SrcCodeCommentedMap[fmt.Sprintf("%s-%s", structName, funcName)]; exist { - funcName = commentedInfo + funcName - _ = funcArray.Set(index, funcName) - } - } - generatedContent += gstr.Trim(gstr.ReplaceByMap(consts.TemplateGenServiceContentInterface, g.MapStrStr{ - "{InterfaceName}": "I" + structName, - "{FuncDefinition}": funcArray.Join("\n\t"), - })) - generatedContent += "\n" - return true - }) - generatedContent += ")" - generatedContent += "\n" - - // Generating variable and register definitions. - var ( - variableContent string - generatingInterfaceCheck string - ) - // Variable definitions. - in.SrcStructFunctions.Iterator(func(key, value interface{}) bool { - structName := key.(string) - generatingInterfaceCheck = fmt.Sprintf(`[^\w\d]+%s.I%s[^\w\d]`, in.DstPackageName, structName) - if gregex.IsMatchString(generatingInterfaceCheck, generatedContent) { - return true - } - variableContent += gstr.Trim(gstr.ReplaceByMap(consts.TemplateGenServiceContentVariable, g.MapStrStr{ - "{StructName}": structName, - "{InterfaceName}": "I" + structName, - })) - variableContent += "\n" - return true - }) - if variableContent != "" { - generatedContent += "var(" - generatedContent += "\n" - generatedContent += variableContent - generatedContent += ")" - generatedContent += "\n" - } - // Variable register function definitions. - in.SrcStructFunctions.Iterator(func(key, value interface{}) bool { - structName := key.(string) - generatingInterfaceCheck = fmt.Sprintf(`[^\w\d]+%s.I%s[^\w\d]`, in.DstPackageName, structName) - if gregex.IsMatchString(generatingInterfaceCheck, generatedContent) { - return true - } - generatedContent += gstr.Trim(gstr.ReplaceByMap(consts.TemplateGenServiceContentRegister, g.MapStrStr{ - "{StructName}": structName, - "{InterfaceName}": "I" + structName, - })) - generatedContent += "\n\n" - return true - }) - - // Replace empty braces that have new line. - generatedContent, _ = gregex.ReplaceString(`{[\s\t]+}`, `{}`, generatedContent) - - // Remove package name calls of `dstPackageName` in produced codes. - generatedContent, _ = gregex.ReplaceString(fmt.Sprintf(`\*{0,1}%s\.`, in.DstPackageName), ``, generatedContent) + c.generatePackageImports(&generatedContent, in.DstPackageName, in.SrcImportedPackages) + c.generateType(&generatedContent, in.SrcStructFunctions, in.DstPackageName) + c.generateVar(&generatedContent, in.SrcStructFunctions) + c.generateFunc(&generatedContent, in.SrcStructFunctions) // Write file content to disk. if gfile.Exists(in.DstFilePath) { @@ -120,59 +42,14 @@ func (c CGenService) generateServiceFile(in generateServiceFilesInput) (ok bool, mlog.Printf(`ignore file as it is manually maintained: %s`, in.DstFilePath) return false, nil } - if !c.isToGenerateServiceGoFile(in.DstPackageName, in.DstFilePath, allFuncArray) { - mlog.Printf(`not dirty, ignore generating service go file: %s`, in.DstFilePath) - return false, nil - } } mlog.Printf(`generating service go file: %s`, in.DstFilePath) - if err = gfile.PutContents(in.DstFilePath, generatedContent); err != nil { + if err = gfile.PutBytes(in.DstFilePath, generatedContent.Bytes()); err != nil { return true, err } return true, nil } -// isToGenerateServiceGoFile checks and returns whether the service content dirty. -func (c CGenService) isToGenerateServiceGoFile(dstPackageName, filePath string, funcArray *garray.StrArray) bool { - var ( - err error - fileContent = gfile.GetContents(filePath) - generatedFuncArray = garray.NewSortedStrArrayFrom(funcArray.Slice()) - contentFuncArray = garray.NewSortedStrArray() - ) - if fileContent == "" { - return true - } - // remove all comments. - fileContent, err = gregex.ReplaceString(`(//.*)|((?s)/\*.*?\*/)`, "", fileContent) - if err != nil { - panic(err) - return false - } - matches, _ := gregex.MatchAllString(`\s+interface\s+{([\s\S]+?)}`, fileContent) - for _, match := range matches { - contentFuncArray.Append(gstr.SplitAndTrim(match[1], "\n")...) - } - if generatedFuncArray.Len() != contentFuncArray.Len() { - mlog.Debugf( - `dirty, generatedFuncArray.Len()[%d] != contentFuncArray.Len()[%d]`, - generatedFuncArray.Len(), contentFuncArray.Len(), - ) - return true - } - var funcDefinition string - for i := 0; i < generatedFuncArray.Len(); i++ { - funcDefinition, _ = gregex.ReplaceString( - fmt.Sprintf(`\*{0,1}%s\.`, dstPackageName), ``, generatedFuncArray.At(i), - ) - if funcDefinition != contentFuncArray.At(i) { - mlog.Debugf(`dirty, %s != %s`, funcDefinition, contentFuncArray.At(i)) - return true - } - } - return false -} - // generateInitializationFile generates `logic.go`. func (c CGenService) generateInitializationFile(in CGenServiceInput, importSrcPackages []string) (err error) { var ( diff --git a/server/internal/library/hggen/internal/cmd/genservice/genservice_generate_template.go b/server/internal/library/hggen/internal/cmd/genservice/genservice_generate_template.go new file mode 100644 index 0000000..0e384cf --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/genservice/genservice_generate_template.go @@ -0,0 +1,104 @@ +// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package genservice + +import ( + "bytes" + "fmt" + + "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" + "hotgo/internal/library/hggen/internal/consts" +) + +func (c CGenService) generatePackageImports(generatedContent *bytes.Buffer, packageName string, imports []string) { + generatedContent.WriteString(gstr.ReplaceByMap(consts.TemplateGenServiceContentHead, g.MapStrStr{ + "{PackageName}": packageName, + "{Imports}": fmt.Sprintf( + "import (\n%s\n)", gstr.Join(imports, "\n"), + ), + })) +} + +// generateType type definitions. +// See: const.TemplateGenServiceContentInterface +func (c CGenService) generateType(generatedContent *bytes.Buffer, srcStructFunctions *gmap.ListMap, dstPackageName string) { + generatedContent.WriteString("type(") + generatedContent.WriteString("\n") + + srcStructFunctions.Iterator(func(key, value interface{}) bool { + var ( + funcContents = make([]string, 0) + funcContent string + ) + structName, funcSlice := key.(string), value.([]map[string]string) + // Generating interface content. + for _, funcInfo := range funcSlice { + // Remove package name calls of `dstPackageName` in produced codes. + funcHead, _ := gregex.ReplaceString( + fmt.Sprintf(`\*{0,1}%s\.`, dstPackageName), + ``, funcInfo["funcHead"], + ) + funcContent = funcInfo["funcComment"] + funcHead + funcContents = append(funcContents, funcContent) + } + + // funcContents to string. + generatedContent.WriteString( + gstr.Trim(gstr.ReplaceByMap(consts.TemplateGenServiceContentInterface, g.MapStrStr{ + "{InterfaceName}": "I" + structName, + "{FuncDefinition}": gstr.Join(funcContents, "\n\t"), + })), + ) + generatedContent.WriteString("\n") + return true + }) + + generatedContent.WriteString(")") + generatedContent.WriteString("\n") +} + +// generateVar variable definitions. +// See: const.TemplateGenServiceContentVariable +func (c CGenService) generateVar(generatedContent *bytes.Buffer, srcStructFunctions *gmap.ListMap) { + // Generating variable and register definitions. + var variableContent string + + srcStructFunctions.Iterator(func(key, value interface{}) bool { + structName := key.(string) + variableContent += gstr.Trim(gstr.ReplaceByMap(consts.TemplateGenServiceContentVariable, g.MapStrStr{ + "{StructName}": structName, + "{InterfaceName}": "I" + structName, + })) + variableContent += "\n" + return true + }) + if variableContent != "" { + generatedContent.WriteString("var(") + generatedContent.WriteString("\n") + generatedContent.WriteString(variableContent) + generatedContent.WriteString(")") + generatedContent.WriteString("\n") + } +} + +// generateFunc function definitions. +// See: const.TemplateGenServiceContentRegister +func (c CGenService) generateFunc(generatedContent *bytes.Buffer, srcStructFunctions *gmap.ListMap) { + // Variable register function definitions. + srcStructFunctions.Iterator(func(key, value interface{}) bool { + structName := key.(string) + generatedContent.WriteString(gstr.Trim(gstr.ReplaceByMap(consts.TemplateGenServiceContentRegister, g.MapStrStr{ + "{StructName}": structName, + "{InterfaceName}": "I" + structName, + }))) + generatedContent.WriteString("\n\n") + return true + }) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/build/multiple/multiple.go b/server/internal/library/hggen/internal/cmd/testdata/build/multiple/multiple.go new file mode 100644 index 0000000..7905807 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/build/multiple/multiple.go @@ -0,0 +1,5 @@ +package main + +func main() { + +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/build/single/main.go b/server/internal/library/hggen/internal/cmd/testdata/build/single/main.go new file mode 100644 index 0000000..7905807 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/build/single/main.go @@ -0,0 +1,5 @@ +package main + +func main() { + +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/build/varmap/go.mod b/server/internal/library/hggen/internal/cmd/testdata/build/varmap/go.mod new file mode 100644 index 0000000..7457292 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/build/varmap/go.mod @@ -0,0 +1,12 @@ +module github.com/gogf/gf/cmd/gf/cmd/gf/testdata/vardump/v2 + +go 1.18 + +require github.com/gogf/gf/v2 v2.6.1 + +require ( + go.opentelemetry.io/otel v1.14.0 // indirect + go.opentelemetry.io/otel/trace v1.14.0 // indirect +) + +replace github.com/gogf/gf/v2 => ../../../../../../../ diff --git a/server/internal/library/hggen/internal/cmd/testdata/build/varmap/go.sum b/server/internal/library/hggen/internal/cmd/testdata/build/varmap/go.sum new file mode 100644 index 0000000..4e5a51b --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/build/varmap/go.sum @@ -0,0 +1,27 @@ +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= +go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= +go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY= +go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= +go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/server/internal/library/hggen/internal/cmd/testdata/build/varmap/main.go b/server/internal/library/hggen/internal/cmd/testdata/build/varmap/main.go new file mode 100644 index 0000000..788a885 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/build/varmap/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + + "github.com/gogf/gf/v2/os/gbuild" +) + +func main() { + for k, v := range gbuild.Data() { + fmt.Printf("%s: %v\n", k, v) + } +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/fix/fix25_content.go b/server/internal/library/hggen/internal/cmd/testdata/fix/fix25_content.go new file mode 100644 index 0000000..934ebd2 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/fix/fix25_content.go @@ -0,0 +1,30 @@ +package testdata + +import ( + "fmt" + "testing" + "time" + + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/guid" +) + +func Test_Router_Hook_Multi(t *testing.T) { + s := g.Server(guid.S()) + s.BindHandler("/multi-hook", func(r *ghttp.Request) { + r.Response.Write("show") + }) + + s.BindHookHandlerByMap("/multi-hook", map[string]ghttp.HandlerFunc{ + ghttp.HookBeforeServe: func(r *ghttp.Request) { + r.Response.Write("1") + }, + }) + s.BindHookHandlerByMap("/multi-hook/{id}", map[string]ghttp.HandlerFunc{ + ghttp.HookBeforeServe: func(r *ghttp.Request) { + r.Response.Write("2") + }, + }) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/dict_add_new_ctrl_expect.gotest b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/dict_add_new_ctrl_expect.gotest new file mode 100644 index 0000000..fbe3e59 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/dict_add_new_ctrl_expect.gotest @@ -0,0 +1,17 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package dict + +import ( + "context" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/v1" +) + +type IDictV1 interface { + DictTypeAddPage(ctx context.Context, req *v1.DictTypeAddPageReq) (res *v1.DictTypeAddPageRes, err error) + DictTypeAdd(ctx context.Context, req *v1.DictTypeAddReq) (res *v1.DictTypeAddRes, err error) +} + diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/dict_expect.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/dict_expect.go new file mode 100644 index 0000000..bcfaad0 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/dict_expect.go @@ -0,0 +1,15 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package dict + +import ( + "context" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/v1" +) + +type IDictV1 interface { + DictTypeAddPage(ctx context.Context, req *v1.DictTypeAddPageReq) (res *v1.DictTypeAddPageRes, err error) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/v1/dict_type.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/v1/dict_type.go new file mode 100644 index 0000000..459ced8 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/v1/dict_type.go @@ -0,0 +1,17 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package v1 + +import "github.com/gogf/gf/v2/frame/g" + +type DictTypeAddPageReq struct { + g.Meta `path:"/dict/type/add" tags:"字典管理" method:"get" summary:"字典类型添加页面"` +} + +type DictTypeAddPageRes struct { + g.Meta `mime:"text/html" type:"string" example:""` +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict.go new file mode 100644 index 0000000..b280a53 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict.go @@ -0,0 +1,5 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dict diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_new.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_new.go new file mode 100644 index 0000000..2174be5 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_new.go @@ -0,0 +1,15 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dict + +import ( + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict" +) + +type ControllerV1 struct{} + +func NewV1() dict.IDictV1 { + return &ControllerV1{} +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_v1_dict_type.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_v1_dict_type.go new file mode 100644 index 0000000..218228e --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_v1_dict_type.go @@ -0,0 +1,14 @@ +package dict + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/v1" +) + +func (c *ControllerV1) DictTypeAddPage(ctx context.Context, req *v1.DictTypeAddPageReq) (res *v1.DictTypeAddPageRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_v1_test_new.gotest b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_v1_test_new.gotest new file mode 100644 index 0000000..5e1a08d --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/controller/dict/dict_v1_test_new.gotest @@ -0,0 +1,17 @@ +package dict + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/v1" +) + +func (c *ControllerV1) DictTypeAddPage(ctx context.Context, req *v1.DictTypeAddPageReq) (res *v1.DictTypeAddPageRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} +func (c *ControllerV1) DictTypeAdd(ctx context.Context, req *v1.DictTypeAddReq) (res *v1.DictTypeAddRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/dict_add_new_ctrl_expect.gotest b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/dict_add_new_ctrl_expect.gotest new file mode 100644 index 0000000..fbe3e59 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/dict_add_new_ctrl_expect.gotest @@ -0,0 +1,17 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package dict + +import ( + "context" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_ctrl/api/dict/v1" +) + +type IDictV1 interface { + DictTypeAddPage(ctx context.Context, req *v1.DictTypeAddPageReq) (res *v1.DictTypeAddPageRes, err error) + DictTypeAdd(ctx context.Context, req *v1.DictTypeAddReq) (res *v1.DictTypeAddRes, err error) +} + diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/dict_expect.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/dict_expect.go new file mode 100644 index 0000000..98f9fdb --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/dict_expect.go @@ -0,0 +1,15 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package dict + +import ( + "context" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/v1" +) + +type IDictV1 interface { + DictTypeAddPage(ctx context.Context, req *v1.DictTypeAddPageReq) (res *v1.DictTypeAddPageRes, err error) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/v1/dict_type.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/v1/dict_type.go new file mode 100644 index 0000000..459ced8 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/v1/dict_type.go @@ -0,0 +1,17 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package v1 + +import "github.com/gogf/gf/v2/frame/g" + +type DictTypeAddPageReq struct { + g.Meta `path:"/dict/type/add" tags:"字典管理" method:"get" summary:"字典类型添加页面"` +} + +type DictTypeAddPageRes struct { + g.Meta `mime:"text/html" type:"string" example:""` +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict.go new file mode 100644 index 0000000..b280a53 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict.go @@ -0,0 +1,5 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dict diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_new.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_new.go new file mode 100644 index 0000000..b715880 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_new.go @@ -0,0 +1,15 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dict + +import ( + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict" +) + +type ControllerV1 struct{} + +func NewV1() dict.IDictV1 { + return &ControllerV1{} +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_v1_dict_type.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_v1_dict_type.go new file mode 100644 index 0000000..229560c --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_v1_dict_type.go @@ -0,0 +1,14 @@ +package dict + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/v1" +) + +func (c *ControllerV1) DictTypeAddPage(ctx context.Context, req *v1.DictTypeAddPageReq) (res *v1.DictTypeAddPageRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_v1_test_new.gotest b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_v1_test_new.gotest new file mode 100644 index 0000000..a6386d7 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/controller/dict/dict_v1_test_new.gotest @@ -0,0 +1,14 @@ +package dict + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl-merge/add_new_file/api/dict/v1" +) + +func (c *ControllerV1) DictTypeAdd(ctx context.Context, req *v1.DictTypeAddReq) (res *v1.DictTypeAddRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/article_expect.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/article_expect.go new file mode 100644 index 0000000..880d81f --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/article_expect.go @@ -0,0 +1,24 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package article + +import ( + "context" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1" + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v2" +) + +type IArticleV1 interface { + Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) + Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) + GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) + GetOne(ctx context.Context, req *v1.GetOneReq) (res *v1.GetOneRes, err error) +} + +type IArticleV2 interface { + Create(ctx context.Context, req *v2.CreateReq) (res *v2.CreateRes, err error) + Update(ctx context.Context, req *v2.UpdateReq) (res *v2.UpdateRes, err error) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1/edit.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1/edit.go new file mode 100644 index 0000000..9e893d8 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1/edit.go @@ -0,0 +1,27 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package v1 + +import "github.com/gogf/gf/v2/frame/g" + +type ( + CreateReq struct { + g.Meta `path:"/article/create" method:"post" tags:"ArticleService"` + Title string `v:"required"` + } + + CreateRes struct{} +) + +type ( + UpdateReq struct { + g.Meta `path:"/article/update" method:"post" tags:"ArticleService"` + Title string `v:"required"` + } + + UpdateRes struct{} +) diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1/get.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1/get.go new file mode 100644 index 0000000..36134f5 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1/get.go @@ -0,0 +1,25 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package v1 + +import "github.com/gogf/gf/v2/frame/g" + +type GetListReq struct { + g.Meta `path:"/article/list" method:"get" tags:"ArticleService"` +} + +type GetListRes struct { + list []struct{} +} + +type GetOneReq struct { + g.Meta `path:"/article/one" method:"get" tags:"ArticleService"` +} + +type GetOneRes struct { + one struct{} +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v2/edit.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v2/edit.go new file mode 100644 index 0000000..2ae2069 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v2/edit.go @@ -0,0 +1,31 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package v2 + +import "github.com/gogf/gf/v2/frame/g" + +type CreateReq struct { + g.Meta `path:"/article/create" method:"post" tags:"ArticleService"` + Title string `v:"required"` +} + +type CreateRes struct{} + +type UpdateReq struct { + g.Meta `path:"/article/update" method:"post" tags:"ArticleService"` + Title string `v:"required"` +} + +type UpdateRes struct{} + +//type GetListReq struct { +// g.Meta `path:"/article/list" method:"get" tags:"ArticleService"` +//} +// +//type GetListRes struct { +// list []struct{} +//} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article.go new file mode 100644 index 0000000..4bd478c --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article.go @@ -0,0 +1,5 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package article diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_new.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_new.go new file mode 100644 index 0000000..c4ac00e --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_new.go @@ -0,0 +1,21 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package article + +import ( + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl/api/article" +) + +type ControllerV1 struct{} + +func NewV1() article.IArticleV1 { + return &ControllerV1{} +} + +type ControllerV2 struct{} + +func NewV2() article.IArticleV2 { + return &ControllerV2{} +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_create.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_create.go new file mode 100644 index 0000000..1b37e99 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_create.go @@ -0,0 +1,14 @@ +package article + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1" +) + +func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_get_list.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_get_list.go new file mode 100644 index 0000000..a0f48e8 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_get_list.go @@ -0,0 +1,14 @@ +package article + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1" +) + +func (c *ControllerV1) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_get_one.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_get_one.go new file mode 100644 index 0000000..e258f06 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_get_one.go @@ -0,0 +1,14 @@ +package article + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1" +) + +func (c *ControllerV1) GetOne(ctx context.Context, req *v1.GetOneReq) (res *v1.GetOneRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_update.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_update.go new file mode 100644 index 0000000..7919aa2 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v1_update.go @@ -0,0 +1,14 @@ +package article + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v1" +) + +func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v2_create.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v2_create.go new file mode 100644 index 0000000..7b435f2 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v2_create.go @@ -0,0 +1,14 @@ +package article + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v2" +) + +func (c *ControllerV2) Create(ctx context.Context, req *v2.CreateReq) (res *v2.CreateRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v2_update.go b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v2_update.go new file mode 100644 index 0000000..e91a6ac --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genctrl/controller/article/article_v2_update.go @@ -0,0 +1,14 @@ +package article + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genctrl/api/article/v2" +) + +func (c *ControllerV2) Update(ctx context.Context, req *v2.UpdateReq) (res *v2.UpdateRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go new file mode 100644 index 0000000..f883408 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// TableUserDao is the data access object for table table_user. +type TableUserDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns TableUserColumns // columns contains all the column names of Table for convenient usage. +} + +// TableUserColumns defines and stores column names for table table_user. +type TableUserColumns struct { + Id string // User ID + Passport string // User Passport + Password string // User Password + Nickname string // User Nickname + Score string // Total score amount. + CreateAt string // Created Time + UpdateAt string // Updated Time +} + +// tableUserColumns holds the columns for table table_user. +var tableUserColumns = TableUserColumns{ + Id: "id", + Passport: "passport", + Password: "password", + Nickname: "nickname", + Score: "score", + CreateAt: "create_at", + UpdateAt: "update_at", +} + +// NewTableUserDao creates and returns a new DAO object for table data access. +func NewTableUserDao() *TableUserDao { + return &TableUserDao{ + group: "test", + table: "table_user", + columns: tableUserColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *TableUserDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *TableUserDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *TableUserDao) Columns() TableUserColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *TableUserDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *TableUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/dao/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/dao/table_user.go new file mode 100644 index 0000000..9bc9cff --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/dao/table_user.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "for-gendao-test/pkg/dao/internal" +) + +// internalTableUserDao is internal type for wrapping internal DAO implements. +type internalTableUserDao = *internal.TableUserDao + +// tableUserDao is the data access object for table table_user. +// You can define custom methods on it to extend its functionality as you wish. +type tableUserDao struct { + internalTableUserDao +} + +var ( + // TableUser is globally public accessible object for table table_user operations. + TableUser = tableUserDao{ + internal.NewTableUserDao(), + } +) + +// Fill with you ideas below. diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/model/do/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/model/do/table_user.go new file mode 100644 index 0000000..656fb9c --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/model/do/table_user.go @@ -0,0 +1,22 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// TableUser is the golang structure of table table_user for DAO operations like Where/Data. +type TableUser struct { + g.Meta `orm:"table:table_user, do:true"` + Id interface{} // User ID + Passport interface{} // User Passport + Password interface{} // User Password + Nickname interface{} // User Nickname + Score interface{} // Total score amount. + CreateAt *gtime.Time // Created Time + UpdateAt *gtime.Time // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/model/entity/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/model/entity/table_user.go new file mode 100644 index 0000000..edde0ad --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user/model/entity/table_user.go @@ -0,0 +1,20 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// TableUser is the golang structure for table table_user. +type TableUser struct { + Id uint `json:"ID" orm:"id" ` // User ID + Passport string `json:"PASSPORT" orm:"passport" ` // User Passport + Password string `json:"PASSWORD" orm:"password" ` // User Password + Nickname string `json:"NICKNAME" orm:"nickname" ` // User Nickname + Score float64 `json:"SCORE" orm:"score" ` // Total score amount. + CreateAt *gtime.Time `json:"CREATE_AT" orm:"create_at" ` // Created Time + UpdateAt *gtime.Time `json:"UPDATE_AT" orm:"update_at" ` // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go new file mode 100644 index 0000000..f883408 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// TableUserDao is the data access object for table table_user. +type TableUserDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns TableUserColumns // columns contains all the column names of Table for convenient usage. +} + +// TableUserColumns defines and stores column names for table table_user. +type TableUserColumns struct { + Id string // User ID + Passport string // User Passport + Password string // User Password + Nickname string // User Nickname + Score string // Total score amount. + CreateAt string // Created Time + UpdateAt string // Updated Time +} + +// tableUserColumns holds the columns for table table_user. +var tableUserColumns = TableUserColumns{ + Id: "id", + Passport: "passport", + Password: "password", + Nickname: "nickname", + Score: "score", + CreateAt: "create_at", + UpdateAt: "update_at", +} + +// NewTableUserDao creates and returns a new DAO object for table data access. +func NewTableUserDao() *TableUserDao { + return &TableUserDao{ + group: "test", + table: "table_user", + columns: tableUserColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *TableUserDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *TableUserDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *TableUserDao) Columns() TableUserColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *TableUserDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *TableUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go new file mode 100644 index 0000000..9bc9cff --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "for-gendao-test/pkg/dao/internal" +) + +// internalTableUserDao is internal type for wrapping internal DAO implements. +type internalTableUserDao = *internal.TableUserDao + +// tableUserDao is the data access object for table table_user. +// You can define custom methods on it to extend its functionality as you wish. +type tableUserDao struct { + internalTableUserDao +} + +var ( + // TableUser is globally public accessible object for table table_user operations. + TableUser = tableUserDao{ + internal.NewTableUserDao(), + } +) + +// Fill with you ideas below. diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/model/do/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/model/do/table_user.go new file mode 100644 index 0000000..656fb9c --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/model/do/table_user.go @@ -0,0 +1,22 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// TableUser is the golang structure of table table_user for DAO operations like Where/Data. +type TableUser struct { + g.Meta `orm:"table:table_user, do:true"` + Id interface{} // User ID + Passport interface{} // User Passport + Password interface{} // User Password + Nickname interface{} // User Nickname + Score interface{} // Total score amount. + CreateAt *gtime.Time // Created Time + UpdateAt *gtime.Time // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/model/entity/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/model/entity/table_user.go new file mode 100644 index 0000000..c447af2 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_field_mapping/model/entity/table_user.go @@ -0,0 +1,21 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" + "github.com/shopspring/decimal" +) + +// TableUser is the golang structure for table table_user. +type TableUser struct { + Id int64 `json:"id" orm:"id" ` // User ID + Passport string `json:"passport" orm:"passport" ` // User Passport + Password string `json:"password" orm:"password" ` // User Password + Nickname string `json:"nickname" orm:"nickname" ` // User Nickname + Score decimal.Decimal `json:"score" orm:"score" ` // Total score amount. + CreateAt *gtime.Time `json:"createAt" orm:"create_at" ` // Created Time + UpdateAt *gtime.Time `json:"updateAt" orm:"update_at" ` // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go new file mode 100644 index 0000000..f883408 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// TableUserDao is the data access object for table table_user. +type TableUserDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns TableUserColumns // columns contains all the column names of Table for convenient usage. +} + +// TableUserColumns defines and stores column names for table table_user. +type TableUserColumns struct { + Id string // User ID + Passport string // User Passport + Password string // User Password + Nickname string // User Nickname + Score string // Total score amount. + CreateAt string // Created Time + UpdateAt string // Updated Time +} + +// tableUserColumns holds the columns for table table_user. +var tableUserColumns = TableUserColumns{ + Id: "id", + Passport: "passport", + Password: "password", + Nickname: "nickname", + Score: "score", + CreateAt: "create_at", + UpdateAt: "update_at", +} + +// NewTableUserDao creates and returns a new DAO object for table data access. +func NewTableUserDao() *TableUserDao { + return &TableUserDao{ + group: "test", + table: "table_user", + columns: tableUserColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *TableUserDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *TableUserDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *TableUserDao) Columns() TableUserColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *TableUserDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *TableUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go new file mode 100644 index 0000000..9bc9cff --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "for-gendao-test/pkg/dao/internal" +) + +// internalTableUserDao is internal type for wrapping internal DAO implements. +type internalTableUserDao = *internal.TableUserDao + +// tableUserDao is the data access object for table table_user. +// You can define custom methods on it to extend its functionality as you wish. +type tableUserDao struct { + internalTableUserDao +} + +var ( + // TableUser is globally public accessible object for table table_user operations. + TableUser = tableUserDao{ + internal.NewTableUserDao(), + } +) + +// Fill with you ideas below. diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/model/do/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/model/do/table_user.go new file mode 100644 index 0000000..656fb9c --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/model/do/table_user.go @@ -0,0 +1,22 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// TableUser is the golang structure of table table_user for DAO operations like Where/Data. +type TableUser struct { + g.Meta `orm:"table:table_user, do:true"` + Id interface{} // User ID + Passport interface{} // User Passport + Password interface{} // User Password + Nickname interface{} // User Nickname + Score interface{} // Total score amount. + CreateAt *gtime.Time // Created Time + UpdateAt *gtime.Time // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/model/entity/table_user.go b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/model/entity/table_user.go new file mode 100644 index 0000000..c447af2 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/generated_user_type_mapping/model/entity/table_user.go @@ -0,0 +1,21 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" + "github.com/shopspring/decimal" +) + +// TableUser is the golang structure for table table_user. +type TableUser struct { + Id int64 `json:"id" orm:"id" ` // User ID + Passport string `json:"passport" orm:"passport" ` // User Passport + Password string `json:"password" orm:"password" ` // User Password + Nickname string `json:"nickname" orm:"nickname" ` // User Nickname + Score decimal.Decimal `json:"score" orm:"score" ` // Total score amount. + CreateAt *gtime.Time `json:"createAt" orm:"create_at" ` // Created Time + UpdateAt *gtime.Time `json:"updateAt" orm:"update_at" ` // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/go.mod.txt b/server/internal/library/hggen/internal/cmd/testdata/gendao/go.mod.txt new file mode 100644 index 0000000..c121305 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/go.mod.txt @@ -0,0 +1,32 @@ +module for-gendao-test/pkg + +go 1.18 + +require ( + github.com/gogf/gf/v2 v2.5.3 + github.com/shopspring/decimal v1.3.1 +) + +require ( + github.com/BurntSushi/toml v1.2.0 // indirect + github.com/clbanning/mxj/v2 v2.7.0 // indirect + github.com/fatih/color v1.15.0 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/gorilla/websocket v1.5.0 // indirect + github.com/grokify/html-strip-tags-go v0.0.1 // indirect + github.com/magiconair/properties v1.8.6 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + go.opentelemetry.io/otel v1.14.0 // indirect + go.opentelemetry.io/otel/sdk v1.14.0 // indirect + go.opentelemetry.io/otel/trace v1.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/server/internal/library/hggen/internal/cmd/testdata/gendao/user.tpl.sql b/server/internal/library/hggen/internal/cmd/testdata/gendao/user.tpl.sql new file mode 100644 index 0000000..f27fc11 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/gendao/user.tpl.sql @@ -0,0 +1,10 @@ +CREATE TABLE `%s` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated/table_user.proto b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated/table_user.proto new file mode 100644 index 0000000..e5074b4 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated/table_user.proto @@ -0,0 +1,21 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +syntax = "proto3"; + +package unittest; + +option go_package = "unittest"; + +import "google/protobuf/timestamp.proto"; + +message TableUser { + uint32 Id = 1; // User ID + string Passport = 2; // User Passport + string Password = 3; // User Password + string Nickname = 4; // User Nickname + string Score = 5; // Total score amount. + google.protobuf.Timestamp CreateAt = 6; // Created Time + google.protobuf.Timestamp UpdateAt = 7; // Updated Time +} \ No newline at end of file diff --git a/server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated/table_user_snake_screaming.proto b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated/table_user_snake_screaming.proto new file mode 100644 index 0000000..365999e --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated/table_user_snake_screaming.proto @@ -0,0 +1,21 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +syntax = "proto3"; + +package unittest; + +option go_package = "unittest"; + +import "google/protobuf/timestamp.proto"; + +message TableUser { + uint32 ID = 1; // User ID + string PASSPORT = 2; // User Passport + string PASSWORD = 3; // User Password + string NICKNAME = 4; // User Nickname + string SCORE = 5; // Total score amount. + google.protobuf.Timestamp CREATE_AT = 6; // Created Time + google.protobuf.Timestamp UPDATE_AT = 7; // Updated Time +} \ No newline at end of file diff --git a/server/internal/library/hggen/internal/cmd/testdata/genpbentity/user.tpl.sql b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/user.tpl.sql new file mode 100644 index 0000000..f27fc11 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/user.tpl.sql @@ -0,0 +1,10 @@ +CREATE TABLE `%s` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/article/article.go b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/article/article.go new file mode 100644 index 0000000..4bc5447 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/article/article.go @@ -0,0 +1,47 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package article + +import ( + "context" + "go/ast" + t "time" + + gdbalias "github.com/gogf/gf/v2/database/gdb" + "hotgo/internal/library/hggen/internal/cmd/testdata/genservice/service" +) + +type sArticle struct { +} + +func init() { + service.RegisterArticle(&sArticle{}) +} + +// Get article details +func (s *sArticle) Get(ctx context.Context, id uint) (info struct{}, err error) { + return struct{}{}, err +} + +// Create +/** + * create an article. + * @author oldme + */ +func (s *sArticle) Create(ctx context.Context, info struct{}) (id uint, err error) { + // Use time package to test alias import. + t.Now() + return id, err +} + +func (s *sArticle) A1o2(ctx context.Context, str string, a, b *ast.GoStmt) error { + return nil +} + +func (s *sArticle) B_2(ctx context.Context, db gdbalias.Raw) (err error) { + return nil +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/article/article_extra.go b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/article/article_extra.go new file mode 100644 index 0000000..b61cb06 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/article/article_extra.go @@ -0,0 +1,75 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package article + +// import ( +// "context" +// +// "hotgo/internal/library/hggen/internal/cmd/testdata/genservice/service" +// ) +import ( + "context" + + // This is a random comment + gdbas "github.com/gogf/gf/v2/database/gdb" + /** + * + */ + _ "github.com/gogf/gf/v2/os/gfile" +) + +// T1 random comment +func (s sArticle) T1(ctx context.Context, id, id2 uint) (gdb gdbas.Model, err error) { + g := gdbas.Model{} + return g, err +} + +// I'm a random comment + +// t2 random comment +func (s *sArticle) t2(ctx context.Context) (err error) { + /** + * random comment + * i (1). func (s *sArticle) t2(ctx context.Context) (err error) { /** 1883 + * + */ + _ = func(ctx2 context.Context) {} + return nil +} + +// T3 +/** + * random comment @*4213hHY1&%##%>< ? , . / +func (s *sArticle) T4(i interface{}) interface{} { + return nil +} + +/** + * func (s *sArticle) T4(i interface{}) interface{} { + * return nil + * } + */ diff --git a/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/delivery/delivery_app.go b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/delivery/delivery_app.go new file mode 100644 index 0000000..edb42ec --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/delivery/delivery_app.go @@ -0,0 +1,38 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package delivery + +import ( + "context" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genservice/service" +) + +type sDeliveryApp struct{} + +func NewDeliveryApp() *sDeliveryApp { + return &sDeliveryApp{} +} + +func (s *sDeliveryApp) Create(ctx context.Context) (i service.IDeliveryCluster, err error) { + return +} + +func (s *sDeliveryApp) GetList(ctx context.Context, i service.IDeliveryCluster) (err error) { + service.Article().Get(ctx, 1) + return +} + +func (s *sDeliveryApp) GetOne(ctx context.Context) (err error) { + return +} + +func (s *sDeliveryApp) Delete(ctx context.Context) (err error) { + return +} + +func (s *sDeliveryApp) AA(ctx context.Context) (err error) { return } diff --git a/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/delivery/delivery_cluster.go b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/delivery/delivery_cluster.go new file mode 100644 index 0000000..4be21e7 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/delivery/delivery_cluster.go @@ -0,0 +1,32 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package delivery + +import ( + "context" + + gdbas "github.com/gogf/gf/v2/database/gdb" +) + +type sDeliveryCluster struct{} + +func NewDeliveryCluster() *sDeliveryCluster { + return &sDeliveryCluster{} +} + +// Create 自动创建Cluster及Project. +func (s *sDeliveryCluster) Create(ctx context.Context) (err error, gdb gdbas.Model) { + return +} + +func (s *sDeliveryCluster) Delete(ctx context.Context) (err error) { + return +} + +func (s *sDeliveryCluster) GetList(ctx context.Context) (err error) { + return +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/logic_expect.go b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/logic_expect.go new file mode 100644 index 0000000..6175855 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/logic_expect.go @@ -0,0 +1,11 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package logic + +import ( + _ "hotgo/internal/library/hggen/internal/cmd/testdata/genservice/logic/article" + _ "hotgo/internal/library/hggen/internal/cmd/testdata/genservice/logic/delivery" + _ "hotgo/internal/library/hggen/internal/cmd/testdata/genservice/logic/user" +) diff --git a/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/user/user.go b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/user/user.go new file mode 100644 index 0000000..337c0cc --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genservice/logic/user/user.go @@ -0,0 +1,49 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package user + +import ( + "context" + + "hotgo/internal/library/hggen/internal/cmd/testdata/genservice/service" +) + +func init() { + service.RegisterUser(New()) +} + +type sUser struct { +} + +func New() *sUser { + return &sUser{} +} + +// Create creates a new user. +func (s *sUser) Create(ctx context.Context, name string) (id int, err error) { + return 0, nil +} + +// GetOne retrieves user by id. +func (s *sUser) GetOne(ctx context.Context, id int) (name string, err error) { + return "", nil +} + +// GetList retrieves user list. +func (s *sUser) GetList(ctx context.Context) (names []string, err error) { + return nil, nil +} + +// Update updates user by id. +func (s *sUser) Update(ctx context.Context, id int) (name string, err error) { + return "", nil +} + +// Delete deletes user by id. +func (s *sUser) Delete(ctx context.Context, id int) (err error) { + return nil +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genservice/service/article.go b/server/internal/library/hggen/internal/cmd/testdata/genservice/service/article.go new file mode 100644 index 0000000..0d10924 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genservice/service/article.go @@ -0,0 +1,58 @@ +// ================================================================================ +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + "go/ast" + + gdbalias "github.com/gogf/gf/v2/database/gdb" + gdbas "github.com/gogf/gf/v2/database/gdb" +) + +type ( + IArticle interface { + // Get article details + Get(ctx context.Context, id uint) (info struct{}, err error) + // Create + /** + * create an article. + * @author oldme + */ + Create(ctx context.Context, info struct{}) (id uint, err error) + A1o2(ctx context.Context, str string, a *ast.GoStmt, b *ast.GoStmt) error + B_2(ctx context.Context, db gdbalias.Raw) (err error) + // T1 random comment + T1(ctx context.Context, id uint, id2 uint) (gdb gdbas.Model, err error) + // T3 + /** + * random comment @*4213hHY1&%##%>< ? , . / + T4(i interface{}) interface{} + } +) + +var ( + localArticle IArticle +) + +func Article() IArticle { + if localArticle == nil { + panic("implement not found for interface IArticle, forgot register?") + } + return localArticle +} + +func RegisterArticle(i IArticle) { + localArticle = i +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genservice/service/delivery.go b/server/internal/library/hggen/internal/cmd/testdata/genservice/service/delivery.go new file mode 100644 index 0000000..842ed88 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genservice/service/delivery.go @@ -0,0 +1,55 @@ +// ================================================================================ +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + gdbas "github.com/gogf/gf/v2/database/gdb" +) + +type ( + IDeliveryApp interface { + Create(ctx context.Context) (i IDeliveryCluster, err error) + GetList(ctx context.Context, i IDeliveryCluster) (err error) + GetOne(ctx context.Context) (err error) + Delete(ctx context.Context) (err error) + AA(ctx context.Context) (err error) + } + IDeliveryCluster interface { + // Create 自动创建Cluster及Project. + Create(ctx context.Context) (err error, gdb gdbas.Model) + Delete(ctx context.Context) (err error) + GetList(ctx context.Context) (err error) + } +) + +var ( + localDeliveryApp IDeliveryApp + localDeliveryCluster IDeliveryCluster +) + +func DeliveryApp() IDeliveryApp { + if localDeliveryApp == nil { + panic("implement not found for interface IDeliveryApp, forgot register?") + } + return localDeliveryApp +} + +func RegisterDeliveryApp(i IDeliveryApp) { + localDeliveryApp = i +} + +func DeliveryCluster() IDeliveryCluster { + if localDeliveryCluster == nil { + panic("implement not found for interface IDeliveryCluster, forgot register?") + } + return localDeliveryCluster +} + +func RegisterDeliveryCluster(i IDeliveryCluster) { + localDeliveryCluster = i +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/genservice/service/user.go b/server/internal/library/hggen/internal/cmd/testdata/genservice/service/user.go new file mode 100644 index 0000000..731ee87 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/genservice/service/user.go @@ -0,0 +1,40 @@ +// ================================================================================ +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" +) + +type ( + IUser interface { + // Create creates a new user. + Create(ctx context.Context, name string) (id int, err error) + // GetOne retrieves user by id. + GetOne(ctx context.Context, id int) (name string, err error) + // GetList retrieves user list. + GetList(ctx context.Context) (names []string, err error) + // Update updates user by id. + Update(ctx context.Context, id int) (name string, err error) + // Delete deletes user by id. + Delete(ctx context.Context, id int) (err error) + } +) + +var ( + localUser IUser +) + +func User() IUser { + if localUser == nil { + panic("implement not found for interface IUser, forgot register?") + } + return localUser +} + +func RegisterUser(i IUser) { + localUser = i +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/config.yaml b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/config.yaml new file mode 100644 index 0000000..82e437f --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/config.yaml @@ -0,0 +1,20 @@ +gfcli: + gen: + dao: + - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" + tables: "user1" + descriptionTag: true + noModelComment: true + group: "sys" + clear: true + overwriteDao: true + - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" + tables: "user2" + descriptionTag: true + noModelComment: true + group: "book" + clear: true + overwriteDao: true + + + diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/internal/user_3.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/internal/user_3.go new file mode 100644 index 0000000..db59440 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/internal/user_3.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// User3Dao is the data access object for table user3. +type User3Dao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns User3Columns // columns contains all the column names of Table for convenient usage. +} + +// User3Columns defines and stores column names for table user3. +type User3Columns struct { + Id string // User ID + Passport string // User Passport + Password string // User Password + Nickname string // User Nickname + Score string // Total score amount. + CreateAt string // Created Time + UpdateAt string // Updated Time +} + +// user3Columns holds the columns for table user3. +var user3Columns = User3Columns{ + Id: "id", + Passport: "passport", + Password: "password", + Nickname: "nickname", + Score: "score", + CreateAt: "create_at", + UpdateAt: "update_at", +} + +// NewUser3Dao creates and returns a new DAO object for table data access. +func NewUser3Dao() *User3Dao { + return &User3Dao{ + group: "sys", + table: "user3", + columns: user3Columns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *User3Dao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *User3Dao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *User3Dao) Columns() User3Columns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *User3Dao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *User3Dao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *User3Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/internal/user_4.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/internal/user_4.go new file mode 100644 index 0000000..0488034 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/internal/user_4.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// User4Dao is the data access object for table user4. +type User4Dao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns User4Columns // columns contains all the column names of Table for convenient usage. +} + +// User4Columns defines and stores column names for table user4. +type User4Columns struct { + Id string // User ID + Passport string // User Passport + Password string // User Password + Nickname string // User Nickname + Score string // Total score amount. + CreateAt string // Created Time + UpdateAt string // Updated Time +} + +// user4Columns holds the columns for table user4. +var user4Columns = User4Columns{ + Id: "id", + Passport: "passport", + Password: "password", + Nickname: "nickname", + Score: "score", + CreateAt: "create_at", + UpdateAt: "update_at", +} + +// NewUser4Dao creates and returns a new DAO object for table data access. +func NewUser4Dao() *User4Dao { + return &User4Dao{ + group: "book", + table: "user4", + columns: user4Columns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *User4Dao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *User4Dao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *User4Dao) Columns() User4Columns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *User4Dao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *User4Dao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *User4Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/user_3.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/user_3.go new file mode 100644 index 0000000..375276e --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/user_3.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "/internal" +) + +// internalUser3Dao is internal type for wrapping internal DAO implements. +type internalUser3Dao = *internal.User3Dao + +// user3Dao is the data access object for table user3. +// You can define custom methods on it to extend its functionality as you wish. +type user3Dao struct { + internalUser3Dao +} + +var ( + // User3 is globally public accessible object for table user3 operations. + User3 = user3Dao{ + internal.NewUser3Dao(), + } +) + +// Fill with you ideas below. diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/user_4.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/user_4.go new file mode 100644 index 0000000..7d02359 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/dao/user_4.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "/internal" +) + +// internalUser4Dao is internal type for wrapping internal DAO implements. +type internalUser4Dao = *internal.User4Dao + +// user4Dao is the data access object for table user4. +// You can define custom methods on it to extend its functionality as you wish. +type user4Dao struct { + internalUser4Dao +} + +var ( + // User4 is globally public accessible object for table user4 operations. + User4 = user4Dao{ + internal.NewUser4Dao(), + } +) + +// Fill with you ideas below. diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/do/user_3.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/do/user_3.go new file mode 100644 index 0000000..14a1bf4 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/do/user_3.go @@ -0,0 +1,22 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// User1 is the golang structure of table user1 for DAO operations like Where/Data. +type User1 struct { + g.Meta `orm:"table:user1, do:true"` + Id interface{} // User ID + Passport interface{} // User Passport + Password interface{} // User Password + Nickname interface{} // User Nickname + Score interface{} // Total score amount. + CreateAt *gtime.Time // Created Time + UpdateAt *gtime.Time // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/do/user_4.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/do/user_4.go new file mode 100644 index 0000000..8019772 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/do/user_4.go @@ -0,0 +1,22 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// User2 is the golang structure of table user2 for DAO operations like Where/Data. +type User2 struct { + g.Meta `orm:"table:user2, do:true"` + Id interface{} // User ID + Passport interface{} // User Passport + Password interface{} // User Password + Nickname interface{} // User Nickname + Score interface{} // Total score amount. + CreateAt *gtime.Time // Created Time + UpdateAt *gtime.Time // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/entity/user_3.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/entity/user_3.go new file mode 100644 index 0000000..de4cd54 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/entity/user_3.go @@ -0,0 +1,20 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// User1 is the golang structure for table user1. +type User1 struct { + Id uint `json:"ID" description:"User ID"` + Passport string `json:"PASSPORT" description:"User Passport"` + Password string `json:"PASSWORD" description:"User Password"` + Nickname string `json:"NICKNAME" description:"User Nickname"` + Score float64 `json:"SCORE" description:"Total score amount."` + CreateAt *gtime.Time `json:"CREATE_AT" description:"Created Time"` + UpdateAt *gtime.Time `json:"UPDATE_AT" description:"Updated Time"` +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/entity/user_4.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/entity/user_4.go new file mode 100644 index 0000000..4727f62 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/model/entity/user_4.go @@ -0,0 +1,20 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// User2 is the golang structure for table user2. +type User2 struct { + Id uint `json:"ID" description:"User ID"` + Passport string `json:"PASSPORT" description:"User Passport"` + Password string `json:"PASSWORD" description:"User Password"` + Nickname string `json:"NICKNAME" description:"User Nickname"` + Score float64 `json:"SCORE" description:"Total score amount."` + CreateAt *gtime.Time `json:"CREATE_AT" description:"Created Time"` + UpdateAt *gtime.Time `json:"UPDATE_AT" description:"Updated Time"` +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/sql1.sql b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/sql1.sql new file mode 100644 index 0000000..2877f1f --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/sql1.sql @@ -0,0 +1,10 @@ +CREATE TABLE `user1` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2572/sql2.sql b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/sql2.sql new file mode 100644 index 0000000..ca450aa --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2572/sql2.sql @@ -0,0 +1,10 @@ +CREATE TABLE `user2` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/config.yaml b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/config.yaml new file mode 100644 index 0000000..fc6299a --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/config.yaml @@ -0,0 +1,20 @@ +gfcli: + gen: + dao: + - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" + tables: "user1" + descriptionTag: true + noModelComment: true + group: "sys" + clear: true + overwriteDao: false + - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" + tables: "user2" + descriptionTag: true + noModelComment: true + group: "book" + clear: true + overwriteDao: true + + + diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_1.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_1.go new file mode 100644 index 0000000..9988251 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_1.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// User1Dao is the data access object for table user1. +type User1Dao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns User1Columns // columns contains all the column names of Table for convenient usage. +} + +// User1Columns defines and stores column names for table user1. +type User1Columns struct { + Id string // User ID + Passport string // User Passport + Password string // User Password + Nickname string // User Nickname + Score string // Total score amount. + CreateAt string // Created Time + UpdateAt string // Updated Time +} + +// user1Columns holds the columns for table user1. +var user1Columns = User1Columns{ + Id: "id", + Passport: "passport", + Password: "password", + Nickname: "nickname", + Score: "score", + CreateAt: "create_at", + UpdateAt: "update_at", +} + +// NewUser1Dao creates and returns a new DAO object for table data access. +func NewUser1Dao() *User1Dao { + return &User1Dao{ + group: "sys", + table: "user1", + columns: user1Columns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *User1Dao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *User1Dao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *User1Dao) Columns() User1Columns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *User1Dao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *User1Dao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *User1Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_2.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_2.go new file mode 100644 index 0000000..7e9cf2f --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_2.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// User2Dao is the data access object for table user2. +type User2Dao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns User2Columns // columns contains all the column names of Table for convenient usage. +} + +// User2Columns defines and stores column names for table user2. +type User2Columns struct { + Id string // User ID + Passport string // User Passport + Password string // User Password + Nickname string // User Nickname + Score string // Total score amount. + CreateAt string // Created Time + UpdateAt string // Updated Time +} + +// user2Columns holds the columns for table user2. +var user2Columns = User2Columns{ + Id: "id", + Passport: "passport", + Password: "password", + Nickname: "nickname", + Score: "score", + CreateAt: "create_at", + UpdateAt: "update_at", +} + +// NewUser2Dao creates and returns a new DAO object for table data access. +func NewUser2Dao() *User2Dao { + return &User2Dao{ + group: "sys", + table: "user2", + columns: user2Columns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *User2Dao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *User2Dao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *User2Dao) Columns() User2Columns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *User2Dao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *User2Dao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *User2Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_3.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_3.go new file mode 100644 index 0000000..db59440 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_3.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// User3Dao is the data access object for table user3. +type User3Dao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns User3Columns // columns contains all the column names of Table for convenient usage. +} + +// User3Columns defines and stores column names for table user3. +type User3Columns struct { + Id string // User ID + Passport string // User Passport + Password string // User Password + Nickname string // User Nickname + Score string // Total score amount. + CreateAt string // Created Time + UpdateAt string // Updated Time +} + +// user3Columns holds the columns for table user3. +var user3Columns = User3Columns{ + Id: "id", + Passport: "passport", + Password: "password", + Nickname: "nickname", + Score: "score", + CreateAt: "create_at", + UpdateAt: "update_at", +} + +// NewUser3Dao creates and returns a new DAO object for table data access. +func NewUser3Dao() *User3Dao { + return &User3Dao{ + group: "sys", + table: "user3", + columns: user3Columns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *User3Dao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *User3Dao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *User3Dao) Columns() User3Columns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *User3Dao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *User3Dao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *User3Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_4.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_4.go new file mode 100644 index 0000000..0488034 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/internal/user_4.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// User4Dao is the data access object for table user4. +type User4Dao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns User4Columns // columns contains all the column names of Table for convenient usage. +} + +// User4Columns defines and stores column names for table user4. +type User4Columns struct { + Id string // User ID + Passport string // User Passport + Password string // User Password + Nickname string // User Nickname + Score string // Total score amount. + CreateAt string // Created Time + UpdateAt string // Updated Time +} + +// user4Columns holds the columns for table user4. +var user4Columns = User4Columns{ + Id: "id", + Passport: "passport", + Password: "password", + Nickname: "nickname", + Score: "score", + CreateAt: "create_at", + UpdateAt: "update_at", +} + +// NewUser4Dao creates and returns a new DAO object for table data access. +func NewUser4Dao() *User4Dao { + return &User4Dao{ + group: "book", + table: "user4", + columns: user4Columns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *User4Dao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *User4Dao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *User4Dao) Columns() User4Columns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *User4Dao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *User4Dao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *User4Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_1.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_1.go new file mode 100644 index 0000000..69af67a --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_1.go @@ -0,0 +1,29 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +// I am not overwritten. + +package dao + +import ( + "/internal" +) + +// internalUser1Dao is internal type for wrapping internal DAO implements. +type internalUser1Dao = *internal.User1Dao + +// user1Dao is the data access object for table user1. +// You can define custom methods on it to extend its functionality as you wish. +type user1Dao struct { + internalUser1Dao +} + +var ( + // User1 is globally public accessible object for table user1 operations. + User1 = user1Dao{ + internal.NewUser1Dao(), + } +) + +// Fill with you ideas below. diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_2.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_2.go new file mode 100644 index 0000000..895d406 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_2.go @@ -0,0 +1,29 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +// I am not overwritten. + +package dao + +import ( + "/internal" +) + +// internalUser2Dao is internal type for wrapping internal DAO implements. +type internalUser2Dao = *internal.User2Dao + +// user2Dao is the data access object for table user2. +// You can define custom methods on it to extend its functionality as you wish. +type user2Dao struct { + internalUser2Dao +} + +var ( + // User2 is globally public accessible object for table user2 operations. + User2 = user2Dao{ + internal.NewUser2Dao(), + } +) + +// Fill with you ideas below. diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_3.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_3.go new file mode 100644 index 0000000..375276e --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_3.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "/internal" +) + +// internalUser3Dao is internal type for wrapping internal DAO implements. +type internalUser3Dao = *internal.User3Dao + +// user3Dao is the data access object for table user3. +// You can define custom methods on it to extend its functionality as you wish. +type user3Dao struct { + internalUser3Dao +} + +var ( + // User3 is globally public accessible object for table user3 operations. + User3 = user3Dao{ + internal.NewUser3Dao(), + } +) + +// Fill with you ideas below. diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_4.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_4.go new file mode 100644 index 0000000..7d02359 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/dao/user_4.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "/internal" +) + +// internalUser4Dao is internal type for wrapping internal DAO implements. +type internalUser4Dao = *internal.User4Dao + +// user4Dao is the data access object for table user4. +// You can define custom methods on it to extend its functionality as you wish. +type user4Dao struct { + internalUser4Dao +} + +var ( + // User4 is globally public accessible object for table user4 operations. + User4 = user4Dao{ + internal.NewUser4Dao(), + } +) + +// Fill with you ideas below. diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/do/user_3.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/do/user_3.go new file mode 100644 index 0000000..14a1bf4 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/do/user_3.go @@ -0,0 +1,22 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// User1 is the golang structure of table user1 for DAO operations like Where/Data. +type User1 struct { + g.Meta `orm:"table:user1, do:true"` + Id interface{} // User ID + Passport interface{} // User Passport + Password interface{} // User Password + Nickname interface{} // User Nickname + Score interface{} // Total score amount. + CreateAt *gtime.Time // Created Time + UpdateAt *gtime.Time // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/do/user_4.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/do/user_4.go new file mode 100644 index 0000000..8019772 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/do/user_4.go @@ -0,0 +1,22 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// User2 is the golang structure of table user2 for DAO operations like Where/Data. +type User2 struct { + g.Meta `orm:"table:user2, do:true"` + Id interface{} // User ID + Passport interface{} // User Passport + Password interface{} // User Password + Nickname interface{} // User Nickname + Score interface{} // Total score amount. + CreateAt *gtime.Time // Created Time + UpdateAt *gtime.Time // Updated Time +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/entity/user_3.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/entity/user_3.go new file mode 100644 index 0000000..de4cd54 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/entity/user_3.go @@ -0,0 +1,20 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// User1 is the golang structure for table user1. +type User1 struct { + Id uint `json:"ID" description:"User ID"` + Passport string `json:"PASSPORT" description:"User Passport"` + Password string `json:"PASSWORD" description:"User Password"` + Nickname string `json:"NICKNAME" description:"User Nickname"` + Score float64 `json:"SCORE" description:"Total score amount."` + CreateAt *gtime.Time `json:"CREATE_AT" description:"Created Time"` + UpdateAt *gtime.Time `json:"UPDATE_AT" description:"Updated Time"` +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/entity/user_4.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/entity/user_4.go new file mode 100644 index 0000000..4727f62 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/model/entity/user_4.go @@ -0,0 +1,20 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// User2 is the golang structure for table user2. +type User2 struct { + Id uint `json:"ID" description:"User ID"` + Passport string `json:"PASSPORT" description:"User Passport"` + Password string `json:"PASSWORD" description:"User Password"` + Nickname string `json:"NICKNAME" description:"User Nickname"` + Score float64 `json:"SCORE" description:"Total score amount."` + CreateAt *gtime.Time `json:"CREATE_AT" description:"Created Time"` + UpdateAt *gtime.Time `json:"UPDATE_AT" description:"Updated Time"` +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/sql1.sql b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/sql1.sql new file mode 100644 index 0000000..2877f1f --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/sql1.sql @@ -0,0 +1,10 @@ +CREATE TABLE `user1` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2616/sql2.sql b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/sql2.sql new file mode 100644 index 0000000..ca450aa --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2616/sql2.sql @@ -0,0 +1,10 @@ +CREATE TABLE `user2` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2746/issue_2746.go b/server/internal/library/hggen/internal/cmd/testdata/issue/2746/issue_2746.go new file mode 100644 index 0000000..af2b98c --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2746/issue_2746.go @@ -0,0 +1,18 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/encoding/gjson" +) + +// Issue2746 is the golang structure for table issue2746. +type Issue2746 struct { + Id uint `json:"ID" orm:"id" ` // User ID + Nickname string `json:"NICKNAME" orm:"nickname" ` // User Nickname + Tag *gjson.Json `json:"TAG" orm:"tag" ` // + Info string `json:"INFO" orm:"info" ` // + Tag2 *gjson.Json `json:"TAG_2" orm:"tag2" ` // Tag2 +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/2746/sql.sql b/server/internal/library/hggen/internal/cmd/testdata/issue/2746/sql.sql new file mode 100644 index 0000000..99357a1 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/2746/sql.sql @@ -0,0 +1,9 @@ +CREATE TABLE %s ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `tag` json NOT NULL, + `info` longtext DEFAULT NULL, + `tag2` json COMMENT 'Tag2', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/3459/config.yaml b/server/internal/library/hggen/internal/cmd/testdata/issue/3459/config.yaml new file mode 100644 index 0000000..ae62cf6 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/3459/config.yaml @@ -0,0 +1,5 @@ +gfcli: + gen: + dao: + - link: "pgsql:postgres:postgres@tcp(127.0.0.1:5432)/postgres" + tablesEx: "ex_table1,ex_table2" \ No newline at end of file diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/hello.go b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/hello.go new file mode 100644 index 0000000..c1b3b8b --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/hello.go @@ -0,0 +1,26 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package hello + +import ( + "context" + + "hotgo/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v1" + "hotgo/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v2" +) + +type IHelloV1 interface { + DictTypeAddPage(ctx context.Context, req *v1.DictTypeAddPageReq) (res *v1.DictTypeAddPageRes, err error) + DictTypeAdd(ctx context.Context, req *v1.DictTypeAddReq) (res *v1.DictTypeAddRes, err error) + DictTypeEditPage(ctx context.Context, req *v1.DictTypeEditPageReq) (res *v1.DictTypeEditPageRes, err error) + DictTypeEdit(ctx context.Context, req *v1.DictTypeEditReq) (res *v1.DictTypeEditRes, err error) +} + +type IHelloV2 interface { + DictTypeAddPage(ctx context.Context, req *v2.DictTypeAddPageReq) (res *v2.DictTypeAddPageRes, err error) + DictTypeAdd(ctx context.Context, req *v2.DictTypeAddReq) (res *v2.DictTypeAddRes, err error) + DictTypeEditPage(ctx context.Context, req *v2.DictTypeEditPageReq) (res *v2.DictTypeEditPageRes, err error) + DictTypeEdit(ctx context.Context, req *v2.DictTypeEditReq) (res *v2.DictTypeEditRes, err error) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v1/req.go b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v1/req.go new file mode 100644 index 0000000..33c2795 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v1/req.go @@ -0,0 +1,37 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package v1 + +import "github.com/gogf/gf/v2/frame/g" + +type DictTypeAddPageReq struct { + g.Meta `path:"/dict/type/add" tags:"字典管理" method:"get" summary:"字典类型添加页面"` +} + +type DictTypeAddPageRes struct { + g.Meta `mime:"text/html" type:"string" example:""` +} + +type DictTypeAddReq struct { + g.Meta `path:"/dict/type/add" tags:"字典管理" method:"post" summary:"添加字典类型"` +} +type DictTypeAddRes struct { +} + +type DictTypeEditPageReq struct { + g.Meta `path:"/dict/type/edit" tags:"字典管理" method:"get" summary:"字典类型添加页面"` +} + +type DictTypeEditPageRes struct { + g.Meta `mime:"text/html" type:"string" example:""` +} + +type DictTypeEditReq struct { + g.Meta `path:"/dict/type/edit" tags:"字典管理" method:"put" summary:"修改字典类型"` +} +type DictTypeEditRes struct { +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v2/req.go b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v2/req.go new file mode 100644 index 0000000..2764c53 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v2/req.go @@ -0,0 +1,37 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package v2 + +import "github.com/gogf/gf/v2/frame/g" + +type DictTypeAddPageReq struct { + g.Meta `path:"/dict/type/add" tags:"字典管理" method:"get" summary:"字典类型添加页面"` +} + +type DictTypeAddPageRes struct { + g.Meta `mime:"text/html" type:"string" example:""` +} + +type DictTypeAddReq struct { + g.Meta `path:"/dict/type/add" tags:"字典管理" method:"post" summary:"添加字典类型"` +} +type DictTypeAddRes struct { +} + +type DictTypeEditPageReq struct { + g.Meta `path:"/dict/type/edit" tags:"字典管理" method:"get" summary:"字典类型添加页面"` +} + +type DictTypeEditPageRes struct { + g.Meta `mime:"text/html" type:"string" example:""` +} + +type DictTypeEditReq struct { + g.Meta `path:"/dict/type/edit" tags:"字典管理" method:"put" summary:"修改字典类型"` +} +type DictTypeEditRes struct { +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello.go b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello.go new file mode 100644 index 0000000..f72082f --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello.go @@ -0,0 +1,5 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package hello diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_new.go b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_new.go new file mode 100644 index 0000000..cdc9864 --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_new.go @@ -0,0 +1,21 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package hello + +import ( + "hotgo/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello" +) + +type ControllerV1 struct{} + +func NewV1() hello.IHelloV1 { + return &ControllerV1{} +} + +type ControllerV2 struct{} + +func NewV2() hello.IHelloV2 { + return &ControllerV2{} +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_v1_req.go b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_v1_req.go new file mode 100644 index 0000000..53fcfef --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_v1_req.go @@ -0,0 +1,23 @@ +package hello + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v1" +) + +func (c *ControllerV1) DictTypeAddPage(ctx context.Context, req *v1.DictTypeAddPageReq) (res *v1.DictTypeAddPageRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} +func (c *ControllerV1) DictTypeAdd(ctx context.Context, req *v1.DictTypeAddReq) (res *v1.DictTypeAddRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} +func (c *ControllerV1) DictTypeEditPage(ctx context.Context, req *v1.DictTypeEditPageReq) (res *v1.DictTypeEditPageRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} +func (c *ControllerV1) DictTypeEdit(ctx context.Context, req *v1.DictTypeEditReq) (res *v1.DictTypeEditRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_v2_req.go b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_v2_req.go new file mode 100644 index 0000000..7d6d02a --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/3460/controller/hello/hello_v2_req.go @@ -0,0 +1,23 @@ +package hello + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "hotgo/internal/library/hggen/internal/cmd/testdata/issue/3460/api/hello/v2" +) + +func (c *ControllerV2) DictTypeAddPage(ctx context.Context, req *v2.DictTypeAddPageReq) (res *v2.DictTypeAddPageRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} +func (c *ControllerV2) DictTypeAdd(ctx context.Context, req *v2.DictTypeAddReq) (res *v2.DictTypeAddRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} +func (c *ControllerV2) DictTypeEditPage(ctx context.Context, req *v2.DictTypeEditPageReq) (res *v2.DictTypeEditPageRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} +func (c *ControllerV2) DictTypeEdit(ctx context.Context, req *v2.DictTypeEditReq) (res *v2.DictTypeEditRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/server/internal/library/hggen/internal/cmd/testdata/issue/3545/table_user.proto b/server/internal/library/hggen/internal/cmd/testdata/issue/3545/table_user.proto new file mode 100644 index 0000000..28cf62e --- /dev/null +++ b/server/internal/library/hggen/internal/cmd/testdata/issue/3545/table_user.proto @@ -0,0 +1,21 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +syntax = "proto3"; + +package pbentity; + +option go_package = "hotgo/internal/library/hggen/internal/cmd/api/pbentity"; + +import "google/protobuf/timestamp.proto"; + +message TableUser { + uint32 Id = 1; // User ID + string Passport = 2; // User Passport + string Password = 3; // User Password + string Nickname = 4; // User Nickname + string Score = 5; // Total score amount. + google.protobuf.Timestamp CreateAt = 6; // Created Time + google.protobuf.Timestamp UpdateAt = 7; // Updated Time +} \ No newline at end of file diff --git a/server/internal/library/hggen/internal/consts/consts_gen_ctrl_template.go b/server/internal/library/hggen/internal/consts/consts_gen_ctrl_template.go index 9197992..da0429e 100644 --- a/server/internal/library/hggen/internal/consts/consts_gen_ctrl_template.go +++ b/server/internal/library/hggen/internal/consts/consts_gen_ctrl_template.go @@ -51,6 +51,20 @@ func (c *{CtrlName}) {MethodName}(ctx context.Context, req *{Version}.{MethodNam } ` +const TemplateGenCtrlControllerHeader = ` +package {Module} + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "{ImportPath}" +) + +` + const TemplateGenCtrlControllerMethodFuncMerge = ` func (c *{CtrlName}) {MethodName}(ctx context.Context, req *{Version}.{MethodName}Req) (res *{Version}.{MethodName}Res, err error) { diff --git a/server/internal/library/hggen/internal/consts/consts_gen_ctrl_template_sdk.go b/server/internal/library/hggen/internal/consts/consts_gen_ctrl_template_sdk.go index 92177fb..09f3795 100644 --- a/server/internal/library/hggen/internal/consts/consts_gen_ctrl_template_sdk.go +++ b/server/internal/library/hggen/internal/consts/consts_gen_ctrl_template_sdk.go @@ -26,12 +26,6 @@ type implementer struct { } func New(config httpclient.Config) IClient { - if !gstr.HasPrefix(config.URL, "http") { - config.URL = fmt.Sprintf("http://%s", config.URL) - } - if config.Logger == nil { - config.Logger = g.Log() - } return &implementer{ config: config, } diff --git a/server/internal/library/hggen/internal/consts/consts_gen_dao_template_dao.go b/server/internal/library/hggen/internal/consts/consts_gen_dao_template_dao.go index bcf2373..5af47e4 100644 --- a/server/internal/library/hggen/internal/consts/consts_gen_dao_template_dao.go +++ b/server/internal/library/hggen/internal/consts/consts_gen_dao_template_dao.go @@ -11,7 +11,7 @@ const TemplateGenDaoIndexContent = ` // This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. // ================================================================================= -package dao +package {TplPackageName} import ( "{TplImportPrefix}/internal" diff --git a/server/internal/library/hggen/internal/consts/consts_gen_dao_template_do.go b/server/internal/library/hggen/internal/consts/consts_gen_dao_template_do.go index 11914b0..320aaa9 100644 --- a/server/internal/library/hggen/internal/consts/consts_gen_dao_template_do.go +++ b/server/internal/library/hggen/internal/consts/consts_gen_dao_template_do.go @@ -11,7 +11,7 @@ const TemplateGenDaoDoContent = ` // Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr} // ================================================================================= -package do +package {TplPackageName} {TplPackageImports} diff --git a/server/internal/library/hggen/internal/consts/consts_gen_dao_template_entity.go b/server/internal/library/hggen/internal/consts/consts_gen_dao_template_entity.go index 44af06a..67a868e 100644 --- a/server/internal/library/hggen/internal/consts/consts_gen_dao_template_entity.go +++ b/server/internal/library/hggen/internal/consts/consts_gen_dao_template_entity.go @@ -11,7 +11,7 @@ const TemplateGenDaoEntityContent = ` // Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr} // ================================================================================= -package entity +package {TplPackageName} {TplPackageImports} diff --git a/server/internal/library/hggen/internal/packed/template-mono-app.go b/server/internal/library/hggen/internal/packed/template-mono-app.go new file mode 100644 index 0000000..3df4114 --- /dev/null +++ b/server/internal/library/hggen/internal/packed/template-mono-app.go @@ -0,0 +1,9 @@ +package packed + +import "github.com/gogf/gf/v2/os/gres" + +func init() { + if err := gres.Add("H4sIAAAAAAAC/7RaCTjU2xs+tuxLsiQi+24oWcq1VmTsImRJjDEZM5hB6lKKtMh+leWmREjI0iZZs4a4KloIlWQpRZH1/3Tv5T8/y5gZXc/TzKOe3vf9vu+c8/vO73vN4DS0XIABMIBB5jwbQPCzCTACPMLTC+2MR8h7YjFYeWcvL5ixswfCDYVGWO2jA1SHOXa5MX0dZz/r/4XFwszM7JaVWatUs0FTvbmUlGnru6+4MV9WNi+8Hx1cOj3tunh8X5yU9/176yYm9GtOpen0imfdp1M/K55VXJ0Q8FE9y9BeYba5K1fn3vv7W0djcIaWFtxjY9s4YwsrQhwxKlsAmJszg9MzHM2SveYJADgHAFhZPf+y6i126+wy3q1gvGtBPtfjfKZKbRbQMlMq0o2O1LvI8yinN/Mbve4FpQ4V4QuTU+/v3C3ZbF/kn8woqPwqRKclu2oLsylesi0O48SnpUh7FB/1fSTi1u3HCd+sXK41v4hCNWldPW51yuWMwoeBwdF9huqCL/2Y57WbDIgZHQYAeBBoB0u0cy+r3dkLtaD6Jxbh/1gZi38lLJg7Ao3Groq4NLNixBH/+VRA/h+6KML48KA2R0j7gCWX3V52LdYd2tY+QbTCpw8WYOHDXzhQdoK+4cZ1naf+kPM5kXZVekLqRoP66+nv0Tj3It4jZ2M60uhrBUXD3AVSxzocvPL8z+rrjHZU7gtjGmS9rHLgde4rT7rJWGdl7/EGR68oZ7NURZNEFjpEQEbrO7Q6Iu69ZkeP537fHTvygj4b1aAOxs7hzgRx1Fp6wUN2PlP/Y5dfAu1wFffDpwytYsP3N5RY3ilPLdxWKnujD77fwOdRmaWDfDxSPV4qplGrteRkGj7QWDyQoxUJ5iuKbf7U/gIAkE9FrAqCq+TMT4mCQkiuCrq0FuimfJNTSiy03feDmB5vkLtwsHED3tnZJfuHd/KZSyGPsuyEuzabS6RFSHZ2tgccQ3Jr/Aa4Bj3Vuioiio445k3l2LZcl3ZnyqiNWpdEK36PfgTOq2GQM2yr6T1pk/SWdwg/J9Z8ZGhI3aKujFUX+Wc02/GKR7hj59N6Q3AJX+7tOopituRr+1Ks8yk0YmSGPVF1i6xEtH2zYMEB8bhtB/I4UZNSQkd/+8E4n1xOOwH0DQDAB6JLnGfZPLg7u3hQkFSRFcFgLliMGwqpEODsiV4AFmvKP1ylyBXa02nqbfC8IfWe2EGpzTvodoxxcw3aPdz318O6ApeyQPPCwCr16U6+FCfVfdET1PVfAPLIS6lzEg3ccaoKMUlTn8JT7Hz5cli38l7MvMh5s1j7fOclQeOHSTLwWffSH+M9Ppsd8/R4+6S/dlA5XneSMS4PfN+vnxx+Cj77dV3hFh9H/42709MUx9RmTLOZ34S6daECgqhO4ceS7SzbHxiHed84TjWf0Y2DE2E3AQCtlCbh54e8Cxql4Pn/7KKjnLI3KHFUp6im9N4at5ArPjvZoWvFdIfOe/cXnZci3tvqT7vFFiTcYZoZKZgRTR339OmLGt0pKnjrXIIvw8Bgl7uEF/XdkCsJW11mnelMpA2EteQHI99IuJ/kNR7ZYF7S9CjT/dwFKRPMJQ+18/EBKZKG6k+Ge8LQFhn2Ptbq2UeZ0rYhfGccEvDnhFHXkmdmJ+TuclHbU1eL8vjOIKbLJj6N/q5e467squJ5keXynIBu3rl9zZVOU1cmfS2n2Kp0Gb6cCIA3se1I1Lojyd/wynp6+1xbh+0+/cYrLJutNEJOtBe2yiY/GeEZ3N5Qqyp+w0DKKb4Dk1FlJapCLcV0+GWIT3TXYIQC0BSVKN0WHRDcWIwcmnrKwSe0eSy4rfPKiwypdDmY2O4Mf2UzJ8fnpsfp50shGaxbtpUKgGdUxEohSLwUhGUIsTLHiqhyBNWUHWowD/V8chNvym1ucjXYJ8ORxtDnD5P0c27+yIpqjwd3Lm5Inx5vcGSIChFk78r/kIStcZnSy7R/TqcDczhYGk7zJL3fCl7TVY60vCK5cdBJzpo2k4mjq6IpI7J7u8HYOw21yAQxm2hf3WzBQWMtI0zZ2FWVmyqBDGhd9UiLguffSkJegtryWZy8K1WCmXu72c6rfVEeVucCPFuZc64UFZ+02V/YdcBFnJ2xgONJ74Rh4j225NLT+yyLIsCFM8cuxYrwq8R7vM+Jj0EPnHsfrD5uXaBYUrlT8tnEC/6Nn8/WbDIUrtfJkmehj8Wr7dVvYC7TjOLJtA2eZEGMaHIntj+P+Xrw5ux5H/bR32b2fksbaBgODNPwTqj+YpS7zvvO7LEC2WghpWK34OFSpM14ZlUrzw6nGDrznukz8ia2AilKvsVFuoyR7KeUyrnxxRgdi0r7I1J1761daZN5Kye3e0V8lc3d7PXJW1DzEiLeer8W1Qfuyd+peLOFFLqdvPaVh8IDXsLfPLwkybghPbXs6tR3sZTR/sHyw0VNe1PNRj4F2rXIWN2O2/vVML/C8Gh+cUi0zK4fTAZxLS80WGpe3R1xHdKN3JuR8llLYMSZx+uY6Ba9dv+ZYbRIEPNr2X58WGySk75/5N1Tb/bsLStkfP3q8bYMThjXc8f9/bsjLHIrnmLWO46zudX3I5HtzBx+ilM3fR16YvzirsbLYhLj9LZa5EXGhEoK9I/v/90WGXeMMc268rBV9Fd9U4k9hX1tWp4f7mN4ikSyjGMUnxf7vQtuE2+0ybbjqaRWbfnYZSzBHlkV6b93IGvrxwI/x/29QsXJ+daOyUBmX6rYh7brp2lUnskWcLYrDKMF9e+WYfVGYv0zND/PSdpyFUpkfgRgk2h7+WPsntCZM5yzDBm/JQYl/o4y4S99cNKPf7aEtmwLt7b+O4lSRkGMAXhjSq96zbW9p+XbGB+vaktX48tmM02PcdVCPykxg6Bt2XUuwYJJCY/C0zyGUisaX06Nc83pBU13iRd+V5l+mT9roawqJuUYFeRyu93WoXRfcXenbHcP5lJ4wlA4V8LQrs7L5vQXmNOR/Qy9Ke2M8rs73Y69RZ+rmXFaeKR/yDyA3EUDgA49safO8u0xCoNH+GCc0RR0aoJEAWEunq4UPM7EVwX9+YewQ8BH6Xi8VuQIffJX3kZ8zCnZVkHW+2It32PM7hT5Wwl67E6P5qtP0n4x5ygHUw7rE+trakuKvLtj7hUdbQpS2sWRWbXFQsops8fD0oKJ+9BObFk47MVpTh5+nmM/XHn9+DzNPm9iSGL98Pz5uHz6y+7R6TeyrKOJ9lXs2y0M3EW3u/rUf3K3t9C9gzTKklI3CPAuwWndN/BiP5YZIKe+M3HOQPiyQw2jNoJ37wWLM0LP6JK7GNgFvBO0n/XdqzBh5f5x8vXdFNWvG+T4A4Zfyb5uUIqs3Vk5cE+kyqFsKoedxt11nauCRjmbsIzROEfj+OXsMIUEmP0dK9nsGlGtoW2vv/U2ZqFZ7x/A8KV+brJM/hACizAXaj5euV8fp6vp7MBsJdA1ffSM8qDm+a7kgJqLKULfFP1yduap3mzbQy/s8urSiUMxuvb60rk+Ucdp5hdT0xl/NTgVACrUxGovvEqZsBgcHkdB+WVJwf33i3ARyBgYNZsYmVoZND+RVZDuo6adD6ecl6WRGwDATnQpi69Ki/fBotEIHwq2iSyp2BRfcJTJY1jmwtNcwUitxBHac+zGEdZ7WeWxt0SOFAV7b1Y95XIZLWFQzHusZW626uK272UK78Ph+es8ogRf59j5xrbw59LoNydpcIeNMurssAk84dvKWHhftHSw016Y9dRmrAfC8Hj09Yty7LbcuzsTNBeauiwzg9NoAAAb0U5CjZKwnDAIf2hoDw9XaXPQdr+c4jp1/iBv61V6A/EP+hxDNZlO8MHR6LZhb8f14S0PwsSMBbdcdrsRyfdhZOyN8IeW/i0jMWm36oEJzR62ejUxPq/iHisnpsiTfQ9Ds2qYHtB8DxO97D+cT935fiPik1YHswLnNc5QJQ8ltPvt7xUKbVkDvnjHmRcJ4eoF9W+3iwlVe7N90s9BwV3vyrkr27ZuTMdvz7W+3tUX2q+RLnjsx9BA03f/zMNvSrOzldpunDEW7+nJu8xrd6aUej5nlZoFnNUAgHCiOfuNopz5KTktvXhdqDAJVeTY3d64P9yh9SKSf5qO821iKPaCb79oPJsRve6haX+aYq+eQ1vrm+6PNwZO9Iv2/Glx6IR3oi2XR6ZR982i7OCGR+afB5OYNX7UeY94j7yKFUpLqdOnmeMwbEs+ml67te9S3fhov2nom000PAdtcOU7utPf36yUji5R4XFiu85W/Dav67bW3DldZsc7NX8a6J+vtsucvtDAvfedGs/5FLPd7a0FFq3InqxnMxvv5F7bilN4h9kqk26fVBipGj82e1Bun26x4WnYBNt8Bu+P0Hs0/3xuUa3hqebqjP1lN19CUJgCEoX3QCC8FtAXdstPALpVj5ktxCnQWCTKhQLl0iTA/tfaPbGuCPSv1/437Jq1i5JC4krJopEjDXnNEUiSwoPA4FH4AAqiUCQdfc2RrNKVeDm7eCBcf31X8g/uv1/LdSWgNUva/sRCvz667vCzDav2JCLESXEIHz+UC+LXR/MvMJnFWErDtyyNpzMKQ5ii35t1blQqctR88f3AdTXbtZWlRLYk9J7XWzpXo7aNQ0a6fxrolDx4mtM7OxU0LRsqm+5+qQC45iLMXa7uTNBEPCwqZA9V+kP56p7cbSiBewZ8mdaNqd7rE70tezto8EJ5yj0z7I9ZLVu+DfaG8R8ZqqAyMq7c2bpj9ITCSD97XLVQUkfTtweZx+on87J92S6PMM1HKMpx+WMMAKAdkH+j8nTGoNwQODwFraIwUcB/3+dRUHF5UnCXfV2oHG7ORK3EsmsOd06YviXI0KSHm5p10LAjPu1AHozbv9TtSCP8PEqY1j3HOeEkd7y+dCijeyfb8JRlLbzcf3hq+M9hGymtYk8e3klTia93GmKKjXEMNp3HL5q/UqcVNREVmVw3n3KnLLYINwDA8bVkyBXhhcYG/LImfREuzMMXh8d6oo4iKGBQJI8BdsgZR8nm1qaA5t+/9URg8NDq46MemtAqsYRMaVSXlDM6JLGdjemVORpbyMZce/YQzcu7+j3I27Id0pLbUiSuK5hq2CcizD4HjQeZ5B1qD6f/9DK+gSfLp+WPkz7U4TJI2vZcrt998pN8qOMu2wZKKOocF+263/ihwiE9Cpm8ofumfeqFz4fSpWCR/H9RMWePtr1iSf5rcy8H9XREokzTyUdH0Ocy8uZErsV0DFBbfPz+mc8v+HHSQHpWnPhbRy33L3GaCxfYexck1PIBAN5EG2U9SvI0/6szHoXFQFMl15DPWqnIQdcye32EWskwrIT6t4femv2Pvzi8w4mEfpQ2+JF2UVWz9c/r0k87w7YHrT//MSnF5rMg6q5LkPM7WxnfvT3eORruMpsxx2AjYpY2t3L8VPrPIDHZRhWt7DzT0iJlC0+Paob6mp8bBQvIvwisEt+/Rz80MtcmJaYqRZbQHoeMFjrqj9ZF36mD4z9VBtBa1nIW1P2A697FaP1Fb/qwdP01O15NzFhWIHeQSISd9k6L/cbchz4V66nlH2t7pHz4zSZ3tYYfvucFkEb7md4gD7l9v1V0yHjim00u/DC67n1YXyyrclxRFHPm1Bxb4EI1i4Jb8o4CADKJbi5lMqPF+iF80M4BOAr2sQaFVDBXhB8CjfWiYE/D10j578nu6ewFrazGhb+397opjeqMMX+5zT7wC7t2Y9dvoG6O5PwsIiYouF6lPUDDJeHA0WhNC/mQt12B1zkZIm+XpE88akIosaGN2KSSQw/GJBXUI9I4rRTyCptevx6YVW3HNhtOeAPFNKG/UM0grAXBktj90fmVyvEbL9O84E/Qn2mP18o7aO2Rh0fCIswn/5I8qnr7uZaN6T42cw6N7K5m+aedDM/9vcsW+g3Jgq/r0wAAk0SzZLTWLK10Cro25f/cALQtnU7eWhyG+5/MnP4kon4yU/y8De3kuDidf5bEF7ZPYmP1Lu7jTGc33h11dBw4UH2qdfJVv224dFLaU+p7G2VjeIxjHpu94X/MkLt/x8xkcFZ7Tqfl04Bw6fKvnnqhZydNqba/mNMfqInNqZWcj1u74KO6LwCgkGjcpmuNm9ip1mh8OESbQ/9L4J+psINnH7TsZ7ClK4C9KrveMnslW8DLRIvl7ez4ZeUZPdUc8dMzynm2Kd37Ht/g/+xUY1dbq1yFSHV4zFk1nvPoNk8qWzbS9JaB3kHBhFpbFuWQJ2Lwt/CvOk8ftWkNtT9QUzHW6ufvenbS76nstQn58642sSEbeW76CJrsGlvoyqbT66bPAQCy19QiYF08SHiPR+p1bBEubNffXxDDiQ/z13GrunpTI+nnpo3SdY3w21ufF3b3WlxX6Law3gI0Zk7qCQT+LqCnMTOTidl5Mdvpku6941F3zyM5TjdNnqWjs49QUGDanVX9I313fVY/074rO75V3Bgbg1vgmMdwW0cNZXs34CwbjcZwG7aNctzQ1si9YqYV+i789TQX3TCTsvSNqYiDHTJSUrRhautCzTrdbKIqNereDzEzbbmlSrWwx1IxkX1XAQC21ORfHRbn4J8vBZz7QgosrJ+aNjS2mRrKNXf3Wlgz1NfJWf/ju6mTszbIMTBWkN9rbG5gaPwYZmhlUG/abCJvYSDT1Li39S01jfbCoy+60OKL3t9NDrEFIERcJEpJDUNB+aVWR/2P3iUscHj5YPHYQ75uFKhXIQ0ZpvBTvjzKTR6DcEHgcM4+AZTGsvzlyAeBw/r6uCB+2eVoHhDm5XsITcIbrqW4EqTgwtzxnpS8goKRDL7mxSNFEpUX2heJomT9K5EBv+ZYZEgiW8NiUiCLAOaCo2SYpUo2yZoTp0geJcrTGUnJLVOdApo1xyZPHulh3C87J4lw/Edn/gLD/D/9soZlCfKaI1j+RZ8vHoWm7I2xCDG8Natdvxz632Aey6qkouai+b9OQi/vzyfc/M9c8M9PEtzHiwEJDbb8EMDSZQGXGoL/j7i8MfefHw4wp3OUCqxq010Zix+CVbMS1pIpNjReQvupGCTejdSAPJsuMbGCELFGNIB0NytUL6GjUxKi9+qqoORJ5oFIzqIFq3tEoVIJrZIiEKnfVwRb9qXvYmBC4x8UeIoOkOO7XAxMaFwShACfpgekugiJ5XQTJKdCzIA0BxSp68qLKOAiBxQ0dEKbjTgk9OpVQRc7oIgJFoYIRrMCsmw7UM2EXhpZiOZHpOAuY9shplwconwnGyDbobMytiwE+yKp2KucbYS2FmVIfn6Qx0Ds4PiHitANogahamEHa3fNLKYjtE78BqGjXQ9+keGE9G23hxOQbtGABkLYI0CP86RVQZe2HsQkb4FIniWOvtidsbJoaYhoqw2AAncG6bKLieMvNmaQKns9F6DAmEFMtihEth8p+K6krRI56O4iDZk88ZIQ8WrcgAI7xsoBKEICiCcdnbwgoA8aah5AlhMDKp/QIAF90NiRgruME4OYchGI8ifEGZbaLlbOPFS6FC+gyHaxmIHQm8AHYYhclmGx44L0fsl7IyDN30DqqqgkCrjU3wANnNAhIA8JfBMfoNDfQLr2d8Q5ljgPSG0+NDYBCp0HKzMoQhguk8ew2HkALQLhdF0bUgQ6fvDrnAeLaQmH3noQWnkB8EsH+YuZCQfQ0NaHdTP4RSN2YrVUhtRyikzOZQbdK1NpQKjcBMGvGnQvuk4SjHPhkIy+WCPlSoPuxQoIB6tGEAVzQuC/GSIvlkA4yzSFSBjfAv6zeS7pxx29CCBrigqNjnCaCG2gnEjBXW6KupiCcBYIfdC6iAKKhpTEkiMESQ6DGCBjwrhygyAF0e24OupamuJK4vDLDBdXFq4CES4gDtY6XCS9KYlYlmyZURCpK/0NUcClc8WVcSUguKoSgPy54soph0FSHkcyOHlLRgoSwhxJLEtGiisHoQRd8JJgDSNFYmHIQMJ4TBIPWUtIAUIgJwUonyaunC1VSLaiySYhL2fQppFWGqxlkLhyUOqQoDwooCEvLHlIWN3k8R3GUXAc7pIBa50hkn6q3yFOtsz4kNRXHRyygLLxITHxfBDxR5alWDo5XFkydBxRRwyPPKHrIUIl5ADRoSHdun98mnAgLgAARu7nb/8LAAD//8jA88epSAAA"); err != nil { + panic("add binary content to resource manager failed: " + err.Error()) + } +} diff --git a/server/internal/library/hggen/internal/utility/utils/utils_http_download.go b/server/internal/library/hggen/internal/utility/utils/utils_http_download.go index d68e61c..3210d1d 100644 --- a/server/internal/library/hggen/internal/utility/utils/utils_http_download.go +++ b/server/internal/library/hggen/internal/utility/utils/utils_http_download.go @@ -69,16 +69,18 @@ func doPrintDownloadPercent(doneCh chan int64, localSaveFilePath string, total i stop = false lastPercentFmt string ) + file, err := os.Open(localSaveFilePath) + if err != nil { + mlog.Fatal(err) + } + defer file.Close() + for { select { case <-doneCh: stop = true default: - file, err := os.Open(localSaveFilePath) - if err != nil { - mlog.Fatal(err) - } fi, err := file.Stat() if err != nil { mlog.Fatal(err) diff --git a/server/internal/library/hggen/views/column_default.go b/server/internal/library/hggen/views/column_default.go index 040f9c2..41729be 100644 --- a/server/internal/library/hggen/views/column_default.go +++ b/server/internal/library/hggen/views/column_default.go @@ -62,6 +62,8 @@ var defaultSort = map[string]bool{ "sort": true, } +var defaultTreeFields = []string{"pid", "level", "tree"} + // 默认表单验证映射 物理类型命名识别 var defaultFormRoleMap = map[string]string{ "mobile": FormRolePhone, diff --git a/server/internal/library/hggen/views/curd_generate_input.go b/server/internal/library/hggen/views/curd_generate_input.go index 2861b0c..2e94944 100644 --- a/server/internal/library/hggen/views/curd_generate_input.go +++ b/server/internal/library/hggen/views/curd_generate_input.go @@ -165,6 +165,32 @@ func (l *gCurd) generateStructFieldDefinition(in *CurdPreviewInput, field *sysin return result } + isUpdateOrInsertInputFields := func() bool { + if !isMaster { + return field.IsEdit + } + + if field.IsEdit { + return true + } + + // 树表内部维护字段 + if in.options.Step.IsTreeTable && gstr.InArray(defaultTreeFields, field.Name) { + return true + } + + // 修改人 + if inputType == InputTypeUpdateFields && field.GoName == "UpdatedBy" { + return true + } + + // 创建人 + if inputType == InputTypeInsertFields && field.GoName == "CreatedBy" { + return true + } + return false + } + isQuery := false switch inputType { @@ -225,12 +251,12 @@ func (l *gCurd) generateStructFieldDefinition(in *CurdPreviewInput, field *sysin } result = []string{rule} case InputTypeUpdateFields: - if !field.IsEdit && field.GoName != "UpdatedBy" { + if !isUpdateOrInsertInputFields() { return nil } addResult() case InputTypeInsertFields: - if !field.IsEdit && field.GoName != "CreatedBy" { + if !isUpdateOrInsertInputFields() { return nil } addResult() diff --git a/server/internal/library/hggen/views/curd_generate_web_edit.go b/server/internal/library/hggen/views/curd_generate_web_edit.go index dd4ceb9..2bb771c 100644 --- a/server/internal/library/hggen/views/curd_generate_web_edit.go +++ b/server/internal/library/hggen/views/curd_generate_web_edit.go @@ -67,20 +67,20 @@ func (l *gCurd) generateWebEditFormItem(ctx context.Context, in *CurdPreviewInpu // case FormModeTimeRange: // 必须要有两个字段,后面优化下 case FormModeRadio: - component = fmt.Sprintf("\n \n \n \n ", field.Dc, field.TsName, field.TsName, field.TsName, field.TsName, in.options.dictMap[field.TsName], field.TsName, field.TsName, field.TsName) + component = fmt.Sprintf("\n \n \n \n ", field.Dc, field.TsName, field.TsName, field.TsName, field.TsName, in.options.dictMap[field.TsName], field.TsName, field.TsName, field.TsName) case FormModeCheckbox: - component = fmt.Sprintf("\n \n \n \n \n \n ", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName]) + component = fmt.Sprintf("\n \n \n \n \n \n ", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName]) case FormModeSelect: if in.options.dictMap[field.TsName] != nil { - component = fmt.Sprintf("\n \n ", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName]) + component = fmt.Sprintf("\n \n ", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName]) } else { component = fmt.Sprintf("\n \n ", field.Dc, field.TsName, field.TsName) } case FormModeSelectMultiple: - component = fmt.Sprintf("\n \n ", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName]) + component = fmt.Sprintf("\n \n ", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName]) case FormModeUploadImage: component = fmt.Sprintf("\n \n ", field.Dc, field.TsName, field.TsName) @@ -154,6 +154,11 @@ func (l *gCurd) generateWebEditScript(ctx context.Context, in *CurdPreviewInput) importBuffer.WriteString(" import { ref, computed } from 'vue';\n") + // 导入字典 + if in.options.DictOps.Has { + importBuffer.WriteString(" import { useDictStore } from '@/store/modules/dict';\n") + } + // 导入api var importApiMethod = []string{"Edit", "View"} if in.options.Step.HasMaxSort { @@ -162,7 +167,7 @@ func (l *gCurd) generateWebEditScript(ctx context.Context, in *CurdPreviewInput) importBuffer.WriteString(" import " + ImportWebMethod(importApiMethod) + " from '" + in.options.ImportWebApi + "';\n") // 导入model - var importModelMethod = []string{"options", "State", "newState"} + var importModelMethod = []string{"State", "newState"} if in.options.Step.IsTreeTable { importModelMethod = append(importModelMethod, []string{"treeOption", "loadTreeOption"}...) } diff --git a/server/internal/library/hggen/views/curd_generate_web_index.go b/server/internal/library/hggen/views/curd_generate_web_index.go index 6674765..4ec37d8 100644 --- a/server/internal/library/hggen/views/curd_generate_web_index.go +++ b/server/internal/library/hggen/views/curd_generate_web_index.go @@ -60,8 +60,6 @@ func (l *gCurd) webIndexTplData(ctx context.Context, in *CurdPreviewInput) (g.Ma // 修改状态 if in.options.Step.HasStatus { importApiMethod = append(importApiMethod, "Status") - importUtilsMethod = append(importUtilsMethod, "getOptionLabel") - importModelMethod = append(importModelMethod, "options") in.options.Step.ActionColumnWidth += actionWidth } @@ -108,6 +106,11 @@ func (l *gCurd) webIndexTplData(ctx context.Context, in *CurdPreviewInput) (g.Ma importBuffer.WriteString(" import { BasicForm, useForm } from '@/components/Form/index';\n") importBuffer.WriteString(" import { usePermission } from '@/hooks/web/usePermission';\n") + // 导入字典 + if in.options.DictOps.Has { + importBuffer.WriteString(" import { useDictStore } from '@/store/modules/dict';\n") + } + // 导入api importBuffer.WriteString(" import " + ImportWebMethod(importApiMethod) + " from '" + in.options.ImportWebApi + "';\n") diff --git a/server/internal/library/hggen/views/curd_generate_web_model.go b/server/internal/library/hggen/views/curd_generate_web_model.go index 6331050..b4d596f 100644 --- a/server/internal/library/hggen/views/curd_generate_web_model.go +++ b/server/internal/library/hggen/views/curd_generate_web_model.go @@ -34,12 +34,13 @@ func (l *gCurd) webModelTplData(ctx context.Context, in *CurdPreviewInput) (data } // 根据表单生成情况,按需导包 - data["import"] = l.generateWebModelImport(ctx, in) + data["import"], data["const"] = l.generateWebModelImport(ctx, in) return } -func (l *gCurd) generateWebModelImport(ctx context.Context, in *CurdPreviewInput) string { +func (l *gCurd) generateWebModelImport(ctx context.Context, in *CurdPreviewInput) (string, string) { importBuffer := bytes.NewBuffer(nil) + constBuffer := bytes.NewBuffer(nil) importBuffer.WriteString("import { h, ref } from 'vue';\n") @@ -55,11 +56,6 @@ func (l *gCurd) generateWebModelImport(ctx context.Context, in *CurdPreviewInput importBuffer.WriteString("import { FormSchema } from '@/components/Form';\n") } - // 导入字典选项 - if in.options.DictOps.Has { - importBuffer.WriteString("import { Dicts } from '@/api/dict/dict';\n") - } - // 导入工具类 if len(in.options.Step.ImportModel.UtilsIs) > 0 { importBuffer.WriteString("import " + ImportWebMethod(in.options.Step.ImportModel.UtilsIs) + " from '@/utils/is';\n") @@ -97,12 +93,19 @@ func (l *gCurd) generateWebModelImport(ctx context.Context, in *CurdPreviewInput importBuffer.WriteString("import " + ImportWebMethod(importApiMethod) + " from '" + in.options.ImportWebApi + "';\n") } + // 导入字典选项 + if in.options.DictOps.Has { + importBuffer.WriteString("import { useDictStore } from '@/store/modules/dict';\n") + constBuffer.WriteString("const dict = useDictStore();\n") + } + if in.options.Step.HasSwitch { importBuffer.WriteString("import { usePermission } from '@/hooks/web/usePermission';\n") - importBuffer.WriteString("const { hasPermission } = usePermission();\n") - importBuffer.WriteString("const $message = window['$message'];\n") + constBuffer.WriteString("const { hasPermission } = usePermission();\n") + constBuffer.WriteString("const $message = window['$message'];\n") } - return importBuffer.String() + + return importBuffer.String(), constBuffer.String() } func (l *gCurd) generateWebModelStateItems(ctx context.Context, in *CurdPreviewInput) (items []*StateItem) { @@ -212,9 +215,6 @@ func (l *gCurd) generateWebModelDictOptions(ctx context.Context, in *CurdPreview in.options.DictOps.Has = true - // 导入选项包 - in.options.Step.ImportModel.UtilsHotGo = append(in.options.Step.ImportModel.UtilsHotGo, "Option") - for _, v := range dictTypeList { // 字段映射字典 for _, field := range in.masterFields { @@ -272,6 +272,11 @@ func (l *gCurd) generateWebModelFormSchema(ctx context.Context, in *CurdPreviewI return buffer.String() } +// generateWebDictOption 生产字典选项 +func (l *gCurd) generateWebDictOption(typ any) string { + return fmt.Sprintf(`dict.getOption('%v')`, typ) +} + func (l *gCurd) generateWebModelFormSchemaEach(buffer *bytes.Buffer, fields []*sysin.GenCodesColumnListModel, in *CurdPreviewInput) { for _, field := range fields { if !field.IsQuery { @@ -317,16 +322,16 @@ func (l *gCurd) generateWebModelFormSchemaEach(buffer *bytes.Buffer, fields []*s case FormModeSwitch: fallthrough case FormModeRadio: - component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n giProps: {\n //span: 24,\n },\n componentProps: {\n options: [],\n onUpdateChecked: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NRadioGroup", field.Dc) + component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n giProps: {\n //span: 24,\n },\n componentProps: {\n options: %v,\n onUpdateChecked: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NRadioGroup", field.Dc, l.generateWebDictOption(in.options.dictMap[field.TsName])) case FormModeCheckbox: - component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n giProps: {\n span: 1,\n },\n componentProps: {\n placeholder: '请选择%s',\n options: [],\n onUpdateChecked: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NCheckbox", field.Dc, field.Dc) + component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n giProps: {\n span: 1,\n },\n componentProps: {\n placeholder: '请选择%s',\n options: %v,\n onUpdateChecked: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NCheckbox", field.Dc, field.Dc, l.generateWebDictOption(in.options.dictMap[field.TsName])) case FormModeSelect: - component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n defaultValue: null,\n componentProps: {\n placeholder: '请选择%s',\n options: [],\n onUpdateValue: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NSelect", field.Dc, field.Dc) + component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n defaultValue: null,\n componentProps: {\n placeholder: '请选择%s',\n options: %v,\n onUpdateValue: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NSelect", field.Dc, field.Dc, l.generateWebDictOption(in.options.dictMap[field.TsName])) case FormModeSelectMultiple: - component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n defaultValue: null,\n componentProps: {\n multiple: true,\n placeholder: '请选择%s',\n options: [],\n onUpdateValue: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NSelect", field.Dc, field.Dc) + component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n defaultValue: null,\n componentProps: {\n multiple: true,\n placeholder: '请选择%s',\n options: %v,\n onUpdateValue: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NSelect", field.Dc, field.Dc, l.generateWebDictOption(in.options.dictMap[field.TsName])) default: component = defaultComponent @@ -373,7 +378,7 @@ func (l *gCurd) generateWebModelColumnsEach(buffer *bytes.Buffer, in *CurdPrevie // 查询用户摘要 if in.options.Step.HasHookMemberSummary && IsMemberSummaryField(field.Name) { - buffer.WriteString(fmt.Sprintf(" {\n title: '%v',\n key: '%v',\n align: '%v',\n width: %v,\n render(row) {\n return renderPopoverMemberSumma(row.%vSumma);\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName)) + buffer.WriteString(fmt.Sprintf(" {\n title: '%v',\n key: '%v',\n align: '%v',\n width: %v,\n render(row: State) {\n return renderPopoverMemberSumma(row.%vSumma);\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName)) in.options.Step.ImportModel.UtilsIndex = append(in.options.Step.ImportModel.UtilsIndex, []string{"renderPopoverMemberSumma", "MemberSumma"}...) continue } @@ -381,7 +386,7 @@ func (l *gCurd) generateWebModelColumnsEach(buffer *bytes.Buffer, in *CurdPrevie // 这里根据编辑表单组件来进行推断,如果没有则使用默认input,这可能会导致和查询条件所需参数不符的情况 switch field.FormMode { case FormModeDate: - component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row) {\n return formatToDate(row.%s);\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName) + component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row: State) {\n return formatToDate(row.%s);\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName) in.options.Step.ImportModel.UtilsDate = append(in.options.Step.ImportModel.UtilsDate, "formatToDate") case FormModeRadio: @@ -391,49 +396,46 @@ func (l *gCurd) generateWebModelColumnsEach(buffer *bytes.Buffer, in *CurdPrevie err = gerror.Newf("设置单选下拉框选项时,必须选择字典类型,字段名称:%v", field.Name) return } - component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row) {\n if (isNullObject(row.%s)) {\n return ``;\n }\n return h(\n NTag,\n {\n style: {\n marginRight: '6px',\n },\n type: getOptionTag(options.value.%s, row.%s),\n bordered: false,\n },\n {\n default: () => getOptionLabel(options.value.%s, row.%s),\n }\n );\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName, in.options.dictMap[field.TsName], field.TsName, in.options.dictMap[field.TsName], field.TsName) - in.options.Step.ImportModel.NaiveUI = append(in.options.Step.ImportModel.NaiveUI, "NTag") - in.options.Step.ImportModel.UtilsIs = append(in.options.Step.ImportModel.UtilsIs, "isNullObject") - in.options.Step.ImportModel.UtilsHotGo = append(in.options.Step.ImportModel.UtilsHotGo, []string{"getOptionLabel", "getOptionTag"}...) + component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row: State) {\n return renderOptionTag('%v', row.%v);\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, in.options.dictMap[field.TsName], field.TsName) + in.options.Step.ImportModel.UtilsIndex = append(in.options.Step.ImportModel.UtilsIndex, "renderOptionTag") case FormModeSelectMultiple: if g.IsEmpty(in.options.dictMap[field.TsName]) { err = gerror.Newf("设置多选下拉框选项时,必须选择字典类型,字段名称:%v", field.Name) return } - component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row) {\n if (isNullObject(row.%s) || !isArray(row.%s)) {\n return ``;\n }\n return row.%s.map((tagKey) => {\n return h(\n NTag,\n {\n style: {\n marginRight: '6px',\n },\n type: getOptionTag(options.value.%s, tagKey),\n bordered: false,\n },\n {\n default: () => getOptionLabel(options.value.%s, tagKey),\n }\n );\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName, field.TsName, field.TsName, in.options.dictMap[field.TsName], in.options.dictMap[field.TsName]) + component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row: State) {\n if (isNullObject(row.%s) || !isArray(row.%s)) {\n return ``;\n }\n return row.%s.map((tagKey) => {\n return renderOptionTag('%s', row.tagKey)\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName, field.TsName, field.TsName, in.options.dictMap[field.TsName]) in.options.Step.ImportModel.NaiveUI = append(in.options.Step.ImportModel.NaiveUI, "NTag") in.options.Step.ImportModel.UtilsIs = append(in.options.Step.ImportModel.UtilsIs, "isNullObject") - in.options.Step.ImportModel.UtilsHotGo = append(in.options.Step.ImportModel.UtilsHotGo, []string{"getOptionLabel", "getOptionTag"}...) case FormModeUploadImage: - component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row) {\n return h(%s, {\n width: 32,\n height: 32,\n src: row.%s,\n fallbackSrc: errorImg,\n onError: errorImg,\n style: {\n width: '32px',\n height: '32px',\n 'max-width': '100%%',\n 'max-height': '100%%',\n },\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, "NImage", field.TsName) + component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row: State) {\n return h(%s, {\n width: 32,\n height: 32,\n src: row.%s,\n fallbackSrc: fallbackSrc(),\n onError: errorImg,\n style: {\n width: '32px',\n height: '32px',\n 'max-width': '100%%',\n 'max-height': '100%%',\n },\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, "NImage", field.TsName) in.options.Step.ImportModel.NaiveUI = append(in.options.Step.ImportModel.NaiveUI, "NImage") - in.options.Step.ImportModel.UtilsHotGo = append(in.options.Step.ImportModel.UtilsHotGo, "errorImg") + in.options.Step.ImportModel.UtilsHotGo = append(in.options.Step.ImportModel.UtilsHotGo, "fallbackSrc") case FormModeUploadImages: - component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row) {\n if (isNullObject(row.%s)) {\n return ``;\n }\n return row.%s.map((image) => {\n return h(%s, {\n width: 32,\n height: 32,\n src: image,\n onError: errorImg,\n style: {\n width: '32px',\n height: '32px',\n 'max-width': '100%%',\n 'max-height': '100%%',\n 'margin-left': '2px',\n },\n });\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName, field.TsName, "NImage") + component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row: State) {\n if (isNullObject(row.%s)) {\n return ``;\n }\n return row.%s.map((image) => {\n return h(%s, {\n width: 32,\n height: 32,\n src: image,\n onError: errorImg,\n style: {\n width: '32px',\n height: '32px',\n 'max-width': '100%%',\n 'max-height': '100%%',\n 'margin-left': '2px',\n },\n });\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName, field.TsName, "NImage") in.options.Step.ImportModel.NaiveUI = append(in.options.Step.ImportModel.NaiveUI, "NImage") in.options.Step.ImportModel.UtilsIs = append(in.options.Step.ImportModel.UtilsIs, "isArray") in.options.Step.ImportModel.UtilsHotGo = append(in.options.Step.ImportModel.UtilsHotGo, "errorImg") case FormModeUploadFile: - component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row) {\n if (row.%s === '') {\n return ``;\n }\n return h(\n %s,\n {\n size: 'small',\n },\n {\n default: () => getFileExt(row.%s),\n }\n );\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName, "NAvatar", field.TsName) + component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row: State) {\n if (row.%s === '') {\n return ``;\n }\n return h(\n %s,\n {\n size: 'small',\n },\n {\n default: () => getFileExt(row.%s),\n }\n );\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName, "NAvatar", field.TsName) in.options.Step.ImportModel.NaiveUI = append(in.options.Step.ImportModel.NaiveUI, "NAvatar") in.options.Step.ImportModel.UtilsUrl = append(in.options.Step.ImportModel.UtilsUrl, "getFileExt") case FormModeUploadFiles: - component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row) {\n if (isNullObject(row.%s)) {\n return ``;\n }\n return row.%s.map((attachfile) => {\n return h(\n %s,\n {\n size: 'small',\n style: {\n 'margin-left': '2px',\n },\n },\n {\n default: () => getFileExt(attachfile),\n }\n );\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName, field.TsName, "NAvatar") + component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row: State) {\n if (isNullObject(row.%s)) {\n return ``;\n }\n return row.%s.map((attachfile) => {\n return h(\n %s,\n {\n size: 'small',\n style: {\n 'margin-left': '2px',\n },\n },\n {\n default: () => getFileExt(attachfile),\n }\n );\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, field.TsName, field.TsName, "NAvatar") in.options.Step.ImportModel.NaiveUI = append(in.options.Step.ImportModel.NaiveUI, "NAvatar") in.options.Step.ImportModel.UtilsIs = append(in.options.Step.ImportModel.UtilsIs, "isNullObject") in.options.Step.ImportModel.UtilsUrl = append(in.options.Step.ImportModel.UtilsUrl, "getFileExt") case FormModeSwitch: - component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row) {\n return h(%s, {\n value: row.%s === 1,\n checked: '开启',\n unchecked: '关闭',\n disabled: !hasPermission(['%s']),\n onUpdateValue: function (e) {\n console.log('onUpdateValue e:' + JSON.stringify(e));\n row.%s = e ? 1 : 2;\n Switch({ %s: row.%s, key: '%s', value: row.%s }).then((_res) => {\n $message.success('操作成功');\n });\n },\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, "NSwitch", field.TsName, "/"+in.options.ApiPrefix+"/switch", field.TsName, in.pk.TsName, in.pk.TsName, convert.CamelCaseToUnderline(field.TsName), field.TsName) + component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row: State) {\n return h(%s, {\n value: row.%s === 1,\n checked: '开启',\n unchecked: '关闭',\n disabled: !hasPermission(['%s']),\n onUpdateValue: function (e) {\n console.log('onUpdateValue e:' + JSON.stringify(e));\n row.%s = e ? 1 : 2;\n Switch({ %s: row.%s, key: '%s', value: row.%s }).then((_res) => {\n $message.success('操作成功');\n });\n },\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, "NSwitch", field.TsName, "/"+in.options.ApiPrefix+"/switch", field.TsName, in.pk.TsName, in.pk.TsName, convert.CamelCaseToUnderline(field.TsName), field.TsName) in.options.Step.ImportModel.NaiveUI = append(in.options.Step.ImportModel.NaiveUI, "NSwitch") case FormModeRate: - component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row) {\n return h(%s, {\n allowHalf: true,\n readonly: true,\n defaultValue: row.%s,\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, "NRate", field.TsName) + component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n align: '%v',\n width: %v,\n render(row: State) {\n return h(%s, {\n allowHalf: true,\n readonly: true,\n defaultValue: row.%s,\n });\n },\n },\n", field.Dc, field.TsName, field.Align, field.Width, "NRate", field.TsName) in.options.Step.ImportModel.NaiveUI = append(in.options.Step.ImportModel.NaiveUI, "NRate") default: diff --git a/server/internal/library/hggen/views/curd_generate_web_view.go b/server/internal/library/hggen/views/curd_generate_web_view.go index 39363a7..304ab32 100644 --- a/server/internal/library/hggen/views/curd_generate_web_view.go +++ b/server/internal/library/hggen/views/curd_generate_web_view.go @@ -44,16 +44,16 @@ func (l *gCurd) generateWebViewItem(ctx context.Context, in *CurdPreviewInput) s component = defaultComponent case FormModeRadio, FormModeSelect: - component = fmt.Sprintf("\n {{ getOptionLabel(options.%s, formValue?.%s) }}\n ", field.Dc, in.options.dictMap[field.TsName], field.TsName, in.options.dictMap[field.TsName], field.TsName) + component = fmt.Sprintf("\n {{ dict.getLabel('%s', formValue.%s) }}\n ", field.Dc, in.options.dictMap[field.TsName], field.TsName, in.options.dictMap[field.TsName], field.TsName) case FormModeCheckbox, FormModeSelectMultiple: - component = fmt.Sprintf("\n \n ", field.Dc, field.TsName, in.options.dictMap[field.TsName], in.options.dictMap[field.TsName]) + component = fmt.Sprintf("\n \n ", field.Dc, field.TsName, in.options.dictMap[field.TsName], in.options.dictMap[field.TsName]) case FormModeUploadImage: component = fmt.Sprintf("\n \n ", field.Dc, field.TsName) case FormModeUploadImages: - component = fmt.Sprintf("\n \n \n \n \n \n \n \n \n ", field.Dc, field.TsName) + component = fmt.Sprintf("\n \n \n \n \n \n \n \n \n ", field.Dc, field.TsName) case FormModeUploadFile: component = fmt.Sprintf("\n \n
\n
\n
\n
\n {{ getFileExt(formValue.%s) }}\n
\n
\n
\n
\n
", field.Dc, field.TsName, field.TsName, field.TsName) diff --git a/server/internal/library/hggen/views/utils.go b/server/internal/library/hggen/views/utils.go index 588ea2a..e159d0e 100644 --- a/server/internal/library/hggen/views/utils.go +++ b/server/internal/library/hggen/views/utils.go @@ -8,6 +8,7 @@ package views import ( "context" "fmt" + "github.com/gogf/gf/v2/util/gutil" "hotgo/internal/consts" "hotgo/internal/library/hggen/views/gohtml" "hotgo/internal/model" @@ -227,7 +228,7 @@ func ImportWebMethod(vs []string) string { // CheckTreeTableFields 检查树表字段 func CheckTreeTableFields(columns []*sysin.GenCodesColumnListModel) (err error) { - var fields = []string{"pid", "level", "tree"} + var fields = gutil.Copy(defaultTreeFields).([]string) for _, v := range columns { if validate.InSlice(fields, v.Name) { fields = convert.RemoveSlice(fields, v.Name) diff --git a/server/internal/library/storager/upload.go b/server/internal/library/storager/upload.go index 78f9761..a2683c9 100644 --- a/server/internal/library/storager/upload.go +++ b/server/internal/library/storager/upload.go @@ -196,9 +196,9 @@ func GetFileMeta(file *ghttp.UploadFile) (meta *FileMeta, err error) { } // 兼容naiveUI - naiveType := "text/plain" - if IsImgType(Ext(file.Filename)) { - naiveType = "" + naiveType := meta.MimeType + if len(naiveType) == 0 { + naiveType = "text/plain" } meta.NaiveType = naiveType diff --git a/server/internal/logic/sys/attachment.go b/server/internal/logic/sys/attachment.go index d4f6673..7f08ec7 100644 --- a/server/internal/logic/sys/attachment.go +++ b/server/internal/logic/sys/attachment.go @@ -11,8 +11,10 @@ import ( "github.com/gogf/gf/v2/errors/gerror" "hotgo/internal/dao" "hotgo/internal/library/contexts" + "hotgo/internal/library/dict" "hotgo/internal/library/hgorm/handler" "hotgo/internal/library/storager" + "hotgo/internal/model" "hotgo/internal/model/input/sysin" "hotgo/internal/service" "hotgo/utility/format" @@ -26,6 +28,7 @@ func NewSysAttachment() *sSysAttachment { func init() { service.RegisterSysAttachment(NewSysAttachment()) + dict.RegisterFunc("AttachmentKindOption", "上传类型选项", service.SysAttachment().AttachmentKindOption) } // Model ORM模型 @@ -111,3 +114,15 @@ func (s *sSysAttachment) ClearKind(ctx context.Context, in *sysin.AttachmentClea } return } + +// AttachmentKindOption 上传类型选项 +func (s *sSysAttachment) AttachmentKindOption(ctx context.Context) (opts []*model.Option, err error) { + opts = append(opts, dict.GenDefaultOption("", "全部")) + opts = append(opts, dict.GenSuccessOption(storager.KindImg, "图片", "PictureOutlined")) + opts = append(opts, dict.GenPrimaryOption(storager.KindDoc, "文档", "FileWordOutlined")) + opts = append(opts, dict.GenSuccessOption(storager.KindAudio, "音频", "CustomerServiceOutlined")) + opts = append(opts, dict.GenSuccessOption(storager.KindVideo, "视频", "PlaySquareOutlined")) + opts = append(opts, dict.GenSuccessOption(storager.KindZip, "压缩包", "FileZipOutlined")) + opts = append(opts, dict.GenSuccessOption(storager.KindOther, "其他", "PlusOutlined")) + return +} diff --git a/server/internal/logic/sys/curd_demo.go b/server/internal/logic/sys/curd_demo.go index 72c8828..b661779 100644 --- a/server/internal/logic/sys/curd_demo.go +++ b/server/internal/logic/sys/curd_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sys import ( @@ -69,11 +69,6 @@ func (s *sSysCurdDemo) List(ctx context.Context, in *sysin.CurdDemoListInp) (lis mod = mod.WhereLike(dao.SysGenCurdDemo.Columns().Description, "%"+in.Description+"%") } - // 查询状态 - if in.Status > 0 { - mod = mod.Where(dao.SysGenCurdDemo.Columns().Status, in.Status) - } - // 查询创建者 if in.CreatedBy != "" { ids, err := service.AdminMember().GetIdsByKeyword(ctx, in.CreatedBy) @@ -88,11 +83,6 @@ func (s *sSysCurdDemo) List(ctx context.Context, in *sysin.CurdDemoListInp) (lis mod = mod.WhereBetween(dao.SysGenCurdDemo.Columns().CreatedAt, in.CreatedAt[0], in.CreatedAt[1]) } - // 查询测试分类 - if in.CategoryId > 0 { - mod = mod.Where(dao.SysGenCurdDemo.Columns().CategoryId, in.CategoryId) - } - // 查询关联分类 if in.TestCategoryName != "" { mod = mod.WherePrefix(dao.TestCategory.Table(), dao.TestCategory.Columns().Name, in.TestCategoryName) @@ -145,6 +135,7 @@ func (s *sSysCurdDemo) Export(ctx context.Context, in *sysin.CurdDemoListInp) (e // Edit 修改/新增CURD列表 func (s *sSysCurdDemo) Edit(ctx context.Context, in *sysin.CurdDemoEditInp) (err error) { return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) { + // 修改 if in.Id > 0 { in.UpdatedBy = contexts.GetUserId(ctx) @@ -169,6 +160,7 @@ func (s *sSysCurdDemo) Edit(ctx context.Context, in *sysin.CurdDemoEditInp) (err // Delete 删除CURD列表 func (s *sSysCurdDemo) Delete(ctx context.Context, in *sysin.CurdDemoDeleteInp) (err error) { + if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil { err = gerror.Wrap(err, "删除CURD列表失败,请稍后重试!") return @@ -200,6 +192,18 @@ func (s *sSysCurdDemo) View(ctx context.Context, in *sysin.CurdDemoViewInp) (res return } +// Status 更新CURD列表状态 +func (s *sSysCurdDemo) Status(ctx context.Context, in *sysin.CurdDemoStatusInp) (err error) { + if _, err = s.Model(ctx).WherePri(in.Id).Data(g.Map{ + dao.SysGenCurdDemo.Columns().Status: in.Status, + dao.SysGenCurdDemo.Columns().UpdatedBy: contexts.GetUserId(ctx), + }).Update(); err != nil { + err = gerror.Wrap(err, "更新CURD列表状态失败,请稍后重试!") + return + } + return +} + // Switch 更新CURD列表开关 func (s *sSysCurdDemo) Switch(ctx context.Context, in *sysin.CurdDemoSwitchInp) (err error) { var fields = []string{ @@ -220,4 +224,4 @@ func (s *sSysCurdDemo) Switch(ctx context.Context, in *sysin.CurdDemoSwitchInp) return } return -} +} \ No newline at end of file diff --git a/server/internal/logic/sys/ems_log.go b/server/internal/logic/sys/ems_log.go index d75128d..3a042f0 100644 --- a/server/internal/logic/sys/ems_log.go +++ b/server/internal/logic/sys/ems_log.go @@ -186,7 +186,7 @@ func (s *sSysEmsLog) Send(ctx context.Context, in *sysin.SendEmsInp) (err error) data.Content = in.Content data.Code = in.Code data.Ip = location.GetClientIp(ghttp.RequestFromCtx(ctx)) - data.Status = consts.EmsStatusNotUsed + data.Status = consts.CodeStatusNotUsed data.CreatedAt = gtime.Now() data.UpdatedAt = gtime.Now() @@ -395,7 +395,7 @@ func (s *sSysEmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) } if in.Event != consts.EmsTemplateCode { - if models.Status == consts.EmsStatusUsed { + if models.Status == consts.CodeStatusUsed { err = gerror.New("验证码已使用,请重新发送!") return } @@ -414,7 +414,7 @@ func (s *sSysEmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) _, err = dao.SysEmsLog.Ctx(ctx).Where("id", models.Id).Data(g.Map{ "times": models.Times + 1, - "status": consts.EmsStatusUsed, + "status": consts.CodeStatusUsed, "updated_at": gtime.Now(), }).Update() return diff --git a/server/internal/logic/sys/log.go b/server/internal/logic/sys/log.go index 302368b..8747f22 100644 --- a/server/internal/logic/sys/log.go +++ b/server/internal/logic/sys/log.go @@ -17,6 +17,7 @@ import ( "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gmode" "hotgo/internal/consts" "hotgo/internal/dao" "hotgo/internal/global" @@ -226,7 +227,7 @@ func (s *sSysLog) AnalysisLog(ctx context.Context) entity.SysLog { takeUpTime = tt } - headerData.MustSet("qqq", request.EnterTime.String()) + headerData.MustAppend("Enter-Time", request.EnterTime.String()) data = entity.SysLog{ AppId: appId, @@ -237,7 +238,7 @@ func (s *sSysLog) AnalysisLog(ctx context.Context) entity.SysLog { Url: request.URL.Path, GetData: getData, PostData: postData, - HeaderData: headerData, + HeaderData: s.SimplifyHeaderParams(headerData), Ip: clientIp, ProvinceId: ipData.ProvinceCode, CityId: ipData.CityCode, @@ -255,6 +256,21 @@ func (s *sSysLog) AnalysisLog(ctx context.Context) entity.SysLog { return data } +// SimplifyHeaderParams 过滤掉请求头中的大参数 +func (s *sSysLog) SimplifyHeaderParams(data *gjson.Json) *gjson.Json { + if data == nil || data.IsNil() { + return data + } + var filters = []string{"Accept", "Authorization", "Cookie"} + for _, filter := range filters { + v := data.Get(filter) + if len(v.String()) > 128 { + data.MustRemove(filter) + } + } + return data +} + // View 获取指定请求日志信息 func (s *sSysLog) View(ctx context.Context, in *sysin.LogViewInp) (res *sysin.LogViewModel, err error) { mod := s.Model(ctx) @@ -350,7 +366,18 @@ func (s *sSysLog) List(ctx context.Context, in *sysin.LogListInp) (list []*sysin // 请求耗时 if dict.HasOptionKey(consts.HTTPHandlerTimeOptions, in.TakeUpTime) { - mod = mod.Where(fmt.Sprintf("`take_up_time` %v", in.TakeUpTime)) + mod = mod.Where(gdb.Raw(fmt.Sprintf("(`take_up_time` %v)", in.TakeUpTime))) + } + + // 非生产环境,允许关键词查询日志 + // 生成环境使用需谨慎,日志量大易产生慢日志 + if !gmode.IsProduct() && in.Keyword != "" { + mod = mod.Where("(`get_data` LIKE '%" + + in.Keyword + "%' or `post_data` LIKE '%" + + in.Keyword + "%' or `header_data` LIKE '%" + + in.Keyword + "%' or `error_data` LIKE '%" + + in.Keyword + "%' or `error_msg` LIKE '%" + + in.Keyword + "%')") } totalCount, err = mod.Count() diff --git a/server/internal/logic/sys/normal_tree_demo.go b/server/internal/logic/sys/normal_tree_demo.go index 6fd66a6..3fa4674 100644 --- a/server/internal/logic/sys/normal_tree_demo.go +++ b/server/internal/logic/sys/normal_tree_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sys import ( @@ -173,4 +173,4 @@ func (s *sSysNormalTreeDemo) TreeOption(ctx context.Context) (nodes []tree.Node, nodes[i] = v } return tree.ListToTree(0, nodes) -} +} \ No newline at end of file diff --git a/server/internal/logic/sys/option_tree_demo.go b/server/internal/logic/sys/option_tree_demo.go index 3f4ec51..9f50ab0 100644 --- a/server/internal/logic/sys/option_tree_demo.go +++ b/server/internal/logic/sys/option_tree_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sys import ( @@ -173,4 +173,4 @@ func (s *sSysOptionTreeDemo) TreeOption(ctx context.Context) (nodes []tree.Node, nodes[i] = v } return tree.ListToTree(0, nodes) -} +} \ No newline at end of file diff --git a/server/internal/logic/sys/serve_log.go b/server/internal/logic/sys/serve_log.go index e19c6cd..6df2ed7 100644 --- a/server/internal/logic/sys/serve_log.go +++ b/server/internal/logic/sys/serve_log.go @@ -11,6 +11,7 @@ import ( "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gmode" "hotgo/internal/dao" "hotgo/internal/library/hgorm" "hotgo/internal/library/hgorm/handler" @@ -46,6 +47,12 @@ func (s *sSysServeLog) List(ctx context.Context, in *sysin.ServeLogListInp) (lis mod = mod.Where(dao.SysServeLog.Columns().TraceId, in.TraceId) } + // 非生产环境,允许关键词查询日志 + // 生成环境使用需谨慎,日志量大易产生慢日志 + if !gmode.IsProduct() && in.Content != "" { + mod = mod.WhereLike(dao.SysServeLog.Columns().Content, "%"+in.Content+"%") + } + // 查询日志级别 if in.LevelFormat != "" { mod = mod.WhereLike(dao.SysServeLog.Columns().LevelFormat, in.LevelFormat) diff --git a/server/internal/logic/sys/sms_log.go b/server/internal/logic/sys/sms_log.go index 02e153a..71d51ad 100644 --- a/server/internal/logic/sys/sms_log.go +++ b/server/internal/logic/sys/sms_log.go @@ -134,7 +134,7 @@ func (s *sSysSmsLog) SendCode(ctx context.Context, in *sysin.SendCodeInp) (err e data.Mobile = in.Mobile data.Code = in.Code data.Ip = location.GetClientIp(ghttp.RequestFromCtx(ctx)) - data.Status = consts.SmsStatusNotUsed + data.Status = consts.CodeStatusNotUsed data.CreatedAt = gtime.Now() data.UpdatedAt = gtime.Now() @@ -261,7 +261,7 @@ func (s *sSysSmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (e } if in.Event != consts.SmsTemplateCode { - if models.Status == consts.SmsStatusUsed { + if models.Status == consts.CodeStatusUsed { err = gerror.New("验证码已使用,请重新发送!") return } @@ -280,7 +280,7 @@ func (s *sSysSmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (e _, err = dao.SysSmsLog.Ctx(ctx).WherePri(models.Id).Data(g.Map{ cols.Times: models.Times + 1, - cols.Status: consts.SmsStatusUsed, + cols.Status: consts.CodeStatusUsed, cols.UpdatedAt: gtime.Now(), }).Update() return diff --git a/server/internal/logic/sys/test_category.go b/server/internal/logic/sys/test_category.go index 31dbf68..673d415 100644 --- a/server/internal/logic/sys/test_category.go +++ b/server/internal/logic/sys/test_category.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sys import ( @@ -84,6 +84,7 @@ func (s *sSysTestCategory) List(ctx context.Context, in *sysin.TestCategoryListI // Edit 修改/新增测试分类 func (s *sSysTestCategory) Edit(ctx context.Context, in *sysin.TestCategoryEditInp) (err error) { return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) { + // 修改 if in.Id > 0 { if _, err = s.Model(ctx). @@ -106,6 +107,7 @@ func (s *sSysTestCategory) Edit(ctx context.Context, in *sysin.TestCategoryEditI // Delete 删除测试分类 func (s *sSysTestCategory) Delete(ctx context.Context, in *sysin.TestCategoryDeleteInp) (err error) { + if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil { err = gerror.Wrap(err, "删除测试分类失败,请稍后重试!") return @@ -162,4 +164,4 @@ func (s *sSysTestCategory) Option(ctx context.Context) (opts []*model.Option, er opts[k] = dict.GenHashOption(v.Id, gconv.String(v.Name)) } return -} +} \ No newline at end of file diff --git a/server/internal/logic/tcpclient/cron_interceptor.go b/server/internal/logic/tcpclient/cron_interceptor.go index 37cf289..0dbe61a 100644 --- a/server/internal/logic/tcpclient/cron_interceptor.go +++ b/server/internal/logic/tcpclient/cron_interceptor.go @@ -12,7 +12,7 @@ import ( // DefaultInterceptor 默认拦截器 func (s *sCronClient) DefaultInterceptor(ctx context.Context, msg *tcp.Message) (err error) { - // conn := tcp.ConnFromCtx(ctx) - // g.Log().Debugf(ctx, "DefaultInterceptor msg:%+v, conn:%+v", msg, gjson.New(conn).String()) + //conn := tcp.ConnFromCtx(ctx) + //g.Log().Warningf(ctx, "DefaultInterceptor msg:%+v, conn:%+v", msg, gjson.New(conn).String()) return } diff --git a/server/internal/model/dict.go b/server/internal/model/dict.go index bec1210..6d740d5 100644 --- a/server/internal/model/dict.go +++ b/server/internal/model/dict.go @@ -13,4 +13,5 @@ type Option struct { ValueType string `json:"valueType" description:"键值数据类型"` Type string `json:"type" description:"字典类型"` ListClass string `json:"listClass" description:"表格回显样式"` + Extra interface{} `json:"extra" description:"额外数据配置"` } diff --git a/server/internal/model/do/addon_hgexample_table.go b/server/internal/model/do/addon_hgexample_table.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/addon_hgexample_tenant_order.go b/server/internal/model/do/addon_hgexample_tenant_order.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_cash.go b/server/internal/model/do/admin_cash.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_credits_log.go b/server/internal/model/do/admin_credits_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_dept.go b/server/internal/model/do/admin_dept.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_member.go b/server/internal/model/do/admin_member.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_member_post.go b/server/internal/model/do/admin_member_post.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_member_role.go b/server/internal/model/do/admin_member_role.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_menu.go b/server/internal/model/do/admin_menu.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_notice.go b/server/internal/model/do/admin_notice.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_notice_read.go b/server/internal/model/do/admin_notice_read.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_oauth.go b/server/internal/model/do/admin_oauth.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_order.go b/server/internal/model/do/admin_order.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_post.go b/server/internal/model/do/admin_post.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_role.go b/server/internal/model/do/admin_role.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_role_casbin.go b/server/internal/model/do/admin_role_casbin.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/admin_role_menu.go b/server/internal/model/do/admin_role_menu.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/pay_log.go b/server/internal/model/do/pay_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/pay_refund.go b/server/internal/model/do/pay_refund.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_addons_config.go b/server/internal/model/do/sys_addons_config.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_attachment.go b/server/internal/model/do/sys_attachment.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_blacklist.go b/server/internal/model/do/sys_blacklist.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_config.go b/server/internal/model/do/sys_config.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_cron.go b/server/internal/model/do/sys_cron.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_cron_group.go b/server/internal/model/do/sys_cron_group.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_dict_data.go b/server/internal/model/do/sys_dict_data.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_dict_type.go b/server/internal/model/do/sys_dict_type.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_ems_log.go b/server/internal/model/do/sys_ems_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_gen_codes.go b/server/internal/model/do/sys_gen_codes.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_gen_curd_demo.go b/server/internal/model/do/sys_gen_curd_demo.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_gen_tree_demo.go b/server/internal/model/do/sys_gen_tree_demo.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_log.go b/server/internal/model/do/sys_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_login_log.go b/server/internal/model/do/sys_login_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_provinces.go b/server/internal/model/do/sys_provinces.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_serve_license.go b/server/internal/model/do/sys_serve_license.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_serve_log.go b/server/internal/model/do/sys_serve_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/sys_sms_log.go b/server/internal/model/do/sys_sms_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/do/test_category.go b/server/internal/model/do/test_category.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/addon_hgexample_table.go b/server/internal/model/entity/addon_hgexample_table.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/addon_hgexample_tenant_order.go b/server/internal/model/entity/addon_hgexample_tenant_order.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_cash.go b/server/internal/model/entity/admin_cash.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_credits_log.go b/server/internal/model/entity/admin_credits_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_dept.go b/server/internal/model/entity/admin_dept.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_member.go b/server/internal/model/entity/admin_member.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_member_post.go b/server/internal/model/entity/admin_member_post.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_member_role.go b/server/internal/model/entity/admin_member_role.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_menu.go b/server/internal/model/entity/admin_menu.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_notice.go b/server/internal/model/entity/admin_notice.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_notice_read.go b/server/internal/model/entity/admin_notice_read.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_oauth.go b/server/internal/model/entity/admin_oauth.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_order.go b/server/internal/model/entity/admin_order.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_post.go b/server/internal/model/entity/admin_post.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_role.go b/server/internal/model/entity/admin_role.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_role_casbin.go b/server/internal/model/entity/admin_role_casbin.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/admin_role_menu.go b/server/internal/model/entity/admin_role_menu.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/pay_log.go b/server/internal/model/entity/pay_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/pay_refund.go b/server/internal/model/entity/pay_refund.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_addons_config.go b/server/internal/model/entity/sys_addons_config.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_attachment.go b/server/internal/model/entity/sys_attachment.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_blacklist.go b/server/internal/model/entity/sys_blacklist.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_config.go b/server/internal/model/entity/sys_config.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_cron.go b/server/internal/model/entity/sys_cron.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_cron_group.go b/server/internal/model/entity/sys_cron_group.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_dict_data.go b/server/internal/model/entity/sys_dict_data.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_dict_type.go b/server/internal/model/entity/sys_dict_type.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_ems_log.go b/server/internal/model/entity/sys_ems_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_gen_codes.go b/server/internal/model/entity/sys_gen_codes.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_gen_curd_demo.go b/server/internal/model/entity/sys_gen_curd_demo.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_gen_tree_demo.go b/server/internal/model/entity/sys_gen_tree_demo.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_log.go b/server/internal/model/entity/sys_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_login_log.go b/server/internal/model/entity/sys_login_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_provinces.go b/server/internal/model/entity/sys_provinces.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_serve_license.go b/server/internal/model/entity/sys_serve_license.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_serve_log.go b/server/internal/model/entity/sys_serve_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/sys_sms_log.go b/server/internal/model/entity/sys_sms_log.go old mode 100644 new mode 100755 diff --git a/server/internal/model/entity/test_category.go b/server/internal/model/entity/test_category.go old mode 100644 new mode 100755 diff --git a/server/internal/model/input/sysin/curd_demo.go b/server/internal/model/input/sysin/curd_demo.go index 24177a3..c7eb8ff 100644 --- a/server/internal/model/input/sysin/curd_demo.go +++ b/server/internal/model/input/sysin/curd_demo.go @@ -3,15 +3,18 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sysin import ( "context" + "hotgo/internal/consts" "hotgo/internal/library/hgorm/hook" "hotgo/internal/model/entity" "hotgo/internal/model/input/form" + "hotgo/utility/validate" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" ) @@ -26,9 +29,7 @@ type CurdDemoUpdateFields struct { CityId int64 `json:"cityId" dc:"所在城市"` Sort int `json:"sort" dc:"排序"` Switch int `json:"switch" dc:"显示开关"` - Status int `json:"status" dc:"状态"` UpdatedBy int64 `json:"updatedBy" dc:"更新者"` - CategoryId int64 `json:"categoryId" dc:"测试分类"` } // CurdDemoInsertFields 新增CURD列表字段过滤 @@ -41,9 +42,7 @@ type CurdDemoInsertFields struct { CityId int64 `json:"cityId" dc:"所在城市"` Sort int `json:"sort" dc:"排序"` Switch int `json:"switch" dc:"显示开关"` - Status int `json:"status" dc:"状态"` CreatedBy int64 `json:"createdBy" dc:"创建者"` - CategoryId int64 `json:"categoryId" dc:"测试分类"` } // CurdDemoEditInp 修改/新增CURD列表 @@ -72,11 +71,6 @@ func (in *CurdDemoEditInp) Filter(ctx context.Context) (err error) { return err.Current() } - // 验证测试分类 - if err := g.Validator().Rules("required").Data(in.CategoryId).Messages("测试分类不能为空").Run(ctx); err != nil { - return err.Current() - } - return } @@ -114,10 +108,8 @@ type CurdDemoListInp struct { Id int64 `json:"id" dc:"ID"` Title string `json:"title" dc:"标题"` Description string `json:"description" dc:"描述"` - Status int `json:"status" dc:"状态"` CreatedBy string `json:"createdBy" dc:"创建者"` CreatedAt []*gtime.Time `json:"createdAt" dc:"创建时间"` - CategoryId int64 `json:"categoryId" dc:"测试分类"` TestCategoryName string `json:"testCategoryName" dc:"关联分类"` } @@ -133,14 +125,12 @@ type CurdDemoListModel struct { Attachfile string `json:"attachfile" dc:"附件"` Sort int `json:"sort" dc:"排序"` Switch int `json:"switch" dc:"显示开关"` - Status int `json:"status" dc:"状态"` CreatedBy int64 `json:"createdBy" dc:"创建者"` CreatedBySumma *hook.MemberSumma `json:"createdBySumma" dc:"创建者摘要信息"` CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"` UpdatedBy int64 `json:"updatedBy" dc:"更新者"` UpdatedBySumma *hook.MemberSumma `json:"updatedBySumma" dc:"更新者摘要信息"` UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"` - CategoryId int64 `json:"categoryId" dc:"测试分类"` TestCategoryName string `json:"testCategoryName" dc:"关联分类"` } @@ -154,11 +144,9 @@ type CurdDemoExportModel struct { CityId int64 `json:"cityId" dc:"所在城市"` Sort int `json:"sort" dc:"排序"` Switch int `json:"switch" dc:"显示开关"` - Status int `json:"status" dc:"状态"` CreatedBy int64 `json:"createdBy" dc:"创建者"` CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"` UpdatedBy int64 `json:"updatedBy" dc:"更新者"` - CategoryId int64 `json:"categoryId" dc:"测试分类"` TestCategoryName string `json:"testCategoryName" dc:"关联分类"` } @@ -173,6 +161,32 @@ type CurdDemoMaxSortModel struct { Sort int `json:"sort" description:"排序"` } +// CurdDemoStatusInp 更新CURD列表状态 +type CurdDemoStatusInp struct { + Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"` + Status int `json:"status" dc:"状态"` +} + +func (in *CurdDemoStatusInp) Filter(ctx context.Context) (err error) { + if in.Id <= 0 { + err = gerror.New("ID不能为空") + return + } + + if in.Status <= 0 { + err = gerror.New("状态不能为空") + return + } + + if !validate.InSlice(consts.StatusSlice, in.Status) { + err = gerror.New("状态不正确") + return + } + return +} + +type CurdDemoStatusModel struct{} + // CurdDemoSwitchInp 更新CURD列表开关状态 type CurdDemoSwitchInp struct { form.SwitchReq @@ -183,4 +197,4 @@ func (in *CurdDemoSwitchInp) Filter(ctx context.Context) (err error) { return } -type CurdDemoSwitchModel struct{} +type CurdDemoSwitchModel struct{} \ No newline at end of file diff --git a/server/internal/model/input/sysin/log.go b/server/internal/model/input/sysin/log.go index ce2fa80..6f222d7 100644 --- a/server/internal/model/input/sysin/log.go +++ b/server/internal/model/input/sysin/log.go @@ -23,6 +23,7 @@ type LogListInp struct { Ip string `json:"ip" dc:"访问IP"` ErrorCode string `json:"errorCode" dc:"状态码"` CreatedAt []int64 `json:"createdAt" dc:"创建时间"` + Keyword string `json:"keyword" dc:"关键词"` } type LogListModel struct { diff --git a/server/internal/model/input/sysin/normal_tree_demo.go b/server/internal/model/input/sysin/normal_tree_demo.go index 71458b6..feecac8 100644 --- a/server/internal/model/input/sysin/normal_tree_demo.go +++ b/server/internal/model/input/sysin/normal_tree_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sysin import ( diff --git a/server/internal/model/input/sysin/option_tree_demo.go b/server/internal/model/input/sysin/option_tree_demo.go index 7f7c89f..40f9254 100644 --- a/server/internal/model/input/sysin/option_tree_demo.go +++ b/server/internal/model/input/sysin/option_tree_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sysin import ( @@ -21,6 +21,8 @@ import ( type OptionTreeDemoUpdateFields struct { Title string `json:"title" dc:"标题"` Pid int64 `json:"pid" dc:"上级"` + Level int `json:"level" dc:"关系树级别"` + Tree string `json:"tree" dc:"关系树"` CategoryId int64 `json:"categoryId" dc:"测试分类"` Description string `json:"description" dc:"描述"` Sort int `json:"sort" dc:"排序"` @@ -32,6 +34,8 @@ type OptionTreeDemoUpdateFields struct { type OptionTreeDemoInsertFields struct { Title string `json:"title" dc:"标题"` Pid int64 `json:"pid" dc:"上级"` + Level int `json:"level" dc:"关系树级别"` + Tree string `json:"tree" dc:"关系树"` CategoryId int64 `json:"categoryId" dc:"测试分类"` Description string `json:"description" dc:"描述"` Sort int `json:"sort" dc:"排序"` diff --git a/server/internal/model/input/sysin/serve_log.go b/server/internal/model/input/sysin/serve_log.go index eedb545..b88630c 100644 --- a/server/internal/model/input/sysin/serve_log.go +++ b/server/internal/model/input/sysin/serve_log.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package sysin import ( @@ -34,6 +33,7 @@ type ServeLogListInp struct { form.PageReq TraceId string `json:"traceId" dc:"链路ID"` LevelFormat string `json:"levelFormat" dc:"日志级别"` + Content string `json:"content" dc:"日志内容"` TriggerNs []int64 `json:"triggerNs" dc:"触发时间(ns)"` CreatedAt []*gtime.Time `json:"createdAt" dc:"创建时间"` } diff --git a/server/internal/model/input/sysin/test_category.go b/server/internal/model/input/sysin/test_category.go index eb77e13..2dbeed9 100644 --- a/server/internal/model/input/sysin/test_category.go +++ b/server/internal/model/input/sysin/test_category.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package sysin import ( diff --git a/server/internal/router/genrouter/curd_demo.go b/server/internal/router/genrouter/curd_demo.go index d596af6..d259dc1 100644 --- a/server/internal/router/genrouter/curd_demo.go +++ b/server/internal/router/genrouter/curd_demo.go @@ -3,11 +3,11 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package genrouter import "hotgo/internal/controller/admin/sys" func init() { LoginRequiredRouter = append(LoginRequiredRouter, sys.CurdDemo) // CURD列表 -} +} \ No newline at end of file diff --git a/server/internal/router/genrouter/normal_tree_demo.go b/server/internal/router/genrouter/normal_tree_demo.go index 8e0c946..08adb1a 100644 --- a/server/internal/router/genrouter/normal_tree_demo.go +++ b/server/internal/router/genrouter/normal_tree_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package genrouter import "hotgo/internal/controller/admin/sys" diff --git a/server/internal/router/genrouter/option_tree_demo.go b/server/internal/router/genrouter/option_tree_demo.go index 4eed5a8..7f995e2 100644 --- a/server/internal/router/genrouter/option_tree_demo.go +++ b/server/internal/router/genrouter/option_tree_demo.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package genrouter import "hotgo/internal/controller/admin/sys" diff --git a/server/internal/router/genrouter/test_category.go b/server/internal/router/genrouter/test_category.go index d3f8d01..032d2ed 100644 --- a/server/internal/router/genrouter/test_category.go +++ b/server/internal/router/genrouter/test_category.go @@ -3,7 +3,7 @@ // @Copyright Copyright (c) 2024 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// @AutoGenerate Version 2.13.1 +// @AutoGenerate Version 2.15.1 package genrouter import "hotgo/internal/controller/admin/sys" diff --git a/server/internal/service/admin.go b/server/internal/service/admin.go index 6b6b80b..93bd730 100644 --- a/server/internal/service/admin.go +++ b/server/internal/service/admin.go @@ -218,7 +218,7 @@ type ( } IAdminRole interface { // Verify 验证权限 - Verify(ctx context.Context, path, method string) bool + Verify(ctx context.Context, path string, method string) bool // List 获取列表 List(ctx context.Context, in *adminin.RoleListInp) (res *adminin.RoleListModel, totalCount int, err error) // GetName 获取指定角色的名称 diff --git a/server/internal/service/common.go b/server/internal/service/common.go index 37eec73..2553c28 100644 --- a/server/internal/service/common.go +++ b/server/internal/service/common.go @@ -28,7 +28,7 @@ type ( AuthorizeCall(ctx context.Context, in *commonin.WechatAuthorizeCallInp) (res *commonin.WechatAuthorizeCallModel, err error) // GetOpenId 从缓存中获取临时openid GetOpenId(ctx context.Context) (openId string, err error) - GetCacheKey(typ, ak string) string + GetCacheKey(typ string, ak string) string // CleanTempMap 清理临时map CleanTempMap(ctx context.Context) } diff --git a/server/internal/service/hook.go b/server/internal/service/hook.go index c2584d0..22fc52a 100644 --- a/server/internal/service/hook.go +++ b/server/internal/service/hook.go @@ -1,5 +1,5 @@ // ================================================================================ -// Code generated by GoFrame CLI tool. DO NOT EDIT. +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // You can delete these comments if you wish manually maintain this interface file. // ================================================================================ diff --git a/server/internal/service/middleware.go b/server/internal/service/middleware.go index 526504a..7a15a58 100644 --- a/server/internal/service/middleware.go +++ b/server/internal/service/middleware.go @@ -30,9 +30,9 @@ type ( // DeliverUserContext 将用户信息传递到上下文中 DeliverUserContext(r *ghttp.Request) (err error) // IsExceptAuth 是否是不需要验证权限的路由地址 - IsExceptAuth(ctx context.Context, appName, path string) bool + IsExceptAuth(ctx context.Context, appName string, path string) bool // IsExceptLogin 是否是不需要登录的路由地址 - IsExceptLogin(ctx context.Context, appName, path string) bool + IsExceptLogin(ctx context.Context, appName string, path string) bool // Blacklist IP黑名单限制中间件 Blacklist(r *ghttp.Request) // Develop 开发工具白名单过滤 diff --git a/server/internal/service/sys.go b/server/internal/service/sys.go index 53ce9b8..1b94874 100644 --- a/server/internal/service/sys.go +++ b/server/internal/service/sys.go @@ -15,6 +15,7 @@ import ( "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/database/gredis" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/net/ghttp" ) @@ -50,6 +51,8 @@ type ( List(ctx context.Context, in *sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error) // ClearKind 清空上传类型 ClearKind(ctx context.Context, in *sysin.AttachmentClearKindInp) (err error) + // AttachmentKindOption 上传类型选项 + AttachmentKindOption(ctx context.Context) (opts []*model.Option, err error) } ISysBlacklist interface { // Delete 删除 @@ -163,6 +166,8 @@ type ( MaxSort(ctx context.Context, in *sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error) // View 获取CURD列表指定信息 View(ctx context.Context, in *sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error) + // Status 更新CURD列表状态 + Status(ctx context.Context, in *sysin.CurdDemoStatusInp) (err error) // Switch 更新CURD列表开关 Switch(ctx context.Context, in *sysin.CurdDemoSwitchInp) (err error) } @@ -253,6 +258,8 @@ type ( AutoLog(ctx context.Context) error // AnalysisLog 解析日志数据 AnalysisLog(ctx context.Context) entity.SysLog + // SimplifyHeaderParams 过滤掉请求头中的大参数 + SimplifyHeaderParams(data *gjson.Json) *gjson.Json // View 获取指定请求日志信息 View(ctx context.Context, in *sysin.LogViewInp) (res *sysin.LogViewModel, err error) // Delete 删除请求日志 diff --git a/server/internal/service/tcpserver.go b/server/internal/service/tcpserver.go index 16833d5..a6c0767 100644 --- a/server/internal/service/tcpserver.go +++ b/server/internal/service/tcpserver.go @@ -24,7 +24,7 @@ type ( CronStatus(ctx context.Context, in *servmsg.CronStatusReq) (err error) // CronOnlineExec 执行一次任务 CronOnlineExec(ctx context.Context, in *servmsg.CronOnlineExecReq) (err error) - // DispatchLog 执行一次任务 + // DispatchLog 查看调度日志 DispatchLog(ctx context.Context, in *servmsg.CronDispatchLogReq) (log *cron.Log, err error) // OnExampleHello 一个tcp请求例子 OnExampleHello(ctx context.Context, req *servmsg.ExampleHelloReq) diff --git a/server/internal/service/view.go b/server/internal/service/view.go index 84a3124..ecf67b7 100644 --- a/server/internal/service/view.go +++ b/server/internal/service/view.go @@ -1,5 +1,5 @@ // ================================================================================ -// Code generated by GoFrame CLI tool. DO NOT EDIT. +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // You can delete these comments if you wish manually maintain this interface file. // ================================================================================ @@ -12,10 +12,15 @@ import ( type ( IView interface { + // GetBreadCrumb 前台系统-获取面包屑列表 GetBreadCrumb(ctx context.Context, in *model.ViewGetBreadCrumbInput) []model.ViewBreadCrumb + // GetTitle 前台系统-获取标题 GetTitle(ctx context.Context, in *model.ViewGetTitleInput) string + // RenderTpl 渲染指定模板页面 RenderTpl(ctx context.Context, tpl string, data ...model.View) + // Render 渲染默认模板页面 Render(ctx context.Context, data ...model.View) + // Error 自定义错误页面 Error(ctx context.Context, err error) } ) diff --git a/server/manifest/config/config.example.yaml b/server/manifest/config/config.example.yaml index 0568707..2b353f1 100644 --- a/server/manifest/config/config.example.yaml +++ b/server/manifest/config/config.example.yaml @@ -147,7 +147,6 @@ router: "/dictData/options", # 多个数据字典 "/provinces/select", # 动态省市区选项 "/provinces/cityLabel", # 动态解析省市区名称 - "/attachment/chooserOption", # 附件选择器选项 "/member/option", # 用户选项 ] # 接口 diff --git a/server/resource/generate/default/curd/web.edit.vue.template b/server/resource/generate/default/curd/web.edit.vue.template index a46f101..dc5c505 100644 --- a/server/resource/generate/default/curd/web.edit.vue.template +++ b/server/resource/generate/default/curd/web.edit.vue.template @@ -45,6 +45,7 @@ const emit = defineEmits(['reloadTable']); const message = useMessage(); const settingStore = useProjectSettingStore(); + @{ if eq .options.DictOps.Has true }const dict = useDictStore();@{end} const loading = ref(false); const showModal = ref(false); const formValue = ref(newState(null)); @@ -54,6 +55,34 @@ return adaModalWidth(840); }); + // 提交表单 + function confirmForm(e) { + e.preventDefault(); + formRef.value.validate((errors) => { + if (!errors) { + formBtnLoading.value = true; + Edit(formValue.value) + .then((_res) => { + message.success('操作成功'); + closeForm(); + emit('reloadTable'); + }) + .finally(() => { + formBtnLoading.value = false; + }); + } else { + message.error('请填写完整信息'); + } + }); + } + + // 关闭表单 + function closeForm() { + showModal.value = false; + loading.value = false; + } + + // 打开模态框 function openModal(state: State) { showModal.value = true; @{ if eq .options.Step.IsTreeTable true } @@ -86,31 +115,6 @@ }); } - function confirmForm(e) { - e.preventDefault(); - formBtnLoading.value = true; - formRef.value.validate((errors) => { - if (!errors) { - Edit(formValue.value).then((_res) => { - message.success('操作成功'); - setTimeout(() => { - closeForm(); - emit('reloadTable'); - }); - }); - } else { - message.error('请填写完整信息'); - } - formBtnLoading.value = false; - loading.value = false; - }); - } - - function closeForm() { - showModal.value = false; - loading.value = false; - } - defineExpose({ openModal, }); diff --git a/server/resource/generate/default/curd/web.index.vue.template b/server/resource/generate/default/curd/web.index.vue.template index 622766c..a0b51de 100644 --- a/server/resource/generate/default/curd/web.index.vue.template +++ b/server/resource/generate/default/curd/web.index.vue.template @@ -40,7 +40,7 @@ @{end} @{ if eq .options.Step.HasBatchDel true } - + - diff --git a/web/src/views/addons/hgexample/table/model.ts b/web/src/views/addons/hgexample/table/model.ts index 6a76282..f3f9184 100644 --- a/web/src/views/addons/hgexample/table/model.ts +++ b/web/src/views/addons/hgexample/table/model.ts @@ -2,14 +2,19 @@ import { h, ref } from 'vue'; import { NAvatar, NImage, NTag, NSwitch, NRate } from 'naive-ui'; import { cloneDeep } from 'lodash-es'; import { FormSchema } from '@/components/Form'; -import { Dicts } from '@/api/dict/dict'; import { Switch } from '@/api/addons/hgexample/table'; import { isNullObject } from '@/utils/is'; import { getFileExt } from '@/utils/urlUtils'; import { defRangeShortcuts, defShortcuts, formatToDate } from '@/utils/dateUtil'; import { validate } from '@/utils/validateUtil'; -import { errorImg, getOptionLabel, getOptionTag, Options } from '@/utils/hotgo'; +import { fallbackSrc } from '@/utils/hotgo'; +import { useDictStore } from '@/store/modules/dict'; +import { renderOptionTag } from '@/utils'; +import type { FormRules } from 'naive-ui/es/form/src/interface'; + +const dict = useDictStore(); const $message = window['$message']; + export interface State { id: number; memberId: number; @@ -95,16 +100,7 @@ export function newState(state: State | null): State { return cloneDeep(defaultState); } -export const options = ref({ - sys_normal_disable: [], - sys_user_sex: [], - sys_notice_type: [], - sys_user_channel: [], - sys_user_hobby: [], - sys_switch: [], -}); - -export const rules = { +export const rules: FormRules = { title: { required: true, trigger: ['blur', 'input'], @@ -207,7 +203,7 @@ export const schemas = ref([ }, componentProps: { placeholder: '请选择标签', - options: [], + options: dict.getOption('sys_notice_type'), onUpdateChecked: (e: any) => { console.log(e); }, @@ -221,7 +217,7 @@ export const schemas = ref([ //span: 24, }, componentProps: { - options: [], + options: dict.getOption('sys_switch'), onUpdateChecked: (e: any) => { console.log(e); }, @@ -235,7 +231,7 @@ export const schemas = ref([ componentProps: { multiple: true, placeholder: '请选择爱好', - options: [], + options: dict.getOption('sys_user_hobby'), onUpdateValue: (e: any) => { console.log(e); }, @@ -248,7 +244,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择类型', - options: [], + options: dict.getOption('sys_normal_disable'), onUpdateValue: (e: any) => { console.log(e); }, @@ -280,19 +276,7 @@ export const columns = [ return ``; } return row.flag.map((tagKey) => { - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_notice_type, tagKey), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_notice_type, tagKey), - } - ); + return renderOptionTag('sys_notice_type', tagKey); }); }, }, @@ -304,7 +288,7 @@ export const columns = [ width: 32, height: 32, src: row.image, - fallbackSrc: errorImg, + fallbackSrc: fallbackSrc(), style: { width: '32px', height: '32px', @@ -326,7 +310,7 @@ export const columns = [ width: 32, height: 32, src: image, - fallbackSrc: errorImg, + fallbackSrc: fallbackSrc(), style: { width: '32px', height: '32px', @@ -443,22 +427,7 @@ export const columns = [ title: '状态', key: 'status', render(row) { - if (isNullObject(row.status)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_normal_disable, row.status), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_normal_disable, row.status), - } - ); + return renderOptionTag('sys_normal_disable', row.status); }, }, { @@ -469,19 +438,7 @@ export const columns = [ return ``; } return row.hobby.map((tagKey) => { - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_user_hobby, tagKey), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_user_hobby, tagKey), - } - ); + return renderOptionTag('sys_user_hobby', tagKey); }); }, }, @@ -497,33 +454,13 @@ export const columns = [ }, ]; -async function loadOptions() { - options.value = await Dicts({ - types: [ - 'sys_normal_disable', - 'sys_user_sex', - 'sys_notice_type', - 'sys_switch', - 'sys_user_hobby', - 'sys_user_channel', - ], - }); - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.sys_normal_disable; - break; - case 'flag': - item.componentProps.options = options.value.sys_notice_type; - break; - case 'switch': - item.componentProps.options = options.value.sys_switch; - break; - case 'hobby': - item.componentProps.options = options.value.sys_user_hobby; - break; - } - } +export function loadOptions() { + dict.loadOptions([ + 'sys_normal_disable', + 'sys_user_sex', + 'sys_notice_type', + 'sys_switch', + 'sys_user_hobby', + 'sys_user_channel', + ]); } - -await loadOptions(); diff --git a/web/src/views/addons/hgexample/table/view.vue b/web/src/views/addons/hgexample/table/view.vue index 126bd96..2ce3618 100644 --- a/web/src/views/addons/hgexample/table/view.vue +++ b/web/src/views/addons/hgexample/table/view.vue @@ -4,7 +4,7 @@ 基础详情,有时也用于显示只读信息。 - + {{ formValue.categoryId }} @@ -13,10 +13,10 @@ @@ -37,19 +37,19 @@ - + - + - + @@ -61,7 +61,7 @@ - +
- +
@@ -110,10 +110,11 @@ import { useRouter } from 'vue-router'; import { useMessage } from 'naive-ui'; import { View } from '@/api/addons/hgexample/table'; - import { newState, options } from './model'; - import { getOptionLabel, getOptionTag } from '@/utils/hotgo'; + import { newState } from './model'; import { getFileExt } from '@/utils/urlUtils'; + import { useDictStore } from '@/store/modules/dict'; + const dict = useDictStore(); const message = useMessage(); const router = useRouter(); const id = Number(router.currentRoute.value.params.id); diff --git a/web/src/views/addons/hgexample/tenantOrder/edit.vue b/web/src/views/addons/hgexample/tenantOrder/edit.vue index 41fe82e..82e9b08 100644 --- a/web/src/views/addons/hgexample/tenantOrder/edit.vue +++ b/web/src/views/addons/hgexample/tenantOrder/edit.vue @@ -71,7 +71,10 @@ - + @@ -91,13 +94,15 @@ diff --git a/web/src/views/addons/hgexample/treeTable/list.vue b/web/src/views/addons/hgexample/treeTable/list.vue index 98be7bd..943730e 100644 --- a/web/src/views/addons/hgexample/treeTable/list.vue +++ b/web/src/views/addons/hgexample/treeTable/list.vue @@ -71,8 +71,8 @@ (), { checkedId: 0, optionTreeData: [] }); const emit = defineEmits(['reloadTable']); + const dict = useDictStore(); const dialog = useDialog(); const message = useMessage(); const searchFormRef = ref(); @@ -232,7 +234,7 @@ function handleStatus(record: Recordable, status: number) { Status({ id: record.id, status: status }).then((_res) => { - message.success('设为' + getOptionLabel(options.value.sys_normal_disable, status) + '成功'); + message.success('设为' + dict.getLabel('sys_normal_disable', status) + '成功'); setTimeout(() => { reloadTable(); }); diff --git a/web/src/views/addons/hgexample/treeTable/model.ts b/web/src/views/addons/hgexample/treeTable/model.ts index 6a76282..541f471 100644 --- a/web/src/views/addons/hgexample/treeTable/model.ts +++ b/web/src/views/addons/hgexample/treeTable/model.ts @@ -2,14 +2,18 @@ import { h, ref } from 'vue'; import { NAvatar, NImage, NTag, NSwitch, NRate } from 'naive-ui'; import { cloneDeep } from 'lodash-es'; import { FormSchema } from '@/components/Form'; -import { Dicts } from '@/api/dict/dict'; import { Switch } from '@/api/addons/hgexample/table'; import { isNullObject } from '@/utils/is'; import { getFileExt } from '@/utils/urlUtils'; import { defRangeShortcuts, defShortcuts, formatToDate } from '@/utils/dateUtil'; import { validate } from '@/utils/validateUtil'; -import { errorImg, getOptionLabel, getOptionTag, Options } from '@/utils/hotgo'; +import { fallbackSrc } from '@/utils/hotgo'; +import { useDictStore } from '@/store/modules/dict'; +import { renderOptionTag } from '@/utils'; + +const dict = useDictStore(); const $message = window['$message']; + export interface State { id: number; memberId: number; @@ -21,7 +25,7 @@ export interface State { images: string[] | null; attachfile: string; attachfiles: string[] | null; - map: unknown[] | null; + map: any | null; star: number; description: string; price: number; @@ -95,15 +99,6 @@ export function newState(state: State | null): State { return cloneDeep(defaultState); } -export const options = ref({ - sys_normal_disable: [], - sys_user_sex: [], - sys_notice_type: [], - sys_user_channel: [], - sys_user_hobby: [], - sys_switch: [], -}); - export const rules = { title: { required: true, @@ -207,7 +202,7 @@ export const schemas = ref([ }, componentProps: { placeholder: '请选择标签', - options: [], + options: dict.getOption('sys_notice_type'), onUpdateChecked: (e: any) => { console.log(e); }, @@ -221,7 +216,7 @@ export const schemas = ref([ //span: 24, }, componentProps: { - options: [], + options: dict.getOption('sys_switch'), onUpdateChecked: (e: any) => { console.log(e); }, @@ -235,7 +230,7 @@ export const schemas = ref([ componentProps: { multiple: true, placeholder: '请选择爱好', - options: [], + options: dict.getOption('sys_user_hobby'), onUpdateValue: (e: any) => { console.log(e); }, @@ -248,7 +243,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择类型', - options: [], + options: dict.getOption('sys_normal_disable'), onUpdateValue: (e: any) => { console.log(e); }, @@ -280,19 +275,7 @@ export const columns = [ return ``; } return row.flag.map((tagKey) => { - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_notice_type, tagKey), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_notice_type, tagKey), - } - ); + return renderOptionTag('sys_notice_type', tagKey); }); }, }, @@ -304,7 +287,7 @@ export const columns = [ width: 32, height: 32, src: row.image, - fallbackSrc: errorImg, + fallbackSrc: fallbackSrc(), style: { width: '32px', height: '32px', @@ -326,7 +309,7 @@ export const columns = [ width: 32, height: 32, src: image, - fallbackSrc: errorImg, + fallbackSrc: fallbackSrc(), style: { width: '32px', height: '32px', @@ -443,46 +426,14 @@ export const columns = [ title: '状态', key: 'status', render(row) { - if (isNullObject(row.status)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_normal_disable, row.status), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_normal_disable, row.status), - } - ); + return renderOptionTag('sys_normal_disable', row.status); }, }, { title: '爱好', key: 'hobby', render(row) { - if (isNullObject(row.hobby)) { - return ``; - } - return row.hobby.map((tagKey) => { - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_user_hobby, tagKey), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_user_hobby, tagKey), - } - ); - }); + return renderOptionTag('sys_user_hobby', row.hobby); }, }, { @@ -497,33 +448,13 @@ export const columns = [ }, ]; -async function loadOptions() { - options.value = await Dicts({ - types: [ - 'sys_normal_disable', - 'sys_user_sex', - 'sys_notice_type', - 'sys_switch', - 'sys_user_hobby', - 'sys_user_channel', - ], - }); - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.sys_normal_disable; - break; - case 'flag': - item.componentProps.options = options.value.sys_notice_type; - break; - case 'switch': - item.componentProps.options = options.value.sys_switch; - break; - case 'hobby': - item.componentProps.options = options.value.sys_user_hobby; - break; - } - } +export function loadOptions() { + dict.loadOptions([ + 'sys_normal_disable', + 'sys_user_sex', + 'sys_notice_type', + 'sys_switch', + 'sys_user_hobby', + 'sys_user_channel', + ]); } - -await loadOptions(); diff --git a/web/src/views/apply/attachment/columns.ts b/web/src/views/apply/attachment/columns.ts index 57a2587..4337d38 100644 --- a/web/src/views/apply/attachment/columns.ts +++ b/web/src/views/apply/attachment/columns.ts @@ -1,15 +1,13 @@ import { h, ref } from 'vue'; -import { NAvatar, NImage, NTag } from 'naive-ui'; +import { NAvatar, NImage } from 'naive-ui'; import { getFileExt } from '@/utils/urlUtils'; -import { getOptionLabel, getOptionTag, Options } from '@/utils/hotgo'; import { FormSchema } from '@/components/Form'; -import { errorImg } from '@/utils/hotgo'; +import { fallbackSrc } from '@/utils/hotgo'; import { defRangeShortcuts } from '@/utils/dateUtil'; -import { ChooserOption } from '@/api/apply/attachment'; -export const options = ref({ - kind: [], - drive: [], -}); +import { useDictStore } from '@/store/modules/dict'; +import { renderOptionTag } from '@/utils'; + +const dict = useDictStore(); export const schemas = ref([ { @@ -19,7 +17,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择上传驱动', - options: [], + options: dict.getOption('config_upload_drive'), onUpdateValue: (e: any) => { console.log(e); }, @@ -32,7 +30,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择上传类型', - options: [], + options: dict.getOption('AttachmentKindOption'), onUpdateValue: (e: any) => { console.log(e); }, @@ -89,11 +87,6 @@ export const columns = [ key: 'appId', width: 100, }, - // { - // title: '用户ID', - // key: 'memberId', - // width: 100, - // }, { title: '驱动', key: 'drive', @@ -106,19 +99,7 @@ export const columns = [ title: '上传类型', key: 'kind', render(row) { - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.kind, row.kind), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.kind, row.kind), - } - ); + return renderOptionTag('AttachmentKindOption', row.kind); }, width: 120, }, @@ -153,7 +134,7 @@ export const columns = [ width: 40, height: 40, src: row.fileUrl, - fallbackSrc: errorImg, + fallbackSrc: fallbackSrc(), style: { width: '40px', height: '40px', @@ -185,18 +166,6 @@ export const columns = [ }, ]; -async function loadOptions() { - options.value = await ChooserOption(); - for (const item of schemas.value) { - switch (item.field) { - case 'kind': - item.componentProps.options = options.value.kind; - break; - case 'drive': - item.componentProps.options = options.value.drive; - break; - } - } +export function loadOptions() { + dict.loadOptions(['AttachmentKindOption', 'config_upload_drive']); } - -await loadOptions(); diff --git a/web/src/views/apply/attachment/index.vue b/web/src/views/apply/attachment/index.vue index ee0b0c9..2436937 100644 --- a/web/src/views/apply/attachment/index.vue +++ b/web/src/views/apply/attachment/index.vue @@ -72,17 +72,17 @@ - +
diff --git a/web/src/views/apply/notice/columns.ts b/web/src/views/apply/notice/columns.ts index a281ebc..7b6a235 100644 --- a/web/src/views/apply/notice/columns.ts +++ b/web/src/views/apply/notice/columns.ts @@ -1,8 +1,9 @@ import { h } from 'vue'; -import { NAvatar, NAvatarGroup, NTag, NTooltip } from 'naive-ui'; -import { noticeTagOptions, noticeTypeOptions } from '@/enums/systemMessageEnum'; -import { getOptionLabel, getOptionTag } from '@/utils/hotgo'; +import { NAvatar, NAvatarGroup, NTooltip } from 'naive-ui'; +import { renderOptionTag } from '@/utils'; +import { useDictStore } from '@/store/modules/dict'; +const dict = useDictStore(); export const columns = [ { title: 'ID', @@ -25,19 +26,7 @@ export const columns = [ title: '消息类型', key: 'type', render(row) { - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(noticeTypeOptions, row.type), - bordered: false, - }, - { - default: () => getOptionLabel(noticeTypeOptions, row.type), - } - ); + return renderOptionTag('noticeTypeOptions', row.type); }, width: 100, }, @@ -45,19 +34,7 @@ export const columns = [ title: '标签', key: 'tag', render(row) { - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(noticeTagOptions, row.tag), - bordered: false, - }, - { - default: () => getOptionLabel(noticeTagOptions, row.tag), - } - ); + return renderOptionTag('noticeTagOptions', row.tag); }, width: 100, }, @@ -129,3 +106,7 @@ export const columns = [ width: 180, }, ]; + +export function loadOptions() { + dict.loadOptions(['sys_normal_disable']); +} diff --git a/web/src/views/apply/notice/index.vue b/web/src/views/apply/notice/index.vue index d21ce84..ef2e1d1 100644 --- a/web/src/views/apply/notice/index.vue +++ b/web/src/views/apply/notice/index.vue @@ -97,8 +97,8 @@ preset="dialog" :title=" formParams.id > 0 - ? '编辑' + getOptionLabel(noticeTypeOptions, formParams.type) + ' #' + formParams.id - : '发送' + getOptionLabel(noticeTypeOptions, formParams.type) + ? '编辑' + dict.getLabel('noticeTypeOptions', formParams.type) + ' #' + formParams.id + : '发送' + dict.getLabel('noticeTypeOptions', formParams.type) " :style="{ width: dialogWidth, @@ -152,7 +152,7 @@ placeholder="可以不填" :render-tag="renderTag" v-model:value="formParams.tag" - :options="noticeTagOptions" + :options="dict.getOptionUnRef('noticeTagOptions')" /> @@ -208,23 +208,19 @@ MaxSort, Status, } from '@/api/apply/notice'; - import { columns } from './columns'; + import { columns, loadOptions } from './columns'; import { BellOutlined, DeleteOutlined, NotificationOutlined, SendOutlined } from '@vicons/antd'; import { statusOptions } from '@/enums/optionsiEnum'; - import { - noticeTagOptions, - noticeTypeOptions, - personOption, - renderLabel, - renderMultipleSelectTag, - } from '@/enums/systemMessageEnum'; - import { adaModalWidth, getOptionLabel } from '@/utils/hotgo'; + import { personOption, renderLabel, renderMultipleSelectTag } from '@/enums/systemMessageEnum'; + import { adaModalWidth } from '@/utils/hotgo'; import { renderTag } from '@/utils'; import Editor from '@/components/Editor/editor.vue'; import { cloneDeep } from 'lodash-es'; import { GetMemberOption } from '@/api/org/user'; import { usePermission } from '@/hooks/web/usePermission'; + import { useDictStore } from '@/store/modules/dict'; + const dict = useDictStore(); const rules = { title: { required: true, @@ -241,7 +237,7 @@ defaultValue: null, componentProps: { placeholder: '请选择消息类型', - options: noticeTypeOptions, + options: dict.getOption('noticeTypeOptions'), onUpdateValue: (e: any) => { console.log(e); }, @@ -278,7 +274,7 @@ defaultValue: null, componentProps: { placeholder: '请选择类型', - options: statusOptions, + options: dict.getOption('sys_normal_disable'), onUpdateValue: (e: any) => { console.log(e); }, @@ -483,6 +479,7 @@ } onMounted(async () => { + loadOptions(); await getMemberOption(); }); diff --git a/web/src/views/apply/provinces/edit.vue b/web/src/views/apply/provinces/edit.vue index 2b075c7..955f93b 100644 --- a/web/src/views/apply/provinces/edit.vue +++ b/web/src/views/apply/provinces/edit.vue @@ -59,7 +59,7 @@ import { ref, computed, watch } from 'vue'; - import { options, State, newState } from './model'; + import { State, newState } from './model'; import { Edit, MaxSort, CheckProvincesUniqueId } from '@/api/apply/provinces'; import { FormItemRule, useMessage } from 'naive-ui'; import { adaModalWidth } from '@/utils/hotgo'; + import { useDictStore } from '@/store/modules/dict'; const emit = defineEmits(['reloadTable', 'updateShowModal']); interface Props { @@ -138,6 +139,7 @@ }, }; + const dict = useDictStore(); const message = useMessage(); const formRef = ref({}); const formBtnLoading = ref(false); diff --git a/web/src/views/apply/provinces/index.vue b/web/src/views/apply/provinces/index.vue index 35177f7..267baba 100644 --- a/web/src/views/apply/provinces/index.vue +++ b/web/src/views/apply/provinces/index.vue @@ -101,14 +101,14 @@ - + { - await loadData(); - }); - async function loadData() { const treeMenuList = await getProvincesTree(); Object.assign( @@ -228,4 +224,9 @@ function updateShowModal(value) { showModal.value = value; } + + onMounted(async () => { + loadOptions(); + await loadData(); + }); diff --git a/web/src/views/apply/provinces/list.vue b/web/src/views/apply/provinces/list.vue index 1623ac7..29b121f 100644 --- a/web/src/views/apply/provinces/list.vue +++ b/web/src/views/apply/provinces/list.vue @@ -183,9 +183,6 @@ reloadTable(); }); }, - onNegativeClick: () => { - // message.error('取消'); - }, }); } diff --git a/web/src/views/apply/provinces/model.ts b/web/src/views/apply/provinces/model.ts index cb87fbd..e21ba37 100644 --- a/web/src/views/apply/provinces/model.ts +++ b/web/src/views/apply/provinces/model.ts @@ -1,9 +1,10 @@ -import { h, ref } from 'vue'; +import { h } from 'vue'; import { NTag } from 'naive-ui'; import { cloneDeep } from 'lodash-es'; -import { getOptionLabel, getOptionTag, Options } from '@/utils/hotgo'; -import { Dicts } from '@/api/dict/dict'; -import { isNullObject } from '@/utils/is'; +import { useDictStore } from '@/store/modules/dict'; +import { renderOptionTag } from '@/utils'; + +const dict = useDictStore(); export const listColumns = [ { @@ -45,22 +46,7 @@ export const listColumns = [ title: '状态', key: 'status', render(row) { - if (isNullObject(row.status)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_normal_disable, row.status), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_normal_disable, row.status), - } - ); + return renderOptionTag('sys_normal_disable', row.status); }, }, ]; @@ -96,14 +82,6 @@ export function newState(state: State | null): State { return cloneDeep(defaultState); } -export const options = ref({ - sys_normal_disable: [], -}); - -async function loadOptions() { - options.value = await Dicts({ - types: ['sys_normal_disable'], - }); +export function loadOptions() { + dict.loadOptions(['sys_normal_disable']); } - -await loadOptions(); diff --git a/web/src/views/asset/cash/list.vue b/web/src/views/asset/cash/list.vue index 2efdbb6..b5f7829 100644 --- a/web/src/views/asset/cash/list.vue +++ b/web/src/views/asset/cash/list.vue @@ -100,7 +100,6 @@ > { if (!errors) { - Apply({ money: formParams.value.money }) - .then((_res) => { - message.success('操作成功'); - setTimeout(() => { - showModal.value = false; - reloadTable(); - formParams.value = ref(resetFormParams); - }); + Apply({ money: formParams.value.money }).then((_res) => { + message.success('操作成功'); + setTimeout(() => { + showModal.value = false; + reloadTable(); + formParams.value = ref(resetFormParams); }); + }); } else { message.error('请填写完整信息'); } @@ -358,15 +356,14 @@ id: PaymentRef.value.model.id, status: PaymentRef.value.model.status, msg: PaymentRef.value.model.msg, - }) - .then((_res) => { - message.success('操作成功'); - setTimeout(() => { - showPaymentModal.value = false; - reloadTable(); - PaymentRef.value = ref(resetPaymentParams); - }); + }).then((_res) => { + message.success('操作成功'); + setTimeout(() => { + showPaymentModal.value = false; + reloadTable(); + PaymentRef.value = ref(resetPaymentParams); }); + }); } else { message.error('请填写完整信息'); } diff --git a/web/src/views/asset/creditsLog/index.vue b/web/src/views/asset/creditsLog/index.vue index 21682c6..84b6131 100644 --- a/web/src/views/asset/creditsLog/index.vue +++ b/web/src/views/asset/creditsLog/index.vue @@ -26,19 +26,21 @@ import { onMounted, ref } from 'vue'; import List from './list.vue'; import { useRouter } from 'vue-router'; + import { loadOptions } from './model'; const router = useRouter(); const defaultTab = ref(''); + function handleBeforeLeave(tabName: string) { + defaultTab.value = tabName; + } + onMounted(() => { if (router.currentRoute.value.query?.type) { defaultTab.value = router.currentRoute.value.query.type as string; } + loadOptions(); }); - - function handleBeforeLeave(tabName: string) { - defaultTab.value = tabName; - } diff --git a/web/src/views/asset/creditsLog/model.ts b/web/src/views/asset/creditsLog/model.ts index 6c9b1d8..406f987 100644 --- a/web/src/views/asset/creditsLog/model.ts +++ b/web/src/views/asset/creditsLog/model.ts @@ -1,62 +1,10 @@ -import { h, ref } from 'vue'; -import { NTag } from 'naive-ui'; -import { cloneDeep } from 'lodash-es'; +import { ref } from 'vue'; import { FormSchema } from '@/components/Form'; -import { Option } from '@/api/creditsLog'; -import { isNullObject } from '@/utils/is'; import { defRangeShortcuts } from '@/utils/dateUtil'; -import { getOptionLabel, getOptionTag, Options } from '@/utils/hotgo'; -import {Dicts} from "@/api/dict/dict"; +import { useDictStore } from '@/store/modules/dict'; +import { renderOptionTag } from '@/utils'; -export interface State { - id: number; - memberId: number; - appId: string; - addonsName: string; - creditType: string; - creditGroup: string; - beforeNum: number; - num: number; - afterNum: number; - remark: string; - ip: string; - mapId: number; - status: number; - createdAt: string; - updatedAt: string; -} - -export const defaultState = { - id: 0, - memberId: 0, - appId: '', - addonsName: '', - creditType: '', - creditGroup: '', - beforeNum: 0, - num: 0, - afterNum: 0, - remark: '', - ip: '', - mapId: 0, - status: 1, - createdAt: '', - updatedAt: '', -}; - -export function newState(state: State | null): State { - if (state !== null) { - return cloneDeep(state); - } - return cloneDeep(defaultState); -} - -export const options = ref({ - creditType: [], - creditGroup: [], -}); - -export const rules = {}; +const dict = useDictStore(); export const schemas = ref([ { @@ -77,7 +25,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择变动的组别', - options: [], + options: dict.getOption('creditGroup'), onUpdateValue: (e: any) => { console.log(e); }, @@ -146,22 +94,7 @@ export const columns = [ title: '变动类型', key: 'creditType', render(row) { - if (isNullObject(row.creditType)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.creditType, row.creditType), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.creditType, row.creditType), - } - ); + return renderOptionTag('creditType', row.creditType); }, width: 150, }, @@ -169,22 +102,7 @@ export const columns = [ title: '组别', key: 'creditGroup', render(row) { - if (isNullObject(row.creditGroup)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.creditGroup, row.creditGroup), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.creditGroup, row.creditGroup), - } - ); + return renderOptionTag('creditGroup', row.creditGroup); }, width: 150, }, @@ -240,20 +158,6 @@ export const columns = [ }, ]; -async function loadOptions() { - options.value = await Dicts({ - types: ['creditType', 'creditGroup'], - }); - for (const item of schemas.value) { - switch (item.field) { - case 'creditType': - item.componentProps.options = options.value.creditType; - break; - case 'creditGroup': - item.componentProps.options = options.value.creditGroup; - break; - } - } +export function loadOptions() { + dict.loadOptions(['creditType', 'creditGroup']); } - -await loadOptions(); diff --git a/web/src/views/asset/payRefund/index.vue b/web/src/views/asset/payRefund/index.vue index f847d41..98ce65e 100644 --- a/web/src/views/asset/payRefund/index.vue +++ b/web/src/views/asset/payRefund/index.vue @@ -24,8 +24,6 @@ :request="loadDataTable" :row-key="(row) => row.id" ref="actionRef" - :actionColumn="actionColumn" - @update:checked-row-keys="onCheckedRow" :scroll-x="1090" :resizeHeightOffset="-10000" size="small" @@ -51,33 +49,19 @@ diff --git a/web/src/views/asset/payRefund/model.ts b/web/src/views/asset/payRefund/model.ts index c5866a0..8c66f18 100644 --- a/web/src/views/asset/payRefund/model.ts +++ b/web/src/views/asset/payRefund/model.ts @@ -1,60 +1,10 @@ -import { h, ref } from 'vue'; -import { NAvatar, NImage, NTag, NSwitch, NRate } from 'naive-ui'; -import { cloneDeep } from 'lodash-es'; +import { ref } from 'vue'; import { FormSchema } from '@/components/Form'; -import { Dicts } from '@/api/dict/dict'; -import { isNullObject } from '@/utils/is'; import { defRangeShortcuts } from '@/utils/dateUtil'; -import { getOptionLabel, getOptionTag, Options } from '@/utils/hotgo'; +import { useDictStore } from '@/store/modules/dict'; +import { renderOptionTag } from '@/utils'; -export interface State { - id: number; - memberId: number; - appId: string; - addonsName: string; - creditType: string; - creditGroup: string; - beforeNum: number; - num: number; - afterNum: number; - remark: string; - ip: string; - mapId: number; - status: number; - createdAt: string; - updatedAt: string; -} - -export const defaultState = { - id: 0, - memberId: 0, - appId: '', - addonsName: '', - creditType: '', - creditGroup: '', - beforeNum: 0, - num: 0, - afterNum: 0, - remark: '', - ip: '', - mapId: 0, - status: 1, - createdAt: '', - updatedAt: '', -}; - -export function newState(state: State | null): State { - if (state !== null) { - return cloneDeep(state); - } - return cloneDeep(defaultState); -} - -export const options = ref({ - sys_normal_disable: [], -}); - -export const rules = {}; +const dict = useDictStore(); export const schemas = ref([ { @@ -211,22 +161,7 @@ export const columns = [ title: '状态', key: 'status', render(row) { - if (isNullObject(row.status)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_normal_disable, row.status), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_normal_disable, row.status), - } - ); + return renderOptionTag('sys_normal_disable', row.status); }, }, { @@ -239,17 +174,8 @@ export const columns = [ }, ]; -async function loadOptions() { - options.value = await Dicts({ - types: ['sys_normal_disable'], - }); - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.sys_normal_disable; - break; - } - } +export function loadOptions() { + dict.loadOptions(['sys_normal_disable']); } -await loadOptions(); +loadOptions(); diff --git a/web/src/views/asset/rechargeLog/acceptRefund.vue b/web/src/views/asset/rechargeLog/acceptRefund.vue index 0afd686..d033e6e 100644 --- a/web/src/views/asset/rechargeLog/acceptRefund.vue +++ b/web/src/views/asset/rechargeLog/acceptRefund.vue @@ -36,7 +36,10 @@ - + @@ -64,10 +67,11 @@ diff --git a/web/src/views/asset/rechargeLog/list.vue b/web/src/views/asset/rechargeLog/list.vue index a230ec8..9bd7ff8 100644 --- a/web/src/views/asset/rechargeLog/list.vue +++ b/web/src/views/asset/rechargeLog/list.vue @@ -58,15 +58,15 @@ @@ -184,9 +184,6 @@ reloadTable(); }); }, - onNegativeClick: () => { - // message.error('取消'); - }, }); } diff --git a/web/src/views/asset/rechargeLog/model.ts b/web/src/views/asset/rechargeLog/model.ts index 7a62e66..3147b7b 100644 --- a/web/src/views/asset/rechargeLog/model.ts +++ b/web/src/views/asset/rechargeLog/model.ts @@ -1,12 +1,9 @@ -import { h, ref } from 'vue'; -import { NTag } from 'naive-ui'; +import { ref } from 'vue'; import { cloneDeep } from 'lodash-es'; import { FormSchema } from '@/components/Form'; -import { Option } from '@/api/order'; -import { isNullObject } from '@/utils/is'; import { defRangeShortcuts } from '@/utils/dateUtil'; -import { getOptionLabel, getOptionTag, Options } from '@/utils/hotgo'; -import { Dicts } from '@/api/dict/dict'; +import { useDictStore } from '@/store/modules/dict'; +import { renderOptionTag } from '@/utils'; export interface State { id: number; @@ -49,12 +46,7 @@ export function newState(state: State | null): State { return cloneDeep(defaultState); } -export const options = ref({ - orderStatus: [], - acceptRefundStatus: [], - payType: [], -}); - +const dict = useDictStore(); export const rules = {}; export const schemas = ref([ @@ -131,22 +123,7 @@ export const columns = [ title: '支付方式', key: 'payLogPayType', render(row) { - if (isNullObject(row.payLogPayType)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.payType, row.payLogPayType), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.payType, row.payLogPayType), - } - ); + return renderOptionTag('payType', row.payLogPayType); }, width: 150, }, @@ -162,24 +139,7 @@ export const columns = [ title: '订单状态', key: 'status', render(row) { - if (isNullObject(row.status)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.orderStatus, row.status), - bordered: false, - }, - { - default: () => - getOptionLabel(options.value.orderStatus, row.status) + - (row.status === 9 ? ',' + row.rejectRefundReason : ''), - } - ); + return renderOptionTag('orderStatus', row.status); }, width: 150, }, @@ -190,23 +150,6 @@ export const columns = [ }, ]; -async function loadOptions() { - options.value = await Dicts({ - types: ['payType', 'orderStatus', 'acceptRefundStatus'], - }); - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.orderStatus; - break; - case 'acceptRefundStatus': - item.componentProps.options = options.value.acceptRefundStatus; - break; - case 'payType': - item.componentProps.options = options.value.payType; - break; - } - } +export function loadOptions() { + dict.loadOptions(['payType', 'orderStatus', 'acceptRefundStatus']); } - -await loadOptions(); diff --git a/web/src/views/curdDemo/edit.vue b/web/src/views/curdDemo/edit.vue index f02c8a3..5c5f4cf 100644 --- a/web/src/views/curdDemo/edit.vue +++ b/web/src/views/curdDemo/edit.vue @@ -63,16 +63,6 @@ /> - - - - - - - - - - @@ -93,8 +83,9 @@ - + \ No newline at end of file diff --git a/web/src/views/curdDemo/index.vue b/web/src/views/curdDemo/index.vue index cb365ad..a49db27 100644 --- a/web/src/views/curdDemo/index.vue +++ b/web/src/views/curdDemo/index.vue @@ -50,7 +50,8 @@ import { BasicTable, TableAction } from '@/components/Table'; import { BasicForm, useForm } from '@/components/Form/index'; import { usePermission } from '@/hooks/web/usePermission'; - import { List, Export, Delete } from '@/api/curdDemo'; + import { useDictStore } from '@/store/modules/dict'; + import { List, Export, Delete, Status } from '@/api/curdDemo'; import { PlusOutlined, ExportOutlined, DeleteOutlined } from '@vicons/antd'; import { columns, schemas, loadOptions } from './model'; import { adaTableScrollX } from '@/utils/hotgo'; @@ -59,6 +60,7 @@ const dialog = useDialog(); const message = useMessage(); const { hasPermission } = usePermission(); + const dict = useDictStore(); const actionRef = ref(); const searchFormRef = ref({}); const editRef = ref(); @@ -66,7 +68,7 @@ const checkedIds = ref([]); const actionColumn = reactive({ - width: 144, + width: 216, title: '操作', key: 'action', fixed: 'right', @@ -80,6 +82,22 @@ auth: ['/curdDemo/edit'], }, + { + label: '禁用', + onClick: handleStatus.bind(null, record, 2), + ifShow: () => { + return record.status === 1; + }, + auth: ['/curdDemo/status'], + }, + { + label: '启用', + onClick: handleStatus.bind(null, record, 1), + ifShow: () => { + return record.status === 2; + }, + auth: ['/curdDemo/status'], + }, { label: '删除', onClick: handleDelete.bind(null, record), @@ -170,9 +188,20 @@ Export(searchFormRef.value?.formModel); } + // 修改状态 + function handleStatus(record: Recordable, status: number) { + Status({ id: record.id, status: status }).then((_res) => { + message.success('设为' + dict.getLabel('sys_normal_disable', status) + '成功'); + setTimeout(() => { + reloadTable(); + }); + }); + } + onMounted(() => { loadOptions(); + }); - + \ No newline at end of file diff --git a/web/src/views/curdDemo/model.ts b/web/src/views/curdDemo/model.ts index 1ed59d1..1ef663d 100644 --- a/web/src/views/curdDemo/model.ts +++ b/web/src/views/curdDemo/model.ts @@ -1,15 +1,16 @@ import { h, ref } from 'vue'; -import { NImage, NAvatar, NSwitch, NTag } from 'naive-ui'; +import { NImage, NAvatar, NSwitch } from 'naive-ui'; import { cloneDeep } from 'lodash-es'; import { FormSchema } from '@/components/Form'; -import { Dicts } from '@/api/dict/dict'; -import { isNullObject } from '@/utils/is'; import { getFileExt } from '@/utils/urlUtils'; import { defRangeShortcuts } from '@/utils/dateUtil'; -import { Option, errorImg, getOptionLabel, getOptionTag } from '@/utils/hotgo'; +import { fallbackSrc } from '@/utils/hotgo'; import { renderPopoverMemberSumma, MemberSumma } from '@/utils'; import { Switch } from '@/api/curdDemo'; +import { useDictStore } from '@/store/modules/dict'; import { usePermission } from '@/hooks/web/usePermission'; + +const dict = useDictStore(); const { hasPermission } = usePermission(); const $message = window['$message']; @@ -76,12 +77,6 @@ export const rules = { type: 'number', message: '请输入排序', }, - categoryId: { - required: true, - trigger: ['blur', 'input'], - type: 'number', - message: '请输入测试分类', - }, }; // 表格搜索表单 @@ -119,19 +114,6 @@ export const schemas = ref([ }, }, }, - { - field: 'status', - component: 'NSelect', - label: '状态', - defaultValue: null, - componentProps: { - placeholder: '请选择状态', - options: [], - onUpdateValue: (e: any) => { - console.log(e); - }, - }, - }, { field: 'createdBy', component: 'NInput', @@ -156,19 +138,6 @@ export const schemas = ref([ }, }, }, - { - field: 'categoryId', - component: 'NSelect', - label: '测试分类', - defaultValue: null, - componentProps: { - placeholder: '请选择测试分类', - options: [], - onUpdateValue: (e: any) => { - console.log(e); - }, - }, - }, { field: 'testCategoryName', component: 'NInput', @@ -212,8 +181,7 @@ export const columns = [ width: 32, height: 32, src: row.image, - fallbackSrc: errorImg, - onError: errorImg, + fallbackSrc: fallbackSrc(), style: { width: '32px', height: '32px', @@ -270,30 +238,6 @@ export const columns = [ }); }, }, - { - title: '状态', - key: 'status', - align: 'left', - width: 100, - render(row) { - if (isNullObject(row.status)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_normal_disable, row.status), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_normal_disable, row.status), - } - ); - }, - }, { title: '创建者', key: 'createdBy', @@ -324,30 +268,6 @@ export const columns = [ align: 'left', width: 180, }, - { - title: '测试分类', - key: 'categoryId', - align: 'left', - width: 100, - render(row) { - if (isNullObject(row.categoryId)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.testCategoryOption, row.categoryId), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.testCategoryOption, row.categoryId), - } - ); - }, - }, { title: '关联分类', key: 'testCategoryName', @@ -356,27 +276,7 @@ export const columns = [ }, ]; -// 字典数据选项 -export const options = ref({ - sys_normal_disable: [] as Option[], - testCategoryOption: [] as Option[], -}); - // 加载字典数据选项 export function loadOptions() { - Dicts({ - types: ['sys_normal_disable', 'testCategoryOption'], - }).then((res) => { - options.value = res; - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.sys_normal_disable; - break; - case 'categoryId': - item.componentProps.options = options.value.testCategoryOption; - break; - } - } - }); -} \ No newline at end of file + dict.loadOptions(['sys_normal_disable', 'testCategoryOption']); +} diff --git a/web/src/views/curdDemo/view.vue b/web/src/views/curdDemo/view.vue deleted file mode 100644 index 1945bad..0000000 --- a/web/src/views/curdDemo/view.vue +++ /dev/null @@ -1,123 +0,0 @@ - - - - - diff --git a/web/src/views/dashboard/console/components/FluxTrend.vue b/web/src/views/dashboard/console/components/FluxTrend.vue index c7bdd66..4c3db4e 100644 --- a/web/src/views/dashboard/console/components/FluxTrend.vue +++ b/web/src/views/dashboard/console/components/FluxTrend.vue @@ -3,9 +3,7 @@ diff --git a/web/src/views/develop/addons/model.ts b/web/src/views/develop/addons/model.ts index 1ed6d67..575b9ad 100644 --- a/web/src/views/develop/addons/model.ts +++ b/web/src/views/develop/addons/model.ts @@ -1,11 +1,13 @@ import { cloneDeep } from 'lodash-es'; import { h, ref } from 'vue'; -import { Dicts } from '@/api/dict/dict'; -import { errorImg, Option, Options } from '@/utils/hotgo'; +import { fallbackSrc } from '@/utils/hotgo'; import { isUrl } from '@/utils/is'; import { NIcon, NIconWrapper, NImage, NTag } from 'naive-ui'; import { getIconComponent } from '@/utils/icons'; import { FormSchema } from '@/components/Form'; +import { useDictStore } from '@/store/modules/dict'; + +const dict = useDictStore(); export const genInfoObj = { label: '', @@ -36,7 +38,7 @@ export const columns = [ width: 48, height: 48, src: row.logo, - fallbackSrc: errorImg, + fallbackSrc: fallbackSrc(), style: { width: '48px', height: '48px', @@ -152,7 +154,7 @@ export const schemas = ref([ label: '分组', componentProps: { placeholder: '请选择分组', - options: [], + options: dict.getOption('addonsGroupOptions'), onUpdateValue: (e: any) => { console.log(e); }, @@ -164,7 +166,7 @@ export const schemas = ref([ label: '安装状态', componentProps: { placeholder: '请选择状态', - options: [], + options: dict.getOption('addonsInstallStatus'), onUpdateValue: (e: any) => { console.log(e); }, @@ -172,32 +174,6 @@ export const schemas = ref([ }, ]); -export interface IOptions extends Options { - addonsGroupOptions: Option[]; - addonsInstallStatus: Option[]; - addonsExtend: Option[]; +export function loadOptions() { + dict.loadOptions(['addonsGroupOptions', 'addonsInstallStatus', 'addonsExtend']); } - -export const options = ref({ - addonsGroupOptions: [], - addonsInstallStatus: [], - addonsExtend: [], -}); - -async function loadOptions() { - options.value = await Dicts({ - types: ['addonsGroupOptions', 'addonsInstallStatus', 'addonsExtend'], - }); - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.addonsInstallStatus; - break; - case 'group': - item.componentProps.options = options.value.addonsGroupOptions; - break; - } - } -} - -await loadOptions(); diff --git a/web/src/views/develop/code/index.vue b/web/src/views/develop/code/index.vue index dabc400..586b37c 100644 --- a/web/src/views/develop/code/index.vue +++ b/web/src/views/develop/code/index.vue @@ -31,7 +31,12 @@ 立即生成 - + diff --git a/web/src/views/monitor/netconn/columns.ts b/web/src/views/monitor/netconn/columns.ts index 63bdbdc..74c254c 100644 --- a/web/src/views/monitor/netconn/columns.ts +++ b/web/src/views/monitor/netconn/columns.ts @@ -1,9 +1,7 @@ import { h } from 'vue'; import { NButton, NTag } from 'naive-ui'; import { timestampToTime, formatBefore } from '@/utils/dateUtil'; -import { getOptionLabel } from '@/utils/hotgo'; -import { options } from '@/views/monitor/netconn/modal/model'; -import { renderIcon, renderTooltip } from '@/utils'; +import { renderIcon, renderOptionTag, renderTooltip } from '@/utils'; import { HelpCircleOutline } from '@vicons/ionicons5'; export const columns = [ @@ -95,19 +93,7 @@ export const columns = [ key: 'group', width: 100, render(row) { - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: 'info', - bordered: false, - }, - { - default: () => getOptionLabel(options.value.group, row.group), - } - ); + return renderOptionTag('ServerLicenseGroupOptions', row.group); }, }, { diff --git a/web/src/views/monitor/netconn/index.vue b/web/src/views/monitor/netconn/index.vue index 601f492..0dd0130 100644 --- a/web/src/views/monitor/netconn/index.vue +++ b/web/src/views/monitor/netconn/index.vue @@ -38,8 +38,8 @@ @@ -47,7 +47,7 @@ diff --git a/web/src/views/monitor/netconn/modal/edit.vue b/web/src/views/monitor/netconn/modal/edit.vue index a05b160..3a70330 100644 --- a/web/src/views/monitor/netconn/modal/edit.vue +++ b/web/src/views/monitor/netconn/modal/edit.vue @@ -24,7 +24,10 @@ - + @@ -78,7 +81,10 @@ - + @@ -100,9 +106,10 @@ import { ref, computed, watch } from 'vue'; import { Edit, View } from '@/api/serveLicense'; import DatePicker from '@/components/DatePicker/datePicker.vue'; - import { rules, options, State, newState } from './model'; + import { rules, State, newState } from './model'; import { useMessage } from 'naive-ui'; import { adaModalWidth } from '@/utils/hotgo'; + import { useDictStore } from '@/store/modules/dict'; const emit = defineEmits(['reloadTable', 'updateShowModal']); @@ -129,6 +136,7 @@ const loading = ref(false); const params = ref(props.formParams); + const dict = useDictStore(); const message = useMessage(); const formRef = ref({}); const formBtnLoading = ref(false); diff --git a/web/src/views/monitor/netconn/modal/index.vue b/web/src/views/monitor/netconn/modal/index.vue index ebf804b..3fcdaf8 100644 --- a/web/src/views/monitor/netconn/modal/index.vue +++ b/web/src/views/monitor/netconn/modal/index.vue @@ -70,8 +70,8 @@ @@ -99,7 +99,7 @@ ref="transfer" v-model:value="formParams.routes" virtual-scroll - :options="options.routes" + :options="routesOptions" source-filterable :render-source-label="renderLabel" :render-target-label="renderLabel" @@ -117,17 +117,20 @@ diff --git a/web/src/views/monitor/netconn/modal/model.ts b/web/src/views/monitor/netconn/modal/model.ts index 1b9dadf..bab1967 100644 --- a/web/src/views/monitor/netconn/modal/model.ts +++ b/web/src/views/monitor/netconn/modal/model.ts @@ -1,12 +1,11 @@ import { h, ref } from 'vue'; -import { NTag } from 'naive-ui'; import { cloneDeep } from 'lodash-es'; import { FormSchema } from '@/components/Form'; -import { Dicts } from '@/api/dict/dict'; -import { isNullObject } from '@/utils/is'; import { defRangeShortcuts, formatBefore } from '@/utils/dateUtil'; -import { getOptionLabel, getOptionTag, Options } from '@/utils/hotgo'; -import { NetOption } from '@/api/monitor/monitor'; +import { useDictStore } from '@/store/modules/dict'; +import { renderOptionTag } from '@/utils'; + +const dict = useDictStore(); export interface State { id: number; @@ -55,12 +54,6 @@ export function newState(state: State | null): State { return cloneDeep(defaultState); } -export const options = ref({ - sys_normal_disable: [], - group: [], - routes: [], -}); - export const rules = { group: { required: true, @@ -107,7 +100,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择授权分组', - options: options.value.group, + options: dict.getOption('ServerLicenseGroupOptions'), onUpdateValue: (e: any) => { console.log(e); }, @@ -142,7 +135,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择状态', - options: [], + options: dict.getOption('sys_normal_disable'), onUpdateValue: (e: any) => { console.log(e); }, @@ -187,19 +180,7 @@ export const columns = [ key: 'group', width: 100, render(row) { - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: 'info', - bordered: false, - }, - { - default: () => getOptionLabel(options.value.group, row.group), - } - ); + return renderOptionTag('ServerLicenseGroupOptions', row.group); }, }, { @@ -235,22 +216,7 @@ export const columns = [ key: 'status', width: 100, render(row) { - if (isNullObject(row.status)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_normal_disable, row.status), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_normal_disable, row.status), - } - ); + return renderOptionTag('sys_normal_disable', row.status); }, }, { @@ -283,25 +249,6 @@ export const columns = [ }, ]; -async function loadOptions() { - options.value = await Dicts({ - types: ['sys_normal_disable'], - }); - - const netOption = await NetOption(); - options.value.group = netOption.licenseGroup; - options.value.routes = netOption.routes; - - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.sys_normal_disable; - break; - case 'group': - item.componentProps.options = options.value.group; - break; - } - } +export function loadOptions() { + dict.loadOptions(['sys_normal_disable', 'ServerLicenseGroupOptions']); } - -await loadOptions(); diff --git a/web/src/views/monitor/serve-log/index.vue b/web/src/views/monitor/serve-log/index.vue index 7fe2d2d..21d02e6 100644 --- a/web/src/views/monitor/serve-log/index.vue +++ b/web/src/views/monitor/serve-log/index.vue @@ -100,7 +100,7 @@ diff --git a/web/src/views/monitor/serve-log/model.ts b/web/src/views/monitor/serve-log/model.ts index d665fab..18921e5 100644 --- a/web/src/views/monitor/serve-log/model.ts +++ b/web/src/views/monitor/serve-log/model.ts @@ -1,57 +1,13 @@ import { h, ref } from 'vue'; import { NTag, NButton } from 'naive-ui'; -import { cloneDeep } from 'lodash-es'; import { FormSchema } from '@/components/Form'; -import { Dicts } from '@/api/dict/dict'; - -import { isNullObject } from '@/utils/is'; import { defRangeShortcuts } from '@/utils/dateUtil'; import { format } from 'date-fns'; -import { getOptionLabel, getOptionTag, Options } from '@/utils/hotgo'; -import { renderIcon, renderTooltip } from '@/utils'; +import { renderIcon, renderOptionTag, renderTooltip } from '@/utils'; import { HelpCircleOutline } from '@vicons/ionicons5'; +import { useDictStore } from '@/store/modules/dict'; -export interface State { - id: number; - env: string; - traceid: string; - levelFormat: string; - content: string; - stack: any; - line: string; - triggerNs: number; - status: number; - createdAt: string; - updatedAt: string; -} - -export const defaultState = { - id: 0, - env: '', - traceid: '', - levelFormat: '', - content: '', - stack: null, - line: '', - triggerNs: 0, - status: 1, - createdAt: '', - updatedAt: '', -}; - -export function newState(state: State | null): State { - if (state !== null) { - return cloneDeep(state); - } - return cloneDeep(defaultState); -} - -export const options = ref({ - sys_normal_disable: [], - sys_log_type: [], -}); - -export const rules = {}; +const dict = useDictStore(); export const schemas = ref([ { @@ -65,6 +21,17 @@ export const schemas = ref([ }, }, }, + { + field: 'content', + component: 'NInput', + label: '日志内容', + componentProps: { + placeholder: '请输入日志内容关键词', + onUpdateValue: (e: any) => { + console.log(e); + }, + }, + }, { field: 'levelFormat', component: 'NSelect', @@ -72,7 +39,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择日志级别', - options: [], + options: dict.getOption('sys_log_type'), onUpdateValue: (e: any) => { console.log(e); }, @@ -138,22 +105,7 @@ export const columns = [ title: '日志级别', key: 'levelFormat', render(row) { - if (isNullObject(row.levelFormat)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_log_type, row.levelFormat), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_log_type, row.levelFormat), - } - ); + return renderOptionTag('sys_log_type', row.levelFormat); }, width: 120, }, @@ -162,11 +114,6 @@ export const columns = [ key: 'content', width: 320, }, - // { - // title: '调用行', - // key: 'line', - // width: 150, - // }, { title: '触发时间', key: 'triggerNs', @@ -185,20 +132,6 @@ export const columns = [ }, ]; -async function loadOptions() { - options.value = await Dicts({ - types: ['sys_normal_disable', 'sys_log_type'], - }); - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.sys_normal_disable; - break; - case 'levelFormat': - item.componentProps.options = options.value.sys_log_type; - break; - } - } +export function loadOptions() { + dict.loadOptions(['sys_normal_disable', 'sys_log_type']); } - -await loadOptions(); diff --git a/web/src/views/normalTreeDemo/edit.vue b/web/src/views/normalTreeDemo/edit.vue index 95cf4c6..8608f5a 100644 --- a/web/src/views/normalTreeDemo/edit.vue +++ b/web/src/views/normalTreeDemo/edit.vue @@ -43,7 +43,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -81,8 +81,9 @@ diff --git a/web/src/views/normalTreeDemo/model.ts b/web/src/views/normalTreeDemo/model.ts index b19ae07..1b0ef97 100644 --- a/web/src/views/normalTreeDemo/model.ts +++ b/web/src/views/normalTreeDemo/model.ts @@ -2,12 +2,13 @@ import { h, ref } from 'vue'; import { NTag } from 'naive-ui'; import { cloneDeep } from 'lodash-es'; import { FormSchema } from '@/components/Form'; -import { Dicts } from '@/api/dict/dict'; import { isNullObject } from '@/utils/is'; import { defRangeShortcuts } from '@/utils/dateUtil'; -import { Option, getOptionLabel, getOptionTag } from '@/utils/hotgo'; import { renderPopoverMemberSumma, MemberSumma } from '@/utils'; import { TreeOption } from '@/api/normalTreeDemo'; +import { useDictStore } from '@/store/modules/dict'; + +const dict = useDictStore(); export class State { public title = ''; // 标题 @@ -73,7 +74,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择测试分类', - options: [], + options: dict.getOption('testCategoryOption'), onUpdateValue: (e: any) => { console.log(e); }, @@ -86,7 +87,7 @@ export const schemas = ref([ defaultValue: null, componentProps: { placeholder: '请选择状态', - options: [], + options: dict.getOption('sys_normal_disable'), onUpdateValue: (e: any) => { console.log(e); }, @@ -130,11 +131,11 @@ export const columns = [ style: { marginRight: '6px', }, - type: getOptionTag(options.value.testCategoryOption, row.categoryId), + type: dict.getType('testCategoryOption', row.categoryId), bordered: false, }, { - default: () => getOptionLabel(options.value.testCategoryOption, row.categoryId), + default: () => dict.getLabel('testCategoryOption', row.categoryId), } ); }, @@ -160,11 +161,11 @@ export const columns = [ style: { marginRight: '6px', }, - type: getOptionTag(options.value.sys_normal_disable, row.status), + type: dict.getType('sys_normal_disable', row.status), bordered: false, }, { - default: () => getOptionLabel(options.value.sys_normal_disable, row.status), + default: () => dict.getLabel('sys_normal_disable', row.status), } ); }, @@ -186,29 +187,9 @@ export const columns = [ }, ]; -// 字典数据选项 -export const options = ref({ - sys_normal_disable: [] as Option[], - testCategoryOption: [] as Option[], -}); - // 加载字典数据选项 export function loadOptions() { - Dicts({ - types: ['sys_normal_disable', 'testCategoryOption'], - }).then((res) => { - options.value = res; - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.sys_normal_disable; - break; - case 'categoryId': - item.componentProps.options = options.value.testCategoryOption; - break; - } - } - }); + dict.loadOptions(['sys_normal_disable', 'testCategoryOption']); } // 关系树选项 diff --git a/web/src/views/normalTreeDemo/view.vue b/web/src/views/normalTreeDemo/view.vue deleted file mode 100644 index c6e6847..0000000 --- a/web/src/views/normalTreeDemo/view.vue +++ /dev/null @@ -1,92 +0,0 @@ - - - - - \ No newline at end of file diff --git a/web/src/views/optionTreeDemo/edit.vue b/web/src/views/optionTreeDemo/edit.vue index f4a7bf2..ce90b26 100644 --- a/web/src/views/optionTreeDemo/edit.vue +++ b/web/src/views/optionTreeDemo/edit.vue @@ -43,12 +43,12 @@ - + - + @@ -58,7 +58,7 @@ - + @@ -81,8 +81,9 @@ - - \ No newline at end of file diff --git a/web/src/views/org/dept/edit.vue b/web/src/views/org/dept/edit.vue index ed72a28..c1aacdb 100644 --- a/web/src/views/org/dept/edit.vue +++ b/web/src/views/org/dept/edit.vue @@ -50,7 +50,7 @@ - + {{ item.label }} @@ -86,7 +86,7 @@ import { ref, computed } from 'vue'; import { Edit, View, MaxSort } from '@/api/org/dept'; - import { options, State, newState, treeOption, loadTreeOption, rules } from './model'; + import { State, newState, treeOption, loadTreeOption, rules } from './model'; import { useProjectSettingStore } from '@/store/modules/projectSetting'; import { useMessage } from 'naive-ui'; import { adaModalWidth } from '@/utils/hotgo'; + import { useDictStore } from '@/store/modules/dict'; const emit = defineEmits(['reloadTable']); const message = useMessage(); const settingStore = useProjectSettingStore(); + const dict = useDictStore(); const loading = ref(false); const showModal = ref(false); const formValue = ref(newState(null)); diff --git a/web/src/views/org/dept/model.ts b/web/src/views/org/dept/model.ts index c794d30..30fc87e 100644 --- a/web/src/views/org/dept/model.ts +++ b/web/src/views/org/dept/model.ts @@ -2,14 +2,15 @@ import { h, ref } from 'vue'; import { NTag, NButton } from 'naive-ui'; import { cloneDeep } from 'lodash-es'; import { FormSchema } from '@/components/Form'; -import { Dicts } from '@/api/dict/dict'; import { defRangeShortcuts } from '@/utils/dateUtil'; import { validate } from '@/utils/validateUtil'; -import { Option, getOptionLabel, getOptionTag } from '@/utils/hotgo'; -import { renderTooltip, renderIcon } from '@/utils'; +import { renderTooltip, renderIcon, renderOptionTag } from '@/utils'; import { HelpCircleOutline } from '@vicons/ionicons5'; import { TreeOption } from '@/api/org/dept'; -import { isNullObject } from '@/utils/is'; +import { useDictStore } from '@/store/modules/dict'; +import type { FormRules } from 'naive-ui/es/form/src/interface'; + +const dict = useDictStore(); export class State { public id = 0; // 部门ID @@ -45,7 +46,7 @@ export function newState(state: State | Record | null): State { } // 表单验证规则 -export const rules = { +export const rules: FormRules = { email: { required: false, trigger: ['blur', 'input'], @@ -155,22 +156,7 @@ export const columns = [ align: 'left', width: 100, render(row) { - if (isNullObject(row.type)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.deptType, row.type), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.deptType, row.type), - } - ); + return renderOptionTag('deptType', row.type); }, }, { @@ -189,22 +175,7 @@ export const columns = [ align: 'left', width: 80, render(row) { - if (isNullObject(row.status)) { - return ``; - } - return h( - NTag, - { - style: { - marginRight: '6px', - }, - type: getOptionTag(options.value.sys_normal_disable, row.status), - bordered: false, - }, - { - default: () => getOptionLabel(options.value.sys_normal_disable, row.status), - } - ); + return renderOptionTag('sys_normal_disable', row.status); }, }, { @@ -214,26 +185,9 @@ export const columns = [ }, ]; -// 字典数据选项 -export const options = ref({ - sys_normal_disable: [] as Option[], - deptType: [] as Option[], -}); - // 加载字典数据选项 export function loadOptions() { - Dicts({ - types: ['sys_normal_disable', 'deptType'], - }).then((res) => { - options.value = res; - for (const item of schemas.value) { - switch (item.field) { - case 'status': - item.componentProps.options = options.value.sys_normal_disable; - break; - } - } - }); + dict.loadOptions(['sys_normal_disable', 'deptType']); } // 关系树选项 diff --git a/web/src/views/org/user/list.vue b/web/src/views/org/user/list.vue index 8682d08..22336e5 100644 --- a/web/src/views/org/user/list.vue +++ b/web/src/views/org/user/list.vue @@ -20,7 +20,7 @@ ref="actionRef" :actionColumn="actionColumn" @update:checked-row-keys="onCheckedRow" - :scroll-x="1500" + :scroll-x="scrollX" :resizeHeightOffset="-10000" > diff --git a/web/src/views/org/user/model.ts b/web/src/views/org/user/model.ts index edd187d..4f18199 100644 --- a/web/src/views/org/user/model.ts +++ b/web/src/views/org/user/model.ts @@ -3,12 +3,13 @@ import { ref } from 'vue'; import { getDeptOption } from '@/api/org/dept'; import { getRoleOption } from '@/api/system/role'; import { FormSchema, useForm } from '@/components/Form'; -import { statusOptions } from '@/enums/optionsiEnum'; import { defRangeShortcuts } from '@/utils/dateUtil'; -import { Dicts } from '@/api/dict/dict'; +import { useDictStore, Option } from '@/store/modules/dict'; // 增加余额/积分. +const dict = useDictStore(); + export interface addState { id: number; username: string; @@ -166,7 +167,7 @@ const schemas: FormSchema[] = [ defaultValue: null, componentProps: { placeholder: '请选择类型', - options: statusOptions, + options: dict.getOption('sys_normal_disable'), onUpdateValue: (e: any) => { console.log(e); }, @@ -193,42 +194,44 @@ export const [register, {}] = useForm({ schemas, }); -export const options = ref({ - role: [], - roleTabs: [{ id: -1, name: '全部' }], - dept: [], - post: [], - sys_user_sex: [], - sys_normal_disable: [], -}); +export const deptTreeOptions = ref([]); +export const roleTreeOptions = ref([]); export async function loadOptions() { - const dept = await getDeptOption(); - if (dept.list) { - options.value.dept = dept.list; - } + dict.loadOptions(['adminPostOption', 'sys_user_sex', 'sys_normal_disable']); - const role = await getRoleOption(); - if (role.list) { - options.value.role = role.list; - options.value.roleTabs = [{ id: -1, name: '全部' }]; - treeDataToCompressed(role.list); - } - - const tmpOptions = await Dicts({ - types: ['adminPostOption', 'sys_user_sex', 'sys_normal_disable'], + getDeptOption().then((res) => { + if (res.list) { + deptTreeOptions.value = res.list; + } + }); + + getRoleOption().then((res) => { + if (res.list) { + roleTreeOptions.value = res.list; + registerRoleTabsOption(); + } }); - options.value.post = tmpOptions?.adminPostOption; - options.value.sys_user_sex = tmpOptions?.sys_user_sex; - options.value.sys_normal_disable = tmpOptions?.sys_normal_disable; } -function treeDataToCompressed(source) { +// 将角色Tabs选项注册到字典 +function registerRoleTabsOption() { + const items = [{ id: -1, name: '全部' }]; + treeDataToCompressed(items, roleTreeOptions.value); + + const roleTabs: Option[] = []; + for (const item of items) { + roleTabs.push(dict.genOption(item.id, item.name)); + } + dict.setOption('roleTabs', roleTabs); +} + +function treeDataToCompressed(items: any[], source: any) { for (const i in source) { - options.value.roleTabs.push(source[i]); + items.push(source[i]); source[i].children && source[i].children.length > 0 - ? treeDataToCompressed(source[i].children) + ? treeDataToCompressed(items, source[i].children) : ''; // 子级递归 } - return options.value.roleTabs; + return items; } diff --git a/web/src/views/org/user/user.vue b/web/src/views/org/user/user.vue index 705a35f..64a6267 100644 --- a/web/src/views/org/user/user.vue +++ b/web/src/views/org/user/user.vue @@ -12,9 +12,9 @@ @before-leave="handleBeforeLeave" > @@ -28,8 +28,10 @@ import { onMounted, ref } from 'vue'; import List from './list.vue'; import { useRouter } from 'vue-router'; - import { options } from './model'; + import { loadOptions } from './model'; + import { useDictStore } from '@/store/modules/dict'; + const dict = useDictStore(); const router = useRouter(); const defaultTab = ref('-1'); @@ -37,6 +39,7 @@ if (router.currentRoute.value.query?.type) { defaultTab.value = router.currentRoute.value.query.type as string; } + loadOptions(); }); function handleBeforeLeave(tabName: string): boolean | Promise { diff --git a/web/src/views/permission/menu/editForm.vue b/web/src/views/permission/menu/editForm.vue index bba393a..3fc245e 100644 --- a/web/src/views/permission/menu/editForm.vue +++ b/web/src/views/permission/menu/editForm.vue @@ -17,7 +17,7 @@ :on-update:value="handleUpdateType" > { return adaModalWidth(1280); }); - const emit = defineEmits(['reloadTable']); - function openModal() { showModal.value = true; } diff --git a/web/src/views/permission/menu/model.ts b/web/src/views/permission/menu/model.ts index 168716f..44929ee 100644 --- a/web/src/views/permission/menu/model.ts +++ b/web/src/views/permission/menu/model.ts @@ -1,11 +1,11 @@ -import { ref } from 'vue'; import { cloneDeep } from 'lodash-es'; -import { Option } from '@/utils/hotgo'; -import { Dicts } from '@/api/dict/dict'; +import { useDictStore } from '@/store/modules/dict'; + +const dict = useDictStore(); export interface State { id: number; - pid?: number; + pid?: number | null; title: string; name: string; path: string; @@ -15,7 +15,7 @@ export interface State { redirect: string; permissions: string; permissionName: string; - component?: string; + component?: string | null; alwaysShow: number; activeMenu: string; isRoot: number; @@ -27,7 +27,7 @@ export interface State { status: number; sort: number; disabled: boolean; - children?: State[]; + children?: State[] | null; } export const defaultState: State = { @@ -66,7 +66,10 @@ export function newState(state: State | null): State { // 默认值校正,主要为了解决历史数据格式不规范问题 export function defaultValueCheck(state: State): State { - if (state.pid < 1) { + if (!state) { + state = newState(null); + } + if (!state.pid || state.pid < 1) { state.pid = null; } if (state.alwaysShow != 1) { @@ -93,19 +96,7 @@ export function defaultValueCheck(state: State): State { return state; } -// 字典数据选项 -export const options = ref({ - sys_menu_types: [] as Option[], - sys_menu_component: [] as Option[], - sys_normal_disable: [] as Option[], - sys_switch: [] as Option[], -}); - // 加载字典数据选项 export function loadOptions() { - Dicts({ - types: ['sys_menu_types', 'sys_menu_component', 'sys_normal_disable', 'sys_switch'], - }).then((res) => { - options.value = res; - }); + dict.loadOptions(['sys_menu_types', 'sys_menu_component', 'sys_normal_disable', 'sys_switch']); } diff --git a/web/src/views/system/blacklist/index.vue b/web/src/views/system/blacklist/index.vue index 5f2c185..00e6fbc 100644 --- a/web/src/views/system/blacklist/index.vue +++ b/web/src/views/system/blacklist/index.vue @@ -73,7 +73,7 @@ diff --git a/web/src/views/system/config/PaySetting.vue b/web/src/views/system/config/PaySetting.vue index 54059a3..f7715fb 100644 --- a/web/src/views/system/config/PaySetting.vue +++ b/web/src/views/system/config/PaySetting.vue @@ -119,7 +119,10 @@ class="py-4" > - + @@ -153,8 +156,7 @@ import { ref, onMounted } from 'vue'; import { useMessage } from 'naive-ui'; import { getConfig, sendTestSms, updateConfig } from '@/api/sys/config'; - import { Dicts } from '@/api/dict/dict'; - import { Options } from '@/utils/hotgo'; + import { useDictStore } from '@/store/modules/dict'; const group = ref('pay'); const show = ref(false); @@ -165,11 +167,7 @@ const formTestRef = ref(); const formRef: any = ref(null); const message = useMessage(); - - const options = ref({ - config_sms_template: [], - config_sms_drive: [], - }); + const dict = useDictStore(); const formValue = ref({ payDebug: true, @@ -188,11 +186,6 @@ payQQPayApiKey: '', }); - function sendTest() { - showModal.value = true; - formBtnLoading.value = false; - } - function formSubmit() { formRef.value.validate((errors) => { if (!errors) { @@ -206,28 +199,20 @@ }); } - onMounted(() => { - load(); - }); - - async function load() { + function load() { show.value = true; - await loadOptions(); - new Promise((_resolve, _reject) => { - getConfig({ group: group.value }) - .then((res) => { - formValue.value = res.list; - }) - .finally(() => { - show.value = false; - }); - }); + loadOptions(); + getConfig({ group: group.value }) + .then((res) => { + formValue.value = res.list; + }) + .finally(() => { + show.value = false; + }); } - async function loadOptions() { - options.value = await Dicts({ - types: ['config_sms_template', 'config_sms_drive'], - }); + function loadOptions() { + dict.loadOptions(['config_sms_template', 'config_sms_drive']); } function confirmForm(e) { @@ -245,4 +230,8 @@ formBtnLoading.value = false; }); } + + onMounted(() => { + load(); + }); diff --git a/web/src/views/system/config/SmsSetting.vue b/web/src/views/system/config/SmsSetting.vue index 02df2c6..9c1755d 100644 --- a/web/src/views/system/config/SmsSetting.vue +++ b/web/src/views/system/config/SmsSetting.vue @@ -6,17 +6,16 @@ :model="formValue" :rules="rules" ref="formRef" - label-placement="left" + label-placement="top" > + 基础设置 - - 发信限制 - + @@ -213,17 +215,23 @@ import { ref, onMounted, watch } from 'vue'; import { useMessage } from 'naive-ui'; import { getConfig, sendTestSms, updateConfig } from '@/api/sys/config'; - import { Dicts } from '@/api/dict/dict'; - import { Options } from '@/utils/hotgo'; import { GlassesOutline, Glasses } from '@vicons/ionicons5'; + import { useDictStore } from '@/store/modules/dict'; + import type { FormRules } from 'naive-ui/es/form/src/interface'; + const dict = useDictStore(); + const message = useMessage(); const group = ref('sms'); const show = ref(false); const showModal = ref(false); const formBtnLoading = ref(false); const formParams = ref({ mobile: '', event: '', code: '1234' }); + const formTestRef = ref(); + const formRef: any = ref(null); + const defaultTabName = 'aliyun'; + const tabName = ref(defaultTabName); - const rules = { + const rules: FormRules = { smsDrive: { required: true, message: '请输入默认驱动', @@ -231,20 +239,6 @@ }, }; - const formTestRef = ref(); - const formRef: any = ref(null); - const message = useMessage(); - - const options = ref({ - config_sms_template: [], - config_sms_drive: [], - }); - - /** 默认选项卡 */ - const defaultTabName = 'aliyun'; - /** 选项卡名称 */ - const tabName = ref(defaultTabName); - const formValue = ref({ smsDrive: defaultTabName, smsMinInterval: 60, @@ -263,14 +257,6 @@ smsTencentTemplate: null, }); - /** 监听类型变化,同步到选项卡中 */ - watch( - () => formValue.value.smsDrive, - (smsDrive: string) => { - tabName.value = smsDrive; - } - ); - function sendTest() { showModal.value = true; formBtnLoading.value = false; @@ -289,30 +275,21 @@ }); } - onMounted(() => { - load(); - }); - - async function load() { + function load() { show.value = true; - await loadOptions(); - new Promise((_resolve, _reject) => { - getConfig({ group: group.value }) - .then((res) => { - res.list.smsAliYunTemplate = JSON.parse(res.list.smsAliYunTemplate); - res.list.smsTencentTemplate = JSON.parse(res.list.smsTencentTemplate); - formValue.value = res.list; - }) - .finally(() => { - show.value = false; - }); - }); + getConfig({ group: group.value }) + .then((res) => { + res.list.smsAliYunTemplate = JSON.parse(res.list.smsAliYunTemplate); + res.list.smsTencentTemplate = JSON.parse(res.list.smsTencentTemplate); + formValue.value = res.list; + }) + .finally(() => { + show.value = false; + }); } - async function loadOptions() { - options.value = await Dicts({ - types: ['config_sms_template', 'config_sms_drive'], - }); + function loadOptions() { + dict.loadOptions(['config_sms_template', 'config_sms_drive']); } function confirmForm(e) { @@ -330,4 +307,16 @@ formBtnLoading.value = false; }); } + + watch( + () => formValue.value.smsDrive, + (smsDrive: string) => { + tabName.value = smsDrive; + } + ); + + onMounted(() => { + loadOptions(); + load(); + }); diff --git a/web/src/views/system/config/UploadSetting.vue b/web/src/views/system/config/UploadSetting.vue index 2d9b0bb..48fcefb 100644 --- a/web/src/views/system/config/UploadSetting.vue +++ b/web/src/views/system/config/UploadSetting.vue @@ -6,17 +6,16 @@ :model="formValue" :rules="rules" ref="formRef" - label-placement="left" + label-placement="top" > + 基础设置 - - 上传限制 (defaultTabName); - const rules = { + const rules: FormRules = { uploadDrive: { required: true, message: '请输入默认驱动', @@ -327,15 +329,6 @@ }, }; - const options = ref({ - config_upload_drive: [], - }); - - /** 默认选项卡 */ - const defaultTabName = 'local'; - /** 选项卡名称 */ - const tabName = ref(defaultTabName); - const formValue = ref({ uploadDrive: defaultTabName, uploadImageSize: 2, @@ -374,14 +367,6 @@ uploadMinioDomain: '', }); - /** 监听类型变化,同步到选项卡中 */ - watch( - () => formValue.value.uploadDrive, - (uploadDrive: string) => { - tabName.value = uploadDrive; - } - ); - function formSubmit() { formRef.value.validate((errors) => { if (!errors) { @@ -395,27 +380,30 @@ }); } - onMounted(async () => { - load(); - await loadOptions(); - }); - function load() { show.value = true; - new Promise((_resolve, _reject) => { - getConfig({ group: group.value }) - .then((res) => { - formValue.value = res.list; - }) - .finally(() => { - show.value = false; - }); - }); + getConfig({ group: group.value }) + .then((res) => { + formValue.value = res.list; + }) + .finally(() => { + show.value = false; + }); } - async function loadOptions() { - options.value = await Dicts({ - types: ['config_upload_drive'], - }); + function loadOptions() { + dict.loadOptions(['config_upload_drive']); } + + watch( + () => formValue.value.uploadDrive, + (uploadDrive: string) => { + tabName.value = uploadDrive; + } + ); + + onMounted(async () => { + loadOptions(); + load(); + }); diff --git a/web/src/views/system/dict/CreateDrawer.vue b/web/src/views/system/dict/CreateDrawer.vue index 44b8c5e..10b704a 100644 --- a/web/src/views/system/dict/CreateDrawer.vue +++ b/web/src/views/system/dict/CreateDrawer.vue @@ -1,5 +1,9 @@ - diff --git a/web/src/views/system/dict/index.vue b/web/src/views/system/dict/index.vue index 6b9a1c3..eb267f6 100644 --- a/web/src/views/system/dict/index.vue +++ b/web/src/views/system/dict/index.vue @@ -58,7 +58,7 @@