feat/modules: 更新模块引用并添加 Redis 配置
- 更新 go.work 文件,添加 modules 引用 - 修改 logic/main.go,增加 Redis 模式监听 - 更新 login/main.go,引入 modules 模块 - 修改 manifest/config/config.yaml,添加 Redis 配置信息
This commit is contained in:
540
README.md
540
README.md
@@ -1,270 +1,270 @@
|
|||||||
# blazing
|
# blazing
|
||||||
|
|
||||||
这是骄阳号开发团队的开源项目,请勿用于商业用途。
|
这是骄阳号开发团队的开源项目,请勿用于商业用途。
|
||||||
|
在软件开发中,repo、impl、mapper 和 model 是常见的分层架构组件
|
||||||
## 项目介绍
|
## 项目介绍
|
||||||
|
|
||||||
## seer-project
|
## seer-project
|
||||||
|
|
||||||
项目结构:
|
项目结构:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
. 📂 blazing
|
. 📂 blazing
|
||||||
├── 📄 README.md
|
├── 📄 README.md
|
||||||
└── 📂 common/
|
└── 📂 common/
|
||||||
│ └── 📂 bytearray/
|
│ └── 📂 bytearray/
|
||||||
│ ├── 📄 bytearray.go
|
│ ├── 📄 bytearray.go
|
||||||
│ ├── 📄 bytearray_test.go
|
│ ├── 📄 bytearray_test.go
|
||||||
│ └── 📂 contrib/
|
│ └── 📂 contrib/
|
||||||
│ └── 📂 drivers/
|
│ └── 📂 drivers/
|
||||||
│ └── 📂 mysql/
|
│ └── 📂 mysql/
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ ├── 📄 mysql.go
|
│ ├── 📄 mysql.go
|
||||||
│ └── 📂 files/
|
│ └── 📂 files/
|
||||||
│ ├── 📄 README.md
|
│ ├── 📄 README.md
|
||||||
│ └── 📂 local/
|
│ └── 📂 local/
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ ├── 📄 local.go
|
│ ├── 📄 local.go
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ └── 📂 player/
|
│ └── 📂 player/
|
||||||
│ ├── 📄 Server.go
|
│ ├── 📄 Server.go
|
||||||
│ └── 📂 socket/
|
│ └── 📂 socket/
|
||||||
│ ├── 📄 ServerEvent.go
|
│ ├── 📄 ServerEvent.go
|
||||||
│ ├── 📄 ServerOption.go
|
│ ├── 📄 ServerOption.go
|
||||||
│ └── 📂 codec/
|
│ └── 📂 codec/
|
||||||
│ ├── 📄 CrossDomain.go
|
│ ├── 📄 CrossDomain.go
|
||||||
│ ├── 📄 SocketCodec.go
|
│ ├── 📄 SocketCodec.go
|
||||||
│ ├── 📄 SocketCodec_Tomee.go
|
│ ├── 📄 SocketCodec_Tomee.go
|
||||||
│ └── 📂 handler/
|
│ └── 📂 handler/
|
||||||
│ ├── 📄 SocketHandler.go
|
│ ├── 📄 SocketHandler.go
|
||||||
│ ├── 📄 SocketHandler_Tomee.go
|
│ ├── 📄 SocketHandler_Tomee.go
|
||||||
└── 📂 cool/
|
└── 📂 cool/
|
||||||
│ ├── 📄 config.go
|
│ ├── 📄 config.go
|
||||||
│ ├── 📄 const.go
|
│ ├── 📄 const.go
|
||||||
│ ├── 📄 controller-simple.go
|
│ ├── 📄 controller-simple.go
|
||||||
│ ├── 📄 controller.go
|
│ ├── 📄 controller.go
|
||||||
│ ├── 📄 cool.go
|
│ ├── 📄 cool.go
|
||||||
│ └── 📂 coolconfig/
|
│ └── 📂 coolconfig/
|
||||||
│ ├── 📄 config.go
|
│ ├── 📄 config.go
|
||||||
│ └── 📂 cooldb/
|
│ └── 📂 cooldb/
|
||||||
│ ├── 📄 cooldb.go
|
│ ├── 📄 cooldb.go
|
||||||
│ └── 📂 coolfile/
|
│ └── 📂 coolfile/
|
||||||
│ ├── 📄 coolfile.go
|
│ ├── 📄 coolfile.go
|
||||||
│ ├── 📄 ctx.go
|
│ ├── 📄 ctx.go
|
||||||
│ ├── 📄 db.go
|
│ ├── 📄 db.go
|
||||||
│ ├── 📄 file.go
|
│ ├── 📄 file.go
|
||||||
│ ├── 📄 func.go
|
│ ├── 📄 func.go
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ ├── 📄 initdb.go
|
│ ├── 📄 initdb.go
|
||||||
│ ├── 📄 middleware.go
|
│ ├── 📄 middleware.go
|
||||||
│ ├── 📄 middleware_handler_response.go
|
│ ├── 📄 middleware_handler_response.go
|
||||||
│ ├── 📄 model.go
|
│ ├── 📄 model.go
|
||||||
│ ├── 📄 service.go
|
│ ├── 📄 service.go
|
||||||
├── 📄 docker-compose.yml
|
├── 📄 docker-compose.yml
|
||||||
├── 📄 go.work
|
├── 📄 go.work
|
||||||
├── 📄 gotidy.sh
|
├── 📄 gotidy.sh
|
||||||
├── 📄 gowork.sh
|
├── 📄 gowork.sh
|
||||||
└── 📂 logic/
|
└── 📂 logic/
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 main.go
|
│ ├── 📄 main.go
|
||||||
└── 📂 login/
|
└── 📂 login/
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ └── 📂 internal/
|
│ └── 📂 internal/
|
||||||
│ └── 📂 cmd/
|
│ └── 📂 cmd/
|
||||||
│ ├── 📄 cmd.go
|
│ ├── 📄 cmd.go
|
||||||
│ └── 📂 consts/
|
│ └── 📂 consts/
|
||||||
│ ├── 📄 consts.go
|
│ ├── 📄 consts.go
|
||||||
│ ├── 📄 main.go
|
│ ├── 📄 main.go
|
||||||
│ └── 📂 public/
|
│ └── 📂 public/
|
||||||
│ └── 📂 uploads/
|
│ └── 📂 uploads/
|
||||||
└── 📂 manifest/
|
└── 📂 manifest/
|
||||||
│ └── 📂 config/
|
│ └── 📂 config/
|
||||||
│ ├── 📄 config.yaml
|
│ ├── 📄 config.yaml
|
||||||
└── 📂 modules/
|
└── 📂 modules/
|
||||||
│ └── 📂 base/
|
│ └── 📂 base/
|
||||||
│ └── 📂 api/
|
│ └── 📂 api/
|
||||||
│ └── 📂 v1/
|
│ └── 📂 v1/
|
||||||
│ ├── 📄 base_open.go
|
│ ├── 📄 base_open.go
|
||||||
│ ├── 📄 base.go
|
│ ├── 📄 base.go
|
||||||
│ └── 📂 config/
|
│ └── 📂 config/
|
||||||
│ ├── 📄 config.go
|
│ ├── 📄 config.go
|
||||||
│ └── 📂 controller/
|
│ └── 📂 controller/
|
||||||
│ └── 📂 admin/
|
│ └── 📂 admin/
|
||||||
│ ├── 📄 admin.go
|
│ ├── 📄 admin.go
|
||||||
│ ├── 📄 base_comm.go
|
│ ├── 📄 base_comm.go
|
||||||
│ ├── 📄 base_open.go
|
│ ├── 📄 base_open.go
|
||||||
│ ├── 📄 base_sys_department.go
|
│ ├── 📄 base_sys_department.go
|
||||||
│ ├── 📄 base_sys_log.go
|
│ ├── 📄 base_sys_log.go
|
||||||
│ ├── 📄 base_sys_menu.go
|
│ ├── 📄 base_sys_menu.go
|
||||||
│ ├── 📄 base_sys_param.go
|
│ ├── 📄 base_sys_param.go
|
||||||
│ ├── 📄 base_sys_role.go
|
│ ├── 📄 base_sys_role.go
|
||||||
│ ├── 📄 base_sys_user.go
|
│ ├── 📄 base_sys_user.go
|
||||||
│ └── 📂 app/
|
│ └── 📂 app/
|
||||||
│ ├── 📄 base_comm.go
|
│ ├── 📄 base_comm.go
|
||||||
│ ├── 📄 controller.go
|
│ ├── 📄 controller.go
|
||||||
│ └── 📂 funcs/
|
│ └── 📂 funcs/
|
||||||
│ ├── 📄 base_sys_log_clear.go
|
│ ├── 📄 base_sys_log_clear.go
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ └── 📂 middleware/
|
│ └── 📂 middleware/
|
||||||
│ ├── 📄 authority.go
|
│ ├── 📄 authority.go
|
||||||
│ ├── 📄 i18n.go
|
│ ├── 📄 i18n.go
|
||||||
│ ├── 📄 log.go
|
│ ├── 📄 log.go
|
||||||
│ ├── 📄 middleware.go
|
│ ├── 📄 middleware.go
|
||||||
│ └── 📂 model/
|
│ └── 📂 model/
|
||||||
│ ├── 📄 base_eps_admin.go
|
│ ├── 📄 base_eps_admin.go
|
||||||
│ ├── 📄 base_eps_app.go
|
│ ├── 📄 base_eps_app.go
|
||||||
│ ├── 📄 base_sys_conf.go
|
│ ├── 📄 base_sys_conf.go
|
||||||
│ ├── 📄 base_sys_department.go
|
│ ├── 📄 base_sys_department.go
|
||||||
│ ├── 📄 base_sys_init.go
|
│ ├── 📄 base_sys_init.go
|
||||||
│ ├── 📄 base_sys_log.go
|
│ ├── 📄 base_sys_log.go
|
||||||
│ ├── 📄 base_sys_menu.go
|
│ ├── 📄 base_sys_menu.go
|
||||||
│ ├── 📄 base_sys_param.go
|
│ ├── 📄 base_sys_param.go
|
||||||
│ ├── 📄 base_sys_role.go
|
│ ├── 📄 base_sys_role.go
|
||||||
│ ├── 📄 base_sys_role_department.go
|
│ ├── 📄 base_sys_role_department.go
|
||||||
│ ├── 📄 base_sys_role_menu.go
|
│ ├── 📄 base_sys_role_menu.go
|
||||||
│ ├── 📄 base_sys_user.go
|
│ ├── 📄 base_sys_user.go
|
||||||
│ ├── 📄 base_sys_user_role.go
|
│ ├── 📄 base_sys_user_role.go
|
||||||
│ └── 📂 packed/
|
│ └── 📂 packed/
|
||||||
│ ├── 📄 packed.go
|
│ ├── 📄 packed.go
|
||||||
│ └── 📂 resource/
|
│ └── 📂 resource/
|
||||||
│ └── 📂 initjson/
|
│ └── 📂 initjson/
|
||||||
│ ├── 📄 base_sys_department.json
|
│ ├── 📄 base_sys_department.json
|
||||||
│ ├── 📄 base_sys_menu.json
|
│ ├── 📄 base_sys_menu.json
|
||||||
│ ├── 📄 base_sys_param.json
|
│ ├── 📄 base_sys_param.json
|
||||||
│ ├── 📄 base_sys_role.json
|
│ ├── 📄 base_sys_role.json
|
||||||
│ ├── 📄 base_sys_role_department.json
|
│ ├── 📄 base_sys_role_department.json
|
||||||
│ ├── 📄 base_sys_role_menu.json
|
│ ├── 📄 base_sys_role_menu.json
|
||||||
│ ├── 📄 base_sys_user.json
|
│ ├── 📄 base_sys_user.json
|
||||||
│ ├── 📄 base_sys_user_role.json
|
│ ├── 📄 base_sys_user_role.json
|
||||||
│ └── 📂 service/
|
│ └── 📂 service/
|
||||||
│ ├── 📄 base_open.go
|
│ ├── 📄 base_open.go
|
||||||
│ ├── 📄 base_sys_conf.go
|
│ ├── 📄 base_sys_conf.go
|
||||||
│ ├── 📄 base_sys_department.go
|
│ ├── 📄 base_sys_department.go
|
||||||
│ ├── 📄 base_sys_log.go
|
│ ├── 📄 base_sys_log.go
|
||||||
│ ├── 📄 base_sys_login.go
|
│ ├── 📄 base_sys_login.go
|
||||||
│ ├── 📄 base_sys_menu.go
|
│ ├── 📄 base_sys_menu.go
|
||||||
│ ├── 📄 base_sys_param.go
|
│ ├── 📄 base_sys_param.go
|
||||||
│ ├── 📄 base_sys_perms.go
|
│ ├── 📄 base_sys_perms.go
|
||||||
│ ├── 📄 base_sys_role.go
|
│ ├── 📄 base_sys_role.go
|
||||||
│ ├── 📄 base_sys_user.go
|
│ ├── 📄 base_sys_user.go
|
||||||
│ └── 📂 utils/
|
│ └── 📂 utils/
|
||||||
│ ├── 📄 README.md
|
│ ├── 📄 README.md
|
||||||
│ ├── 📄 utils.go
|
│ ├── 📄 utils.go
|
||||||
│ └── 📂 demo/
|
│ └── 📂 demo/
|
||||||
│ └── 📂 controller/
|
│ └── 📂 controller/
|
||||||
│ └── 📂 admin/
|
│ └── 📂 admin/
|
||||||
│ ├── 📄 demo_sample.go
|
│ ├── 📄 demo_sample.go
|
||||||
│ ├── 📄 controller.go
|
│ ├── 📄 controller.go
|
||||||
│ ├── 📄 demo.go
|
│ ├── 📄 demo.go
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ └── 📂 model/
|
│ └── 📂 model/
|
||||||
│ ├── 📄 demo_goods.go
|
│ ├── 📄 demo_goods.go
|
||||||
│ ├── 📄 demo_sample.go
|
│ ├── 📄 demo_sample.go
|
||||||
│ └── 📂 service/
|
│ └── 📂 service/
|
||||||
│ ├── 📄 demo_goods.go
|
│ ├── 📄 demo_goods.go
|
||||||
│ ├── 📄 demo_sample.go
|
│ ├── 📄 demo_sample.go
|
||||||
│ ├── 📄 demo_test.go
|
│ ├── 📄 demo_test.go
|
||||||
│ └── 📂 dict/
|
│ └── 📂 dict/
|
||||||
│ ├── 📄 README.MD
|
│ ├── 📄 README.MD
|
||||||
│ └── 📂 controller/
|
│ └── 📂 controller/
|
||||||
│ └── 📂 admin/
|
│ └── 📂 admin/
|
||||||
│ ├── 📄 dict_info.go
|
│ ├── 📄 dict_info.go
|
||||||
│ ├── 📄 dict_type.go
|
│ ├── 📄 dict_type.go
|
||||||
│ ├── 📄 controller.go
|
│ ├── 📄 controller.go
|
||||||
│ ├── 📄 dict.go
|
│ ├── 📄 dict.go
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ └── 📂 model/
|
│ └── 📂 model/
|
||||||
│ ├── 📄 dict_info.go
|
│ ├── 📄 dict_info.go
|
||||||
│ ├── 📄 dict_type.go
|
│ ├── 📄 dict_type.go
|
||||||
│ └── 📂 packed/
|
│ └── 📂 packed/
|
||||||
│ ├── 📄 packed.go
|
│ ├── 📄 packed.go
|
||||||
│ └── 📂 resource/
|
│ └── 📂 resource/
|
||||||
│ └── 📂 initjson/
|
│ └── 📂 initjson/
|
||||||
│ ├── 📄 dict_info.json
|
│ ├── 📄 dict_info.json
|
||||||
│ ├── 📄 dict_type.json
|
│ ├── 📄 dict_type.json
|
||||||
│ └── 📂 service/
|
│ └── 📂 service/
|
||||||
│ ├── 📄 dict_info.go
|
│ ├── 📄 dict_info.go
|
||||||
│ ├── 📄 dict_type.go
|
│ ├── 📄 dict_type.go
|
||||||
│ ├── 📄 modules.go
|
│ ├── 📄 modules.go
|
||||||
│ └── 📂 space/
|
│ └── 📂 space/
|
||||||
│ ├── 📄 README.md
|
│ ├── 📄 README.md
|
||||||
│ └── 📂 controller/
|
│ └── 📂 controller/
|
||||||
│ └── 📂 admin/
|
│ └── 📂 admin/
|
||||||
│ ├── 📄 space_info.go
|
│ ├── 📄 space_info.go
|
||||||
│ ├── 📄 space_type.go
|
│ ├── 📄 space_type.go
|
||||||
│ ├── 📄 controller.go
|
│ ├── 📄 controller.go
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ └── 📂 middleware/
|
│ └── 📂 middleware/
|
||||||
│ ├── 📄 middleware.go
|
│ ├── 📄 middleware.go
|
||||||
│ └── 📂 model/
|
│ └── 📂 model/
|
||||||
│ ├── 📄 model.go
|
│ ├── 📄 model.go
|
||||||
│ ├── 📄 space_info.go
|
│ ├── 📄 space_info.go
|
||||||
│ ├── 📄 space_type.go
|
│ ├── 📄 space_type.go
|
||||||
│ └── 📂 service/
|
│ └── 📂 service/
|
||||||
│ ├── 📄 service.go
|
│ ├── 📄 service.go
|
||||||
│ ├── 📄 space_info.go
|
│ ├── 📄 space_info.go
|
||||||
│ ├── 📄 space_type.go
|
│ ├── 📄 space_type.go
|
||||||
│ ├── 📄 space.go
|
│ ├── 📄 space.go
|
||||||
│ └── 📂 task/
|
│ └── 📂 task/
|
||||||
│ ├── 📄 README.md
|
│ ├── 📄 README.md
|
||||||
│ └── 📂 controller/
|
│ └── 📂 controller/
|
||||||
│ └── 📂 admin/
|
│ └── 📂 admin/
|
||||||
│ ├── 📄 admin.go
|
│ ├── 📄 admin.go
|
||||||
│ ├── 📄 task_info.go
|
│ ├── 📄 task_info.go
|
||||||
│ └── 📂 app/
|
│ └── 📂 app/
|
||||||
│ ├── 📄 app.go
|
│ ├── 📄 app.go
|
||||||
│ ├── 📄 controller.go
|
│ ├── 📄 controller.go
|
||||||
│ └── 📂 funcs/
|
│ └── 📂 funcs/
|
||||||
│ ├── 📄 task_add_task.go
|
│ ├── 📄 task_add_task.go
|
||||||
│ ├── 📄 task_stop_func.go
|
│ ├── 📄 task_stop_func.go
|
||||||
│ ├── 📄 task_testfunc.go
|
│ ├── 📄 task_testfunc.go
|
||||||
│ ├── 📄 tast_start_func.go
|
│ ├── 📄 tast_start_func.go
|
||||||
│ ├── 📄 go.mod
|
│ ├── 📄 go.mod
|
||||||
│ ├── 📄 go.sum
|
│ ├── 📄 go.sum
|
||||||
│ └── 📂 middleware/
|
│ └── 📂 middleware/
|
||||||
│ ├── 📄 middleware.go
|
│ ├── 📄 middleware.go
|
||||||
│ └── 📂 model/
|
│ └── 📂 model/
|
||||||
│ ├── 📄 model.go
|
│ ├── 📄 model.go
|
||||||
│ ├── 📄 task_info.go
|
│ ├── 📄 task_info.go
|
||||||
│ ├── 📄 task_log.go
|
│ ├── 📄 task_log.go
|
||||||
│ └── 📂 packed/
|
│ └── 📂 packed/
|
||||||
│ ├── 📄 packed.go
|
│ ├── 📄 packed.go
|
||||||
│ └── 📂 resource/
|
│ └── 📂 resource/
|
||||||
│ └── 📂 initjson/
|
│ └── 📂 initjson/
|
||||||
│ ├── 📄 task_info.json
|
│ ├── 📄 task_info.json
|
||||||
│ └── 📂 service/
|
│ └── 📂 service/
|
||||||
│ ├── 📄 service.go
|
│ ├── 📄 service.go
|
||||||
│ ├── 📄 task_info.go
|
│ ├── 📄 task_info.go
|
||||||
│ ├── 📄 task.go
|
│ ├── 📄 task.go
|
||||||
├── 📄 pre-release.sh
|
├── 📄 pre-release.sh
|
||||||
└── 📂 public/
|
└── 📂 public/
|
||||||
│ └── 📂 uploads/
|
│ └── 📂 uploads/
|
||||||
├── 📄 release.sh
|
├── 📄 release.sh
|
||||||
└── 📂 scripts/
|
└── 📂 scripts/
|
||||||
│ ├── 📄 clean.sh
|
│ ├── 📄 clean.sh
|
||||||
│ ├── 📄 daemon.json
|
│ ├── 📄 daemon.json
|
||||||
│ ├── 📄 frontend.sh
|
│ ├── 📄 frontend.sh
|
||||||
│ ├── 📄 init.sh
|
│ ├── 📄 init.sh
|
||||||
│ ├── 📄 other_pack.sh
|
│ ├── 📄 other_pack.sh
|
||||||
│ └── 📄 windows_pack.bat
|
│ └── 📄 windows_pack.bat
|
||||||
```
|
```
|
||||||
|
|
||||||
目前仅有Logic服
|
目前仅有Logic服
|
||||||
主类位于 **server -> logic -> go -> LogicServer**
|
主类位于 **server -> logic -> go -> LogicServer**
|
||||||
|
|
||||||
详情查看 [文档](./docs)
|
详情查看 [文档](./docs)
|
||||||
|
|
||||||
- [战斗](./docs/battle.md)
|
- [战斗](./docs/battle.md)
|
||||||
- [编解码](./docs/codec.md)
|
- [编解码](./docs/codec.md)
|
||||||
- [指令](./docs/command.md)
|
- [指令](./docs/command.md)
|
||||||
- [系统属性](./docs/properties.md)
|
- [系统属性](./docs/properties.md)
|
||||||
- [登录](./docs/login.md)
|
- [登录](./docs/login.md)
|
||||||
|
|||||||
3
go.work
3
go.work
@@ -8,8 +8,9 @@ use (
|
|||||||
./common/serialize/sturc
|
./common/serialize/sturc
|
||||||
./logic
|
./logic
|
||||||
./login
|
./login
|
||||||
|
./modules
|
||||||
./modules/base
|
./modules/base
|
||||||
./modules/demo
|
./modules/blazing
|
||||||
./modules/dict
|
./modules/dict
|
||||||
./modules/space
|
./modules/space
|
||||||
./modules/task
|
./modules/task
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import (
|
|||||||
"blazing/common/socket"
|
"blazing/common/socket"
|
||||||
"blazing/common/socket/cmd"
|
"blazing/common/socket/cmd"
|
||||||
"blazing/common/socket/handler"
|
"blazing/common/socket/handler"
|
||||||
|
"blazing/cool"
|
||||||
"blazing/logic/controller"
|
"blazing/logic/controller"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -20,7 +23,9 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if cool.IsRedisMode {
|
||||||
|
go cool.ListenFunc(gctx.New())
|
||||||
|
}
|
||||||
Start("27777") //注入service
|
Start("27777") //注入service
|
||||||
}
|
}
|
||||||
func Start(port string) {
|
func Start(port string) {
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
||||||
|
|
||||||
_ "blazing/contrib/files/local"
|
_ "blazing/contrib/files/local"
|
||||||
|
|
||||||
// Minio,按需启用
|
// Minio,按需启用
|
||||||
// _ "blazing/contrib/files/minio"
|
// _ "blazing/contrib/files/minio"
|
||||||
|
|
||||||
// 阿里云OSS,按需启用
|
// 阿里云OSS,按需启用
|
||||||
// _ "blazing/contrib/files/oss"
|
// _ "blazing/contrib/files/oss"
|
||||||
|
|
||||||
// _ "blazing/contrib/drivers/sqlite"
|
// _ "blazing/contrib/drivers/sqlite"
|
||||||
|
|
||||||
_ "blazing/contrib/drivers/mysql"
|
_ "blazing/contrib/drivers/mysql"
|
||||||
|
|
||||||
//_ "blazing/contrib/drivers/pgsql"
|
//_ "blazing/contrib/drivers/pgsql"
|
||||||
|
|
||||||
_ "blazing/modules/base"
|
_ "blazing/modules"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/os/gctx"
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
|
|
||||||
"blazing/login/internal/cmd"
|
"blazing/login/internal/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// gres.Dump()
|
// gres.Dump()
|
||||||
cmd.Main.Run(gctx.New())
|
cmd.Main.Run(gctx.New())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,76 +1,78 @@
|
|||||||
server:
|
server:
|
||||||
address: ":8001"
|
address: ":8001"
|
||||||
openapiPath: "/api.json"
|
openapiPath: "/api.json"
|
||||||
swaggerPath: "/swagger"
|
swaggerPath: "/swagger"
|
||||||
clientMaxBodySize: 104857600 # 100MB in bytes 100*1024*1024
|
clientMaxBodySize: 104857600 # 100MB in bytes 100*1024*1024
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
level: "all"
|
level: "all"
|
||||||
stdout: true
|
stdout: true
|
||||||
|
|
||||||
database:
|
database:
|
||||||
# default:
|
# default:
|
||||||
# type: "pgsql"
|
# type: "pgsql"
|
||||||
# host: "160.251.151.226"
|
# host: "160.251.151.226"
|
||||||
# port: "5432"
|
# port: "5432"
|
||||||
# user: "qxblog_blazing"
|
# user: "qxblog_blazing"
|
||||||
# pass: "root"
|
# pass: "root"
|
||||||
# name: "qxblog_blazing"
|
# name: "qxblog_blazing"
|
||||||
# debug: true
|
# debug: true
|
||||||
# createdAt: "createTime"
|
# createdAt: "createTime"
|
||||||
# updatedAt: "updateTime"
|
# updatedAt: "updateTime"
|
||||||
default:
|
default:
|
||||||
type: "mysql"
|
type: "mysql"
|
||||||
host: "159.75.107.160"
|
host: "159.75.107.160"
|
||||||
port: "3306"
|
port: "3306"
|
||||||
user: "blazing"
|
user: "blazing"
|
||||||
pass: "zjjSrsBMrB5RmjE7"
|
pass: "zjjSrsBMrB5RmjE7"
|
||||||
name: "blazing"
|
name: "blazing"
|
||||||
charset: "utf8mb4"
|
charset: "utf8mb4"
|
||||||
timezone: "Asia/Shanghai"
|
timezone: "Asia/Shanghai"
|
||||||
debug: true
|
debug: true
|
||||||
createdAt: "createTime"
|
createdAt: "createTime"
|
||||||
updatedAt: "updateTime"
|
updatedAt: "updateTime"
|
||||||
deletedAt: "deleteTime"
|
deletedAt: "deleteTime"
|
||||||
# baseConfig:
|
# baseConfig:
|
||||||
# type: "sqlite"
|
# type: "sqlite"
|
||||||
# link: "base-config.sqlite"
|
# link: "base-config.sqlite"
|
||||||
# extra: busy_timeout=5000
|
# extra: busy_timeout=5000
|
||||||
# createdAt: "createTime"
|
# createdAt: "createTime"
|
||||||
# updatedAt: "updateTime"
|
# updatedAt: "updateTime"
|
||||||
# debug: true
|
# debug: true
|
||||||
|
|
||||||
# Redis 配置示例
|
# Redis 配置示例
|
||||||
redis:
|
redis:
|
||||||
cool:
|
cool:
|
||||||
address: "127.0.0.1:6379"
|
address: "159.75.107.160:6379"
|
||||||
db: 0
|
db: 0
|
||||||
|
pass: 154252
|
||||||
cool:
|
|
||||||
autoMigrate: true
|
|
||||||
eps: true
|
cool:
|
||||||
file:
|
autoMigrate: true
|
||||||
mode: "local" # local | minio | oss
|
eps: true
|
||||||
domain: "http://127.0.0.1:8002"
|
file:
|
||||||
# oss配置项兼容 minio oss 需要配置bucket公开读
|
mode: "local" # local | minio | oss
|
||||||
oss:
|
domain: "http://127.0.0.1:8002"
|
||||||
endpoint: "192.168.192.110:9000"
|
# oss配置项兼容 minio oss 需要配置bucket公开读
|
||||||
accessKeyID: "accessKeyID"
|
oss:
|
||||||
secretAccessKey: "secretAccessKey"
|
endpoint: "192.168.192.110:9000"
|
||||||
bucketName: "cool-admin-go"
|
accessKeyID: "accessKeyID"
|
||||||
useSSL: false #minio用到
|
secretAccessKey: "secretAccessKey"
|
||||||
location: "us-east-1" #minio用到
|
bucketName: "cool-admin-go"
|
||||||
|
useSSL: false #minio用到
|
||||||
modules:
|
location: "us-east-1" #minio用到
|
||||||
base:
|
|
||||||
jwt:
|
modules:
|
||||||
sso: false
|
base:
|
||||||
secret: "cool-base88776655"
|
jwt:
|
||||||
token:
|
sso: false
|
||||||
expire: 10 # 2*3600
|
secret: "cool-base88776655"
|
||||||
refreshExpire: 1296000 # 24*3600*15
|
token:
|
||||||
middleware:
|
expire: 10 # 2*3600
|
||||||
authority:
|
refreshExpire: 1296000 # 24*3600*15
|
||||||
enable: true
|
middleware:
|
||||||
log:
|
authority:
|
||||||
enable: true
|
enable: true
|
||||||
|
log:
|
||||||
|
enable: true
|
||||||
|
|||||||
@@ -1,240 +1,251 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
|
|
||||||
"blazing/modules/base/model"
|
"blazing/modules/base/model"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/container/garray"
|
"github.com/gogf/gf/v2/container/garray"
|
||||||
"github.com/gogf/gf/v2/container/gset"
|
"github.com/gogf/gf/v2/container/gset"
|
||||||
"github.com/gogf/gf/v2/crypto/gmd5"
|
"github.com/gogf/gf/v2/crypto/gmd5"
|
||||||
"github.com/gogf/gf/v2/database/gdb"
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
"github.com/gogf/gf/v2/errors/gerror"
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
"github.com/gogf/gf/v2/util/gconv"
|
"github.com/gogf/gf/v2/util/gconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BaseSysUserService struct {
|
type BaseSysUserService struct {
|
||||||
*cool.Service
|
*cool.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
// Person 方法 返回不带密码的用户信息
|
// Person 方法 返回不带密码的用户信息
|
||||||
func (s *BaseSysUserService) Person(userId uint) (res gdb.Record, err error) {
|
func (s *BaseSysUserService) Person(userId uint) (res gdb.Record, err error) {
|
||||||
m := cool.DBM(s.Model)
|
m := cool.DBM(s.Model)
|
||||||
res, err = m.Where("id = ?", userId).FieldsEx("password").One()
|
res, err = m.Where("id = ?", userId).FieldsEx("password").One()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
func (s *BaseSysUserService) GetSession(email string, password string) (res *model.BaseSysUser, err error) {
|
||||||
func (s *BaseSysUserService) ModifyBefore(ctx context.Context, method string, param g.MapStrAny) (err error) {
|
m := cool.DBM(s.Model)
|
||||||
if method == "Delete" {
|
|
||||||
// 禁止删除超级管理员
|
m.Where("email = ?", email).Where("password=?", password).Where("status=?", 1).Scan(&res)
|
||||||
userIds := garray.NewIntArrayFrom(gconv.Ints(param["ids"]))
|
if res == nil {
|
||||||
currentId, found := userIds.Get(0)
|
err = gerror.New("账户或密码不正确~")
|
||||||
superAdminId := 1
|
return
|
||||||
|
}
|
||||||
if userIds.Len() == 1 && found && currentId == superAdminId {
|
|
||||||
err = gerror.New("超级管理员不能删除")
|
return
|
||||||
return
|
}
|
||||||
}
|
func (s *BaseSysUserService) ModifyBefore(ctx context.Context, method string, param g.MapStrAny) (err error) {
|
||||||
|
if method == "Delete" {
|
||||||
// 删除超级管理员
|
// 禁止删除超级管理员
|
||||||
userIds.RemoveValue(1)
|
userIds := garray.NewIntArrayFrom(gconv.Ints(param["ids"]))
|
||||||
g.RequestFromCtx(ctx).SetParam("ids", userIds.Slice())
|
currentId, found := userIds.Get(0)
|
||||||
}
|
superAdminId := 1
|
||||||
return
|
|
||||||
}
|
if userIds.Len() == 1 && found && currentId == superAdminId {
|
||||||
|
err = gerror.New("超级管理员不能删除")
|
||||||
func (s *BaseSysUserService) ModifyAfter(ctx context.Context, method string, param g.MapStrAny) (err error) {
|
return
|
||||||
if method == "Delete" {
|
}
|
||||||
userIds := garray.NewIntArrayFrom(gconv.Ints(param["ids"]))
|
|
||||||
userIds.RemoveValue(1)
|
// 删除超级管理员
|
||||||
// 删除用户时删除相关数据
|
userIds.RemoveValue(1)
|
||||||
cool.DBM(model.NewBaseSysUserRole()).WhereIn("userId", userIds.Slice()).Delete()
|
g.RequestFromCtx(ctx).SetParam("ids", userIds.Slice())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceAdd 方法 添加用户
|
func (s *BaseSysUserService) ModifyAfter(ctx context.Context, method string, param g.MapStrAny) (err error) {
|
||||||
func (s *BaseSysUserService) ServiceAdd(ctx context.Context, req *cool.AddReq) (data interface{}, err error) {
|
if method == "Delete" {
|
||||||
var (
|
userIds := garray.NewIntArrayFrom(gconv.Ints(param["ids"]))
|
||||||
m = cool.DBM(s.Model)
|
userIds.RemoveValue(1)
|
||||||
r = g.RequestFromCtx(ctx)
|
// 删除用户时删除相关数据
|
||||||
reqmap = r.GetMap()
|
cool.DBM(model.NewBaseSysUserRole()).WhereIn("userId", userIds.Slice()).Delete()
|
||||||
)
|
}
|
||||||
// 如果reqmap["password"]不为空,则对密码进行md5加密
|
return
|
||||||
if !r.Get("password").IsNil() {
|
}
|
||||||
reqmap["password"] = gmd5.MustEncryptString(r.Get("password").String())
|
|
||||||
}
|
// ServiceAdd 方法 添加用户
|
||||||
lastInsertId, err := m.Data(reqmap).InsertAndGetId()
|
func (s *BaseSysUserService) ServiceAdd(ctx context.Context, req *cool.AddReq) (data interface{}, err error) {
|
||||||
if err != nil {
|
var (
|
||||||
return
|
m = cool.DBM(s.Model)
|
||||||
}
|
r = g.RequestFromCtx(ctx)
|
||||||
data = g.Map{"id": lastInsertId}
|
reqmap = r.GetMap()
|
||||||
return
|
)
|
||||||
}
|
// 如果reqmap["password"]不为空,则对密码进行md5加密
|
||||||
|
if !r.Get("password").IsNil() {
|
||||||
// ServiceInfo 方法 返回服务信息
|
reqmap["password"] = gmd5.MustEncryptString(r.Get("password").String())
|
||||||
func (s *BaseSysUserService) ServiceInfo(ctx g.Ctx, req *cool.InfoReq) (data interface{}, err error) {
|
}
|
||||||
result, err := s.Service.ServiceInfo(ctx, req)
|
lastInsertId, err := m.Data(reqmap).InsertAndGetId()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return
|
||||||
}
|
}
|
||||||
if result.(gdb.Record).IsEmpty() {
|
data = g.Map{"id": lastInsertId}
|
||||||
return nil, nil
|
return
|
||||||
}
|
}
|
||||||
// g.DumpWithType(result)
|
|
||||||
resultMap := result.(gdb.Record).Map()
|
// ServiceInfo 方法 返回服务信息
|
||||||
|
func (s *BaseSysUserService) ServiceInfo(ctx g.Ctx, req *cool.InfoReq) (data interface{}, err error) {
|
||||||
// 获取角色
|
result, err := s.Service.ServiceInfo(ctx, req)
|
||||||
roleIds, err := cool.DBM(model.NewBaseSysUserRole()).Where("userId = ?", resultMap["id"]).Fields("roleId").Array()
|
if err != nil {
|
||||||
if err != nil {
|
return nil, err
|
||||||
return nil, err
|
}
|
||||||
}
|
if result.(gdb.Record).IsEmpty() {
|
||||||
resultMap["roleIdList"] = roleIds
|
return nil, nil
|
||||||
data = resultMap
|
}
|
||||||
|
// g.DumpWithType(result)
|
||||||
return
|
resultMap := result.(gdb.Record).Map()
|
||||||
}
|
|
||||||
|
// 获取角色
|
||||||
// ServiceUpdate 方法 更新用户信息
|
roleIds, err := cool.DBM(model.NewBaseSysUserRole()).Where("userId = ?", resultMap["id"]).Fields("roleId").Array()
|
||||||
func (s *BaseSysUserService) ServiceUpdate(ctx context.Context, req *cool.UpdateReq) (data interface{}, err error) {
|
if err != nil {
|
||||||
var (
|
return nil, err
|
||||||
admin = cool.GetAdmin(ctx)
|
}
|
||||||
m = cool.DBM(s.Model)
|
resultMap["roleIdList"] = roleIds
|
||||||
)
|
data = resultMap
|
||||||
|
|
||||||
r := g.RequestFromCtx(ctx)
|
return
|
||||||
rMap := r.GetMap()
|
}
|
||||||
|
|
||||||
// 如果不传入ID代表更新当前用户
|
// ServiceUpdate 方法 更新用户信息
|
||||||
userId := r.Get("id", admin.UserId).Uint()
|
func (s *BaseSysUserService) ServiceUpdate(ctx context.Context, req *cool.UpdateReq) (data interface{}, err error) {
|
||||||
userInfo, err := m.Where("id = ?", userId).One()
|
var (
|
||||||
|
admin = cool.GetAdmin(ctx)
|
||||||
if err != nil {
|
m = cool.DBM(s.Model)
|
||||||
return
|
)
|
||||||
}
|
|
||||||
if userInfo.IsEmpty() {
|
r := g.RequestFromCtx(ctx)
|
||||||
err = gerror.New("用户不存在")
|
rMap := r.GetMap()
|
||||||
return
|
|
||||||
}
|
// 如果不传入ID代表更新当前用户
|
||||||
|
userId := r.Get("id", admin.UserId).Uint()
|
||||||
// 禁止禁用超级管理员
|
userInfo, err := m.Where("id = ?", userId).One()
|
||||||
if userId == 1 && (!r.Get("status").IsNil() && r.Get("status").Int() == 0) {
|
|
||||||
err = gerror.New("禁止禁用超级管理员")
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if userInfo.IsEmpty() {
|
||||||
// 如果请求的password不为空并且密码加密后的值有变动,说明要修改密码
|
err = gerror.New("用户不存在")
|
||||||
var rPassword = r.Get("password", "").String()
|
return
|
||||||
if rPassword != "" && rPassword != userInfo["password"].String() {
|
}
|
||||||
rMap["password"], _ = gmd5.Encrypt(rPassword)
|
|
||||||
rMap["passwordV"] = userInfo["passwordV"].Int() + 1
|
// 禁止禁用超级管理员
|
||||||
cool.CacheManager.Set(ctx, fmt.Sprintf("admin:passwordVersion:%d", userId), rMap["passwordV"], 0)
|
if userId == 1 && (!r.Get("status").IsNil() && r.Get("status").Int() == 0) {
|
||||||
} else {
|
err = gerror.New("禁止禁用超级管理员")
|
||||||
delete(rMap, "password")
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
// 如果请求的password不为空并且密码加密后的值有变动,说明要修改密码
|
||||||
roleModel := cool.DBM(model.NewBaseSysUserRole()).TX(tx).Where("userId = ?", userId)
|
var rPassword = r.Get("password", "").String()
|
||||||
roleIds, err := roleModel.Fields("roleId").Array()
|
if rPassword != "" && rPassword != userInfo["password"].String() {
|
||||||
if err != nil {
|
rMap["password"], _ = gmd5.Encrypt(rPassword)
|
||||||
return
|
rMap["passwordV"] = userInfo["passwordV"].Int() + 1
|
||||||
}
|
cool.CacheManager.Set(ctx, fmt.Sprintf("admin:passwordVersion:%d", userId), rMap["passwordV"], 0)
|
||||||
|
} else {
|
||||||
// 如果请求参数中不包含roleIdList说明不修改角色信息
|
delete(rMap, "password")
|
||||||
if !r.Get("roleIdList").IsNil() {
|
}
|
||||||
inRoleIdSet := gset.NewFrom(r.Get("roleIdList").Ints())
|
|
||||||
roleIdsSet := gset.NewFrom(gconv.Ints(roleIds))
|
err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||||
|
roleModel := cool.DBM(model.NewBaseSysUserRole()).TX(tx).Where("userId = ?", userId)
|
||||||
// 如果请求的角色信息未发生变化则跳过更新逻辑
|
roleIds, err := roleModel.Fields("roleId").Array()
|
||||||
if roleIdsSet.Diff(inRoleIdSet).Size() != 0 || inRoleIdSet.Diff(roleIdsSet).Size() != 0 {
|
if err != nil {
|
||||||
roleArray := garray.NewArray()
|
return
|
||||||
inRoleIdSet.Iterator(func(v interface{}) bool {
|
}
|
||||||
roleArray.PushRight(g.Map{
|
|
||||||
"userId": gconv.Uint(userId),
|
// 如果请求参数中不包含roleIdList说明不修改角色信息
|
||||||
"roleId": gconv.Uint(v),
|
if !r.Get("roleIdList").IsNil() {
|
||||||
})
|
inRoleIdSet := gset.NewFrom(r.Get("roleIdList").Ints())
|
||||||
return true
|
roleIdsSet := gset.NewFrom(gconv.Ints(roleIds))
|
||||||
})
|
|
||||||
|
// 如果请求的角色信息未发生变化则跳过更新逻辑
|
||||||
_, err = roleModel.Delete()
|
if roleIdsSet.Diff(inRoleIdSet).Size() != 0 || inRoleIdSet.Diff(roleIdsSet).Size() != 0 {
|
||||||
|
roleArray := garray.NewArray()
|
||||||
if err != nil {
|
inRoleIdSet.Iterator(func(v interface{}) bool {
|
||||||
return err
|
roleArray.PushRight(g.Map{
|
||||||
}
|
"userId": gconv.Uint(userId),
|
||||||
_, err = roleModel.Fields("userId,roleId").Insert(roleArray)
|
"roleId": gconv.Uint(v),
|
||||||
if err != nil {
|
})
|
||||||
return err
|
return true
|
||||||
}
|
})
|
||||||
}
|
|
||||||
}
|
_, err = roleModel.Delete()
|
||||||
|
|
||||||
_, err = m.TX(tx).Update(rMap)
|
if err != nil {
|
||||||
|
return err
|
||||||
if err != nil {
|
}
|
||||||
return err
|
_, err = roleModel.Fields("userId,roleId").Insert(roleArray)
|
||||||
}
|
if err != nil {
|
||||||
return
|
return err
|
||||||
})
|
}
|
||||||
return
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move 移动用户部门
|
_, err = m.TX(tx).Update(rMap)
|
||||||
func (s *BaseSysUserService) Move(ctx g.Ctx) (err error) {
|
|
||||||
request := g.RequestFromCtx(ctx)
|
if err != nil {
|
||||||
departmentId := request.Get("departmentId").Int()
|
return err
|
||||||
userIds := request.Get("userIds").Slice()
|
}
|
||||||
|
return
|
||||||
_, err = cool.DBM(s.Model).Where("`id` IN(?)", userIds).Data(g.Map{"departmentId": departmentId}).Update()
|
})
|
||||||
|
return
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
// Move 移动用户部门
|
||||||
// NewBaseSysUserService 创建一个新的BaseSysUserService实例
|
func (s *BaseSysUserService) Move(ctx g.Ctx) (err error) {
|
||||||
func NewBaseSysUserService() *BaseSysUserService {
|
request := g.RequestFromCtx(ctx)
|
||||||
return &BaseSysUserService{
|
departmentId := request.Get("departmentId").Int()
|
||||||
Service: &cool.Service{
|
userIds := request.Get("userIds").Slice()
|
||||||
Model: model.NewBaseSysUser(),
|
|
||||||
InfoIgnoreProperty: "password",
|
_, err = cool.DBM(s.Model).Where("`id` IN(?)", userIds).Data(g.Map{"departmentId": departmentId}).Update()
|
||||||
UniqueKey: map[string]string{
|
|
||||||
"username": "用户名不能重复",
|
return
|
||||||
},
|
}
|
||||||
PageQueryOp: &cool.QueryOp{
|
|
||||||
Select: "base_sys_user.*,dept.`name` as departmentName,GROUP_CONCAT( role.`name` ) AS `roleName`",
|
// NewBaseSysUserService 创建一个新的BaseSysUserService实例
|
||||||
Join: []*cool.JoinOp{
|
func NewBaseSysUserService() *BaseSysUserService {
|
||||||
{
|
return &BaseSysUserService{
|
||||||
Model: model.NewBaseSysDepartment(),
|
Service: &cool.Service{
|
||||||
Alias: "dept",
|
Model: model.NewBaseSysUser(),
|
||||||
Type: "LeftJoin",
|
InfoIgnoreProperty: "password",
|
||||||
Condition: "`base_sys_user`.`departmentId` = `dept`.`id`",
|
UniqueKey: map[string]string{
|
||||||
},
|
// "username": "用户名不能重复",
|
||||||
{
|
"email": "邮箱不能重复",
|
||||||
Model: model.NewBaseSysUserRole(),
|
},
|
||||||
Alias: "user_role",
|
PageQueryOp: &cool.QueryOp{
|
||||||
Type: "LeftJoin",
|
Select: "base_sys_user.*,dept.`name` as departmentName,GROUP_CONCAT( role.`name` ) AS `roleName`",
|
||||||
Condition: "`base_sys_user`.`id` = `user_role`.`userId`",
|
Join: []*cool.JoinOp{
|
||||||
},
|
{
|
||||||
{
|
Model: model.NewBaseSysDepartment(),
|
||||||
Model: model.NewBaseSysRole(),
|
Alias: "dept",
|
||||||
Alias: "`role`",
|
Type: "LeftJoin",
|
||||||
Type: "LeftJoin",
|
Condition: "`base_sys_user`.`departmentId` = `dept`.`id`",
|
||||||
Condition: "`role`.`id` = `user_role`.`roleId`",
|
},
|
||||||
},
|
{
|
||||||
},
|
Model: model.NewBaseSysUserRole(),
|
||||||
Where: func(ctx context.Context) []g.Array {
|
Alias: "user_role",
|
||||||
r := g.RequestFromCtx(ctx).GetMap()
|
Type: "LeftJoin",
|
||||||
return []g.Array{
|
Condition: "`base_sys_user`.`id` = `user_role`.`userId`",
|
||||||
{"(departmentId IN (?))", gconv.SliceStr(r["departmentIds"])},
|
},
|
||||||
}
|
{
|
||||||
},
|
Model: model.NewBaseSysRole(),
|
||||||
Extend: func(ctx g.Ctx, m *gdb.Model) *gdb.Model {
|
Alias: "`role`",
|
||||||
return m.Group("`base_sys_user`.`id`")
|
Type: "LeftJoin",
|
||||||
},
|
Condition: "`role`.`id` = `user_role`.`roleId`",
|
||||||
KeyWordField: []string{"name", "username", "nickName"},
|
},
|
||||||
},
|
},
|
||||||
},
|
Where: func(ctx context.Context) []g.Array {
|
||||||
}
|
r := g.RequestFromCtx(ctx).GetMap()
|
||||||
}
|
return []g.Array{
|
||||||
|
{"(departmentId IN (?))", gconv.SliceStr(r["departmentIds"])},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Extend: func(ctx g.Ctx, m *gdb.Model) *gdb.Model {
|
||||||
|
return m.Group("`base_sys_user`.`id`")
|
||||||
|
},
|
||||||
|
KeyWordField: []string{"name", "username", "nickName"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
76
modules/blazing/controller/admin/login.go
Normal file
76
modules/blazing/controller/admin/login.go
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
baseservice "blazing/modules/base/service"
|
||||||
|
"blazing/modules/blazing/service"
|
||||||
|
"context"
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/util/gconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SessionReq struct {
|
||||||
|
g.Meta `path:"/getSessionByAuth" method:"GET"`
|
||||||
|
Email string `json:"email" v:"required|email"`
|
||||||
|
Password string `json:"password" v:"required"`
|
||||||
|
}
|
||||||
|
type SessionRes struct {
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Code int `json:"code"`
|
||||||
|
Session string `json:"session"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *BlazingController) GetSession(ctx context.Context, req *SessionReq) (res *SessionRes, err error) {
|
||||||
|
// res = &DemoSampleWelcomeRes{
|
||||||
|
// BaseRes: cool.Ok("Welcome to Cool Admin Go"),
|
||||||
|
// Data: gjson.New(`{"name": "Cool Admin Go", "age":0}`),
|
||||||
|
// }
|
||||||
|
res = &SessionRes{
|
||||||
|
Msg: "success",
|
||||||
|
Code: 200,
|
||||||
|
Session: ""}
|
||||||
|
if err := g.Validator().Data(req).Run(ctx); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
res.Code = 400
|
||||||
|
res.Msg = err.Error()
|
||||||
|
|
||||||
|
}
|
||||||
|
res1, err := baseservice.NewBaseSysUserService().GetSession(req.Email, req.Password)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
res.Code = 400
|
||||||
|
res.Msg = err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
accountID := res1.ID
|
||||||
|
|
||||||
|
// 生成SID
|
||||||
|
sidInfo := fmt.Sprintf("%d%d", accountID, time.Now().UnixNano())
|
||||||
|
hash := sha256.Sum256([]byte(sidInfo))
|
||||||
|
sidByte := hex.EncodeToString(hash[:])
|
||||||
|
|
||||||
|
// 确保长度为48字符
|
||||||
|
if len(sidByte) < 48 {
|
||||||
|
sidByte = sidByte + strings.Repeat("0", 48-len(sidByte))
|
||||||
|
} else {
|
||||||
|
sidByte = sidByte[:48]
|
||||||
|
}
|
||||||
|
|
||||||
|
// UID拼接SID
|
||||||
|
hex8 := fmt.Sprintf("%08X", int(accountID&0xFFFFFFFF))
|
||||||
|
res.Session = hex8 + sidByte[8:]
|
||||||
|
|
||||||
|
// 保存后端校验的SID
|
||||||
|
backendSID := res.Session[8 : len(res.Session)-8]
|
||||||
|
if err := service.NewLoginServiceService().SaveSessionId(backendSID, gconv.String(accountID)); err != nil {
|
||||||
|
res.Code = 400
|
||||||
|
res.Msg = err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
55
modules/blazing/controller/admin/reg.go
Normal file
55
modules/blazing/controller/admin/reg.go
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"blazing/cool"
|
||||||
|
|
||||||
|
"blazing/modules/blazing/service"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BlazingController struct {
|
||||||
|
*cool.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
var demo_sample_controller = &BlazingController{
|
||||||
|
&cool.Controller{
|
||||||
|
Prefix: "/seer/game",
|
||||||
|
Api: []string{},
|
||||||
|
Service: service.NewDemoSampleService(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// 注册路由
|
||||||
|
cool.RegisterController(demo_sample_controller)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 增加 Welcome 演示 方法
|
||||||
|
type RegReq struct {
|
||||||
|
g.Meta `path:"/reg" method:"POST"`
|
||||||
|
Email string `json:"email" v:"required|email"`
|
||||||
|
Password string `json:"password" v:"required"`
|
||||||
|
}
|
||||||
|
type RegRes struct {
|
||||||
|
*cool.BaseRes
|
||||||
|
Data interface{} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *BlazingController) Reg(ctx context.Context, req *RegReq) (res *cool.BaseRes, err error) {
|
||||||
|
// res = &DemoSampleWelcomeRes{
|
||||||
|
// BaseRes: cool.Ok("Welcome to Cool Admin Go"),
|
||||||
|
// Data: gjson.New(`{"name": "Cool Admin Go", "age":0}`),
|
||||||
|
// }
|
||||||
|
if err := g.Validator().Data(req).Run(ctx); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
res = cool.Ok(err)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
res = cool.Ok("注册成功")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
5
modules/blazing/controller/controller.go
Normal file
5
modules/blazing/controller/controller.go
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "blazing/modules/blazing/controller/admin"
|
||||||
|
)
|
||||||
7
modules/blazing/demo.go
Normal file
7
modules/blazing/demo.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package demo
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "blazing/modules/blazing/controller"
|
||||||
|
_ "blazing/modules/blazing/model"
|
||||||
|
_ "blazing/modules/blazing/service"
|
||||||
|
)
|
||||||
@@ -1,38 +1,38 @@
|
|||||||
module blazing/modules/demo
|
module blazing/modules/blazing
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require github.com/gogf/gf/v2 v2.6.3
|
require github.com/gogf/gf/v2 v2.6.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||||
github.com/fatih/color v1.16.0 // indirect
|
github.com/fatih/color v1.16.0 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.1 // indirect
|
github.com/go-logr/logr v1.4.1 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
||||||
github.com/gorilla/websocket v1.5.1 // indirect
|
github.com/gorilla/websocket v1.5.1 // indirect
|
||||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/kr/pretty v0.1.0 // indirect
|
github.com/kr/pretty v0.1.0 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/magiconair/properties v1.8.7 // indirect
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.6.1 // indirect
|
github.com/rogpeppe/go-internal v1.6.1 // indirect
|
||||||
go.opentelemetry.io/otel v1.24.0 // indirect
|
go.opentelemetry.io/otel v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
|
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||||
golang.org/x/net v0.21.0 // indirect
|
golang.org/x/net v0.21.0 // indirect
|
||||||
golang.org/x/sys v0.17.0 // indirect
|
golang.org/x/sys v0.17.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
gorm.io/gorm v1.25.7 // indirect
|
gorm.io/gorm v1.25.7 // indirect
|
||||||
)
|
)
|
||||||
@@ -1,35 +1,35 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
)
|
)
|
||||||
|
|
||||||
const TableNameDemoGoods = "demo_goods"
|
const TableNameDemoGoods = "demo_goods"
|
||||||
|
|
||||||
// DemoGoods mapped from table <demo_goods>
|
// DemoGoods mapped from table <demo_goods>
|
||||||
type DemoGoods struct {
|
type DemoGoods struct {
|
||||||
*cool.Model
|
*cool.Model
|
||||||
Name string `gorm:"not null" json:"name"`
|
Name string `gorm:"not null" json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName DemoGoods's table name
|
// TableName DemoGoods's table name
|
||||||
func (*DemoGoods) TableName() string {
|
func (*DemoGoods) TableName() string {
|
||||||
return TableNameDemoGoods
|
return TableNameDemoGoods
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupName DemoGoods's table group
|
// GroupName DemoGoods's table group
|
||||||
func (*DemoGoods) GroupName() string {
|
func (*DemoGoods) GroupName() string {
|
||||||
return "default"
|
return "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDemoGoods create a new DemoGoods
|
// NewDemoGoods create a new DemoGoods
|
||||||
func NewDemoGoods() *DemoGoods {
|
func NewDemoGoods() *DemoGoods {
|
||||||
return &DemoGoods{
|
return &DemoGoods{
|
||||||
Model: cool.NewModel(),
|
Model: cool.NewModel(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// init 创建表
|
// init 创建表
|
||||||
func init() {
|
func init() {
|
||||||
cool.CreateTable(&DemoGoods{})
|
cool.CreateTable(&DemoGoods{})
|
||||||
}
|
}
|
||||||
@@ -1,35 +1,35 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
)
|
)
|
||||||
|
|
||||||
const TableNameDemoSample = "demo_sample"
|
const TableNameDemoSample = "demo_sample"
|
||||||
|
|
||||||
// DemoSample mapped from table <demo_sample>
|
// DemoSample mapped from table <demo_sample>
|
||||||
type DemoSample struct {
|
type DemoSample struct {
|
||||||
*cool.Model
|
*cool.Model
|
||||||
// Name string `gorm:"column:name;not null;comment:名称" json:"name"`
|
// Name string `gorm:"column:name;not null;comment:名称" json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName DemoSample's table name
|
// TableName DemoSample's table name
|
||||||
func (*DemoSample) TableName() string {
|
func (*DemoSample) TableName() string {
|
||||||
return TableNameDemoSample
|
return TableNameDemoSample
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupName DemoSample's table group
|
// GroupName DemoSample's table group
|
||||||
func (*DemoSample) GroupName() string {
|
func (*DemoSample) GroupName() string {
|
||||||
return "default"
|
return "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDemoSample create a new DemoSample
|
// NewDemoSample create a new DemoSample
|
||||||
func NewDemoSample() *DemoSample {
|
func NewDemoSample() *DemoSample {
|
||||||
return &DemoSample{
|
return &DemoSample{
|
||||||
Model: cool.NewModel(),
|
Model: cool.NewModel(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// init 创建表
|
// init 创建表
|
||||||
func init() {
|
func init() {
|
||||||
cool.CreateTable(&DemoSample{})
|
cool.CreateTable(&DemoSample{})
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
|
|
||||||
"blazing/modules/demo/model"
|
"blazing/modules/blazing/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DemoGoodsService struct {
|
type DemoGoodsService struct {
|
||||||
*cool.Service
|
*cool.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDemoGoodsService() *DemoGoodsService {
|
func NewDemoGoodsService() *DemoGoodsService {
|
||||||
return &DemoGoodsService{
|
return &DemoGoodsService{
|
||||||
&cool.Service{
|
&cool.Service{
|
||||||
Model: model.NewDemoGoods(),
|
Model: model.NewDemoGoods(),
|
||||||
ListQueryOp: &cool.QueryOp{
|
ListQueryOp: &cool.QueryOp{
|
||||||
|
|
||||||
Join: []*cool.JoinOp{},
|
Join: []*cool.JoinOp{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
|
|
||||||
"blazing/modules/demo/model"
|
"blazing/modules/blazing/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DemoSampleService struct {
|
type DemoSampleService struct {
|
||||||
*cool.Service
|
*cool.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDemoSampleService() *DemoSampleService {
|
func NewDemoSampleService() *DemoSampleService {
|
||||||
return &DemoSampleService{
|
return &DemoSampleService{
|
||||||
&cool.Service{
|
&cool.Service{
|
||||||
Model: model.NewDemoSample(),
|
Model: model.NewDemoSample(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DemoTestService struct {
|
type DemoTestService struct {
|
||||||
*cool.Service
|
*cool.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDemoTestService() *DemoTestService {
|
func NewDemoTestService() *DemoTestService {
|
||||||
return &DemoTestService{
|
return &DemoTestService{
|
||||||
&cool.Service{},
|
&cool.Service{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DemoTestService) GetDemoTestList() (interface{}, error) {
|
func (s *DemoTestService) GetDemoTestList() (interface{}, error) {
|
||||||
// gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`))
|
// gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`))
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
21
modules/blazing/service/login.go
Normal file
21
modules/blazing/service/login.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"blazing/cool"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LoginService struct {
|
||||||
|
*cool.Service
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLoginServiceService() *LoginService {
|
||||||
|
return &LoginService{
|
||||||
|
&cool.Service{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *LoginService) SaveSessionId(session, userid string) error {
|
||||||
|
// gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"blazing/cool"
|
|
||||||
|
|
||||||
"blazing/modules/demo/service"
|
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/encoding/gjson"
|
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DemoSampleController struct {
|
|
||||||
*cool.Controller
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
var demo_sample_controller = &DemoSampleController{
|
|
||||||
&cool.Controller{
|
|
||||||
Prefix: "/admin/demo/demo_sample",
|
|
||||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
|
|
||||||
Service: service.NewDemoSampleService(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
// 注册路由
|
|
||||||
cool.RegisterController(demo_sample_controller)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 增加 Welcome 演示 方法
|
|
||||||
type DemoSampleWelcomeReq struct {
|
|
||||||
g.Meta `path:"/welcome" method:"GET"`
|
|
||||||
}
|
|
||||||
type DemoSampleWelcomeRes struct {
|
|
||||||
*cool.BaseRes
|
|
||||||
Data interface{} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *DemoSampleController) Welcome(ctx context.Context, req *DemoSampleWelcomeReq) (res *DemoSampleWelcomeRes, err error) {
|
|
||||||
res = &DemoSampleWelcomeRes{
|
|
||||||
BaseRes: cool.Ok("Welcome to Cool Admin Go"),
|
|
||||||
Data: gjson.New(`{"name": "Cool Admin Go", "age":0}`),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package controller
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "blazing/modules/demo/controller/admin"
|
|
||||||
)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package demo
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "blazing/modules/demo/controller"
|
|
||||||
_ "blazing/modules/demo/model"
|
|
||||||
_ "blazing/modules/demo/service"
|
|
||||||
)
|
|
||||||
6
modules/go.mod
Normal file
6
modules/go.mod
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
module blazing/modules
|
||||||
|
|
||||||
|
go 1.19
|
||||||
|
|
||||||
|
require (
|
||||||
|
)
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package blazing/modules
|
package modules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "blazing/modules/base"
|
_ "blazing/modules/base"
|
||||||
_ "blazing/modules/demo"
|
_ "blazing/modules/blazing"
|
||||||
_ "blazing/modules/dict"
|
_ "blazing/modules/dict"
|
||||||
_ "blazing/modules/space"
|
_ "blazing/modules/space"
|
||||||
_ "blazing/modules/task"
|
_ "blazing/modules/task"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user