mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-21 08:26:48 +08:00
Compare commits
117 Commits
v2.0-sqlit
...
bf5bcd3eeb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf5bcd3eeb | ||
|
|
f254132e18 | ||
|
|
edb673ee34 | ||
|
|
1688aaf371 | ||
|
|
ae540c6bfe | ||
|
|
9f1c1ce031 | ||
|
|
dd5b2b660e | ||
|
|
207bba186e | ||
|
|
42d5500941 | ||
|
|
20a9e38fa8 | ||
|
|
35c6387b4b | ||
|
|
17daeb9121 | ||
|
|
5efae235e4 | ||
|
|
ef05cc946f | ||
|
|
1017a92c29 | ||
|
|
1a5f77ffb4 | ||
|
|
9f2038cc4b | ||
|
|
be6c13e781 | ||
|
|
6da8cafb6f | ||
|
|
d79138d278 | ||
|
|
3146dc13ed | ||
|
|
6f8761756a | ||
|
|
c9af5ae093 | ||
|
|
6fcfa61dff | ||
|
|
1564e8605d | ||
|
|
cce0476bb9 | ||
|
|
4d5ae6907a | ||
|
|
ae3ad53806 | ||
|
|
d807084d55 | ||
|
|
99967d35e5 | ||
|
|
6cb0fcfd93 | ||
|
|
c377b6b92d | ||
|
|
56efd5d206 | ||
|
|
9da8eb264d | ||
|
|
416ae4c27f | ||
|
|
19c0c0c1bc | ||
|
|
0c5b27d864 | ||
|
|
62af998991 | ||
|
|
5301bedff2 | ||
|
|
b48079bbdc | ||
|
|
2fd3854aeb | ||
|
|
6254505a7d | ||
|
|
07df5a20e1 | ||
|
|
8e7992d7f4 | ||
|
|
86805ba047 | ||
|
|
abfd6a056f | ||
|
|
e364aa4a4f | ||
|
|
52c2538a66 | ||
|
|
f010ef07ac | ||
|
|
dbdfdaae93 | ||
|
|
a2c6a8ac16 | ||
|
|
1055e44b2b | ||
|
|
01f194d7ef | ||
|
|
52263c608f | ||
|
|
ffce905371 | ||
|
|
ef8d0bde5b | ||
|
|
98233d7deb | ||
|
|
1c8dd5e6d2 | ||
|
|
0cba31c885 | ||
|
|
f497fb7a1a | ||
|
|
f5e448a999 | ||
|
|
a94c6745ea | ||
|
|
6caa644259 | ||
|
|
37b2b82130 | ||
|
|
33e5252516 | ||
|
|
6cf80ed0fe | ||
|
|
fa87584316 | ||
|
|
194e86ea05 | ||
|
|
cc13a16e90 | ||
|
|
d9b57e6c62 | ||
|
|
09026a606b | ||
|
|
950637a976 | ||
|
|
06fed9025f | ||
|
|
7eb32efa92 | ||
|
|
2e322e2606 | ||
|
|
804d5d5e59 | ||
|
|
a37d088360 | ||
|
|
7d8330f72f | ||
|
|
b33591e8bd | ||
|
|
71e2176a35 | ||
|
|
733313d309 | ||
|
|
9feb4c2022 | ||
|
|
f33e36803a | ||
|
|
e914f1db33 | ||
|
|
1b563e0957 | ||
|
|
9133afb864 | ||
|
|
5c3bcaf6cc | ||
|
|
e501a33163 | ||
|
|
491e6cef09 | ||
|
|
b005c80ba6 | ||
|
|
7bf0efe667 | ||
|
|
f78f44e00f | ||
|
|
93395df7fa | ||
|
|
ea7cc97ed4 | ||
|
|
1292a15385 | ||
|
|
bbca0e8db8 | ||
|
|
9ff6e2d690 | ||
|
|
69b8f42092 | ||
|
|
e672f54fbb | ||
|
|
67520c9e38 | ||
|
|
a642c322e3 | ||
|
|
b2440e8ddc | ||
|
|
59beb07e98 | ||
|
|
7180157259 | ||
|
|
b97410738e | ||
|
|
ba2fa86767 | ||
|
|
406e3ef168 | ||
|
|
817482bedb | ||
|
|
dc20a86b33 | ||
|
|
269b2f9e43 | ||
|
|
211d3872e4 | ||
|
|
6d0c22f98c | ||
|
|
90ea29051f | ||
|
|
50a32db1d9 | ||
|
|
0dddbcd50c | ||
|
|
ac46200a23 | ||
|
|
ce4629e082 |
18
README.md
18
README.md
@@ -1,24 +1,24 @@
|
||||
# HotGo-V2
|
||||
<div align="center">
|
||||
<img width="140px" src="https://bufanyun.cn-bj.ufileos.com/hotgo/logo.sig.png">
|
||||
<img width="140px" src="https://gmycos.facms.cn/hotgo/logo.sig.png">
|
||||
<p>
|
||||
<h1>HotGo V2</h1>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://goframe.org/pages/viewpage.action?pageId=1114119" target="_blank">
|
||||
<img src="https://img.shields.io/badge/goframe-2.7-green" alt="goframe">
|
||||
<img src="https://img.shields.io/badge/goframe-2.9.0-green" alt="goframe">
|
||||
</a>
|
||||
<a href="https://v3.vuejs.org/" target="_blank">
|
||||
<img src="https://img.shields.io/badge/vue.js-vue3.4-green" alt="vue">
|
||||
</a>
|
||||
<a href="https://www.naiveui.com" target="_blank">
|
||||
<img src="https://img.shields.io/badge/naiveui-%3E2.38.0-blue" alt="naiveui">
|
||||
<img src="https://img.shields.io/badge/naiveui-%3E2.42.0-blue" alt="naiveui">
|
||||
</a>
|
||||
<a href="https://www.tslang.cn/" target="_blank">
|
||||
<img src="https://img.shields.io/badge/typescript-%3E4.0.0-blue" alt="typescript">
|
||||
</a>
|
||||
<a href="https://vitejs.dev/" target="_blank">
|
||||
<img src="https://img.shields.io/badge/vite-%3E4.0.0-yellow" alt="vite">
|
||||
<img src="https://img.shields.io/badge/vite-%3E5.4.2-yellow" alt="vite">
|
||||
</a>
|
||||
<a href="https://github.com/bufanyun/hotgo/blob/v2.0/LICENSE" target="_blank">
|
||||
<img src="https://img.shields.io/badge/license-MIT-success" alt="license">
|
||||
@@ -124,8 +124,8 @@
|
||||
|
||||
|
||||
## 交流QQ群
|
||||
交流群①:190966648 <a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=mJafkvme3VNyiQlCFIFNRtY8Xlr7pj9U&jump_from=webapi&authKey=jL10vIESr+vO8wpxwyd6DlChzkrbHpzN9uhAsIHgAinL/Vvd+nvuRyilf2UqUlCy"><img border="0" src="https://bufanyun.cn-bj.ufileos.com/hotgo/group.png" alt="HotGo框架交流1群" title="HotGo框架交流1群"></a>
|
||||
> <img src="https://bufanyun.cn-bj.ufileos.com/hotgo/hotgo1qun.png" width="400px"/>
|
||||
交流群①:190966648 <a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=mJafkvme3VNyiQlCFIFNRtY8Xlr7pj9U&jump_from=webapi&authKey=jL10vIESr+vO8wpxwyd6DlChzkrbHpzN9uhAsIHgAinL/Vvd+nvuRyilf2UqUlCy"><img border="0" src="https://gmycos.facms.cn/hotgo/group.png" alt="HotGo框架交流1群" title="HotGo框架交流1群"></a>
|
||||
> <img src="https://gmycos.facms.cn/hotgo/hotgo1qun.png" width="400px"/>
|
||||
|
||||
|
||||
## 商用说明
|
||||
@@ -136,7 +136,7 @@
|
||||
|
||||
* 本项目包含的第三方源码和二进制文件之版权信息另行标注。
|
||||
|
||||
* 版权所有Copyright © 2020-2024 by Ms (https://github.com/bufanyun/hotgo)
|
||||
* 版权所有Copyright © 2020-2025 by Ms (https://github.com/bufanyun/hotgo)
|
||||
|
||||
* All rights reserved。
|
||||
|
||||
@@ -154,11 +154,11 @@
|
||||
|
||||
|
||||
## [感谢JetBrains提供的免费GoLand](https://jb.gg/OpenSource)
|
||||
[](https://jb.gg/OpenSource)
|
||||
[](https://jb.gg/OpenSource)
|
||||
|
||||
|
||||
## License
|
||||
[MIT © HotGo-2024](./LICENSE)
|
||||
[MIT © HotGo-2025](./LICENSE)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
1、HotGo 后台进入 开发工具->插件管理->找到创建新插件,根据引导进行创建即可。
|
||||
|
||||
```
|
||||
```shell
|
||||
创建成功后默认情况下会在以下目录中生成插件文件,假设新生成的插件名为:hgexample
|
||||
|
||||
1. /server/addons/hgexample/ # 插件模块目录
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
2、创建插件完毕重启服务端后,插件管理中会出现你新创建的插件信息。操作栏有几个按钮,在此进行说明
|
||||
- 安装:会自动执行 server/hgexample/main.go 文件中的Install方法,方法中的具体逻辑默认为空,可以根据实际情况自行配置。如生成后台菜单、生成插件配置表初始化数据、迁移home页面、web项目文件等。
|
||||
```
|
||||
```go
|
||||
// Install 安装模块
|
||||
func (m *module) Install(ctx context.Context) (err error) {
|
||||
// ...
|
||||
@@ -38,7 +38,7 @@ func (m *module) Install(ctx context.Context) (err error) {
|
||||
```
|
||||
|
||||
- 更新:会自动执行 server/hgexample/main.go 文件中的Upgrade方法,方法中的具体逻辑默认为空,可以根据实际情况自行配置。
|
||||
```
|
||||
```go
|
||||
// Upgrade 更新模块
|
||||
func (m *module) Upgrade(ctx context.Context) (err error) {
|
||||
// ...
|
||||
@@ -47,7 +47,7 @@ func (m *module) Upgrade(ctx context.Context) (err error) {
|
||||
```
|
||||
|
||||
- 卸载:会自动执行 server/hgexample/main.go 文件中的UnInstall方法,方法中的具体逻辑默认为空,可以根据实际情况自行配置。如会清除所有的数据表和已安装的信息等。
|
||||
```
|
||||
```go
|
||||
// UnInstall 卸载模块
|
||||
func (m *module) UnInstall(ctx context.Context) (err error) {
|
||||
// ...
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#### 模块结构
|
||||
- 文件路径:server/internal/library/addons/module.go
|
||||
|
||||
```go
|
||||
// Skeleton 模块骨架
|
||||
type Skeleton struct {
|
||||
@@ -43,6 +44,7 @@ type Module interface {
|
||||
#### 获取模块信息
|
||||
|
||||
- 在插件模块内
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
@@ -57,6 +59,7 @@ func test() {
|
||||
```
|
||||
|
||||
- 在插件模块外
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ gf run main.go
|
||||
|
||||
# web端
|
||||
cd web
|
||||
yarn dev
|
||||
pnpm run dev 或 npm run dev
|
||||
```
|
||||
|
||||
以下是一个关联表的CURD生成流程
|
||||
|
||||
@@ -10,7 +10,7 @@ gf run main.go
|
||||
|
||||
# web端
|
||||
cd web
|
||||
yarn dev
|
||||
pnpm run dev 或 npm run dev
|
||||
```
|
||||
|
||||
以下是一个基本的CURD生成流程
|
||||
|
||||
@@ -10,7 +10,7 @@ gf run main.go
|
||||
|
||||
# web端
|
||||
cd web
|
||||
yarn dev
|
||||
pnpm run dev 或 npm run dev
|
||||
```
|
||||
|
||||
以下是一个基本的树形CURD生成流程
|
||||
|
||||
BIN
docs/guide-zh-CN/images/issue/1.4.0.png
Normal file
BIN
docs/guide-zh-CN/images/issue/1.4.0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 163 KiB |
BIN
docs/guide-zh-CN/images/issue/1.4.1.png
Normal file
BIN
docs/guide-zh-CN/images/issue/1.4.1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 283 KiB |
BIN
docs/guide-zh-CN/images/issue/1.4.2.png
Normal file
BIN
docs/guide-zh-CN/images/issue/1.4.2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 255 KiB |
BIN
docs/guide-zh-CN/images/issue/1.4.3.png
Normal file
BIN
docs/guide-zh-CN/images/issue/1.4.3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 294 KiB |
@@ -41,8 +41,9 @@ cd server && make build
|
||||
cd server # 切换到服务端目录下
|
||||
rm -rf ./resource/public/admin/ # 删除之前的web资源
|
||||
mkdir ./resource/public/admin/ # 重新创建web资源存放目录,除首次编译后续可以跳过执行此步骤
|
||||
cd ../web && yarn build # 切换到web项目下,编译web项目
|
||||
cd ../web && pnpm run build # 切换到web项目下,编译web项目
|
||||
\cp -rf ./dist/* ../server/resource/public/admin/ # 将编译好的web资源复制到server对应的资源存放路径下
|
||||
cd ../server # 切换回服务端目录下
|
||||
echo "y" | gf build # 编译hotgo服务端
|
||||
|
||||
# 不出意外你已经编译好了hotgo可执行文件!
|
||||
@@ -57,7 +58,7 @@ echo "y" | gf build # 编译hotgo服务端
|
||||
|
||||
# 编译web端
|
||||
cd web
|
||||
yarn build
|
||||
pnpm run build 或 npm run build
|
||||
|
||||
# web端编译完成后,将web/dist/*中的文件上传到`server`端线上运行目录:/resource/public/admin即可
|
||||
# 至此,web端和server端都可以独立覆盖更新
|
||||
@@ -77,7 +78,7 @@ yarn build
|
||||
### Nginx配置
|
||||
```
|
||||
# websocket
|
||||
location ^~ /socket {
|
||||
location = /socket {
|
||||
proxy_pass http://127.0.0.1:8000/socket;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@@ -97,9 +98,11 @@ yarn build
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_pass http://127.0.0.1:8000/; # 设置代理服务器的协议和地址
|
||||
proxy_pass http://127.0.0.1:8000/;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection upgrade;
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
@@ -11,21 +11,21 @@
|
||||
1. 前往https://nodejs.org/zh-cn/下载当前版本node
|
||||
2. 命令行运行 `node -v` 若控制台输出版本号则node安装成功
|
||||
3. node 版本需大于等于 `16.0`
|
||||
4. 安装yarn:`npm install -g yarn`
|
||||
5. 命令行运行 `yarn -v` 若控制台输出版本号则前端环境搭建成功
|
||||
4. 安装pnpm:`npm install -g pnpm`
|
||||
5. 命令行运行 `pnpm -v` 若控制台输出版本号则前端环境搭建成功
|
||||
|
||||
### 后端环境
|
||||
1. 下载golang安装 版本号需>=1.21
|
||||
1. 下载golang安装 版本号需>=1.23
|
||||
2. 国际: https://golang.org/dl/
|
||||
3. 国内: https://golang.google.cn/dl/
|
||||
4. 命令行运行 go 若控制台输出各类提示命令 则安装成功 输入 `go version` 确认版本大于1.19
|
||||
4. 命令行运行 go 若控制台输出各类提示命令 则安装成功 输入 `go version` 确认版本大于1.23
|
||||
5. 开发工具推荐 [Goland](https://www.jetbrains.com/go/)
|
||||
|
||||
### 使用说明
|
||||
|
||||
> 需要本地具有 git node golang 环境
|
||||
|
||||
- node版本 >= 16.0.0
|
||||
- golang版本 >= 1.21
|
||||
- node版本 >= 20.0.0
|
||||
- golang版本 >= 1.23
|
||||
- mysql版本 >= 5.7,引擎需要是 innoDB
|
||||
- IDE推荐:Goland
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
### 环境要求
|
||||
|
||||
- node版本 >= v16.0.0
|
||||
- golang版本 >= v1.21
|
||||
- node版本 >= v20.0.0
|
||||
- golang版本 >= v1.23
|
||||
- goframe版本 >=v2.7.0
|
||||
- mysql版本 >=5.7
|
||||
|
||||
@@ -69,7 +69,7 @@ gfcli:
|
||||
三、 启动服务
|
||||
|
||||
1、服务端:
|
||||
```shell script
|
||||
```shell
|
||||
cd server
|
||||
|
||||
# 设置国内代理,如果已经设置好了代理可以跳过
|
||||
@@ -86,15 +86,15 @@ gfcli:
|
||||
```
|
||||
|
||||
2、web前端:
|
||||
```shell script
|
||||
```shell
|
||||
cd web
|
||||
# 首先确定你以安装node16.0以上版本并安装了包[npm、yarn],否则可能会出现一些未知报错
|
||||
# 首先确定你以安装node16.0以上版本并安装了包[npm、pnpm],否则可能会出现一些未知报错
|
||||
|
||||
# 安装依赖
|
||||
yarn install
|
||||
pnpm install
|
||||
|
||||
# 启动web项目
|
||||
yarn dev
|
||||
pnpm run dev
|
||||
|
||||
# 如果顺利,至此到浏览器打开:http://你的IP:8001/admin
|
||||
# 登录账号:admin, 密码:123456
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#### 1、安装数据库出现 json 报错不支持
|
||||
|
||||
请安装 mysql5.7 及以上版本的数据库
|
||||
请安装 mysql5.7 及以上版本的数据库。如果你使用的是mariadb请确认版本号,mariadb从 10.2 版本开始支持 json 数据类型。
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,31 @@
|
||||
|
||||
系统运行目录下配置hack/config.yaml文件。如果是生产环境运行,并且不需要开发工具相关功能,可以将`manifest/config/config.yaml`配置文件中的`system.mode`值改为`product`,这样启动时不会加载开发工具相关功能
|
||||
|
||||
#### 4、非超管角色提示:你没有访问权限!
|
||||

|
||||
|
||||
此问题因当前角色访问的页面包含未分配权限的接口所致,在多角色场景中较为常见,解决步骤如下:
|
||||
|
||||
1. 定位缺失权限的接口
|
||||
- 用超管账号进入系统应用 -> 日志管理 -> 全局日志,搜索状态码为`62 无访问权限`的记录
|
||||
- 示例:若请求接口为`/admin/hgexample/treeTable/list`,需处理的权限路径为`/hgexample/treeTable/list`(去除`/admin`前缀)
|
||||
|
||||

|
||||
|
||||
假如查到请求接口是:`/admin/hgexample/treeTable/list`,那需要分配的菜单权限就是:`/hgexample/treeTable/list`,要把`/admin`去掉
|
||||
|
||||
2. 配置菜单权限
|
||||
- 进入权限管理 -> 菜单权限:
|
||||
- 若目标菜单不存在,先新增菜单
|
||||
- 若菜单已存在但未配置接口权限,就把步骤1中的权限路径添加到【分配权限】中(已配置则跳过)
|
||||
|
||||

|
||||
|
||||
3. 分配权限给角色
|
||||
- 进入权限管理 -> 角色权限,找到对应角色并点击【菜单权限】
|
||||
- 勾选步骤2中配置的菜单权限,保存即可
|
||||
|
||||

|
||||
|
||||
### 四、前端相关
|
||||
|
||||
|
||||
@@ -11,6 +11,54 @@
|
||||
|
||||
> 如果升级(覆盖)代码后打开会出现 sql 报错, 请检查更新的数据库格式或自行调整
|
||||
|
||||
|
||||
### v2.17.8
|
||||
updated 2025.7.13
|
||||
|
||||
- 优化:表格排序处理器兼容关联表别名
|
||||
- 优化:优化动态统计数字在0值时显示问题
|
||||
- 优化:优化首页快捷菜单点击事件范围
|
||||
- 优化:优化短信、邮件验证码相关验证类数据排序
|
||||
- 优化:优化Nginx配置,支持流式请求和兼容部分版本无法匹配到websocket规则问题
|
||||
- 优化:naive-ui版本升级到2.42.0
|
||||
- 优化:vue3-json-viewer版本升级到2.4.1
|
||||
- 修复:修复可选用户选项`Fields`生成错误问题
|
||||
|
||||
|
||||
### v2.16.10
|
||||
updated 2025.3.22
|
||||
|
||||
- 增加:增加组合下拉用户筛选组件
|
||||
- 优化:文件上传类型限制改为统一由后台配置控制
|
||||
- 优化:websocket重连时间调整为10秒,初始化数据库中的网站地址调整为`127.0.0.1`
|
||||
- 优化:优化访问日志字段展示方式
|
||||
- 优化:系统公告发送编辑模态框调整为抽屉
|
||||
- 优化:gf版本升级到v2.9.0
|
||||
- 优化:naive-ui版本升级到2.41.0
|
||||
- 修复:修复vue路由`Redirect`命名重复问题
|
||||
- 修复:优化代码生成在插件中`使用生成字典选项`时model包名重复问题
|
||||
|
||||
|
||||
### v2.15.11
|
||||
updated 2024.11.27
|
||||
|
||||
- 增加:增加配置管理子页面选项参数记忆
|
||||
- 修复:修复定时任务中日志配置的读取并发读问题
|
||||
- 优化:gf版本升级到v2.8.2
|
||||
- 优化:优化数据卡片展示
|
||||
|
||||
|
||||
### v2.15.7
|
||||
updated 2024.7.21
|
||||
|
||||
- 增加:访问日志、服务日志增加关键词搜索
|
||||
- 增加:web端增加字典状态管理,重构字典选项使用方式,大幅减少冗余代码
|
||||
- 修复:修复生成代码选项式树表已知的一些小bug
|
||||
- 优化:gf版本升级到v2.7.2
|
||||
- 优化:naive-ui版本升级到2.39.0
|
||||
- 优化:访问日志不再记录过大的请求头参数,减少日志大小
|
||||
|
||||
|
||||
### v2.15.1
|
||||
updated 2024.4.22
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ gfcli:
|
||||
### 生成CRUD表格
|
||||
|
||||
- 推荐使用热编译方式启动HotGo,这样生成完成页面自动刷新即可看到新生成内容,无需手动重启
|
||||
- 服务端热编译启动:`gf run main.go`, web前端启动:`yarn dev`
|
||||
- 服务端热编译启动:`gf run main.go`, web前端启动:`pnpm run dev` 或 `npm run dev`
|
||||
|
||||
1、创建数据表
|
||||
|
||||
@@ -176,7 +176,7 @@ CREATE TABLE `hg_test_category` (
|
||||
|
||||
1.3 插入测试数据
|
||||
```mysql
|
||||
INSERT INTO `hg_test_table` (`id`, `category_id`, `title`, `description`, `content`, `image`, `attachfile`, `city_id`, `switch`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (1, 1, '测试标题', '描述', '<h2><strong>不知道写点啥!</strong></h2><p><br></p><iframe class=\"ql-video\" frameborder=\"0\" allowfullscreen=\"true\" src=\"https://media.w3.org/2010/05/sintel/trailer.mp4\"></iframe><p><br></p><p><img src=\"http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2023-02-09/cqdq9iuv0phsg8patk.png\"></p>', 'https://bufanyun.cn-bj.ufileos.com/hotgo/logo.sig.png', 'http://bufanyun.cn-bj.ufileos.com/hotgo/attachment/2022-12-30/cpf1x44idoycrtajf2.xlsx', 110102, 1, 10, 1, 0, 1, '2022-12-15 19:30:14', '2023-02-23 13:55:32', NULL);
|
||||
INSERT INTO `hg_test_table` (`id`, `category_id`, `title`, `description`, `content`, `image`, `attachfile`, `city_id`, `switch`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (1, 1, '测试标题', '描述', '<h2><strong>不知道写点啥!</strong></h2><p><br></p><iframe class=\"ql-video\" frameborder=\"0\" allowfullscreen=\"true\" src=\"https://media.w3.org/2010/05/sintel/trailer.mp4\"></iframe><p><br></p><p><img src=\"https://gmycos.facms.cn/hotgo/attachment/2023-02-09/cqdq9iuv0phsg8patk.png\"></p>', 'https://gmycos.facms.cn/hotgo/logo.sig.png', 'https://gmycos.facms.cn/hotgo/attachment/2022-12-30/cpf1x44idoycrtajf2.xlsx', 110102, 1, 10, 1, 0, 1, '2022-12-15 19:30:14', '2023-02-23 13:55:32', NULL);
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -1,149 +1,150 @@
|
||||
## 数据库
|
||||
|
||||
目录
|
||||
|
||||
- 字段类型
|
||||
- 特殊字段默认表单组件
|
||||
- 特殊字段默认表单验证器
|
||||
- SQL默认查询方式
|
||||
- 其他
|
||||
|
||||
### 字段类型
|
||||
|
||||
- 创建数据库表当按如下的规则进行字段命名、类型、属性设置和备注后,再生成CRUD代码时会自动生成对应的Api、控制器、业务逻辑、Web页面、[表单组件](web-form.md)等的一些默认属性
|
||||
- 当你了解这些默认技巧后,会有效提高你在实际开发中的生产效率
|
||||
|
||||
| 数据库类型 | 额外属性 | 转换Go类型 | 转换Ts类型 | 表单组件 |
|
||||
|---------------------------------------------------------------|--------------|--------------|---------|-----------------------|
|
||||
| int, tinyint,small_int,smallint,medium_int,mediumint,serial | / | int | number | InputNumber(数字输入框) |
|
||||
| int, tinyint,small_int,smallint,medium_int,mediumint,serial | unsigned | uint | number | InputNumber(数字输入框) |
|
||||
| big_int,bigint,bigserial | / | int64 | number | InputNumber(数字输入框) |
|
||||
| big_int,bigint,bigserial | unsigned | uint64 | number | InputNumber(数字输入框) |
|
||||
| real | / | float32 | number | InputNumber(数字输入框) |
|
||||
| float,double,decimal,money,numeric,smallmoney | / | float64 | number | InputNumber(数字输入框) |
|
||||
| bit(1) 、bit(true)、bit(false) | / | bool | boolean | Input(文本输入框,默认) |
|
||||
| bit | / | int64-bytes | array | InputDynamic(动态KV表单) |
|
||||
| bit | unsigned | uint64-bytes | array | InputDynamic (动态KV表单) |
|
||||
| bool | / | bool | boolean | Input(文本输入框,默认) |
|
||||
| date | / | *gtime.Time | string | Date(日期选择器) |
|
||||
| datetime,timestamp,timestamptz | / | *gtime.Time | string | Time(时间选择器) |
|
||||
| json | / | *gjson.Json | string | Input(文本输入框) |
|
||||
| jsonb | / | *gjson.Json | string | Input(文本输入框) |
|
||||
| 以下为物理类型中包含字段部分时的转换方式,默认情况 | / | / | / | / |
|
||||
| text,char,character | / | string | string | Input(文本输入框) |
|
||||
| float,double,numeric | / | string | string | Input(文本输入框) |
|
||||
| bool | / | bool | boolean | Input(文本输入框,默认) |
|
||||
| binary,blob | / | []byte | string | Input(文本输入框,默认) |
|
||||
| int | / | int | number | InputNumber(数字输入框) |
|
||||
| int | unsigned | int | number | InputNumber(数字输入框) |
|
||||
| time | / | *gtime.Time | string | Time(时间选择器) |
|
||||
| date | / | *gtime.Time | string | Date(日期选择器) |
|
||||
| 没有满足以上任何条件的 | / | string | string | Input(文本输入框) |
|
||||
|
||||
|
||||
### 特殊字段默认表单组件
|
||||
- 以下字段在不设置表单组件时会默认使用的表单组件
|
||||
|
||||
| 数据库字段 | 字段名称 | 表单组件 |
|
||||
|--------------|----------------------|----------------------|
|
||||
| status | 状态字段(任意int类型) | Select (单选下拉框) |
|
||||
| created_at | 创建时间字段 | TimeRange (时间范围选择) |
|
||||
| province_id | 省份ID字段(任意int类型) | CitySelector (省市区选择) |
|
||||
| city_id | 城市ID字段(任意int类型) | CitySelector (省市区选择) |
|
||||
| 任意字串符字段 | 长度>= 200 and <= 500 | InputTextarea (文本域) |
|
||||
| 任意字串符字段 | 长度> 500 | InputEditor (富文本) |
|
||||
|
||||
|
||||
### 特殊字段默认表单验证器
|
||||
- 以下字段在不设置表单组件时会默认使用的表单验证器
|
||||
|
||||
| 数据库字段/Go类型 | 字段名称 | 表单验证规则 |
|
||||
|-------------------|--------|-----------------------|
|
||||
| mobile | 手机号 | 不为空时必须是手机号码(国内) |
|
||||
| qq | QQ | 不为空时必须是QQ号码 |
|
||||
| email | 邮箱地址 | 不为空时必须是邮箱格式 |
|
||||
| id_card | 身份证号码 | 不为空时必须是15或18位身份证号码 |
|
||||
| bank_card | 银行卡号码 | 银行卡号码 |
|
||||
| password | 密码 | 密码验证,必须包含6-18为字母和数字 |
|
||||
| price | 价格 | 金额验证,最多允许输入10位整数及2位小数 |
|
||||
| Go类型为uint、uint64 | 正整数 | 非零正整数验证 |
|
||||
|
||||
### SQL默认查询方式
|
||||
- Go类型取决于数据库物理类型,请参考 [字段类型] 部分
|
||||
|
||||
| Go类型 | 查询方式 |
|
||||
|-------------------------|--------------------------------------|
|
||||
| string | LIKE |
|
||||
| date,datetime | = |
|
||||
| int,uint,int64,uint64 | = |
|
||||
| []int,[]int64,[]uint64 | IN (...) |
|
||||
| float32,float64 | = |
|
||||
| []byte4 | =(默认) |
|
||||
| time.Time,*gtime.Time | = |
|
||||
| *gjson.Json | JSON_CONTAINS(json_doc, val[, path]) |
|
||||
|
||||
|
||||
|
||||
### 其他
|
||||
|
||||
#### 默认字典选项
|
||||
|
||||
- 数据库字段为 `status`且类型为任意数字类型的会使用系统默认的状态字典
|
||||
|
||||
#### 默认属性
|
||||
|
||||
- 默认必填,当数据库字段存在非空`IS_NULLABLE`属性时,默认勾选必填验证
|
||||
- 默认唯一,当数据库字段索引存在`UNI`时,默认勾选唯一值验证
|
||||
- 默认主键,当数据库字段索引存在`PRI`时,默认为主键,不允许编辑
|
||||
- 默认排序,当数据库字段存在`sort`时,默认开启排序,添加表单自动获取最大排序增量值并填充表单
|
||||
- 默认列名,默认使用字段注释作为表格的列名。当数据库字段未设置注释时,默认使用字段名称作为列名
|
||||
|
||||
#### 自动更新/插入
|
||||
|
||||
- 自动更新,当数据库字段为`updated_at`(更新时间),`updated_by`(更新者)
|
||||
- 自动插入,当数据库字段为`created_at`(创建时间),`created_by`(创建者)
|
||||
- 软删除,表存在字段`deleted_at`时,使用表的Orm模型查询条件将会自动加入[ `deleted_at` IS NULL ],删除时只更新删除时间而不会真的删除数据
|
||||
- 树表:不论更新插入,都会根据表中字段`pid`(上级ID)自动维护`level`(树等级)和`tree`(关系树)
|
||||
|
||||
|
||||
#### 操作人字段维护
|
||||
|
||||
- 生成列表中存在并且勾选展示字段`created_by`(创建者)、`updated_by`(修改者)、`deleted_by`(删除者)时,会自动到表`hg_admin_member`中获取操作人的基本信息摘要,并渲染到列表中,效果如下:
|
||||
|
||||

|
||||
|
||||
- 生成列表中存在并且勾选查询字段`created_by`(创建者)、`updated_by`(修改者)、`deleted_by`(删除者)时,会强制将查询表单改为关键词查询,从`hg_admin_member`查询操作人。效果如下:
|
||||
|
||||

|
||||
|
||||
- 查询代码片段,参考路径:[server/internal/logic/admin/member.go](../../server/internal/logic/admin/member.go)
|
||||
```go
|
||||
|
||||
// 查询创建者
|
||||
if in.CreatedBy != "" {
|
||||
ids, err := service.AdminMember().GetIdsByKeyword(ctx, in.CreatedBy)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
mod = mod.WhereIn(dao.SysGenCurdDemo.Columns().CreatedBy, ids)
|
||||
}
|
||||
|
||||
// GetIdsByKeyword 根据关键词查找符合条件的用户ID
|
||||
func (s *sAdminMember) GetIdsByKeyword(ctx context.Context, ks string) (res []int64, err error) {
|
||||
ks = gstr.Trim(ks)
|
||||
if len(ks) == 0 {
|
||||
return
|
||||
}
|
||||
array, err := dao.AdminMember.Ctx(ctx).Fields("id").
|
||||
Where("`id` = ? or `real_name` = ? or `username` = ? or `mobile` = ?", ks, ks, ks, ks).
|
||||
Array()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "根据关键词获取用户ID失败,请稍后重试!")
|
||||
}
|
||||
res = gvar.New(array).Int64s()
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
> 这里只列举了较为常用的默认规则,其他更多默认规则请参考:[server/internal/library/hggen/views/column_default.go](../../server/internal/library/hggen/views/column_default.go)
|
||||
## 数据库
|
||||
|
||||
目录
|
||||
|
||||
- 字段类型
|
||||
- 特殊字段默认表单组件
|
||||
- 特殊字段默认表单验证器
|
||||
- SQL默认查询方式
|
||||
- 其他
|
||||
|
||||
### 字段类型
|
||||
|
||||
- 创建数据库表当按如下的规则进行字段命名、类型、属性设置和备注后,再生成CRUD代码时会自动生成对应的Api、控制器、业务逻辑、Web页面、[表单组件](web-form.md)等的一些默认属性
|
||||
- 当你了解这些默认技巧后,会有效提高你在实际开发中的生产效率
|
||||
|
||||
| 数据库类型 | 额外属性 | 转换Go类型 | 转换Ts类型 | 表单组件 |
|
||||
|---------------------------------------------------------------|--------------|--------------|---------|-----------------------|
|
||||
| int, tinyint,small_int,smallint,medium_int,mediumint,serial | / | int | number | InputNumber(数字输入框) |
|
||||
| int, tinyint,small_int,smallint,medium_int,mediumint,serial | unsigned | uint | number | InputNumber(数字输入框) |
|
||||
| big_int,bigint,bigserial | / | int64 | number | InputNumber(数字输入框) |
|
||||
| big_int,bigint,bigserial | unsigned | uint64 | number | InputNumber(数字输入框) |
|
||||
| real | / | float32 | number | InputNumber(数字输入框) |
|
||||
| float,double,decimal,money,numeric,smallmoney | / | float64 | number | InputNumber(数字输入框) |
|
||||
| bit(1) 、bit(true)、bit(false) | / | bool | boolean | Input(文本输入框,默认) |
|
||||
| bit | / | int64-bytes | array | InputDynamic(动态KV表单) |
|
||||
| bit | unsigned | uint64-bytes | array | InputDynamic (动态KV表单) |
|
||||
| bool | / | bool | boolean | Input(文本输入框,默认) |
|
||||
| date | / | *gtime.Time | string | Date(日期选择器) |
|
||||
| datetime,timestamp,timestamptz | / | *gtime.Time | string | Time(时间选择器) |
|
||||
| json | / | *gjson.Json | string | Input(文本输入框) |
|
||||
| jsonb | / | *gjson.Json | string | Input(文本输入框) |
|
||||
| 以下为物理类型中包含字段部分时的转换方式,默认情况 | / | / | / | / |
|
||||
| text,char,character | / | string | string | Input(文本输入框) |
|
||||
| float,double,numeric | / | string | string | Input(文本输入框) |
|
||||
| bool | / | bool | boolean | Input(文本输入框,默认) |
|
||||
| binary,blob | / | []byte | string | Input(文本输入框,默认) |
|
||||
| int | / | int | number | InputNumber(数字输入框) |
|
||||
| int | unsigned | int | number | InputNumber(数字输入框) |
|
||||
| time | / | *gtime.Time | string | Time(时间选择器) |
|
||||
| date | / | *gtime.Time | string | Date(日期选择器) |
|
||||
| 没有满足以上任何条件的 | / | string | string | Input(文本输入框) |
|
||||
|
||||
|
||||
### 特殊字段默认表单组件
|
||||
- 以下字段在不设置表单组件时会默认使用的表单组件
|
||||
|
||||
| 数据库字段 | 字段名称 | 表单组件 |
|
||||
|--------------|----------------------|----------------------|
|
||||
| status | 状态字段(任意int类型) | Select (单选下拉框) |
|
||||
| created_at | 创建时间字段 | TimeRange (时间范围选择) |
|
||||
| province_id | 省份ID字段(任意int类型) | CitySelector (省市区选择) |
|
||||
| city_id | 城市ID字段(任意int类型) | CitySelector (省市区选择) |
|
||||
| 任意字串符字段 | 长度>= 200 and <= 500 | InputTextarea (文本域) |
|
||||
| 任意字串符字段 | 长度> 500 | InputEditor (富文本) |
|
||||
|
||||
|
||||
### 特殊字段默认表单验证器
|
||||
- 以下字段在不设置表单组件时会默认使用的表单验证器
|
||||
|
||||
| 数据库字段/Go类型 | 字段名称 | 表单验证规则 |
|
||||
|-------------------|--------|-----------------------|
|
||||
| mobile | 手机号 | 不为空时必须是手机号码(国内) |
|
||||
| qq | QQ | 不为空时必须是QQ号码 |
|
||||
| email | 邮箱地址 | 不为空时必须是邮箱格式 |
|
||||
| id_card | 身份证号码 | 不为空时必须是15或18位身份证号码 |
|
||||
| bank_card | 银行卡号码 | 银行卡号码 |
|
||||
| password | 密码 | 密码验证,必须包含6-18为字母和数字 |
|
||||
| price | 价格 | 金额验证,最多允许输入10位整数及2位小数 |
|
||||
| Go类型为uint、uint64 | 正整数 | 非零正整数验证 |
|
||||
|
||||
### SQL默认查询方式
|
||||
- Go类型取决于数据库物理类型,请参考 [字段类型] 部分
|
||||
|
||||
| Go类型 | 查询方式 |
|
||||
|-------------------------|--------------------------------------|
|
||||
| string | LIKE |
|
||||
| date,datetime | = |
|
||||
| int,uint,int64,uint64 | = |
|
||||
| []int,[]int64,[]uint64 | IN (...) |
|
||||
| float32,float64 | = |
|
||||
| []byte4 | =(默认) |
|
||||
| time.Time,*gtime.Time | = |
|
||||
| *gjson.Json | JSON_CONTAINS(json_doc, val[, path]) |
|
||||
|
||||
|
||||
|
||||
### 其他
|
||||
|
||||
#### 默认字典选项
|
||||
|
||||
- 数据库字段为 `status`且类型为任意数字类型的会使用系统默认的状态字典
|
||||
|
||||
#### 默认属性
|
||||
|
||||
- 默认必填,当数据库字段存在非空`IS_NULLABLE`属性时,默认勾选必填验证
|
||||
- 默认唯一,当数据库字段索引存在`UNI`时,默认勾选唯一值验证
|
||||
- 默认主键,当数据库字段索引存在`PRI`时,默认为主键,不允许编辑
|
||||
- 默认排序,当数据库字段存在`sort`时,默认开启排序,添加表单自动获取最大排序增量值并填充表单
|
||||
- 默认列名,默认使用字段注释作为表格的列名。当数据库字段未设置注释时,默认使用字段名称作为列名
|
||||
|
||||
#### 自动更新/插入
|
||||
|
||||
- 自动更新,当数据库字段为`updated_at`(更新时间),`updated_by`(更新者)
|
||||
- 自动插入,当数据库字段为`created_at`(创建时间),`created_by`(创建者)
|
||||
- 软删除,表存在字段`deleted_at`时,使用表的Orm模型查询条件将会自动加入[ `deleted_at` IS NULL ],删除时只更新删除时间而不会真的删除数据
|
||||
- 树表:不论更新插入,都会根据表中字段`pid`(上级ID)自动维护`level`(树等级)和`tree`(关系树)
|
||||
|
||||
|
||||
#### 操作人字段维护
|
||||
|
||||
- 生成列表中存在并且勾选展示字段`created_by`(创建者)、`updated_by`(修改者)、`deleted_by`(删除者)时,会自动到表`hg_admin_member`中获取操作人的基本信息摘要,并渲染到列表中,效果如下:
|
||||
|
||||

|
||||
|
||||
- 生成列表中存在并且勾选查询字段`created_by`(创建者)、`updated_by`(修改者)、`deleted_by`(删除者)时,会强制将查询表单改为关键词查询,从`hg_admin_member`查询操作人。效果如下:
|
||||
|
||||

|
||||
|
||||
- 查询代码片段,参考路径:[server/internal/logic/admin/member.go](../../server/internal/logic/admin/member.go)
|
||||
|
||||
```go
|
||||
|
||||
// 查询创建者
|
||||
if in.CreatedBy != "" {
|
||||
ids, err := service.AdminMember().GetIdsByKeyword(ctx, in.CreatedBy)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
mod = mod.WhereIn(dao.SysGenCurdDemo.Columns().CreatedBy, ids)
|
||||
}
|
||||
|
||||
// GetIdsByKeyword 根据关键词查找符合条件的用户ID
|
||||
func (s *sAdminMember) GetIdsByKeyword(ctx context.Context, ks string) (res []int64, err error) {
|
||||
ks = gstr.Trim(ks)
|
||||
if len(ks) == 0 {
|
||||
return
|
||||
}
|
||||
array, err := dao.AdminMember.Ctx(ctx).Fields("id").
|
||||
Where("`id` = ? or `real_name` = ? or `username` = ? or `mobile` = ?", ks, ks, ks, ks).
|
||||
Array()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "根据关键词获取用户ID失败,请稍后重试!")
|
||||
}
|
||||
res = gvar.New(array).Int64s()
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
> 这里只列举了较为常用的默认规则,其他更多默认规则请参考:[server/internal/library/hggen/views/column_default.go](../../server/internal/library/hggen/views/column_default.go)
|
||||
|
||||
@@ -63,16 +63,17 @@
|
||||
#### import
|
||||
* 单行import不建议用圆括号包裹
|
||||
* 按照`官方包`,NEW LINE,`当前工程包`,NEW LINE,`第三方依赖包`顺序引入
|
||||
```go
|
||||
import (
|
||||
"context"
|
||||
"string"
|
||||
|
||||
"greet/user/internal/config"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
```
|
||||
|
||||
```go
|
||||
import (
|
||||
"context"
|
||||
"string"
|
||||
|
||||
"greet/user/internal/config"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
```
|
||||
|
||||
#### 函数返回
|
||||
* 对象避免非指针返回
|
||||
@@ -84,7 +85,8 @@
|
||||
|
||||
#### 函数体编码
|
||||
* 建议一个block结束空一行,如if、for等
|
||||
```go
|
||||
|
||||
```go
|
||||
func main (){
|
||||
if x==1{
|
||||
// do something
|
||||
@@ -92,15 +94,16 @@
|
||||
|
||||
fmt.println("xxx")
|
||||
}
|
||||
```
|
||||
```
|
||||
* return前尽可能空一行
|
||||
```go
|
||||
func getUser(id string)(string,error){
|
||||
....
|
||||
|
||||
return "xx",nil
|
||||
}
|
||||
```
|
||||
|
||||
```go
|
||||
func getUser(id string)(string,error){
|
||||
....
|
||||
|
||||
return "xx",nil
|
||||
}
|
||||
```
|
||||
|
||||
### 框架规范
|
||||
|
||||
|
||||
@@ -1,316 +1,318 @@
|
||||
## 功能扩展库
|
||||
|
||||
目录
|
||||
|
||||
- 缓存驱动
|
||||
- 请求上下文
|
||||
- JWT
|
||||
- 数据字典
|
||||
- 地理定位(待写)
|
||||
- 通知(待写)
|
||||
|
||||
|
||||
### 缓存驱动
|
||||
|
||||
> 系统默认的缓存驱动为file,目前已支持:memory|redis|file等多种驱动。请自行选择适合你的驱动使用。
|
||||
|
||||
- 配置文件:server/manifest/config/config.yaml
|
||||
|
||||
```yaml
|
||||
#缓存
|
||||
cache:
|
||||
adapter: "file" # 缓存驱动方式,支持:memory|redis|file,不填默认memory
|
||||
fileDir: "./storage/cache" # 文件缓存路径,adapter=file时必填
|
||||
```
|
||||
|
||||
#### 使用方式
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/cache"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
func test() {
|
||||
ctx := gctx.New()
|
||||
|
||||
// 添加/修改
|
||||
cache.Instance().Set(ctx, "qwe", 123, 0)
|
||||
|
||||
// 查询
|
||||
cache.Instance().Get(ctx, "qwe")
|
||||
|
||||
// 删除
|
||||
cache.Instance().Remove(ctx, "qwe")
|
||||
|
||||
// 更多方法请参考:https://goframe.org/pages/viewpage.action?pageId=27755640
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### 请求上下文
|
||||
|
||||
- 主要用于在处理HTTP和websocket请求时通过中间件将用户、应用、插件等信息绑定到上下文中,方便在做业务处理时用到这些信息
|
||||
|
||||
```go
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"context"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/library/addons"
|
||||
)
|
||||
|
||||
|
||||
func test(ctx context.Context) {
|
||||
// 获取当前请求的所有上下文变量
|
||||
var ctxModel = contexts.Get(ctx)
|
||||
fmt.Printf("当前请求的所有上下文变量:%+v\n", ctxModel)
|
||||
|
||||
// 获取当前请求的应用模块
|
||||
var module = contexts.GetModule(ctx)
|
||||
fmt.Printf("当前请求的应用:%+v\n", module)
|
||||
|
||||
// 获取当前请求的用户信息
|
||||
var member = contexts.GetUser(ctx)
|
||||
fmt.Printf("当前访问用户信息:%+v\n", member)
|
||||
|
||||
// 获取当前请求的插件模块
|
||||
fmt.Printf("当前是否为插件请求:%v", contexts.IsAddonRequest(ctx))
|
||||
if contexts.IsAddonRequest(ctx) {
|
||||
fmt.Printf("当前插件名称:%v", contexts.GetAddonName(ctx))
|
||||
fmt.Printf("当前插件信息:%v", addons.GetModule(contexts.GetAddonName(ctx)))
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### JWT
|
||||
|
||||
- 基于jwt+缓存驱动实现的用户登录令牌功能,支持自动续约,解决了jwt服务端无法退出问题和jwt令牌无法主动失效问题
|
||||
|
||||
#### 配置示例
|
||||
```yaml
|
||||
# 登录令牌
|
||||
token:
|
||||
secretKey: "hotgo123" # 令牌加密秘钥,考虑安全问题生产环境中请修改默认值
|
||||
expires: 604800 # 令牌有效期,单位:秒。默认7天
|
||||
autoRefresh: true # 是否开启自动刷新过期时间, false|true 默认为true
|
||||
refreshInterval: 86400 # 刷新间隔,单位:秒。必须小于expires,否则无法触发。默认1天内只允许刷新一次
|
||||
maxRefreshTimes: 30 # 最大允许刷新次数,-1不限制。默认30次
|
||||
multiLogin: true # 是否允许多端登录, false|true 默认为true
|
||||
|
||||
```
|
||||
|
||||
```go
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"context"
|
||||
"hotgo/internal/library/token"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
|
||||
func test(ctx context.Context) {
|
||||
// 登录
|
||||
user := &model.Identity{
|
||||
Id: mb.Id,
|
||||
Pid: mb.Pid,
|
||||
DeptId: mb.DeptId,
|
||||
RoleId: ro.Id,
|
||||
RoleKey: ro.Key,
|
||||
Username: mb.Username,
|
||||
RealName: mb.RealName,
|
||||
Avatar: mb.Avatar,
|
||||
Email: mb.Email,
|
||||
Mobile: mb.Mobile,
|
||||
App: consts.AppAdmin,
|
||||
LoginAt: gtime.Now(),
|
||||
}
|
||||
|
||||
loginToken, expires, err := token.Login(ctx, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// gf请求对象
|
||||
r := *ghttp.Request
|
||||
|
||||
// 获取登录用户信息
|
||||
user, err := token.ParseLoginUser(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 注销登录
|
||||
err = token.Logout(r)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### 数据字典
|
||||
|
||||
- hotgo增加了对枚举字典和自定义方法字典的内置支持,从而在系统中经常使用的一些特定数据上做出了增强。
|
||||
|
||||
#### 字典数据选项
|
||||
- 文件路径:server/internal/model/dict.go
|
||||
```go
|
||||
package model
|
||||
|
||||
// Option 字典数据选项
|
||||
type Option struct {
|
||||
Key interface{} `json:"key"`
|
||||
Label string `json:"label" description:"字典标签"`
|
||||
Value interface{} `json:"value" description:"字典键值"`
|
||||
ValueType string `json:"valueType" description:"键值数据类型"`
|
||||
Type string `json:"type" description:"字典类型"`
|
||||
ListClass string `json:"listClass" description:"表格回显样式"`
|
||||
}
|
||||
```
|
||||
|
||||
#### 枚举字典
|
||||
- 适用于系统开发期间内置的枚举数据,这样即维护了枚举值,又关联了数据字典
|
||||
|
||||
##### 一个例子
|
||||
- 定义枚举值和字典数据选项,并注册字典类型
|
||||
- 文件路径:server/internal/consts/credit_log.go
|
||||
|
||||
```go
|
||||
package consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("creditType", "资金变动类型", CreditTypeOptions)
|
||||
dict.RegisterEnums("creditGroup", "资金变动分组", CreditGroupOptions)
|
||||
}
|
||||
|
||||
const (
|
||||
CreditTypeBalance = "balance" // 余额
|
||||
CreditTypeIntegral = "integral" // 积分
|
||||
)
|
||||
|
||||
const (
|
||||
CreditGroupDecr = "decr" // 扣款
|
||||
CreditGroupIncr = "incr" // 加款
|
||||
CreditGroupOpDecr = "op_decr" // 操作扣款
|
||||
CreditGroupOpIncr = "op_incr" // 操作加款
|
||||
CreditGroupBalanceRecharge = "balance_recharge" // 余额充值
|
||||
CreditGroupBalanceRefund = "balance_refund" // 余额退款
|
||||
CreditGroupApplyCash = "apply_cash" // 申请提现
|
||||
)
|
||||
|
||||
// CreditTypeOptions 变动类型
|
||||
var CreditTypeOptions = []*model.Option{
|
||||
dict.GenSuccessOption(CreditTypeBalance, "余额"),
|
||||
dict.GenInfoOption(CreditTypeIntegral, "积分"),
|
||||
}
|
||||
|
||||
// CreditGroupOptions 变动分组
|
||||
var CreditGroupOptions = []*model.Option{
|
||||
dict.GenWarningOption(CreditGroupDecr, "扣款"),
|
||||
dict.GenSuccessOption(CreditGroupIncr, "加款"),
|
||||
dict.GenWarningOption(CreditGroupOpDecr, "操作扣款"),
|
||||
dict.GenSuccessOption(CreditGroupOpIncr, "操作加款"),
|
||||
dict.GenWarningOption(CreditGroupBalanceRefund, "余额退款"),
|
||||
dict.GenSuccessOption(CreditGroupBalanceRecharge, "余额充值"),
|
||||
dict.GenInfoOption(CreditGroupApplyCash, "申请提现"),
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### 自定义方法字典
|
||||
- 适用于非固定选项,如数据是从某个表/文件读取或从第三方读取,数据需要进行转换时使用
|
||||
|
||||
##### 方法字典接口
|
||||
- 文件路径:server/internal/consts/credit_log.go
|
||||
```go
|
||||
package dict
|
||||
|
||||
// FuncDict 方法字典,实现本接口即可使用内置方法字典
|
||||
type FuncDict func(ctx context.Context) (res []*model.Option, err error)
|
||||
```
|
||||
|
||||
##### 一个例子
|
||||
- 定义获取字典数据方法,并注册字典类型
|
||||
- 文件路径:server/internal/logic/admin/post.go
|
||||
|
||||
```go
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
type sAdminPost struct{}
|
||||
|
||||
func NewAdminPost() *sAdminPost {
|
||||
return &sAdminPost{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterAdminPost(NewAdminPost())
|
||||
dict.RegisterFunc("adminPostOption", "岗位选项", service.AdminPost().Option)
|
||||
}
|
||||
|
||||
// Option 岗位选项
|
||||
func (s *sAdminPost) Option(ctx context.Context) (opts []*model.Option, err error) {
|
||||
var list []*entity.AdminPost
|
||||
if err = dao.AdminPost.Ctx(ctx).OrderAsc(dao.AdminPost.Columns().Sort).Scan(&list); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
opts = make([]*model.Option, 0)
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range list {
|
||||
opts = append(opts, dict.GenHashOption(v.Id, v.Name))
|
||||
}
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
#### 代码生成支持
|
||||
- 内置的枚举字典和自定义方法字典在生成代码时可以直接进行选择,生成代码格式和系统字典管理写法一致
|
||||
|
||||

|
||||
|
||||
|
||||
#### 内置字典和系统字典的区分
|
||||
|
||||
##### 主要区别
|
||||
- 系统字典由表:`hg_sys_dict_type`和`hg_sys_dict_data`共同进行维护,使用时需通过后台到字典管理中进行添加
|
||||
- 内置字典是系统开发期间在代码层面事先定义和注册好的数据选项
|
||||
|
||||
|
||||
##### 数据格式区别
|
||||
- 系统字典所有ID都是大于0的int64类型
|
||||
- 内置字典ID都是小于0的int64类型。枚举字典以20000开头,如:-200001381053496;方法字典以30000开头,如:-30000892528327;开头以外数字是根据数据选项的`key`值进行哈希算法得出
|
||||
|
||||
### 地理定位
|
||||
```go
|
||||
// 待写
|
||||
```
|
||||
|
||||
### 通知
|
||||
```go
|
||||
// 待写
|
||||
## 功能扩展库
|
||||
|
||||
目录
|
||||
|
||||
- 缓存驱动
|
||||
- 请求上下文
|
||||
- JWT
|
||||
- 数据字典
|
||||
- 地理定位(待写)
|
||||
- 通知(待写)
|
||||
|
||||
|
||||
### 缓存驱动
|
||||
|
||||
> 系统默认的缓存驱动为file,目前已支持:memory|redis|file等多种驱动。请自行选择适合你的驱动使用。
|
||||
|
||||
- 配置文件:server/manifest/config/config.yaml
|
||||
|
||||
```yaml
|
||||
#缓存
|
||||
cache:
|
||||
adapter: "file" # 缓存驱动方式,支持:memory|redis|file,不填默认memory
|
||||
fileDir: "./storage/cache" # 文件缓存路径,adapter=file时必填
|
||||
```
|
||||
|
||||
#### 使用方式
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/cache"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
func test() {
|
||||
ctx := gctx.New()
|
||||
|
||||
// 添加/修改
|
||||
cache.Instance().Set(ctx, "qwe", 123, 0)
|
||||
|
||||
// 查询
|
||||
cache.Instance().Get(ctx, "qwe")
|
||||
|
||||
// 删除
|
||||
cache.Instance().Remove(ctx, "qwe")
|
||||
|
||||
// 更多方法请参考:https://goframe.org/pages/viewpage.action?pageId=27755640
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### 请求上下文
|
||||
|
||||
- 主要用于在处理HTTP和websocket请求时通过中间件将用户、应用、插件等信息绑定到上下文中,方便在做业务处理时用到这些信息
|
||||
|
||||
```go
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"context"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/library/addons"
|
||||
)
|
||||
|
||||
|
||||
func test(ctx context.Context) {
|
||||
// 获取当前请求的所有上下文变量
|
||||
var ctxModel = contexts.Get(ctx)
|
||||
fmt.Printf("当前请求的所有上下文变量:%+v\n", ctxModel)
|
||||
|
||||
// 获取当前请求的应用模块
|
||||
var module = contexts.GetModule(ctx)
|
||||
fmt.Printf("当前请求的应用:%+v\n", module)
|
||||
|
||||
// 获取当前请求的用户信息
|
||||
var member = contexts.GetUser(ctx)
|
||||
fmt.Printf("当前访问用户信息:%+v\n", member)
|
||||
|
||||
// 获取当前请求的插件模块
|
||||
fmt.Printf("当前是否为插件请求:%v", contexts.IsAddonRequest(ctx))
|
||||
if contexts.IsAddonRequest(ctx) {
|
||||
fmt.Printf("当前插件名称:%v", contexts.GetAddonName(ctx))
|
||||
fmt.Printf("当前插件信息:%v", addons.GetModule(contexts.GetAddonName(ctx)))
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### JWT
|
||||
|
||||
- 基于jwt+缓存驱动实现的用户登录令牌功能,支持自动续约,解决了jwt服务端无法退出问题和jwt令牌无法主动失效问题
|
||||
|
||||
#### 配置示例
|
||||
```yaml
|
||||
# 登录令牌
|
||||
token:
|
||||
secretKey: "hotgo123" # 令牌加密秘钥,考虑安全问题生产环境中请修改默认值
|
||||
expires: 604800 # 令牌有效期,单位:秒。默认7天
|
||||
autoRefresh: true # 是否开启自动刷新过期时间, false|true 默认为true
|
||||
refreshInterval: 86400 # 刷新间隔,单位:秒。必须小于expires,否则无法触发。默认1天内只允许刷新一次
|
||||
maxRefreshTimes: 30 # 最大允许刷新次数,-1不限制。默认30次
|
||||
multiLogin: true # 是否允许多端登录, false|true 默认为true
|
||||
|
||||
```
|
||||
|
||||
```go
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"context"
|
||||
"hotgo/internal/library/token"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
|
||||
func test(ctx context.Context) {
|
||||
// 登录
|
||||
user := &model.Identity{
|
||||
Id: mb.Id,
|
||||
Pid: mb.Pid,
|
||||
DeptId: mb.DeptId,
|
||||
RoleId: ro.Id,
|
||||
RoleKey: ro.Key,
|
||||
Username: mb.Username,
|
||||
RealName: mb.RealName,
|
||||
Avatar: mb.Avatar,
|
||||
Email: mb.Email,
|
||||
Mobile: mb.Mobile,
|
||||
App: consts.AppAdmin,
|
||||
LoginAt: gtime.Now(),
|
||||
}
|
||||
|
||||
loginToken, expires, err := token.Login(ctx, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// gf请求对象
|
||||
r := *ghttp.Request
|
||||
|
||||
// 获取登录用户信息
|
||||
user, err := token.ParseLoginUser(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 注销登录
|
||||
err = token.Logout(r)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### 数据字典
|
||||
|
||||
- hotgo增加了对枚举字典和自定义方法字典的内置支持,从而在系统中经常使用的一些特定数据上做出了增强。
|
||||
|
||||
#### 字典数据选项
|
||||
- 文件路径:server/internal/model/dict.go
|
||||
|
||||
```go
|
||||
package model
|
||||
|
||||
// Option 字典数据选项
|
||||
type Option struct {
|
||||
Key interface{} `json:"key"`
|
||||
Label string `json:"label" description:"字典标签"`
|
||||
Value interface{} `json:"value" description:"字典键值"`
|
||||
ValueType string `json:"valueType" description:"键值数据类型"`
|
||||
Type string `json:"type" description:"字典类型"`
|
||||
ListClass string `json:"listClass" description:"表格回显样式"`
|
||||
}
|
||||
```
|
||||
|
||||
#### 枚举字典
|
||||
- 适用于系统开发期间内置的枚举数据,这样即维护了枚举值,又关联了数据字典
|
||||
|
||||
##### 一个例子
|
||||
- 定义枚举值和字典数据选项,并注册字典类型
|
||||
- 文件路径:server/internal/consts/credit_log.go
|
||||
|
||||
```go
|
||||
package consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("creditType", "资金变动类型", CreditTypeOptions)
|
||||
dict.RegisterEnums("creditGroup", "资金变动分组", CreditGroupOptions)
|
||||
}
|
||||
|
||||
const (
|
||||
CreditTypeBalance = "balance" // 余额
|
||||
CreditTypeIntegral = "integral" // 积分
|
||||
)
|
||||
|
||||
const (
|
||||
CreditGroupDecr = "decr" // 扣款
|
||||
CreditGroupIncr = "incr" // 加款
|
||||
CreditGroupOpDecr = "op_decr" // 操作扣款
|
||||
CreditGroupOpIncr = "op_incr" // 操作加款
|
||||
CreditGroupBalanceRecharge = "balance_recharge" // 余额充值
|
||||
CreditGroupBalanceRefund = "balance_refund" // 余额退款
|
||||
CreditGroupApplyCash = "apply_cash" // 申请提现
|
||||
)
|
||||
|
||||
// CreditTypeOptions 变动类型
|
||||
var CreditTypeOptions = []*model.Option{
|
||||
dict.GenSuccessOption(CreditTypeBalance, "余额"),
|
||||
dict.GenInfoOption(CreditTypeIntegral, "积分"),
|
||||
}
|
||||
|
||||
// CreditGroupOptions 变动分组
|
||||
var CreditGroupOptions = []*model.Option{
|
||||
dict.GenWarningOption(CreditGroupDecr, "扣款"),
|
||||
dict.GenSuccessOption(CreditGroupIncr, "加款"),
|
||||
dict.GenWarningOption(CreditGroupOpDecr, "操作扣款"),
|
||||
dict.GenSuccessOption(CreditGroupOpIncr, "操作加款"),
|
||||
dict.GenWarningOption(CreditGroupBalanceRefund, "余额退款"),
|
||||
dict.GenSuccessOption(CreditGroupBalanceRecharge, "余额充值"),
|
||||
dict.GenInfoOption(CreditGroupApplyCash, "申请提现"),
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### 自定义方法字典
|
||||
- 适用于非固定选项,如数据是从某个表/文件读取或从第三方读取,数据需要进行转换时使用
|
||||
|
||||
##### 方法字典接口
|
||||
- 文件路径:server/internal/consts/credit_log.go
|
||||
|
||||
```go
|
||||
package dict
|
||||
|
||||
// FuncDict 方法字典,实现本接口即可使用内置方法字典
|
||||
type FuncDict func(ctx context.Context) (res []*model.Option, err error)
|
||||
```
|
||||
|
||||
##### 一个例子
|
||||
- 定义获取字典数据方法,并注册字典类型
|
||||
- 文件路径:server/internal/logic/admin/post.go
|
||||
|
||||
```go
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
type sAdminPost struct{}
|
||||
|
||||
func NewAdminPost() *sAdminPost {
|
||||
return &sAdminPost{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterAdminPost(NewAdminPost())
|
||||
dict.RegisterFunc("adminPostOption", "岗位选项", service.AdminPost().Option)
|
||||
}
|
||||
|
||||
// Option 岗位选项
|
||||
func (s *sAdminPost) Option(ctx context.Context) (opts []*model.Option, err error) {
|
||||
var list []*entity.AdminPost
|
||||
if err = dao.AdminPost.Ctx(ctx).OrderAsc(dao.AdminPost.Columns().Sort).Scan(&list); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
opts = make([]*model.Option, 0)
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range list {
|
||||
opts = append(opts, dict.GenHashOption(v.Id, v.Name))
|
||||
}
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
#### 代码生成支持
|
||||
- 内置的枚举字典和自定义方法字典在生成代码时可以直接进行选择,生成代码格式和系统字典管理写法一致
|
||||
|
||||

|
||||
|
||||
|
||||
#### 内置字典和系统字典的区分
|
||||
|
||||
##### 主要区别
|
||||
- 系统字典由表:`hg_sys_dict_type`和`hg_sys_dict_data`共同进行维护,使用时需通过后台到字典管理中进行添加
|
||||
- 内置字典是系统开发期间在代码层面事先定义和注册好的数据选项
|
||||
|
||||
|
||||
##### 数据格式区别
|
||||
- 系统字典所有ID都是大于0的int64类型
|
||||
- 内置字典ID都是小于0的int64类型。枚举字典以20000开头,如:-200001381053496;方法字典以30000开头,如:-30000892528327;开头以外数字是根据数据选项的`key`值进行哈希算法得出
|
||||
|
||||
### 地理定位
|
||||
```go
|
||||
// 待写
|
||||
```
|
||||
|
||||
### 通知
|
||||
```go
|
||||
// 待写
|
||||
```
|
||||
@@ -1,249 +1,250 @@
|
||||
## 中间件/拦截器
|
||||
|
||||
目录
|
||||
|
||||
- 介绍
|
||||
- 全局中间件
|
||||
- 鉴权中间件
|
||||
- 响应中间件
|
||||
- 更多
|
||||
|
||||
### 介绍
|
||||
- 在hotgo中,中间件/拦截器主要作用于web请求的上下文预设、跨域请求处理、鉴权处理、请求拦截和请求结束后统一响应处理等。
|
||||
|
||||
|
||||
### 全局中间件
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// 初始化请求上下文,一般需要第一个进行加载,后续中间件存在依赖关系
|
||||
service.Middleware().Ctx()
|
||||
|
||||
// 跨域中间件,自动处理跨域问题
|
||||
service.Middleware().CORS()
|
||||
|
||||
// IP黑名单中间件,如果请求IP被后台拉黑,所有请求将被拒绝
|
||||
service.Middleware().Blacklist()
|
||||
|
||||
// 演示系統操作限制,当开启演示模式时,所有POST请求将被拒绝
|
||||
service.Middleware().DemoLimit()
|
||||
|
||||
// 请求输入预处理,api使用gf规范路由并且XxxReq结构体实现了validate.Filter接口即可隐式预处理
|
||||
service.Middleware().PreFilter()
|
||||
|
||||
// HTTP响应预处理,在业务处理完成后,对响应结果进行格式化和错误过滤,将处理后的数据发送给请求方
|
||||
service.Middleware().ResponseHandler()
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
### 鉴权中间件
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// 在鉴权中间件下的路由如果没有通过权限验证,后续请求将被拒绝
|
||||
// 在hotgo中,鉴权中间件一般是配合一个业务模块下的路由组进行使用
|
||||
// 目前admin、api、home、websocket模块都已接入
|
||||
// 如果你需要创建一个新的模块也需要用到鉴权中间件,可以参考:server/internal/logic/middleware/admin_auth.go
|
||||
|
||||
|
||||
// 一个简单例子
|
||||
s := g.Server()
|
||||
s.Group("/api", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(service.Middleware().ApiAuth)
|
||||
group.Bind(
|
||||
member.Member, // 管理员
|
||||
)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### 响应中间件
|
||||
- 文件路径:server/internal/logic/middleware/response.go
|
||||
|
||||
|
||||
#### 常用响应类型
|
||||
|
||||
- hotgo为一些常用的响应类型做了统一格式封装,例如:`application/json`、`text/xml`、`text/html`、`text/event-stream`等,默认使用`application/json`。
|
||||
- 下面我们以`text/xml`为例简单演示几种使用方法:
|
||||
|
||||
1. 当你使用规范化路由时,可直接在XxxRes结构体的`g.Meta`中声明响应类型:
|
||||
```go
|
||||
type HelloReq struct {
|
||||
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"`
|
||||
Name string `json:"name" d:"hotgo" dc:"名字"`
|
||||
}
|
||||
|
||||
type HelloRes struct {
|
||||
g.Meta `mime:"text/xml" type:"string"`
|
||||
Tips string `json:"tips"`
|
||||
}
|
||||
```
|
||||
|
||||
2. 在响应前设置响应头:
|
||||
```go
|
||||
var (
|
||||
Hello = cHello{}
|
||||
)
|
||||
|
||||
type cHello struct{}
|
||||
|
||||
func (c *cHello) Hello(ctx context.Context, req *user.HelloReq) (res *user.HelloRes, err error) {
|
||||
r := ghttp.RequestFromCtx(ctx)
|
||||
r.Response.Header().Set("Content-Type", "text/xml")
|
||||
|
||||
res = &user.HelloRes{
|
||||
Tips: fmt.Sprintf("hello %v, this is the api for %v applications.", req.Name, simple.AppName(ctx)),
|
||||
}
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
- 浏览器中访问响应内容如下:
|
||||
|
||||

|
||||
|
||||
|
||||
#### 自定义响应
|
||||
- 在实际开发中,可能需要使用自定义的响应类型,由于响应中间件是全局的,因此您需要对其进行单独处理。
|
||||
- 推荐以下几种处理方案,可做参考:
|
||||
1. 使用`ghttp.ExitAll()`,需要注意的是此方法会终止后续所有的http处理
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := new(ghttp.Request) // 当前请求对象
|
||||
|
||||
// 清空响应
|
||||
r.Response.ClearBuffer()
|
||||
|
||||
// 写入响应
|
||||
r.Response.Write("自定义响应内容")
|
||||
|
||||
// 终止后续http处理
|
||||
r.ExitAll()
|
||||
}
|
||||
```
|
||||
|
||||
2. 在`server/internal/logic/middleware/response.go`中根据请求的独有特征进行单独的处理,兼容后续http处理。
|
||||
|
||||
|
||||
#### 重写响应错误提示
|
||||
|
||||
- 在实际开发中,我们可能想要隐藏一些敏感错误,返回给客户端友好的错误提示,但开发者同时又想需要看到真实的敏感错误。对此hotgo已经进行了过滤处理,下面是一个简单的例子:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
func test() error {
|
||||
err = gerror.New("这是一个sql执行错误")
|
||||
err = gerror.Wrap(err, "用户创建失败,请稍后重试!~")
|
||||
return err
|
||||
}
|
||||
```
|
||||
|
||||
- 开启debug时的客户端响应:
|
||||
```json
|
||||
{
|
||||
"code": -1,
|
||||
"message": "用户创建失败,请稍后重试!~",
|
||||
"error": [
|
||||
"1. 用户创建失败,请稍后重试!~",
|
||||
" 1). hotgo/internal/logic/admin.(*sAdminMember).List",
|
||||
" E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/admin/member.go:526",
|
||||
"2. 这是一个sql执行错误", " 1). hotgo/internal/logic/admin.(*sAdminMember).List",
|
||||
" E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/admin/member.go:525",
|
||||
" 2). hotgo/internal/controller/admin/admin.(*cMember).List",
|
||||
" E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/controller/admin/admin/member.go:157", ""
|
||||
],
|
||||
"timestamp": 1684145107,
|
||||
"traceID": "084022730d495f17f19e550140f3e1a8"
|
||||
}
|
||||
```
|
||||
|
||||
- 关闭debug时的客户端响应:
|
||||
```json
|
||||
{
|
||||
"code": -1,
|
||||
"message": "用户创建失败,请稍后重试!~",
|
||||
"timestamp": 1684145107,
|
||||
"traceID": "084022730d495f17f19e550140f3e1a8"
|
||||
}
|
||||
```
|
||||
|
||||
- 控制台的输出日志:
|
||||
```shell
|
||||
2023-05-15 18:05:07.776 {084022730d495f17f19e550140f3e1a8} 200 "GET http localhost:8000 /admin/member/list?page=1&pageSize=10&roleId=-1 HTTP/1.1" 0.002, 127.0.0.1, "http://192.168.0.207:8001/login", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Co
|
||||
re/1.94.197.400 QQBrowser/11.7.5287.400", -1, "", ""
|
||||
Stack:
|
||||
1. 用户创建失败,请稍后重试!~
|
||||
1). hotgo/internal/logic/admin.(*sAdminMember).List
|
||||
E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/admin/member.go:526
|
||||
2. 这是一个sql执行错误
|
||||
1). hotgo/internal/logic/admin.(*sAdminMember).List
|
||||
E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/middleware/response.go:24
|
||||
13). hotgo/internal/logic/middleware.(*sMiddleware).DemoLimit
|
||||
E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/middleware/init.go:90
|
||||
|
||||
```
|
||||
|
||||
- 如果你开启了访问日志,那么日志记录中会详细记录本次请求的相关信息,内容如下:
|
||||

|
||||
|
||||
|
||||
#### 重写错误码
|
||||
- hotgo默认使用了gf内置的错误码进行业务处理,通常情况下成功状态码为`0`,失败状态码为`-1`
|
||||
- 查看gf内置错误码:https://goframe.org/pages/viewpage.action?pageId=30739587
|
||||
- 以下是自定义错误码的简单例子:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
func test() error {
|
||||
// 使用自定义状态码30001响应客户端
|
||||
err = gerror.NewCode(gcode.New(30001, "用户创建失败,请稍后重试!~", nil))
|
||||
return err
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
- 客户端响应如下:
|
||||
```json
|
||||
{
|
||||
"code": 30001,
|
||||
"message": "用户创建失败,请稍后重试!~",
|
||||
"timestamp": 1684146313,
|
||||
"traceID": "b4f90e16264a5f17cd3fc27141aba448"
|
||||
}
|
||||
```
|
||||
|
||||
### 更多
|
||||
- 更多关于中间件/拦截器的介绍请参考:https://goframe.org/pages/viewpage.action?pageId=55289881
|
||||
|
||||
## 中间件/拦截器
|
||||
|
||||
目录
|
||||
|
||||
- 介绍
|
||||
- 全局中间件
|
||||
- 鉴权中间件
|
||||
- 响应中间件
|
||||
- 更多
|
||||
|
||||
### 介绍
|
||||
- 在hotgo中,中间件/拦截器主要作用于web请求的上下文预设、跨域请求处理、鉴权处理、请求拦截和请求结束后统一响应处理等。
|
||||
|
||||
|
||||
### 全局中间件
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// 初始化请求上下文,一般需要第一个进行加载,后续中间件存在依赖关系
|
||||
service.Middleware().Ctx()
|
||||
|
||||
// 跨域中间件,自动处理跨域问题
|
||||
service.Middleware().CORS()
|
||||
|
||||
// IP黑名单中间件,如果请求IP被后台拉黑,所有请求将被拒绝
|
||||
service.Middleware().Blacklist()
|
||||
|
||||
// 演示系統操作限制,当开启演示模式时,所有POST请求将被拒绝
|
||||
service.Middleware().DemoLimit()
|
||||
|
||||
// 请求输入预处理,api使用gf规范路由并且XxxReq结构体实现了validate.Filter接口即可隐式预处理
|
||||
service.Middleware().PreFilter()
|
||||
|
||||
// HTTP响应预处理,在业务处理完成后,对响应结果进行格式化和错误过滤,将处理后的数据发送给请求方
|
||||
service.Middleware().ResponseHandler()
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
### 鉴权中间件
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// 在鉴权中间件下的路由如果没有通过权限验证,后续请求将被拒绝
|
||||
// 在hotgo中,鉴权中间件一般是配合一个业务模块下的路由组进行使用
|
||||
// 目前admin、api、home、websocket模块都已接入
|
||||
// 如果你需要创建一个新的模块也需要用到鉴权中间件,可以参考:server/internal/logic/middleware/admin_auth.go
|
||||
|
||||
|
||||
// 一个简单例子
|
||||
s := g.Server()
|
||||
s.Group("/api", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(service.Middleware().ApiAuth)
|
||||
group.Bind(
|
||||
member.Member, // 管理员
|
||||
)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### 响应中间件
|
||||
- 文件路径:server/internal/logic/middleware/response.go
|
||||
|
||||
|
||||
#### 常用响应类型
|
||||
|
||||
- hotgo为一些常用的响应类型做了统一格式封装,例如:`application/json`、`text/xml`、`text/html`、`text/event-stream`等,默认使用`application/json`。
|
||||
- 下面我们以`text/xml`为例简单演示几种使用方法:
|
||||
|
||||
1. 当你使用规范化路由时,可直接在XxxRes结构体的`g.Meta`中声明响应类型:
|
||||
|
||||
```go
|
||||
type HelloReq struct {
|
||||
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"`
|
||||
Name string `json:"name" d:"hotgo" dc:"名字"`
|
||||
}
|
||||
|
||||
type HelloRes struct {
|
||||
g.Meta `mime:"text/xml" type:"string"`
|
||||
Tips string `json:"tips"`
|
||||
}
|
||||
```
|
||||
|
||||
2. 在响应前设置响应头:
|
||||
|
||||
```go
|
||||
var (
|
||||
Hello = cHello{}
|
||||
)
|
||||
|
||||
type cHello struct{}
|
||||
|
||||
func (c *cHello) Hello(ctx context.Context, req *user.HelloReq) (res *user.HelloRes, err error) {
|
||||
r := ghttp.RequestFromCtx(ctx)
|
||||
r.Response.Header().Set("Content-Type", "text/xml")
|
||||
|
||||
res = &user.HelloRes{
|
||||
Tips: fmt.Sprintf("hello %v, this is the api for %v applications.", req.Name, simple.AppName(ctx)),
|
||||
}
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
- 浏览器中访问响应内容如下:
|
||||
|
||||

|
||||
|
||||
|
||||
#### 自定义响应
|
||||
- 在实际开发中,可能需要使用自定义的响应类型,由于响应中间件是全局的,因此您需要对其进行单独处理。
|
||||
- 推荐以下几种处理方案,可做参考:
|
||||
1. 使用`ghttp.ExitAll()`,需要注意的是此方法会终止后续所有的http处理
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := new(ghttp.Request) // 当前请求对象
|
||||
|
||||
// 清空响应
|
||||
r.Response.ClearBuffer()
|
||||
|
||||
// 写入响应
|
||||
r.Response.Write("自定义响应内容")
|
||||
|
||||
// 终止后续http处理
|
||||
r.ExitAll()
|
||||
}
|
||||
```
|
||||
|
||||
2. 在`server/internal/logic/middleware/response.go`中根据请求的独有特征进行单独的处理,兼容后续http处理。
|
||||
|
||||
#### 重写响应错误提示
|
||||
- 在实际开发中,我们可能想要隐藏一些敏感错误,返回给客户端友好的错误提示,但开发者同时又想需要看到真实的敏感错误。对此hotgo已经进行了过滤处理,下面是一个简单的例子:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
func test() error {
|
||||
err = gerror.New("这是一个sql执行错误")
|
||||
err = gerror.Wrap(err, "用户创建失败,请稍后重试!~")
|
||||
return err
|
||||
}
|
||||
```
|
||||
|
||||
- 开启debug时的客户端响应:
|
||||
```json
|
||||
{
|
||||
"code": -1,
|
||||
"message": "用户创建失败,请稍后重试!~",
|
||||
"error": [
|
||||
"1. 用户创建失败,请稍后重试!~",
|
||||
" 1). hotgo/internal/logic/admin.(*sAdminMember).List",
|
||||
" E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/admin/member.go:526",
|
||||
"2. 这是一个sql执行错误", " 1). hotgo/internal/logic/admin.(*sAdminMember).List",
|
||||
" E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/admin/member.go:525",
|
||||
" 2). hotgo/internal/controller/admin/admin.(*cMember).List",
|
||||
" E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/controller/admin/admin/member.go:157", ""
|
||||
],
|
||||
"timestamp": 1684145107,
|
||||
"traceID": "084022730d495f17f19e550140f3e1a8"
|
||||
}
|
||||
```
|
||||
|
||||
- 关闭debug时的客户端响应:
|
||||
```json
|
||||
{
|
||||
"code": -1,
|
||||
"message": "用户创建失败,请稍后重试!~",
|
||||
"timestamp": 1684145107,
|
||||
"traceID": "084022730d495f17f19e550140f3e1a8"
|
||||
}
|
||||
```
|
||||
|
||||
- 控制台的输出日志:
|
||||
|
||||
```shell
|
||||
2023-05-15 18:05:07.776 {084022730d495f17f19e550140f3e1a8} 200 "GET http localhost:8000 /admin/member/list?page=1&pageSize=10&roleId=-1 HTTP/1.1" 0.002, 127.0.0.1, "http://192.168.0.207:8001/login", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Co
|
||||
re/1.94.197.400 QQBrowser/11.7.5287.400", -1, "", ""
|
||||
Stack:
|
||||
1. 用户创建失败,请稍后重试!~
|
||||
1). hotgo/internal/logic/admin.(*sAdminMember).List
|
||||
E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/admin/member.go:526
|
||||
2. 这是一个sql执行错误
|
||||
1). hotgo/internal/logic/admin.(*sAdminMember).List
|
||||
E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/middleware/response.go:24
|
||||
13). hotgo/internal/logic/middleware.(*sMiddleware).DemoLimit
|
||||
E:/Users/Administrator/Desktop/gosrc/hotgo_dev/server/internal/logic/middleware/init.go:90
|
||||
|
||||
```
|
||||
|
||||
- 如果你开启了访问日志,那么日志记录中会详细记录本次请求的相关信息,内容如下:
|
||||

|
||||
|
||||
|
||||
#### 重写错误码
|
||||
- hotgo默认使用了gf内置的错误码进行业务处理,通常情况下成功状态码为`0`,失败状态码为`-1`
|
||||
- 查看gf内置错误码:https://goframe.org/pages/viewpage.action?pageId=30739587
|
||||
- 以下是自定义错误码的简单例子:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
func test() error {
|
||||
// 使用自定义状态码30001响应客户端
|
||||
err = gerror.NewCode(gcode.New(30001, "用户创建失败,请稍后重试!~", nil))
|
||||
return err
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
- 客户端响应如下:
|
||||
```json
|
||||
{
|
||||
"code": 30001,
|
||||
"message": "用户创建失败,请稍后重试!~",
|
||||
"timestamp": 1684146313,
|
||||
"traceID": "b4f90e16264a5f17cd3fc27141aba448"
|
||||
}
|
||||
```
|
||||
|
||||
### 更多
|
||||
- 更多关于中间件/拦截器的介绍请参考:https://goframe.org/pages/viewpage.action?pageId=55289881
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ SaaS系统多租户多应用设计,已成为互联网企业的重要发展建
|
||||
|
||||
- 在用户登录成功后,server端可通过上下文来获取用户部门类型来确定用户身份
|
||||
- 文件路径:server/internal/library/contexts/context.go
|
||||
|
||||
```go
|
||||
package contexts
|
||||
|
||||
@@ -87,6 +88,7 @@ func IsUserDept(ctx context.Context) bool {
|
||||
|
||||
- 在用户登录成功后,web端可通`useUserStore`来获取用户部门类型来确定用户身份
|
||||
- 文件路径:web/src/store/modules/user.ts
|
||||
|
||||
```vue
|
||||
<script lang="ts" setup>
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
@@ -125,6 +127,7 @@ HotGo定位是中小型应用开发,推荐采用一套数据库不同Schema。
|
||||
下面是多租户功能演示例子代码中的使用片段
|
||||
|
||||
- 封装查询Model
|
||||
|
||||
```go
|
||||
// Model 多租户功能演示ORM模型
|
||||
func (s *sSysTenantOrder) Model(ctx context.Context, option ...*handler.Option) *gdb.Model {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
### 全局消息监听
|
||||
- 所有全局的消息监听都在这里
|
||||
- 文件路径:web/src/utils/websocket/registerMessage.ts
|
||||
|
||||
```ts
|
||||
import { TABS_ROUTES } from '@/store/mutation-types';
|
||||
import { SocketEnum } from '@/enums/socketEnum';
|
||||
@@ -51,6 +52,7 @@ export function registerGlobalMessage() {
|
||||
#### 单页面消息监听
|
||||
- 当你只需要某个页面使用WebSocket,这将是一个不错的选择,下面是一个简单的演示例子
|
||||
- 文件路径:web/src/views/addons/hgexample/portal/websocketTest.vue
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<div>
|
||||
@@ -190,6 +192,7 @@ export function registerGlobalMessage() {
|
||||
|
||||
#### 发送消息
|
||||
- 向服务器发送一条消息
|
||||
|
||||
```ts
|
||||
import { sendMsg } from '@/utils/websocket';
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#### 1.消息处理接口
|
||||
- 消息处理在设计上采用了接口化的思路。只需要实现以下接口,即可进行WebSocket消息注册
|
||||
- 文件路径:server/internal/websocket/model.go
|
||||
|
||||
```go
|
||||
package websocket
|
||||
|
||||
@@ -26,6 +27,7 @@ type EventHandler func(client *Client, req *WRequest)
|
||||
#### 2.定义消息处理方法
|
||||
- 以下是功能案例中的一个简单演示,实现了消息处理接口,并将收到的消息原样发送给客户端
|
||||
- 文件路径:server/addons/hgexample/controller/websocket/handler/index.go
|
||||
|
||||
```go
|
||||
package handler
|
||||
|
||||
@@ -52,6 +54,7 @@ func (c *cIndex) TestMessage(client *websocket.Client, req *websocket.WRequest)
|
||||
#### 3.注册消息
|
||||
- 定义消息处理方法后,需要将其注册到WebSocket消息处理器,一般放在对应应用模块的`router/websocket.go`下即可
|
||||
- 文件路径:server/addons/hgexample/router/websocket.go
|
||||
|
||||
```go
|
||||
package router
|
||||
|
||||
@@ -80,6 +83,7 @@ func WebSocket(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
|
||||
### 常用方法
|
||||
- websocket服务器还提供了一些常用的方法,下面只对部分进行说明
|
||||
|
||||
```go
|
||||
func test() {
|
||||
websocket.SendToAll() // 发送全部客户端
|
||||
@@ -105,6 +109,7 @@ func test() {
|
||||
### 其他
|
||||
- WebSocket被连接时需验证用户认证中间件,所以用户必须登录成功后才能连接成功
|
||||
- 参考文件:server/internal/logic/middleware/weboscket_auth.go
|
||||
|
||||
```go
|
||||
package middleware
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
项目开发完成之后,执行以下命令进行构建
|
||||
```shell
|
||||
yarn build
|
||||
pnpm run build 或 npm run build
|
||||
```
|
||||
构建打包成功之后,会在根目录生成 dist 文件夹,里面就是构建打包好的文件
|
||||
|
||||
@@ -40,15 +40,15 @@ VITE_LEGACY = true
|
||||
使用项目自定的命令进行预览(推荐)
|
||||
```shell
|
||||
# 先打包在进行预览
|
||||
yarn preview
|
||||
pnpm run preview 或 npm run preview
|
||||
# 直接预览本地 dist 文件目录
|
||||
yarn preview:dist
|
||||
pnpm run preview:dist 或 npm run preview:dist
|
||||
```
|
||||
|
||||
- 本地服务器预览(通过 live-server)
|
||||
```shell
|
||||
# 1.全局安装live-server
|
||||
yarn global add live-server
|
||||
npm -g install live-server
|
||||
# 2. 进入打包的后目录
|
||||
cd ./dist
|
||||
# 本地预览,默认端口8080
|
||||
@@ -60,7 +60,7 @@ live-server --port 9000
|
||||
### 分析构建文件体积
|
||||
如果你的构建文件很大,可以通过项目内置 [rollup-plugin-analyzer](https://github.com/doesdev/rollup-plugin-analyzer) 插件进行代码体积分析,从而优化你的代码。
|
||||
```shell
|
||||
yarn report
|
||||
pnpm run report 或 npm run report
|
||||
```
|
||||
运行之后,在自动打开的页面可以看到具体的体积分布,以分析哪些依赖有问题。
|
||||
|
||||
|
||||
187
index.html
Normal file
187
index.html
Normal file
@@ -0,0 +1,187 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1, minimum-scale=1.0, shrink-to-fit=no, viewport-fit=cover">
|
||||
|
||||
<!-- Replace with your own title and description. -->
|
||||
<title>HotGo-V2</title>
|
||||
<meta name="description" content="基于全新GoFrame2+Vue3+NaiveUI+uniapp开发的全栖框架,为二次开发而生,适合中小型完整应用开发。">
|
||||
|
||||
<!-- Default Theme (see //docsify.js.org/#/themes) -->
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
<script>
|
||||
// Docsify Configuration (see //docsify.js.org/#/configuration)
|
||||
window.$docsify = {
|
||||
name: "HotGo-V2",
|
||||
nameLink: {
|
||||
'/': '/hotgo/',
|
||||
},
|
||||
relativePath: true,
|
||||
// alias: {
|
||||
// "/.*/_navbar.md": "/_navbar.md",
|
||||
// },
|
||||
// themeColor: "#42b983",
|
||||
// logo: "//bufanyun.cn-bj.ufileos.com/hotgo/logo.sig.png",
|
||||
// coverpage: true,
|
||||
// homepage: "README.md",
|
||||
|
||||
// Sidebar Configuration
|
||||
auto2top: true,
|
||||
loadSidebar: "sidebar.md",
|
||||
// maxLevel: 2,
|
||||
// Set subMaxLevel to 0 to remove automatic display of page table of contents (TOC) in Sidebar
|
||||
// subMaxLevel: 3,
|
||||
|
||||
// Navbar Configuration
|
||||
// loadNavbar: true,
|
||||
|
||||
// Search Plugin Configuration
|
||||
search: {
|
||||
placeholder: {
|
||||
"/": "搜索",
|
||||
// "/": "Type to search"
|
||||
},
|
||||
noData: {
|
||||
"/": "找不到结果",
|
||||
// "/": "No Results"
|
||||
},
|
||||
// Headline depth, 1 - 6
|
||||
// depth: 2,
|
||||
},
|
||||
|
||||
// Flexible-alerts Plugin Configuration
|
||||
"flexible-alerts": {
|
||||
important: {
|
||||
label: "Important",
|
||||
|
||||
// localization
|
||||
label: {
|
||||
// "/zh-cn": "重要",
|
||||
"/": "Important"
|
||||
},
|
||||
|
||||
// Assuming that we use Font Awesome
|
||||
icon: "far fa-message",
|
||||
className: "important"
|
||||
},
|
||||
warning: {
|
||||
label: "Warning",
|
||||
|
||||
// localization
|
||||
label: {
|
||||
// "/zh-cn": "警告",
|
||||
"/": "Warning"
|
||||
},
|
||||
|
||||
// Assuming that we use Font Awesome
|
||||
icon: "fas fa-triangle-exclamation",
|
||||
className: "warning"
|
||||
},
|
||||
caution: {
|
||||
label: "Caution",
|
||||
|
||||
// localization
|
||||
label: {
|
||||
// "/zh-cn": "注意",
|
||||
"/": "Caution"
|
||||
},
|
||||
|
||||
// Assuming that we use Font Awesome
|
||||
icon: "fas fa-circle-exclamation",
|
||||
className: "attention"
|
||||
},
|
||||
},
|
||||
|
||||
// Hide-code Plugin Configuration
|
||||
hideCode: {
|
||||
// scroll: false, // Enable scrolling
|
||||
height: 300 // Max height
|
||||
},
|
||||
|
||||
// Versioned Plugin Configuration
|
||||
// versions: [
|
||||
// { folder: "/", label: "v2", default: true },
|
||||
// ],
|
||||
// versionSelectorLabel: "Version",
|
||||
|
||||
// Progress Plugin Configuration
|
||||
progress: {
|
||||
position: "top",
|
||||
// color: "var(--theme-color,#42b983)",
|
||||
height: "3px",
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Required -->
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/docsify.min.js"></script>
|
||||
|
||||
<!-- Recommended -->
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/zoom-image.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/search.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-pagination/dist/docsify-pagination.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-hide-code/dist/docsify-hide-code.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-progress@latest/dist/progress.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-example-panels"></script>
|
||||
|
||||
<!-- Prism code highlight -->
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-matlab.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-go.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-yaml.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-vue.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-json.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-sql.min.js"></script>
|
||||
|
||||
<!--mermaid插件-->
|
||||
<script type="module">
|
||||
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
|
||||
mermaid.initialize({ startOnLoad: true });
|
||||
window.mermaid = mermaid;
|
||||
</script>
|
||||
<script src="//unpkg.com/docsify-mermaid@2.0.1/dist/docsify-mermaid.js"></script>
|
||||
|
||||
<!-- docsify-dark-switcher -->
|
||||
<script src="//cdn.jsdelivr.net/gh/LIGMATV/docsify-dark-switcher@latest/docsify-dark-switcher.js"></script>
|
||||
<style>
|
||||
:root {
|
||||
--dark-base-background: #222;
|
||||
--dark-base-color: #bbc0c4;
|
||||
--dark-theme-color: var(--theme-color, #42b983);
|
||||
--dark-code-color: var(--dark-color);
|
||||
--dark-heading-color: var(--dark-theme-color);
|
||||
--dark-cover-background: #000000a8;
|
||||
--dark-code-background: #303030;
|
||||
--dark-tip-background: #2c0000;
|
||||
--dark-warn-background: #005842;
|
||||
--dark-icon-size: 25px;
|
||||
--dark-icon-transition: .1s ease-in-out .1s;
|
||||
--dark-moon-color: #000000;
|
||||
--dark-sun-color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- docsify-plugin-flexible-alerts -->
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-flexible-alerts/dist/docsify-plugin-flexible-alerts.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/js/all.min.js"></script>
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/fontawesome.min.css">
|
||||
|
||||
<!-- docsify-versioned-plugin -->
|
||||
<!-- <script src="//cdn.jsdelivr.net/npm/docsify-versioned-plugin@0.0.1/index.js"></script>
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify-versioned-plugin@0.0.1/styles.css"> -->
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -13,14 +13,15 @@ run:
|
||||
# Include test files or not.
|
||||
# Default: true
|
||||
tests: false
|
||||
go: "1.20"
|
||||
|
||||
# Which dirs to skip: issues from them won't be reported.
|
||||
# Can use regexp here: `generated.*`, regexp is applied on full path.
|
||||
# Default value is empty list,
|
||||
# but default dirs are skipped independently of this option's value (see skip-dirs-use-default).
|
||||
# "/" will be replaced by current OS file path separator to properly work on Windows.
|
||||
skip-dirs:
|
||||
- internal/library/hggen/internal
|
||||
# skip-dirs:
|
||||
# - internal/library/hggen/internal
|
||||
|
||||
# Which files to skip: they will be analyzed, but issues from them won't be reported.
|
||||
# Default value is empty list,
|
||||
@@ -28,7 +29,7 @@ run:
|
||||
# we confidently recognize autogenerated files.
|
||||
# If it's not please let us know.
|
||||
# "/" will be replaced by current OS file path separator to properly work on Windows.
|
||||
skip-files: []
|
||||
# skip-files: []
|
||||
|
||||
|
||||
# Main linters configurations.
|
||||
@@ -71,7 +72,10 @@ issues:
|
||||
- linters:
|
||||
- gocritic
|
||||
text: "unnecessaryDefer:"
|
||||
|
||||
exclude-dirs:
|
||||
- internal/library/hggen/internal
|
||||
exclude-files: []
|
||||
|
||||
|
||||
# https://golangci-lint.run/usage/linters
|
||||
linters-settings:
|
||||
@@ -176,7 +180,7 @@ linters-settings:
|
||||
# Select the Go version to target.
|
||||
# Default: 1.13
|
||||
# Deprecated: use the global `run.go` instead.
|
||||
go: "1.15"
|
||||
# go: "1.15"
|
||||
# Sxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
|
||||
# Default: ["*"]
|
||||
checks: [
|
||||
@@ -187,7 +191,7 @@ linters-settings:
|
||||
govet:
|
||||
# Report about shadowed variables.
|
||||
# Default: false
|
||||
check-shadowing: true
|
||||
# check-shadowing: true
|
||||
# Settings per analyzer.
|
||||
settings:
|
||||
# Analyzer name, run `go tool vet help` to see all analyzers.
|
||||
@@ -263,7 +267,7 @@ linters-settings:
|
||||
# Select the Go version to target.
|
||||
# Default: "1.13"
|
||||
# Deprecated: use the global `run.go` instead.
|
||||
go: "1.15"
|
||||
# go: "1.15"
|
||||
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
|
||||
# Default: ["*"]
|
||||
checks: [ "all","-SA1019","-SA4015","-SA1029","-SA1016","-SA9003","-SA4006","-SA6003" ]
|
||||
|
||||
@@ -9,7 +9,8 @@ ADMIN_RESOURCE_PATH = "/resource/public/admin/"
|
||||
build:
|
||||
@rm -rf ./$(ADMIN_RESOURCE_PATH)
|
||||
@mkdir ./$(ADMIN_RESOURCE_PATH)
|
||||
@cd ../web && yarn build && \cp -rf ./dist/* ../server$(ADMIN_RESOURCE_PATH)
|
||||
@cd ../web && pnpm run build && \cp -rf ./dist/* ../server$(ADMIN_RESOURCE_PATH)
|
||||
@cd ../server
|
||||
@echo "y" | gf build
|
||||
|
||||
# 通过热编译启动所有服务
|
||||
@@ -36,7 +37,7 @@ auth:
|
||||
# 启动web服务
|
||||
.PHONY: web
|
||||
web:
|
||||
@cd ../web && yarn dev
|
||||
@cd ../web && pnpm run dev
|
||||
|
||||
# 刷新casbin权限
|
||||
.PHONY: refresh
|
||||
|
||||
45
server/addons/flashbanner/README.MD
Normal file
45
server/addons/flashbanner/README.MD
Normal file
@@ -0,0 +1,45 @@
|
||||
## 轮播图管理
|
||||
|
||||
### 简介
|
||||
|
||||
|
||||
|
||||
|
||||
### 使用说明
|
||||
|
||||
|
||||
|
||||
|
||||
### 迁移或安装
|
||||
|
||||
1、安装 HotGo (2.17.8及以上)
|
||||
|
||||
项目介绍:https://github.com/bufanyun/hotgo
|
||||
|
||||
2、将当前插件项目拷贝进 HotGo 根目录的 server/addons 目录下
|
||||
|
||||
3、在 HotGo 根目录的 server/addons/modules 目录下创建go文件:flashbanner.go,内容如下:
|
||||
```go
|
||||
package modules
|
||||
|
||||
import _ "hotgo/addons/flashbanner"
|
||||
```
|
||||
|
||||
4、HotGo 后台进入 开发工具->插件管理->找到 轮播图管理 (flashbanner) 进行安装
|
||||
|
||||
5、重启服务即可生效
|
||||
|
||||
|
||||
### 常用命令行
|
||||
|
||||
```shell
|
||||
# 接口维护-gen service
|
||||
gf gen service -s=addons/flashbanner/logic -d=addons/flashbanner/service
|
||||
|
||||
```
|
||||
|
||||
### `gf gen dao` 之后迁移model文件
|
||||
```
|
||||
cp .\internal\dao\internal\banner* .\addons\flashbanner\dao\internal\
|
||||
cp .\internal\model\entity\banner* .\addons\flashbanner\model\entity\
|
||||
```
|
||||
65
server/addons/flashbanner/api/admin/banner/banner.go
Normal file
65
server/addons/flashbanner/api/admin/banner/banner.go
Normal file
@@ -0,0 +1,65 @@
|
||||
// Package banner
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package banner
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
"hotgo/internal/model/input/form"
|
||||
)
|
||||
|
||||
// CreateReq 创建轮播图
|
||||
type CreateReq struct {
|
||||
g.Meta `path:"/banner/create" method:"post" tags:"轮播图" summary:"创建轮播图"`
|
||||
sysin.BannerCreateInp
|
||||
}
|
||||
|
||||
type CreateRes struct{}
|
||||
|
||||
// ListReq 查询列表
|
||||
type ListReq struct {
|
||||
g.Meta `path:"/banner/list" method:"get" tags:"轮播图" summary:"获取轮播图列表"`
|
||||
sysin.BannerListInp
|
||||
}
|
||||
|
||||
type ListRes struct {
|
||||
List []*sysin.BannerListModel `json:"list" dc:"数据列表"`
|
||||
form.PageRes
|
||||
}
|
||||
|
||||
// ViewReq 获取指定信息
|
||||
type ViewReq struct {
|
||||
g.Meta `path:"/banner/view" method:"get" tags:"轮播图" summary:"获取指定轮播图信息"`
|
||||
sysin.BannerViewInp
|
||||
}
|
||||
|
||||
type ViewRes struct {
|
||||
*sysin.BannerViewModel
|
||||
}
|
||||
|
||||
// EditReq 修改/新增轮播图
|
||||
type EditReq struct {
|
||||
g.Meta `path:"/banner/edit" method:"post" tags:"轮播图" summary:"修改/新增轮播图"`
|
||||
sysin.BannerEditInp
|
||||
}
|
||||
|
||||
type EditRes struct{}
|
||||
|
||||
// DeleteReq 删除轮播图
|
||||
type DeleteReq struct {
|
||||
g.Meta `path:"/banner/delete" method:"post" tags:"轮播图" summary:"删除轮播图"`
|
||||
sysin.BannerDeleteInp
|
||||
}
|
||||
|
||||
type DeleteRes struct{}
|
||||
|
||||
// StatusReq 更新轮播图状态
|
||||
type StatusReq struct {
|
||||
g.Meta `path:"/banner/status" method:"post" tags:"轮播图" summary:"更新轮播图状态"`
|
||||
sysin.BannerStatusInp
|
||||
}
|
||||
|
||||
type StatusRes struct{}
|
||||
30
server/addons/flashbanner/api/admin/config/config.go
Normal file
30
server/addons/flashbanner/api/admin/config/config.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// Package config
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
)
|
||||
|
||||
// GetReq 获取指定分组的配置
|
||||
type GetReq struct {
|
||||
g.Meta `path:"/config/get" method:"get" tags:"轮播图管理" summary:"获取指定分组的配置"`
|
||||
sysin.GetConfigInp
|
||||
}
|
||||
|
||||
type GetRes struct {
|
||||
*sysin.GetConfigModel
|
||||
}
|
||||
|
||||
// UpdateReq 获取指定分组的配置
|
||||
type UpdateReq struct {
|
||||
g.Meta `path:"/config/update" method:"post" tags:"轮播图管理" summary:"获取指定分组的配置"`
|
||||
sysin.UpdateConfigInp
|
||||
}
|
||||
|
||||
type UpdateRes struct {
|
||||
}
|
||||
33
server/addons/flashbanner/api/admin/index/banner/banner.go
Normal file
33
server/addons/flashbanner/api/admin/index/banner/banner.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Package banner
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package banner
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
"hotgo/internal/model/input/form"
|
||||
)
|
||||
|
||||
// ListReq 查询列表
|
||||
type ListReq struct {
|
||||
g.Meta `path:"/banner/list" method:"get" tags:"轮播图" summary:"获取轮播图列表"`
|
||||
sysin.BannerListInp
|
||||
}
|
||||
|
||||
type ListRes struct {
|
||||
List []*sysin.BannerListModel `json:"list" dc:"数据列表"`
|
||||
form.PageRes
|
||||
}
|
||||
|
||||
// ViewReq 获取指定信息
|
||||
type ViewReq struct {
|
||||
g.Meta `path:"/banner/view" method:"get" tags:"轮播图" summary:"获取指定轮播图信息"`
|
||||
sysin.BannerViewInp
|
||||
}
|
||||
|
||||
type ViewRes struct {
|
||||
*sysin.BannerViewModel
|
||||
}
|
||||
23
server/addons/flashbanner/api/admin/index/index.go
Normal file
23
server/addons/flashbanner/api/admin/index/index.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Package index
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package index
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
)
|
||||
|
||||
// TestReq 测试
|
||||
type TestReq struct {
|
||||
g.Meta `path:"/index/test" method:"get" tags:"轮播图管理" summary:"测试后台API"`
|
||||
sysin.IndexTestInp
|
||||
}
|
||||
|
||||
type TestRes struct {
|
||||
*sysin.IndexTestModel
|
||||
}
|
||||
|
||||
|
||||
21
server/addons/flashbanner/api/api/index/index.go
Normal file
21
server/addons/flashbanner/api/api/index/index.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// Package index
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package index
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
)
|
||||
|
||||
// TestReq 测试
|
||||
type TestReq struct {
|
||||
g.Meta `path:"/index/test" method:"get" tags:"轮播图管理" summary:"测试前台API"`
|
||||
sysin.IndexTestInp
|
||||
}
|
||||
|
||||
type TestRes struct {
|
||||
*sysin.IndexTestModel
|
||||
}
|
||||
21
server/addons/flashbanner/api/home/index/index.go
Normal file
21
server/addons/flashbanner/api/home/index/index.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// Package index
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package index
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
)
|
||||
|
||||
// TestReq 测试
|
||||
type TestReq struct {
|
||||
g.Meta `path:"/index/test" method:"get" summary:"轮播图管理" tags:"测试首页"`
|
||||
sysin.IndexTestInp
|
||||
}
|
||||
|
||||
type TestRes struct {
|
||||
g.Meta `mime:"text/html" type:"string" example:"<html/>"`
|
||||
}
|
||||
21
server/addons/flashbanner/api/websocket/index/index.go
Normal file
21
server/addons/flashbanner/api/websocket/index/index.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// Package index
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package index
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
)
|
||||
|
||||
// TestReq 测试
|
||||
type TestReq struct {
|
||||
g.Meta `path:"/index/test" method:"get" tags:"轮播图管理" summary:"测试websocket"`
|
||||
sysin.IndexTestInp
|
||||
}
|
||||
|
||||
type TestRes struct {
|
||||
*sysin.IndexTestModel
|
||||
}
|
||||
9
server/addons/flashbanner/consts/consts.go
Normal file
9
server/addons/flashbanner/consts/consts.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
// 常量枚举.
|
||||
// 插件中的常量枚举可以统一在这目录下
|
||||
81
server/addons/flashbanner/controller/admin/banner/banner.go
Normal file
81
server/addons/flashbanner/controller/admin/banner/banner.go
Normal file
@@ -0,0 +1,81 @@
|
||||
// Package banner
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package banner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/flashbanner/api/admin/banner"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Banner = cBanner{}
|
||||
)
|
||||
|
||||
type cBanner struct{}
|
||||
|
||||
// Create 创建轮播图
|
||||
func (c *cBanner) Create(ctx context.Context, req *banner.CreateReq) (res *banner.CreateRes, err error) {
|
||||
err = service.SysBanner().Create(ctx, &req.BannerCreateInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = &banner.CreateRes{}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// List 获取轮播图列表
|
||||
func (c *cBanner) List(ctx context.Context, req *banner.ListReq) (res *banner.ListRes, err error) {
|
||||
list, totalCount, err := service.SysBanner().List(ctx, &req.BannerListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = &banner.ListRes{
|
||||
List: list,
|
||||
}
|
||||
res.PageRes.Pack(&req.BannerListInp, totalCount)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// View 获取指定轮播图信息
|
||||
func (c *cBanner) View(ctx context.Context, req *banner.ViewReq) (res *banner.ViewRes, err error) {
|
||||
model, err := service.SysBanner().View(ctx, &req.BannerViewInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = &banner.ViewRes{model}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Edit 修改/新增轮播图
|
||||
func (c *cBanner) Edit(ctx context.Context, req *banner.EditReq) (res *banner.EditRes, err error) {
|
||||
err = service.SysBanner().Edit(ctx, &req.BannerEditInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = &banner.EditRes{}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Delete 删除轮播图
|
||||
func (c *cBanner) Delete(ctx context.Context, req *banner.DeleteReq) (res *banner.DeleteRes, err error) {
|
||||
err = service.SysBanner().Delete(ctx, &req.BannerDeleteInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = &banner.DeleteRes{}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Status 更新轮播图状态
|
||||
func (c *cBanner) Status(ctx context.Context, req *banner.StatusReq) (res *banner.StatusRes, err error) {
|
||||
err = service.SysBanner().Status(ctx, &req.BannerStatusInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = &banner.StatusRes{}
|
||||
return res, nil
|
||||
}
|
||||
14
server/addons/flashbanner/controller/admin/sys/banner.go
Normal file
14
server/addons/flashbanner/controller/admin/sys/banner.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package sys
|
||||
|
||||
import (
|
||||
"hotgo/addons/flashbanner/controller/admin/banner"
|
||||
)
|
||||
|
||||
var (
|
||||
Banner = banner.Banner
|
||||
)
|
||||
33
server/addons/flashbanner/controller/admin/sys/config.go
Normal file
33
server/addons/flashbanner/controller/admin/sys/config.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/flashbanner/api/admin/config"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Config = cConfig{}
|
||||
)
|
||||
|
||||
type cConfig struct{}
|
||||
|
||||
// GetConfig 获取指定分组的配置
|
||||
func (c *cConfig) GetConfig(ctx context.Context, req *config.GetReq) (res *config.GetRes, err error) {
|
||||
data, err := service.SysConfig().GetConfigByGroup(ctx, &req.GetConfigInp)
|
||||
|
||||
res = new(config.GetRes)
|
||||
res.GetConfigModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateConfig 更新指定分组的配置
|
||||
func (c *cConfig) UpdateConfig(ctx context.Context, req *config.UpdateReq) (res *config.UpdateRes, err error) {
|
||||
err = service.SysConfig().UpdateConfigByGroup(ctx, &req.UpdateConfigInp)
|
||||
return
|
||||
}
|
||||
30
server/addons/flashbanner/controller/admin/sys/index.go
Normal file
30
server/addons/flashbanner/controller/admin/sys/index.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/flashbanner/api/admin/index"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// Test 测试
|
||||
func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(index.TestRes)
|
||||
res.IndexTestModel = data
|
||||
return
|
||||
}
|
||||
41
server/addons/flashbanner/controller/api/banner/banner.go
Normal file
41
server/addons/flashbanner/controller/api/banner/banner.go
Normal file
@@ -0,0 +1,41 @@
|
||||
// Package banner
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package banner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/flashbanner/api/admin/banner"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
)
|
||||
|
||||
var (
|
||||
BannerIndex = cBanner{}
|
||||
)
|
||||
|
||||
type cBanner struct{}
|
||||
|
||||
// List 获取轮播图列表
|
||||
func (c *cBanner) List(ctx context.Context, req *banner.ListReq) (res *banner.ListRes, err error) {
|
||||
list, totalCount, err := service.SysBanner().List(ctx, &req.BannerListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = &banner.ListRes{
|
||||
List: list,
|
||||
}
|
||||
res.PageRes.Pack(&req.BannerListInp, totalCount)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// View 获取指定轮播图信息
|
||||
func (c *cBanner) View(ctx context.Context, req *banner.ViewReq) (res *banner.ViewRes, err error) {
|
||||
model, err := service.SysBanner().View(ctx, &req.BannerViewInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = &banner.ViewRes{model}
|
||||
return res, nil
|
||||
}
|
||||
31
server/addons/flashbanner/controller/api/index.go
Normal file
31
server/addons/flashbanner/controller/api/index.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Package api
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/flashbanner/api/api/index"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// Test 测试
|
||||
func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(index.TestRes)
|
||||
res.IndexTestModel = data
|
||||
return
|
||||
}
|
||||
|
||||
34
server/addons/flashbanner/controller/home/index.go
Normal file
34
server/addons/flashbanner/controller/home/index.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// Package home
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package home
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/flashbanner/api/home/index"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
"hotgo/internal/model"
|
||||
isc "hotgo/internal/service"
|
||||
)
|
||||
|
||||
// Index 基础
|
||||
var Index = cIndex{}
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
func (a *cIndex) Index(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
isc.View().RenderTpl(ctx, "home/index.html", model.View{Data: g.Map{
|
||||
"name": data.Name,
|
||||
"module": data.Module,
|
||||
"time": data.Time,
|
||||
}})
|
||||
return
|
||||
}
|
||||
30
server/addons/flashbanner/controller/websocket/index.go
Normal file
30
server/addons/flashbanner/controller/websocket/index.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// Package websocket
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/flashbanner/api/websocket/index"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// Test 测试
|
||||
func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(index.TestRes)
|
||||
res.IndexTestModel = data
|
||||
return
|
||||
}
|
||||
9
server/addons/flashbanner/crons/crons.go
Normal file
9
server/addons/flashbanner/crons/crons.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Package crons
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package crons
|
||||
|
||||
// 定时任务.
|
||||
// 插件中的定时任务可以统一在这里注册和处理
|
||||
12
server/addons/flashbanner/dao/banner.go
Normal file
12
server/addons/flashbanner/dao/banner.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// Package dao
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package dao
|
||||
|
||||
import "hotgo/addons/flashbanner/dao/internal"
|
||||
|
||||
var (
|
||||
Banner = internal.NewBannerDao()
|
||||
)
|
||||
89
server/addons/flashbanner/dao/internal/banner.go
Normal file
89
server/addons/flashbanner/dao/internal/banner.go
Normal file
@@ -0,0 +1,89 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// BannerDao is the data access object for table hg_banner.
|
||||
type BannerDao 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 BannerColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// BannerColumns defines and stores column names for table hg_banner.
|
||||
type BannerColumns struct {
|
||||
Id string //
|
||||
Name string // 轮播图名称
|
||||
Cover string // 图片URL
|
||||
Link string // 跳转链接,小程序内用相对地址
|
||||
Type string // 类型默认不传
|
||||
Status string // 1可用
|
||||
Sort string // 排序,数字越大越靠前
|
||||
CreatedAt string //
|
||||
UpdatedAt string //
|
||||
}
|
||||
|
||||
// bannerColumns holds the columns for table hg_banner.
|
||||
var bannerColumns = BannerColumns{
|
||||
Id: "id",
|
||||
Name: "name",
|
||||
Cover: "cover",
|
||||
Link: "link",
|
||||
Type: "type",
|
||||
Status: "status",
|
||||
Sort: "sort",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
}
|
||||
|
||||
// NewBannerDao creates and returns a new DAO object for table data access.
|
||||
func NewBannerDao() *BannerDao {
|
||||
return &BannerDao{
|
||||
group: "default",
|
||||
table: "hg_banner",
|
||||
columns: bannerColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *BannerDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *BannerDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *BannerDao) Columns() BannerColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *BannerDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *BannerDao) 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 *BannerDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
12
server/addons/flashbanner/global/global.go
Normal file
12
server/addons/flashbanner/global/global.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// Package global
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package global
|
||||
|
||||
import "hotgo/internal/library/addons"
|
||||
|
||||
var (
|
||||
skeleton *addons.Skeleton // 插件架子
|
||||
)
|
||||
22
server/addons/flashbanner/global/init.go
Normal file
22
server/addons/flashbanner/global/init.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Package global
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package global
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/internal/library/addons"
|
||||
)
|
||||
|
||||
func Init(ctx context.Context, sk *addons.Skeleton) {
|
||||
skeleton = sk
|
||||
}
|
||||
|
||||
func GetSkeleton() *addons.Skeleton {
|
||||
if skeleton == nil {
|
||||
panic("addon skeleton not initialized.")
|
||||
}
|
||||
return skeleton
|
||||
}
|
||||
0
server/addons/flashbanner/logic/.gitkeep
Normal file
0
server/addons/flashbanner/logic/.gitkeep
Normal file
9
server/addons/flashbanner/logic/logic.go
Normal file
9
server/addons/flashbanner/logic/logic.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package logic
|
||||
|
||||
import (
|
||||
_ "hotgo/addons/flashbanner/logic/sys"
|
||||
)
|
||||
173
server/addons/flashbanner/logic/sys/banner.go
Normal file
173
server/addons/flashbanner/logic/sys/banner.go
Normal file
@@ -0,0 +1,173 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/flashbanner/dao"
|
||||
"hotgo/addons/flashbanner/model/entity"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type sSysBanner struct{}
|
||||
|
||||
func NewSysBanner() *sSysBanner {
|
||||
return &sSysBanner{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysBanner(NewSysBanner())
|
||||
}
|
||||
|
||||
// GetMaxSort 获取最大排序值
|
||||
func (s *sSysBanner) GetMaxSort(ctx context.Context) (maxSort int, err error) {
|
||||
var result struct {
|
||||
MaxSort int `json:"maxSort"`
|
||||
}
|
||||
err = dao.Banner.Ctx(ctx).Fields("MAX(sort) as maxSort").Scan(&result)
|
||||
if err != nil {
|
||||
return 0, gerror.Wrap(err, "获取最大排序值失败")
|
||||
}
|
||||
return result.MaxSort, nil
|
||||
}
|
||||
|
||||
// Create 创建轮播图
|
||||
func (s *sSysBanner) Create(ctx context.Context, in *sysin.BannerCreateInp) (err error) {
|
||||
// 如果没有设置排序值,自动设置为最大值+1
|
||||
if in.Sort == 0 {
|
||||
maxSort, err := s.GetMaxSort(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
in.Sort = maxSort + 1
|
||||
}
|
||||
|
||||
_, err = dao.Banner.Ctx(ctx).Data(g.Map{
|
||||
dao.Banner.Columns().Name: in.Name,
|
||||
dao.Banner.Columns().Cover: in.Cover,
|
||||
dao.Banner.Columns().Link: in.Link,
|
||||
dao.Banner.Columns().Type: in.Type,
|
||||
dao.Banner.Columns().Status: 1, // 默认启用
|
||||
dao.Banner.Columns().Sort: in.Sort,
|
||||
dao.Banner.Columns().CreatedAt: gtime.Now(),
|
||||
dao.Banner.Columns().UpdatedAt: gtime.Now(),
|
||||
}).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "创建轮播图失败")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改/新增轮播图
|
||||
func (s *sSysBanner) Edit(ctx context.Context, in *sysin.BannerEditInp) (err error) {
|
||||
if in.Id > 0 {
|
||||
// 修改
|
||||
_, err = dao.Banner.Ctx(ctx).Where(dao.Banner.Columns().Id, in.Id).Data(g.Map{
|
||||
dao.Banner.Columns().Name: in.Name,
|
||||
dao.Banner.Columns().Cover: in.Cover,
|
||||
dao.Banner.Columns().Link: in.Link,
|
||||
dao.Banner.Columns().Type: in.Type,
|
||||
dao.Banner.Columns().Status: in.Status,
|
||||
dao.Banner.Columns().Sort: in.Sort,
|
||||
dao.Banner.Columns().UpdatedAt: gtime.Now(),
|
||||
}).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "修改轮播图失败")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// 新增
|
||||
_, err = dao.Banner.Ctx(ctx).Data(g.Map{
|
||||
dao.Banner.Columns().Name: in.Name,
|
||||
dao.Banner.Columns().Cover: in.Cover,
|
||||
dao.Banner.Columns().Link: in.Link,
|
||||
dao.Banner.Columns().Type: in.Type,
|
||||
dao.Banner.Columns().Status: in.Status,
|
||||
dao.Banner.Columns().Sort: in.Sort,
|
||||
dao.Banner.Columns().CreatedAt: gtime.Now(),
|
||||
dao.Banner.Columns().UpdatedAt: gtime.Now(),
|
||||
}).Insert()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "新增轮播图失败")
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除轮播图
|
||||
func (s *sSysBanner) Delete(ctx context.Context, in *sysin.BannerDeleteInp) (err error) {
|
||||
_, err = dao.Banner.Ctx(ctx).Where(dao.Banner.Columns().Id, in.Id).Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "删除轮播图失败")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定轮播图信息
|
||||
func (s *sSysBanner) View(ctx context.Context, in *sysin.BannerViewInp) (res *sysin.BannerViewModel, err error) {
|
||||
var banner entity.Banner
|
||||
err = dao.Banner.Ctx(ctx).Where(dao.Banner.Columns().Id, in.Id).Scan(&banner)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "获取轮播图信息失败")
|
||||
return
|
||||
}
|
||||
if banner.Id == 0 {
|
||||
err = gerror.New("轮播图不存在")
|
||||
return
|
||||
}
|
||||
res = &sysin.BannerViewModel{Banner: banner}
|
||||
return
|
||||
}
|
||||
|
||||
// List 获取轮播图列表
|
||||
func (s *sSysBanner) List(ctx context.Context, in *sysin.BannerListInp) (list []*sysin.BannerListModel, totalCount int, err error) {
|
||||
m := dao.Banner.Ctx(ctx)
|
||||
|
||||
// 条件查询
|
||||
if in.Name != "" {
|
||||
m = m.WhereLike(dao.Banner.Columns().Name, "%"+in.Name+"%")
|
||||
}
|
||||
if in.Type > 0 {
|
||||
m = m.Where(dao.Banner.Columns().Type, in.Type)
|
||||
}
|
||||
|
||||
var banners []*entity.Banner
|
||||
if in.Page > 0 && in.PerPage > 0 {
|
||||
err = m.Page(in.Page, in.PerPage).OrderDesc(dao.Banner.Columns().Sort).OrderDesc(dao.Banner.Columns().Id).ScanAndCount(&banners, &totalCount, false)
|
||||
} else {
|
||||
err = m.OrderDesc(dao.Banner.Columns().Sort).OrderDesc(dao.Banner.Columns().Id).ScanAndCount(&banners, &totalCount, false)
|
||||
}
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "获取轮播图列表失败")
|
||||
return
|
||||
}
|
||||
|
||||
list = make([]*sysin.BannerListModel, len(banners))
|
||||
for i, banner := range banners {
|
||||
list[i] = &sysin.BannerListModel{Banner: *banner}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新轮播图状态
|
||||
func (s *sSysBanner) Status(ctx context.Context, in *sysin.BannerStatusInp) (err error) {
|
||||
_, err = dao.Banner.Ctx(ctx).Where(dao.Banner.Columns().Id, in.Id).Data(g.Map{
|
||||
dao.Banner.Columns().Status: in.Status,
|
||||
dao.Banner.Columns().UpdatedAt: gtime.Now(),
|
||||
}).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "更新轮播图状态失败")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
59
server/addons/flashbanner/logic/sys/config.go
Normal file
59
server/addons/flashbanner/logic/sys/config.go
Normal file
@@ -0,0 +1,59 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/flashbanner/global"
|
||||
"hotgo/addons/flashbanner/model"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
isc "hotgo/internal/service"
|
||||
)
|
||||
|
||||
type sSysConfig struct{}
|
||||
|
||||
func NewSysConfig() *sSysConfig {
|
||||
return &sSysConfig{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysConfig(NewSysConfig())
|
||||
}
|
||||
|
||||
// GetBasic 获取基础配置
|
||||
func (s *sSysConfig) GetBasic(ctx context.Context) (conf *model.BasicConfig, err error) {
|
||||
var in sysin.GetConfigInp
|
||||
in.GetAddonsConfigInp.AddonName = global.GetSkeleton().Name
|
||||
in.GetAddonsConfigInp.Group = "basic"
|
||||
models, err := isc.SysAddonsConfig().GetConfigByGroup(ctx, &in.GetAddonsConfigInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = gconv.Struct(models.List, &conf)
|
||||
return
|
||||
}
|
||||
|
||||
// GetConfigByGroup 获取指定分组配置
|
||||
func (s *sSysConfig) GetConfigByGroup(ctx context.Context, in *sysin.GetConfigInp) (res *sysin.GetConfigModel, err error) {
|
||||
in.GetAddonsConfigInp.AddonName = global.GetSkeleton().Name
|
||||
models, err := isc.SysAddonsConfig().GetConfigByGroup(ctx, &in.GetAddonsConfigInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(sysin.GetConfigModel)
|
||||
res.List = models.List
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateConfigByGroup 更新指定分组的配置
|
||||
func (s *sSysConfig) UpdateConfigByGroup(ctx context.Context, in *sysin.UpdateConfigInp) error {
|
||||
in.UpdateAddonsConfigInp.AddonName = global.GetSkeleton().Name
|
||||
return isc.SysAddonsConfig().UpdateConfigByGroup(ctx, &in.UpdateAddonsConfigInp)
|
||||
}
|
||||
35
server/addons/flashbanner/logic/sys/index.go
Normal file
35
server/addons/flashbanner/logic/sys/index.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"hotgo/addons/flashbanner/global"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
"hotgo/addons/flashbanner/service"
|
||||
"hotgo/internal/library/contexts"
|
||||
)
|
||||
|
||||
type sSysIndex struct{}
|
||||
|
||||
func NewSysIndex() *sSysIndex {
|
||||
return &sSysIndex{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysIndex(NewSysIndex())
|
||||
}
|
||||
|
||||
// Test 测试
|
||||
func (s *sSysIndex) Test(ctx context.Context, in *sysin.IndexTestInp) (res *sysin.IndexTestModel, err error) {
|
||||
res = new(sysin.IndexTestModel)
|
||||
res.Name = in.Name
|
||||
res.Module = fmt.Sprintf("当前插件模块是:%s,当前应用模块是:%s", global.GetSkeleton().Name, contexts.Get(ctx).Module)
|
||||
res.Time = gtime.Now()
|
||||
return
|
||||
}
|
||||
176
server/addons/flashbanner/main.go
Normal file
176
server/addons/flashbanner/main.go
Normal file
@@ -0,0 +1,176 @@
|
||||
// Package flashbanner
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package flashbanner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
_ "hotgo/addons/flashbanner/crons"
|
||||
"hotgo/addons/flashbanner/global"
|
||||
_ "hotgo/addons/flashbanner/logic"
|
||||
_ "hotgo/addons/flashbanner/queues"
|
||||
"hotgo/addons/flashbanner/router"
|
||||
"hotgo/addons/migrations"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
"sync"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
|
||||
|
||||
)
|
||||
|
||||
type module struct {
|
||||
skeleton *addons.Skeleton
|
||||
ctx context.Context
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
newModule()
|
||||
}
|
||||
|
||||
func newModule() {
|
||||
m := &module{
|
||||
skeleton: &addons.Skeleton{
|
||||
Label: `轮播图管理`,
|
||||
Name: `flashbanner`,
|
||||
Group: 6,
|
||||
Logo: "",
|
||||
Brief: ``,
|
||||
Description: ``,
|
||||
Author: ``,
|
||||
Version: `v1.0.0`, // 当该版本号高于已安装的版本号时,会提示可以更新
|
||||
},
|
||||
ctx: gctx.New(),
|
||||
}
|
||||
addons.RegisterModule(m)
|
||||
}
|
||||
|
||||
// Start 启动模块
|
||||
func (m *module) Start(option *addons.Option) (err error) {
|
||||
// 初始化模块
|
||||
global.Init(m.ctx, m.skeleton)
|
||||
|
||||
// 注册插件路由
|
||||
option.Server.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(service.Middleware().Addon)
|
||||
router.Admin(m.ctx, group)
|
||||
router.Api(m.ctx, group)
|
||||
router.Home(m.ctx, group)
|
||||
router.WebSocket(m.ctx, group)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Stop 停止模块
|
||||
func (m *module) Stop() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Ctx 上下文
|
||||
func (m *module) Ctx() context.Context {
|
||||
return m.ctx
|
||||
}
|
||||
|
||||
// GetSkeleton 获取模块
|
||||
func (m *module) GetSkeleton() *addons.Skeleton {
|
||||
return m.skeleton
|
||||
}
|
||||
|
||||
// Install 安装模块
|
||||
func (m *module) Install(ctx context.Context) (err error) {
|
||||
// 执行数据库安装文件
|
||||
// 获取当前目录
|
||||
sqlPath := gfile.Pwd() + gfile.Separator + "addons/migrations/flashbanner/install.sql"
|
||||
g.Log().Debug(ctx, "安装模块", m.skeleton.Label, "路径", sqlPath)
|
||||
result, err := migrations.DoSqlContent(ctx, sqlPath)
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, "安装模块", m.skeleton.Label, "失败", err)
|
||||
return
|
||||
}
|
||||
g.Log().Debug(ctx, "安装模块", m.skeleton.Label, "成功", result)
|
||||
// 复制web目录下的文件到管理后台对应位置
|
||||
// 插件的前端配置文件位于插件目录下的web子目录
|
||||
sourceWebPath := gfile.Pwd() + gfile.Separator + "addons/" + m.skeleton.Name + "/web/src/views/addons/" + m.skeleton.Name
|
||||
targetWebPath := "../web/src/views/addons/" + m.skeleton.Name
|
||||
g.Log().Debug(ctx, "复制前端配置文件", "源路径:", sourceWebPath, "目标路径:", targetWebPath)
|
||||
|
||||
// 检查源路径是否存在
|
||||
if gfile.Exists(sourceWebPath) {
|
||||
err = gfile.CopyDir(sourceWebPath, targetWebPath)
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, "复制前端配置文件失败:", err)
|
||||
} else {
|
||||
g.Log().Debug(ctx, "复制前端配置文件成功")
|
||||
}
|
||||
} else {
|
||||
g.Log().Warning(ctx, "前端配置文件源路径不存在:", sourceWebPath)
|
||||
}
|
||||
|
||||
// 复制API文件
|
||||
sourceApiPath := gfile.Pwd() + gfile.Separator + "addons/" + m.skeleton.Name + "/web/src/api/addons/" + m.skeleton.Name
|
||||
targetApiPath := "../web/src/api/addons/" + m.skeleton.Name
|
||||
g.Log().Debug(ctx, "复制API文件", "源路径:", sourceApiPath, "目标路径:", targetApiPath)
|
||||
if gfile.Exists(sourceApiPath) {
|
||||
err = gfile.CopyDir(sourceApiPath, targetApiPath)
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, "复制API文件失败:", err)
|
||||
} else {
|
||||
g.Log().Debug(ctx, "复制API文件成功")
|
||||
}
|
||||
} else {
|
||||
g.Log().Warning(ctx, "API文件源路径不存在:", sourceApiPath)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Upgrade 更新模块
|
||||
func (m *module) Upgrade(ctx context.Context) (err error) {
|
||||
// ...
|
||||
return
|
||||
}
|
||||
|
||||
// UnInstall 卸载模块
|
||||
func (m *module) UnInstall(ctx context.Context) (err error) {
|
||||
// ...
|
||||
// 移除数据库安装文件
|
||||
sqlPath := gfile.Pwd() + gfile.Separator + "addons/migrations/flashbanner/uninstall.sql"
|
||||
g.Log().Debug(ctx, "卸载模块", m.skeleton.Label, "路径", sqlPath)
|
||||
result, err := migrations.DoSqlContent(ctx, sqlPath)
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, "卸载模块", m.skeleton.Label, "失败", err)
|
||||
return
|
||||
}
|
||||
g.Log().Debug(ctx, "卸载模块", m.skeleton.Label, "成功", result)
|
||||
// 删除前端文件
|
||||
targetWebPath := "../web/src/views/addons/" + m.skeleton.Name
|
||||
targetApiPath := "../web/src/api/addons/" + m.skeleton.Name
|
||||
|
||||
// 删除配置页面文件
|
||||
if gfile.Exists(targetWebPath) {
|
||||
err = gfile.Remove(targetWebPath)
|
||||
if err != nil {
|
||||
g.Log().Warning(ctx, "删除前端配置文件失败:", err)
|
||||
} else {
|
||||
g.Log().Debug(ctx, "删除前端配置文件成功")
|
||||
}
|
||||
}
|
||||
|
||||
// 删除API文件
|
||||
if gfile.Exists(targetApiPath) {
|
||||
err = gfile.Remove(targetApiPath)
|
||||
if err != nil {
|
||||
g.Log().Warning(ctx, "删除API文件失败:", err)
|
||||
} else {
|
||||
g.Log().Debug(ctx, "删除API文件成功")
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
11
server/addons/flashbanner/model/config.go
Normal file
11
server/addons/flashbanner/model/config.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// Package model
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package model
|
||||
|
||||
// BasicConfig 基础配置
|
||||
type BasicConfig struct {
|
||||
Test string `json:"basicTest"`
|
||||
}
|
||||
22
server/addons/flashbanner/model/entity/banner.go
Normal file
22
server/addons/flashbanner/model/entity/banner.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// Banner is the golang structure for table banner.
|
||||
type Banner struct {
|
||||
Id int `json:"id" orm:"id" description:""`
|
||||
Name string `json:"name" orm:"name" description:"轮播图名称"`
|
||||
Cover string `json:"cover" orm:"cover" description:"图片URL"`
|
||||
Link string `json:"link" orm:"link" description:"跳转链接,小程序内用相对地址"`
|
||||
Type int `json:"type" orm:"type" description:"类型默认不传"`
|
||||
Status uint `json:"status" orm:"status" description:"1可用"`
|
||||
Sort int `json:"sort" orm:"sort" description:"排序,数字越大越靠前"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
|
||||
}
|
||||
98
server/addons/flashbanner/model/input/sysin/banner.go
Normal file
98
server/addons/flashbanner/model/input/sysin/banner.go
Normal file
@@ -0,0 +1,98 @@
|
||||
// Package sysin
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/flashbanner/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
// BannerCreateInp 创建轮播图
|
||||
type BannerCreateInp struct {
|
||||
Name string `json:"name" v:"required#轮播图名称不能为空" dc:"轮播图名称"`
|
||||
Cover string `json:"cover" v:"required#轮播图封面不能为空" dc:"轮播图封面"`
|
||||
Link string `json:"link" dc:"轮播图链接"`
|
||||
Type int `json:"type" dc:"轮播图类型"`
|
||||
Sort int `json:"sort" dc:"排序,数字越大越靠前"`
|
||||
}
|
||||
|
||||
func (in *BannerCreateInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type BannerCreateModel struct{}
|
||||
|
||||
// BannerEditInp 修改/新增轮播图
|
||||
type BannerEditInp struct {
|
||||
entity.Banner
|
||||
}
|
||||
|
||||
func (in *BannerEditInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Name == "" {
|
||||
err = gerror.New("轮播图名称不能为空")
|
||||
return
|
||||
}
|
||||
if in.Cover == "" {
|
||||
err = gerror.New("轮播图封面不能为空")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type BannerEditModel struct{}
|
||||
|
||||
// BannerDeleteInp 删除轮播图
|
||||
type BannerDeleteInp struct {
|
||||
Id interface{} `json:"id" v:"required#轮播图ID不能为空" dc:"轮播图ID"`
|
||||
}
|
||||
|
||||
func (in *BannerDeleteInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type BannerDeleteModel struct{}
|
||||
|
||||
// BannerViewInp 获取指定轮播图信息
|
||||
type BannerViewInp struct {
|
||||
Id int64 `json:"id" v:"required#轮播图ID不能为空" dc:"轮播图ID"`
|
||||
}
|
||||
|
||||
func (in *BannerViewInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type BannerViewModel struct {
|
||||
entity.Banner
|
||||
}
|
||||
|
||||
// BannerListInp 获取轮播图列表
|
||||
type BannerListInp struct {
|
||||
form.PageReq
|
||||
Name string `json:"name" dc:"轮播图名称"`
|
||||
Type int `json:"type" dc:"轮播图类型"`
|
||||
}
|
||||
|
||||
func (in *BannerListInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type BannerListModel struct {
|
||||
entity.Banner
|
||||
}
|
||||
|
||||
// BannerStatusInp 更新轮播图状态
|
||||
type BannerStatusInp struct {
|
||||
Id int64 `json:"id" v:"required#轮播图ID不能为空" dc:"轮播图ID"`
|
||||
Status int `json:"status" v:"required#状态不能为空" dc:"状态"`
|
||||
}
|
||||
|
||||
func (in *BannerStatusInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type BannerStatusModel struct{}
|
||||
24
server/addons/flashbanner/model/input/sysin/config.go
Normal file
24
server/addons/flashbanner/model/input/sysin/config.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Package sysin
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
)
|
||||
|
||||
// UpdateConfigInp 更新指定配置
|
||||
type UpdateConfigInp struct {
|
||||
sysin.UpdateAddonsConfigInp
|
||||
}
|
||||
|
||||
type GetConfigInp struct {
|
||||
sysin.GetAddonsConfigInp
|
||||
}
|
||||
|
||||
type GetConfigModel struct {
|
||||
List g.Map `json:"list"`
|
||||
}
|
||||
27
server/addons/flashbanner/model/input/sysin/index.go
Normal file
27
server/addons/flashbanner/model/input/sysin/index.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Package sysin
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// IndexTestInp 测试
|
||||
type IndexTestInp struct {
|
||||
Name string `json:"name" d:"HotGo" dc:"名称"`
|
||||
}
|
||||
|
||||
func (in *IndexTestInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type IndexTestModel struct {
|
||||
Name string `json:"name" dc:"名称"`
|
||||
Module string `json:"module" dc:"当前插件模块"`
|
||||
Time *gtime.Time `json:"time" dc:"当前时间"`
|
||||
}
|
||||
9
server/addons/flashbanner/queues/queues.go
Normal file
9
server/addons/flashbanner/queues/queues.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Package queues
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package queues
|
||||
|
||||
// 消息队列.
|
||||
// 插件中的消息队列消费者可以统一在这里注册和处理
|
||||
0
server/addons/flashbanner/resource/public/.gitkeep
Normal file
0
server/addons/flashbanner/resource/public/.gitkeep
Normal file
1
server/addons/flashbanner/resource/public/default
Normal file
1
server/addons/flashbanner/resource/public/default
Normal file
@@ -0,0 +1 @@
|
||||
Hello!这是创建插件 [轮播图管理] 时默认生成的一个静态目录文件,用于测试,当你看到这个提示时,说明已经联调成功啦!
|
||||
30
server/addons/flashbanner/resource/template/home/index.html
Normal file
30
server/addons/flashbanner/resource/template/home/index.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
|
||||
<meta name="keywords" content="@{.Keywords}"/>
|
||||
<meta name="description" content="@{.Description}"/>
|
||||
<title>@{.Title}</title>
|
||||
<script type="text/javascript" src="/resource/home/js/jquery-3.6.0.min.js"></script>
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="padding-top: 100px;text-align:center;">
|
||||
<h1><p>Hello,@{.Data.name}!!</p></h1>
|
||||
<h2><p>@{.Data.module}</p></h2>
|
||||
<h2><p>服务器时间:@{.Data.time}</p></h2>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
</script>
|
||||
</html>
|
||||
36
server/addons/flashbanner/router/admin.go
Normal file
36
server/addons/flashbanner/router/admin.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Package router
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/flashbanner/controller/admin/sys"
|
||||
"hotgo/addons/flashbanner/controller/admin/banner"
|
||||
"hotgo/addons/flashbanner/global"
|
||||
"hotgo/addons/flashbanner/router/genrouter"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// Admin 后台路由
|
||||
func Admin(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppAdmin, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
group.Bind(
|
||||
sys.Index,
|
||||
)
|
||||
group.Middleware(service.Middleware().AdminAuth)
|
||||
group.Bind(
|
||||
sys.Config,
|
||||
banner.Banner,
|
||||
)
|
||||
})
|
||||
|
||||
// 注册生成路由
|
||||
genrouter.Register(ctx, group)
|
||||
}
|
||||
32
server/addons/flashbanner/router/api.go
Normal file
32
server/addons/flashbanner/router/api.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Package router
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/flashbanner/controller/api/banner"
|
||||
"hotgo/addons/flashbanner/global"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// Api 前台路由
|
||||
func Api(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppApi, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
group.Bind(
|
||||
// 无需验证的路由
|
||||
banner.BannerIndex,
|
||||
)
|
||||
group.Middleware(service.Middleware().ApiAuth)
|
||||
group.Bind(
|
||||
// 需要验证的路由
|
||||
// ...
|
||||
)
|
||||
})
|
||||
}
|
||||
34
server/addons/flashbanner/router/genrouter/init.go
Normal file
34
server/addons/flashbanner/router/genrouter/init.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// Package genrouter
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package genrouter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/flashbanner/global"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
NoLoginRouter []interface{} // 无需登录
|
||||
LoginRequiredRouter []interface{} // 需要登录
|
||||
)
|
||||
|
||||
// Register 注册通过代码生成的后台路由
|
||||
func Register(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppAdmin, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
if len(NoLoginRouter) > 0 {
|
||||
group.Bind(NoLoginRouter...)
|
||||
}
|
||||
group.Middleware(service.Middleware().AdminAuth)
|
||||
if len(LoginRequiredRouter) > 0 {
|
||||
group.Bind(LoginRequiredRouter...)
|
||||
}
|
||||
})
|
||||
}
|
||||
25
server/addons/flashbanner/router/home.go
Normal file
25
server/addons/flashbanner/router/home.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Package router
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/flashbanner/controller/home"
|
||||
"hotgo/addons/flashbanner/global"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
)
|
||||
|
||||
// Home 前台页面路由
|
||||
func Home(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppHome, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
group.Bind(
|
||||
home.Index,
|
||||
)
|
||||
})
|
||||
}
|
||||
39
server/addons/flashbanner/router/websocket.go
Normal file
39
server/addons/flashbanner/router/websocket.go
Normal file
@@ -0,0 +1,39 @@
|
||||
// Package router
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/flashbanner/controller/websocket"
|
||||
"hotgo/addons/flashbanner/global"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
ws "hotgo/internal/websocket"
|
||||
)
|
||||
|
||||
// WebSocket ws路由配置
|
||||
func WebSocket(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppWebSocket, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
group.Bind(
|
||||
// 无需验证的路由
|
||||
websocket.Index,
|
||||
)
|
||||
// ws连接中间件
|
||||
group.Middleware(service.Middleware().WebSocketAuth)
|
||||
group.Bind(
|
||||
// 需要验证的路由
|
||||
// ..
|
||||
)
|
||||
})
|
||||
|
||||
// 注册消息路由
|
||||
ws.RegisterMsg(ws.EventHandlers{
|
||||
// ...
|
||||
})
|
||||
}
|
||||
0
server/addons/flashbanner/service/.gitkeep
Normal file
0
server/addons/flashbanner/service/.gitkeep
Normal file
71
server/addons/flashbanner/service/sys.go
Normal file
71
server/addons/flashbanner/service/sys.go
Normal file
@@ -0,0 +1,71 @@
|
||||
// ================================================================================
|
||||
// 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"
|
||||
"hotgo/addons/flashbanner/model"
|
||||
"hotgo/addons/flashbanner/model/input/sysin"
|
||||
)
|
||||
|
||||
type (
|
||||
ISysConfig interface {
|
||||
GetBasic(ctx context.Context) (conf *model.BasicConfig, err error)
|
||||
GetConfigByGroup(ctx context.Context, in *sysin.GetConfigInp) (res *sysin.GetConfigModel, err error)
|
||||
UpdateConfigByGroup(ctx context.Context, in *sysin.UpdateConfigInp) error
|
||||
}
|
||||
ISysIndex interface {
|
||||
Test(ctx context.Context, in *sysin.IndexTestInp) (res *sysin.IndexTestModel, err error)
|
||||
}
|
||||
ISysBanner interface {
|
||||
Create(ctx context.Context, in *sysin.BannerCreateInp) (err error)
|
||||
Edit(ctx context.Context, in *sysin.BannerEditInp) (err error)
|
||||
Delete(ctx context.Context, in *sysin.BannerDeleteInp) (err error)
|
||||
View(ctx context.Context, in *sysin.BannerViewInp) (res *sysin.BannerViewModel, err error)
|
||||
List(ctx context.Context, in *sysin.BannerListInp) (list []*sysin.BannerListModel, totalCount int, err error)
|
||||
Status(ctx context.Context, in *sysin.BannerStatusInp) (err error)
|
||||
GetMaxSort(ctx context.Context) (maxSort int, err error)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localSysConfig ISysConfig
|
||||
localSysIndex ISysIndex
|
||||
localSysBanner ISysBanner
|
||||
)
|
||||
|
||||
func SysConfig() ISysConfig {
|
||||
if localSysConfig == nil {
|
||||
panic("implement not found for interface ISysConfig, forgot register?")
|
||||
}
|
||||
return localSysConfig
|
||||
}
|
||||
|
||||
func RegisterSysConfig(i ISysConfig) {
|
||||
localSysConfig = i
|
||||
}
|
||||
|
||||
func SysIndex() ISysIndex {
|
||||
if localSysIndex == nil {
|
||||
panic("implement not found for interface ISysIndex, forgot register?")
|
||||
}
|
||||
return localSysIndex
|
||||
}
|
||||
|
||||
func RegisterSysIndex(i ISysIndex) {
|
||||
localSysIndex = i
|
||||
}
|
||||
|
||||
func SysBanner() ISysBanner {
|
||||
if localSysBanner == nil {
|
||||
panic("implement not found for interface ISysBanner, forgot register?")
|
||||
}
|
||||
return localSysBanner
|
||||
}
|
||||
|
||||
func RegisterSysBanner(i ISysBanner) {
|
||||
localSysBanner = i
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { http } from '@/utils/http/axios';
|
||||
|
||||
export function getConfig(params) {
|
||||
return http.request({
|
||||
url: '/flashbanner/config/get',
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function updateConfig(params) {
|
||||
return http.request({
|
||||
url: '/flashbanner/config/update',
|
||||
method: 'post',
|
||||
params,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { http } from '@/utils/http/axios';
|
||||
|
||||
export function List(params) {
|
||||
return http.request({
|
||||
url: '/flashbanner/banner/list',
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function Add(params) {
|
||||
return http.request({
|
||||
url: '/flashbanner/banner/create',
|
||||
method: 'POST',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function Edit(params) {
|
||||
return http.request({
|
||||
url: '/flashbanner/banner/edit',
|
||||
method: 'POST',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function Delete(params) {
|
||||
return http.request({
|
||||
url: '/flashbanner/banner/delete',
|
||||
method: 'POST',
|
||||
params,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-modal
|
||||
v-model:show="showModal"
|
||||
:on-after-leave="cancelForm"
|
||||
:mask-closable="false"
|
||||
:show-icon="false"
|
||||
preset="dialog"
|
||||
:title="formParams?.id > 0 ? '编辑 #' + formParams?.id : '添加'"
|
||||
:style="{
|
||||
width: dialogWidth,
|
||||
}"
|
||||
>
|
||||
<n-form
|
||||
:model="formParams"
|
||||
:rules="rules"
|
||||
ref="formRef"
|
||||
label-placement="left"
|
||||
:label-width="100"
|
||||
class="py-8"
|
||||
>
|
||||
<n-grid x-gap="24" :cols="1">
|
||||
<n-gi>
|
||||
<n-form-item label="名称" path="name">
|
||||
<n-input placeholder="请输入名称" v-model:value="formParams.name" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi>
|
||||
<n-form-item label="上传图片" path="cover">
|
||||
<UploadImage v-model:value="formParams.cover" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi>
|
||||
<n-form-item label="链接地址" path="link">
|
||||
<n-input placeholder="请输入链接地址" v-model:value="formParams.link" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
</n-form>
|
||||
|
||||
<template #action>
|
||||
<n-space>
|
||||
<n-button @click="cancelForm">取消</n-button>
|
||||
<n-button type="info" :loading="formBtnLoading" @click="confirmForm">确定</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
</n-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { h, reactive, ref, computed, defineExpose, defineEmits } from 'vue';
|
||||
import { useDialog, useMessage } from 'naive-ui';
|
||||
import UploadImage from '@/components/Upload/uploadImage.vue';
|
||||
import { rules } from './model';
|
||||
import { Edit, Add } from '@/api/addons/flashbanner/index';
|
||||
import { adaModalWidth } from '@/utils/hotgo';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
const emit = defineEmits(['on-refresh']);
|
||||
|
||||
const defaultState = {
|
||||
name: '',
|
||||
cover: '',
|
||||
link: '',
|
||||
};
|
||||
|
||||
const message = useMessage();
|
||||
const showModal = ref(false);
|
||||
const formBtnLoading = ref(false);
|
||||
const formRef = ref<any>();
|
||||
const formParams = ref<any>(cloneDeep(defaultState));
|
||||
|
||||
const dialogWidth = computed(() => {
|
||||
return adaModalWidth();
|
||||
});
|
||||
|
||||
// 关闭表单
|
||||
const cancelForm = () => {
|
||||
showModal.value = false;
|
||||
formParams.value = cloneDeep(defaultState);
|
||||
};
|
||||
|
||||
// 新增或编辑
|
||||
function confirmForm(e) {
|
||||
e.preventDefault();
|
||||
formBtnLoading.value = true;
|
||||
const Request = formParams.value.id > 0 ? Edit : Add;
|
||||
formRef.value.validate((errors) => {
|
||||
if (!errors) {
|
||||
Request(formParams.value).then((_res) => {
|
||||
message.success('操作成功');
|
||||
cancelForm();
|
||||
emit('on-refresh');
|
||||
});
|
||||
} else {
|
||||
message.error('请填写完整信息');
|
||||
}
|
||||
formBtnLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
defineExpose({ showModal, formParams });
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@@ -0,0 +1,83 @@
|
||||
import { h, render } from 'vue';
|
||||
import { FormSchema, useForm } from '@/components/Form';
|
||||
import { NImage } from 'naive-ui';
|
||||
import { fallbackSrc } from '@/utils/hotgo';
|
||||
|
||||
// **********查询表单********
|
||||
const detailSchemas: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
component: 'NInput',
|
||||
label: '图片名称',
|
||||
defaultValue: null,
|
||||
componentProps: {
|
||||
placeholder: '请输入图片名称',
|
||||
},
|
||||
},
|
||||
];
|
||||
export const [register, {}] = useForm({
|
||||
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
|
||||
labelWidth: 80,
|
||||
schemas: detailSchemas,
|
||||
});
|
||||
|
||||
// *********表格**********
|
||||
export const defaultColumns = [
|
||||
{
|
||||
title: 'ID',
|
||||
key: 'id',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '图片名称',
|
||||
key: 'name',
|
||||
},
|
||||
{
|
||||
title: '图片',
|
||||
key: 'cover',
|
||||
render(row) {
|
||||
if (row.cover !== '') {
|
||||
return h(NImage, {
|
||||
width: 40,
|
||||
height: 40,
|
||||
src: row.cover,
|
||||
fallbackSrc: fallbackSrc(),
|
||||
style: {
|
||||
width: '40px',
|
||||
height: '40px',
|
||||
'max-width': '100%',
|
||||
'max-height': '100%',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
return '暂无图片'
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '链接地址',
|
||||
key: 'link',
|
||||
render(row) {
|
||||
return h('a', { href: row.link, target: '_blank' }, row.link);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
key: 'createdAt',
|
||||
width: 180,
|
||||
},
|
||||
];
|
||||
|
||||
// *********编辑表单规则***********
|
||||
export const rules = {
|
||||
name: {
|
||||
required: true,
|
||||
trigger: ['blur', 'input'],
|
||||
message: '请输入图片名称',
|
||||
},
|
||||
cover: {
|
||||
required: true,
|
||||
trigger: ['blur', 'input'],
|
||||
message: '请上传图片',
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-spin :show="show" description="请稍候...">
|
||||
<n-form :label-width="80" :model="formValue" :rules="rules" ref="formRef">
|
||||
<n-form-item label="测试参数" path="basicTest">
|
||||
<n-input v-model:value="formValue.basicTest" placeholder="请输入测试参数" />
|
||||
<template #feedback>
|
||||
这是一个测试参数,每个插件都可以有独立的配置项,可以按需添加</template
|
||||
>
|
||||
</n-form-item>
|
||||
|
||||
<div>
|
||||
<n-space>
|
||||
<n-button type="primary" @click="formSubmit">保存更新</n-button>
|
||||
</n-space>
|
||||
</div>
|
||||
</n-form>
|
||||
</n-spin>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { useMessage } from 'naive-ui';
|
||||
import { getConfig, updateConfig } from '@/api/addons/flashbanner/config';
|
||||
|
||||
const group = ref('basic');
|
||||
|
||||
const show = ref(false);
|
||||
const rules = {
|
||||
basicTest: {
|
||||
required: true,
|
||||
message: '请输入测试参数',
|
||||
trigger: 'blur',
|
||||
},
|
||||
};
|
||||
|
||||
const formRef: any = ref(null);
|
||||
const message = useMessage();
|
||||
|
||||
const formValue = ref({
|
||||
basicTest: 'HotGo',
|
||||
});
|
||||
|
||||
function formSubmit() {
|
||||
formRef.value.validate((errors) => {
|
||||
if (!errors) {
|
||||
updateConfig({ group: group.value, list: formValue.value }).then((_res) => {
|
||||
message.success('更新成功');
|
||||
load();
|
||||
});
|
||||
} else {
|
||||
message.error('验证失败,请填写完整信息');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
|
||||
function load() {
|
||||
show.value = true;
|
||||
new Promise((_resolve, _reject) => {
|
||||
getConfig({ group: group.value })
|
||||
.then((res) => {
|
||||
formValue.value = res.list;
|
||||
})
|
||||
.finally(() => {
|
||||
show.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-grid cols="24 300:1 600:24" :x-gap="12">
|
||||
<n-grid-item span="6">
|
||||
<n-card :bordered="false" size="small" class="proCard">
|
||||
<n-thing
|
||||
class="thing-cell"
|
||||
v-for="item in typeTabList"
|
||||
:key="item.key"
|
||||
:class="{ 'thing-cell-on': type === item.key }"
|
||||
@click="switchType(item)"
|
||||
>
|
||||
<template #header>{{ item.name }}</template>
|
||||
<template #description>{{ item.desc }}</template>
|
||||
</n-thing>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
<n-grid-item span="18">
|
||||
<n-card :bordered="false" size="small" :title="typeTitle" class="proCard">
|
||||
<BasicSetting v-if="type === 1" />
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-grid>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, reactive, toRefs } from 'vue';
|
||||
import BasicSetting from './BasicSetting.vue';
|
||||
const typeTabList = [
|
||||
{
|
||||
name: '基本设置',
|
||||
desc: '系统常规设置',
|
||||
key: 1,
|
||||
},
|
||||
];
|
||||
export default defineComponent({
|
||||
components: {
|
||||
BasicSetting,
|
||||
},
|
||||
setup() {
|
||||
const state = reactive({
|
||||
type: 1,
|
||||
typeTitle: '基本设置',
|
||||
});
|
||||
|
||||
function switchType(e) {
|
||||
state.type = e.key;
|
||||
state.typeTitle = e.name;
|
||||
}
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
switchType,
|
||||
typeTabList,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.thing-cell {
|
||||
margin: 0 -16px 10px;
|
||||
padding: 5px 16px;
|
||||
|
||||
&:hover {
|
||||
background: #f3f3f3;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.thing-cell-on {
|
||||
background: #f0faff;
|
||||
color: #2d8cf0;
|
||||
|
||||
::v-deep(.n-thing-main .n-thing-header .n-thing-header__title) {
|
||||
color: #2d8cf0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #f0faff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,151 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-card :bordered="false" class="proCard" title="轮播图管理">
|
||||
<BasicForm
|
||||
@register="register"
|
||||
@submit="handleQuery"
|
||||
@reset="resetForm"
|
||||
@keyup.enter="handleQuery"
|
||||
ref="searchFormRef"
|
||||
>
|
||||
<template #statusSlot="{ model, field }">
|
||||
<n-input v-model:value="model[field]" />
|
||||
</template>
|
||||
</BasicForm>
|
||||
<BasicTable
|
||||
:openChecked="true"
|
||||
:columns="columns"
|
||||
:actionColumn="actionColumn"
|
||||
:request="loadDataTable"
|
||||
:row-key="(row) => row.id"
|
||||
ref="tableRef"
|
||||
:scroll-x="scrollX"
|
||||
:resizeHeightOffset="-10000"
|
||||
>
|
||||
<template #tableTitle>
|
||||
<n-button
|
||||
type="primary"
|
||||
@click="handleAdd"
|
||||
class="min-left-space"
|
||||
v-if="hasPermission(['/member/edit'])"
|
||||
>
|
||||
<template #icon>
|
||||
<n-icon>
|
||||
<PlusOutlined />
|
||||
</n-icon>
|
||||
</template>
|
||||
添加
|
||||
</n-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<BasicEdit ref="editRef" @on-refresh="onRefresh" />
|
||||
</n-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { h, onMounted, ref, computed, watch, reactive } from 'vue';
|
||||
import { register, defaultColumns } from './components/model';
|
||||
import BasicEdit from './components/Edit.vue';
|
||||
import { BasicForm } from '@/components/Form/index';
|
||||
import { BasicTable, TableAction } from '@/components/Table';
|
||||
import { usePermission } from '@/hooks/web/usePermission';
|
||||
import { List, Delete } from '@/api/addons/flashbanner/index';
|
||||
import { PlusOutlined } from '@vicons/antd';
|
||||
import { useDialog, useMessage } from 'naive-ui';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { adaTableScrollX } from '@/utils/hotgo';
|
||||
|
||||
interface TableActionState {
|
||||
reload: () => void;
|
||||
}
|
||||
|
||||
const { hasPermission } = usePermission();
|
||||
const dialog = useDialog();
|
||||
const message = useMessage();
|
||||
const formParams = ref({});
|
||||
const tableRef = ref<TableActionState>();
|
||||
const editRef = ref();
|
||||
const columns = ref(defaultColumns);
|
||||
const actionColumn = reactive({
|
||||
width: 200,
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
fixed: 'right',
|
||||
render(record) {
|
||||
return h(TableAction as any, {
|
||||
style: 'button',
|
||||
actions: [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
auth: ['/member/delete'],
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
onClick: handleDelete.bind(null, record),
|
||||
auth: ['/member/delete'],
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const scrollX = computed(() => {
|
||||
return adaTableScrollX(defaultColumns, actionColumn.width);
|
||||
});
|
||||
|
||||
const loadDataTable = async (res) => {
|
||||
return await List({ ...formParams.value, ...res });
|
||||
};
|
||||
|
||||
// 刷新table
|
||||
const onRefresh = () => {
|
||||
tableRef.value?.reload();
|
||||
};
|
||||
|
||||
// 重置查询框
|
||||
const resetForm = () => {
|
||||
formParams.value = {};
|
||||
onRefresh();
|
||||
};
|
||||
|
||||
// 查询
|
||||
const handleQuery = (e: any) => {
|
||||
formParams.value = { ...e };
|
||||
onRefresh();
|
||||
};
|
||||
|
||||
// 添加
|
||||
const handleAdd = () => {
|
||||
if (editRef.value) {
|
||||
editRef.value.showModal = true;
|
||||
}
|
||||
};
|
||||
|
||||
// 编辑
|
||||
const handleEdit = (record: Recordable) => {
|
||||
if (editRef.value) {
|
||||
editRef.value.showModal = true;
|
||||
editRef.value.formParams = cloneDeep(record);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除
|
||||
const handleDelete = (record: Recordable) => {
|
||||
dialog.warning({
|
||||
title: '警告',
|
||||
content: '你确定要删除?',
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: () => {
|
||||
Delete({ id: record.id }).then((_res) => {
|
||||
message.success('操作成功');
|
||||
onRefresh();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less"></style>
|
||||
@@ -153,7 +153,7 @@ func (s *sSysTable) Edit(ctx context.Context, in *sysin.TableEditInp) (err error
|
||||
|
||||
// 新增
|
||||
in.CreatedBy = contexts.GetUserId(ctx)
|
||||
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).Data(in).Insert(); err != nil {
|
||||
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).Data(in).OmitEmptyData().Insert(); err != nil {
|
||||
err = gerror.Wrap(err, "新增表格失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@ func (s *sSysTenantOrder) Export(ctx context.Context, in *sysin.TenantOrderListI
|
||||
// Edit 修改/新增多租户功能演示
|
||||
func (s *sSysTenantOrder) Edit(ctx context.Context, in *sysin.TenantOrderEditInp) (err error) {
|
||||
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
if _, err = s.Model(ctx).
|
||||
@@ -158,7 +157,6 @@ func (s *sSysTenantOrder) Edit(ctx context.Context, in *sysin.TenantOrderEditInp
|
||||
|
||||
// Delete 删除多租户功能演示
|
||||
func (s *sSysTenantOrder) Delete(ctx context.Context, in *sysin.TenantOrderDeleteInp) (err error) {
|
||||
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil {
|
||||
err = gerror.Wrap(err, "删除多租户功能演示失败,请稍后重试!")
|
||||
return
|
||||
|
||||
@@ -125,7 +125,7 @@ func (s *sSysTreeTable) Edit(ctx context.Context, in *sysin.TableEditInp) (err e
|
||||
}
|
||||
} else {
|
||||
in.CreatedBy = contexts.GetUserId(ctx)
|
||||
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).Data(in).Insert(); err != nil {
|
||||
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).Data(in).OmitEmptyData().Insert(); err != nil {
|
||||
err = gerror.Wrap(err, "新增表格失败,请稍后重试!")
|
||||
return err
|
||||
}
|
||||
|
||||
167
server/addons/migrations/flashbanner/install.pg.sql
Normal file
167
server/addons/migrations/flashbanner/install.pg.sql
Normal file
@@ -0,0 +1,167 @@
|
||||
-- 删除表(如果存在)
|
||||
DROP TABLE IF EXISTS hg_banner;
|
||||
|
||||
-- 创建表
|
||||
CREATE TABLE hg_banner (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
cover VARCHAR(255) DEFAULT NULL,
|
||||
link VARCHAR(255) DEFAULT NULL,
|
||||
type INTEGER DEFAULT 0,
|
||||
status SMALLINT DEFAULT 1,
|
||||
sort INTEGER DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT NULL,
|
||||
updated_at TIMESTAMP DEFAULT NULL
|
||||
);
|
||||
|
||||
-- 添加表注释
|
||||
COMMENT ON TABLE hg_banner IS '轮播图表';
|
||||
|
||||
-- 添加列注释
|
||||
COMMENT ON COLUMN hg_banner.name IS '轮播图名称';
|
||||
COMMENT ON COLUMN hg_banner.cover IS '图片URL';
|
||||
COMMENT ON COLUMN hg_banner.link IS '跳转链接,小程序内用相对地址';
|
||||
COMMENT ON COLUMN hg_banner.type IS '类型默认不传';
|
||||
COMMENT ON COLUMN hg_banner.status IS '1可用,2不可用';
|
||||
COMMENT ON COLUMN hg_banner.sort IS '排序,数字越大越靠前';
|
||||
|
||||
-- 添加 updated_at 字段的更新触发器(模拟 MySQL 的 ON UPDATE CURRENT_TIMESTAMP)
|
||||
CREATE OR REPLACE FUNCTION update_updated_at_column()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = NOW();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER trigger_update_updated_at
|
||||
BEFORE UPDATE ON hg_banner
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION update_updated_at_column();
|
||||
|
||||
-- 添加菜单项
|
||||
-- 先查找或创建"内容管理"父菜单(如果不存在)
|
||||
INSERT INTO hg_admin_menu (pid, level, tree, title, name, path, icon, type, redirect, permissions, permission_name, component, always_show, active_menu, is_root, is_frame, frame_src, keep_alive, hidden, affix, sort, remark, status, updated_at, created_at)
|
||||
SELECT 0, 1, '', '内容管理', 'content', '/content', 'BookOutlined', 1, '/content', '', '', 'LAYOUT', 2, '', 1, 2, '', 2, 2, 2, 12, '内容管理模块', 1, NOW(), NOW()
|
||||
WHERE NOT EXISTS (SELECT 1 FROM hg_admin_menu WHERE name = 'content');
|
||||
|
||||
-- 获取内容管理菜单ID并添加轮播图管理菜单
|
||||
WITH content_parent AS (
|
||||
SELECT id FROM hg_admin_menu WHERE name = 'content' LIMIT 1
|
||||
),
|
||||
inserted_menu AS (
|
||||
INSERT INTO hg_admin_menu (pid, level, tree, title, name, path, icon, type, redirect, permissions, permission_name, component, always_show, active_menu, is_root, is_frame, frame_src, keep_alive, hidden, affix, sort, remark, status, updated_at, created_at)
|
||||
SELECT
|
||||
cp.id,
|
||||
2,
|
||||
'tr_' || cp.id::text || ' ',
|
||||
'轮播图管理',
|
||||
'flashbanner',
|
||||
'/flashbanner',
|
||||
'',
|
||||
2,
|
||||
'',
|
||||
'/flashbanner/banner/list',
|
||||
'',
|
||||
'/addons/flashbanner/index',
|
||||
2,
|
||||
'',
|
||||
2,
|
||||
2,
|
||||
'',
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
10,
|
||||
'轮播图管理模块',
|
||||
1,
|
||||
NOW(),
|
||||
NOW()
|
||||
FROM content_parent cp
|
||||
RETURNING id
|
||||
)
|
||||
-- 添加子菜单和按钮
|
||||
INSERT INTO hg_admin_menu (pid, level, tree, title, name, path, icon, type, redirect, permissions, permission_name, component, always_show, active_menu, is_root, is_frame, frame_src, keep_alive, hidden, affix, sort, remark, status, updated_at, created_at)
|
||||
SELECT
|
||||
im.id,
|
||||
3,
|
||||
'tr_' || (SELECT id FROM content_parent)::text || ' tr_' || im.id::text || ' ',
|
||||
'新增轮播',
|
||||
'addbanner',
|
||||
'',
|
||||
'',
|
||||
3,
|
||||
'',
|
||||
'/flashbanner/banner/create',
|
||||
'',
|
||||
'',
|
||||
2,
|
||||
'',
|
||||
2,
|
||||
2,
|
||||
'',
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
10,
|
||||
'新增轮播图权限',
|
||||
1,
|
||||
NOW(),
|
||||
NOW()
|
||||
FROM inserted_menu im
|
||||
UNION ALL
|
||||
SELECT
|
||||
im.id,
|
||||
3,
|
||||
'tr_' || (SELECT id FROM content_parent)::text || ' tr_' || im.id::text || ' ',
|
||||
'轮播编辑',
|
||||
'editbanner',
|
||||
'',
|
||||
'',
|
||||
3,
|
||||
'',
|
||||
'/flashbanner/banner/update',
|
||||
'',
|
||||
'',
|
||||
2,
|
||||
'',
|
||||
2,
|
||||
2,
|
||||
'',
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
10,
|
||||
'编辑轮播图权限',
|
||||
1,
|
||||
NOW(),
|
||||
NOW()
|
||||
FROM inserted_menu im
|
||||
UNION ALL
|
||||
SELECT
|
||||
im.id,
|
||||
3,
|
||||
'tr_' || (SELECT id FROM content_parent)::text || ' tr_' || im.id::text || ' ',
|
||||
'删除轮播',
|
||||
'delbanner',
|
||||
'',
|
||||
'',
|
||||
3,
|
||||
'',
|
||||
'/flashbanner/banner/delete',
|
||||
'',
|
||||
'',
|
||||
2,
|
||||
'',
|
||||
2,
|
||||
2,
|
||||
'',
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
10,
|
||||
'删除轮播图权限',
|
||||
1,
|
||||
NOW(),
|
||||
NOW()
|
||||
FROM inserted_menu im;
|
||||
33
server/addons/migrations/flashbanner/install.sql
Normal file
33
server/addons/migrations/flashbanner/install.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
DROP TABLE IF EXISTS `hg_banner`;
|
||||
CREATE TABLE `hg_banner` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL COMMENT '轮播图名称',
|
||||
`cover` varchar(255) DEFAULT NULL COMMENT '图片URL',
|
||||
`link` varchar(255) DEFAULT NULL COMMENT '跳转链接,小程序内用相对地址',
|
||||
`type` int(11) DEFAULT 0 COMMENT '类型默认不传',
|
||||
`status` tinyint(1) DEFAULT 1 COMMENT '1可用,2不可用',
|
||||
`sort` int(11) DEFAULT 0 COMMENT '排序,数字越大越靠前',
|
||||
`created_at` datetime DEFAULT NULL,
|
||||
`updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='轮播图表';
|
||||
|
||||
|
||||
-- 添加菜单项
|
||||
-- 先查找或创建"内容管理"父菜单(如果不存在)
|
||||
INSERT IGNORE INTO `hg_admin_menu`(`pid`, `level`, `tree`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `sort`, `remark`, `status`, `updated_at`, `created_at`) VALUES
|
||||
(0, 1, '', '内容管理', 'content', '/content', 'BookOutlined', 1, '/content', '', '', 'LAYOUT', 2, '', 1, 2, '', 2, 2, 2, 12, '内容管理模块', 1, NOW(), NOW());
|
||||
|
||||
-- 获取内容管理菜单ID并添加轮播图管理菜单
|
||||
SET @content_parent_id = (SELECT id FROM `hg_admin_menu` WHERE `name` = 'content' LIMIT 1);
|
||||
|
||||
INSERT INTO `hg_admin_menu`(`pid`, `level`, `tree`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `sort`, `remark`, `status`, `updated_at`, `created_at`) VALUES
|
||||
(@content_parent_id, 2, CONCAT('tr_', @content_parent_id, ' '), '轮播图管理', 'flashbanner', '/flashbanner', '', 2, '', '/flashbanner/banner/list', '', '/addons/flashbanner/index', 2, '', 2, 2, '', 1, 2, 2, 10, '轮播图管理模块', 1, NOW(), NOW());
|
||||
|
||||
-- 添加子菜单和按钮
|
||||
SET @flashbanner_menu_id = LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO `hg_admin_menu`(`pid`, `level`, `tree`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `sort`, `remark`, `status`, `updated_at`, `created_at`) VALUES
|
||||
(@flashbanner_menu_id, 3, CONCAT('tr_', @content_parent_id, ' tr_', @flashbanner_menu_id, ' '), '新增轮播', 'addbanner', '', '', 3, '', '/flashbanner/banner/create', '', '', 2, '', 2, 2, '', 2, 2, 2, 10, '新增轮播图权限', 1, NOW(), NOW()),
|
||||
(@flashbanner_menu_id, 3, CONCAT('tr_', @content_parent_id, ' tr_', @flashbanner_menu_id, ' '), '轮播编辑', 'editbanner', '', '', 3, '', '/flashbanner/banner/update', '', '', 2, '', 2, 2, '', 2, 2, 2, 10, '编辑轮播图权限', 1, NOW(), NOW()),
|
||||
(@flashbanner_menu_id, 3, CONCAT('tr_', @content_parent_id, ' tr_', @flashbanner_menu_id, ' '), '删除轮播', 'delbanner', '', '', 3, '', '/flashbanner/banner/delete', '', '', 2, '', 2, 2, '', 2, 2, 2, 10, '删除轮播图权限', 1, NOW(), NOW());
|
||||
9
server/addons/migrations/flashbanner/uninstall.pg.sql
Normal file
9
server/addons/migrations/flashbanner/uninstall.pg.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- 删除表
|
||||
DROP TABLE IF EXISTS hg_banner;
|
||||
|
||||
-- 删除 flashbanner 相关菜单
|
||||
-- 先删除子菜单(权限按钮)
|
||||
DELETE FROM hg_admin_menu WHERE name IN ('addbanner', 'editbanner', 'delbanner');
|
||||
|
||||
-- 删除主菜单
|
||||
DELETE FROM hg_admin_menu WHERE name = 'flashbanner';
|
||||
9
server/addons/migrations/flashbanner/uninstall.sql
Normal file
9
server/addons/migrations/flashbanner/uninstall.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- 删除表
|
||||
DROP TABLE IF EXISTS `hg_banner`;
|
||||
|
||||
-- 删除 flashbanner 相关菜单
|
||||
-- 先删除子菜单(权限按钮)
|
||||
DELETE FROM `hg_admin_menu` WHERE `name` IN ('addbanner', 'editbanner', 'delbanner');
|
||||
|
||||
-- 删除主菜单
|
||||
DELETE FROM `hg_admin_menu` WHERE `name` = 'flashbanner';
|
||||
2
server/addons/migrations/readme.md
Normal file
2
server/addons/migrations/readme.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# 为了在容器映射sql所以需要独立出来
|
||||
# 兼容数据库和前端文件的迁移
|
||||
66
server/addons/migrations/sqlDo.go
Normal file
66
server/addons/migrations/sqlDo.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/container/gvar"
|
||||
)
|
||||
func DoSqlContent(ctx context.Context, sqlPath string) (string, error) {
|
||||
open, err := os.Open(sqlPath)
|
||||
if err != nil {
|
||||
return "fail", err
|
||||
}
|
||||
defer open.Close()
|
||||
sqlContent, err := io.ReadAll(open)
|
||||
if err != nil {
|
||||
return "fail", err
|
||||
}
|
||||
|
||||
// 首先尝试整个执行
|
||||
_, err = g.DB().Exec(ctx, string(sqlContent))
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, "整个执行SQL失败,尝试分句执行:", err)
|
||||
|
||||
// 整个执行失败,尝试按分号分割执行
|
||||
sqls := strings.Split(string(sqlContent), ";")
|
||||
for _, sql := range sqls {
|
||||
sql = strings.TrimSpace(sql)
|
||||
if sql != "" {
|
||||
_, err := g.DB().Exec(ctx, sql)
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, "执行SQL失败:", err, sql)
|
||||
return "fail", err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "success", nil
|
||||
}
|
||||
|
||||
func GetDbLink(ctx context.Context) *gvar.Var {
|
||||
link := g.Cfg().MustGet(ctx, "database.default")
|
||||
//读写分离
|
||||
if !link.IsSlice() {
|
||||
return g.Cfg().MustGet(ctx, "database.default.link")
|
||||
}
|
||||
for _, v := range link.Array() {
|
||||
// 只获取主库
|
||||
val := v.(map[string]interface{})
|
||||
if val["role"] == "master" {
|
||||
return gvar.New(val["link"])
|
||||
}
|
||||
}
|
||||
return gvar.New("database.default.0.link")
|
||||
}
|
||||
|
||||
func GetDbType(ctx context.Context) string {
|
||||
var (
|
||||
link = GetDbLink(ctx)
|
||||
)
|
||||
config := strings.SplitN(link.String(), ":", 2)
|
||||
return config[0]
|
||||
}
|
||||
8
server/addons/modules/flashbanner.go
Normal file
8
server/addons/modules/flashbanner.go
Normal file
@@ -0,0 +1,8 @@
|
||||
// Package modules
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package modules
|
||||
|
||||
import _ "hotgo/addons/flashbanner"
|
||||
@@ -47,21 +47,3 @@ type ClearKindReq struct {
|
||||
}
|
||||
|
||||
type ClearKindRes struct{}
|
||||
|
||||
// ChooserOptionReq 获取选择器选项
|
||||
type ChooserOptionReq struct {
|
||||
g.Meta `path:"/attachment/chooserOption" method:"get" tags:"附件" summary:"获取选择器选项"`
|
||||
}
|
||||
|
||||
type ChooserOptionRes struct {
|
||||
Drive sysin.DataSelectModel `json:"drive" dc:"驱动"`
|
||||
Kind []KindSelect `json:"kind" dc:"上传类型"`
|
||||
}
|
||||
|
||||
type KindSelect struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
Tag string `json:"listClass"`
|
||||
Label string `json:"label"`
|
||||
Icon string `json:"icon"`
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.13.1
|
||||
// @AutoGenerate Version 2.15.7
|
||||
package curddemo
|
||||
|
||||
import (
|
||||
@@ -68,6 +68,14 @@ type MaxSortRes struct {
|
||||
*sysin.CurdDemoMaxSortModel
|
||||
}
|
||||
|
||||
// StatusReq 更新CURD列表状态
|
||||
type StatusReq struct {
|
||||
g.Meta `path:"/curdDemo/status" method:"post" tags:"CURD列表" summary:"更新CURD列表状态"`
|
||||
sysin.CurdDemoStatusInp
|
||||
}
|
||||
|
||||
type StatusRes struct{}
|
||||
|
||||
// SwitchReq 更新CURD列表开关状态
|
||||
type SwitchReq struct {
|
||||
g.Meta `path:"/curdDemo/switch" method:"post" tags:"CURD列表" summary:"更新CURD列表状态"`
|
||||
|
||||
@@ -30,16 +30,6 @@ type ExportReq struct {
|
||||
|
||||
type ExportRes struct{}
|
||||
|
||||
// ViewReq 获取登录日志指定信息
|
||||
type ViewReq struct {
|
||||
g.Meta `path:"/loginLog/view" method:"get" tags:"登录日志" summary:"获取登录日志指定信息"`
|
||||
sysin.LoginLogViewInp
|
||||
}
|
||||
|
||||
type ViewRes struct {
|
||||
*sysin.LoginLogViewModel
|
||||
}
|
||||
|
||||
// DeleteReq 删除登录日志
|
||||
type DeleteReq struct {
|
||||
g.Meta `path:"/loginLog/delete" method:"post" tags:"登录日志" summary:"删除登录日志"`
|
||||
|
||||
@@ -87,8 +87,7 @@ type NetOptionReq struct {
|
||||
}
|
||||
|
||||
type NetOptionRes struct {
|
||||
LicenseGroup form.Selects `json:"licenseGroup" dc:"授权分组"`
|
||||
Routes []*RouteSelect `json:"routes" dc:"路由选项"`
|
||||
Routes []*RouteSelect `json:"routes" dc:"路由选项"`
|
||||
}
|
||||
|
||||
type RouteSelect struct {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.13.1
|
||||
// @AutoGenerate Version 2.15.7
|
||||
package normaltreedemo
|
||||
|
||||
import (
|
||||
@@ -66,4 +66,4 @@ type TreeOptionReq struct {
|
||||
g.Meta `path:"/normalTreeDemo/treeOption" method:"get" tags:"普通树表" summary:"获取普通树表关系树选项"`
|
||||
}
|
||||
|
||||
type TreeOptionRes []tree.Node
|
||||
type TreeOptionRes []tree.Node
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.13.1
|
||||
// @AutoGenerate Version 2.15.7
|
||||
package optiontreedemo
|
||||
|
||||
import (
|
||||
@@ -66,4 +66,4 @@ type TreeOptionReq struct {
|
||||
g.Meta `path:"/optionTreeDemo/treeOption" method:"get" tags:"选项树表" summary:"获取选项树表关系树选项"`
|
||||
}
|
||||
|
||||
type TreeOptionRes []tree.Node
|
||||
type TreeOptionRes []tree.Node
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.13.1
|
||||
// @AutoGenerate Version 2.15.7
|
||||
package testcategory
|
||||
|
||||
import (
|
||||
@@ -66,4 +66,4 @@ type StatusReq struct {
|
||||
sysin.TestCategoryStatusInp
|
||||
}
|
||||
|
||||
type StatusRes struct{}
|
||||
type StatusRes struct{}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
// Package member
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package member
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
import (
|
||||
"context"
|
||||
|
||||
// GetIdByCodeReq 通过邀请码获取用户ID
|
||||
type GetIdByCodeReq struct {
|
||||
g.Meta `path:"/member/getIdByCode" method:"post" tags:"用户" summary:"通过邀请码获取用户ID"`
|
||||
Code string `json:"code" dc:"邀请码"`
|
||||
"hotgo/api/api/member/v1"
|
||||
)
|
||||
|
||||
type IMemberV1 interface {
|
||||
GetIdByCode(ctx context.Context, req *v1.GetIdByCodeReq) (res *v1.GetIdByCodeRes, err error)
|
||||
}
|
||||
|
||||
type GetIdByCodeRes struct{}
|
||||
|
||||
16
server/api/api/member/v1/member.go
Normal file
16
server/api/api/member/v1/member.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// Package member
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package v1
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
// GetIdByCodeReq 通过邀请码获取用户ID
|
||||
type GetIdByCodeReq struct {
|
||||
g.Meta `path:"/member/getIdByCode" method:"post" tags:"用户" summary:"通过邀请码获取用户ID"`
|
||||
Code string `json:"code" dc:"邀请码"`
|
||||
}
|
||||
|
||||
type GetIdByCodeRes struct{}
|
||||
17
server/api/api/pay/pay.go
Normal file
17
server/api/api/pay/pay.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package pay
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hotgo/api/api/pay/v1"
|
||||
)
|
||||
|
||||
type IPayV1 interface {
|
||||
NotifyAliPay(ctx context.Context, req *v1.NotifyAliPayReq) (res *v1.NotifyAliPayRes, err error)
|
||||
NotifyWxPay(ctx context.Context, req *v1.NotifyWxPayReq) (res *v1.NotifyWxPayRes, err error)
|
||||
NotifyQQPay(ctx context.Context, req *v1.NotifyQQPayReq) (res *v1.NotifyQQPayRes, err error)
|
||||
}
|
||||
@@ -3,11 +3,12 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package pay
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/internal/model/input/payin"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// NotifyAliPayReq 支付宝回调
|
||||
180
server/go.mod
180
server/go.mod
@@ -1,141 +1,159 @@
|
||||
module hotgo
|
||||
|
||||
go 1.21
|
||||
|
||||
toolchain go1.22.1
|
||||
go 1.24.4
|
||||
|
||||
require (
|
||||
github.com/Shopify/sarama v1.34.1
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.2
|
||||
github.com/alibabacloud-go/dysmsapi-20170525/v3 v3.0.5
|
||||
github.com/alibabacloud-go/tea v1.1.20
|
||||
github.com/alibabacloud-go/tea-utils/v2 v2.0.1
|
||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible
|
||||
github.com/IBM/sarama v1.45.2
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.1.7
|
||||
github.com/alibabacloud-go/dysmsapi-20170525/v3 v3.0.6
|
||||
github.com/alibabacloud-go/tea v1.3.9
|
||||
github.com/alibabacloud-go/tea-utils/v2 v2.0.7
|
||||
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
|
||||
github.com/apache/rocketmq-client-go/v2 v2.1.2
|
||||
github.com/casbin/casbin/v2 v2.55.0
|
||||
github.com/forgoer/openssl v1.4.0
|
||||
github.com/go-pay/gopay v1.5.91
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.7.0
|
||||
github.com/gogf/gf/contrib/nosql/redis/v2 v2.7.0
|
||||
github.com/gogf/gf/contrib/trace/jaeger/v2 v2.7.0
|
||||
github.com/gogf/gf/v2 v2.7.0
|
||||
github.com/casbin/casbin/v2 v2.108.0
|
||||
github.com/forgoer/openssl v1.6.1
|
||||
github.com/go-pay/crypto v0.0.1
|
||||
github.com/go-pay/gopay v1.5.114
|
||||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0
|
||||
github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0
|
||||
github.com/gogf/gf/contrib/trace/jaeger/v2 v2.7.4
|
||||
github.com/gogf/gf/v2 v2.9.1-0.20250624075347-5fa656d1cc92
|
||||
github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f
|
||||
github.com/golang-jwt/jwt/v5 v5.0.0
|
||||
github.com/gorilla/websocket v1.5.1
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/kayon/iploc v0.0.0-20200312105652-bda3e968a794
|
||||
github.com/minio/minio-go/v7 v7.0.63
|
||||
github.com/mojocn/base64Captcha v1.3.6
|
||||
github.com/minio/minio-go/v7 v7.0.94
|
||||
github.com/mojocn/base64Captcha v1.3.8
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/qiniu/go-sdk/v7 v7.14.0
|
||||
github.com/shirou/gopsutil/v3 v3.23.3
|
||||
github.com/silenceper/wechat/v2 v2.1.4
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.633
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.633
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.45
|
||||
github.com/ufilesdk-dev/ufile-gosdk v1.0.3
|
||||
github.com/xuri/excelize/v2 v2.6.0
|
||||
go.opentelemetry.io/otel v1.25.0
|
||||
golang.org/x/mod v0.9.0
|
||||
golang.org/x/net v0.24.0
|
||||
golang.org/x/tools v0.7.0
|
||||
github.com/qiniu/go-sdk/v7 v7.25.4
|
||||
github.com/schollz/progressbar/v3 v3.18.0
|
||||
github.com/shirou/gopsutil/v3 v3.24.5
|
||||
github.com/silenceper/wechat/v2 v2.1.9
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1202
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.1200
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.66
|
||||
github.com/ufilesdk-dev/ufile-gosdk v1.0.6
|
||||
github.com/xuri/excelize/v2 v2.9.1
|
||||
go.opentelemetry.io/otel v1.37.0
|
||||
golang.org/x/mod v0.25.0
|
||||
golang.org/x/net v0.41.0
|
||||
golang.org/x/tools v0.34.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
aead.dev/minisign v0.2.0 // indirect
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
|
||||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 // indirect
|
||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
|
||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||
github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82 // indirect
|
||||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 // indirect
|
||||
github.com/alibabacloud-go/debug v1.0.1 // indirect
|
||||
github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect
|
||||
github.com/alibabacloud-go/openapi-util v0.1.0 // indirect
|
||||
github.com/alibabacloud-go/tea-utils v1.3.1 // indirect
|
||||
github.com/alibabacloud-go/tea-xml v1.1.2 // indirect
|
||||
github.com/aliyun/credentials-go v1.1.2 // indirect
|
||||
github.com/aliyun/credentials-go v1.4.5 // indirect
|
||||
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
|
||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d // indirect
|
||||
github.com/casbin/govaluate v1.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/clbanning/mxj v1.8.4 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/eapache/go-resiliency v1.2.0 // indirect
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
|
||||
github.com/eapache/go-resiliency v1.7.0 // indirect
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
|
||||
github.com/eapache/queue v1.1.0 // indirect
|
||||
github.com/emirpasic/gods v1.12.0 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/fatih/structs v1.1.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-logr/logr v1.4.1 // indirect
|
||||
github.com/gammazero/toposort v0.1.1 // indirect
|
||||
github.com/go-ini/ini v1.67.0 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-pay/errgroup v0.0.3 // indirect
|
||||
github.com/go-pay/smap v0.0.2 // indirect
|
||||
github.com/go-pay/util v0.0.4 // indirect
|
||||
github.com/go-pay/xlog v0.0.3 // indirect
|
||||
github.com/go-pay/xtime v0.0.2 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.1 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/gofrs/flock v0.8.1 // indirect
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/mock v1.4.4 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/btree v1.1.2 // indirect
|
||||
github.com/google/btree v1.1.3 // indirect
|
||||
github.com/google/go-querystring v1.0.0 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-uuid v1.0.2 // indirect
|
||||
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
||||
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
|
||||
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
|
||||
github.com/jcmturner/gofork v1.0.0 // indirect
|
||||
github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect
|
||||
github.com/jcmturner/gofork v1.7.6 // indirect
|
||||
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
|
||||
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.17.2 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/magiconair/properties v1.8.9 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // 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.16 // indirect
|
||||
github.com/minio/crc64nvme v1.0.1 // indirect
|
||||
github.com/minio/md5-simd v1.1.2 // indirect
|
||||
github.com/minio/sha256-simd v1.0.1 // indirect
|
||||
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||
github.com/mozillazg/go-httpheader v0.2.1 // indirect
|
||||
github.com/olekukonko/errors v0.0.0-20250405072817-4e6d85265da6 // indirect
|
||||
github.com/olekukonko/ll v0.0.8 // indirect
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.18 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.22 // indirect
|
||||
github.com/pkg/errors v0.8.1 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/redis/go-redis/v9 v9.5.1 // indirect
|
||||
github.com/redis/go-redis/v9 v9.7.0 // indirect
|
||||
github.com/richardlehane/mscfb v1.0.4 // indirect
|
||||
github.com/richardlehane/msoleps v1.0.1 // indirect
|
||||
github.com/richardlehane/msoleps v1.0.4 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/rs/xid v1.5.0 // indirect
|
||||
github.com/shoenig/go-m1cpu v0.1.4 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/rs/xid v1.6.0 // indirect
|
||||
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
github.com/tidwall/gjson v1.14.1 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tjfoc/gmsm v1.3.2 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.11 // indirect
|
||||
github.com/tklauser/numcpus v0.6.0 // indirect
|
||||
github.com/xuri/efp v0.0.0-20220407160117-ad0f7a785be8 // indirect
|
||||
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.25.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.25.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.25.0 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/image v0.13.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
|
||||
github.com/tiendc/go-deepcopy v1.6.0 // indirect
|
||||
github.com/tinylib/msgp v1.3.0 // indirect
|
||||
github.com/tjfoc/gmsm v1.4.1 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||
github.com/xuri/efp v0.0.1 // indirect
|
||||
github.com/xuri/nfp v0.0.1 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.37.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.37.0 // indirect
|
||||
go.uber.org/atomic v1.5.1 // indirect
|
||||
golang.org/x/crypto v0.39.0 // indirect
|
||||
golang.org/x/image v0.25.0 // indirect
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de // indirect
|
||||
golang.org/x/sync v0.15.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/term v0.32.0 // indirect
|
||||
golang.org/x/text v0.26.0 // indirect
|
||||
golang.org/x/time v0.12.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
modernc.org/fileutil v1.0.0 // indirect
|
||||
stathat.com/c/consistent v1.0.0 // indirect
|
||||
)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user