From bd93d07e1dc68319071d462746ec7d8bb2bf9a31 Mon Sep 17 00:00:00 2001 From: Kevin <77494658+Kevin-Ben@users.noreply.github.com> Date: Sat, 7 Oct 2023 10:20:39 +0800 Subject: [PATCH] * delete hgexample --- server/addons/hgexample/README.MD | 39 --- .../hgexample/api/admin/config/config.go | 30 --- .../addons/hgexample/api/admin/index/index.go | 21 -- .../addons/hgexample/api/admin/table/table.go | 83 ------- .../addons/hgexample/api/api/index/index.go | 21 -- .../addons/hgexample/api/home/index/index.go | 21 -- .../hgexample/api/websocket/index/index.go | 21 -- .../hgexample/controller/admin/sys/config.go | 33 --- .../hgexample/controller/admin/sys/index.go | 30 --- .../hgexample/controller/admin/sys/table.go | 85 ------- .../addons/hgexample/controller/api/index.go | 30 --- .../addons/hgexample/controller/home/index.go | 34 --- .../hgexample/controller/websocket/index.go | 30 --- server/addons/hgexample/crons/crons.go | 9 - server/addons/hgexample/global/global.go | 12 - server/addons/hgexample/global/init.go | 22 -- server/addons/hgexample/logic/.gitkeep | 0 server/addons/hgexample/logic/logic.go | 9 - server/addons/hgexample/logic/sys/config.go | 59 ----- server/addons/hgexample/logic/sys/index.go | 35 --- server/addons/hgexample/logic/sys/table.go | 233 ------------------ server/addons/hgexample/main.go | 92 ------- server/addons/hgexample/model/config.go | 11 - .../hgexample/model/input/sysin/config.go | 24 -- .../hgexample/model/input/sysin/index.go | 27 -- .../hgexample/model/input/sysin/table.go | 180 -------------- server/addons/hgexample/queues/queues.go | 9 - .../addons/hgexample/resource/public/default | 1 - .../resource/template/home/index.html | 32 --- server/addons/hgexample/router/admin.go | 34 --- server/addons/hgexample/router/api.go | 32 --- .../addons/hgexample/router/genrouter/init.go | 34 --- server/addons/hgexample/router/home.go | 25 -- server/addons/hgexample/router/websocket.go | 39 --- server/addons/hgexample/service/.gitkeep | 0 server/addons/hgexample/service/sys.go | 76 ------ server/addons/modules/hgexample.go | 8 - 37 files changed, 1481 deletions(-) delete mode 100644 server/addons/hgexample/README.MD delete mode 100644 server/addons/hgexample/api/admin/config/config.go delete mode 100644 server/addons/hgexample/api/admin/index/index.go delete mode 100644 server/addons/hgexample/api/admin/table/table.go delete mode 100644 server/addons/hgexample/api/api/index/index.go delete mode 100644 server/addons/hgexample/api/home/index/index.go delete mode 100644 server/addons/hgexample/api/websocket/index/index.go delete mode 100644 server/addons/hgexample/controller/admin/sys/config.go delete mode 100644 server/addons/hgexample/controller/admin/sys/index.go delete mode 100644 server/addons/hgexample/controller/admin/sys/table.go delete mode 100644 server/addons/hgexample/controller/api/index.go delete mode 100644 server/addons/hgexample/controller/home/index.go delete mode 100644 server/addons/hgexample/controller/websocket/index.go delete mode 100644 server/addons/hgexample/crons/crons.go delete mode 100644 server/addons/hgexample/global/global.go delete mode 100644 server/addons/hgexample/global/init.go delete mode 100644 server/addons/hgexample/logic/.gitkeep delete mode 100644 server/addons/hgexample/logic/logic.go delete mode 100644 server/addons/hgexample/logic/sys/config.go delete mode 100644 server/addons/hgexample/logic/sys/index.go delete mode 100644 server/addons/hgexample/logic/sys/table.go delete mode 100644 server/addons/hgexample/main.go delete mode 100644 server/addons/hgexample/model/config.go delete mode 100644 server/addons/hgexample/model/input/sysin/config.go delete mode 100644 server/addons/hgexample/model/input/sysin/index.go delete mode 100644 server/addons/hgexample/model/input/sysin/table.go delete mode 100644 server/addons/hgexample/queues/queues.go delete mode 100644 server/addons/hgexample/resource/public/default delete mode 100644 server/addons/hgexample/resource/template/home/index.html delete mode 100644 server/addons/hgexample/router/admin.go delete mode 100644 server/addons/hgexample/router/api.go delete mode 100644 server/addons/hgexample/router/genrouter/init.go delete mode 100644 server/addons/hgexample/router/home.go delete mode 100644 server/addons/hgexample/router/websocket.go delete mode 100644 server/addons/hgexample/service/.gitkeep delete mode 100644 server/addons/hgexample/service/sys.go delete mode 100644 server/addons/modules/hgexample.go diff --git a/server/addons/hgexample/README.MD b/server/addons/hgexample/README.MD deleted file mode 100644 index ae0adeb..0000000 --- a/server/addons/hgexample/README.MD +++ /dev/null @@ -1,39 +0,0 @@ -## 功能案例 - -### 简介 - -系统的一些功能案例 - - -### 使用说明 - -系统自带的功能使用示例及其说明,包含一些简单的交互 - - -### 安装 - -1、安装 HotGo (2.1.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 - -``` diff --git a/server/addons/hgexample/api/admin/config/config.go b/server/addons/hgexample/api/admin/config/config.go deleted file mode 100644 index 83b431f..0000000 --- a/server/addons/hgexample/api/admin/config/config.go +++ /dev/null @@ -1,30 +0,0 @@ -// 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 { -} diff --git a/server/addons/hgexample/api/admin/index/index.go b/server/addons/hgexample/api/admin/index/index.go deleted file mode 100644 index 764eaa8..0000000 --- a/server/addons/hgexample/api/admin/index/index.go +++ /dev/null @@ -1,21 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/api/admin/table/table.go b/server/addons/hgexample/api/admin/table/table.go deleted file mode 100644 index 32f8b85..0000000 --- a/server/addons/hgexample/api/admin/table/table.go +++ /dev/null @@ -1,83 +0,0 @@ -// 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{} diff --git a/server/addons/hgexample/api/api/index/index.go b/server/addons/hgexample/api/api/index/index.go deleted file mode 100644 index 764eaa8..0000000 --- a/server/addons/hgexample/api/api/index/index.go +++ /dev/null @@ -1,21 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/api/home/index/index.go b/server/addons/hgexample/api/home/index/index.go deleted file mode 100644 index 3a876ed..0000000 --- a/server/addons/hgexample/api/home/index/index.go +++ /dev/null @@ -1,21 +0,0 @@ -// 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" summary:"功能案例" tags:"测试首页"` - sysin.IndexTestInp -} - -type TestRes struct { - g.Meta `mime:"text/html" type:"string" example:"
"` -} diff --git a/server/addons/hgexample/api/websocket/index/index.go b/server/addons/hgexample/api/websocket/index/index.go deleted file mode 100644 index 764eaa8..0000000 --- a/server/addons/hgexample/api/websocket/index/index.go +++ /dev/null @@ -1,21 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/controller/admin/sys/config.go b/server/addons/hgexample/controller/admin/sys/config.go deleted file mode 100644 index ef40a69..0000000 --- a/server/addons/hgexample/controller/admin/sys/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/controller/admin/sys/index.go b/server/addons/hgexample/controller/admin/sys/index.go deleted file mode 100644 index b378b1d..0000000 --- a/server/addons/hgexample/controller/admin/sys/index.go +++ /dev/null @@ -1,30 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/controller/admin/sys/table.go b/server/addons/hgexample/controller/admin/sys/table.go deleted file mode 100644 index 03188cf..0000000 --- a/server/addons/hgexample/controller/admin/sys/table.go +++ /dev/null @@ -1,85 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/controller/api/index.go b/server/addons/hgexample/controller/api/index.go deleted file mode 100644 index c604f1d..0000000 --- a/server/addons/hgexample/controller/api/index.go +++ /dev/null @@ -1,30 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/controller/home/index.go b/server/addons/hgexample/controller/home/index.go deleted file mode 100644 index 668fc74..0000000 --- a/server/addons/hgexample/controller/home/index.go +++ /dev/null @@ -1,34 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/controller/websocket/index.go b/server/addons/hgexample/controller/websocket/index.go deleted file mode 100644 index 37b9bbf..0000000 --- a/server/addons/hgexample/controller/websocket/index.go +++ /dev/null @@ -1,30 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/crons/crons.go b/server/addons/hgexample/crons/crons.go deleted file mode 100644 index e20bf6c..0000000 --- a/server/addons/hgexample/crons/crons.go +++ /dev/null @@ -1,9 +0,0 @@ -// 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 - -// 定时任务. -// 插件中的定时任务可以统一在这里注册和处理 diff --git a/server/addons/hgexample/global/global.go b/server/addons/hgexample/global/global.go deleted file mode 100644 index f549f88..0000000 --- a/server/addons/hgexample/global/global.go +++ /dev/null @@ -1,12 +0,0 @@ -// 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 // 插件架子 -) diff --git a/server/addons/hgexample/global/init.go b/server/addons/hgexample/global/init.go deleted file mode 100644 index 9db6de9..0000000 --- a/server/addons/hgexample/global/init.go +++ /dev/null @@ -1,22 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/logic/.gitkeep b/server/addons/hgexample/logic/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/server/addons/hgexample/logic/logic.go b/server/addons/hgexample/logic/logic.go deleted file mode 100644 index cc557f4..0000000 --- a/server/addons/hgexample/logic/logic.go +++ /dev/null @@ -1,9 +0,0 @@ -// ========================================================================== -// Code generated by GoFrame CLI tool. DO NOT EDIT. -// ========================================================================== - -package logic - -import ( - _ "hotgo/addons/hgexample/logic/sys" -) diff --git a/server/addons/hgexample/logic/sys/config.go b/server/addons/hgexample/logic/sys/config.go deleted file mode 100644 index 73620b2..0000000 --- a/server/addons/hgexample/logic/sys/config.go +++ /dev/null @@ -1,59 +0,0 @@ -// 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) -} diff --git a/server/addons/hgexample/logic/sys/index.go b/server/addons/hgexample/logic/sys/index.go deleted file mode 100644 index d3e8ccd..0000000 --- a/server/addons/hgexample/logic/sys/index.go +++ /dev/null @@ -1,35 +0,0 @@ -// 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 -} diff --git a/server/addons/hgexample/logic/sys/table.go b/server/addons/hgexample/logic/sys/table.go deleted file mode 100644 index ebf8c4b..0000000 --- a/server/addons/hgexample/logic/sys/table.go +++ /dev/null @@ -1,233 +0,0 @@ -// 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(1) - 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) + ".xlsx" - 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).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 -} diff --git a/server/addons/hgexample/main.go b/server/addons/hgexample/main.go deleted file mode 100644 index 97af95f..0000000 --- a/server/addons/hgexample/main.go +++ /dev/null @@ -1,92 +0,0 @@ -// 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) -} - -// Init 初始化 -func (m *module) Init(ctx context.Context) { - global.Init(ctx, m.skeleton) - // ... -} - -// InitRouter 初始化WEB路由 -func (m *module) InitRouter(ctx context.Context, group *ghttp.RouterGroup) { - m.Init(ctx) - group.Middleware(service.Middleware().Addon) - router.Admin(ctx, group) - router.Api(ctx, group) - router.Home(ctx, group) - router.WebSocket(ctx, group) -} - -// 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 -} diff --git a/server/addons/hgexample/model/config.go b/server/addons/hgexample/model/config.go deleted file mode 100644 index 7496b4b..0000000 --- a/server/addons/hgexample/model/config.go +++ /dev/null @@ -1,11 +0,0 @@ -// 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"` -} diff --git a/server/addons/hgexample/model/input/sysin/config.go b/server/addons/hgexample/model/input/sysin/config.go deleted file mode 100644 index 05c4fc1..0000000 --- a/server/addons/hgexample/model/input/sysin/config.go +++ /dev/null @@ -1,24 +0,0 @@ -// 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"` -} diff --git a/server/addons/hgexample/model/input/sysin/index.go b/server/addons/hgexample/model/input/sysin/index.go deleted file mode 100644 index 8e19ad5..0000000 --- a/server/addons/hgexample/model/input/sysin/index.go +++ /dev/null @@ -1,27 +0,0 @@ -// 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:"当前时间"` -} diff --git a/server/addons/hgexample/model/input/sysin/table.go b/server/addons/hgexample/model/input/sysin/table.go deleted file mode 100644 index e8d9f58..0000000 --- a/server/addons/hgexample/model/input/sysin/table.go +++ /dev/null @@ -1,180 +0,0 @@ -// 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{} diff --git a/server/addons/hgexample/queues/queues.go b/server/addons/hgexample/queues/queues.go deleted file mode 100644 index 9f2e7eb..0000000 --- a/server/addons/hgexample/queues/queues.go +++ /dev/null @@ -1,9 +0,0 @@ -// 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 - -// 消息队列. -// 插件中的消息队列消费者可以统一在这里注册和处理 diff --git a/server/addons/hgexample/resource/public/default b/server/addons/hgexample/resource/public/default deleted file mode 100644 index 52e122c..0000000 --- a/server/addons/hgexample/resource/public/default +++ /dev/null @@ -1 +0,0 @@ -Hello!这是创建插件 [功能案例] 时默认生成的一个静态目录文件,用于测试,当你看到这个提示时,说明已经联调成功啦! diff --git a/server/addons/hgexample/resource/template/home/index.html b/server/addons/hgexample/resource/template/home/index.html deleted file mode 100644 index c4754c0..0000000 --- a/server/addons/hgexample/resource/template/home/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - -Hello,@{.Data.name}!!
-@{.Data.module}
-服务器时间:@{.Data.time}
-