feat: add Go backend

This commit is contained in:
richjohnrambo
2026-10-10 20:56:17 +08:00
parent 50fcfd2d3d
commit f6024f0964
1040 changed files with 107169 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
## 功能案例
### 简介
系统的一些功能案例
### 使用说明
系统自带的功能使用示例及其说明,包含一些简单的交互
### 安装
1、安装 HotGo (2.11.4及以上)
项目介绍:https://github.com/bufanyun/hotgo
2、将当前插件项目拷贝进 HotGo 根目录的 server/addons 目录下
3、在 HotGo 根目录的 server/addons/modules 目录下创建go文件:hgexample.go,内容如下:
```go
package modules
import _ "hotgo/addons/hgexample"
```
4、HotGo 后台进入 开发工具->插件管理->找到 功能案例 (hgexample) 进行安装
5、重启服务即可生效
### 常用命令行
```shell
# 接口维护-gen service
gf gen service -s=addons/hgexample/logic -d=addons/hgexample/service
```
@@ -0,0 +1,26 @@
// Package comp
// @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 comp
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
// ImportExcelReq 导入Excel
type ImportExcelReq struct {
g.Meta `path:"/comp/importExcel" method:"post" tags:"功能案例" summary:"导入Excel"`
File *ghttp.UploadFile `json:"file" type:"file" dc:"分片文件"`
}
type ImportExcelSheet struct {
Sheet string `json:"sheet"`
Rows [][]string `json:"rows"`
}
type ImportExcelRes struct {
Sheets []*ImportExcelSheet `json:"sheets"`
}
@@ -0,0 +1,30 @@
// Package config
// @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 config
import (
"github.com/gogf/gf/v2/frame/g"
"hotgo/addons/hgexample/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 {
}
@@ -0,0 +1,21 @@
// Package index
// @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 index
import (
"github.com/gogf/gf/v2/frame/g"
"hotgo/addons/hgexample/model/input/sysin"
)
// TestReq 测试
type TestReq struct {
g.Meta `path:"/index/test" method:"get" tags:"功能案例" summary:"测试"`
sysin.IndexTestInp
}
type TestRes struct {
*sysin.IndexTestModel
}
@@ -0,0 +1,83 @@
// Package table
// @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 table
import (
"github.com/gogf/gf/v2/frame/g"
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/internal/model/input/form"
)
// ListReq 查询列表
type ListReq struct {
g.Meta `path:"/table/list" method:"get" tags:"表格例子" summary:"获取表格列表"`
sysin.TableListInp
}
type ListRes struct {
form.PageRes
List []*sysin.TableListModel `json:"list" dc:"数据列表"`
}
// ExportReq 导出列表
type ExportReq struct {
g.Meta `path:"/table/export" method:"get" tags:"表格例子" summary:"导出表格列表"`
sysin.TableListInp
}
type ExportRes struct{}
// ViewReq 获取信息
type ViewReq struct {
g.Meta `path:"/table/view" method:"get" tags:"表格例子" summary:"获取指定信息"`
sysin.TableViewInp
}
type ViewRes struct {
*sysin.TableViewModel
}
// EditReq 修改/新增
type EditReq struct {
g.Meta `path:"/table/edit" method:"post" tags:"表格例子" summary:"修改/新增表格"`
sysin.TableEditInp
}
type EditRes struct{}
// DeleteReq 删除
type DeleteReq struct {
g.Meta `path:"/table/delete" method:"post" tags:"表格例子" summary:"删除表格"`
sysin.TableDeleteInp
}
type DeleteRes struct{}
// MaxSortReq 最大排序
type MaxSortReq struct {
g.Meta `path:"/table/maxSort" method:"get" tags:"表格例子" summary:"表格最大排序"`
sysin.TableMaxSortInp
}
type MaxSortRes struct {
*sysin.TableMaxSortModel
}
// StatusReq 更新状态
type StatusReq struct {
g.Meta `path:"/table/status" method:"post" tags:"表格例子" summary:"更新表格状态"`
sysin.TableStatusInp
}
type StatusRes struct{}
// SwitchReq 更新开关状态
type SwitchReq struct {
g.Meta `path:"/table/switch" method:"post" tags:"表格例子" summary:"更新表格状态"`
sysin.TableSwitchInp
}
type SwitchRes struct{}
@@ -0,0 +1,59 @@
// Package tenantorder
// @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
// @AutoGenerate Version 2.13.1
package tenantorder
import (
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/internal/model/input/form"
"github.com/gogf/gf/v2/frame/g"
)
// ListReq 查询多租户功能演示列表
type ListReq struct {
g.Meta `path:"/tenantOrder/list" method:"get" tags:"多租户功能演示" summary:"获取多租户功能演示列表"`
sysin.TenantOrderListInp
}
type ListRes struct {
form.PageRes
List []*sysin.TenantOrderListModel `json:"list" dc:"数据列表"`
}
// ExportReq 导出多租户功能演示列表
type ExportReq struct {
g.Meta `path:"/tenantOrder/export" method:"get" tags:"多租户功能演示" summary:"导出多租户功能演示列表"`
sysin.TenantOrderListInp
}
type ExportRes struct{}
// ViewReq 获取多租户功能演示指定信息
type ViewReq struct {
g.Meta `path:"/tenantOrder/view" method:"get" tags:"多租户功能演示" summary:"获取多租户功能演示指定信息"`
sysin.TenantOrderViewInp
}
type ViewRes struct {
*sysin.TenantOrderViewModel
}
// EditReq 修改/新增多租户功能演示
type EditReq struct {
g.Meta `path:"/tenantOrder/edit" method:"post" tags:"多租户功能演示" summary:"修改/新增多租户功能演示"`
sysin.TenantOrderEditInp
}
type EditRes struct{}
// DeleteReq 删除多租户功能演示
type DeleteReq struct {
g.Meta `path:"/tenantOrder/delete" method:"post" tags:"多租户功能演示" summary:"删除多租户功能演示"`
sysin.TenantOrderDeleteInp
}
type DeleteRes struct{}
@@ -0,0 +1,92 @@
// Package treetable
// @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 treetable
import (
"github.com/gogf/gf/v2/frame/g"
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/internal/model/input/form"
)
// ListReq 查询列表
type ListReq struct {
g.Meta `path:"/treeTable/list" method:"get" tags:"树形表格例子" summary:"获取表格列表"`
sysin.TreeTableListInp
}
type ListRes struct {
form.PageRes
List []*sysin.TreeTableListModel `json:"list" dc:"数据列表"`
}
// ExportReq 导出列表
type ExportReq struct {
g.Meta `path:"/treeTable/export" method:"get" tags:"树形表格例子" summary:"导出表格列表"`
sysin.TableListInp
}
type ExportRes struct{}
// ViewReq 获取信息
type ViewReq struct {
g.Meta `path:"/treeTable/view" method:"get" tags:"树形表格例子" summary:"获取指定信息"`
sysin.TableViewInp
}
type ViewRes struct {
*sysin.TableViewModel
}
// EditReq 修改/新增
type EditReq struct {
g.Meta `path:"/treeTable/edit" method:"post" tags:"树形表格例子" summary:"修改/新增表格"`
sysin.TableEditInp
}
type EditRes struct{}
// DeleteReq 删除
type DeleteReq struct {
g.Meta `path:"/treeTable/delete" method:"post" tags:"树形表格例子" summary:"删除表格"`
sysin.TableDeleteInp
}
type DeleteRes struct{}
// MaxSortReq 最大排序
type MaxSortReq struct {
g.Meta `path:"/treeTable/maxSort" method:"get" tags:"树形表格例子" summary:"表格最大排序"`
sysin.TableMaxSortInp
}
type MaxSortRes struct {
*sysin.TableMaxSortModel
}
// StatusReq 更新状态
type StatusReq struct {
g.Meta `path:"/treeTable/status" method:"post" tags:"树形表格例子" summary:"更新表格状态"`
sysin.TableStatusInp
}
type StatusRes struct{}
// SwitchReq 更新开关状态
type SwitchReq struct {
g.Meta `path:"/treeTable/switch" method:"post" tags:"树形表格例子" summary:"更新表格状态"`
sysin.TableSwitchInp
}
type SwitchRes struct{}
// SelectReq 树形选项
type SelectReq struct {
g.Meta `path:"/treeTable/select" method:"get" tags:"树形表格例子" summary:"树形选项"`
}
type SelectRes struct {
List []*sysin.TableTree `json:"list" dc:"数据列表"`
}
@@ -0,0 +1,21 @@
// Package index
// @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 index
import (
"github.com/gogf/gf/v2/frame/g"
"hotgo/addons/hgexample/model/input/sysin"
)
// TestReq 测试
type TestReq struct {
g.Meta `path:"/index/test" method:"get" tags:"功能案例" summary:"测试"`
sysin.IndexTestInp
}
type TestRes struct {
*sysin.IndexTestModel
}
@@ -0,0 +1,21 @@
// Package index
// @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 index
import (
"github.com/gogf/gf/v2/frame/g"
"hotgo/addons/hgexample/model/input/sysin"
)
// TestReq 测试
type TestReq struct {
g.Meta `path:"/index/test" method:"get" tags:"功能案例" summary:"测试首页"`
sysin.IndexTestInp
}
type TestRes struct {
g.Meta `mime:"text/html" type:"string" example:"<html/>"`
}
@@ -0,0 +1,21 @@
// Package index
// @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 index
import (
"github.com/gogf/gf/v2/frame/g"
"hotgo/addons/hgexample/model/input/sysin"
)
// TestReq 测试
type TestReq struct {
g.Meta `path:"/index/test" method:"get" tags:"功能案例" summary:"测试"`
sysin.IndexTestInp
}
type TestRes struct {
*sysin.IndexTestModel
}
@@ -0,0 +1,46 @@
// Package sys
// @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 sys
import (
"context"
"github.com/xuri/excelize/v2"
"hotgo/addons/hgexample/api/admin/comp"
)
var (
Comp = cComp{}
)
type cComp struct{}
// ImportExcel 导入Excel
func (c *cComp) ImportExcel(ctx context.Context, req *comp.ImportExcelReq) (res *comp.ImportExcelRes, err error) {
file, err := req.File.Open()
if err != nil {
return
}
defer file.Close()
excel, err := excelize.OpenReader(file)
if err != nil {
return
}
defer excel.Close()
res = new(comp.ImportExcelRes)
sheetList := excel.GetSheetList()
for _, sheet := range sheetList {
item := new(comp.ImportExcelSheet)
item.Sheet = sheet
item.Rows, err = excel.GetRows(sheet)
if err != nil {
return nil, err
}
res.Sheets = append(res.Sheets, item)
}
return
}
@@ -0,0 +1,33 @@
// Package sys
// @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 sys
import (
"context"
"hotgo/addons/hgexample/api/admin/config"
"hotgo/addons/hgexample/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
}
@@ -0,0 +1,30 @@
// Package sys
// @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 sys
import (
"context"
"hotgo/addons/hgexample/api/admin/index"
"hotgo/addons/hgexample/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
}
@@ -0,0 +1,85 @@
// Package sys
// @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 sys
import (
"context"
"hotgo/addons/hgexample/api/admin/table"
"hotgo/addons/hgexample/service"
)
var (
Table = cTable{}
)
type cTable struct{}
// List 查看列表
func (c *cTable) List(ctx context.Context, req *table.ListReq) (res *table.ListRes, err error) {
list, totalCount, err := service.SysTable().List(ctx, &req.TableListInp)
if err != nil {
return
}
res = new(table.ListRes)
res.List = list
res.PageRes.Pack(req, totalCount)
return
}
// Export 导出列表
func (c *cTable) Export(ctx context.Context, req *table.ExportReq) (res *table.ExportRes, err error) {
err = service.SysTable().Export(ctx, &req.TableListInp)
return
}
// Edit 更新
func (c *cTable) Edit(ctx context.Context, req *table.EditReq) (res *table.EditRes, err error) {
err = service.SysTable().Edit(ctx, &req.TableEditInp)
return
}
// MaxSort 最大排序
func (c *cTable) MaxSort(ctx context.Context, req *table.MaxSortReq) (res *table.MaxSortRes, err error) {
data, err := service.SysTable().MaxSort(ctx, &req.TableMaxSortInp)
if err != nil {
return
}
res = new(table.MaxSortRes)
res.TableMaxSortModel = data
return
}
// View 获取指定信息
func (c *cTable) View(ctx context.Context, req *table.ViewReq) (res *table.ViewRes, err error) {
data, err := service.SysTable().View(ctx, &req.TableViewInp)
if err != nil {
return
}
res = new(table.ViewRes)
res.TableViewModel = data
return
}
// Delete 删除
func (c *cTable) Delete(ctx context.Context, req *table.DeleteReq) (res *table.DeleteRes, err error) {
err = service.SysTable().Delete(ctx, &req.TableDeleteInp)
return
}
// Status 更新状态
func (c *cTable) Status(ctx context.Context, req *table.StatusReq) (res *table.StatusRes, err error) {
err = service.SysTable().Status(ctx, &req.TableStatusInp)
return
}
// Switch 更新开关状态
func (c *cTable) Switch(ctx context.Context, req *table.SwitchReq) (res *table.SwitchRes, err error) {
err = service.SysTable().Switch(ctx, &req.TableSwitchInp)
return
}
@@ -0,0 +1,67 @@
// 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
// @AutoGenerate Version 2.13.1
package sys
import (
"context"
"hotgo/addons/hgexample/api/admin/tenantorder"
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/addons/hgexample/service"
)
var (
TenantOrder = cTenantOrder{}
)
type cTenantOrder struct{}
// List 查看多租户功能演示列表
func (c *cTenantOrder) List(ctx context.Context, req *tenantorder.ListReq) (res *tenantorder.ListRes, err error) {
list, totalCount, err := service.SysTenantOrder().List(ctx, &req.TenantOrderListInp)
if err != nil {
return
}
if list == nil {
list = []*sysin.TenantOrderListModel{}
}
res = new(tenantorder.ListRes)
res.List = list
res.PageRes.Pack(req, totalCount)
return
}
// Export 导出多租户功能演示列表
func (c *cTenantOrder) Export(ctx context.Context, req *tenantorder.ExportReq) (res *tenantorder.ExportRes, err error) {
err = service.SysTenantOrder().Export(ctx, &req.TenantOrderListInp)
return
}
// Edit 更新多租户功能演示
func (c *cTenantOrder) Edit(ctx context.Context, req *tenantorder.EditReq) (res *tenantorder.EditRes, err error) {
err = service.SysTenantOrder().Edit(ctx, &req.TenantOrderEditInp)
return
}
// View 获取指定多租户功能演示信息
func (c *cTenantOrder) View(ctx context.Context, req *tenantorder.ViewReq) (res *tenantorder.ViewRes, err error) {
data, err := service.SysTenantOrder().View(ctx, &req.TenantOrderViewInp)
if err != nil {
return
}
res = new(tenantorder.ViewRes)
res.TenantOrderViewModel = data
return
}
// Delete 删除多租户功能演示
func (c *cTenantOrder) Delete(ctx context.Context, req *tenantorder.DeleteReq) (res *tenantorder.DeleteRes, err error) {
err = service.SysTenantOrder().Delete(ctx, &req.TenantOrderDeleteInp)
return
}
@@ -0,0 +1,92 @@
// Package sys
// @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 sys
import (
"context"
"hotgo/addons/hgexample/api/admin/treetable"
"hotgo/addons/hgexample/service"
)
var (
TreeTable = cTreeTable{}
)
type cTreeTable struct{}
// List 查看列表
func (c *cTreeTable) List(ctx context.Context, req *treetable.ListReq) (res *treetable.ListRes, err error) {
list, totalCount, err := service.SysTreeTable().List(ctx, &req.TreeTableListInp)
if err != nil {
return
}
res = new(treetable.ListRes)
res.List = list
res.PageRes.Pack(req, totalCount)
return
}
// Export 导出列表
func (c *cTreeTable) Export(ctx context.Context, req *treetable.ExportReq) (res *treetable.ExportRes, err error) {
err = service.SysTable().Export(ctx, &req.TableListInp)
return
}
// Edit 更新
func (c *cTreeTable) Edit(ctx context.Context, req *treetable.EditReq) (res *treetable.EditRes, err error) {
err = service.SysTreeTable().Edit(ctx, &req.TableEditInp)
return
}
// MaxSort 最大排序
func (c *cTreeTable) MaxSort(ctx context.Context, req *treetable.MaxSortReq) (res *treetable.MaxSortRes, err error) {
data, err := service.SysTable().MaxSort(ctx, &req.TableMaxSortInp)
if err != nil {
return
}
res = new(treetable.MaxSortRes)
res.TableMaxSortModel = data
return
}
// View 获取指定信息
func (c *cTreeTable) View(ctx context.Context, req *treetable.ViewReq) (res *treetable.ViewRes, err error) {
data, err := service.SysTable().View(ctx, &req.TableViewInp)
if err != nil {
return
}
res = new(treetable.ViewRes)
res.TableViewModel = data
return
}
// Delete 删除
func (c *cTreeTable) Delete(ctx context.Context, req *treetable.DeleteReq) (res *treetable.DeleteRes, err error) {
err = service.SysTreeTable().Delete(ctx, &req.TableDeleteInp)
return
}
// Status 更新状态
func (c *cTreeTable) Status(ctx context.Context, req *treetable.StatusReq) (res *treetable.StatusRes, err error) {
err = service.SysTable().Status(ctx, &req.TableStatusInp)
return
}
// Switch 更新开关状态
func (c *cTreeTable) Switch(ctx context.Context, req *treetable.SwitchReq) (res *treetable.SwitchRes, err error) {
err = service.SysTable().Switch(ctx, &req.TableSwitchInp)
return
}
// Select 树形选项
func (c *cTreeTable) Select(ctx context.Context, _ *treetable.SelectReq) (res *treetable.SelectRes, err error) {
res = new(treetable.SelectRes)
res.List, err = service.SysTreeTable().Select(ctx)
return
}
@@ -0,0 +1,30 @@
// Package api
// @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 api
import (
"context"
"hotgo/addons/hgexample/api/api/index"
"hotgo/addons/hgexample/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
}
@@ -0,0 +1,34 @@
// Package home
// @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 home
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"hotgo/addons/hgexample/api/home/index"
"hotgo/addons/hgexample/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
}
@@ -0,0 +1,25 @@
// Package handler
// @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 handler
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/websocket"
)
var (
Index = cIndex{}
)
type cIndex struct{}
// TestMessage 测试消息
func (c *cIndex) TestMessage(client *websocket.Client, req *websocket.WRequest) {
g.Log().Infof(client.Context(), "收到客户端测试消息:%v", gjson.New(req).String())
// 将收到的消息原样发送给客户端
websocket.SendSuccess(client, req.Event, req.Data)
}
@@ -0,0 +1,30 @@
// Package websocket
// @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 websocket
import (
"context"
"hotgo/addons/hgexample/api/websocket/index"
"hotgo/addons/hgexample/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
View File
@@ -0,0 +1,9 @@
// Package crons
// @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 crons
// 定时任务.
// 插件中的定时任务可以统一在这里注册和处理
+12
View File
@@ -0,0 +1,12 @@
// Package global
// @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 global
import "hotgo/internal/library/addons"
var (
skeleton *addons.Skeleton // 插件架子
)
+22
View File
@@ -0,0 +1,22 @@
// Package global
// @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 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
}
+9
View File
@@ -0,0 +1,9 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package logic
import (
_ "hotgo/addons/hgexample/logic/sys"
)
@@ -0,0 +1,59 @@
// Package sys
// @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 sys
import (
"context"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/addons/hgexample/global"
"hotgo/addons/hgexample/model"
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/addons/hgexample/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)
}
@@ -0,0 +1,35 @@
// Package sys
// @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 sys
import (
"context"
"fmt"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/addons/hgexample/global"
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/addons/hgexample/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
}
+233
View File
@@ -0,0 +1,233 @@
// Package sys
// @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 sys
import (
"context"
"fmt"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/addons/hgexample/service"
"hotgo/internal/dao"
"hotgo/internal/library/contexts"
"hotgo/internal/library/hgorm"
"hotgo/internal/library/hgorm/handler"
"hotgo/internal/model/input/form"
"hotgo/utility/convert"
"hotgo/utility/excel"
"hotgo/utility/validate"
)
type sSysTable struct{}
func NewSysTable() *sSysTable {
return &sSysTable{}
}
func init() {
service.RegisterSysTable(NewSysTable())
}
// Model Orm模型
func (s *sSysTable) Model(ctx context.Context, option ...*handler.Option) *gdb.Model {
return handler.Model(dao.AddonHgexampleTable.Ctx(ctx), option...)
}
// List 获取列表
func (s *sSysTable) List(ctx context.Context, in *sysin.TableListInp) (list []*sysin.TableListModel, totalCount int, err error) {
mod := s.Model(ctx)
cols := dao.AddonHgexampleTable.Columns()
if in.Title != "" {
mod = mod.WhereLike(cols.Title, "%"+in.Title+"%")
}
if in.Content != "" {
mod = mod.WhereLike(cols.Content, "%"+in.Content+"%")
}
if in.Status > 0 {
mod = mod.Where(cols.Status, in.Status)
}
if in.Switch > 0 {
mod = mod.Where(cols.Switch, in.Switch)
}
if len(in.Price) > 0 {
if in.Price[0] > 0 && in.Price[1] > 0 {
mod = mod.WhereBetween(cols.Price, in.Price[0], in.Price[1])
} else if in.Price[0] > 0 && in.Price[1] == 0 {
mod = mod.WhereGTE(cols.Price, in.Price[0])
} else if in.Price[0] == 0 && in.Price[1] > 0 {
mod = mod.WhereLTE(cols.Price, in.Price[1])
}
}
if in.ActivityAt != nil {
mod = mod.Where(cols.ActivityAt, in.ActivityAt)
}
if len(in.CreatedAt) == 2 {
mod = mod.WhereBetween(cols.CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
}
if !in.Flag.IsNil() {
mod = mod.Where(fmt.Sprintf(`JSON_CONTAINS(%s,'%v')`, cols.Flag, in.Flag))
}
if !in.Hobby.IsNil() {
mod = mod.Where(fmt.Sprintf(`JSON_CONTAINS(%s,'%v')`, cols.Hobby, in.Hobby))
}
totalCount, err = mod.Clone().Count()
if err != nil {
err = gerror.Wrap(err, "获取表格数据行失败,请稍后重试!")
return
}
if totalCount == 0 {
return
}
// .OrderAsc(cols.Sort).OrderDesc(cols.Id)
if err = mod.Fields(sysin.TableListModel{}).Page(in.Page, in.PerPage).Handler(handler.Sorter(in)).Scan(&list); err != nil {
err = gerror.Wrap(err, "获取表格列表失败,请稍后重试!")
return
}
return
}
// Export 导出
func (s *sSysTable) Export(ctx context.Context, in *sysin.TableListInp) (err error) {
list, totalCount, err := s.List(ctx, in)
if err != nil {
return
}
// 字段的排序是依据tags的字段顺序,如果你不想使用默认的排序方式,可以直接定义 tags = []string{"字段名称", "字段名称2", ...}
tags, err := convert.GetEntityDescTags(sysin.TableExportModel{})
if err != nil {
return
}
var (
fileName = "表格例子导出-" + gctx.CtxId(ctx)
sheetName = fmt.Sprintf("索引条件共%v行,共%v页,当前导出是第%v页,本页共%v行", totalCount, form.CalPageCount(totalCount, in.PerPage), in.Page, len(list))
exports []sysin.TableExportModel
)
if err = gconv.Scan(list, &exports); err != nil {
return
}
if err = excel.ExportByStructs(ctx, tags, exports, fileName, sheetName); err != nil {
return
}
return
}
// Edit 修改/新增
func (s *sSysTable) Edit(ctx context.Context, in *sysin.TableEditInp) (err error) {
cols := dao.AddonHgexampleTable.Columns()
if err = hgorm.IsUnique(ctx, &dao.AddonHgexampleTable, g.Map{cols.Qq: in.Qq}, "QQ号码已存在,请换一个", in.Id); err != nil {
return
}
// 修改
if in.Id > 0 {
in.UpdatedBy = contexts.GetUserId(ctx)
if _, err = s.Model(ctx).WherePri(in.Id).Data(in).Update(); err != nil {
err = gerror.Wrap(err, "修改表格失败,请稍后重试!")
return
}
return
}
// 新增
in.CreatedBy = contexts.GetUserId(ctx)
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).Data(in).OmitEmptyData().Insert(); err != nil {
err = gerror.Wrap(err, "新增表格失败,请稍后重试!")
return
}
return
}
// Delete 删除
func (s *sSysTable) Delete(ctx context.Context, in *sysin.TableDeleteInp) (err error) {
if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil {
err = gerror.Wrap(err, "删除表格失败,请稍后重试!")
return
}
return
}
// Status 更新状态
func (s *sSysTable) Status(ctx context.Context, in *sysin.TableStatusInp) (err error) {
update := g.Map{
dao.AddonHgexampleTable.Columns().Status: in.Status,
dao.AddonHgexampleTable.Columns().UpdatedBy: contexts.GetUserId(ctx),
}
if _, err = s.Model(ctx).WherePri(in.Id).Data(update).Update(); err != nil {
err = gerror.Wrap(err, "更新表格状态失败,请稍后重试!")
return
}
return
}
// Switch 更新开关状态
func (s *sSysTable) Switch(ctx context.Context, in *sysin.TableSwitchInp) (err error) {
var fields = []string{
dao.AddonHgexampleTable.Columns().Switch,
// ...
}
if !validate.InSlice(fields, in.Key) {
err = gerror.New("开关键名不在白名单")
return
}
update := g.Map{
in.Key: in.Value,
dao.AddonHgexampleTable.Columns().UpdatedBy: contexts.GetUserId(ctx),
}
if _, err = s.Model(ctx).Where(dao.AddonHgexampleTable.Columns().Id, in.Id).Data(update).Update(); err != nil {
err = gerror.Wrap(err, "更新表格开关失败,请稍后重试!")
return
}
return
}
// MaxSort 最大排序
func (s *sSysTable) MaxSort(ctx context.Context, in *sysin.TableMaxSortInp) (res *sysin.TableMaxSortModel, err error) {
dx := dao.AddonHgexampleTable
if err = dx.Ctx(ctx).Fields(dx.Columns().Sort).OrderDesc(dx.Columns().Sort).Scan(&res); err != nil {
err = gerror.Wrap(err, "获取表格最大排序,请稍后重试!")
return
}
if res == nil {
res = new(sysin.TableMaxSortModel)
}
res.Sort = form.DefaultMaxSort(res.Sort)
return
}
// View 获取指定信息
func (s *sSysTable) View(ctx context.Context, in *sysin.TableViewInp) (res *sysin.TableViewModel, err error) {
if err = s.Model(ctx).WherePri(in.Id).Scan(&res); err != nil {
err = gerror.Wrap(err, "获取生成演示信息,请稍后重试!")
return
}
return
}
@@ -0,0 +1,174 @@
// 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
// @AutoGenerate Version 2.13.1
package sys
import (
"context"
"fmt"
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/addons/hgexample/service"
"hotgo/internal/dao"
"hotgo/internal/library/hgorm/handler"
"hotgo/internal/library/hgorm/hook"
"hotgo/internal/model/input/form"
"hotgo/utility/convert"
"hotgo/utility/excel"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/util/gconv"
)
type sSysTenantOrder struct{}
func NewSysTenantOrder() *sSysTenantOrder {
return &sSysTenantOrder{}
}
func init() {
service.RegisterSysTenantOrder(NewSysTenantOrder())
}
// Model 多租户功能演示ORM模型
func (s *sSysTenantOrder) Model(ctx context.Context, option ...*handler.Option) *gdb.Model {
if len(option) == 0 {
// 过滤多租户数据权限
option = append(option, &handler.Option{
FilterTenant: true,
//FilterAuth: true, // 如果还需要维护created_by、member_id等部门数据权限范围可放开注释
})
}
return handler.Model(dao.AddonHgexampleTenantOrder.Ctx(ctx), option...)
}
// List 获取多租户功能演示列表
func (s *sSysTenantOrder) List(ctx context.Context, in *sysin.TenantOrderListInp) (list []*sysin.TenantOrderListModel, totalCount int, err error) {
mod := s.Model(ctx)
// 字段过滤
mod = mod.Fields(sysin.TenantOrderListModel{})
// 查询主键
if in.Id > 0 {
mod = mod.Where(dao.AddonHgexampleTenantOrder.Columns().Id, in.Id)
}
// 查询租户ID
if in.TenantId > 0 {
mod = mod.Where(dao.AddonHgexampleTenantOrder.Columns().TenantId, in.TenantId)
}
// 查询商户ID
if in.MerchantId > 0 {
mod = mod.Where(dao.AddonHgexampleTenantOrder.Columns().MerchantId, in.MerchantId)
}
// 查询用户ID
if in.UserId > 0 {
mod = mod.Where(dao.AddonHgexampleTenantOrder.Columns().UserId, in.UserId)
}
// 查询关联订单号
if in.OrderSn != "" {
mod = mod.Where(dao.AddonHgexampleTenantOrder.Columns().OrderSn, in.OrderSn)
}
// 查询支付状态
if in.Status > 0 {
mod = mod.Where(dao.AddonHgexampleTenantOrder.Columns().Status, in.Status)
}
// 查询创建时间
if len(in.CreatedAt) == 2 {
mod = mod.WhereBetween(dao.AddonHgexampleTenantOrder.Columns().CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
}
// 分页
mod = mod.Page(in.Page, in.PerPage)
// 排序
mod = mod.OrderDesc(dao.AddonHgexampleTenantOrder.Columns().Id)
// 查询数据
if err = mod.ScanAndCount(&list, &totalCount, false); err != nil {
err = gerror.Wrap(err, "获取多租户功能演示列表失败,请稍后重试!")
return
}
return
}
// Export 导出多租户功能演示
func (s *sSysTenantOrder) Export(ctx context.Context, in *sysin.TenantOrderListInp) (err error) {
list, totalCount, err := s.List(ctx, in)
if err != nil {
return
}
// 字段的排序是依据tags的字段顺序,如果你不想使用默认的排序方式,可以直接定义 tags = []string{"字段名称", "字段名称2", ...}
tags, err := convert.GetEntityDescTags(sysin.TenantOrderExportModel{})
if err != nil {
return
}
var (
fileName = "导出多租户功能演示-" + gctx.CtxId(ctx)
sheetName = fmt.Sprintf("索引条件共%v行,共%v页,当前导出是第%v页,本页共%v行", totalCount, form.CalPageCount(totalCount, in.PerPage), in.Page, len(list))
exports []sysin.TenantOrderExportModel
)
if err = gconv.Scan(list, &exports); err != nil {
return
}
err = excel.ExportByStructs(ctx, tags, exports, fileName, sheetName)
return
}
// 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).
Fields(sysin.TenantOrderUpdateFields{}).
WherePri(in.Id).Data(in).
Hook(hook.SaveTenant). // 自动维护租户关系更新
Update(); err != nil {
}
return
}
// 新增
if _, err = dao.AddonHgexampleTenantOrder.Ctx(ctx).
Fields(sysin.TenantOrderInsertFields{}).
Hook(hook.SaveTenant). // 自动维护租户关系更新
Data(in).
Insert(); err != nil {
}
return
})
}
// 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
}
return
}
// View 获取多租户功能演示指定信息
func (s *sSysTenantOrder) View(ctx context.Context, in *sysin.TenantOrderViewInp) (res *sysin.TenantOrderViewModel, err error) {
if err = s.Model(ctx).WherePri(in.Id).Scan(&res); err != nil {
err = gerror.Wrap(err, "获取多租户功能演示信息,请稍后重试!")
return
}
return
}
@@ -0,0 +1,186 @@
// Package sys
// @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 sys
import (
"context"
"fmt"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/addons/hgexample/service"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/contexts"
"hotgo/internal/library/hgorm"
"hotgo/internal/library/hgorm/handler"
"hotgo/internal/model/entity"
)
type sSysTreeTable struct{}
func NewSysTreeTable() *sSysTreeTable {
return &sSysTreeTable{}
}
func init() {
service.RegisterSysTreeTable(NewSysTreeTable())
}
// Model Orm模型
func (s *sSysTreeTable) Model(ctx context.Context, option ...*handler.Option) *gdb.Model {
return handler.Model(dao.AddonHgexampleTable.Ctx(ctx), option...)
}
// List 获取列表
func (s *sSysTreeTable) List(ctx context.Context, in *sysin.TreeTableListInp) (list []*sysin.TreeTableListModel, totalCount int, err error) {
mod := s.Model(ctx)
cols := dao.AddonHgexampleTable.Columns()
if in.Title != "" {
mod = mod.WhereLike(cols.Title, "%"+in.Title+"%")
}
if in.Content != "" {
mod = mod.WhereLike(cols.Content, "%"+in.Content+"%")
}
if in.Status > 0 {
mod = mod.Where(cols.Status, in.Status)
}
if in.Switch > 0 {
mod = mod.Where(cols.Switch, in.Switch)
}
if in.Pid > 0 {
mod = mod.Where(cols.Pid, in.Pid)
}
if len(in.Price) > 0 {
if in.Price[0] > 0 && in.Price[1] > 0 {
mod = mod.WhereBetween(cols.Price, in.Price[0], in.Price[1])
} else if in.Price[0] > 0 && in.Price[1] == 0 {
mod = mod.WhereGTE(cols.Price, in.Price[0])
} else if in.Price[0] == 0 && in.Price[1] > 0 {
mod = mod.WhereLTE(cols.Price, in.Price[1])
}
}
if in.ActivityAt != nil {
mod = mod.Where(cols.ActivityAt, in.ActivityAt)
}
if len(in.CreatedAt) == 2 {
mod = mod.WhereBetween(cols.CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
}
if !in.Flag.IsNil() {
mod = mod.Where(fmt.Sprintf(`JSON_CONTAINS(%s,'%v')`, cols.Flag, in.Flag))
}
if !in.Hobby.IsNil() {
mod = mod.Where(fmt.Sprintf(`JSON_CONTAINS(%s,'%v')`, cols.Hobby, in.Hobby))
}
totalCount, err = mod.Clone().Count()
if err != nil {
err = gerror.Wrap(err, "获取表格数据行失败,请稍后重试!")
return
}
if totalCount == 0 {
return
}
if err = mod.Fields(sysin.TableListModel{}).Page(in.Page, in.PerPage).Handler(handler.Sorter(in)).Scan(&list); err != nil {
err = gerror.Wrap(err, "获取表格列表失败,请稍后重试!")
return
}
return
}
// Edit 修改/新增
func (s *sSysTreeTable) Edit(ctx context.Context, in *sysin.TableEditInp) (err error) {
cols := dao.AddonHgexampleTable.Columns()
if err = hgorm.IsUnique(ctx, &dao.AddonHgexampleTable, g.Map{cols.Qq: in.Qq}, "QQ号码已存在,请换一个", in.Id); err != nil {
return
}
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
in.Pid, in.Level, in.Tree, err = hgorm.AutoUpdateTree(ctx, &dao.AddonHgexampleTable, in.Id, in.Pid)
if err != nil {
return err
}
if in.Id > 0 {
in.UpdatedBy = contexts.GetUserId(ctx)
if _, err = s.Model(ctx).WherePri(in.Id).Data(in).Update(); err != nil {
err = gerror.Wrap(err, "修改表格失败,请稍后重试!")
return err
}
} else {
in.CreatedBy = contexts.GetUserId(ctx)
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).Data(in).OmitEmptyData().Insert(); err != nil {
err = gerror.Wrap(err, "新增表格失败,请稍后重试!")
return err
}
}
return
})
}
// Delete 删除
func (s *sSysTreeTable) Delete(ctx context.Context, in *sysin.TableDeleteInp) (err error) {
count, err := dao.AdminMenu.Ctx(ctx).Where("pid", in.Id).Count()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
if count > 0 {
return gerror.New("请先删除该表格下的所有下级!")
}
if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil {
err = gerror.Wrap(err, "删除表格失败,请稍后重试!")
return
}
return
}
// Select 关系树选项列表
func (s *sSysTreeTable) Select(ctx context.Context) (list []*sysin.TableTree, err error) {
var models []*entity.AddonHgexampleTable
if err = dao.AddonHgexampleTable.Ctx(ctx).Order("pid asc,id asc,sort asc").Scan(&models); err != nil {
err = gerror.Wrap(err, "获取关系树选项列表失败!")
return
}
list = s.treeList(0, models)
return
}
// treeList 树状列表
func (s *sSysTreeTable) treeList(pid int64, nodes []*entity.AddonHgexampleTable) (list []*sysin.TableTree) {
list = make([]*sysin.TableTree, 0)
for _, v := range nodes {
if v.Pid == pid {
item := new(sysin.TableTree)
item.AddonHgexampleTable = *v
item.Label = v.Title
item.Value = v.Id
item.Key = v.Id
child := s.treeList(v.Id, nodes)
if len(child) > 0 {
item.Children = child
}
list = append(list, item)
}
}
return
}
+97
View File
@@ -0,0 +1,97 @@
// Package hgexample
// @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 hgexample
import (
"context"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gctx"
_ "hotgo/addons/hgexample/crons"
"hotgo/addons/hgexample/global"
_ "hotgo/addons/hgexample/logic"
_ "hotgo/addons/hgexample/queues"
"hotgo/addons/hgexample/router"
"hotgo/internal/library/addons"
"hotgo/internal/service"
"sync"
)
type module struct {
skeleton *addons.Skeleton
ctx context.Context
sync.Mutex
}
func init() {
newModule()
}
func newModule() {
m := &module{
skeleton: &addons.Skeleton{
Label: "功能案例",
Name: "hgexample",
Group: 1,
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) {
// ...
return
}
// Upgrade 更新模块
func (m *module) Upgrade(ctx context.Context) (err error) {
// ...
return
}
// UnInstall 卸载模块
func (m *module) UnInstall(ctx context.Context) (err error) {
// ...
return
}
+11
View File
@@ -0,0 +1,11 @@
// Package model
// @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 model
// BasicConfig 基础配置
type BasicConfig struct {
Test string `json:"basicTest"`
}
@@ -0,0 +1,24 @@
// Package sysin
// @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 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"`
}
@@ -0,0 +1,27 @@
// Package sysin
// @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 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:"当前时间"`
}
@@ -0,0 +1,180 @@
// Package sysin
// @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 sysin
import (
"context"
"errors"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/consts"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
"hotgo/utility/validate"
)
// TableEditInp 修改/新增
type TableEditInp struct {
entity.AddonHgexampleTable
}
type TableEditModel struct{}
func (in *TableEditInp) Filter(ctx context.Context) (err error) {
if in.Map.IsNil() {
in.Map = gjson.New(consts.NilJsonToString)
}
if in.Flag.IsNil() {
in.Flag = gjson.New(consts.NilJsonToString)
}
if in.Images.IsNil() {
in.Images = gjson.New(consts.NilJsonToString)
}
if in.Attachfiles.IsNil() {
in.Attachfiles = gjson.New(consts.NilJsonToString)
}
if in.Hobby.IsNil() {
in.Hobby = gjson.New(consts.NilJsonToString)
}
if in.Title == "" {
return errors.New("标题不能为空")
}
if in.Email != "" && !validate.IsEmail(in.Email) {
return errors.New("邮箱格式不正确")
}
if err := g.Validator().Rules("float|between:0,5").Messages("请输入一个浮点数|推荐星只能是0~5星").Data(in.Star).Run(ctx); err != nil {
return err.Current()
}
return
}
// TableDeleteInp 删除类型
type TableDeleteInp struct {
Id interface{} `json:"id" v:"required#表格ID不能为空" dc:"表格ID"`
}
type TableDeleteModel struct{}
// TableViewInp 获取信息
type TableViewInp struct {
Id int64 `json:"id" v:"required#表格ID不能为空" dc:"表格ID"`
}
type TableViewModel struct {
entity.AddonHgexampleTable
}
// TableListInp 获取列表
type TableListInp struct {
form.PageReq
form.Sorters
Id int64 `json:"id" description:""`
Flag *gjson.Json `json:"flag" description:"标签"`
Title string `json:"title" description:"标题"`
Content string `json:"content" description:"内容"`
Price []float64 `json:"price" description:"价格"`
ActivityAt *gtime.Time `json:"activityAt" description:"活动时间"`
Switch int `json:"switch" description:"开关"`
Hobby *gjson.Json `json:"hobby" description:"爱好"`
Status int `json:"status" description:"状态"`
CreatedAt []*gtime.Time `json:"createdAt" description:"创建时间"`
}
type TableListModel struct {
entity.AddonHgexampleTable
TableCategoryName string `json:"TableCategoryName" description:"分类名称"`
TableCategoryDescription string `json:"TableCategoryDescription" description:"分类描述"`
TableCategoryRemark string `json:"TableCategoryRemark" description:"分类备注"`
SysProvincesTitle string `json:"sysProvincesTitle" description:""`
}
func (in *TableListInp) Filter(ctx context.Context) (err error) {
if !in.Flag.IsNil() {
in.Flag = gjson.New(in.Flag.Var().Ints())
}
if !in.Hobby.IsNil() {
in.Hobby = gjson.New(in.Hobby.Var().Ints())
}
return
}
type TableExportModel struct {
Id int64 `json:"id" description:""`
CategoryId int64 `json:"categoryId" description:"分类ID"`
Flag *gjson.Json `json:"flag" description:"标签"`
Title string `json:"title" description:"标题"`
Star float64 `json:"star" description:"推荐星"`
Price float64 `json:"price" description:"价格"`
Views int64 `json:"views" description:"浏览次数"`
ActivityAt *gtime.Time `json:"activityAt" description:"活动时间"`
StartAt *gtime.Time `json:"startAt" description:"开启时间"`
EndAt *gtime.Time `json:"endAt" description:"结束时间"`
Switch int `json:"switch" description:"开关"`
Sort int `json:"sort" description:"排序"`
Avatar string `json:"avatar" description:"头像"`
Sex int `json:"sex" description:"性别"`
Qq string `json:"qq" description:"qq"`
Email string `json:"email" description:"邮箱"`
Mobile string `json:"mobile" description:"手机号码"`
Hobby *gjson.Json `json:"hobby" description:"爱好"`
Channel int `json:"channel" description:"渠道"`
Pid int64 `json:"pid" description:"上级ID"`
Level int `json:"level" description:"树等级"`
Tree string `json:"tree" description:"关系树"`
Remark string `json:"remark" description:"备注"`
Status int `json:"status" description:"状态"`
CreatedBy int64 `json:"createdBy" description:"创建者"`
UpdatedBy int64 `json:"updatedBy" description:"更新者"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"`
}
// TableMaxSortInp 最大排序
type TableMaxSortInp struct{}
type TableMaxSortModel struct {
Sort int `json:"sort" description:"排序"`
}
// TableStatusInp 更新状态
type TableStatusInp struct {
Id int64 `json:"id" v:"required#表格ID不能为空" dc:"表格ID"`
Status int `json:"status" dc:"状态"`
}
func (in *TableStatusInp) Filter(ctx context.Context) (err error) {
if in.Id <= 0 {
err = gerror.New("ID不能为空")
return
}
if in.Status <= 0 {
err = gerror.New("状态不能为空")
return
}
if !validate.InSlice(consts.StatusSlice, in.Status) {
err = gerror.New("状态不正确")
return
}
return
}
type TableStatusModel struct{}
// TableSwitchInp 更新开关状态
type TableSwitchInp struct {
form.SwitchReq
Id int64 `json:"id" v:"required#表格ID不能为空" dc:"表格ID"`
}
type TableSwitchModel struct{}
@@ -0,0 +1,123 @@
// 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
// @AutoGenerate Version 2.13.1
package sysin
import (
"context"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// TenantOrderUpdateFields 修改多租户功能演示字段过滤
type TenantOrderUpdateFields struct {
TenantId int64 `json:"tenantId" dc:"租户ID"`
MerchantId int64 `json:"merchantId" dc:"商户ID"`
UserId int64 `json:"userId" dc:"用户ID"`
ProductName string `json:"productName" dc:"购买产品"`
OrderSn string `json:"orderSn" dc:"关联订单号"`
Money float64 `json:"money" dc:"充值金额"`
Remark string `json:"remark" dc:"备注"`
Status int `json:"status" dc:"支付状态"`
}
// TenantOrderInsertFields 新增多租户功能演示字段过滤
type TenantOrderInsertFields struct {
TenantId int64 `json:"tenantId" dc:"租户ID"`
MerchantId int64 `json:"merchantId" dc:"商户ID"`
UserId int64 `json:"userId" dc:"用户ID"`
ProductName string `json:"productName" dc:"购买产品"`
OrderSn string `json:"orderSn" dc:"关联订单号"`
Money float64 `json:"money" dc:"充值金额"`
Remark string `json:"remark" dc:"备注"`
Status int `json:"status" dc:"支付状态"`
}
// TenantOrderEditInp 修改/新增多租户功能演示
type TenantOrderEditInp struct {
entity.AddonHgexampleTenantOrder
}
func (in *TenantOrderEditInp) Filter(ctx context.Context) (err error) {
// 验证充值金额
if err := g.Validator().Rules("required").Data(in.Money).Messages("充值金额不能为空").Run(ctx); err != nil {
return err.Current()
}
return
}
type TenantOrderEditModel struct{}
// TenantOrderDeleteInp 删除多租户功能演示
type TenantOrderDeleteInp struct {
Id interface{} `json:"id" v:"required#主键不能为空" dc:"主键"`
}
func (in *TenantOrderDeleteInp) Filter(ctx context.Context) (err error) {
return
}
type TenantOrderDeleteModel struct{}
// TenantOrderViewInp 获取指定多租户功能演示信息
type TenantOrderViewInp struct {
Id int64 `json:"id" v:"required#主键不能为空" dc:"主键"`
}
func (in *TenantOrderViewInp) Filter(ctx context.Context) (err error) {
return
}
type TenantOrderViewModel struct {
entity.AddonHgexampleTenantOrder
}
// TenantOrderListInp 获取多租户功能演示列表
type TenantOrderListInp struct {
form.PageReq
Id int64 `json:"id" dc:"主键"`
TenantId int64 `json:"tenantId" dc:"租户ID"`
MerchantId int64 `json:"merchantId" dc:"商户ID"`
UserId int64 `json:"userId" dc:"用户ID"`
OrderSn string `json:"orderSn" dc:"关联订单号"`
Status int `json:"status" dc:"支付状态"`
CreatedAt []*gtime.Time `json:"createdAt" dc:"创建时间"`
}
func (in *TenantOrderListInp) Filter(ctx context.Context) (err error) {
return
}
type TenantOrderListModel struct {
Id int64 `json:"id" dc:"主键"`
TenantId int64 `json:"tenantId" dc:"租户ID"`
MerchantId int64 `json:"merchantId" dc:"商户ID"`
UserId int64 `json:"userId" dc:"用户ID"`
ProductName string `json:"productName" dc:"购买产品"`
OrderSn string `json:"orderSn" dc:"关联订单号"`
Money float64 `json:"money" dc:"充值金额"`
Remark string `json:"remark" dc:"备注"`
Status int `json:"status" dc:"支付状态"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
}
// TenantOrderExportModel 导出多租户功能演示
type TenantOrderExportModel struct {
Id int64 `json:"id" dc:"主键"`
TenantId int64 `json:"tenantId" dc:"租户ID"`
MerchantId int64 `json:"merchantId" dc:"商户ID"`
UserId int64 `json:"userId" dc:"用户ID"`
ProductName string `json:"productName" dc:"购买产品"`
OrderSn string `json:"orderSn" dc:"关联订单号"`
Money float64 `json:"money" dc:"充值金额"`
Remark string `json:"remark" dc:"备注"`
Status int `json:"status" dc:"支付状态"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
}
@@ -0,0 +1,47 @@
// Package sysin
// @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 sysin
import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
)
// TreeTableListInp 获取列表
type TreeTableListInp struct {
form.PageReq
form.Sorters
Id int64 `json:"id" description:""`
Flag *gjson.Json `json:"flag" description:"标签"`
Title string `json:"title" description:"标题"`
Content string `json:"content" description:"内容"`
Price []float64 `json:"price" description:"价格"`
ActivityAt *gtime.Time `json:"activityAt" description:"活动时间"`
Switch int `json:"switch" description:"开关"`
Hobby *gjson.Json `json:"hobby" description:"爱好"`
Status int `json:"status" description:"状态"`
CreatedAt []*gtime.Time `json:"createdAt" description:"创建时间"`
Pid int64 `json:"pid" description:"上级ID"`
}
type TreeTableListModel struct {
entity.AddonHgexampleTable
TableCategoryName string `json:"TableCategoryName" description:"分类名称"`
TableCategoryDescription string `json:"TableCategoryDescription" description:"分类描述"`
TableCategoryRemark string `json:"TableCategoryRemark" description:"分类备注"`
SysProvincesTitle string `json:"sysProvincesTitle" description:""`
}
// TableTree 树
type TableTree struct {
entity.AddonHgexampleTable
Key int64 `json:"key" dc:"key"`
Label string `json:"label" dc:"标签"`
Value int64 `json:"value" dc:"键值"`
Children []*TableTree `json:"children"`
}
+9
View File
@@ -0,0 +1,9 @@
// Package queues
// @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 queues
// 消息队列.
// 插件中的消息队列消费者可以统一在这里注册和处理
+36
View File
@@ -0,0 +1,36 @@
// Package router
// @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 router
import (
"context"
"github.com/gogf/gf/v2/net/ghttp"
"hotgo/addons/hgexample/controller/admin/sys"
"hotgo/addons/hgexample/global"
"hotgo/addons/hgexample/router/genrouter"
"hotgo/internal/consts"
"hotgo/internal/library/addons"
"hotgo/internal/service"
)
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.Comp,
sys.Config,
sys.Table,
sys.TreeTable,
)
})
// 注册生成路由
genrouter.Register(ctx, group)
}
+32
View File
@@ -0,0 +1,32 @@
// Package router
// @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 router
import (
"context"
"github.com/gogf/gf/v2/net/ghttp"
"hotgo/addons/hgexample/controller/api"
"hotgo/addons/hgexample/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(
// 无需验证的路由
api.Index,
)
group.Middleware(service.Middleware().ApiAuth)
group.Bind(
// 需要验证的路由
// ...
)
})
}
@@ -0,0 +1,34 @@
// Package genrouter
// @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 genrouter
import (
"context"
"github.com/gogf/gf/v2/net/ghttp"
"hotgo/addons/hgexample/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...)
}
})
}
@@ -0,0 +1,13 @@
// 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
// @AutoGenerate Version 2.13.1
package genrouter
import "hotgo/addons/hgexample/controller/admin/sys"
func init() {
LoginRequiredRouter = append(LoginRequiredRouter, sys.TenantOrder) // 多租户功能演示
}
+25
View File
@@ -0,0 +1,25 @@
// Package router
// @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 router
import (
"context"
"github.com/gogf/gf/v2/net/ghttp"
"hotgo/addons/hgexample/controller/home"
"hotgo/addons/hgexample/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,
)
})
}
@@ -0,0 +1,40 @@
// Package router
// @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 router
import (
"context"
"github.com/gogf/gf/v2/net/ghttp"
"hotgo/addons/hgexample/controller/websocket"
"hotgo/addons/hgexample/controller/websocket/handler"
"hotgo/addons/hgexample/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{
"admin/addons/hgexample/testMessage": handler.Index.TestMessage, // 测试消息
})
}
+139
View File
@@ -0,0 +1,139 @@
// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"hotgo/addons/hgexample/model"
"hotgo/addons/hgexample/model/input/sysin"
"hotgo/internal/library/hgorm/handler"
"github.com/gogf/gf/v2/database/gdb"
)
type (
ISysConfig interface {
// GetBasic 获取基础配置
GetBasic(ctx context.Context) (conf *model.BasicConfig, err error)
// GetConfigByGroup 获取指定分组配置
GetConfigByGroup(ctx context.Context, in *sysin.GetConfigInp) (res *sysin.GetConfigModel, err error)
// UpdateConfigByGroup 更新指定分组的配置
UpdateConfigByGroup(ctx context.Context, in *sysin.UpdateConfigInp) error
}
ISysIndex interface {
// Test 测试
Test(ctx context.Context, in *sysin.IndexTestInp) (res *sysin.IndexTestModel, err error)
}
ISysTable interface {
// Model Orm模型
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
// List 获取列表
List(ctx context.Context, in *sysin.TableListInp) (list []*sysin.TableListModel, totalCount int, err error)
// Export 导出
Export(ctx context.Context, in *sysin.TableListInp) (err error)
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.TableEditInp) (err error)
// Delete 删除
Delete(ctx context.Context, in *sysin.TableDeleteInp) (err error)
// Status 更新状态
Status(ctx context.Context, in *sysin.TableStatusInp) (err error)
// Switch 更新开关状态
Switch(ctx context.Context, in *sysin.TableSwitchInp) (err error)
// MaxSort 最大排序
MaxSort(ctx context.Context, in *sysin.TableMaxSortInp) (res *sysin.TableMaxSortModel, err error)
// View 获取指定信息
View(ctx context.Context, in *sysin.TableViewInp) (res *sysin.TableViewModel, err error)
}
ISysTenantOrder interface {
// Model 多租户功能演示ORM模型
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
// List 获取多租户功能演示列表
List(ctx context.Context, in *sysin.TenantOrderListInp) (list []*sysin.TenantOrderListModel, totalCount int, err error)
// Export 导出多租户功能演示
Export(ctx context.Context, in *sysin.TenantOrderListInp) (err error)
// Edit 修改/新增多租户功能演示
Edit(ctx context.Context, in *sysin.TenantOrderEditInp) (err error)
// Delete 删除多租户功能演示
Delete(ctx context.Context, in *sysin.TenantOrderDeleteInp) (err error)
// View 获取多租户功能演示指定信息
View(ctx context.Context, in *sysin.TenantOrderViewInp) (res *sysin.TenantOrderViewModel, err error)
}
ISysTreeTable interface {
// Model Orm模型
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
// List 获取列表
List(ctx context.Context, in *sysin.TreeTableListInp) (list []*sysin.TreeTableListModel, totalCount int, err error)
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.TableEditInp) (err error)
// Delete 删除
Delete(ctx context.Context, in *sysin.TableDeleteInp) (err error)
// Select 关系树选项列表
Select(ctx context.Context) (list []*sysin.TableTree, err error)
}
)
var (
localSysConfig ISysConfig
localSysIndex ISysIndex
localSysTable ISysTable
localSysTenantOrder ISysTenantOrder
localSysTreeTable ISysTreeTable
)
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 SysTable() ISysTable {
if localSysTable == nil {
panic("implement not found for interface ISysTable, forgot register?")
}
return localSysTable
}
func RegisterSysTable(i ISysTable) {
localSysTable = i
}
func SysTenantOrder() ISysTenantOrder {
if localSysTenantOrder == nil {
panic("implement not found for interface ISysTenantOrder, forgot register?")
}
return localSysTenantOrder
}
func RegisterSysTenantOrder(i ISysTenantOrder) {
localSysTenantOrder = i
}
func SysTreeTable() ISysTreeTable {
if localSysTreeTable == nil {
panic("implement not found for interface ISysTreeTable, forgot register?")
}
return localSysTreeTable
}
func RegisterSysTreeTable(i ISysTreeTable) {
localSysTreeTable = i
}