From f4668412002ee4483f9fd3ae309e8c2621df505a Mon Sep 17 00:00:00 2001 From: yxh Date: Fri, 20 Jan 2023 10:53:34 +0800 Subject: [PATCH] gfast-v3.2.1 --- .gitignore | 29 + LICENSE | 201 +++ README.MD | 170 +++ api/v1/common/captcha.go | 19 + api/v1/common/req.go | 20 + api/v1/common/res.go | 21 + api/v1/system/big_upload.go | 38 + api/v1/system/personal.go | 57 + api/v1/system/sys_auth_rule.go | 112 ++ api/v1/system/sys_big_file.go | 66 + api/v1/system/sys_config.go | 71 + api/v1/system/sys_dept.go | 71 + api/v1/system/sys_dict_data.go | 93 ++ api/v1/system/sys_dict_type.go | 79 ++ api/v1/system/sys_init.go | 66 + api/v1/system/sys_job.go | 154 +++ api/v1/system/sys_login.go | 38 + api/v1/system/sys_login_log.go | 47 + api/v1/system/sys_monitor.go | 11 + api/v1/system/sys_oper_log.go | 65 + api/v1/system/sys_post.go | 61 + api/v1/system/sys_role.go | 105 ++ api/v1/system/sys_user.go | 133 ++ api/v1/system/sys_user_online.go | 40 + api/v1/system/tools_gen_table.go | 127 ++ api/v1/system/ueditor.go | 34 + api/v1/system/upload.go | 45 + go.mod | 24 + go.sum | 307 +++++ hack/config.yaml | 10 + internal/app/boot/boot.go | 13 + internal/app/common/consts/cache.go | 21 + internal/app/common/consts/consts.go | 8 + internal/app/common/consts/upload.go | 11 + internal/app/common/controller/base.go | 19 + internal/app/common/controller/captcha.go | 32 + internal/app/common/dao/casbin_rule.go | 24 + .../app/common/dao/internal/casbin_rule.go | 84 ++ .../app/common/dao/internal/sys_config.go | 90 ++ .../app/common/dao/internal/sys_dict_data.go | 98 ++ .../app/common/dao/internal/sys_dict_type.go | 88 ++ internal/app/common/dao/sys_config.go | 24 + internal/app/common/dao/sys_dict_data.go | 24 + internal/app/common/dao/sys_dict_type.go | 24 + .../app/common/logic/bigUpload/big_upload.go | 74 + internal/app/common/logic/cache/cache.go | 45 + internal/app/common/logic/captcha/captcha.go | 69 + internal/app/common/logic/logic.go | 16 + .../app/common/logic/middleware/middleware.go | 31 + .../app/common/logic/sysConfig/sys_config.go | 178 +++ .../common/logic/sysDictData/sys_dict_data.go | 173 +++ .../common/logic/sysDictType/sys_dict_type.go | 186 +++ internal/app/common/logic/upload/upload.go | 201 +++ internal/app/common/model/do/casbin_rule.go | 21 + internal/app/common/model/do/sys_config.go | 25 + internal/app/common/model/do/sys_dict_data.go | 29 + internal/app/common/model/do/sys_dict_type.go | 24 + .../app/common/model/entity/casbin_rule.go | 16 + .../app/common/model/entity/sys_config.go | 23 + .../app/common/model/entity/sys_dict_data.go | 27 + .../app/common/model/entity/sys_dict_type.go | 22 + internal/app/common/model/sys_config.go | 8 + internal/app/common/model/sys_dict_data.go | 21 + internal/app/common/model/sys_dict_type.go | 19 + internal/app/common/model/token.go | 32 + internal/app/common/model/upload.go | 15 + internal/app/common/router/router.go | 28 + internal/app/common/service/big_upload.go | 30 + internal/app/common/service/cache.go | 29 + internal/app/common/service/captcha.go | 28 + internal/app/common/service/casbin.go | 220 +++ internal/app/common/service/middleware.go | 27 + internal/app/common/service/sys_config.go | 37 + internal/app/common/service/sys_dict_data.go | 34 + internal/app/common/service/sys_dict_type.go | 36 + internal/app/common/service/upload.go | 33 + internal/app/system/consts/cache.go | 29 + internal/app/system/consts/consts.go | 5 + internal/app/system/consts/context.go | 13 + internal/app/system/controller/base.go | 22 + internal/app/system/controller/big_file.go | 38 + internal/app/system/controller/big_upload.go | 45 + internal/app/system/controller/personal.go | 34 + .../app/system/controller/sys_auth_rule.go | 79 ++ internal/app/system/controller/sys_config.go | 51 + internal/app/system/controller/sys_dept.go | 60 + .../app/system/controller/sys_dict_data.go | 55 + .../app/system/controller/sys_dict_type.go | 57 + internal/app/system/controller/sys_job.go | 82 ++ internal/app/system/controller/sys_login.go | 112 ++ .../app/system/controller/sys_login_log.go | 35 + internal/app/system/controller/sys_monitor.go | 142 ++ .../app/system/controller/sys_oper_log.go | 43 + internal/app/system/controller/sys_post.go | 44 + internal/app/system/controller/sys_role.go | 74 + internal/app/system/controller/sys_user.go | 102 ++ .../app/system/controller/sys_user_online.go | 28 + .../app/system/controller/tools_gen_table.go | 88 ++ internal/app/system/controller/ueditor.go | 199 +++ internal/app/system/controller/upload.go | 66 + internal/app/system/dao/big_file.go | 27 + internal/app/system/dao/internal/big_file.go | 98 ++ .../app/system/dao/internal/sys_auth_rule.go | 114 ++ internal/app/system/dao/internal/sys_dept.go | 98 ++ internal/app/system/dao/internal/sys_job.go | 102 ++ .../app/system/dao/internal/sys_job_log.go | 79 ++ .../app/system/dao/internal/sys_login_log.go | 90 ++ .../app/system/dao/internal/sys_oper_log.go | 99 ++ internal/app/system/dao/internal/sys_post.go | 92 ++ internal/app/system/dao/internal/sys_role.go | 86 ++ .../app/system/dao/internal/sys_role_dept.go | 75 + internal/app/system/dao/internal/sys_user.go | 112 ++ .../system/dao/internal/sys_user_online.go | 87 ++ .../app/system/dao/internal/sys_user_post.go | 74 + .../system/dao/internal/tools_gen_table.go | 107 ++ .../dao/internal/tools_gen_table_column.go | 151 +++ internal/app/system/dao/sys_auth_rule.go | 24 + internal/app/system/dao/sys_dept.go | 27 + internal/app/system/dao/sys_job.go | 29 + internal/app/system/dao/sys_job_log.go | 27 + internal/app/system/dao/sys_login_log.go | 24 + internal/app/system/dao/sys_oper_log.go | 27 + internal/app/system/dao/sys_post.go | 24 + internal/app/system/dao/sys_role.go | 24 + internal/app/system/dao/sys_role_dept.go | 27 + internal/app/system/dao/sys_user.go | 24 + internal/app/system/dao/sys_user_online.go | 27 + internal/app/system/dao/sys_user_post.go | 27 + internal/app/system/dao/tools_gen_table.go | 27 + .../app/system/dao/tools_gen_table_column.go | 27 + internal/app/system/logic/context/context.go | 66 + internal/app/system/logic/logic.go | 19 + .../app/system/logic/middleware/middleware.go | 127 ++ .../app/system/logic/personal/personal.go | 95 ++ .../system/logic/sysAuthRule/sys_auth_rule.go | 316 +++++ internal/app/system/logic/sysDept/sys_dept.go | 179 +++ internal/app/system/logic/sysJob/sys_job.go | 252 ++++ .../app/system/logic/sysJobLog/sys_job_log.go | 62 + .../system/logic/sysLoginLog/sys_login_log.go | 103 ++ .../system/logic/sysOperLog/sys_oper_log.go | 194 +++ internal/app/system/logic/sysPost/sys_post.go | 111 ++ internal/app/system/logic/sysRole/sys_role.go | 244 ++++ internal/app/system/logic/sysUser/sys_user.go | 697 ++++++++++ .../logic/sysUserOnline/sys_user_online.go | 187 +++ .../app/system/logic/timeTask/time_task.go | 61 + internal/app/system/logic/token/token.go | 51 + .../logic/toolsGenTable/tools_gen_table.go | 1207 +++++++++++++++++ .../tools_gen_table_column.go | 369 +++++ internal/app/system/model/.gitkeep | 0 internal/app/system/model/context.go | 16 + internal/app/system/model/do/big_file.go | 29 + internal/app/system/model/do/sys_auth_rule.go | 37 + internal/app/system/model/do/sys_dept.go | 29 + internal/app/system/model/do/sys_job.go | 34 + internal/app/system/model/do/sys_job_log.go | 19 + internal/app/system/model/do/sys_login_log.go | 25 + internal/app/system/model/do/sys_oper_log.go | 29 + internal/app/system/model/do/sys_post.go | 26 + internal/app/system/model/do/sys_role.go | 23 + internal/app/system/model/do/sys_role_dept.go | 16 + internal/app/system/model/do/sys_user.go | 36 + .../app/system/model/do/sys_user_online.go | 23 + internal/app/system/model/do/sys_user_post.go | 16 + .../app/system/model/do/tools_gen_table.go | 33 + .../system/model/do/tools_gen_table_column.go | 54 + internal/app/system/model/entity/.gitkeep | 0 internal/app/system/model/entity/big_file.go | 27 + .../app/system/model/entity/sys_auth_rule.go | 35 + internal/app/system/model/entity/sys_dept.go | 27 + internal/app/system/model/entity/sys_job.go | 34 + .../app/system/model/entity/sys_job_log.go | 17 + .../app/system/model/entity/sys_login_log.go | 23 + .../app/system/model/entity/sys_oper_log.go | 27 + internal/app/system/model/entity/sys_post.go | 24 + internal/app/system/model/entity/sys_role.go | 21 + .../app/system/model/entity/sys_role_dept.go | 11 + internal/app/system/model/entity/sys_user.go | 34 + .../system/model/entity/sys_user_online.go | 21 + .../app/system/model/entity/sys_user_post.go | 11 + .../system/model/entity/tools_gen_table.go | 31 + .../model/entity/tools_gen_table_column.go | 49 + internal/app/system/model/sys_auth_rule.go | 59 + internal/app/system/model/sys_dept.go | 15 + internal/app/system/model/sys_init.go | 39 + internal/app/system/model/sys_job.go | 44 + internal/app/system/model/sys_oper_log.go | 66 + internal/app/system/model/sys_role.go | 8 + internal/app/system/model/sys_user.go | 47 + internal/app/system/model/sys_user_login.go | 18 + internal/app/system/model/sys_user_online.go | 17 + internal/app/system/model/task.go | 16 + internal/app/system/model/tools_gen_table.go | 80 ++ .../system/model/tools_gen_table_column.go | 60 + internal/app/system/packed/packed.go | 1 + internal/app/system/router/router.go | 59 + internal/app/system/router/sys_job.go | 24 + internal/app/system/service/.gitkeep | 0 internal/app/system/service/big_file.go | 101 ++ internal/app/system/service/context.go | 34 + internal/app/system/service/middleware.go | 28 + internal/app/system/service/personal.go | 35 + internal/app/system/service/sys_auth_rule.go | 47 + internal/app/system/service/sys_dept.go | 38 + internal/app/system/service/sys_job.go | 43 + internal/app/system/service/sys_job_log.go | 36 + internal/app/system/service/sys_login_log.go | 33 + internal/app/system/service/sys_oper_log.go | 40 + internal/app/system/service/sys_post.go | 34 + internal/app/system/service/sys_role.go | 45 + internal/app/system/service/sys_user.go | 65 + .../app/system/service/sys_user_online.go | 42 + internal/app/system/service/time_task.go | 33 + internal/app/system/service/token.go | 38 + .../app/system/service/tools_gen_table.go | 50 + .../system/service/tools_gen_table_column.go | 53 + internal/cmd/cmd.go | 47 + internal/consts/consts_openapi.go | 8 + internal/consts/version.go | 12 + internal/router/router.go | 32 + library/libResponse/response.go | 107 ++ library/libRouter/router.go | 36 + library/libUtils/slice_tree.go | 249 ++++ library/libUtils/utils.go | 196 +++ library/liberr/err.go | 30 + library/upload/init.go | 47 + library/upload/local.go | 57 + library/upload/qiniou.go | 75 + library/upload/tencent.go | 75 + library/upload_chunk/consts.go | 7 + library/upload_chunk/helper.go | 81 ++ library/upload_chunk/option.go | 241 ++++ library/upload_chunk/upload_chunk.go | 309 +++++ main.go | 16 + manifest/config/config.yaml.bak | 104 ++ .../deploy/kustomize/base/deployment.yaml | 21 + .../deploy/kustomize/base/kustomization.yaml | 8 + manifest/deploy/kustomize/base/service.yaml | 12 + .../kustomize/overlays/develop/configmap.yaml | 14 + .../overlays/develop/deployment.yaml | 10 + .../overlays/develop/kustomization.yaml | 14 + manifest/docker/Dockerfile | 19 + manifest/docker/docker.sh | 8 + resource/casbin/rbac_model.conf | 14 + resource/casbin/rbac_policy.csv | 5 + resource/data/.gitkeep | 0 resource/data/gfast-v32.sql | 1125 +++++++++++++++ resource/i18n/.gitkeep | 0 resource/public/html/.gitkeep | 0 resource/public/plugin/.gitkeep | 0 resource/scripts/.gitkeep | 0 resource/template/.gitkeep | 0 resource/template/vm/go/api.template | 120 ++ resource/template/vm/go/controller.template | 68 + resource/template/vm/go/dao.template | 32 + resource/template/vm/go/dao_internal.template | 90 ++ resource/template/vm/go/logic.template | 309 +++++ resource/template/vm/go/model.template | 74 + resource/template/vm/go/model_do.template | 28 + resource/template/vm/go/model_entity.template | 46 + resource/template/vm/go/router.template | 38 + resource/template/vm/go/router_func.template | 25 + resource/template/vm/go/service.template | 54 + resource/template/vm/sql/sql.template | 64 + resource/template/vm/ts/api.template | 108 ++ resource/template/vm/ts/model.template | 75 + resource/template/vm/vue/detail-vue.template | 511 +++++++ resource/template/vm/vue/edit-vue.template | 527 +++++++ resource/template/vm/vue/list-vue.template | 669 +++++++++ resource/template/vm/vue/tree-vue.template | 673 +++++++++ task/bind_function.go | 43 + task/demo.go | 42 + test/path_test.go | 51 + utility/.gitkeep | 0 273 files changed, 21141 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.MD create mode 100644 api/v1/common/captcha.go create mode 100644 api/v1/common/req.go create mode 100644 api/v1/common/res.go create mode 100644 api/v1/system/big_upload.go create mode 100644 api/v1/system/personal.go create mode 100644 api/v1/system/sys_auth_rule.go create mode 100644 api/v1/system/sys_big_file.go create mode 100644 api/v1/system/sys_config.go create mode 100644 api/v1/system/sys_dept.go create mode 100644 api/v1/system/sys_dict_data.go create mode 100644 api/v1/system/sys_dict_type.go create mode 100644 api/v1/system/sys_init.go create mode 100644 api/v1/system/sys_job.go create mode 100644 api/v1/system/sys_login.go create mode 100644 api/v1/system/sys_login_log.go create mode 100644 api/v1/system/sys_monitor.go create mode 100644 api/v1/system/sys_oper_log.go create mode 100644 api/v1/system/sys_post.go create mode 100644 api/v1/system/sys_role.go create mode 100644 api/v1/system/sys_user.go create mode 100644 api/v1/system/sys_user_online.go create mode 100644 api/v1/system/tools_gen_table.go create mode 100644 api/v1/system/ueditor.go create mode 100644 api/v1/system/upload.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 hack/config.yaml create mode 100644 internal/app/boot/boot.go create mode 100644 internal/app/common/consts/cache.go create mode 100644 internal/app/common/consts/consts.go create mode 100644 internal/app/common/consts/upload.go create mode 100644 internal/app/common/controller/base.go create mode 100644 internal/app/common/controller/captcha.go create mode 100644 internal/app/common/dao/casbin_rule.go create mode 100644 internal/app/common/dao/internal/casbin_rule.go create mode 100644 internal/app/common/dao/internal/sys_config.go create mode 100644 internal/app/common/dao/internal/sys_dict_data.go create mode 100644 internal/app/common/dao/internal/sys_dict_type.go create mode 100644 internal/app/common/dao/sys_config.go create mode 100644 internal/app/common/dao/sys_dict_data.go create mode 100644 internal/app/common/dao/sys_dict_type.go create mode 100644 internal/app/common/logic/bigUpload/big_upload.go create mode 100644 internal/app/common/logic/cache/cache.go create mode 100644 internal/app/common/logic/captcha/captcha.go create mode 100644 internal/app/common/logic/logic.go create mode 100644 internal/app/common/logic/middleware/middleware.go create mode 100644 internal/app/common/logic/sysConfig/sys_config.go create mode 100644 internal/app/common/logic/sysDictData/sys_dict_data.go create mode 100644 internal/app/common/logic/sysDictType/sys_dict_type.go create mode 100644 internal/app/common/logic/upload/upload.go create mode 100644 internal/app/common/model/do/casbin_rule.go create mode 100644 internal/app/common/model/do/sys_config.go create mode 100644 internal/app/common/model/do/sys_dict_data.go create mode 100644 internal/app/common/model/do/sys_dict_type.go create mode 100644 internal/app/common/model/entity/casbin_rule.go create mode 100644 internal/app/common/model/entity/sys_config.go create mode 100644 internal/app/common/model/entity/sys_dict_data.go create mode 100644 internal/app/common/model/entity/sys_dict_type.go create mode 100644 internal/app/common/model/sys_config.go create mode 100644 internal/app/common/model/sys_dict_data.go create mode 100644 internal/app/common/model/sys_dict_type.go create mode 100644 internal/app/common/model/token.go create mode 100644 internal/app/common/model/upload.go create mode 100644 internal/app/common/router/router.go create mode 100644 internal/app/common/service/big_upload.go create mode 100644 internal/app/common/service/cache.go create mode 100644 internal/app/common/service/captcha.go create mode 100644 internal/app/common/service/casbin.go create mode 100644 internal/app/common/service/middleware.go create mode 100644 internal/app/common/service/sys_config.go create mode 100644 internal/app/common/service/sys_dict_data.go create mode 100644 internal/app/common/service/sys_dict_type.go create mode 100644 internal/app/common/service/upload.go create mode 100644 internal/app/system/consts/cache.go create mode 100644 internal/app/system/consts/consts.go create mode 100644 internal/app/system/consts/context.go create mode 100644 internal/app/system/controller/base.go create mode 100644 internal/app/system/controller/big_file.go create mode 100644 internal/app/system/controller/big_upload.go create mode 100644 internal/app/system/controller/personal.go create mode 100644 internal/app/system/controller/sys_auth_rule.go create mode 100644 internal/app/system/controller/sys_config.go create mode 100644 internal/app/system/controller/sys_dept.go create mode 100644 internal/app/system/controller/sys_dict_data.go create mode 100644 internal/app/system/controller/sys_dict_type.go create mode 100644 internal/app/system/controller/sys_job.go create mode 100644 internal/app/system/controller/sys_login.go create mode 100644 internal/app/system/controller/sys_login_log.go create mode 100644 internal/app/system/controller/sys_monitor.go create mode 100644 internal/app/system/controller/sys_oper_log.go create mode 100644 internal/app/system/controller/sys_post.go create mode 100644 internal/app/system/controller/sys_role.go create mode 100644 internal/app/system/controller/sys_user.go create mode 100644 internal/app/system/controller/sys_user_online.go create mode 100644 internal/app/system/controller/tools_gen_table.go create mode 100644 internal/app/system/controller/ueditor.go create mode 100644 internal/app/system/controller/upload.go create mode 100644 internal/app/system/dao/big_file.go create mode 100644 internal/app/system/dao/internal/big_file.go create mode 100644 internal/app/system/dao/internal/sys_auth_rule.go create mode 100644 internal/app/system/dao/internal/sys_dept.go create mode 100644 internal/app/system/dao/internal/sys_job.go create mode 100644 internal/app/system/dao/internal/sys_job_log.go create mode 100644 internal/app/system/dao/internal/sys_login_log.go create mode 100644 internal/app/system/dao/internal/sys_oper_log.go create mode 100644 internal/app/system/dao/internal/sys_post.go create mode 100644 internal/app/system/dao/internal/sys_role.go create mode 100644 internal/app/system/dao/internal/sys_role_dept.go create mode 100644 internal/app/system/dao/internal/sys_user.go create mode 100644 internal/app/system/dao/internal/sys_user_online.go create mode 100644 internal/app/system/dao/internal/sys_user_post.go create mode 100644 internal/app/system/dao/internal/tools_gen_table.go create mode 100644 internal/app/system/dao/internal/tools_gen_table_column.go create mode 100644 internal/app/system/dao/sys_auth_rule.go create mode 100644 internal/app/system/dao/sys_dept.go create mode 100644 internal/app/system/dao/sys_job.go create mode 100644 internal/app/system/dao/sys_job_log.go create mode 100644 internal/app/system/dao/sys_login_log.go create mode 100644 internal/app/system/dao/sys_oper_log.go create mode 100644 internal/app/system/dao/sys_post.go create mode 100644 internal/app/system/dao/sys_role.go create mode 100644 internal/app/system/dao/sys_role_dept.go create mode 100644 internal/app/system/dao/sys_user.go create mode 100644 internal/app/system/dao/sys_user_online.go create mode 100644 internal/app/system/dao/sys_user_post.go create mode 100644 internal/app/system/dao/tools_gen_table.go create mode 100644 internal/app/system/dao/tools_gen_table_column.go create mode 100644 internal/app/system/logic/context/context.go create mode 100644 internal/app/system/logic/logic.go create mode 100644 internal/app/system/logic/middleware/middleware.go create mode 100644 internal/app/system/logic/personal/personal.go create mode 100644 internal/app/system/logic/sysAuthRule/sys_auth_rule.go create mode 100644 internal/app/system/logic/sysDept/sys_dept.go create mode 100644 internal/app/system/logic/sysJob/sys_job.go create mode 100644 internal/app/system/logic/sysJobLog/sys_job_log.go create mode 100644 internal/app/system/logic/sysLoginLog/sys_login_log.go create mode 100644 internal/app/system/logic/sysOperLog/sys_oper_log.go create mode 100644 internal/app/system/logic/sysPost/sys_post.go create mode 100644 internal/app/system/logic/sysRole/sys_role.go create mode 100644 internal/app/system/logic/sysUser/sys_user.go create mode 100644 internal/app/system/logic/sysUserOnline/sys_user_online.go create mode 100644 internal/app/system/logic/timeTask/time_task.go create mode 100644 internal/app/system/logic/token/token.go create mode 100644 internal/app/system/logic/toolsGenTable/tools_gen_table.go create mode 100644 internal/app/system/logic/toolsGenTableColumn/tools_gen_table_column.go create mode 100644 internal/app/system/model/.gitkeep create mode 100644 internal/app/system/model/context.go create mode 100644 internal/app/system/model/do/big_file.go create mode 100644 internal/app/system/model/do/sys_auth_rule.go create mode 100644 internal/app/system/model/do/sys_dept.go create mode 100644 internal/app/system/model/do/sys_job.go create mode 100644 internal/app/system/model/do/sys_job_log.go create mode 100644 internal/app/system/model/do/sys_login_log.go create mode 100644 internal/app/system/model/do/sys_oper_log.go create mode 100644 internal/app/system/model/do/sys_post.go create mode 100644 internal/app/system/model/do/sys_role.go create mode 100644 internal/app/system/model/do/sys_role_dept.go create mode 100644 internal/app/system/model/do/sys_user.go create mode 100644 internal/app/system/model/do/sys_user_online.go create mode 100644 internal/app/system/model/do/sys_user_post.go create mode 100644 internal/app/system/model/do/tools_gen_table.go create mode 100644 internal/app/system/model/do/tools_gen_table_column.go create mode 100644 internal/app/system/model/entity/.gitkeep create mode 100644 internal/app/system/model/entity/big_file.go create mode 100644 internal/app/system/model/entity/sys_auth_rule.go create mode 100644 internal/app/system/model/entity/sys_dept.go create mode 100644 internal/app/system/model/entity/sys_job.go create mode 100644 internal/app/system/model/entity/sys_job_log.go create mode 100644 internal/app/system/model/entity/sys_login_log.go create mode 100644 internal/app/system/model/entity/sys_oper_log.go create mode 100644 internal/app/system/model/entity/sys_post.go create mode 100644 internal/app/system/model/entity/sys_role.go create mode 100644 internal/app/system/model/entity/sys_role_dept.go create mode 100644 internal/app/system/model/entity/sys_user.go create mode 100644 internal/app/system/model/entity/sys_user_online.go create mode 100644 internal/app/system/model/entity/sys_user_post.go create mode 100644 internal/app/system/model/entity/tools_gen_table.go create mode 100644 internal/app/system/model/entity/tools_gen_table_column.go create mode 100644 internal/app/system/model/sys_auth_rule.go create mode 100644 internal/app/system/model/sys_dept.go create mode 100644 internal/app/system/model/sys_init.go create mode 100644 internal/app/system/model/sys_job.go create mode 100644 internal/app/system/model/sys_oper_log.go create mode 100644 internal/app/system/model/sys_role.go create mode 100644 internal/app/system/model/sys_user.go create mode 100644 internal/app/system/model/sys_user_login.go create mode 100644 internal/app/system/model/sys_user_online.go create mode 100644 internal/app/system/model/task.go create mode 100644 internal/app/system/model/tools_gen_table.go create mode 100644 internal/app/system/model/tools_gen_table_column.go create mode 100644 internal/app/system/packed/packed.go create mode 100644 internal/app/system/router/router.go create mode 100644 internal/app/system/router/sys_job.go create mode 100644 internal/app/system/service/.gitkeep create mode 100644 internal/app/system/service/big_file.go create mode 100644 internal/app/system/service/context.go create mode 100644 internal/app/system/service/middleware.go create mode 100644 internal/app/system/service/personal.go create mode 100644 internal/app/system/service/sys_auth_rule.go create mode 100644 internal/app/system/service/sys_dept.go create mode 100644 internal/app/system/service/sys_job.go create mode 100644 internal/app/system/service/sys_job_log.go create mode 100644 internal/app/system/service/sys_login_log.go create mode 100644 internal/app/system/service/sys_oper_log.go create mode 100644 internal/app/system/service/sys_post.go create mode 100644 internal/app/system/service/sys_role.go create mode 100644 internal/app/system/service/sys_user.go create mode 100644 internal/app/system/service/sys_user_online.go create mode 100644 internal/app/system/service/time_task.go create mode 100644 internal/app/system/service/token.go create mode 100644 internal/app/system/service/tools_gen_table.go create mode 100644 internal/app/system/service/tools_gen_table_column.go create mode 100644 internal/cmd/cmd.go create mode 100644 internal/consts/consts_openapi.go create mode 100644 internal/consts/version.go create mode 100644 internal/router/router.go create mode 100644 library/libResponse/response.go create mode 100644 library/libRouter/router.go create mode 100644 library/libUtils/slice_tree.go create mode 100644 library/libUtils/utils.go create mode 100644 library/liberr/err.go create mode 100644 library/upload/init.go create mode 100644 library/upload/local.go create mode 100644 library/upload/qiniou.go create mode 100644 library/upload/tencent.go create mode 100644 library/upload_chunk/consts.go create mode 100644 library/upload_chunk/helper.go create mode 100644 library/upload_chunk/option.go create mode 100644 library/upload_chunk/upload_chunk.go create mode 100644 main.go create mode 100644 manifest/config/config.yaml.bak create mode 100644 manifest/deploy/kustomize/base/deployment.yaml create mode 100644 manifest/deploy/kustomize/base/kustomization.yaml create mode 100644 manifest/deploy/kustomize/base/service.yaml create mode 100644 manifest/deploy/kustomize/overlays/develop/configmap.yaml create mode 100644 manifest/deploy/kustomize/overlays/develop/deployment.yaml create mode 100644 manifest/deploy/kustomize/overlays/develop/kustomization.yaml create mode 100644 manifest/docker/Dockerfile create mode 100644 manifest/docker/docker.sh create mode 100644 resource/casbin/rbac_model.conf create mode 100644 resource/casbin/rbac_policy.csv create mode 100644 resource/data/.gitkeep create mode 100644 resource/data/gfast-v32.sql create mode 100644 resource/i18n/.gitkeep create mode 100644 resource/public/html/.gitkeep create mode 100644 resource/public/plugin/.gitkeep create mode 100644 resource/scripts/.gitkeep create mode 100644 resource/template/.gitkeep create mode 100644 resource/template/vm/go/api.template create mode 100644 resource/template/vm/go/controller.template create mode 100644 resource/template/vm/go/dao.template create mode 100644 resource/template/vm/go/dao_internal.template create mode 100644 resource/template/vm/go/logic.template create mode 100644 resource/template/vm/go/model.template create mode 100644 resource/template/vm/go/model_do.template create mode 100644 resource/template/vm/go/model_entity.template create mode 100644 resource/template/vm/go/router.template create mode 100644 resource/template/vm/go/router_func.template create mode 100644 resource/template/vm/go/service.template create mode 100644 resource/template/vm/sql/sql.template create mode 100644 resource/template/vm/ts/api.template create mode 100644 resource/template/vm/ts/model.template create mode 100644 resource/template/vm/vue/detail-vue.template create mode 100644 resource/template/vm/vue/edit-vue.template create mode 100644 resource/template/vm/vue/list-vue.template create mode 100644 resource/template/vm/vue/tree-vue.template create mode 100644 task/bind_function.go create mode 100644 task/demo.go create mode 100644 test/path_test.go create mode 100644 utility/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..deab41c --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +.buildpath +.hgignore.swp +.project +.orig +.swp +.idea/ +.settings/ +.vscode/ +vendor/ +composer.lock +gitpush.sh +pkg/ +bin/ +cbuild +**/.DS_Store +.vscode/ +.test/ +main +output/ +manifest/output/ +*.exe +tmp/ +resource/data/gen_sql +resource/log/ +resource/public/big_file +resource/public/upload_file +manifest/config/config.yaml +GFastV3 +/manifest/config/db.yaml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..8f0a83f --- /dev/null +++ b/README.MD @@ -0,0 +1,170 @@ +# GFast-V3 +
+ +

+

GFast V3.0

+

+

+ + goframe + + + vue + + + element plus + + + typescript + + + vite + + + license + +

+
+ + + +## 平台简介 +* 基于全新Go Frame 2.0+Vue3+Element Plus开发的全栈前后端分离的管理系统 +* 前端采用vue-next-admin 、Vue、Element UI。 +* 本项目由奇讯科技团队开发。 +* 如您想购买云服务器请先领取阿里云优惠券:[点我进入](https://www.aliyun.com/minisite/goods?userCode=fcor2omk ),腾讯云优惠券:[点我领取](https://cloud.tencent.com/act/cps/redirect?redirect=1062&cps_key=20b1c3842f74986b2894e2c5fcde7ea2&from=console ) + +## 特征 +* 高生产率:几分钟即可搭建一个后台管理系统 +* 模块化:单应用多系统的模式,将一个完整的应用拆分为多个系统,后续扩展更加便捷,增加代码复用性。 +* 插件化: 可通过插件的方式扩展系统功能 +* 认证机制:采用gtoken的用户状态认证及casbin的权限认证 +* 路由模式:得利于goframe2.0提供了规范化的路由注册方式,无需注解自动生成api文档 +* 面向接口开发 + + +## 内置功能 + +1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。 +2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。 +3. 岗位管理:配置系统用户所属担任职务。 +4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。 +5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。 +6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。 +7. 参数管理:对系统动态配置常用参数。 +8. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。 +9. 登录日志:系统登录日志记录查询包含登录异常。 +10. 在线用户:当前系统中活跃用户状态监控。 +11. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。 +12. 代码生成:前后端代码的生成。 +13. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。 +14. 在线构建器:拖动表单元素生成相应的HTML代码。 +15. 文件上传,缓存标签等。 + +> 项目使用模块化与插件化的方式开发,目前正在升级的插件有:cms系统、万能模型、微信管理、工单系统、问答系统、工作流引擎...,同时也欢迎大家把写好的插件上传到商城,我们来帮您实现技术变现,获取收益! + +> GFast开源以来得到了大家的很多支持,如果您愿意为GFast贡献代码或提供建议,请加微信:qixun007(备注:gfast) + +## 演示地址 +[http://v3.g-fast.cn/sys](http://v3.g-fast.cn/sys) +账号:demo 密码:123456 +## 配置 +项目数据库文件 `resource/data/db.sql` 创建数据库导入后修改配置 `manifest/config/config.yaml.bak` 复制改为`manifest/config/config.yaml` + +其中gfToken配置 +```yaml +gfToken: + cacheKey: "gfToken_" #缓存前缀 + timeOut: 10800 #token超时时间(秒) + maxRefresh: 5400 #token自动刷新时间(秒) + multiLogin: true #是否允许一个账号多人同时登录 + encryptKey: "49c54195e750b04e74a8429b17896586" #加密key (32位) + cacheModel: "redis" #存储引擎 (memory使用内存|redis使用redis) + excludePaths: #排除不做登录验证的路由地址 + - "/api/v1/system/login" +``` + +项目为前后端分离,前端地址: + +github地址:[https://github.com/tiger1103/gfast-ui](https://github.com/tiger1103/gfast-ui) + +gitee地址:[https://gitee.com/tiger1103/gfast-ui](https://gitee.com/tiger1103/gfast-ui) + +## 文档地址 +> 文档正在书写中,请耐心等一等。 + +## 相关视频 +[https://space.bilibili.com/254192571/channel/seriesdetail?sid=223204](https://space.bilibili.com/254192571/channel/seriesdetail?sid=223204) + +## 演示图 + + + + + + + + + + + + + + + + + + +
+ +## 感谢(排名不分先后) +> gf框架 [https://github.com/gogf/gf](https://github.com/gogf/gf) +> +> vue-next-admin [https://gitee.com/lyt-top/vue-next-admin](https://gitee.com/lyt-top/vue-next-admin) +> +> swaggo [https://github.com/swaggo/swag](https://github.com/swaggo/swag) +> +>gtoken [https://github.com/goflyfox/gtoken](https://github.com/goflyfox/gtoken) +> +>casbin [https://github.com/casbin/casbin](https://github.com/casbin/casbin) + + +PHP开源工作流引擎tpflow [https://gitee.com/ntdgg/tpflow](https://gitee.com/ntdgg/tpflow) + +CCflow 国内最优秀的开源流程引擎 [https://gitee.com/opencc/ccflow](https://gitee.com/opencc/ccflow) + +## 交流QQ群 + +> + +> 感谢你使用GFast,公司团队精力时间有限,因此我们不再提供免费的技术服务,目前Gfast QQ交流群有部分用户进行了捐赠,捐赠后请联系作者进vip用户群,vip群中问题将得到优先解答,同时也会根据您的需求进行分析和优先安排,vip群也会提供Gfast的其它福利。 +> 同时您也可以联系我们,雇佣我们团队为您干活,谢谢合作! +>快来加入群聊【Gfast框架交流群】(1群:865697297-已满,2群:444129379),发现精彩内容,记得备注加群来意。 + +## 免责声明: +> 1、Gfast仅限自己学习使用,一切商业行为与Gfast无关。 + +> 2、用户不得利用Gfast从事非法行为,用户应当合法合规的使用,发现用户在使用产品时有任何的非法行为,Gfast有权配合有关机关进行调查或向政府部门举报,Gfast不承担用户因非法行为造成的任何法律责任,一切法律责任由用户自行承担,如因用户使用造成第三方损害的,用户应当依法予以赔偿。 + +> 3、所有与使用Gfast相关的资源直接风险均由用户承担。 + + +## 商用说明 +> 商用注意事项 +如果您将此项目用于商业用途,请遵守Apache2.0协议并保留作者技术支持声明。 + +* GFast快速开发平台采用Apache-2.0技术协议 +* 二次开发如用于商业性质或开源竞品请不要删除和修改GFast源码头部的版权与作者声明及出处 +* 允许进行商用,但是不允许二次开源出来并进行收费 +* 我们已经申请了相关的软件著作权和相关登记(证书号:软著登字第7511736号) +* 如果您在自己的项目中使用了我们项目中的扩展或模块,请在项目介绍中进行明确说明 + +## 支持开源 +如果您喜爱gfast,请给常熬夜的作者来杯咖啡吧! 点我送咖啡 + +## 生成service示例 +```shell +gf2 gen service -s internal/app/system/logic -d internal/app/system/service +``` +## [感谢JetBrains提供的免费GoLand](https://jb.gg/OpenSource) +[![avatar](https://camo.githubusercontent.com/323657c6e81419b8e151e9da4c71f409e3fcc65d630535170c59fe4807dbc905/68747470733a2f2f676f6672616d652e6f72672f646f776e6c6f61642f7468756d626e61696c732f313131343131392f6a6574627261696e732e706e67)](https://jb.gg/OpenSource) diff --git a/api/v1/common/captcha.go b/api/v1/common/captcha.go new file mode 100644 index 0000000..aca0c14 --- /dev/null +++ b/api/v1/common/captcha.go @@ -0,0 +1,19 @@ +/* +* @desc:验证码参数 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/2 17:47 + */ + +package common + +import "github.com/gogf/gf/v2/frame/g" + +type CaptchaReq struct { + g.Meta `path:"/get" tags:"验证码" method:"get" summary:"获取验证码"` +} +type CaptchaRes struct { + g.Meta `mime:"application/json"` + Key string `json:"key"` + Img string `json:"img"` +} diff --git a/api/v1/common/req.go b/api/v1/common/req.go new file mode 100644 index 0000000..08879ab --- /dev/null +++ b/api/v1/common/req.go @@ -0,0 +1,20 @@ +/* +* @desc:公共接口相关 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/30 9:28 + */ + +package common + +// PageReq 公共请求参数 +type PageReq struct { + DateRange []string `p:"dateRange"` //日期范围 + PageNum int `p:"pageNum"` //当前页码 + PageSize int `p:"pageSize"` //每页数 + OrderBy string //排序方式 +} + +type Author struct { + Authorization string `p:"Authorization" in:"header" dc:"Bearer {{token}}"` +} diff --git a/api/v1/common/res.go b/api/v1/common/res.go new file mode 100644 index 0000000..ef9a877 --- /dev/null +++ b/api/v1/common/res.go @@ -0,0 +1,21 @@ +/* +* @desc:返回响应公共参数 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/10/27 16:30 + */ + +package common + +import "github.com/gogf/gf/v2/frame/g" + +// EmptyRes 不响应任何数据 +type EmptyRes struct { + g.Meta `mime:"application/json"` +} + +// ListRes 列表公共返回 +type ListRes struct { + CurrentPage int `json:"currentPage"` + Total interface{} `json:"total"` +} diff --git a/api/v1/system/big_upload.go b/api/v1/system/big_upload.go new file mode 100644 index 0000000..6a789ec --- /dev/null +++ b/api/v1/system/big_upload.go @@ -0,0 +1,38 @@ +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/library/upload_chunk" +) + +// 上传文件 +type BigUploadReq struct { + g.Meta `path:"/bigUpload/upload" tags:"后台大文件上传" method:"post" summary:"上传文件"` + upload_chunk.UploadReq +} + +type BigUploadRes struct { + upload_chunk.UpLoadRes +} + +// 上传文件检查 +type BigUploadCheckReq struct { + g.Meta `path:"/bigUpload/upload" tags:"后台大文件上传" method:"get" summary:"上传文件检查"` + upload_chunk.UploadReq +} + +type BigUploadCheckRes struct { + upload_chunk.CheckRes + Identifier string `json:"identifier"` // 标识 + TotalChunks int `json:"totalChunks"` // 分片总数 +} + +// 上传文件合并 +type BigUploadMergeReq struct { + g.Meta `path:"/bigUpload/uploadMerge" tags:"后台大文件上传" method:"post" summary:"上传文件合并"` + upload_chunk.UploadReq +} + +type BigUploadMergeRes struct { + upload_chunk.MergeRes +} diff --git a/api/v1/system/personal.go b/api/v1/system/personal.go new file mode 100644 index 0000000..1f74678 --- /dev/null +++ b/api/v1/system/personal.go @@ -0,0 +1,57 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/11/3 10:04 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type PersonalInfoReq struct { + g.Meta `path:"/personal/getPersonalInfo" tags:"用户管理" method:"get" summary:"登录用户信息"` + commonApi.Author +} + +type PersonalInfoRes struct { + g.Meta `mime:"application/json"` + User *entity.SysUser `json:"user"` + Roles []string `json:"roles"` + DeptName string `json:"deptName"` +} + +// SetPersonalReq 添加修改用户公用请求字段 +type SetPersonalReq struct { + Nickname string `p:"nickname" v:"required#用户昵称不能为空"` + Mobile string `p:"mobile" v:"required|phone#手机号不能为空|手机号格式错误"` + Remark string `p:"remark"` + Sex int `p:"sex"` + UserEmail string `p:"userEmail" v:"required|email#邮箱不能为空|邮箱格式错误"` + Describe string `p:"describe"` //签名 + Avatar string `p:"avatar"` //签名 + +} + +// PersonalEditReq 修改个人 +type PersonalEditReq struct { + g.Meta `path:"/personal/edit" tags:"用户管理" method:"put" summary:"修改个人资料"` + *SetPersonalReq + commonApi.Author +} + +type PersonalEditRes struct { +} + +type PersonalResetPwdReq struct { + g.Meta `path:"/personal/resetPwd" tags:"用户管理" method:"put" summary:"重置个人密码"` + Password string `p:"password" v:"required|password#密码不能为空|密码以字母开头,只能包含字母、数字和下划线,长度在6~18之间"` + commonApi.Author +} + +type PersonalResetPwdRes struct { +} diff --git a/api/v1/system/sys_auth_rule.go b/api/v1/system/sys_auth_rule.go new file mode 100644 index 0000000..23f8ca4 --- /dev/null +++ b/api/v1/system/sys_auth_rule.go @@ -0,0 +1,112 @@ +/* +* @desc:菜单api +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 10:27 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type RuleSearchReq struct { + g.Meta `path:"/menu/list" tags:"菜单管理" method:"get" summary:"菜单列表"` + commonApi.Author + Title string `p:"menuName" ` + Component string `p:"component"` +} + +type RuleListRes struct { + g.Meta `mime:"application/json"` + Rules []*model.SysAuthRuleTreeRes `json:"rules"` +} + +type RuleAddReq struct { + g.Meta `path:"/menu/add" tags:"菜单管理" method:"post" summary:"添加菜单"` + commonApi.Author + MenuType uint `p:"menuType" v:"min:0|max:2#菜单类型最小值为:min|菜单类型最大值为:max"` + Pid uint `p:"parentId" v:"min:0"` + Name string `p:"name" v:"required#请填写规则名称"` + Title string `p:"menuName" v:"required|length:1,100#请填写标题|标题长度在:min到:max位"` + Icon string `p:"icon"` + Weigh int `p:"menuSort" ` + Condition string `p:"condition" ` + Remark string `p:"remark" ` + IsHide uint `p:"isHide"` + Path string `p:"path"` + Redirect string `p:"redirect"` // 路由重定向 + Roles []uint `p:"roles"` // 角色ids + Component string `p:"component" v:"required-if:menuType,1#组件路径不能为空"` + IsLink uint `p:"isLink"` + IsIframe uint `p:"isIframe"` + IsCached uint `p:"isKeepAlive"` + IsAffix uint `p:"isAffix"` + LinkUrl string `p:"linkUrl"` +} + +type RuleAddRes struct { +} + +type RuleGetParamsReq struct { + g.Meta `path:"/menu/getParams" tags:"菜单管理" method:"get" summary:"获取添加、编辑菜单相关参数"` + commonApi.Author +} + +type RuleGetParamsRes struct { + g.Meta `mime:"application/json"` + Roles []*entity.SysRole `json:"roles"` + Menus []*model.SysAuthRuleInfoRes `json:"menus"` +} + +type RuleInfoReq struct { + g.Meta `path:"/menu/get" tags:"菜单管理" method:"get" summary:"获取菜单信息"` + commonApi.Author + Id uint `p:"required#菜单id必须"` +} + +type RuleInfoRes struct { + g.Meta `mime:"application/json"` + Rule *entity.SysAuthRule `json:"rule"` + RoleIds []uint `json:"roleIds"` +} + +type RuleUpdateReq struct { + g.Meta `path:"/menu/update" tags:"菜单管理" method:"put" summary:"修改菜单"` + commonApi.Author + Id uint `p:"id" v:"required#id必须"` + MenuType uint `p:"menuType" v:"min:0|max:2#菜单类型最小值为:min|菜单类型最大值为:max"` + Pid uint `p:"parentId" v:"min:0"` + Name string `p:"name" v:"required#请填写规则名称"` + Title string `p:"menuName" v:"required|length:1,100#请填写标题|标题长度在:min到:max位"` + Icon string `p:"icon"` + Weigh int `p:"menuSort" ` + Condition string `p:"condition" ` + Remark string `p:"remark" ` + IsHide uint `p:"isHide"` + Path string `p:"path"` + Redirect string `p:"redirect"` // 路由重定向 + Roles []uint `p:"roles"` // 角色ids + Component string `p:"component" v:"required-if:menuType,1#组件路径不能为空"` + IsLink uint `p:"isLink"` + IsIframe uint `p:"isIframe"` + IsCached uint `p:"isKeepAlive"` + IsAffix uint `p:"isAffix"` + LinkUrl string `p:"linkUrl"` +} + +type RuleUpdateRes struct { +} + +type RuleDeleteReq struct { + g.Meta `path:"/menu/delete" tags:"菜单管理" method:"delete" summary:"删除菜单"` + commonApi.Author + Ids []int `p:"ids" v:"required#菜单id必须"` +} + +type RuleDeleteRes struct { +} diff --git a/api/v1/system/sys_big_file.go b/api/v1/system/sys_big_file.go new file mode 100644 index 0000000..175f9ad --- /dev/null +++ b/api/v1/system/sys_big_file.go @@ -0,0 +1,66 @@ +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type BigFileSearchReq struct { + g.Meta `path:"/bigFile/list" tags:"大文件管理" method:"get" summary:"大文件管理"` + Name string `p:"name"` //文件名称 + commonApi.PageReq +} + +type BigFileSearchRes struct { + g.Meta `mime:"application/json"` + List []*entity.BigFile `json:"list"` + commonApi.ListRes +} + +type BigFileForm struct { + Name string `p:"name" v:"required#文件名称必须"` + Size int `p:"size" v:"required#文件大小必须"` + Path string `p:"path" v:"required#文件路径必须"` + FullPath string `p:"fullPath"` + MimeType string `p:"mimeType"` + Source int `p:"source"` + Describe string `p:"describe"` + Md5 string `p:"md5"` +} + +type BigFileGetReq struct { + g.Meta `path:"/bigFile/get" tags:"大文件管理" method:"get" summary:"获取大文件信息"` + Id uint64 `p:"id"` +} + +type BigFileGetRes struct { + g.Meta `mime:"application/json"` + entity.BigFile +} + +type BigFileAddReq struct { + g.Meta `path:"/bigFile/add" tags:"大文件管理" method:"post" summary:"大文件新增"` + BigFileForm +} + +type BigFileAddRes struct { +} + +type BigFileEditReq struct { + g.Meta `path:"/bigFile/edit" tags:"大文件管理" method:"put" summary:"大文件新增"` + Id uint64 `p:"id" v:"required|min:1#主键ID不能为空|主键ID参数错误"` + Name string `p:"name" v:"required#标题必须"` + Describe string `p:"describe"` +} + +type BigFileEditRes struct { +} + +type BigFileDeleteReq struct { + g.Meta `path:"/bigFile/delete" tags:"大文件管理" method:"delete" summary:"大文件删除"` + Ids []uint64 `p:"ids"` +} + +type BigFileDeleteRes struct { +} diff --git a/api/v1/system/sys_config.go b/api/v1/system/sys_config.go new file mode 100644 index 0000000..ee9c98e --- /dev/null +++ b/api/v1/system/sys_config.go @@ -0,0 +1,71 @@ +/* +* @desc:系统参数配置 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/18 21:11 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + commonEntity "github.com/tiger1103/gfast/v3/internal/app/common/model/entity" +) + +type ConfigSearchReq struct { + g.Meta `path:"/config/list" tags:"系统参数管理" method:"get" summary:"系统参数列表"` + ConfigName string `p:"configName"` //参数名称 + ConfigKey string `p:"configKey"` //参数键名 + ConfigType string `p:"configType"` //状态 + commonApi.PageReq +} + +type ConfigSearchRes struct { + g.Meta `mime:"application/json"` + List []*commonEntity.SysConfig `json:"list"` + commonApi.ListRes +} + +type ConfigReq struct { + ConfigName string `p:"configName" v:"required#参数名称不能为空"` + ConfigKey string `p:"configKey" v:"required#参数键名不能为空"` + ConfigValue string `p:"configValue" v:"required#参数键值不能为空"` + ConfigType int `p:"configType" v:"required|in:0,1#系统内置不能为空|系统内置类型只能为0或1"` + Remark string `p:"remark"` +} + +type ConfigAddReq struct { + g.Meta `path:"/config/add" tags:"系统参数管理" method:"post" summary:"添加系统参数"` + *ConfigReq +} + +type ConfigAddRes struct { +} + +type ConfigGetReq struct { + g.Meta `path:"/config/get" tags:"系统参数管理" method:"get" summary:"获取系统参数"` + Id int `p:"id"` +} + +type ConfigGetRes struct { + g.Meta `mime:"application/json"` + Data *commonEntity.SysConfig `json:"data"` +} + +type ConfigEditReq struct { + g.Meta `path:"/config/edit" tags:"系统参数管理" method:"put" summary:"修改系统参数"` + ConfigId int64 `p:"configId" v:"required|min:1#主键ID不能为空|主键ID参数错误"` + *ConfigReq +} + +type ConfigEditRes struct { +} + +type ConfigDeleteReq struct { + g.Meta `path:"/config/delete" tags:"系统参数管理" method:"delete" summary:"删除系统参数"` + Ids []int `p:"ids"` +} + +type ConfigDeleteRes struct { +} diff --git a/api/v1/system/sys_dept.go b/api/v1/system/sys_dept.go new file mode 100644 index 0000000..162cff4 --- /dev/null +++ b/api/v1/system/sys_dept.go @@ -0,0 +1,71 @@ +/* +* @desc:部门管理参数 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/6 15:07 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type DeptSearchReq struct { + g.Meta `path:"/dept/list" tags:"部门管理" method:"get" summary:"部门列表"` + DeptName string `p:"deptName"` + Status string `p:"status"` +} + +type DeptSearchRes struct { + g.Meta `mime:"application/json"` + DeptList []*entity.SysDept `json:"deptList"` +} + +type DeptAddReq struct { + g.Meta `path:"/dept/add" tags:"部门管理" method:"post" summary:"添加部门"` + ParentID int `p:"parentId" v:"required#父级不能为空"` + DeptName string `p:"deptName" v:"required#部门名称不能为空"` + OrderNum int `p:"orderNum" v:"required#排序不能为空"` + Leader string `p:"leader"` + Phone string `p:"phone"` + Email string `p:"email" v:"email#邮箱格式不正确"` + Status uint `p:"status" v:"required#状态必须"` +} + +type DeptAddRes struct { +} + +type DeptEditReq struct { + g.Meta `path:"/dept/edit" tags:"部门管理" method:"put" summary:"修改部门"` + DeptId int `p:"deptId" v:"required#deptId不能为空"` + ParentID int `p:"parentId" v:"required#父级不能为空"` + DeptName string `p:"deptName" v:"required#部门名称不能为空"` + OrderNum int `p:"orderNum" v:"required#排序不能为空"` + Leader string `p:"leader"` + Phone string `p:"phone"` + Email string `p:"email" v:"email#邮箱格式不正确"` + Status uint `p:"status" v:"required#状态必须"` +} + +type DeptEditRes struct { +} + +type DeptDeleteReq struct { + g.Meta `path:"/dept/delete" tags:"部门管理" method:"delete" summary:"删除部门"` + Id uint64 `p:"id" v:"required#id不能为空"` +} + +type DeptDeleteRes struct { +} + +type DeptTreeSelectReq struct { + g.Meta `path:"/dept/treeSelect" tags:"部门管理" method:"get" summary:"获取部门树形菜单"` +} + +type DeptTreeSelectRes struct { + g.Meta `mime:"application/json"` + Deps []*model.SysDeptTreeRes `json:"deps"` +} diff --git a/api/v1/system/sys_dict_data.go b/api/v1/system/sys_dict_data.go new file mode 100644 index 0000000..3d86502 --- /dev/null +++ b/api/v1/system/sys_dict_data.go @@ -0,0 +1,93 @@ +/* +* @desc:字典数据api +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:59 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + commonModel "github.com/tiger1103/gfast/v3/internal/app/common/model" + commonEntity "github.com/tiger1103/gfast/v3/internal/app/common/model/entity" +) + +// GetDictReq 获取字典信息请求参数 +type GetDictReq struct { + g.Meta `path:"/dict/data/getDictData" tags:"字典管理" method:"get" summary:"获取字典数据公共方法"` + commonApi.Author + DictType string `p:"dictType" v:"required#字典类型不能为空"` + DefaultValue string `p:"defaultValue"` +} + +// GetDictRes 完整的一个字典信息 +type GetDictRes struct { + g.Meta `mime:"application/json"` + Info *commonModel.DictTypeRes `json:"info"` + Values []*commonModel.DictDataRes `json:"values"` +} + +// DictDataSearchReq 分页请求参数 +type DictDataSearchReq struct { + g.Meta `path:"/dict/data/list" tags:"字典管理" method:"get" summary:"字典数据列表"` + DictType string `p:"dictType"` //字典类型 + DictLabel string `p:"dictLabel"` //字典标签 + Status string `p:"status"` //状态 + commonApi.PageReq +} + +// DictDataSearchRes 字典数据结果 +type DictDataSearchRes struct { + g.Meta `mime:"application/json"` + List []*commonEntity.SysDictData `json:"list"` + commonApi.ListRes +} + +type DictDataReq struct { + DictLabel string `p:"dictLabel" v:"required#字典标签不能为空"` + DictValue string `p:"dictValue" v:"required#字典键值不能为空"` + DictType string `p:"dictType" v:"required#字典类型不能为空"` + DictSort int `p:"dictSort" v:"integer#排序只能为整数"` + CssClass string `p:"cssClass"` + ListClass string `p:"listClass"` + IsDefault int `p:"isDefault" v:"required|in:0,1#系统默认不能为空|默认值只能为0或1"` + Status int `p:"status" v:"required|in:0,1#状态不能为空|状态只能为0或1"` + Remark string `p:"remark"` +} + +type DictDataAddReq struct { + g.Meta `path:"/dict/data/add" tags:"字典管理" method:"post" summary:"添加字典数据"` + *DictDataReq +} + +type DictDataAddRes struct { +} + +type DictDataGetReq struct { + g.Meta `path:"/dict/data/get" tags:"字典管理" method:"get" summary:"获取字典数据"` + DictCode uint `p:"dictCode"` +} + +type DictDataGetRes struct { + g.Meta `mime:"application/json"` + Dict *commonEntity.SysDictData `json:"dict"` +} + +type DictDataEditReq struct { + g.Meta `path:"/dict/data/edit" tags:"字典管理" method:"put" summary:"修改字典数据"` + DictCode int `p:"dictCode" v:"required|min:1#主键ID不能为空|主键ID不能小于1"` + *DictDataReq +} + +type DictDataEditRes struct { +} + +type DictDataDeleteReq struct { + g.Meta `path:"/dict/data/delete" tags:"字典管理" method:"delete" summary:"删除字典数据"` + Ids []int `p:"ids"` +} + +type DictDataDeleteRes struct { +} diff --git a/api/v1/system/sys_dict_type.go b/api/v1/system/sys_dict_type.go new file mode 100644 index 0000000..98fe4a1 --- /dev/null +++ b/api/v1/system/sys_dict_type.go @@ -0,0 +1,79 @@ +/* +* @desc:字典类型 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/14 21:30 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + commonModel "github.com/tiger1103/gfast/v3/internal/app/common/model" + commonEntity "github.com/tiger1103/gfast/v3/internal/app/common/model/entity" +) + +type DictTypeSearchReq struct { + g.Meta `path:"/dict/type/list" tags:"字典管理" method:"get" summary:"字典类型列表"` + DictName string `p:"dictName"` //字典名称 + DictType string `p:"dictType"` //字典类型 + Status string `p:"status"` //字典状态 + commonApi.PageReq +} + +type DictTypeSearchRes struct { + g.Meta `mime:"application/json"` + DictTypeList []*commonModel.SysDictTypeInfoRes `json:"dictTypeList"` + commonApi.ListRes +} + +type DictTypeAddReq struct { + g.Meta `path:"/dict/type/add" tags:"字典管理" method:"post" summary:"添加字典类型"` + DictName string `p:"dictName" v:"required#字典名称不能为空"` + DictType string `p:"dictType" v:"required#字典类型不能为空"` + Status uint `p:"status" v:"required|in:0,1#状态不能为空|状态只能为0或1"` + Remark string `p:"remark"` +} + +type DictTypeAddRes struct { +} + +type DictTypeGetReq struct { + g.Meta `path:"/dict/type/get" tags:"字典管理" method:"get" summary:"获取字典类型"` + DictId uint `p:"dictId" v:"required#类型id不能为空"` +} + +type DictTypeGetRes struct { + g.Meta `mime:"application/json"` + DictType *commonEntity.SysDictType `json:"dictType"` +} + +type DictTypeEditReq struct { + g.Meta `path:"/dict/type/edit" tags:"字典管理" method:"put" summary:"修改字典类型"` + DictId int64 `p:"dictId" v:"required|min:1#主键ID不能为空|主键ID必须为大于0的值"` + DictName string `p:"dictName" v:"required#字典名称不能为空"` + DictType string `p:"dictType" v:"required#字典类型不能为空"` + Status uint `p:"status" v:"required|in:0,1#状态不能为空|状态只能为0或1"` + Remark string `p:"remark"` +} + +type DictTypeEditRes struct { +} + +type DictTypeDeleteReq struct { + g.Meta `path:"/dict/type/delete" tags:"字典管理" method:"delete" summary:"删除字典类型"` + DictIds []int `p:"dictIds" v:"required#字典类型id不能为空"` +} + +type DictTypeDeleteRes struct { +} + +type DictTypeAllReq struct { + g.Meta `path:"/dict/type/optionSelect" tags:"字典管理" method:"get" summary:"获取字典选择框列表"` +} + +type DictTYpeAllRes struct { + g.Meta `mime:"application/json"` + DictType []*commonEntity.SysDictType `json:"dictType"` +} diff --git a/api/v1/system/sys_init.go b/api/v1/system/sys_init.go new file mode 100644 index 0000000..de13233 --- /dev/null +++ b/api/v1/system/sys_init.go @@ -0,0 +1,66 @@ +package system + +import ( + "fmt" + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/internal/app/system/model" +) + +type DbInitIsInitReq struct { + g.Meta `path:"/dbInit/isInit" tags:"系统初始化" method:"get" summary:"系统初始化"` +} + +type DbInitIsInitRes bool + +type DbInitGetEnvInfoReq struct { + g.Meta `path:"/dbInit/getEnvInfo" tags:"系统初始化" method:"get" summary:"获取环境信息"` +} + +type DbInitGetEnvInfoRes g.Map + +type DbInitCreateDbReq struct { + g.Meta `path:"/dbInit/createDb" tags:"系统初始化" method:"post" summary:"创建配置文件"` + DbHost string `json:"dbHost" p:"dbHost" v:"required#数据库地址必须"` + DbPort int `json:"dbPort" p:"dbPort" v:"required#数据库端口必须"` + DbUser string `json:"dbUser" p:"dbUser" v:"required#数据库用户名称必须"` + DbPass string `json:"dbPass"` + DbName string `json:"dbName" p:"dbName" v:"required#数据库名称必须"` + DbCharset string `json:"dbCharset" p:"dbCharset" v:"required#数据库编码必须"` + RedisAddress string `json:"redisAddress" p:"redisAddress" v:"required#Redis地址必须"` + RedisPort int `json:"redisPort" p:"redisPort" v:"required#Redis端口必须"` + RedisDb int `json:"redisDb" p:"redisDb" v:"required#Redis索引必须"` + RedisPass string `json:"redisPass"` +} + +type DbInitCreateDbRes bool + +func (req *DbInitCreateDbReq) ToDbInitConfig() *model.DbInitConfig { + return &model.DbInitConfig{ + Database: model.Database{ + Default: model.DbDefault{ + Host: req.DbHost, + Port: req.DbPort, + User: req.DbUser, + Pass: req.DbPass, + Name: req.DbName, + Type: "mysql", + Role: "master", + Debug: true, + Charset: req.DbCharset, + DryRun: false, + MaxIdle: 10, + MaxOpen: 10, + MaxLifetime: 10, + }, + }, + Redis: model.Redis{ + Default: model.RedisDefault{ + Address: fmt.Sprintf("%s:%d", req.RedisAddress, req.RedisPort), + Db: req.RedisDb, + Pass: req.RedisPass, + IdleTimeout: 600, + MaxActive: 100, + }, + }, + } +} diff --git a/api/v1/system/sys_job.go b/api/v1/system/sys_job.go new file mode 100644 index 0000000..4ff4db9 --- /dev/null +++ b/api/v1/system/sys_job.go @@ -0,0 +1,154 @@ +// ========================================================================== +// GFast自动生成api操作代码。 +// 生成日期:2023-01-12 17:43:50 +// 生成路径: api/v1/system/sys_job.go +// 生成人:gfast +// desc:定时任务相关参数 +// company:云南奇讯科技有限公司 +// ========================================================================== + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model" +) + +// SysJobSearchReq 分页请求参数 +type SysJobSearchReq struct { + g.Meta `path:"/list" tags:"定时任务" method:"get" summary:"定时任务列表"` + JobName string `p:"jobName"` //任务名称 + JobGroup string `p:"jobGroup"` //任务组名 + Status string `p:"status" v:"status@integer#状态需为整数"` //状态 + commonApi.PageReq + commonApi.Author +} + +// SysJobSearchRes 列表返回结果 +type SysJobSearchRes struct { + g.Meta `mime:"application/json"` + commonApi.ListRes + List []*model.SysJobListRes `json:"list"` +} + +// SysJobAddReq 添加操作请求参数 +type SysJobAddReq struct { + g.Meta `path:"/add" tags:"定时任务" method:"post" summary:"定时任务添加"` + commonApi.Author + JobName string `p:"jobName" v:"required#任务名称不能为空"` + JobParams string `p:"jobParams" ` + JobGroup string `p:"jobGroup" ` + InvokeTarget string `p:"invokeTarget" v:"required#任务方法不能为空"` + CronExpression string `p:"cronExpression" v:"required#cron执行表达式不能为空"` + MisfirePolicy int `p:"misfirePolicy" ` + Status int `p:"status" v:"required#状态不能为空"` + Remark string `p:"remark" ` + CreatedBy uint64 +} + +// SysJobAddRes 添加操作返回结果 +type SysJobAddRes struct { + commonApi.EmptyRes +} + +// SysJobEditReq 修改操作请求参数 +type SysJobEditReq struct { + g.Meta `path:"/edit" tags:"定时任务" method:"put" summary:"定时任务修改"` + commonApi.Author + JobId uint64 `p:"jobId" v:"required#主键ID不能为空"` + JobName string `p:"jobName" v:"required#任务名称不能为空"` + JobParams string `p:"jobParams" ` + JobGroup string `p:"jobGroup" ` + InvokeTarget string `p:"invokeTarget" v:"required#任务方法不能为空"` + CronExpression string `p:"cronExpression" v:"required#cron执行表达式不能为空"` + MisfirePolicy int `p:"misfirePolicy" ` + Status int `p:"status" v:"required#状态不能为空"` + Remark string `p:"remark" ` + UpdatedBy uint64 +} + +// SysJobEditRes 修改操作返回结果 +type SysJobEditRes struct { + commonApi.EmptyRes +} + +// SysJobGetReq 获取一条数据请求 +type SysJobGetReq struct { + g.Meta `path:"/get" tags:"定时任务" method:"get" summary:"获取定时任务信息"` + commonApi.Author + JobId uint64 `p:"jobId" v:"required#主键必须"` //通过主键获取 +} + +// SysJobGetRes 获取一条数据结果 +type SysJobGetRes struct { + g.Meta `mime:"application/json"` + *model.SysJobInfoRes +} + +// SysJobDeleteReq 删除数据请求 +type SysJobDeleteReq struct { + g.Meta `path:"/delete" tags:"定时任务" method:"delete" summary:"删除定时任务"` + commonApi.Author + JobIds []uint64 `p:"jobIds" v:"required#主键必须"` //通过主键删除 +} + +// SysJobDeleteRes 删除数据返回 +type SysJobDeleteRes struct { + commonApi.EmptyRes +} + +type SysJobStartReq struct { + g.Meta `path:"/start" tags:"定时任务" method:"put" summary:"启动任务"` + commonApi.Author + JobId uint64 `p:"jobId" v:"required#jobId必须"` +} + +type SysJobStartRes struct { + commonApi.EmptyRes +} + +type SysJobStopReq struct { + g.Meta `path:"/stop" tags:"定时任务" method:"put" summary:"停止任务"` + commonApi.Author + JobId uint64 `p:"jobId" v:"required#jobId必须"` +} + +type SysJobStopRes struct { + commonApi.EmptyRes +} + +type SysJobRunReq struct { + g.Meta `path:"/run" tags:"定时任务" method:"put" summary:"运行任务"` + commonApi.Author + JobId uint64 `p:"jobId" v:"required#jobId必须"` +} + +type SysJobRunRes struct { + commonApi.EmptyRes +} + +type SysJobLogListReq struct { + g.Meta `path:"/logs" tags:"定时任务" method:"get" summary:"执行日志"` + commonApi.Author + commonApi.PageReq + TargetName string `p:"targetName" v:"required#targetName必须"` +} + +type SysJobLogListRes struct { + g.Meta `mime:"application/json"` + commonApi.ListRes + List []*entity.SysJobLog `json:"list"` +} + +type SysJobLogDeleteReq struct { + g.Meta `path:"/deleteLogs" tags:"定时任务" method:"delete" summary:"删除执行日志"` + commonApi.Author + LogIds []uint64 `p:"logIds" v:"required#主键必须"` +} + +type SysJobLogDeleteRes struct { + commonApi.EmptyRes +} diff --git a/api/v1/system/sys_login.go b/api/v1/system/sys_login.go new file mode 100644 index 0000000..3bc7935 --- /dev/null +++ b/api/v1/system/sys_login.go @@ -0,0 +1,38 @@ +/* +* @desc:登录 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/27 21:51 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model" +) + +type UserLoginReq struct { + g.Meta `path:"/login" tags:"登录" method:"post" summary:"用户登录"` + Username string `p:"username" v:"required#用户名不能为空"` + Password string `p:"password" v:"required#密码不能为空"` + VerifyCode string `p:"verifyCode" v:"required#验证码不能为空"` + VerifyKey string `p:"verifyKey"` +} + +type UserLoginRes struct { + g.Meta `mime:"application/json"` + UserInfo *model.LoginUserRes `json:"userInfo"` + Token string `json:"token"` + MenuList []*model.UserMenus `json:"menuList"` + Permissions []string `json:"permissions"` +} + +type UserLoginOutReq struct { + g.Meta `path:"/logout" tags:"登录" method:"get" summary:"退出登录"` + commonApi.Author +} + +type UserLoginOutRes struct { +} diff --git a/api/v1/system/sys_login_log.go b/api/v1/system/sys_login_log.go new file mode 100644 index 0000000..fc7e207 --- /dev/null +++ b/api/v1/system/sys_login_log.go @@ -0,0 +1,47 @@ +/* +* @desc:登录日志 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/24 22:09 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +// LoginLogSearchReq 查询列表请求参数 +type LoginLogSearchReq struct { + g.Meta `path:"/loginLog/list" tags:"登录日志管理" method:"get" summary:"日志列表"` + LoginName string `p:"userName"` //登陆名 + Status string `p:"status"` //状态 + Ipaddr string `p:"ipaddr"` //登录地址 + SortName string `p:"orderByColumn"` //排序字段 + SortOrder string `p:"isAsc"` //排序方式 + LoginLocation string `p:"loginLocation"` //登录地点 + commonApi.PageReq +} + +type LoginLogSearchRes struct { + g.Meta `mime:"application/json"` + commonApi.ListRes + List []*entity.SysLoginLog `json:"list"` +} + +type LoginLogDelReq struct { + g.Meta `path:"/loginLog/delete" tags:"登录日志管理" method:"delete" summary:"删除日志"` + Ids []int `p:"ids" v:"required#ids必须"` +} + +type LoginLogDelRes struct { +} + +type LoginLogClearReq struct { + g.Meta `path:"/loginLog/clear" tags:"登录日志管理" method:"delete" summary:"清除日志"` +} + +type LoginLogClearRes struct { +} diff --git a/api/v1/system/sys_monitor.go b/api/v1/system/sys_monitor.go new file mode 100644 index 0000000..d22ee1c --- /dev/null +++ b/api/v1/system/sys_monitor.go @@ -0,0 +1,11 @@ +package system + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +type MonitorSearchReq struct { + g.Meta `path:"/monitor/server" tags:"服务监控" method:"get" summary:"服务监控"` +} + +type MonitorSearchRes g.Map diff --git a/api/v1/system/sys_oper_log.go b/api/v1/system/sys_oper_log.go new file mode 100644 index 0000000..33f1cf8 --- /dev/null +++ b/api/v1/system/sys_oper_log.go @@ -0,0 +1,65 @@ +/* +* @desc:操作日志 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/12/21 14:37 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model" +) + +// SysOperLogSearchReq 分页请求参数 +type SysOperLogSearchReq struct { + g.Meta `path:"/operLog/list" tags:"操作日志" method:"get" summary:"操作日志列表"` + Title string `p:"title"` //系统模块 + RequestMethod string `p:"requestMethod"` //请求方式 + OperName string `p:"operName"` //操作人员 + commonApi.PageReq + commonApi.Author +} + +// SysOperLogSearchRes 列表返回结果 +type SysOperLogSearchRes struct { + g.Meta `mime:"application/json"` + commonApi.ListRes + List []*model.SysOperLogListRes `json:"list"` +} + +// SysOperLogGetReq 获取一条数据请求 +type SysOperLogGetReq struct { + g.Meta `path:"/operLog/get" tags:"操作日志" method:"get" summary:"获取操作日志信息"` + commonApi.Author + OperId uint64 `p:"operId" v:"required#主键必须"` //通过主键获取 +} + +// SysOperLogGetRes 获取一条数据结果 +type SysOperLogGetRes struct { + g.Meta `mime:"application/json"` + *model.SysOperLogInfoRes +} + +// SysOperLogDeleteReq 删除数据请求 +type SysOperLogDeleteReq struct { + g.Meta `path:"/operLog/delete" tags:"操作日志" method:"delete" summary:"删除操作日志"` + commonApi.Author + OperIds []uint64 `p:"operIds" v:"required#主键必须"` //通过主键删除 +} + +// SysOperLogDeleteRes 删除数据返回 +type SysOperLogDeleteRes struct { + commonApi.EmptyRes +} + +type SysOperLogClearReq struct { + g.Meta `path:"/operLog/clear" tags:"操作日志" method:"delete" summary:"清除日志"` + commonApi.Author +} + +type SysOperLogClearRes struct { + commonApi.EmptyRes +} diff --git a/api/v1/system/sys_post.go b/api/v1/system/sys_post.go new file mode 100644 index 0000000..379c9d7 --- /dev/null +++ b/api/v1/system/sys_post.go @@ -0,0 +1,61 @@ +/* +* @desc:岗位相关参数 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/7 23:09 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type PostSearchReq struct { + g.Meta `path:"/post/list" tags:"岗位管理" method:"get" summary:"岗位列表"` + PostCode string `p:"postCode"` //岗位编码 + PostName string `p:"postName"` //岗位名称 + Status string `p:"status"` //状态 + commonApi.PageReq +} + +type PostSearchRes struct { + g.Meta `mime:"application/json"` + commonApi.ListRes + PostList []*entity.SysPost `json:"postList"` +} + +type PostAddReq struct { + g.Meta `path:"/post/add" tags:"岗位管理" method:"post" summary:"添加岗位"` + PostCode string `p:"postCode" v:"required#岗位编码不能为空"` + PostName string `p:"postName" v:"required#岗位名称不能为空"` + PostSort int `p:"postSort" v:"required#岗位排序不能为空"` + Status uint `p:"status" v:"required#状态不能为空"` + Remark string `p:"remark"` +} + +type PostAddRes struct { +} + +type PostEditReq struct { + g.Meta `path:"/post/edit" tags:"岗位管理" method:"put" summary:"修改岗位"` + PostId int64 `p:"postId" v:"required#id必须"` + PostCode string `p:"postCode" v:"required#岗位编码不能为空"` + PostName string `p:"postName" v:"required#岗位名称不能为空"` + PostSort int `p:"postSort" v:"required#岗位排序不能为空"` + Status uint `p:"status" v:"required#状态不能为空"` + Remark string `p:"remark"` +} + +type PostEditRes struct { +} + +type PostDeleteReq struct { + g.Meta `path:"/post/delete" tags:"岗位管理" method:"delete" summary:"删除岗位"` + Ids []int `p:"ids"` +} + +type PostDeleteRes struct { +} diff --git a/api/v1/system/sys_role.go b/api/v1/system/sys_role.go new file mode 100644 index 0000000..3040968 --- /dev/null +++ b/api/v1/system/sys_role.go @@ -0,0 +1,105 @@ +/* +* @desc:角色api +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/30 9:16 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type RoleListReq struct { + g.Meta `path:"/role/list" tags:"角色管理" method:"get" summary:"角色列表"` + RoleName string `p:"roleName"` //参数名称 + Status string `p:"roleStatus"` //状态 + commonApi.PageReq +} + +type RoleListRes struct { + g.Meta `mime:"application/json"` + commonApi.ListRes + List []*entity.SysRole `json:"list"` +} + +type RoleGetParamsReq struct { + g.Meta `path:"/role/getParams" tags:"角色管理" method:"get" summary:"角色编辑参数"` +} + +type RoleGetParamsRes struct { + g.Meta `mime:"application/json"` + Menu []*model.SysAuthRuleInfoRes `json:"menu"` +} + +type RoleAddReq struct { + g.Meta `path:"/role/add" tags:"角色管理" method:"post" summary:"添加角色"` + Name string `p:"name" v:"required#角色名称不能为空"` + Status uint `p:"status" ` + ListOrder uint `p:"listOrder" ` + Remark string `p:"remark" ` + MenuIds []uint `p:"menuIds"` +} + +type RoleAddRes struct { +} + +type RoleGetReq struct { + g.Meta `path:"/role/get" tags:"角色管理" method:"get" summary:"获取角色信息"` + Id uint `p:"id" v:"required#角色id不能为空""` +} + +type RoleGetRes struct { + g.Meta `mime:"application/json"` + Role *entity.SysRole `json:"role"` + MenuIds []int `json:"menuIds"` +} + +type RoleEditReq struct { + g.Meta `path:"/role/edit" tags:"角色管理" method:"put" summary:"修改角色"` + Id int64 `p:"id" v:"required#角色id必须"` + Name string `p:"name" v:"required#角色名称不能为空"` + Status uint `p:"status" ` + ListOrder uint `p:"listOrder" ` + Remark string `p:"remark" ` + MenuIds []uint `p:"menuIds"` +} + +type RoleEditRes struct { +} + +type RoleDeleteReq struct { + g.Meta `path:"/role/delete" tags:"角色管理" method:"delete" summary:"删除角色"` + Ids []int64 `p:"ids" v:"required#角色id不能为空"` +} + +type RoleDeleteRes struct { +} + +type RoleDeptTreeSelectReq struct { + g.Meta `path:"/role/deptTreeSelect" tags:"角色管理" method:"get" summary:"获取角色数据权限"` + commonApi.Author + RoleId int64 `p:"roleId" v:"required#角色id必须"` +} + +type RoleDeptTreeSelectRes struct { + g.Meta `mime:"application/json"` + Depts []*model.SysDeptTreeRes `json:"depts"` + CheckedKeys []int64 `json:"checkedKeys"` +} + +// DataScopeReq 角色数据授权参数 +type DataScopeReq struct { + g.Meta `path:"/role/dataScope" tags:"角色管理" method:"put" summary:"角色数据授权"` + RoleId uint `p:"roleId" v:"required#角色ID不能为空"` + DataScope uint `p:"dataScope" v:"required#权限范围不能为空"` + DeptIds []uint `p:"deptIds"` +} + +type DataScopeRes struct { + commonApi.EmptyRes +} diff --git a/api/v1/system/sys_user.go b/api/v1/system/sys_user.go new file mode 100644 index 0000000..fc1071a --- /dev/null +++ b/api/v1/system/sys_user.go @@ -0,0 +1,133 @@ +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type UserMenusReq struct { + g.Meta `path:"/user/getUserMenus" tags:"用户管理" method:"get" summary:"获取用户菜单"` + commonApi.Author +} + +type UserMenusRes struct { + g.Meta `mime:"application/json"` + MenuList []*model.UserMenus `json:"menuList"` + Permissions []string `json:"permissions"` +} + +// UserSearchReq 用户搜索请求参数 +type UserSearchReq struct { + g.Meta `path:"/user/list" tags:"用户管理" method:"get" summary:"用户列表"` + DeptId string `p:"deptId"` //部门id + Mobile string `p:"mobile"` + Status string `p:"status"` + KeyWords string `p:"keyWords"` + commonApi.PageReq + commonApi.Author +} + +type UserSearchRes struct { + g.Meta `mime:"application/json"` + UserList []*model.SysUserRoleDeptRes `json:"userList"` + commonApi.ListRes +} + +type UserGetParamsReq struct { + g.Meta `path:"/user/params" tags:"用户管理" method:"get" summary:"用户维护参数获取"` +} + +type UserGetParamsRes struct { + g.Meta `mime:"application/json"` + RoleList []*entity.SysRole `json:"roleList"` + Posts []*entity.SysPost `json:"posts"` +} + +// SetUserReq 添加修改用户公用请求字段 +type SetUserReq struct { + DeptId uint64 `p:"deptId" v:"required#用户部门不能为空"` //所属部门 + Email string `p:"email" v:"email#邮箱格式错误"` //邮箱 + NickName string `p:"nickName" v:"required#用户昵称不能为空"` + Mobile string `p:"mobile" v:"required|phone#手机号不能为空|手机号格式错误"` + PostIds []int64 `p:"postIds"` + Remark string `p:"remark"` + RoleIds []int64 `p:"roleIds"` + Sex int `p:"sex"` + Status uint `p:"status"` + IsAdmin int `p:"isAdmin"` // 是否后台管理员 1 是 0 否 +} + +// UserAddReq 添加用户参数 +type UserAddReq struct { + g.Meta `path:"/user/add" tags:"用户管理" method:"post" summary:"添加用户"` + *SetUserReq + UserName string `p:"userName" v:"required#用户账号不能为空"` + Password string `p:"password" v:"required|password#密码不能为空|密码以字母开头,只能包含字母、数字和下划线,长度在6~18之间"` + UserSalt string +} + +type UserAddRes struct { +} + +// UserEditReq 修改用户参数 +type UserEditReq struct { + g.Meta `path:"/user/edit" tags:"用户管理" method:"put" summary:"修改用户"` + *SetUserReq + UserId int64 `p:"userId" v:"required#用户id不能为空"` +} + +type UserEditRes struct { +} + +type UserGetEditReq struct { + g.Meta `path:"/user/getEdit" tags:"用户管理" method:"get" summary:"获取用户信息"` + Id uint64 `p:"id"` +} + +type UserGetEditRes struct { + g.Meta `mime:"application/json"` + User *entity.SysUser `json:"user"` + CheckedRoleIds []uint `json:"checkedRoleIds"` + CheckedPosts []int64 `json:"checkedPosts"` +} + +// UserResetPwdReq 重置用户密码状态参数 +type UserResetPwdReq struct { + g.Meta `path:"/user/resetPwd" tags:"用户管理" method:"put" summary:"重置用户密码"` + Id uint64 `p:"userId" v:"required#用户id不能为空"` + Password string `p:"password" v:"required|password#密码不能为空|密码以字母开头,只能包含字母、数字和下划线,长度在6~18之间"` +} + +type UserResetPwdRes struct { +} + +// UserStatusReq 设置用户状态参数 +type UserStatusReq struct { + g.Meta `path:"/user/setStatus" tags:"用户管理" method:"put" summary:"设置用户状态"` + Id uint64 `p:"userId" v:"required#用户id不能为空"` + UserStatus uint `p:"status" v:"required#用户状态不能为空"` +} + +type UserStatusRes struct { +} + +type UserDeleteReq struct { + g.Meta `path:"/user/delete" tags:"用户管理" method:"delete" summary:"删除用户"` + Ids []int `p:"ids" v:"required#ids不能为空"` +} + +type UserDeleteRes struct { +} + +type UserGetByIdsReq struct { + g.Meta `path:"/user/getUsers" tags:"用户管理" method:"get" summary:"同时获取多个用户"` + commonApi.Author + Ids []int `p:"ids" v:"required#ids不能为空"` +} + +type UserGetByIdsRes struct { + g.Meta `mime:"application/json"` + List []*model.SysUserSimpleRes `json:"list"` +} diff --git a/api/v1/system/sys_user_online.go b/api/v1/system/sys_user_online.go new file mode 100644 index 0000000..a61852a --- /dev/null +++ b/api/v1/system/sys_user_online.go @@ -0,0 +1,40 @@ +/* +* @desc:在线用户 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2023/1/10 16:57 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +// SysUserOnlineSearchReq 列表搜索参数 +type SysUserOnlineSearchReq struct { + g.Meta `path:"/online/list" tags:"在线用户管理" method:"get" summary:"列表"` + Username string `p:"userName"` + Ip string `p:"ipaddr"` + commonApi.PageReq + commonApi.Author +} + +// SysUserOnlineSearchRes 列表结果 +type SysUserOnlineSearchRes struct { + g.Meta `mime:"application/json"` + commonApi.ListRes + List []*entity.SysUserOnline `json:"list"` +} + +type SysUserOnlineForceLogoutReq struct { + g.Meta `path:"/online/forceLogout" tags:"在线用户管理" method:"delete" summary:"强制用户退出登录"` + commonApi.Author + Ids []int `p:"ids" v:"required#ids不能为空"` +} + +type SysUserOnlineForceLogoutRes struct { + commonApi.EmptyRes +} diff --git a/api/v1/system/tools_gen_table.go b/api/v1/system/tools_gen_table.go new file mode 100644 index 0000000..865b250 --- /dev/null +++ b/api/v1/system/tools_gen_table.go @@ -0,0 +1,127 @@ +/* +* @desc:代码生成 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/10/26 16:44 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + commonApi "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +// ToolsGenTableSearchReq 列表分页请求参数 +type ToolsGenTableSearchReq struct { + g.Meta `path:"/tools/gen/tableList" tags:"代码生成" method:"get" summary:"获取数据表"` + TableName string `p:"tableName"` //表名称 + TableComment string `p:"tableComment"` //表描述 + commonApi.PageReq + commonApi.Author +} + +// ToolsGenTableSearchRes 表列表数据 +type ToolsGenTableSearchRes struct { + g.Meta `mime:"application/json"` + commonApi.ListRes + List []*entity.ToolsGenTable `json:"list"` +} + +// ToolsGenTableImportSearchReq 要导入的表列表数据 +type ToolsGenTableImportSearchReq struct { + g.Meta `path:"/tools/gen/dataList" tags:"代码生成" method:"get" summary:"获取需要导入的数据表"` + TableName string `p:"tableName"` //表名称 + TableComment string `p:"tableComment"` //表描述 + commonApi.PageReq + commonApi.Author +} + +// ToolsGenTableImportTableReq 导入表数据操作 +type ToolsGenTableImportTableReq struct { + g.Meta `path:"/tools/gen/importTableSave" tags:"代码生成" method:"post" summary:"导入表结构操作"` + commonApi.Author + Tables []string `p:"tables" v:"required#表名必须指定"` +} + +type ToolsGenTableDeleteReq struct { + g.Meta `path:"/tools/gen/tableDelete" tags:"代码生成" method:"delete" summary:"删除已导入的表"` + commonApi.Author + Ids []int `p:"ids" v:required#删除的id必须` +} + +type ToolsGenTableEditReq struct { + g.Meta `path:"/tools/gen/columnList" tags:"代码生成" method:"get" summary:"生成数据编辑"` + commonApi.Author + TableId int64 `p:"tableId" v:"required#tableId字段必须"` +} + +// ToolsGenTableEditRes 生成数据编辑页面返回数据 +type ToolsGenTableEditRes struct { + g.Meta `mime:"application/json"` + List []*entity.ToolsGenTableColumn `json:"list"` + Info *model.ToolsGenTableEditData `json:"info"` +} + +// ToolsGenRelationTableReq 获取关联表数据 +type ToolsGenRelationTableReq struct { + g.Meta `path:"/tools/gen/relationTable" tags:"代码生成" method:"get" summary:"获取关联表数据"` +} + +// ToolsGenRelationTableRes 关联表返回数据 +type ToolsGenRelationTableRes struct { + g.Meta `mime:"application/json"` + Data []*model.ToolsGenTableColumnsData `json:"data"` +} + +// ToolsGenTableColumnsEditReq 生成信息修改参数 +type ToolsGenTableColumnsEditReq struct { + g.Meta `path:"/tools/gen/editSave" tags:"代码生成" method:"post" summary:"生成信息修改保存"` + commonApi.Author + TableId int64 `p:"tableId" v:"required#主键ID不能为空"` + TableName string `p:"tableName" v:"required#表名称不能为空"` + TableComment string `p:"tableComment" v:"required#表描述不能为空"` + ClassName string `p:"className" v:"required#实体类名称不能为空"` + FunctionAuthor string `p:"functionAuthor" v:"required#作者不能为空"` + TplCategory string `p:"tplCategory"` + PackageName string `p:"packageName" v:"required#生成包路径不能为空"` + ModuleName string `p:"moduleName" v:"required#生成模块名不能为空"` + BusinessName string `p:"businessName" v:"required#生成业务名不能为空"` + FunctionName string `p:"functionName" v:"required#生成功能名不能为空"` + Remark string `p:"remark"` + Overwrite string `p:"overwrite" v:"required#是否覆盖原有文件不能为空"` + SortColumn string `p:"sort_column" v:"required#缺省排序字段不能为空"` + SortType string `p:"sort_type" v:"required#缺省排序方式不能为空"` + ShowDetail string `p:"show_detail" v:"required#是否有查看详情功能不能为空"` + Params string `p:"params"` + Columns []*entity.ToolsGenTableColumn `p:"columns"` + TreeCode string `p:"tree_code"` + TreeParentCode string `p:"tree_parent_code"` + TreeName string `p:"tree_name"` + UserName string +} + +type ToolsGenTableColumnsEditRes struct { + commonApi.EmptyRes +} + +type ToolsGenTablePreviewReq struct { + g.Meta `path:"/tools/gen/preview" tags:"代码生成" method:"get" summary:"代码预览"` + TableId int64 `p:"tableId" v:"required#表ID必须"` +} + +type ToolsGenTablePreviewRes struct { + g.Meta `mime:"application/json"` + Data g.MapStrStr `json:"data"` +} + +type ToolsGenTableBatchGenCodeReq struct { + g.Meta `path:"/tools/gen/batchGenCode" tags:"代码生成" method:"post" summary:"代码生成"` + Ids []int `p:"ids" v:"required#ids必须且不能为空"` +} + +type ToolsGenTableBatchGenCodeRes struct { + commonApi.EmptyRes +} diff --git a/api/v1/system/ueditor.go b/api/v1/system/ueditor.go new file mode 100644 index 0000000..fd8eecb --- /dev/null +++ b/api/v1/system/ueditor.go @@ -0,0 +1,34 @@ +/* +* @desc:ueditor编辑器 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/11/17 14:15 + */ + +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" +) + +type UEditorConfigReq struct { + g.Meta `path:"/uEditor/action" tags:"UEditor" method:"get" summary:"获取UEditor配置"` + UEditorReq +} + +type UEditorUpFileReq struct { + g.Meta `path:"/uEditor/action" tags:"UEditor" method:"post" summary:"UEditor上传"` + UEditorReq +} + +type UEditorReq struct { + Action string `p:"action"` + Callback string `p:"callback"` + File *ghttp.UploadFile `p:"upfile" type:"file"` +} + +type UEditorRes struct { + g.Meta `mime:"application/json"` + g.Map +} diff --git a/api/v1/system/upload.go b/api/v1/system/upload.go new file mode 100644 index 0000000..7eaedcc --- /dev/null +++ b/api/v1/system/upload.go @@ -0,0 +1,45 @@ +package system + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" +) + +// 单图上传 +type UploadSingleImgReq struct { + g.Meta `path:"/upload/singleImg" tags:"后台文件上传" method:"post" summary:"上传图片"` + File *ghttp.UploadFile `p:"file" type:"file" dc:"选择上传文件" v:"required#上传文件必须"` +} + +// 单文件上传 +type UploadSingleFileReq struct { + g.Meta `path:"/upload/singleFile" tags:"后台文件上传" method:"post" summary:"上传文件"` + File *ghttp.UploadFile `p:"file" type:"file" dc:"选择上传文件" v:"required#上传文件必须"` +} + +type UploadSingleRes struct { + g.Meta `mime:"application/json"` + UploadResponse +} + +// 多图上传 +type UploadMultipleImgReq struct { + g.Meta `path:"/upload/multipleImg" tags:"后台文件上传" method:"post" summary:"上传多图片"` + File ghttp.UploadFiles `p:"file" type:"file" dc:"选择上传文件" v:"required#上传文件必须"` +} + +// 多文件上传 +type UploadMultipleFileReq struct { + g.Meta `path:"/upload/multipleFile" tags:"后台文件上传" method:"post" summary:"上传多文件"` + File ghttp.UploadFiles `p:"file" type:"file" dc:"选择上传文件" v:"required#上传文件必须"` +} + +type UploadMultipleRes []*UploadResponse + +type UploadResponse struct { + Size int64 `json:"size" dc:"文件大小"` + Path string `json:"path" dc:"文件相对路径"` + FullPath string `json:"fullPath" dc:"文件绝对路径"` + Name string `json:"name" dc:"文件名称"` + Type string `json:"type" dc:"文件类型"` +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..781c65b --- /dev/null +++ b/go.mod @@ -0,0 +1,24 @@ +module github.com/tiger1103/gfast/v3 + +go 1.16 + +require ( + github.com/casbin/casbin/v2 v2.42.0 + github.com/go-sql-driver/mysql v1.7.0 // indirect + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.2.5 + github.com/gogf/gf/contrib/nosql/redis/v2 v2.3.0 + github.com/gogf/gf/v2 v2.3.1 + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mojocn/base64Captcha v1.3.5 + github.com/mssola/user_agent v0.5.3 + github.com/qiniu/go-sdk/v7 v7.13.0 + github.com/rivo/uniseg v0.4.3 // indirect + github.com/shirou/gopsutil v3.21.11+incompatible + github.com/tencentyun/cos-go-sdk-v5 v0.7.34 + github.com/tiger1103/gfast-cache v1.0.0 + github.com/tiger1103/gfast-token v1.0.3 + github.com/tklauser/go-sysconf v0.3.10 // indirect + github.com/yusufpapurcu/wmi v1.2.2 // indirect + golang.org/x/net v0.4.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..d9cd7e8 --- /dev/null +++ b/go.sum @@ -0,0 +1,307 @@ +github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +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= +github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= +github.com/casbin/casbin/v2 v2.42.0 h1:EA0aE5PZnFSYY6WulzTScOo4YO6xrGAAZkXRLs8p2ME= +github.com/casbin/casbin/v2 v2.42.0/go.mod h1:sEL80qBYTbd+BPeL4iyvwYzFT3qwLaESq5aFKVLbLfA= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I= +github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= +github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= +github.com/clbanning/mxj/v2 v2.5.7 h1:7q5lvUpaPF/WOkqgIDiwjBJaznaLCCBd78pi8ZyAnE0= +github.com/clbanning/mxj/v2 v2.5.7/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +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= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk= +github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w= +github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= +github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= +github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +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.2.5 h1:lbktAfOabQV9ZzLdEUK6DkELnq2hcHLd8gAD1a6HfSQ= +github.com/gogf/gf/contrib/drivers/mysql/v2 v2.2.5/go.mod h1:z+/0qiOwMroAnj5ESuobTv0l5P83rf+XR3r6Fj8WJyk= +github.com/gogf/gf/contrib/nosql/redis/v2 v2.3.0 h1:r2q8MLwF6yUIEm6Hhwsfo/ixaJTKluTXSjU8rSeXo3c= +github.com/gogf/gf/contrib/nosql/redis/v2 v2.3.0/go.mod h1:V9o2BF9ovJnaZhHImHAanqUgjX4kI51lgU45u5rPqvw= +github.com/gogf/gf/v2 v2.0.0/go.mod h1:apktt6TleWtCIwpz63vBqUnw8MX8gWKoZyxgDpXFtgM= +github.com/gogf/gf/v2 v2.3.0/go.mod h1:tsbmtwcAl2chcYoq/fP9W2FZf06aw4i89X34nbSHo9Y= +github.com/gogf/gf/v2 v2.3.1 h1:uptCJK47N6KSRwTBnFAqBWYnYa/OXBkZ0OlhO9CK7bQ= +github.com/gogf/gf/v2 v2.3.1/go.mod h1:tsbmtwcAl2chcYoq/fP9W2FZf06aw4i89X34nbSHo9Y= +github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= +github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +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/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0= +github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= +github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= +github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mojocn/base64Captcha v1.3.5 h1:Qeilr7Ta6eDtG4S+tQuZ5+hO+QHbiGAJdi4PfoagaA0= +github.com/mojocn/base64Captcha v1.3.5/go.mod h1:/tTTXn4WTpX9CfrmipqRytCpJ27Uw3G6I7NcP2WwcmY= +github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ= +github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= +github.com/mssola/user_agent v0.5.3 h1:lBRPML9mdFuIZgI2cmlQ+atbpJdLdeVl2IDodjBR578= +github.com/mssola/user_agent v0.5.3/go.mod h1:TTPno8LPY3wAIEKRpAtkdMT0f8SE24pLRGPahjCH4uw= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdkk= +github.com/qiniu/go-sdk/v7 v7.13.0 h1:0bWRh/oAC2cArUILZLuWN+s9hPep1JYch5sA2Mfxq7A= +github.com/qiniu/go-sdk/v7 v7.13.0/go.mod h1:btsaOc8CA3hdVloULfFdDgDc+g4f3TDZEFsDY0BLE+w= +github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= +github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= +github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +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 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.194/go.mod h1:yrBKWhChnDqNz1xuXdSbWXG56XawEq0G5j1lg4VwBD4= +github.com/tencentyun/cos-go-sdk-v5 v0.7.34 h1:xm+Pg+6m486y4eugRI7/E4WasbVmpY1hp9QBSRErgp8= +github.com/tencentyun/cos-go-sdk-v5 v0.7.34/go.mod h1:4dCEtLHGh8QPxHEkgq+nFaky7yZxQuYwgSJM87icDaw= +github.com/tiger1103/gfast-cache v1.0.0 h1:+amboC6uu4AvkUnDz4DECcsBTp5HW+O98k8guJtrDlA= +github.com/tiger1103/gfast-cache v1.0.0/go.mod h1:l+e5vdUHmqK0Th5VBOCSxXORbm8MwZQMXDkn+KA+amE= +github.com/tiger1103/gfast-token v1.0.3 h1:6uPGGuhxlLODV9tDS1djhWHUSaIYtVNyOqibHTITCt4= +github.com/tiger1103/gfast-token v1.0.3/go.mod h1:yjTBd86Gi2tOrgNBZe60QKyMprJVFSg3zUmQDEkD/Lw= +github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= +github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= +github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= +github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= +github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg= +go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= +go.opentelemetry.io/otel v1.11.2 h1:YBZcQlsVekzFsFbjygXMOXSs6pialIZxcjfO/mBDmR0= +go.opentelemetry.io/otel v1.11.2/go.mod h1:7p4EUV+AqgdlNV9gL97IgUZiVR3yrFXYo53f9BM3tRI= +go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM= +go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU= +go.opentelemetry.io/otel/sdk v1.11.2 h1:GF4JoaEx7iihdMFu30sOyRx52HDHOkl9xQ8SMqNXUiU= +go.opentelemetry.io/otel/sdk v1.11.2/go.mod h1:wZ1WxImwpq+lVRo4vsmSOxdd+xwoUJ6rqyLc3SyX9aU= +go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs= +go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= +go.opentelemetry.io/otel/trace v1.11.2 h1:Xf7hWSF2Glv0DE3MH7fBHvtpSBsjcBUe5MYAmZM/+y0= +go.opentelemetry.io/otel/trace v1.11.2/go.mod h1:4N+yC7QEz7TTsG9BSRLNAa63eg5E06ObSbKPmxQ/pKA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/image v0.0.0-20190501045829-6d32002ffd75 h1:TbGuee8sSq15Iguxu4deQ7+Bqq/d2rsQejGcEtADAMQ= +golang.org/x/image v0.0.0-20190501045829-6d32002ffd75/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +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/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= +golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +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 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +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.3.8-0.20211105212822-18b340fc7af2/go.mod h1:EFNZuWvGYxIRUEX+K8UmCFwYmZjqcrnq15ZuVldZkZ0= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +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= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/hack/config.yaml b/hack/config.yaml new file mode 100644 index 0000000..e7fb751 --- /dev/null +++ b/hack/config.yaml @@ -0,0 +1,10 @@ +# CLI. +gfcli: + gen: + dao: + - link: "mysql:gfast3:gfast333@tcp(127.0.0.1:3306)/gfast-v32" + tables: "sys_role_dept" + removePrefix: "gf_" + descriptionTag: true + noModelComment: true + path: "./internal/app/system" \ No newline at end of file diff --git a/internal/app/boot/boot.go b/internal/app/boot/boot.go new file mode 100644 index 0000000..799ce27 --- /dev/null +++ b/internal/app/boot/boot.go @@ -0,0 +1,13 @@ +/* +* @desc:启动 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/23 15:55 + */ + +package boot + +import ( + _ "github.com/tiger1103/gfast/v3/internal/app/common/logic" + _ "github.com/tiger1103/gfast/v3/internal/app/system/logic" +) diff --git a/internal/app/common/consts/cache.go b/internal/app/common/consts/cache.go new file mode 100644 index 0000000..cb1b3b8 --- /dev/null +++ b/internal/app/common/consts/cache.go @@ -0,0 +1,21 @@ +/* +* @desc:缓存相关 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/9 11:25 + */ + +package consts + +const ( + CacheModelMem = "memory" + CacheModelRedis = "redis" + + // CacheSysDict 字典缓存菜单KEY + CacheSysDict = "sysDict" + + // CacheSysDictTag 字典缓存标签 + CacheSysDictTag = "sysDictTag" + // CacheSysConfigTag 系统参数配置 + CacheSysConfigTag = "sysConfigTag" +) diff --git a/internal/app/common/consts/consts.go b/internal/app/common/consts/consts.go new file mode 100644 index 0000000..9303cfa --- /dev/null +++ b/internal/app/common/consts/consts.go @@ -0,0 +1,8 @@ +/* +* @desc:常量 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/30 11:54 + */ + +package consts diff --git a/internal/app/common/consts/upload.go b/internal/app/common/consts/upload.go new file mode 100644 index 0000000..22a8143 --- /dev/null +++ b/internal/app/common/consts/upload.go @@ -0,0 +1,11 @@ +package consts + +const ( + UploadPath = "upload_file" + ImgTypeKey = "sys.uploadFile.imageType" + ImgSizeKey = "sys.uploadFile.imageSize" + FileTypeKey = "sys.uploadFile.fileType" + FileSizeKey = "sys.uploadFile.fileSize" + CheckFileTypeImg = "img" // 文件类型(图片) + CheckFileTypeFile = "file" // 文件类型(任意) +) diff --git a/internal/app/common/controller/base.go b/internal/app/common/controller/base.go new file mode 100644 index 0000000..e9b22f3 --- /dev/null +++ b/internal/app/common/controller/base.go @@ -0,0 +1,19 @@ +/* +* @desc: +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/4 18:19 + */ + +package controller + +import ( + "github.com/gogf/gf/v2/net/ghttp" +) + +type BaseController struct { +} + +// Init 自动执行的初始化方法 +func (c *BaseController) Init(r *ghttp.Request) { +} diff --git a/internal/app/common/controller/captcha.go b/internal/app/common/controller/captcha.go new file mode 100644 index 0000000..0471ff6 --- /dev/null +++ b/internal/app/common/controller/captcha.go @@ -0,0 +1,32 @@ +/* +* @desc:验证码获取 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/2 17:45 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/internal/app/common/service" +) + +var Captcha = captchaController{} + +type captchaController struct { +} + +// Get 获取验证码 +func (c *captchaController) Get(ctx context.Context, req *common.CaptchaReq) (res *common.CaptchaRes, err error) { + var ( + idKeyC, base64stringC string + ) + idKeyC, base64stringC, err = service.Captcha().GetVerifyImgString(ctx) + res = &common.CaptchaRes{ + Key: idKeyC, + Img: base64stringC, + } + return +} diff --git a/internal/app/common/dao/casbin_rule.go b/internal/app/common/dao/casbin_rule.go new file mode 100644 index 0000000..f58b618 --- /dev/null +++ b/internal/app/common/dao/casbin_rule.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/common/dao/internal" +) + +// casbinRuleDao is the data access object for table casbin_rule. +// You can define custom methods on it to extend its functionality as you wish. +type casbinRuleDao struct { + *internal.CasbinRuleDao +} + +var ( + // CasbinRule is globally public accessible object for table casbin_rule operations. + CasbinRule = casbinRuleDao{ + internal.NewCasbinRuleDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/common/dao/internal/casbin_rule.go b/internal/app/common/dao/internal/casbin_rule.go new file mode 100644 index 0000000..c3d7648 --- /dev/null +++ b/internal/app/common/dao/internal/casbin_rule.go @@ -0,0 +1,84 @@ +// ========================================================================== +// Code generated 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" +) + +// CasbinRuleDao is the data access object for table casbin_rule. +type CasbinRuleDao 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 CasbinRuleColumns // columns contains all the column names of Table for convenient usage. +} + +// CasbinRuleColumns defines and stores column names for table casbin_rule. +type CasbinRuleColumns struct { + Ptype string // + V0 string // + V1 string // + V2 string // + V3 string // + V4 string // + V5 string // +} + +// casbinRuleColumns holds the columns for table casbin_rule. +var casbinRuleColumns = CasbinRuleColumns{ + Ptype: "ptype", + V0: "v0", + V1: "v1", + V2: "v2", + V3: "v3", + V4: "v4", + V5: "v5", +} + +// NewCasbinRuleDao creates and returns a new DAO object for table data access. +func NewCasbinRuleDao() *CasbinRuleDao { + return &CasbinRuleDao{ + group: "default", + table: "casbin_rule", + columns: casbinRuleColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *CasbinRuleDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *CasbinRuleDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *CasbinRuleDao) Columns() CasbinRuleColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *CasbinRuleDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *CasbinRuleDao) 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 *CasbinRuleDao) 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/internal/app/common/dao/internal/sys_config.go b/internal/app/common/dao/internal/sys_config.go new file mode 100644 index 0000000..f5673c1 --- /dev/null +++ b/internal/app/common/dao/internal/sys_config.go @@ -0,0 +1,90 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-18 21:09:17 +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysConfigDao is the data access object for table sys_config. +type SysConfigDao 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 SysConfigColumns // columns contains all the column names of Table for convenient usage. +} + +// SysConfigColumns defines and stores column names for table sys_config. +type SysConfigColumns struct { + ConfigId string // 参数主键 + ConfigName string // 参数名称 + ConfigKey string // 参数键名 + ConfigValue string // 参数键值 + ConfigType string // 系统内置(Y是 N否) + CreateBy string // 创建者 + UpdateBy string // 更新者 + Remark string // 备注 + CreatedAt string // 创建时间 + UpdatedAt string // 修改时间 +} + +// sysConfigColumns holds the columns for table sys_config. +var sysConfigColumns = SysConfigColumns{ + ConfigId: "config_id", + ConfigName: "config_name", + ConfigKey: "config_key", + ConfigValue: "config_value", + ConfigType: "config_type", + CreateBy: "create_by", + UpdateBy: "update_by", + Remark: "remark", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} + +// NewSysConfigDao creates and returns a new DAO object for table data access. +func NewSysConfigDao() *SysConfigDao { + return &SysConfigDao{ + group: "default", + table: "sys_config", + columns: sysConfigColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysConfigDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysConfigDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysConfigDao) Columns() SysConfigColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysConfigDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysConfigDao) 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 *SysConfigDao) 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/internal/app/common/dao/internal/sys_dict_data.go b/internal/app/common/dao/internal/sys_dict_data.go new file mode 100644 index 0000000..f601006 --- /dev/null +++ b/internal/app/common/dao/internal/sys_dict_data.go @@ -0,0 +1,98 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52 +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysDictDataDao is the data access object for table sys_dict_data. +type SysDictDataDao 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 SysDictDataColumns // columns contains all the column names of Table for convenient usage. +} + +// SysDictDataColumns defines and stores column names for table sys_dict_data. +type SysDictDataColumns struct { + DictCode string // 字典编码 + DictSort string // 字典排序 + DictLabel string // 字典标签 + DictValue string // 字典键值 + DictType string // 字典类型 + CssClass string // 样式属性(其他样式扩展) + ListClass string // 表格回显样式 + IsDefault string // 是否默认(1是 0否) + Status string // 状态(0正常 1停用) + CreateBy string // 创建者 + UpdateBy string // 更新者 + Remark string // 备注 + CreatedAt string // 创建时间 + UpdatedAt string // 修改时间 +} + +// sysDictDataColumns holds the columns for table sys_dict_data. +var sysDictDataColumns = SysDictDataColumns{ + DictCode: "dict_code", + DictSort: "dict_sort", + DictLabel: "dict_label", + DictValue: "dict_value", + DictType: "dict_type", + CssClass: "css_class", + ListClass: "list_class", + IsDefault: "is_default", + Status: "status", + CreateBy: "create_by", + UpdateBy: "update_by", + Remark: "remark", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} + +// NewSysDictDataDao creates and returns a new DAO object for table data access. +func NewSysDictDataDao() *SysDictDataDao { + return &SysDictDataDao{ + group: "default", + table: "sys_dict_data", + columns: sysDictDataColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysDictDataDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysDictDataDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysDictDataDao) Columns() SysDictDataColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysDictDataDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysDictDataDao) 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 *SysDictDataDao) 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/internal/app/common/dao/internal/sys_dict_type.go b/internal/app/common/dao/internal/sys_dict_type.go new file mode 100644 index 0000000..edee6dc --- /dev/null +++ b/internal/app/common/dao/internal/sys_dict_type.go @@ -0,0 +1,88 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52 +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysDictTypeDao is the data access object for table sys_dict_type. +type SysDictTypeDao 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 SysDictTypeColumns // columns contains all the column names of Table for convenient usage. +} + +// SysDictTypeColumns defines and stores column names for table sys_dict_type. +type SysDictTypeColumns struct { + DictId string // 字典主键 + DictName string // 字典名称 + DictType string // 字典类型 + Status string // 状态(0正常 1停用) + CreateBy string // 创建者 + UpdateBy string // 更新者 + Remark string // 备注 + CreatedAt string // 创建日期 + UpdatedAt string // 修改日期 +} + +// sysDictTypeColumns holds the columns for table sys_dict_type. +var sysDictTypeColumns = SysDictTypeColumns{ + DictId: "dict_id", + DictName: "dict_name", + DictType: "dict_type", + Status: "status", + CreateBy: "create_by", + UpdateBy: "update_by", + Remark: "remark", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} + +// NewSysDictTypeDao creates and returns a new DAO object for table data access. +func NewSysDictTypeDao() *SysDictTypeDao { + return &SysDictTypeDao{ + group: "default", + table: "sys_dict_type", + columns: sysDictTypeColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysDictTypeDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysDictTypeDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysDictTypeDao) Columns() SysDictTypeColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysDictTypeDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysDictTypeDao) 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 *SysDictTypeDao) 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/internal/app/common/dao/sys_config.go b/internal/app/common/dao/sys_config.go new file mode 100644 index 0000000..bb94040 --- /dev/null +++ b/internal/app/common/dao/sys_config.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/common/dao/internal" +) + +// sysConfigDao is the data access object for table sys_config. +// You can define custom methods on it to extend its functionality as you wish. +type sysConfigDao struct { + *internal.SysConfigDao +} + +var ( + // SysConfig is globally public accessible object for table sys_config operations. + SysConfig = sysConfigDao{ + internal.NewSysConfigDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/common/dao/sys_dict_data.go b/internal/app/common/dao/sys_dict_data.go new file mode 100644 index 0000000..7bf40ed --- /dev/null +++ b/internal/app/common/dao/sys_dict_data.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/common/dao/internal" +) + +// sysDictDataDao is the data access object for table sys_dict_data. +// You can define custom methods on it to extend its functionality as you wish. +type sysDictDataDao struct { + *internal.SysDictDataDao +} + +var ( + // SysDictData is globally public accessible object for table sys_dict_data operations. + SysDictData = sysDictDataDao{ + internal.NewSysDictDataDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/common/dao/sys_dict_type.go b/internal/app/common/dao/sys_dict_type.go new file mode 100644 index 0000000..4cb5521 --- /dev/null +++ b/internal/app/common/dao/sys_dict_type.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/common/dao/internal" +) + +// sysDictTypeDao is the data access object for table sys_dict_type. +// You can define custom methods on it to extend its functionality as you wish. +type sysDictTypeDao struct { + *internal.SysDictTypeDao +} + +var ( + // SysDictType is globally public accessible object for table sys_dict_type operations. + SysDictType = sysDictTypeDao{ + internal.NewSysDictTypeDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/common/logic/bigUpload/big_upload.go b/internal/app/common/logic/bigUpload/big_upload.go new file mode 100644 index 0000000..02ad9bc --- /dev/null +++ b/internal/app/common/logic/bigUpload/big_upload.go @@ -0,0 +1,74 @@ +/* +* @desc:大文件上传 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/27 16:25 + */ + +package bigUpload + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/library/upload_chunk" +) + +func init() { + service.RegisterBigUpload(New()) +} + +func New() *sBigUpload { + return &sBigUpload{} +} + +type sBigUpload struct{} + +// Upload 上传分片文件 +func (s *sBigUpload) Upload(ctx context.Context, req *system.BigUploadReq) (res *system.BigUploadRes, err error) { + uploadChunk := &upload_chunk.UploadChunk{} + result, err := uploadChunk.Upload(req.UploadReq) + if err != nil { + return + } + res = new(system.BigUploadRes) + res.UpLoadRes = *result + return +} + +// UploadCheck 上传文件检查 +func (s *sBigUpload) UploadCheck(ctx context.Context, req *system.BigUploadCheckReq) (res *system.BigUploadCheckRes, err error) { + uploadChunk := &upload_chunk.UploadChunk{} + result, err := uploadChunk.CheckChunk(req.UploadReq) + if err != nil { + return + } + //res = new(common.BigUploadCheckRes) + //res.CheckRes = *result + + res = &system.BigUploadCheckRes{ + CheckRes: *result, + Identifier: req.Identifier, + TotalChunks: req.TotalChunks, + } + return +} + +// UploadMerge 上传文件合并 +func (s *sBigUpload) UploadMerge(ctx context.Context, req *system.BigUploadMergeReq) (res *system.BigUploadRes, err error) { + uploadChunk := &upload_chunk.UploadChunk{} + result, err := uploadChunk.MergeChunk(req.UploadReq) + if err != nil { + return + } + res = &system.BigUploadRes{ + UpLoadRes: upload_chunk.UpLoadRes{ + BaseRes: result.BaseRes, + NeedMerge: false, + Identifier: req.Identifier, + TotalChunks: req.TotalChunks, + }, + } + + return +} diff --git a/internal/app/common/logic/cache/cache.go b/internal/app/common/logic/cache/cache.go new file mode 100644 index 0000000..f9184e0 --- /dev/null +++ b/internal/app/common/logic/cache/cache.go @@ -0,0 +1,45 @@ +/* +* @desc:缓存处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/27 16:33 + */ + +package cache + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + "github.com/tiger1103/gfast-cache/cache" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + "github.com/tiger1103/gfast/v3/internal/app/common/service" +) + +func init() { + service.RegisterCache(New()) +} + +func New() *sCache { + var ( + ctx = gctx.New() + cacheContainer *cache.GfCache + ) + prefix := g.Cfg().MustGet(ctx, "system.cache.prefix").String() + model := g.Cfg().MustGet(ctx, "system.cache.model").String() + if model == consts.CacheModelRedis { + // redis + cacheContainer = cache.NewRedis(prefix) + } else { + // memory + cacheContainer = cache.New(prefix) + } + return &sCache{ + GfCache: cacheContainer, + prefix: prefix, + } +} + +type sCache struct { + *cache.GfCache + prefix string +} diff --git a/internal/app/common/logic/captcha/captcha.go b/internal/app/common/logic/captcha/captcha.go new file mode 100644 index 0000000..bfc690a --- /dev/null +++ b/internal/app/common/logic/captcha/captcha.go @@ -0,0 +1,69 @@ +/* +* @desc:验证码处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/28 9:01 + */ + +package captcha + +import ( + "context" + "github.com/gogf/gf/v2/text/gstr" + "github.com/mojocn/base64Captcha" + "github.com/tiger1103/gfast/v3/internal/app/common/service" +) + +func init() { + service.RegisterCaptcha(New()) +} + +func New() *sCaptcha { + return &sCaptcha{ + driver: &base64Captcha.DriverString{ + Height: 80, + Width: 240, + NoiseCount: 50, + ShowLineOptions: 20, + Length: 4, + Source: "abcdefghjkmnpqrstuvwxyz23456789", + Fonts: []string{"chromohv.ttf"}, + }, + store: base64Captcha.DefaultMemStore, + } +} + +type sCaptcha struct { + driver *base64Captcha.DriverString + store base64Captcha.Store +} + +var ( + captcha = sCaptcha{ + driver: &base64Captcha.DriverString{ + Height: 80, + Width: 240, + NoiseCount: 50, + ShowLineOptions: 20, + Length: 4, + Source: "abcdefghjkmnpqrstuvwxyz23456789", + Fonts: []string{"chromohv.ttf"}, + }, + store: base64Captcha.DefaultMemStore, + } +) + +// GetVerifyImgString 获取字母数字混合验证码 +func (s *sCaptcha) GetVerifyImgString(ctx context.Context) (idKeyC string, base64stringC string, err error) { + driver := s.driver.ConvertFonts() + c := base64Captcha.NewCaptcha(driver, s.store) + idKeyC, base64stringC, err = c.Generate() + return +} + +// VerifyString 验证输入的验证码是否正确 +func (s *sCaptcha) VerifyString(id, answer string) bool { + c := base64Captcha.NewCaptcha(s.driver, s.store) + answer = gstr.ToLower(answer) + return c.Verify(id, answer, true) +} diff --git a/internal/app/common/logic/logic.go b/internal/app/common/logic/logic.go new file mode 100644 index 0000000..0dcb5d0 --- /dev/null +++ b/internal/app/common/logic/logic.go @@ -0,0 +1,16 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package logic + +import ( + _ "github.com/tiger1103/gfast/v3/internal/app/common/logic/bigUpload" + _ "github.com/tiger1103/gfast/v3/internal/app/common/logic/cache" + _ "github.com/tiger1103/gfast/v3/internal/app/common/logic/captcha" + _ "github.com/tiger1103/gfast/v3/internal/app/common/logic/middleware" + _ "github.com/tiger1103/gfast/v3/internal/app/common/logic/sysConfig" + _ "github.com/tiger1103/gfast/v3/internal/app/common/logic/sysDictData" + _ "github.com/tiger1103/gfast/v3/internal/app/common/logic/sysDictType" + _ "github.com/tiger1103/gfast/v3/internal/app/common/logic/upload" +) diff --git a/internal/app/common/logic/middleware/middleware.go b/internal/app/common/logic/middleware/middleware.go new file mode 100644 index 0000000..7d25fa4 --- /dev/null +++ b/internal/app/common/logic/middleware/middleware.go @@ -0,0 +1,31 @@ +/* +* @desc:中间件处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/28 9:08 + */ + +package middleware + +import ( + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast/v3/internal/app/common/service" +) + +func init() { + service.RegisterMiddleware(New()) +} + +func New() *sMiddleware { + return &sMiddleware{} +} + +type sMiddleware struct{} + +func (s *sMiddleware) MiddlewareCORS(r *ghttp.Request) { + corsOptions := r.Response.DefaultCORSOptions() + // you can set options + //corsOptions.AllowDomain = []string{"goframe.org", "baidu.com"} + r.Response.CORS(corsOptions) + r.Middleware.Next() +} diff --git a/internal/app/common/logic/sysConfig/sys_config.go b/internal/app/common/logic/sysConfig/sys_config.go new file mode 100644 index 0000000..65eb167 --- /dev/null +++ b/internal/app/common/logic/sysConfig/sys_config.go @@ -0,0 +1,178 @@ +/* +* @desc:配置参数管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/28 9:13 + */ + +package sysConfig + +import ( + "context" + "errors" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + "github.com/tiger1103/gfast/v3/internal/app/common/dao" + "github.com/tiger1103/gfast/v3/internal/app/common/model/do" + "github.com/tiger1103/gfast/v3/internal/app/common/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/common/service" + systemConsts "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysConfig(New()) +} + +func New() *sSysConfig { + return &sSysConfig{} +} + +type sSysConfig struct { +} + +// List 系统参数列表 +func (s *sSysConfig) List(ctx context.Context, req *system.ConfigSearchReq) (res *system.ConfigSearchRes, err error) { + res = new(system.ConfigSearchRes) + err = g.Try(ctx, func(ctx context.Context) { + m := dao.SysConfig.Ctx(ctx) + if req != nil { + if req.ConfigName != "" { + m = m.Where("config_name like ?", "%"+req.ConfigName+"%") + } + if req.ConfigType != "" { + m = m.Where("config_type = ", gconv.Int(req.ConfigType)) + } + if req.ConfigKey != "" { + m = m.Where("config_key like ?", "%"+req.ConfigKey+"%") + } + if len(req.DateRange) > 0 { + m = m.Where("created_at >= ? AND created_at<=?", req.DateRange[0], req.DateRange[1]) + } + } + res.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取数据失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + res.CurrentPage = req.PageNum + if req.PageSize == 0 { + req.PageSize = systemConsts.PageSize + } + err = m.Page(req.PageNum, req.PageSize).Order("config_id asc").Scan(&res.List) + liberr.ErrIsNil(ctx, err, "获取数据失败") + }) + return +} + +func (s *sSysConfig) Add(ctx context.Context, req *system.ConfigAddReq, userId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = s.CheckConfigKeyUnique(ctx, req.ConfigKey) + liberr.ErrIsNil(ctx, err) + _, err = dao.SysConfig.Ctx(ctx).Insert(do.SysConfig{ + ConfigName: req.ConfigName, + ConfigKey: req.ConfigKey, + ConfigValue: req.ConfigValue, + ConfigType: req.ConfigType, + CreateBy: userId, + Remark: req.Remark, + }) + liberr.ErrIsNil(ctx, err, "添加系统参数失败") + //清除缓存 + service.Cache().RemoveByTag(ctx, consts.CacheSysConfigTag) + }) + return +} + +// CheckConfigKeyUnique 验证参数键名是否存在 +func (s *sSysConfig) CheckConfigKeyUnique(ctx context.Context, configKey string, configId ...int64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + data := (*entity.SysConfig)(nil) + m := dao.SysConfig.Ctx(ctx).Fields(dao.SysConfig.Columns().ConfigId).Where(dao.SysConfig.Columns().ConfigKey, configKey) + if len(configId) > 0 { + m = m.Where(dao.SysConfig.Columns().ConfigId+" != ?", configId[0]) + } + err = m.Scan(&data) + liberr.ErrIsNil(ctx, err, "校验失败") + if data != nil { + liberr.ErrIsNil(ctx, errors.New("参数键名重复")) + } + }) + return +} + +// Get 获取系统参数 +func (s *sSysConfig) Get(ctx context.Context, id int) (res *system.ConfigGetRes, err error) { + res = new(system.ConfigGetRes) + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysConfig.Ctx(ctx).WherePri(id).Scan(&res.Data) + liberr.ErrIsNil(ctx, err, "获取系统参数失败") + }) + return +} + +// Edit 修改系统参数 +func (s *sSysConfig) Edit(ctx context.Context, req *system.ConfigEditReq, userId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = s.CheckConfigKeyUnique(ctx, req.ConfigKey, req.ConfigId) + liberr.ErrIsNil(ctx, err) + _, err = dao.SysConfig.Ctx(ctx).WherePri(req.ConfigId).Update(do.SysConfig{ + ConfigName: req.ConfigName, + ConfigKey: req.ConfigKey, + ConfigValue: req.ConfigValue, + ConfigType: req.ConfigType, + UpdateBy: userId, + Remark: req.Remark, + }) + liberr.ErrIsNil(ctx, err, "修改系统参数失败") + //清除缓存 + service.Cache().RemoveByTag(ctx, consts.CacheSysConfigTag) + }) + return +} + +// Delete 删除系统参数 +func (s *sSysConfig) Delete(ctx context.Context, ids []int) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysConfig.Ctx(ctx).Delete(dao.SysConfig.Columns().ConfigId+" in (?)", ids) + liberr.ErrIsNil(ctx, err, "删除失败") + //清除缓存 + service.Cache().RemoveByTag(ctx, consts.CacheSysConfigTag) + }) + return +} + +// GetConfigByKey 通过key获取参数(从缓存获取) +func (s *sSysConfig) GetConfigByKey(ctx context.Context, key string) (config *entity.SysConfig, err error) { + if key == "" { + err = gerror.New("参数key不能为空") + return + } + cache := service.Cache() + cf := cache.Get(ctx, consts.CacheSysConfigTag+key) + if cf != nil && !cf.IsEmpty() { + err = gconv.Struct(cf, &config) + return + } + config, err = s.GetByKey(ctx, key) + if err != nil { + return + } + if config != nil { + cache.Set(ctx, consts.CacheSysConfigTag+key, config, 0, consts.CacheSysConfigTag) + } + return +} + +// GetByKey 通过key获取参数(从数据库获取) +func (s *sSysConfig) GetByKey(ctx context.Context, key string) (config *entity.SysConfig, err error) { + err = dao.SysConfig.Ctx(ctx).Where("config_key", key).Scan(&config) + if err != nil { + g.Log().Error(ctx, err) + err = gerror.New("获取配置失败") + } + return +} diff --git a/internal/app/common/logic/sysDictData/sys_dict_data.go b/internal/app/common/logic/sysDictData/sys_dict_data.go new file mode 100644 index 0000000..ded8f47 --- /dev/null +++ b/internal/app/common/logic/sysDictData/sys_dict_data.go @@ -0,0 +1,173 @@ +/* +* @desc:字典数据管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/28 9:22 + */ + +package sysDictData + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + "github.com/tiger1103/gfast/v3/internal/app/common/dao" + "github.com/tiger1103/gfast/v3/internal/app/common/model" + "github.com/tiger1103/gfast/v3/internal/app/common/model/do" + "github.com/tiger1103/gfast/v3/internal/app/common/service" + systemConsts "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysDictData(New()) +} + +func New() *sSysDictData { + return &sSysDictData{} +} + +type sSysDictData struct { +} + +// GetDictWithDataByType 通过字典键类型获取选项 +func (s *sSysDictData) GetDictWithDataByType(ctx context.Context, req *system.GetDictReq) (dict *system.GetDictRes, + err error) { + cache := service.Cache() + cacheKey := consts.CacheSysDict + "_" + req.DictType + //从缓存获取 + iDict := cache.GetOrSetFuncLock(ctx, cacheKey, func(ctx context.Context) (value interface{}, err error) { + err = g.Try(ctx, func(ctx context.Context) { + //从数据库获取 + dict = &system.GetDictRes{} + //获取类型数据 + err = dao.SysDictType.Ctx(ctx).Where(dao.SysDictType.Columns().DictType, req.DictType). + Where(dao.SysDictType.Columns().Status, 1).Fields(model.DictTypeRes{}).Scan(&dict.Info) + liberr.ErrIsNil(ctx, err, "获取字典类型失败") + err = dao.SysDictData.Ctx(ctx).Fields(model.DictDataRes{}). + Where(dao.SysDictData.Columns().DictType, req.DictType). + Order(dao.SysDictData.Columns().DictSort + " asc," + + dao.SysDictData.Columns().DictCode + " asc"). + Scan(&dict.Values) + liberr.ErrIsNil(ctx, err, "获取字典数据失败") + }) + value = dict + return + }, 0, consts.CacheSysDictTag) + if iDict != nil { + err = gconv.Struct(iDict, &dict) + if err != nil { + return + } + } + //设置给定的默认值 + for _, v := range dict.Values { + if req.DefaultValue != "" { + if gstr.Equal(req.DefaultValue, v.DictValue) { + v.IsDefault = 1 + } else { + v.IsDefault = 0 + } + } + } + return +} + +// List 获取字典数据 +func (s *sSysDictData) List(ctx context.Context, req *system.DictDataSearchReq) (res *system.DictDataSearchRes, err error) { + res = new(system.DictDataSearchRes) + err = g.Try(ctx, func(ctx context.Context) { + m := dao.SysDictData.Ctx(ctx) + if req != nil { + if req.DictLabel != "" { + m = m.Where(dao.SysDictData.Columns().DictLabel+" like ?", "%"+req.DictLabel+"%") + } + if req.Status != "" { + m = m.Where(dao.SysDictData.Columns().Status+" = ", gconv.Int(req.Status)) + } + if req.DictType != "" { + m = m.Where(dao.SysDictData.Columns().DictType+" = ?", req.DictType) + } + res.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取字典数据失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + res.CurrentPage = req.PageNum + } + if req.PageSize == 0 { + req.PageSize = systemConsts.PageSize + } + err = m.Page(req.PageNum, req.PageSize).Order(dao.SysDictData.Columns().DictSort + " asc," + + dao.SysDictData.Columns().DictCode + " asc").Scan(&res.List) + liberr.ErrIsNil(ctx, err, "获取字典数据失败") + }) + return +} + +func (s *sSysDictData) Add(ctx context.Context, req *system.DictDataAddReq, userId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysDictData.Ctx(ctx).Insert(do.SysDictData{ + DictSort: req.DictSort, + DictLabel: req.DictLabel, + DictValue: req.DictValue, + DictType: req.DictType, + CssClass: req.CssClass, + ListClass: req.ListClass, + IsDefault: req.IsDefault, + Status: req.Status, + CreateBy: userId, + Remark: req.Remark, + }) + liberr.ErrIsNil(ctx, err, "添加字典数据失败") + //清除缓存 + service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag) + }) + return +} + +// Get 获取字典数据 +func (s *sSysDictData) Get(ctx context.Context, dictCode uint) (res *system.DictDataGetRes, err error) { + res = new(system.DictDataGetRes) + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysDictData.Ctx(ctx).WherePri(dictCode).Scan(&res.Dict) + liberr.ErrIsNil(ctx, err, "获取字典数据失败") + }) + return +} + +// Edit 修改字典数据 +func (s *sSysDictData) Edit(ctx context.Context, req *system.DictDataEditReq, userId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysDictData.Ctx(ctx).WherePri(req.DictCode).Update(do.SysDictData{ + DictSort: req.DictSort, + DictLabel: req.DictLabel, + DictValue: req.DictValue, + DictType: req.DictType, + CssClass: req.CssClass, + ListClass: req.ListClass, + IsDefault: req.IsDefault, + Status: req.Status, + UpdateBy: userId, + Remark: req.Remark, + }) + liberr.ErrIsNil(ctx, err, "修改字典数据失败") + //清除缓存 + service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag) + }) + return +} + +// Delete 删除字典数据 +func (s *sSysDictData) Delete(ctx context.Context, ids []int) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysDictData.Ctx(ctx).Where(dao.SysDictData.Columns().DictCode+" in(?)", ids).Delete() + liberr.ErrIsNil(ctx, err, "删除字典数据失败") + //清除缓存 + service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag) + }) + return +} diff --git a/internal/app/common/logic/sysDictType/sys_dict_type.go b/internal/app/common/logic/sysDictType/sys_dict_type.go new file mode 100644 index 0000000..9657106 --- /dev/null +++ b/internal/app/common/logic/sysDictType/sys_dict_type.go @@ -0,0 +1,186 @@ +/* +* @desc:字典类型管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/28 9:26 + */ + +package sysDictType + +import ( + "context" + "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + "github.com/tiger1103/gfast/v3/internal/app/common/dao" + "github.com/tiger1103/gfast/v3/internal/app/common/model" + "github.com/tiger1103/gfast/v3/internal/app/common/model/do" + "github.com/tiger1103/gfast/v3/internal/app/common/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/common/service" + systemConsts "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysDictType(New()) +} + +func New() *sSysDictType { + return &sSysDictType{} +} + +type sSysDictType struct { +} + +// List 字典类型列表 +func (s *sSysDictType) List(ctx context.Context, req *system.DictTypeSearchReq) (res *system.DictTypeSearchRes, err error) { + res = new(system.DictTypeSearchRes) + err = g.Try(ctx, func(ctx context.Context) { + m := dao.SysDictType.Ctx(ctx) + if req.DictName != "" { + m = m.Where(dao.SysDictType.Columns().DictName+" like ?", "%"+req.DictName+"%") + } + if req.DictType != "" { + m = m.Where(dao.SysDictType.Columns().DictType+" like ?", "%"+req.DictType+"%") + } + if req.Status != "" { + m = m.Where(dao.SysDictType.Columns().Status+" = ", gconv.Int(req.Status)) + } + res.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取字典类型失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + res.CurrentPage = req.PageNum + if req.PageSize == 0 { + req.PageSize = systemConsts.PageSize + } + err = m.Fields(model.SysDictTypeInfoRes{}).Page(req.PageNum, req.PageSize). + Order(dao.SysDictType.Columns().DictId + " asc").Scan(&res.DictTypeList) + liberr.ErrIsNil(ctx, err, "获取字典类型失败") + }) + return +} + +// Add 添加字典类型 +func (s *sSysDictType) Add(ctx context.Context, req *system.DictTypeAddReq, userId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = s.ExistsDictType(ctx, req.DictType) + liberr.ErrIsNil(ctx, err) + _, err = dao.SysDictType.Ctx(ctx).Insert(do.SysDictType{ + DictName: req.DictName, + DictType: req.DictType, + Status: req.Status, + CreateBy: userId, + Remark: req.Remark, + }) + liberr.ErrIsNil(ctx, err, "添加字典类型失败") + //清除缓存 + service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag) + }) + return +} + +// Edit 修改字典类型 +func (s *sSysDictType) Edit(ctx context.Context, req *system.DictTypeEditReq, userId uint64) (err error) { + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + err = s.ExistsDictType(ctx, req.DictType, req.DictId) + liberr.ErrIsNil(ctx, err) + dictType := (*entity.SysDictType)(nil) + e := dao.SysDictType.Ctx(ctx).Fields(dao.SysDictType.Columns().DictType).WherePri(req.DictId).Scan(&dictType) + liberr.ErrIsNil(ctx, e, "获取字典类型失败") + liberr.ValueIsNil(dictType, "字典类型不存在") + //修改字典类型 + _, e = dao.SysDictType.Ctx(ctx).TX(tx).WherePri(req.DictId).Update(do.SysDictType{ + DictName: req.DictName, + DictType: req.DictType, + Status: req.Status, + UpdateBy: userId, + Remark: req.Remark, + }) + liberr.ErrIsNil(ctx, e, "修改字典类型失败") + //修改字典数据 + _, e = dao.SysDictData.Ctx(ctx).TX(tx).Data(do.SysDictData{DictType: req.DictType}). + Where(dao.SysDictData.Columns().DictType, dictType.DictType).Update() + liberr.ErrIsNil(ctx, e, "修改字典数据失败") + //清除缓存 + service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag) + }) + return err + }) + return +} + +func (s *sSysDictType) Get(ctx context.Context, req *system.DictTypeGetReq) (dictType *entity.SysDictType, err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysDictType.Ctx(ctx).Where(dao.SysDictType.Columns().DictId, req.DictId).Scan(&dictType) + liberr.ErrIsNil(ctx, err, "获取字典类型失败") + }) + return +} + +// ExistsDictType 检查类型是否已经存在 +func (s *sSysDictType) ExistsDictType(ctx context.Context, dictType string, dictId ...int64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + m := dao.SysDictType.Ctx(ctx).Fields(dao.SysDictType.Columns().DictId). + Where(dao.SysDictType.Columns().DictType, dictType) + if len(dictId) > 0 { + m = m.Where(dao.SysDictType.Columns().DictId+" !=? ", dictId[0]) + } + res, e := m.One() + liberr.ErrIsNil(ctx, e, "sql err") + if !res.IsEmpty() { + liberr.ErrIsNil(ctx, gerror.New("字典类型已存在")) + } + }) + return +} + +// Delete 删除字典类型 +func (s *sSysDictType) Delete(ctx context.Context, dictIds []int) (err error) { + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + discs := ([]*entity.SysDictType)(nil) + err = dao.SysDictType.Ctx(ctx).Fields(dao.SysDictType.Columns().DictType). + Where(dao.SysDictType.Columns().DictId+" in (?) ", dictIds).Scan(&discs) + liberr.ErrIsNil(ctx, err, "删除失败") + types := garray.NewStrArray() + for _, dt := range discs { + types.Append(dt.DictType) + } + if types.Len() > 0 { + _, err = dao.SysDictType.Ctx(ctx).TX(tx).Delete(dao.SysDictType.Columns().DictId+" in (?) ", dictIds) + liberr.ErrIsNil(ctx, err, "删除类型失败") + _, err = dao.SysDictData.Ctx(ctx).TX(tx).Delete(dao.SysDictData.Columns().DictType+" in (?) ", types.Slice()) + liberr.ErrIsNil(ctx, err, "删除字典数据失败") + } + //清除缓存 + service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag) + }) + return err + }) + return +} + +// GetAllDictType 获取所有正常状态下的字典类型 +func (s *sSysDictType) GetAllDictType(ctx context.Context) (list []*entity.SysDictType, err error) { + cache := service.Cache() + //从缓存获取 + data := cache.Get(ctx, consts.CacheSysDict+"_dict_type_all") + if !data.IsNil() { + err = data.Structs(&list) + return + } + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysDictType.Ctx(ctx).Where("status", 1).Order("dict_id ASC").Scan(&list) + liberr.ErrIsNil(ctx, err, "获取字典类型数据出错") + //缓存 + cache.Set(ctx, consts.CacheSysDict+"_dict_type_all", list, 0, consts.CacheSysDictTag) + }) + return +} diff --git a/internal/app/common/logic/upload/upload.go b/internal/app/common/logic/upload/upload.go new file mode 100644 index 0000000..8e5e1c4 --- /dev/null +++ b/internal/app/common/logic/upload/upload.go @@ -0,0 +1,201 @@ +/* +* @desc:上传处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/28 9:37 + */ + +package upload + +import ( + "context" + "errors" + "fmt" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + "github.com/tiger1103/gfast/v3/internal/app/common/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/library/upload" +) + +func init() { + service.RegisterUpload(New()) +} + +func New() *sUpload { + return &sUpload{} +} + +type sUpload struct{} + +// UploadFiles 上传多文件 +func (s *sUpload) UploadFiles(ctx context.Context, files []*ghttp.UploadFile, checkFileType string, source int) (result system.UploadMultipleRes, err error) { + for _, item := range files { + f, e := s.UploadFile(ctx, item, checkFileType, source) + if e != nil { + return + } + result = append(result, &f) + } + return +} + +// UploadFile 上传单文件 +func (s *sUpload) UploadFile(ctx context.Context, file *ghttp.UploadFile, checkFileType string, source int) (result system.UploadResponse, err error) { + + // 检查文件类型 + err = s.CheckType(ctx, checkFileType, file) + if err != nil { + return + } + + // 检查文件大小 + err = s.CheckSize(ctx, checkFileType, file) + if err != nil { + return + } + + uploader := upload.GetUploader(upload.UploaderType(source)) + if uploader == nil { + err = errors.New("没有找到上传适配器") + return + } + return uploader.Upload(ctx, file) +} + +// CheckSize 检查上传文件大小 +func (s *sUpload) CheckSize(ctx context.Context, checkFileType string, file *ghttp.UploadFile) (err error) { + + var ( + configSize *entity.SysConfig + ) + + if checkFileType == consts.CheckFileTypeFile { + + //获取上传大小配置 + configSize, err = s.getUpConfig(ctx, consts.FileSizeKey) + if err != nil { + return + } + } else if checkFileType == consts.CheckFileTypeImg { + + //获取上传大小配置 + configSize, err = s.getUpConfig(ctx, consts.ImgSizeKey) + if err != nil { + return + } + } else { + return errors.New(fmt.Sprintf("文件检查类型错误:%s|%s", consts.CheckFileTypeFile, consts.CheckFileTypeImg)) + } + + var rightSize bool + rightSize, err = s.checkSize(configSize.ConfigValue, file.Size) + if err != nil { + return + } + if !rightSize { + err = gerror.New("上传文件超过最大尺寸:" + configSize.ConfigValue) + return + } + return +} + +// CheckType 检查上传文件类型 +func (s *sUpload) CheckType(ctx context.Context, checkFileType string, file *ghttp.UploadFile) (err error) { + + var ( + configType *entity.SysConfig + ) + + if checkFileType == consts.CheckFileTypeFile { + //获取上传类型配置 + configType, err = s.getUpConfig(ctx, consts.FileTypeKey) + if err != nil { + return + } + + } else if checkFileType == consts.CheckFileTypeImg { + //获取上传类型配置 + configType, err = s.getUpConfig(ctx, consts.ImgTypeKey) + if err != nil { + return + } + } else { + return errors.New(fmt.Sprintf("文件检查类型错误:%s|%s", consts.CheckFileTypeFile, consts.CheckFileTypeImg)) + } + + rightType := s.checkFileType(file.Filename, configType.ConfigValue) + if !rightType { + err = gerror.New("上传文件类型错误,只能包含后缀为:" + configType.ConfigValue + "的文件。") + return + } + return +} + +// 获取上传配置 +func (s *sUpload) getUpConfig(ctx context.Context, key string) (config *entity.SysConfig, err error) { + config, err = service.SysConfig().GetConfigByKey(ctx, key) + if err != nil { + return + } + if config == nil { + err = gerror.New("上传文件类型未设置,请在后台配置") + return + } + return +} + +// 判断上传文件类型是否合法 +func (s *sUpload) checkFileType(fileName, typeString string) bool { + suffix := gstr.SubStrRune(fileName, gstr.PosRRune(fileName, ".")+1, gstr.LenRune(fileName)-1) + imageType := gstr.Split(typeString, ",") + rightType := false + for _, v := range imageType { + if gstr.Equal(suffix, v) { + rightType = true + break + } + } + return rightType +} + +// 检查文件大小是否合法 +func (s *sUpload) checkSize(configSize string, fileSize int64) (bool, error) { + match, err := gregex.MatchString(`^([0-9]+)(?i:([a-z]*))$`, configSize) + if err != nil { + return false, err + } + if len(match) == 0 { + err = gerror.New("上传文件大小未设置,请在后台配置,格式为(30M,30k,30MB)") + return false, err + } + var cfSize int64 + switch gstr.ToUpper(match[2]) { + case "MB", "M": + cfSize = gconv.Int64(match[1]) * 1024 * 1024 + case "KB", "K": + cfSize = gconv.Int64(match[1]) * 1024 + case "": + cfSize = gconv.Int64(match[1]) + } + if cfSize == 0 { + err = gerror.New("上传文件大小未设置,请在后台配置,格式为(30M,30k,30MB),最大单位为MB") + return false, err + } + return cfSize >= fileSize, nil +} + +// 静态文件夹目录 +func (s *sUpload) getStaticPath(ctx context.Context) string { + value, _ := g.Cfg().Get(ctx, "server.serverRoot") + if !value.IsEmpty() { + return value.String() + } + return "" +} diff --git a/internal/app/common/model/do/casbin_rule.go b/internal/app/common/model/do/casbin_rule.go new file mode 100644 index 0000000..3e9ec42 --- /dev/null +++ b/internal/app/common/model/do/casbin_rule.go @@ -0,0 +1,21 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// CasbinRule is the golang structure of table casbin_rule for DAO operations like Where/Data. +type CasbinRule struct { + g.Meta `orm:"table:casbin_rule, do:true"` + Ptype interface{} // + V0 interface{} // + V1 interface{} // + V2 interface{} // + V3 interface{} // + V4 interface{} // + V5 interface{} // +} diff --git a/internal/app/common/model/do/sys_config.go b/internal/app/common/model/do/sys_config.go new file mode 100644 index 0000000..c8d2aff --- /dev/null +++ b/internal/app/common/model/do/sys_config.go @@ -0,0 +1,25 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-18 21:09:17 +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysConfig is the golang structure of table sys_config for DAO operations like Where/Data. +type SysConfig struct { + g.Meta `orm:"table:sys_config, do:true"` + ConfigId interface{} // 参数主键 + ConfigName interface{} // 参数名称 + ConfigKey interface{} // 参数键名 + ConfigValue interface{} // 参数键值 + ConfigType interface{} // 系统内置(Y是 N否) + CreateBy interface{} // 创建者 + UpdateBy interface{} // 更新者 + Remark interface{} // 备注 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 修改时间 +} diff --git a/internal/app/common/model/do/sys_dict_data.go b/internal/app/common/model/do/sys_dict_data.go new file mode 100644 index 0000000..dc355eb --- /dev/null +++ b/internal/app/common/model/do/sys_dict_data.go @@ -0,0 +1,29 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52 +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDictData is the golang structure of table sys_dict_data for DAO operations like Where/Data. +type SysDictData struct { + g.Meta `orm:"table:sys_dict_data, do:true"` + DictCode interface{} // 字典编码 + DictSort interface{} // 字典排序 + DictLabel interface{} // 字典标签 + DictValue interface{} // 字典键值 + DictType interface{} // 字典类型 + CssClass interface{} // 样式属性(其他样式扩展) + ListClass interface{} // 表格回显样式 + IsDefault interface{} // 是否默认(1是 0否) + Status interface{} // 状态(0正常 1停用) + CreateBy interface{} // 创建者 + UpdateBy interface{} // 更新者 + Remark interface{} // 备注 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 修改时间 +} diff --git a/internal/app/common/model/do/sys_dict_type.go b/internal/app/common/model/do/sys_dict_type.go new file mode 100644 index 0000000..682264d --- /dev/null +++ b/internal/app/common/model/do/sys_dict_type.go @@ -0,0 +1,24 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52 +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDictType is the golang structure of table sys_dict_type for DAO operations like Where/Data. +type SysDictType struct { + g.Meta `orm:"table:sys_dict_type, do:true"` + DictId interface{} // 字典主键 + DictName interface{} // 字典名称 + DictType interface{} // 字典类型 + Status interface{} // 状态(0正常 1停用) + CreateBy interface{} // 创建者 + UpdateBy interface{} // 更新者 + Remark interface{} // 备注 + CreatedAt *gtime.Time // 创建日期 + UpdatedAt *gtime.Time // 修改日期 +} diff --git a/internal/app/common/model/entity/casbin_rule.go b/internal/app/common/model/entity/casbin_rule.go new file mode 100644 index 0000000..99ad458 --- /dev/null +++ b/internal/app/common/model/entity/casbin_rule.go @@ -0,0 +1,16 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// CasbinRule is the golang structure for table casbin_rule. +type CasbinRule struct { + Ptype string `json:"ptype" description:""` + V0 string `json:"v0" description:""` + V1 string `json:"v1" description:""` + V2 string `json:"v2" description:""` + V3 string `json:"v3" description:""` + V4 string `json:"v4" description:""` + V5 string `json:"v5" description:""` +} diff --git a/internal/app/common/model/entity/sys_config.go b/internal/app/common/model/entity/sys_config.go new file mode 100644 index 0000000..cb3e446 --- /dev/null +++ b/internal/app/common/model/entity/sys_config.go @@ -0,0 +1,23 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-18 21:09:17 +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysConfig is the golang structure for table sys_config. +type SysConfig struct { + ConfigId uint `json:"configId" description:"参数主键"` + ConfigName string `json:"configName" description:"参数名称"` + ConfigKey string `json:"configKey" description:"参数键名"` + ConfigValue string `json:"configValue" description:"参数键值"` + ConfigType int `json:"configType" description:"系统内置(Y是 N否)"` + CreateBy uint `json:"createBy" description:"创建者"` + UpdateBy uint `json:"updateBy" description:"更新者"` + Remark string `json:"remark" description:"备注"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"` +} diff --git a/internal/app/common/model/entity/sys_dict_data.go b/internal/app/common/model/entity/sys_dict_data.go new file mode 100644 index 0000000..e1ebfa1 --- /dev/null +++ b/internal/app/common/model/entity/sys_dict_data.go @@ -0,0 +1,27 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52 +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDictData is the golang structure for table sys_dict_data. +type SysDictData struct { + DictCode int64 `json:"dictCode" description:"字典编码"` + DictSort int `json:"dictSort" description:"字典排序"` + DictLabel string `json:"dictLabel" description:"字典标签"` + DictValue string `json:"dictValue" description:"字典键值"` + DictType string `json:"dictType" description:"字典类型"` + CssClass string `json:"cssClass" description:"样式属性(其他样式扩展)"` + ListClass string `json:"listClass" description:"表格回显样式"` + IsDefault int `json:"isDefault" description:"是否默认(1是 0否)"` + Status int `json:"status" description:"状态(0正常 1停用)"` + CreateBy uint64 `json:"createBy" description:"创建者"` + UpdateBy uint64 `json:"updateBy" description:"更新者"` + Remark string `json:"remark" description:"备注"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"` +} diff --git a/internal/app/common/model/entity/sys_dict_type.go b/internal/app/common/model/entity/sys_dict_type.go new file mode 100644 index 0000000..142d2f8 --- /dev/null +++ b/internal/app/common/model/entity/sys_dict_type.go @@ -0,0 +1,22 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52 +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDictType is the golang structure for table sys_dict_type. +type SysDictType struct { + DictId uint64 `json:"dictId" description:"字典主键"` + DictName string `json:"dictName" description:"字典名称"` + DictType string `json:"dictType" description:"字典类型"` + Status uint `json:"status" description:"状态(0正常 1停用)"` + CreateBy uint `json:"createBy" description:"创建者"` + UpdateBy uint `json:"updateBy" description:"更新者"` + Remark string `json:"remark" description:"备注"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建日期"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改日期"` +} diff --git a/internal/app/common/model/sys_config.go b/internal/app/common/model/sys_config.go new file mode 100644 index 0000000..737fb8f --- /dev/null +++ b/internal/app/common/model/sys_config.go @@ -0,0 +1,8 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:56 + */ + +package model diff --git a/internal/app/common/model/sys_dict_data.go b/internal/app/common/model/sys_dict_data.go new file mode 100644 index 0000000..ce8434c --- /dev/null +++ b/internal/app/common/model/sys_dict_data.go @@ -0,0 +1,21 @@ +/* +* @desc:字典数据 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:56 + */ + +package model + +type DictTypeRes struct { + DictName string `json:"name"` + Remark string `json:"remark"` +} + +// DictDataRes 字典数据 +type DictDataRes struct { + DictValue string `json:"key"` + DictLabel string `json:"value"` + IsDefault int `json:"isDefault"` + Remark string `json:"remark"` +} diff --git a/internal/app/common/model/sys_dict_type.go b/internal/app/common/model/sys_dict_type.go new file mode 100644 index 0000000..0ff6150 --- /dev/null +++ b/internal/app/common/model/sys_dict_type.go @@ -0,0 +1,19 @@ +/* +* @desc:字典类型 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:56 + */ + +package model + +import "github.com/gogf/gf/v2/os/gtime" + +type SysDictTypeInfoRes struct { + DictId uint64 `orm:"dict_id,primary" json:"dictId"` // 字典主键 + DictName string `orm:"dict_name" json:"dictName"` // 字典名称 + DictType string `orm:"dict_type,unique" json:"dictType"` // 字典类型 + Status uint `orm:"status" json:"status"` // 状态(0正常 1停用) + Remark string `orm:"remark" json:"remark"` // 备注 + CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` // 创建日期 +} diff --git a/internal/app/common/model/token.go b/internal/app/common/model/token.go new file mode 100644 index 0000000..288e72d --- /dev/null +++ b/internal/app/common/model/token.go @@ -0,0 +1,32 @@ +/* +* @desc:token options +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/8 16:02 + */ + +package model + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +type TokenOptions struct { + // server name + ServerName string `json:"serverName"` + // 缓存key (每创建一个实例CacheKey必须不相同) + CacheKey string `json:"cacheKey"` + // 超时时间 默认10天(秒) + Timeout int64 `json:"timeout"` + // 缓存刷新时间 默认5天(秒) + // 处理携带token的请求时当前时间大于超时时间并小于缓存刷新时间时token将自动刷新即重置token存活时间 + // MaxRefresh值为0时,token将不会自动刷新 + MaxRefresh int64 `json:"maxRefresh"` + // 是否允许多点登录 + MultiLogin bool `json:"multiLogin"` + // Token加密key 32位 + EncryptKey []byte `json:"encryptKey"` + // 拦截排除地址 + ExcludePaths g.SliceStr `json:"excludePaths"` + CacheModel string `json:"cacheModel"` +} diff --git a/internal/app/common/model/upload.go b/internal/app/common/model/upload.go new file mode 100644 index 0000000..65a27e1 --- /dev/null +++ b/internal/app/common/model/upload.go @@ -0,0 +1,15 @@ +/* +* @desc:上传文件model +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/12/6 15:29 + */ + +package model + +type UpFile struct { + Name string `json:"name"` + Url string `json:"url"` + FileType string `json:"fileType"` + Size uint64 `json:"size"` +} diff --git a/internal/app/common/router/router.go b/internal/app/common/router/router.go new file mode 100644 index 0000000..4519158 --- /dev/null +++ b/internal/app/common/router/router.go @@ -0,0 +1,28 @@ +/* +* @desc:后台路由 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/2/18 17:34 + */ + +package router + +import ( + "context" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast/v3/internal/app/common/controller" +) + +var R = new(Router) + +type Router struct{} + +func (router *Router) BindController(ctx context.Context, group *ghttp.RouterGroup) { + group.Group("/pub", func(group *ghttp.RouterGroup) { + group.Group("/captcha", func(group *ghttp.RouterGroup) { + group.Bind( + controller.Captcha, + ) + }) + }) +} diff --git a/internal/app/common/service/big_upload.go b/internal/app/common/service/big_upload.go new file mode 100644 index 0000000..c246ad2 --- /dev/null +++ b/internal/app/common/service/big_upload.go @@ -0,0 +1,30 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" +) + +type IBigUpload interface { + Upload(ctx context.Context, req *system.BigUploadReq) (res *system.BigUploadRes, err error) + UploadCheck(ctx context.Context, req *system.BigUploadCheckReq) (res *system.BigUploadCheckRes, err error) + UploadMerge(ctx context.Context, req *system.BigUploadMergeReq) (res *system.BigUploadRes, err error) +} + +var localBigUpload IBigUpload + +func BigUpload() IBigUpload { + if localBigUpload == nil { + panic("implement not found for interface IBigUpload, forgot register?") + } + return localBigUpload +} + +func RegisterBigUpload(i IBigUpload) { + localBigUpload = i +} diff --git a/internal/app/common/service/cache.go b/internal/app/common/service/cache.go new file mode 100644 index 0000000..5580e74 --- /dev/null +++ b/internal/app/common/service/cache.go @@ -0,0 +1,29 @@ +/* +* @desc:缓存处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/9 11:15 + */ + +package service + +import ( + "github.com/tiger1103/gfast-cache/cache" +) + +type ICache interface { + cache.IGCache +} + +var c ICache + +func Cache() ICache { + if c == nil { + panic("implement not found for interface ICache, forgot register?") + } + return c +} + +func RegisterCache(che ICache) { + c = che +} diff --git a/internal/app/common/service/captcha.go b/internal/app/common/service/captcha.go new file mode 100644 index 0000000..c5227de --- /dev/null +++ b/internal/app/common/service/captcha.go @@ -0,0 +1,28 @@ +// ================================================================================ +// Code generated 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 ICaptcha interface { + GetVerifyImgString(ctx context.Context) (idKeyC string, base64stringC string, err error) + VerifyString(id, answer string) bool +} + +var localCaptcha ICaptcha + +func Captcha() ICaptcha { + if localCaptcha == nil { + panic("implement not found for interface ICaptcha, forgot register?") + } + return localCaptcha +} + +func RegisterCaptcha(i ICaptcha) { + localCaptcha = i +} diff --git a/internal/app/common/service/casbin.go b/internal/app/common/service/casbin.go new file mode 100644 index 0000000..fdbdf6f --- /dev/null +++ b/internal/app/common/service/casbin.go @@ -0,0 +1,220 @@ +package service + +import ( + "context" + "sync" + + "github.com/casbin/casbin/v2" + "github.com/casbin/casbin/v2/model" + "github.com/casbin/casbin/v2/persist" + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/internal/app/common/dao" + "github.com/tiger1103/gfast/v3/internal/app/common/model/entity" +) + +type cabinImpl struct{} + +type adapterCasbin struct { + Enforcer *casbin.SyncedEnforcer + EnforcerErr error + ctx context.Context +} + +var ( + cb = cabinImpl{} + once sync.Once + ac *adapterCasbin +) + +// CasbinEnforcer 获取adapter单例对象 +func CasbinEnforcer(ctx context.Context) (enforcer *casbin.SyncedEnforcer, err error) { + once.Do(func() { + ac = cb.newAdapter(ctx) + }) + enforcer = ac.Enforcer + err = ac.EnforcerErr + return +} + +// 初始化adapter操作 +func (s *cabinImpl) newAdapter(ctx context.Context) (a *adapterCasbin) { + a = new(adapterCasbin) + a.initPolicy(ctx) + a.ctx = ctx + return +} + +func (a *adapterCasbin) initPolicy(ctx context.Context) { + // Because the DB is empty at first, + // so we need to load the policy from the file adapter (.CSV) first. + e, err := casbin.NewSyncedEnforcer(g.Cfg().MustGet(ctx, "casbin.modelFile").String(), a) + if err != nil { + a.EnforcerErr = err + return + } + a.Enforcer = e +} + +// SavePolicy saves policy to database. +func (a *adapterCasbin) SavePolicy(model model.Model) (err error) { + err = a.dropTable() + if err != nil { + return + } + err = a.createTable() + if err != nil { + return + } + for ptype, ast := range model["p"] { + for _, rule := range ast.Policy { + line := savePolicyLine(ptype, rule) + _, err := dao.CasbinRule.Ctx(a.ctx).Data(line).Insert() + if err != nil { + return err + } + } + } + + for ptype, ast := range model["g"] { + for _, rule := range ast.Policy { + line := savePolicyLine(ptype, rule) + _, err := dao.CasbinRule.Ctx(a.ctx).Data(line).Insert() + if err != nil { + return err + } + } + } + return +} + +func (a *adapterCasbin) dropTable() (err error) { + return +} + +func (a *adapterCasbin) createTable() (err error) { + return +} + +// LoadPolicy loads policy from database. +func (a *adapterCasbin) LoadPolicy(model model.Model) error { + var lines []*entity.CasbinRule + if err := dao.CasbinRule.Ctx(a.ctx).Scan(&lines); err != nil { + return err + } + for _, line := range lines { + loadPolicyLine(line, model) + } + return nil +} + +// AddPolicy adds a policy rule to the storage. +func (a *adapterCasbin) AddPolicy(sec string, ptype string, rule []string) error { + line := savePolicyLine(ptype, rule) + _, err := dao.CasbinRule.Ctx(a.ctx).Data(line).Insert() + return err +} + +// RemovePolicy removes a policy rule from the storage. +func (a *adapterCasbin) RemovePolicy(sec string, ptype string, rule []string) error { + line := savePolicyLine(ptype, rule) + err := rawDelete(a, line) + return err +} + +// RemoveFilteredPolicy removes policy rules that match the filter from the storage. +func (a *adapterCasbin) RemoveFilteredPolicy(sec string, ptype string, + fieldIndex int, fieldValues ...string) error { + line := &entity.CasbinRule{} + line.Ptype = ptype + if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) { + line.V0 = fieldValues[0-fieldIndex] + } + if fieldIndex <= 1 && 1 < fieldIndex+len(fieldValues) { + line.V1 = fieldValues[1-fieldIndex] + } + if fieldIndex <= 2 && 2 < fieldIndex+len(fieldValues) { + line.V2 = fieldValues[2-fieldIndex] + } + if fieldIndex <= 3 && 3 < fieldIndex+len(fieldValues) { + line.V3 = fieldValues[3-fieldIndex] + } + if fieldIndex <= 4 && 4 < fieldIndex+len(fieldValues) { + line.V4 = fieldValues[4-fieldIndex] + } + if fieldIndex <= 5 && 5 < fieldIndex+len(fieldValues) { + line.V5 = fieldValues[5-fieldIndex] + } + err := rawDelete(a, line) + return err +} + +func loadPolicyLine(line *entity.CasbinRule, model model.Model) { + lineText := line.Ptype + if line.V0 != "" { + lineText += ", " + line.V0 + } + if line.V1 != "" { + lineText += ", " + line.V1 + } + if line.V2 != "" { + lineText += ", " + line.V2 + } + if line.V3 != "" { + lineText += ", " + line.V3 + } + if line.V4 != "" { + lineText += ", " + line.V4 + } + if line.V5 != "" { + lineText += ", " + line.V5 + } + persist.LoadPolicyLine(lineText, model) +} + +func savePolicyLine(ptype string, rule []string) *entity.CasbinRule { + line := &entity.CasbinRule{} + line.Ptype = ptype + if len(rule) > 0 { + line.V0 = rule[0] + } + if len(rule) > 1 { + line.V1 = rule[1] + } + if len(rule) > 2 { + line.V2 = rule[2] + } + if len(rule) > 3 { + line.V3 = rule[3] + } + if len(rule) > 4 { + line.V4 = rule[4] + } + if len(rule) > 5 { + line.V5 = rule[5] + } + return line +} + +func rawDelete(a *adapterCasbin, line *entity.CasbinRule) error { + db := dao.CasbinRule.Ctx(a.ctx).Where("ptype = ?", line.Ptype) + if line.V0 != "" { + db = db.Where("v0 = ?", line.V0) + } + if line.V1 != "" { + db = db.Where("v1 = ?", line.V1) + } + if line.V2 != "" { + db = db.Where("v2 = ?", line.V2) + } + if line.V3 != "" { + db = db.Where("v3 = ?", line.V3) + } + if line.V4 != "" { + db = db.Where("v4 = ?", line.V4) + } + if line.V5 != "" { + db = db.Where("v5 = ?", line.V5) + } + _, err := db.Delete() + return err +} diff --git a/internal/app/common/service/middleware.go b/internal/app/common/service/middleware.go new file mode 100644 index 0000000..da88600 --- /dev/null +++ b/internal/app/common/service/middleware.go @@ -0,0 +1,27 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "github.com/gogf/gf/v2/net/ghttp" +) + +type IMiddleware interface { + MiddlewareCORS(r *ghttp.Request) +} + +var localMiddleware IMiddleware + +func Middleware() IMiddleware { + if localMiddleware == nil { + panic("implement not found for interface IMiddleware, forgot register?") + } + return localMiddleware +} + +func RegisterMiddleware(i IMiddleware) { + localMiddleware = i +} diff --git a/internal/app/common/service/sys_config.go b/internal/app/common/service/sys_config.go new file mode 100644 index 0000000..5154005 --- /dev/null +++ b/internal/app/common/service/sys_config.go @@ -0,0 +1,37 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/model/entity" +) + +type ISysConfig interface { + List(ctx context.Context, req *system.ConfigSearchReq) (res *system.ConfigSearchRes, err error) + Add(ctx context.Context, req *system.ConfigAddReq, userId uint64) (err error) + CheckConfigKeyUnique(ctx context.Context, configKey string, configId ...int64) (err error) + Get(ctx context.Context, id int) (res *system.ConfigGetRes, err error) + Edit(ctx context.Context, req *system.ConfigEditReq, userId uint64) (err error) + Delete(ctx context.Context, ids []int) (err error) + GetConfigByKey(ctx context.Context, key string) (config *entity.SysConfig, err error) + GetByKey(ctx context.Context, key string) (config *entity.SysConfig, err error) +} + +var localSysConfig ISysConfig + +func SysConfig() ISysConfig { + if localSysConfig == nil { + panic("implement not found for interface ISysConfig, forgot register?") + } + return localSysConfig +} + +func RegisterSysConfig(i ISysConfig) { + localSysConfig = i +} diff --git a/internal/app/common/service/sys_dict_data.go b/internal/app/common/service/sys_dict_data.go new file mode 100644 index 0000000..76eb180 --- /dev/null +++ b/internal/app/common/service/sys_dict_data.go @@ -0,0 +1,34 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" +) + +type ISysDictData interface { + GetDictWithDataByType(ctx context.Context, req *system.GetDictReq) (dict *system.GetDictRes, err error) + List(ctx context.Context, req *system.DictDataSearchReq) (res *system.DictDataSearchRes, err error) + Add(ctx context.Context, req *system.DictDataAddReq, userId uint64) (err error) + Get(ctx context.Context, dictCode uint) (res *system.DictDataGetRes, err error) + Edit(ctx context.Context, req *system.DictDataEditReq, userId uint64) (err error) + Delete(ctx context.Context, ids []int) (err error) +} + +var localSysDictData ISysDictData + +func SysDictData() ISysDictData { + if localSysDictData == nil { + panic("implement not found for interface ISysDictData, forgot register?") + } + return localSysDictData +} + +func RegisterSysDictData(i ISysDictData) { + localSysDictData = i +} diff --git a/internal/app/common/service/sys_dict_type.go b/internal/app/common/service/sys_dict_type.go new file mode 100644 index 0000000..ed905e3 --- /dev/null +++ b/internal/app/common/service/sys_dict_type.go @@ -0,0 +1,36 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/model/entity" +) + +type ISysDictType interface { + List(ctx context.Context, req *system.DictTypeSearchReq) (res *system.DictTypeSearchRes, err error) + Add(ctx context.Context, req *system.DictTypeAddReq, userId uint64) (err error) + Edit(ctx context.Context, req *system.DictTypeEditReq, userId uint64) (err error) + Get(ctx context.Context, req *system.DictTypeGetReq) (dictType *entity.SysDictType, err error) + ExistsDictType(ctx context.Context, dictType string, dictId ...int64) (err error) + Delete(ctx context.Context, dictIds []int) (err error) + GetAllDictType(ctx context.Context) (list []*entity.SysDictType, err error) +} + +var localSysDictType ISysDictType + +func SysDictType() ISysDictType { + if localSysDictType == nil { + panic("implement not found for interface ISysDictType, forgot register?") + } + return localSysDictType +} + +func RegisterSysDictType(i ISysDictType) { + localSysDictType = i +} diff --git a/internal/app/common/service/upload.go b/internal/app/common/service/upload.go new file mode 100644 index 0000000..ac17829 --- /dev/null +++ b/internal/app/common/service/upload.go @@ -0,0 +1,33 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + + "github.com/gogf/gf/v2/net/ghttp" +) + +type IUpload interface { + UploadFiles(ctx context.Context, files []*ghttp.UploadFile, checkFileType string, source int) (result system.UploadMultipleRes, err error) + UploadFile(ctx context.Context, file *ghttp.UploadFile, checkFileType string, source int) (result system.UploadResponse, err error) + CheckSize(ctx context.Context, checkFileType string, file *ghttp.UploadFile) (err error) + CheckType(ctx context.Context, checkFileType string, file *ghttp.UploadFile) (err error) +} + +var localUpload IUpload + +func Upload() IUpload { + if localUpload == nil { + panic("implement not found for interface IUpload, forgot register?") + } + return localUpload +} + +func RegisterUpload(i IUpload) { + localUpload = i +} diff --git a/internal/app/system/consts/cache.go b/internal/app/system/consts/cache.go new file mode 100644 index 0000000..7bc5ea4 --- /dev/null +++ b/internal/app/system/consts/cache.go @@ -0,0 +1,29 @@ +/* +* @desc:缓存键 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/9 12:06 + */ + +package consts + +const ( + // CacheSysAuthMenu 缓存菜单key + CacheSysAuthMenu = "sysAuthMenu" + // CacheSysDept 缓存部门key + CacheSysDept = "sysDept" + + // CacheSysRole 角色缓存key + CacheSysRole = "sysRole" + // CacheSysWebSet 站点配置缓存key + CacheSysWebSet = "sysWebSet" + // CacheSysCmsMenu cms缓存key + CacheSysCmsMenu = "sysCmsMenu" + + // CacheSysAuthTag 权限缓存TAG标签 + CacheSysAuthTag = "sysAuthTag" + // CacheSysModelTag 模型缓存标签 + CacheSysModelTag = "sysModelTag" + // CacheSysCmsTag cms缓存标签 + CacheSysCmsTag = "sysCmsTag" +) diff --git a/internal/app/system/consts/consts.go b/internal/app/system/consts/consts.go new file mode 100644 index 0000000..c0c0da5 --- /dev/null +++ b/internal/app/system/consts/consts.go @@ -0,0 +1,5 @@ +package consts + +const ( + PageSize = 10 //分页长度 +) diff --git a/internal/app/system/consts/context.go b/internal/app/system/consts/context.go new file mode 100644 index 0000000..827c13e --- /dev/null +++ b/internal/app/system/consts/context.go @@ -0,0 +1,13 @@ +/* +* @desc:context 相关常量 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/16 14:52 + */ + +package consts + +const ( + // CtxKey 上下文变量存储键名,前后端系统共享 + CtxKey = "GFastContext" +) diff --git a/internal/app/system/controller/base.go b/internal/app/system/controller/base.go new file mode 100644 index 0000000..5dae69a --- /dev/null +++ b/internal/app/system/controller/base.go @@ -0,0 +1,22 @@ +/* +* @desc:system base controller +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/4 18:12 + */ + +package controller + +import ( + "github.com/gogf/gf/v2/net/ghttp" + commonController "github.com/tiger1103/gfast/v3/internal/app/common/controller" +) + +type BaseController struct { + commonController.BaseController +} + +// Init 自动执行的初始化方法 +func (c *BaseController) Init(r *ghttp.Request) { + c.BaseController.Init(r) +} diff --git a/internal/app/system/controller/big_file.go b/internal/app/system/controller/big_file.go new file mode 100644 index 0000000..d74bb4f --- /dev/null +++ b/internal/app/system/controller/big_file.go @@ -0,0 +1,38 @@ +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +type bigFile struct{} + +var BigFile = new(bigFile) + +func (c *bigFile) List(ctx context.Context, req *system.BigFileSearchReq) (res *system.BigFileSearchRes, err error) { + return service.BigFile().List(ctx, req) +} + +// Add 添加系统参数 +func (c *bigFile) Add(ctx context.Context, req *system.BigFileAddReq) (res *system.BigFileAddRes, err error) { + err = service.BigFile().Add(ctx, req, service.Context().GetUserId(ctx)) + return +} + +// Get 获取文件信息 +func (c *bigFile) Get(ctx context.Context, req *system.BigFileGetReq) (res *system.BigFileGetRes, err error) { + return service.BigFile().Get(ctx, req.Id) +} + +// Edit 修改系统参数 +func (c *bigFile) Edit(ctx context.Context, req *system.BigFileEditReq) (res *system.BigFileEditRes, err error) { + err = service.BigFile().Edit(ctx, req, service.Context().GetUserId(ctx)) + return +} + +// Delete 删除系统参数 +func (c *bigFile) Delete(ctx context.Context, req *system.BigFileDeleteReq) (res *system.BigFileDeleteRes, err error) { + err = service.BigFile().Delete(ctx, req.Ids) + return +} diff --git a/internal/app/system/controller/big_upload.go b/internal/app/system/controller/big_upload.go new file mode 100644 index 0000000..3031275 --- /dev/null +++ b/internal/app/system/controller/big_upload.go @@ -0,0 +1,45 @@ +package controller + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/service" +) + +var BigUpload = new(bigUploadController) + +type bigUploadController struct{} + +// 上传分片文件 +func (c *bigUploadController) Upload(ctx context.Context, req *system.BigUploadReq) (res *system.BigUploadRes, err error) { + r := g.RequestFromCtx(ctx) + req = new(system.BigUploadReq) + err = req.Bind(r.Request) + if err != nil { + return + } + return service.BigUpload().Upload(ctx, req) +} + +// 上传文件检查 +func (c *bigUploadController) UploadCheck(ctx context.Context, req *system.BigUploadCheckReq) (res *system.BigUploadCheckRes, err error) { + r := g.RequestFromCtx(ctx) + req = new(system.BigUploadCheckReq) + err = req.Bind(r.Request) + if err != nil { + return + } + return service.BigUpload().UploadCheck(ctx, req) +} + +// 上传文件合并 +func (c *bigUploadController) UploadMerge(ctx context.Context, req *system.BigUploadMergeReq) (res *system.BigUploadRes, err error) { + r := g.RequestFromCtx(ctx) + req = new(system.BigUploadMergeReq) + err = req.Bind(r.Request) + if err != nil { + return + } + return service.BigUpload().UploadMerge(ctx, req) +} diff --git a/internal/app/system/controller/personal.go b/internal/app/system/controller/personal.go new file mode 100644 index 0000000..3694843 --- /dev/null +++ b/internal/app/system/controller/personal.go @@ -0,0 +1,34 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/11/3 10:32 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var Personal = new(personalController) + +type personalController struct { +} + +func (c *personalController) GetPersonal(ctx context.Context, req *system.PersonalInfoReq) (res *system.PersonalInfoRes, err error) { + res, err = service.Personal().GetPersonalInfo(ctx, req) + return +} + +func (c *personalController) EditPersonal(ctx context.Context, req *system.PersonalEditReq) (res *system.PersonalEditRes, err error) { + res, err = service.Personal().EditPersonal(ctx, req) + return +} + +func (c *personalController) ResetPwdPersonal(ctx context.Context, req *system.PersonalResetPwdReq) (res *system.PersonalResetPwdRes, err error) { + res, err = service.Personal().ResetPwdPersonal(ctx, req) + return +} diff --git a/internal/app/system/controller/sys_auth_rule.go b/internal/app/system/controller/sys_auth_rule.go new file mode 100644 index 0000000..59141fc --- /dev/null +++ b/internal/app/system/controller/sys_auth_rule.go @@ -0,0 +1,79 @@ +/* +* @desc:菜单 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/16 10:36 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var Menu = menuController{} + +type menuController struct { + BaseController +} + +func (c *menuController) List(ctx context.Context, req *system.RuleSearchReq) (res *system.RuleListRes, err error) { + var list []*model.SysAuthRuleInfoRes + res = &system.RuleListRes{ + Rules: make([]*model.SysAuthRuleTreeRes, 0), + } + list, err = service.SysAuthRule().GetMenuListSearch(ctx, req) + if req.Title != "" || req.Component != "" { + for _, menu := range list { + res.Rules = append(res.Rules, &model.SysAuthRuleTreeRes{ + SysAuthRuleInfoRes: menu, + }) + } + } else { + res.Rules = service.SysAuthRule().GetMenuListTree(0, list) + } + return +} + +func (c *menuController) Add(ctx context.Context, req *system.RuleAddReq) (res *system.RuleAddRes, err error) { + err = service.SysAuthRule().Add(ctx, req) + return +} + +// GetAddParams 获取菜单添加及编辑相关参数 +func (c *menuController) GetAddParams(ctx context.Context, req *system.RuleGetParamsReq) (res *system.RuleGetParamsRes, err error) { + // 获取角色列表 + res = new(system.RuleGetParamsRes) + res.Roles, err = service.SysRole().GetRoleList(ctx) + if err != nil { + return + } + res.Menus, err = service.SysAuthRule().GetIsMenuList(ctx) + return +} + +// Get 获取菜单信息 +func (c *menuController) Get(ctx context.Context, req *system.RuleInfoReq) (res *system.RuleInfoRes, err error) { + res = new(system.RuleInfoRes) + res.Rule, err = service.SysAuthRule().Get(ctx, req.Id) + if err != nil { + return + } + res.RoleIds, err = service.SysAuthRule().GetMenuRoles(ctx, req.Id) + return +} + +// Update 菜单修改 +func (c *menuController) Update(ctx context.Context, req *system.RuleUpdateReq) (res *system.RuleUpdateRes, err error) { + err = service.SysAuthRule().Update(ctx, req) + return +} + +// Delete 删除菜单 +func (c *menuController) Delete(ctx context.Context, req *system.RuleDeleteReq) (res *system.RuleDeleteRes, err error) { + err = service.SysAuthRule().DeleteMenuByIds(ctx, req.Ids) + return +} diff --git a/internal/app/system/controller/sys_config.go b/internal/app/system/controller/sys_config.go new file mode 100644 index 0000000..081478b --- /dev/null +++ b/internal/app/system/controller/sys_config.go @@ -0,0 +1,51 @@ +/* +* @desc:系统参数配置 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/18 21:17 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var Config = configController{} + +type configController struct { + BaseController +} + +// List 系统参数列表 +func (c *configController) List(ctx context.Context, req *system.ConfigSearchReq) (res *system.ConfigSearchRes, err error) { + res, err = commonService.SysConfig().List(ctx, req) + return +} + +// Add 添加系统参数 +func (c *configController) Add(ctx context.Context, req *system.ConfigAddReq) (res *system.ConfigAddRes, err error) { + err = commonService.SysConfig().Add(ctx, req, service.Context().GetUserId(ctx)) + return +} + +// Get 获取系统参数 +func (c *configController) Get(ctx context.Context, req *system.ConfigGetReq) (res *system.ConfigGetRes, err error) { + res, err = commonService.SysConfig().Get(ctx, req.Id) + return +} + +// Edit 修改系统参数 +func (c *configController) Edit(ctx context.Context, req *system.ConfigEditReq) (res *system.ConfigEditRes, err error) { + err = commonService.SysConfig().Edit(ctx, req, service.Context().GetUserId(ctx)) + return +} + +// Delete 删除系统参数 +func (c *configController) Delete(ctx context.Context, req *system.ConfigDeleteReq) (res *system.ConfigDeleteRes, err error) { + err = commonService.SysConfig().Delete(ctx, req.Ids) + return +} diff --git a/internal/app/system/controller/sys_dept.go b/internal/app/system/controller/sys_dept.go new file mode 100644 index 0000000..b7b993c --- /dev/null +++ b/internal/app/system/controller/sys_dept.go @@ -0,0 +1,60 @@ +/* +* @desc:部门管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/6 15:15 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var Dept = sysDeptController{} + +type sysDeptController struct { + BaseController +} + +// List 部门列表 +func (c *sysDeptController) List(ctx context.Context, req *system.DeptSearchReq) (res *system.DeptSearchRes, err error) { + res = new(system.DeptSearchRes) + res.DeptList, err = service.SysDept().GetList(ctx, req) + return +} + +// Add 添加部门 +func (c *sysDeptController) Add(ctx context.Context, req *system.DeptAddReq) (res *system.DeptAddRes, err error) { + err = service.SysDept().Add(ctx, req) + return +} + +// Edit 修改部门 +func (c *sysDeptController) Edit(ctx context.Context, req *system.DeptEditReq) (res *system.DeptEditRes, err error) { + err = service.SysDept().Edit(ctx, req) + return +} + +// Delete 删除部门 +func (c *sysDeptController) Delete(ctx context.Context, req *system.DeptDeleteReq) (res *system.DeptDeleteRes, err error) { + err = service.SysDept().Delete(ctx, req.Id) + return +} + +// TreeSelect 获取部门数据结构数据 +func (c *sysDeptController) TreeSelect(ctx context.Context, req *system.DeptTreeSelectReq) (res *system.DeptTreeSelectRes, err error) { + var deptList []*entity.SysDept + deptList, err = service.SysDept().GetList(ctx, &system.DeptSearchReq{ + Status: "1", //正常状态数据 + }) + if err != nil { + return + } + res = new(system.DeptTreeSelectRes) + res.Deps = service.SysDept().GetListTree(0, deptList) + return +} diff --git a/internal/app/system/controller/sys_dict_data.go b/internal/app/system/controller/sys_dict_data.go new file mode 100644 index 0000000..98d4f68 --- /dev/null +++ b/internal/app/system/controller/sys_dict_data.go @@ -0,0 +1,55 @@ +/* +* @desc:字典数据管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:57 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var DictData = dictDataController{} + +type dictDataController struct { +} + +// GetDictData 获取字典数据 +func (c *dictDataController) GetDictData(ctx context.Context, req *system.GetDictReq) (res *system.GetDictRes, err error) { + res, err = commonService.SysDictData().GetDictWithDataByType(ctx, req) + return +} + +// List 获取字典数据列表 +func (c *dictDataController) List(ctx context.Context, req *system.DictDataSearchReq) (res *system.DictDataSearchRes, err error) { + res, err = commonService.SysDictData().List(ctx, req) + return +} + +// Add 添加字典数据 +func (c *dictDataController) Add(ctx context.Context, req *system.DictDataAddReq) (res *system.DictDataAddRes, err error) { + err = commonService.SysDictData().Add(ctx, req, service.Context().GetUserId(ctx)) + return +} + +// Get 获取对应的字典数据 +func (c *dictDataController) Get(ctx context.Context, req *system.DictDataGetReq) (res *system.DictDataGetRes, err error) { + res, err = commonService.SysDictData().Get(ctx, req.DictCode) + return +} + +// Edit 修改字典数据 +func (c *dictDataController) Edit(ctx context.Context, req *system.DictDataEditReq) (res *system.DictDataEditRes, err error) { + err = commonService.SysDictData().Edit(ctx, req, service.Context().GetUserId(ctx)) + return +} + +func (c *dictDataController) Delete(ctx context.Context, req *system.DictDataDeleteReq) (res *system.DictDataDeleteRes, err error) { + err = commonService.SysDictData().Delete(ctx, req.Ids) + return +} diff --git a/internal/app/system/controller/sys_dict_type.go b/internal/app/system/controller/sys_dict_type.go new file mode 100644 index 0000000..e10d324 --- /dev/null +++ b/internal/app/system/controller/sys_dict_type.go @@ -0,0 +1,57 @@ +/* +* @desc:字典类型 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/18 11:57 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var DictType = &SysDictTypeController{} + +type SysDictTypeController struct { +} + +// List 字典类型列表 +func (c *SysDictTypeController) List(ctx context.Context, req *system.DictTypeSearchReq) (res *system.DictTypeSearchRes, err error) { + res, err = commonService.SysDictType().List(ctx, req) + return +} + +// Add 添加字典类型 +func (c *SysDictTypeController) Add(ctx context.Context, req *system.DictTypeAddReq) (res *system.DictTypeAddRes, err error) { + err = commonService.SysDictType().Add(ctx, req, service.Context().GetUserId(ctx)) + return +} + +// Get 获取字典类型 +func (c *SysDictTypeController) Get(ctx context.Context, req *system.DictTypeGetReq) (res *system.DictTypeGetRes, err error) { + res = new(system.DictTypeGetRes) + res.DictType, err = commonService.SysDictType().Get(ctx, req) + return +} + +// Edit 修改字典数据 +func (c *SysDictTypeController) Edit(ctx context.Context, req *system.DictTypeEditReq) (res *system.DictTypeEditRes, err error) { + err = commonService.SysDictType().Edit(ctx, req, service.Context().GetUserId(ctx)) + return +} + +func (c *SysDictTypeController) Delete(ctx context.Context, req *system.DictTypeDeleteReq) (res *system.DictTypeDeleteRes, err error) { + err = commonService.SysDictType().Delete(ctx, req.DictIds) + return +} + +// OptionSelect 获取字典选择框列表 +func (c *SysDictTypeController) OptionSelect(ctx context.Context, req *system.DictTypeAllReq) (res *system.DictTYpeAllRes, err error) { + res = new(system.DictTYpeAllRes) + res.DictType, err = commonService.SysDictType().GetAllDictType(ctx) + return +} diff --git a/internal/app/system/controller/sys_job.go b/internal/app/system/controller/sys_job.go new file mode 100644 index 0000000..ded3f8b --- /dev/null +++ b/internal/app/system/controller/sys_job.go @@ -0,0 +1,82 @@ +// ========================================================================== +// GFast自动生成controller操作代码。 +// 生成日期:2023-01-12 17:43:50 +// 生成路径: internal/app/system/controller/sys_job.go +// 生成人:gfast +// desc:定时任务 +// company:云南奇讯科技有限公司 +// ========================================================================== + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +type sysJobController struct { + BaseController +} + +var SysJob = new(sysJobController) + +// List 列表 +func (c *sysJobController) List(ctx context.Context, req *system.SysJobSearchReq) (res *system.SysJobSearchRes, err error) { + res, err = service.SysJob().List(ctx, req) + return +} + +// Get 获取定时任务 +func (c *sysJobController) Get(ctx context.Context, req *system.SysJobGetReq) (res *system.SysJobGetRes, err error) { + res = new(system.SysJobGetRes) + res.SysJobInfoRes, err = service.SysJob().GetByJobId(ctx, req.JobId) + return +} + +// Add 添加定时任务 +func (c *sysJobController) Add(ctx context.Context, req *system.SysJobAddReq) (res *system.SysJobAddRes, err error) { + err = service.SysJob().Add(ctx, req) + return +} + +// Edit 修改定时任务 +func (c *sysJobController) Edit(ctx context.Context, req *system.SysJobEditReq) (res *system.SysJobEditRes, err error) { + err = service.SysJob().Edit(ctx, req) + return +} + +// Delete 删除定时任务 +func (c *sysJobController) Delete(ctx context.Context, req *system.SysJobDeleteReq) (res *system.SysJobDeleteRes, err error) { + err = service.SysJob().Delete(ctx, req.JobIds) + return +} + +// Start 启动任务 +func (c *sysJobController) Start(ctx context.Context, req *system.SysJobStartReq) (res *system.SysJobStartRes, err error) { + err = service.SysJob().Start(ctx, req.JobId) + return +} + +// Stop 停止任务 +func (c *sysJobController) Stop(ctx context.Context, req *system.SysJobStopReq) (res *system.SysJobStopRes, err error) { + err = service.SysJob().Stop(ctx, req.JobId) + return +} + +// Run 运行任务 +func (c *sysJobController) Run(ctx context.Context, req *system.SysJobRunReq) (res *system.SysJobRunRes, err error) { + err = service.SysJob().Run(ctx, req.JobId) + return +} + +// Log 获取执行日志列表 +func (c *sysJobController) Log(ctx context.Context, req *system.SysJobLogListReq) (res *system.SysJobLogListRes, err error) { + res, err = service.SysJobLog().List(ctx, req) + return +} + +func (c *sysJobController) LogDelete(ctx context.Context, req *system.SysJobLogDeleteReq) (res *system.SysJobLogDeleteRes, err error) { + err = service.SysJobLog().Delete(ctx, req.LogIds) + return +} diff --git a/internal/app/system/controller/sys_login.go b/internal/app/system/controller/sys_login.go new file mode 100644 index 0000000..e366f06 --- /dev/null +++ b/internal/app/system/controller/sys_login.go @@ -0,0 +1,112 @@ +/* +* @desc:登录 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/27 21:52 + */ + +package controller + +import ( + "context" + "github.com/gogf/gf/v2/crypto/gmd5" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gmode" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/libUtils" +) + +var ( + Login = loginController{} +) + +type loginController struct { + BaseController +} + +func (c *loginController) Login(ctx context.Context, req *system.UserLoginReq) (res *system.UserLoginRes, err error) { + var ( + user *model.LoginUserRes + token string + permissions []string + menuList []*model.UserMenus + ) + //判断验证码是否正确 + debug := gmode.IsDevelop() + if !debug { + if !commonService.Captcha().VerifyString(req.VerifyKey, req.VerifyCode) { + err = gerror.New("验证码输入错误") + return + } + } + ip := libUtils.GetClientIp(ctx) + userAgent := libUtils.GetUserAgent(ctx) + user, err = service.SysUser().GetAdminUserByUsernamePassword(ctx, req) + if err != nil { + // 保存登录失败的日志信息 + service.SysLoginLog().Invoke(ctx, &model.LoginLogParams{ + Status: 0, + Username: req.Username, + Ip: ip, + UserAgent: userAgent, + Msg: err.Error(), + Module: "系统后台", + }) + return + } + err = service.SysUser().UpdateLoginInfo(ctx, user.Id, ip) + if err != nil { + return + } + // 报存登录成功的日志信息 + service.SysLoginLog().Invoke(ctx, &model.LoginLogParams{ + Status: 1, + Username: req.Username, + Ip: ip, + UserAgent: userAgent, + Msg: "登录成功", + Module: "系统后台", + }) + key := gconv.String(user.Id) + "-" + gmd5.MustEncryptString(user.UserName) + gmd5.MustEncryptString(user.UserPassword) + if g.Cfg().MustGet(ctx, "gfToken.multiLogin").Bool() { + key = gconv.String(user.Id) + "-" + gmd5.MustEncryptString(user.UserName) + gmd5.MustEncryptString(user.UserPassword+ip+userAgent) + } + user.UserPassword = "" + token, err = service.GfToken().GenerateToken(ctx, key, user) + if err != nil { + g.Log().Error(ctx, err) + err = gerror.New("登录失败,后端服务出现错误") + return + } + //获取用户菜单数据 + menuList, permissions, err = service.SysUser().GetAdminRules(ctx, user.Id) + if err != nil { + return + } + res = &system.UserLoginRes{ + UserInfo: user, + Token: token, + MenuList: menuList, + Permissions: permissions, + } + //用户在线状态保存 + service.SysUserOnline().Invoke(ctx, &model.SysUserOnlineParams{ + UserAgent: userAgent, + Uuid: gmd5.MustEncrypt(token), + Token: token, + Username: user.UserName, + Ip: ip, + }) + return +} + +// LoginOut 退出登录 +func (c *loginController) LoginOut(ctx context.Context, req *system.UserLoginOutReq) (res *system.UserLoginOutRes, err error) { + err = service.GfToken().RemoveToken(ctx, service.GfToken().GetRequestToken(g.RequestFromCtx(ctx))) + return +} diff --git a/internal/app/system/controller/sys_login_log.go b/internal/app/system/controller/sys_login_log.go new file mode 100644 index 0000000..c38bc21 --- /dev/null +++ b/internal/app/system/controller/sys_login_log.go @@ -0,0 +1,35 @@ +/* +* @desc:登录日志管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/24 22:14 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var LoginLog = loginLogController{} + +type loginLogController struct { + BaseController +} + +func (c *loginLogController) List(ctx context.Context, req *system.LoginLogSearchReq) (res *system.LoginLogSearchRes, err error) { + res, err = service.SysLoginLog().List(ctx, req) + return +} + +func (c *loginLogController) Delete(ctx context.Context, req *system.LoginLogDelReq) (res *system.LoginLogDelRes, err error) { + err = service.SysLoginLog().DeleteLoginLogByIds(ctx, req.Ids) + return +} + +func (c *loginLogController) Clear(ctx context.Context, req *system.LoginLogClearReq) (res *system.LoginLogClearRes, err error) { + err = service.SysLoginLog().ClearLoginLog(ctx) + return +} diff --git a/internal/app/system/controller/sys_monitor.go b/internal/app/system/controller/sys_monitor.go new file mode 100644 index 0000000..9a9cb40 --- /dev/null +++ b/internal/app/system/controller/sys_monitor.go @@ -0,0 +1,142 @@ +package controller + +import ( + "context" + "fmt" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gconv" + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/disk" + "github.com/shirou/gopsutil/host" + "github.com/shirou/gopsutil/load" + "github.com/shirou/gopsutil/mem" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/library/libUtils" + "os" + "runtime" + "strconv" + "time" +) + +var Monitor = sysMonitorController{ + startTime: gtime.Now(), +} + +type sysMonitorController struct { + BaseController + startTime *gtime.Time +} + +func (c *sysMonitorController) List(ctx context.Context, req *system.MonitorSearchReq) (res *system.MonitorSearchRes, err error) { + cpuNum := runtime.NumCPU() //核心数 + var cpuUsed float64 = 0 //用户使用率 + var cpuAvg5 float64 = 0 //CPU负载5 + var cpuAvg15 float64 = 0 //当前空闲率 + + cpuInfo, err := cpu.Percent(time.Duration(time.Second), false) + if err == nil { + cpuUsed, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cpuInfo[0]), 64) + } + + loadInfo, err := load.Avg() + if err == nil { + cpuAvg5, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", loadInfo.Load5), 64) + cpuAvg15, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", loadInfo.Load5), 64) + } + + var memTotal uint64 = 0 //总内存 + var memUsed uint64 = 0 //总内存 := 0 //已用内存 + var memFree uint64 = 0 //剩余内存 + var memUsage float64 = 0 //使用率 + + v, err := mem.VirtualMemory() + if err == nil { + memTotal = v.Total + memUsed = v.Used + memFree = memTotal - memUsed + memUsage, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.UsedPercent), 64) + } + + var goTotal uint64 = 0 //go分配的总内存数 + var goUsed uint64 = 0 //go使用的内存数 + var goFree uint64 = 0 //go剩余的内存数 + var goUsage float64 = 0 //使用率 + + var gomem runtime.MemStats + runtime.ReadMemStats(&gomem) + goUsed = gomem.Sys + goUsage = gconv.Float64(fmt.Sprintf("%.2f", gconv.Float64(goUsed)/gconv.Float64(memTotal)*100)) + sysComputerIp := "" //服务器IP + + ip, err := libUtils.GetLocalIP() + if err == nil { + sysComputerIp = ip + } + + sysComputerName := "" //服务器名称 + sysOsName := "" //操作系统 + sysOsArch := "" //系统架构 + + sysInfo, err := host.Info() + + if err == nil { + sysComputerName = sysInfo.Hostname + sysOsName = sysInfo.OS + sysOsArch = sysInfo.KernelArch + } + + goName := "GoLang" //语言环境 + goVersion := runtime.Version() //版本 + gtime.Date() + goStartTime := c.startTime //启动时间 + + goRunTime := gtime.Now().Timestamp() - c.startTime.Timestamp() //运行时长(秒) + goHome := runtime.GOROOT() //安装路径 + goUserDir := "" //项目路径 + + curDir, err := os.Getwd() + + if err == nil { + goUserDir = curDir + } + + //服务器磁盘信息 + diskList := make([]disk.UsageStat, 0) + diskInfo, err := disk.Partitions(true) //所有分区 + if err == nil { + for _, p := range diskInfo { + diskDetail, err := disk.Usage(p.Mountpoint) + if err == nil { + diskDetail.UsedPercent, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", diskDetail.UsedPercent), 64) + diskList = append(diskList, *diskDetail) + } + } + } + res = new(system.MonitorSearchRes) + res = &system.MonitorSearchRes{ + "cpuNum": cpuNum, + "cpuUsed": cpuUsed, + "cpuAvg5": gconv.String(cpuAvg5), + "cpuAvg15": gconv.String(cpuAvg15), + "memTotal": memTotal, + "goTotal": goTotal, + "memUsed": memUsed, + "goUsed": goUsed, + "memFree": memFree, + "goFree": goFree, + "memUsage": memUsage, + "goUsage": goUsage, + "sysComputerName": sysComputerName, + "sysOsName": sysOsName, + "sysComputerIp": sysComputerIp, + "sysOsArch": sysOsArch, + "goName": goName, + "goVersion": goVersion, + "goStartTime": goStartTime, + "goRunTime": goRunTime, + "goHome": goHome, + "goUserDir": goUserDir, + "diskList": diskList, + } + return +} diff --git a/internal/app/system/controller/sys_oper_log.go b/internal/app/system/controller/sys_oper_log.go new file mode 100644 index 0000000..ac9bd7d --- /dev/null +++ b/internal/app/system/controller/sys_oper_log.go @@ -0,0 +1,43 @@ +/* +* @desc:系统后台操作日志 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/21 16:10 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var OperLog = new(operateLogController) + +type operateLogController struct { + BaseController +} + +// List 列表 +func (c *operateLogController) List(ctx context.Context, req *system.SysOperLogSearchReq) (res *system.SysOperLogSearchRes, err error) { + res, err = service.OperateLog().List(ctx, req) + return +} + +// Get 获取操作日志 +func (c *operateLogController) Get(ctx context.Context, req *system.SysOperLogGetReq) (res *system.SysOperLogGetRes, err error) { + res = new(system.SysOperLogGetRes) + res.SysOperLogInfoRes, err = service.OperateLog().GetByOperId(ctx, req.OperId) + return +} + +func (c *operateLogController) Delete(ctx context.Context, req *system.SysOperLogDeleteReq) (res *system.SysOperLogDeleteRes, err error) { + err = service.OperateLog().DeleteByIds(ctx, req.OperIds) + return +} + +func (c *operateLogController) Clear(ctx context.Context, req *system.SysOperLogClearReq) (res *system.SysOperLogClearRes, err error) { + err = service.OperateLog().ClearLog(ctx) + return +} diff --git a/internal/app/system/controller/sys_post.go b/internal/app/system/controller/sys_post.go new file mode 100644 index 0000000..8586e89 --- /dev/null +++ b/internal/app/system/controller/sys_post.go @@ -0,0 +1,44 @@ +/* +* @desc:岗位管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/7 23:12 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var Post = postController{} + +type postController struct { + BaseController +} + +// List 岗位列表 +func (c *postController) List(ctx context.Context, req *system.PostSearchReq) (res *system.PostSearchRes, err error) { + res, err = service.SysPost().List(ctx, req) + return +} + +// Add 添加岗位 +func (c *postController) Add(ctx context.Context, req *system.PostAddReq) (res *system.PostAddRes, err error) { + err = service.SysPost().Add(ctx, req) + return +} + +// Edit 修改岗位 +func (c *postController) Edit(ctx context.Context, req *system.PostEditReq) (res *system.PostEditRes, err error) { + err = service.SysPost().Edit(ctx, req) + return +} + +// Delete 删除岗位 +func (c *postController) Delete(ctx context.Context, req *system.PostDeleteReq) (res *system.PostDeleteRes, err error) { + err = service.SysPost().Delete(ctx, req.Ids) + return +} diff --git a/internal/app/system/controller/sys_role.go b/internal/app/system/controller/sys_role.go new file mode 100644 index 0000000..275a507 --- /dev/null +++ b/internal/app/system/controller/sys_role.go @@ -0,0 +1,74 @@ +/* +* @desc:角色管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/30 9:08 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var Role = roleController{} + +type roleController struct { + BaseController +} + +// List 角色列表 +func (c *roleController) List(ctx context.Context, req *system.RoleListReq) (res *system.RoleListRes, err error) { + res, err = service.SysRole().GetRoleListSearch(ctx, req) + return +} + +// GetParams 获取角色表单参数 +func (c *roleController) GetParams(ctx context.Context, req *system.RoleGetParamsReq) (res *system.RoleGetParamsRes, err error) { + res = new(system.RoleGetParamsRes) + res.Menu, err = service.SysAuthRule().GetMenuList(ctx) + return +} + +// Add 添加角色信息 +func (c *roleController) Add(ctx context.Context, req *system.RoleAddReq) (res *system.RoleAddRes, err error) { + err = service.SysRole().AddRole(ctx, req) + return +} + +// Get 获取角色信息 +func (c *roleController) Get(ctx context.Context, req *system.RoleGetReq) (res *system.RoleGetRes, err error) { + res = new(system.RoleGetRes) + res.Role, err = service.SysRole().Get(ctx, req.Id) + if err != nil { + return + } + res.MenuIds, err = service.SysRole().GetFilteredNamedPolicy(ctx, req.Id) + return +} + +// Edit 修改角色信息 +func (c *roleController) Edit(ctx context.Context, req *system.RoleEditReq) (res *system.RoleEditRes, err error) { + err = service.SysRole().EditRole(ctx, req) + return +} + +// Delete 删除角色 +func (c *roleController) Delete(ctx context.Context, req *system.RoleDeleteReq) (res *system.RoleDeleteRes, err error) { + err = service.SysRole().DeleteByIds(ctx, req.Ids) + return +} + +// DeptTreeSelect 获取数据权限 +func (c *roleController) DeptTreeSelect(ctx context.Context, req *system.RoleDeptTreeSelectReq) (res *system.RoleDeptTreeSelectRes, err error) { + res, err = service.SysRole().RoleDeptTreeSelect(ctx, req.RoleId) + return +} + +// RoleDataScope 设置角色数据权限 +func (c *roleController) RoleDataScope(ctx context.Context, req *system.DataScopeReq) (res *system.DataScopeRes, err error) { + err = service.SysRole().RoleDataScope(ctx, req) + return +} diff --git a/internal/app/system/controller/sys_user.go b/internal/app/system/controller/sys_user.go new file mode 100644 index 0000000..f7e4b4c --- /dev/null +++ b/internal/app/system/controller/sys_user.go @@ -0,0 +1,102 @@ +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var ( + User = userController{} +) + +type userController struct { + BaseController +} + +// GetUserMenus 获取用户菜单及按钮权限 +func (c *userController) GetUserMenus(ctx context.Context, req *system.UserMenusReq) (res *system.UserMenusRes, err error) { + var ( + permissions []string + menuList []*model.UserMenus + ) + userId := service.Context().GetUserId(ctx) + menuList, permissions, err = service.SysUser().GetAdminRules(ctx, userId) + res = &system.UserMenusRes{ + MenuList: menuList, + Permissions: permissions, + } + return +} + +// List 用户列表 +func (c *userController) List(ctx context.Context, req *system.UserSearchReq) (res *system.UserSearchRes, err error) { + var ( + total interface{} + userList []*entity.SysUser + ) + res = new(system.UserSearchRes) + total, userList, err = service.SysUser().List(ctx, req) + if err != nil || total == 0 { + return + } + res.Total = total + res.UserList, err = service.SysUser().GetUsersRoleDept(ctx, userList) + return +} + +// GetParams 获取用户维护相关参数 +func (c *userController) GetParams(ctx context.Context, req *system.UserGetParamsReq) (res *system.UserGetParamsRes, err error) { + res = new(system.UserGetParamsRes) + res.RoleList, err = service.SysRole().GetRoleList(ctx) + if err != nil { + return + } + res.Posts, err = service.SysPost().GetUsedPost(ctx) + return +} + +// Add 添加用户 +func (c *userController) Add(ctx context.Context, req *system.UserAddReq) (res *system.UserAddRes, err error) { + err = service.SysUser().Add(ctx, req) + return +} + +// GetEditUser 获取修改用户信息 +func (c *userController) GetEditUser(ctx context.Context, req *system.UserGetEditReq) (res *system.UserGetEditRes, err error) { + res, err = service.SysUser().GetEditUser(ctx, req.Id) + return +} + +// Edit 修改用户 +func (c *userController) Edit(ctx context.Context, req *system.UserEditReq) (res *system.UserEditRes, err error) { + err = service.SysUser().Edit(ctx, req) + return +} + +// ResetPwd 重置密码 +func (c *userController) ResetPwd(ctx context.Context, req *system.UserResetPwdReq) (res *system.UserResetPwdRes, err error) { + err = service.SysUser().ResetUserPwd(ctx, req) + return +} + +// SetStatus 修改用户状态 +func (c *userController) SetStatus(ctx context.Context, req *system.UserStatusReq) (res *system.UserStatusRes, err error) { + err = service.SysUser().ChangeUserStatus(ctx, req) + return +} + +// Delete 删除用户 +func (c *userController) Delete(ctx context.Context, req *system.UserDeleteReq) (res *system.UserDeleteRes, err error) { + err = service.SysUser().Delete(ctx, req.Ids) + return +} + +// GetUsers 通过用户id批量获取用户信息 +func (c *userController) GetUsers(ctx context.Context, req *system.UserGetByIdsReq) (res *system.UserGetByIdsRes, err error) { + res = new(system.UserGetByIdsRes) + res.List, err = service.SysUser().GetUsers(ctx, req.Ids) + return +} diff --git a/internal/app/system/controller/sys_user_online.go b/internal/app/system/controller/sys_user_online.go new file mode 100644 index 0000000..e13b172 --- /dev/null +++ b/internal/app/system/controller/sys_user_online.go @@ -0,0 +1,28 @@ +/* +* @desc:在线用户管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2023/1/10 17:23 + */ + +package controller + +import ( + "context" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var UserOnline = new(SysUserOnlineController) + +type SysUserOnlineController struct{} + +func (c *SysUserOnlineController) List(ctx context.Context, req *system.SysUserOnlineSearchReq) (res *system.SysUserOnlineSearchRes, err error) { + res, err = service.SysUserOnline().GetOnlineListPage(ctx, req) + return +} + +func (c *SysUserOnlineController) ForceLogout(ctx context.Context, req *system.SysUserOnlineForceLogoutReq) (res *system.SysUserOnlineForceLogoutRes, err error) { + err = service.SysUserOnline().ForceLogout(ctx, req.Ids) + return +} diff --git a/internal/app/system/controller/tools_gen_table.go b/internal/app/system/controller/tools_gen_table.go new file mode 100644 index 0000000..67394b3 --- /dev/null +++ b/internal/app/system/controller/tools_gen_table.go @@ -0,0 +1,88 @@ +/* +* @desc:代码生成 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/10/26 16:55 + */ + +package controller + +import ( + "context" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +var ToolsGenTable = new(toolsGenTableController) + +type toolsGenTableController struct { + BaseController +} + +// List 获取表数据 +func (c *toolsGenTableController) List(ctx context.Context, req *system.ToolsGenTableSearchReq) (res *system.ToolsGenTableSearchRes, err error) { + res, err = service.ToolsGenTable().List(ctx, req) + return +} + +// GetImportTableList 获取要导入的数据表列表 +func (c *toolsGenTableController) GetImportTableList(ctx context.Context, req *system.ToolsGenTableImportSearchReq) (res *system.ToolsGenTableSearchRes, err error) { + res, err = service.ToolsGenTable().SelectDbTableList(ctx, req) + return +} + +// ImportTableSave 导入表结构数据操作 +func (c *toolsGenTableController) ImportTableSave(ctx context.Context, req *system.ToolsGenTableImportTableReq) (res *common.EmptyRes, err error) { + var tableList []*entity.ToolsGenTable + tableList, err = service.ToolsGenTable().SelectDbTableListByNames(ctx, req.Tables) + if err != nil { + return + } + if tableList == nil { + err = gerror.New("表信息不存在") + return + } + err = service.ToolsGenTable().ImportGenTable(ctx, tableList) + return +} + +// DeleteTable 删除已导入的表数据 +func (c *toolsGenTableController) DeleteTable(ctx context.Context, req *system.ToolsGenTableDeleteReq) (res *common.EmptyRes, err error) { + err = service.ToolsGenTable().DeleteTable(ctx, req) + return +} + +// GenColumnList 获取编辑页面返回数据 +func (c *toolsGenTableController) GenColumnList(ctx context.Context, req *system.ToolsGenTableEditReq) (res *system.ToolsGenTableEditRes, err error) { + res, err = service.ToolsGenTable().ColumnList(ctx, req) + return +} + +// RelationTable 获取关联表数据 +func (c *toolsGenTableController) RelationTable(ctx context.Context, req *system.ToolsGenRelationTableReq) (res *system.ToolsGenRelationTableRes, err error) { + res = new(system.ToolsGenRelationTableRes) + res.Data, err = service.ToolsGenTable().GetRelationTable(ctx) + return +} + +// EditSave 生成配置编辑保存 +func (c *toolsGenTableController) EditSave(ctx context.Context, req *system.ToolsGenTableColumnsEditReq) (res *system.ToolsGenTableColumnsEditRes, err error) { + err = service.ToolsGenTable().SaveEdit(ctx, req) + return +} + +// Preview 代码预览 +func (c *toolsGenTableController) Preview(ctx context.Context, req *system.ToolsGenTablePreviewReq) (res *system.ToolsGenTablePreviewRes, err error) { + res = new(system.ToolsGenTablePreviewRes) + res.Data, _, err = service.ToolsGenTable().GenData(ctx, req.TableId) + return +} + +// BatchGenCode 代码生成 +func (c *toolsGenTableController) BatchGenCode(ctx context.Context, req *system.ToolsGenTableBatchGenCodeReq) (res *system.ToolsGenTableBatchGenCodeRes, err error) { + err = service.ToolsGenTable().GenCode(ctx, req.Ids) + return +} diff --git a/internal/app/system/controller/ueditor.go b/internal/app/system/controller/ueditor.go new file mode 100644 index 0000000..25c4c60 --- /dev/null +++ b/internal/app/system/controller/ueditor.go @@ -0,0 +1,199 @@ +/* +* @desc:UEditor处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/11/17 14:40 + */ + +package controller + +import ( + "context" + "fmt" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + "github.com/tiger1103/gfast/v3/internal/app/common/service" +) + +var UEditor = new(uEditorController) + +type uEditorController struct { + BaseController +} + +func (c *uEditorController) GetConfig(ctx context.Context, req *system.UEditorConfigReq) (res *system.UEditorRes, err error) { + return c.action(ctx, &req.UEditorReq) +} + +func (c *uEditorController) UpFile(ctx context.Context, req *system.UEditorUpFileReq) (res *system.UEditorRes, err error) { + if req.File == nil { + err = gerror.New("请选择文件上传") + return + } + return c.action(ctx, &req.UEditorReq) +} + +func (c *uEditorController) action(ctx context.Context, req *system.UEditorReq) (res *system.UEditorRes, err error) { + r := g.RequestFromCtx(ctx) + switch req.Action { + //获取配置 + case "config": + c.ueditorConfig(ctx, req.Callback) + //上传图片 上传涂鸦 + case "uploadimage", "uploadscrawl": + c.uEditorUpload(ctx, req.File, "image") + //上传视频 上传文件 + case "uploadvideo", "uploadfile": + c.uEditorUpload(ctx, req.File, "file") + //列出图片 列出文件 + case "listimage", "listfile": + r.Response.WriteJson(g.Map{ + "state": "SUCCESS", + "total": 0, + "start": 0, + "list": g.Slice{}, + }) + //抓取远端图片 + case "catchimage": + r.Response.WriteJson(g.Map{ + "state": "抓取失败", + }) + default: + r.Response.WriteJson(g.Map{ + "state": "请求地址出错", + }) + } + return +} + +// 获取ueditor配置 +func (c *uEditorController) ueditorConfig(ctx context.Context, callback string) { + config := g.Map{ + /* 上传图片配置项 */ + "imageActionName": "uploadimage", /* 执行上传图片的action名称 */ + "imageFieldName": "upfile", /* 提交的图片表单名称 */ + "imageMaxSize": 2048000, /* 上传大小限制,单位B */ + "imageAllowFiles": g.Slice{".png", ".jpg", ".jpeg", ".gif", ".bmp"}, /* 上传图片格式显示 */ + "imageCompressEnable": true, /* 是否压缩图片,默认是true */ + "imageCompressBorder": 1600, /* 图片压缩最长边限制 */ + "imageInsertAlign": "none", /* 插入的图片浮动方式 */ + "imageUrlPrefix": "", /* 图片访问路径前缀 */ + "imagePathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + /* {filename} 会替换成原文件名,配置这项需要注意中文乱码问题 */ + /* {rand:6} 会替换成随机数,后面的数字是随机数的位数 */ + /* {time} 会替换成时间戳 */ + /* {yyyy} 会替换成四位年份 */ + /* {yy} 会替换成两位年份 */ + /* {mm} 会替换成两位月份 */ + /* {dd} 会替换成两位日期 */ + /* {hh} 会替换成两位小时 */ + /* {ii} 会替换成两位分钟 */ + /* {ss} 会替换成两位秒 */ + /* 非法字符 \ : * ? " < > | */ + /* 具请体看线上文档: fex.baidu.com/ueditor/#use-format_upload_filename */ + + /* 涂鸦图片上传配置项 */ + "scrawlActionName": "uploadscrawl", /* 执行上传涂鸦的action名称 */ + "scrawlFieldName": "upfile", /* 提交的图片表单名称 */ + "scrawlPathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + "scrawlMaxSize": 2048000, /* 上传大小限制,单位B */ + "scrawlUrlPrefix": "", /* 图片访问路径前缀 */ + "scrawlInsertAlign": "none", + + /* 截图工具上传 */ + "snapscreenActionName": "uploadimage", /* 执行上传截图的action名称 */ + "snapscreenPathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + "snapscreenUrlPrefix": "", /* 图片访问路径前缀 */ + "snapscreenInsertAlign": "none", /* 插入的图片浮动方式 */ + + /* 抓取远程图片配置 */ + "catcherLocalDomain": g.Slice{"127.0.0.1", "localhost", "img.baidu.com"}, + "catcherActionName": "catchimage", /* 执行抓取远程图片的action名称 */ + "catcherFieldName": "source", /* 提交的图片列表表单名称 */ + "catcherPathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + "catcherUrlPrefix": "", /* 图片访问路径前缀 */ + "catcherMaxSize": 2048000, /* 上传大小限制,单位B */ + "catcherAllowFiles": g.Slice{".png", ".jpg", ".jpeg", ".gif", ".bmp"}, /* 抓取图片格式显示 */ + + /* 上传视频配置 */ + "videoActionName": "uploadvideo", /* 执行上传视频的action名称 */ + "videoFieldName": "upfile", /* 提交的视频表单名称 */ + "videoPathFormat": "/ueditor/php/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + "videoUrlPrefix": "", /* 视频访问路径前缀 */ + "videoMaxSize": 1024000000, /* 上传大小限制,单位B,默认1000MB */ + "videoAllowFiles": g.Slice{ + ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", + ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"}, /* 上传视频格式显示 */ + + /* 上传文件配置 */ + "fileActionName": "uploadfile", /* controller里,执行上传视频的action名称 */ + "fileFieldName": "upfile", /* 提交的文件表单名称 */ + "filePathFormat": "/ueditor/php/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ + "fileUrlPrefix": "", /* 文件访问路径前缀 */ + "fileMaxSize": 51200000, /* 上传大小限制,单位B,默认50MB */ + "fileAllowFiles": g.Slice{ + ".png", ".jpg", ".jpeg", ".gif", ".bmp", + ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", + ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid", + ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso", + ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml", + }, /* 上传文件格式显示 */ + + /* 列出指定目录下的图片 */ + "imageManagerActionName": "listimage", /* 执行图片管理的action名称 */ + "imageManagerListPath": "/ueditor/php/upload/image/", /* 指定要列出图片的目录 */ + "imageManagerListSize": 20, /* 每次列出文件数量 */ + "imageManagerUrlPrefix": "", /* 图片访问路径前缀 */ + "imageManagerInsertAlign": "none", /* 插入的图片浮动方式 */ + "imageManagerAllowFiles": g.Slice{".png", ".jpg", ".jpeg", ".gif", ".bmp"}, /* 列出的文件类型 */ + + /* 列出指定目录下的文件 */ + "fileManagerActionName": "listfile", /* 执行文件管理的action名称 */ + "fileManagerListPath": "/ueditor/php/upload/file/", /* 指定要列出文件的目录 */ + "fileManagerUrlPrefix": "", /* 文件访问路径前缀 */ + "fileManagerListSize": 20, /* 每次列出文件数量 */ + "fileManagerAllowFiles": g.Slice{ + ".png", ".jpg", ".jpeg", ".gif", ".bmp", + ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", + ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid", + ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso", + ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml", + }, /* 列出的文件类型 */ + } + r := g.RequestFromCtx(ctx) + r.Response.Write(fmt.Sprintf("%s(%s)", callback, gconv.String(config))) + r.Exit() +} + +// ueditor上传图片 +func (c *uEditorController) uEditorUpload(ctx context.Context, upFile *ghttp.UploadFile, fType string) { + var ( + info system.UploadResponse + err error + r = g.RequestFromCtx(ctx) + ) + v, _ := g.Cfg().Get(ctx, "upload.default") + if fType == "image" { + info, err = service.Upload().UploadFile(ctx, upFile, consts.CheckFileTypeImg, v.Int()) + } else if fType == "file" { + info, err = service.Upload().UploadFile(ctx, upFile, consts.CheckFileTypeFile, v.Int()) + } + + if err != nil { + r.Response.WriteJson(g.Map{ + "state": err.Error(), + }) + } else { + r.Response.WriteJson(g.Map{ + "state": "SUCCESS", + "url": info.FullPath, + "title": info.Name, + "original": info.Name, + }) + } + r.Exit() +} diff --git a/internal/app/system/controller/upload.go b/internal/app/system/controller/upload.go new file mode 100644 index 0000000..b5472c8 --- /dev/null +++ b/internal/app/system/controller/upload.go @@ -0,0 +1,66 @@ +package controller + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + "github.com/tiger1103/gfast/v3/internal/app/common/service" +) + +var Upload = new(uploadController) + +type uploadController struct{} + +// 上传单图 +func (c *uploadController) SingleImg(ctx context.Context, req *system.UploadSingleImgReq) (res *system.UploadSingleRes, err error) { + file := req.File + v, _ := g.Cfg().Get(ctx, "upload.default") + response, err := service.Upload().UploadFile(ctx, file, consts.CheckFileTypeImg, v.Int()) + if err != nil { + return + } + res = &system.UploadSingleRes{ + UploadResponse: response, + } + // 上传第三方 + return +} + +// 上传多图 +func (c *uploadController) MultipleImg(ctx context.Context, req *system.UploadMultipleImgReq) (res *system.UploadMultipleRes, err error) { + files := req.File + v, _ := g.Cfg().Get(ctx, "upload.default") + mf, err := service.Upload().UploadFiles(ctx, files, consts.CheckFileTypeImg, v.Int()) + if err != nil { + return + } + res = &mf + return +} + +// 上传单文件 +func (c *uploadController) SingleFile(ctx context.Context, req *system.UploadSingleFileReq) (res *system.UploadSingleRes, err error) { + file := req.File + v, _ := g.Cfg().Get(ctx, "upload.default") + response, err := service.Upload().UploadFile(ctx, file, consts.CheckFileTypeFile, v.Int()) + if err != nil { + return + } + res = &system.UploadSingleRes{ + UploadResponse: response, + } + return +} + +// 上传多文件 +func (c *uploadController) MultipleFile(ctx context.Context, req *system.UploadMultipleFileReq) (res *system.UploadMultipleRes, err error) { + files := req.File + v, _ := g.Cfg().Get(ctx, "upload.default") + mf, err := service.Upload().UploadFiles(ctx, files, consts.CheckFileTypeFile, v.Int()) + if err != nil { + return + } + res = &mf + return +} diff --git a/internal/app/system/dao/big_file.go b/internal/app/system/dao/big_file.go new file mode 100644 index 0000000..f7db449 --- /dev/null +++ b/internal/app/system/dao/big_file.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// internalBigFileDao is internal type for wrapping internal DAO implements. +type internalBigFileDao = *internal.BigFileDao + +// bigFileDao is the data access object for table big_file. +// You can define custom methods on it to extend its functionality as you wish. +type bigFileDao struct { + internalBigFileDao +} + +var ( + // BigFile is globally public accessible object for table big_file operations. + BigFile = bigFileDao{ + internal.NewBigFileDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/internal/big_file.go b/internal/app/system/dao/internal/big_file.go new file mode 100644 index 0000000..4f60cb0 --- /dev/null +++ b/internal/app/system/dao/internal/big_file.go @@ -0,0 +1,98 @@ +// ========================================================================== +// Code generated 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" +) + +// BigFileDao is the data access object for table big_file. +type BigFileDao 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 BigFileColumns // columns contains all the column names of Table for convenient usage. +} + +// BigFileColumns defines and stores column names for table big_file. +type BigFileColumns struct { + Id string // + Name string // 文件名称 + Size string // 文件大小 + Path string // 文件相对路径 + FullPath string // 文件绝对路径 + MimeType string // 文件类型 + Source string // 文件来源 0 - 本地,1 - 腾讯云 2 - 七牛云 + Describe string // 描述 + Md5 string // md5 + CreatedBy string // + UpdatedBy string // + CreatedAt string // + UpdatedAt string // + DeletedAt string // +} + +// bigFileColumns holds the columns for table big_file. +var bigFileColumns = BigFileColumns{ + Id: "id", + Name: "name", + Size: "size", + Path: "path", + FullPath: "full_path", + MimeType: "mime_type", + Source: "source", + Describe: "describe", + Md5: "md5", + CreatedBy: "created_by", + UpdatedBy: "updated_by", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", +} + +// NewBigFileDao creates and returns a new DAO object for table data access. +func NewBigFileDao() *BigFileDao { + return &BigFileDao{ + group: "default", + table: "big_file", + columns: bigFileColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *BigFileDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *BigFileDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *BigFileDao) Columns() BigFileColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *BigFileDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *BigFileDao) 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 *BigFileDao) 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/internal/app/system/dao/internal/sys_auth_rule.go b/internal/app/system/dao/internal/sys_auth_rule.go new file mode 100644 index 0000000..0aa5a05 --- /dev/null +++ b/internal/app/system/dao/internal/sys_auth_rule.go @@ -0,0 +1,114 @@ +// ========================================================================== +// Code generated 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" +) + +// SysAuthRuleDao is the data access object for table sys_auth_rule. +type SysAuthRuleDao 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 SysAuthRuleColumns // columns contains all the column names of Table for convenient usage. +} + +// SysAuthRuleColumns defines and stores column names for table sys_auth_rule. +type SysAuthRuleColumns struct { + Id string // + Pid string // 父ID + Name string // 规则名称 + Title string // 规则名称 + Icon string // 图标 + Condition string // 条件 + Remark string // 备注 + MenuType string // 类型 0目录 1菜单 2按钮 + Weigh string // 权重 + IsHide string // 显示状态 + Path string // 路由地址 + Component string // 组件路径 + IsLink string // 是否外链 1是 0否 + ModuleType string // 所属模块 + ModelId string // 模型ID + IsIframe string // 是否内嵌iframe + IsCached string // 是否缓存 + Redirect string // 路由重定向地址 + IsAffix string // 是否固定 + LinkUrl string // 链接地址 + CreatedAt string // 创建日期 + UpdatedAt string // 修改日期 +} + +// sysAuthRuleColumns holds the columns for table sys_auth_rule. +var sysAuthRuleColumns = SysAuthRuleColumns{ + Id: "id", + Pid: "pid", + Name: "name", + Title: "title", + Icon: "icon", + Condition: "condition", + Remark: "remark", + MenuType: "menu_type", + Weigh: "weigh", + IsHide: "is_hide", + Path: "path", + Component: "component", + IsLink: "is_link", + ModuleType: "module_type", + ModelId: "model_id", + IsIframe: "is_iframe", + IsCached: "is_cached", + Redirect: "redirect", + IsAffix: "is_affix", + LinkUrl: "link_url", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} + +// NewSysAuthRuleDao creates and returns a new DAO object for table data access. +func NewSysAuthRuleDao() *SysAuthRuleDao { + return &SysAuthRuleDao{ + group: "default", + table: "sys_auth_rule", + columns: sysAuthRuleColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysAuthRuleDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysAuthRuleDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysAuthRuleDao) Columns() SysAuthRuleColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysAuthRuleDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysAuthRuleDao) 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 *SysAuthRuleDao) 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/internal/app/system/dao/internal/sys_dept.go b/internal/app/system/dao/internal/sys_dept.go new file mode 100644 index 0000000..ca166b7 --- /dev/null +++ b/internal/app/system/dao/internal/sys_dept.go @@ -0,0 +1,98 @@ +// ========================================================================== +// Code generated 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" +) + +// SysDeptDao is the data access object for table sys_dept. +type SysDeptDao 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 SysDeptColumns // columns contains all the column names of Table for convenient usage. +} + +// SysDeptColumns defines and stores column names for table sys_dept. +type SysDeptColumns struct { + DeptId string // 部门id + ParentId string // 父部门id + Ancestors string // 祖级列表 + DeptName string // 部门名称 + OrderNum string // 显示顺序 + Leader string // 负责人 + Phone string // 联系电话 + Email string // 邮箱 + Status string // 部门状态(0正常 1停用) + CreatedBy string // 创建人 + UpdatedBy string // 修改人 + CreatedAt string // 创建时间 + UpdatedAt string // 修改时间 + DeletedAt string // 删除时间 +} + +// sysDeptColumns holds the columns for table sys_dept. +var sysDeptColumns = SysDeptColumns{ + DeptId: "dept_id", + ParentId: "parent_id", + Ancestors: "ancestors", + DeptName: "dept_name", + OrderNum: "order_num", + Leader: "leader", + Phone: "phone", + Email: "email", + Status: "status", + CreatedBy: "created_by", + UpdatedBy: "updated_by", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", +} + +// NewSysDeptDao creates and returns a new DAO object for table data access. +func NewSysDeptDao() *SysDeptDao { + return &SysDeptDao{ + group: "default", + table: "sys_dept", + columns: sysDeptColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysDeptDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysDeptDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysDeptDao) Columns() SysDeptColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysDeptDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysDeptDao) 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 *SysDeptDao) 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/internal/app/system/dao/internal/sys_job.go b/internal/app/system/dao/internal/sys_job.go new file mode 100644 index 0000000..21ebcc9 --- /dev/null +++ b/internal/app/system/dao/internal/sys_job.go @@ -0,0 +1,102 @@ +// ========================================================================== +// GFast自动生成dao internal操作代码。 +// 生成日期:2023-01-12 17:43:50 +// 生成路径: internal/app/system/dao/internal/sys_job.go +// 生成人:gfast +// desc:定时任务 +// company:云南奇讯科技有限公司 +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysJobDao is the manager for logic model data accessing and custom defined data operations functions management. +type SysJobDao 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 SysJobColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage. +} + +// SysJobColumns defines and stores column names for table sys_job. +type SysJobColumns struct { + JobId string // 任务ID + JobName string // 任务名称 + JobParams string // 参数 + JobGroup string // 任务组名 + InvokeTarget string // 任务方法 + CronExpression string // cron执行表达式 + MisfirePolicy string // 计划执行策略 + Concurrent string // 是否并发执行 + Status string // 状态 + CreatedBy string // 创建者 + UpdatedBy string // 更新者 + Remark string // 备注信息 + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 +} + +var sysJobColumns = SysJobColumns{ + JobId: "job_id", + JobName: "job_name", + JobParams: "job_params", + JobGroup: "job_group", + InvokeTarget: "invoke_target", + CronExpression: "cron_expression", + MisfirePolicy: "misfire_policy", + Concurrent: "concurrent", + Status: "status", + CreatedBy: "created_by", + UpdatedBy: "updated_by", + Remark: "remark", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} + +// NewSysJobDao creates and returns a new DAO object for table data access. +func NewSysJobDao() *SysJobDao { + return &SysJobDao{ + group: "default", + table: "sys_job", + columns: sysJobColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysJobDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysJobDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysJobDao) Columns() SysJobColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysJobDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysJobDao) 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 *SysJobDao) 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/internal/app/system/dao/internal/sys_job_log.go b/internal/app/system/dao/internal/sys_job_log.go new file mode 100644 index 0000000..463364b --- /dev/null +++ b/internal/app/system/dao/internal/sys_job_log.go @@ -0,0 +1,79 @@ +// ========================================================================== +// Code generated 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" +) + +// SysJobLogDao is the data access object for table sys_job_log. +type SysJobLogDao 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 SysJobLogColumns // columns contains all the column names of Table for convenient usage. +} + +// SysJobLogColumns defines and stores column names for table sys_job_log. +type SysJobLogColumns struct { + Id string // 主键 + TargetName string // 方法名 + CreatedAt string // 执行日期 + Result string // 执行结果 +} + +// sysJobLogColumns holds the columns for table sys_job_log. +var sysJobLogColumns = SysJobLogColumns{ + Id: "id", + TargetName: "target_name", + CreatedAt: "created_at", + Result: "result", +} + +// NewSysJobLogDao creates and returns a new DAO object for table data access. +func NewSysJobLogDao() *SysJobLogDao { + return &SysJobLogDao{ + group: "default", + table: "sys_job_log", + columns: sysJobLogColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysJobLogDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysJobLogDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysJobLogDao) Columns() SysJobLogColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysJobLogDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysJobLogDao) 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 *SysJobLogDao) 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/internal/app/system/dao/internal/sys_login_log.go b/internal/app/system/dao/internal/sys_login_log.go new file mode 100644 index 0000000..110fde2 --- /dev/null +++ b/internal/app/system/dao/internal/sys_login_log.go @@ -0,0 +1,90 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-08 11:31:48 +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysLoginLogDao is the data access object for table sys_login_log. +type SysLoginLogDao 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 SysLoginLogColumns // columns contains all the column names of Table for convenient usage. +} + +// SysLoginLogColumns defines and stores column names for table sys_login_log. +type SysLoginLogColumns struct { + InfoId string // 访问ID + LoginName string // 登录账号 + Ipaddr string // 登录IP地址 + LoginLocation string // 登录地点 + Browser string // 浏览器类型 + Os string // 操作系统 + Status string // 登录状态(0成功 1失败) + Msg string // 提示消息 + LoginTime string // 登录时间 + Module string // 登录模块 +} + +// sysLoginLogColumns holds the columns for table sys_login_log. +var sysLoginLogColumns = SysLoginLogColumns{ + InfoId: "info_id", + LoginName: "login_name", + Ipaddr: "ipaddr", + LoginLocation: "login_location", + Browser: "browser", + Os: "os", + Status: "status", + Msg: "msg", + LoginTime: "login_time", + Module: "module", +} + +// NewSysLoginLogDao creates and returns a new DAO object for table data access. +func NewSysLoginLogDao() *SysLoginLogDao { + return &SysLoginLogDao{ + group: "default", + table: "sys_login_log", + columns: sysLoginLogColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysLoginLogDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysLoginLogDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysLoginLogDao) Columns() SysLoginLogColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysLoginLogDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysLoginLogDao) 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 *SysLoginLogDao) 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/internal/app/system/dao/internal/sys_oper_log.go b/internal/app/system/dao/internal/sys_oper_log.go new file mode 100644 index 0000000..ec36f6a --- /dev/null +++ b/internal/app/system/dao/internal/sys_oper_log.go @@ -0,0 +1,99 @@ +// ========================================================================== +// Code generated 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" +) + +// SysOperLogDao is the data access object for table sys_oper_log. +type SysOperLogDao 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 SysOperLogColumns // columns contains all the column names of Table for convenient usage. +} + +// SysOperLogColumns defines and stores column names for table sys_oper_log. +type SysOperLogColumns struct { + OperId string // 日志主键 + Title string // 模块标题 + BusinessType string // 业务类型(0其它 1新增 2修改 3删除) + Method string // 方法名称 + RequestMethod string // 请求方式 + OperatorType string // 操作类别(0其它 1后台用户 2手机端用户) + OperName string // 操作人员 + DeptName string // 部门名称 + OperUrl string // 请求URL + OperIp string // 主机地址 + OperLocation string // 操作地点 + OperParam string // 请求参数 + ErrorMsg string // 错误消息 + OperTime string // 操作时间 +} + +// sysOperLogColumns holds the columns for table sys_oper_log. +var sysOperLogColumns = SysOperLogColumns{ + OperId: "oper_id", + Title: "title", + BusinessType: "business_type", + Method: "method", + RequestMethod: "request_method", + OperatorType: "operator_type", + OperName: "oper_name", + DeptName: "dept_name", + OperUrl: "oper_url", + OperIp: "oper_ip", + OperLocation: "oper_location", + OperParam: "oper_param", + ErrorMsg: "error_msg", + OperTime: "oper_time", +} + +// NewSysOperLogDao creates and returns a new DAO object for table data access. +func NewSysOperLogDao() *SysOperLogDao { + return &SysOperLogDao{ + group: "default", + table: "sys_oper_log", + columns: sysOperLogColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysOperLogDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysOperLogDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysOperLogDao) Columns() SysOperLogColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysOperLogDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysOperLogDao) 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 *SysOperLogDao) 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/internal/app/system/dao/internal/sys_post.go b/internal/app/system/dao/internal/sys_post.go new file mode 100644 index 0000000..6c2afab --- /dev/null +++ b/internal/app/system/dao/internal/sys_post.go @@ -0,0 +1,92 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-07 23:26:21 +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysPostDao is the data access object for table sys_post. +type SysPostDao 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 SysPostColumns // columns contains all the column names of Table for convenient usage. +} + +// SysPostColumns defines and stores column names for table sys_post. +type SysPostColumns struct { + PostId string // 岗位ID + PostCode string // 岗位编码 + PostName string // 岗位名称 + PostSort string // 显示顺序 + Status string // 状态(0正常 1停用) + Remark string // 备注 + CreatedBy string // 创建人 + UpdatedBy string // 修改人 + CreatedAt string // 创建时间 + UpdatedAt string // 修改时间 + DeletedAt string // 删除时间 +} + +// sysPostColumns holds the columns for table sys_post. +var sysPostColumns = SysPostColumns{ + PostId: "post_id", + PostCode: "post_code", + PostName: "post_name", + PostSort: "post_sort", + Status: "status", + Remark: "remark", + CreatedBy: "created_by", + UpdatedBy: "updated_by", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", +} + +// NewSysPostDao creates and returns a new DAO object for table data access. +func NewSysPostDao() *SysPostDao { + return &SysPostDao{ + group: "default", + table: "sys_post", + columns: sysPostColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysPostDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysPostDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysPostDao) Columns() SysPostColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysPostDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysPostDao) 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 *SysPostDao) 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/internal/app/system/dao/internal/sys_role.go b/internal/app/system/dao/internal/sys_role.go new file mode 100644 index 0000000..d07aede --- /dev/null +++ b/internal/app/system/dao/internal/sys_role.go @@ -0,0 +1,86 @@ +// ========================================================================== +// Code generated 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" +) + +// SysRoleDao is the data access object for table sys_role. +type SysRoleDao 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 SysRoleColumns // columns contains all the column names of Table for convenient usage. +} + +// SysRoleColumns defines and stores column names for table sys_role. +type SysRoleColumns struct { + Id string // + Status string // 状态;0:禁用;1:正常 + ListOrder string // 排序 + Name string // 角色名称 + Remark string // 备注 + DataScope string // 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 +} + +// sysRoleColumns holds the columns for table sys_role. +var sysRoleColumns = SysRoleColumns{ + Id: "id", + Status: "status", + ListOrder: "list_order", + Name: "name", + Remark: "remark", + DataScope: "data_scope", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} + +// NewSysRoleDao creates and returns a new DAO object for table data access. +func NewSysRoleDao() *SysRoleDao { + return &SysRoleDao{ + group: "default", + table: "sys_role", + columns: sysRoleColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysRoleDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysRoleDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysRoleDao) Columns() SysRoleColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysRoleDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysRoleDao) 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 *SysRoleDao) 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/internal/app/system/dao/internal/sys_role_dept.go b/internal/app/system/dao/internal/sys_role_dept.go new file mode 100644 index 0000000..19e2f0e --- /dev/null +++ b/internal/app/system/dao/internal/sys_role_dept.go @@ -0,0 +1,75 @@ +// ========================================================================== +// Code generated 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" +) + +// SysRoleDeptDao is the data access object for table sys_role_dept. +type SysRoleDeptDao 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 SysRoleDeptColumns // columns contains all the column names of Table for convenient usage. +} + +// SysRoleDeptColumns defines and stores column names for table sys_role_dept. +type SysRoleDeptColumns struct { + RoleId string // 角色ID + DeptId string // 部门ID +} + +// sysRoleDeptColumns holds the columns for table sys_role_dept. +var sysRoleDeptColumns = SysRoleDeptColumns{ + RoleId: "role_id", + DeptId: "dept_id", +} + +// NewSysRoleDeptDao creates and returns a new DAO object for table data access. +func NewSysRoleDeptDao() *SysRoleDeptDao { + return &SysRoleDeptDao{ + group: "default", + table: "sys_role_dept", + columns: sysRoleDeptColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysRoleDeptDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysRoleDeptDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysRoleDeptDao) Columns() SysRoleDeptColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysRoleDeptDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysRoleDeptDao) 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 *SysRoleDeptDao) 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/internal/app/system/dao/internal/sys_user.go b/internal/app/system/dao/internal/sys_user.go new file mode 100644 index 0000000..53c4d5b --- /dev/null +++ b/internal/app/system/dao/internal/sys_user.go @@ -0,0 +1,112 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-02 16:48:23 +// ========================================================================== + +package internal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SysUserDao is the data access object for table sys_user. +type SysUserDao 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 SysUserColumns // columns contains all the column names of Table for convenient usage. +} + +// SysUserColumns defines and stores column names for table sys_user. +type SysUserColumns struct { + Id string // + UserName string // 用户名 + Mobile string // 中国手机不带国家代码,国际手机号格式为:国家代码-手机号 + UserNickname string // 用户昵称 + Birthday string // 生日 + UserPassword string // 登录密码;cmf_password加密 + UserSalt string // 加密盐 + UserStatus string // 用户状态;0:禁用,1:正常,2:未验证 + UserEmail string // 用户登录邮箱 + Sex string // 性别;0:保密,1:男,2:女 + Avatar string // 用户头像 + DeptId string // 部门id + Remark string // 备注 + IsAdmin string // 是否后台管理员 1 是 0 否 + Address string // 联系地址 + Describe string // 描述信息 + LastLoginIp string // 最后登录ip + LastLoginTime string // 最后登录时间 + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 + DeletedAt string // 删除时间 +} + +// sysUserColumns holds the columns for table sys_user. +var sysUserColumns = SysUserColumns{ + Id: "id", + UserName: "user_name", + Mobile: "mobile", + UserNickname: "user_nickname", + Birthday: "birthday", + UserPassword: "user_password", + UserSalt: "user_salt", + UserStatus: "user_status", + UserEmail: "user_email", + Sex: "sex", + Avatar: "avatar", + DeptId: "dept_id", + Remark: "remark", + IsAdmin: "is_admin", + Address: "address", + Describe: "describe", + LastLoginIp: "last_login_ip", + LastLoginTime: "last_login_time", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", +} + +// NewSysUserDao creates and returns a new DAO object for table data access. +func NewSysUserDao() *SysUserDao { + return &SysUserDao{ + group: "default", + table: "sys_user", + columns: sysUserColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysUserDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysUserDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysUserDao) Columns() SysUserColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysUserDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysUserDao) 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 *SysUserDao) 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/internal/app/system/dao/internal/sys_user_online.go b/internal/app/system/dao/internal/sys_user_online.go new file mode 100644 index 0000000..775ccd5 --- /dev/null +++ b/internal/app/system/dao/internal/sys_user_online.go @@ -0,0 +1,87 @@ +// ========================================================================== +// Code generated 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" +) + +// SysUserOnlineDao is the data access object for table sys_user_online. +type SysUserOnlineDao 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 SysUserOnlineColumns // columns contains all the column names of Table for convenient usage. +} + +// SysUserOnlineColumns defines and stores column names for table sys_user_online. +type SysUserOnlineColumns struct { + Id string // + Uuid string // 用户标识 + Token string // 用户token + CreateTime string // 登录时间 + UserName string // 用户名 + Ip string // 登录ip + Explorer string // 浏览器 + Os string // 操作系统 +} + +// sysUserOnlineColumns holds the columns for table sys_user_online. +var sysUserOnlineColumns = SysUserOnlineColumns{ + Id: "id", + Uuid: "uuid", + Token: "token", + CreateTime: "create_time", + UserName: "user_name", + Ip: "ip", + Explorer: "explorer", + Os: "os", +} + +// NewSysUserOnlineDao creates and returns a new DAO object for table data access. +func NewSysUserOnlineDao() *SysUserOnlineDao { + return &SysUserOnlineDao{ + group: "default", + table: "sys_user_online", + columns: sysUserOnlineColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysUserOnlineDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysUserOnlineDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysUserOnlineDao) Columns() SysUserOnlineColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysUserOnlineDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysUserOnlineDao) 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 *SysUserOnlineDao) 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/internal/app/system/dao/internal/sys_user_post.go b/internal/app/system/dao/internal/sys_user_post.go new file mode 100644 index 0000000..4385fd5 --- /dev/null +++ b/internal/app/system/dao/internal/sys_user_post.go @@ -0,0 +1,74 @@ +// ========================================================================== +// Code generated 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" +) + +// SysUserPostDao is the data access object for table sys_user_post. +type SysUserPostDao 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 SysUserPostColumns // columns contains all the column names of Table for convenient usage. +} + +// SysUserPostColumns defines and stores column names for table sys_user_post. +type SysUserPostColumns struct { + UserId string // 用户ID + PostId string // 岗位ID +} + +// sysUserPostColumns holds the columns for table sys_user_post. +var sysUserPostColumns = SysUserPostColumns{ + UserId: "user_id", + PostId: "post_id", +} + +// NewSysUserPostDao creates and returns a new DAO object for table data access. +func NewSysUserPostDao() *SysUserPostDao { + return &SysUserPostDao{ + group: "default", + table: "sys_user_post", + columns: sysUserPostColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SysUserPostDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SysUserPostDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SysUserPostDao) Columns() SysUserPostColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SysUserPostDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SysUserPostDao) 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 *SysUserPostDao) 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/internal/app/system/dao/internal/tools_gen_table.go b/internal/app/system/dao/internal/tools_gen_table.go new file mode 100644 index 0000000..839b963 --- /dev/null +++ b/internal/app/system/dao/internal/tools_gen_table.go @@ -0,0 +1,107 @@ +// ========================================================================== +// Code generated 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" +) + +// ToolsGenTableDao is the data access object for table tools_gen_table. +type ToolsGenTableDao 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 ToolsGenTableColumns // columns contains all the column names of Table for convenient usage. +} + +// ToolsGenTableColumns defines and stores column names for table tools_gen_table. +type ToolsGenTableColumns struct { + TableId string // 编号 + TableName string // 表名称 + TableComment string // 表描述 + ClassName string // 实体类名称 + TplCategory string // 使用的模板(crud单表操作 tree树表操作) + PackageName string // 生成包路径 + ModuleName string // 生成模块名 + BusinessName string // 生成业务名 + FunctionName string // 生成功能名 + FunctionAuthor string // 生成功能作者 + Options string // 其它生成选项 + CreateTime string // 创建时间 + UpdateTime string // 更新时间 + Remark string // 备注 + Overwrite string // 是否覆盖原有文件 + SortColumn string // 排序字段名 + SortType string // 排序方式 (asc顺序 desc倒序) + ShowDetail string // 是否有查看详情功能 +} + +// toolsGenTableColumns holds the columns for table tools_gen_table. +var toolsGenTableColumns = ToolsGenTableColumns{ + TableId: "table_id", + TableName: "table_name", + TableComment: "table_comment", + ClassName: "class_name", + TplCategory: "tpl_category", + PackageName: "package_name", + ModuleName: "module_name", + BusinessName: "business_name", + FunctionName: "function_name", + FunctionAuthor: "function_author", + Options: "options", + CreateTime: "create_time", + UpdateTime: "update_time", + Remark: "remark", + Overwrite: "overwrite", + SortColumn: "sort_column", + SortType: "sort_type", + ShowDetail: "show_detail", +} + +// NewToolsGenTableDao creates and returns a new DAO object for table data access. +func NewToolsGenTableDao() *ToolsGenTableDao { + return &ToolsGenTableDao{ + group: "default", + table: "tools_gen_table", + columns: toolsGenTableColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *ToolsGenTableDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *ToolsGenTableDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *ToolsGenTableDao) Columns() ToolsGenTableColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *ToolsGenTableDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *ToolsGenTableDao) 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 *ToolsGenTableDao) 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/internal/app/system/dao/internal/tools_gen_table_column.go b/internal/app/system/dao/internal/tools_gen_table_column.go new file mode 100644 index 0000000..313f9e4 --- /dev/null +++ b/internal/app/system/dao/internal/tools_gen_table_column.go @@ -0,0 +1,151 @@ +// ========================================================================== +// Code generated 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" +) + +// ToolsGenTableColumnDao is the data access object for table tools_gen_table_column. +type ToolsGenTableColumnDao 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 ToolsGenTableColumnColumns // columns contains all the column names of Table for convenient usage. +} + +// ToolsGenTableColumnColumns defines and stores column names for table tools_gen_table_column. +type ToolsGenTableColumnColumns struct { + ColumnId string // 编号 + TableId string // 归属表编号 + ColumnName string // 列名称 + ColumnComment string // 列描述 + ColumnType string // 列类型 + GoType string // Go类型 + TsType string // TS类型 + GoField string // Go字段名 + HtmlField string // html字段名 + IsPk string // 是否主键(1是) + IsIncrement string // 是否自增(1是) + IsRequired string // 是否必填(1是) + IsInsert string // 是否为插入字段(1是) + IsEdit string // 是否编辑字段(1是) + IsList string // 是否列表字段(1是) + IsDetail string // 是否详情字段 + IsQuery string // 是否查询字段(1是) + SortOrderEdit string // 插入编辑显示顺序 + SortOrderList string // 列表显示顺序 + SortOrderDetail string // 详情显示顺序 + SortOrderQuery string // 查询显示顺序 + QueryType string // 查询方式(等于、不等于、大于、小于、范围) + HtmlType string // 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件) + DictType string // 字典类型 + LinkTableName string // 关联表名 + LinkTableClass string // 关联表类名 + LinkTableModuleName string // 关联表模块名 + LinkTableBusinessName string // 关联表业务名 + LinkTablePackage string // 关联表包名 + LinkLabelId string // 关联表键名 + LinkLabelName string // 关联表字段值 + ColSpan string // 详情页占列数 + RowSpan string // 详情页占行数 + IsRowStart string // 详情页为行首 + MinWidth string // 表格最小宽度 + IsFixed string // 是否表格列左固定 + IsOverflowTooltip string // 是否过长自动隐藏 + IsCascade string // 是否级联查询 + ParentColumnName string // 上级字段名 + CascadeColumnName string // 级联查询字段 +} + +// toolsGenTableColumnColumns holds the columns for table tools_gen_table_column. +var toolsGenTableColumnColumns = ToolsGenTableColumnColumns{ + ColumnId: "column_id", + TableId: "table_id", + ColumnName: "column_name", + ColumnComment: "column_comment", + ColumnType: "column_type", + GoType: "go_type", + TsType: "ts_type", + GoField: "go_field", + HtmlField: "html_field", + IsPk: "is_pk", + IsIncrement: "is_increment", + IsRequired: "is_required", + IsInsert: "is_insert", + IsEdit: "is_edit", + IsList: "is_list", + IsDetail: "is_detail", + IsQuery: "is_query", + SortOrderEdit: "sort_order_edit", + SortOrderList: "sort_order_list", + SortOrderDetail: "sort_order_detail", + SortOrderQuery: "sort_order_query", + QueryType: "query_type", + HtmlType: "html_type", + DictType: "dict_type", + LinkTableName: "link_table_name", + LinkTableClass: "link_table_class", + LinkTableModuleName: "link_table_module_name", + LinkTableBusinessName: "link_table_business_name", + LinkTablePackage: "link_table_package", + LinkLabelId: "link_label_id", + LinkLabelName: "link_label_name", + ColSpan: "col_span", + RowSpan: "row_span", + IsRowStart: "is_row_start", + MinWidth: "min_width", + IsFixed: "is_fixed", + IsOverflowTooltip: "is_overflow_tooltip", + IsCascade: "is_cascade", + ParentColumnName: "parent_column_name", + CascadeColumnName: "cascade_column_name", +} + +// NewToolsGenTableColumnDao creates and returns a new DAO object for table data access. +func NewToolsGenTableColumnDao() *ToolsGenTableColumnDao { + return &ToolsGenTableColumnDao{ + group: "default", + table: "tools_gen_table_column", + columns: toolsGenTableColumnColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *ToolsGenTableColumnDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *ToolsGenTableColumnDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *ToolsGenTableColumnDao) Columns() ToolsGenTableColumnColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *ToolsGenTableColumnDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *ToolsGenTableColumnDao) 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 *ToolsGenTableColumnDao) 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/internal/app/system/dao/sys_auth_rule.go b/internal/app/system/dao/sys_auth_rule.go new file mode 100644 index 0000000..de4dfd0 --- /dev/null +++ b/internal/app/system/dao/sys_auth_rule.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// sysAuthRuleDao is the data access object for table sys_auth_rule. +// You can define custom methods on it to extend its functionality as you wish. +type sysAuthRuleDao struct { + *internal.SysAuthRuleDao +} + +var ( + // SysAuthRule is globally public accessible object for table sys_auth_rule operations. + SysAuthRule = sysAuthRuleDao{ + internal.NewSysAuthRuleDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_dept.go b/internal/app/system/dao/sys_dept.go new file mode 100644 index 0000000..4a40ace --- /dev/null +++ b/internal/app/system/dao/sys_dept.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// internalSysDeptDao is internal type for wrapping internal DAO implements. +type internalSysDeptDao = *internal.SysDeptDao + +// sysDeptDao is the data access object for table sys_dept. +// You can define custom methods on it to extend its functionality as you wish. +type sysDeptDao struct { + internalSysDeptDao +} + +var ( + // SysDept is globally public accessible object for table sys_dept operations. + SysDept = sysDeptDao{ + internal.NewSysDeptDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_job.go b/internal/app/system/dao/sys_job.go new file mode 100644 index 0000000..0bd7cbc --- /dev/null +++ b/internal/app/system/dao/sys_job.go @@ -0,0 +1,29 @@ +// ========================================================================== +// GFast自动生成dao操作代码。 +// 生成日期:2023-01-12 17:43:50 +// 生成路径: internal/app/system/dao/sys_job.go +// 生成人:gfast +// desc:定时任务 +// company:云南奇讯科技有限公司 +// ========================================================================== + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// sysJobDao is the manager for logic model data accessing and custom defined data operations functions management. +// You can define custom methods on it to extend its functionality as you wish. +type sysJobDao struct { + *internal.SysJobDao +} + +var ( + // SysJob is globally public accessible object for table tools_gen_table operations. + SysJob = sysJobDao{ + internal.NewSysJobDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_job_log.go b/internal/app/system/dao/sys_job_log.go new file mode 100644 index 0000000..e69ffdf --- /dev/null +++ b/internal/app/system/dao/sys_job_log.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// internalSysJobLogDao is internal type for wrapping internal DAO implements. +type internalSysJobLogDao = *internal.SysJobLogDao + +// sysJobLogDao is the data access object for table sys_job_log. +// You can define custom methods on it to extend its functionality as you wish. +type sysJobLogDao struct { + internalSysJobLogDao +} + +var ( + // SysJobLog is globally public accessible object for table sys_job_log operations. + SysJobLog = sysJobLogDao{ + internal.NewSysJobLogDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_login_log.go b/internal/app/system/dao/sys_login_log.go new file mode 100644 index 0000000..1b7359f --- /dev/null +++ b/internal/app/system/dao/sys_login_log.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// sysLoginLogDao is the data access object for table sys_login_log. +// You can define custom methods on it to extend its functionality as you wish. +type sysLoginLogDao struct { + *internal.SysLoginLogDao +} + +var ( + // SysLoginLog is globally public accessible object for table sys_login_log operations. + SysLoginLog = sysLoginLogDao{ + internal.NewSysLoginLogDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_oper_log.go b/internal/app/system/dao/sys_oper_log.go new file mode 100644 index 0000000..26e1291 --- /dev/null +++ b/internal/app/system/dao/sys_oper_log.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// internalSysOperLogDao is internal type for wrapping internal DAO implements. +type internalSysOperLogDao = *internal.SysOperLogDao + +// sysOperLogDao is the data access object for table sys_oper_log. +// You can define custom methods on it to extend its functionality as you wish. +type sysOperLogDao struct { + internalSysOperLogDao +} + +var ( + // SysOperLog is globally public accessible object for table sys_oper_log operations. + SysOperLog = sysOperLogDao{ + internal.NewSysOperLogDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_post.go b/internal/app/system/dao/sys_post.go new file mode 100644 index 0000000..a3bb45f --- /dev/null +++ b/internal/app/system/dao/sys_post.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// sysPostDao is the data access object for table sys_post. +// You can define custom methods on it to extend its functionality as you wish. +type sysPostDao struct { + *internal.SysPostDao +} + +var ( + // SysPost is globally public accessible object for table sys_post operations. + SysPost = sysPostDao{ + internal.NewSysPostDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_role.go b/internal/app/system/dao/sys_role.go new file mode 100644 index 0000000..edb6eaa --- /dev/null +++ b/internal/app/system/dao/sys_role.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// sysRoleDao is the data access object for table sys_role. +// You can define custom methods on it to extend its functionality as you wish. +type sysRoleDao struct { + *internal.SysRoleDao +} + +var ( + // SysRole is globally public accessible object for table sys_role operations. + SysRole = sysRoleDao{ + internal.NewSysRoleDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_role_dept.go b/internal/app/system/dao/sys_role_dept.go new file mode 100644 index 0000000..cf7785d --- /dev/null +++ b/internal/app/system/dao/sys_role_dept.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// internalSysRoleDeptDao is internal type for wrapping internal DAO implements. +type internalSysRoleDeptDao = *internal.SysRoleDeptDao + +// sysRoleDeptDao is the data access object for table sys_role_dept. +// You can define custom methods on it to extend its functionality as you wish. +type sysRoleDeptDao struct { + internalSysRoleDeptDao +} + +var ( + // SysRoleDept is globally public accessible object for table sys_role_dept operations. + SysRoleDept = sysRoleDeptDao{ + internal.NewSysRoleDeptDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_user.go b/internal/app/system/dao/sys_user.go new file mode 100644 index 0000000..0eb491b --- /dev/null +++ b/internal/app/system/dao/sys_user.go @@ -0,0 +1,24 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// sysUserDao is the data access object for table sys_user. +// You can define custom methods on it to extend its functionality as you wish. +type sysUserDao struct { + *internal.SysUserDao +} + +var ( + // SysUser is globally public accessible object for table sys_user operations. + SysUser = sysUserDao{ + internal.NewSysUserDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_user_online.go b/internal/app/system/dao/sys_user_online.go new file mode 100644 index 0000000..1b43938 --- /dev/null +++ b/internal/app/system/dao/sys_user_online.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// internalSysUserOnlineDao is internal type for wrapping internal DAO implements. +type internalSysUserOnlineDao = *internal.SysUserOnlineDao + +// sysUserOnlineDao is the data access object for table sys_user_online. +// You can define custom methods on it to extend its functionality as you wish. +type sysUserOnlineDao struct { + internalSysUserOnlineDao +} + +var ( + // SysUserOnline is globally public accessible object for table sys_user_online operations. + SysUserOnline = sysUserOnlineDao{ + internal.NewSysUserOnlineDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/sys_user_post.go b/internal/app/system/dao/sys_user_post.go new file mode 100644 index 0000000..b31dfbd --- /dev/null +++ b/internal/app/system/dao/sys_user_post.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// internalSysUserPostDao is internal type for wrapping internal DAO implements. +type internalSysUserPostDao = *internal.SysUserPostDao + +// sysUserPostDao is the data access object for table sys_user_post. +// You can define custom methods on it to extend its functionality as you wish. +type sysUserPostDao struct { + internalSysUserPostDao +} + +var ( + // SysUserPost is globally public accessible object for table sys_user_post operations. + SysUserPost = sysUserPostDao{ + internal.NewSysUserPostDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/tools_gen_table.go b/internal/app/system/dao/tools_gen_table.go new file mode 100644 index 0000000..bb727c5 --- /dev/null +++ b/internal/app/system/dao/tools_gen_table.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// internalToolsGenTableDao is internal type for wrapping internal DAO implements. +type internalToolsGenTableDao = *internal.ToolsGenTableDao + +// toolsGenTableDao is the data access object for table tools_gen_table. +// You can define custom methods on it to extend its functionality as you wish. +type toolsGenTableDao struct { + internalToolsGenTableDao +} + +var ( + // ToolsGenTable is globally public accessible object for table tools_gen_table operations. + ToolsGenTable = toolsGenTableDao{ + internal.NewToolsGenTableDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/dao/tools_gen_table_column.go b/internal/app/system/dao/tools_gen_table_column.go new file mode 100644 index 0000000..984fb20 --- /dev/null +++ b/internal/app/system/dao/tools_gen_table_column.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/dao/internal" +) + +// internalToolsGenTableColumnDao is internal type for wrapping internal DAO implements. +type internalToolsGenTableColumnDao = *internal.ToolsGenTableColumnDao + +// toolsGenTableColumnDao is the data access object for table tools_gen_table_column. +// You can define custom methods on it to extend its functionality as you wish. +type toolsGenTableColumnDao struct { + internalToolsGenTableColumnDao +} + +var ( + // ToolsGenTableColumn is globally public accessible object for table tools_gen_table_column operations. + ToolsGenTableColumn = toolsGenTableColumnDao{ + internal.NewToolsGenTableColumnDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/app/system/logic/context/context.go b/internal/app/system/logic/context/context.go new file mode 100644 index 0000000..938f2cd --- /dev/null +++ b/internal/app/system/logic/context/context.go @@ -0,0 +1,66 @@ +/* +* @desc:context-service +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/23 14:51 + */ + +package context + +import ( + "context" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +func init() { + service.RegisterContext(New()) +} + +type sContext struct{} + +func New() *sContext { + return &sContext{} +} + +// Init 初始化上下文对象指针到上下文对象中,以便后续的请求流程中可以修改。 +func (s *sContext) Init(r *ghttp.Request, customCtx *model.Context) { + r.SetCtxVar(consts.CtxKey, customCtx) +} + +// Get 获得上下文变量,如果没有设置,那么返回nil +func (s *sContext) Get(ctx context.Context) *model.Context { + value := ctx.Value(consts.CtxKey) + if value == nil { + return nil + } + if localCtx, ok := value.(*model.Context); ok { + return localCtx + } + return nil +} + +// SetUser 将上下文信息设置到上下文请求中,注意是完整覆盖 +func (s *sContext) SetUser(ctx context.Context, ctxUser *model.ContextUser) { + s.Get(ctx).User = ctxUser +} + +// GetLoginUser 获取当前登陆用户信息 +func (s *sContext) GetLoginUser(ctx context.Context) *model.ContextUser { + context := s.Get(ctx) + if context == nil { + return nil + } + return context.User +} + +// GetUserId 获取当前登录用户id +func (s *sContext) GetUserId(ctx context.Context) uint64 { + user := s.GetLoginUser(ctx) + if user != nil { + return user.Id + } + return 0 +} diff --git a/internal/app/system/logic/logic.go b/internal/app/system/logic/logic.go new file mode 100644 index 0000000..a519401 --- /dev/null +++ b/internal/app/system/logic/logic.go @@ -0,0 +1,19 @@ +package logic + +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/context" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/middleware" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/personal" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysAuthRule" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysDept" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysJob" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysJobLog" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysLoginLog" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysOperLog" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysPost" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysRole" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysUser" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/sysUserOnline" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/token" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/toolsGenTable" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/toolsGenTableColumn" +import _ "github.com/tiger1103/gfast/v3/internal/app/system/logic/timeTask" diff --git a/internal/app/system/logic/middleware/middleware.go b/internal/app/system/logic/middleware/middleware.go new file mode 100644 index 0000000..a575b88 --- /dev/null +++ b/internal/app/system/logic/middleware/middleware.go @@ -0,0 +1,127 @@ +/* +* @desc:中间件 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/23 15:05 + */ + +package middleware + +import ( + "fmt" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/libResponse" +) + +func init() { + service.RegisterMiddleware(New()) +} + +func New() *sMiddleware { + return &sMiddleware{} +} + +type sMiddleware struct{} + +// Ctx 自定义上下文对象 +func (s *sMiddleware) Ctx(r *ghttp.Request) { + ctx := r.GetCtx() + // 初始化登录用户信息 + data, err := service.GfToken().ParseToken(r) + if err != nil { + // 执行下一步请求逻辑 + r.Middleware.Next() + } + if data != nil { + context := new(model.Context) + err = gconv.Struct(data.Data, &context.User) + if err != nil { + g.Log().Error(ctx, err) + // 执行下一步请求逻辑 + r.Middleware.Next() + } + service.Context().Init(r, context) + } + // 执行下一步请求逻辑 + r.Middleware.Next() +} + +// Auth 权限判断处理中间件 +func (s *sMiddleware) Auth(r *ghttp.Request) { + ctx := r.GetCtx() + //获取登陆用户id + adminId := service.Context().GetUserId(ctx) + accessParams := r.Get("accessParams").Strings() + accessParamsStr := "" + if len(accessParams) > 0 && accessParams[0] != "undefined" { + accessParamsStr = "?" + gstr.Join(accessParams, "&") + } + url := gstr.TrimLeft(r.Request.URL.Path, "/") + accessParamsStr + /*if r.Method != "GET" && adminId != 1 && url!="api/v1/system/login" { + libResponse.FailJson(true, r, "对不起!演示系统,不能删改数据!") + }*/ + //获取无需验证权限的用户id + tagSuperAdmin := false + service.SysUser().NotCheckAuthAdminIds(ctx).Iterator(func(v interface{}) bool { + if gconv.Uint64(v) == adminId { + tagSuperAdmin = true + return false + } + return true + }) + if tagSuperAdmin { + r.Middleware.Next() + //不要再往后面执行 + return + } + //获取地址对应的菜单id + menuList, err := service.SysAuthRule().GetMenuList(ctx) + if err != nil { + g.Log().Error(ctx, err) + libResponse.FailJson(true, r, "请求数据失败") + } + var menu *model.SysAuthRuleInfoRes + for _, m := range menuList { + ms := gstr.SubStr(m.Name, 0, gstr.Pos(m.Name, "?")) + if m.Name == url || ms == url { + menu = m + break + } + } + //只验证存在数据库中的规则 + if menu != nil { + //若存在不需要验证的条件则跳过 + if gstr.Equal(menu.Condition, "nocheck") { + r.Middleware.Next() + return + } + menuId := menu.Id + //菜单没存数据库不验证权限 + if menuId != 0 { + //判断权限操作 + enforcer, err := commonService.CasbinEnforcer(ctx) + if err != nil { + g.Log().Error(ctx, err) + libResponse.FailJson(true, r, "获取权限失败") + } + hasAccess := false + hasAccess, err = enforcer.Enforce(fmt.Sprintf("%s%d", service.SysUser().GetCasBinUserPrefix(), adminId), gconv.String(menuId), "All") + if err != nil { + g.Log().Error(ctx, err) + libResponse.FailJson(true, r, "判断权限失败") + } + if !hasAccess { + libResponse.FailJson(true, r, "没有访问权限") + } + } + } else if menu == nil && accessParamsStr != "" { + libResponse.FailJson(true, r, "没有访问权限") + } + r.Middleware.Next() +} diff --git a/internal/app/system/logic/personal/personal.go b/internal/app/system/logic/personal/personal.go new file mode 100644 index 0000000..2a58cfd --- /dev/null +++ b/internal/app/system/logic/personal/personal.go @@ -0,0 +1,95 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/11/3 9:55 + */ + +package personal + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/grand" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + service "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/libUtils" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterPersonal(New()) +} + +type sPersonal struct { +} + +func New() *sPersonal { + return &sPersonal{} +} + +func (s *sPersonal) GetPersonalInfo(ctx context.Context, req *system.PersonalInfoReq) (res *system.PersonalInfoRes, err error) { + res = new(system.PersonalInfoRes) + userId := service.Context().GetUserId(ctx) + res.User, err = service.SysUser().GetUserInfoById(ctx, userId) + var dept *entity.SysDept + dept, err = service.SysDept().GetByDeptId(ctx, res.User.DeptId) + res.DeptName = dept.DeptName + allRoles, err := service.SysRole().GetRoleList(ctx) + roles, err := service.SysUser().GetAdminRole(ctx, userId, allRoles) + name := make([]string, len(roles)) + roleIds := make([]uint, len(roles)) + for k, v := range roles { + name[k] = v.Name + roleIds[k] = v.Id + } + res.Roles = name + if err != nil { + return + } + return +} + +func (s *sPersonal) EditPersonal(ctx context.Context, req *system.PersonalEditReq) (res *system.PersonalEditRes, err error) { + + userId := service.Context().GetUserId(ctx) + err = service.SysUser().UserNameOrMobileExists(ctx, "", req.Mobile, int64(userId)) + if err != nil { + return + } + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysUser.Ctx(ctx).TX(tx).WherePri(userId).Update(do.SysUser{ + Mobile: req.Mobile, + UserNickname: req.Nickname, + Remark: req.Remark, + Sex: req.Sex, + UserEmail: req.UserEmail, + Describe: req.Describe, + Avatar: req.Avatar, + }) + liberr.ErrIsNil(ctx, err, "修改用户信息失败") + liberr.ErrIsNil(ctx, err) + }) + return err + }) + return +} + +func (s *sPersonal) ResetPwdPersonal(ctx context.Context, req *system.PersonalResetPwdReq) (res *system.PersonalResetPwdRes, err error) { + userId := service.Context().GetUserId(ctx) + salt := grand.S(10) + password := libUtils.EncryptPassword(req.Password, salt) + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysUser.Ctx(ctx).WherePri(userId).Update(g.Map{ + dao.SysUser.Columns().UserSalt: salt, + dao.SysUser.Columns().UserPassword: password, + }) + liberr.ErrIsNil(ctx, err, "重置用户密码失败") + }) + return +} diff --git a/internal/app/system/logic/sysAuthRule/sys_auth_rule.go b/internal/app/system/logic/sysAuthRule/sys_auth_rule.go new file mode 100644 index 0000000..228baf5 --- /dev/null +++ b/internal/app/system/logic/sysAuthRule/sys_auth_rule.go @@ -0,0 +1,316 @@ +/* +* @desc:菜单处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/23 16:14 + */ + +package sysAuthRule + +import ( + "context" + "fmt" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysAuthRule(New()) +} + +func New() *sSysAuthRule { + return &sSysAuthRule{} +} + +type sSysAuthRule struct { +} + +func (s *sSysAuthRule) GetMenuListSearch(ctx context.Context, req *system.RuleSearchReq) (res []*model.SysAuthRuleInfoRes, err error) { + err = g.Try(ctx, func(ctx context.Context) { + m := dao.SysAuthRule.Ctx(ctx) + if req.Title != "" { + m = m.Where("title like ?", "%"+req.Title+"%") + } + if req.Component != "" { + m = m.Where("component like ?", "%"+req.Component+"%") + } + err = m.Fields(model.SysAuthRuleInfoRes{}).Order("weigh desc,id asc").Scan(&res) + liberr.ErrIsNil(ctx, err, "获取菜单失败") + }) + return +} + +// GetIsMenuList 获取isMenu=0|1 +func (s *sSysAuthRule) GetIsMenuList(ctx context.Context) ([]*model.SysAuthRuleInfoRes, error) { + list, err := s.GetMenuList(ctx) + if err != nil { + return nil, err + } + var gList = make([]*model.SysAuthRuleInfoRes, 0, len(list)) + for _, v := range list { + if v.MenuType == 0 || v.MenuType == 1 { + gList = append(gList, v) + } + } + return gList, nil +} + +// GetMenuList 获取所有菜单 +func (s *sSysAuthRule) GetMenuList(ctx context.Context) (list []*model.SysAuthRuleInfoRes, err error) { + cache := commonService.Cache() + //从缓存获取 + iList := cache.GetOrSetFuncLock(ctx, consts.CacheSysAuthMenu, s.getMenuListFromDb, 0, consts.CacheSysAuthTag) + if iList != nil { + err = gconv.Struct(iList, &list) + liberr.ErrIsNil(ctx, err) + } + return +} + +// 从数据库获取所有菜单 +func (s *sSysAuthRule) getMenuListFromDb(ctx context.Context) (value interface{}, err error) { + err = g.Try(ctx, func(ctx context.Context) { + var v []*model.SysAuthRuleInfoRes + //从数据库获取 + err = dao.SysAuthRule.Ctx(ctx). + Fields(model.SysAuthRuleInfoRes{}).Order("weigh desc,id asc").Scan(&v) + liberr.ErrIsNil(ctx, err, "获取菜单数据失败") + value = v + }) + return +} + +// GetIsButtonList 获取所有按钮isMenu=2 菜单列表 +func (s *sSysAuthRule) GetIsButtonList(ctx context.Context) ([]*model.SysAuthRuleInfoRes, error) { + list, err := s.GetMenuList(ctx) + if err != nil { + return nil, err + } + var gList = make([]*model.SysAuthRuleInfoRes, 0, len(list)) + for _, v := range list { + if v.MenuType == 2 { + gList = append(gList, v) + } + } + return gList, nil +} + +// Add 添加菜单 +func (s *sSysAuthRule) Add(ctx context.Context, req *system.RuleAddReq) (err error) { + if s.menuNameExists(ctx, req.Name, 0) { + err = gerror.New("接口规则已经存在") + return + } + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + //菜单数据 + data := do.SysAuthRule{ + Pid: req.Pid, + Name: req.Name, + Title: req.Title, + Icon: req.Icon, + Condition: req.Condition, + Remark: req.Remark, + MenuType: req.MenuType, + Weigh: req.Weigh, + IsHide: req.IsHide, + Path: req.Path, + Component: req.Component, + IsLink: req.IsLink, + IsIframe: req.IsIframe, + IsCached: req.IsCached, + Redirect: req.Redirect, + IsAffix: req.IsAffix, + LinkUrl: req.LinkUrl, + } + ruleId, e := dao.SysAuthRule.Ctx(ctx).TX(tx).InsertAndGetId(data) + liberr.ErrIsNil(ctx, e, "添加菜单失败") + e = s.BindRoleRule(ctx, ruleId, req.Roles) + liberr.ErrIsNil(ctx, e, "添加菜单失败") + }) + return err + }) + if err == nil { + // 删除相关缓存 + commonService.Cache().Remove(ctx, consts.CacheSysAuthMenu) + } + return +} + +// 检查菜单规则是否存在 +func (s *sSysAuthRule) menuNameExists(ctx context.Context, name string, id uint) bool { + m := dao.SysAuthRule.Ctx(ctx).Where("name=?", name) + if id != 0 { + m = m.Where("id!=?", id) + } + c, err := m.Fields(dao.SysAuthRule.Columns().Id).Limit(1).One() + if err != nil { + g.Log().Error(ctx, err) + return false + } + return !c.IsEmpty() +} + +// BindRoleRule 绑定角色权限 +func (s *sSysAuthRule) BindRoleRule(ctx context.Context, ruleId interface{}, roleIds []uint) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + for _, roleId := range roleIds { + _, err = enforcer.AddPolicy(fmt.Sprintf("%d", roleId), fmt.Sprintf("%d", ruleId), "All") + liberr.ErrIsNil(ctx, err) + } + }) + return +} + +func (s *sSysAuthRule) Get(ctx context.Context, id uint) (rule *entity.SysAuthRule, err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysAuthRule.Ctx(ctx).WherePri(id).Scan(&rule) + liberr.ErrIsNil(ctx, err, "获取菜单失败") + }) + return +} + +func (s *sSysAuthRule) GetMenuRoles(ctx context.Context, id uint) (roleIds []uint, err error) { + err = g.Try(ctx, func(ctx context.Context) { + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + policies := enforcer.GetFilteredNamedPolicy("p", 1, gconv.String(id)) + for _, policy := range policies { + roleIds = append(roleIds, gconv.Uint(policy[0])) + } + }) + return +} + +func (s *sSysAuthRule) Update(ctx context.Context, req *system.RuleUpdateReq) (err error) { + if s.menuNameExists(ctx, req.Name, req.Id) { + err = gerror.New("接口规则已经存在") + return + } + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + //菜单数据 + data := do.SysAuthRule{ + Pid: req.Pid, + Name: req.Name, + Title: req.Title, + Icon: req.Icon, + Condition: req.Condition, + Remark: req.Remark, + MenuType: req.MenuType, + Weigh: req.Weigh, + IsHide: req.IsHide, + Path: req.Path, + Component: req.Component, + IsLink: req.IsLink, + IsIframe: req.IsIframe, + IsCached: req.IsCached, + Redirect: req.Redirect, + IsAffix: req.IsAffix, + LinkUrl: req.LinkUrl, + } + _, e := dao.SysAuthRule.Ctx(ctx).TX(tx).WherePri(req.Id).Update(data) + liberr.ErrIsNil(ctx, e, "添加菜单失败") + e = s.UpdateRoleRule(ctx, req.Id, req.Roles) + liberr.ErrIsNil(ctx, e, "添加菜单失败") + }) + return err + }) + if err == nil { + // 删除相关缓存 + commonService.Cache().Remove(ctx, consts.CacheSysAuthMenu) + } + return +} + +func (s *sSysAuthRule) UpdateRoleRule(ctx context.Context, ruleId uint, roleIds []uint) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + //删除旧权限 + _, e = enforcer.RemoveFilteredPolicy(1, gconv.String(ruleId)) + liberr.ErrIsNil(ctx, e) + // 添加新权限 + roleIdsStrArr := gconv.Strings(roleIds) + for _, v := range roleIdsStrArr { + _, e = enforcer.AddPolicy(v, gconv.String(ruleId), "All") + liberr.ErrIsNil(ctx, e) + } + }) + return +} + +func (s *sSysAuthRule) GetMenuListTree(pid uint, list []*model.SysAuthRuleInfoRes) []*model.SysAuthRuleTreeRes { + tree := make([]*model.SysAuthRuleTreeRes, 0, len(list)) + for _, menu := range list { + if menu.Pid == pid { + t := &model.SysAuthRuleTreeRes{ + SysAuthRuleInfoRes: menu, + } + child := s.GetMenuListTree(menu.Id, list) + if child != nil { + t.Children = child + } + tree = append(tree, t) + } + } + return tree +} + +// DeleteMenuByIds 删除菜单 +func (s *sSysAuthRule) DeleteMenuByIds(ctx context.Context, ids []int) (err error) { + var list []*model.SysAuthRuleInfoRes + list, err = s.GetMenuList(ctx) + if err != nil { + return + } + childrenIds := make([]int, 0, len(list)) + for _, id := range ids { + rules := s.FindSonByParentId(list, gconv.Uint(id)) + for _, child := range rules { + childrenIds = append(childrenIds, gconv.Int(child.Id)) + } + } + ids = append(ids, childrenIds...) + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + return g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysAuthRule.Ctx(ctx).Where("id in (?)", ids).Delete() + liberr.ErrIsNil(ctx, err, "删除失败") + //删除权限 + enforcer, err := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, err) + for _, v := range ids { + _, err = enforcer.RemoveFilteredPolicy(1, gconv.String(v)) + liberr.ErrIsNil(ctx, err) + } + // 删除相关缓存 + commonService.Cache().Remove(ctx, consts.CacheSysAuthMenu) + }) + }) + return +} + +func (s *sSysAuthRule) FindSonByParentId(list []*model.SysAuthRuleInfoRes, pid uint) []*model.SysAuthRuleInfoRes { + children := make([]*model.SysAuthRuleInfoRes, 0, len(list)) + for _, v := range list { + if v.Pid == pid { + children = append(children, v) + fChildren := s.FindSonByParentId(list, v.Id) + children = append(children, fChildren...) + } + } + return children +} diff --git a/internal/app/system/logic/sysDept/sys_dept.go b/internal/app/system/logic/sysDept/sys_dept.go new file mode 100644 index 0000000..eef60ca --- /dev/null +++ b/internal/app/system/logic/sysDept/sys_dept.go @@ -0,0 +1,179 @@ +/* +* @desc:部门管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/26 15:14 + */ + +package sysDept + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysDept(New()) +} + +func New() *sSysDept { + return &sSysDept{} +} + +type sSysDept struct { +} + +func (s *sSysDept) GetList(ctx context.Context, req *system.DeptSearchReq) (list []*entity.SysDept, err error) { + list, err = s.GetFromCache(ctx) + if err != nil { + return + } + rList := make([]*entity.SysDept, 0, len(list)) + if req.DeptName != "" || req.Status != "" { + for _, v := range list { + if req.DeptName != "" && !gstr.ContainsI(v.DeptName, req.DeptName) { + continue + } + if req.Status != "" && v.Status != gconv.Uint(req.Status) { + continue + } + rList = append(rList, v) + } + list = rList + } + return +} + +func (s *sSysDept) GetFromCache(ctx context.Context) (list []*entity.SysDept, err error) { + err = g.Try(ctx, func(ctx context.Context) { + cache := commonService.Cache() + //从缓存获取 + iList := cache.GetOrSetFuncLock(ctx, consts.CacheSysDept, func(ctx context.Context) (value interface{}, err error) { + err = dao.SysDept.Ctx(ctx).Scan(&list) + liberr.ErrIsNil(ctx, err, "获取部门列表失败") + value = list + return + }, 0, consts.CacheSysAuthTag) + if iList != nil { + err = gconv.Struct(iList, &list) + liberr.ErrIsNil(ctx, err) + } + }) + return +} + +// Add 添加部门 +func (s *sSysDept) Add(ctx context.Context, req *system.DeptAddReq) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysDept.Ctx(ctx).Insert(do.SysDept{ + ParentId: req.ParentID, + DeptName: req.DeptName, + OrderNum: req.OrderNum, + Leader: req.Leader, + Phone: req.Phone, + Email: req.Email, + Status: req.Status, + CreatedBy: service.Context().GetUserId(ctx), + }) + liberr.ErrIsNil(ctx, err, "添加部门失败") + // 删除缓存 + commonService.Cache().Remove(ctx, consts.CacheSysDept) + }) + return +} + +// Edit 部门修改 +func (s *sSysDept) Edit(ctx context.Context, req *system.DeptEditReq) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysDept.Ctx(ctx).WherePri(req.DeptId).Update(do.SysDept{ + ParentId: req.ParentID, + DeptName: req.DeptName, + OrderNum: req.OrderNum, + Leader: req.Leader, + Phone: req.Phone, + Email: req.Email, + Status: req.Status, + UpdatedBy: service.Context().GetUserId(ctx), + }) + liberr.ErrIsNil(ctx, err, "修改部门失败") + // 删除缓存 + commonService.Cache().Remove(ctx, consts.CacheSysDept) + }) + return +} + +func (s *sSysDept) Delete(ctx context.Context, id uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + var list []*entity.SysDept + err = dao.SysDept.Ctx(ctx).Scan(&list) + liberr.ErrIsNil(ctx, err, "不存在部门信息") + children := s.FindSonByParentId(list, id) + ids := make([]uint64, 0, len(list)) + for _, v := range children { + ids = append(ids, v.DeptId) + } + ids = append(ids, id) + _, err = dao.SysDept.Ctx(ctx).Where(dao.SysDept.Columns().DeptId+" in (?)", ids).Delete() + liberr.ErrIsNil(ctx, err, "删除部门失败") + // 删除缓存 + commonService.Cache().Remove(ctx, consts.CacheSysDept) + }) + return +} + +func (s *sSysDept) FindSonByParentId(deptList []*entity.SysDept, deptId uint64) []*entity.SysDept { + children := make([]*entity.SysDept, 0, len(deptList)) + for _, v := range deptList { + if v.ParentId == deptId { + children = append(children, v) + fChildren := s.FindSonByParentId(deptList, v.DeptId) + children = append(children, fChildren...) + } + } + return children +} + +// GetListTree 部门树形菜单 +func (s *sSysDept) GetListTree(pid uint64, list []*entity.SysDept) (deptTree []*model.SysDeptTreeRes) { + deptTree = make([]*model.SysDeptTreeRes, 0, len(list)) + for _, v := range list { + if v.ParentId == pid { + t := &model.SysDeptTreeRes{ + SysDept: v, + } + child := s.GetListTree(v.DeptId, list) + if len(child) > 0 { + t.Children = child + } + deptTree = append(deptTree, t) + } + } + return +} + +// GetByDeptId 通过部门id获取部门信息 +func (s *sSysDept) GetByDeptId(ctx context.Context, deptId uint64) (dept *entity.SysDept, err error) { + var depts []*entity.SysDept + depts, err = s.GetFromCache(ctx) + if err != nil { + return + } + for _, v := range depts { + if v.DeptId == deptId { + dept = v + break + } + } + return +} diff --git a/internal/app/system/logic/sysJob/sys_job.go b/internal/app/system/logic/sysJob/sys_job.go new file mode 100644 index 0000000..a6e27c2 --- /dev/null +++ b/internal/app/system/logic/sysJob/sys_job.go @@ -0,0 +1,252 @@ +// ========================================================================== +// GFast自动生成logic操作代码。 +// 生成日期:2023-01-12 17:43:50 +// 生成路径: internal/app/system/logic/sys_job.go +// 生成人:gfast +// desc:定时任务 +// company:云南奇讯科技有限公司 +// ========================================================================== + +package logic + +import ( + "context" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gcron" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + systemService "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" + "strings" +) + +func init() { + service.RegisterSysJob(New()) +} + +func New() *sSysJob { + return &sSysJob{} +} + +type sSysJob struct{} + +func (s *sSysJob) List(ctx context.Context, req *system.SysJobSearchReq) (listRes *system.SysJobSearchRes, err error) { + listRes = new(system.SysJobSearchRes) + err = g.Try(ctx, func(ctx context.Context) { + m := dao.SysJob.Ctx(ctx).WithAll() + if req.JobName != "" { + m = m.Where(dao.SysJob.Columns().JobName+" like ?", "%"+req.JobName+"%") + } + if req.JobGroup != "" { + m = m.Where(dao.SysJob.Columns().JobGroup+" = ?", req.JobGroup) + } + if req.Status != "" { + m = m.Where(dao.SysJob.Columns().Status+" = ?", gconv.Int(req.Status)) + } + listRes.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取总行数失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + listRes.CurrentPage = req.PageNum + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + order := "job_id asc" + if req.OrderBy != "" { + order = req.OrderBy + } + var res []*model.SysJobInfoRes + err = m.Fields(system.SysJobSearchRes{}).Page(req.PageNum, req.PageSize).Order(order).Scan(&res) + liberr.ErrIsNil(ctx, err, "获取数据失败") + listRes.List = make([]*model.SysJobListRes, len(res)) + for k, v := range res { + listRes.List[k] = &model.SysJobListRes{ + JobId: v.JobId, + JobName: v.JobName, + JobGroup: v.JobGroup, + InvokeTarget: v.InvokeTarget, + CronExpression: v.CronExpression, + MisfirePolicy: v.MisfirePolicy, + Status: v.Status, + } + } + }) + return +} + +func (s *sSysJob) GetByJobId(ctx context.Context, jobId uint64) (res *model.SysJobInfoRes, err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysJob.Ctx(ctx).WithAll().Where(dao.SysJob.Columns().JobId, jobId).Scan(&res) + liberr.ErrIsNil(ctx, err, "获取信息失败") + }) + return +} + +func (s *sSysJob) Add(ctx context.Context, req *system.SysJobAddReq) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysJob.Ctx(ctx).Insert(do.SysJob{ + JobName: req.JobName, + JobParams: req.JobParams, + JobGroup: req.JobGroup, + InvokeTarget: req.InvokeTarget, + CronExpression: req.CronExpression, + MisfirePolicy: req.MisfirePolicy, + Status: req.Status, + Remark: req.Remark, + CreatedBy: systemService.Context().GetUserId(ctx), + }) + liberr.ErrIsNil(ctx, err, "添加失败") + }) + return +} + +func (s *sSysJob) Edit(ctx context.Context, req *system.SysJobEditReq) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysJob.Ctx(ctx).WherePri(req.JobId).Update(do.SysJob{ + JobName: req.JobName, + JobParams: req.JobParams, + JobGroup: req.JobGroup, + InvokeTarget: req.InvokeTarget, + CronExpression: req.CronExpression, + MisfirePolicy: req.MisfirePolicy, + Status: req.Status, + Remark: req.Remark, + UpdatedBy: systemService.Context().GetUserId(ctx), + }) + liberr.ErrIsNil(ctx, err, "修改失败") + }) + return +} + +func (s *sSysJob) Delete(ctx context.Context, jobIds []uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysJob.Ctx(ctx).Delete(dao.SysJob.Columns().JobId+" in (?)", jobIds) + liberr.ErrIsNil(ctx, err, "删除失败") + }) + return +} + +func (s *sSysJob) Start(ctx context.Context, jobId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + var job *model.SysJobInfoRes + job, err = s.GetByJobId(ctx, jobId) + liberr.ErrIsNil(ctx, err) + if job != nil { + s.JobStart(ctx, job) + } + }) + return +} + +func (s *sSysJob) Stop(ctx context.Context, jobId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + var job *model.SysJobInfoRes + job, err = s.GetByJobId(ctx, jobId) + liberr.ErrIsNil(ctx, err) + if job != nil { + s.jobStop(ctx, job) + } + }) + return +} + +func (s *sSysJob) Run(ctx context.Context, jobId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + var job *model.SysJobInfoRes + job, err = s.GetByJobId(ctx, jobId) + liberr.ErrIsNil(ctx, err) + if job != nil { + s.jobRun(ctx, job) + } + }) + return +} + +// JobRun 执行任务 +func (s *sSysJob) jobRun(ctx context.Context, job *model.SysJobInfoRes) error { + //可以task目录下是否绑定对应的方法 + f := service.TaskList().GetByName(job.InvokeTarget) + if f == nil { + return gerror.New("当前task目录下没有绑定这个方法") + } + //传参 + paramArr := strings.Split(job.JobParams, "|") + service.TaskList().EditParams(f.FuncName, paramArr) + task, err := gcron.AddOnce(ctx, "@every 1s", f.Run) + if err != nil || task == nil { + return gerror.New("启动执行失败") + } + return nil +} + +// GetJobs 获取已开启执行的任务 +func (s *sSysJob) GetJobs(ctx context.Context) (jobs []*model.SysJobInfoRes, err error) { + err = dao.SysJob.Ctx(ctx).Where(dao.SysJob.Columns().Status, 0).Scan(&jobs) + return +} + +// JobStart 启动任务 +func (s *sSysJob) JobStart(ctx context.Context, job *model.SysJobInfoRes) error { + //获取task目录下是否绑定对应的方法 + f := service.TaskList().GetByName(job.InvokeTarget) + if f == nil { + return gerror.New("没有绑定对应的方法") + } + //传参 + paramArr := strings.Split(job.JobParams, "|") + service.TaskList().EditParams(f.FuncName, paramArr) + rs := gcron.Search(job.InvokeTarget) + if rs == nil { + if job.MisfirePolicy == 1 { + t, err := gcron.AddSingleton(ctx, job.CronExpression, f.Run, job.InvokeTarget) + if err != nil { + return err + } + if t == nil { + return gerror.New("启动任务失败") + } + } else { + t, err := gcron.AddOnce(ctx, job.CronExpression, f.Run, job.InvokeTarget) + if err != nil { + return err + } + if t == nil { + return gerror.New("启动任务失败") + } + } + } + gcron.Start(job.InvokeTarget) + if job.MisfirePolicy == 1 { + job.Status = 0 + _, err := dao.SysJob.Ctx(ctx).Where(dao.SysJob.Columns().JobId, job.JobId).Unscoped().Update(g.Map{ + dao.SysJob.Columns().Status: job.Status, + }) + return err + } + return nil +} + +// JobStop 停止任务 +func (s *sSysJob) jobStop(ctx context.Context, job *model.SysJobInfoRes) error { + //获取task目录下是否绑定对应的方法 + f := service.TaskList().GetByName(job.InvokeTarget) + if f == nil { + return gerror.New("没有绑定对应的方法") + } + rs := gcron.Search(job.InvokeTarget) + if rs != nil { + gcron.Remove(job.InvokeTarget) + } + job.Status = 1 + _, err := dao.SysJob.Ctx(ctx).Where(dao.SysJob.Columns().JobId, job.JobId).Unscoped().Update(g.Map{ + dao.SysJob.Columns().Status: job.Status, + }) + return err +} diff --git a/internal/app/system/logic/sysJobLog/sys_job_log.go b/internal/app/system/logic/sysJobLog/sys_job_log.go new file mode 100644 index 0000000..8b6faea --- /dev/null +++ b/internal/app/system/logic/sysJobLog/sys_job_log.go @@ -0,0 +1,62 @@ +/* +* @desc:任务日志 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2023/1/13 21:42 + */ + +package sysJobLog + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysJobLog(New()) +} + +func New() *sSysJobLog { + return new(sSysJobLog) +} + +type sSysJobLog struct { +} + +func (s *sSysJobLog) Add(ctx context.Context, data *do.SysJobLog) (err error) { + _, err = dao.SysJobLog.Ctx(ctx).Insert(data) + return +} + +func (s *sSysJobLog) List(ctx context.Context, req *system.SysJobLogListReq) (listRes *system.SysJobLogListRes, err error) { + err = g.Try(ctx, func(ctx context.Context) { + listRes = new(system.SysJobLogListRes) + m := dao.SysJobLog.Ctx(ctx).Where(dao.SysJobLog.Columns().TargetName, req.TargetName) + listRes.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取总行数失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + listRes.CurrentPage = req.PageNum + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + err = m.Fields(system.SysJobLogListRes{}).Page(req.PageNum, req.PageSize).Order("id desc").Scan(&listRes.List) + liberr.ErrIsNil(ctx, err, "获取数据失败") + }) + return +} + +func (s *sSysJobLog) Delete(ctx context.Context, logIds []uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysJobLog.Ctx(ctx).Delete(dao.SysJobLog.Columns().Id+" in (?)", logIds) + liberr.ErrIsNil(ctx, err, "删除失败") + }) + return +} diff --git a/internal/app/system/logic/sysLoginLog/sys_login_log.go b/internal/app/system/logic/sysLoginLog/sys_login_log.go new file mode 100644 index 0000000..620ad52 --- /dev/null +++ b/internal/app/system/logic/sysLoginLog/sys_login_log.go @@ -0,0 +1,103 @@ +/* +* @desc:登录日志 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/26 15:20 + */ + +package sysLoginLog + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/grpool" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysLoginLog(New()) +} + +func New() *sSysLoginLog { + return &sSysLoginLog{ + Pool: grpool.New(100), + } +} + +type sSysLoginLog struct { + Pool *grpool.Pool +} + +func (s *sSysLoginLog) Invoke(ctx context.Context, data *model.LoginLogParams) { + s.Pool.Add( + ctx, + func(ctx context.Context) { + //写入日志数据 + service.SysUser().LoginLog(ctx, data) + }, + ) +} + +func (s *sSysLoginLog) List(ctx context.Context, req *system.LoginLogSearchReq) (res *system.LoginLogSearchRes, err error) { + res = new(system.LoginLogSearchRes) + if req.PageNum == 0 { + req.PageNum = 1 + } + res.CurrentPage = req.PageNum + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + m := dao.SysLoginLog.Ctx(ctx) + order := "info_id DESC" + if req.LoginName != "" { + m = m.Where("login_name like ?", "%"+req.LoginName+"%") + } + if req.Status != "" { + m = m.Where("status", gconv.Int(req.Status)) + } + if req.Ipaddr != "" { + m = m.Where("ipaddr like ?", "%"+req.Ipaddr+"%") + } + if req.LoginLocation != "" { + m = m.Where("login_location like ?", "%"+req.LoginLocation+"%") + } + if len(req.DateRange) != 0 { + m = m.Where("login_time >=? AND login_time <=?", req.DateRange[0], req.DateRange[1]) + } + if req.SortName != "" { + if req.SortOrder != "" { + order = req.SortName + " " + req.SortOrder + } else { + order = req.SortName + " DESC" + } + } + err = g.Try(ctx, func(ctx context.Context) { + res.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取日志失败") + err = m.Page(req.PageNum, req.PageSize).Order(order).Scan(&res.List) + liberr.ErrIsNil(ctx, err, "获取日志数据失败") + }) + return +} + +func (s *sSysLoginLog) DeleteLoginLogByIds(ctx context.Context, ids []int) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysLoginLog.Ctx(ctx).Delete("info_id in (?)", ids) + liberr.ErrIsNil(ctx, err, "删除失败") + }) + return +} + +func (s *sSysLoginLog) ClearLoginLog(ctx context.Context) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = g.DB().Ctx(ctx).Exec(ctx, "truncate "+dao.SysLoginLog.Table()) + liberr.ErrIsNil(ctx, err, "清除失败") + }) + return +} diff --git a/internal/app/system/logic/sysOperLog/sys_oper_log.go b/internal/app/system/logic/sysOperLog/sys_oper_log.go new file mode 100644 index 0000000..c1f0ea5 --- /dev/null +++ b/internal/app/system/logic/sysOperLog/sys_oper_log.go @@ -0,0 +1,194 @@ +/* +* @desc:后台操作日志业务处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/21 16:14 + */ + +package sysOperLog + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/os/grpool" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/text/gstr" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/libUtils" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +type sOperateLog struct { + Pool *grpool.Pool +} + +func init() { + service.RegisterOperateLog(New()) +} + +func New() *sOperateLog { + return &sOperateLog{ + Pool: grpool.New(100), + } +} + +// OperationLog 操作日志写入 +func (s *sOperateLog) OperationLog(r *ghttp.Request) { + userInfo := service.Context().GetLoginUser(r.GetCtx()) + if userInfo == nil { + return + } + url := r.Request.URL //请求地址 + //获取菜单 + //获取地址对应的菜单id + menuList, err := service.SysAuthRule().GetMenuList(r.GetCtx()) + if err != nil { + g.Log().Error(r.GetCtx(), err) + return + } + var menu *model.SysAuthRuleInfoRes + path := gstr.TrimLeft(url.Path, "/") + for _, m := range menuList { + if gstr.Equal(m.Name, path) { + menu = m + break + } + } + data := &model.SysOperLogAdd{ + User: userInfo, + Menu: menu, + Url: url, + Params: r.GetMap(), + Method: r.Method, + ClientIp: libUtils.GetClientIp(r.GetCtx()), + OperatorType: 1, + } + s.Invoke(r.GetCtx(), data) +} + +func (s *sOperateLog) Invoke(ctx context.Context, data *model.SysOperLogAdd) { + s.Pool.Add(ctx, func(ctx context.Context) { + //写入日志数据 + s.operationLogAdd(ctx, data) + }) +} + +// OperationLogAdd 添加操作日志 +func (s *sOperateLog) operationLogAdd(ctx context.Context, data *model.SysOperLogAdd) { + menuTitle := "" + if data.Menu != nil { + menuTitle = data.Menu.Title + } + dept, err := service.SysDept().GetByDeptId(ctx, data.User.DeptId) + if err != nil { + g.Log().Error(ctx, err) + return + } + if dept == nil { + dept = &entity.SysDept{} + } + insertData := &do.SysOperLog{ + Title: menuTitle, + Method: data.Url.Path, + RequestMethod: data.Method, + OperatorType: data.OperatorType, + OperName: data.User.UserName, + DeptName: dept.DeptName, + OperIp: data.ClientIp, + OperLocation: libUtils.GetCityByIp(data.ClientIp), + OperTime: gtime.Now(), + OperParam: data.Params, + } + rawQuery := data.Url.RawQuery + if rawQuery != "" { + rawQuery = "?" + rawQuery + } + insertData.OperUrl = data.Url.Path + rawQuery + _, err = dao.SysOperLog.Ctx(ctx).Insert(insertData) + if err != nil { + g.Log().Error(ctx, err) + } +} + +func (s *sOperateLog) List(ctx context.Context, req *system.SysOperLogSearchReq) (listRes *system.SysOperLogSearchRes, err error) { + listRes = new(system.SysOperLogSearchRes) + err = g.Try(ctx, func(ctx context.Context) { + m := dao.SysOperLog.Ctx(ctx) + if req.Title != "" { + m = m.Where(dao.SysOperLog.Columns().Title+" = ?", req.Title) + } + if req.RequestMethod != "" { + m = m.Where(dao.SysOperLog.Columns().RequestMethod+" = ?", req.RequestMethod) + } + if req.OperName != "" { + m = m.Where(dao.SysOperLog.Columns().OperName+" like ?", "%"+req.OperName+"%") + } + if len(req.DateRange) != 0 { + m = m.Where("oper_time >=? AND oper_time <=?", req.DateRange[0], req.DateRange[1]) + } + listRes.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取总行数失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + listRes.CurrentPage = req.PageNum + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + order := "oper_id DESC" + if req.OrderBy != "" { + order = req.OrderBy + } + var res []*model.SysOperLogInfoRes + err = m.Fields(system.SysOperLogSearchRes{}).Page(req.PageNum, req.PageSize).Order(order).Scan(&res) + liberr.ErrIsNil(ctx, err, "获取数据失败") + listRes.List = make([]*model.SysOperLogListRes, len(res)) + for k, v := range res { + listRes.List[k] = &model.SysOperLogListRes{ + OperId: v.OperId, + Title: v.Title, + RequestMethod: v.RequestMethod, + OperName: v.OperName, + DeptName: v.DeptName, + LinkedDeptName: v.LinkedDeptName, + OperUrl: v.OperUrl, + OperIp: v.OperIp, + OperLocation: v.OperLocation, + OperParam: v.OperParam, + OperTime: v.OperTime, + } + } + }) + return +} + +func (s *sOperateLog) GetByOperId(ctx context.Context, operId uint64) (res *model.SysOperLogInfoRes, err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysOperLog.Ctx(ctx).WithAll().Where(dao.SysOperLog.Columns().OperId, operId).Scan(&res) + liberr.ErrIsNil(ctx, err, "获取信息失败") + }) + return +} + +func (s *sOperateLog) DeleteByIds(ctx context.Context, ids []uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysOperLog.Ctx(ctx).Delete("oper_id in (?)", ids) + liberr.ErrIsNil(ctx, err, "删除失败") + }) + return +} + +func (s *sOperateLog) ClearLog(ctx context.Context) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = g.DB().Ctx(ctx).Exec(ctx, "truncate "+dao.SysOperLog.Table()) + liberr.ErrIsNil(ctx, err, "清除失败") + }) + return +} diff --git a/internal/app/system/logic/sysPost/sys_post.go b/internal/app/system/logic/sysPost/sys_post.go new file mode 100644 index 0000000..1df8de5 --- /dev/null +++ b/internal/app/system/logic/sysPost/sys_post.go @@ -0,0 +1,111 @@ +/* +* @desc:岗位管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/26 15:28 + */ + +package sysPost + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysPost(New()) +} + +func New() *sSysPost { + return &sSysPost{} +} + +type sSysPost struct { +} + +// List 岗位列表 +func (s *sSysPost) List(ctx context.Context, req *system.PostSearchReq) (res *system.PostSearchRes, err error) { + res = new(system.PostSearchRes) + err = g.Try(ctx, func(ctx context.Context) { + m := dao.SysPost.Ctx(ctx) + if req != nil { + if req.PostCode != "" { + m = m.Where("post_code like ?", "%"+req.PostCode+"%") + } + if req.PostName != "" { + m = m.Where("post_name like ?", "%"+req.PostName+"%") + } + if req.Status != "" { + m = m.Where("status", gconv.Uint(req.Status)) + } + } + res.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取岗位失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + res.CurrentPage = req.PageNum + err = m.Page(req.PageNum, req.PageSize).Order("post_sort asc,post_id asc").Scan(&res.PostList) + liberr.ErrIsNil(ctx, err, "获取岗位失败") + }) + return +} + +func (s *sSysPost) Add(ctx context.Context, req *system.PostAddReq) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysPost.Ctx(ctx).Insert(do.SysPost{ + PostCode: req.PostCode, + PostName: req.PostName, + PostSort: req.PostSort, + Status: req.Status, + Remark: req.Remark, + CreatedBy: service.Context().GetUserId(ctx), + }) + liberr.ErrIsNil(ctx, err, "添加岗位失败") + }) + return +} + +func (s *sSysPost) Edit(ctx context.Context, req *system.PostEditReq) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysPost.Ctx(ctx).WherePri(req.PostId).Update(do.SysPost{ + PostCode: req.PostCode, + PostName: req.PostName, + PostSort: req.PostSort, + Status: req.Status, + Remark: req.Remark, + UpdatedBy: service.Context().GetUserId(ctx), + }) + liberr.ErrIsNil(ctx, err, "修改岗位失败") + }) + return +} + +func (s *sSysPost) Delete(ctx context.Context, ids []int) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysPost.Ctx(ctx).Where(dao.SysPost.Columns().PostId+" in(?)", ids).Delete() + liberr.ErrIsNil(ctx, err, "删除失败") + }) + return +} + +// GetUsedPost 获取正常状态的岗位 +func (s *sSysPost) GetUsedPost(ctx context.Context) (list []*entity.SysPost, err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysPost.Ctx(ctx).Where(dao.SysPost.Columns().Status, 1). + Order(dao.SysPost.Columns().PostSort + " ASC, " + dao.SysPost.Columns().PostId + " ASC ").Scan(&list) + liberr.ErrIsNil(ctx, err, "获取岗位数据失败") + }) + return +} diff --git a/internal/app/system/logic/sysRole/sys_role.go b/internal/app/system/logic/sysRole/sys_role.go new file mode 100644 index 0000000..7a51b13 --- /dev/null +++ b/internal/app/system/logic/sysRole/sys_role.go @@ -0,0 +1,244 @@ +/* +* @desc:角色管理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/26 15:54 + */ + +package sysRole + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysRole(New()) +} + +func New() *sSysRole { + return &sSysRole{} +} + +type sSysRole struct { +} + +func (s *sSysRole) GetRoleListSearch(ctx context.Context, req *system.RoleListReq) (res *system.RoleListRes, err error) { + res = new(system.RoleListRes) + g.Try(ctx, func(ctx context.Context) { + model := dao.SysRole.Ctx(ctx) + if req.RoleName != "" { + model = model.Where("name like ?", "%"+req.RoleName+"%") + } + if req.Status != "" { + model = model.Where("status", gconv.Int(req.Status)) + } + res.Total, err = model.Count() + liberr.ErrIsNil(ctx, err, "获取角色数据失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + res.CurrentPage = req.PageNum + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + err = model.Page(res.CurrentPage, req.PageSize).Order("id asc").Scan(&res.List) + liberr.ErrIsNil(ctx, err, "获取数据失败") + }) + return +} + +// GetRoleList 获取角色列表 +func (s *sSysRole) GetRoleList(ctx context.Context) (list []*entity.SysRole, err error) { + cache := commonService.Cache() + //从缓存获取 + iList := cache.GetOrSetFuncLock(ctx, consts.CacheSysRole, s.getRoleListFromDb, 0, consts.CacheSysAuthTag) + if iList != nil { + err = gconv.Struct(iList, &list) + } + return +} + +// 从数据库获取所有角色 +func (s *sSysRole) getRoleListFromDb(ctx context.Context) (value interface{}, err error) { + err = g.Try(ctx, func(ctx context.Context) { + var v []*entity.SysRole + //从数据库获取 + err = dao.SysRole.Ctx(ctx). + Order(dao.SysRole.Columns().ListOrder + " asc," + dao.SysRole.Columns().Id + " asc"). + Scan(&v) + liberr.ErrIsNil(ctx, err, "获取角色数据失败") + value = v + }) + return +} + +// AddRoleRule 添加角色权限 +func (s *sSysRole) AddRoleRule(ctx context.Context, ruleIds []uint, roleId int64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + ruleIdsStr := gconv.Strings(ruleIds) + for _, v := range ruleIdsStr { + _, err = enforcer.AddPolicy(gconv.String(roleId), v, "All") + liberr.ErrIsNil(ctx, err) + } + }) + return +} + +// DelRoleRule 删除角色权限 +func (s *sSysRole) DelRoleRule(ctx context.Context, roleId int64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + _, err = enforcer.RemoveFilteredPolicy(0, gconv.String(roleId)) + liberr.ErrIsNil(ctx, e) + }) + return +} + +func (s *sSysRole) AddRole(ctx context.Context, req *system.RoleAddReq) (err error) { + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + roleId, e := dao.SysRole.Ctx(ctx).TX(tx).InsertAndGetId(req) + liberr.ErrIsNil(ctx, e, "添加角色失败") + //添加角色权限 + e = s.AddRoleRule(ctx, req.MenuIds, roleId) + liberr.ErrIsNil(ctx, e) + //清除缓存 + commonService.Cache().Remove(ctx, consts.CacheSysRole) + }) + return err + }) + return +} + +func (s *sSysRole) Get(ctx context.Context, id uint) (res *entity.SysRole, err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysRole.Ctx(ctx).WherePri(id).Scan(&res) + liberr.ErrIsNil(ctx, err, "获取角色信息失败") + }) + return +} + +// GetFilteredNamedPolicy 获取角色关联的菜单规则 +func (s *sSysRole) GetFilteredNamedPolicy(ctx context.Context, id uint) (gpSlice []int, err error) { + err = g.Try(ctx, func(ctx context.Context) { + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + gp := enforcer.GetFilteredNamedPolicy("p", 0, gconv.String(id)) + gpSlice = make([]int, len(gp)) + for k, v := range gp { + gpSlice[k] = gconv.Int(v[1]) + } + }) + return +} + +// EditRole 修改角色 +func (s *sSysRole) EditRole(ctx context.Context, req *system.RoleEditReq) (err error) { + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + _, e := dao.SysRole.Ctx(ctx).TX(tx).WherePri(req.Id).Data(&do.SysRole{ + Status: req.Status, + ListOrder: req.ListOrder, + Name: req.Name, + Remark: req.Remark, + }).Update() + liberr.ErrIsNil(ctx, e, "修改角色失败") + //删除角色权限 + e = s.DelRoleRule(ctx, req.Id) + liberr.ErrIsNil(ctx, e) + //添加角色权限 + e = s.AddRoleRule(ctx, req.MenuIds, req.Id) + liberr.ErrIsNil(ctx, e) + //清除缓存 + commonService.Cache().Remove(ctx, consts.CacheSysRole) + }) + return err + }) + return +} + +// DeleteByIds 删除角色 +func (s *sSysRole) DeleteByIds(ctx context.Context, ids []int64) (err error) { + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysRole.Ctx(ctx).TX(tx).Where(dao.SysRole.Columns().Id+" in(?)", ids).Delete() + liberr.ErrIsNil(ctx, err, "删除角色失败") + //删除角色权限 + for _, v := range ids { + err = s.DelRoleRule(ctx, v) + liberr.ErrIsNil(ctx, err) + } + //清除缓存 + commonService.Cache().Remove(ctx, consts.CacheSysRole) + }) + return err + }) + return +} + +func (s *sSysRole) RoleDeptTreeSelect(ctx context.Context, roleId int64) (res *system.RoleDeptTreeSelectRes, err error) { + res = new(system.RoleDeptTreeSelectRes) + err = g.Try(ctx, func(ctx context.Context) { + list, err := service.SysDept().GetList(ctx, &system.DeptSearchReq{ + Status: "1", + }) + liberr.ErrIsNil(ctx, err) + //获取关联的角色数据权限 + checkedKeys, err := s.GetRoleDepts(ctx, roleId) + liberr.ErrIsNil(ctx, err) + + dList := service.SysDept().GetListTree(0, list) + res.Depts = dList + res.CheckedKeys = checkedKeys + }) + return +} + +func (s *sSysRole) GetRoleDepts(ctx context.Context, roleId int64) ([]int64, error) { + var entities []*entity.SysRoleDept + err := dao.SysRoleDept.Ctx(ctx).Where("role_id", roleId).Scan(&entities) + if err != nil { + return nil, err + } + result := make([]int64, 0) + for _, v := range entities { + result = append(result, v.DeptId) + } + return result, nil +} + +// RoleDataScope 设置角色数据权限 +func (s *sSysRole) RoleDataScope(ctx context.Context, req *system.DataScopeReq) error { + err := g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err := g.Try(ctx, func(ctx context.Context) { + _, err := tx.Model(dao.SysRole.Table()).Where("id", req.RoleId).Data(g.Map{"data_scope": req.DataScope}).Update() + liberr.ErrIsNil(ctx, err, "设置失败") + if req.DataScope == 2 { + _, err = tx.Model(dao.SysRoleDept.Table()).Where("role_id", req.RoleId).Delete() + liberr.ErrIsNil(ctx, err, "设置失败") + data := g.List{} + for _, deptId := range req.DeptIds { + data = append(data, g.Map{"role_id": req.RoleId, "dept_id": deptId}) + } + _, err = tx.Model(dao.SysRoleDept.Table()).Data(data).Insert() + liberr.ErrIsNil(ctx, err, "设置失败") + } + }) + return err + }) + return err +} diff --git a/internal/app/system/logic/sysUser/sys_user.go b/internal/app/system/logic/sysUser/sys_user.go new file mode 100644 index 0000000..2a9cfd1 --- /dev/null +++ b/internal/app/system/logic/sysUser/sys_user.go @@ -0,0 +1,697 @@ +/* +* @desc:用户处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/23 15:08 + */ + +package sysUser + +import ( + "context" + "fmt" + "github.com/gogf/gf/v2/container/gset" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "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/grand" + "github.com/mssola/user_agent" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/libUtils" + "github.com/tiger1103/gfast/v3/library/liberr" + "reflect" +) + +func init() { + service.RegisterSysUser(New()) +} + +type sSysUser struct { + casBinUserPrefix string //CasBin 用户id前缀 +} + +func New() *sSysUser { + return &sSysUser{ + casBinUserPrefix: "u_", + } +} + +func (s *sSysUser) GetCasBinUserPrefix() string { + return s.casBinUserPrefix +} + +func (s *sSysUser) NotCheckAuthAdminIds(ctx context.Context) *gset.Set { + ids := g.Cfg().MustGet(ctx, "system.notCheckAuthAdminIds") + if !g.IsNil(ids) { + return gset.NewFrom(ids) + } + return gset.New() +} + +func (s *sSysUser) GetAdminUserByUsernamePassword(ctx context.Context, req *system.UserLoginReq) (user *model.LoginUserRes, err error) { + err = g.Try(ctx, func(ctx context.Context) { + user, err = s.GetUserByUsername(ctx, req.Username) + liberr.ErrIsNil(ctx, err) + liberr.ValueIsNil(user, "账号密码错误") + //验证密码 + if libUtils.EncryptPassword(req.Password, user.UserSalt) != user.UserPassword { + liberr.ErrIsNil(ctx, gerror.New("账号密码错误")) + } + //账号状态 + if user.UserStatus == 0 { + liberr.ErrIsNil(ctx, gerror.New("账号已被冻结")) + } + }) + return +} + +// GetUserByUsername 通过用户名获取用户信息 +func (s *sSysUser) GetUserByUsername(ctx context.Context, userName string) (user *model.LoginUserRes, err error) { + err = g.Try(ctx, func(ctx context.Context) { + user = &model.LoginUserRes{} + err = dao.SysUser.Ctx(ctx).Fields(user).Where(dao.SysUser.Columns().UserName, userName).Scan(user) + liberr.ErrIsNil(ctx, err, "账号密码错误") + }) + return +} + +// LoginLog 记录登录日志 +func (s *sSysUser) LoginLog(ctx context.Context, params *model.LoginLogParams) { + ua := user_agent.New(params.UserAgent) + browser, _ := ua.Browser() + loginData := &do.SysLoginLog{ + LoginName: params.Username, + Ipaddr: params.Ip, + LoginLocation: libUtils.GetCityByIp(params.Ip), + Browser: browser, + Os: ua.OS(), + Status: params.Status, + Msg: params.Msg, + LoginTime: gtime.Now(), + Module: params.Module, + } + _, err := dao.SysLoginLog.Ctx(ctx).Insert(loginData) + if err != nil { + g.Log().Error(ctx, err) + } +} + +func (s *sSysUser) UpdateLoginInfo(ctx context.Context, id uint64, ip string) (err error) { + g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysUser.Ctx(ctx).WherePri(id).Unscoped().Update(g.Map{ + dao.SysUser.Columns().LastLoginIp: ip, + dao.SysUser.Columns().LastLoginTime: gtime.Now(), + }) + liberr.ErrIsNil(ctx, err, "更新用户登录信息失败") + }) + return +} + +// GetAdminRules 获取用户菜单数据 +func (s *sSysUser) GetAdminRules(ctx context.Context, userId uint64) (menuList []*model.UserMenus, permissions []string, err error) { + err = g.Try(ctx, func(ctx context.Context) { + //是否超管 + isSuperAdmin := false + //获取无需验证权限的用户id + s.NotCheckAuthAdminIds(ctx).Iterator(func(v interface{}) bool { + if gconv.Uint64(v) == userId { + isSuperAdmin = true + return false + } + return true + }) + //获取用户菜单数据 + allRoles, err := service.SysRole().GetRoleList(ctx) + liberr.ErrIsNil(ctx, err) + roles, err := s.GetAdminRole(ctx, userId, allRoles) + liberr.ErrIsNil(ctx, err) + name := make([]string, len(roles)) + roleIds := make([]uint, len(roles)) + for k, v := range roles { + name[k] = v.Name + roleIds[k] = v.Id + } + //获取菜单信息 + if isSuperAdmin { + //超管获取所有菜单 + permissions = []string{"*/*/*"} + menuList, err = s.GetAllMenus(ctx) + liberr.ErrIsNil(ctx, err) + } else { + menuList, err = s.GetAdminMenusByRoleIds(ctx, roleIds) + liberr.ErrIsNil(ctx, err) + permissions, err = s.GetPermissions(ctx, roleIds) + liberr.ErrIsNil(ctx, err) + } + }) + return +} + +// GetAdminRole 获取用户角色 +func (s *sSysUser) GetAdminRole(ctx context.Context, userId uint64, allRoleList []*entity.SysRole) (roles []*entity.SysRole, err error) { + var roleIds []uint + roleIds, err = s.GetAdminRoleIds(ctx, userId) + if err != nil { + return + } + roles = make([]*entity.SysRole, 0, len(allRoleList)) + for _, v := range allRoleList { + for _, id := range roleIds { + if id == v.Id { + roles = append(roles, v) + } + } + if len(roles) == len(roleIds) { + break + } + } + return +} + +// GetAdminRoleIds 获取用户角色ids +func (s *sSysUser) GetAdminRoleIds(ctx context.Context, userId uint64) (roleIds []uint, err error) { + enforcer, e := commonService.CasbinEnforcer(ctx) + if e != nil { + err = e + return + } + //查询关联角色规则 + groupPolicy := enforcer.GetFilteredGroupingPolicy(0, fmt.Sprintf("%s%d", s.casBinUserPrefix, userId)) + if len(groupPolicy) > 0 { + roleIds = make([]uint, len(groupPolicy)) + //得到角色id的切片 + for k, v := range groupPolicy { + roleIds[k] = gconv.Uint(v[1]) + } + } + return +} + +func (s *sSysUser) GetAllMenus(ctx context.Context) (menus []*model.UserMenus, err error) { + //获取所有开启的菜单 + var allMenus []*model.SysAuthRuleInfoRes + allMenus, err = service.SysAuthRule().GetIsMenuList(ctx) + if err != nil { + return + } + menus = make([]*model.UserMenus, len(allMenus)) + for k, v := range allMenus { + var menu *model.UserMenu + menu = s.setMenuData(menu, v) + menus[k] = &model.UserMenus{UserMenu: menu} + } + menus = s.GetMenusTree(menus, 0) + return +} + +func (s *sSysUser) GetAdminMenusByRoleIds(ctx context.Context, roleIds []uint) (menus []*model.UserMenus, err error) { + //获取角色对应的菜单id + err = g.Try(ctx, func(ctx context.Context) { + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + menuIds := map[int64]int64{} + for _, roleId := range roleIds { + //查询当前权限 + gp := enforcer.GetFilteredPolicy(0, gconv.String(roleId)) + for _, p := range gp { + mid := gconv.Int64(p[1]) + menuIds[mid] = mid + } + } + //获取所有开启的菜单 + allMenus, err := service.SysAuthRule().GetIsMenuList(ctx) + liberr.ErrIsNil(ctx, err) + menus = make([]*model.UserMenus, 0, len(allMenus)) + for _, v := range allMenus { + if _, ok := menuIds[gconv.Int64(v.Id)]; gstr.Equal(v.Condition, "nocheck") || ok { + var roleMenu *model.UserMenu + roleMenu = s.setMenuData(roleMenu, v) + menus = append(menus, &model.UserMenus{UserMenu: roleMenu}) + } + } + menus = s.GetMenusTree(menus, 0) + }) + return +} + +func (s *sSysUser) GetMenusTree(menus []*model.UserMenus, pid uint) []*model.UserMenus { + returnList := make([]*model.UserMenus, 0, len(menus)) + for _, menu := range menus { + if menu.Pid == pid { + menu.Children = s.GetMenusTree(menus, menu.Id) + returnList = append(returnList, menu) + } + } + return returnList +} + +func (s *sSysUser) setMenuData(menu *model.UserMenu, entity *model.SysAuthRuleInfoRes) *model.UserMenu { + menu = &model.UserMenu{ + Id: entity.Id, + Pid: entity.Pid, + Name: gstr.CaseCamelLower(gstr.Replace(entity.Name, "/", "_")), + Component: entity.Component, + Path: entity.Path, + MenuMeta: &model.MenuMeta{ + Icon: entity.Icon, + Title: entity.Title, + IsLink: "", + IsHide: entity.IsHide == 1, + IsKeepAlive: entity.IsCached == 1, + IsAffix: entity.IsAffix == 1, + IsIframe: entity.IsIframe == 1, + }, + } + if menu.MenuMeta.IsIframe || entity.IsLink == 1 { + menu.MenuMeta.IsLink = entity.LinkUrl + } + return menu +} + +func (s *sSysUser) GetPermissions(ctx context.Context, roleIds []uint) (userButtons []string, err error) { + err = g.Try(ctx, func(ctx context.Context) { + //获取角色对应的菜单id + enforcer, err := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, err) + menuIds := map[int64]int64{} + for _, roleId := range roleIds { + //查询当前权限 + gp := enforcer.GetFilteredPolicy(0, gconv.String(roleId)) + for _, p := range gp { + mid := gconv.Int64(p[1]) + menuIds[mid] = mid + } + } + //获取所有开启的按钮 + allButtons, err := service.SysAuthRule().GetIsButtonList(ctx) + liberr.ErrIsNil(ctx, err) + userButtons = make([]string, 0, len(allButtons)) + for _, button := range allButtons { + if _, ok := menuIds[gconv.Int64(button.Id)]; gstr.Equal(button.Condition, "nocheck") || ok { + userButtons = append(userButtons, button.Name) + } + } + }) + return +} + +// List 用户列表 +func (s *sSysUser) List(ctx context.Context, req *system.UserSearchReq) (total interface{}, userList []*entity.SysUser, err error) { + err = g.Try(ctx, func(ctx context.Context) { + m := dao.SysUser.Ctx(ctx) + if req.KeyWords != "" { + keyWords := "%" + req.KeyWords + "%" + m = m.Where("user_name like ? or user_nickname like ?", keyWords, keyWords) + } + if req.DeptId != "" { + deptIds, e := s.getSearchDeptIds(ctx, gconv.Uint64(req.DeptId)) + liberr.ErrIsNil(ctx, e) + m = m.Where("dept_id in (?)", deptIds) + } + if req.Status != "" { + m = m.Where("user_status", gconv.Int(req.Status)) + } + if req.Mobile != "" { + m = m.Where("mobile like ?", "%"+req.Mobile+"%") + } + if len(req.DateRange) > 0 { + m = m.Where("created_at >=? AND created_at <=?", req.DateRange[0], req.DateRange[1]) + } + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + if req.PageNum == 0 { + req.PageNum = 1 + } + total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取用户数据失败") + err = m.FieldsEx(dao.SysUser.Columns().UserPassword, dao.SysUser.Columns().UserSalt). + Page(req.PageNum, req.PageSize).Order("id asc").Scan(&userList) + liberr.ErrIsNil(ctx, err, "获取用户列表失败") + }) + return +} + +// GetUsersRoleDept 获取多个用户角色 部门信息 +func (s *sSysUser) GetUsersRoleDept(ctx context.Context, userList []*entity.SysUser) (users []*model.SysUserRoleDeptRes, err error) { + err = g.Try(ctx, func(ctx context.Context) { + allRoles, e := service.SysRole().GetRoleList(ctx) + liberr.ErrIsNil(ctx, e) + depts, e := service.SysDept().GetFromCache(ctx) + liberr.ErrIsNil(ctx, e) + users = make([]*model.SysUserRoleDeptRes, len(userList)) + for k, u := range userList { + var dept *entity.SysDept + users[k] = &model.SysUserRoleDeptRes{ + SysUser: u, + } + for _, d := range depts { + if u.DeptId == uint64(d.DeptId) { + dept = d + } + } + users[k].Dept = dept + roles, e := s.GetAdminRole(ctx, u.Id, allRoles) + liberr.ErrIsNil(ctx, e) + for _, r := range roles { + users[k].RoleInfo = append(users[k].RoleInfo, &model.SysUserRoleInfoRes{RoleId: r.Id, Name: r.Name}) + } + } + }) + return +} + +func (s *sSysUser) getSearchDeptIds(ctx context.Context, deptId uint64) (deptIds []uint64, err error) { + err = g.Try(ctx, func(ctx context.Context) { + deptAll, e := service.SysDept().GetFromCache(ctx) + liberr.ErrIsNil(ctx, e) + deptWithChildren := service.SysDept().FindSonByParentId(deptAll, deptId) + deptIds = make([]uint64, len(deptWithChildren)) + for k, v := range deptWithChildren { + deptIds[k] = v.DeptId + } + deptIds = append(deptIds, deptId) + }) + return +} + +func (s *sSysUser) Add(ctx context.Context, req *system.UserAddReq) (err error) { + err = s.UserNameOrMobileExists(ctx, req.UserName, req.Mobile) + if err != nil { + return + } + req.UserSalt = grand.S(10) + req.Password = libUtils.EncryptPassword(req.Password, req.UserSalt) + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + userId, e := dao.SysUser.Ctx(ctx).TX(tx).InsertAndGetId(do.SysUser{ + UserName: req.UserName, + Mobile: req.Mobile, + UserNickname: req.NickName, + UserPassword: req.Password, + UserSalt: req.UserSalt, + UserStatus: req.Status, + UserEmail: req.Email, + Sex: req.Sex, + DeptId: req.DeptId, + Remark: req.Remark, + IsAdmin: req.IsAdmin, + }) + liberr.ErrIsNil(ctx, e, "添加用户失败") + e = s.addUserRole(ctx, req.RoleIds, userId) + liberr.ErrIsNil(ctx, e, "设置用户权限失败") + e = s.AddUserPost(ctx, tx, req.PostIds, userId) + liberr.ErrIsNil(ctx, e) + }) + return err + }) + return +} + +func (s *sSysUser) Edit(ctx context.Context, req *system.UserEditReq) (err error) { + err = s.UserNameOrMobileExists(ctx, "", req.Mobile, req.UserId) + if err != nil { + return + } + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysUser.Ctx(ctx).TX(tx).WherePri(req.UserId).Update(do.SysUser{ + Mobile: req.Mobile, + UserNickname: req.NickName, + UserStatus: req.Status, + UserEmail: req.Email, + Sex: req.Sex, + DeptId: req.DeptId, + Remark: req.Remark, + IsAdmin: req.IsAdmin, + }) + liberr.ErrIsNil(ctx, err, "修改用户信息失败") + //设置用户所属角色信息 + err = s.EditUserRole(ctx, req.RoleIds, req.UserId) + liberr.ErrIsNil(ctx, err, "设置用户权限失败") + err = s.AddUserPost(ctx, tx, req.PostIds, req.UserId) + liberr.ErrIsNil(ctx, err) + }) + return err + }) + return +} + +// AddUserPost 添加用户岗位信息 +func (s *sSysUser) AddUserPost(ctx context.Context, tx gdb.TX, postIds []int64, userId int64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + //删除旧岗位信息 + _, err = dao.SysUserPost.Ctx(ctx).TX(tx).Where(dao.SysUserPost.Columns().UserId, userId).Delete() + liberr.ErrIsNil(ctx, err, "设置用户岗位失败") + if len(postIds) == 0 { + return + } + //添加用户岗位信息 + data := g.List{} + for _, v := range postIds { + data = append(data, g.Map{ + dao.SysUserPost.Columns().UserId: userId, + dao.SysUserPost.Columns().PostId: v, + }) + } + _, err = dao.SysUserPost.Ctx(ctx).TX(tx).Data(data).Insert() + liberr.ErrIsNil(ctx, err, "设置用户岗位失败") + }) + return +} + +// AddUserRole 添加用户角色信息 +func (s *sSysUser) addUserRole(ctx context.Context, roleIds []int64, userId int64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + for _, v := range roleIds { + _, e = enforcer.AddGroupingPolicy(fmt.Sprintf("%s%d", s.casBinUserPrefix, userId), gconv.String(v)) + liberr.ErrIsNil(ctx, e) + } + }) + return +} + +// EditUserRole 修改用户角色信息 +func (s *sSysUser) EditUserRole(ctx context.Context, roleIds []int64, userId int64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + + //删除用户旧角色信息 + enforcer.RemoveFilteredGroupingPolicy(0, fmt.Sprintf("%s%d", s.casBinUserPrefix, userId)) + for _, v := range roleIds { + _, err = enforcer.AddGroupingPolicy(fmt.Sprintf("%s%d", s.casBinUserPrefix, userId), gconv.String(v)) + liberr.ErrIsNil(ctx, err) + } + }) + return +} + +func (s *sSysUser) UserNameOrMobileExists(ctx context.Context, userName, mobile string, id ...int64) error { + user := (*entity.SysUser)(nil) + err := g.Try(ctx, func(ctx context.Context) { + m := dao.SysUser.Ctx(ctx) + if len(id) > 0 { + m = m.Where(dao.SysUser.Columns().Id+" != ", id) + } + m = m.Where(fmt.Sprintf("%s='%s' OR %s='%s'", + dao.SysUser.Columns().UserName, + userName, + dao.SysUser.Columns().Mobile, + mobile)) + err := m.Limit(1).Scan(&user) + liberr.ErrIsNil(ctx, err, "获取用户信息失败") + if user == nil { + return + } + if user.UserName == userName { + liberr.ErrIsNil(ctx, gerror.New("用户名已存在")) + } + if user.Mobile == mobile { + liberr.ErrIsNil(ctx, gerror.New("手机号已存在")) + } + }) + return err +} + +// GetEditUser 获取编辑用户信息 +func (s *sSysUser) GetEditUser(ctx context.Context, id uint64) (res *system.UserGetEditRes, err error) { + res = new(system.UserGetEditRes) + err = g.Try(ctx, func(ctx context.Context) { + //获取用户信息 + res.User, err = s.GetUserInfoById(ctx, id) + liberr.ErrIsNil(ctx, err) + //获取已选择的角色信息 + res.CheckedRoleIds, err = s.GetAdminRoleIds(ctx, id) + liberr.ErrIsNil(ctx, err) + res.CheckedPosts, err = s.GetUserPostIds(ctx, id) + liberr.ErrIsNil(ctx, err) + }) + return +} + +// GetUserInfoById 通过Id获取用户信息 +func (s *sSysUser) GetUserInfoById(ctx context.Context, id uint64, withPwd ...bool) (user *entity.SysUser, err error) { + err = g.Try(ctx, func(ctx context.Context) { + if len(withPwd) > 0 && withPwd[0] { + //用户用户信息 + err = dao.SysUser.Ctx(ctx).Where(dao.SysUser.Columns().Id, id).Scan(&user) + } else { + //用户用户信息 + err = dao.SysUser.Ctx(ctx).Where(dao.SysUser.Columns().Id, id). + FieldsEx(dao.SysUser.Columns().UserPassword, dao.SysUser.Columns().UserSalt).Scan(&user) + } + liberr.ErrIsNil(ctx, err, "获取用户数据失败") + }) + return +} + +// GetUserPostIds 获取用户岗位 +func (s *sSysUser) GetUserPostIds(ctx context.Context, userId uint64) (postIds []int64, err error) { + err = g.Try(ctx, func(ctx context.Context) { + var list []*entity.SysUserPost + err = dao.SysUserPost.Ctx(ctx).Where(dao.SysUserPost.Columns().UserId, userId).Scan(&list) + liberr.ErrIsNil(ctx, err, "获取用户岗位信息失败") + postIds = make([]int64, 0) + for _, entity := range list { + postIds = append(postIds, entity.PostId) + } + }) + return +} + +// ResetUserPwd 重置用户密码 +func (s *sSysUser) ResetUserPwd(ctx context.Context, req *system.UserResetPwdReq) (err error) { + salt := grand.S(10) + password := libUtils.EncryptPassword(req.Password, salt) + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysUser.Ctx(ctx).WherePri(req.Id).Update(g.Map{ + dao.SysUser.Columns().UserSalt: salt, + dao.SysUser.Columns().UserPassword: password, + }) + liberr.ErrIsNil(ctx, err, "重置用户密码失败") + }) + return +} + +func (s *sSysUser) ChangeUserStatus(ctx context.Context, req *system.UserStatusReq) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysUser.Ctx(ctx).WherePri(req.Id).Update(do.SysUser{UserStatus: req.UserStatus}) + liberr.ErrIsNil(ctx, err, "设置用户状态失败") + }) + return +} + +// Delete 删除用户 +func (s *sSysUser) Delete(ctx context.Context, ids []int) (err error) { + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.SysUser.Ctx(ctx).TX(tx).Where(dao.SysUser.Columns().Id+" in(?)", ids).Delete() + liberr.ErrIsNil(ctx, err, "删除用户失败") + //删除对应权限 + enforcer, e := commonService.CasbinEnforcer(ctx) + liberr.ErrIsNil(ctx, e) + for _, v := range ids { + enforcer.RemoveFilteredGroupingPolicy(0, fmt.Sprintf("%s%d", s.casBinUserPrefix, v)) + } + //删除用户对应的岗位 + _, err = dao.SysUserPost.Ctx(ctx).TX(tx).Delete(dao.SysUserPost.Columns().UserId+" in (?)", ids) + liberr.ErrIsNil(ctx, err, "删除用户的岗位失败") + }) + return err + }) + return +} + +// GetUsers 通过用户ids查询多个用户信息 +func (s *sSysUser) GetUsers(ctx context.Context, ids []int) (users []*model.SysUserSimpleRes, err error) { + if len(ids) == 0 { + return + } + idsSet := gset.NewIntSetFrom(ids).Slice() + err = g.Try(ctx, func(ctx context.Context) { + err = dao.SysUser.Ctx(ctx).Where(dao.SysUser.Columns().Id+" in(?)", idsSet). + Order(dao.SysUser.Columns().Id + " ASC").Scan(&users) + }) + return +} + +// GetDataWhere 获取数据权限判断条件 +func (s *sSysUser) GetDataWhere(ctx context.Context, userInfo *model.ContextUser, entityData interface{}) (where g.Map, err error) { + whereJustMe := g.Map{} //本人数据权限 + t := reflect.TypeOf(entityData) + for i := 0; i < t.Elem().NumField(); i++ { + if t.Elem().Field(i).Name == "CreatedBy" { + //若存在用户id的字段,则生成判断数据权限的条件 + //1、获取当前用户所属角色 + allRoles := ([]*entity.SysRole)(nil) + allRoles, err = service.SysRole().GetRoleList(ctx) + if err != nil { + return nil, err + } + roles := ([]*entity.SysRole)(nil) + roles, err = s.GetAdminRole(ctx, userInfo.Id, allRoles) + if err != nil { + return nil, err + } + //2获取角色对应数据权限 + deptIdArr := gset.New() + for _, role := range roles { + switch role.DataScope { + case 1: //全部数据权限 + return + case 2: //自定数据权限 + var deptIds []int64 + deptIds, err = service.SysRole().GetRoleDepts(ctx, gconv.Int64(role.Id)) + if err != nil { + return + } + deptIdArr.Add(gconv.Interfaces(deptIds)...) + case 3: //本部门数据权限 + deptIdArr.Add(gconv.Int64(userInfo.DeptId)) + case 4: //本部门及以下数据权限 + deptIdArr.Add(gconv.Int64(userInfo.DeptId)) + //获取正常状态部门数据 + depts := ([]*entity.SysDept)(nil) + depts, err = service.SysDept().GetList(ctx, &system.DeptSearchReq{Status: "1"}) + if err != nil { + return + } + var dList g.List + for _, d := range depts { + m := g.Map{ + "id": d.DeptId, + "pid": d.ParentId, + "label": d.DeptName, + } + dList = append(dList, m) + } + l := libUtils.FindSonByParentId(dList, gconv.Int(userInfo.DeptId), "pid", "id") + for _, li := range l { + deptIdArr.Add(gconv.Int64(li["id"])) + } + case 5: //仅本人数据权限 + whereJustMe = g.Map{"user.id": userInfo.Id} + } + } + if deptIdArr.Size() > 0 { + where = g.Map{"user.dept_id": deptIdArr.Slice()} + } else if len(whereJustMe) > 0 { + where = whereJustMe + } + } + } + return +} diff --git a/internal/app/system/logic/sysUserOnline/sys_user_online.go b/internal/app/system/logic/sysUserOnline/sys_user_online.go new file mode 100644 index 0000000..0da7cad --- /dev/null +++ b/internal/app/system/logic/sysUserOnline/sys_user_online.go @@ -0,0 +1,187 @@ +/* +* @desc:用户在线状态处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2023/1/10 14:50 + */ + +package sysUserOnline + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/grpool" + "github.com/gogf/gf/v2/os/gtime" + "github.com/mssola/user_agent" + "github.com/tiger1103/gfast/v3/api/v1/common" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +func init() { + service.RegisterSysUserOnline(New()) +} + +func New() *sSysUserOnline { + return &sSysUserOnline{ + Pool: grpool.New(100), + } +} + +type sSysUserOnline struct { + Pool *grpool.Pool +} + +func (s *sSysUserOnline) Invoke(ctx context.Context, params *model.SysUserOnlineParams) { + s.Pool.Add(ctx, func(ctx context.Context) { + //写入数据 + s.SaveOnline(ctx, params) + }) +} + +// SaveOnline 保存用户在线状态 +func (s *sSysUserOnline) SaveOnline(ctx context.Context, params *model.SysUserOnlineParams) { + err := g.Try(ctx, func(ctx context.Context) { + ua := user_agent.New(params.UserAgent) + browser, _ := ua.Browser() + os := ua.OS() + var ( + info *entity.SysUserOnline + data = &do.SysUserOnline{ + Uuid: params.Uuid, + Token: params.Token, + CreateTime: gtime.Now(), + UserName: params.Username, + Ip: params.Ip, + Explorer: browser, + Os: os, + } + ) + + //查询是否已存在当前用户 + err := dao.SysUserOnline.Ctx(ctx).Fields(dao.SysUserOnline.Columns().Id). + Where(dao.SysUserOnline.Columns().Token, data.Token). + Scan(&info) + liberr.ErrIsNil(ctx, err) + //若已存在则更新 + if info != nil { + _, err = dao.SysUserOnline.Ctx(ctx). + Where(dao.SysUserOnline.Columns().Id, info.Id). + FieldsEx(dao.SysUserOnline.Columns().Id).Update(data) + liberr.ErrIsNil(ctx, err) + } else { //否则新增 + _, err = dao.SysUserOnline.Ctx(ctx). + FieldsEx(dao.SysUserOnline.Columns().Id).Insert(data) + liberr.ErrIsNil(ctx, err) + } + }) + if err != nil { + g.Log().Error(ctx, err) + } +} + +// CheckUserOnline 检查在线用户 +func (s *sSysUserOnline) CheckUserOnline(ctx context.Context) { + param := &system.SysUserOnlineSearchReq{ + PageReq: common.PageReq{ + PageNum: 1, + PageSize: 50, + }, + } + var total int + for { + var ( + res *system.SysUserOnlineSearchRes + err error + ) + res, err = s.GetOnlineListPage(ctx, param, true) + if err != nil { + g.Log().Error(ctx, err) + break + } + if res.List == nil { + break + } + for _, v := range res.List { + if b := s.UserIsOnline(ctx, v.Token); !b { + s.DeleteOnlineByToken(ctx, v.Token) + } + } + if param.PageNum*param.PageSize >= total { + break + } + param.PageNum++ + } + service.SysJobLog().Add(ctx, &do.SysJobLog{ + TargetName: "checkUserOnline", + CreatedAt: gtime.Now(), + Result: "在线用户定时更新,执行成功", + }) +} + +// GetOnlineListPage 搜素在线用户列表 +func (s *sSysUserOnline) GetOnlineListPage(ctx context.Context, req *system.SysUserOnlineSearchReq, hasToken ...bool) (res *system.SysUserOnlineSearchRes, err error) { + if req.PageNum == 0 { + req.PageNum = 1 + } + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + model := dao.SysUserOnline.Ctx(ctx) + if req.Ip != "" { + model = model.Where("ip like ?", "%"+req.Ip+"%") + } + if req.Username != "" { + model = model.Where("user_name like ?", "%"+req.Username+"%") + } + res = new(system.SysUserOnlineSearchRes) + err = g.Try(ctx, func(ctx context.Context) { + res.Total, err = model.Count() + liberr.ErrIsNil(ctx, err, "获取总行数失败") + if len(hasToken) == 0 || !hasToken[0] { + model = model.FieldsEx("token") + } + err = model.Page(req.PageNum, req.PageSize).Order("create_time DESC").Scan(&res.List) + liberr.ErrIsNil(ctx, err, "获取数据失败") + }) + return +} + +func (s *sSysUserOnline) UserIsOnline(ctx context.Context, token string) bool { + err := g.Try(ctx, func(ctx context.Context) { + _, _, err := service.GfToken().GetTokenData(ctx, token) + liberr.ErrIsNil(ctx, err) + }) + return err == nil +} + +func (s *sSysUserOnline) DeleteOnlineByToken(ctx context.Context, token string) (err error) { + _, err = dao.SysUserOnline.Ctx(ctx).Delete(dao.SysUserOnline.Columns().Token, token) + return +} + +func (s *sSysUserOnline) ForceLogout(ctx context.Context, ids []int) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + var onlineList []*entity.SysUserOnline + onlineList, err = s.GetInfosByIds(ctx, ids) + liberr.ErrIsNil(ctx, err) + _, err = dao.SysUserOnline.Ctx(ctx).Where(dao.SysUserOnline.Columns().Id+" in(?)", ids).Delete() + liberr.ErrIsNil(ctx, err) + for _, v := range onlineList { + err = service.GfToken().RemoveToken(ctx, v.Token) + liberr.ErrIsNil(ctx, err) + } + }) + return +} + +func (s *sSysUserOnline) GetInfosByIds(ctx context.Context, ids []int) (onlineList []*entity.SysUserOnline, err error) { + err = dao.SysUserOnline.Ctx(ctx).Where(dao.SysUserOnline.Columns().Id+" in(?)", ids).Scan(&onlineList) + return +} diff --git a/internal/app/system/logic/timeTask/time_task.go b/internal/app/system/logic/timeTask/time_task.go new file mode 100644 index 0000000..cbc1ca4 --- /dev/null +++ b/internal/app/system/logic/timeTask/time_task.go @@ -0,0 +1,61 @@ +/* +* @desc:定时任务栈 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2023/1/13 17:41 + */ + +package timeTask + +import ( + "github.com/gogf/gf/v2/os/gmutex" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +func init() { + service.RegisterTaskList(New()) +} + +func New() *sTaskList { + return &sTaskList{ + mu: gmutex.New(), + } +} + +type sTaskList struct { + taskList []*model.TimeTask + mu *gmutex.Mutex +} + +// AddTask 添加任务 +func (s *sTaskList) AddTask(task *model.TimeTask) { + if task.FuncName == "" || task.Run == nil { + return + } + s.taskList = append(s.taskList, task) +} + +// GetByName 通过方法名获取对应task信息 +func (s *sTaskList) GetByName(funcName string) *model.TimeTask { + var result *model.TimeTask + for _, item := range s.taskList { + if item.FuncName == funcName { + result = item + break + } + } + return result +} + +// EditParams 修改参数 +func (s *sTaskList) EditParams(funcName string, params []string) { + s.mu.Lock() + defer s.mu.Unlock() + for _, item := range s.taskList { + if item.FuncName == funcName { + item.Param = params + break + } + } +} diff --git a/internal/app/system/logic/token/token.go b/internal/app/system/logic/token/token.go new file mode 100644 index 0000000..9f65d33 --- /dev/null +++ b/internal/app/system/logic/token/token.go @@ -0,0 +1,51 @@ +/* +* @desc:token功能 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/27 17:01 + */ + +package token + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + "github.com/tiger1103/gfast-token/gftoken" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + commonModel "github.com/tiger1103/gfast/v3/internal/app/common/model" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +type sToken struct { + *gftoken.GfToken +} + +func New() *sToken { + var ( + ctx = gctx.New() + opt *commonModel.TokenOptions + err = g.Cfg().MustGet(ctx, "gfToken").Struct(&opt) + fun gftoken.OptionFunc + ) + liberr.ErrIsNil(ctx, err) + if opt.CacheModel == consts.CacheModelRedis { + fun = gftoken.WithGRedis() + } else { + fun = gftoken.WithGCache() + } + return &sToken{ + GfToken: gftoken.NewGfToken( + gftoken.WithCacheKey(opt.CacheKey), + gftoken.WithTimeout(opt.Timeout), + gftoken.WithMaxRefresh(opt.MaxRefresh), + gftoken.WithMultiLogin(opt.MultiLogin), + gftoken.WithExcludePaths(opt.ExcludePaths), + fun, + ), + } +} + +func init() { + service.RegisterGToken(New()) +} diff --git a/internal/app/system/logic/toolsGenTable/tools_gen_table.go b/internal/app/system/logic/toolsGenTable/tools_gen_table.go new file mode 100644 index 0000000..a968a10 --- /dev/null +++ b/internal/app/system/logic/toolsGenTable/tools_gen_table.go @@ -0,0 +1,1207 @@ +/* +* @desc:代码生成表数据处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/10/26 17:00 + */ + +package toolsGenTable + +import ( + "bufio" + "context" + "database/sql" + "fmt" + "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/container/gset" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/encoding/gjson" + "github.com/gogf/gf/v2/errors/gerror" + "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/os/gview" + "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/api/v1/system" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" + "io" + "os" + "reflect" + "sort" + "strings" +) + +func init() { + service.RegisterToolsGenTable(New()) +} + +func New() *sToolsGenTable { + return new(sToolsGenTable) +} + +type sToolsGenTable struct{} + +// List 代码生成页面数据列表 +func (s *sToolsGenTable) List(ctx context.Context, req *system.ToolsGenTableSearchReq) (res *system.ToolsGenTableSearchRes, err error) { + res = new(system.ToolsGenTableSearchRes) + m := dao.ToolsGenTable.Ctx(ctx) + if req != nil { + if req.TableName != "" { + m = m.Where(dao.ToolsGenTable.Columns().TableName+" like ?", "%"+req.TableName+"%") + } + if req.TableComment != "" { + m = m.Where(dao.ToolsGenTable.Columns().TableComment+"like ?", "%"+req.TableComment+"%") + } + if len(req.DateRange) > 0 { + m = m.Where(dao.ToolsGenTable.Columns().CreateTime+" >=? AND "+dao.ToolsGenTable.Columns().CreateTime+" <=?", req.DateRange[0], req.DateRange[1]) + } + err = g.Try(ctx, func(ctx context.Context) { + res.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取总行数失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + err = m.Page(req.PageNum, req.PageSize).Order(dao.ToolsGenTable.Columns().TableId + " asc").Scan(&res.List) + liberr.ErrIsNil(ctx, err, "获取数据失败") + }) + } + return +} + +// SelectDbTableList 查询据库表 +func (s *sToolsGenTable) SelectDbTableList(ctx context.Context, req *system.ToolsGenTableImportSearchReq) (res *system.ToolsGenTableSearchRes, err error) { + res = new(system.ToolsGenTableSearchRes) + db := g.DB() + err = g.Try(ctx, func(ctx context.Context) { + if s.getDbDriver() != "mysql" { + liberr.ErrIsNil(ctx, gerror.New("代码生成暂时只支持mysql数据库")) + } + sql := " from information_schema.tables where table_schema = (select database())" + + " and table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' and table_name NOT IN (select table_name from " + dao.ToolsGenTable.Table() + ") " + if req != nil { + if req.TableName != "" { + sql += gdb.FormatSqlWithArgs(" and lower(table_name) like lower(?)", []interface{}{"%" + req.TableName + "%"}) + } + + if req.TableComment != "" { + sql += gdb.FormatSqlWithArgs(" and lower(table_comment) like lower(?)", []interface{}{"%" + req.TableComment + "%"}) + } + if len(req.DateRange) > 0 { + sql += gdb.FormatSqlWithArgs(" and date_format(create_time,'%y%m%d') >= date_format(?,'%y%m%d') ", []interface{}{req.DateRange[0]}) + sql += gdb.FormatSqlWithArgs(" and date_format(create_time,'%y%m%d') <= date_format(?,'%y%m%d') ", []interface{}{req.DateRange[1]}) + } + } + countSql := "select count(1) " + sql + res.Total, err = db.GetCount(ctx, countSql) + liberr.ErrIsNil(ctx, err, "读取总表数失败") + sql = "table_name, table_comment, create_time, update_time " + sql + if req.PageNum == 0 { + req.PageNum = 1 + } + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + page := (req.PageNum - 1) * req.PageSize + sql += " order by create_time desc,table_name asc limit " + gconv.String(page) + "," + gconv.String(req.PageSize) + err = db.GetScan(ctx, &res.List, "select "+sql) + liberr.ErrIsNil(ctx, err, "读取数据失败") + }) + return +} + +// SelectDbTableListByNames 查询数据库中对应的表数据 +func (s *sToolsGenTable) SelectDbTableListByNames(ctx context.Context, tableNames []string) ([]*entity.ToolsGenTable, error) { + err := g.Try(ctx, func(ctx context.Context) { + if s.getDbDriver() != "mysql" { + liberr.ErrIsNil(ctx, gerror.New("代码生成只支持mysql数据库")) + } + }) + db := g.DB() + sql := "select * from information_schema.tables where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' " + + " and table_schema = (select database()) " + if len(tableNames) > 0 { + in := gstr.TrimRight(gstr.Repeat("?,", len(tableNames)), ",") + sql += " and " + gdb.FormatSqlWithArgs("table_name in ("+in+")", gconv.SliceAny(tableNames)) + } + var result []*entity.ToolsGenTable + err = db.GetScan(ctx, &result, sql) + liberr.ErrIsNil(ctx, err, "获取表格信息失败") + return result, err +} + +// ImportGenTable 导入表结构 +func (s *sToolsGenTable) ImportGenTable(ctx context.Context, tableList []*entity.ToolsGenTable) error { + if tableList != nil { + err := g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + for _, table := range tableList { + tableName := table.TableName + // 保存列信息 + genTableColumns, err := service.ToolsGenTableColumn().SelectDbTableColumnsByName(ctx, tableName) + if err != nil || len(genTableColumns) <= 0 { + _ = tx.Rollback() + return gerror.New("获取列数据失败") + } + err = s.InitTable(ctx, table, genTableColumns) + if err != nil { + _ = tx.Rollback() + return err + } + result, err1 := tx.Model(dao.ToolsGenTable.Table()).Insert(table) + if err1 != nil { + _ = tx.Rollback() + return err1 + } + tmpId, err2 := result.LastInsertId() + + if err2 != nil || tmpId <= 0 { + _ = tx.Rollback() + return gerror.New("保存数据失败") + } + + table.TableId = tmpId + for _, column := range genTableColumns { + service.ToolsGenTableColumn().InitColumnField(column, table) + _, err3 := tx.Model(dao.ToolsGenTableColumn.Table()).Insert(column) + if err3 != nil { + _ = tx.Rollback() + return gerror.New("保存列数据失败") + } + } + } + return nil + }) + return err + } else { + return gerror.New("参数错误") + } +} + +// InitTable 初始化表信息 +func (s *sToolsGenTable) InitTable(ctx context.Context, table *entity.ToolsGenTable, columns []*entity.ToolsGenTableColumn) error { + table.ClassName = s.ConvertClassName(ctx, table.TableName) + table.PackageName = g.Cfg().MustGet(ctx, "gen.packageName").String() + table.ModuleName = g.Cfg().MustGet(ctx, "gen.moduleName").String() + table.BusinessName = s.GetBusinessName(ctx, table.TableName) + table.FunctionName = strings.ReplaceAll(table.TableComment, "表", "") + table.FunctionAuthor = g.Cfg().MustGet(ctx, "gen.author").String() + table.TplCategory = "crud" + pkColumn, err := s.getPkColumn(columns) + if err != nil { + return err + } + table.Overwrite = false + table.SortColumn = pkColumn.ColumnName + table.SortType = "asc" + table.ShowDetail = false + table.CreateTime = gtime.Now() + table.UpdateTime = table.CreateTime + return nil +} + +// ConvertClassName 表名转换成类名 +func (s *sToolsGenTable) ConvertClassName(ctx context.Context, tableName string) string { + return gstr.CaseCamel(s.removeTablePrefix(ctx, tableName)) +} + +// GetBusinessName 获取业务名 +func (s *sToolsGenTable) GetBusinessName(ctx context.Context, tableName string) string { + return s.removeTablePrefix(ctx, tableName) +} + +// 找到主键 column +func (s *sToolsGenTable) getPkColumn(columns []*entity.ToolsGenTableColumn) (*entity.ToolsGenTableColumn, error) { + for _, column := range columns { + if column.IsPk { + return column, nil + } + } + return nil, gerror.New("无法找到主键") +} + +// 删除表前缀 +func (s *sToolsGenTable) removeTablePrefix(ctx context.Context, tableName string) string { + autoRemovePre := g.Cfg().MustGet(ctx, "gen.autoRemovePre").Bool() + tablePrefix := g.Cfg().MustGet(ctx, "gen.tablePrefix").String() + if autoRemovePre && tablePrefix != "" { + searchList := strings.Split(tablePrefix, ",") + for _, str := range searchList { + if strings.HasPrefix(tableName, str) { + tableName = strings.Replace(tableName, str, "", 1) //注意,只替换一次 + } + } + } + return tableName +} + +// 获取数据库驱动类型 +func (s *sToolsGenTable) getDbDriver() string { + config := g.DB().GetConfig() + return gstr.ToLower(config.Type) +} + +// DeleteTable 删除表信息 +func (s *sToolsGenTable) DeleteTable(ctx context.Context, req *system.ToolsGenTableDeleteReq) error { + err := g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err := g.Try(ctx, func(ctx context.Context) { + _, err := tx.Model(dao.ToolsGenTable.Table()).Where(dao.ToolsGenTable.Columns().TableId+" in(?)", req.Ids).Delete() + liberr.ErrIsNil(ctx, err, "删除表格数据失败") + _, err = tx.Model(dao.ToolsGenTableColumn.Table()).Where(dao.ToolsGenTableColumn.Columns().TableId+" in(?)", req.Ids).Delete() + liberr.ErrIsNil(ctx, err, "删除表格字段数据失败") + }) + return err + }) + return err +} + +// ColumnList 表格字段列表数据 +func (s *sToolsGenTable) ColumnList(ctx context.Context, req *system.ToolsGenTableEditReq) (res *system.ToolsGenTableEditRes, err error) { + res = new(system.ToolsGenTableEditRes) + err = g.Try(ctx, func(ctx context.Context) { + var ( + tableInfo *entity.ToolsGenTable + ) + res.List, err = service.ToolsGenTableColumn().SelectGenTableColumnListByTableId(ctx, req.TableId) + liberr.ErrIsNil(ctx, err) + tableInfo, err = s.GetTableInfoByTableId(ctx, req.TableId) + liberr.ErrIsNil(ctx, err) + if tableInfo == nil { + liberr.ErrIsNil(ctx, gerror.New("表数据不存在")) + } + res.Info = &model.ToolsGenTableEditData{ + ToolsGenTable: tableInfo, + } + //如果是树表则设置树表配置 + if tableInfo != nil && tableInfo.TplCategory == "tree" { + options := gjson.New(tableInfo.Options) + res.Info.TreeCode = options.Get("treeCode") + res.Info.TreeParentCode = options.Get("treeParentCode") + res.Info.TreeName = options.Get("treeName") + } + }) + return +} + +// GetTableInfoByTableId 获取表格数据 +func (s *sToolsGenTable) GetTableInfoByTableId(ctx context.Context, tableId int64) (data *entity.ToolsGenTable, err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = dao.ToolsGenTable.Ctx(ctx).WherePri(tableId).Scan(&data) + liberr.ErrIsNil(ctx, err, "获取表格信息出错") + }) + return +} + +// GetRelationTable 获取关联表数据 +func (s *sToolsGenTable) GetRelationTable(ctx context.Context) (res []*model.ToolsGenTableColumnsData, err error) { + var tableColumnsAll []*entity.ToolsGenTableColumn + err = g.Try(ctx, func(ctx context.Context) { + //获取表数据 + err = dao.ToolsGenTable.Ctx(ctx).Order(dao.ToolsGenTable.Columns().TableId + " ASC ").Scan(&res) + liberr.ErrIsNil(ctx, err, "获取表数据失败") + //获取表字段数据 + tableColumnsAll, err = service.ToolsGenTableColumn().GetAllTableColumns(ctx) + liberr.ErrIsNil(ctx, err) + for k, v := range res { + for _, cv := range tableColumnsAll { + if cv.TableId == v.TableId { + res[k].Columns = append(res[k].Columns, cv) + } + } + } + }) + return +} + +// SaveEdit 更新表及字段生成信息 +func (s *sToolsGenTable) SaveEdit(ctx context.Context, req *system.ToolsGenTableColumnsEditReq) (err error) { + if req == nil { + err = gerror.New("参数错误") + return + } + var table *entity.ToolsGenTable + err = dao.ToolsGenTable.Ctx(ctx).Where("table_id=?", req.TableId).Scan(&table) + if err != nil || table == nil { + err = gerror.New("数据不存在") + return + } + if req.TableName != "" { + table.TableName = req.TableName + } + if req.TableComment != "" { + table.TableComment = req.TableComment + } + if req.BusinessName != "" { + table.BusinessName = req.BusinessName + } + if req.ClassName != "" { + table.ClassName = req.ClassName + } + if req.FunctionAuthor != "" { + table.FunctionAuthor = req.FunctionAuthor + } + if req.FunctionName != "" { + table.FunctionName = req.FunctionName + } + if req.ModuleName != "" { + table.ModuleName = req.ModuleName + } + if req.PackageName != "" { + table.PackageName = req.PackageName + } + if req.Remark != "" { + table.Remark = req.Remark + } + if req.Overwrite != "" { + table.Overwrite = gconv.Bool(req.Overwrite) + } + if req.SortColumn != "" { + table.SortColumn = req.SortColumn + } + if req.SortType != "" { + table.SortType = req.SortType + } + if req.ShowDetail != "" { + table.ShowDetail = gconv.Bool(req.ShowDetail) + } + if req.TplCategory != "" { + table.TplCategory = req.TplCategory + } + if req.Params != "" { + table.Options = req.Params + } + table.UpdateTime = gtime.Now() + var options g.Map + if req.TplCategory == "tree" { + //树表设置options + options = g.Map{ + "treeCode": req.TreeCode, + "treeParentCode": req.TreeParentCode, + "treeName": req.TreeName, + } + table.Options = gconv.String(options) + } else { + table.Options = "" + } + + err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = tx.Model(dao.ToolsGenTable.Table()).Save(table) + liberr.ErrIsNil(ctx, err, "保存表数据失败") + //保存列数据 + if req.Columns != nil { + for _, column := range req.Columns { + if column.ColumnId > 0 { + var dbColumn *entity.ToolsGenTableColumn + err = dao.ToolsGenTableColumn.Ctx(ctx).Where("column_id=?", column.ColumnId).Scan(&dbColumn) + liberr.ErrIsNil(ctx, err, "列数据信息不存在") + if dbColumn != nil { + dbColumn.ColumnComment = column.ColumnComment + dbColumn.GoType = column.GoType + dbColumn.HtmlType = column.HtmlType + dbColumn.HtmlField = column.HtmlField + dbColumn.QueryType = column.QueryType + dbColumn.GoField = column.GoField + dbColumn.DictType = column.DictType + dbColumn.IsInsert = column.IsInsert + dbColumn.IsEdit = column.IsEdit + dbColumn.IsList = column.IsList + dbColumn.IsDetail = column.IsDetail + dbColumn.IsQuery = column.IsQuery + dbColumn.SortOrderEdit = column.SortOrderEdit + dbColumn.SortOrderList = column.SortOrderList + dbColumn.SortOrderDetail = column.SortOrderDetail + dbColumn.SortOrderQuery = column.SortOrderQuery + dbColumn.IsRequired = column.IsRequired + dbColumn.ColSpan = column.ColSpan + dbColumn.RowSpan = column.RowSpan + dbColumn.IsRowStart = column.IsRowStart + dbColumn.MinWidth = column.MinWidth + dbColumn.IsFixed = column.IsFixed + dbColumn.IsOverflowTooltip = column.IsOverflowTooltip + dbColumn.IsCascade = column.IsCascade + dbColumn.ParentColumnName = column.ParentColumnName + dbColumn.CascadeColumnName = column.CascadeColumnName + if tc, e := options["treeParentCode"]; options != nil && e && tc != "" && tc == dbColumn.HtmlField { + dbColumn.IsQuery = false + dbColumn.IsList = false + dbColumn.HtmlType = "select" + } + //获取字段关联表信息 + if column.LinkLabelName != "" { + dbColumn.LinkTableName = column.LinkTableName + dbColumn.LinkLabelId = column.LinkLabelId + dbColumn.LinkLabelName = column.LinkLabelName + var linkTable *entity.ToolsGenTable + err = dao.ToolsGenTable.Ctx(ctx).Where("table_name =?", column.LinkTableName).Scan(&linkTable) + liberr.ErrIsNil(ctx, err, "获取关联表数据失败") + dbColumn.LinkTableClass = linkTable.ClassName + dbColumn.LinkTableModuleName = linkTable.ModuleName + dbColumn.LinkTableBusinessName = linkTable.BusinessName + dbColumn.LinkTablePackage = linkTable.PackageName + } else { + dbColumn.LinkTableName = "" + dbColumn.LinkTableClass = "" + dbColumn.LinkTableModuleName = "" + dbColumn.LinkTableBusinessName = "" + dbColumn.LinkTablePackage = "" + dbColumn.LinkLabelId = "" + dbColumn.LinkLabelName = "" + } + _, err = tx.Model(dao.ToolsGenTableColumn.Table()).Save(dbColumn) + liberr.ErrIsNil(ctx, err, "保存列:"+dbColumn.ColumnName+",数据失败") + } + } + } + } + }) + return + }) + return +} + +// GenData 获取生成数据 +func (s *sToolsGenTable) GenData(ctx context.Context, tableId int64) (data g.MapStrStr, extendData *model.ToolsGenTableEx, err error) { + extendData, err = s.SelectRecordById(ctx, tableId) + if err != nil { + return + } + if extendData == nil { + err = gerror.New("表格数据不存在") + return + } + service.ToolsGenTableColumn().SetPkColumn(extendData, extendData.Columns) + view := gview.New() + view.SetConfigWithMap(g.Map{ + "Paths": g.Cfg().MustGet(ctx, "gen.templatePath").String(), + "Delimiters": []string{"{{", "}}"}, + }) + view.BindFuncMap(g.Map{ + "UcFirst": func(str string) string { + return gstr.UcFirst(str) + }, + "Sum": func(a, b int) int { + return a + b + }, + "CaseCamelLower": gstr.CaseCamelLower, //首字母小写驼峰 + "CaseCamel": gstr.CaseCamel, //首字母大写驼峰 + "HasSuffix": gstr.HasSuffix, //是否存在后缀 + "ContainsI": gstr.ContainsI, //是否包含子字符串 + "VueTag": func(t string) string { + return t + }, + "inArray": func(arr []interface{}, val interface{}) bool { + for _, v := range arr { + if reflect.DeepEqual(v, val) { + return true + } + } + return false + }, + "append": func(arr []interface{}, val ...interface{}) []interface{} { + arr = append(arr, val...) + return arr + }, + "newArray": func() []interface{} { + return []interface{}{} + }, + }) + + //树形菜单选项 + tplData := g.Map{ + "table": extendData, + "goModName": g.Cfg().MustGet(ctx, "gen.goModName").String(), + "apiVersion": g.Cfg().MustGet(ctx, "gen.apiName").String(), + } + apiKey := "api" + apiValue := "" + var tmpApi string + if tmpApi, err = view.Parse(ctx, "go/api.template", tplData); err == nil { + apiValue = tmpApi + apiValue, err = s.trimBreak(apiValue) + } else { + return + } + daoKey := "dao" + daoValue := "" + var tmpDao string + if tmpDao, err = view.Parse(ctx, "go/dao.template", tplData); err == nil { + daoValue = tmpDao + daoValue, err = s.trimBreak(daoValue) + } else { + return + } + daoInternalKey := "dao_internal" + daoInternalValue := "" + var tmpInternalDao string + if tmpInternalDao, err = view.Parse(ctx, "go/dao_internal.template", tplData); err == nil { + daoInternalValue = tmpInternalDao + daoInternalValue, err = s.trimBreak(daoInternalValue) + } else { + return + } + modelKey := "model" + modelValue := "" + var tmpModel string + if tmpModel, err = view.Parse(ctx, "go/model.template", tplData); err == nil { + modelValue = tmpModel + modelValue, err = s.trimBreak(modelValue) + } else { + return + } + modelEntityKey := "model_entity" + modelEntityValue := "" + var tmpModelEntity string + if tmpModelEntity, err = view.Parse(ctx, "go/model_entity.template", tplData); err == nil { + modelEntityValue = tmpModelEntity + modelEntityValue, err = s.trimBreak(modelEntityValue) + } else { + return + } + modelDoKey := "model_do" + modelDoValue := "" + var tmpModelDo string + if tmpModelDo, err = view.Parse(ctx, "go/model_do.template", tplData); err == nil { + modelDoValue = tmpModelDo + modelDoValue, err = s.trimBreak(modelDoValue) + } else { + return + } + controllerKey := "controller" + controllerValue := "" + var tmpController string + if tmpController, err = view.Parse(ctx, "go/controller.template", tplData); err == nil { + controllerValue = tmpController + controllerValue, err = s.trimBreak(controllerValue) + } else { + return + } + + serviceKey := "service" + serviceValue := "" + var tmpService string + if tmpService, err = view.Parse(ctx, "go/service.template", tplData); err == nil { + serviceValue = tmpService + serviceValue, err = s.trimBreak(serviceValue) + } else { + return + } + + logicKey := "logic" + logicValue := "" + var tmpLogic string + if tmpLogic, err = view.Parse(ctx, "go/logic.template", tplData); err == nil { + logicValue = tmpLogic + logicValue, err = s.trimBreak(logicValue) + } else { + return + } + + routerKey := "router" + routerValue := "" + var tmpRouter string + if tmpRouter, err = view.Parse(ctx, "go/router.template", tplData); err == nil { + routerValue = tmpRouter + routerValue, err = s.trimBreak(routerValue) + } else { + return + } + + routerFuncKey := "router_func" + routerFuncValue := "" + var tmpRouterFunc string + if tmpRouterFunc, err = view.Parse(ctx, "go/router_func.template", tplData); err == nil { + routerFuncValue = tmpRouterFunc + routerFuncValue, err = s.trimBreak(routerFuncValue) + } else { + return + } + + sqlKey := "sql" + sqlValue := "" + var tmpSql string + if tmpSql, err = view.Parse(ctx, "sql/sql.template", tplData); err == nil { + sqlValue = tmpSql + sqlValue, err = s.trimBreak(sqlValue) + } else { + return + } + + tsApiKey := "tsApi" + tsApiValue := "" + var tmpTsApi string + if tmpTsApi, err = view.Parse(ctx, "ts/api.template", tplData); err == nil { + tsApiValue = tmpTsApi + tsApiValue, err = s.trimBreak(tsApiValue) + } else { + return + } + + tsModelKey := "tsModel" + tsModelValue := "" + var tmpTsModel string + if tmpTsModel, err = view.Parse(ctx, "ts/model.template", tplData); err == nil { + tsModelValue = tmpTsModel + tsModelValue, err = s.trimBreak(tsModelValue) + } else { + return + } + + vueKey := "vue" + vueValue := "" + var tmpVue string + tmpFile := "vue/list-vue.template" + if extendData.TplCategory == "tree" { + //树表 + tmpFile = "vue/tree-vue.template" + } + if tmpVue, err = view.Parse(ctx, tmpFile, tplData); err == nil { + vueValue = tmpVue + vueValue, err = s.trimBreak(vueValue) + } else { + return + } + + vueEditKey := "vueEdit" + vueEditValue := "" + var tmpVueEditModel string + if tmpVueEditModel, err = view.Parse(ctx, "vue/edit-vue.template", tplData); err == nil { + vueEditValue = tmpVueEditModel + vueEditValue, err = s.trimBreak(vueEditValue) + } else { + return + } + + vueDetailKey := "vueDetail" + vueDetailValue := "" + var tmpVueDetailModel string + if tmpVueDetailModel, err = view.Parse(ctx, "vue/detail-vue.template", tplData); err == nil { + vueDetailValue = tmpVueDetailModel + vueDetailValue, err = s.trimBreak(vueDetailValue) + } else { + return + } + + data = g.MapStrStr{ + apiKey: apiValue, + daoKey: daoValue, + daoInternalKey: daoInternalValue, + modelKey: modelValue, + modelEntityKey: modelEntityValue, + modelDoKey: modelDoValue, + controllerKey: controllerValue, + serviceKey: serviceValue, + logicKey: logicValue, + routerKey: routerValue, + routerFuncKey: routerFuncValue, + sqlKey: sqlValue, + tsApiKey: tsApiValue, + tsModelKey: tsModelValue, + vueKey: vueValue, + vueEditKey: vueEditValue, + vueDetailKey: vueDetailValue, + } + return +} + +func (s *sToolsGenTable) SelectRecordById(ctx context.Context, tableId int64) (tableEx *model.ToolsGenTableEx, err error) { + var table *entity.ToolsGenTable + table, err = s.GetTableInfoByTableId(ctx, tableId) + if err != nil { + return + } + m := gconv.Map(table) + gconv.Struct(m, &tableEx) + if tableEx.TplCategory == "tree" { + opt := gjson.New(tableEx.Options) + tableEx.TreeParentCode = opt.Get("treeParentCode").String() + tableEx.TreeCode = opt.Get("treeCode").String() + tableEx.TreeName = opt.Get("treeName").String() + } + //表字段数据 + var columns []*entity.ToolsGenTableColumn + columns, err = service.ToolsGenTableColumn().SelectGenTableColumnListByTableId(ctx, tableId) + if err != nil { + return + } + for _, column := range columns { + if column.GoType == "Time" { + tableEx.HasTimeColumn = true + continue + } + } + + allColumnExs := make([]*model.ToolsGenTableColumnEx, len(columns)) + + var ( + editColumns []*model.ToolsGenTableColumnEx + listColumns []*model.ToolsGenTableColumnEx + detailColumns []*model.ToolsGenTableColumnEx + queryColumns []*model.ToolsGenTableColumnEx + ) + + columnMap := make(map[string]*model.ToolsGenTableColumnEx, len(columns)) + for i, column := range columns { + columnName := column.ColumnName + columnEx := &model.ToolsGenTableColumnEx{} + m1 := gconv.Map(column) + err = gconv.Struct(m1, columnEx) + columnMap[columnName] = columnEx + allColumnExs[i] = columnEx + tableEx.IsPkInsertable = tableEx.IsPkInsertable || column.IsPk && !column.IsIncrement + tableEx.IsPkListable = tableEx.IsPkListable || column.IsPk && column.IsList + if column.IsEdit && !service.ToolsGenTableColumn().IsNotEdit(columnName) && !column.IsPk { + editColumns = append(editColumns, columnEx) + columnEx.IsEdit = true + } else { + columnEx.IsEdit = false + } + if column.IsList && !service.ToolsGenTableColumn().IsNotList(columnName) { + listColumns = append(listColumns, columnEx) + columnEx.IsList = true + } else { + columnEx.IsList = false + } + if column.IsDetail && !service.ToolsGenTableColumn().IsNotDetail(columnName) { + detailColumns = append(detailColumns, columnEx) + columnEx.IsDetail = true + } else { + columnEx.IsDetail = false + } + if column.IsQuery && !service.ToolsGenTableColumn().IsNotQuery(columnName) { + queryColumns = append(queryColumns, columnEx) + columnEx.IsQuery = true + } else { + columnEx.IsQuery = false + } + // validation 规则 和 conversion 方法 + integerValidationRule := "integer" + floatValidationRule := "float" + dateValidationRule := "date" + datetimeValidationRule := "datetime" + if column.QueryType == "BETWEEN" { + integerValidationRule += "-array" + floatValidationRule += "-array" + dateValidationRule += "-array" + datetimeValidationRule += "-array" + } + if column.IsPk { + //主键不处理 + continue + } + switch column.GoType { + case "byte": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + integerValidationRule + "|max-length:1#" + column.ColumnComment + "需为整数" + columnEx.FieldConversion = "gconv.Uint64" + tableEx.HasConversion = true + break + case "int": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + integerValidationRule + "#" + column.ColumnComment + "需为整数" + columnEx.FieldConversion = "gconv.Int" + tableEx.HasConversion = true + break + case "int64": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + integerValidationRule + "#" + column.ColumnComment + "需为整数" + columnEx.FieldConversion = "gconv.Int64" + tableEx.HasConversion = true + break + case "uint": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + integerValidationRule + "#" + column.ColumnComment + "需为整数" + columnEx.FieldConversion = "gconv.Uint" + tableEx.HasConversion = true + break + case "uint64": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + integerValidationRule + "#" + column.ColumnComment + "需为整数" + columnEx.FieldConversion = "gconv.Uint64" + tableEx.HasConversion = true + break + case "float": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + floatValidationRule + "#" + column.ColumnComment + "需为浮点数" + columnEx.FieldConversion = "gconv.Float" + tableEx.HasConversion = true + break + case "float64": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + floatValidationRule + "#" + column.ColumnComment + "需为浮点数" + columnEx.FieldConversion = "gconv.Float64" + tableEx.HasConversion = true + break + case "bool": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@boolean#" + column.ColumnComment + "需为true/false" + columnEx.FieldConversion = "gconv.Bool" + tableEx.HasConversion = true + break + case "date": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + dateValidationRule + "#" + column.ColumnComment + "需为YYYY-MM-DD格式" + columnEx.FieldConversion = "gconv.Time" + tableEx.HasConversion = true + break + case "Time": + columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + datetimeValidationRule + "#" + column.ColumnComment + "需为YYYY-MM-DD hh:mm:ss格式" + columnEx.FieldConversion = "gconv.Time" + tableEx.HasConversion = true + break + } + } + + sort.Slice(editColumns, func(i, j int) bool { + return editColumns[i].SortOrderEdit < editColumns[j].SortOrderEdit + }) + sort.Slice(listColumns, func(i, j int) bool { + return listColumns[i].SortOrderList < listColumns[j].SortOrderList + }) + sort.Slice(detailColumns, func(i, j int) bool { + return detailColumns[i].SortOrderDetail < detailColumns[j].SortOrderDetail + }) + sort.Slice(queryColumns, func(i, j int) bool { + return queryColumns[i].SortOrderQuery < queryColumns[j].SortOrderQuery + }) + + tableEx.Columns = allColumnExs + tableEx.EditColumns = editColumns + tableEx.DetailColumns = detailColumns + tableEx.ListColumns = listColumns + tableEx.QueryColumns = queryColumns + + _, hasCreatedBy := columnMap["created_by"] + tableEx.HasCreatedBy = hasCreatedBy + _, hasUpdateBy := columnMap["updated_by"] + tableEx.HasUpdatedBy = hasUpdateBy + + for _, column := range allColumnExs { + if column.IsCascade { + parentColumnName := column.ParentColumnName + if g.IsEmpty(parentColumnName) { + err = gerror.New("级联查询字段\"" + column.ColumnName + "\"并未设置parentColumnName") + return nil, err + } + parent := columnMap[parentColumnName] + if g.IsEmpty(parent) { + err = gerror.New("级联查询字段\"" + column.ColumnName + "\"的parentColumnName\"" + parentColumnName + "\"不存在于表中") + return nil, err + } + column.ParentColumnName = parentColumnName + column.CascadeParent = parent + parent.IsCascadeParent = true + parent.CascadeChildrenColumns = gset.NewStrSet() + } + } + for _, column := range allColumnExs { + if column.IsCascade { + child := column + for { + parentColumnName := child.ParentColumnName + if g.IsEmpty(parentColumnName) { + break + } + parent := columnMap[parentColumnName] + parent.CascadeChildrenColumns.Add(column.ColumnName) + child = parent + } + } + } + + // 提取关联表信息 + var linkedTableMap = gmap.New() + for _, column := range allColumnExs { + if len(column.LinkTableName) == 0 { + continue + } + linkedTableName := column.LinkTableName + // 关联表信息 + linkedTableInfo, err1 := s.getLinkedTableInfo(ctx, linkedTableName) + if err1 != nil { + err = err1 + return + } + linkedTable := linkedTableMap.GetOrSet(linkedTableName, interface{}(linkedTableInfo)).(*model.ToolsGenTableLinked) + + allColumnMap, err2 := service.ToolsGenTableColumn().SelectDbTableColumnMapByName(ctx, linkedTableName) + if err2 != nil { + err = err2 + return + } + // 关联字段 + linkedTableIdColumn, foundId := allColumnMap[column.LinkLabelId] + if !foundId { + err = gerror.New("无法找到关联表的列" + column.LinkLabelId) + return + } + linkedTableValueColumn, foundValue := allColumnMap[column.LinkLabelName] + if !foundValue { + err = gerror.New("无法找到关联表的列" + column.LinkLabelId) + return + } + service.ToolsGenTableColumn().InitColumnField(linkedTableIdColumn, table) + service.ToolsGenTableColumn().InitColumnField(linkedTableValueColumn, table) + if linkedTableIdColumn.GoType == "Time" || linkedTableValueColumn.GoType == "Time" { + tableEx.HasTimeColumn = true + } + linkedTable.RefColumns.GetOrSet(linkedTableIdColumn.ColumnName, linkedTableIdColumn) + linkedTable.RefColumns.GetOrSet(linkedTableValueColumn.ColumnName, &linkedTableValueColumn) + } + + tableEx.LinkedTables = make([]*model.ToolsGenTableLinked, linkedTableMap.Size()) + for i, v := range linkedTableMap.Values() { + tableEx.LinkedTables[i] = v.(*model.ToolsGenTableLinked) + } + return +} + +// GenCode 代码生成操作 +func (s *sToolsGenTable) GenCode(ctx context.Context, ids []int) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + //获取当前运行时目录 + curDir, err := os.Getwd() + liberr.ErrIsNil(ctx, err, "获取本地路径失败") + frontDir := g.Cfg().MustGet(ctx, "gen.frontDir").String() + if !gfile.IsDir(frontDir) { + panic("项目前端路径不存在,请检查是否已在配置文件中配置!") + } + apiName := g.Cfg().MustGet(ctx, "gen.apiName").String() + goModName := g.Cfg().MustGet(ctx, "gen.goModName").String() + for _, id := range ids { + var genData g.MapStrStr + var extendData *model.ToolsGenTableEx + genData, extendData, err = s.GenData(ctx, gconv.Int64(id)) + liberr.ErrIsNil(ctx, err) + packageName := extendData.PackageName + pluginName := "" + if gstr.ContainsI(extendData.PackageName, "plugins") { + pluginName = "plugins/" + } + businessName := gstr.CaseCamelLower(extendData.BusinessName) + for key, code := range genData { + switch key { + case "api": + path := strings.Join([]string{curDir, "/", apiName, "/", pluginName, extendData.ModuleName, "/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "controller": + path := strings.Join([]string{curDir, "/", packageName, "/controller/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "dao": + path := strings.Join([]string{curDir, "/", packageName, "/dao/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "dao_internal": + path := strings.Join([]string{curDir, "/", packageName, "/dao/internal/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "logic": + path := strings.Join([]string{curDir, "/", packageName, "/logic/", businessName, "/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "model": + path := strings.Join([]string{curDir, "/", packageName, "/model/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "model_do": + path := strings.Join([]string{curDir, "/", packageName, "/model/do/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "model_entity": + path := strings.Join([]string{curDir, "/", packageName, "/model/entity/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "router": + if !gstr.ContainsI(packageName, "system") { // system 模块不生成router文件 + path := strings.Join([]string{curDir, "/", packageName, "/router/router", ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + } + case "router_func": + path := strings.Join([]string{curDir, "/", packageName, "/router/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "service": + path := strings.Join([]string{curDir, "/", packageName, "/service/", extendData.TableName, ".go"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "sql": + path := strings.Join([]string{curDir, "/resource/data/gen_sql/", extendData.ModuleName, "/", extendData.TableName, ".sql"}, "") + hasSql := gfile.Exists(path) + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + if !hasSql || extendData.Overwrite { + //第一次生成则向数据库写入菜单数据 + err = s.writeDb(ctx, path) + liberr.ErrIsNil(ctx, err) + //清除菜单缓存 + commonService.Cache().Remove(ctx, consts.CacheSysAuthMenu) + } + case "tsApi": + path := strings.Join([]string{frontDir, "/src/api/" + pluginName, extendData.ModuleName, "/", businessName, ".ts"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "tsModel": + path := strings.Join([]string{frontDir, "/src/views/" + pluginName, extendData.ModuleName, "/", businessName + "/list/component/model", ".ts"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "vue": + path := strings.Join([]string{frontDir, "/src/views/" + pluginName, extendData.ModuleName, "/", businessName, "/list/index.vue"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "vueDetail": + path := strings.Join([]string{frontDir, "/src/views/" + pluginName, extendData.ModuleName, "/", businessName + "/list/component/detail", ".vue"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + case "vueEdit": + path := strings.Join([]string{frontDir, "/src/views/" + pluginName, extendData.ModuleName, "/", businessName + "/list/component/edit", ".vue"}, "") + err = s.createFile(path, code, extendData.Overwrite) + liberr.ErrIsNil(ctx, err) + } + } + //生成对应模块的logic + err = s.genModuleLogic(curDir, goModName, extendData.PackageName) + liberr.ErrIsNil(ctx, err) + } + }) + return +} + +// 写入菜单数据 +func (s *sToolsGenTable) writeDb(ctx context.Context, path string) (err error) { + isAnnotation := false + var fi *os.File + fi, err = os.Open(path) + if err != nil { + return + } + defer fi.Close() + br := bufio.NewReader(fi) + var sqlStr []string + now := gtime.Now() + var res sql.Result + var id int64 + var tx gdb.TX + tx, err = g.DB().Ctx(ctx).Begin(ctx) + if err != nil { + return + } + for { + bytes, e := br.ReadBytes('\n') + if e == io.EOF { + break + } + str := gstr.Trim(string(bytes)) + + if str == "" { + continue + } + + if strings.Contains(str, "/*") { + isAnnotation = true + } + + if isAnnotation { + if strings.Contains(str, "*/") { + isAnnotation = false + } + continue + } + + if str == "" || strings.HasPrefix(str, "--") || strings.HasPrefix(str, "#") { + continue + } + if strings.HasSuffix(str, ";") { + if gstr.ContainsI(str, "select") { + if gstr.ContainsI(str, "@now") { + continue + } + if gstr.ContainsI(str, "@parentId") { + id, err = res.LastInsertId() + } + } + sqlStr = append(sqlStr, str) + sql := strings.Join(sqlStr, "") + gstr.ReplaceByArray(sql, []string{"@parentId", gconv.String(id), "@now", now.Format("Y-m-d H:i:s")}) + //插入业务 + res, err = tx.Exec(sql) + if err != nil { + tx.Rollback() + return + } + sqlStr = nil + } else { + sqlStr = []string{str} + } + } + tx.Commit() + return +} + +// createFile 创建文件 +func (s *sToolsGenTable) createFile(fileName, data string, cover bool) (err error) { + if !gfile.Exists(fileName) || cover { + var f *os.File + f, err = gfile.Create(fileName) + if err == nil { + f.WriteString(data) + } + f.Close() + } + return +} + +func (s *sToolsGenTable) getLinkedTableInfo(ctx context.Context, tableName string) (linkedTable *model.ToolsGenTableLinked, err error) { + var table *entity.ToolsGenTable + err = g.Try(ctx, func(ctx context.Context) { + err = dao.ToolsGenTable.Ctx(ctx).Where(dao.ToolsGenTable.Columns().TableName, tableName).Scan(&table) + liberr.ErrIsNil(ctx, err, "获取关联表格"+tableName+"信息出错") + m := gconv.Map(table) + err = gconv.Struct(m, &linkedTable) + liberr.ErrIsNil(ctx, err) + linkedTable.RefColumns = gmap.NewListMap() + }) + return +} + +// 剔除多余的换行 +func (s *sToolsGenTable) trimBreak(str string) (rStr string, err error) { + var b []byte + if b, err = gregex.Replace("(([\\s\t]*)\r?\n){2,}", []byte("$2\n"), []byte(str)); err != nil { + return + } + if b, err = gregex.Replace("(([\\s\t]*)/{4}\r?\n)", []byte("$2\n\n"), b); err == nil { + rStr = gconv.String(b) + } + return +} + +// GenModuleRouter 生成模块路由 +func (s *sToolsGenTable) genModuleLogic(curDir, goModName, packageName string) (err error) { + var ( + packages []string + code string + ) + //logic路径 + path := strings.Join([]string{curDir, "/", packageName, "/logic"}, "") + //获取该路径下所有需要加载的包 + packages, err = gfile.ScanDirFunc(path, "*", false, func(p string) string { + if gfile.IsDir(p) { + return p + } + return "" + }) + if err != nil { + return + } + for _, v := range packages { + v = gstr.Replace(v, "\\", "/") + v = gstr.SubStr(v, gstr.PosR(v, "/")) + code += strings.Join([]string{"import _ ", `"`, goModName, "/", packageName, "/logic", v, `"`, "\n"}, "") + } + code = fmt.Sprintf(`package logic%s%s`, "\n\n", code) + err = s.createFile(path+"/logic.go", code, true) + return +} diff --git a/internal/app/system/logic/toolsGenTableColumn/tools_gen_table_column.go b/internal/app/system/logic/toolsGenTableColumn/tools_gen_table_column.go new file mode 100644 index 0000000..037988a --- /dev/null +++ b/internal/app/system/logic/toolsGenTableColumn/tools_gen_table_column.go @@ -0,0 +1,369 @@ +/* +* @desc:代码生成字段处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/10/28 10:10 + */ + +package toolsGenTableColumn + +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/liberr" + "strings" +) + +func init() { + service.RegisterToolsGenTableColumn(New()) +} + +func New() *sToolsGenTableColumn { + return &sToolsGenTableColumn{ + ColumnTypeStr: []string{"char", "varchar", "narchar", "varchar2", "tinytext", "text", "mediumtext", "longtext"}, + ColumnTypeTime: []string{"datetime", "time", "date", "timestamp"}, + ColumnTypeNumber: []string{"tinyint", "smallint", "mediumint", "int", "number", "integer", "bigint", "float", "float", "double", "decimal"}, + ColumnNameNotEdit: []string{"created_by", "created_at", "updated_by", "updated_at", "deleted_at"}, + ColumnNameNotList: []string{"updated_by", "updated_at", "deleted_at"}, + ColumnNameNotDetail: []string{"updated_at", "deleted_at"}, + ColumnNameNotQuery: []string{"updated_by", "updated_at", "deleted_at", "remark"}, + } +} + +type sToolsGenTableColumn struct { + ColumnTypeStr []string //数据库字符串类型 + ColumnTypeTime []string //数据库时间类型 + ColumnTypeNumber []string //数据库数字类型 + ColumnNameNotEdit []string //页面不需要编辑字段 + ColumnNameNotList []string //页面不需要显示的列表字段 + ColumnNameNotDetail []string //页面不需要显示的详情字段 + ColumnNameNotQuery []string //页面不需要查询字段 +} + +// SelectDbTableColumnsByName 根据表名称查询列信息 +func (s *sToolsGenTableColumn) SelectDbTableColumnsByName(ctx context.Context, tableName string) ([]*entity.ToolsGenTableColumn, error) { + var res []*entity.ToolsGenTableColumn + err := g.Try(ctx, func(ctx context.Context) { + db := g.DB() + sql := " select column_name, (case when (is_nullable = 'YES' || is_nullable = 'NO' && column_default is not null) then '0' else '1' end) as is_required, " + + "(case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort_order_edit, column_comment," + + " (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type from information_schema.columns" + + " where table_schema = (select database()) " + sql += " and " + gdb.FormatSqlWithArgs(" table_name=? ", []interface{}{tableName}) + " order by ordinal_position ASC " + err := db.GetScan(ctx, &res, sql) + liberr.ErrIsNil(ctx, err, "查询列信息失败") + }) + return res, err +} + +// InitColumnField 初始化列属性字段 +func (s *sToolsGenTableColumn) InitColumnField(column *entity.ToolsGenTableColumn, table *entity.ToolsGenTable) { + dataType := s.GetDbType(column.ColumnType) + columnName := column.ColumnName + column.TableId = table.TableId + //设置字段名 + column.GoField = gstr.CaseCamel(columnName) + column.HtmlField = gstr.CaseCamelLower(columnName) + + if s.IsStringObject(dataType) { + //字段为字符串类型 + column.GoType = "string" + column.TsType = "string" + columnLength := s.GetColumnLength(column.ColumnType) + if columnLength >= 500 { + column.HtmlType = "textarea" + } else { + column.HtmlType = "input" + } + } else if s.IsTimeObject(dataType) { + //字段为时间类型 + column.GoType = "Time" + column.TsType = "string" + column.HtmlType = "datetime" + } else if s.IsNumberObject(dataType) { + //字段为数字类型 + column.HtmlType = "input" + t, _ := gregex.ReplaceString(`\(.+\)`, "", column.ColumnType) + t = gstr.Split(gstr.Trim(t), " ")[0] + t = gstr.ToLower(t) + // 如果是浮点型 + switch t { + case "float", "double", "decimal": + column.GoType = "float64" + case "bit", "int", "tinyint", "small_int", "smallint", "medium_int", "mediumint": + if gstr.ContainsI(column.ColumnType, "unsigned") { + column.GoType = "uint" + } else { + column.GoType = "int" + } + case "big_int", "bigint": + if gstr.ContainsI(column.ColumnType, "unsigned") { + column.GoType = "uint64" + } else { + column.GoType = "int64" + } + } + column.TsType = "number" + } else if dataType == "bit" { + column.GoType = "bool" + column.TsType = "boolean" + } + + //新增字段 + if s.IsNotEdit(columnName) { + column.IsInsert = false + } else if column.IsIncrement { + column.IsInsert = false + } else { + column.IsInsert = true + } + + // 编辑字段 + if s.IsNotEdit(columnName) { + column.IsEdit = false + } else if column.IsPk { + column.IsEdit = false + } else { + column.IsEdit = true + } + // 列表字段 + if s.IsNotList(columnName) { + column.IsList = false + } else { + column.IsList = true + } + // 详情字段 + if s.IsNotDetail(columnName) { + column.IsDetail = false + } else { + column.IsDetail = true + } // 查询字段 + if s.IsNotQuery(columnName) { + column.IsQuery = false + } else { + column.IsQuery = true + } + + // 查询字段类型 + if s.CheckNameColumn(columnName) { + column.QueryType = "LIKE" + } else { + column.QueryType = "EQ" + } + + // todo 最好不要用字段名来推断是否必填 + if strings.Index(columnName, "name") >= 0 || strings.Index(columnName, "status") >= 0 { + column.IsRequired = true + } + + // 状态字段设置单选框 + if s.CheckStatusColumn(columnName) { + column.HtmlType = "radio" + //column.IsStatus = true + } else if s.CheckTypeColumn(columnName) || s.CheckSexColumn(columnName) { + // 类型&性别字段设置下拉框 + column.HtmlType = "select" + } + + column.SortOrderList = column.SortOrderEdit + column.SortOrderDetail = column.SortOrderEdit + column.SortOrderQuery = column.SortOrderEdit + column.ColSpan = 12 + column.RowSpan = 1 + column.IsRowStart = false + column.MinWidth = 100 + column.IsFixed = false + column.IsOverflowTooltip = false + column.IsCascade = false + column.ParentColumnName = "" + column.CascadeColumnName = "" +} + +// GetDbType 获取数据库类型字段 +func (s *sToolsGenTableColumn) GetDbType(columnType string) string { + if strings.Index(columnType, "(") > 0 { + return columnType[0:strings.Index(columnType, "(")] + } else if strings.Index(columnType, " ") > 0 { // 类似 int unsigned, 即 int 类型后面并没有标注长度 + return columnType[0:strings.Index(columnType, " ")] + } else { + return columnType + } +} + +// IsExistInArray 判断 value 是否存在在切片array中 +func (s *sToolsGenTableColumn) IsExistInArray(value string, array []string) bool { + for _, v := range array { + if v == value { + return true + } + } + return false +} + +// IsStringObject 判断是否是数据库字符串类型 +func (s *sToolsGenTableColumn) IsStringObject(dataType string) bool { + return s.IsExistInArray(dataType, s.ColumnTypeStr) +} + +// IsTimeObject 判断是否是数据库时间类型 +func (s *sToolsGenTableColumn) IsTimeObject(dataType string) bool { + return s.IsExistInArray(dataType, s.ColumnTypeTime) +} + +// IsNumberObject 是否数字类型 +func (s *sToolsGenTableColumn) IsNumberObject(dataType string) bool { + return s.IsExistInArray(dataType, s.ColumnTypeNumber) +} + +// IsNotEdit 是否不可编辑 +func (s *sToolsGenTableColumn) IsNotEdit(name string) bool { + return s.IsExistInArray(name, s.ColumnNameNotEdit) +} + +// IsNotList 不在列表显示 +func (s *sToolsGenTableColumn) IsNotList(name string) bool { + return s.IsExistInArray(name, s.ColumnNameNotList) +} + +// IsNotDetail 不在详情显示 +func (s *sToolsGenTableColumn) IsNotDetail(name string) bool { + return s.IsExistInArray(name, s.ColumnNameNotDetail) +} + +// IsNotQuery 不可用于查询 +func (s *sToolsGenTableColumn) IsNotQuery(name string) bool { + return s.IsExistInArray(name, s.ColumnNameNotQuery) +} + +// CheckNameColumn 检查字段名后4位是否是name +func (s *sToolsGenTableColumn) CheckNameColumn(columnName string) bool { + if len(columnName) >= 4 { + end := len(columnName) + start := end - 4 + if start <= 0 { + start = 0 + } + tmp := columnName[start:end] + if tmp == "name" { + return true + } + } + return false +} + +// CheckStatusColumn 检查字段名后6位是否是status +func (s *sToolsGenTableColumn) CheckStatusColumn(columnName string) bool { + if len(columnName) >= 6 { + end := len(columnName) + start := end - 6 + + if start <= 0 { + start = 0 + } + tmp := columnName[start:end] + + if tmp == "status" { + return true + } + } + + return false +} + +// CheckTypeColumn 检查字段名后4位是否是type +func (s *sToolsGenTableColumn) CheckTypeColumn(columnName string) bool { + if len(columnName) >= 4 { + end := len(columnName) + start := end - 4 + + if start <= 0 { + start = 0 + } + + if columnName[start:end] == "type" { + return true + } + } + return false +} + +// CheckSexColumn 检查字段名后3位是否是sex +func (s *sToolsGenTableColumn) CheckSexColumn(columnName string) bool { + if len(columnName) >= 3 { + end := len(columnName) + start := end - 3 + if start <= 0 { + start = 0 + } + if columnName[start:end] == "sex" { + return true + } + } + return false +} + +// SelectGenTableColumnListByTableId 查询业务字段列表 +func (s *sToolsGenTableColumn) SelectGenTableColumnListByTableId(ctx context.Context, tableId int64) (list []*entity.ToolsGenTableColumn, err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = dao.ToolsGenTableColumn.Ctx(ctx). + Where(dao.ToolsGenTableColumn.Columns().TableId, tableId). + Order(dao.ToolsGenTableColumn.Columns().SortOrderEdit + " asc, " + + dao.ToolsGenTableColumn.Columns().ColumnId + " asc").Scan(&list) + liberr.ErrIsNil(ctx, err, "获取字段信息出错") + }) + return list, nil +} + +// GetAllTableColumns 获取所有字段信息 +func (s *sToolsGenTableColumn) GetAllTableColumns(ctx context.Context) (list []*entity.ToolsGenTableColumn, err error) { + err = g.Try(ctx, func(ctx context.Context) { + err = dao.ToolsGenTableColumn.Ctx(ctx). + Order(dao.ToolsGenTableColumn.Columns().SortOrderEdit + " asc, " + + dao.ToolsGenTableColumn.Columns().ColumnId + " asc").Scan(&list) + liberr.ErrIsNil(ctx, err, "获取字段信息出错") + }) + return +} + +func (s *sToolsGenTableColumn) SetPkColumn(table *model.ToolsGenTableEx, columns []*model.ToolsGenTableColumnEx) { + for _, column := range columns { + if column.IsPk { + table.PkColumn = column + break + } + } + if table.PkColumn == nil { + table.PkColumn = columns[0] + } +} + +// GetColumnLength 获取字段长度 +func (s *sToolsGenTableColumn) GetColumnLength(columnType string) int { + start := strings.Index(columnType, "(") + end := strings.Index(columnType, ")") + result := "" + if start >= 0 && end >= 0 { + result = columnType[start+1 : end-1] + } + return gconv.Int(result) +} + +func (s *sToolsGenTableColumn) SelectDbTableColumnMapByName(ctx context.Context, tableName string) (res map[string]*entity.ToolsGenTableColumn, err error) { + err = g.Try(ctx, func(ctx context.Context) { + list, err := s.SelectDbTableColumnsByName(ctx, tableName) + liberr.ErrIsNil(ctx, err) + res = make(map[string]*entity.ToolsGenTableColumn, len(list)) + for _, item := range list { + res[item.ColumnName] = item + } + }) + return res, nil +} diff --git a/internal/app/system/model/.gitkeep b/internal/app/system/model/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/internal/app/system/model/context.go b/internal/app/system/model/context.go new file mode 100644 index 0000000..6007206 --- /dev/null +++ b/internal/app/system/model/context.go @@ -0,0 +1,16 @@ +/* +* @desc:context-model +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/16 14:45 + */ + +package model + +type Context struct { + User *ContextUser // User in context. +} + +type ContextUser struct { + *LoginUserRes +} diff --git a/internal/app/system/model/do/big_file.go b/internal/app/system/model/do/big_file.go new file mode 100644 index 0000000..04a85d4 --- /dev/null +++ b/internal/app/system/model/do/big_file.go @@ -0,0 +1,29 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// BigFile is the golang structure of table big_file for DAO operations like Where/Data. +type BigFile struct { + g.Meta `orm:"table:big_file, do:true"` + Id interface{} // + Name interface{} // 文件名称 + Size interface{} // 文件大小 + Path interface{} // 文件相对路径 + FullPath interface{} // 文件绝对路径 + MimeType interface{} // 文件类型 + Source interface{} // 文件来源 0 - 本地,1 - 腾讯云 2 - 七牛云 + Describe interface{} // 描述 + Md5 interface{} // md5 + CreatedBy interface{} // + UpdatedBy interface{} // + CreatedAt *gtime.Time // + UpdatedAt *gtime.Time // + DeletedAt *gtime.Time // +} diff --git a/internal/app/system/model/do/sys_auth_rule.go b/internal/app/system/model/do/sys_auth_rule.go new file mode 100644 index 0000000..3efd7af --- /dev/null +++ b/internal/app/system/model/do/sys_auth_rule.go @@ -0,0 +1,37 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysAuthRule is the golang structure of table sys_auth_rule for DAO operations like Where/Data. +type SysAuthRule struct { + g.Meta `orm:"table:sys_auth_rule, do:true"` + Id interface{} // + Pid interface{} // 父ID + Name interface{} // 规则名称 + Title interface{} // 规则名称 + Icon interface{} // 图标 + Condition interface{} // 条件 + Remark interface{} // 备注 + MenuType interface{} // 类型 0目录 1菜单 2按钮 + Weigh interface{} // 权重 + IsHide interface{} // 显示状态 + Path interface{} // 路由地址 + Component interface{} // 组件路径 + IsLink interface{} // 是否外链 1是 0否 + ModuleType interface{} // 所属模块 + ModelId interface{} // 模型ID + IsIframe interface{} // 是否内嵌iframe + IsCached interface{} // 是否缓存 + Redirect interface{} // 路由重定向地址 + IsAffix interface{} // 是否固定 + LinkUrl interface{} // 链接地址 + CreatedAt *gtime.Time // 创建日期 + UpdatedAt *gtime.Time // 修改日期 +} diff --git a/internal/app/system/model/do/sys_dept.go b/internal/app/system/model/do/sys_dept.go new file mode 100644 index 0000000..6139fbc --- /dev/null +++ b/internal/app/system/model/do/sys_dept.go @@ -0,0 +1,29 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDept is the golang structure of table sys_dept for DAO operations like Where/Data. +type SysDept struct { + g.Meta `orm:"table:sys_dept, do:true"` + DeptId interface{} // 部门id + ParentId interface{} // 父部门id + Ancestors interface{} // 祖级列表 + DeptName interface{} // 部门名称 + OrderNum interface{} // 显示顺序 + Leader interface{} // 负责人 + Phone interface{} // 联系电话 + Email interface{} // 邮箱 + Status interface{} // 部门状态(0正常 1停用) + CreatedBy interface{} // 创建人 + UpdatedBy interface{} // 修改人 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 修改时间 + DeletedAt *gtime.Time // 删除时间 +} diff --git a/internal/app/system/model/do/sys_job.go b/internal/app/system/model/do/sys_job.go new file mode 100644 index 0000000..f690859 --- /dev/null +++ b/internal/app/system/model/do/sys_job.go @@ -0,0 +1,34 @@ +// ========================================================================== +// GFast自动生成model entity操作代码。 +// 生成日期:2023-01-12 17:43:50 +// 生成路径: internal/app/system/model/entity/sys_job.go +// 生成人:gfast +// desc:定时任务 +// company:云南奇讯科技有限公司 +// ========================================================================== + +package do + +import ( + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gmeta" +) + +// SysJob is the golang structure for table sys_job. +type SysJob struct { + gmeta.Meta `orm:"table:sys_job, do:true"` + JobId interface{} `orm:"job_id,primary" json:"jobId"` // 任务ID + JobName interface{} `orm:"job_name" json:"jobName"` // 任务名称 + JobParams interface{} `orm:"job_params" json:"jobParams"` // 参数 + JobGroup interface{} `orm:"job_group" json:"jobGroup"` // 任务组名 + InvokeTarget interface{} `orm:"invoke_target" json:"invokeTarget"` // 任务方法 + CronExpression interface{} `orm:"cron_expression" json:"cronExpression"` // cron执行表达式 + MisfirePolicy interface{} `orm:"misfire_policy" json:"misfirePolicy"` // 计划执行策略 + Concurrent interface{} `orm:"concurrent" json:"concurrent"` // 是否并发执行 + Status interface{} `orm:"status" json:"status"` // 状态 + CreatedBy interface{} `orm:"created_by" json:"createdBy"` // 创建者 + UpdatedBy interface{} `orm:"updated_by" json:"updatedBy"` // 更新者 + Remark interface{} `orm:"remark" json:"remark"` // 备注信息 + CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` // 创建时间 + UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt"` // 更新时间 +} diff --git a/internal/app/system/model/do/sys_job_log.go b/internal/app/system/model/do/sys_job_log.go new file mode 100644 index 0000000..424e3fc --- /dev/null +++ b/internal/app/system/model/do/sys_job_log.go @@ -0,0 +1,19 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysJobLog is the golang structure of table sys_job_log for DAO operations like Where/Data. +type SysJobLog struct { + g.Meta `orm:"table:sys_job_log, do:true"` + Id interface{} // 主键 + TargetName interface{} // 方法名 + CreatedAt *gtime.Time // 执行日期 + Result interface{} // 执行结果 +} diff --git a/internal/app/system/model/do/sys_login_log.go b/internal/app/system/model/do/sys_login_log.go new file mode 100644 index 0000000..d68762e --- /dev/null +++ b/internal/app/system/model/do/sys_login_log.go @@ -0,0 +1,25 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-08 11:31:48 +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysLoginLog is the golang structure of table sys_login_log for DAO operations like Where/Data. +type SysLoginLog struct { + g.Meta `orm:"table:sys_login_log, do:true"` + InfoId interface{} // 访问ID + LoginName interface{} // 登录账号 + Ipaddr interface{} // 登录IP地址 + LoginLocation interface{} // 登录地点 + Browser interface{} // 浏览器类型 + Os interface{} // 操作系统 + Status interface{} // 登录状态(0成功 1失败) + Msg interface{} // 提示消息 + LoginTime *gtime.Time // 登录时间 + Module interface{} // 登录模块 +} diff --git a/internal/app/system/model/do/sys_oper_log.go b/internal/app/system/model/do/sys_oper_log.go new file mode 100644 index 0000000..0e3f32b --- /dev/null +++ b/internal/app/system/model/do/sys_oper_log.go @@ -0,0 +1,29 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysOperLog is the golang structure of table sys_oper_log for DAO operations like Where/Data. +type SysOperLog struct { + g.Meta `orm:"table:sys_oper_log, do:true"` + OperId interface{} // 日志主键 + Title interface{} // 模块标题 + BusinessType interface{} // 业务类型(0其它 1新增 2修改 3删除) + Method interface{} // 方法名称 + RequestMethod interface{} // 请求方式 + OperatorType interface{} // 操作类别(0其它 1后台用户 2手机端用户) + OperName interface{} // 操作人员 + DeptName interface{} // 部门名称 + OperUrl interface{} // 请求URL + OperIp interface{} // 主机地址 + OperLocation interface{} // 操作地点 + OperParam interface{} // 请求参数 + ErrorMsg interface{} // 错误消息 + OperTime *gtime.Time // 操作时间 +} diff --git a/internal/app/system/model/do/sys_post.go b/internal/app/system/model/do/sys_post.go new file mode 100644 index 0000000..c6e7189 --- /dev/null +++ b/internal/app/system/model/do/sys_post.go @@ -0,0 +1,26 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-07 23:26:21 +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysPost is the golang structure of table sys_post for DAO operations like Where/Data. +type SysPost struct { + g.Meta `orm:"table:sys_post, do:true"` + PostId interface{} // 岗位ID + PostCode interface{} // 岗位编码 + PostName interface{} // 岗位名称 + PostSort interface{} // 显示顺序 + Status interface{} // 状态(0正常 1停用) + Remark interface{} // 备注 + CreatedBy interface{} // 创建人 + UpdatedBy interface{} // 修改人 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 修改时间 + DeletedAt *gtime.Time // 删除时间 +} diff --git a/internal/app/system/model/do/sys_role.go b/internal/app/system/model/do/sys_role.go new file mode 100644 index 0000000..47e9599 --- /dev/null +++ b/internal/app/system/model/do/sys_role.go @@ -0,0 +1,23 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysRole is the golang structure of table sys_role for DAO operations like Where/Data. +type SysRole struct { + g.Meta `orm:"table:sys_role, do:true"` + Id interface{} // + Status interface{} // 状态;0:禁用;1:正常 + ListOrder interface{} // 排序 + Name interface{} // 角色名称 + Remark interface{} // 备注 + DataScope interface{} // 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 +} diff --git a/internal/app/system/model/do/sys_role_dept.go b/internal/app/system/model/do/sys_role_dept.go new file mode 100644 index 0000000..df1a1ad --- /dev/null +++ b/internal/app/system/model/do/sys_role_dept.go @@ -0,0 +1,16 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// SysRoleDept is the golang structure of table sys_role_dept for DAO operations like Where/Data. +type SysRoleDept struct { + g.Meta `orm:"table:sys_role_dept, do:true"` + RoleId interface{} // 角色ID + DeptId interface{} // 部门ID +} diff --git a/internal/app/system/model/do/sys_user.go b/internal/app/system/model/do/sys_user.go new file mode 100644 index 0000000..9f39673 --- /dev/null +++ b/internal/app/system/model/do/sys_user.go @@ -0,0 +1,36 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-02 16:48:23 +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysUser is the golang structure of table sys_user for DAO operations like Where/Data. +type SysUser struct { + g.Meta `orm:"table:sys_user, do:true"` + Id interface{} // + UserName interface{} // 用户名 + Mobile interface{} // 中国手机不带国家代码,国际手机号格式为:国家代码-手机号 + UserNickname interface{} // 用户昵称 + Birthday interface{} // 生日 + UserPassword interface{} // 登录密码;cmf_password加密 + UserSalt interface{} // 加密盐 + UserStatus interface{} // 用户状态;0:禁用,1:正常,2:未验证 + UserEmail interface{} // 用户登录邮箱 + Sex interface{} // 性别;0:保密,1:男,2:女 + Avatar interface{} // 用户头像 + DeptId interface{} // 部门id + Remark interface{} // 备注 + IsAdmin interface{} // 是否后台管理员 1 是 0 否 + Address interface{} // 联系地址 + Describe interface{} // 描述信息 + LastLoginIp interface{} // 最后登录ip + LastLoginTime *gtime.Time // 最后登录时间 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 + DeletedAt *gtime.Time // 删除时间 +} diff --git a/internal/app/system/model/do/sys_user_online.go b/internal/app/system/model/do/sys_user_online.go new file mode 100644 index 0000000..f47ec4b --- /dev/null +++ b/internal/app/system/model/do/sys_user_online.go @@ -0,0 +1,23 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// SysUserOnline is the golang structure of table sys_user_online for DAO operations like Where/Data. +type SysUserOnline struct { + g.Meta `orm:"table:sys_user_online, do:true"` + Id interface{} // + Uuid interface{} // 用户标识 + Token interface{} // 用户token + CreateTime *gtime.Time // 登录时间 + UserName interface{} // 用户名 + Ip interface{} // 登录ip + Explorer interface{} // 浏览器 + Os interface{} // 操作系统 +} diff --git a/internal/app/system/model/do/sys_user_post.go b/internal/app/system/model/do/sys_user_post.go new file mode 100644 index 0000000..a06c02d --- /dev/null +++ b/internal/app/system/model/do/sys_user_post.go @@ -0,0 +1,16 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// SysUserPost is the golang structure of table sys_user_post for DAO operations like Where/Data. +type SysUserPost struct { + g.Meta `orm:"table:sys_user_post, do:true"` + UserId interface{} // 用户ID + PostId interface{} // 岗位ID +} diff --git a/internal/app/system/model/do/tools_gen_table.go b/internal/app/system/model/do/tools_gen_table.go new file mode 100644 index 0000000..53dd06c --- /dev/null +++ b/internal/app/system/model/do/tools_gen_table.go @@ -0,0 +1,33 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// ToolsGenTable is the golang structure of table tools_gen_table for DAO operations like Where/Data. +type ToolsGenTable struct { + g.Meta `orm:"table:tools_gen_table, do:true"` + TableId interface{} // 编号 + TableName interface{} // 表名称 + TableComment interface{} // 表描述 + ClassName interface{} // 实体类名称 + TplCategory interface{} // 使用的模板(crud单表操作 tree树表操作) + PackageName interface{} // 生成包路径 + ModuleName interface{} // 生成模块名 + BusinessName interface{} // 生成业务名 + FunctionName interface{} // 生成功能名 + FunctionAuthor interface{} // 生成功能作者 + Options interface{} // 其它生成选项 + CreateTime *gtime.Time // 创建时间 + UpdateTime *gtime.Time // 更新时间 + Remark interface{} // 备注 + Overwrite interface{} // 是否覆盖原有文件 + SortColumn interface{} // 排序字段名 + SortType interface{} // 排序方式 (asc顺序 desc倒序) + ShowDetail interface{} // 是否有查看详情功能 +} diff --git a/internal/app/system/model/do/tools_gen_table_column.go b/internal/app/system/model/do/tools_gen_table_column.go new file mode 100644 index 0000000..c4a58db --- /dev/null +++ b/internal/app/system/model/do/tools_gen_table_column.go @@ -0,0 +1,54 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// ToolsGenTableColumn is the golang structure of table tools_gen_table_column for DAO operations like Where/Data. +type ToolsGenTableColumn struct { + g.Meta `orm:"table:tools_gen_table_column, do:true"` + ColumnId interface{} // 编号 + TableId interface{} // 归属表编号 + ColumnName interface{} // 列名称 + ColumnComment interface{} // 列描述 + ColumnType interface{} // 列类型 + GoType interface{} // Go类型 + TsType interface{} // TS类型 + GoField interface{} // Go字段名 + HtmlField interface{} // html字段名 + IsPk interface{} // 是否主键(1是) + IsIncrement interface{} // 是否自增(1是) + IsRequired interface{} // 是否必填(1是) + IsInsert interface{} // 是否为插入字段(1是) + IsEdit interface{} // 是否编辑字段(1是) + IsList interface{} // 是否列表字段(1是) + IsDetail interface{} // 是否详情字段 + IsQuery interface{} // 是否查询字段(1是) + SortOrderEdit interface{} // 插入编辑显示顺序 + SortOrderList interface{} // 列表显示顺序 + SortOrderDetail interface{} // 详情显示顺序 + SortOrderQuery interface{} // 查询显示顺序 + QueryType interface{} // 查询方式(等于、不等于、大于、小于、范围) + HtmlType interface{} // 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件) + DictType interface{} // 字典类型 + LinkTableName interface{} // 关联表名 + LinkTableClass interface{} // 关联表类名 + LinkTableModuleName interface{} // 关联表模块名 + LinkTableBusinessName interface{} // 关联表业务名 + LinkTablePackage interface{} // 关联表包名 + LinkLabelId interface{} // 关联表键名 + LinkLabelName interface{} // 关联表字段值 + ColSpan interface{} // 详情页占列数 + RowSpan interface{} // 详情页占行数 + IsRowStart interface{} // 详情页为行首 + MinWidth interface{} // 表格最小宽度 + IsFixed interface{} // 是否表格列左固定 + IsOverflowTooltip interface{} // 是否过长自动隐藏 + IsCascade interface{} // 是否级联查询 + ParentColumnName interface{} // 上级字段名 + CascadeColumnName interface{} // 级联查询字段 +} diff --git a/internal/app/system/model/entity/.gitkeep b/internal/app/system/model/entity/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/internal/app/system/model/entity/big_file.go b/internal/app/system/model/entity/big_file.go new file mode 100644 index 0000000..4542e82 --- /dev/null +++ b/internal/app/system/model/entity/big_file.go @@ -0,0 +1,27 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// BigFile is the golang structure for table big_file. +type BigFile struct { + Id uint64 `json:"id" description:""` + Name string `json:"name" description:"文件名称"` + Size int `json:"size" description:"文件大小"` + Path string `json:"path" description:"文件相对路径"` + FullPath string `json:"fullPath" description:"文件绝对路径"` + MimeType string `json:"mimeType" description:"文件类型"` + Source int `json:"source" description:"文件来源 0 - 本地,1 - 腾讯云 2 - 七牛云"` + Describe string `json:"describe" description:"描述"` + Md5 string `json:"md5" description:"md5"` + CreatedBy uint64 `json:"createdBy" description:""` + UpdatedBy uint64 `json:"updatedBy" description:""` + CreatedAt *gtime.Time `json:"createdAt" description:""` + UpdatedAt *gtime.Time `json:"updatedAt" description:""` + DeletedAt *gtime.Time `json:"deletedAt" description:""` +} diff --git a/internal/app/system/model/entity/sys_auth_rule.go b/internal/app/system/model/entity/sys_auth_rule.go new file mode 100644 index 0000000..b4d8197 --- /dev/null +++ b/internal/app/system/model/entity/sys_auth_rule.go @@ -0,0 +1,35 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysAuthRule is the golang structure for table sys_auth_rule. +type SysAuthRule struct { + Id uint `json:"id" description:""` + Pid uint `json:"pid" description:"父ID"` + Name string `json:"name" description:"规则名称"` + Title string `json:"title" description:"规则名称"` + Icon string `json:"icon" description:"图标"` + Condition string `json:"condition" description:"条件"` + Remark string `json:"remark" description:"备注"` + MenuType uint `json:"menuType" description:"类型 0目录 1菜单 2按钮"` + Weigh int `json:"weigh" description:"权重"` + IsHide uint `json:"isHide" description:"显示状态"` + Path string `json:"path" description:"路由地址"` + Component string `json:"component" description:"组件路径"` + IsLink uint `json:"isLink" description:"是否外链 1是 0否"` + ModuleType string `json:"moduleType" description:"所属模块"` + ModelId uint `json:"modelId" description:"模型ID"` + IsIframe uint `json:"isIframe" description:"是否内嵌iframe"` + IsCached uint `json:"isCached" description:"是否缓存"` + Redirect string `json:"redirect" description:"路由重定向地址"` + IsAffix uint `json:"isAffix" description:"是否固定"` + LinkUrl string `json:"linkUrl" description:"链接地址"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建日期"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改日期"` +} diff --git a/internal/app/system/model/entity/sys_dept.go b/internal/app/system/model/entity/sys_dept.go new file mode 100644 index 0000000..568589f --- /dev/null +++ b/internal/app/system/model/entity/sys_dept.go @@ -0,0 +1,27 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysDept is the golang structure for table sys_dept. +type SysDept struct { + DeptId uint64 `json:"deptId" description:"部门id"` + ParentId uint64 `json:"parentId" description:"父部门id"` + Ancestors string `json:"ancestors" description:"祖级列表"` + DeptName string `json:"deptName" description:"部门名称"` + OrderNum int `json:"orderNum" description:"显示顺序"` + Leader string `json:"leader" description:"负责人"` + Phone string `json:"phone" description:"联系电话"` + Email string `json:"email" description:"邮箱"` + Status uint `json:"status" description:"部门状态(0正常 1停用)"` + CreatedBy uint64 `json:"createdBy" description:"创建人"` + UpdatedBy int64 `json:"updatedBy" description:"修改人"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"` + DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"` +} diff --git a/internal/app/system/model/entity/sys_job.go b/internal/app/system/model/entity/sys_job.go new file mode 100644 index 0000000..1166c90 --- /dev/null +++ b/internal/app/system/model/entity/sys_job.go @@ -0,0 +1,34 @@ +// ========================================================================== +// GFast自动生成model entity操作代码。 +// 生成日期:2023-01-12 17:43:50 +// 生成路径: internal/app/system/model/entity/sys_job.go +// 生成人:gfast +// desc:定时任务 +// company:云南奇讯科技有限公司 +// ========================================================================== + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gmeta" +) + +// SysJob is the golang structure for table sys_job. +type SysJob struct { + gmeta.Meta `orm:"table:sys_job"` + JobId uint64 `orm:"job_id,primary" json:"jobId"` // 任务ID + JobName string `orm:"job_name" json:"jobName"` // 任务名称 + JobParams string `orm:"job_params" json:"jobParams"` // 参数 + JobGroup string `orm:"job_group" json:"jobGroup"` // 任务组名 + InvokeTarget string `orm:"invoke_target" json:"invokeTarget"` // 任务方法 + CronExpression string `orm:"cron_expression" json:"cronExpression"` // cron执行表达式 + MisfirePolicy int `orm:"misfire_policy" json:"misfirePolicy"` // 计划执行策略 + Concurrent int `orm:"concurrent" json:"concurrent"` // 是否并发执行 + Status int `orm:"status" json:"status"` // 状态 + CreatedBy uint64 `orm:"created_by" json:"createdBy"` // 创建者 + UpdatedBy uint64 `orm:"updated_by" json:"updatedBy"` // 更新者 + Remark string `orm:"remark" json:"remark"` // 备注信息 + CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` // 创建时间 + UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt"` // 更新时间 +} diff --git a/internal/app/system/model/entity/sys_job_log.go b/internal/app/system/model/entity/sys_job_log.go new file mode 100644 index 0000000..dba5832 --- /dev/null +++ b/internal/app/system/model/entity/sys_job_log.go @@ -0,0 +1,17 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysJobLog is the golang structure for table sys_job_log. +type SysJobLog struct { + Id uint64 `json:"id" description:"主键"` + TargetName string `json:"targetName" description:"方法名"` + CreatedAt *gtime.Time `json:"createdAt" description:"执行日期"` + Result string `json:"result" description:"执行结果"` +} diff --git a/internal/app/system/model/entity/sys_login_log.go b/internal/app/system/model/entity/sys_login_log.go new file mode 100644 index 0000000..9bac7b9 --- /dev/null +++ b/internal/app/system/model/entity/sys_login_log.go @@ -0,0 +1,23 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-08 11:31:48 +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysLoginLog is the golang structure for table sys_login_log. +type SysLoginLog struct { + InfoId int64 `json:"infoId" description:"访问ID"` + LoginName string `json:"loginName" description:"登录账号"` + Ipaddr string `json:"ipaddr" description:"登录IP地址"` + LoginLocation string `json:"loginLocation" description:"登录地点"` + Browser string `json:"browser" description:"浏览器类型"` + Os string `json:"os" description:"操作系统"` + Status int `json:"status" description:"登录状态(0成功 1失败)"` + Msg string `json:"msg" description:"提示消息"` + LoginTime *gtime.Time `json:"loginTime" description:"登录时间"` + Module string `json:"module" description:"登录模块"` +} diff --git a/internal/app/system/model/entity/sys_oper_log.go b/internal/app/system/model/entity/sys_oper_log.go new file mode 100644 index 0000000..cf52ac9 --- /dev/null +++ b/internal/app/system/model/entity/sys_oper_log.go @@ -0,0 +1,27 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysOperLog is the golang structure for table sys_oper_log. +type SysOperLog struct { + OperId uint64 `json:"operId" description:"日志主键"` + Title string `json:"title" description:"模块标题"` + BusinessType int `json:"businessType" description:"业务类型(0其它 1新增 2修改 3删除)"` + Method string `json:"method" description:"方法名称"` + RequestMethod string `json:"requestMethod" description:"请求方式"` + OperatorType int `json:"operatorType" description:"操作类别(0其它 1后台用户 2手机端用户)"` + OperName string `json:"operName" description:"操作人员"` + DeptName string `json:"deptName" description:"部门名称"` + OperUrl string `json:"operUrl" description:"请求URL"` + OperIp string `json:"operIp" description:"主机地址"` + OperLocation string `json:"operLocation" description:"操作地点"` + OperParam string `json:"operParam" description:"请求参数"` + ErrorMsg string `json:"errorMsg" description:"错误消息"` + OperTime *gtime.Time `json:"operTime" description:"操作时间"` +} diff --git a/internal/app/system/model/entity/sys_post.go b/internal/app/system/model/entity/sys_post.go new file mode 100644 index 0000000..6ca4fe5 --- /dev/null +++ b/internal/app/system/model/entity/sys_post.go @@ -0,0 +1,24 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-07 23:26:21 +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysPost is the golang structure for table sys_post. +type SysPost struct { + PostId uint64 `json:"postId" description:"岗位ID"` + PostCode string `json:"postCode" description:"岗位编码"` + PostName string `json:"postName" description:"岗位名称"` + PostSort int `json:"postSort" description:"显示顺序"` + Status uint `json:"status" description:"状态(0正常 1停用)"` + Remark string `json:"remark" description:"备注"` + CreatedBy uint64 `json:"createdBy" description:"创建人"` + UpdatedBy uint64 `json:"updatedBy" description:"修改人"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"` + DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"` +} diff --git a/internal/app/system/model/entity/sys_role.go b/internal/app/system/model/entity/sys_role.go new file mode 100644 index 0000000..c98e802 --- /dev/null +++ b/internal/app/system/model/entity/sys_role.go @@ -0,0 +1,21 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysRole is the golang structure for table sys_role. +type SysRole struct { + Id uint `json:"id" description:""` + Status uint `json:"status" description:"状态;0:禁用;1:正常"` + ListOrder uint `json:"listOrder" description:"排序"` + Name string `json:"name" description:"角色名称"` + Remark string `json:"remark" description:"备注"` + DataScope uint `json:"dataScope" description:"数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"更新时间"` +} diff --git a/internal/app/system/model/entity/sys_role_dept.go b/internal/app/system/model/entity/sys_role_dept.go new file mode 100644 index 0000000..c795ca0 --- /dev/null +++ b/internal/app/system/model/entity/sys_role_dept.go @@ -0,0 +1,11 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// SysRoleDept is the golang structure for table sys_role_dept. +type SysRoleDept struct { + RoleId int64 `json:"roleId" description:"角色ID"` + DeptId int64 `json:"deptId" description:"部门ID"` +} diff --git a/internal/app/system/model/entity/sys_user.go b/internal/app/system/model/entity/sys_user.go new file mode 100644 index 0000000..3bd7c51 --- /dev/null +++ b/internal/app/system/model/entity/sys_user.go @@ -0,0 +1,34 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-03-02 16:48:23 +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysUser is the golang structure for table sys_user. +type SysUser struct { + Id uint64 `json:"id" description:""` + UserName string `json:"userName" description:"用户名"` + Mobile string `json:"mobile" description:"中国手机不带国家代码,国际手机号格式为:国家代码-手机号"` + UserNickname string `json:"userNickname" description:"用户昵称"` + Birthday int `json:"birthday" description:"生日"` + UserPassword string `json:"userPassword" description:"登录密码;cmf_password加密"` + UserSalt string `json:"userSalt" description:"加密盐"` + UserStatus uint `json:"userStatus" description:"用户状态;0:禁用,1:正常,2:未验证"` + UserEmail string `json:"userEmail" description:"用户登录邮箱"` + Sex int `json:"sex" description:"性别;0:保密,1:男,2:女"` + Avatar string `json:"avatar" description:"用户头像"` + DeptId uint64 `json:"deptId" description:"部门id"` + Remark string `json:"remark" description:"备注"` + IsAdmin int `json:"isAdmin" description:"是否后台管理员 1 是 0 否"` + Address string `json:"address" description:"联系地址"` + Describe string `json:"describe" description:"描述信息"` + LastLoginIp string `json:"lastLoginIp" description:"最后登录ip"` + LastLoginTime *gtime.Time `json:"lastLoginTime" description:"最后登录时间"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"更新时间"` + DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"` +} diff --git a/internal/app/system/model/entity/sys_user_online.go b/internal/app/system/model/entity/sys_user_online.go new file mode 100644 index 0000000..a286995 --- /dev/null +++ b/internal/app/system/model/entity/sys_user_online.go @@ -0,0 +1,21 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// SysUserOnline is the golang structure for table sys_user_online. +type SysUserOnline struct { + Id uint64 `json:"id" description:""` + Uuid string `json:"uuid" description:"用户标识"` + Token string `json:"token" description:"用户token"` + CreateTime *gtime.Time `json:"createTime" description:"登录时间"` + UserName string `json:"userName" description:"用户名"` + Ip string `json:"ip" description:"登录ip"` + Explorer string `json:"explorer" description:"浏览器"` + Os string `json:"os" description:"操作系统"` +} diff --git a/internal/app/system/model/entity/sys_user_post.go b/internal/app/system/model/entity/sys_user_post.go new file mode 100644 index 0000000..8de724c --- /dev/null +++ b/internal/app/system/model/entity/sys_user_post.go @@ -0,0 +1,11 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// SysUserPost is the golang structure for table sys_user_post. +type SysUserPost struct { + UserId int64 `json:"userId" description:"用户ID"` + PostId int64 `json:"postId" description:"岗位ID"` +} diff --git a/internal/app/system/model/entity/tools_gen_table.go b/internal/app/system/model/entity/tools_gen_table.go new file mode 100644 index 0000000..e8c4434 --- /dev/null +++ b/internal/app/system/model/entity/tools_gen_table.go @@ -0,0 +1,31 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// ToolsGenTable is the golang structure for table tools_gen_table. +type ToolsGenTable struct { + TableId int64 `json:"tableId" description:"编号"` + TableName string `json:"tableName" description:"表名称"` + TableComment string `json:"tableComment" description:"表描述"` + ClassName string `json:"className" description:"实体类名称"` + TplCategory string `json:"tplCategory" description:"使用的模板(crud单表操作 tree树表操作)"` + PackageName string `json:"packageName" description:"生成包路径"` + ModuleName string `json:"moduleName" description:"生成模块名"` + BusinessName string `json:"businessName" description:"生成业务名"` + FunctionName string `json:"functionName" description:"生成功能名"` + FunctionAuthor string `json:"functionAuthor" description:"生成功能作者"` + Options string `json:"options" description:"其它生成选项"` + CreateTime *gtime.Time `json:"createTime" description:"创建时间"` + UpdateTime *gtime.Time `json:"updateTime" description:"更新时间"` + Remark string `json:"remark" description:"备注"` + Overwrite bool `json:"overwrite" description:"是否覆盖原有文件"` + SortColumn string `json:"sortColumn" description:"排序字段名"` + SortType string `json:"sortType" description:"排序方式 (asc顺序 desc倒序)"` + ShowDetail bool `json:"showDetail" description:"是否有查看详情功能"` +} diff --git a/internal/app/system/model/entity/tools_gen_table_column.go b/internal/app/system/model/entity/tools_gen_table_column.go new file mode 100644 index 0000000..c2f6810 --- /dev/null +++ b/internal/app/system/model/entity/tools_gen_table_column.go @@ -0,0 +1,49 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// ToolsGenTableColumn is the golang structure for table tools_gen_table_column. +type ToolsGenTableColumn struct { + ColumnId int64 `json:"columnId" description:"编号"` + TableId int64 `json:"tableId" description:"归属表编号"` + ColumnName string `json:"columnName" description:"列名称"` + ColumnComment string `json:"columnComment" description:"列描述"` + ColumnType string `json:"columnType" description:"列类型"` + GoType string `json:"goType" description:"Go类型"` + TsType string `json:"tsType" description:"TS类型"` + GoField string `json:"goField" description:"Go字段名"` + HtmlField string `json:"htmlField" description:"html字段名"` + IsPk bool `json:"isPk" description:"是否主键(1是)"` + IsIncrement bool `json:"isIncrement" description:"是否自增(1是)"` + IsRequired bool `json:"isRequired" description:"是否必填(1是)"` + IsInsert bool `json:"isInsert" description:"是否为插入字段(1是)"` + IsEdit bool `json:"isEdit" description:"是否编辑字段(1是)"` + IsList bool `json:"isList" description:"是否列表字段(1是)"` + IsDetail bool `json:"isDetail" description:"是否详情字段"` + IsQuery bool `json:"isQuery" description:"是否查询字段(1是)"` + SortOrderEdit int `json:"sortOrderEdit" description:"插入编辑显示顺序"` + SortOrderList int `json:"sortOrderList" description:"列表显示顺序"` + SortOrderDetail int `json:"sortOrderDetail" description:"详情显示顺序"` + SortOrderQuery int `json:"sortOrderQuery" description:"查询显示顺序"` + QueryType string `json:"queryType" description:"查询方式(等于、不等于、大于、小于、范围)"` + HtmlType string `json:"htmlType" description:"显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)"` + DictType string `json:"dictType" description:"字典类型"` + LinkTableName string `json:"linkTableName" description:"关联表名"` + LinkTableClass string `json:"linkTableClass" description:"关联表类名"` + LinkTableModuleName string `json:"linkTableModuleName" description:"关联表模块名"` + LinkTableBusinessName string `json:"linkTableBusinessName" description:"关联表业务名"` + LinkTablePackage string `json:"linkTablePackage" description:"关联表包名"` + LinkLabelId string `json:"linkLabelId" description:"关联表键名"` + LinkLabelName string `json:"linkLabelName" description:"关联表字段值"` + ColSpan int `json:"colSpan" description:"详情页占列数"` + RowSpan int `json:"rowSpan" description:"详情页占行数"` + IsRowStart bool `json:"isRowStart" description:"详情页为行首"` + MinWidth int `json:"minWidth" description:"表格最小宽度"` + IsFixed bool `json:"isFixed" description:"是否表格列左固定"` + IsOverflowTooltip bool `json:"isOverflowTooltip" description:"是否过长自动隐藏"` + IsCascade bool `json:"isCascade" description:"是否级联查询"` + ParentColumnName string `json:"parentColumnName" description:"上级字段名"` + CascadeColumnName string `json:"cascadeColumnName" description:"级联查询字段"` +} diff --git a/internal/app/system/model/sys_auth_rule.go b/internal/app/system/model/sys_auth_rule.go new file mode 100644 index 0000000..8ff60de --- /dev/null +++ b/internal/app/system/model/sys_auth_rule.go @@ -0,0 +1,59 @@ +/* +* @desc:菜单model +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/11 14:53 + */ + +package model + +type SysAuthRuleInfoRes struct { + Id uint `orm:"id,primary" json:"id"` // + Pid uint `orm:"pid" json:"pid"` // 父ID + Name string `orm:"name,unique" json:"name"` // 规则名称 + Title string `orm:"title" json:"title"` // 规则名称 + Icon string `orm:"icon" json:"icon"` // 图标 + Condition string `orm:"condition" json:"condition"` // 条件 + Remark string `orm:"remark" json:"remark"` // 备注 + MenuType uint `orm:"menu_type" json:"menuType"` // 类型 0目录 1菜单 2按钮 + Weigh int `orm:"weigh" json:"weigh"` // 权重 + IsHide uint `orm:"is_hide" json:"isHide"` // 显示状态 + IsCached uint `orm:"is_cached" json:"isCached"` // 是否缓存 + IsAffix uint `orm:"is_affix" json:"isAffix"` //是否固定 + Path string `orm:"path" json:"path"` // 路由地址 + Redirect string `orm:"redirect" json:"redirect"` // 跳转路由 + Component string `orm:"component" json:"component"` // 组件路径 + IsIframe uint `orm:"is_iframe" json:"isIframe"` // 是否iframe + IsLink uint `orm:"is_link" json:"isLink"` // 是否外链 1是 0否 + LinkUrl string `orm:"link_url" json:"linkUrl"` //链接地址 +} + +// SysAuthRuleTreeRes 菜单树形结构 +type SysAuthRuleTreeRes struct { + *SysAuthRuleInfoRes + Children []*SysAuthRuleTreeRes `json:"children"` +} + +type UserMenu struct { + Id uint `json:"id"` + Pid uint `json:"pid"` + Name string `json:"name"` + Component string `json:"component"` + Path string `json:"path"` + *MenuMeta `json:"meta"` +} + +type UserMenus struct { + *UserMenu `json:""` + Children []*UserMenus `json:"children"` +} + +type MenuMeta struct { + Icon string `json:"icon"` + Title string `json:"title"` + IsLink string `json:"isLink"` + IsHide bool `json:"isHide"` + IsKeepAlive bool `json:"isKeepAlive"` + IsAffix bool `json:"isAffix"` + IsIframe bool `json:"isIframe"` +} diff --git a/internal/app/system/model/sys_dept.go b/internal/app/system/model/sys_dept.go new file mode 100644 index 0000000..d7f5226 --- /dev/null +++ b/internal/app/system/model/sys_dept.go @@ -0,0 +1,15 @@ +/* +* @desc:部门model +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/4/11 9:07 + */ + +package model + +import "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + +type SysDeptTreeRes struct { + *entity.SysDept + Children []*SysDeptTreeRes `json:"children"` +} diff --git a/internal/app/system/model/sys_init.go b/internal/app/system/model/sys_init.go new file mode 100644 index 0000000..91cb6ff --- /dev/null +++ b/internal/app/system/model/sys_init.go @@ -0,0 +1,39 @@ +package model + +// 程序初始化yaml配置文件 +type DbInitConfig struct { + Database Database `json:"database" yaml:"database"` + Redis Redis `json:"redis" yaml:"redis"` +} + +type Database struct { + Default DbDefault `json:"default" yaml:"default"` +} + +type DbDefault struct { + Host string `json:"host" yaml:"host"` + Port int `json:"port" yaml:"port"` + User string `json:"user" yaml:"user"` + Pass string `json:"pass" yaml:"pass"` + Name string `json:"name" yaml:"name"` + Type string `json:"type" yaml:"type"` + Role string `json:"role" yaml:"role"` + Debug bool `json:"debug" yaml:"debug"` + Charset string `json:"charset" yaml:"charset"` + DryRun bool `json:"dryRun" yaml:"dryRun"` + MaxIdle int `json:"maxIdle" yaml:"maxIdle"` + MaxOpen int `json:"maxOpen" yaml:"maxOpen"` + MaxLifetime int `json:"maxLifetime" yaml:"maxLifetime"` +} + +type Redis struct { + Default RedisDefault `json:"default" yaml:"default"` +} + +type RedisDefault struct { + Address string `json:"address" yaml:"address"` + Db int `json:"db" yaml:"db"` + Pass string `json:"pass" yaml:"pass"` + IdleTimeout int `json:"idleTimeout" yaml:"idleTimeout"` + MaxActive int `json:"maxActive" yaml:"maxActive"` +} diff --git a/internal/app/system/model/sys_job.go b/internal/app/system/model/sys_job.go new file mode 100644 index 0000000..2a6cdb7 --- /dev/null +++ b/internal/app/system/model/sys_job.go @@ -0,0 +1,44 @@ +// ========================================================================== +// GFast自动生成model操作代码。 +// 生成日期:2023-01-12 17:43:50 +// 生成路径: internal/app/system/model/sys_job.go +// 生成人:gfast +// desc:定时任务 +// company:云南奇讯科技有限公司 +// ========================================================================== + +package model + +import ( + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gmeta" +) + +// SysJobInfoRes is the golang structure for table sys_job. +type SysJobInfoRes struct { + gmeta.Meta `orm:"table:sys_job"` + JobId uint64 `orm:"job_id,primary" json:"jobId"` // 任务ID + JobName string `orm:"job_name" json:"jobName"` // 任务名称 + JobParams string `orm:"job_params" json:"jobParams"` // 参数 + JobGroup string `orm:"job_group" json:"jobGroup"` // 任务组名 + InvokeTarget string `orm:"invoke_target" json:"invokeTarget"` // 任务方法 + CronExpression string `orm:"cron_expression" json:"cronExpression"` // cron执行表达式 + MisfirePolicy int `orm:"misfire_policy" json:"misfirePolicy"` // 计划执行策略 + Concurrent int `orm:"concurrent" json:"concurrent"` // 是否并发执行 + Status int `orm:"status" json:"status"` // 状态 + CreatedBy uint64 `orm:"created_by" json:"createdBy"` // 创建者 + UpdatedBy uint64 `orm:"updated_by" json:"updatedBy"` // 更新者 + Remark string `orm:"remark" json:"remark"` // 备注信息 + CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` // 创建时间 + UpdatedAt *gtime.Time `orm:"updated_at" json:"updatedAt"` // 更新时间 +} + +type SysJobListRes struct { + JobId uint64 `json:"jobId"` + JobName string `json:"jobName"` + JobGroup string `json:"jobGroup"` + InvokeTarget string `json:"invokeTarget"` + CronExpression string `json:"cronExpression"` + MisfirePolicy int `json:"misfirePolicy"` + Status int `json:"status"` +} diff --git a/internal/app/system/model/sys_oper_log.go b/internal/app/system/model/sys_oper_log.go new file mode 100644 index 0000000..46eb187 --- /dev/null +++ b/internal/app/system/model/sys_oper_log.go @@ -0,0 +1,66 @@ +/* +* @desc:操作日志模型对象 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/9/21 16:34 + */ + +package model + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gmeta" + "net/url" +) + +// SysOperLogAdd 添加操作日志参数 +type SysOperLogAdd struct { + User *ContextUser + Menu *SysAuthRuleInfoRes + Url *url.URL + Params g.Map + Method string + ClientIp string + OperatorType int +} + +// SysOperLogInfoRes is the golang structure for table sys_oper_log. +type SysOperLogInfoRes struct { + gmeta.Meta `orm:"table:sys_oper_log"` + OperId uint64 `orm:"oper_id,primary" json:"operId"` // 日志编号 + Title string `orm:"title" json:"title"` // 系统模块 + BusinessType int `orm:"business_type" json:"businessType"` // 操作类型 + Method string `orm:"method" json:"method"` // 操作方法 + RequestMethod string `orm:"request_method" json:"requestMethod"` // 请求方式 + OperatorType int `orm:"operator_type" json:"operatorType"` // 操作类别 + OperName string `orm:"oper_name" json:"operName"` // 操作人员 + DeptName string `orm:"dept_name" json:"deptName"` // 部门名称 + LinkedDeptName *LinkedSysOperLogSysDept `orm:"with:dept_id=dept_name" json:"linkedDeptName"` + OperUrl string `orm:"oper_url" json:"operUrl"` // 请求URL + OperIp string `orm:"oper_ip" json:"operIp"` // 主机地址 + OperLocation string `orm:"oper_location" json:"operLocation"` // 操作地点 + OperParam string `orm:"oper_param" json:"operParam"` // 请求参数 + ErrorMsg string `orm:"error_msg" json:"errorMsg"` // 错误消息 + OperTime *gtime.Time `orm:"oper_time" json:"operTime"` // 操作时间 +} + +type LinkedSysOperLogSysDept struct { + gmeta.Meta `orm:"table:sys_dept"` + DeptId int64 `orm:"dept_id" json:"deptId"` // 部门id + DeptName string `orm:"dept_name" json:"deptName"` // 部门名称 +} + +type SysOperLogListRes struct { + OperId uint64 `json:"operId"` + Title string `json:"title"` + RequestMethod string `json:"requestMethod"` + OperName string `json:"operName"` + DeptName string `json:"deptName"` + LinkedDeptName *LinkedSysOperLogSysDept `orm:"with:dept_id=dept_name" json:"linkedDeptName"` + OperUrl string `json:"operUrl"` + OperIp string `json:"operIp"` + OperLocation string `json:"operLocation"` + OperParam string `json:"operParam"` + OperTime *gtime.Time `json:"operTime"` +} diff --git a/internal/app/system/model/sys_role.go b/internal/app/system/model/sys_role.go new file mode 100644 index 0000000..cb4b8b4 --- /dev/null +++ b/internal/app/system/model/sys_role.go @@ -0,0 +1,8 @@ +/* +* @desc:角色 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/30 9:11 + */ + +package model diff --git a/internal/app/system/model/sys_user.go b/internal/app/system/model/sys_user.go new file mode 100644 index 0000000..08518d4 --- /dev/null +++ b/internal/app/system/model/sys_user.go @@ -0,0 +1,47 @@ +/* +* @desc:用户模型对象 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/7 11:47 + */ + +package model + +import "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" + +// LoginUserRes 登录返回 +type LoginUserRes struct { + Id uint64 `orm:"id,primary" json:"id"` // + UserName string `orm:"user_name,unique" json:"userName"` // 用户名 + UserNickname string `orm:"user_nickname" json:"userNickname"` // 用户昵称 + UserPassword string `orm:"user_password" json:"userPassword"` // 登录密码;cmf_password加密 + UserSalt string `orm:"user_salt" json:"userSalt"` // 加密盐 + UserStatus uint `orm:"user_status" json:"userStatus"` // 用户状态;0:禁用,1:正常,2:未验证 + IsAdmin int `orm:"is_admin" json:"isAdmin"` // 是否后台管理员 1 是 0 否 + Avatar string `orm:"avatar" json:"avatar"` //头像 + DeptId uint64 `orm:"dept_id" json:"deptId"` //部门id +} + +// SysUserRoleDeptRes 带有部门、角色、岗位信息的用户数据 +type SysUserRoleDeptRes struct { + *entity.SysUser + Dept *entity.SysDept `json:"dept"` + RoleInfo []*SysUserRoleInfoRes `json:"roleInfo"` + Post []*SysUserPostInfoRes `json:"post"` +} + +type SysUserRoleInfoRes struct { + RoleId uint `json:"roleId"` + Name string `json:"name"` +} + +type SysUserPostInfoRes struct { + PostId int64 `json:"postId"` + PostName string `json:"postName"` +} + +type SysUserSimpleRes struct { + Id uint64 `orm:"id" json:"id"` // + UserName string `orm:"user_name" json:"userName"` // 用户名 + UserNickname string `orm:"user_nickname" json:"userNickname"` // 用户昵称 +} diff --git a/internal/app/system/model/sys_user_login.go b/internal/app/system/model/sys_user_login.go new file mode 100644 index 0000000..50ffdba --- /dev/null +++ b/internal/app/system/model/sys_user_login.go @@ -0,0 +1,18 @@ +/* +* @desc:登录日志 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/8 11:43 + */ + +package model + +// LoginLogParams 登录日志写入参数 +type LoginLogParams struct { + Status int + Username string + Ip string + UserAgent string + Msg string + Module string +} diff --git a/internal/app/system/model/sys_user_online.go b/internal/app/system/model/sys_user_online.go new file mode 100644 index 0000000..567ff4f --- /dev/null +++ b/internal/app/system/model/sys_user_online.go @@ -0,0 +1,17 @@ +/* +* @desc:用户在线状态 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2023/1/10 15:08 + */ + +package model + +// SysUserOnlineParams 用户在线状态写入参数 +type SysUserOnlineParams struct { + UserAgent string + Uuid string + Token string + Username string + Ip string +} diff --git a/internal/app/system/model/task.go b/internal/app/system/model/task.go new file mode 100644 index 0000000..c443a4a --- /dev/null +++ b/internal/app/system/model/task.go @@ -0,0 +1,16 @@ +/* +* @desc:定时任务 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2023/1/13 17:47 + */ + +package model + +import "context" + +type TimeTask struct { + FuncName string + Param []string + Run func(ctx context.Context) +} diff --git a/internal/app/system/model/tools_gen_table.go b/internal/app/system/model/tools_gen_table.go new file mode 100644 index 0000000..4659400 --- /dev/null +++ b/internal/app/system/model/tools_gen_table.go @@ -0,0 +1,80 @@ +/* +* @desc:代码生成表数据模型 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/10/28 11:43 + */ + +package model + +import ( + "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/os/gtime" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +// ToolsGenTableEx 实体扩展 +type ToolsGenTableEx struct { + TableId int64 // 编号 + TableName string // 表名称 + TableComment string // 表描述 + ClassName string // 实体类名称 + TplCategory string // 使用的模板(crud单表操作 tree树表操作) + PackageName string // 生成包路径 + ModuleName string // 生成模块名 + BusinessName string // 生成业务名 + FunctionName string // 生成功能名 + FunctionAuthor string // 生成功能作者 + Options string // 其它生成选项 + CreateBy string // 创建者 + CreateTime *gtime.Time // 创建时间 + UpdateBy string // 更新者 + UpdateTime *gtime.Time // 更新时间 + Remark string // 备注 + Overwrite bool // 是否覆盖原有文件 + SortColumn string // 缺省排序字段 + SortType string // 缺省排序方式 (asc顺序 desc倒序) + ShowDetail bool // 是否有查看详情功能 + TreeCode string // 树编码字段 + TreeParentCode string // 树父编码字段 + TreeName string // 树名称字段 + IsPkInsertable bool // 主键是否应该在新增时填写 + IsPkListable bool // 主键是否出现在列表中 + HasTimeColumn bool // 是否有时间类型 + HasCreatedBy bool // 是否有created_by字段 + HasUpdatedBy bool // 是否有updated_by字段 + HasConversion bool // service中是否有转换函数 + Columns []*ToolsGenTableColumnEx // 表列信息 + EditColumns []*ToolsGenTableColumnEx // 新增、编辑界面列信息,主键单独判断不在此列 + ListColumns []*ToolsGenTableColumnEx // 列表界面列信息 + DetailColumns []*ToolsGenTableColumnEx // 详情界面列信息 + QueryColumns []*ToolsGenTableColumnEx // 查询表单列信息 + PkColumn *ToolsGenTableColumnEx // 主键列信息 + LinkedTables []*ToolsGenTableLinked // 关联表信息 +} + +// ToolsGenTableLinked 关联表 +type ToolsGenTableLinked struct { + TableName string // 表名称 + TableComment string // 表描述 + ClassName string // 实体类名称 + PackageName string // 生成包路径 + ModuleName string // 生成模块名 + BusinessName string // 生成业务名 + RefColumns *gmap.ListMap // 要被查询的所有数据列信息 + LinkedTables []*ToolsGenTableLinked // 嵌套关联表信息 +} + +// ToolsGenTableEditData 编辑页面表数据详情 +type ToolsGenTableEditData struct { + *entity.ToolsGenTable + TreeCode interface{} `json:"treeCode"` + TreeParentCode interface{} `json:"treeParentCode"` + TreeName interface{} `json:"treeName"` +} + +// ToolsGenTableColumnsData 表与字段组合数据 +type ToolsGenTableColumnsData struct { + *entity.ToolsGenTable + Columns []*entity.ToolsGenTableColumn `json:"columns"` +} diff --git a/internal/app/system/model/tools_gen_table_column.go b/internal/app/system/model/tools_gen_table_column.go new file mode 100644 index 0000000..d4c833b --- /dev/null +++ b/internal/app/system/model/tools_gen_table_column.go @@ -0,0 +1,60 @@ +/* +* @desc:代码生成表字段数据模型 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/10/28 11:41 + */ + +package model + +import "github.com/gogf/gf/v2/container/gset" + +// ToolsGenTableColumnEx 扩展 +type ToolsGenTableColumnEx struct { + ColumnId int64 // 编号 + TableId int64 // 归属表编号 + ColumnName string // 列名称 + ColumnComment string // 列描述 + ColumnType string // 列类型 + GoType string // Go类型 + TsType string // Ts类型 + GoField string // Go字段名 + HtmlField string // html字段名 + IsPk bool // 是否主键 + IsIncrement bool // 是否自增 + IsRequired bool // 是否必填 + IsInsert bool // 是否为插入字段 + IsEdit bool // 是否编辑字段 + IsList bool // 是否列表字段 + IsDetail bool // 是否详情字段 + IsQuery bool // 是否查询字段 + IsStatus bool // 是否状态字段 + SortOrderEdit int // 插入编辑显示顺序 + SortOrderList int // 列表显示顺序 + SortOrderDetail int // 详情显示顺序 + SortOrderQuery int // 查询显示顺序 + QueryType string // 查询方式(等于、不等于、大于、小于、范围) + HtmlType string // 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件) + DictType string // 字典类型 + LinkTableName string // 关联表名 + LinkTableClass string // 关联表类名 + LinkTableModuleName string // 关联表业务名 + LinkTableBusinessName string // 关联表业务名 + LinkTablePackage string // 关联表包名 + LinkLabelId string // 关联表键名 + LinkLabelName string // 关联表字段值 + ColSpan int // 占多少列 + RowSpan int // 占多少行 + IsRowStart bool // 是否另起一行 + MinWidth int // 表格最小宽度 + IsFixed bool // 是否表格列左固定 + IsOverflowTooltip bool // 是否过长自动隐藏 + FieldConversion string // 字段转换方法 + FieldValidation string // 字段校验规则 + IsCascade bool // 是否级联查询 + ParentColumnName string // 上级字段名 + CascadeColumnName string // 级联查询字段 + IsCascadeParent bool // 是否为级联父字段 + CascadeParent *ToolsGenTableColumnEx // 级联父字段指针 + CascadeChildrenColumns *gset.StrSet // 所有级联子字段名(按级联顺序) +} diff --git a/internal/app/system/packed/packed.go b/internal/app/system/packed/packed.go new file mode 100644 index 0000000..e20ab1e --- /dev/null +++ b/internal/app/system/packed/packed.go @@ -0,0 +1 @@ +package packed diff --git a/internal/app/system/router/router.go b/internal/app/system/router/router.go new file mode 100644 index 0000000..023503e --- /dev/null +++ b/internal/app/system/router/router.go @@ -0,0 +1,59 @@ +/* +* @desc:后台路由 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/2/18 17:34 + */ + +package router + +import ( + "context" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast/v3/internal/app/system/controller" + "github.com/tiger1103/gfast/v3/internal/app/system/service" + "github.com/tiger1103/gfast/v3/library/libRouter" +) + +var R = new(Router) + +type Router struct{} + +func (router *Router) BindController(ctx context.Context, group *ghttp.RouterGroup) { + group.Group("/system", func(group *ghttp.RouterGroup) { + group.Bind( + //登录 + controller.Login, + ) + //登录验证拦截 + service.GfToken().Middleware(group) + //context拦截器 + group.Middleware(service.Middleware().Ctx, service.Middleware().Auth) + //后台操作日志记录 + group.Hook("/*", ghttp.HookAfterOutput, service.OperateLog().OperationLog) + group.Bind( + controller.User, + controller.Menu, + controller.Role, + controller.Dept, + controller.Post, + controller.DictType, + controller.DictData, + controller.Config, + controller.Monitor, + controller.LoginLog, + controller.OperLog, + controller.BigFile, + controller.ToolsGenTable, + controller.Personal, + controller.UserOnline, + controller.Upload, // 普通文件上传 + controller.BigUpload, // 大文件上传 + controller.UEditor, //编辑器 + ) + //自动绑定定义的控制器 + if err := libRouter.RouterAutoBind(router, ctx, group); err != nil { + panic(err) + } + }) +} diff --git a/internal/app/system/router/sys_job.go b/internal/app/system/router/sys_job.go new file mode 100644 index 0000000..9548844 --- /dev/null +++ b/internal/app/system/router/sys_job.go @@ -0,0 +1,24 @@ +// ========================================================================== +// GFast自动生成router操作代码。 +// 生成日期:2023-01-12 17:43:50 +// 生成路径: internal/app/system/router/sys_job.go +// 生成人:gfast +// desc:定时任务 +// company:云南奇讯科技有限公司 +// ========================================================================== + +package router + +import ( + "context" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast/v3/internal/app/system/controller" +) + +func (router *Router) BindSysJobController(ctx context.Context, group *ghttp.RouterGroup) { + group.Group("/sysJob", func(group *ghttp.RouterGroup) { + group.Bind( + controller.SysJob, + ) + }) +} diff --git a/internal/app/system/service/.gitkeep b/internal/app/system/service/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/internal/app/system/service/big_file.go b/internal/app/system/service/big_file.go new file mode 100644 index 0000000..2c68dff --- /dev/null +++ b/internal/app/system/service/big_file.go @@ -0,0 +1,101 @@ +package service + +import ( + "context" + + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/dao" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + + systemConsts "github.com/tiger1103/gfast/v3/internal/app/system/consts" + "github.com/tiger1103/gfast/v3/library/liberr" +) + +type IBigFile interface { + List(ctx context.Context, req *system.BigFileSearchReq) (res *system.BigFileSearchRes, err error) + Add(ctx context.Context, req *system.BigFileAddReq, userId uint64) (err error) + Get(ctx context.Context, id uint64) (res *system.BigFileGetRes, err error) + Edit(ctx context.Context, req *system.BigFileEditReq, userId uint64) (err error) + Delete(ctx context.Context, ids []uint64) (err error) +} + +func BigFile() IBigFile { + return new(bigFileTmpl) +} + +type bigFileTmpl struct{} + +func (s *bigFileTmpl) List(ctx context.Context, req *system.BigFileSearchReq) (res *system.BigFileSearchRes, err error) { + res = new(system.BigFileSearchRes) + err = g.Try(ctx, func(ctx context.Context) { + m := dao.BigFile.Ctx(ctx) + if req != nil { + if req.Name != "" { + m = m.Where("name like ?", "%"+req.Name+"%") + } + } + res.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取数据失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + res.CurrentPage = req.PageNum + if req.PageSize == 0 { + req.PageSize = systemConsts.PageSize + } + + var orderBy string = "id asc" + if req.OrderBy != "" { + orderBy = req.OrderBy + } + err = m.Page(req.PageNum, req.PageSize).Order(orderBy).Scan(&res.List) + liberr.ErrIsNil(ctx, err, "获取数据失败") + }) + return +} + +func (s *bigFileTmpl) Add(ctx context.Context, req *system.BigFileAddReq, userId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.BigFile.Ctx(ctx).Insert(do.BigFile{ + Name: req.Name, + Size: req.Size, + Path: req.Path, + FullPath: req.FullPath, + MimeType: req.MimeType, + Source: req.Source, + Describe: req.Describe, + Md5: req.Md5, + }) + liberr.ErrIsNil(ctx, err, "添加失败") + }) + return +} + +func (s *bigFileTmpl) Get(ctx context.Context, id uint64) (res *system.BigFileGetRes, err error) { + res = new(system.BigFileGetRes) + err = g.Try(ctx, func(ctx context.Context) { + err = dao.BigFile.Ctx(ctx).WherePri(id).Scan(&res) + liberr.ErrIsNil(ctx, err, "获取数据失败") + }) + return +} + +func (s *bigFileTmpl) Edit(ctx context.Context, req *system.BigFileEditReq, userId uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.BigFile.Ctx(ctx).WherePri(req.Id).Update(do.BigFile{ + Name: req.Name, + Describe: req.Describe, + }) + liberr.ErrIsNil(ctx, err, "修改错误") + }) + return +} + +func (s *bigFileTmpl) Delete(ctx context.Context, ids []uint64) (err error) { + err = g.Try(ctx, func(ctx context.Context) { + _, err = dao.BigFile.Ctx(ctx).WherePri(ids).Delete() + liberr.ErrIsNil(ctx, err, "删除失败") + }) + return +} diff --git a/internal/app/system/service/context.go b/internal/app/system/service/context.go new file mode 100644 index 0000000..7476bb9 --- /dev/null +++ b/internal/app/system/service/context.go @@ -0,0 +1,34 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast/v3/internal/app/system/model" +) + +type IContext interface { + Init(r *ghttp.Request, customCtx *model.Context) + Get(ctx context.Context) *model.Context + SetUser(ctx context.Context, ctxUser *model.ContextUser) + GetLoginUser(ctx context.Context) *model.ContextUser + GetUserId(ctx context.Context) uint64 +} + +var localContext IContext + +func Context() IContext { + if localContext == nil { + panic("implement not found for interface IContext, forgot register?") + } + return localContext +} + +func RegisterContext(i IContext) { + localContext = i +} diff --git a/internal/app/system/service/middleware.go b/internal/app/system/service/middleware.go new file mode 100644 index 0000000..96af88e --- /dev/null +++ b/internal/app/system/service/middleware.go @@ -0,0 +1,28 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "github.com/gogf/gf/v2/net/ghttp" +) + +type IMiddleware interface { + Ctx(r *ghttp.Request) + Auth(r *ghttp.Request) +} + +var localMiddleware IMiddleware + +func Middleware() IMiddleware { + if localMiddleware == nil { + panic("implement not found for interface IMiddleware, forgot register?") + } + return localMiddleware +} + +func RegisterMiddleware(i IMiddleware) { + localMiddleware = i +} diff --git a/internal/app/system/service/personal.go b/internal/app/system/service/personal.go new file mode 100644 index 0000000..85a1ec6 --- /dev/null +++ b/internal/app/system/service/personal.go @@ -0,0 +1,35 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" +) + +type ( + IPersonal interface { + GetPersonalInfo(ctx context.Context, req *system.PersonalInfoReq) (res *system.PersonalInfoRes, err error) + EditPersonal(ctx context.Context, req *system.PersonalEditReq) (res *system.PersonalEditRes, err error) + ResetPwdPersonal(ctx context.Context, req *system.PersonalResetPwdReq) (res *system.PersonalResetPwdRes, err error) + } +) + +var ( + localPersonal IPersonal +) + +func Personal() IPersonal { + if localPersonal == nil { + panic("implement not found for interface IPersonal, forgot register?") + } + return localPersonal +} + +func RegisterPersonal(i IPersonal) { + localPersonal = i +} diff --git a/internal/app/system/service/sys_auth_rule.go b/internal/app/system/service/sys_auth_rule.go new file mode 100644 index 0000000..376966c --- /dev/null +++ b/internal/app/system/service/sys_auth_rule.go @@ -0,0 +1,47 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type ( + ISysAuthRule interface { + GetMenuListSearch(ctx context.Context, req *system.RuleSearchReq) (res []*model.SysAuthRuleInfoRes, err error) + GetIsMenuList(ctx context.Context) ([]*model.SysAuthRuleInfoRes, error) + GetMenuList(ctx context.Context) (list []*model.SysAuthRuleInfoRes, err error) + GetIsButtonList(ctx context.Context) ([]*model.SysAuthRuleInfoRes, error) + Add(ctx context.Context, req *system.RuleAddReq) (err error) + BindRoleRule(ctx context.Context, ruleId interface{}, roleIds []uint) (err error) + Get(ctx context.Context, id uint) (rule *entity.SysAuthRule, err error) + GetMenuRoles(ctx context.Context, id uint) (roleIds []uint, err error) + Update(ctx context.Context, req *system.RuleUpdateReq) (err error) + UpdateRoleRule(ctx context.Context, ruleId uint, roleIds []uint) (err error) + GetMenuListTree(pid uint, list []*model.SysAuthRuleInfoRes) []*model.SysAuthRuleTreeRes + DeleteMenuByIds(ctx context.Context, ids []int) (err error) + FindSonByParentId(list []*model.SysAuthRuleInfoRes, pid uint) []*model.SysAuthRuleInfoRes + } +) + +var ( + localSysAuthRule ISysAuthRule +) + +func SysAuthRule() ISysAuthRule { + if localSysAuthRule == nil { + panic("implement not found for interface ISysAuthRule, forgot register?") + } + return localSysAuthRule +} + +func RegisterSysAuthRule(i ISysAuthRule) { + localSysAuthRule = i +} diff --git a/internal/app/system/service/sys_dept.go b/internal/app/system/service/sys_dept.go new file mode 100644 index 0000000..83157aa --- /dev/null +++ b/internal/app/system/service/sys_dept.go @@ -0,0 +1,38 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type ISysDept interface { + GetList(ctx context.Context, req *system.DeptSearchReq) (list []*entity.SysDept, err error) + GetFromCache(ctx context.Context) (list []*entity.SysDept, err error) + Add(ctx context.Context, req *system.DeptAddReq) (err error) + Edit(ctx context.Context, req *system.DeptEditReq) (err error) + Delete(ctx context.Context, id uint64) (err error) + FindSonByParentId(deptList []*entity.SysDept, deptId uint64) []*entity.SysDept + GetListTree(pid uint64, list []*entity.SysDept) (deptTree []*model.SysDeptTreeRes) + GetByDeptId(ctx context.Context, deptId uint64) (dept *entity.SysDept, err error) +} + +var localSysDept ISysDept + +func SysDept() ISysDept { + if localSysDept == nil { + panic("implement not found for interface ISysDept, forgot register?") + } + return localSysDept +} + +func RegisterSysDept(i ISysDept) { + localSysDept = i +} diff --git a/internal/app/system/service/sys_job.go b/internal/app/system/service/sys_job.go new file mode 100644 index 0000000..cb3abb8 --- /dev/null +++ b/internal/app/system/service/sys_job.go @@ -0,0 +1,43 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" +) + +type ( + ISysJob interface { + List(ctx context.Context, req *system.SysJobSearchReq) (listRes *system.SysJobSearchRes, err error) + GetByJobId(ctx context.Context, jobId uint64) (res *model.SysJobInfoRes, err error) + Add(ctx context.Context, req *system.SysJobAddReq) (err error) + Edit(ctx context.Context, req *system.SysJobEditReq) (err error) + Delete(ctx context.Context, jobIds []uint64) (err error) + Start(ctx context.Context, jobId uint64) (err error) + Stop(ctx context.Context, jobId uint64) (err error) + Run(ctx context.Context, jobId uint64) (err error) + GetJobs(ctx context.Context) (jobs []*model.SysJobInfoRes, err error) + JobStart(ctx context.Context, job *model.SysJobInfoRes) error + } +) + +var ( + localSysJob ISysJob +) + +func SysJob() ISysJob { + if localSysJob == nil { + panic("implement not found for interface ISysJob, forgot register?") + } + return localSysJob +} + +func RegisterSysJob(i ISysJob) { + localSysJob = i +} diff --git a/internal/app/system/service/sys_job_log.go b/internal/app/system/service/sys_job_log.go new file mode 100644 index 0000000..1bc7247 --- /dev/null +++ b/internal/app/system/service/sys_job_log.go @@ -0,0 +1,36 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" +) + +type ( + ISysJobLog interface { + Add(ctx context.Context, data *do.SysJobLog) (err error) + List(ctx context.Context, req *system.SysJobLogListReq) (listRes *system.SysJobLogListRes, err error) + Delete(ctx context.Context, logIds []uint64) (err error) + } +) + +var ( + localSysJobLog ISysJobLog +) + +func SysJobLog() ISysJobLog { + if localSysJobLog == nil { + panic("implement not found for interface ISysJobLog, forgot register?") + } + return localSysJobLog +} + +func RegisterSysJobLog(i ISysJobLog) { + localSysJobLog = i +} diff --git a/internal/app/system/service/sys_login_log.go b/internal/app/system/service/sys_login_log.go new file mode 100644 index 0000000..281ab2c --- /dev/null +++ b/internal/app/system/service/sys_login_log.go @@ -0,0 +1,33 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" +) + +type ISysLoginLog interface { + Invoke(ctx context.Context, data *model.LoginLogParams) + List(ctx context.Context, req *system.LoginLogSearchReq) (res *system.LoginLogSearchRes, err error) + DeleteLoginLogByIds(ctx context.Context, ids []int) (err error) + ClearLoginLog(ctx context.Context) (err error) +} + +var localSysLoginLog ISysLoginLog + +func SysLoginLog() ISysLoginLog { + if localSysLoginLog == nil { + panic("implement not found for interface ISysLoginLog, forgot register?") + } + return localSysLoginLog +} + +func RegisterSysLoginLog(i ISysLoginLog) { + localSysLoginLog = i +} diff --git a/internal/app/system/service/sys_oper_log.go b/internal/app/system/service/sys_oper_log.go new file mode 100644 index 0000000..39eb261 --- /dev/null +++ b/internal/app/system/service/sys_oper_log.go @@ -0,0 +1,40 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" +) + +type ( + IOperateLog interface { + OperationLog(r *ghttp.Request) + Invoke(ctx context.Context, data *model.SysOperLogAdd) + List(ctx context.Context, req *system.SysOperLogSearchReq) (listRes *system.SysOperLogSearchRes, err error) + GetByOperId(ctx context.Context, operId uint64) (res *model.SysOperLogInfoRes, err error) + DeleteByIds(ctx context.Context, ids []uint64) (err error) + ClearLog(ctx context.Context) (err error) + } +) + +var ( + localOperateLog IOperateLog +) + +func OperateLog() IOperateLog { + if localOperateLog == nil { + panic("implement not found for interface IOperateLog, forgot register?") + } + return localOperateLog +} + +func RegisterOperateLog(i IOperateLog) { + localOperateLog = i +} diff --git a/internal/app/system/service/sys_post.go b/internal/app/system/service/sys_post.go new file mode 100644 index 0000000..2ecace1 --- /dev/null +++ b/internal/app/system/service/sys_post.go @@ -0,0 +1,34 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type ISysPost interface { + List(ctx context.Context, req *system.PostSearchReq) (res *system.PostSearchRes, err error) + Add(ctx context.Context, req *system.PostAddReq) (err error) + Edit(ctx context.Context, req *system.PostEditReq) (err error) + Delete(ctx context.Context, ids []int) (err error) + GetUsedPost(ctx context.Context) (list []*entity.SysPost, err error) +} + +var localSysPost ISysPost + +func SysPost() ISysPost { + if localSysPost == nil { + panic("implement not found for interface ISysPost, forgot register?") + } + return localSysPost +} + +func RegisterSysPost(i ISysPost) { + localSysPost = i +} diff --git a/internal/app/system/service/sys_role.go b/internal/app/system/service/sys_role.go new file mode 100644 index 0000000..b93d10d --- /dev/null +++ b/internal/app/system/service/sys_role.go @@ -0,0 +1,45 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type ( + ISysRole interface { + GetRoleListSearch(ctx context.Context, req *system.RoleListReq) (res *system.RoleListRes, err error) + GetRoleList(ctx context.Context) (list []*entity.SysRole, err error) + AddRoleRule(ctx context.Context, ruleIds []uint, roleId int64) (err error) + DelRoleRule(ctx context.Context, roleId int64) (err error) + AddRole(ctx context.Context, req *system.RoleAddReq) (err error) + Get(ctx context.Context, id uint) (res *entity.SysRole, err error) + GetFilteredNamedPolicy(ctx context.Context, id uint) (gpSlice []int, err error) + EditRole(ctx context.Context, req *system.RoleEditReq) (err error) + DeleteByIds(ctx context.Context, ids []int64) (err error) + RoleDeptTreeSelect(ctx context.Context, roleId int64) (res *system.RoleDeptTreeSelectRes, err error) + GetRoleDepts(ctx context.Context, roleId int64) ([]int64, error) + RoleDataScope(ctx context.Context, req *system.DataScopeReq) error + } +) + +var ( + localSysRole ISysRole +) + +func SysRole() ISysRole { + if localSysRole == nil { + panic("implement not found for interface ISysRole, forgot register?") + } + return localSysRole +} + +func RegisterSysRole(i ISysRole) { + localSysRole = i +} diff --git a/internal/app/system/service/sys_user.go b/internal/app/system/service/sys_user.go new file mode 100644 index 0000000..4d3ca3c --- /dev/null +++ b/internal/app/system/service/sys_user.go @@ -0,0 +1,65 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/gogf/gf/v2/container/gset" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type ( + ISysUser interface { + GetCasBinUserPrefix() string + NotCheckAuthAdminIds(ctx context.Context) *gset.Set + GetAdminUserByUsernamePassword(ctx context.Context, req *system.UserLoginReq) (user *model.LoginUserRes, err error) + GetUserByUsername(ctx context.Context, userName string) (user *model.LoginUserRes, err error) + LoginLog(ctx context.Context, params *model.LoginLogParams) + UpdateLoginInfo(ctx context.Context, id uint64, ip string) (err error) + GetAdminRules(ctx context.Context, userId uint64) (menuList []*model.UserMenus, permissions []string, err error) + GetAdminRole(ctx context.Context, userId uint64, allRoleList []*entity.SysRole) (roles []*entity.SysRole, err error) + GetAdminRoleIds(ctx context.Context, userId uint64) (roleIds []uint, err error) + GetAllMenus(ctx context.Context) (menus []*model.UserMenus, err error) + GetAdminMenusByRoleIds(ctx context.Context, roleIds []uint) (menus []*model.UserMenus, err error) + GetMenusTree(menus []*model.UserMenus, pid uint) []*model.UserMenus + GetPermissions(ctx context.Context, roleIds []uint) (userButtons []string, err error) + List(ctx context.Context, req *system.UserSearchReq) (total interface{}, userList []*entity.SysUser, err error) + GetUsersRoleDept(ctx context.Context, userList []*entity.SysUser) (users []*model.SysUserRoleDeptRes, err error) + Add(ctx context.Context, req *system.UserAddReq) (err error) + Edit(ctx context.Context, req *system.UserEditReq) (err error) + AddUserPost(ctx context.Context, tx gdb.TX, postIds []int64, userId int64) (err error) + EditUserRole(ctx context.Context, roleIds []int64, userId int64) (err error) + UserNameOrMobileExists(ctx context.Context, userName, mobile string, id ...int64) error + GetEditUser(ctx context.Context, id uint64) (res *system.UserGetEditRes, err error) + GetUserInfoById(ctx context.Context, id uint64, withPwd ...bool) (user *entity.SysUser, err error) + GetUserPostIds(ctx context.Context, userId uint64) (postIds []int64, err error) + ResetUserPwd(ctx context.Context, req *system.UserResetPwdReq) (err error) + ChangeUserStatus(ctx context.Context, req *system.UserStatusReq) (err error) + Delete(ctx context.Context, ids []int) (err error) + GetUsers(ctx context.Context, ids []int) (users []*model.SysUserSimpleRes, err error) + GetDataWhere(ctx context.Context, userInfo *model.ContextUser, entityData interface{}) (where g.Map, err error) + } +) + +var ( + localSysUser ISysUser +) + +func SysUser() ISysUser { + if localSysUser == nil { + panic("implement not found for interface ISysUser, forgot register?") + } + return localSysUser +} + +func RegisterSysUser(i ISysUser) { + localSysUser = i +} diff --git a/internal/app/system/service/sys_user_online.go b/internal/app/system/service/sys_user_online.go new file mode 100644 index 0000000..790ec83 --- /dev/null +++ b/internal/app/system/service/sys_user_online.go @@ -0,0 +1,42 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type ( + ISysUserOnline interface { + Invoke(ctx context.Context, params *model.SysUserOnlineParams) + SaveOnline(ctx context.Context, params *model.SysUserOnlineParams) + CheckUserOnline(ctx context.Context) + GetOnlineListPage(ctx context.Context, req *system.SysUserOnlineSearchReq, hasToken ...bool) (res *system.SysUserOnlineSearchRes, err error) + UserIsOnline(ctx context.Context, token string) bool + DeleteOnlineByToken(ctx context.Context, token string) (err error) + ForceLogout(ctx context.Context, ids []int) (err error) + GetInfosByIds(ctx context.Context, ids []int) (onlineList []*entity.SysUserOnline, err error) + } +) + +var ( + localSysUserOnline ISysUserOnline +) + +func SysUserOnline() ISysUserOnline { + if localSysUserOnline == nil { + panic("implement not found for interface ISysUserOnline, forgot register?") + } + return localSysUserOnline +} + +func RegisterSysUserOnline(i ISysUserOnline) { + localSysUserOnline = i +} diff --git a/internal/app/system/service/time_task.go b/internal/app/system/service/time_task.go new file mode 100644 index 0000000..b477d26 --- /dev/null +++ b/internal/app/system/service/time_task.go @@ -0,0 +1,33 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "github.com/tiger1103/gfast/v3/internal/app/system/model" +) + +type ( + ITaskList interface { + AddTask(task *model.TimeTask) + GetByName(funcName string) *model.TimeTask + EditParams(funcName string, params []string) + } +) + +var ( + localTaskList ITaskList +) + +func TaskList() ITaskList { + if localTaskList == nil { + panic("implement not found for interface ITaskList, forgot register?") + } + return localTaskList +} + +func RegisterTaskList(i ITaskList) { + localTaskList = i +} diff --git a/internal/app/system/service/token.go b/internal/app/system/service/token.go new file mode 100644 index 0000000..f0bcae2 --- /dev/null +++ b/internal/app/system/service/token.go @@ -0,0 +1,38 @@ +/* +* @desc:token功能 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/8 15:54 + */ + +package service + +import ( + "context" + + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast-token/gftoken" +) + +type IGfToken interface { + GenerateToken(ctx context.Context, key string, data interface{}) (keys string, err error) + Middleware(group *ghttp.RouterGroup) error + ParseToken(r *ghttp.Request) (*gftoken.CustomClaims, error) + IsLogin(r *ghttp.Request) (b bool, failed *gftoken.AuthFailed) + GetRequestToken(r *ghttp.Request) (token string) + RemoveToken(ctx context.Context, token string) (err error) + GetTokenData(ctx context.Context, token string) (tData *gftoken.TokenData, key string, err error) +} + +var gt IGfToken + +func RegisterGToken(gtk IGfToken) { + gt = gtk +} + +func GfToken() IGfToken { + if gt == nil { + panic("implement not found for interface IGfToken, forgot register?") + } + return gt +} diff --git a/internal/app/system/service/tools_gen_table.go b/internal/app/system/service/tools_gen_table.go new file mode 100644 index 0000000..93bbe9b --- /dev/null +++ b/internal/app/system/service/tools_gen_table.go @@ -0,0 +1,50 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type ( + IToolsGenTable interface { + List(ctx context.Context, req *system.ToolsGenTableSearchReq) (res *system.ToolsGenTableSearchRes, err error) + SelectDbTableList(ctx context.Context, req *system.ToolsGenTableImportSearchReq) (res *system.ToolsGenTableSearchRes, err error) + SelectDbTableListByNames(ctx context.Context, tableNames []string) ([]*entity.ToolsGenTable, error) + ImportGenTable(ctx context.Context, tableList []*entity.ToolsGenTable) error + InitTable(ctx context.Context, table *entity.ToolsGenTable, columns []*entity.ToolsGenTableColumn) error + ConvertClassName(ctx context.Context, tableName string) string + GetBusinessName(ctx context.Context, tableName string) string + DeleteTable(ctx context.Context, req *system.ToolsGenTableDeleteReq) error + ColumnList(ctx context.Context, req *system.ToolsGenTableEditReq) (res *system.ToolsGenTableEditRes, err error) + GetTableInfoByTableId(ctx context.Context, tableId int64) (data *entity.ToolsGenTable, err error) + GetRelationTable(ctx context.Context) (res []*model.ToolsGenTableColumnsData, err error) + SaveEdit(ctx context.Context, req *system.ToolsGenTableColumnsEditReq) (err error) + GenData(ctx context.Context, tableId int64) (data g.MapStrStr, extendData *model.ToolsGenTableEx, err error) + SelectRecordById(ctx context.Context, tableId int64) (tableEx *model.ToolsGenTableEx, err error) + GenCode(ctx context.Context, ids []int) (err error) + } +) + +var ( + localToolsGenTable IToolsGenTable +) + +func ToolsGenTable() IToolsGenTable { + if localToolsGenTable == nil { + panic("implement not found for interface IToolsGenTable, forgot register?") + } + return localToolsGenTable +} + +func RegisterToolsGenTable(i IToolsGenTable) { + localToolsGenTable = i +} diff --git a/internal/app/system/service/tools_gen_table_column.go b/internal/app/system/service/tools_gen_table_column.go new file mode 100644 index 0000000..2e0e3de --- /dev/null +++ b/internal/app/system/service/tools_gen_table_column.go @@ -0,0 +1,53 @@ +// ================================================================================ +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/model/entity" +) + +type ( + IToolsGenTableColumn interface { + SelectDbTableColumnsByName(ctx context.Context, tableName string) ([]*entity.ToolsGenTableColumn, error) + InitColumnField(column *entity.ToolsGenTableColumn, table *entity.ToolsGenTable) + GetDbType(columnType string) string + IsExistInArray(value string, array []string) bool + IsStringObject(dataType string) bool + IsTimeObject(dataType string) bool + IsNumberObject(dataType string) bool + IsNotEdit(name string) bool + IsNotList(name string) bool + IsNotDetail(name string) bool + IsNotQuery(name string) bool + CheckNameColumn(columnName string) bool + CheckStatusColumn(columnName string) bool + CheckTypeColumn(columnName string) bool + CheckSexColumn(columnName string) bool + SelectGenTableColumnListByTableId(ctx context.Context, tableId int64) (list []*entity.ToolsGenTableColumn, err error) + GetAllTableColumns(ctx context.Context) (list []*entity.ToolsGenTableColumn, err error) + SetPkColumn(table *model.ToolsGenTableEx, columns []*model.ToolsGenTableColumnEx) + GetColumnLength(columnType string) int + SelectDbTableColumnMapByName(ctx context.Context, tableName string) (res map[string]*entity.ToolsGenTableColumn, err error) + } +) + +var ( + localToolsGenTableColumn IToolsGenTableColumn +) + +func ToolsGenTableColumn() IToolsGenTableColumn { + if localToolsGenTableColumn == nil { + panic("implement not found for interface IToolsGenTableColumn, forgot register?") + } + return localToolsGenTableColumn +} + +func RegisterToolsGenTableColumn(i IToolsGenTableColumn) { + localToolsGenTableColumn = i +} diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go new file mode 100644 index 0000000..7a7b63d --- /dev/null +++ b/internal/cmd/cmd.go @@ -0,0 +1,47 @@ +package cmd + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/net/goai" + "github.com/gogf/gf/v2/os/gcmd" + "github.com/gogf/gf/v2/os/glog" + "github.com/tiger1103/gfast/v3/internal/consts" + "github.com/tiger1103/gfast/v3/internal/router" +) + +var ( + Main = gcmd.Command{ + Name: "main", + Usage: "main", + Brief: "start http server", + Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { + g.Log().SetFlags(glog.F_ASYNC | glog.F_TIME_DATE | glog.F_TIME_TIME | glog.F_FILE_LONG) + g.Log().Info(ctx, "GFast version:", consts.Version) + s := g.Server() + s.Group("/", func(group *ghttp.RouterGroup) { + router.R.BindController(ctx, group) + }) + enhanceOpenAPIDoc(s) + s.Run() + return nil + }, + } +) + +func enhanceOpenAPIDoc(s *ghttp.Server) { + openapi := s.GetOpenApi() + openapi.Config.CommonResponse = ghttp.DefaultHandlerResponse{} + openapi.Config.CommonResponseDataField = `Data` + + // API description. + openapi.Info = goai.Info{ + Title: consts.OpenAPITitle, + Description: consts.OpenAPIDescription, + Contact: &goai.Contact{ + Name: consts.OpenAPIContactName, + URL: consts.OpenAPIContactUrl, + }, + } +} diff --git a/internal/consts/consts_openapi.go b/internal/consts/consts_openapi.go new file mode 100644 index 0000000..0b1663b --- /dev/null +++ b/internal/consts/consts_openapi.go @@ -0,0 +1,8 @@ +package consts + +const ( + OpenAPITitle = `GFast-v3` + OpenAPIDescription = `基于 GoFrame2.0的后台管理系统。 Enjoy 💖 ` + OpenAPIContactName = "GFast" + OpenAPIContactUrl = "http://www.g-fast.cn" +) diff --git a/internal/consts/version.go b/internal/consts/version.go new file mode 100644 index 0000000..5293fe9 --- /dev/null +++ b/internal/consts/version.go @@ -0,0 +1,12 @@ +/* +* @desc:版本号 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/11 11:24 + */ + +package consts + +const ( + Version = "3.2.1" +) diff --git a/internal/router/router.go b/internal/router/router.go new file mode 100644 index 0000000..1677108 --- /dev/null +++ b/internal/router/router.go @@ -0,0 +1,32 @@ +/* +* @desc:路由绑定 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/2/18 16:23 + */ + +package router + +import ( + "context" + "github.com/gogf/gf/v2/net/ghttp" + commonRouter "github.com/tiger1103/gfast/v3/internal/app/common/router" + commonService "github.com/tiger1103/gfast/v3/internal/app/common/service" + systemRouter "github.com/tiger1103/gfast/v3/internal/app/system/router" +) + +var R = new(Router) + +type Router struct{} + +func (router *Router) BindController(ctx context.Context, group *ghttp.RouterGroup) { + group.Group("/api/v1", func(group *ghttp.RouterGroup) { + //跨域处理,安全起见正式环境请注释该行 + group.Middleware(commonService.Middleware().MiddlewareCORS) + group.Middleware(ghttp.MiddlewareHandlerResponse) + // 绑定后台路由 + systemRouter.R.BindController(ctx, group) + // 绑定公共路由 + commonRouter.R.BindController(ctx, group) + }) +} diff --git a/library/libResponse/response.go b/library/libResponse/response.go new file mode 100644 index 0000000..64d4340 --- /dev/null +++ b/library/libResponse/response.go @@ -0,0 +1,107 @@ +package libResponse + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/os/gview" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" +) + +const ( + SuccessCode int = 0 + ErrorCode int = -1 +) + +type Response struct { + // 代码 + Code int `json:"code" example:"200"` + // 数据集 + Data interface{} `json:"data"` + // 消息 + Msg string `json:"message"` +} + +var response = new(Response) + +func JsonExit(r *ghttp.Request, code int, msg string, data ...interface{}) { + response.JsonExit(r, code, msg, data...) +} + +func RJson(r *ghttp.Request, code int, msg string, data ...interface{}) { + response.RJson(r, code, msg, data...) +} + +func SusJson(isExit bool, r *ghttp.Request, msg string, data ...interface{}) { + response.SusJson(isExit, r, msg, data...) +} + +func FailJson(isExit bool, r *ghttp.Request, msg string, data ...interface{}) { + response.FailJson(isExit, r, msg, data...) +} + +func WriteTpl(r *ghttp.Request, tpl string, view *gview.View, params ...gview.Params) error { + return response.WriteTpl(r, tpl, view, params...) +} + +// 返回JSON数据并退出当前HTTP执行函数。 +func (res *Response) JsonExit(r *ghttp.Request, code int, msg string, data ...interface{}) { + res.RJson(r, code, msg, data...) + r.ExitAll() +} + +// 标准返回结果数据结构封装。 +// 返回固定数据结构的JSON: +// code: 状态码(200:成功,302跳转,和http请求状态码一至); +// msg: 请求结果信息; +// data: 请求结果,根据不同接口返回结果的数据结构不同; +func (res *Response) RJson(r *ghttp.Request, code int, msg string, data ...interface{}) { + responseData := interface{}(nil) + if len(data) > 0 { + responseData = data[0] + } + response = &Response{ + Code: code, + Msg: msg, + Data: responseData, + } + r.Response.WriteJson(response) +} + +// 成功返回JSON +func (res *Response) SusJson(isExit bool, r *ghttp.Request, msg string, data ...interface{}) { + if isExit { + res.JsonExit(r, SuccessCode, msg, data...) + } + res.RJson(r, SuccessCode, msg, data...) +} + +// 失败返回JSON +func (res *Response) FailJson(isExit bool, r *ghttp.Request, msg string, data ...interface{}) { + if isExit { + res.JsonExit(r, ErrorCode, msg, data...) + } + res.RJson(r, ErrorCode, msg, data...) +} + +// WriteTpl 模板输出 +func (res *Response) WriteTpl(r *ghttp.Request, tpl string, view *gview.View, params ...gview.Params) error { + //绑定模板中需要用到的方法 + view.BindFuncMap(g.Map{ + // 根据长度i来切割字符串 + "subStr": func(str interface{}, i int) (s string) { + s1 := gconv.String(str) + if gstr.LenRune(s1) > i { + s = gstr.SubStrRune(s1, 0, i) + "..." + return s + } + return s1 + }, + }) + r.Response.Write(view.Parse(r.GetCtx(), tpl, params...)) + return nil +} + +func (res *Response) Redirect(r *ghttp.Request, location string, code ...int) { + r.Response.RedirectTo(location, code...) +} diff --git a/library/libRouter/router.go b/library/libRouter/router.go new file mode 100644 index 0000000..4ee7d83 --- /dev/null +++ b/library/libRouter/router.go @@ -0,0 +1,36 @@ +/* +* @desc:路由处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/11/16 11:09 + */ + +package libRouter + +import ( + "context" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/text/gregex" + "reflect" +) + +// RouterAutoBind 收集需要被绑定的控制器,自动绑定 +// 路由的方法命名规则必须为:BindXXXController +func RouterAutoBind(R interface{}, ctx context.Context, group *ghttp.RouterGroup) (err error) { + //TypeOf会返回目标数据的类型,比如int/float/struct/指针等 + typ := reflect.TypeOf(R) + //ValueOf返回目标数据的的值 + val := reflect.ValueOf(R) + if val.Elem().Kind() != reflect.Struct { + err = gerror.New("expect struct but a " + val.Elem().Kind().String()) + return + } + for i := 0; i < typ.NumMethod(); i++ { + if match := gregex.IsMatchString(`^Bind(.+)Controller$`, typ.Method(i).Name); match { + //调用绑定方法 + val.Method(i).Call([]reflect.Value{reflect.ValueOf(ctx), reflect.ValueOf(group)}) + } + } + return +} diff --git a/library/libUtils/slice_tree.go b/library/libUtils/slice_tree.go new file mode 100644 index 0000000..e1b3a3e --- /dev/null +++ b/library/libUtils/slice_tree.go @@ -0,0 +1,249 @@ +package libUtils + +import ( + "fmt" + "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/gconv" + "reflect" +) + +// ParentSonSort 有层级关系的数组,父级-》子级 排序 +func ParentSonSort(list g.List, params ...interface{}) g.List { + args := make([]interface{}, 8) + for k, v := range params { + if k == 8 { + break + } + args[k] = v + } + var ( + pid int //父级id + level int //层级数 + fieldName string //父级id键名 + id string //id键名 + levelName string //层级名称 + title string //标题名称 + breaks int //中断层级 + prefixStr string //字符串前缀 + ) + pid = gconv.Int(GetSliceByKey(args, 0, 0)) + level = gconv.Int(GetSliceByKey(args, 1, 0)) + fieldName = gconv.String(GetSliceByKey(args, 2, "pid")) + id = gconv.String(GetSliceByKey(args, 3, "id")) + levelName = gconv.String(GetSliceByKey(args, 4, "flg")) + title = gconv.String(GetSliceByKey(args, 5, "title")) + breaks = gconv.Int(GetSliceByKey(args, 6, -1)) + prefixStr = gconv.String(GetSliceByKey(args, 7, "─")) + //定义一个新slice用于返回 + var returnSlice g.List + for _, v := range list { + if pid == gconv.Int(v[fieldName]) { + v[levelName] = level + levelClone := level + titlePrefix := "" + for { + if levelClone < 0 { + break + } + titlePrefix += prefixStr + levelClone-- + } + titlePrefix = "├" + titlePrefix + if level == 0 { + v["title_prefix"] = "" + } else { + v["title_prefix"] = titlePrefix + } + v["title_show"] = fmt.Sprintf("%s%s", v["title_prefix"], v[title]) + returnSlice = append(returnSlice, v) + if breaks != -1 && breaks == level { + continue + } + args[0] = v[id] + args[1] = level + 1 + newSlice2 := ParentSonSort(list, args...) + if len(newSlice2) > 0 { + returnSlice = append(returnSlice, newSlice2...) + } + } + } + return returnSlice +} + +// PushSonToParent 有层级关系的数组 ,将子级压入到父级(树形结构) +func PushSonToParent(list g.List, params ...interface{}) g.List { + args := make([]interface{}, 7) + for k, v := range params { + if k == 7 { + break + } + args[k] = v + } + var ( + pid string //父级id + fieldName string //父级id键名 + id string //id键名 + key string //子级数组键名 + filter string //过滤键名 + filterVal interface{} //过滤的值 + showNoChild bool //是否显示不存在的子级健 + ) + pid = gconv.String(GetSliceByKey(args, 0, 0)) + fieldName = gconv.String(GetSliceByKey(args, 1, "pid")) + id = gconv.String(GetSliceByKey(args, 2, "id")) + key = gconv.String(GetSliceByKey(args, 3, "children")) + filter = gconv.String(GetSliceByKey(args, 4, "")) + filterVal = GetSliceByKey(args, 5, nil) + showNoChild = gconv.Bool(GetSliceByKey(args, 6, true)) + var returnList g.List + for _, v := range list { + if gconv.String(v[fieldName]) == pid { + if filter != "" { + if reflect.DeepEqual(v[filter], filterVal) { + args[0] = v[id] + child := PushSonToParent(list, args...) + if child != nil || showNoChild { + v[key] = child + } + returnList = append(returnList, v) + } + } else { + args[0] = v[id] + child := PushSonToParent(list, args...) + if child != nil || showNoChild { + v[key] = child + } + returnList = append(returnList, v) + } + } + } + return returnList +} + +// GetSliceByKey 获取切片里的值 若为nil 可设置默认值val +func GetSliceByKey(args []interface{}, key int, val interface{}) interface{} { + var value interface{} + if args[key] != nil { + value = args[key] + } else { + value = val + } + return value +} + +// FindSonByParentId 有层级关系的切片,通过父级id查找所有子级id数组 +// parentId 父级id +// parentIndex 父级索引名称 +// idIndex id索引名称 +func FindSonByParentId(list g.List, parentId interface{}, parentIndex, idIndex string) g.List { + newList := make(g.List, 0, len(list)) + for _, v := range list { + if reflect.DeepEqual(v[parentIndex], parentId) { + newList = append(newList, v) + fList := FindSonByParentId(list, v[idIndex], parentIndex, idIndex) + newList = append(newList, fList...) + } + } + return newList +} + +// GetTopPidList 获取最顶层 parent Id +func GetTopPidList(list g.List, parentIndex, idIndex string) *garray.Array { + arr := garray.NewArray() + for _, v1 := range list { + tag := true + for _, v2 := range list { + if v1[parentIndex] == v2[idIndex] { + tag = false + break + } + } + if tag { + arr.PushRight(v1[parentIndex]) + } + } + return arr.Unique() +} + +// FindParentBySonPid 有层级关系的数组,通过子级fid查找所有父级数组 +func FindParentBySonPid(list g.List, id int, params ...interface{}) g.List { + args := make([]interface{}, 4) + for k, v := range params { + if k == 4 { + break + } + args[k] = v + } + var ( + filter = gconv.String(GetSliceByKey(args, 0, "filter")) //过滤键名 + fPid = gconv.String(GetSliceByKey(args, 1, "pid")) //父级id字段键名 + filterValue = GetSliceByKey(args, 2, nil) //过滤键值 + fid = gconv.String(GetSliceByKey(args, 3, "id")) //id字段键名 + ) + rList := make(g.List, 0, len(list)) + for _, v := range list { + if gconv.Int(v[fid]) == id { + if fv, ok := v[filter]; ok { + if reflect.DeepEqual(fv, filterValue) { + rList = append(rList, v) + } + } else { + rList = append(rList, v) + } + r := FindParentBySonPid(list, gconv.Int(v[fPid]), filter, fPid, filterValue, fid) + rList = append(rList, r...) + } + } + return rList +} + +// FindTopParent +/** + * 根据id查询最顶层父级信息 + * @param list 有层级关系的数组 + * @param id 查找的id + * @param string fpid 父级id键名 + * @param string fid 当前id键名 + * @return g.Map + */ +func FindTopParent(list g.List, id int64, params ...interface{}) g.Map { + if len(list) == 0 { + return g.Map{} + } + args := make([]interface{}, 2) + for k, v := range params { + if k == 2 { + break + } + args[k] = v + } + var ( + fPid = gconv.String(GetSliceByKey(args, 0, "pid")) //父级id字段键名 + fid = gconv.String(GetSliceByKey(args, 1, "id")) //id字段键名 + ) + hasParent := true + top := g.Map{} + //找到要查找id值的数组 + for _, v := range list { + if gconv.Int64(v[fid]) == gconv.Int64(id) { + top = v + break + } + } + for { + if !hasParent { + break + } + //查询最顶层 + for _, v := range list { + if gconv.Int64(top[fPid]) == gconv.Int64(v[fid]) { + top = v + hasParent = true + break + } + hasParent = false + } + } + return top +} diff --git a/library/libUtils/utils.go b/library/libUtils/utils.go new file mode 100644 index 0000000..42d5ad8 --- /dev/null +++ b/library/libUtils/utils.go @@ -0,0 +1,196 @@ +/* +* @desc:工具 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/4 22:16 + */ + +package libUtils + +import ( + "context" + "fmt" + "github.com/gogf/gf/v2/crypto/gmd5" + "github.com/gogf/gf/v2/encoding/gcharset" + "github.com/gogf/gf/v2/encoding/gjson" + "github.com/gogf/gf/v2/encoding/gurl" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/text/gstr" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + "net" + "net/http" + "os" + "path" + "strings" +) + +// EncryptPassword 密码加密 +func EncryptPassword(password, salt string) string { + return gmd5.MustEncryptString(gmd5.MustEncryptString(password) + gmd5.MustEncryptString(salt)) +} + +// GetDomain 获取当前请求接口域名 +func GetDomain(ctx context.Context) string { + r := g.RequestFromCtx(ctx) + pathInfo, err := gurl.ParseURL(r.GetUrl(), -1) + if err != nil { + g.Log().Error(ctx, err) + return "" + } + return fmt.Sprintf("%s://%s:%s/", pathInfo["scheme"], pathInfo["host"], pathInfo["port"]) +} + +// GetClientIp 获取客户端IP +func GetClientIp(ctx context.Context) string { + return g.RequestFromCtx(ctx).GetClientIp() +} + +// GetUserAgent 获取user-agent +func GetUserAgent(ctx context.Context) string { + return ghttp.RequestFromCtx(ctx).Header.Get("User-Agent") +} + +// GetLocalIP 服务端ip +func GetLocalIP() (ip string, err error) { + var addrs []net.Addr + addrs, err = net.InterfaceAddrs() + if err != nil { + return + } + for _, addr := range addrs { + ipAddr, ok := addr.(*net.IPNet) + if !ok { + continue + } + if ipAddr.IP.IsLoopback() { + continue + } + if !ipAddr.IP.IsGlobalUnicast() { + continue + } + return ipAddr.IP.String(), nil + } + return +} + +// GetCityByIp 获取ip所属城市 +func GetCityByIp(ip string) string { + if ip == "" { + return "" + } + if ip == "::1" || ip == "127.0.0.1" { + return "内网IP" + } + url := "http://whois.pconline.com.cn/ipJson.jsp?json=true&ip=" + ip + bytes := g.Client().GetBytes(context.TODO(), url) + src := string(bytes) + srcCharset := "GBK" + tmp, _ := gcharset.ToUTF8(srcCharset, src) + json, err := gjson.DecodeToJson(tmp) + if err != nil { + return "" + } + if json.Get("code").Int() == 0 { + city := fmt.Sprintf("%s %s", json.Get("pro").String(), json.Get("city").String()) + return city + } else { + return "" + } +} + +// 写入文件 +func WriteToFile(fileName string, content string) error { + f, err := os.OpenFile(fileName, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) + if err != nil { + return err + } + n, _ := f.Seek(0, os.SEEK_END) + _, err = f.WriteAt([]byte(content), n) + defer f.Close() + return err +} + +// 文件或文件夹是否存在 +func FileIsExisted(filename string) bool { + existed := true + if _, err := os.Stat(filename); os.IsNotExist(err) { + existed = false + } + return existed +} + +// 解析路径获取文件名称及后缀 +func ParseFilePath(pathStr string) (fileName string, fileType string) { + fileNameWithSuffix := path.Base(pathStr) + fileType = path.Ext(fileNameWithSuffix) + fileName = strings.TrimSuffix(fileNameWithSuffix, fileType) + return +} + +// IsNotExistMkDir 检查文件夹是否存在 +// 如果不存在则新建文件夹 +func IsNotExistMkDir(src string) error { + if exist := !FileIsExisted(src); exist == false { + if err := MkDir(src); err != nil { + return err + } + } + + return nil +} + +// MkDir 新建文件夹 +func MkDir(src string) error { + err := os.MkdirAll(src, os.ModePerm) + if err != nil { + return err + } + + return nil +} + +// 获取文件后缀 +func GetExt(fileName string) string { + return path.Ext(fileName) +} + +// GetType 获取文件类型 +func GetType(p string) (result string, err error) { + file, err := os.Open(p) + if err != nil { + g.Log().Error(context.TODO(), err) + return + } + buff := make([]byte, 512) + + _, err = file.Read(buff) + + if err != nil { + g.Log().Error(context.TODO(), err) + return + } + filetype := http.DetectContentType(buff) + return filetype, nil +} + +// GetFilesPath 获取附件相对路径 +func GetFilesPath(ctx context.Context, fileUrl string) (path string, err error) { + upType := g.Cfg().MustGet(ctx, "upload.default").Int() + if upType != 0 || (upType == 0 && !gstr.ContainsI(fileUrl, consts.UploadPath)) { + path = fileUrl + return + } + pathInfo, err := gurl.ParseURL(fileUrl, 32) + if err != nil { + g.Log().Error(ctx, err) + err = gerror.New("解析附件路径失败") + return + } + pos := gstr.PosI(pathInfo["path"], consts.UploadPath) + if pos >= 0 { + path = gstr.SubStr(pathInfo["path"], pos) + } + return +} diff --git a/library/liberr/err.go b/library/liberr/err.go new file mode 100644 index 0000000..dd5ec83 --- /dev/null +++ b/library/liberr/err.go @@ -0,0 +1,30 @@ +/* +* @desc:错误处理 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/3/2 14:53 + */ + +package liberr + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" +) + +func ErrIsNil(ctx context.Context, err error, msg ...string) { + if !g.IsNil(err) { + if len(msg) > 0 { + g.Log().Error(ctx, err.Error()) + panic(msg[0]) + } else { + panic(err.Error()) + } + } +} + +func ValueIsNil(value interface{}, msg string) { + if g.IsNil(value) { + panic(msg) + } +} diff --git a/library/upload/init.go b/library/upload/init.go new file mode 100644 index 0000000..33559c7 --- /dev/null +++ b/library/upload/init.go @@ -0,0 +1,47 @@ +package upload + +import ( + "context" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast/v3/api/v1/system" +) + +const ( + SourceLocal UploaderType = iota // 上传到本地 + SourceTencent // 上传至腾讯云 + SourceQiniu // 上传到七牛云 +) + +type UploaderType int + +type IUpload interface { + Upload(ctx context.Context, file *ghttp.UploadFile) (result system.UploadResponse, err error) +} + +var uploadCollection map[UploaderType]IUpload + +// 注册上传接口 +func RegisterUploader(key UploaderType, value IUpload) { + if uploadCollection == nil { + uploadCollection = make(map[UploaderType]IUpload) + } + uploadCollection[key] = value +} + +// 获取上传接口 +func GetUploader(key UploaderType) IUpload { + if uploadCollection == nil { + return nil + } + if v, ok := uploadCollection[key]; ok { + return v + } + return nil +} + +func init() { + + RegisterUploader(SourceLocal, &Local{}) + RegisterUploader(SourceTencent, &Tencent{}) + RegisterUploader(SourceQiniu, &Qiniou{}) +} diff --git a/library/upload/local.go b/library/upload/local.go new file mode 100644 index 0000000..0ba2d84 --- /dev/null +++ b/library/upload/local.go @@ -0,0 +1,57 @@ +package upload + +import ( + "context" + "errors" + "fmt" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/tiger1103/gfast/v3/api/v1/system" + "github.com/tiger1103/gfast/v3/internal/app/common/consts" + "strings" + "time" +) + +type Local struct { +} + +func (s *Local) Upload(ctx context.Context, file *ghttp.UploadFile) (result system.UploadResponse, err error) { + if file == nil { + err = errors.New("文件必须!") + return + } + r := g.RequestFromCtx(ctx) + urlPerfix := fmt.Sprintf("http://%s/", r.Host) + p := strings.Trim(consts.UploadPath, "/") + sp := s.getStaticPath(ctx) + if sp != "" { + sp = strings.Trim(sp, "/") + } + nowData := time.Now().Format("2006-01-02") + // 包含静态文件夹的路径 + fullDirPath := sp + "/" + p + "/" + nowData + fileName, err := file.Save(fullDirPath, true) + if err != nil { + return + } + // 不含静态文件夹的路径 + fullPath := p + "/" + nowData + "/" + fileName + + result = system.UploadResponse{ + Size: file.Size, + Path: fullPath, + FullPath: urlPerfix + fullPath, + Name: file.Filename, + Type: file.Header.Get("Content-type"), + } + return +} + +// 静态文件夹目录 +func (s *Local) getStaticPath(ctx context.Context) string { + value, _ := g.Cfg().Get(ctx, "server.serverRoot") + if !value.IsEmpty() { + return value.String() + } + return "" +} diff --git a/library/upload/qiniou.go b/library/upload/qiniou.go new file mode 100644 index 0000000..58de5e7 --- /dev/null +++ b/library/upload/qiniou.go @@ -0,0 +1,75 @@ +package upload + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/util/guid" + "github.com/qiniu/go-sdk/v7/auth/qbox" + "github.com/qiniu/go-sdk/v7/storage" + "github.com/tiger1103/gfast/v3/api/v1/system" + "path" +) + +type Qiniou struct{} + +func (s *Qiniou) Upload(ctx context.Context, file *ghttp.UploadFile) (result system.UploadResponse, err error) { + + url, err := s.toQiniou(ctx, file) + if err != nil { + return + } + result = system.UploadResponse{ + Size: file.Size, + Path: url, + FullPath: url, + Name: file.Filename, + Type: file.Header.Get("Content-type"), + } + + return +} + +func (s *Qiniou) toQiniou(ctx context.Context, f *ghttp.UploadFile) (url string, err error) { + file, err := f.Open() + if err != nil { + return + } + defer file.Close() + v, err := g.Cfg().Get(ctx, "upload.qiniou") + if err != nil { + return + } + m := v.MapStrVar() + var AccessKey = m["accessKey"].String() + var SerectKey = m["sercetKey"].String() + var Bucket = m["bucket"].String() + var ImgUrl = m["qiniuServer"].String() + + putPlicy := storage.PutPolicy{ + Scope: Bucket, + } + mac := qbox.NewMac(AccessKey, SerectKey) + upToken := putPlicy.UploadToken(mac) + cfg := storage.Config{ + Zone: &storage.ZoneHuanan, + UseCdnDomains: false, + UseHTTPS: false, + } + putExtra := storage.PutExtra{ + MimeType: f.Header.Get("Content-type"), + } + formUploader := storage.NewFormUploader(&cfg) + ret := storage.PutRet{} + filename := guid.S() + path.Ext(f.Filename) + fileSize := f.Size + //err = formUploader.PutWithoutKey(context.Background(), &ret, upToken, file, fileSize, &putExtra) + err = formUploader.Put(context.Background(), &ret, upToken, filename, file, fileSize, &putExtra) + if err != nil { + return + } + + url = ImgUrl + "/" + filename + return url, nil + +} diff --git a/library/upload/tencent.go b/library/upload/tencent.go new file mode 100644 index 0000000..d006b2b --- /dev/null +++ b/library/upload/tencent.go @@ -0,0 +1,75 @@ +package upload + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/grand" + "github.com/tencentyun/cos-go-sdk-v5" + "github.com/tencentyun/cos-go-sdk-v5/debug" + "github.com/tiger1103/gfast/v3/api/v1/system" + "io" + "net/http" + "net/url" + "strconv" + "strings" +) + +type Tencent struct { +} + +func (s *Tencent) Upload(ctx context.Context, file *ghttp.UploadFile) (result system.UploadResponse, err error) { + v, err := g.Cfg().Get(ctx, "upload.tencentCOS") + if err != nil { + return + } + m := v.MapStrVar() + var ( + upPath = m["upPath"].String() + rawUrl = m["rawUrl"].String() + secretID = m["secretID"].String() + secretKey = m["secretKey"].String() + ) + name := gfile.Basename(file.Filename) + name = strings.ToLower(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.S(6)) + name = name + gfile.Ext(file.Filename) + + path := upPath + name + + url, _ := url.Parse(rawUrl) + b := &cos.BaseURL{BucketURL: url} + client := cos.NewClient(b, &http.Client{ + Transport: &cos.AuthorizationTransport{ + SecretID: secretID, + SecretKey: secretKey, + Transport: &debug.DebugRequestTransport{ + RequestHeader: false, + RequestBody: false, + ResponseHeader: false, + ResponseBody: false, + }, + }, + }) + opt := &cos.ObjectPutOptions{ + ObjectPutHeaderOptions: &cos.ObjectPutHeaderOptions{ + ContentLength: int64(file.Size), + }, + } + var f io.ReadCloser + f, err = file.Open() + if err != nil { + return + } + defer f.Close() + _, err = client.Object.Put(context.Background(), path, f, opt) + result = system.UploadResponse{ + Size: file.Size, + Path: rawUrl + path, + FullPath: rawUrl + path, + Name: file.Filename, + Type: file.Header.Get("Content-type"), + } + return +} diff --git a/library/upload_chunk/consts.go b/library/upload_chunk/consts.go new file mode 100644 index 0000000..04f799d --- /dev/null +++ b/library/upload_chunk/consts.go @@ -0,0 +1,7 @@ +package upload_chunk + +const ( + Tmp = "./resource/public/big_file/" // 文件保存目录 + RelativePath = "big_file/" // 返回前端的相对路径 + FileName = "upfile" // 上传文件的文件名 +) diff --git a/library/upload_chunk/helper.go b/library/upload_chunk/helper.go new file mode 100644 index 0000000..b46da79 --- /dev/null +++ b/library/upload_chunk/helper.go @@ -0,0 +1,81 @@ +package upload_chunk + +import ( + "errors" + "fmt" + "os" + "path" + "strings" +) + +// 解析文件目录,文件前缀及文件后缀 +func parseFilePath(filename string) (dir, prefix, suffix string) { + filenameall := path.Base(filename) //不含目录的文件名 + filesuffix := path.Ext(filename) // 后缀 + fileprefix := strings.TrimSuffix(filenameall, filesuffix) // 前缀 + + dir = strings.TrimRight(filename, filenameall) // 文件目录 + prefix = fileprefix // 文件前缀 + suffix = filesuffix // 文件后缀 + return +} + +// 创建文件 +func createFile(fullFilePath string) (ok bool, err error) { + ok = fileExists(fullFilePath) + if ok { + return + } + dir, _, _ := parseFilePath(fullFilePath) + if dir != "" { + err = mkDir(dir) + if err != nil { + return + } + } + newFile, err := os.Create(fullFilePath) + defer newFile.Close() + if err != nil { + return + } + return +} + +// 创建文件夹 +func mkDir(path string) (err error) { + if !fileExists(path) { + if err = os.MkdirAll(path, os.ModePerm); err != nil { + return errors.New(fmt.Sprintf(`os.MkdirAll failed for path "%s" with perm "%d" , err : %v`, path, os.ModePerm, err)) + } + return nil + } + + return +} + +// 判断所给路径是否为文件夹 +func IsDir(path string) bool { + s, err := os.Stat(path) + if err != nil { + return false + } + return s.IsDir() +} + +// 是否文件 +func IsFile(path string) bool { + return !IsDir(path) +} + +// 判断文件或文件夹是否存在 +func fileExists(path string) bool { + if stat, err := os.Stat(path); stat != nil && !os.IsNotExist(err) { + return true + } + return false +} + +// 生成分片文件名 +func getChunkFilename(identifier, chunkNumber string) string { + return fmt.Sprintf("uploader-%s.%s", identifier, chunkNumber) +} diff --git a/library/upload_chunk/option.go b/library/upload_chunk/option.go new file mode 100644 index 0000000..4d32fe9 --- /dev/null +++ b/library/upload_chunk/option.go @@ -0,0 +1,241 @@ +package upload_chunk + +import ( + "encoding/json" + "errors" + "io" + "mime/multipart" + "net/http" + "strconv" +) + +type checkErr func() error + +type UploadReq struct { + ChunkNumber int `json:"chunkNumber"` // 分片序列号 + ChunkSize int `json:"chunkSize"` // 分片大小 + CurrentChunkSize int `json:"currentChunkSize"` // 当前分片大小 + TotalSize int64 `json:"totalSize"` // 文件总大小 + Identifier string `json:"identifier"` // 标识 + Filename string `json:"filename"` // 文件名 + RelativePath string `json:"relativePath"` //文件夹上传的时候文件的相对路径属性 + TotalChunks int `json:"totalChunks"` // 分片总数 + File multipart.File + FileHeader *multipart.FileHeader + + verification map[interface{}][]checkErr +} + +func (u *UploadReq) verificationInit() { + if u.verification == nil { + u.verification = make(map[interface{}][]checkErr) + } +} + +func (u *UploadReq) MustChunkNumber() *UploadReq { + u.verificationInit() + u.verification["ChunkNumber"] = append(u.verification["ChunkNumber"], func() error { + if u.ChunkNumber == 0 { + return errors.New("ChunkNumber不能为空") + } + return nil + }) + + return u +} + +func (u *UploadReq) MustChunkSize() *UploadReq { + u.verificationInit() + u.verification["ChunkSize"] = append(u.verification["ChunkSize"], func() error { + if u.ChunkSize == 0 { + return errors.New("ChunkSize不能为空") + } + return nil + }) + + return u +} + +func (u *UploadReq) MustCurrentChunkSize() *UploadReq { + u.verificationInit() + u.verification["CurrentChunkSize"] = append(u.verification["CurrentChunkSize"], func() error { + if u.CurrentChunkSize == 0 { + return errors.New("CurrentChunkSize不能为空") + } + return nil + }) + return u +} + +func (u *UploadReq) MustTotalSize() *UploadReq { + u.verificationInit() + u.verification["TotalSize"] = append(u.verification["TotalSize"], func() error { + if u.TotalSize == 0 { + return errors.New("TotalSize不能为空") + } + return nil + }) + return u +} + +func (u *UploadReq) MustIdentifier() *UploadReq { + u.verificationInit() + u.verification["Identifier"] = append(u.verification["Identifier"], func() error { + if u.Identifier == "" { + return errors.New("Identifier不能为空") + } + return nil + }) + return u +} + +func (u *UploadReq) MustFilename() *UploadReq { + u.verificationInit() + u.verification["Filename"] = append(u.verification["Filename"], func() error { + if u.Filename == "" { + return errors.New("Filename不能为空") + } + return nil + }) + return u +} + +func (u *UploadReq) MustTotalChunks() *UploadReq { + u.verificationInit() + u.verification["TotalChunks"] = append(u.verification["TotalChunks"], func() error { + if u.TotalChunks == 0 { + return errors.New("TotalChunks不能为空") + } + return nil + }) + return u +} + +func (u *UploadReq) MustFile() *UploadReq { + u.verificationInit() + u.verification["File"] = append(u.verification["File"], func() error { + if u.File == nil || u.FileHeader == nil { + return errors.New("File不能为空") + } + return nil + }) + return u +} + +func (u *UploadReq) Check() (err error) { + for _, item := range u.verification { + for _, fn := range item { + err = fn() + if err != nil { + return + } + + } + } + return +} + +func (u *UploadReq) Bind(r *http.Request) (err error) { + if r.Header.Get("Content-Type") == "application/json" { + l := r.ContentLength + if l == 0 { + return + } + buf := make([]byte, l) + _, err = r.Body.Read(buf) + + if err != nil && err != io.EOF { + return + } + err = json.Unmarshal(buf, u) + if err != nil { + return + } + + } else { + chunkNumber := r.FormValue("chunkNumber") + if chunkNumber != "" { + u.ChunkNumber, _ = strconv.Atoi(chunkNumber) + } + + chunkSize := r.FormValue("chunkSize") + if chunkSize != "" { + u.ChunkSize, _ = strconv.Atoi(chunkSize) + } + + currentChunkSize := r.FormValue("currentChunkSize") + if currentChunkSize != "" { + u.CurrentChunkSize, _ = strconv.Atoi(currentChunkSize) + } + + totalSize := r.FormValue("totalSize") + if totalSize != "" { + u.TotalSize, _ = strconv.ParseInt(totalSize, 10, 64) + } + + identifier := r.FormValue("identifier") + if identifier != "" { + u.Identifier = identifier + } + + filename := r.FormValue("filename") + if filename != "" { + u.Filename = filename + } + + relativePath := r.FormValue("relativePath") + if relativePath != "" { + u.RelativePath = relativePath + } + + totalChunks := r.FormValue("totalChunks") + if totalChunks != "" { + u.TotalChunks, _ = strconv.Atoi(totalChunks) + } + } + + u.File, u.FileHeader, _ = r.FormFile(FileName) + return +} + +type BaseRes struct { + Filename string `json:"filename"` // 文件名 + TotalSize int64 `json:"totalSize"` // 文件总大小 + Url string `json:"url"` // 上传文件路径 +} + +// 返回前端的相对路径 +func (b *BaseRes) RelativePath() { + _, prefix, suffix := parseFilePath(b.Url) + b.Url = RelativePath + prefix + suffix +} + +type UpLoadRes struct { + BaseRes + NeedMerge bool `json:"needMerge"` // 是否合并文件 + Identifier string `json:"identifier"` // 标识 + TotalChunks int `json:"totalChunks"` // 分片总数 +} + +type CheckRes struct { + SkipUpload bool `json:"skipUpload"` // 秒传 + Uploaded []int `json:"uploaded"` // 已上传过的分片 + BaseRes +} + +func (r *CheckRes) HasUploaded(i int) (ok bool) { + for _, item := range r.Uploaded { + if item == i { + return true + } + } + return +} + +func (r *CheckRes) HasFirst() (ok bool) { + return r.HasUploaded(1) +} + +type MergeRes struct { + BaseRes +} diff --git a/library/upload_chunk/upload_chunk.go b/library/upload_chunk/upload_chunk.go new file mode 100644 index 0000000..bec7656 --- /dev/null +++ b/library/upload_chunk/upload_chunk.go @@ -0,0 +1,309 @@ +package upload_chunk + +import ( + "errors" + "fmt" + "io" + "log" + "mime/multipart" + "os" + "strconv" + "strings" + "sync" +) + +type UploadChunk struct{} + +// 检查分片 +func (u *UploadChunk) CheckChunk(uploadReq UploadReq) (result *CheckRes, err error) { + + err = uploadReq.MustIdentifier().MustTotalChunks().MustFilename().MustTotalSize().Check() + if err != nil { + return + } + identifier, totalChunks, filename, totalSize := uploadReq.Identifier, uploadReq.TotalChunks, uploadReq.Filename, uploadReq.TotalSize + + dir, prefix, suffix := parseFilePath(filename) + _, _, _ = dir, prefix, suffix + + if !strings.Contains(suffix, ".") { + err = errors.New("文件名解析错误") + return + } + + result = &CheckRes{} + + // 秒传 + resultFilePath := u.Tmp() + identifier + suffix + if fileExists(resultFilePath) { + result.SkipUpload = true + result.Url = resultFilePath + result.Filename = filename + result.TotalSize = totalSize + result.RelativePath() + return + } + + // 断点续传 + for i := 1; i <= totalChunks; i++ { + chunkFilePath := u.chunkPath(identifier, strconv.FormatInt(int64(i), 10)) + if fileExists(chunkFilePath) { + result.Uploaded = append(result.Uploaded, i) + } + } + + return +} + +// 合并文件 +func (u *UploadChunk) MergeChunk(uploadReq UploadReq) (result *MergeRes, err error) { + err = uploadReq.MustIdentifier().MustTotalChunks().MustTotalSize().MustFilename().Check() + if err != nil { + return + } + identifier, totalChunks, totalSize, filename := uploadReq.Identifier, uploadReq.TotalChunks, uploadReq.TotalSize, uploadReq.Filename + + _, _, suffix := parseFilePath(filename) + if !strings.Contains(suffix, ".") { + return nil, errors.New("文件名解析错误") + } + + // 合并后的文件 + resultFilePath := u.Tmp() + identifier + suffix + ok, err := createFile(resultFilePath) + if err != nil { + return + } + result = new(MergeRes) + // 文件已存在 + if ok { + result.Url = resultFilePath + result.Filename = filename + result.TotalSize = totalSize + result.RelativePath() + return + } + + // 检查分片文件是否完整 + ok, err = u.checkChunkAll(identifier, totalChunks, totalSize) + if err != nil { + err = fmt.Errorf("分片文件检查错误:%s", err) + return + } + + if !ok { + err = errors.New("分片文件不完整") + return + } + + var chunkSize int64 + var wg sync.WaitGroup + ch := make(chan struct{}, 10) + for i := 1; i <= totalChunks; i++ { + // 分片文件 + filePath := u.chunkPath(identifier, fmt.Sprintf("%d", i)) + if chunkSize == 0 { + fi, _ := os.Stat(filePath) + if chunkSize = fi.Size(); chunkSize == 0 { + err = errors.New("分片文件大小为0") + return + } + } + ch <- struct{}{} + wg.Add(1) + go func(i int) { + defer func() { + <-ch + wg.Done() + }() + uploadChunk := &UploadChunk{} + err = uploadChunk.mergeFile(filePath, resultFilePath, chunkSize*int64(i-1)) + if err != nil { + log.Println(err) + return + } + }(i) + } + wg.Wait() + + result.Url = resultFilePath + result.Filename = filename + result.TotalSize = totalSize + result.RelativePath() + return +} + +// 上传分片文件 +func (u *UploadChunk) Upload(uploadReq UploadReq) (result *UpLoadRes, err error) { + err = uploadReq.MustTotalChunks().MustChunkNumber().MustIdentifier().MustFile().MustTotalSize().MustFilename().Check() + if err != nil { + return + } + totalChunks, chunkNumber, identifier, upFile, filename := uploadReq.TotalChunks, uploadReq.ChunkNumber, uploadReq.Identifier, uploadReq.File, uploadReq.Filename + var fullFilePath string + if totalChunks > 1 { + // 分片文件路径 + fullFilePath = u.chunkPath(identifier, strconv.Itoa(chunkNumber)) + } else { + _, _, suffix := parseFilePath(filename) + if !strings.Contains(suffix, ".") { + return nil, errors.New("文件名解析错误") + } + fullFilePath = u.Tmp() + identifier + suffix + } + + // 创建文件 + ok, err := createFile(fullFilePath) + + if err != nil { + return + } + if ok { + // 文件已经存在 + result = &UpLoadRes{ + BaseRes: BaseRes{ + Filename: uploadReq.Filename, + TotalSize: uploadReq.TotalSize, + Url: fullFilePath, + }, + NeedMerge: totalChunks > 1, + Identifier: uploadReq.Identifier, + TotalChunks: uploadReq.TotalChunks, + } + result.RelativePath() + return + } + + // 打开分片文件 + file, err := os.OpenFile(fullFilePath, os.O_CREATE|os.O_WRONLY, 0666) + if err != nil { + return + } + defer file.Close() + // 文件偏移量 + var fi os.FileInfo + fi, err = os.Stat(fullFilePath) + if err != nil { + return + } + start := fi.Size() + // 写入分片文件 + _, err = u.writeFile(upFile, start, file, start) + if err != nil { + return + } + result = &UpLoadRes{ + BaseRes: BaseRes{ + Filename: uploadReq.Filename, + TotalSize: uploadReq.TotalSize, + Url: fullFilePath, + }, + NeedMerge: totalChunks > 1, + Identifier: uploadReq.Identifier, + TotalChunks: uploadReq.TotalChunks, + } + result.RelativePath() + return +} + +func (u *UploadChunk) Tmp() string { + return Tmp +} + +// 合并文件 +func (u *UploadChunk) mergeFile(chunkFile, mergeFile string, offset int64) (err error) { + + // 合并后的文件 + file, err := os.OpenFile(mergeFile, os.O_CREATE|os.O_WRONLY, os.ModePerm) + if err != nil { + return + } + defer file.Close() + + _, err = file.Seek(offset, 0) + if err != nil { + return + } + // 分片文件 + chunkFileObj, err := os.Open(chunkFile) + if err != nil { + return + } + defer chunkFileObj.Close() + // 写入数据 + data := make([]byte, 1024, 1024) + + for { + tal, e := chunkFileObj.Read(data) + if e == io.EOF { + chunkFileObj.Close() + os.Remove(chunkFile) + break + } + _, e = file.Write(data[:tal]) + if e != nil { + return e + } + } + return +} + +// 检查分片文件是否完整 +func (u *UploadChunk) checkChunkAll(identifier string, totalChunks int, totalSize int64) (ok bool, err error) { + if identifier == "" || totalChunks == 0 { + return false, errors.New("checkChunkAll 参数错误") + } + var _totalSize int64 + for i := 1; i <= totalChunks; i++ { + filePath := u.chunkPath(identifier, fmt.Sprintf("%d", i)) + fi, e := os.Stat(filePath) + if e != nil { + return false, e + } + _totalSize += fi.Size() + } + + return _totalSize == totalSize, nil +} + +// 获取分片文件路径 +func (u *UploadChunk) chunkPath(identifier string, chunkNumber string) string { + return fmt.Sprintf("%s%s", u.Tmp(), getChunkFilename(identifier, chunkNumber)) +} + +// 检查文件完整性 +func (u *UploadChunk) verifyFileSize(fullFilePath string, size int64) (ok bool, err error) { + fi, err := os.Stat(fullFilePath) + if err != nil { + return + } + if fi.Size() == size { + return true, nil + } + return false, nil +} + +// 写入文件 +func (u *UploadChunk) writeFile(upfile multipart.File, upSeek int64, file *os.File, fSeek int64) (result int, err error) { + // 上传文件大小记录 + fileSzie := 0 + // 设置上传偏移量 + upfile.Seek(upSeek, 0) + // 设置文件偏移量 + file.Seek(fSeek, 0) + data := make([]byte, 1024, 1024) + for { + total, e := upfile.Read(data) + if e == io.EOF { + // 文件复制完毕 + break + } + l, e := file.Write(data[:total]) + if e != nil { + return 0, errors.New("文件上传失败") + } + // 记录上传长度 + fileSzie += l + } + return fileSzie, nil +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..785b477 --- /dev/null +++ b/main.go @@ -0,0 +1,16 @@ +package main + +import ( + _ "github.com/gogf/gf/contrib/drivers/mysql/v2" + _ "github.com/gogf/gf/contrib/nosql/redis/v2" + _ "github.com/tiger1103/gfast/v3/internal/app/boot" + + "github.com/gogf/gf/v2/os/gctx" + _ "github.com/tiger1103/gfast/v3/internal/app/system/packed" + "github.com/tiger1103/gfast/v3/internal/cmd" + _ "github.com/tiger1103/gfast/v3/task" +) + +func main() { + cmd.Main.Run(gctx.New()) +} diff --git a/manifest/config/config.yaml.bak b/manifest/config/config.yaml.bak new file mode 100644 index 0000000..82d3c7a --- /dev/null +++ b/manifest/config/config.yaml.bak @@ -0,0 +1,104 @@ +server: + address: ":8808" + serverRoot: "resource/public" + dumpRouterMap: false + routeOverWrite: true + openapiPath: "/api.json" + swaggerPath: "/swagger" + NameToUriType: 3 + maxHeaderBytes: "20KB" + clientMaxBodySize: "50MB" + # Logging配置 + logPath: "resource/log/server" # 日志文件存储目录路径,建议使用绝对路径。默认为空,表示关闭 + logStdout: true # 日志是否输出到终端。默认为true + errorStack: true # 当Server捕获到异常时是否记录堆栈信息到日志中。默认为true + errorLogEnabled: true # 是否记录异常日志信息到日志中。默认为true + errorLogPattern: "error-{Ymd}.log" # 异常错误日志文件格式。默认为"error-{Ymd}.log" + accessLogEnabled: true # 是否记录访问日志。默认为false + accessLogPattern: "access-{Ymd}.log" # 访问日志文件格式。默认为"access-{Ymd}.log" + +logger: + path: "resource/log/run" + file: "{Y-m-d}.log" + level: "all" + stdout: true + +# Database. +database: + logger: + level: "all" + stdout: true + Path: "resource/log/sql" + + default: + link: "mysql:gfast3:gfast333@tcp(192.168.0.212:3306)/gfast-v32?charset=utf8mb4&parseTime=true&loc=Local" + debug: true + charset: "utf8mb4" #数据库编码 + dryRun: false #空跑 + maxIdle: 10 #连接池最大闲置的连接数 + maxOpen: 10 #连接池最大打开的连接数 + maxLifetime: 30 #(单位秒)连接对象可重复使用的时间长度 + +gfToken: + cacheKey: "gfToken:" + timeOut: 10800 + maxRefresh: 5400 + multiLogin: true + encryptKey: "49c54195e750b04e74a8429b17896586" + cacheModel: "redis" + excludePaths: + - "/api/v1/system/login" + +# Redis 配置示例 +redis: + # 单实例配置 + default: + address: 127.0.0.1:6379 + db: 1 + idleTimeout: 600 + maxActive: 100 + +system: + notCheckAuthAdminIds: [1,2,31] #无需验证后台权限的用户id + dataDir: "./resource/data" + cache: + model: "redis" #缓存模式 memory OR redis + prefix: "gFastV3Cache:" #缓存前缀 + +#casbin配置 +casbin: + modelFile: "./resource/casbin/rbac_model.conf" + policyFile: "./resource/casbin/rbac_policy.csv" + + +# CLI. +gfcli: + gen: + dao: + - link: "mysql:gfast3:gfast333@tcp(192.168.0.212:3306)/gfast-v32" + tables: "tools_gen_table,tools_gen_table_column" + removePrefix: "gf_" + descriptionTag: true + noModelComment: true + path: "./internal/app/system" + +# 上传配置 +upload: + default: 0 # 默认上传至本地 + tencentCOS: + upPath : "/gfast/" + rawUrl : "https://xxxxxx.ap-xxxxx.myqcloud.com" + secretID : "xxxxxxxxxx" + secretKey : "xxxxxxxxxx" + +# 代码生成配置 +gen: + author: "gfast" + moduleName: "system" + apiName: "api/v1" + packageName: "internal/app/system" + goModName: "github.com/tiger1103/gfast/v3" + autoRemovePre: true #是否自动删除表前缀 + tablePrefix: "table_,qxkj_" #表前缀 + templatePath: "./resource/template/vm" #代码生成模板路径 + frontDir: "../../../project/webProject/p2022/gfast-v3.2-ui/gfast3.2-ui" #前端路径 \ No newline at end of file diff --git a/manifest/deploy/kustomize/base/deployment.yaml b/manifest/deploy/kustomize/base/deployment.yaml new file mode 100644 index 0000000..28f1d69 --- /dev/null +++ b/manifest/deploy/kustomize/base/deployment.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: template-single + labels: + app: template-single +spec: + replicas: 1 + selector: + matchLabels: + app: template-single + template: + metadata: + labels: + app: template-single + spec: + containers: + - name : main + image: template-single + imagePullPolicy: Always + diff --git a/manifest/deploy/kustomize/base/kustomization.yaml b/manifest/deploy/kustomize/base/kustomization.yaml new file mode 100644 index 0000000..302d92d --- /dev/null +++ b/manifest/deploy/kustomize/base/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- deployment.yaml +- service.yaml + + + diff --git a/manifest/deploy/kustomize/base/service.yaml b/manifest/deploy/kustomize/base/service.yaml new file mode 100644 index 0000000..608771c --- /dev/null +++ b/manifest/deploy/kustomize/base/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: template-single +spec: + ports: + - port: 80 + protocol: TCP + targetPort: 8000 + selector: + app: template-single + diff --git a/manifest/deploy/kustomize/overlays/develop/configmap.yaml b/manifest/deploy/kustomize/overlays/develop/configmap.yaml new file mode 100644 index 0000000..3b1d0af --- /dev/null +++ b/manifest/deploy/kustomize/overlays/develop/configmap.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: template-single-configmap +data: + config.yaml: | + server: + address: ":8000" + openapiPath: "/api.json" + swaggerPath: "/swagger" + + logger: + level : "all" + stdout: true diff --git a/manifest/deploy/kustomize/overlays/develop/deployment.yaml b/manifest/deploy/kustomize/overlays/develop/deployment.yaml new file mode 100644 index 0000000..04e4851 --- /dev/null +++ b/manifest/deploy/kustomize/overlays/develop/deployment.yaml @@ -0,0 +1,10 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: template-single +spec: + template: + spec: + containers: + - name : main + image: template-single:develop \ No newline at end of file diff --git a/manifest/deploy/kustomize/overlays/develop/kustomization.yaml b/manifest/deploy/kustomize/overlays/develop/kustomization.yaml new file mode 100644 index 0000000..4731c47 --- /dev/null +++ b/manifest/deploy/kustomize/overlays/develop/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../base +- configmap.yaml + +patchesStrategicMerge: +- deployment.yaml + +namespace: default + + + diff --git a/manifest/docker/Dockerfile b/manifest/docker/Dockerfile new file mode 100644 index 0000000..399619e --- /dev/null +++ b/manifest/docker/Dockerfile @@ -0,0 +1,19 @@ +FROM loads/alpine:3.8 + +############################################################################### +# INSTALLATION +############################################################################### + +ENV WORKDIR /app + +ADD resource $WORKDIR/ + +ADD ./bin/linux_amd64/main $WORKDIR/main + +RUN chmod +x $WORKDIR/main + +############################################################################### +# START +############################################################################### +WORKDIR $WORKDIR +CMD ./main diff --git a/manifest/docker/docker.sh b/manifest/docker/docker.sh new file mode 100644 index 0000000..ff393f9 --- /dev/null +++ b/manifest/docker/docker.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# This shell is executed before docker build. + + + + + diff --git a/resource/casbin/rbac_model.conf b/resource/casbin/rbac_model.conf new file mode 100644 index 0000000..71159e3 --- /dev/null +++ b/resource/casbin/rbac_model.conf @@ -0,0 +1,14 @@ +[request_definition] +r = sub, obj, act + +[policy_definition] +p = sub, obj, act + +[role_definition] +g = _, _ + +[policy_effect] +e = some(where (p.eft == allow)) + +[matchers] +m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/resource/casbin/rbac_policy.csv b/resource/casbin/rbac_policy.csv new file mode 100644 index 0000000..f93d6df --- /dev/null +++ b/resource/casbin/rbac_policy.csv @@ -0,0 +1,5 @@ +p, alice, data1, read +p, bob, data2, write +p, data2_admin, data2, read +p, data2_admin, data2, write +g, alice, data2_admin \ No newline at end of file diff --git a/resource/data/.gitkeep b/resource/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resource/data/gfast-v32.sql b/resource/data/gfast-v32.sql new file mode 100644 index 0000000..b937505 --- /dev/null +++ b/resource/data/gfast-v32.sql @@ -0,0 +1,1125 @@ +/* + Navicat Premium Data Transfer + + Source Server : localhost + Source Server Type : MySQL + Source Server Version : 50736 + Source Host : localhost:3306 + Source Schema : gfast-v32 + + Target Server Type : MySQL + Target Server Version : 50736 + File Encoding : 65001 + + Date: 16/01/2023 21:12:04 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for big_file +-- ---------------------------- +DROP TABLE IF EXISTS `big_file`; +CREATE TABLE `big_file` ( + `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '文件名称', + `size` int(11) NOT NULL DEFAULT 0 COMMENT '文件大小', + `path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '文件相对路径', + `full_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '文件绝对路径', + `mime_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '文件类型', + `source` tinyint(3) NOT NULL DEFAULT 0 COMMENT '文件来源 0 - 本地,1 - 腾讯云 2 - 七牛云', + `describe` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '描述', + `md5` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'md5', + `created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0, + `updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0, + `created_at` datetime NULL DEFAULT NULL, + `updated_at` datetime NULL DEFAULT NULL, + `deleted_at` datetime NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 39 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of big_file +-- ---------------------------- +INSERT INTO `big_file` VALUES (10, '1.jpg', 14699, 'big_file/4c91375006d4ae881e941a6948337685.jpg', '', 'image/jpeg', 0, '', '4c91375006d4ae881e941a6948337685', 0, 0, '2022-06-15 16:39:31', '2022-06-15 16:39:31', NULL); +INSERT INTO `big_file` VALUES (11, 'yellowicon-cc20.png', 9307, 'big_file/b55ee4f352e34bf7b07481e6da792bbc.png', '', 'image/png', 0, '', 'b55ee4f352e34bf7b07481e6da792bbc', 0, 0, '2022-06-15 16:39:39', '2022-06-15 16:39:39', NULL); +INSERT INTO `big_file` VALUES (12, '测试文档.doc', 10752, 'big_file/b55a440fcdd29779d7e49ec372fcc003.doc', '', 'application/msword', 0, '', 'b55a440fcdd29779d7e49ec372fcc003', 0, 0, '2022-06-15 16:39:39', '2022-06-15 16:39:39', NULL); +INSERT INTO `big_file` VALUES (13, '大文件测试.doc', 114704896, 'big_file/834978ef56f207dd6711b56ccde67a3f.doc', '', 'application/msword', 0, '', '834978ef56f207dd6711b56ccde67a3f', 0, 0, '2022-06-15 16:39:41', '2022-06-15 16:39:41', NULL); +INSERT INTO `big_file` VALUES (14, '1.jpg', 14699, 'big_file/4c91375006d4ae881e941a6948337685.jpg', '', 'image/jpeg', 0, '', '4c91375006d4ae881e941a6948337685', 0, 0, '2022-06-15 16:53:14', '2022-06-15 16:53:14', NULL); +INSERT INTO `big_file` VALUES (15, '03b0d39583f48206768a7534e55bcpng.png', 15926, 'big_file/08803b0d39583f48206768a7534e55bc.png', '', 'image/png', 0, '', '08803b0d39583f48206768a7534e55bc', 0, 0, '2022-06-15 16:53:14', '2022-06-15 16:53:14', NULL); +INSERT INTO `big_file` VALUES (16, '15681693.jfif', 22352, 'big_file/daba796b1f231e7a588fcabf71bc3f60.jfif', '', 'image/jpeg', 0, '', 'daba796b1f231e7a588fcabf71bc3f60', 0, 0, '2022-06-15 16:53:15', '2022-06-15 16:53:15', '2022-06-15 17:35:52'); +INSERT INTO `big_file` VALUES (17, '9.jpg', 489114, 'big_file/e9dac83f6cf1b67a4313ba2e5b3105ee.jpg', '', 'image/jpeg', 0, '', 'e9dac83f6cf1b67a4313ba2e5b3105ee', 0, 0, '2022-06-15 16:53:15', '2022-06-15 16:53:15', '2022-06-15 17:36:07'); +INSERT INTO `big_file` VALUES (18, '6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg', 94425, 'big_file/2116535bcfb26e4c79b48ddde44f4b6f.jpeg', '', 'image/jpeg', 0, '', '2116535bcfb26e4c79b48ddde44f4b6f', 0, 0, '2022-06-15 16:53:15', '2022-06-15 16:53:15', '2022-06-15 17:54:04'); +INSERT INTO `big_file` VALUES (19, 'default_member_bg.jpg', 64744, 'big_file/1890c96c72abfce088e00f6977e41cce.jpg', '', 'image/jpeg', 0, '', '1890c96c72abfce088e00f6977e41cce', 0, 0, '2022-06-15 16:53:15', '2022-06-15 16:53:15', '2022-06-15 17:54:04'); +INSERT INTO `big_file` VALUES (20, 'asdasd', 225922, 'big_file/606d1ca36a2fd8f22567b894e222b5f9.png', '', 'image/png', 0, 'xxxxx', '606d1ca36a2fd8f22567b894e222b5f9', 0, 0, '2022-06-15 16:53:15', '2022-06-16 10:07:54', NULL); +INSERT INTO `big_file` VALUES (21, 'banner.jpg', 273554, 'big_file/13c8164ffeef82f9967eedc3fb4ca4c2.jpg', '', 'image/jpeg', 0, '', '13c8164ffeef82f9967eedc3fb4ca4c2', 0, 0, '2022-06-15 16:53:15', '2022-06-15 16:53:15', NULL); +INSERT INTO `big_file` VALUES (22, 'lanrentuku.com.url', 183, 'big_file/e594b1d1c4ef10654c4bc83ae4a612c0.url', '', '', 0, '', 'e594b1d1c4ef10654c4bc83ae4a612c0', 0, 0, '2022-06-15 16:53:15', '2022-06-15 16:53:15', NULL); +INSERT INTO `big_file` VALUES (23, '6535bcfb26e4c79b48ddde44f4b6fjpeg - 副本.jpeg', 94425, 'big_file/2116535bcfb26e4c79b48ddde44f4b6f.jpeg', '', 'image/jpeg', 0, '', '2116535bcfb26e4c79b48ddde44f4b6f', 0, 0, '2022-06-16 10:11:25', '2022-06-16 10:11:25', NULL); +INSERT INTO `big_file` VALUES (24, '6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg', 94425, 'big_file/2116535bcfb26e4c79b48ddde44f4b6f.jpeg', '', 'image/jpeg', 0, '', '2116535bcfb26e4c79b48ddde44f4b6f', 0, 0, '2022-06-16 10:11:25', '2022-06-16 10:11:25', NULL); +INSERT INTO `big_file` VALUES (25, '大文件测试.doc', 114704896, 'big_file/834978ef56f207dd6711b56ccde67a3f.doc', '', 'application/msword', 0, '', '834978ef56f207dd6711b56ccde67a3f', 0, 0, '2022-06-16 10:12:31', '2022-06-16 10:12:31', NULL); +INSERT INTO `big_file` VALUES (26, '大文件测试 - 副本.doc', 114704896, 'big_file/834978ef56f207dd6711b56ccde67a3f.doc', '', 'application/msword', 0, '', '834978ef56f207dd6711b56ccde67a3f', 0, 0, '2022-06-16 10:12:31', '2022-06-16 10:12:31', NULL); +INSERT INTO `big_file` VALUES (27, '大文件测试.doc', 114704896, 'big_file/834978ef56f207dd6711b56ccde67a3f.doc', '', 'application/msword', 0, '', '834978ef56f207dd6711b56ccde67a3f', 0, 0, '2022-06-16 10:14:05', '2022-06-16 10:14:05', NULL); +INSERT INTO `big_file` VALUES (28, '大文件测试 - 副本.doc', 114704896, 'big_file/834978ef56f207dd6711b56ccde67a3f.doc', '', 'application/msword', 0, '', '834978ef56f207dd6711b56ccde67a3f', 0, 0, '2022-06-16 10:14:11', '2022-06-16 10:14:11', NULL); +INSERT INTO `big_file` VALUES (29, '5a30f58e4bcea.mp4', 1610085, 'big_file/95954f7e187e17655e81c8a3fbea2714.mp4', '', 'video/mp4', 0, '', '95954f7e187e17655e81c8a3fbea2714', 0, 0, '2022-09-05 14:53:48', '2022-09-05 14:53:48', NULL); +INSERT INTO `big_file` VALUES (30, 'blog完整版.zip', 844647, 'big_file/e2431d90c87d5159b4c154578d9c1181.zip', '', 'application/x-zip-compressed', 0, '', 'e2431d90c87d5159b4c154578d9c1181', 0, 0, '2022-09-20 09:56:54', '2022-09-20 09:56:54', '2022-09-20 14:45:42'); +INSERT INTO `big_file` VALUES (31, 'blog完整版.zip', 844647, 'big_file/e2431d90c87d5159b4c154578d9c1181.zip', '', 'application/x-zip-compressed', 0, '', 'e2431d90c87d5159b4c154578d9c1181', 0, 0, '2022-09-20 10:04:52', '2022-09-20 10:04:52', '2022-09-20 14:45:39'); +INSERT INTO `big_file` VALUES (32, 'blog完整版.zip', 844647, 'big_file/e2431d90c87d5159b4c154578d9c1181.zip', '', 'application/x-zip-compressed', 0, '', 'e2431d90c87d5159b4c154578d9c1181', 0, 0, '2022-09-20 10:05:22', '2022-09-20 10:05:22', '2022-09-20 14:45:37'); +INSERT INTO `big_file` VALUES (33, 'jdk-17_windows-x64_bin.zip', 180154345, 'big_file/9af0c44f20e0d4e35df3c05843360b5d.zip', '', 'application/x-zip-compressed', 0, '', '9af0c44f20e0d4e35df3c05843360b5d', 0, 0, '2022-09-20 10:18:33', '2022-09-20 10:18:33', '2022-09-20 14:45:34'); +INSERT INTO `big_file` VALUES (34, 'jdk-17_windows-x64_bin.zip', 180154345, 'big_file/9af0c44f20e0d4e35df3c05843360b5d.zip', '', 'application/x-zip-compressed', 0, '', '9af0c44f20e0d4e35df3c05843360b5d', 0, 0, '2022-09-20 14:44:27', '2022-09-20 14:44:27', '2022-09-20 14:45:32'); +INSERT INTO `big_file` VALUES (35, '软件著作权申请资料.zip', 44262766, 'big_file/1f68856b8d93ada93785bf2136c7f64d.zip', '', 'application/x-zip-compressed', 0, '', '1f68856b8d93ada93785bf2136c7f64d', 0, 0, '2022-10-26 08:37:27', '2022-10-26 08:37:27', NULL); +INSERT INTO `big_file` VALUES (36, '软件著作权申请资料.zip', 44262766, 'big_file/1f68856b8d93ada93785bf2136c7f64d.zip', '', 'application/x-zip-compressed', 0, '', '1f68856b8d93ada93785bf2136c7f64d', 0, 0, '2022-10-26 08:37:45', '2022-10-26 08:37:45', NULL); +INSERT INTO `big_file` VALUES (37, '吸毒人员风险管控后台ui源码.zip', 126472376, 'big_file/ceb83e922fcb093809ae27aa16f358a2.zip', '', 'application/x-zip-compressed', 0, '', 'ceb83e922fcb093809ae27aa16f358a2', 0, 0, '2022-10-26 08:39:19', '2022-10-26 08:39:19', '2022-12-20 11:46:18'); +INSERT INTO `big_file` VALUES (38, '吸毒人员风险管控后端源码.zip', 62820547, 'big_file/96576caf22dbeb2988776a31b96164ef.zip', '', 'application/x-zip-compressed', 0, '', '96576caf22dbeb2988776a31b96164ef', 0, 0, '2022-10-26 08:41:57', '2022-10-26 08:41:57', '2022-12-20 11:46:21'); + +-- ---------------------------- +-- Table structure for casbin_rule +-- ---------------------------- +DROP TABLE IF EXISTS `casbin_rule`; +CREATE TABLE `casbin_rule` ( + `ptype` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `v0` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `v1` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `v2` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `v3` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `v4` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `v5` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of casbin_rule +-- ---------------------------- +INSERT INTO `casbin_rule` VALUES ('p', '1', '27', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '28', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '29', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '30', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '1', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '2', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '3', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '4', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '11', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '10', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '12', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '13', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '14', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '15', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '19', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '20', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '21', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '22', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '23', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '24', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '25', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '26', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('g', 'u_3', '1', '', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('g', 'u_3', '2', '', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '2', '31', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '2', '32', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '2', '34', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('g', 'u_31', '2', '', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '35', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '36', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '1', '37', 'All', '', '', ''); +INSERT INTO `casbin_rule` VALUES ('p', '2', '33', 'All', '', '', ''); + +-- ---------------------------- +-- Table structure for demo_gen +-- ---------------------------- +DROP TABLE IF EXISTS `demo_gen`; +CREATE TABLE `demo_gen` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `demo_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '姓名', + `demo_age` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '年龄', + `classes` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '班级', + `demo_born` datetime NULL DEFAULT NULL COMMENT '出生年月', + `demo_gender` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '性别', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建日期', + `updated_at` datetime NULL DEFAULT NULL COMMENT '修改日期', + `deleted_at` datetime NULL DEFAULT NULL COMMENT '删除日期', + `created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人', + `updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '修改人', + `demo_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态', + `demo_cate` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '分类', + `demo_thumb` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '头像', + `demo_photo` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '相册', + `demo_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '个人描述', + `demo_file` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '相关附件', + `classes_two` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '班级二', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成测试表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of demo_gen +-- ---------------------------- +INSERT INTO `demo_gen` VALUES (4, '张三', 50, '4', '2022-12-20 11:23:36', 1, '2021-08-21 12:07:19', '2022-12-20 11:23:38', NULL, 31, 31, 1, '0,1', 'upload_file/2022-11-11/co9copop81co0gysbz.jpg', '[{\"name\":\"74595d93db72bc45e5f5161ca35f5995.jpg\",\"url\":\"upload_file/2022-12-20/cp6bmkqcyfpc30zh52.jpg\",\"fileType\":\"image/jpeg\",\"size\":62462},{\"name\":\"a222.jpg\",\"url\":\"upload_file/2022-12-20/cp6bmkqcnncsyckbae.jpg\",\"fileType\":\"image/jpeg\",\"size\":25947},{\"name\":\"5b5fd982ce018.jpg\",\"url\":\"upload_file/2022-12-20/cp6bmkqcnncsx40dak.jpg\",\"fileType\":\"image/jpeg\",\"size\":84889}]', '

快乐就好可厉害了夸奖哈啥是利空打击阿松大快乐就好可厉害了夸奖哈啥是利空打击阿松大快乐就好可厉害了夸奖哈啥是利空打击阿松大快乐就好可厉害了夸奖哈啥是利空打击阿松大快乐就好可厉害了夸奖哈啥是利空打击阿松大快乐就好可厉害了夸奖哈啥是利空打击阿松大


', '[{\"name\":\"1.xlsx\",\"url\":\"http://localhost:8808//pub_upload/2021-08-21/cdow7mg24tu4f5yuid.xlsx\",\"fileType\":\"\",\"size\":0},{\"name\":\"楚雄市数据楚雄应用统计表.xls\",\"url\":\"http://localhost:8808//pub_upload/2021-08-21/cdow7rjjzk0wtpk74t.xls\",\"fileType\":\"\",\"size\":0}]', '5'); +INSERT INTO `demo_gen` VALUES (5, '里斯', 0, '5', '2022-12-06 03:03:04', 2, '2022-12-14 16:19:21', '2022-12-20 11:24:13', NULL, 31, 31, 0, '0', 'upload_file/2022-12-20/cp6bni4ojf30sroz55.jpg', '[{\"name\":\"a222.jpg\",\"url\":\"upload_file/2022-12-20/cp6bnmhefzswddxrys.jpg\",\"fileType\":\"image/jpeg\",\"size\":25947},{\"name\":\"a111.jpg\",\"url\":\"upload_file/2022-12-20/cp6bnmhefzswthixpp.jpg\",\"fileType\":\"image/jpeg\",\"size\":104079}]', '

客户机阿斯利康到家啦可是建档立卡

', '[{\"name\":\"5b5fd982ce018.jpg\",\"url\":\"upload_file/2022-12-20/cp69z5ryzgews7ovj7.jpg\",\"fileType\":\"image/jpeg\",\"size\":84889},{\"name\":\"a222.jpg\",\"url\":\"upload_file/2022-12-20/cp6amc8ulju033lhyp.jpg\",\"fileType\":\"image/jpeg\",\"size\":25947},{\"name\":\"a333.jpg\",\"url\":\"upload_file/2022-12-20/cp6amc8ulju0j9yq3d.jpg\",\"fileType\":\"image/jpeg\",\"size\":18381}]', '4'); +INSERT INTO `demo_gen` VALUES (6, '王五', 56, '4', '2022-12-05 15:05:02', 1, '2022-12-15 08:56:00', '2022-12-20 11:24:45', NULL, 31, 31, 1, '1', 'upload_file/2022-12-20/cp6bnyl49axcbedg2y.jpg', '[{\"name\":\"2.jpg\",\"url\":\"upload_file/2022-12-20/cp6bo15yvl9gvzlkok.jpg\",\"fileType\":\"image/jpeg\",\"size\":18618},{\"name\":\"t01b3a5a18109dea24a.jpg\",\"url\":\"upload_file/2022-12-20/cp6bo15yvl9gffm2ar.jpg\",\"fileType\":\"image/jpeg\",\"size\":36537}]', '

个人描述信息

', '[]', '5'); +INSERT INTO `demo_gen` VALUES (7, '赵四', 53, '4', '2022-12-15 10:12:24', 1, '2022-12-15 10:13:53', '2022-12-20 11:25:05', NULL, 31, 31, 1, '1', 'upload_file/2022-12-20/cp6bo5wte6mo0ahvhl.jpg', '[{\"name\":\"t01698c1bc3af22a34b.jpg\",\"url\":\"upload_file/2022-12-20/cp6boael3pk4yhzjlm.jpg\",\"fileType\":\"image/jpeg\",\"size\":21834},{\"name\":\"1.jpg\",\"url\":\"upload_file/2022-12-20/cp6boaelehg0h6gvub.jpg\",\"fileType\":\"image/jpeg\",\"size\":13610}]', '

富文本内容

', '[]', '5'); +INSERT INTO `demo_gen` VALUES (8, '刘涛', 18, '4', '2022-12-15 10:47:23', 1, '2022-12-15 10:49:47', '2022-12-20 11:26:15', NULL, 31, 31, 1, '0', 'upload_file/2022-12-20/cp6boein2zq4uuywuh.jpg', '[{\"name\":\"t01b97b4bd97190d33a.jpg\",\"url\":\"upload_file/2022-12-20/cp6boiffcarkavs1tp.jpg\",\"fileType\":\"image/jpeg\",\"size\":9859}]', '

富文本





', '[{\"name\":\"74595d93db72bc45e5f5161ca35f5995.jpg\",\"url\":\"upload_file/2022-12-15/cp21ptkim0ow0z3iys.jpg\",\"fileType\":\"\",\"size\":0},{\"name\":\"a333.jpg\",\"url\":\"upload_file/2022-12-15/cp21qys54nxwgxzjxg.jpg\",\"fileType\":\"\",\"size\":0}]', '5'); +INSERT INTO `demo_gen` VALUES (9, '刘涛', 18, '4', '2022-12-15 10:47:23', 1, '2022-12-15 10:52:38', '2022-12-15 10:52:38', '2022-12-20 10:02:37', 31, 0, 1, '', 'upload_file/2022-12-15/cp21qt8kek30kh1fej.jpg', '[{\"name\":\"65d3d7ad866394bf86309af1bbba11a3.jpeg\",\"url\":\"http://localhost:8808/upload_file/2022-12-15/cp21plv1zpawhwy53b.jpeg\",\"path\":\"upload_file/2022-12-15/cp21plv1zpawhwy53b.jpeg\"},{\"name\":\"a333.jpg\",\"url\":\"http://localhost:8808/upload_file/2022-12-15/cp21quzjof9wg9cm28.jpg\",\"path\":\"upload_file/2022-12-15/cp21quzjof9wg9cm28.jpg\"}]', '

富文本内容

', '[{\"name\":\"74595d93db72bc45e5f5161ca35f5995.jpg\",\"url\":\"http://localhost:8808/upload_file/2022-12-15/cp21ptkim0ow0z3iys.jpg\",\"path\":\"upload_file/2022-12-15/cp21ptkim0ow0z3iys.jpg\"},{\"name\":\"a333.jpg\",\"url\":\"http://localhost:8808/upload_file/2022-12-15/cp21qys54nxwgxzjxg.jpg\",\"path\":\"upload_file/2022-12-15/cp21qys54nxwgxzjxg.jpg\"}]', '5'); +INSERT INTO `demo_gen` VALUES (10, '刘淼', 25, '4', '2022-12-15 11:03:17', 1, '2022-12-15 11:06:29', '2022-12-15 11:06:29', '2022-12-20 10:02:28', 31, 0, 1, '', 'upload_file/2022-12-15/cp222yx2yjhshflfgx.jpeg', '[{\"name\":\"00300281425_2fbbb18b.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyjdhcwwgowa.jpg\",\"fileType\":\"image/jpeg\",\"size\":87448},{\"name\":\"a111.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejsbp173g.jpg\",\"fileType\":\"image/jpeg\",\"size\":104079},{\"name\":\"a222.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejse0u2xs.jpg\",\"fileType\":\"image/jpeg\",\"size\":25947}]', '

流量卡圣诞节拉克丝的拉克斯基的

', '[{\"name\":\"5b0fac3e20268.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzc58mucz.jpg\",\"fileType\":\"image/jpeg\",\"size\":137811},{\"name\":\"5b5fd982ce018.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzch4dgpt.jpg\",\"fileType\":\"image/jpeg\",\"size\":84889},{\"name\":\"5b5589ebf0af8.png\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzcaun4c4.png\",\"fileType\":\"image/png\",\"size\":105997}]', '5'); +INSERT INTO `demo_gen` VALUES (11, '刘淼', 25, '4', '2022-12-15 11:03:17', 1, '2022-12-15 11:33:49', '2022-12-15 16:42:28', '2022-12-20 10:02:28', 31, 31, 1, '1', 'upload_file/2022-12-15/cp222yx2yjhshflfgx.jpeg', '[{\"name\":\"00300281425_2fbbb18b.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyjdhcwwgowa.jpg\",\"fileType\":\"image/jpeg\",\"size\":87448},{\"name\":\"a111.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejsbp173g.jpg\",\"fileType\":\"image/jpeg\",\"size\":104079},{\"name\":\"t01b97b4bd97190d33a.jpg\",\"url\":\"upload_file/2022-12-15/cp29adtc1nyklqvr9a.jpg\",\"fileType\":\"image/jpeg\",\"size\":9859},{\"name\":\"t01b69a50d3f1ec115b.jpg\",\"url\":\"upload_file/2022-12-15/cp29af4z2178lzkdd3.jpg\",\"fileType\":\"image/jpeg\",\"size\":19040}]', '

aaaaaaaaaaaaaaaaaaaaaaa

', '[{\"name\":\"5b0fac3e20268.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzc58mucz.jpg\",\"fileType\":\"image/jpeg\",\"size\":137811},{\"name\":\"5b5fd982ce018.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzch4dgpt.jpg\",\"fileType\":\"image/jpeg\",\"size\":84889},{\"name\":\"5b5589ebf0af8.png\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzcaun4c4.png\",\"fileType\":\"image/png\",\"size\":105997}]', '5'); +INSERT INTO `demo_gen` VALUES (12, '刘淼', 25, '4', '2022-12-15 11:03:17', 1, '2022-12-15 16:56:16', '2022-12-15 16:56:16', '2022-12-20 10:02:21', 31, 0, 1, '1', 'upload_file/2022-12-15/cp222yx2yjhshflfgx.jpeg', '[{\"name\":\"00300281425_2fbbb18b.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyjdhcwwgowa.jpg\",\"fileType\":\"image/jpeg\",\"size\":87448},{\"name\":\"a111.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejsbp173g.jpg\",\"fileType\":\"image/jpeg\",\"size\":104079},{\"name\":\"a222.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejse0u2xs.jpg\",\"fileType\":\"image/jpeg\",\"size\":25947}]', '

流量卡圣诞节拉克丝的拉克斯基的

', '[{\"name\":\"5b0fac3e20268.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzc58mucz.jpg\",\"fileType\":\"image/jpeg\",\"size\":137811},{\"name\":\"5b5fd982ce018.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzch4dgpt.jpg\",\"fileType\":\"image/jpeg\",\"size\":84889},{\"name\":\"5b5589ebf0af8.png\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzcaun4c4.png\",\"fileType\":\"image/png\",\"size\":105997}]', '5'); +INSERT INTO `demo_gen` VALUES (13, '刘淼', 25, '4', '2022-12-15 11:03:17', 1, '2022-12-15 16:56:17', '2022-12-18 14:16:56', '2022-12-20 10:02:15', 31, 31, 1, '1,0', 'upload_file/2022-12-15/cp222yx2yjhshflfgx.jpeg', '[{\"name\":\"00300281425_2fbbb18b.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyjdhcwwgowa.jpg\",\"fileType\":\"image/jpeg\",\"size\":87448},{\"name\":\"a111.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejsbp173g.jpg\",\"fileType\":\"image/jpeg\",\"size\":104079},{\"name\":\"t01b97b4bd97190d33a.jpg\",\"url\":\"upload_file/2022-12-15/cp2a2juhxyq0ehrr0s.jpg\",\"fileType\":\"image/jpeg\",\"size\":9859}]', '

流量卡圣诞节拉克丝的拉克54656斯基的

\"5b5fd982ce018.jpg\"/


', '[{\"name\":\"5b0fac3e20268.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzc58mucz.jpg\",\"fileType\":\"image/jpeg\",\"size\":137811},{\"name\":\"5b5fd982ce018.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzch4dgpt.jpg\",\"fileType\":\"image/jpeg\",\"size\":84889},{\"name\":\"2.jpg\",\"url\":\"upload_file/2022-12-15/cp2ajn91urfchlqi1e.jpg\",\"fileType\":\"image/jpeg\",\"size\":18618}]', '5'); +INSERT INTO `demo_gen` VALUES (14, '刘淼', 25, '4', '2022-12-15 11:03:17', 1, '2022-12-15 16:56:18', '2022-12-15 16:56:18', '2022-12-20 10:02:07', 31, 0, 1, '1', 'upload_file/2022-12-15/cp222yx2yjhshflfgx.jpeg', '[{\"name\":\"00300281425_2fbbb18b.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyjdhcwwgowa.jpg\",\"fileType\":\"image/jpeg\",\"size\":87448},{\"name\":\"a111.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejsbp173g.jpg\",\"fileType\":\"image/jpeg\",\"size\":104079},{\"name\":\"a222.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejse0u2xs.jpg\",\"fileType\":\"image/jpeg\",\"size\":25947}]', '

流量卡圣诞节拉克丝的拉克斯基的

', '[{\"name\":\"5b0fac3e20268.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzc58mucz.jpg\",\"fileType\":\"image/jpeg\",\"size\":137811},{\"name\":\"5b5fd982ce018.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzch4dgpt.jpg\",\"fileType\":\"image/jpeg\",\"size\":84889},{\"name\":\"5b5589ebf0af8.png\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzcaun4c4.png\",\"fileType\":\"image/png\",\"size\":105997}]', '5'); +INSERT INTO `demo_gen` VALUES (15, '刘淼', 25, '4', '2022-12-15 11:03:17', 1, '2022-12-15 16:56:19', '2022-12-15 16:56:19', '2022-12-20 10:02:07', 31, 0, 1, '1', 'upload_file/2022-12-15/cp222yx2yjhshflfgx.jpeg', '[{\"name\":\"00300281425_2fbbb18b.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyjdhcwwgowa.jpg\",\"fileType\":\"image/jpeg\",\"size\":87448},{\"name\":\"a111.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejsbp173g.jpg\",\"fileType\":\"image/jpeg\",\"size\":104079},{\"name\":\"a222.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejse0u2xs.jpg\",\"fileType\":\"image/jpeg\",\"size\":25947}]', '

流量卡圣诞节拉克丝的拉克斯基的

', '[{\"name\":\"5b0fac3e20268.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzc58mucz.jpg\",\"fileType\":\"image/jpeg\",\"size\":137811},{\"name\":\"5b5fd982ce018.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzch4dgpt.jpg\",\"fileType\":\"image/jpeg\",\"size\":84889},{\"name\":\"5b5589ebf0af8.png\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzcaun4c4.png\",\"fileType\":\"image/png\",\"size\":105997}]', '5'); +INSERT INTO `demo_gen` VALUES (16, '刘淼', 25, '4', '2022-12-15 11:03:17', 1, '2022-12-15 16:56:19', '2022-12-15 16:56:19', '2022-12-20 10:02:07', 31, 0, 1, '1', 'upload_file/2022-12-15/cp222yx2yjhshflfgx.jpeg', '[{\"name\":\"00300281425_2fbbb18b.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyjdhcwwgowa.jpg\",\"fileType\":\"image/jpeg\",\"size\":87448},{\"name\":\"a111.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejsbp173g.jpg\",\"fileType\":\"image/jpeg\",\"size\":104079},{\"name\":\"a222.jpg\",\"url\":\"upload_file/2022-12-15/cp2230vyuejse0u2xs.jpg\",\"fileType\":\"image/jpeg\",\"size\":25947}]', '

流量卡圣诞节拉克丝的拉克斯基的

', '[{\"name\":\"5b0fac3e20268.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzc58mucz.jpg\",\"fileType\":\"image/jpeg\",\"size\":137811},{\"name\":\"5b5fd982ce018.jpg\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzch4dgpt.jpg\",\"fileType\":\"image/jpeg\",\"size\":84889},{\"name\":\"5b5589ebf0af8.png\",\"url\":\"upload_file/2022-12-15/cp2237cm8pzcaun4c4.png\",\"fileType\":\"image/png\",\"size\":105997}]', '5'); +INSERT INTO `demo_gen` VALUES (17, '大头', 26, '4', '2023-01-06 00:00:00', 1, '2023-01-06 18:06:50', '2023-01-06 18:06:50', NULL, 31, 0, 1, '0', 'upload_file/2023-01-06/cpl0u24gle003jcdpj.jpg', '[{\"name\":\"74595d93db72bc45e5f5161ca35f5995.jpg\",\"url\":\"upload_file/2023-01-06/cpl0u37j3ag4bdc0bi.jpg\",\"fileType\":\"image/jpeg\",\"size\":62462}]', '

啊实打实的

', '[]', '5'); + +-- ---------------------------- +-- Table structure for demo_gen_class +-- ---------------------------- +DROP TABLE IF EXISTS `demo_gen_class`; +CREATE TABLE `demo_gen_class` ( + `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '分类id', + `class_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '分类名', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成关联测试表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of demo_gen_class +-- ---------------------------- +INSERT INTO `demo_gen_class` VALUES (4, '一班'); +INSERT INTO `demo_gen_class` VALUES (5, '二班'); + +-- ---------------------------- +-- Table structure for demo_gen_other +-- ---------------------------- +DROP TABLE IF EXISTS `demo_gen_other`; +CREATE TABLE `demo_gen_other` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', + `info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '内容', + `img` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '单图', + `imgs` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '多图', + `file` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '单文件', + `files` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '多文件', + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '特殊字段测试' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of demo_gen_other +-- ---------------------------- +INSERT INTO `demo_gen_other` VALUES (9, '

khash喀什打开就是的埃里克森

\n\n

的拉卡市的案例咯技术的

\n\n

\"\"

\n', 'pub_upload/2021-08-12/cdhcvhxq38u8xbjcfd.jpg', '[{\"name\":\"5b5fd982ce018.jpg\",\"status\":\"success\",\"uid\":1628753354094,\"url\":\"pub_upload/2021-08-12/cdhcvjhlcdvcolnz7t.jpg\"},{\"name\":\"111.jpg\",\"status\":\"success\",\"uid\":1628753354095,\"url\":\"pub_upload/2021-08-12/cdhcvlav6u3oiwnybe.jpg\"}]', '[{\"name\":\"5b0fac3e20268.jpg\",\"status\":\"success\",\"uid\":1628753358537,\"url\":\"pub_upload/2021-08-12/cdhcvncc4gikxrqnh1.jpg\"}]', '[{\"name\":\"5b0fac3e20268.jpg\",\"status\":\"success\",\"uid\":1628753365149,\"url\":\"pub_upload/2021-08-12/cdhcvow3zq4g9zdqze.jpg\"},{\"name\":\"5b5fd982ce018.jpg\",\"status\":\"success\",\"uid\":1628753365150,\"url\":\"pub_upload/2021-08-12/cdhcvqdnyl9opkyu9p.jpg\"}]', 'asdasdasd'); + +-- ---------------------------- +-- Table structure for demo_gen_tree +-- ---------------------------- +DROP TABLE IF EXISTS `demo_gen_tree`; +CREATE TABLE `demo_gen_tree` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `parent_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '父级ID', + `demo_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '姓名', + `demo_age` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '年龄', + `classes` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '班级', + `demo_born` datetime NULL DEFAULT NULL COMMENT '出生年月', + `demo_gender` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '性别', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建日期', + `updated_at` datetime NULL DEFAULT NULL COMMENT '修改日期', + `deleted_at` datetime NULL DEFAULT NULL COMMENT '删除日期', + `created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人', + `updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '修改人', + `demo_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态', + `demo_cate` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '分类', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成树形结构测试表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of demo_gen_tree +-- ---------------------------- +INSERT INTO `demo_gen_tree` VALUES (1, 0, '张三', 20, '4', '2021-08-23 00:00:00', 1, '2021-08-04 11:54:21', '2022-12-20 11:33:01', NULL, 31, 31, 1, '0'); +INSERT INTO `demo_gen_tree` VALUES (2, 1, '李四', 28, '5', '2021-08-24 00:00:00', 1, '2021-08-04 11:54:38', '2022-12-20 11:33:05', NULL, 31, 31, 0, '0'); +INSERT INTO `demo_gen_tree` VALUES (3, 0, '王五', 63, '5', '2021-08-17 00:00:00', 1, '2021-08-04 11:54:56', '2022-12-20 11:33:18', NULL, 31, 31, 1, '0'); +INSERT INTO `demo_gen_tree` VALUES (4, 3, '小小', 65, '4', '2021-08-24 00:00:00', 1, '2021-08-04 15:51:55', '2022-12-20 11:33:21', NULL, 31, 31, 0, '0'); +INSERT INTO `demo_gen_tree` VALUES (5, 3, '麻花', 23, '5', NULL, 2, '2021-08-04 15:52:13', '2022-12-20 11:33:26', NULL, 31, 31, 1, '0'); +INSERT INTO `demo_gen_tree` VALUES (6, 2, 'xxx', 232, '4', '2021-08-21 00:00:00', 123, '2021-08-21 12:11:53', '2022-12-20 11:33:14', NULL, 31, 31, 1, '123123'); + +-- ---------------------------- +-- Table structure for sys_auth_rule +-- ---------------------------- +DROP TABLE IF EXISTS `sys_auth_rule`; +CREATE TABLE `sys_auth_rule` ( + `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `pid` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '父ID', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '规则名称', + `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '规则名称', + `icon` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '图标', + `condition` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '条件', + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '备注', + `menu_type` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '类型 0目录 1菜单 2按钮', + `weigh` int(10) NOT NULL DEFAULT 0 COMMENT '权重', + `is_hide` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '显示状态', + `path` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '路由地址', + `component` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '组件路径', + `is_link` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否外链 1是 0否', + `module_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '所属模块', + `model_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '模型ID', + `is_iframe` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否内嵌iframe', + `is_cached` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否缓存', + `redirect` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '路由重定向地址', + `is_affix` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否固定', + `link_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '链接地址', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建日期', + `updated_at` datetime NULL DEFAULT NULL COMMENT '修改日期', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `name`(`name`) USING BTREE, + INDEX `pid`(`pid`) USING BTREE, + INDEX `weigh`(`weigh`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 59 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单节点表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_auth_rule +-- ---------------------------- +INSERT INTO `sys_auth_rule` VALUES (1, 0, 'api/v1/system/auth', '权限管理', 'ele-Stamp', '', '', 0, 30, 0, '/system/auth', 'layout/routerView/parent', 0, '', 0, 0, 1, '0', 0, '', '2022-03-24 15:03:37', '2022-04-14 16:29:19'); +INSERT INTO `sys_auth_rule` VALUES (2, 1, 'api/v1/system/auth/menuList', '菜单管理', 'ele-Calendar', '', '', 1, 0, 0, '/system/auth/menuList', 'system/menu/index', 0, '', 0, 0, 1, '', 0, '', '2022-03-24 17:24:13', '2022-03-29 10:54:49'); +INSERT INTO `sys_auth_rule` VALUES (3, 2, 'api/v1/system/menu/add', '添加菜单', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-03-29 16:48:43', '2022-03-29 17:05:19'); +INSERT INTO `sys_auth_rule` VALUES (4, 2, 'api/v1/system/menu/update', '修改菜单', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-03-29 17:04:25', '2022-03-29 18:11:36'); +INSERT INTO `sys_auth_rule` VALUES (10, 1, 'api/v1/system/role/list', '角色管理', 'iconfont icon-juxingkaobei', '', '', 1, 0, 0, '/system/auth/roleList', 'system/role/index', 0, '', 0, 0, 1, '', 0, '', '2022-03-29 18:15:03', '2022-03-30 10:25:34'); +INSERT INTO `sys_auth_rule` VALUES (11, 2, 'api/v1/system/menu/delete', '删除菜单', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-06 14:49:10', '2022-04-06 14:49:17'); +INSERT INTO `sys_auth_rule` VALUES (12, 10, 'api/v1/system/role/add', '添加角色', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-06 14:49:46', '2022-04-06 14:49:46'); +INSERT INTO `sys_auth_rule` VALUES (13, 10, '/api/v1/system/role/edit', '修改角色', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-06 14:50:08', '2022-04-06 14:50:08'); +INSERT INTO `sys_auth_rule` VALUES (14, 10, '/api/v1/system/role/delete', '删除角色', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-06 14:50:22', '2022-04-06 14:50:22'); +INSERT INTO `sys_auth_rule` VALUES (15, 1, 'api/v1/system/dept/list', '部门管理', 'iconfont icon-siweidaotu', '', '', 1, 0, 0, '/system/auth/deptList', 'system/dept/index', 0, '', 0, 0, 1, '', 0, '', '2022-04-06 14:52:23', '2022-04-07 22:59:20'); +INSERT INTO `sys_auth_rule` VALUES (16, 17, 'aliyun', '阿里云-iframe', 'iconfont icon-diannao1', '', '', 1, 0, 0, '/demo/outLink/aliyun', 'layout/routerView/iframes', 1, '', 0, 1, 1, '', 0, 'https://www.aliyun.com/daily-act/ecs/activity_selection?spm=5176.8789780.J_3965641470.5.568845b58KHj51', '2022-04-06 17:26:29', '2022-04-07 15:27:17'); +INSERT INTO `sys_auth_rule` VALUES (17, 0, 'outLink', '外链测试', 'iconfont icon-zhongduancanshu', '', '', 0, 20, 0, '/demo/outLink', 'layout/routerView/parent', 0, '', 0, 0, 1, '', 0, '', '2022-04-07 15:20:51', '2022-04-14 16:29:07'); +INSERT INTO `sys_auth_rule` VALUES (18, 17, 'tenyun', '腾讯云-外链', 'iconfont icon-shouye_dongtaihui', '', '', 1, 0, 0, '/demo/outLink/tenyun', 'layout/routerView/link', 1, '', 0, 0, 1, '', 0, 'https://cloud.tencent.com/act/new?cps_key=20b1c3842f74986b2894e2c5fcde7ea2&fromSource=gwzcw.3775555.3775555.3775555&utm_id=gwzcw.3775555.3775555.3775555&utm_medium=cpc', '2022-04-07 15:23:52', '2022-04-07 15:27:25'); +INSERT INTO `sys_auth_rule` VALUES (19, 15, 'api/v1/system/dept/add', '添加部门', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-07 22:56:39', '2022-04-07 22:56:39'); +INSERT INTO `sys_auth_rule` VALUES (20, 15, 'api/v1/system/dept/edit', '修改部门', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-07 22:57:00', '2022-04-07 22:57:00'); +INSERT INTO `sys_auth_rule` VALUES (21, 15, 'api/v1/system/dept/delete', '删除部门', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-07 22:57:30', '2022-04-07 22:57:30'); +INSERT INTO `sys_auth_rule` VALUES (22, 1, 'api/v1/system/post/list', '岗位管理', 'iconfont icon-neiqianshujuchucun', '', '', 1, 0, 0, '/system/auth/postList', 'system/post/index', 0, '', 0, 0, 1, '', 0, '', '2022-04-07 22:58:46', '2022-04-09 14:26:15'); +INSERT INTO `sys_auth_rule` VALUES (23, 22, 'api/v1/system/post/add', '添加岗位', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-09 14:14:49', '2022-04-09 14:14:49'); +INSERT INTO `sys_auth_rule` VALUES (24, 22, 'api/v1/system/post/edit', '修改岗位', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-09 14:15:25', '2022-04-09 14:15:25'); +INSERT INTO `sys_auth_rule` VALUES (25, 22, 'api/v1/system/post/delete', '删除岗位', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2022-04-09 14:15:47', '2022-04-09 14:15:47'); +INSERT INTO `sys_auth_rule` VALUES (26, 1, 'api/v1/system/user/list', '用户管理', 'ele-User', '', '', 1, 0, 0, '/system/auth/user/list', 'system/user/index', 0, '', 0, 0, 1, '', 0, '', '2022-04-09 14:19:10', '2022-04-09 14:19:58'); +INSERT INTO `sys_auth_rule` VALUES (27, 0, 'api/v1/system/dict', '系统配置', 'iconfont icon-shuxingtu', '', '', 0, 40, 0, '/system/dict', 'layout/routerView/parent', 0, '', 0, 0, 1, '654', 0, '', '2022-04-14 16:28:51', '2022-04-18 14:40:56'); +INSERT INTO `sys_auth_rule` VALUES (28, 27, 'api/v1/system/dict/type/list', '字典管理', 'iconfont icon-crew_feature', '', '', 1, 0, 0, '/system/dict/type/list', 'system/dict/index', 0, '', 0, 0, 1, '', 0, '', '2022-04-14 16:32:10', '2022-04-16 17:02:50'); +INSERT INTO `sys_auth_rule` VALUES (29, 27, 'api/v1/system/dict/dataList', '字典数据管理', 'iconfont icon-putong', '', '', 1, 0, 1, '/system/dict/data/list/:dictType', 'system/dict/dataList', 0, '', 0, 0, 1, '', 0, '', '2022-04-18 12:04:17', '2022-04-18 14:58:43'); +INSERT INTO `sys_auth_rule` VALUES (30, 27, 'api/v1/system/config/list', '参数管理', 'ele-Cherry', '', '', 1, 0, 0, '/system/config/list', 'system/config/index', 0, '', 0, 0, 1, '', 0, '', '2022-04-18 21:05:20', '2022-04-18 21:13:19'); +INSERT INTO `sys_auth_rule` VALUES (31, 0, 'api/v1/system/monitor', '系统监控', 'iconfont icon-xuanzeqi', '', '', 0, 30, 0, '/system/monitor', 'layout/routerView/parent', 0, '', 0, 0, 1, '', 0, '', '2022-04-19 10:40:19', '2022-04-19 10:44:38'); +INSERT INTO `sys_auth_rule` VALUES (32, 31, 'api/v1/system/monitor/server', '服务监控', 'iconfont icon-shuju', '', '', 1, 0, 0, '/system/monitor/server', 'system/monitor/server/index', 0, '', 0, 0, 1, '', 0, '', '2022-04-19 10:43:32', '2022-04-19 10:44:47'); +INSERT INTO `sys_auth_rule` VALUES (33, 35, 'api/swagger', 'api文档', 'iconfont icon--chaifenlie', '', '', 1, 0, 0, '/system/swagger', 'layout/routerView/iframes', 1, '', 0, 1, 1, '', 0, 'http://localhost:8808/swagger', '2022-04-21 09:23:43', '2022-11-29 17:10:35'); +INSERT INTO `sys_auth_rule` VALUES (34, 31, 'api/v1/system/loginLog/list', '登录日志', 'ele-Finished', '', '', 1, 0, 0, '/system/monitor/loginLog', 'system/monitor/loginLog/index', 0, '', 0, 0, 1, '', 0, '', '2022-04-28 09:59:47', '2022-04-28 09:59:47'); +INSERT INTO `sys_auth_rule` VALUES (35, 0, 'api/v1/system/tools', '系统工具', 'iconfont icon-zujian', '', '', 0, 25, 0, '/system/tools', 'layout/routerView/parent', 0, '', 0, 0, 1, '', 0, '', '2022-10-26 09:29:08', '2022-10-26 10:11:25'); +INSERT INTO `sys_auth_rule` VALUES (36, 35, 'api/v1/system/tools/gen/tableList', '代码生成', 'iconfont icon-step', '', '', 1, 0, 0, '/system/tools/gen', 'system/tools/gen/index', 0, '', 0, 0, 1, '', 0, '', '2022-10-26 09:31:08', '2022-10-31 10:17:23'); +INSERT INTO `sys_auth_rule` VALUES (37, 36, 'api/v1/system/tools/gen/columnList', '代码生成配置', 'ele-Edit', '', '', 1, 0, 1, '/system/tools/gen/edit', 'system/tools/gen/component/edit', 0, '', 0, 0, 1, '', 0, '', '2022-10-31 10:11:12', '2022-10-31 10:19:19'); +INSERT INTO `sys_auth_rule` VALUES (38, 31, 'api/v1/system/operLog/list', '操作日志', 'iconfont icon-bolangnengshiyanchang', '', '', 1, 0, 0, '/system/monitor/operLog', 'system/monitor/operLog/index', 0, '', 0, 0, 1, '', 0, '', '2022-12-23 16:19:05', '2022-12-23 16:21:50'); +INSERT INTO `sys_auth_rule` VALUES (39, 31, 'api/v1/system/online/list', '在线用户', 'iconfont icon-skin', '', '', 1, 0, 0, '/system/monitor/userOnlie', 'system/monitor/userOnline/index', 0, '', 0, 0, 1, '', 0, '', '2023-01-11 15:48:06', '2023-01-11 17:02:39'); +INSERT INTO `sys_auth_rule` VALUES (53, 35, 'api/v1/system/sysJob/list', '定时任务', 'fa fa-superpowers', '', '', 1, 0, 0, '/system/sysJob/list', 'system/sysJob/list/index', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, '2023-01-12 17:51:27'); +INSERT INTO `sys_auth_rule` VALUES (54, 53, 'api/v1/system/sysJob/get', '定时任务查询', '', '', '定时任务查询', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL); +INSERT INTO `sys_auth_rule` VALUES (55, 53, 'api/v1/system/sysJob/add', '定时任务添加', '', '', '定时任务添加', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL); +INSERT INTO `sys_auth_rule` VALUES (56, 53, 'api/v1/system/sysJob/edit', '定时任务修改', '', '', '定时任务修改', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL); +INSERT INTO `sys_auth_rule` VALUES (57, 53, 'api/v1/system/sysJob/delete', '定时任务删除', '', '', '定时任务删除', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL); +INSERT INTO `sys_auth_rule` VALUES (58, 53, 'api/v1/system/sysJob/run', '执行一次', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2023-01-12 18:20:13', '2023-01-12 18:20:13'); + +-- ---------------------------- +-- Table structure for sys_config +-- ---------------------------- +DROP TABLE IF EXISTS `sys_config`; +CREATE TABLE `sys_config` ( + `config_id` int(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '参数主键', + `config_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数名称', + `config_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数键名', + `config_value` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数键值', + `config_type` tinyint(1) NULL DEFAULT 0 COMMENT '系统内置(Y是 N否)', + `create_by` int(64) UNSIGNED NULL DEFAULT 0 COMMENT '创建者', + `update_by` int(64) UNSIGNED NULL DEFAULT 0 COMMENT '更新者', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建时间', + `updated_at` datetime NULL DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`config_id`) USING BTREE, + UNIQUE INDEX `uni_config_key`(`config_key`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_config +-- ---------------------------- +INSERT INTO `sys_config` VALUES (1, '文件上传-文件大小', 'sys.uploadFile.fileSize', '50M', 1, 31, 31, '文件上传大小限制', NULL, '2021-07-06 14:57:35'); +INSERT INTO `sys_config` VALUES (2, '文件上传-文件类型', 'sys.uploadFile.fileType', 'doc,docx,zip,xls,xlsx,rar,jpg,jpeg,gif,npm,png,mp4', 1, 31, 31, '文件上传后缀类型限制', NULL, '2022-12-16 09:52:45'); +INSERT INTO `sys_config` VALUES (3, '图片上传-图片类型', 'sys.uploadFile.imageType', 'jpg,jpeg,gif,npm,png', 1, 31, 0, '图片上传后缀类型限制', NULL, NULL); +INSERT INTO `sys_config` VALUES (4, '图片上传-图片大小', 'sys.uploadFile.imageSize', '50M', 1, 31, 31, '图片上传大小限制', NULL, NULL); +INSERT INTO `sys_config` VALUES (11, '静态资源', 'static.resource', '/', 1, 2, 0, '', NULL, NULL); + +-- ---------------------------- +-- Table structure for sys_dept +-- ---------------------------- +DROP TABLE IF EXISTS `sys_dept`; +CREATE TABLE `sys_dept` ( + `dept_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '部门id', + `parent_id` bigint(20) NULL DEFAULT 0 COMMENT '父部门id', + `ancestors` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '祖级列表', + `dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '部门名称', + `order_num` int(4) NULL DEFAULT 0 COMMENT '显示顺序', + `leader` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '负责人', + `phone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系电话', + `email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱', + `status` tinyint(3) UNSIGNED NULL DEFAULT 0 COMMENT '部门状态(0正常 1停用)', + `created_by` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '创建人', + `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '修改人', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建时间', + `updated_at` datetime NULL DEFAULT NULL COMMENT '修改时间', + `deleted_at` datetime NULL DEFAULT NULL COMMENT '删除时间', + PRIMARY KEY (`dept_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 204 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '部门表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_dept +-- ---------------------------- +INSERT INTO `sys_dept` VALUES (100, 0, '0', '奇讯科技', 0, NULL, '15888888888', 'ry@qq.com', 1, 0, 31, '2021-07-13 15:56:52', '2021-07-13 15:57:05', NULL); +INSERT INTO `sys_dept` VALUES (101, 100, '0,100', '深圳总公司', 1, NULL, '15888888888', 'ry@qq.com', 1, 0, NULL, '2021-07-13 15:56:52', '2021-07-13 15:56:52', NULL); +INSERT INTO `sys_dept` VALUES (102, 100, '0,100', '长沙分公司', 2, NULL, '15888888888', 'ry@qq.com', 1, 0, NULL, '2021-07-13 15:56:52', '2021-07-13 15:56:52', NULL); +INSERT INTO `sys_dept` VALUES (103, 101, '0,100,101', '研发部门', 1, NULL, '15888888888', 'ry@qq.com', 1, 0, NULL, '2021-07-13 15:56:52', '2021-07-13 15:56:52', NULL); +INSERT INTO `sys_dept` VALUES (104, 101, '0,100,101', '市场部门', 2, NULL, '15888888888', 'ry@qq.com', 1, 0, 31, '2021-07-13 15:56:52', '2021-11-04 09:16:38', NULL); +INSERT INTO `sys_dept` VALUES (105, 101, '0,100,101', '测试部门', 3, NULL, '15888888888', 'ry@qq.com', 1, 0, NULL, '2021-07-13 15:56:52', '2021-07-13 15:56:52', NULL); +INSERT INTO `sys_dept` VALUES (106, 101, '0,100,101', '财务部门', 4, NULL, '15888888888', 'ry@qq.com', 1, 0, NULL, '2021-07-13 15:56:52', '2021-07-13 15:56:52', NULL); +INSERT INTO `sys_dept` VALUES (107, 101, '0,100,101', '运维部门', 5, NULL, '15888888888', 'ry@qq.com', 1, 0, NULL, '2021-07-13 15:56:52', '2021-07-13 15:56:52', NULL); +INSERT INTO `sys_dept` VALUES (108, 102, '0,100,102', '市场部门', 1, NULL, '15888888888', 'ry@qq.com', 1, 0, NULL, '2021-07-13 15:56:52', '2021-07-13 15:56:52', NULL); +INSERT INTO `sys_dept` VALUES (109, 102, '0,100,102', '财务部门', 2, NULL, '15888888888', 'ry@qq.com', 1, 0, NULL, '2021-07-13 15:56:52', '2021-07-13 15:56:52', NULL); +INSERT INTO `sys_dept` VALUES (200, 100, '', '大数据', 1, '', '18888888888', 'liou@qq.com', 0, 0, 31, '2021-07-13 15:56:52', '2022-09-16 16:46:57', NULL); +INSERT INTO `sys_dept` VALUES (201, 100, '', '开发', 1, NULL, '18888888888', 'li@qq.com', 0, 31, NULL, '2021-07-13 15:56:52', '2022-04-07 22:35:21', NULL); +INSERT INTO `sys_dept` VALUES (202, 108, '', '外勤', 1, NULL, '18888888888', 'aa@qq.com', 1, 0, NULL, '2021-07-13 15:56:52', '2021-07-13 15:56:52', NULL); +INSERT INTO `sys_dept` VALUES (203, 108, '', '行政', 0, '', '18888888888', 'aa@qq.com', 1, 0, 31, '2021-07-13 15:56:52', '2022-09-16 16:46:47', NULL); + +-- ---------------------------- +-- Table structure for sys_dict_data +-- ---------------------------- +DROP TABLE IF EXISTS `sys_dict_data`; +CREATE TABLE `sys_dict_data` ( + `dict_code` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '字典编码', + `dict_sort` int(4) NULL DEFAULT 0 COMMENT '字典排序', + `dict_label` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典标签', + `dict_value` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典键值', + `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型', + `css_class` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '样式属性(其他样式扩展)', + `list_class` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '表格回显样式', + `is_default` tinyint(1) NULL DEFAULT 0 COMMENT '是否默认(1是 0否)', + `status` tinyint(1) NULL DEFAULT 0 COMMENT '状态(0正常 1停用)', + `create_by` bigint(64) UNSIGNED NULL DEFAULT 0 COMMENT '创建者', + `update_by` bigint(64) UNSIGNED NULL DEFAULT 0 COMMENT '更新者', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建时间', + `updated_at` datetime NULL DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`dict_code`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 106 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '字典数据表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_dict_data +-- ---------------------------- +INSERT INTO `sys_dict_data` VALUES (1, 0, '男', '1', 'sys_user_sex', '', '', 0, 1, 31, 2, '备注信息', '2022-04-18 16:46:22', NULL); +INSERT INTO `sys_dict_data` VALUES (2, 0, '女', '2', 'sys_user_sex', '', '', 0, 1, 31, 31, '备注信息', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (3, 0, '保密', '0', 'sys_user_sex', '', '', 1, 1, 31, 31, '备注信息', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (24, 0, '频道页', '1', 'cms_category_type', '', '', 0, 1, 31, 31, '作为频道页,不可作为栏目发布文章,可添加下级分类', NULL, '2021-07-21 10:54:22'); +INSERT INTO `sys_dict_data` VALUES (25, 0, '发布栏目', '2', 'cms_category_type', '', '', 0, 1, 31, 31, '作为发布栏目,可添加文章', NULL, '2021-07-21 10:54:22'); +INSERT INTO `sys_dict_data` VALUES (26, 0, '跳转栏目', '3', 'cms_category_type', '', '', 0, 1, 31, 31, '不直接发布内容,用于跳转页面', NULL, '2021-07-21 10:54:22'); +INSERT INTO `sys_dict_data` VALUES (27, 0, '单页栏目', '4', 'cms_category_type', '', '', 0, 1, 31, 31, '单页面模式,分类直接显示为文章', NULL, '2021-07-21 10:54:22'); +INSERT INTO `sys_dict_data` VALUES (28, 0, '正常', '0', 'sys_job_status', '', 'default', 1, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (29, 0, '暂停', '1', 'sys_job_status', '', 'default', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (30, 0, '默认', 'DEFAULT', 'sys_job_group', '', 'default', 1, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (31, 0, '系统', 'SYSTEM', 'sys_job_group', '', 'default', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (32, 0, '成功', '1', 'admin_login_status', '', 'default', 0, 1, 31, 31, '', NULL, '2022-09-16 15:26:01'); +INSERT INTO `sys_dict_data` VALUES (33, 0, '失败', '0', 'admin_login_status', '', 'default', 0, 1, 31, 0, '', NULL, '2022-09-16 15:26:01'); +INSERT INTO `sys_dict_data` VALUES (34, 0, '成功', '1', 'sys_oper_log_status', '', 'default', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (35, 0, '失败', '0', 'sys_oper_log_status', '', 'default', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (36, 0, '重复执行', '1', 'sys_job_policy', '', 'default', 1, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (37, 0, '执行一次', '2', 'sys_job_policy', '', 'default', 1, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (38, 0, '显示', '0', 'sys_show_hide', NULL, 'default', 1, 1, 31, 0, NULL, NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (39, 0, '隐藏', '1', 'sys_show_hide', NULL, 'default', 0, 1, 31, 0, NULL, NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (40, 0, '正常', '1', 'sys_normal_disable', '', 'default', 1, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (41, 0, '停用', '0', 'sys_normal_disable', '', 'default', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (49, 0, '是', '1', 'sys_yes_no', '', '', 1, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (50, 0, '否', '0', 'sys_yes_no', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (51, 0, '已发布', '1', 'cms_article_pub_type', '', '', 1, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (54, 0, '未发布', '0', 'cms_article_pub_type', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (55, 0, '置顶', '1', 'cms_article_attr', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (56, 0, '推荐', '2', 'cms_article_attr', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (57, 0, '普通文章', '0', 'cms_article_type', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (58, 0, '跳转链接', '1', 'cms_article_type', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (59, 0, 'cms模型', '6', 'cms_cate_models', '', '', 0, 1, 1, 1, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (61, 0, '政府工作目标', '1', 'gov_cate_models', '', '', 0, 1, 2, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (62, 0, '系统后台', 'sys_admin', 'menu_module_type', '', '', 1, 1, 2, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (63, 0, '政务工作', 'gov_work', 'menu_module_type', '', '', 0, 1, 2, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (64, 0, '幻灯', '3', 'cms_article_attr', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (65, 0, '[work]测试业务表', 'wf_news', 'flow_type', '', '', 0, 1, 2, 2, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (66, 0, '回退修改', '-1', 'flow_status', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (67, 0, '保存中', '0', 'flow_status', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (68, 0, '流程中', '1', 'flow_status', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (69, 0, '审批通过', '2', 'flow_status', '', '', 0, 1, 31, 2, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (70, 2, '发布栏目', '2', 'sys_blog_sign', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (71, 3, '跳转栏目', '3', 'sys_blog_sign', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (72, 4, '单页栏目', '4', 'sys_blog_sign', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (73, 2, '置顶', '1', 'sys_log_sign', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (74, 3, '幻灯', '2', 'sys_log_sign', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (75, 4, '推荐', '3', 'sys_log_sign', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (76, 1, '一般', '0', 'sys_log_sign', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (77, 1, '频道页', '1', 'sys_blog_sign', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (78, 0, '普通', '0', 'flow_level', '', '', 0, 1, 31, 0, '', NULL, '2021-07-20 08:55:20'); +INSERT INTO `sys_dict_data` VALUES (79, 0, '加急', '1', 'flow_level', '', '', 0, 1, 31, 0, '', NULL, '2021-07-20 08:55:20'); +INSERT INTO `sys_dict_data` VALUES (80, 0, '紧急', '2', 'flow_level', '', '', 0, 1, 31, 0, '', NULL, '2021-07-20 08:55:20'); +INSERT INTO `sys_dict_data` VALUES (81, 0, '特急', '3', 'flow_level', '', '', 0, 1, 31, 31, '', NULL, '2021-07-20 08:55:25'); +INSERT INTO `sys_dict_data` VALUES (82, 0, '频道页', '1', 'sys_blog_type', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (83, 0, '发布栏目', '2', 'sys_blog_type', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (84, 0, '跳转栏目', '3', 'sys_blog_type', '', '', 0, 1, 31, 31, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (85, 0, '单页栏目', '4', 'sys_blog_type', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (87, 0, '[cms]文章表', 'cms_news', 'flow_type', '', '', 0, 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_data` VALUES (91, 0, '测试一下', '666', 'cms_article_type', '', '', 0, 1, 31, 0, '', '2021-08-03 17:04:12', '2021-08-03 17:04:12'); +INSERT INTO `sys_dict_data` VALUES (92, 0, '缓存测试222', '33333', 'cms_article_type', '', '', 0, 1, 31, 31, '', '2021-08-03 17:16:45', '2021-08-03 17:19:41'); +INSERT INTO `sys_dict_data` VALUES (93, 0, '缓存测试222', '11111', 'cms_article_type', '', '', 0, 1, 31, 31, '', '2021-08-03 17:26:14', '2021-08-03 17:26:26'); +INSERT INTO `sys_dict_data` VALUES (94, 0, '1折', '10', 'plugin_store_discount', '', '', 0, 1, 31, 0, '', '2021-08-14 11:59:38', '2021-08-14 11:59:38'); +INSERT INTO `sys_dict_data` VALUES (95, 0, '5折', '50', 'plugin_store_discount', '', '', 0, 1, 31, 0, '', '2021-08-14 11:59:49', '2021-08-14 11:59:49'); +INSERT INTO `sys_dict_data` VALUES (96, 0, '8折', '80', 'plugin_store_discount', '', '', 0, 1, 31, 0, '', '2021-08-14 12:00:00', '2021-08-14 12:00:00'); +INSERT INTO `sys_dict_data` VALUES (97, 0, '9折', '90', 'plugin_store_discount', '', '', 0, 1, 31, 0, '', '2021-08-14 12:00:07', '2021-08-14 12:00:07'); +INSERT INTO `sys_dict_data` VALUES (98, 0, '无折扣', '100', 'plugin_store_discount', '', '', 0, 1, 31, 0, '', '2021-08-14 12:00:16', '2021-08-14 12:00:16'); +INSERT INTO `sys_dict_data` VALUES (99, 0, '不显示', 'none', 'cms_nav_position', '', '', 1, 1, 22, 0, '', '2021-08-31 15:37:35', '2021-08-31 15:37:35'); +INSERT INTO `sys_dict_data` VALUES (100, 0, '顶部导航', 'top', 'cms_nav_position', '', '', 0, 1, 22, 0, '', '2021-08-31 15:37:57', '2021-08-31 15:37:57'); +INSERT INTO `sys_dict_data` VALUES (101, 0, '底部导航', 'bottom', 'cms_nav_position', '', '', 0, 1, 22, 0, '', '2021-08-31 15:38:08', '2021-08-31 15:38:08'); +INSERT INTO `sys_dict_data` VALUES (102, 0, '读取', 'GET', 'sys_oper_log_type', '', '', 0, 1, 31, 31, '', '2022-12-21 11:59:10', '2022-12-23 19:03:02'); +INSERT INTO `sys_dict_data` VALUES (103, 0, '新增', 'POST', 'sys_oper_log_type', '', '', 0, 1, 31, 31, '', '2022-12-21 11:59:22', '2022-12-23 19:03:10'); +INSERT INTO `sys_dict_data` VALUES (104, 0, '修改', 'PUT', 'sys_oper_log_type', '', '', 0, 1, 31, 31, '', '2022-12-21 11:59:32', '2022-12-23 19:03:19'); +INSERT INTO `sys_dict_data` VALUES (105, 0, '删除', 'DELETE', 'sys_oper_log_type', '', '', 0, 1, 31, 31, '', '2022-12-21 11:59:44', '2022-12-23 19:03:27'); + +-- ---------------------------- +-- Table structure for sys_dict_type +-- ---------------------------- +DROP TABLE IF EXISTS `sys_dict_type`; +CREATE TABLE `sys_dict_type` ( + `dict_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '字典主键', + `dict_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典名称', + `dict_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型', + `status` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '状态(0正常 1停用)', + `create_by` int(64) UNSIGNED NULL DEFAULT 0 COMMENT '创建者', + `update_by` int(64) UNSIGNED NULL DEFAULT 0 COMMENT '更新者', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建日期', + `updated_at` datetime NULL DEFAULT NULL COMMENT '修改日期', + PRIMARY KEY (`dict_id`) USING BTREE, + UNIQUE INDEX `dict_type`(`dict_type`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 51 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '字典类型表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_dict_type +-- ---------------------------- +INSERT INTO `sys_dict_type` VALUES (1, '用户性别', 'sys_user_sex', 1, 31, 1, '用于选择用户性别', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (2, '分类类型', 'cms_category_type', 1, 31, 3, '文章分类类型', NULL, '2021-07-21 10:54:22'); +INSERT INTO `sys_dict_type` VALUES (3, '任务状态', 'sys_job_status', 1, 31, 31, '任务状态列表', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (13, '任务分组', 'sys_job_group', 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (14, '管理员登录状态', 'admin_login_status', 1, 31, 31, '', NULL, '2022-09-16 15:26:01'); +INSERT INTO `sys_dict_type` VALUES (15, '操作日志状态', 'sys_oper_log_status', 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (16, '任务策略', 'sys_job_policy', 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (17, '菜单状态', 'sys_show_hide', 1, 31, 0, '菜单状态', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (18, '系统开关', 'sys_normal_disable', 1, 31, 31, '系统开关', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (24, '系统内置', 'sys_yes_no', 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (25, '文章发布状态', 'cms_article_pub_type', 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (26, '文章附加状态', 'cms_article_attr', 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (27, '文章类型', 'cms_article_type', 1, 31, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (28, '文章栏目模型分类', 'cms_cate_models', 1, 1, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (29, '政务工作模型分类', 'gov_cate_models', 1, 2, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (30, '菜单模块类型', 'menu_module_type', 1, 2, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (31, '工作流程类型', 'flow_type', 1, 2, 0, '', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (32, '工作流程审批状态', 'flow_status', 1, 31, 0, '工作流程审批状态', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (33, '博客分类类型', 'sys_blog_type', 1, 31, 31, '博客分类中的标志', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (34, '博客日志标志', 'sys_log_sign', 1, 31, 0, '博客日志管理中的标志数据字典', NULL, NULL); +INSERT INTO `sys_dict_type` VALUES (35, '工作流紧急状态', 'flow_level', 1, 31, 31, '', NULL, '2021-07-20 08:55:20'); +INSERT INTO `sys_dict_type` VALUES (48, '插件商城折扣', 'plugin_store_discount', 1, 31, 0, '', '2021-08-14 11:59:26', '2021-08-14 11:59:26'); +INSERT INTO `sys_dict_type` VALUES (49, 'CMS栏目导航位置', 'cms_nav_position', 1, 22, 0, '', '2021-08-31 15:37:04', '2021-08-31 15:37:04'); +INSERT INTO `sys_dict_type` VALUES (50, '操作日志类型', 'sys_oper_log_type', 1, 31, 0, '', '2022-12-21 11:55:02', '2022-12-21 11:55:02'); + +-- ---------------------------- +-- Table structure for sys_job +-- ---------------------------- +DROP TABLE IF EXISTS `sys_job`; +CREATE TABLE `sys_job` ( + `job_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '任务ID', + `job_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '任务名称', + `job_params` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '参数', + `job_group` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'DEFAULT' COMMENT '任务组名', + `invoke_target` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '调用目标字符串', + `cron_expression` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'cron执行表达式', + `misfire_policy` tinyint(4) NULL DEFAULT 1 COMMENT '计划执行策略(1多次执行 2执行一次)', + `concurrent` tinyint(4) NULL DEFAULT 1 COMMENT '是否并发执行(0允许 1禁止)', + `status` tinyint(4) NULL DEFAULT 0 COMMENT '状态(0正常 1暂停)', + `created_by` bigint(64) UNSIGNED NULL DEFAULT 0 COMMENT '创建者', + `updated_by` bigint(64) UNSIGNED NULL DEFAULT 0 COMMENT '更新者', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注信息', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建时间', + `updated_at` datetime NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`job_id`) USING BTREE, + UNIQUE INDEX `invoke_target`(`invoke_target`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '定时任务调度表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_job +-- ---------------------------- +INSERT INTO `sys_job` VALUES (1, '测试任务1', '', 'DEFAULT', 'test1', '* * * * * ?', 1, 0, 1, 1, 31, '', '2021-07-16 16:01:59', '2021-07-16 16:01:59'); +INSERT INTO `sys_job` VALUES (2, '测试任务2', 'hello|gfast', 'DEFAULT', 'test2', '* * * * * ?', 1, 0, 1, 1, 31, '备注', '2021-07-16 17:15:09', '2021-07-16 17:15:09'); +INSERT INTO `sys_job` VALUES (8, '在线用户定时更新', '', 'DEFAULT', 'checkUserOnline', '5 */10 * * * ?', 1, 0, 0, 2, 1, '', '2021-07-19 08:57:24', '2021-07-19 08:57:24'); + +-- ---------------------------- +-- Table structure for sys_job_log +-- ---------------------------- +DROP TABLE IF EXISTS `sys_job_log`; +CREATE TABLE `sys_job_log` ( + `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键', + `target_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '方法名', + `created_at` datetime NULL DEFAULT NULL COMMENT '执行日期', + `result` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行结果', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 103 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '任务日志表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_job_log +-- ---------------------------- +INSERT INTO `sys_job_log` VALUES (1, 'test1', '2023-01-13 21:53:44', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (2, 'test1', '2023-01-13 21:53:45', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (3, 'test1', '2023-01-13 21:53:46', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (5, 'test1', '2023-01-13 21:53:47', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (7, 'test1', '2023-01-13 21:53:48', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (9, 'test1', '2023-01-13 21:53:49', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (11, 'test1', '2023-01-13 21:53:50', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (13, 'test1', '2023-01-13 21:53:51', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (14, 'test2', '2023-01-13 21:53:51', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (15, 'test1', '2023-01-13 21:53:52', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (16, 'test2', '2023-01-13 21:53:52', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (17, 'test1', '2023-01-13 21:53:53', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (18, 'test2', '2023-01-13 21:53:53', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (19, 'test1', '2023-01-13 21:53:54', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (20, 'test2', '2023-01-13 21:53:54', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (21, 'test1', '2023-01-13 21:53:55', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (22, 'test2', '2023-01-13 21:53:55', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (23, 'test1', '2023-01-13 21:53:56', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (24, 'test2', '2023-01-13 21:53:56', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (25, 'test1', '2023-01-13 21:53:57', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (26, 'test2', '2023-01-13 21:53:57', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (27, 'test1', '2023-01-13 21:53:58', '无参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (28, 'test2', '2023-01-13 21:53:58', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (29, 'test2', '2023-01-13 21:53:59', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (30, 'test2', '2023-01-13 21:54:00', '有参测试运行成功'); +INSERT INTO `sys_job_log` VALUES (31, 'checkUserOnline', '2023-01-13 22:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (32, 'checkUserOnline', '2023-01-13 22:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (33, 'checkUserOnline', '2023-01-13 22:20:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (34, 'checkUserOnline', '2023-01-13 22:30:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (35, 'checkUserOnline', '2023-01-13 22:40:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (36, 'checkUserOnline', '2023-01-13 22:50:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (37, 'checkUserOnline', '2023-01-13 23:00:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (38, 'checkUserOnline', '2023-01-13 23:10:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (39, 'checkUserOnline', '2023-01-13 23:20:07', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (40, 'checkUserOnline', '2023-01-13 23:30:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (41, 'checkUserOnline', '2023-01-16 11:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (42, 'checkUserOnline', '2023-01-16 11:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (43, 'checkUserOnline', '2023-01-16 11:20:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (44, 'checkUserOnline', '2023-01-16 11:30:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (45, 'checkUserOnline', '2023-01-16 11:40:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (46, 'checkUserOnline', '2023-01-16 11:50:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (47, 'checkUserOnline', '2023-01-16 12:00:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (48, 'checkUserOnline', '2023-01-16 12:10:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (49, 'checkUserOnline', '2023-01-16 12:20:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (50, 'checkUserOnline', '2023-01-16 12:30:07', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (51, 'checkUserOnline', '2023-01-16 12:40:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (52, 'checkUserOnline', '2023-01-16 12:50:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (53, 'checkUserOnline', '2023-01-16 13:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (54, 'checkUserOnline', '2023-01-16 13:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (55, 'checkUserOnline', '2023-01-16 13:20:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (56, 'checkUserOnline', '2023-01-16 13:30:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (57, 'checkUserOnline', '2023-01-16 13:40:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (58, 'checkUserOnline', '2023-01-16 13:50:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (59, 'checkUserOnline', '2023-01-16 14:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (60, 'checkUserOnline', '2023-01-16 14:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (61, 'checkUserOnline', '2023-01-16 14:20:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (62, 'checkUserOnline', '2023-01-16 14:30:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (63, 'checkUserOnline', '2023-01-16 14:40:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (64, 'checkUserOnline', '2023-01-16 14:50:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (65, 'checkUserOnline', '2023-01-16 15:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (66, 'checkUserOnline', '2023-01-16 15:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (67, 'checkUserOnline', '2023-01-16 15:20:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (68, 'checkUserOnline', '2023-01-16 15:30:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (69, 'checkUserOnline', '2023-01-16 15:40:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (70, 'checkUserOnline', '2023-01-16 15:50:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (71, 'checkUserOnline', '2023-01-16 16:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (72, 'checkUserOnline', '2023-01-16 16:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (73, 'checkUserOnline', '2023-01-16 16:20:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (74, 'checkUserOnline', '2023-01-16 16:30:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (75, 'checkUserOnline', '2023-01-16 16:40:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (76, 'checkUserOnline', '2023-01-16 16:50:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (77, 'checkUserOnline', '2023-01-16 17:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (78, 'checkUserOnline', '2023-01-16 17:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (79, 'checkUserOnline', '2023-01-16 17:20:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (80, 'checkUserOnline', '2023-01-16 17:30:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (81, 'checkUserOnline', '2023-01-16 17:40:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (82, 'checkUserOnline', '2023-01-16 17:50:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (83, 'checkUserOnline', '2023-01-16 18:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (84, 'checkUserOnline', '2023-01-16 18:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (85, 'checkUserOnline', '2023-01-16 18:20:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (86, 'checkUserOnline', '2023-01-16 18:30:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (87, 'checkUserOnline', '2023-01-16 18:40:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (88, 'checkUserOnline', '2023-01-16 18:50:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (89, 'checkUserOnline', '2023-01-16 19:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (90, 'checkUserOnline', '2023-01-16 19:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (91, 'checkUserOnline', '2023-01-16 19:20:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (92, 'checkUserOnline', '2023-01-16 19:30:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (93, 'checkUserOnline', '2023-01-16 19:40:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (94, 'checkUserOnline', '2023-01-16 19:50:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (95, 'checkUserOnline', '2023-01-16 20:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (96, 'checkUserOnline', '2023-01-16 20:10:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (97, 'checkUserOnline', '2023-01-16 20:20:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (98, 'checkUserOnline', '2023-01-16 20:30:06', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (99, 'checkUserOnline', '2023-01-16 20:40:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (100, 'checkUserOnline', '2023-01-16 20:50:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (101, 'checkUserOnline', '2023-01-16 21:00:05', '在线用户定时更新,执行成功'); +INSERT INTO `sys_job_log` VALUES (102, 'checkUserOnline', '2023-01-16 21:10:05', '在线用户定时更新,执行成功'); + +-- ---------------------------- +-- Table structure for sys_login_log +-- ---------------------------- +DROP TABLE IF EXISTS `sys_login_log`; +CREATE TABLE `sys_login_log` ( + `info_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '访问ID', + `login_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '登录账号', + `ipaddr` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '登录IP地址', + `login_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '登录地点', + `browser` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '浏览器类型', + `os` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '操作系统', + `status` tinyint(4) NULL DEFAULT 0 COMMENT '登录状态(0成功 1失败)', + `msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '提示消息', + `login_time` datetime NULL DEFAULT NULL COMMENT '登录时间', + `module` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '登录模块', + PRIMARY KEY (`info_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统访问记录' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_login_log +-- ---------------------------- +INSERT INTO `sys_login_log` VALUES (1, 'demo', '::1', '内网IP', 'Chrome', 'Windows 10', 1, '登录成功', '2023-01-16 11:00:42', '系统后台'); +INSERT INTO `sys_login_log` VALUES (2, 'demo', '::1', '内网IP', 'Chrome', 'Windows 10', 1, '登录成功', '2023-01-16 18:40:52', '系统后台'); + +-- ---------------------------- +-- Table structure for sys_oper_log +-- ---------------------------- +DROP TABLE IF EXISTS `sys_oper_log`; +CREATE TABLE `sys_oper_log` ( + `oper_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '日志主键', + `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '模块标题', + `business_type` int(2) NULL DEFAULT 0 COMMENT '业务类型(0其它 1新增 2修改 3删除)', + `method` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '方法名称', + `request_method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '请求方式', + `operator_type` int(1) NULL DEFAULT 0 COMMENT '操作类别(0其它 1后台用户 2手机端用户)', + `oper_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '操作人员', + `dept_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '部门名称', + `oper_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '请求URL', + `oper_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '主机地址', + `oper_location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '操作地点', + `oper_param` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求参数', + `error_msg` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '错误消息', + `oper_time` datetime NULL DEFAULT NULL COMMENT '操作时间', + PRIMARY KEY (`oper_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 77 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '操作日志记录' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_oper_log +-- ---------------------------- +INSERT INTO `sys_oper_log` VALUES (1, '定时任务', 0, '/api/v1/system/sysJob/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/sysJob/list?pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\"}', '', '2023-01-16 11:00:54'); +INSERT INTO `sys_oper_log` VALUES (2, '', 0, '/api/v1/system/dict/data/getDictData', 'GET', 1, 'demo', '财务部门', '/api/v1/system/dict/data/getDictData?dictType=sys_job_policy&defaultValue=', '::1', '内网IP', '{\"defaultValue\":\"\",\"dictType\":\"sys_job_policy\"}', '', '2023-01-16 11:00:54'); +INSERT INTO `sys_oper_log` VALUES (3, '', 0, '/api/v1/system/dict/data/getDictData', 'GET', 1, 'demo', '财务部门', '/api/v1/system/dict/data/getDictData?dictType=sys_job_status&defaultValue=', '::1', '内网IP', '{\"defaultValue\":\"\",\"dictType\":\"sys_job_status\"}', '', '2023-01-16 11:00:54'); +INSERT INTO `sys_oper_log` VALUES (4, '', 0, '/api/v1/system/dict/data/getDictData', 'GET', 1, 'demo', '财务部门', '/api/v1/system/dict/data/getDictData?dictType=sys_job_group&defaultValue=', '::1', '内网IP', '{\"defaultValue\":\"\",\"dictType\":\"sys_job_group\"}', '', '2023-01-16 11:00:54'); +INSERT INTO `sys_oper_log` VALUES (5, '定时任务查询', 0, '/api/v1/system/sysJob/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/sysJob/get?jobId=8', '::1', '内网IP', '{\"jobId\":\"8\"}', '', '2023-01-16 11:00:57'); +INSERT INTO `sys_oper_log` VALUES (6, '', 0, '/api/v1/system/sysJob/logs', 'GET', 1, 'demo', '财务部门', '/api/v1/system/sysJob/logs?pageNum=1&pageSize=10&targetName=checkUserOnline', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"targetName\":\"checkUserOnline\"}', '', '2023-01-16 11:00:57'); +INSERT INTO `sys_oper_log` VALUES (7, '', 0, '/api/v1/system/user/getUsers', 'GET', 1, 'demo', '财务部门', '/api/v1/system/user/getUsers?ids[]=2&ids[]=1', '::1', '内网IP', '{\"ids\":[\"2\",\"1\"]}', '', '2023-01-16 11:00:57'); +INSERT INTO `sys_oper_log` VALUES (8, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 11:01:12'); +INSERT INTO `sys_oper_log` VALUES (9, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 11:01:27'); +INSERT INTO `sys_oper_log` VALUES (10, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=3', '::1', '内网IP', '{\"id\":\"3\"}', '', '2023-01-16 11:01:30'); +INSERT INTO `sys_oper_log` VALUES (11, '', 0, '/api/v1/system/role/getParams', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/getParams', '::1', '内网IP', '{}', '', '2023-01-16 11:01:30'); +INSERT INTO `sys_oper_log` VALUES (12, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 11:16:33'); +INSERT INTO `sys_oper_log` VALUES (13, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 11:16:52'); +INSERT INTO `sys_oper_log` VALUES (14, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=3', '::1', '内网IP', '{\"id\":\"3\"}', '', '2023-01-16 11:16:55'); +INSERT INTO `sys_oper_log` VALUES (15, '', 0, '/api/v1/system/role/getParams', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/getParams', '::1', '内网IP', '{}', '', '2023-01-16 11:16:55'); +INSERT INTO `sys_oper_log` VALUES (16, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 11:18:50'); +INSERT INTO `sys_oper_log` VALUES (17, '', 0, '/api/v1/system/role/getParams', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/getParams', '::1', '内网IP', '{}', '', '2023-01-16 11:18:50'); +INSERT INTO `sys_oper_log` VALUES (18, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 11:19:57'); +INSERT INTO `sys_oper_log` VALUES (19, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 12:28:07'); +INSERT INTO `sys_oper_log` VALUES (20, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 12:28:09'); +INSERT INTO `sys_oper_log` VALUES (21, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 12:29:47'); +INSERT INTO `sys_oper_log` VALUES (22, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 12:33:42'); +INSERT INTO `sys_oper_log` VALUES (23, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 12:34:11'); +INSERT INTO `sys_oper_log` VALUES (24, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 12:34:38'); +INSERT INTO `sys_oper_log` VALUES (25, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 12:34:42'); +INSERT INTO `sys_oper_log` VALUES (26, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 12:35:10'); +INSERT INTO `sys_oper_log` VALUES (27, '在线用户', 0, '/api/v1/system/online/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/online/list?ipaddr=&userName=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"ipaddr\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"userName\":\"\"}', '', '2023-01-16 12:36:23'); +INSERT INTO `sys_oper_log` VALUES (28, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 12:36:32'); +INSERT INTO `sys_oper_log` VALUES (29, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 12:37:19'); +INSERT INTO `sys_oper_log` VALUES (30, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 18:40:59'); +INSERT INTO `sys_oper_log` VALUES (31, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 18:41:19'); +INSERT INTO `sys_oper_log` VALUES (32, '', 0, '/api/v1/system/role/getParams', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/getParams', '::1', '内网IP', '{}', '', '2023-01-16 18:41:19'); +INSERT INTO `sys_oper_log` VALUES (33, '登录日志', 0, '/api/v1/system/loginLog/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/loginLog/list?pageNum=1&pageSize=10&status=&ipaddr=&loginLocation=&userName=', '::1', '内网IP', '{\"ipaddr\":\"\",\"loginLocation\":\"\",\"pageNum\":\"1\",\"pageSize\":\"10\",\"status\":\"\",\"userName\":\"\"}', '', '2023-01-16 20:10:57'); +INSERT INTO `sys_oper_log` VALUES (34, '', 0, '/api/v1/system/dict/data/getDictData', 'GET', 1, 'demo', '财务部门', '/api/v1/system/dict/data/getDictData?dictType=admin_login_status&defaultValue=', '::1', '内网IP', '{\"defaultValue\":\"\",\"dictType\":\"admin_login_status\"}', '', '2023-01-16 20:10:57'); +INSERT INTO `sys_oper_log` VALUES (35, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 20:35:34'); +INSERT INTO `sys_oper_log` VALUES (36, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 20:35:36'); +INSERT INTO `sys_oper_log` VALUES (37, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=2', '::1', '内网IP', '{\"id\":\"2\"}', '', '2023-01-16 20:36:10'); +INSERT INTO `sys_oper_log` VALUES (38, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 20:38:26'); +INSERT INTO `sys_oper_log` VALUES (39, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=2', '::1', '内网IP', '{\"roleId\":\"2\"}', '', '2023-01-16 20:38:31'); +INSERT INTO `sys_oper_log` VALUES (40, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=2', '::1', '内网IP', '{\"id\":\"2\"}', '', '2023-01-16 20:38:31'); +INSERT INTO `sys_oper_log` VALUES (41, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 20:38:44'); +INSERT INTO `sys_oper_log` VALUES (42, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 20:38:46'); +INSERT INTO `sys_oper_log` VALUES (43, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=1', '::1', '内网IP', '{\"roleId\":\"1\"}', '', '2023-01-16 20:38:46'); +INSERT INTO `sys_oper_log` VALUES (44, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=5', '::1', '内网IP', '{\"id\":\"5\"}', '', '2023-01-16 20:39:19'); +INSERT INTO `sys_oper_log` VALUES (45, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=5', '::1', '内网IP', '{\"roleId\":\"5\"}', '', '2023-01-16 20:39:19'); +INSERT INTO `sys_oper_log` VALUES (46, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 20:49:39'); +INSERT INTO `sys_oper_log` VALUES (47, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=2', '::1', '内网IP', '{\"roleId\":\"2\"}', '', '2023-01-16 20:49:42'); +INSERT INTO `sys_oper_log` VALUES (48, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=2', '::1', '内网IP', '{\"id\":\"2\"}', '', '2023-01-16 20:49:42'); +INSERT INTO `sys_oper_log` VALUES (49, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 20:52:42'); +INSERT INTO `sys_oper_log` VALUES (50, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=3', '::1', '内网IP', '{\"id\":\"3\"}', '', '2023-01-16 20:52:47'); +INSERT INTO `sys_oper_log` VALUES (51, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=3', '::1', '内网IP', '{\"roleId\":\"3\"}', '', '2023-01-16 20:52:47'); +INSERT INTO `sys_oper_log` VALUES (52, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 20:54:24'); +INSERT INTO `sys_oper_log` VALUES (53, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=1', '::1', '内网IP', '{\"roleId\":\"1\"}', '', '2023-01-16 20:54:24'); +INSERT INTO `sys_oper_log` VALUES (54, '', 0, '/api/v1/system/role/dataScope', 'PUT', 1, 'demo', '财务部门', '/api/v1/system/role/dataScope', '::1', '内网IP', '{\"dataScope\":\"2\",\"deptCheckStrictly\":true,\"deptIds\":[101,103,104,105,106,107],\"roleId\":1,\"roleName\":\"超级管理员\"}', '', '2023-01-16 20:55:52'); +INSERT INTO `sys_oper_log` VALUES (55, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 20:55:52'); +INSERT INTO `sys_oper_log` VALUES (56, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=1', '::1', '内网IP', '{\"roleId\":\"1\"}', '', '2023-01-16 20:55:55'); +INSERT INTO `sys_oper_log` VALUES (57, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 20:55:55'); +INSERT INTO `sys_oper_log` VALUES (58, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 20:56:08'); +INSERT INTO `sys_oper_log` VALUES (59, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=1', '::1', '内网IP', '{\"roleId\":\"1\"}', '', '2023-01-16 20:56:08'); +INSERT INTO `sys_oper_log` VALUES (60, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 20:57:40'); +INSERT INTO `sys_oper_log` VALUES (61, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 20:57:42'); +INSERT INTO `sys_oper_log` VALUES (62, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=1', '::1', '内网IP', '{\"roleId\":\"1\"}', '', '2023-01-16 20:57:42'); +INSERT INTO `sys_oper_log` VALUES (63, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 20:58:17'); +INSERT INTO `sys_oper_log` VALUES (64, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=1', '::1', '内网IP', '{\"roleId\":\"1\"}', '', '2023-01-16 20:58:17'); +INSERT INTO `sys_oper_log` VALUES (65, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=2', '::1', '内网IP', '{\"id\":\"2\"}', '', '2023-01-16 20:58:21'); +INSERT INTO `sys_oper_log` VALUES (66, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=2', '::1', '内网IP', '{\"roleId\":\"2\"}', '', '2023-01-16 20:58:21'); +INSERT INTO `sys_oper_log` VALUES (67, '', 0, '/api/v1/system/role/dataScope', 'PUT', 1, 'demo', '财务部门', '/api/v1/system/role/dataScope', '::1', '内网IP', '{\"dataScope\":\"5\",\"deptCheckStrictly\":false,\"deptIds\":[],\"roleId\":2,\"roleName\":\"普通管理员\"}', '', '2023-01-16 20:58:25'); +INSERT INTO `sys_oper_log` VALUES (68, '角色管理', 0, '/api/v1/system/role/list', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/list?roleName=&roleStatus=&pageNum=1&pageSize=10', '::1', '内网IP', '{\"pageNum\":\"1\",\"pageSize\":\"10\",\"roleName\":\"\",\"roleStatus\":\"\"}', '', '2023-01-16 20:58:25'); +INSERT INTO `sys_oper_log` VALUES (69, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=2', '::1', '内网IP', '{\"id\":\"2\"}', '', '2023-01-16 20:58:27'); +INSERT INTO `sys_oper_log` VALUES (70, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=2', '::1', '内网IP', '{\"roleId\":\"2\"}', '', '2023-01-16 20:58:27'); +INSERT INTO `sys_oper_log` VALUES (71, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=3', '::1', '内网IP', '{\"roleId\":\"3\"}', '', '2023-01-16 20:58:29'); +INSERT INTO `sys_oper_log` VALUES (72, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=3', '::1', '内网IP', '{\"id\":\"3\"}', '', '2023-01-16 20:58:29'); +INSERT INTO `sys_oper_log` VALUES (73, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=4', '::1', '内网IP', '{\"id\":\"4\"}', '', '2023-01-16 20:58:32'); +INSERT INTO `sys_oper_log` VALUES (74, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=4', '::1', '内网IP', '{\"roleId\":\"4\"}', '', '2023-01-16 20:58:32'); +INSERT INTO `sys_oper_log` VALUES (75, '', 0, '/api/v1/system/role/get', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/get?id=1', '::1', '内网IP', '{\"id\":\"1\"}', '', '2023-01-16 20:58:35'); +INSERT INTO `sys_oper_log` VALUES (76, '', 0, '/api/v1/system/role/deptTreeSelect', 'GET', 1, 'demo', '财务部门', '/api/v1/system/role/deptTreeSelect?roleId=1', '::1', '内网IP', '{\"roleId\":\"1\"}', '', '2023-01-16 20:58:35'); + +-- ---------------------------- +-- Table structure for sys_post +-- ---------------------------- +DROP TABLE IF EXISTS `sys_post`; +CREATE TABLE `sys_post` ( + `post_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '岗位ID', + `post_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '岗位编码', + `post_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '岗位名称', + `post_sort` int(4) NOT NULL COMMENT '显示顺序', + `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '状态(0正常 1停用)', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + `created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人', + `updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '修改人', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建时间', + `updated_at` datetime NULL DEFAULT NULL COMMENT '修改时间', + `deleted_at` datetime NULL DEFAULT NULL COMMENT '删除时间', + PRIMARY KEY (`post_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '岗位信息表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_post +-- ---------------------------- +INSERT INTO `sys_post` VALUES (1, 'ceo', '董事长', 1, 1, '', 0, 0, '2021-07-11 11:32:58', NULL, NULL); +INSERT INTO `sys_post` VALUES (2, 'se', '项目经理', 2, 1, '', 0, 0, '2021-07-12 11:01:26', NULL, NULL); +INSERT INTO `sys_post` VALUES (3, 'hr', '人力资源', 3, 1, '', 0, 31, '2021-07-12 11:01:30', '2022-09-16 16:48:18', NULL); +INSERT INTO `sys_post` VALUES (4, 'user', '普通员工', 4, 0, '普通员工', 0, 31, '2021-07-12 11:01:33', '2022-04-08 15:32:23', NULL); +INSERT INTO `sys_post` VALUES (5, 'it', 'IT部', 5, 1, '信息部', 31, 31, '2021-07-12 11:09:42', '2022-04-09 12:59:12', NULL); +INSERT INTO `sys_post` VALUES (6, '1111', '1111', 0, 1, '11111', 31, 0, '2022-04-08 15:32:44', '2022-04-08 15:32:44', '2022-04-08 15:51:24'); +INSERT INTO `sys_post` VALUES (7, '222', '2222', 0, 1, '22222', 31, 0, '2022-04-08 15:32:55', '2022-04-08 15:32:55', '2022-04-08 15:51:24'); +INSERT INTO `sys_post` VALUES (8, '33333', '3333', 0, 0, '33333', 31, 0, '2022-04-08 15:33:01', '2022-04-08 15:33:01', '2022-04-08 15:51:40'); +INSERT INTO `sys_post` VALUES (9, '222', '111', 0, 1, '2313213', 31, 0, '2022-04-08 15:52:53', '2022-04-08 15:52:53', '2022-04-08 15:52:56'); + +-- ---------------------------- +-- Table structure for sys_role +-- ---------------------------- +DROP TABLE IF EXISTS `sys_role`; +CREATE TABLE `sys_role` ( + `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `status` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '状态;0:禁用;1:正常', + `list_order` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序', + `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '角色名称', + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '备注', + `data_scope` tinyint(3) UNSIGNED NOT NULL DEFAULT 3 COMMENT '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建时间', + `updated_at` datetime NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE, + INDEX `status`(`status`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_role +-- ---------------------------- +INSERT INTO `sys_role` VALUES (1, 1, 0, '超级管理员', '备注', 2, '2022-04-01 11:38:39', '2023-01-16 20:55:51'); +INSERT INTO `sys_role` VALUES (2, 1, 0, '普通管理员', '备注', 5, '2022-04-01 11:38:39', '2023-01-16 20:58:24'); +INSERT INTO `sys_role` VALUES (3, 1, 0, '站点管理员', '站点管理人员', 3, '2022-04-01 11:38:39', '2022-04-01 11:38:39'); +INSERT INTO `sys_role` VALUES (4, 1, 0, '初级管理员', '初级管理员', 3, '2022-04-01 11:38:39', '2022-04-01 11:38:39'); +INSERT INTO `sys_role` VALUES (5, 1, 0, '高级管理员', '高级管理员', 2, '2022-04-01 11:38:39', '2022-04-01 11:38:39'); +INSERT INTO `sys_role` VALUES (8, 1, 0, '区级管理员', '', 2, '2022-04-01 11:38:39', '2022-04-06 09:53:40'); + +-- ---------------------------- +-- Table structure for sys_role_dept +-- ---------------------------- +DROP TABLE IF EXISTS `sys_role_dept`; +CREATE TABLE `sys_role_dept` ( + `role_id` bigint(20) NOT NULL COMMENT '角色ID', + `dept_id` bigint(20) NOT NULL COMMENT '部门ID', + PRIMARY KEY (`role_id`, `dept_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色和部门关联表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_role_dept +-- ---------------------------- +INSERT INTO `sys_role_dept` VALUES (1, 101); +INSERT INTO `sys_role_dept` VALUES (1, 103); +INSERT INTO `sys_role_dept` VALUES (1, 104); +INSERT INTO `sys_role_dept` VALUES (1, 105); +INSERT INTO `sys_role_dept` VALUES (1, 106); +INSERT INTO `sys_role_dept` VALUES (1, 107); +INSERT INTO `sys_role_dept` VALUES (5, 103); +INSERT INTO `sys_role_dept` VALUES (5, 104); +INSERT INTO `sys_role_dept` VALUES (5, 105); +INSERT INTO `sys_role_dept` VALUES (8, 105); +INSERT INTO `sys_role_dept` VALUES (8, 106); + +-- ---------------------------- +-- Table structure for sys_user +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user`; +CREATE TABLE `sys_user` ( + `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, + `user_name` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '用户名', + `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '中国手机不带国家代码,国际手机号格式为:国家代码-手机号', + `user_nickname` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '用户昵称', + `birthday` int(11) NOT NULL DEFAULT 0 COMMENT '生日', + `user_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '登录密码;cmf_password加密', + `user_salt` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '加密盐', + `user_status` tinyint(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT '用户状态;0:禁用,1:正常,2:未验证', + `user_email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户登录邮箱', + `sex` tinyint(2) NOT NULL DEFAULT 0 COMMENT '性别;0:保密,1:男,2:女', + `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户头像', + `dept_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '部门id', + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '备注', + `is_admin` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否后台管理员 1 是 0 否', + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '联系地址', + `describe` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT ' 描述信息', + `last_login_ip` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '最后登录ip', + `last_login_time` datetime NULL DEFAULT NULL COMMENT '最后登录时间', + `created_at` datetime NULL DEFAULT NULL COMMENT '创建时间', + `updated_at` datetime NULL DEFAULT NULL COMMENT '更新时间', + `deleted_at` datetime NULL DEFAULT NULL COMMENT '删除时间', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `user_login`(`user_name`, `deleted_at`) USING BTREE, + UNIQUE INDEX `mobile`(`mobile`, `deleted_at`) USING BTREE, + INDEX `user_nickname`(`user_nickname`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 43 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_user +-- ---------------------------- +INSERT INTO `sys_user` VALUES (1, 'admin', '13578342363', '超级管理员', 0, 'c567ae329f9929b518759d3bea13f492', 'f9aZTAa8yz', 1, 'yxh669@qq.com', 1, 'https://yxh-1301841944.cos.ap-chongqing.myqcloud.com/gfast/2021-07-19/ccwpeuqz1i2s769hua.jpeg', 101, '', 1, 'asdasfdsaf大发放打发士大夫发按时', '描述信息', '::1', '2022-10-26 03:01:52', '2021-06-22 17:58:00', '2022-11-03 15:44:38', NULL); +INSERT INTO `sys_user` VALUES (2, 'yixiaohu', '13699885599', '奈斯', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, 'yxh@qq.com', 1, 'upload_file/2022-11-04/co3e5ljknns8jhlp8s.jpg', 102, '备注', 1, '', '', '::1', '2022-11-04 09:54:56', '2021-06-22 17:58:00', '2022-11-04 17:54:56', NULL); +INSERT INTO `sys_user` VALUES (3, 'zs', '16399669855', '张三', 0, '41e3778c20338f4d7d6cc886fd3b2a52', 'redoHIj524', 1, 'zs@qq.com', 0, 'https://yxh-1301841944.cos.ap-chongqing.myqcloud.com/gfast/2021-08-02/cd8nif79egjg9kbkgk.jpeg', 101, '', 1, '', '', '::1', '2022-04-28 10:01:47', '2021-06-22 17:58:00', '2022-04-28 10:01:47', NULL); +INSERT INTO `sys_user` VALUES (4, 'qlgl', '13758596696', '测试c', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, 'qlgl@qq.com', 0, '', 102, '', 1, '', '', '127.0.0.1', NULL, '2021-06-22 17:58:00', '2022-11-03 15:44:20', NULL); +INSERT INTO `sys_user` VALUES (5, 'test', '13845696696', '测试2', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '123@qq.com', 0, '', 101, '', 0, '', '', '::1', '2022-03-30 10:50:39', '2021-06-22 17:58:00', '2022-11-03 15:44:10', NULL); +INSERT INTO `sys_user` VALUES (6, '18999998889', '13755866654', '刘大大', 0, '5df78d20315a5af61f45d20f72c184fc', 'lC6OoXDCbM', 1, '1223@qq.com', 0, '', 103, '', 1, '', '', '[::1]', '2022-02-25 14:29:22', '2021-06-22 17:58:00', '2022-11-03 17:05:07', NULL); +INSERT INTO `sys_user` VALUES (7, 'zmm', '13788566696', '张明明', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '11123@qq.com', 0, '', 104, '', 1, '', '', '127.0.0.1', NULL, '2021-06-22 17:58:00', '2022-04-12 17:55:42', NULL); +INSERT INTO `sys_user` VALUES (8, 'lxx', '13756566696', '李小小', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '123333@qq.com', 0, '', 101, '', 1, '', '', '127.0.0.1', NULL, '2021-06-22 17:58:00', '2022-04-12 17:55:45', NULL); +INSERT INTO `sys_user` VALUES (10, 'xmm', '13588999969', '小秘密', 0, '2de2a8df703bfc634cfda2cb2f6a59be', 'Frz7LJY7SE', 1, '696@qq.com', 0, '', 101, '', 1, '', '', '[::1]', '2021-07-22 17:08:53', '2021-06-22 17:58:00', '2022-04-12 17:55:50', NULL); +INSERT INTO `sys_user` VALUES (14, 'cd_19', '13699888899', '看金利科技', 0, '1169d5fe4119fd4277a95f02d7036171', '7paigEoedh', 1, '', 0, '', 102, '', 1, '', '', '', NULL, '2021-06-22 17:58:00', '2022-04-12 18:13:22', NULL); +INSERT INTO `sys_user` VALUES (15, 'lmm', '13587754545', '刘敏敏', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, 'a@coc.com', 0, '', 201, '', 1, '', '', '127.0.0.1', NULL, '2021-06-22 17:58:00', '2022-04-12 17:56:23', NULL); +INSERT INTO `sys_user` VALUES (16, 'ldn', '13899658874', '李大牛', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, 'a@ll.con', 0, '', 102, '', 1, '', '', '127.0.0.1', NULL, '2021-06-22 17:58:00', '2022-04-12 17:56:27', NULL); +INSERT INTO `sys_user` VALUES (20, 'dbc', '13877555566', '大百词', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '', 0, '', 0, '', 1, '', '', '', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (22, 'yxfmlbb', '15969423326', '大数据部门测试', 0, '66f89b40ee4a10aabaf70c15756429ea', 'mvd2OtUe8f', 1, 'yxh6691@qq.com', 0, 'https://yxh-1301841944.cos.ap-chongqing.myqcloud.com/gfast/2021-09-29/cem20k3fdciosy7nwo.jpeg', 200, '', 1, '2222233', '1222', '[::1]', '2021-10-28 11:36:07', '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (23, 'wangming', '13699888855', '王明', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '', 0, '', 0, '', 1, '', '', '', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (24, 'zhk', '13699885591', '综合科', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '', 0, '', 0, '', 1, '', '', '192.168.0.146', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (28, 'demo3', '18699888855', '测试账号1', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '123132@qq.com', 0, '', 109, '', 1, '', '', '192.168.0.229', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (31, 'demo', '15334455789', '李四', 0, '6dd68eea81e0fca319add0bd58c3fdf6', '46PvWe1Sl7', 1, '123@qq.com', 2, 'upload_file/2022-11-11/co9copop81co0gysbz.jpg', 109, '3', 1, '云南省曲靖市22223', '生活变的再糟糕,也不妨碍我变得更好', '::1', '2023-01-16 18:40:52', '2021-06-22 17:58:00', '2022-11-11 17:25:27', NULL); +INSERT INTO `sys_user` VALUES (32, 'demo100', '18699888859', '测试账号1', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '', 0, '', 0, '', 1, '', '', '[::1]', '2021-11-24 18:01:21', '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (33, 'demo110', '18699888853', '测试账号1', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '', 0, '', 0, '', 1, '', '', '', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (34, 'yxfmlbb2', '15969423327', '研发部门测试', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '1111@qqq.com', 1, '', 103, '', 0, '', '', '127.0.0.1', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (35, 'wk666', '18888888888', 'wk', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '396861557@qq.com', 1, '', 100, '', 1, '', '', '[::1]', '2021-12-09 14:52:37', '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (36, 'zxd', '13699885565', '张晓东', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, 'zxk@qq.com', 1, '', 201, '666', 1, '', '', '', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL); +INSERT INTO `sys_user` VALUES (37, 'yxfmlbb3', '13513513511', '张三', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '111@qq.com', 0, '', 204, '', 1, '', '', '[::1]', '2021-07-26 14:49:25', '2021-06-22 17:58:00', '2021-07-26 14:49:18', NULL); +INSERT INTO `sys_user` VALUES (38, 'test_user', '18888888880', 'test', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '11@qq.com', 1, '', 200, '111', 0, '', '', '', NULL, '2021-06-22 17:58:00', '2021-07-12 22:05:29', NULL); +INSERT INTO `sys_user` VALUES (39, 'asan', '18687460555', '阿三', 0, '2354837137115700e2adf870ac113dcf', 'drdDvbtYZW', 1, '456654@qq.com', 1, '', 201, '666666', 1, '', '', '', NULL, '2021-07-12 17:21:43', '2021-07-12 21:13:31', '2021-07-12 22:00:44'); +INSERT INTO `sys_user` VALUES (40, 'asi', '13655888888', '啊四', 0, 'fbb755b35d48759dad47bb1540249fd1', '9dfUstcxrz', 1, '5464@qq.com', 1, '', 201, 'adsaasd', 1, '', '', '', '0000-00-00 00:00:00', '2021-07-12 17:46:27', '2021-07-12 21:29:41', '2021-07-12 22:00:44'); +INSERT INTO `sys_user` VALUES (41, 'awu', '13578556546', '阿五', 0, '3b36a96afa0dfd66aa915e0816e0e9f6', '9gHRa9ho4U', 0, '132321@qq.com', 1, '', 201, 'asdasdasd', 1, '', '', '', NULL, '2021-07-12 17:54:31', '2021-07-12 21:46:34', '2021-07-12 21:59:56'); +INSERT INTO `sys_user` VALUES (42, 'demo01', '13699888556', '测试01222', 0, '048dc94116558fb40920f3553ecd5fe8', 'KiVrfzKJQx', 1, '456@qq.com', 2, '', 109, '测试用户', 1, '', '', '', NULL, '2022-04-12 16:15:23', '2022-04-12 17:54:49', NULL); + +-- ---------------------------- +-- Table structure for sys_user_online +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user_online`; +CREATE TABLE `sys_user_online` ( + `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, + `uuid` char(32) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '' COMMENT '用户标识', + `token` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '' COMMENT '用户token', + `create_time` datetime NULL DEFAULT NULL COMMENT '登录时间', + `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名', + `ip` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '登录ip', + `explorer` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '浏览器', + `os` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '操作系统', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uni_token`(`token`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户在线状态表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_user_online +-- ---------------------------- +INSERT INTO `sys_user_online` VALUES (17, '1157002b2589ddfbdb34bb3caac863f4', '7ZUSfVIf2HyYjcv86SKPPs29v003ECPEScsdYsYYqO1xEIcOpHEu9FS4ZmjQsf1GCmQAky2EuUzyGJF53YyQWnIkMzq6/8K5VfMPKx1Dt7wrbx+P+2GCvaeUtBH8OcleUJg6TDzXKnby3T6A3ot83g==', '2023-01-16 18:40:52', 'demo', '::1', 'Chrome', 'Windows 10'); + +-- ---------------------------- +-- Table structure for sys_user_post +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user_post`; +CREATE TABLE `sys_user_post` ( + `user_id` bigint(20) NOT NULL COMMENT '用户ID', + `post_id` bigint(20) NOT NULL COMMENT '岗位ID', + PRIMARY KEY (`user_id`, `post_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户与岗位关联表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of sys_user_post +-- ---------------------------- +INSERT INTO `sys_user_post` VALUES (1, 2); +INSERT INTO `sys_user_post` VALUES (1, 3); +INSERT INTO `sys_user_post` VALUES (2, 1); +INSERT INTO `sys_user_post` VALUES (2, 2); +INSERT INTO `sys_user_post` VALUES (3, 2); +INSERT INTO `sys_user_post` VALUES (4, 1); +INSERT INTO `sys_user_post` VALUES (5, 2); +INSERT INTO `sys_user_post` VALUES (10, 1); +INSERT INTO `sys_user_post` VALUES (10, 2); +INSERT INTO `sys_user_post` VALUES (10, 3); +INSERT INTO `sys_user_post` VALUES (10, 4); +INSERT INTO `sys_user_post` VALUES (10, 5); +INSERT INTO `sys_user_post` VALUES (14, 1); +INSERT INTO `sys_user_post` VALUES (15, 4); +INSERT INTO `sys_user_post` VALUES (16, 2); +INSERT INTO `sys_user_post` VALUES (22, 1); +INSERT INTO `sys_user_post` VALUES (22, 2); +INSERT INTO `sys_user_post` VALUES (31, 2); +INSERT INTO `sys_user_post` VALUES (34, 1); +INSERT INTO `sys_user_post` VALUES (35, 2); +INSERT INTO `sys_user_post` VALUES (35, 3); +INSERT INTO `sys_user_post` VALUES (36, 1); +INSERT INTO `sys_user_post` VALUES (37, 3); +INSERT INTO `sys_user_post` VALUES (38, 2); +INSERT INTO `sys_user_post` VALUES (38, 3); +INSERT INTO `sys_user_post` VALUES (42, 2); +INSERT INTO `sys_user_post` VALUES (42, 3); + +-- ---------------------------- +-- Table structure for tools_gen_table +-- ---------------------------- +DROP TABLE IF EXISTS `tools_gen_table`; +CREATE TABLE `tools_gen_table` ( + `table_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号', + `table_name` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '表名称', + `table_comment` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '表描述', + `class_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '实体类名称', + `tpl_category` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'crud' COMMENT '使用的模板(crud单表操作 tree树表操作)', + `package_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生成包路径', + `module_name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生成模块名', + `business_name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生成业务名', + `function_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生成功能名', + `function_author` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生成功能作者', + `options` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其它生成选项', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', + `overwrite` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否覆盖原有文件', + `sort_column` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '排序字段名', + `sort_type` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'asc' COMMENT '排序方式 (asc顺序 desc倒序)', + `show_detail` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否有查看详情功能', + PRIMARY KEY (`table_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 94 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '代码生成业务表' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of tools_gen_table +-- ---------------------------- +INSERT INTO `tools_gen_table` VALUES (91, 'demo_gen', '代码生成测试表', 'DemoGen', 'crud', 'internal/app/demo', 'demo', 'demo_gen', '代码生成测试', 'gfast', '', '2022-11-01 17:27:43', '2022-12-16 17:30:01', '', b'1', 'id', 'asc', b'1'); +INSERT INTO `tools_gen_table` VALUES (92, 'demo_gen_class', '代码生成关联测试表', 'DemoGenClass', 'crud', 'internal/app/demo', 'demo', 'demo_gen_class', '分类信息', 'gfast', '', '2022-11-03 06:36:57', '2022-12-15 15:17:45', '分类', b'1', 'id', 'asc', b'1'); +INSERT INTO `tools_gen_table` VALUES (93, 'demo_gen_tree', '代码生成树形结构测试表', 'DemoGenTree', 'tree', 'internal/app/demo', 'demo', 'demo_gen_tree', '代码生成树形结构测试', 'gfast', '{\"treeCode\":\"id\",\"treeName\":\"demoName\",\"treeParentCode\":\"parentId\"}', '2022-11-29 15:11:34', '2022-12-20 11:29:00', '', b'1', 'id', 'asc', b'1'); + +-- ---------------------------- +-- Table structure for tools_gen_table_column +-- ---------------------------- +DROP TABLE IF EXISTS `tools_gen_table_column`; +CREATE TABLE `tools_gen_table_column` ( + `column_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号', + `table_id` bigint(20) NULL DEFAULT NULL COMMENT '归属表编号', + `column_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列名称', + `column_comment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列描述', + `column_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列类型', + `go_type` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Go类型', + `ts_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'TS类型', + `go_field` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Go字段名', + `html_field` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'html字段名', + `is_pk` bit(1) NULL DEFAULT b'0' COMMENT '是否主键(1是)', + `is_increment` bit(1) NULL DEFAULT b'0' COMMENT '是否自增(1是)', + `is_required` bit(1) NULL DEFAULT b'0' COMMENT '是否必填(1是)', + `is_insert` bit(1) NULL DEFAULT b'0' COMMENT '是否为插入字段(1是)', + `is_edit` bit(1) NULL DEFAULT b'0' COMMENT '是否编辑字段(1是)', + `is_list` bit(1) NULL DEFAULT b'1' COMMENT '是否列表字段(1是)', + `is_detail` bit(1) NULL DEFAULT b'1' COMMENT '是否详情字段', + `is_query` bit(1) NULL DEFAULT b'0' COMMENT '是否查询字段(1是)', + `sort_order_edit` int(11) NULL DEFAULT 999 COMMENT '插入编辑显示顺序', + `sort_order_list` int(11) NULL DEFAULT 999 COMMENT '列表显示顺序', + `sort_order_detail` int(11) NULL DEFAULT 999 COMMENT '详情显示顺序', + `sort_order_query` int(11) NULL DEFAULT 999 COMMENT '查询显示顺序', + `query_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'EQ' COMMENT '查询方式(等于、不等于、大于、小于、范围)', + `html_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)', + `dict_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型', + `link_table_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联表名', + `link_table_class` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联表类名', + `link_table_module_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联表模块名', + `link_table_business_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联表业务名', + `link_table_package` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联表包名', + `link_label_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联表键名', + `link_label_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联表字段值', + `col_span` int(11) NULL DEFAULT 12 COMMENT '详情页占列数', + `row_span` int(11) NULL DEFAULT 1 COMMENT '详情页占行数', + `is_row_start` bit(1) NULL DEFAULT b'0' COMMENT '详情页为行首', + `min_width` int(11) NULL DEFAULT 100 COMMENT '表格最小宽度', + `is_fixed` bit(1) NULL DEFAULT b'0' COMMENT '是否表格列左固定', + `is_overflow_tooltip` bit(1) NULL DEFAULT b'0' COMMENT '是否过长自动隐藏', + `is_cascade` bit(1) NULL DEFAULT b'0' COMMENT '是否级联查询', + `parent_column_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上级字段名', + `cascade_column_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '级联查询字段', + PRIMARY KEY (`column_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 978 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成业务表字段' ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of tools_gen_table_column +-- ---------------------------- +INSERT INTO `tools_gen_table_column` VALUES (944, 91, 'id', 'ID', 'int(11) unsigned', 'uint', 'number', 'Id', 'id', b'1', b'1', b'1', b'0', b'0', b'1', b'1', b'0', 1, 1, 1, 1, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (945, 91, 'demo_name', '姓名', 'varchar(20)', 'string', 'string', 'DemoName', 'demoName', b'0', b'0', b'1', b'1', b'1', b'1', b'1', b'1', 2, 2, 2, 2, 'LIKE', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (946, 91, 'demo_age', '年龄', 'int(10) unsigned', 'uint', 'number', 'DemoAge', 'demoAge', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 3, 3, 3, 3, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (947, 91, 'classes', '班级', 'varchar(30)', 'string', 'string', 'Classes', 'classes', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 4, 4, 4, 4, 'EQ', 'select', '', 'demo_gen_class', 'DemoGenClass', 'demo', 'demo_gen_class', 'internal/app/demo', 'id', 'class_name', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (948, 91, 'demo_born', '出生年月', 'datetime', 'Time', 'string', 'DemoBorn', 'demoBorn', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 5, 5, 5, 5, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (949, 91, 'demo_gender', '性别', 'tinyint(3) unsigned', 'uint', 'number', 'DemoGender', 'demoGender', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 6, 6, 6, 6, 'EQ', 'radio', 'sys_user_sex', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (950, 91, 'created_at', '创建日期', 'datetime', 'Time', 'string', 'CreatedAt', 'createdAt', b'0', b'0', b'0', b'0', b'0', b'1', b'1', b'0', 7, 7, 7, 7, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (951, 91, 'updated_at', '修改日期', 'datetime', 'Time', 'string', 'UpdatedAt', 'updatedAt', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', 8, 8, 8, 8, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (952, 91, 'deleted_at', '删除日期', 'datetime', 'Time', 'string', 'DeletedAt', 'deletedAt', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', 9, 9, 9, 9, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (953, 91, 'created_by', '创建人', 'bigint(20) unsigned', 'uint64', 'number', 'CreatedBy', 'createdBy', b'0', b'0', b'0', b'0', b'0', b'1', b'1', b'0', 10, 10, 10, 10, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (954, 91, 'updated_by', '修改人', 'bigint(20) unsigned', 'uint64', 'number', 'UpdatedBy', 'updatedBy', b'0', b'0', b'0', b'0', b'0', b'0', b'1', b'0', 11, 11, 11, 11, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (955, 91, 'demo_status', '状态', 'tinyint(4)', 'int', 'number', 'DemoStatus', 'demoStatus', b'0', b'0', b'1', b'1', b'1', b'1', b'1', b'1', 12, 12, 12, 12, 'EQ', 'radio', 'sys_normal_disable', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (956, 91, 'demo_cate', '分类', 'varchar(30)', 'string', 'string', 'DemoCate', 'demoCate', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 13, 13, 13, 13, 'EQ', 'checkbox', 'sys_oper_log_status', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (957, 91, 'demo_thumb', '头像', 'text', 'string', 'string', 'DemoThumb', 'demoThumb', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'0', 14, 14, 14, 14, 'EQ', 'imagefile', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (958, 91, 'demo_photo', '相册', 'text', 'string', 'string', 'DemoPhoto', 'demoPhoto', b'0', b'0', b'0', b'1', b'1', b'0', b'1', b'0', 15, 15, 15, 15, 'EQ', 'images', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (959, 91, 'demo_info', '个人描述', 'text', 'string', 'string', 'DemoInfo', 'demoInfo', b'0', b'0', b'0', b'1', b'1', b'0', b'1', b'0', 16, 16, 16, 16, 'EQ', 'richtext', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (960, 91, 'demo_file', '相关附件', 'text', 'string', 'string', 'DemoFile', 'demoFile', b'0', b'0', b'0', b'1', b'1', b'0', b'1', b'0', 17, 17, 17, 17, 'EQ', 'files', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (961, 92, 'id', '分类id', 'int(10) unsigned', 'uint', 'number', 'Id', 'id', b'1', b'1', b'1', b'0', b'0', b'1', b'1', b'0', 1, 1, 1, 1, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (962, 92, 'class_name', '分类名', 'varchar(30)', 'string', 'string', 'ClassName', 'className', b'0', b'0', b'1', b'1', b'1', b'1', b'1', b'1', 2, 2, 2, 2, 'LIKE', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (963, 93, 'id', '', 'int(11) unsigned', 'uint', 'number', 'Id', 'id', b'1', b'1', b'1', b'0', b'0', b'1', b'0', b'0', 1, 1, 1, 1, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (964, 93, 'parent_id', '父级ID', 'int(10) unsigned', 'uint', 'number', 'ParentId', 'parentId', b'0', b'0', b'0', b'1', b'1', b'0', b'1', b'0', 2, 2, 2, 2, 'EQ', 'select', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (965, 93, 'demo_name', '姓名', 'varchar(20)', 'string', 'string', 'DemoName', 'demoName', b'0', b'0', b'1', b'1', b'1', b'1', b'1', b'1', 3, 3, 3, 3, 'LIKE', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (966, 93, 'demo_age', '年龄', 'int(10) unsigned', 'uint', 'number', 'DemoAge', 'demoAge', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 4, 4, 4, 4, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (967, 93, 'classes', '班级', 'varchar(30)', 'string', 'string', 'Classes', 'classes', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 5, 5, 5, 5, 'EQ', 'select', '', 'demo_gen_class', 'DemoGenClass', 'demo', 'demo_gen_class', 'internal/app/demo', 'id', 'class_name', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (968, 93, 'demo_born', '出生年月', 'datetime', 'Time', 'string', 'DemoBorn', 'demoBorn', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 6, 6, 6, 6, 'EQ', 'date', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (969, 93, 'demo_gender', '性别', 'tinyint(3) unsigned', 'uint', 'number', 'DemoGender', 'demoGender', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 7, 7, 7, 7, 'EQ', 'radio', 'sys_user_sex', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (970, 93, 'created_at', '创建日期', 'datetime', 'Time', 'string', 'CreatedAt', 'createdAt', b'0', b'0', b'0', b'0', b'0', b'1', b'1', b'0', 8, 8, 8, 8, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (971, 93, 'updated_at', '修改日期', 'datetime', 'Time', 'string', 'UpdatedAt', 'updatedAt', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', 9, 9, 9, 9, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (972, 93, 'deleted_at', '删除日期', 'datetime', 'Time', 'string', 'DeletedAt', 'deletedAt', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', 10, 10, 10, 10, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (973, 93, 'created_by', '创建人', 'bigint(20) unsigned', 'uint64', 'number', 'CreatedBy', 'createdBy', b'0', b'0', b'0', b'0', b'0', b'1', b'1', b'0', 11, 11, 11, 11, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (974, 93, 'updated_by', '修改人', 'bigint(20) unsigned', 'uint64', 'number', 'UpdatedBy', 'updatedBy', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', 12, 12, 12, 12, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (975, 93, 'demo_status', '状态', 'tinyint(4)', 'int', 'number', 'DemoStatus', 'demoStatus', b'0', b'0', b'1', b'1', b'1', b'1', b'1', b'1', 13, 13, 13, 13, 'EQ', 'radio', 'sys_normal_disable', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (976, 93, 'demo_cate', '分类', 'varchar(30)', 'string', 'string', 'DemoCate', 'demoCate', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'0', 14, 14, 14, 14, 'EQ', 'select', 'sys_oper_log_status', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); +INSERT INTO `tools_gen_table_column` VALUES (977, 91, 'classes_two', '班级2', 'varchar(30)', 'string', 'string', 'ClassesTwo', 'classesTwo', b'0', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 4, 4, 4, 4, 'EQ', 'select', '', 'demo_gen_class', 'DemoGenClass', 'demo', 'demo_gen_class', 'internal/app/demo', 'id', 'class_name', 12, 1, b'0', 100, b'0', b'0', b'0', '', ''); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/resource/i18n/.gitkeep b/resource/i18n/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resource/public/html/.gitkeep b/resource/public/html/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resource/public/plugin/.gitkeep b/resource/public/plugin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resource/scripts/.gitkeep b/resource/scripts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resource/template/.gitkeep b/resource/template/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resource/template/vm/go/api.template b/resource/template/vm/go/api.template new file mode 100644 index 0000000..b150b67 --- /dev/null +++ b/resource/template/vm/go/api.template @@ -0,0 +1,120 @@ +// ========================================================================== +// GFast自动生成api操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: api/v1/{{.table.ModuleName }}/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}}相关参数 +// company:云南奇讯科技有限公司 +// ========================================================================== +//// +package {{.table.ModuleName }} +//// +{{$hasUpFile:=false}} +{{$hasArr:=false}} +{{range $index,$column :=.table.Columns}} +{{if eq $column.HtmlType "imagefile" "images" "file" "files" }} + {{$hasUpFile = true}} +{{end}} +{{if eq $column.HtmlType "checkbox"}} + {{$hasArr = true}} +{{end}} +{{end}} + +import ( + {{if $hasArr}} + "github.com/gogf/gf/v2/container/garray" + {{end}} + "github.com/gogf/gf/v2/frame/g" + {{if .table.HasTimeColumn}} + "github.com/gogf/gf/v2/os/gtime" + {{end}} + commonApi "{{.goModName}}/api/v1/common" + {{if $hasUpFile}} + comModel "{{.goModName}}/internal/app/common/model" + {{end}} + "{{.goModName}}/{{.table.PackageName}}/model" +) + + +// {{.table.ClassName}}SearchReq 分页请求参数 +type {{.table.ClassName}}SearchReq struct { + g.Meta `path:"/list" tags:"{{$.table.FunctionName}}" method:"get" summary:"{{$.table.FunctionName}}列表"` + {{range $index, $column := .table.QueryColumns}} + {{$column.GoField}} {{if or (eq $column.GoType "Time") (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") (eq $column.GoType "float") (eq $column.GoType "float64") (eq $column.GoType "bool")}}{{if eq $column.QueryType "BETWEEN"}}[]{{end}}string{{else}}{{if eq $column.QueryType "BETWEEN"}}[]{{end}}{{$column.GoType}}{{end}} `p:"{{$column.HtmlField}}"{{if ne $column.FieldValidation ""}} v:"{{$column.FieldValidation}}"{{end}}` //{{$column.ColumnComment}} + {{end}} + commonApi.PageReq + commonApi.Author +} + + +// {{.table.ClassName}}SearchRes 列表返回结果 +type {{.table.ClassName}}SearchRes struct { + g.Meta `mime:"application/json"` + commonApi.ListRes + List []*model.{{.table.ClassName}}ListRes `json:"list"` +} + + +// {{.table.ClassName}}AddReq 添加操作请求参数 +type {{.table.ClassName}}AddReq struct { + g.Meta `path:"/add" tags:"{{$.table.FunctionName}}" method:"post" summary:"{{$.table.FunctionName}}添加"` + commonApi.Author + {{if .table.IsPkInsertable}} + {{.table.PkColumn.GoField}} {{.table.PkColumn.GoType}} `p:"{{.table.PkColumn.HtmlField}}" v:"required#主键ID不能为空"` + {{end}} + {{range $index, $column := .table.EditColumns}} + {{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else if eq $column.HtmlType "checkbox"}}garray.StrArray{{else}}{{$column.GoType}}{{end}} `p:"{{$column.HtmlField}}" {{if $column.IsRequired}}v:"required#{{$column.ColumnComment}}不能为空"{{end}}` + {{end}} + {{if .table.HasCreatedBy}} + CreatedBy uint64 + {{end}} +} + +// {{.table.ClassName}}AddRes 添加操作返回结果 +type {{.table.ClassName}}AddRes struct { + commonApi.EmptyRes +} + + +// {{.table.ClassName}}EditReq 修改操作请求参数 +type {{.table.ClassName}}EditReq struct { + g.Meta `path:"/edit" tags:"{{$.table.FunctionName}}" method:"put" summary:"{{$.table.FunctionName}}修改"` + commonApi.Author + {{.table.PkColumn.GoField}} {{.table.PkColumn.GoType}} `p:"{{.table.PkColumn.HtmlField}}" v:"required#主键ID不能为空"` + {{range $index, $column := .table.EditColumns}} + {{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else if eq $column.HtmlType "checkbox"}}garray.StrArray{{else}}{{$column.GoType}}{{end}} `p:"{{$column.HtmlField}}" {{if $column.IsRequired}}v:"required#{{$column.ColumnComment}}不能为空"{{end}}` + {{end}} + {{if .table.HasUpdatedBy}} + UpdatedBy uint64 + {{end}} +} + +// {{.table.ClassName}}EditRes 修改操作返回结果 +type {{.table.ClassName}}EditRes struct { + commonApi.EmptyRes +} + +// {{.table.ClassName}}GetReq 获取一条数据请求 +type {{.table.ClassName}}GetReq struct { + g.Meta `path:"/get" tags:"{{$.table.FunctionName}}" method:"get" summary:"获取{{$.table.FunctionName}}信息"` + commonApi.Author + {{$.table.PkColumn.GoField}} {{$.table.PkColumn.GoType}} `p:"{{$.table.PkColumn.HtmlField}}" v:"required#主键必须"` //通过主键获取 +} + +// {{.table.ClassName}}GetRes 获取一条数据结果 +type {{.table.ClassName}}GetRes struct { + g.Meta `mime:"application/json"` + *model.{{.table.ClassName}}InfoRes +} + +// {{.table.ClassName}}DeleteReq 删除数据请求 +type {{.table.ClassName}}DeleteReq struct { + g.Meta `path:"/delete" tags:"{{$.table.FunctionName}}" method:"delete" summary:"删除{{$.table.FunctionName}}"` + commonApi.Author + {{$.table.PkColumn.GoField}}s []{{$.table.PkColumn.GoType}} `p:"{{$.table.PkColumn.HtmlField}}s" v:"required#主键必须"` //通过主键删除 +} + +// {{.table.ClassName}}DeleteRes 删除数据返回 +type {{.table.ClassName}}DeleteRes struct { + commonApi.EmptyRes +} diff --git a/resource/template/vm/go/controller.template b/resource/template/vm/go/controller.template new file mode 100644 index 0000000..79eca93 --- /dev/null +++ b/resource/template/vm/go/controller.template @@ -0,0 +1,68 @@ +// ========================================================================== +// GFast自动生成controller操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/controller/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// + +{{$structName := .table.BusinessName | CaseCamelLower}} + +package controller +//// + +import ( + "context" + "{{.goModName}}/api/v1/{{.table.ModuleName}}" + "{{.goModName}}/{{.table.PackageName}}/service" + {{if ne $.table.ModuleName "system"}} + systemController "{{.goModName}}/internal/app/system/controller" + {{end}} +) +//// +type {{$structName}}Controller struct { + {{if ne $.table.ModuleName "system"}} + systemController.BaseController + {{else}} + BaseController + {{end}} +} +//// +var {{.table.ClassName}} = new({{$structName}}Controller) +//// +// List 列表 +func (c *{{$structName}}Controller) List(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}SearchReq) (res *{{.table.ModuleName}}.{{.table.ClassName}}SearchRes, err error) { + res, err = service.{{.table.ClassName}}().List(ctx, req) + return +} + +//// +// Get 获取{{.table.FunctionName}} +func (c *{{$structName}}Controller) Get(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}GetReq) (res *{{.table.ModuleName}}.{{.table.ClassName}}GetRes, err error) { + res = new({{.table.ModuleName}}.{{.table.ClassName}}GetRes) + res.{{.table.ClassName}}InfoRes,err = service.{{.table.ClassName}}().GetBy{{.table.PkColumn.GoField}}(ctx, req.{{.table.PkColumn.GoField}}) + return +} + +//// +// Add 添加{{.table.FunctionName}} +func (c *{{$structName}}Controller) Add(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}AddReq) (res *{{.table.ModuleName}}.{{.table.ClassName}}AddRes, err error) { + err = service.{{.table.ClassName}}().Add(ctx, req) + return +} + +//// +// Edit 修改{{.table.FunctionName}} +func (c *{{$structName}}Controller) Edit(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}EditReq) (res *{{.table.ModuleName}}.{{.table.ClassName}}EditRes, err error) { + err = service.{{.table.ClassName}}().Edit(ctx, req) + return +} + +//// +// Delete 删除{{.table.FunctionName}} +func (c *{{$structName}}Controller) Delete(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}DeleteReq) (res *{{.table.ModuleName}}.{{.table.ClassName}}DeleteRes, err error) { + err = service.{{.table.ClassName}}().Delete(ctx, req.{{$.table.PkColumn.GoField}}s) + return +} \ No newline at end of file diff --git a/resource/template/vm/go/dao.template b/resource/template/vm/go/dao.template new file mode 100644 index 0000000..5ee7a78 --- /dev/null +++ b/resource/template/vm/go/dao.template @@ -0,0 +1,32 @@ +// ========================================================================== +// GFast自动生成dao操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/dao/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// +package dao +//// +import ( + "{{.goModName}}/{{.table.PackageName}}/dao/internal" +) + + +// {{.table.BusinessName | CaseCamelLower}}Dao is the manager for logic model data accessing and custom defined data operations functions management. +// You can define custom methods on it to extend its functionality as you wish. +type {{.table.BusinessName | CaseCamelLower}}Dao struct { + *internal.{{.table.BusinessName | CaseCamel}}Dao +} + +var ( + // {{.table.ClassName}} is globally public accessible object for table tools_gen_table operations. + {{.table.ClassName}} = {{.table.BusinessName | CaseCamelLower}}Dao{ + internal.New{{.table.ClassName}}Dao(), + } +) + +//// +// Fill with you ideas below. +//// diff --git a/resource/template/vm/go/dao_internal.template b/resource/template/vm/go/dao_internal.template new file mode 100644 index 0000000..31af0d8 --- /dev/null +++ b/resource/template/vm/go/dao_internal.template @@ -0,0 +1,90 @@ +// ========================================================================== +// GFast自动生成dao internal操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/dao/internal/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// +package internal +//// +import ( + "context" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +//// +// {{.table.ClassName}}Dao is the manager for logic model data accessing and custom defined data operations functions management. +type {{.table.ClassName}}Dao 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 {{.table.ClassName}}Columns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage. +} + +//// +// {{.table.ClassName}}Columns defines and stores column names for table {{.table.TableName}}. +type {{.table.ClassName}}Columns struct { + {{range $index, $column := .table.Columns}} + {{$column.GoField}} string // {{$column.ColumnComment}} + {{end}} +} + +//// +var {{.table.BusinessName | CaseCamelLower}}Columns = {{.table.ClassName}}Columns{ + {{range $index, $column := .table.Columns}} + {{$column.GoField}}: "{{$column.ColumnName}}", + {{end}} +} + +//// +// New{{.table.ClassName}}Dao creates and returns a new DAO object for table data access. +func New{{.table.ClassName}}Dao() *{{.table.ClassName}}Dao { + return &{{.table.ClassName}}Dao{ + group: "default", + table: "{{.table.TableName}}", + columns:{{.table.BusinessName | CaseCamelLower}}Columns, + } +} + +//// +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *{{.table.ClassName}}Dao) DB() gdb.DB { + return g.DB(dao.group) +} + +//// +// Table returns the table name of current dao. +func (dao *{{.table.ClassName}}Dao) Table() string { + return dao.table +} + +//// +// Columns returns all column names of current dao. +func (dao *{{.table.ClassName}}Dao) Columns() {{.table.ClassName}}Columns { + return dao.columns +} + +//// +// Group returns the configuration group name of database of current dao. +func (dao *{{.table.ClassName}}Dao) Group() string { + return dao.group +} + +//// +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *{{.table.ClassName}}Dao) 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 *{{.table.ClassName}}Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} \ No newline at end of file diff --git a/resource/template/vm/go/logic.template b/resource/template/vm/go/logic.template new file mode 100644 index 0000000..d9ec78c --- /dev/null +++ b/resource/template/vm/go/logic.template @@ -0,0 +1,309 @@ +// ========================================================================== +// GFast自动生成logic操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/logic/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// + +{{$structName := .table.BusinessName | CaseCamelLower}} + +package logic +//// +{{$gjson:=false}} +{{$usedSystemModule:=false}} +{{range $index, $column := .table.Columns}} +{{if eq $column.HtmlType "images" "file" "files"}} +{{$gjson = true}} +{{end}} +{{if eq $column.HtmlField "createdBy" "updatedBy" "deletedBy"}} +{{$usedSystemModule = true}} +{{end}} +{{end}} + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + {{if or .table.HasConversion (eq .table.TplCategory "tree")}} + "github.com/gogf/gf/v2/util/gconv" + {{end}} + "{{.goModName}}/api/v1/{{.table.ModuleName}}" + "{{.goModName}}/{{.table.PackageName}}/dao" + "{{.goModName}}/{{.table.PackageName}}/model" + "{{.goModName}}/{{.table.PackageName}}/model/do" + "{{.goModName}}/{{.table.PackageName}}/service" + {{if ne .table.TplCategory "tree"}} + "{{.goModName}}/internal/app/system/consts" + {{end}} + {{if $usedSystemModule}} + systemService "{{.goModName}}/internal/app/system/service" + {{end}} + {{if or (eq .table.TplCategory "tree") $gjson}} + "{{.goModName}}/library/libUtils" + {{end}} + "{{.goModName}}/library/liberr" +) + + +{{$pk:=""}} +{{$pkGoField:=""}} + +{{$createdAt:=""}} +{{$createdAtGoField:=""}} + +{{range $index, $column := .table.Columns}} +{{if $column.IsPk}} + {{$pk = $column.ColumnName}} + {{$pkGoField = $column.GoField}} +{{end}} +{{if eq $column.ColumnName "created_at"}} + {{$createdAt = $column.ColumnName}} + {{$createdAtGoField = $column.GoField}} +{{end}} +{{end}} +//// +func init() { + service.Register{{.table.ClassName}}(New()) +} +//// +func New() *s{{.table.ClassName}} { + return &s{{.table.ClassName}}{} +} +//// +type s{{.table.ClassName}} struct{} +//// +func (s *s{{.table.ClassName}})List(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}SearchReq) (listRes *{{.table.ModuleName}}.{{.table.ClassName}}SearchRes, err error){ + listRes = new({{.table.ModuleName}}.{{.table.ClassName}}SearchRes) + err = g.Try(ctx, func(ctx context.Context) { + m := dao.{{.table.ClassName}}.Ctx(ctx).WithAll() + {{range $index, $column := .table.QueryColumns}} + {{if eq $column.QueryType "LIKE"}} + if req.{{$column.GoField}} != "" { + m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" like ?", "%"+req.{{$column.GoField}}+"%") + } + {{else if eq $column.QueryType "EQ"}} + {{if eq $column.GoType "string"}} + if req.{{$column.GoField}} != "" { + m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" = ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}{{if ne $column.FieldConversion ""}}){{end}}) + } + {{else if eq $column.GoType "Time"}} + {{if eq $column.ColumnName "created_at"}} + if req.BeginTime != "" { + m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" >=", req.BeginTime) + } + if req.EndTime != "" { + m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" <", req.EndTime) + } + {{else}} + if req.{{$column.GoField}} != "" { + m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" = ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}{{if ne $column.FieldConversion ""}}){{end}}) + } + {{end}} + {{else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") (eq $column.GoType "bool")}} + if req.{{$column.GoField}} != "" { + m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" = ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}{{if ne $column.FieldConversion ""}}){{end}}) + } + {{end}} + {{else if eq $column.QueryType "BETWEEN" }} + if req.{{$column.GoField}} != nil && len(req.{{$column.GoField}}) > 0 { + if req.{{$column.GoField}}[0] != "" { + m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" >= ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}[0]{{if ne $column.FieldConversion ""}}){{end}}) + } + if len(req.{{$column.GoField}}) > 1 && req.{{$column.GoField}}[1] != "" { + m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" < ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}[1]{{if ne $column.FieldConversion ""}}){{end}}) + } + } + {{end}} + {{end}} + {{if ne .table.TplCategory "tree"}} + listRes.Total, err = m.Count() + liberr.ErrIsNil(ctx, err, "获取总行数失败") + if req.PageNum == 0 { + req.PageNum = 1 + } + listRes.CurrentPage = req.PageNum + if req.PageSize == 0 { + req.PageSize = consts.PageSize + } + order:= "{{.table.SortColumn}} {{.table.SortType}}" + if req.OrderBy!=""{ + order = req.OrderBy + } + var res []*model.{{.table.ClassName}}InfoRes + err = m.Fields({{.table.ModuleName}}.{{.table.ClassName}}SearchRes{}).Page(req.PageNum, req.PageSize).Order(order).Scan(&res) + {{else}} + order:= "{{.table.SortColumn}} {{.table.SortType}}" + if req.OrderBy!=""{ + order = req.OrderBy + } + var res []*model.{{.table.ClassName}}InfoRes + err = m.Fields({{.table.ModuleName}}.{{.table.ClassName}}SearchRes{}).Order(order).Scan(&res) + {{end}} + liberr.ErrIsNil(ctx, err, "获取数据失败") + listRes.List = make([]*model.{{.table.ClassName}}ListRes,len(res)) + for k,v:=range res{ + {{range $index, $column := .table.Columns}} + {{if and $column.IsList (eq $column.HtmlType "images" "file" "files")}} + {{$column.HtmlField}}:= ([]*comModel.UpFile)(nil) + err = gjson.DecodeTo(v.{{$column.GoField}},&{{$column.HtmlField}}) + liberr.ErrIsNil(ctx,err) + {{end}} + {{end}} + listRes.List[k] = &model.{{.table.ClassName}}ListRes{ + {{if eq .table.TplCategory "tree"}} + {{range $index, $column := .table.Columns}} + {{if or (eq $column.HtmlField $.table.TreeCode) (eq $column.HtmlField $.table.TreeParentCode) (eq $column.HtmlField $.table.TreeName) }} + {{$column.GoField}} : v.{{$column.GoField}}, + {{end}} + {{end}} + {{range $index, $column := .table.Columns}} + {{if and $column.IsList (ne $column.HtmlField $.table.TreeCode) (ne $column.HtmlField $.table.TreeParentCode) (ne $column.HtmlField $.table.TreeName) }} + {{if eq $column.HtmlType "images" "file" "files"}} + {{$column.GoField}} : {{$column.HtmlField}}, + {{else}} + {{$column.GoField}} : v.{{$column.GoField}}, + {{range $ti, $linkedTable := $.table.LinkedTables}} + {{if eq $column.LinkTableClass $linkedTable.ClassName}} + Linked{{$column.GoField}}:v.Linked{{$column.GoField}}, + {{end}} + {{end}} + {{end}} + {{end}} + {{end}} + {{else}} + {{if not .table.IsPkListable}} + {{.table.PkColumn.GoField}} : v.{{.table.PkColumn.GoField}}, + {{end}} + {{range $index, $column := .table.ListColumns}} + {{if eq $column.HtmlType "images" "file" "files"}} + {{$column.GoField}} : {{$column.HtmlField}}, + {{else}} + {{$column.GoField}} : v.{{$column.GoField}}, + {{range $ti, $linkedTable := $.table.LinkedTables}} + {{if eq $column.LinkTableClass $linkedTable.ClassName}} + Linked{{$column.GoField}}:v.Linked{{$column.GoField}}, + {{end}} + {{end}} + {{end}} + {{end}} + {{end}} + } + } + }) + return +} +//// +func (s *s{{.table.ClassName}})GetBy{{$pkGoField}}(ctx context.Context, {{$.table.PkColumn.HtmlField}} {{$.table.PkColumn.GoType}}) (res *model.{{.table.ClassName}}InfoRes,err error){ + err =g.Try(ctx, func(ctx context.Context){ + err = dao.{{.table.ClassName}}.Ctx(ctx).WithAll().Where(dao.{{.table.ClassName}}.Columns().{{$pkGoField}}, {{$.table.PkColumn.HtmlField}}).Scan(&res) + liberr.ErrIsNil(ctx,err,"获取信息失败") + }) + return +} +//// +func (s *s{{.table.ClassName}})Add(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}AddReq) (err error){ + err = g.Try(ctx, func(ctx context.Context) { + {{range $index, $column := .table.EditColumns}} + {{if eq $column.HtmlType "checkbox"}} + {{$column.HtmlField}} := "" + req.{{$column.GoField}}.FilterEmpty() + if !req.{{$column.GoField}}.IsEmpty(){ + {{$column.HtmlField}}=req.{{$column.GoField}}.Join(",") + } + {{else if eq $column.HtmlType "images" "file" "files"}} + for _,obj:=range req.{{$column.GoField}}{ + obj.Url,err = libUtils.GetFilesPath(ctx,obj.Url) + liberr.ErrIsNil(ctx, err) + } + {{end}} + {{end}} + _, err = dao.{{.table.ClassName}}.Ctx(ctx).Insert(do.{{.table.ClassName}}{ + {{if .table.IsPkInsertable}} + {{.table.PkColumn.GoField}}:req.{{.table.PkColumn.GoField}}, + {{end}} + {{range $index, $column := .table.EditColumns}} + {{if eq $column.HtmlType "checkbox"}} + {{$column.GoField}}:{{$column.HtmlField}}, + {{else}} + {{$column.GoField}}:req.{{$column.GoField}}, + {{end}} + {{end}} + {{if .table.HasCreatedBy}} + CreatedBy:systemService.Context().GetUserId(ctx), + {{end}} + }) + liberr.ErrIsNil(ctx, err, "添加失败") + }) + return +} +//// +func (s *s{{.table.ClassName}})Edit(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}EditReq) (err error){ + err = g.Try(ctx, func(ctx context.Context) { + {{range $index, $column := .table.EditColumns}} + {{if eq $column.HtmlType "checkbox"}} + {{$column.HtmlField}} := "" + req.{{$column.GoField}}.FilterEmpty() + if !req.{{$column.GoField}}.IsEmpty(){ + {{$column.HtmlField}}=req.{{$column.GoField}}.Join(",") + } + {{else if eq $column.HtmlType "images" "file" "files"}} + for _,obj:=range req.{{$column.GoField}}{ + obj.Url,err = libUtils.GetFilesPath(ctx,obj.Url) + liberr.ErrIsNil(ctx, err) + } + {{end}} + {{end}} + _, err = dao.{{.table.ClassName}}.Ctx(ctx).WherePri(req.{{.table.PkColumn.GoField}}).Update(do.{{.table.ClassName}}{ + {{range $index, $column := .table.EditColumns}} + {{if eq $column.HtmlType "checkbox"}} + {{$column.GoField}}:{{$column.HtmlField}}, + {{else}} + {{$column.GoField}}:req.{{$column.GoField}}, + {{end}} + {{end}} + {{if .table.HasUpdatedBy}} + UpdatedBy:systemService.Context().GetUserId(ctx), + {{end}} + }) + liberr.ErrIsNil(ctx, err, "修改失败") + }) + return +} +//// +func (s *s{{.table.ClassName}})Delete(ctx context.Context, {{$.table.PkColumn.HtmlField}}s []{{$.table.PkColumn.GoType}}) (err error){ + err = g.Try(ctx,func(ctx context.Context){ + {{if eq .table.TplCategory "tree"}} + ids, err = s.GetChildrenIds(ctx,ids) + liberr.ErrIsNil(ctx,err) + {{end}} + _, err = dao.{{.table.ClassName}}.Ctx(ctx).Delete(dao.{{.table.ClassName}}.Columns().{{$pkGoField}}+" in (?)", {{$.table.PkColumn.HtmlField}}s) + liberr.ErrIsNil(ctx,err,"删除失败") + }) + return +} + +//// +{{if eq .table.TplCategory "tree"}} +// GetChildrenIds 通过ID获取子级ID +func (s *s{{.table.ClassName}})GetChildrenIds(ctx context.Context,ids []{{$.table.PkColumn.GoType}}) (returnIds []{{$.table.PkColumn.GoType}},err error) { + err = g.Try(ctx,func(ctx context.Context){ + //获取所有 + var all *{{.table.ModuleName}}.{{.table.ClassName}}SearchRes + all, err = s.List(ctx, &{{.table.ModuleName}}.{{.table.ClassName}}SearchReq{}) + liberr.ErrIsNil(ctx,err) + list := make(g.List, len(all.List)) + for k, info := range all.List { + list[k] = gconv.Map(info) + } + for _, id := range ids { + children := libUtils.FindSonByParentId(list, id, "{{.table.TreeParentCode}}", "{{.table.TreeCode}}") + for _, cid := range children { + returnIds = append(ids, cid["{{.table.TreeCode}}"].({{$.table.PkColumn.GoType}})) + } + } + }) + return +} +{{end}} \ No newline at end of file diff --git a/resource/template/vm/go/model.template b/resource/template/vm/go/model.template new file mode 100644 index 0000000..308c218 --- /dev/null +++ b/resource/template/vm/go/model.template @@ -0,0 +1,74 @@ +// ========================================================================== +// GFast自动生成model操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/model/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// +package model +//// +import ( + {{if .table.HasTimeColumn}} + "github.com/gogf/gf/v2/os/gtime" + {{end}} + "github.com/gogf/gf/v2/util/gmeta" +) + +//// +// {{.table.ClassName}}InfoRes is the golang structure for table {{.table.TableName}}. +type {{.table.ClassName}}InfoRes struct { + gmeta.Meta `orm:"table:{{.table.TableName}}"` + {{range $index, $column := .table.Columns}} + {{if $column.IsPk}}{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `orm:"{{$column.ColumnName}},primary" json:"{{$column.HtmlField}}"` // {{$column.ColumnComment}} {{else}}{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `orm:"{{$column.ColumnName}}" json:"{{$column.HtmlField}}"` // {{$column.ColumnComment}} {{end}} + {{range $ti, $linkedTable := $.table.LinkedTables}} + {{if eq $column.LinkTableClass $linkedTable.ClassName}} + Linked{{$column.GoField}} *Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" json:"linked{{$column.GoField}}"` + {{end}} + {{end}} + {{end}} +} + +//// +{{range $ti, $linkedTable := .table.LinkedTables}} +type Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} struct { + gmeta.Meta `orm:"table:{{$linkedTable.TableName}}"` + {{range $ci, $linkedColumn := $linkedTable.RefColumns.Values}} + {{$linkedColumn.GoField}} {{if eq $linkedColumn.GoType "Time"}}*gtime.Time{{else}}{{$linkedColumn.GoType}}{{end}} `orm:"{{$linkedColumn.ColumnName}}" json:"{{$linkedColumn.HtmlField}}"` // {{$linkedColumn.ColumnComment}} + {{end}} +} +{{end}} + +//// +type {{.table.ClassName}}ListRes struct{ + {{if eq .table.TplCategory "tree"}} + {{range $index, $column := .table.Columns}} + {{if or (eq $column.HtmlField $.table.TreeCode) (eq $column.HtmlField $.table.TreeParentCode) (eq $column.HtmlField $.table.TreeName) }} + {{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}} `json:"{{$column.HtmlField}}"` + {{end}} + {{end}} + {{range $index, $column := .table.Columns}} + {{if and $column.IsList (ne $column.HtmlField $.table.TreeCode) (ne $column.HtmlField $.table.TreeParentCode) (ne $column.HtmlField $.table.TreeName) }} + {{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}} `json:"{{$column.HtmlField}}"` + {{range $ti, $linkedTable := $.table.LinkedTables}} + {{if eq $column.LinkTableClass $linkedTable.ClassName}} + Linked{{$column.GoField}} *Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" json:"linked{{$column.GoField}}"` + {{end}} + {{end}} + {{end}} + {{end}} + {{else}} + {{if not .table.IsPkListable }} + {{.table.PkColumn.GoField}} {{.table.PkColumn.GoType}} `json:"{{.table.PkColumn.HtmlField}}"` + {{end}} + {{range $index, $column := .table.ListColumns}} + {{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}} `json:"{{$column.HtmlField}}"` + {{range $ti, $linkedTable := $.table.LinkedTables}} + {{if eq $column.LinkTableClass $linkedTable.ClassName}} + Linked{{$column.GoField}} *Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" json:"linked{{$column.GoField}}"` + {{end}} + {{end}} + {{end}} + {{end}} +} \ No newline at end of file diff --git a/resource/template/vm/go/model_do.template b/resource/template/vm/go/model_do.template new file mode 100644 index 0000000..2266cae --- /dev/null +++ b/resource/template/vm/go/model_do.template @@ -0,0 +1,28 @@ +// ========================================================================== +// GFast自动生成model entity操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/model/entity/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// + +package do + +//// +import ( + {{if .table.HasTimeColumn}} + "github.com/gogf/gf/v2/os/gtime" + {{end}} + "github.com/gogf/gf/v2/util/gmeta" +) + +//// +// {{.table.ClassName}} is the golang structure for table {{.table.TableName}}. +type {{.table.ClassName}} struct { + gmeta.Meta `orm:"table:{{.table.TableName}}, do:true"` + {{range $index, $column := .table.Columns}} + {{if $column.IsPk}}{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}interface{}{{end}} `orm:"{{$column.ColumnName}},primary" json:"{{$column.HtmlField}}"` // {{$column.ColumnComment}} {{else}}{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}interface{}{{end}} `orm:"{{$column.ColumnName}}" json:"{{$column.HtmlField}}"` // {{$column.ColumnComment}} {{end}} + {{end}} +} \ No newline at end of file diff --git a/resource/template/vm/go/model_entity.template b/resource/template/vm/go/model_entity.template new file mode 100644 index 0000000..d7b26ea --- /dev/null +++ b/resource/template/vm/go/model_entity.template @@ -0,0 +1,46 @@ +// ========================================================================== +// GFast自动生成model entity操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/model/entity/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// + +package entity + +//// +import ( + {{if .table.HasTimeColumn}} + "github.com/gogf/gf/v2/os/gtime" + {{end}} + "github.com/gogf/gf/v2/util/gmeta" +) + +//// +// {{.table.ClassName}} is the golang structure for table {{.table.TableName}}. +type {{.table.ClassName}} struct { + gmeta.Meta `orm:"table:{{.table.TableName}}"` + {{range $index, $column := .table.Columns}} + {{if $column.IsPk}}{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `orm:"{{$column.ColumnName}},primary" json:"{{$column.HtmlField}}"` // {{$column.ColumnComment}} {{else}}{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `orm:"{{$column.ColumnName}}" json:"{{$column.HtmlField}}"` // {{$column.ColumnComment}} {{end}} + {{if ne $column.LinkTableName ""}} + {{range $ti, $linkedTable := $.table.LinkedTables}} + {{if eq $column.LinkTableClass $linkedTable.ClassName}} + Linked{{$column.GoField}} *Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" json:"linked{{$column.GoField}}"` + {{end}} + {{end}} + {{end}} + {{end}} + +} + +{{range $ti, $linkedTable := .table.LinkedTables}} +//// +type Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} struct { + gmeta.Meta `orm:"table:{{$linkedTable.TableName}}"` + {{range $ci, $linkedColumn := $linkedTable.RefColumns.Values}} + {{$linkedColumn.GoField}} {{if eq $linkedColumn.GoType "Time"}}*gtime.Time{{else}}{{$linkedColumn.GoType}}{{end}} `orm:"{{$linkedColumn.ColumnName}}" json:"{{$linkedColumn.HtmlField}}"` // {{$linkedColumn.ColumnComment}} + {{end}} +} +{{end}} \ No newline at end of file diff --git a/resource/template/vm/go/router.template b/resource/template/vm/go/router.template new file mode 100644 index 0000000..ce15b28 --- /dev/null +++ b/resource/template/vm/go/router.template @@ -0,0 +1,38 @@ +// ========================================================================== +// GFast自动生成router操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/router/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// +package router + +//// +import ( + "context" + "github.com/gogf/gf/v2/net/ghttp" + "{{.goModName}}/internal/app/system/service" + "{{.goModName}}/library/libRouter" +) +//// + +var R = new(Router) +//// +type Router struct{} +//// +func (router *Router) BindController(ctx context.Context, group *ghttp.RouterGroup) { + group.Group("/demo", func(group *ghttp.RouterGroup) { + //登录验证拦截 + service.GfToken().Middleware(group) + //context拦截器 + group.Middleware(service.Middleware().Ctx, service.Middleware().Auth) + //后台操作日志记录 + group.Hook("/*", ghttp.HookAfterOutput, service.OperateLog().OperationLog) + //自动绑定定义的控制器 + if err := libRouter.RouterAutoBind(router, ctx, group); err != nil { + panic(err) + } + }) +} \ No newline at end of file diff --git a/resource/template/vm/go/router_func.template b/resource/template/vm/go/router_func.template new file mode 100644 index 0000000..084b42b --- /dev/null +++ b/resource/template/vm/go/router_func.template @@ -0,0 +1,25 @@ +// ========================================================================== +// GFast自动生成router操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/router/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// +package router + +//// +import ( + "context" + "github.com/gogf/gf/v2/net/ghttp" + "{{.goModName}}/{{.table.PackageName}}/controller" +) + +func (router *Router) Bind{{.table.ClassName}}Controller(ctx context.Context, group *ghttp.RouterGroup) { + group.Group("/{{$.table.ClassName|CaseCamelLower}}", func(group *ghttp.RouterGroup) { + group.Bind( + controller.{{.table.ClassName}}, + ) + }) +} diff --git a/resource/template/vm/go/service.template b/resource/template/vm/go/service.template new file mode 100644 index 0000000..0eb8130 --- /dev/null +++ b/resource/template/vm/go/service.template @@ -0,0 +1,54 @@ +// ========================================================================== +// GFast自动生成service操作代码。 +// 生成日期:{{date "Y-m-d H:i:s"}} +// 生成路径: {{.table.PackageName}}/service/{{.table.TableName}}.go +// 生成人:{{.table.FunctionAuthor}} +// desc:{{.table.FunctionName}} +// company:云南奇讯科技有限公司 +// ========================================================================== +//// + +{{$structName := .table.BusinessName | CaseCamelLower}} + +package service +//// + +{{$gjson:=false}} +{{range $index, $column := .table.Columns}} +{{if eq $column.HtmlType "images" "file" "files"}} +{{$gjson = true}} +{{end}} +{{end}} + +import ( + "context" + "{{.goModName}}/api/v1/{{.table.ModuleName}}" + "{{.goModName}}/{{.table.PackageName}}/model" + {{if or .table.HasConversion (eq .table.TplCategory "tree")}} + {{end}} +) + +//// +type I{{.table.ClassName}} interface { + List(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}SearchReq) (res *{{.table.ModuleName}}.{{.table.ClassName}}SearchRes, err error) + GetBy{{.table.PkColumn.GoField}}(ctx context.Context, {{.table.PkColumn.GoField}} {{$.table.PkColumn.GoType}}) (res *model.{{.table.ClassName}}InfoRes,err error) + Add(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}AddReq) (err error) + Edit(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}EditReq) (err error) + Delete(ctx context.Context, {{$.table.PkColumn.GoField}} []{{$.table.PkColumn.GoType}}) (err error) +} + +//// +var local{{.table.ClassName}} I{{.table.ClassName}} + +//// +func {{.table.ClassName}}() I{{.table.ClassName}} { + if local{{.table.ClassName}} == nil { + panic("implement not found for interface I{{.table.ClassName}}, forgot register?") + } + return local{{.table.ClassName}} +} + +//// +func Register{{.table.ClassName}}(i I{{.table.ClassName}}) { + local{{.table.ClassName}} = i +} diff --git a/resource/template/vm/sql/sql.template b/resource/template/vm/sql/sql.template new file mode 100644 index 0000000..7716c1e --- /dev/null +++ b/resource/template/vm/sql/sql.template @@ -0,0 +1,64 @@ +/* +========================================================================== +GFast自动生成菜单SQL +生成日期:{{date "Y-m-d H:i:s"}} +生成路径: resource/data/gen_sql/{{.table.ModuleName}}/{{.table.BusinessName}}_menu.sql +生成人:{{.table.FunctionAuthor}} +========================================================================== +*/ +//// + +{{$plugin:=""}} +{{if ContainsI $.table.PackageName "plugins"}} +{{$plugin = "plugins/"}} +{{end}} + +-- 删除原有数据 +DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}'; +DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/list'; +DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/get'; +DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/add'; +DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/edit'; +DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/delete'; +{{range $index,$column:= .table.Columns}} +{{if and $column.IsStatus $column.IsList}} +DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{$.table.ModuleName}}/{{$.table.BusinessName | CaseCamelLower}}/change{{$column.GoField}}'; +{{end}} +{{end}} + +-- 当前日期 +select @now := now(); + +-- 目录 SQL +INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at` ) +VALUES(0,'{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}','{{.table.FunctionName}}管理','iconfont icon-fuwenbenkuang','','{{.table.FunctionName}}管理',0,0,1,0,'/{{$plugin}}{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}','','layout/routerView/parent',0,'sys_admin',0,@now,@now); + +-- 菜单父目录ID +SELECT @parentId := LAST_INSERT_ID(); + +-- 菜单 SQL +INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`) +VALUES(@parentId,'{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/list','{{.table.FunctionName}}列表','ele-Fold','','{{.table.FunctionName}}列表',1,0,1,0,'/{{$plugin}}{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/list','','{{$plugin}}{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/list/index',0,'sys_admin',0,@now,@now); + +-- 按钮父目录ID +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`) +VALUES(@parentId,'{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/get','{{.table.FunctionName}}查询','','','{{.table.FunctionName}}查询',2,0,1,0,'','','',0,'sys_admin',0,@now,@now); + +INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`) +VALUES(@parentId,'{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/add','{{.table.FunctionName}}添加','','','{{.table.FunctionName}}添加',2,0,1,0,'','','',0,'sys_admin',0,@now,@now); + +INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`) +VALUES(@parentId,'{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/edit','{{.table.FunctionName}}修改','','','{{.table.FunctionName}}修改',2,0,1,0,'','','',0,'sys_admin',0,@now,@now); + +INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`) +VALUES(@parentId,'{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/delete','{{.table.FunctionName}}删除','','','{{.table.FunctionName}}删除',2,0,1,0,'','','',0,'sys_admin',0,@now,@now); + +{{range $index,$column:= .table.Columns}} +{{if and $column.IsStatus $column.IsList}} +INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`) +VALUES(@parentId,'{{$plugin}}{{.apiVersion}}/{{$.table.ModuleName}}/{{$.table.BusinessName | CaseCamelLower}}/change{{$column.GoField}}','{{$.table.FunctionName}}{{$column.ColumnComment}}修改','','','{{$.table.FunctionName}}{{$column.ColumnComment}}修改',2,0,1,0,'','','',0,'sys_admin',0,@now,@now); +{{end}} +{{end}} diff --git a/resource/template/vm/ts/api.template b/resource/template/vm/ts/api.template new file mode 100644 index 0000000..5ee8c02 --- /dev/null +++ b/resource/template/vm/ts/api.template @@ -0,0 +1,108 @@ +import request from '/@/utils/request' + +{{$businessName := .table.BusinessName | CaseCamelLower}} + + +{{$plugin:=""}} +{{if ContainsI $.table.PackageName "plugins"}} +{{$plugin = "plugins/"}} +{{end}} + + +// 查询{{.table.FunctionName}}列表 +export function list{{.table.ClassName}}(query:object) { + return request({ + url: '/{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/list', + method: 'get', + params: query + }) +} + +// 查询{{.table.FunctionName}}详细 +export function get{{.table.ClassName}}({{.table.PkColumn.HtmlField}}:{{.table.PkColumn.TsType}}) { + return request({ + url: '/{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/get', + method: 'get', + params: { + {{.table.PkColumn.HtmlField}}: {{.table.PkColumn.HtmlField}}.toString() + } + }) +} + +// 新增{{.table.FunctionName}} +export function add{{.table.ClassName}}(data:object) { + return request({ + url: '/{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/add', + method: 'post', + data: data + }) +} + +// 修改{{.table.FunctionName}} +export function update{{.table.ClassName}}(data:object) { + return request({ + url: '/{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/edit', + method: 'put', + data: data + }) +} + +// 删除{{.table.FunctionName}} +export function del{{.table.ClassName}}({{.table.PkColumn.HtmlField}}s:{{.table.PkColumn.TsType}}[]) { + return request({ + url: '/{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/delete', + method: 'delete', + data:{ + {{.table.PkColumn.HtmlField}}s:{{.table.PkColumn.HtmlField}}s + } + }) +} + + +{{$getUserList:=false}} + +{{/*去重处理*/}} +{{$hasMethods:=newArray}} +{{range $index,$column:= .table.Columns}} +{{if and $column.IsStatus $column.IsList}} +// {{$.table.FunctionName}}{{$column.ColumnComment}}修改 +export function change{{$.table.ClassName}}{{$column.GoField}}({{$.table.PkColumn.HtmlField}}:{{$.table.PkColumn.TsType}},{{$column.HtmlField}}:{{$column.TsType}}) { + const data = { + {{$.table.PkColumn.HtmlField}}, + {{$column.HtmlField}} + } + return request({ + url: '/{{$plugin}}{{$.apiVersion}}/{{$.table.ModuleName}}/{{$businessName}}/change{{$column.GoField}}', + method: 'put', + data:data + }) +} +{{end}} +{{if ne $column.LinkTableName ""}} +{{if not (inArray $hasMethods (concat "list" $column.LinkTableClass))}} +{{$hasMethods = append $hasMethods (concat "list" $column.LinkTableClass)}} +// 关联{{$column.LinkTableName}}表选项 +export function list{{$column.LinkTableClass}}(query:object){ + return request({ + url: '/{{$plugin}}{{$.apiVersion}}/{{$column.LinkTableModuleName}}/{{$column.LinkTableBusinessName | CaseCamelLower}}/list', + method: 'get', + params: query + }) +} +{{end}} +{{end}} +{{if eq $column.HtmlField "createdBy" "updatedBy"}} +{{$getUserList = true}} +{{end}} +{{end}} + +{{if $getUserList}} +//获取用户信息列表 +export function getUserList(uIds:number[]){ + return request({ + url: '/{{.apiVersion|}}/system/user/getUsers', + method: 'get', + params: {ids:uIds} + }) +} +{{end}} \ No newline at end of file diff --git a/resource/template/vm/ts/model.template b/resource/template/vm/ts/model.template new file mode 100644 index 0000000..22f2b91 --- /dev/null +++ b/resource/template/vm/ts/model.template @@ -0,0 +1,75 @@ +export interface {{.table.ClassName}}TableColumns { + {{if eq .table.TplCategory "tree"}} + {{range $index, $column := .table.Columns}} + {{if or (eq $column.HtmlField $.table.TreeCode) (eq $column.HtmlField $.table.TreeParentCode) (eq $column.HtmlField $.table.TreeName) }} + {{$column.HtmlField}}:{{$column.TsType}}; // {{$column.ColumnComment}} + {{end}} + {{end}} + {{range $index, $column := .table.Columns}} + {{if and $column.IsList (ne $column.HtmlField $.table.TreeCode) (ne $column.HtmlField $.table.TreeParentCode) (ne $column.HtmlField $.table.TreeName) }} + {{$column.HtmlField}}:{{if eq $column.HtmlType "images" "file" "files"}}any[]{{else}}{{$column.TsType}}{{end}}; // {{$column.ColumnComment}} + {{end}} + {{end}} + {{else}} + {{if not .table.IsPkListable }} + {{.table.PkColumn.HtmlField}}:{{.table.PkColumn.TsType}} + {{end}} + {{range $index, $column := .table.ListColumns}} + {{if eq $column.HtmlField "createdBy" "updatedBy"}} + {{$column.HtmlField}}:string; // {{$column.ColumnComment}} + {{else}} + {{$column.HtmlField}}:{{if eq $column.HtmlType "images" "file" "files"}}any[]{{else}}{{$column.TsType}}{{end}}; // {{$column.ColumnComment}} + {{end}} + {{end}} + {{end}} + {{range $ti, $linkedTable := .table.LinkedTables}} + linked{{$.table.ClassName}}{{$linkedTable.ClassName}}:Linked{{$.table.ClassName}}{{$linkedTable.ClassName}}; + {{end}} +} + +//// +export interface {{.table.ClassName}}InfoData { + {{range $index, $column := .table.Columns}} + {{if $column.IsPk}}{{$column.HtmlField}}:{{if eq $column.HtmlType "images" "file" "files" "checkbox"}}any[]{{else if eq $column.HtmlType "radio"}}boolean{{else}}{{$column.TsType}}|undefined{{end}}; // {{$column.ColumnComment}} {{else}}{{$column.HtmlField}}:{{if eq $column.HtmlType "images" "file" "files" "checkbox"}}any[]{{else if eq $column.HtmlType "radio"}}boolean{{else}}{{$column.TsType}}|undefined{{end}}; // {{$column.ColumnComment}} {{end}} + {{end}} + {{range $ti, $linkedTable := .table.LinkedTables}} + linked{{$.table.ClassName}}{{$linkedTable.ClassName}}:Linked{{$.table.ClassName}}{{$linkedTable.ClassName}}; + {{end}} +} + +{{range $ti, $linkedTable := .table.LinkedTables}} +//// +export interface Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} { + {{range $ci, $linkedColumn := $linkedTable.RefColumns.Values}} + {{$linkedColumn.HtmlField}}:{{if eq $linkedColumn.HtmlType "images" "file" "files"}}any[]{{else}}{{$linkedColumn.TsType}}|undefined{{end}}; // {{$linkedColumn.ColumnComment}} + {{end}} +} +{{end}} + +//// +export interface {{.table.ClassName}}TableDataState { + {{.table.PkColumn.HtmlField}}s:any[]; + tableData: { + data: Array<{{.table.ClassName}}TableColumns>; + total: number; + loading: boolean; + param: { + pageNum: number; + pageSize: number; + {{range $index, $column := .table.QueryColumns}} + {{if eq $column.QueryType "BETWEEN"}} + {{$column.HtmlField}}: {{$column.TsType}}[]; + {{else}} + {{$column.HtmlField}}: {{$column.TsType}}|undefined; + {{end}}{{end}} + }; + }; +} + +//// +export interface {{.table.ClassName}}EditState{ + loading:boolean; + isShowDialog: boolean; + formData:{{.table.ClassName}}InfoData; + rules: object; +} \ No newline at end of file diff --git a/resource/template/vm/vue/detail-vue.template b/resource/template/vm/vue/detail-vue.template new file mode 100644 index 0000000..ab1a1f6 --- /dev/null +++ b/resource/template/vm/vue/detail-vue.template @@ -0,0 +1,511 @@ + + + +{{$tokenImp := false}} +{{$imgsImp := false}} +{{$editImp := false }} +{{$fileImp := false}} +{{$getUserList:=false}} + +{{range $index,$column:=.table.Columns}} + {{if eq $column.HtmlType "richtext"}} + {{$editImp = true}} + {{else if eq $column.HtmlType "imagefile"}} + {{$tokenImp = true}} + {{else if eq $column.HtmlType "images"}} + {{$imgsImp = true}} + {{else if eq $column.HtmlType "file" "files"}} + {{$fileImp = true}} + {{end}} + {{if eq $column.HtmlField "createdBy" "updatedBy"}} + {{$getUserList = true}} + {{end}} +{{end}} + +{{$plugin:=""}} +{{if ContainsI $.table.PackageName "plugins"}} + {{$plugin = "plugins/"}} +{{end}} + + + \ No newline at end of file diff --git a/resource/template/vm/vue/edit-vue.template b/resource/template/vm/vue/edit-vue.template new file mode 100644 index 0000000..e3b1dd9 --- /dev/null +++ b/resource/template/vm/vue/edit-vue.template @@ -0,0 +1,527 @@ + + +{{$tokenImp := false}} +{{$imgsImp := false}} +{{$editImp := false }} +{{$fileImp := false}} +{{$getUserList:=false}} + +{{range $index,$column:=.table.Columns}} + {{if eq $column.HtmlType "richtext"}} + {{$editImp = true}} + {{else if eq $column.HtmlType "imagefile"}} + {{$tokenImp = true}} + {{else if eq $column.HtmlType "images"}} + {{$imgsImp = true}} + {{else if eq $column.HtmlType "file" "files"}} + {{$fileImp = true}} + {{end}} + {{if eq $column.HtmlField "createdBy" "updatedBy"}} + {{$getUserList = true}} + {{end}} +{{end}} + +{{$plugin:=""}} +{{if ContainsI $.table.PackageName "plugins"}} + {{$plugin = "plugins/"}} +{{end}} + + + \ No newline at end of file diff --git a/resource/template/vm/vue/list-vue.template b/resource/template/vm/vue/list-vue.template new file mode 100644 index 0000000..cbf9414 --- /dev/null +++ b/resource/template/vm/vue/list-vue.template @@ -0,0 +1,669 @@ + + + + \ No newline at end of file diff --git a/resource/template/vm/vue/tree-vue.template b/resource/template/vm/vue/tree-vue.template new file mode 100644 index 0000000..5307f61 --- /dev/null +++ b/resource/template/vm/vue/tree-vue.template @@ -0,0 +1,673 @@ + + + + \ No newline at end of file diff --git a/task/bind_function.go b/task/bind_function.go new file mode 100644 index 0000000..03c47bb --- /dev/null +++ b/task/bind_function.go @@ -0,0 +1,43 @@ +/* +* @desc:定时任务配置 +* @company:云南省奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2021/7/16 15:45 + */ + +package task + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + "github.com/tiger1103/gfast/v3/internal/app/system/model" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +func init() { + task1 := &model.TimeTask{ + FuncName: "test1", + Run: Test1, + } + task2 := &model.TimeTask{ + FuncName: "test2", + Run: Test2, + } + checkUserOnlineTask := &model.TimeTask{ + FuncName: "checkUserOnline", + Run: service.SysUserOnline().CheckUserOnline, + } + service.TaskList().AddTask(task1) + service.TaskList().AddTask(task2) + service.TaskList().AddTask(checkUserOnlineTask) + ctx := gctx.New() + //自动执行已开启的任务 + jobs, err := service.SysJob().GetJobs(ctx) + if err != nil { + g.Log().Error(ctx, err) + return + } + for _, job := range jobs { + service.SysJob().JobStart(ctx, job) + } +} diff --git a/task/demo.go b/task/demo.go new file mode 100644 index 0000000..f8711ec --- /dev/null +++ b/task/demo.go @@ -0,0 +1,42 @@ +/* +* @desc:测试定时任务 +* @company:云南省奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2021/7/16 15:52 + */ + +package task + +import ( + "context" + "fmt" + "github.com/gogf/gf/v2/os/gtime" + "github.com/tiger1103/gfast/v3/internal/app/system/model/do" + "github.com/tiger1103/gfast/v3/internal/app/system/service" +) + +func Test1(ctx context.Context) { + fmt.Println("无参测试") + service.SysJobLog().Add(ctx, &do.SysJobLog{ + TargetName: "test1", + CreatedAt: gtime.Now(), + Result: "无参测试运行成功", + }) +} + +func Test2(ctx context.Context) { + //获取参数 + t := service.TaskList().GetByName("test2") + if t == nil { + return + } + for _, v := range t.Param { + fmt.Printf("参数:%s; ", v) + } + fmt.Println() + service.SysJobLog().Add(ctx, &do.SysJobLog{ + TargetName: "test2", + CreatedAt: gtime.Now(), + Result: "有参测试运行成功", + }) +} diff --git a/test/path_test.go b/test/path_test.go new file mode 100644 index 0000000..5e12f49 --- /dev/null +++ b/test/path_test.go @@ -0,0 +1,51 @@ +/* +* @desc:xxxx功能描述 +* @company:云南奇讯科技有限公司 +* @Author: yixiaohu +* @Date: 2022/12/8 17:48 + */ + +package test + +import ( + "fmt" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/text/gstr" + "strings" + "testing" +) + +func TestContainer(t *testing.T) { + //t.Run("testEncryptPassword", testEncryptPassword) + //t.Run("testIpToAddr", testIpToAddr) + //t.Run("testDb", testDb) + t.Run("ScanPath", scanPath) +} + +func scanPath(t *testing.T) { + var ( + packages []string + err error + packageNames []string + ) + //logic路径 + path := strings.Join([]string{"D:/goProject/p2022/gfast-v3/internal/app/demo/logic"}, "") + //获取该路径下所有需要加载的包 + packages, err = gfile.ScanDirFunc(path, "*", false, func(p string) string { + if gfile.IsDir(p) { + return p + } + return "" + }) + if err != nil { + panic(err) + } + packageNames = make([]string, len(packages)) + for k, v := range packages { + fmt.Println("111111", v) + v = gstr.Replace(v, "\\", "/") + fmt.Println("2222222", v) + packageNames[k] = gstr.SubStr(v, gstr.PosR(v, "/")+1) + } + fmt.Println("dddd", packageNames) +} diff --git a/utility/.gitkeep b/utility/.gitkeep new file mode 100644 index 0000000..e69de29