im 管理后台
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// Package cmd
|
||||
// @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 cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Auth = &gcmd.Command{
|
||||
Name: "auth",
|
||||
Brief: "系统授权,当为第三方客户开发应用项目不想将源码和可执行文件让其随意使用时,可以通过授权的方式约束使用方。",
|
||||
Description: `目前已实现,一对一、一对多、有效期授权,具体使用可以参考现有逻辑结合实际场景进行改造`,
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
service.AuthClient().Start(ctx)
|
||||
|
||||
serverWg.Add(1)
|
||||
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
|
||||
<-serverCloseSignal
|
||||
service.AuthClient().Stop(ctx)
|
||||
g.Log().Debug(ctx, "auth successfully closed ..")
|
||||
serverWg.Done()
|
||||
return
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,86 @@
|
||||
// Package cmd
|
||||
// @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 cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"hotgo/utility/simple"
|
||||
)
|
||||
|
||||
var (
|
||||
Main = &gcmd.Command{
|
||||
Description: `默认启动所有服务`,
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
return All.Func(ctx, parser)
|
||||
},
|
||||
}
|
||||
|
||||
Help = &gcmd.Command{
|
||||
Name: "help",
|
||||
Brief: "查看帮助",
|
||||
Description: `
|
||||
命令提示符
|
||||
---------------------------------------------------------------------------------
|
||||
启动服务
|
||||
>> 所有服务 [go run main.go] 热编译 [gf run main.go]
|
||||
>> HTTP服务 [go run main.go http]
|
||||
>> 消息队列 [go run main.go queue]
|
||||
>> 定时任务 [go run main.go cron]
|
||||
>> 查看帮助 [go run main.go help]
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
工具
|
||||
>> 释放casbin权限,用于清理无效的权限设置 [go run main.go tools -m=casbin -a1=refresh]
|
||||
>> 打印所有打包的资源文件列表 [go run main.go tools -m=gres -a1=dump]
|
||||
>> 打印指定打包的资源文件内容 [go run main.go tools -m=gres -a1=content -a2=resource/template/home/index.html]
|
||||
---------------------------------------------------------------------------------
|
||||
升级更新
|
||||
>> 修复菜单关系树 [go run main.go up -m=fix -a1=menuTree]
|
||||
---------------------------------------------------------------------------------
|
||||
更多
|
||||
github地址:https://github.com/bufanyun/hotgo
|
||||
文档地址:https://github.com/bufanyun/hotgo/tree/v2.0/docs/guide-zh-CN
|
||||
HotGo框架交流1群:190966648
|
||||
`,
|
||||
}
|
||||
|
||||
All = &gcmd.Command{
|
||||
Name: "all",
|
||||
Brief: "start all server",
|
||||
Description: "this is the command entry for starting all server",
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
g.Log().Debug(ctx, "starting all server")
|
||||
|
||||
// 需要启动的服务
|
||||
var allServers = []*gcmd.Command{Http, Queue, Cron}
|
||||
|
||||
for _, server := range allServers {
|
||||
var cmd = server
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
if err := cmd.Func(ctx, parser); err != nil {
|
||||
g.Log().Fatalf(ctx, "%v start fail:%v", cmd.Name, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
|
||||
<-serverCloseSignal
|
||||
serverWg.Wait()
|
||||
g.Log().Debug(ctx, "all service successfully closed ..")
|
||||
return
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
if err := Main.AddCommand(All, Http, Queue, Cron, Auth, Tools, Up, Help); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Package cmd
|
||||
// @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 cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
_ "hotgo/internal/crons"
|
||||
"hotgo/internal/global"
|
||||
"hotgo/internal/library/cron"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Cron = &gcmd.Command{
|
||||
Name: "cron",
|
||||
Brief: "定时任务,用来部署一些可独立运行的定时任务,通过tcp方式和后台保持长连接通讯,动态调整任务属性。",
|
||||
Description: ``,
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
// 服务日志处理
|
||||
cron.Logger().SetHandlers(global.LoggingServeLogHandler)
|
||||
|
||||
// 启动定时任务
|
||||
service.SysCron().StartCron(ctx)
|
||||
|
||||
// tcp客户端
|
||||
service.CronClient().Start(ctx)
|
||||
|
||||
serverWg.Add(1)
|
||||
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
|
||||
<-serverCloseSignal
|
||||
service.CronClient().Stop(ctx)
|
||||
cron.StopALL()
|
||||
cron.Logger().Debug(ctx, "cron successfully closed ..")
|
||||
serverWg.Done()
|
||||
return
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,44 @@
|
||||
// Package cmd
|
||||
// @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 cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/gproc"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/utility/simple"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
serverCloseSignal = make(chan struct{}, 1)
|
||||
serverWg = sync.WaitGroup{}
|
||||
once sync.Once
|
||||
)
|
||||
|
||||
// signalHandlerForOverall 关闭信号处理
|
||||
func signalHandlerForOverall(sig os.Signal) {
|
||||
serverCloseEvent(gctx.GetInitCtx())
|
||||
serverCloseSignal <- struct{}{}
|
||||
}
|
||||
|
||||
// signalListen 信号监听
|
||||
func signalListen(ctx context.Context, handler ...gproc.SigHandler) {
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
gproc.AddSigHandlerShutdown(handler...)
|
||||
gproc.Listen()
|
||||
})
|
||||
}
|
||||
|
||||
// serverCloseEvent 关闭事件
|
||||
// 区别于服务收到退出信号后的处理,只会执行一次
|
||||
func serverCloseEvent(ctx context.Context) {
|
||||
once.Do(func() {
|
||||
simple.Event().Call(consts.EventServerClose, ctx)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// Package cmd
|
||||
// @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 cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"github.com/gogf/gf/v2/util/gmode"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/library/casbin"
|
||||
"hotgo/internal/library/hggen"
|
||||
"hotgo/internal/router"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/internal/websocket"
|
||||
)
|
||||
|
||||
var (
|
||||
Http = &gcmd.Command{
|
||||
Name: "http",
|
||||
Usage: "http",
|
||||
Brief: "HTTP服务,也可以称为主服务,包含http、websocket、tcpserver多个可对外服务",
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
// 初始化http服务
|
||||
s := g.Server()
|
||||
|
||||
// 初始化请求前回调
|
||||
s.BindHookHandler("/*any", ghttp.HookBeforeServe, service.Hook().BeforeServe)
|
||||
|
||||
// 请求响应结束后回调
|
||||
s.BindHookHandler("/*any", ghttp.HookAfterOutput, service.Hook().AfterOutput)
|
||||
|
||||
// 注册全局中间件
|
||||
s.BindMiddleware("/*any", []ghttp.HandlerFunc{
|
||||
service.Middleware().Ctx, // 初始化请求上下文,一般需要第一个进行加载,后续中间件存在依赖关系
|
||||
service.Middleware().CORS, // 跨域中间件,自动处理跨域问题
|
||||
service.Middleware().Blacklist, // IP黑名单中间件,如果请求IP被后台拉黑,所有请求将被拒绝
|
||||
service.Middleware().DemoLimit, // 演示系統操作限制,当开启演示模式时,所有POST请求将被拒绝
|
||||
service.Middleware().PreFilter, // 请求输入预处理,api使用gf规范路由并且XxxReq结构体实现了validate.Filter接口即可隐式预处理
|
||||
service.Middleware().ResponseHandler, // HTTP响应预处理,在业务处理完成后,对响应结果进行格式化和错误过滤,将处理后的数据发送给请求方
|
||||
}...)
|
||||
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
// 注册后台路由
|
||||
router.Admin(ctx, group)
|
||||
|
||||
// 注册Api路由
|
||||
router.Api(ctx, group)
|
||||
|
||||
// 注册websocket路由
|
||||
router.WebSocket(ctx, group)
|
||||
|
||||
// 注册前台页面路由
|
||||
router.Home(ctx, group)
|
||||
})
|
||||
|
||||
// 启动插件
|
||||
if err = addons.StartModules(ctx, &addons.Option{Server: s}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 初始化casbin权限
|
||||
casbin.InitEnforcer(ctx)
|
||||
|
||||
// 初始化生成代码配置
|
||||
if !gmode.IsProduct() {
|
||||
hggen.InIt(ctx)
|
||||
}
|
||||
|
||||
// 启动tcp服务
|
||||
service.TCPServer().Start(ctx)
|
||||
|
||||
// 启动服务监控
|
||||
service.AdminMonitor().StartMonitor(ctx)
|
||||
|
||||
// 加载ip访问黑名单
|
||||
service.SysBlacklist().Load(ctx)
|
||||
|
||||
// 注册支付成功回调方法
|
||||
service.Pay().RegisterNotifyCall()
|
||||
|
||||
serverWg.Add(1)
|
||||
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
|
||||
go func() {
|
||||
<-serverCloseSignal
|
||||
websocket.Stop() // 关闭websocket
|
||||
service.TCPServer().Stop(ctx) // 关闭tcp服务器
|
||||
addons.StopModules(ctx) // 停止插件
|
||||
_ = s.Shutdown() // 关闭http服务,主服务建议放在最后一个关闭
|
||||
g.Log().Debug(ctx, "http successfully closed ..")
|
||||
serverWg.Done()
|
||||
}()
|
||||
|
||||
// Just run the server.
|
||||
s.Run()
|
||||
return
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,43 @@
|
||||
// Package cmd
|
||||
// @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 cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"hotgo/internal/global"
|
||||
"hotgo/internal/library/queue"
|
||||
_ "hotgo/internal/queues"
|
||||
"hotgo/utility/simple"
|
||||
)
|
||||
|
||||
var (
|
||||
Queue = &gcmd.Command{
|
||||
Name: "queue",
|
||||
Brief: "消息队列",
|
||||
Description: ``,
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
// 服务日志处理
|
||||
queue.Logger().SetHandlers(global.LoggingServeLogHandler)
|
||||
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
queue.Logger().Debug(ctx, "start queue consumer..")
|
||||
queue.StartConsumersListener(ctx)
|
||||
queue.Logger().Debug(ctx, "start queue consumer success..")
|
||||
})
|
||||
|
||||
serverWg.Add(1)
|
||||
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
|
||||
<-serverCloseSignal
|
||||
queue.Logger().Debug(ctx, "queue successfully closed ..")
|
||||
serverWg.Done()
|
||||
return
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,107 @@
|
||||
// Package cmd
|
||||
// @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 cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"github.com/gogf/gf/v2/os/gres"
|
||||
"hotgo/internal/library/casbin"
|
||||
)
|
||||
|
||||
var (
|
||||
Tools = &gcmd.Command{
|
||||
Name: "tools",
|
||||
Brief: "常用工具",
|
||||
Description: ``,
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
args := parser.GetOptAll()
|
||||
g.Log().Debugf(ctx, "tools args:%v", args)
|
||||
if len(args) == 0 {
|
||||
err = gerror.New("tools args cannot be empty.")
|
||||
return
|
||||
}
|
||||
|
||||
method, ok := args["m"]
|
||||
if !ok {
|
||||
err = gerror.New("tools method cannot be empty.")
|
||||
return
|
||||
}
|
||||
|
||||
switch method {
|
||||
case "casbin":
|
||||
err = handleCasbin(ctx, args)
|
||||
case "gres":
|
||||
err = handleGRes(ctx, args)
|
||||
default:
|
||||
err = gerror.Newf("tools method[%v] does not exist", method)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
g.Log().Info(ctx, "tools exec successful!")
|
||||
}
|
||||
return
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// handleCasbin casbin.
|
||||
func handleCasbin(ctx context.Context, args map[string]string) (err error) {
|
||||
a1, ok := args["a1"]
|
||||
if !ok {
|
||||
err = gerror.New("casbin args cannot be empty.")
|
||||
return
|
||||
}
|
||||
|
||||
casbin.InitEnforcer(ctx)
|
||||
switch a1 {
|
||||
case "clear":
|
||||
err = casbin.Clear(ctx)
|
||||
case "refresh":
|
||||
err = casbin.Refresh(ctx)
|
||||
default:
|
||||
err = gerror.Newf("casbin a1 is invalid, a1:%v", a1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func handleGRes(ctx context.Context, args map[string]string) (err error) {
|
||||
a1, ok := args["a1"]
|
||||
if !ok {
|
||||
err = gerror.New("gres args cannot be empty.")
|
||||
return
|
||||
}
|
||||
|
||||
switch a1 {
|
||||
case "dump":
|
||||
gres.Dump()
|
||||
case "content":
|
||||
path, ok := args["a2"]
|
||||
if !ok {
|
||||
err = gerror.New("缺少查看文件路径参数:`a2`")
|
||||
return
|
||||
}
|
||||
|
||||
if !gres.Contains(path) {
|
||||
err = gerror.Newf("没有找到资源文件:%v", path)
|
||||
return
|
||||
}
|
||||
content := string(gres.GetContent(path))
|
||||
|
||||
if len(content) == 0 {
|
||||
err = gerror.Newf("没有找到资源文件内容,请确认传入`a2`参数是一个文件,a2:%v", path)
|
||||
return
|
||||
}
|
||||
fmt.Println("以下是资源文件内容:")
|
||||
fmt.Println(content)
|
||||
default:
|
||||
err = gerror.Newf("handleGRes a1 is invalid, a1:%v", a1)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// Package cmd
|
||||
// @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 cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"hotgo/internal/cmd/upgrade/fix"
|
||||
)
|
||||
|
||||
var (
|
||||
Up = &gcmd.Command{
|
||||
Name: "up",
|
||||
Brief: "处理hotgo版本升级更新带来的兼容问题",
|
||||
Description: ``,
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
args := parser.GetOptAll()
|
||||
g.Log().Debugf(ctx, "up args:%v", args)
|
||||
if len(args) == 0 {
|
||||
err = gerror.New("up args cannot be empty.")
|
||||
return
|
||||
}
|
||||
|
||||
method, ok := args["m"]
|
||||
if !ok {
|
||||
err = gerror.New("up method cannot be empty.")
|
||||
return
|
||||
}
|
||||
|
||||
switch method {
|
||||
case "fix":
|
||||
err = handleUpgradeFix(ctx, args)
|
||||
default:
|
||||
err = gerror.Newf("up method[%v] does not exist", method)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
g.Log().Info(ctx, "up exec successful!")
|
||||
}
|
||||
return
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// handleUpgradeFix 处理修复脚本
|
||||
func handleUpgradeFix(ctx context.Context, args map[string]string) (err error) {
|
||||
a1, ok := args["a1"]
|
||||
if !ok {
|
||||
err = gerror.New("fix args cannot be empty.")
|
||||
return
|
||||
}
|
||||
|
||||
switch a1 {
|
||||
case "menuTree":
|
||||
fix.UpdateAdminMenuTree(ctx)
|
||||
default:
|
||||
err = gerror.Newf("fix a1 is invalid, a1:%v", a1)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Package fix
|
||||
// @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 fix
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/hgorm"
|
||||
"hotgo/internal/model/entity"
|
||||
)
|
||||
|
||||
// UpdateAdminMenuTree 更新菜单关系树
|
||||
// 根据树等级从上到下依次检查,将无效的关系树进行修复更新
|
||||
func UpdateAdminMenuTree(ctx context.Context) {
|
||||
var list []*entity.AdminMenu
|
||||
err := dao.AdminMenu.Ctx(ctx).OrderAsc("level").Scan(&list)
|
||||
if err != nil {
|
||||
g.Log().Fatal(ctx, err)
|
||||
}
|
||||
|
||||
genUpdateData := func(v *entity.AdminMenu) g.Map {
|
||||
update := g.Map{"updated_at": gtime.Now()}
|
||||
if v.Pid <= 0 {
|
||||
update["level"] = 1
|
||||
update["tree"] = ""
|
||||
return update
|
||||
}
|
||||
|
||||
// 生成下级关系树
|
||||
update["pid"], update["level"], update["tree"], err = hgorm.GenSubTree(ctx, &dao.AdminMenu, v.Pid)
|
||||
return update
|
||||
}
|
||||
|
||||
for _, v := range list {
|
||||
update := genUpdateData(v)
|
||||
if v.Level == update["level"] && v.Tree == update["tree"] {
|
||||
continue
|
||||
}
|
||||
if _, err = dao.AdminMenu.Ctx(ctx).WherePri(v.Id).Data(genUpdateData(v)).Update(); err != nil {
|
||||
g.Log().Fatal(ctx, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("addonsGroupOptions", "插件分组", AddonsGroupOptions)
|
||||
dict.RegisterEnums("addonsInstallStatus", "插件安装状态", AddonsInstallStatusOptions)
|
||||
dict.RegisterEnums("addonsExtend", "插件扩展", AddonsExtendOptions)
|
||||
}
|
||||
|
||||
const (
|
||||
AddonsTag = "addons_" // 插件标签前缀
|
||||
AddonsDir = "addons" // 插件路径
|
||||
)
|
||||
|
||||
const (
|
||||
AddonsGroupPlug = 1 // 功能扩展
|
||||
AddonsGroupBusiness = 2 // 主要业务
|
||||
AddonsGroupThirdParty = 3 // 第三方插件
|
||||
AddonsGroupMiniApp = 4 // 小程序
|
||||
AddonsGroupCustomer = 5 // 客户关系
|
||||
AddonsGroupActivity = 6 // 营销及活动
|
||||
AddonsGroupServices = 7 // 常用服务及工具
|
||||
AddonsGroupBiz = 8 // 行业解决方案
|
||||
)
|
||||
|
||||
// AddonsGroupOptions 插件分组选项
|
||||
var AddonsGroupOptions = []*model.Option{
|
||||
dict.GenInfoOption(AddonsGroupPlug, "功能扩展"),
|
||||
dict.GenInfoOption(AddonsGroupBusiness, "主要业务"),
|
||||
dict.GenInfoOption(AddonsGroupThirdParty, "第三方插件"),
|
||||
dict.GenInfoOption(AddonsGroupMiniApp, "小程序"),
|
||||
dict.GenInfoOption(AddonsGroupCustomer, "客户关系"),
|
||||
dict.GenInfoOption(AddonsGroupActivity, "营销及活动"),
|
||||
dict.GenInfoOption(AddonsGroupServices, "常用服务及工具"),
|
||||
dict.GenInfoOption(AddonsGroupBiz, "行业解决方案"),
|
||||
}
|
||||
|
||||
var AddonsGroupIconMap = map[int]string{
|
||||
AddonsGroupPlug: "AppstoreAddOutlined",
|
||||
AddonsGroupBusiness: "FireOutlined",
|
||||
AddonsGroupThirdParty: "ApiOutlined",
|
||||
AddonsGroupMiniApp: "RocketOutlined",
|
||||
AddonsGroupCustomer: "UserSwitchOutlined",
|
||||
AddonsGroupActivity: "TagOutlined",
|
||||
AddonsGroupServices: "ToolOutlined",
|
||||
AddonsGroupBiz: "CheckCircleOutlined",
|
||||
}
|
||||
|
||||
const (
|
||||
AddonsInstallStatusOk = 1 // 已安装
|
||||
AddonsInstallStatusNo = 2 // 未安装
|
||||
AddonsInstallStatusUn = 3 // 已卸载
|
||||
)
|
||||
|
||||
// AddonsInstallStatusOptions 插件安装状态
|
||||
var AddonsInstallStatusOptions = []*model.Option{
|
||||
dict.GenInfoOption(AddonsInstallStatusOk, "已安装"),
|
||||
dict.GenInfoOption(AddonsInstallStatusNo, "未安装"),
|
||||
dict.GenInfoOption(AddonsInstallStatusUn, "已卸载"),
|
||||
}
|
||||
|
||||
const (
|
||||
AddonsExtendResourcePublic = "resourcePublic"
|
||||
AddonsExtendResourceTemplate = "resourceTemplate"
|
||||
)
|
||||
|
||||
// AddonsExtendOptions 插件扩展选项
|
||||
var AddonsExtendOptions = []*model.Option{
|
||||
dict.GenInfoOption(AddonsExtendResourcePublic, "创建静态目录"),
|
||||
dict.GenInfoOption(AddonsExtendResourceTemplate, "创建模板目录"),
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// 应用类型
|
||||
const (
|
||||
AppAdmin = "admin"
|
||||
AppApi = "api"
|
||||
AppHome = "home"
|
||||
AppWebSocket = "websocket"
|
||||
AppDefault = "default"
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// cache
|
||||
const (
|
||||
CacheToken = "token" // 登录token
|
||||
CacheTokenBind = "token_bind" // 登录用户身份绑定
|
||||
CacheMultipartUpload = "multipart_upload" // 分片上传
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
package consts
|
||||
|
||||
const (
|
||||
CaptchaTypeString = iota + 1 // 字符串
|
||||
CaptchaTypeMath // 数字计算
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// 提现状态
|
||||
const (
|
||||
CashStatusWait = 1 // 处理中
|
||||
CashStatusOk = 2 // 提现成功
|
||||
CashStatusFail = 3 // 提现异常
|
||||
)
|
||||
@@ -0,0 +1,117 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
// RequestEncryptKey
|
||||
// 请求加密密钥用于敏感数据加密,16位字符,前后端需保持一致
|
||||
// 安全起见,生产环境运行时请注意修改
|
||||
var RequestEncryptKey = []byte("f080a463654b2279")
|
||||
|
||||
// 配置数据类型
|
||||
const (
|
||||
ConfigTypeString = "string"
|
||||
ConfigTypeInt = "int"
|
||||
ConfigTypeInt8 = "int8"
|
||||
ConfigTypeInt16 = "int16"
|
||||
ConfigTypeInt32 = "int32"
|
||||
ConfigTypeInt64 = "int64"
|
||||
ConfigTypeUint = "uint"
|
||||
ConfigTypeUint8 = "uint8"
|
||||
ConfigTypeUint16 = "uint16"
|
||||
ConfigTypeUint32 = "uint32"
|
||||
ConfigTypeUint64 = "uint64"
|
||||
ConfigTypeFloat32 = "float32"
|
||||
ConfigTypeFloat64 = "float64"
|
||||
ConfigTypeBool = "bool"
|
||||
ConfigTypeDate = "date"
|
||||
ConfigTypeDateTime = "datetime"
|
||||
ConfigTypeSliceString = "[]string"
|
||||
ConfigTypeSliceInt = "[]int"
|
||||
ConfigTypeSliceInt64 = "[]int64"
|
||||
)
|
||||
|
||||
var ConfigTypes = []string{ConfigTypeString,
|
||||
ConfigTypeInt, ConfigTypeInt8, ConfigTypeInt16, ConfigTypeInt32, ConfigTypeInt64,
|
||||
ConfigTypeUint, ConfigTypeUint8, ConfigTypeUint16, ConfigTypeUint32, ConfigTypeUint64,
|
||||
ConfigTypeFloat32, ConfigTypeFloat64,
|
||||
ConfigTypeBool,
|
||||
ConfigTypeDate, ConfigTypeDateTime,
|
||||
ConfigTypeSliceString, ConfigTypeSliceInt, ConfigTypeSliceInt64,
|
||||
}
|
||||
|
||||
// ConfigMaskDemoField 演示环境下需要隐藏的配置
|
||||
var ConfigMaskDemoField = map[string]struct{}{
|
||||
// 邮箱
|
||||
"smtpUser": {}, "smtpPass": {},
|
||||
|
||||
// 云存储
|
||||
"uploadUCloudPublicKey": {}, "uploadUCloudPrivateKey": {}, "uploadCosSecretId": {}, "uploadCosSecretKey": {},
|
||||
"uploadOssSecretId": {}, "uploadOssSecretKey": {}, "uploadQiNiuAccessKey": {}, "uploadQiNiuSecretKey": {},
|
||||
|
||||
// 地图
|
||||
"geoAmapWebKey": {},
|
||||
|
||||
// 短信
|
||||
"smsAliYunAccessKeyID": {}, "smsAliYunAccessKeySecret": {}, "smsTencentSecretId": {}, "smsTencentSecretKey": {},
|
||||
|
||||
// 支付
|
||||
"payWxPayMchId": {}, "payWxPaySerialNo": {}, "payWxPayAPIv3Key": {}, "payWxPayPrivateKey": {}, "payQQPayMchId": {}, "payQQPayApiKey": {},
|
||||
|
||||
// 微信
|
||||
"officialAccountAppSecret": {}, "officialAccountToken": {}, "officialAccountEncodingAESKey": {}, "openPlatformAppSecret": {},
|
||||
"openPlatformToken": {}, "openPlatformEncodingAESKey": {},
|
||||
}
|
||||
|
||||
// ConvType 类型转换
|
||||
func ConvType(val interface{}, t string) interface{} {
|
||||
switch t {
|
||||
case ConfigTypeString:
|
||||
val = gconv.String(val)
|
||||
case ConfigTypeInt:
|
||||
val = gconv.Int(val)
|
||||
case ConfigTypeInt8:
|
||||
val = gconv.Int8(val)
|
||||
case ConfigTypeInt16:
|
||||
val = gconv.Int16(val)
|
||||
case ConfigTypeInt32:
|
||||
val = gconv.Int32(val)
|
||||
case ConfigTypeInt64:
|
||||
val = gconv.Int64(val)
|
||||
case ConfigTypeUint:
|
||||
val = gconv.Uint(val)
|
||||
case ConfigTypeUint8:
|
||||
val = gconv.Uint8(val)
|
||||
case ConfigTypeUint16:
|
||||
val = gconv.Uint16(val)
|
||||
case ConfigTypeUint32:
|
||||
val = gconv.Uint32(val)
|
||||
case ConfigTypeUint64:
|
||||
val = gconv.Uint64(val)
|
||||
case ConfigTypeFloat32:
|
||||
val = gconv.Float32(val)
|
||||
case ConfigTypeFloat64:
|
||||
val = gconv.Float64(val)
|
||||
case ConfigTypeBool:
|
||||
val = gconv.Bool(val)
|
||||
case ConfigTypeDate:
|
||||
val = gconv.Time(val, "Y-m-d")
|
||||
case ConfigTypeDateTime:
|
||||
val = gconv.Time(val, "Y-m-d H:i:s")
|
||||
case ConfigTypeSliceInt:
|
||||
val = gconv.SliceInt(val)
|
||||
case ConfigTypeSliceInt64:
|
||||
val = gconv.SliceInt64(val)
|
||||
case ConfigTypeSliceString:
|
||||
val = gconv.SliceStr(val)
|
||||
default:
|
||||
val = gconv.String(val)
|
||||
}
|
||||
return val
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
type CtxKey string
|
||||
|
||||
// ContextKey 上下文
|
||||
const (
|
||||
ContextHTTPKey CtxKey = "httpContext" // http上下文变量名称
|
||||
ContextKeyCronArgs CtxKey = "cronArgs" // 定时任务参数
|
||||
ContextKeyCronSn CtxKey = "cronSn" // 定时任务序列号
|
||||
)
|
||||
@@ -0,0 +1,48 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("creditType", "资金变动类型", CreditTypeOptions)
|
||||
dict.RegisterEnums("creditGroup", "资金变动分组", CreditGroupOptions)
|
||||
}
|
||||
|
||||
const (
|
||||
CreditTypeBalance = "balance" // 余额
|
||||
CreditTypeIntegral = "integral" // 积分
|
||||
)
|
||||
|
||||
const (
|
||||
CreditGroupDecr = "decr" // 扣款
|
||||
CreditGroupIncr = "incr" // 加款
|
||||
CreditGroupOpDecr = "op_decr" // 操作扣款
|
||||
CreditGroupOpIncr = "op_incr" // 操作加款
|
||||
CreditGroupBalanceRecharge = "balance_recharge" // 余额充值
|
||||
CreditGroupBalanceRefund = "balance_refund" // 余额退款
|
||||
CreditGroupApplyCash = "apply_cash" // 申请提现
|
||||
)
|
||||
|
||||
// CreditTypeOptions 变动类型
|
||||
var CreditTypeOptions = []*model.Option{
|
||||
dict.GenSuccessOption(CreditTypeBalance, "余额"),
|
||||
dict.GenInfoOption(CreditTypeIntegral, "积分"),
|
||||
}
|
||||
|
||||
// CreditGroupOptions 变动分组
|
||||
var CreditGroupOptions = []*model.Option{
|
||||
dict.GenWarningOption(CreditGroupDecr, "扣款"),
|
||||
dict.GenSuccessOption(CreditGroupIncr, "加款"),
|
||||
dict.GenWarningOption(CreditGroupOpDecr, "操作扣款"),
|
||||
dict.GenSuccessOption(CreditGroupOpIncr, "操作加款"),
|
||||
dict.GenWarningOption(CreditGroupBalanceRefund, "余额退款"),
|
||||
dict.GenSuccessOption(CreditGroupBalanceRecharge, "余额充值"),
|
||||
dict.GenInfoOption(CreditGroupApplyCash, "申请提现"),
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// 定时任务
|
||||
|
||||
const (
|
||||
CronSplitStr = "," // 变量分割符
|
||||
CronPolicySame = 1 // 并行策略
|
||||
CronPolicySingle = 2 // 单例策略
|
||||
CronPolicyOnce = 3 // 单次策略
|
||||
CronPolicyTimes = 4 // 多次策略
|
||||
)
|
||||
@@ -0,0 +1,37 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2025 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
// 碎片
|
||||
|
||||
const (
|
||||
DemoTips = "演示系统已隐藏" // 演示系统敏感数据打码
|
||||
NilJsonToString = "{}" // 空json初始化值
|
||||
RegionSpilt = " / " // 地区分隔符
|
||||
Unknown = "Unknown" // Unknown
|
||||
SuperRoleKey = "super" // 超管角色唯一标识符,通过角色验证超管
|
||||
MaxServeLogContentLen = 2048 // 最大保留服务日志内容大小
|
||||
SysDefaultLanguage = "zh_CN" // 系统默认语言,当配置文件没有国际化配置时生效
|
||||
)
|
||||
|
||||
// curd.
|
||||
const (
|
||||
DefaultPage = 10 // 默认列表分页加载数量
|
||||
DefaultPageSize = 1 // 默认列表分页加载页码
|
||||
MaxSortIncr = 10 // 最大排序值增量
|
||||
)
|
||||
|
||||
// TenantField 租户字段
|
||||
const (
|
||||
TenantId = "tenant_id" // 租户ID
|
||||
MerchantId = "merchant_id" // 商户ID
|
||||
UserId = "user_id" // 用户ID
|
||||
)
|
||||
|
||||
const (
|
||||
DBMysql = "mysql"
|
||||
DBPgsql = "pgsql"
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("deptType", "部门类型选项", DeptTypeOptions)
|
||||
}
|
||||
|
||||
const (
|
||||
DeptTypeCompany = "company" // 公司
|
||||
DeptTypeTenant = "tenant" // 租户
|
||||
DeptTypeMerchant = "merchant" // 商户
|
||||
DeptTypeUser = "user" // 用户
|
||||
)
|
||||
|
||||
// DeptTypeOptions 部门类型选项
|
||||
var DeptTypeOptions = []*model.Option{
|
||||
dict.GenSuccessOption(DeptTypeCompany, "公司"),
|
||||
dict.GenErrorOption(DeptTypeTenant, "租户"),
|
||||
dict.GenInfoOption(DeptTypeMerchant, "商户"),
|
||||
dict.GenWarningOption(DeptTypeUser, "用户"),
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
// 邮件内置模板
|
||||
const (
|
||||
EmsTemplateText = "text" // 通用文本
|
||||
EmsTemplateCode = "code" // 通用验证码
|
||||
EmsTemplateLogin = "login" // 登录
|
||||
EmsTemplateRegister = "register" // 注册
|
||||
EmsTemplateResetPwd = "resetPwd" // 重置密码
|
||||
EmsTemplateBind = "bind" // 绑定邮箱
|
||||
EmsTemplateCash = "cash" // 申请提现
|
||||
)
|
||||
|
||||
var EmsSubjectMap = g.MapStrStr{
|
||||
EmsTemplateText: "这是一封来自HotGo的邮件",
|
||||
EmsTemplateCode: "验证码",
|
||||
EmsTemplateLogin: "登录验证码",
|
||||
EmsTemplateRegister: "注册验证码",
|
||||
EmsTemplateResetPwd: "重置密码",
|
||||
EmsTemplateBind: "绑定邮箱验证码",
|
||||
EmsTemplateCash: "申请提现验证码",
|
||||
}
|
||||
|
||||
// IsCodeEmsTemplate 是否是验证码类型的模板
|
||||
func IsCodeEmsTemplate(template string) bool {
|
||||
return template == EmsTemplateCode ||
|
||||
template == EmsTemplateLogin ||
|
||||
template == EmsTemplateRegister ||
|
||||
template == EmsTemplateBind ||
|
||||
template == EmsTemplateCash
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
)
|
||||
|
||||
// 错误解释
|
||||
const (
|
||||
ErrorORM = "sql执行异常"
|
||||
ErrorNotData = "数据不存在"
|
||||
ErrorRotaPointer = "指针转换异常"
|
||||
)
|
||||
|
||||
// 需要隐藏真实错误的Wrap,开启访问日志后仍然会将真实错误记录
|
||||
var concealErrorSlice = []string{ErrorORM, ErrorRotaPointer}
|
||||
|
||||
// ErrorMessage 错误显示信息,非debug模式有效
|
||||
func ErrorMessage(err error) (message string) {
|
||||
if err == nil {
|
||||
return "操作失败!~"
|
||||
}
|
||||
|
||||
message = err.Error()
|
||||
for _, e := range concealErrorSlice {
|
||||
if gstr.Contains(message, e) {
|
||||
return "操作失败,请稍后重试!~"
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
const (
|
||||
EventServerClose = "server.close" // 服务关闭事件
|
||||
)
|
||||
@@ -0,0 +1,96 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
// 生成代码类型
|
||||
const (
|
||||
GenCodesTypeCurd = 10 // 增删改查列表
|
||||
GenCodesTypeTree = 11 // 树列表
|
||||
GenCodesTypeQueue = 20 // 队列消费者
|
||||
GenCodesTypeCron = 30 // 定时任务
|
||||
)
|
||||
|
||||
var GenCodesTypeNameMap = map[int]string{
|
||||
GenCodesTypeCurd: "增删改查列表",
|
||||
GenCodesTypeTree: "关系树列表",
|
||||
GenCodesTypeQueue: "队列消费者(未实现)",
|
||||
GenCodesTypeCron: "定时任务(未实现)",
|
||||
}
|
||||
|
||||
var GenCodesTypeConfMap = map[int]string{
|
||||
GenCodesTypeCurd: "crud",
|
||||
GenCodesTypeTree: "tree",
|
||||
GenCodesTypeQueue: "queue",
|
||||
GenCodesTypeCron: "cron",
|
||||
}
|
||||
|
||||
// 生成代码状态
|
||||
const (
|
||||
GenCodesStatusOk = 1 // 生成成功
|
||||
GenCodesStatusWait = 2 // 未生成
|
||||
GenCodesStatusFail = 3 // 生成失败
|
||||
)
|
||||
|
||||
var GenCodesStatusNameMap = map[int]string{
|
||||
GenCodesStatusOk: "生成成功",
|
||||
GenCodesStatusWait: "未生成",
|
||||
GenCodesStatusFail: "生成失败",
|
||||
}
|
||||
|
||||
// 生成代码关联表方式
|
||||
const (
|
||||
GenCodesJoinLeft = 1 // 左关联
|
||||
GenCodesJoinRight = 2 // 右关联
|
||||
GenCodesJoinInner = 3 // 内关联
|
||||
)
|
||||
|
||||
var GenCodesJoinNameMap = map[int]string{
|
||||
GenCodesJoinLeft: "左关联",
|
||||
GenCodesJoinRight: "右关联",
|
||||
GenCodesJoinInner: "内关联",
|
||||
}
|
||||
|
||||
var GenCodesJoinLinkMap = map[int]string{
|
||||
GenCodesJoinLeft: "LeftJoin",
|
||||
GenCodesJoinRight: "RightJoin",
|
||||
GenCodesJoinInner: "InnerJoin",
|
||||
}
|
||||
|
||||
// 生成代码的生成方式
|
||||
const (
|
||||
GenCodesBuildMethCreate = 1 // 创建
|
||||
GenCodesBuildMethCover = 2 // 覆盖
|
||||
GenCodesBuildMethSkip = 3 // 跳过
|
||||
GenCodesBuildIgnore = 4 // 不生成
|
||||
)
|
||||
|
||||
var GenCodesBuildMethNameMap = map[int]string{
|
||||
GenCodesBuildMethCreate: "创建文件",
|
||||
GenCodesBuildMethCover: "强制覆盖",
|
||||
GenCodesBuildMethSkip: "已存在跳过",
|
||||
GenCodesBuildIgnore: "不生成",
|
||||
}
|
||||
|
||||
const (
|
||||
GenCodesIndexPK = "PRI" // 主键索引
|
||||
GenCodesIndexUNI = "UNI" // 唯一索引
|
||||
)
|
||||
|
||||
const (
|
||||
GenCodesTreeStyleTypeNormal = 1 // 普通树表格
|
||||
GenCodesTreeStyleTypeOption = 2 // 选项式树表
|
||||
)
|
||||
|
||||
// GenCodesTreeStyleTypeOptions 树表样式选项
|
||||
var GenCodesTreeStyleTypeOptions = []*model.Option{
|
||||
dict.GenSuccessOption(GenCodesTreeStyleTypeNormal, "普通树表格"),
|
||||
dict.GenInfoOption(GenCodesTreeStyleTypeOption, "选项式树表"),
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
"net/http"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("HTTPMethod", "HTTP请求方式选项", HTTPMethodOptions)
|
||||
dict.RegisterEnums("HTTPHandlerTime", "HTTP处理耗时选项", HTTPHandlerTimeOptions)
|
||||
dict.RegisterEnums("HTTPApiCode", "HTTP接口状态码选项", HTTPApiCodeOptions)
|
||||
}
|
||||
|
||||
const (
|
||||
HTTPContentTypeXml = "text/xml"
|
||||
HTTPContentTypeHtml = "text/html"
|
||||
HTTPContentTypeStream = "text/event-stream"
|
||||
HTTPContentTypeJson = "application/json"
|
||||
HTTPContentTypeOctetStream = "application/octet-stream"
|
||||
)
|
||||
|
||||
// HTTPMethodOptions HTTP请求方式选项
|
||||
var HTTPMethodOptions = []*model.Option{
|
||||
dict.GenSuccessOption(http.MethodGet, "GET"),
|
||||
dict.GenInfoOption(http.MethodPost, "POST"),
|
||||
dict.GenSuccessOption(http.MethodPut, "PUT"),
|
||||
dict.GenInfoOption(http.MethodDelete, "DELETE"),
|
||||
}
|
||||
|
||||
const (
|
||||
HTTPHandlerTime50 = "< 50"
|
||||
HTTPHandlerTime200 = "< 200"
|
||||
HTTPHandlerTime200To500 = "BETWEEN 200 AND 500"
|
||||
HTTPHandlerTime500To1000 = "BETWEEN 500 AND 1000"
|
||||
HTTPHandlerTime1000To10000 = "BETWEEN 1000 AND 10000"
|
||||
HTTPHandlerTime10000UP = "> 10000"
|
||||
)
|
||||
|
||||
// HTTPHandlerTimeOptions HTTP处理耗时选项
|
||||
var HTTPHandlerTimeOptions = []*model.Option{
|
||||
dict.GenSuccessOption(HTTPHandlerTime50, "50ms以内"),
|
||||
dict.GenInfoOption(HTTPHandlerTime200, "200ms以内"),
|
||||
dict.GenSuccessOption(HTTPHandlerTime200To500, "200~500ms"),
|
||||
dict.GenSuccessOption(HTTPHandlerTime500To1000, "500~1000ms"),
|
||||
dict.GenInfoOption(HTTPHandlerTime1000To10000, "1000~10000ms"),
|
||||
dict.GenInfoOption(HTTPHandlerTime10000UP, "10000ms以上"),
|
||||
}
|
||||
|
||||
// HTTPApiCodeOptions HTTP接口状态码选项
|
||||
var HTTPApiCodeOptions = []*model.Option{
|
||||
dict.GenSuccessOption(gcode.CodeOK.Code(), fmt.Sprintf("%v %v", gcode.CodeOK.Code(), "成功")),
|
||||
dict.GenWarningOption(gcode.CodeNil.Code(), fmt.Sprintf("%v %v", gcode.CodeNil.Code(), "失败")),
|
||||
dict.GenWarningOption(gcode.CodeSecurityReason.Code(), fmt.Sprintf("%v %v", gcode.CodeSecurityReason.Code(), "无访问权限")),
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// 公告类型
|
||||
const (
|
||||
NoticeTypeNotify = 1 // 通知
|
||||
NoticeTypeNotice = 2 // 公告
|
||||
NoticeTypeLetter = 3 // 私信
|
||||
)
|
||||
@@ -0,0 +1,66 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("orderStatus", "订单状态", OrderStatusOptions)
|
||||
dict.RegisterEnums("acceptRefundStatus", "订单退款受理状态", OrderAcceptRefundOptions)
|
||||
}
|
||||
|
||||
// 订单分组
|
||||
// 为不同的业务订单设置不同的分组,分组可以设置不同的业务回调方法
|
||||
|
||||
const (
|
||||
OrderGroupDefault = "order" // 普通订单
|
||||
OrderGroupAdminOrder = "admin_order" // 后台充值订单
|
||||
// 还可以设置其他,方便后期扩展..
|
||||
)
|
||||
|
||||
// 订单类型
|
||||
|
||||
const (
|
||||
OrderTypeBalance = "balance" // 余额充值
|
||||
OrderTypeProduct = "product" // 购买产品
|
||||
)
|
||||
|
||||
const (
|
||||
OrderStatusALL = -1 // 全部状态
|
||||
OrderStatusNotPay = 1 // 待付款
|
||||
OrderStatusPay = 2 // 已付款
|
||||
OrderStatusShipments = 3 // 已发货
|
||||
OrderStatusDone = 4 // 已完成
|
||||
OrderStatusClose = 5 // 已关闭
|
||||
OrderStatusReturnRequest = 6 // 申请退款
|
||||
OrderStatusReturning = 7 // 退款中
|
||||
OrderStatusReturned = 8 // 已退款
|
||||
OrderStatusReturnReject = 9 // 拒绝退款
|
||||
)
|
||||
|
||||
// OrderStatusOptions 订单状态选项
|
||||
var OrderStatusOptions = []*model.Option{
|
||||
dict.GenInfoOption(OrderStatusALL, "全部"),
|
||||
dict.GenInfoOption(OrderStatusNotPay, "待付款"),
|
||||
dict.GenInfoOption(OrderStatusPay, "已付款"),
|
||||
dict.GenInfoOption(OrderStatusShipments, "已发货"),
|
||||
dict.GenSuccessOption(OrderStatusDone, "已完成"),
|
||||
dict.GenDefaultOption(OrderStatusClose, "已关闭"),
|
||||
dict.GenWarningOption(OrderStatusReturnRequest, "申请退款"),
|
||||
dict.GenDefaultOption(OrderStatusReturning, "退款中"),
|
||||
dict.GenErrorOption(OrderStatusReturned, "已退款"),
|
||||
dict.GenWarningOption(OrderStatusReturnReject, "拒绝退款"),
|
||||
}
|
||||
|
||||
// OrderAcceptRefundOptions 订单退款受理状态
|
||||
var OrderAcceptRefundOptions = []*model.Option{
|
||||
dict.GenWarningOption(OrderStatusReturnRequest, "申请退款"),
|
||||
dict.GenSuccessOption(OrderStatusReturned, "已退款"),
|
||||
dict.GenErrorOption(OrderStatusReturnReject, "拒绝退款"),
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
// 支付方式
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("payType", "支付方式", PayTypeOptions)
|
||||
dict.RegisterEnums("payStatus", "支付状态", PayStatusOptions)
|
||||
}
|
||||
|
||||
const (
|
||||
PayTypeALL = "" // 全部
|
||||
PayTypeWxPay = "wxpay" // 微信支付
|
||||
PayTypeAliPay = "alipay" // 支付宝
|
||||
PayTypeQQPay = "qqpay" // QQ支付
|
||||
)
|
||||
|
||||
var (
|
||||
PayTypeSlice = []string{
|
||||
PayTypeWxPay, PayTypeAliPay, PayTypeQQPay,
|
||||
}
|
||||
|
||||
PayTypeNameMap = map[string]string{
|
||||
PayTypeALL: "全部",
|
||||
PayTypeWxPay: "微信支付",
|
||||
PayTypeAliPay: "支付宝",
|
||||
PayTypeQQPay: "QQ支付",
|
||||
}
|
||||
)
|
||||
|
||||
// 交易方式
|
||||
|
||||
const (
|
||||
// 微信
|
||||
TradeTypeWxMP = "mp" // 公众号
|
||||
TradeTypeWxMini = "mini" // 小程序
|
||||
TradeTypeWxApp = "app" // APP
|
||||
TradeTypeWxScan = "scan" // 二维码扫码
|
||||
TradeTypeWxPos = "pos" // 二维码收款
|
||||
TradeTypeWxH5 = "h5" // H5
|
||||
|
||||
// 支付宝
|
||||
TradeTypeAliWeb = "web" // 电脑网页
|
||||
TradeTypeAliApp = "app" // APP
|
||||
TradeTypeAliScan = "scan" // 二维码扫码
|
||||
TradeTypeAliWap = "wap" // 手机网页
|
||||
TradeTypeAliPos = "pos" // 二维码收款
|
||||
|
||||
// QQ
|
||||
TradeTypeQQWeb = "qqweb" // PC网页
|
||||
TradeTypeQQWap = "qqwap" // 移动端
|
||||
)
|
||||
|
||||
var (
|
||||
TradeTypeWxSlice = []string{TradeTypeWxMP, TradeTypeWxMini, TradeTypeWxApp, TradeTypeWxScan, TradeTypeWxPos, TradeTypeWxH5}
|
||||
TradeTypeAliSlice = []string{TradeTypeAliWeb, TradeTypeAliApp, TradeTypeAliScan, TradeTypeAliWap, TradeTypeAliPos}
|
||||
TradeTypeQQSlice = []string{TradeTypeQQWeb, TradeTypeQQWap}
|
||||
)
|
||||
|
||||
// 支付状态
|
||||
|
||||
const (
|
||||
PayStatusWait = 1 // 待支付
|
||||
PayStatusOk = 2 // 已支付
|
||||
)
|
||||
|
||||
// PayStatusOptions 支付状态选项
|
||||
var PayStatusOptions = []*model.Option{
|
||||
dict.GenDefaultOption(PayStatusWait, "待支付"),
|
||||
dict.GenSuccessOption(PayStatusOk, "已支付"),
|
||||
}
|
||||
|
||||
// 退款状态
|
||||
|
||||
const (
|
||||
RefundStatusNo = 1 // 未退款
|
||||
RefundStatusApply = 2 // 申请退款
|
||||
RefundStatusReject = 3 // 拒绝退款
|
||||
RefundStatusAgree = 4 // 同意退款,已退款
|
||||
)
|
||||
|
||||
// PayTypeOptions 支付方式选项
|
||||
var PayTypeOptions = []*model.Option{
|
||||
dict.GenSuccessOption(PayTypeWxPay, "微信支付"),
|
||||
dict.GenInfoOption(PayTypeAliPay, "支付宝"),
|
||||
dict.GenDefaultOption(PayTypeQQPay, "QQ支付"),
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
const (
|
||||
ClusterSyncSysconfig = "cluster.sync.sysConfig" // 系统配置
|
||||
ClusterSyncSysBlacklist = "cluster.sync.sysBlacklist" // 系统黑名单
|
||||
ClusterSyncSysSuperAdmin = "cluster.sync.superAdmin" // 超管
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// 消息队列
|
||||
const (
|
||||
QueueLogTopic = `request_log` // 访问日志
|
||||
QueueLoginLogTopic = `login_log` // 登录日志
|
||||
QueueServeLogTopic = `serve_log` // 服务日志
|
||||
)
|
||||
@@ -0,0 +1,90 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// 数据范围
|
||||
const (
|
||||
RoleDataAll = 1 // 全部权限
|
||||
|
||||
// 通过部门划分
|
||||
RoleDataNowDept = 2 // 当前部门
|
||||
RoleDataDeptAndSub = 3 // 当前部门及以下部门
|
||||
RoleDataDeptCustom = 4 // 自定义部门
|
||||
|
||||
// 通过上下级关系划分
|
||||
RoleDataSelf = 5 // 仅自己
|
||||
RoleDataSelfAndSub = 6 // 自己和直属下级
|
||||
RoleDataSelfAndAllSub = 7 // 自己和全部下级
|
||||
)
|
||||
|
||||
var RoleDataNameMap = map[int]string{
|
||||
RoleDataAll: "全部权限",
|
||||
RoleDataNowDept: "当前部门",
|
||||
RoleDataDeptAndSub: "当前及以下部门",
|
||||
RoleDataDeptCustom: "自定义部门",
|
||||
RoleDataSelf: "仅自己",
|
||||
RoleDataSelfAndSub: "自己和直属下级",
|
||||
RoleDataSelfAndAllSub: "自己和全部下级",
|
||||
}
|
||||
|
||||
type GroupScopeSelect struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Label string `json:"label"`
|
||||
Key int `json:"key"`
|
||||
Value int `json:"value,omitempty"`
|
||||
Children []ScopeSelect `json:"children,omitempty"`
|
||||
}
|
||||
|
||||
type ScopeSelect struct {
|
||||
Label string `json:"label"`
|
||||
Value int `json:"value"`
|
||||
}
|
||||
|
||||
var DataScopeSelect = []GroupScopeSelect{
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataAll],
|
||||
Key: RoleDataAll,
|
||||
Value: RoleDataAll,
|
||||
},
|
||||
{
|
||||
Type: "group",
|
||||
Label: "按部门划分",
|
||||
Key: -1,
|
||||
Children: []ScopeSelect{
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataNowDept],
|
||||
Value: RoleDataNowDept,
|
||||
},
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataDeptAndSub],
|
||||
Value: RoleDataDeptAndSub,
|
||||
},
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataDeptCustom],
|
||||
Value: RoleDataDeptCustom,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: "group",
|
||||
Label: "按上下级关系划分",
|
||||
Key: -2,
|
||||
Children: []ScopeSelect{
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataSelf],
|
||||
Value: RoleDataSelf,
|
||||
},
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataSelfAndSub],
|
||||
Value: RoleDataSelfAndSub,
|
||||
},
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataSelfAndAllSub],
|
||||
Value: RoleDataSelfAndAllSub,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("ServerLicenseGroupOptions", "服务授权分组选项", ServerLicenseGroupOptions)
|
||||
}
|
||||
|
||||
// 授权分组
|
||||
const (
|
||||
LicenseGroupDefault = "default" // 默认组
|
||||
LicenseGroupCron = "cron" // 定时任务
|
||||
LicenseGroupAuth = "auth" // 服务授权
|
||||
)
|
||||
|
||||
// ServerLicenseGroupOptions 服务授权分组选项
|
||||
var ServerLicenseGroupOptions = []*model.Option{
|
||||
dict.GenWarningOption(LicenseGroupDefault, "默认组"),
|
||||
dict.GenSuccessOption(LicenseGroupCron, "定时任务"),
|
||||
dict.GenSuccessOption(LicenseGroupAuth, "服务授权"),
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// 短信驱动
|
||||
const (
|
||||
SmsDriveAliYun = "aliyun" // 阿里云
|
||||
SmsDriveTencent = "tencent" // 腾讯云
|
||||
)
|
||||
|
||||
// 短信内置模板
|
||||
const (
|
||||
SmsTemplateCode = "code" // 通用验证码
|
||||
SmsTemplateLogin = "login" // 登录
|
||||
SmsTemplateRegister = "register" // 注册
|
||||
SmsTemplateResetPwd = "resetPwd" // 重置密码
|
||||
SmsTemplateBind = "bind" // 绑定手机号
|
||||
SmsTemplateCash = "cash" // 申请提现
|
||||
)
|
||||
|
||||
var (
|
||||
SmsTemplateEventMap = map[string]string{
|
||||
SmsTemplateCode: "通用验证码",
|
||||
SmsTemplateLogin: "登录",
|
||||
SmsTemplateRegister: "注册",
|
||||
SmsTemplateResetPwd: "重置密码",
|
||||
SmsTemplateBind: "绑定手机号",
|
||||
SmsTemplateCash: "申请提现",
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
import (
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dict.RegisterEnums("CodeStatusOptions", "验证码状态选项", CodeStatusOptions)
|
||||
dict.RegisterEnums("BlacklistStatusOptions", "黑名单拉黑状态选项", BlacklistStatusOptions)
|
||||
}
|
||||
|
||||
// 状态码
|
||||
const (
|
||||
StatusALL int = -1 // 全部状态
|
||||
StatusEnabled int = 1 // 启用
|
||||
StatusDisable int = 2 // 禁用
|
||||
StatusDelete int = 3 // 已删除
|
||||
)
|
||||
|
||||
var StatusSlice = []int{StatusALL, StatusEnabled, StatusDisable, StatusDelete}
|
||||
|
||||
// 验证码状态
|
||||
const (
|
||||
CodeStatusNotUsed = 1 // 未使用
|
||||
CodeStatusUsed = 2 // 已使用
|
||||
)
|
||||
|
||||
// CodeStatusOptions 验证码状态选项
|
||||
var CodeStatusOptions = []*model.Option{
|
||||
dict.GenWarningOption(CodeStatusNotUsed, "未使用"),
|
||||
dict.GenSuccessOption(CodeStatusUsed, "已使用"),
|
||||
}
|
||||
|
||||
const (
|
||||
BlacklistStatusDisable = 1 // 封禁中
|
||||
BlacklistStatusEnabled = 2 // 已解封
|
||||
)
|
||||
|
||||
// BlacklistStatusOptions 黑名单拉黑状态选项
|
||||
var BlacklistStatusOptions = []*model.Option{
|
||||
dict.GenWarningOption(BlacklistStatusDisable, "封禁中"),
|
||||
dict.GenSuccessOption(BlacklistStatusEnabled, "已解封"),
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// 上传存储驱动
|
||||
const (
|
||||
UploadDriveLocal = "local" // 本地驱动
|
||||
UploadDriveUCloud = "ucloud" // ucloud对象存储
|
||||
UploadDriveCos = "cos" // 腾讯云cos
|
||||
UploadDriveOss = "oss" // 阿里云oss
|
||||
UploadDriveQiNiu = "qiniu" // 七牛云对象存储
|
||||
UploadDriveMinio = "minio" // minio对象存储
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2025 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
// VersionApp HotGo版本
|
||||
const (
|
||||
VersionApp = "2.18.9"
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
// Package consts
|
||||
// @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 consts
|
||||
|
||||
// 授权类型
|
||||
const (
|
||||
WechatAuthorizeOpenId = "openId" // 设置openid
|
||||
WechatAuthorizeBindLogin = "bindLogin" // 绑定微信登录
|
||||
)
|
||||
|
||||
// 应用授权作用域
|
||||
const (
|
||||
WechatScopeBase = "snsapi_base" // 只获取openid,无需用户授权
|
||||
WechatScopeUserinfo = "snsapi_userinfo" // 获取用户信息,需要授权
|
||||
)
|
||||
@@ -0,0 +1,60 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/cash"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/model/input/adminin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Cash = cCash{}
|
||||
)
|
||||
|
||||
type cCash struct{}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cCash) View(ctx context.Context, req *cash.ViewReq) (res *cash.ViewRes, err error) {
|
||||
data, err := service.AdminCash().View(ctx, &req.CashViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(cash.ViewRes)
|
||||
res.CashViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cCash) List(ctx context.Context, req *cash.ListReq) (res *cash.ListRes, err error) {
|
||||
list, totalCount, err := service.AdminCash().List(ctx, &req.CashListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(cash.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Apply 申请提现
|
||||
func (c *cCash) Apply(ctx context.Context, req *cash.ApplyReq) (res *cash.ApplyRes, err error) {
|
||||
err = service.AdminCash().Apply(ctx, &adminin.CashApplyInp{
|
||||
Money: req.Money,
|
||||
MemberId: contexts.GetUserId(ctx),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Payment 提现打款处理
|
||||
func (c *cCash) Payment(ctx context.Context, req *cash.PaymentReq) (res *cash.PaymentRes, err error) {
|
||||
err = service.AdminCash().Payment(ctx, &req.CashPaymentInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Package admin
|
||||
// @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
|
||||
// @AutoGenerate Version 2.5.3
|
||||
// @AutoGenerate Date 2023-04-15 15:59:58
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/creditslog"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
CreditsLog = cCreditsLog{}
|
||||
)
|
||||
|
||||
type cCreditsLog struct{}
|
||||
|
||||
// List 查看资产变动列表
|
||||
func (c *cCreditsLog) List(ctx context.Context, req *creditslog.ListReq) (res *creditslog.ListRes, err error) {
|
||||
list, totalCount, err := service.AdminCreditsLog().List(ctx, &req.CreditsLogListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(creditslog.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出资产变动列表
|
||||
func (c *cCreditsLog) Export(ctx context.Context, req *creditslog.ExportReq) (res *creditslog.ExportRes, err error) {
|
||||
err = service.AdminCreditsLog().Export(ctx, &req.CreditsLogListInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/dept"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Dept = cDept{}
|
||||
)
|
||||
|
||||
type cDept struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cDept) Delete(ctx context.Context, req *dept.DeleteReq) (res *dept.DeleteRes, err error) {
|
||||
err = service.AdminDept().Delete(ctx, &req.DeptDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cDept) Edit(ctx context.Context, req *dept.EditReq) (res *dept.EditRes, err error) {
|
||||
err = service.AdminDept().Edit(ctx, &req.DeptEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (c *cDept) MaxSort(ctx context.Context, req *dept.MaxSortReq) (res *dept.MaxSortRes, err error) {
|
||||
res = new(dept.MaxSortRes)
|
||||
res.DeptMaxSortModel, err = service.AdminDept().MaxSort(ctx, &req.DeptMaxSortInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cDept) View(ctx context.Context, req *dept.ViewReq) (res *dept.ViewRes, err error) {
|
||||
res = new(dept.ViewRes)
|
||||
res.DeptViewModel, err = service.AdminDept().View(ctx, &req.DeptViewInp)
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cDept) List(ctx context.Context, req *dept.ListReq) (res *dept.ListRes, err error) {
|
||||
data, err := service.AdminDept().List(ctx, &req.DeptListInp)
|
||||
if err != nil || data == nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = (*dept.ListRes)(&data)
|
||||
return
|
||||
}
|
||||
|
||||
// Option 获取部门选项树
|
||||
func (c *cDept) Option(ctx context.Context, req *dept.OptionReq) (res *dept.OptionRes, err error) {
|
||||
list, totalCount, err := service.AdminDept().Option(ctx, &req.DeptOptionInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(dept.OptionRes)
|
||||
res.DeptOptionModel = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// TreeOption 获取部门管理关系树选项
|
||||
func (c *cDept) TreeOption(ctx context.Context, req *dept.TreeOptionReq) (res *dept.TreeOptionRes, err error) {
|
||||
data, err := service.AdminDept().TreeOption(ctx)
|
||||
res = (*dept.TreeOptionRes)(&data)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/api/admin/member"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/model/input/adminin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Member = cMember{}
|
||||
)
|
||||
|
||||
type cMember struct{}
|
||||
|
||||
// UpdateCash 修改代理商提现信息
|
||||
func (c *cMember) UpdateCash(ctx context.Context, req *member.UpdateCashReq) (res *member.UpdateCashRes, err error) {
|
||||
err = service.AdminMember().UpdateCash(ctx, &req.MemberUpdateCashInp)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateEmail 换绑邮箱
|
||||
func (c *cMember) UpdateEmail(ctx context.Context, req *member.UpdateEmailReq) (res *member.UpdateEmailRes, err error) {
|
||||
err = service.AdminMember().UpdateEmail(ctx, &req.MemberUpdateEmailInp)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateMobile 换绑手机号
|
||||
func (c *cMember) UpdateMobile(ctx context.Context, req *member.UpdateMobileReq) (res *member.UpdateMobileRes, err error) {
|
||||
err = service.AdminMember().UpdateMobile(ctx, &req.MemberUpdateMobileInp)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateProfile 更新用户资料
|
||||
func (c *cMember) UpdateProfile(ctx context.Context, req *member.UpdateProfileReq) (res *member.UpdateProfileRes, err error) {
|
||||
err = service.AdminMember().UpdateProfile(ctx, &req.MemberUpdateProfileInp)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePwd 修改登录密码
|
||||
func (c *cMember) UpdatePwd(ctx context.Context, req *member.UpdatePwdReq) (res *member.UpdatePwdRes, err error) {
|
||||
var memberId = contexts.Get(ctx).User.Id
|
||||
if memberId <= 0 {
|
||||
err = gerror.New("获取用户信息失败!")
|
||||
return
|
||||
}
|
||||
|
||||
err = service.AdminMember().UpdatePwd(ctx, &adminin.MemberUpdatePwdInp{
|
||||
Id: memberId,
|
||||
OldPassword: req.OldPassword,
|
||||
NewPassword: req.NewPassword,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// ResetPwd 重置密码
|
||||
func (c *cMember) ResetPwd(ctx context.Context, req *member.ResetPwdReq) (res *member.ResetPwdRes, err error) {
|
||||
err = service.AdminMember().ResetPwd(ctx, &req.MemberResetPwdInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MemberInfo 登录用户信息
|
||||
func (c *cMember) MemberInfo(ctx context.Context, _ *member.InfoReq) (res *member.InfoRes, err error) {
|
||||
data, err := service.AdminMember().LoginMemberInfo(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(member.InfoRes)
|
||||
res.LoginMemberInfoModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除用户
|
||||
func (c *cMember) Delete(ctx context.Context, req *member.DeleteReq) (res *member.DeleteRes, err error) {
|
||||
err = service.AdminMember().Delete(ctx, &req.MemberDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改/新增用户
|
||||
func (c *cMember) Edit(ctx context.Context, req *member.EditReq) (res *member.EditRes, err error) {
|
||||
err = service.AdminMember().Edit(ctx, &req.MemberEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定用户信息
|
||||
func (c *cMember) View(ctx context.Context, req *member.ViewReq) (res *member.ViewRes, err error) {
|
||||
data, err := service.AdminMember().View(ctx, &req.MemberViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(member.ViewRes)
|
||||
res.MemberViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看用户列表
|
||||
func (c *cMember) List(ctx context.Context, req *member.ListReq) (res *member.ListRes, err error) {
|
||||
list, totalCount, err := service.AdminMember().List(ctx, &req.MemberListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(member.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新用户状态
|
||||
func (c *cMember) Status(ctx context.Context, req *member.StatusReq) (res *member.StatusRes, err error) {
|
||||
err = service.AdminMember().Status(ctx, &req.MemberStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Select 获取可选的后台用户选项
|
||||
func (c *cMember) Select(ctx context.Context, req *member.SelectReq) (res *member.SelectRes, err error) {
|
||||
data, err := service.AdminMember().Select(ctx, &req.MemberSelectInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = (*member.SelectRes)(&data)
|
||||
return
|
||||
}
|
||||
|
||||
// AddBalance 增加用户余额
|
||||
func (c *cMember) AddBalance(ctx context.Context, req *member.AddBalanceReq) (res *member.AddBalanceRes, err error) {
|
||||
err = service.AdminMember().AddBalance(ctx, &req.MemberAddBalanceInp)
|
||||
return
|
||||
}
|
||||
|
||||
// AddIntegral 增加用户积分
|
||||
func (c *cMember) AddIntegral(ctx context.Context, req *member.AddIntegralReq) (res *member.AddIntegralRes, err error) {
|
||||
err = service.AdminMember().AddIntegral(ctx, &req.MemberAddIntegralInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/menu"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// Menu 菜单
|
||||
var (
|
||||
Menu = cMenu{}
|
||||
)
|
||||
|
||||
type cMenu struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cMenu) Delete(ctx context.Context, req *menu.DeleteReq) (res *menu.DeleteRes, err error) {
|
||||
err = service.AdminMenu().Delete(ctx, &req.MenuDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cMenu) Edit(ctx context.Context, req *menu.EditReq) (res *menu.EditRes, err error) {
|
||||
err = service.AdminMenu().Edit(ctx, &req.MenuEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (c *cMenu) List(ctx context.Context, req *menu.ListReq) (res menu.ListRes, err error) {
|
||||
res.MenuListModel, err = service.AdminMenu().List(ctx, &req.MenuListInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"hotgo/api/admin/monitor"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/internal/websocket"
|
||||
"hotgo/utility/simple"
|
||||
"hotgo/utility/useragent"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Monitor 监控
|
||||
var Monitor = cMonitor{
|
||||
wsManager: websocket.Manager(),
|
||||
}
|
||||
|
||||
type cMonitor struct {
|
||||
wsManager *websocket.ClientManager
|
||||
}
|
||||
|
||||
// UserOffline 下线用户
|
||||
func (c *cMonitor) UserOffline(ctx context.Context, req *monitor.UserOfflineReq) (res *monitor.UserOfflineRes, err error) {
|
||||
client := c.wsManager.GetClient(req.Id)
|
||||
if client == nil {
|
||||
err = gerror.New("客户端已离线")
|
||||
return
|
||||
}
|
||||
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
websocket.SendSuccess(client, "kick")
|
||||
websocket.Close(client)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// UserOnlineList 获取用户在线列表
|
||||
func (c *cMonitor) UserOnlineList(ctx context.Context, req *monitor.UserOnlineListReq) (res *monitor.UserOnlineListRes, err error) {
|
||||
var (
|
||||
clients []*monitor.UserOnlineModel
|
||||
i int
|
||||
)
|
||||
|
||||
if c.wsManager.GetClientsLen() == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for conn := range c.wsManager.GetClients() {
|
||||
if conn.SendClose || conn.User == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if req.UserId > 0 && req.UserId != conn.User.Id {
|
||||
continue
|
||||
}
|
||||
|
||||
if req.Username != "" && req.Username != conn.User.Username {
|
||||
continue
|
||||
}
|
||||
|
||||
if req.IP != "" && !gstr.Contains(conn.IP, req.IP) {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(req.FirstTime) == 2 && (conn.User.LoginAt.Before(req.FirstTime[0]) || conn.User.LoginAt.After(req.FirstTime[1])) {
|
||||
continue
|
||||
}
|
||||
|
||||
clients = append(clients, &monitor.UserOnlineModel{
|
||||
ID: conn.ID,
|
||||
IP: conn.IP,
|
||||
Os: useragent.GetOs(conn.UserAgent),
|
||||
Browser: useragent.GetBrowser(conn.UserAgent),
|
||||
FirstTime: conn.User.LoginAt.Unix(),
|
||||
HeartbeatTime: conn.HeartbeatTime,
|
||||
App: conn.User.App,
|
||||
UserId: conn.User.Id,
|
||||
Username: conn.User.Username,
|
||||
Avatar: conn.User.Avatar,
|
||||
})
|
||||
}
|
||||
|
||||
res = new(monitor.UserOnlineListRes)
|
||||
res.PageRes.Pack(req, len(clients))
|
||||
|
||||
sort.Slice(clients, func(i, j int) bool {
|
||||
if clients[i].FirstTime == clients[j].FirstTime {
|
||||
return clients[i].ID < clients[j].ID
|
||||
}
|
||||
return clients[i].FirstTime < clients[j].FirstTime
|
||||
})
|
||||
|
||||
_, perPage, offset := form.CalPage(req.Page, req.PerPage)
|
||||
for k, v := range clients {
|
||||
if k >= offset && i <= perPage {
|
||||
if simple.IsDemo(ctx) {
|
||||
v.IP = consts.DemoTips
|
||||
}
|
||||
res.List = append(res.List, v)
|
||||
i++
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// NetOnlineList 获取服务在线列表
|
||||
func (c *cMonitor) NetOnlineList(ctx context.Context, req *monitor.NetOnlineListReq) (res *monitor.NetOnlineListRes, err error) {
|
||||
var (
|
||||
clients []*monitor.NetOnlineModel
|
||||
i int
|
||||
cols = dao.SysServeLicense.Columns()
|
||||
serv = service.TCPServer().Instance()
|
||||
models *entity.SysServeLicense
|
||||
)
|
||||
|
||||
conns := serv.GetClients()
|
||||
if len(conns) == 0 {
|
||||
res = new(monitor.NetOnlineListRes)
|
||||
res.PageRes.Pack(req, 0)
|
||||
return
|
||||
}
|
||||
|
||||
for _, conn := range conns {
|
||||
v := &monitor.NetOnlineModel{
|
||||
AuthMeta: conn.Auth,
|
||||
Id: conn.CID,
|
||||
IsAuth: conn.Auth != nil,
|
||||
Addr: conn.RemoteAddr().String(),
|
||||
Port: gstr.SubStrFromEx(conn.LocalAddr().String(), `:`),
|
||||
FirstTime: conn.FirstTime,
|
||||
HeartbeatTime: conn.Heartbeat,
|
||||
Proto: "TCP",
|
||||
}
|
||||
|
||||
if v.IsAuth {
|
||||
if err = dao.SysServeLicense.Ctx(ctx).Where(cols.Appid, conn.Auth.AppId).Where(cols.Group, conn.Auth.Group).Scan(&models); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if models == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
v.LicenseId = models.Id
|
||||
v.LicenseName = models.Name
|
||||
v.LoginTimes = models.LoginTimes
|
||||
v.Online = serv.GetAppIdOnline(models.Appid)
|
||||
v.OnlineLimit = models.OnlineLimit
|
||||
}
|
||||
|
||||
if req.Addr != "" && !gstr.Contains(v.Addr, req.Addr) {
|
||||
continue
|
||||
}
|
||||
|
||||
if req.Name != "" && !gstr.Contains(v.Name, req.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
if req.Group != "" && (!v.IsAuth || v.Group != req.Group) {
|
||||
continue
|
||||
}
|
||||
|
||||
if req.AppId != "" && (!v.IsAuth || v.AppId != req.AppId) {
|
||||
continue
|
||||
}
|
||||
|
||||
ft := gtime.New(conn.FirstTime)
|
||||
if len(req.FirstTime) == 2 && (ft.Before(req.FirstTime[0]) || ft.After(req.FirstTime[1])) {
|
||||
continue
|
||||
}
|
||||
clients = append(clients, v)
|
||||
}
|
||||
|
||||
res = new(monitor.NetOnlineListRes)
|
||||
res.PageRes.Pack(req, len(clients))
|
||||
|
||||
sort.Slice(clients, func(i, j int) bool {
|
||||
return clients[i].Id > clients[j].Id
|
||||
})
|
||||
|
||||
_, perPage, offset := form.CalPage(req.Page, req.PerPage)
|
||||
for k, v := range clients {
|
||||
if k >= offset && i <= perPage {
|
||||
res.List = append(res.List, v)
|
||||
i++
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// NetOption 获取服务选项
|
||||
func (c *cMonitor) NetOption(ctx context.Context, req *monitor.NetOptionReq) (res *monitor.NetOptionRes, err error) {
|
||||
res = new(monitor.NetOptionRes)
|
||||
|
||||
for _, v := range service.TCPServer().Instance().GetRoutes() {
|
||||
// 无需勾选的路由
|
||||
disabled := false
|
||||
if v.Id == "ServerLoginReq" || v.Id == "ServerHeartbeatReq" {
|
||||
disabled = true
|
||||
}
|
||||
|
||||
res.Routes = append(res.Routes, &monitor.RouteSelect{
|
||||
Value: v.Id,
|
||||
Label: v.Id,
|
||||
Disabled: disabled,
|
||||
IsRPC: v.IsRPC,
|
||||
})
|
||||
}
|
||||
|
||||
sort.Slice(res.Routes, func(i, j int) bool {
|
||||
if res.Routes[i].IsRPC && !res.Routes[j].IsRPC {
|
||||
return true
|
||||
} else if !res.Routes[i].IsRPC && res.Routes[j].IsRPC {
|
||||
return false
|
||||
}
|
||||
return res.Routes[i].Label < res.Routes[j].Label
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// NetOffline 下线服务
|
||||
func (c *cMonitor) NetOffline(ctx context.Context, req *monitor.NetOfflineReq) (res *monitor.NetOfflineRes, err error) {
|
||||
conn := service.TCPServer().Instance().GetClientById(req.Id)
|
||||
if conn == nil {
|
||||
err = gerror.New("客户端不在线")
|
||||
return
|
||||
}
|
||||
// 关闭连接
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/notice"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Notice = cNotice{}
|
||||
)
|
||||
|
||||
type cNotice struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cNotice) Delete(ctx context.Context, req *notice.DeleteReq) (res *notice.DeleteRes, err error) {
|
||||
err = service.AdminNotice().Delete(ctx, &req.NoticeDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cNotice) Edit(ctx context.Context, req *notice.EditReq) (res *notice.EditRes, err error) {
|
||||
err = service.AdminNotice().Edit(ctx, &req.NoticeEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (c *cNotice) MaxSort(ctx context.Context, req *notice.MaxSortReq) (res *notice.MaxSortRes, err error) {
|
||||
res = new(notice.MaxSortRes)
|
||||
res.NoticeMaxSortModel, err = service.AdminNotice().MaxSort(ctx, &req.NoticeMaxSortInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cNotice) View(ctx context.Context, req *notice.ViewReq) (res *notice.ViewRes, err error) {
|
||||
data, err := service.AdminNotice().View(ctx, &req.NoticeViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(notice.ViewRes)
|
||||
res.NoticeViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cNotice) List(ctx context.Context, req *notice.ListReq) (res *notice.ListRes, err error) {
|
||||
list, totalCount, err := service.AdminNotice().List(ctx, &req.NoticeListInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res = new(notice.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (c *cNotice) Status(ctx context.Context, req *notice.StatusReq) (res *notice.StatusRes, err error) {
|
||||
err = service.AdminNotice().Status(ctx, &req.NoticeStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Notify 更新通知
|
||||
func (c *cNotice) Notify(ctx context.Context, req *notice.EditNotifyReq) (res *notice.EditNotifyRes, err error) {
|
||||
req.Type = consts.NoticeTypeNotify
|
||||
err = service.AdminNotice().Edit(ctx, &req.NoticeEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Notice 更新公告
|
||||
func (c *cNotice) Notice(ctx context.Context, req *notice.EditNoticeReq) (res *notice.EditNoticeRes, err error) {
|
||||
req.Type = consts.NoticeTypeNotice
|
||||
err = service.AdminNotice().Edit(ctx, &req.NoticeEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Letter 更新私信
|
||||
func (c *cNotice) Letter(ctx context.Context, req *notice.EditLetterReq) (res *notice.EditLetterRes, err error) {
|
||||
req.Type = consts.NoticeTypeLetter
|
||||
err = service.AdminNotice().Edit(ctx, &req.NoticeEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// UpRead 更新已读
|
||||
func (c *cNotice) UpRead(ctx context.Context, req *notice.UpReadReq) (res *notice.UpReadRes, err error) {
|
||||
err = service.AdminNotice().UpRead(ctx, &req.NoticeUpReadInp)
|
||||
return
|
||||
}
|
||||
|
||||
// PullMessages 拉取未读消息列表
|
||||
func (c *cNotice) PullMessages(ctx context.Context, req *notice.PullMessagesReq) (res *notice.PullMessagesRes, err error) {
|
||||
data, err := service.AdminNotice().PullMessages(ctx, &req.PullMessagesInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(notice.PullMessagesRes)
|
||||
res.PullMessagesModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// ReadAll 全部已读
|
||||
func (c *cNotice) ReadAll(ctx context.Context, req *notice.ReadAllReq) (res *notice.ReadAllRes, err error) {
|
||||
err = service.AdminNotice().ReadAll(ctx, &req.NoticeReadAllInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MessageList 我的消息列表
|
||||
func (c *cNotice) MessageList(ctx context.Context, req *notice.MessageListReq) (res *notice.MessageListRes, err error) {
|
||||
list, totalCount, err := service.AdminNotice().MessageList(ctx, &req.NoticeMessageListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(notice.MessageListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/order"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Order = cOrder{}
|
||||
)
|
||||
|
||||
type cOrder struct{}
|
||||
|
||||
// AcceptRefund 受理申请退款
|
||||
func (c *cOrder) AcceptRefund(ctx context.Context, req *order.AcceptRefundReq) (res *order.AcceptRefundRes, err error) {
|
||||
err = service.AdminOrder().AcceptRefund(ctx, &req.OrderAcceptRefundInp)
|
||||
return
|
||||
}
|
||||
|
||||
// ApplyRefund 申请退款
|
||||
func (c *cOrder) ApplyRefund(ctx context.Context, req *order.ApplyRefundReq) (res *order.ApplyRefundRes, err error) {
|
||||
err = service.AdminOrder().ApplyRefund(ctx, &req.OrderApplyRefundInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Create 创建充值订单
|
||||
func (c *cOrder) Create(ctx context.Context, req *order.CreateReq) (res *order.CreateRes, err error) {
|
||||
data, err := service.AdminOrder().Create(ctx, &req.OrderCreateInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(order.CreateRes)
|
||||
res.OrderCreateModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看充值订单列表
|
||||
func (c *cOrder) List(ctx context.Context, req *order.ListReq) (res *order.ListRes, err error) {
|
||||
list, totalCount, err := service.AdminOrder().List(ctx, &req.OrderListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(order.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出充值订单列表
|
||||
func (c *cOrder) Export(ctx context.Context, req *order.ExportReq) (res *order.ExportRes, err error) {
|
||||
err = service.AdminOrder().Export(ctx, &req.OrderListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新充值订单
|
||||
func (c *cOrder) Edit(ctx context.Context, req *order.EditReq) (res *order.EditRes, err error) {
|
||||
err = service.AdminOrder().Edit(ctx, &req.OrderEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定充值订单信息
|
||||
func (c *cOrder) View(ctx context.Context, req *order.ViewReq) (res *order.ViewRes, err error) {
|
||||
data, err := service.AdminOrder().View(ctx, &req.OrderViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(order.ViewRes)
|
||||
res.OrderViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除充值订单
|
||||
func (c *cOrder) Delete(ctx context.Context, req *order.DeleteReq) (res *order.DeleteRes, err error) {
|
||||
err = service.AdminOrder().Delete(ctx, &req.OrderDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新充值订单状态
|
||||
func (c *cOrder) Status(ctx context.Context, req *order.StatusReq) (res *order.StatusRes, err error) {
|
||||
err = service.AdminOrder().Status(ctx, &req.OrderStatusInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/post"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// Post 岗位
|
||||
var Post = cPost{}
|
||||
|
||||
type cPost struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cPost) Delete(ctx context.Context, req *post.DeleteReq) (res *post.DeleteRes, err error) {
|
||||
err = service.AdminPost().Delete(ctx, &req.PostDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (c *cPost) Edit(ctx context.Context, req *post.EditReq) (res *post.EditRes, err error) {
|
||||
err = service.AdminPost().Edit(ctx, &req.PostEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (c *cPost) MaxSort(ctx context.Context, req *post.MaxSortReq) (res *post.MaxSortRes, err error) {
|
||||
res = new(post.MaxSortRes)
|
||||
res.PostMaxSortModel, err = service.AdminPost().MaxSort(ctx, &req.PostMaxSortInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cPost) View(ctx context.Context, req *post.ViewReq) (res *post.ViewRes, err error) {
|
||||
data, err := service.AdminPost().View(ctx, &req.PostViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(post.ViewRes)
|
||||
res.PostViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (c *cPost) List(ctx context.Context, req *post.ListReq) (res *post.ListRes, err error) {
|
||||
list, totalCount, err := service.AdminPost().List(ctx, &req.PostListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(post.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (c *cPost) Status(ctx context.Context, req *post.StatusReq) (res *post.StatusRes, err error) {
|
||||
err = service.AdminPost().Status(ctx, &req.PostStatusInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/role"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Role = cRole{}
|
||||
)
|
||||
|
||||
type cRole struct{}
|
||||
|
||||
// List 获取列表
|
||||
func (c *cRole) List(ctx context.Context, req *role.ListReq) (res *role.ListRes, err error) {
|
||||
list, totalCount, err := service.AdminRole().List(ctx, &req.RoleListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(role.ListRes)
|
||||
res.RoleListModel = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改角色
|
||||
func (c *cRole) Edit(ctx context.Context, req *role.EditReq) (res *role.EditRes, err error) {
|
||||
err = service.AdminRole().Edit(ctx, &req.RoleEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cRole) Delete(ctx context.Context, req *role.DeleteReq) (res *role.DeleteRes, err error) {
|
||||
err = service.AdminRole().Delete(ctx, &req.RoleDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Dynamic 动态路由
|
||||
func (c *cRole) Dynamic(ctx context.Context, _ *role.DynamicReq) (res *role.DynamicRes, err error) {
|
||||
return service.AdminMenu().GetMenuList(ctx, contexts.GetUserId(ctx))
|
||||
}
|
||||
|
||||
// GetPermissions 获取指定角色权限
|
||||
func (c *cRole) GetPermissions(ctx context.Context, req *role.GetPermissionsReq) (res *role.GetPermissionsRes, err error) {
|
||||
data, err := service.AdminRole().GetPermissions(ctx, &req.GetPermissionsInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(role.GetPermissionsRes)
|
||||
res.GetPermissionsModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePermissions 修改角色菜单权限
|
||||
func (c *cRole) UpdatePermissions(ctx context.Context, req *role.UpdatePermissionsReq) (res *role.UpdatePermissionsRes, err error) {
|
||||
err = service.AdminRole().UpdatePermissions(ctx, &req.UpdatePermissionsInp)
|
||||
return
|
||||
}
|
||||
|
||||
// DataScopeSelect 获取数据权限选项
|
||||
func (c *cRole) DataScopeSelect(_ context.Context, _ *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) {
|
||||
res = new(role.DataScopeSelectRes)
|
||||
res.List = consts.DataScopeSelect
|
||||
return
|
||||
}
|
||||
|
||||
// DataScopeEdit 获取数据权限选项
|
||||
func (c *cRole) DataScopeEdit(ctx context.Context, req *role.DataScopeEditReq) (res *role.DataScopeEditRes, err error) {
|
||||
err = service.AdminRole().DataScopeEdit(ctx, &req.DataScopeEditInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Package common
|
||||
// @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 common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/common"
|
||||
)
|
||||
|
||||
var Console = cConsole{}
|
||||
|
||||
type cConsole struct{}
|
||||
|
||||
// Stat 综合数据统计
|
||||
func (c *cConsole) Stat(_ context.Context, _ *common.ConsoleStatReq) (res *common.ConsoleStatRes, err error) {
|
||||
res = new(common.ConsoleStatRes)
|
||||
|
||||
// 此处均为模拟数据,可以根据实际业务情况替换成真实数据
|
||||
|
||||
res.Visits.DayVisits = 12010
|
||||
res.Visits.Rise = 13501
|
||||
res.Visits.Decline = 10502
|
||||
res.Visits.Amount = 10403
|
||||
|
||||
res.Saleroom.WeekSaleroom = 20501
|
||||
res.Saleroom.Amount = 21002
|
||||
res.Saleroom.Degree = 83.66
|
||||
|
||||
res.OrderLarge.WeekLarge = 39901
|
||||
res.OrderLarge.Rise = 31012
|
||||
res.OrderLarge.Decline = 30603
|
||||
res.OrderLarge.Amount = 36084
|
||||
|
||||
res.Volume.WeekLarge = 40021
|
||||
res.Volume.Rise = 40202
|
||||
res.Volume.Decline = 45003
|
||||
res.Volume.Amount = 49004
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// Package common
|
||||
// @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 common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/api/admin/common"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var Ems = new(cEms)
|
||||
|
||||
type cEms struct{}
|
||||
|
||||
// SendTest 发送测试邮件
|
||||
func (c *cEms) SendTest(ctx context.Context, req *common.SendTestEmailReq) (res *common.SendTestEmailRes, err error) {
|
||||
err = service.SysEmsLog().Send(ctx, &sysin.SendEmsInp{
|
||||
Event: consts.EmsTemplateText,
|
||||
Email: req.To,
|
||||
Content: `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="iso-8859-15">
|
||||
<title>这是一封来自HotGo的测试邮件</title>
|
||||
</head>
|
||||
<body>
|
||||
这是您通过HotGo后台发送的测试邮件。当你收到这封邮件的时候,说明已经联调成功了,恭喜你!
|
||||
</body>
|
||||
</html>`,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// SendBindEms 发送换绑邮件
|
||||
func (c *cEms) SendBindEms(ctx context.Context, _ *common.SendBindEmsReq) (res *common.SendBindEmsRes, err error) {
|
||||
var (
|
||||
memberId = contexts.GetUserId(ctx)
|
||||
models *entity.AdminMember
|
||||
)
|
||||
|
||||
if memberId <= 0 {
|
||||
err = gerror.New("用户身份异常,请重新登录!")
|
||||
return
|
||||
}
|
||||
|
||||
if err = dao.AdminMember.Ctx(ctx).Fields(dao.AdminMember.Columns().Email).Where(dao.AdminMember.Columns().Id, memberId).Scan(&models); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if models == nil {
|
||||
err = gerror.New("用户信息不存在")
|
||||
return
|
||||
}
|
||||
|
||||
if models.Email == "" {
|
||||
err = gerror.New("未绑定邮箱无需发送")
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysEmsLog().Send(ctx, &sysin.SendEmsInp{
|
||||
Event: consts.EmsTemplateBind,
|
||||
Email: models.Email,
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
// Package common
|
||||
// @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 common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/i18n/gi18n"
|
||||
"hotgo/api/admin/common"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/captcha"
|
||||
"hotgo/internal/library/token"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/utility/validate"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/gogf/gf/v2/util/gmode"
|
||||
)
|
||||
|
||||
var Site = cSite{}
|
||||
|
||||
type cSite struct{}
|
||||
|
||||
// Ping ping
|
||||
func (c *cSite) Ping(_ context.Context, _ *common.SitePingReq) (res *common.SitePingRes, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Config 获取配置
|
||||
func (c *cSite) Config(ctx context.Context, _ *common.SiteConfigReq) (res *common.SiteConfigRes, err error) {
|
||||
request := ghttp.RequestFromCtx(ctx)
|
||||
res = &common.SiteConfigRes{
|
||||
Version: consts.VersionApp,
|
||||
WsAddr: c.getWsAddr(ctx, request),
|
||||
Domain: c.getDomain(ctx, request),
|
||||
Mode: gmode.Mode(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c *cSite) getWsAddr(ctx context.Context, request *ghttp.Request) string {
|
||||
// 如果是本地IP访问,则认为是调试模式,走实际请求地址,否则走配置中的地址
|
||||
// 尝试读取hostname,兼容本地运行模式
|
||||
ip := ghttp.RequestFromCtx(ctx).GetHeader("hostname")
|
||||
if len(ip) == 0 {
|
||||
ip = ghttp.RequestFromCtx(ctx).GetHost()
|
||||
}
|
||||
|
||||
if validate.IsLocalIPAddr(ip) {
|
||||
return "ws://" + ip + ":" + gstr.StrEx(request.Host, ":") + g.Cfg().MustGet(ctx, "router.websocket.prefix").String()
|
||||
}
|
||||
|
||||
basic, err := service.SysConfig().GetBasic(ctx)
|
||||
if err != nil || basic == nil {
|
||||
return ""
|
||||
}
|
||||
return basic.WsAddr
|
||||
}
|
||||
|
||||
func (c *cSite) getDomain(ctx context.Context, request *ghttp.Request) string {
|
||||
// 如果是本地IP访问,则认为是调试模式,走实际请求地址,否则走配置中的地址
|
||||
// 尝试读取hostname,兼容本地运行模式
|
||||
ip := ghttp.RequestFromCtx(ctx).GetHeader("hostname")
|
||||
if len(ip) == 0 {
|
||||
ip = ghttp.RequestFromCtx(ctx).GetHost()
|
||||
}
|
||||
|
||||
if validate.IsLocalIPAddr(ip) {
|
||||
return "http://" + ip + ":" + gstr.StrEx(request.Host, ":")
|
||||
}
|
||||
|
||||
basic, err := service.SysConfig().GetBasic(ctx)
|
||||
if err != nil || basic == nil {
|
||||
return ""
|
||||
}
|
||||
return basic.Domain
|
||||
}
|
||||
|
||||
// LoginConfig 登录配置
|
||||
func (c *cSite) LoginConfig(ctx context.Context, _ *common.SiteLoginConfigReq) (res *common.SiteLoginConfigRes, err error) {
|
||||
res = new(common.SiteLoginConfigRes)
|
||||
login, err := service.SysConfig().GetLogin(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res.LoginConfig = login
|
||||
res.I18nSwitch = g.Cfg().MustGet(ctx, "system.i18n.switch", true).Bool()
|
||||
res.DefaultLanguage = g.Cfg().MustGet(ctx, "system.i18n.defaultLanguage", consts.SysDefaultLanguage).String()
|
||||
res.ProjectName = gi18n.T(ctx, "HotGo管理系统")
|
||||
return
|
||||
}
|
||||
|
||||
// Captcha 登录验证码
|
||||
func (c *cSite) Captcha(ctx context.Context, _ *common.LoginCaptchaReq) (res *common.LoginCaptchaRes, err error) {
|
||||
loginConf, err := service.SysConfig().GetLogin(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
cid, base64 := captcha.Generate(ctx, loginConf.CaptchaType)
|
||||
res = &common.LoginCaptchaRes{Cid: cid, Base64: base64}
|
||||
return
|
||||
}
|
||||
|
||||
// Register 账号注册
|
||||
func (c *cSite) Register(ctx context.Context, req *common.RegisterReq) (res *common.RegisterRes, err error) {
|
||||
err = service.AdminSite().Register(ctx, &req.RegisterInp)
|
||||
return
|
||||
}
|
||||
|
||||
// AccountLogin 账号登录
|
||||
func (c *cSite) AccountLogin(ctx context.Context, req *common.AccountLoginReq) (res *common.AccountLoginRes, err error) {
|
||||
login, err := service.SysConfig().GetLogin(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !req.IsLock && login.CaptchaSwitch == consts.StatusEnabled {
|
||||
// 校验 验证码
|
||||
if !captcha.Verify(req.Cid, req.Code) {
|
||||
err = gerror.New("验证码错误")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
model, err := service.AdminSite().AccountLogin(ctx, &req.AccountLoginInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = gconv.Scan(model, &res)
|
||||
return
|
||||
}
|
||||
|
||||
// MobileLogin 手机号登录
|
||||
func (c *cSite) MobileLogin(ctx context.Context, req *common.MobileLoginReq) (res *common.MobileLoginRes, err error) {
|
||||
model, err := service.AdminSite().MobileLogin(ctx, &req.MobileLoginInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = gconv.Scan(model, &res)
|
||||
return
|
||||
}
|
||||
|
||||
// Logout 注销登录
|
||||
func (c *cSite) Logout(ctx context.Context, _ *common.LoginLogoutReq) (res *common.LoginLogoutRes, err error) {
|
||||
err = token.Logout(ghttp.RequestFromCtx(ctx))
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Package common
|
||||
// @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 common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/api/admin/common"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var Sms = new(cSms)
|
||||
|
||||
type cSms struct{}
|
||||
|
||||
// SendTest 发送测试短信
|
||||
func (c *cSms) SendTest(ctx context.Context, req *common.SendTestSmsReq) (res *common.SendTestSmsRes, err error) {
|
||||
err = service.SysSmsLog().SendCode(ctx, &req.SendCodeInp)
|
||||
return
|
||||
}
|
||||
|
||||
// SendBindSms 发送换绑短信
|
||||
func (c *cSms) SendBindSms(ctx context.Context, _ *common.SendBindSmsReq) (res *common.SendBindSmsRes, err error) {
|
||||
var (
|
||||
memberId = contexts.GetUserId(ctx)
|
||||
models *entity.AdminMember
|
||||
)
|
||||
|
||||
if memberId <= 0 {
|
||||
err = gerror.New("用户身份异常,请重新登录!")
|
||||
return
|
||||
}
|
||||
|
||||
if err = dao.AdminMember.Ctx(ctx).Fields(dao.AdminMember.Columns().Mobile).Where(dao.AdminMember.Columns().Id, memberId).Scan(&models); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if models == nil {
|
||||
err = gerror.New("用户信息不存在")
|
||||
return
|
||||
}
|
||||
|
||||
if models.Mobile == "" {
|
||||
err = gerror.New("未绑定手机号无需发送")
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysSmsLog().SendCode(ctx, &sysin.SendCodeInp{
|
||||
Event: consts.SmsTemplateBind,
|
||||
Mobile: models.Mobile,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// SendSms 发送短信
|
||||
func (c *cSms) SendSms(ctx context.Context, req *common.SendSmsReq) (res *common.SendSmsRes, err error) {
|
||||
err = service.SysSmsLog().SendCode(ctx, &req.SendCodeInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// Package common
|
||||
// @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 common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/api/admin/common"
|
||||
"hotgo/internal/library/storager"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
var Upload = new(cUpload)
|
||||
|
||||
type cUpload struct{}
|
||||
|
||||
// UploadFile 上传文件
|
||||
func (c *cUpload) UploadFile(ctx context.Context, _ *common.UploadFileReq) (res common.UploadFileRes, err error) {
|
||||
r := g.RequestFromCtx(ctx)
|
||||
uploadType := r.Header.Get("uploadType")
|
||||
if uploadType != "default" && !validate.InSlice(storager.KindSlice, uploadType) {
|
||||
err = gerror.New("上传类型是无效的")
|
||||
return
|
||||
}
|
||||
|
||||
file := r.GetUploadFile("file")
|
||||
if file == nil {
|
||||
err = gerror.New("没有找到上传的文件")
|
||||
return
|
||||
}
|
||||
return service.CommonUpload().UploadFile(ctx, uploadType, file)
|
||||
}
|
||||
|
||||
// CheckMultipart 检查文件分片
|
||||
func (c *cUpload) CheckMultipart(ctx context.Context, req *common.CheckMultipartReq) (res *common.CheckMultipartRes, err error) {
|
||||
data, err := service.CommonUpload().CheckMultipart(ctx, &req.CheckMultipartInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = new(common.CheckMultipartRes)
|
||||
res.CheckMultipartModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// UploadPart 上传分片
|
||||
func (c *cUpload) UploadPart(ctx context.Context, req *common.UploadPartReq) (res *common.UploadPartRes, err error) {
|
||||
data, err := service.CommonUpload().UploadPart(ctx, &req.UploadPartInp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = new(common.UploadPartRes)
|
||||
res.UploadPartModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// ImageTransferStorage 图片链接转存
|
||||
func (c *cUpload) ImageTransferStorage(ctx context.Context, req *common.ImageTransferStorageReq) (res *common.ImageTransferStorageRes, err error) {
|
||||
res = new(common.ImageTransferStorageRes)
|
||||
res.ImageTransferStorageModel, err = service.CommonUpload().ImageTransferStorage(ctx, &req.ImageTransferStorageInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Package common
|
||||
// @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 common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/common"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Wechat = cWechat{}
|
||||
)
|
||||
|
||||
type cWechat struct{}
|
||||
|
||||
func (c *cWechat) Authorize(ctx context.Context, req *common.WechatAuthorizeReq) (res *common.WechatAuthorizeRes, err error) {
|
||||
_, err = service.CommonWechat().Authorize(ctx, &req.WechatAuthorizeInp)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *cWechat) AuthorizeCall(ctx context.Context, req *common.WechatAuthorizeCallReq) (res *common.WechatAuthorizeCallRes, err error) {
|
||||
_, err = service.CommonWechat().AuthorizeCall(ctx, &req.WechatAuthorizeCallInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Package pay
|
||||
// @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
|
||||
// @AutoGenerate Version 2.5.3
|
||||
// @AutoGenerate Date 2023-04-15 15:59:58
|
||||
package pay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/pay"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Refund = cRefund{}
|
||||
)
|
||||
|
||||
type cRefund struct{}
|
||||
|
||||
// List 查看交易退款列表
|
||||
func (c *cRefund) List(ctx context.Context, req *pay.RefundListReq) (res *pay.RefundListRes, err error) {
|
||||
list, totalCount, err := service.PayRefund().List(ctx, &req.PayRefundListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(pay.RefundListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出交易退款列表
|
||||
func (c *cRefund) Export(ctx context.Context, req *pay.RefundExportReq) (res *pay.RefundExportRes, err error) {
|
||||
err = service.PayRefund().Export(ctx, &req.PayRefundListInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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/api/admin/addons"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Addons = cAddons{}
|
||||
)
|
||||
|
||||
type cAddons struct{}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cAddons) List(ctx context.Context, req *addons.ListReq) (res *addons.ListRes, err error) {
|
||||
list, totalCount, err := service.SysAddons().List(ctx, &req.AddonsListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(addons.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Build 生成预览
|
||||
func (c *cAddons) Build(ctx context.Context, req *addons.BuildReq) (res *addons.BuildRes, err error) {
|
||||
err = service.SysAddons().Build(ctx, &req.AddonsBuildInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Install 安装模块
|
||||
func (c *cAddons) Install(ctx context.Context, req *addons.InstallReq) (res *addons.InstallRes, err error) {
|
||||
if err = service.SysAddons().Install(ctx, &req.AddonsInstallInp); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Upgrade 更新模块
|
||||
func (c *cAddons) Upgrade(ctx context.Context, req *addons.UpgradeReq) (res *addons.UpgradeRes, err error) {
|
||||
if err = service.SysAddons().Upgrade(ctx, &req.AddonsUpgradeInp); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// UnInstall 卸载模块
|
||||
func (c *cAddons) UnInstall(ctx context.Context, req *addons.UnInstallReq) (res *addons.UnInstallRes, err error) {
|
||||
if err = service.SysAddons().UnInstall(ctx, &req.AddonsUnInstallInp); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// 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/api/admin/attachment"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Attachment = cAttachment{}
|
||||
)
|
||||
|
||||
type cAttachment struct{}
|
||||
|
||||
// Delete 删除附件
|
||||
func (c *cAttachment) Delete(ctx context.Context, req *attachment.DeleteReq) (res *attachment.DeleteRes, err error) {
|
||||
err = service.SysAttachment().Delete(ctx, &req.AttachmentDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定附件信息
|
||||
func (c *cAttachment) View(ctx context.Context, req *attachment.ViewReq) (res *attachment.ViewRes, err error) {
|
||||
data, err := service.SysAttachment().View(ctx, &req.AttachmentViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(attachment.ViewRes)
|
||||
res.AttachmentViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看附件列表
|
||||
func (c *cAttachment) List(ctx context.Context, req *attachment.ListReq) (res *attachment.ListRes, err error) {
|
||||
list, totalCount, err := service.SysAttachment().List(ctx, &req.AttachmentListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(attachment.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// ClearKind 清空上传类型
|
||||
func (c *cAttachment) ClearKind(ctx context.Context, req *attachment.ClearKindReq) (res *attachment.ClearKindRes, err error) {
|
||||
err = service.SysAttachment().ClearKind(ctx, &req.AttachmentClearKindInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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/api/admin/blacklist"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Blacklist = cBlacklist{}
|
||||
)
|
||||
|
||||
type cBlacklist struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cBlacklist) Delete(ctx context.Context, req *blacklist.DeleteReq) (res *blacklist.DeleteRes, err error) {
|
||||
err = service.SysBlacklist().Delete(ctx, &req.BlacklistDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cBlacklist) Edit(ctx context.Context, req *blacklist.EditReq) (res *blacklist.EditRes, err error) {
|
||||
err = service.SysBlacklist().Edit(ctx, &req.BlacklistEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cBlacklist) View(ctx context.Context, req *blacklist.ViewReq) (res *blacklist.ViewRes, err error) {
|
||||
data, err := service.SysBlacklist().View(ctx, &req.BlacklistViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(blacklist.ViewRes)
|
||||
res.BlacklistViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cBlacklist) List(ctx context.Context, req *blacklist.ListReq) (res *blacklist.ListRes, err error) {
|
||||
list, totalCount, err := service.SysBlacklist().List(ctx, &req.BlacklistListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(blacklist.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新黑名单状态
|
||||
func (c *cBlacklist) Status(ctx context.Context, req *blacklist.StatusReq) (res *blacklist.StatusRes, err error) {
|
||||
err = service.SysBlacklist().Status(ctx, &req.BlacklistStatusInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// 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/api/admin/config"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Config = cConfig{}
|
||||
)
|
||||
|
||||
type cConfig struct{}
|
||||
|
||||
// GetConfig 获取指定分组的配置
|
||||
func (c *cConfig) GetConfig(ctx context.Context, req *config.GetReq) (res *config.GetRes, err error) {
|
||||
res = new(config.GetRes)
|
||||
res.GetConfigModel, err = service.SysConfig().GetConfigByGroup(ctx, &req.GetConfigInp)
|
||||
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
|
||||
}
|
||||
|
||||
// TypeSelect 数据类型选项
|
||||
func (c *cConfig) TypeSelect(_ context.Context, _ *config.TypeSelectReq) (res config.TypeSelectRes, err error) {
|
||||
for _, v := range consts.ConfigTypes {
|
||||
res = append(res, form.Select{
|
||||
Value: v,
|
||||
Name: v,
|
||||
Label: v,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetCash 获取提现的配置
|
||||
func (c *cConfig) GetCash(ctx context.Context, _ *config.GetCashReq) (res *config.GetCashRes, err error) {
|
||||
res = new(config.GetCashRes)
|
||||
res.GetConfigModel, err = service.SysConfig().GetConfigByGroup(ctx, &sysin.GetConfigInp{Group: "cash"})
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
// 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/errors/gerror"
|
||||
"hotgo/api/admin/cron"
|
||||
"hotgo/api/servmsg"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Cron = cCron{}
|
||||
)
|
||||
|
||||
type cCron struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cCron) Delete(ctx context.Context, req *cron.DeleteReq) (res *cron.DeleteRes, err error) {
|
||||
err = service.TCPServer().CronDelete(ctx, &servmsg.CronDeleteReq{CronDeleteInp: &req.CronDeleteInp})
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cCron) Edit(ctx context.Context, req *cron.EditReq) (res *cron.EditRes, err error) {
|
||||
err = service.TCPServer().CronEdit(ctx, &servmsg.CronEditReq{CronEditInp: &req.CronEditInp})
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (c *cCron) MaxSort(ctx context.Context, req *cron.MaxSortReq) (res *cron.MaxSortRes, err error) {
|
||||
res = new(cron.MaxSortRes)
|
||||
res.CronMaxSortModel, err = service.SysCron().MaxSort(ctx, &req.CronMaxSortInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cCron) View(ctx context.Context, req *cron.ViewReq) (res *cron.ViewRes, err error) {
|
||||
data, err := service.SysCron().View(ctx, &req.CronViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(cron.ViewRes)
|
||||
res.CronViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cCron) List(ctx context.Context, req *cron.ListReq) (res *cron.ListRes, err error) {
|
||||
list, totalCount, err := service.SysCron().List(ctx, &req.CronListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(cron.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (c *cCron) Status(ctx context.Context, req *cron.StatusReq) (res *cron.StatusRes, err error) {
|
||||
if req.Id <= 0 {
|
||||
return nil, gerror.New("定时任务ID不能为空")
|
||||
}
|
||||
|
||||
err = service.TCPServer().CronStatus(ctx, &servmsg.CronStatusReq{CronStatusInp: &req.CronStatusInp})
|
||||
return
|
||||
}
|
||||
|
||||
// OnlineExec 在线执行
|
||||
func (c *cCron) OnlineExec(ctx context.Context, req *cron.OnlineExecReq) (res *cron.OnlineExecRes, err error) {
|
||||
if req.Id <= 0 {
|
||||
return nil, gerror.New("定时任务ID不能为空")
|
||||
}
|
||||
|
||||
err = service.TCPServer().CronOnlineExec(ctx, &servmsg.CronOnlineExecReq{OnlineExecInp: &req.OnlineExecInp})
|
||||
return
|
||||
}
|
||||
|
||||
// DispatchLog 调度日志
|
||||
func (c *cCron) DispatchLog(ctx context.Context, req *cron.DispatchLogReq) (res *cron.DispatchLogRes, err error) {
|
||||
if req.Id <= 0 {
|
||||
return nil, gerror.New("定时任务ID不能为空")
|
||||
}
|
||||
|
||||
res = new(cron.DispatchLogRes)
|
||||
res.DispatchLogModel = new(sysin.DispatchLogModel)
|
||||
res.Log, err = service.TCPServer().DispatchLog(ctx, &servmsg.CronDispatchLogReq{DispatchLogInp: &req.DispatchLogInp})
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// 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/api/admin/cron"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
CronGroup = cCronGroup{}
|
||||
)
|
||||
|
||||
type cCronGroup struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cCronGroup) Delete(ctx context.Context, req *cron.GroupDeleteReq) (res *cron.GroupDeleteRes, err error) {
|
||||
err = service.SysCronGroup().Delete(ctx, &req.CronGroupDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cCronGroup) Edit(ctx context.Context, req *cron.GroupEditReq) (res *cron.GroupEditRes, err error) {
|
||||
err = service.SysCronGroup().Edit(ctx, &req.CronGroupEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (c *cCronGroup) MaxSort(ctx context.Context, req *cron.GroupMaxSortReq) (res *cron.GroupMaxSortRes, err error) {
|
||||
res = new(cron.GroupMaxSortRes)
|
||||
res.CronGroupMaxSortModel, err = service.SysCronGroup().MaxSort(ctx, &req.CronGroupMaxSortInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cCronGroup) View(ctx context.Context, req *cron.GroupViewReq) (res *cron.GroupViewRes, err error) {
|
||||
data, err := service.SysCronGroup().View(ctx, &req.CronGroupViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(cron.GroupViewRes)
|
||||
res.CronGroupViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cCronGroup) List(ctx context.Context, req *cron.GroupListReq) (res *cron.GroupListRes, err error) {
|
||||
list, totalCount, err := service.SysCronGroup().List(ctx, &req.CronGroupListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(cron.GroupListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (c *cCronGroup) Status(ctx context.Context, req *cron.GroupStatusReq) (res *cron.GroupStatusRes, err error) {
|
||||
err = service.SysCronGroup().Status(ctx, &req.CronGroupStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Select 选项
|
||||
func (c *cCronGroup) Select(ctx context.Context, req *cron.GroupSelectReq) (res *cron.GroupSelectRes, err error) {
|
||||
data, err := service.SysCronGroup().Select(ctx, &req.CronGroupSelectInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(cron.GroupSelectRes)
|
||||
res.CronGroupSelectModel = data
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2025 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.18.6
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/curddemo"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
CurdDemo = cCurdDemo{}
|
||||
)
|
||||
|
||||
type cCurdDemo struct{}
|
||||
|
||||
// List 查看CURD列表列表
|
||||
func (c *cCurdDemo) List(ctx context.Context, req *curddemo.ListReq) (res *curddemo.ListRes, err error) {
|
||||
list, totalCount, err := service.SysCurdDemo().List(ctx, &req.CurdDemoListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if list == nil {
|
||||
list = []*sysin.CurdDemoListModel{}
|
||||
}
|
||||
|
||||
res = new(curddemo.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出CURD列表列表
|
||||
func (c *cCurdDemo) Export(ctx context.Context, req *curddemo.ExportReq) (res *curddemo.ExportRes, err error) {
|
||||
err = service.SysCurdDemo().Export(ctx, &req.CurdDemoListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新CURD列表
|
||||
func (c *cCurdDemo) Edit(ctx context.Context, req *curddemo.EditReq) (res *curddemo.EditRes, err error) {
|
||||
err = service.SysCurdDemo().Edit(ctx, &req.CurdDemoEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 获取CURD列表最大排序
|
||||
func (c *cCurdDemo) MaxSort(ctx context.Context, req *curddemo.MaxSortReq) (res *curddemo.MaxSortRes, err error) {
|
||||
data, err := service.SysCurdDemo().MaxSort(ctx, &req.CurdDemoMaxSortInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(curddemo.MaxSortRes)
|
||||
res.CurdDemoMaxSortModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定CURD列表信息
|
||||
func (c *cCurdDemo) View(ctx context.Context, req *curddemo.ViewReq) (res *curddemo.ViewRes, err error) {
|
||||
data, err := service.SysCurdDemo().View(ctx, &req.CurdDemoViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(curddemo.ViewRes)
|
||||
res.CurdDemoViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除CURD列表
|
||||
func (c *cCurdDemo) Delete(ctx context.Context, req *curddemo.DeleteReq) (res *curddemo.DeleteRes, err error) {
|
||||
err = service.SysCurdDemo().Delete(ctx, &req.CurdDemoDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新CURD列表状态
|
||||
func (c *cCurdDemo) Status(ctx context.Context, req *curddemo.StatusReq) (res *curddemo.StatusRes, err error) {
|
||||
err = service.SysCurdDemo().Status(ctx, &req.CurdDemoStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Switch 更新CURD列表开关状态
|
||||
func (c *cCurdDemo) Switch(ctx context.Context, req *curddemo.SwitchReq) (res *curddemo.SwitchRes, err error) {
|
||||
err = service.SysCurdDemo().Switch(ctx, &req.CurdDemoSwitchInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// 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/api/admin/dict"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
DictData = cDictData{}
|
||||
)
|
||||
|
||||
type cDictData struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cDictData) Delete(ctx context.Context, req *dict.DataDeleteReq) (res *dict.DataDeleteRes, err error) {
|
||||
err = service.SysDictData().Delete(ctx, &req.DictDataDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cDictData) Edit(ctx context.Context, req *dict.DataEditReq) (res *dict.DataEditRes, err error) {
|
||||
err = service.SysDictData().Edit(ctx, &req.DictDataEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cDictData) List(ctx context.Context, req *dict.DataListReq) (res *dict.DataListRes, err error) {
|
||||
list, totalCount, err := service.SysDictData().List(ctx, &req.DictDataListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(dict.DataListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Select 指定选项
|
||||
func (c *cDictData) Select(ctx context.Context, req *dict.DataSelectReq) (res dict.DataSelectRes, err error) {
|
||||
list, err := service.SysDictData().Select(ctx, &req.DataSelectInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = dict.DataSelectRes(list)
|
||||
return
|
||||
}
|
||||
|
||||
// Selects 多个选项
|
||||
func (c *cDictData) Selects(ctx context.Context, req *dict.DataSelectsReq) (res dict.DataSelectsRes, err error) {
|
||||
res = make(dict.DataSelectsRes)
|
||||
for _, v := range req.Types {
|
||||
option, err := service.SysDictData().Select(ctx, &sysin.DataSelectInp{Type: v})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res[v] = option
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// 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/api/admin/dict"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
DictType = cDictType{}
|
||||
)
|
||||
|
||||
type cDictType struct{}
|
||||
|
||||
// Tree 树
|
||||
func (c *cDictType) Tree(ctx context.Context, _ *dict.TypeTreeReq) (res *dict.TypeTreeRes, err error) {
|
||||
res = new(dict.TypeTreeRes)
|
||||
res.List, err = service.SysDictType().Tree(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cDictType) Delete(ctx context.Context, req *dict.TypeDeleteReq) (res *dict.TypeDeleteRes, err error) {
|
||||
err = service.SysDictType().Delete(ctx, &req.DictTypeDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cDictType) Edit(ctx context.Context, req *dict.TypeEditReq) (res *dict.TypeEditRes, err error) {
|
||||
err = service.SysDictType().Edit(ctx, &req.DictTypeEditInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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/api/admin/emslog"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
EmsLog = cEmsLog{}
|
||||
)
|
||||
|
||||
type cEmsLog struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cEmsLog) Delete(ctx context.Context, req *emslog.DeleteReq) (res *emslog.DeleteRes, err error) {
|
||||
err = service.SysEmsLog().Delete(ctx, &req.EmsLogDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cEmsLog) Edit(ctx context.Context, req *emslog.EditReq) (res *emslog.EditRes, err error) {
|
||||
err = service.SysEmsLog().Edit(ctx, &req.EmsLogEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cEmsLog) View(ctx context.Context, req *emslog.ViewReq) (res *emslog.ViewRes, err error) {
|
||||
data, err := service.SysEmsLog().View(ctx, &req.EmsLogViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(emslog.ViewRes)
|
||||
res.EmsLogViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cEmsLog) List(ctx context.Context, req *emslog.ListReq) (res *emslog.ListRes, err error) {
|
||||
list, totalCount, err := service.SysEmsLog().List(ctx, &req.EmsLogListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(emslog.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (c *cEmsLog) Status(ctx context.Context, req *emslog.StatusReq) (res *emslog.StatusRes, err error) {
|
||||
err = service.SysEmsLog().Status(ctx, &req.EmsLogStatusInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
// 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/api/admin/gencodes"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
GenCodes = cGenCodes{}
|
||||
)
|
||||
|
||||
type cGenCodes struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cGenCodes) Delete(ctx context.Context, req *gencodes.DeleteReq) (res *gencodes.DeleteRes, err error) {
|
||||
err = service.SysGenCodes().Delete(ctx, &req.GenCodesDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cGenCodes) Edit(ctx context.Context, req *gencodes.EditReq) (res *gencodes.EditRes, err error) {
|
||||
data, err := service.SysGenCodes().Edit(ctx, &req.GenCodesEditInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(gencodes.EditRes)
|
||||
res.GenCodesEditModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (c *cGenCodes) MaxSort(ctx context.Context, req *gencodes.MaxSortReq) (res *gencodes.MaxSortRes, err error) {
|
||||
res = new(gencodes.MaxSortRes)
|
||||
res.GenCodesMaxSortModel, err = service.SysGenCodes().MaxSort(ctx, &req.GenCodesMaxSortInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cGenCodes) View(ctx context.Context, req *gencodes.ViewReq) (res *gencodes.ViewRes, err error) {
|
||||
data, err := service.SysGenCodes().View(ctx, &req.GenCodesViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(gencodes.ViewRes)
|
||||
res.GenCodesViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cGenCodes) List(ctx context.Context, req *gencodes.ListReq) (res *gencodes.ListRes, err error) {
|
||||
list, totalCount, err := service.SysGenCodes().List(ctx, &req.GenCodesListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(gencodes.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (c *cGenCodes) Status(ctx context.Context, req *gencodes.StatusReq) (res *gencodes.StatusRes, err error) {
|
||||
err = service.SysGenCodes().Status(ctx, &req.GenCodesStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Selects 获取指定信息
|
||||
func (c *cGenCodes) Selects(ctx context.Context, req *gencodes.SelectsReq) (res *gencodes.SelectsRes, err error) {
|
||||
data, err := service.SysGenCodes().Selects(ctx, &req.GenCodesSelectsInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(gencodes.SelectsRes)
|
||||
res.GenCodesSelectsModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// TableSelect 数据库表选项
|
||||
func (c *cGenCodes) TableSelect(ctx context.Context, req *gencodes.TableSelectReq) (res *gencodes.TableSelectRes, err error) {
|
||||
data, err := service.SysGenCodes().TableSelect(ctx, &req.GenCodesTableSelectInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = (*gencodes.TableSelectRes)(&data)
|
||||
return
|
||||
}
|
||||
|
||||
// ColumnSelect 表字段选项
|
||||
func (c *cGenCodes) ColumnSelect(ctx context.Context, req *gencodes.ColumnSelectReq) (res *gencodes.ColumnSelectRes, err error) {
|
||||
data, err := service.SysGenCodes().ColumnSelect(ctx, &req.GenCodesColumnSelectInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = (*gencodes.ColumnSelectRes)(&data)
|
||||
return
|
||||
}
|
||||
|
||||
// ColumnList 表字段列表
|
||||
func (c *cGenCodes) ColumnList(ctx context.Context, req *gencodes.ColumnListReq) (res *gencodes.ColumnListRes, err error) {
|
||||
data, err := service.SysGenCodes().ColumnList(ctx, &req.GenCodesColumnListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = (*gencodes.ColumnListRes)(&data)
|
||||
return
|
||||
}
|
||||
|
||||
// Preview 生成预览
|
||||
func (c *cGenCodes) Preview(ctx context.Context, req *gencodes.PreviewReq) (res *gencodes.PreviewRes, err error) {
|
||||
data, err := service.SysGenCodes().Preview(ctx, &req.GenCodesPreviewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(gencodes.PreviewRes)
|
||||
res.GenCodesPreviewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Build 生成预览
|
||||
func (c *cGenCodes) Build(ctx context.Context, req *gencodes.BuildReq) (res *gencodes.BuildRes, err error) {
|
||||
err = service.SysGenCodes().Build(ctx, &req.GenCodesBuildInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// 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/errors/gerror"
|
||||
"hotgo/api/admin/log"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// Log 日志
|
||||
var Log = sLog{}
|
||||
|
||||
type sLog struct{}
|
||||
|
||||
// Clear 清空日志
|
||||
func (c *sLog) Clear(ctx context.Context, _ *log.ClearReq) (res *log.ClearRes, err error) {
|
||||
err = gerror.New("暂时考虑到安全问题,请到数据库清空")
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出
|
||||
func (c *sLog) Export(ctx context.Context, req *log.ExportReq) (res *log.ExportRes, err error) {
|
||||
err = service.SysLog().Export(ctx, &req.LogListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// List 获取访问日志列表
|
||||
func (c *sLog) List(ctx context.Context, req *log.ListReq) (res *log.ListRes, err error) {
|
||||
list, totalCount, err := service.SysLog().List(ctx, &req.LogListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(log.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *sLog) View(ctx context.Context, req *log.ViewReq) (res *log.ViewRes, err error) {
|
||||
res = new(log.ViewRes)
|
||||
res.LogViewModel, err = service.SysLog().View(ctx, &req.LogViewInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (c *sLog) Delete(ctx context.Context, req *log.DeleteReq) (res *log.DeleteRes, err error) {
|
||||
err = service.SysLog().Delete(ctx, &req.LogDeleteInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// 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
|
||||
// @AutoGenerate Version 2.1.1
|
||||
// @AutoGenerate Date 2023-01-19 16:57:33
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/loginlog"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
LoginLog = cLoginLog{}
|
||||
)
|
||||
|
||||
type cLoginLog struct{}
|
||||
|
||||
// List 查看登录日志列表
|
||||
func (c *cLoginLog) List(ctx context.Context, req *loginlog.ListReq) (res *loginlog.ListRes, err error) {
|
||||
list, totalCount, err := service.SysLoginLog().List(ctx, &req.LoginLogListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(loginlog.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出登录日志列表
|
||||
func (c *cLoginLog) Export(ctx context.Context, req *loginlog.ExportReq) (res *loginlog.ExportRes, err error) {
|
||||
err = service.SysLoginLog().Export(ctx, &req.LoginLogListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除登录日志
|
||||
func (c *cLoginLog) Delete(ctx context.Context, req *loginlog.DeleteReq) (res *loginlog.DeleteRes, err error) {
|
||||
err = service.SysLoginLog().Delete(ctx, &req.LoginLogDeleteInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
// 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.15.7
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/normaltreedemo"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
NormalTreeDemo = cNormalTreeDemo{}
|
||||
)
|
||||
|
||||
type cNormalTreeDemo struct{}
|
||||
|
||||
// List 查看普通树表列表
|
||||
func (c *cNormalTreeDemo) List(ctx context.Context, req *normaltreedemo.ListReq) (res *normaltreedemo.ListRes, err error) {
|
||||
list, totalCount, err := service.SysNormalTreeDemo().List(ctx, &req.NormalTreeDemoListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if list == nil {
|
||||
list = []*sysin.NormalTreeDemoListModel{}
|
||||
}
|
||||
|
||||
res = new(normaltreedemo.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新普通树表
|
||||
func (c *cNormalTreeDemo) Edit(ctx context.Context, req *normaltreedemo.EditReq) (res *normaltreedemo.EditRes, err error) {
|
||||
err = service.SysNormalTreeDemo().Edit(ctx, &req.NormalTreeDemoEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 获取普通树表最大排序
|
||||
func (c *cNormalTreeDemo) MaxSort(ctx context.Context, req *normaltreedemo.MaxSortReq) (res *normaltreedemo.MaxSortRes, err error) {
|
||||
data, err := service.SysNormalTreeDemo().MaxSort(ctx, &req.NormalTreeDemoMaxSortInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(normaltreedemo.MaxSortRes)
|
||||
res.NormalTreeDemoMaxSortModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定普通树表信息
|
||||
func (c *cNormalTreeDemo) View(ctx context.Context, req *normaltreedemo.ViewReq) (res *normaltreedemo.ViewRes, err error) {
|
||||
data, err := service.SysNormalTreeDemo().View(ctx, &req.NormalTreeDemoViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(normaltreedemo.ViewRes)
|
||||
res.NormalTreeDemoViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除普通树表
|
||||
func (c *cNormalTreeDemo) Delete(ctx context.Context, req *normaltreedemo.DeleteReq) (res *normaltreedemo.DeleteRes, err error) {
|
||||
err = service.SysNormalTreeDemo().Delete(ctx, &req.NormalTreeDemoDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// TreeOption 获取普通树表关系树选项
|
||||
func (c *cNormalTreeDemo) TreeOption(ctx context.Context, req *normaltreedemo.TreeOptionReq) (res *normaltreedemo.TreeOptionRes, err error) {
|
||||
data, err := service.SysNormalTreeDemo().TreeOption(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(data) > 0 {
|
||||
res = (*normaltreedemo.TreeOptionRes)(&data)
|
||||
} else {
|
||||
temp := make(normaltreedemo.TreeOptionRes, 0)
|
||||
res = &temp
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2025 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.17.8
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/optiontreedemo"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
OptionTreeDemo = cOptionTreeDemo{}
|
||||
)
|
||||
|
||||
type cOptionTreeDemo struct{}
|
||||
|
||||
// List 查看选项树表列表
|
||||
func (c *cOptionTreeDemo) List(ctx context.Context, req *optiontreedemo.ListReq) (res *optiontreedemo.ListRes, err error) {
|
||||
list, totalCount, err := service.SysOptionTreeDemo().List(ctx, &req.OptionTreeDemoListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if list == nil {
|
||||
list = []*sysin.OptionTreeDemoListModel{}
|
||||
}
|
||||
|
||||
res = new(optiontreedemo.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新选项树表
|
||||
func (c *cOptionTreeDemo) Edit(ctx context.Context, req *optiontreedemo.EditReq) (res *optiontreedemo.EditRes, err error) {
|
||||
err = service.SysOptionTreeDemo().Edit(ctx, &req.OptionTreeDemoEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 获取选项树表最大排序
|
||||
func (c *cOptionTreeDemo) MaxSort(ctx context.Context, req *optiontreedemo.MaxSortReq) (res *optiontreedemo.MaxSortRes, err error) {
|
||||
data, err := service.SysOptionTreeDemo().MaxSort(ctx, &req.OptionTreeDemoMaxSortInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(optiontreedemo.MaxSortRes)
|
||||
res.OptionTreeDemoMaxSortModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定选项树表信息
|
||||
func (c *cOptionTreeDemo) View(ctx context.Context, req *optiontreedemo.ViewReq) (res *optiontreedemo.ViewRes, err error) {
|
||||
data, err := service.SysOptionTreeDemo().View(ctx, &req.OptionTreeDemoViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(optiontreedemo.ViewRes)
|
||||
res.OptionTreeDemoViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除选项树表
|
||||
func (c *cOptionTreeDemo) Delete(ctx context.Context, req *optiontreedemo.DeleteReq) (res *optiontreedemo.DeleteRes, err error) {
|
||||
err = service.SysOptionTreeDemo().Delete(ctx, &req.OptionTreeDemoDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// TreeOption 获取选项树表关系树选项
|
||||
func (c *cOptionTreeDemo) TreeOption(ctx context.Context, req *optiontreedemo.TreeOptionReq) (res *optiontreedemo.TreeOptionRes, err error) {
|
||||
data, err := service.SysOptionTreeDemo().TreeOption(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(data) > 0 {
|
||||
res = (*optiontreedemo.TreeOptionRes)(&data)
|
||||
} else {
|
||||
temp := make(optiontreedemo.TreeOptionRes, 0)
|
||||
res = &temp
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// 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/api/admin/provinces"
|
||||
"hotgo/internal/library/location"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Provinces = cProvinces{}
|
||||
)
|
||||
|
||||
type cProvinces struct{}
|
||||
|
||||
// Tree 关系树选项列表
|
||||
func (c *cProvinces) Tree(ctx context.Context, _ *provinces.TreeReq) (res *provinces.TreeRes, err error) {
|
||||
res = new(provinces.TreeRes)
|
||||
res.List, err = service.SysProvinces().Tree(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cProvinces) Delete(ctx context.Context, req *provinces.DeleteReq) (res *provinces.DeleteRes, err error) {
|
||||
err = service.SysProvinces().Delete(ctx, &req.ProvincesDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cProvinces) Edit(ctx context.Context, req *provinces.EditReq) (res *provinces.EditRes, err error) {
|
||||
err = service.SysProvinces().Edit(ctx, &req.ProvincesEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (c *cProvinces) MaxSort(ctx context.Context, req *provinces.MaxSortReq) (res *provinces.MaxSortRes, err error) {
|
||||
data, err := service.SysProvinces().MaxSort(ctx, &req.ProvincesMaxSortInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(provinces.MaxSortRes)
|
||||
res.ProvincesMaxSortModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cProvinces) View(ctx context.Context, req *provinces.ViewReq) (res *provinces.ViewRes, err error) {
|
||||
data, err := service.SysProvinces().View(ctx, &req.ProvincesViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(provinces.ViewRes)
|
||||
res.ProvincesViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cProvinces) List(ctx context.Context, req *provinces.ListReq) (res *provinces.ListRes, err error) {
|
||||
list, totalCount, err := service.SysProvinces().List(ctx, &req.ProvincesListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(provinces.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新省市区状态
|
||||
func (c *cProvinces) Status(ctx context.Context, req *provinces.StatusReq) (res *provinces.StatusRes, err error) {
|
||||
err = service.SysProvinces().Status(ctx, &req.ProvincesStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// ChildrenList 获取省市区下级列表
|
||||
func (c *cProvinces) ChildrenList(ctx context.Context, req *provinces.ChildrenListReq) (res *provinces.ChildrenListRes, err error) {
|
||||
list, totalCount, err := service.SysProvinces().ChildrenList(ctx, &req.ProvincesChildrenListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(provinces.ChildrenListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// UniqueId 地区ID是否唯一
|
||||
func (c *cProvinces) UniqueId(ctx context.Context, req *provinces.UniqueIdReq) (res *provinces.UniqueIdRes, err error) {
|
||||
data, err := service.SysProvinces().UniqueId(ctx, &req.ProvincesUniqueIdInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(provinces.UniqueIdRes)
|
||||
res.ProvincesUniqueIdModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Select 省市区选项
|
||||
func (c *cProvinces) Select(ctx context.Context, req *provinces.SelectReq) (res *provinces.SelectRes, err error) {
|
||||
data, err := service.SysProvinces().Select(ctx, &req.ProvincesSelectInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(provinces.SelectRes)
|
||||
res.ProvincesSelectModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// CityLabel 省市区选项
|
||||
func (c *cProvinces) CityLabel(ctx context.Context, req *provinces.CityLabelReq) (res *provinces.CityLabelRes, err error) {
|
||||
cityLabel, err := location.ParseSimpleRegion(ctx, req.Id, req.Spilt)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = (*provinces.CityLabelRes)(&cityLabel)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// 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
|
||||
// @AutoGenerate Version 2.7.6
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/servelicense"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
ServeLicense = cServeLicense{}
|
||||
)
|
||||
|
||||
type cServeLicense struct{}
|
||||
|
||||
// List 查看服务授权许可列表
|
||||
func (c *cServeLicense) List(ctx context.Context, req *servelicense.ListReq) (res *servelicense.ListRes, err error) {
|
||||
list, totalCount, err := service.SysServeLicense().List(ctx, &req.ServeLicenseListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(servelicense.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出服务授权许可列表
|
||||
func (c *cServeLicense) Export(ctx context.Context, req *servelicense.ExportReq) (res *servelicense.ExportRes, err error) {
|
||||
err = service.SysServeLicense().Export(ctx, &req.ServeLicenseListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新服务授权许可
|
||||
func (c *cServeLicense) Edit(ctx context.Context, req *servelicense.EditReq) (res *servelicense.EditRes, err error) {
|
||||
err = service.SysServeLicense().Edit(ctx, &req.ServeLicenseEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定服务授权许可信息
|
||||
func (c *cServeLicense) View(ctx context.Context, req *servelicense.ViewReq) (res *servelicense.ViewRes, err error) {
|
||||
data, err := service.SysServeLicense().View(ctx, &req.ServeLicenseViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(servelicense.ViewRes)
|
||||
res.ServeLicenseViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除服务授权许可
|
||||
func (c *cServeLicense) Delete(ctx context.Context, req *servelicense.DeleteReq) (res *servelicense.DeleteRes, err error) {
|
||||
err = service.SysServeLicense().Delete(ctx, &req.ServeLicenseDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新服务授权许可状态
|
||||
func (c *cServeLicense) Status(ctx context.Context, req *servelicense.StatusReq) (res *servelicense.StatusRes, err error) {
|
||||
err = service.SysServeLicense().Status(ctx, &req.ServeLicenseStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// AssignRouter 分配服务授权许可路由
|
||||
func (c *cServeLicense) AssignRouter(ctx context.Context, req *servelicense.AssignRouterReq) (res *servelicense.AssignRouterRes, err error) {
|
||||
err = service.SysServeLicense().AssignRouter(ctx, &req.ServeLicenseAssignRouterInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// 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/api/admin/servelog"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
ServeLog = cServeLog{}
|
||||
)
|
||||
|
||||
type cServeLog struct{}
|
||||
|
||||
// List 查看服务日志列表
|
||||
func (c *cServeLog) List(ctx context.Context, req *servelog.ListReq) (res *servelog.ListRes, err error) {
|
||||
list, totalCount, err := service.SysServeLog().List(ctx, &req.ServeLogListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(servelog.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出服务日志列表
|
||||
func (c *cServeLog) Export(ctx context.Context, req *servelog.ExportReq) (res *servelog.ExportRes, err error) {
|
||||
err = service.SysServeLog().Export(ctx, &req.ServeLogListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定服务日志信息
|
||||
func (c *cServeLog) View(ctx context.Context, req *servelog.ViewReq) (res *servelog.ViewRes, err error) {
|
||||
data, err := service.SysServeLog().View(ctx, &req.ServeLogViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(servelog.ViewRes)
|
||||
res.ServeLogViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除服务日志
|
||||
func (c *cServeLog) Delete(ctx context.Context, req *servelog.DeleteReq) (res *servelog.DeleteRes, err error) {
|
||||
err = service.SysServeLog().Delete(ctx, &req.ServeLogDeleteInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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/api/admin/smslog"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
SmsLog = cSmsLog{}
|
||||
)
|
||||
|
||||
type cSmsLog struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cSmsLog) Delete(ctx context.Context, req *smslog.DeleteReq) (res *smslog.DeleteRes, err error) {
|
||||
err = service.SysSmsLog().Delete(ctx, &req.SmsLogDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cSmsLog) View(ctx context.Context, req *smslog.ViewReq) (res *smslog.ViewRes, err error) {
|
||||
data, err := service.SysSmsLog().View(ctx, &req.SmsLogViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(smslog.ViewRes)
|
||||
res.SmsLogViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cSmsLog) List(ctx context.Context, req *smslog.ListReq) (res *smslog.ListRes, err error) {
|
||||
list, totalCount, err := service.SysSmsLog().List(ctx, &req.SmsLogListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(smslog.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// 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.15.7
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/testcategory"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
TestCategory = cTestCategory{}
|
||||
)
|
||||
|
||||
type cTestCategory struct{}
|
||||
|
||||
// List 查看测试分类列表
|
||||
func (c *cTestCategory) List(ctx context.Context, req *testcategory.ListReq) (res *testcategory.ListRes, err error) {
|
||||
list, totalCount, err := service.SysTestCategory().List(ctx, &req.TestCategoryListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if list == nil {
|
||||
list = []*sysin.TestCategoryListModel{}
|
||||
}
|
||||
|
||||
res = new(testcategory.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新测试分类
|
||||
func (c *cTestCategory) Edit(ctx context.Context, req *testcategory.EditReq) (res *testcategory.EditRes, err error) {
|
||||
err = service.SysTestCategory().Edit(ctx, &req.TestCategoryEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 获取测试分类最大排序
|
||||
func (c *cTestCategory) MaxSort(ctx context.Context, req *testcategory.MaxSortReq) (res *testcategory.MaxSortRes, err error) {
|
||||
data, err := service.SysTestCategory().MaxSort(ctx, &req.TestCategoryMaxSortInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(testcategory.MaxSortRes)
|
||||
res.TestCategoryMaxSortModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定测试分类信息
|
||||
func (c *cTestCategory) View(ctx context.Context, req *testcategory.ViewReq) (res *testcategory.ViewRes, err error) {
|
||||
data, err := service.SysTestCategory().View(ctx, &req.TestCategoryViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(testcategory.ViewRes)
|
||||
res.TestCategoryViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除测试分类
|
||||
func (c *cTestCategory) Delete(ctx context.Context, req *testcategory.DeleteReq) (res *testcategory.DeleteRes, err error) {
|
||||
err = service.SysTestCategory().Delete(ctx, &req.TestCategoryDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新测试分类状态
|
||||
func (c *cTestCategory) Status(ctx context.Context, req *testcategory.StatusReq) (res *testcategory.StatusRes, err error) {
|
||||
err = service.SysTestCategory().Status(ctx, &req.TestCategoryStatusInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package member
|
||||
@@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package member
|
||||
|
||||
import (
|
||||
"hotgo/api/api/member"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() member.IMemberV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package member
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "hotgo/api/api/member/v1"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) GetIdByCode(ctx context.Context, req *v1.GetIdByCodeReq) (res *v1.GetIdByCodeRes, err error) {
|
||||
g.RequestFromCtx(ctx).Response.Writeln("Hello World api member!")
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package pay
|
||||
@@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package pay
|
||||
|
||||
import (
|
||||
"hotgo/api/api/pay"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() pay.IPayV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "hotgo/api/api/pay/v1"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/response"
|
||||
"hotgo/internal/model/input/payin"
|
||||
"hotgo/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) NotifyAliPay(ctx context.Context, req *v1.NotifyAliPayReq) (res *v1.NotifyAliPayRes, err error) {
|
||||
if _, err = service.Pay().Notify(ctx, &payin.PayNotifyInp{PayType: consts.PayTypeAliPay}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response.RText(g.RequestFromCtx(ctx), "success")
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "hotgo/api/api/pay/v1"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model/input/payin"
|
||||
"hotgo/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) NotifyQQPay(ctx context.Context, req *v1.NotifyQQPayReq) (res *v1.NotifyQQPayRes, err error) {
|
||||
if _, err = service.Pay().Notify(ctx, &payin.PayNotifyInp{PayType: consts.PayTypeQQPay}); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
r := g.RequestFromCtx(ctx)
|
||||
r.Response.ClearBuffer()
|
||||
r.Response.Write(`<?xml version="1.0" encoding="UTF-8"?>`)
|
||||
r.Response.WriteXml(g.Map{
|
||||
"return_code": "SUCCESS",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
v1 "hotgo/api/api/pay/v1"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/response"
|
||||
"hotgo/internal/model/input/payin"
|
||||
"hotgo/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) NotifyWxPay(ctx context.Context, req *v1.NotifyWxPayReq) (res *v1.NotifyWxPayRes, err error) {
|
||||
if _, err = service.Pay().Notify(ctx, &payin.PayNotifyInp{PayType: consts.PayTypeWxPay}); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
response.CustomJson(g.RequestFromCtx(ctx), `{"code": "SUCCESS","message": "收单成功"}`)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Package base
|
||||
// @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 base
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/api/home/base"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/utility/simple"
|
||||
)
|
||||
|
||||
// Site 基础
|
||||
var Site = cSite{}
|
||||
|
||||
type cSite struct{}
|
||||
|
||||
func (a *cSite) Index(ctx context.Context, _ *base.SiteIndexReq) (res *base.SiteIndexRes, err error) {
|
||||
service.View().Render(ctx, model.View{Data: g.Map{
|
||||
"name": simple.AppName(ctx),
|
||||
"version": consts.VersionApp,
|
||||
}})
|
||||
|
||||
// err = gerror.New("这是一个测试错误")
|
||||
// return
|
||||
|
||||
// err = gerror.NewCode(gcode.New(10000, "这是一个测试自定义错误码错误", nil))
|
||||
// return
|
||||
|
||||
// service.View().Error(ctx, gerror.New("这是一个允许被自定义格式的错误,默认和通用错误格式一致,你可以修改它"))
|
||||
// return
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
// Package admin
|
||||
// @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 admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/shirou/gopsutil/v3/cpu"
|
||||
"github.com/shirou/gopsutil/v3/disk"
|
||||
"github.com/shirou/gopsutil/v3/host"
|
||||
"github.com/shirou/gopsutil/v3/mem"
|
||||
"github.com/shirou/gopsutil/v3/process"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/internal/websocket"
|
||||
"hotgo/utility/file"
|
||||
"hotgo/utility/format"
|
||||
"hotgo/utility/simple"
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
Monitor = cMonitor{}
|
||||
)
|
||||
|
||||
type cMonitor struct{}
|
||||
|
||||
type MonitorHeadExtra struct {
|
||||
Data interface{} `json:"data"`
|
||||
Data1 string `json:"data1,omitempty"`
|
||||
}
|
||||
type MonitorHead struct {
|
||||
Title string `json:"title"`
|
||||
Data string `json:"data"`
|
||||
BottomTitle string `json:"bottomTitle"`
|
||||
TotalSum string `json:"totalSum"`
|
||||
IconClass string `json:"iconClass"`
|
||||
Extra MonitorHeadExtra `json:"extra"`
|
||||
}
|
||||
|
||||
// RunInfo 运行信息
|
||||
func (c *cMonitor) RunInfo(client *websocket.Client, req *websocket.WRequest) {
|
||||
var (
|
||||
meta = service.AdminMonitor().GetMeta(client.Context())
|
||||
mHost, _ = host.Info()
|
||||
pwd, _ = os.Getwd()
|
||||
gm runtime.MemStats
|
||||
)
|
||||
|
||||
runtime.ReadMemStats(&gm)
|
||||
|
||||
data := g.Map{
|
||||
// 服务器信息
|
||||
"hostname": mHost.Hostname,
|
||||
"os": mHost.OS,
|
||||
"arch": mHost.KernelArch,
|
||||
"intranet_ip": meta.IntranetIP,
|
||||
"public_ip": meta.PublicIP,
|
||||
|
||||
// 运行信息
|
||||
"version": runtime.Version(), // GO 版本
|
||||
"hgVersion": consts.VersionApp, // HG 版本
|
||||
"startTime": gtime.New(meta.STartTime),
|
||||
"runTime": gtime.Now().Timestamp() - meta.STartTime,
|
||||
"rootPath": runtime.GOROOT(),
|
||||
"pwd": pwd,
|
||||
"goroutine": runtime.NumGoroutine(),
|
||||
"goMem": format.FileSize(int64(gm.Sys)),
|
||||
"goSize": file.DirSize(pwd),
|
||||
}
|
||||
|
||||
if simple.IsDemo(client.Context()) {
|
||||
data["rootPath"] = consts.DemoTips
|
||||
data["pwd"] = consts.DemoTips
|
||||
data["intranet_ip"] = consts.DemoTips
|
||||
data["public_ip"] = consts.DemoTips
|
||||
}
|
||||
|
||||
websocket.SendSuccess(client, req.Event, data)
|
||||
}
|
||||
|
||||
// Trends 实时数据
|
||||
func (c *cMonitor) Trends(client *websocket.Client, req *websocket.WRequest) {
|
||||
type NetC struct {
|
||||
Time *gtime.Time `json:"time"`
|
||||
BytesSent string `json:"bytesSent"` // number of bytes sent
|
||||
BytesRecv string `json:"bytesRecv"` // number of bytes received
|
||||
Down float64 `json:"down"`
|
||||
UP float64 `json:"up"`
|
||||
}
|
||||
|
||||
var (
|
||||
mCpu, cpuErr = cpu.Info()
|
||||
mCpuUsed float64
|
||||
mMem, memErr = mem.VirtualMemory()
|
||||
mMemUsed float64
|
||||
mDisk, diskErr = disk.Usage("/")
|
||||
mProcess, processErr = process.Pids()
|
||||
mLoadAvg = new(model.LoadAvgStats)
|
||||
monitorHeads []MonitorHead
|
||||
nets []NetC
|
||||
meta = service.AdminMonitor().GetMeta(client.Context())
|
||||
)
|
||||
|
||||
if cpuErr != nil {
|
||||
g.Log().Infof(client.Context(), "read CPU info fail:%+v", cpuErr)
|
||||
mCpu = []cpu.InfoStat{{VendorID: "", ModelName: ""}}
|
||||
}
|
||||
|
||||
if memErr != nil {
|
||||
g.Log().Infof(client.Context(), "read mem info fail:%+v", memErr)
|
||||
mMem = new(mem.VirtualMemoryStat)
|
||||
}
|
||||
|
||||
if diskErr != nil {
|
||||
g.Log().Infof(client.Context(), "read disk info fail:%+v", diskErr)
|
||||
mDisk = new(disk.UsageStat)
|
||||
}
|
||||
|
||||
if processErr != nil {
|
||||
g.Log().Infof(client.Context(), "read process.Pids fail:%+v", processErr)
|
||||
}
|
||||
|
||||
// cpu使用率
|
||||
cu, err := cpu.Percent(time.Second, false)
|
||||
if err == nil {
|
||||
mCpuUsed = gconv.Float64(fmt.Sprintf("%.2f", cu[0]))
|
||||
}
|
||||
|
||||
// 内存使用率
|
||||
mMemUsed = gconv.Float64(fmt.Sprintf("%.2f", mMem.UsedPercent))
|
||||
|
||||
// 负载
|
||||
if len(meta.LoadAvg) > 0 {
|
||||
mLoadAvg = meta.LoadAvg[len(meta.LoadAvg)-1]
|
||||
}
|
||||
|
||||
monitorHeads = append(monitorHeads, MonitorHead{
|
||||
Title: "CPU",
|
||||
Data: "使用率 " + format.Round2String(mCpuUsed) + "%",
|
||||
BottomTitle: "CPU数量",
|
||||
TotalSum: gconv.String(runtime.NumCPU()) + "核心",
|
||||
IconClass: "HardwareChip",
|
||||
Extra: MonitorHeadExtra{
|
||||
Data: mCpu[0].VendorID,
|
||||
Data1: mCpu[0].ModelName,
|
||||
}},
|
||||
MonitorHead{
|
||||
Title: "内存",
|
||||
Data: "使用率 " + format.Round2String(mMemUsed) + "%",
|
||||
BottomTitle: "总内存",
|
||||
TotalSum: format.FileSize(int64(mMem.Total)),
|
||||
IconClass: "AppsSharp",
|
||||
Extra: MonitorHeadExtra{
|
||||
Data: format.FileSize(int64(mMem.Used)),
|
||||
Data1: format.FileSize(int64(mMem.Total - mMem.Used)),
|
||||
}},
|
||||
MonitorHead{
|
||||
Title: "磁盘",
|
||||
Data: "已用 " + format.FileSize(int64(mDisk.Used)),
|
||||
BottomTitle: "总容量",
|
||||
TotalSum: format.FileSize(int64(mDisk.Total)),
|
||||
IconClass: "PieChart",
|
||||
Extra: MonitorHeadExtra{
|
||||
Data: format.Round2String(mDisk.UsedPercent),
|
||||
}},
|
||||
MonitorHead{
|
||||
Title: "负载",
|
||||
Data: format.Round2String(mLoadAvg.Ratio) + "%",
|
||||
BottomTitle: "总进程数",
|
||||
TotalSum: gconv.String(len(mProcess)) + "个",
|
||||
IconClass: "Analytics",
|
||||
})
|
||||
|
||||
for _, v := range meta.NetIO {
|
||||
nets = append(nets, NetC{
|
||||
Time: v.Time,
|
||||
BytesSent: format.FileSize(int64(v.BytesSent)), // 转换为最大整数单位
|
||||
BytesRecv: format.FileSize(int64(v.BytesRecv)),
|
||||
Down: format.Round2Float64(v.Down / 1024), // 转换为kb
|
||||
UP: format.Round2Float64(v.UP / 1024),
|
||||
})
|
||||
}
|
||||
|
||||
websocket.SendSuccess(client, req.Event, g.Map{
|
||||
"head": monitorHeads,
|
||||
"load": meta.LoadAvg,
|
||||
"net": nets,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Package common
|
||||
// @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 common
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/internal/websocket"
|
||||
)
|
||||
|
||||
var (
|
||||
Site = cSite{}
|
||||
)
|
||||
|
||||
type cSite struct{}
|
||||
|
||||
func (c *cSite) Join(client *websocket.Client, req *websocket.WRequest) {
|
||||
name := gconv.String(req.Data["id"])
|
||||
|
||||
if !client.Tags.Contains(name) {
|
||||
client.Tags.Append(name)
|
||||
}
|
||||
|
||||
websocket.SendSuccess(client, req.Event, client.Tags.Slice())
|
||||
}
|
||||
|
||||
func (c *cSite) Quit(client *websocket.Client, req *websocket.WRequest) {
|
||||
name := gconv.String(req.Data["id"])
|
||||
if client.Tags.Contains(name) {
|
||||
client.Tags.RemoveValue(name)
|
||||
}
|
||||
websocket.SendSuccess(client, req.Event, client.Tags.Slice())
|
||||
}
|
||||
|
||||
func (c *cSite) Ping(client *websocket.Client, req *websocket.WRequest) {
|
||||
websocket.SendSuccess(client, req.Event)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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/api/websocket/base"
|
||||
"hotgo/internal/websocket"
|
||||
"hotgo/utility/simple"
|
||||
)
|
||||
|
||||
// Send 通过http发送ws消息
|
||||
var Send = send{}
|
||||
|
||||
type send struct{}
|
||||
|
||||
// SendToTag 发送标签消息
|
||||
func (c *send) SendToTag(ctx context.Context, req *base.SendToTagReq) (res *base.SendToTagRes, err error) {
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
websocket.SendToTag(req.Tag, &websocket.WResponse{
|
||||
Event: req.Response.Event,
|
||||
Data: req.Response,
|
||||
})
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// 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
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/cron"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cron.Register(CloseOrder)
|
||||
}
|
||||
|
||||
// CloseOrder 取消过期订单
|
||||
var CloseOrder = &cCloseOrder{name: "close_order"}
|
||||
|
||||
type cCloseOrder struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func (c *cCloseOrder) GetName() string {
|
||||
return c.name
|
||||
}
|
||||
|
||||
// Execute 执行任务
|
||||
func (c *cCloseOrder) Execute(ctx context.Context, parser *cron.Parser) (err error) {
|
||||
_, err = service.AdminOrder().Model(ctx).
|
||||
Where(dao.AdminOrder.Columns().Status, consts.OrderStatusNotPay).
|
||||
WhereLTE(dao.AdminOrder.Columns().CreatedAt, gtime.Now().AddDate(0, 0, -1)).
|
||||
Data(g.Map{
|
||||
dao.AdminOrder.Columns().Status: consts.OrderStatusClose,
|
||||
}).Update()
|
||||
if err != nil {
|
||||
parser.Logger.Warning(ctx, "cron CloseOrder Execute err:%+v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// 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
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/internal/library/cron"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cron.Register(Test)
|
||||
}
|
||||
|
||||
// Test 测试任务(无参数)
|
||||
var Test = &cTest{name: "test"}
|
||||
|
||||
type cTest struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func (c *cTest) GetName() string {
|
||||
return c.name
|
||||
}
|
||||
|
||||
// Execute 执行任务
|
||||
func (c *cTest) Execute(ctx context.Context, parser *cron.Parser) (err error) {
|
||||
parser.Logger.Infof(ctx, "cron test Execute:%v", time.Now())
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// 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
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/internal/library/cron"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cron.Register(Test2)
|
||||
}
|
||||
|
||||
// Test2 测试2任务(带参数)
|
||||
var Test2 = &cTest2{name: "test2"}
|
||||
|
||||
type cTest2 struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func (c *cTest2) GetName() string {
|
||||
return c.name
|
||||
}
|
||||
|
||||
// Execute 执行任务
|
||||
func (c *cTest2) Execute(ctx context.Context, parser *cron.Parser) (err error) {
|
||||
if len(parser.Args) != 3 {
|
||||
err = gerror.New("传入参数不正确!")
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
name = parser.Args[0]
|
||||
age = parser.Args[1]
|
||||
msg = parser.Args[2]
|
||||
)
|
||||
|
||||
parser.Logger.Infof(ctx, "cron test2 Execute:%v, name:%v, age:%v, msg:%v", time.Now(), name, age, msg)
|
||||
return
|
||||
}
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// addonHgexampleTableDao is the data access object for the table hg_addon_hgexample_table.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type addonHgexampleTableDao struct {
|
||||
*internal.AddonHgexampleTableDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AddonHgexampleTable is a globally accessible object for table hg_addon_hgexample_table operations.
|
||||
AddonHgexampleTable = addonHgexampleTableDao{internal.NewAddonHgexampleTableDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// addonHgexampleTenantOrderDao is the data access object for the table hg_addon_hgexample_tenant_order.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type addonHgexampleTenantOrderDao struct {
|
||||
*internal.AddonHgexampleTenantOrderDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AddonHgexampleTenantOrder is a globally accessible object for table hg_addon_hgexample_tenant_order operations.
|
||||
AddonHgexampleTenantOrder = addonHgexampleTenantOrderDao{internal.NewAddonHgexampleTenantOrderDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminCashDao is the data access object for the table hg_admin_cash.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type adminCashDao struct {
|
||||
*internal.AdminCashDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminCash is a globally accessible object for table hg_admin_cash operations.
|
||||
AdminCash = adminCashDao{internal.NewAdminCashDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminCreditsLogDao is the data access object for the table hg_admin_credits_log.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type adminCreditsLogDao struct {
|
||||
*internal.AdminCreditsLogDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminCreditsLog is a globally accessible object for table hg_admin_credits_log operations.
|
||||
AdminCreditsLog = adminCreditsLogDao{internal.NewAdminCreditsLogDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminDeptDao is the data access object for the table hg_admin_dept.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type adminDeptDao struct {
|
||||
*internal.AdminDeptDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminDept is a globally accessible object for table hg_admin_dept operations.
|
||||
AdminDept = adminDeptDao{internal.NewAdminDeptDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminMemberDao is the data access object for the table hg_admin_member.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type adminMemberDao struct {
|
||||
*internal.AdminMemberDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMember is a globally accessible object for table hg_admin_member operations.
|
||||
AdminMember = adminMemberDao{internal.NewAdminMemberDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminMemberPostDao is the data access object for the table hg_admin_member_post.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type adminMemberPostDao struct {
|
||||
*internal.AdminMemberPostDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMemberPost is a globally accessible object for table hg_admin_member_post operations.
|
||||
AdminMemberPost = adminMemberPostDao{internal.NewAdminMemberPostDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminMemberRoleDao is the data access object for the table hg_admin_member_role.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type adminMemberRoleDao struct {
|
||||
*internal.AdminMemberRoleDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMemberRole is a globally accessible object for table hg_admin_member_role operations.
|
||||
AdminMemberRole = adminMemberRoleDao{internal.NewAdminMemberRoleDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminMenuDao is the data access object for the table hg_admin_menu.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type adminMenuDao struct {
|
||||
*internal.AdminMenuDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminMenu is a globally accessible object for table hg_admin_menu operations.
|
||||
AdminMenu = adminMenuDao{internal.NewAdminMenuDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"hotgo/internal/dao/internal"
|
||||
)
|
||||
|
||||
// adminNoticeDao is the data access object for the table hg_admin_notice.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type adminNoticeDao struct {
|
||||
*internal.AdminNoticeDao
|
||||
}
|
||||
|
||||
var (
|
||||
// AdminNotice is a globally accessible object for table hg_admin_notice operations.
|
||||
AdminNotice = adminNoticeDao{internal.NewAdminNoticeDao()}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user