diff --git a/server/api/admin/addons/addons.go b/server/api/admin/addons/addons.go index 1425902..bef6c6f 100644 --- a/server/api/admin/addons/addons.go +++ b/server/api/admin/addons/addons.go @@ -25,6 +25,7 @@ type ListRes struct { type SelectsReq struct { g.Meta `path:"/addons/selects" method:"get" tags:"插件管理" summary:"生成入口选项"` } + type SelectsRes struct { *sysin.AddonsSelectsModel } @@ -34,6 +35,7 @@ type BuildReq struct { g.Meta `path:"/addons/build" method:"post" tags:"插件管理" summary:"提交生成"` sysin.AddonsBuildInp } + type BuildRes struct { } @@ -42,6 +44,7 @@ type InstallReq struct { g.Meta `path:"/addons/install" method:"post" tags:"插件管理" summary:"安装模块"` sysin.AddonsInstallInp } + type InstallRes struct { } @@ -50,6 +53,7 @@ type UpgradeReq struct { g.Meta `path:"/addons/upgrade" method:"post" tags:"插件管理" summary:"更新模块"` sysin.AddonsUpgradeInp } + type UpgradeRes struct { } @@ -58,5 +62,6 @@ type UnInstallReq struct { g.Meta `path:"/addons/uninstall" method:"post" tags:"插件管理" summary:"卸载模块"` sysin.AddonsUnInstallInp } + type UnInstallRes struct { } diff --git a/server/api/admin/attachment/attachment.go b/server/api/admin/attachment/attachment.go index c3ba94d..bb06707 100644 --- a/server/api/admin/attachment/attachment.go +++ b/server/api/admin/attachment/attachment.go @@ -31,6 +31,7 @@ type ViewReq struct { Id int64 `json:"id" v:"required#附件ID不能为空" dc:"附件ID"` g.Meta `path:"/attachment/view" method:"get" tags:"附件" summary:"获取指定附件信息"` } + type ViewRes struct { *sysin.AttachmentViewModel } @@ -40,4 +41,5 @@ type DeleteReq struct { Id interface{} `json:"id" v:"required#附件ID不能为空" dc:"附件ID"` g.Meta `path:"/attachment/delete" method:"post" tags:"附件" summary:"删除附件"` } + type DeleteRes struct{} diff --git a/server/api/admin/blacklist/blacklist.go b/server/api/admin/blacklist/blacklist.go index de526b2..85a5965 100644 --- a/server/api/admin/blacklist/blacklist.go +++ b/server/api/admin/blacklist/blacklist.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package blacklist import ( @@ -33,6 +32,7 @@ type ViewReq struct { Id int64 `json:"id" v:"required#黑名单ID不能为空" dc:"黑名单ID"` g.Meta `path:"/blacklist/view" method:"get" tags:"黑名单" summary:"获取指定信息"` } + type ViewRes struct { *sysin.BlacklistViewModel } @@ -42,6 +42,7 @@ type EditReq struct { entity.SysBlacklist g.Meta `path:"/blacklist/edit" method:"post" tags:"黑名单" summary:"修改/新增黑名单"` } + type EditRes struct{} // DeleteReq 删除 @@ -49,6 +50,7 @@ type DeleteReq struct { Id interface{} `json:"id" v:"required#黑名单ID不能为空" dc:"黑名单ID"` g.Meta `path:"/blacklist/delete" method:"post" tags:"黑名单" summary:"删除黑名单"` } + type DeleteRes struct{} // MaxSortReq 最大排序 @@ -56,6 +58,7 @@ type MaxSortReq struct { Id int64 `json:"id" dc:"黑名单ID"` g.Meta `path:"/blacklist/maxSort" method:"get" tags:"黑名单" summary:"黑名单最大排序"` } + type MaxSortRes struct { Sort int `json:"sort" dc:"排序"` } @@ -65,4 +68,5 @@ type StatusReq struct { entity.SysBlacklist g.Meta `path:"/blacklist/status" method:"post" tags:"黑名单" summary:"更新黑名单状态"` } + type StatusRes struct{} diff --git a/server/api/admin/cash/cash.go b/server/api/admin/cash/cash.go index 4d4e065..434c5de 100644 --- a/server/api/admin/cash/cash.go +++ b/server/api/admin/cash/cash.go @@ -27,6 +27,7 @@ type ViewReq struct { g.Meta `path:"/cash/view" method:"get" tags:"提现" summary:"获取指定信息"` adminin.CashViewInp } + type ViewRes struct { *adminin.CashViewModel } @@ -36,6 +37,7 @@ type ApplyReq struct { Money float64 `json:"money" description:"提现金额"` g.Meta `path:"/cash/apply" method:"post" tags:"提现" summary:"申请提现"` } + type ApplyRes struct{} // PaymentReq 提现打款处理 @@ -45,4 +47,5 @@ type PaymentReq struct { Msg string `json:"msg" description:"处理结果"` g.Meta `path:"/cash/payment" method:"post" tags:"提现" summary:"提现打款处理"` } + type PaymentRes struct{} diff --git a/server/api/admin/common/console.go b/server/api/admin/common/console.go index 1ec7602..025ba2a 100644 --- a/server/api/admin/common/console.go +++ b/server/api/admin/common/console.go @@ -3,7 +3,6 @@ // @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/frame/g" @@ -12,6 +11,7 @@ import "github.com/gogf/gf/v2/frame/g" type ConsoleStatReq struct { g.Meta `path:"/console/stat" method:"get" tags:"控制台" summary:"综合数据统计"` } + type ConsoleStatRes struct { Visits struct { DayVisits float64 `json:"dayVisits"` diff --git a/server/api/admin/common/ems.go b/server/api/admin/common/ems.go index c4d8bd7..4b3a97b 100644 --- a/server/api/admin/common/ems.go +++ b/server/api/admin/common/ems.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package common import ( @@ -15,6 +14,7 @@ type SendTestEmailReq struct { To string `json:"to" v:"required#接收者邮件不能为空" dc:"接收者邮件,多个用;隔开"` g.Meta `path:"/ems/sendTest" tags:"邮件" method:"post" summary:"发送测试邮件"` } + type SendTestEmailRes struct { } @@ -22,5 +22,6 @@ type SendTestEmailRes struct { type SendBindEmsReq struct { g.Meta `path:"/ems/sendBind" tags:"邮件" method:"post" summary:"发送换绑邮件"` } + type SendBindEmsRes struct { } diff --git a/server/api/admin/common/site.go b/server/api/admin/common/site.go index 0580f2b..e897f46 100644 --- a/server/api/admin/common/site.go +++ b/server/api/admin/common/site.go @@ -15,6 +15,7 @@ import ( type LoginLogoutReq struct { g.Meta `path:"/site/logout" method:"post" tags:"后台基础" summary:"注销登录"` } + type LoginLogoutRes struct{} // RegisterReq 提交账号注册 @@ -22,6 +23,7 @@ type RegisterReq struct { g.Meta `path:"/site/register" method:"post" tags:"后台基础" summary:"账号注册"` adminin.RegisterInp } + type RegisterRes struct { *adminin.LoginModel } @@ -30,6 +32,7 @@ type RegisterRes struct { type LoginCaptchaReq struct { g.Meta `path:"/site/captcha" method:"get" tags:"后台基础" summary:"获取登录验证码"` } + type LoginCaptchaRes struct { Cid string `json:"cid" dc:"验证码ID"` Base64 string `json:"base64" dc:"验证码"` @@ -40,6 +43,7 @@ type AccountLoginReq struct { g.Meta `path:"/site/accountLogin" method:"post" tags:"后台基础" summary:"账号登录"` adminin.AccountLoginInp } + type AccountLoginRes struct { *adminin.LoginModel } @@ -49,6 +53,7 @@ type MobileLoginReq struct { g.Meta `path:"/site/mobileLogin" method:"post" tags:"后台基础" summary:"手机号登录"` adminin.MobileLoginInp } + type MobileLoginRes struct { *adminin.LoginModel } @@ -57,6 +62,7 @@ type MobileLoginRes struct { type SiteConfigReq struct { g.Meta `path:"/site/config" method:"get" tags:"后台基础" summary:"获取配置"` } + type SiteConfigRes struct { Version string `json:"version" dc:"系统版本"` WsAddr string `json:"wsAddr" dc:"客户端websocket地址"` @@ -68,6 +74,7 @@ type SiteConfigRes struct { type SiteLoginConfigReq struct { g.Meta `path:"/site/loginConfig" method:"get" tags:"后台基础" summary:"获取登录配置"` } + type SiteLoginConfigRes struct { *model.LoginConfig } @@ -76,4 +83,5 @@ type SiteLoginConfigRes struct { type SitePingReq struct { g.Meta `path:"/site/ping" method:"get" tags:"后台基础" summary:"ping"` } + type SitePingRes struct{} diff --git a/server/api/admin/common/sms.go b/server/api/admin/common/sms.go index f383755..4343ece 100644 --- a/server/api/admin/common/sms.go +++ b/server/api/admin/common/sms.go @@ -14,6 +14,7 @@ type SendTestSmsReq struct { Code string `json:"code" v:"required#接收验证码不能为空" dc:"接收验证码"` g.Meta `path:"/sms/sendTest" tags:"短信" method:"post" summary:"发送测试短信"` } + type SendTestSmsRes struct { } @@ -21,6 +22,7 @@ type SendTestSmsRes struct { type SendBindSmsReq struct { g.Meta `path:"/sms/sendBind" tags:"短信" method:"post" summary:"发送换绑短信"` } + type SendBindSmsRes struct { } @@ -30,5 +32,6 @@ type SendSmsReq struct { Event string `json:"event" v:"required#事件模板不能为空" dc:"事件模板"` Mobile string `json:"mobile" v:"required#接收手机号不能为空" dc:"接收手机号"` } + type SendSmsRes struct { } diff --git a/server/api/admin/common/wechat.go b/server/api/admin/common/wechat.go index a9ab0d2..c7af478 100644 --- a/server/api/admin/common/wechat.go +++ b/server/api/admin/common/wechat.go @@ -15,6 +15,7 @@ type WechatAuthorizeReq struct { g.Meta `path:"/wechat/authorize" method:"get" tags:"微信" summary:"微信用户授权"` commonin.WechatAuthorizeInp } + type WechatAuthorizeRes struct { *commonin.WechatAuthorizeModel } @@ -24,6 +25,7 @@ type WechatAuthorizeCallReq struct { g.Meta `path:"/wechat/authorizeCall" method:"get" tags:"微信" summary:"微信用户授权"` commonin.WechatAuthorizeCallInp } + type WechatAuthorizeCallRes struct { *commonin.WechatAuthorizeCallModel } diff --git a/server/api/admin/config/config.go b/server/api/admin/config/config.go index e4e7ebc..ea8851d 100644 --- a/server/api/admin/config/config.go +++ b/server/api/admin/config/config.go @@ -16,6 +16,7 @@ type GetReq struct { Group string `json:"group" dc:"分组名称" v:"required#分组名称不能为空" ` g.Meta `path:"/config/get" method:"get" tags:"配置" summary:"获取指定分组的配置"` } + type GetRes struct { *sysin.GetConfigModel } @@ -26,6 +27,7 @@ type UpdateReq struct { List g.Map `json:"list" dc:"更新配置列表" ` g.Meta `path:"/config/update" method:"post" tags:"配置" summary:"获取指定分组的配置"` } + type UpdateRes struct { } @@ -33,12 +35,14 @@ type UpdateRes struct { type TypeSelectReq struct { g.Meta `path:"/config/typeSelect" method:"get" tags:"配置" summary:"数据类型选项"` } + type TypeSelectRes []form.Select // GetCashReq 获取提现配置 type GetCashReq struct { g.Meta `path:"/config/getCash" method:"get" tags:"配置" summary:"获取提现配置"` } + type GetCashRes struct { *sysin.GetConfigModel } diff --git a/server/api/admin/creditslog/creditslog.go b/server/api/admin/creditslog/creditslog.go index 6b19481..bd4c3a7 100644 --- a/server/api/admin/creditslog/creditslog.go +++ b/server/api/admin/creditslog/creditslog.go @@ -36,6 +36,7 @@ type ExportRes struct{} type OptionReq struct { g.Meta `path:"/creditsLog/option" method:"get" summary:"资产变动" tags:"获取变动状态选项"` } + type OptionRes struct { CreditType []g.Map `json:"creditType" dc:"变动类型 "` CreditGroup []g.Map `json:"creditGroup" dc:"变动组别"` diff --git a/server/api/admin/cron/cron.go b/server/api/admin/cron/cron.go index 338f344..1721566 100644 --- a/server/api/admin/cron/cron.go +++ b/server/api/admin/cron/cron.go @@ -27,6 +27,7 @@ type ViewReq struct { g.Meta `path:"/cron/view" method:"get" tags:"定时任务" summary:"获取指定信息"` sysin.CronViewInp } + type ViewRes struct { *sysin.CronViewModel } @@ -36,6 +37,7 @@ type EditReq struct { g.Meta `path:"/cron/edit" method:"post" tags:"定时任务" summary:"修改/新增定时任务"` sysin.CronEditInp } + type EditRes struct { *sysin.CronEditModel } @@ -45,6 +47,7 @@ type DeleteReq struct { g.Meta `path:"/cron/delete" method:"post" tags:"定时任务" summary:"删除定时任务"` sysin.CronDeleteInp } + type DeleteRes struct { *sysin.CronDeleteModel } @@ -54,6 +57,7 @@ type MaxSortReq struct { g.Meta `path:"/cron/maxSort" method:"get" tags:"定时任务" summary:"定时任务最大排序"` sysin.CronMaxSortInp } + type MaxSortRes struct { *sysin.CronMaxSortModel } @@ -63,6 +67,7 @@ type StatusReq struct { g.Meta `path:"/cron/status" method:"post" tags:"定时任务" summary:"更新定时任务状态"` sysin.CronStatusInp } + type StatusRes struct { *sysin.CronStatusModel } @@ -72,6 +77,7 @@ type OnlineExecReq struct { g.Meta `path:"/cron/onlineExec" method:"post" tags:"定时任务" summary:"在线执行"` sysin.OnlineExecInp } + type OnlineExecRes struct { *sysin.OnlineExecModel } diff --git a/server/api/admin/cron/cron_group.go b/server/api/admin/cron/cron_group.go index c89c3d1..38d9ea4 100644 --- a/server/api/admin/cron/cron_group.go +++ b/server/api/admin/cron/cron_group.go @@ -7,7 +7,6 @@ package cron import ( "github.com/gogf/gf/v2/frame/g" - "hotgo/internal/model/entity" "hotgo/internal/model/input/form" "hotgo/internal/model/input/sysin" ) @@ -28,6 +27,7 @@ type GroupViewReq struct { g.Meta `path:"/cronGroup/view" method:"get" tags:"定时任务分组" summary:"获取指定信息"` sysin.CronGroupViewInp } + type GroupViewRes struct { *sysin.CronGroupViewModel } @@ -37,6 +37,7 @@ type GroupEditReq struct { g.Meta `path:"/cronGroup/edit" method:"post" tags:"定时任务分组" summary:"修改/新增定时任务分组"` sysin.CronGroupEditInp } + type GroupEditRes struct { *sysin.CronGroupEditModel } @@ -46,6 +47,7 @@ type GroupDeleteReq struct { g.Meta `path:"/cronGroup/delete" method:"post" tags:"定时任务分组" summary:"删除定时任务分组"` sysin.CronGroupDeleteInp } + type GroupDeleteRes struct { *sysin.CronGroupDeleteModel } @@ -55,16 +57,17 @@ type GroupMaxSortReq struct { g.Meta `path:"/cronGroup/maxSort" method:"get" tags:"定时任务分组" summary:"定时任务分组最大排序"` sysin.CronGroupMaxSortInp } + type GroupMaxSortRes struct { *sysin.CronGroupMaxSortModel } // GroupStatusReq 更新状态 type GroupStatusReq struct { - entity.SysCronGroup g.Meta `path:"/cronGroup/status" method:"post" tags:"定时任务分组" summary:"更新定时任务分组状态"` sysin.CronGroupStatusInp } + type GroupStatusRes struct { *sysin.CronGroupStatusModel } diff --git a/server/api/admin/dept/dept.go b/server/api/admin/dept/dept.go index 8879575..0d0ef18 100644 --- a/server/api/admin/dept/dept.go +++ b/server/api/admin/dept/dept.go @@ -28,6 +28,7 @@ type ViewReq struct { Id int64 `json:"id" v:"required#部门ID不能为空" dc:"部门ID"` g.Meta `path:"/dept/view" method:"get" tags:"部门" summary:"获取指定信息"` } + type ViewRes struct { *adminin.DeptViewModel } @@ -37,6 +38,7 @@ type EditReq struct { entity.AdminDept g.Meta `path:"/dept/edit" method:"post" tags:"部门" summary:"修改/新增部门"` } + type EditRes struct{} // DeleteReq 删除字典类型 @@ -44,6 +46,7 @@ type DeleteReq struct { Id interface{} `json:"id" v:"required#部门ID不能为空" dc:"部门ID"` g.Meta `path:"/dept/delete" method:"post" tags:"部门" summary:"删除部门"` } + type DeleteRes struct{} // MaxSortReq 最大排序 @@ -51,6 +54,7 @@ type MaxSortReq struct { Id int64 `json:"id" dc:"部门ID"` g.Meta `path:"/dept/maxSort" method:"get" tags:"部门" summary:"部门最大排序"` } + type MaxSortRes struct { Sort int `json:"sort" dc:"排序"` } @@ -60,6 +64,7 @@ type StatusReq struct { entity.AdminDept g.Meta `path:"/dept/status" method:"post" tags:"部门" summary:"更新部门状态"` } + type StatusRes struct{} // OptionReq 获取部门选项树 diff --git a/server/api/admin/dict/dict_data.go b/server/api/admin/dict/dict_data.go index c264041..ddfb011 100644 --- a/server/api/admin/dict/dict_data.go +++ b/server/api/admin/dict/dict_data.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package dict import ( @@ -27,6 +26,7 @@ type DataDeleteReq struct { Id interface{} `json:"id" v:"required#字典数据ID不能为空" dc:"字典数据ID"` g.Meta `path:"/dictData/delete" method:"post" tags:"字典数据" summary:"删除字典数据"` } + type DataDeleteRes struct{} // DataListReq 查询列表 @@ -49,10 +49,12 @@ type DataSelectReq struct { g.Meta `path:"/dictData/option/{Type}" method:"get" summary:"字典数据" tags:"获取指定字典选项"` Type string `in:"path" v:"required#字典类型不能为空" dc:"字典类型"` } + type DataSelectRes sysin.DataSelectModel type DataSelectsReq struct { g.Meta `path:"/dictData/options" method:"get" summary:"字典数据" tags:"获取多个字典选项"` Types []string `json:"types"` } + type DataSelectsRes map[string]sysin.DataSelectModel diff --git a/server/api/admin/dict/dict_type.go b/server/api/admin/dict/dict_type.go index cfc52f1..3c184b3 100644 --- a/server/api/admin/dict/dict_type.go +++ b/server/api/admin/dict/dict_type.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package dict import ( @@ -16,6 +15,7 @@ import ( type TypeTreeReq struct { g.Meta `path:"/dictType/tree" tags:"字典类型" method:"get" summary:"字典类型树列表"` } + type TypeTreeRes struct { List []*sysin.DictTypeTree `json:"list" dc:"数据列表"` } @@ -33,4 +33,5 @@ type TypeDeleteReq struct { Id interface{} `json:"id" v:"required#字典类型ID不能为空" dc:"字典类型ID"` g.Meta `path:"/dictType/delete" method:"post" tags:"字典类型" summary:"删除字典类型"` } + type TypeDeleteRes struct{} diff --git a/server/api/admin/emslog/emslog.go b/server/api/admin/emslog/emslog.go index 42f03cf..3fd1578 100644 --- a/server/api/admin/emslog/emslog.go +++ b/server/api/admin/emslog/emslog.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package emslog import ( @@ -28,6 +27,7 @@ type ViewReq struct { g.Meta `path:"/emsLog/view" method:"get" tags:"邮件记录" summary:"获取指定信息"` sysin.EmsLogViewInp } + type ViewRes struct { *sysin.EmsLogViewModel } @@ -37,6 +37,7 @@ type EditReq struct { g.Meta `path:"/emsLog/edit" method:"post" tags:"邮件记录" summary:"修改/新增邮件记录"` sysin.EmsLogEditInp } + type EditRes struct{} // DeleteReq 删除 @@ -44,6 +45,7 @@ type DeleteReq struct { g.Meta `path:"/emsLog/delete" method:"post" tags:"邮件记录" summary:"删除邮件记录"` sysin.EmsLogDeleteInp } + type DeleteRes struct{} // StatusReq 更新状态 @@ -51,6 +53,7 @@ type StatusReq struct { g.Meta `path:"/emsLog/status" method:"post" tags:"邮件记录" summary:"更新邮件记录状态"` sysin.EmsLogStatusInp } + type StatusRes struct{} // SendTestReq 更新状态 @@ -58,4 +61,5 @@ type SendTestReq struct { g.Meta `path:"/emsLog/sendTest" method:"post" tags:"邮件记录" summary:"发送测试邮件"` sysin.SendEmsInp } + type SendTestRes struct{} diff --git a/server/api/admin/gencodes/gencodes.go b/server/api/admin/gencodes/gencodes.go index bbac65e..a4fe628 100644 --- a/server/api/admin/gencodes/gencodes.go +++ b/server/api/admin/gencodes/gencodes.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package gencodes import ( @@ -29,6 +28,7 @@ type ViewReq struct { Id int64 `json:"id" v:"required#生成代码ID不能为空" dc:"生成代码ID"` g.Meta `path:"/genCodes/view" method:"get" tags:"生成代码" summary:"获取指定信息"` } + type ViewRes struct { *sysin.GenCodesViewModel } @@ -38,6 +38,7 @@ type EditReq struct { entity.SysGenCodes g.Meta `path:"/genCodes/edit" method:"post" tags:"生成代码" summary:"修改/新增生成代码"` } + type EditRes struct { *sysin.GenCodesEditModel } @@ -47,6 +48,7 @@ type DeleteReq struct { Id interface{} `json:"id" v:"required#生成代码ID不能为空" dc:"生成代码ID"` g.Meta `path:"/genCodes/delete" method:"post" tags:"生成代码" summary:"删除生成代码"` } + type DeleteRes struct{} // MaxSortReq 最大排序 @@ -54,6 +56,7 @@ type MaxSortReq struct { Id int64 `json:"id" dc:"生成代码ID"` g.Meta `path:"/genCodes/maxSort" method:"get" tags:"生成代码" summary:"生成代码最大排序"` } + type MaxSortRes struct { Sort int `json:"sort" dc:"排序"` } @@ -63,11 +66,13 @@ type StatusReq struct { entity.SysGenCodes g.Meta `path:"/genCodes/status" method:"post" tags:"生成代码" summary:"更新生成代码状态"` } + type StatusRes struct{} type SelectsReq struct { g.Meta `path:"/genCodes/selects" method:"get" tags:"生成代码" summary:"生成入口选项"` } + type SelectsRes struct { *sysin.GenCodesSelectsModel } @@ -76,18 +81,21 @@ type TableSelectReq struct { g.Meta `path:"/genCodes/tableSelect" method:"get" tags:"生成代码" summary:"数据库表选项"` sysin.GenCodesTableSelectInp } + type TableSelectRes []*sysin.GenCodesTableSelectModel type ColumnSelectReq struct { g.Meta `path:"/genCodes/columnSelect" method:"get" tags:"生成代码" summary:"表字段选项"` sysin.GenCodesColumnSelectInp } + type ColumnSelectRes []*sysin.GenCodesColumnSelectModel type ColumnListReq struct { g.Meta `path:"/genCodes/columnList" method:"get" tags:"生成代码" summary:"表字段列表"` sysin.GenCodesColumnListInp } + type ColumnListRes []*sysin.GenCodesColumnListModel // PreviewReq 生成预览 @@ -95,6 +103,7 @@ type PreviewReq struct { g.Meta `path:"/genCodes/preview" method:"post" tags:"生成代码" summary:"生成预览"` sysin.GenCodesPreviewInp } + type PreviewRes struct { *sysin.GenCodesPreviewModel } @@ -104,5 +113,6 @@ type BuildReq struct { g.Meta `path:"/genCodes/build" method:"post" tags:"生成代码" summary:"提交生成"` sysin.GenCodesPreviewInp } + type BuildRes struct { } diff --git a/server/api/admin/log/log.go b/server/api/admin/log/log.go index 72a3d0b..08122ed 100644 --- a/server/api/admin/log/log.go +++ b/server/api/admin/log/log.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package log import ( @@ -16,6 +15,7 @@ import ( type ClearReq struct { g.Meta `path:"/log/clear" method:"post" tags:"日志" summary:"清空日志"` } + type ClearRes struct{} // ExportReq 导出 @@ -31,6 +31,7 @@ type ExportReq struct { Ip string `json:"ip" dc:"访问IP"` ErrorCode string `json:"error_code" dc:"状态码"` } + type ExportRes struct{} // ListReq 获取菜单列表 @@ -58,6 +59,7 @@ type DeleteReq struct { g.Meta `path:"/log/delete" method:"post" tags:"日志" summary:"删除日志"` Id interface{} `json:"id" v:"required#日志ID不能为空" description:"日志ID"` } + type DeleteRes struct{} // ViewReq 获取指定信息 @@ -65,6 +67,7 @@ type ViewReq struct { g.Meta `path:"/log/view" method:"get" tags:"日志" summary:"获取指定信息"` Id string `json:"id" v:"required#日志ID不能为空" description:"日志ID"` } + type ViewRes struct { *sysin.LogViewModel } diff --git a/server/api/admin/member/member.go b/server/api/admin/member/member.go index 5de114e..42e8014 100644 --- a/server/api/admin/member/member.go +++ b/server/api/admin/member/member.go @@ -16,6 +16,7 @@ type UpdateCashReq struct { g.Meta `path:"/member/updateCash" method:"post" tags:"用户" summary:"更新提现信息"` adminin.MemberUpdateCashInp } + type UpdateCashRes struct{} // UpdateEmailReq 换绑邮箱 @@ -23,6 +24,7 @@ type UpdateEmailReq struct { g.Meta `path:"/member/updateEmail" method:"post" tags:"用户" summary:"换绑邮箱"` adminin.MemberUpdateEmailInp } + type UpdateEmailRes struct{} // UpdateMobileReq 换绑手机号 @@ -30,6 +32,7 @@ type UpdateMobileReq struct { g.Meta `path:"/member/updateMobile" method:"post" tags:"用户" summary:"换绑手机号"` adminin.MemberUpdateMobileInp } + type UpdateMobileRes struct{} // UpdateProfileReq 更新用户资料 @@ -37,6 +40,7 @@ type UpdateProfileReq struct { g.Meta `path:"/member/updateProfile" method:"post" tags:"用户" summary:"更新用户资料"` adminin.MemberUpdateProfileInp } + type UpdateProfileRes struct{} // UpdatePwdReq 修改登录密码 @@ -44,6 +48,7 @@ type UpdatePwdReq struct { g.Meta `path:"/member/updatePwd" method:"post" tags:"用户" summary:"重置密码"` adminin.MemberUpdatePwdInp } + type UpdatePwdRes struct{} // ResetPwdReq 重置密码 @@ -51,6 +56,7 @@ type ResetPwdReq struct { g.Meta `path:"/member/resetPwd" method:"post" tags:"用户" summary:"重置密码"` adminin.MemberResetPwdInp } + type ResetPwdRes struct{} // ListReq 查询列表 @@ -69,6 +75,7 @@ type ViewReq struct { g.Meta `path:"/member/view" method:"get" tags:"用户" summary:"获取指定信息"` adminin.MemberViewInp } + type ViewRes struct { *adminin.MemberViewModel } @@ -78,6 +85,7 @@ type EditReq struct { g.Meta `path:"/member/edit" method:"post" tags:"用户" summary:"修改/新增用户"` adminin.MemberEditInp } + type EditRes struct{} // DeleteReq 删除 @@ -85,6 +93,7 @@ type DeleteReq struct { g.Meta `path:"/member/delete" method:"post" tags:"用户" summary:"删除用户"` adminin.MemberDeleteInp } + type DeleteRes struct{} // StatusReq 更新用户状态 @@ -92,18 +101,21 @@ type StatusReq struct { g.Meta `path:"/member/status" method:"post" tags:"用户" summary:"更新用户状态"` adminin.MemberStatusInp } + type StatusRes struct{} // SelectReq 获取可选的后台用户选项 type SelectReq struct { g.Meta `path:"/member/option" method:"get" tags:"用户" summary:"获取可选的后台用户选项"` } + type SelectRes []*adminin.MemberSelectModel // InfoReq 获取登录用户信息 type InfoReq struct { g.Meta `path:"/member/info" method:"get" tags:"用户" summary:"获取登录用户信息"` } + type InfoRes struct { *adminin.LoginMemberInfoModel } @@ -113,6 +125,7 @@ type AddBalanceReq struct { g.Meta `path:"/member/addBalance" method:"post" tags:"用户" summary:"增加余额"` adminin.MemberAddBalanceInp } + type AddBalanceRes struct{} // AddIntegralReq 增加积分 @@ -120,4 +133,5 @@ type AddIntegralReq struct { g.Meta `path:"/member/addIntegral" method:"post" tags:"用户" summary:"增加积分"` adminin.MemberAddIntegralInp } + type AddIntegralRes struct{} diff --git a/server/api/admin/menu/menu.go b/server/api/admin/menu/menu.go index d6648cc..07ccb16 100644 --- a/server/api/admin/menu/menu.go +++ b/server/api/admin/menu/menu.go @@ -16,6 +16,7 @@ type MaxSortReq struct { g.Meta `path:"/menu/maxSort" method:"get" tags:"菜单" summary:"菜单最大排序"` Id int64 `json:"id" dc:"菜单ID"` } + type MaxSortRes struct { Sort int `json:"sort" dc:"排序"` } @@ -26,6 +27,7 @@ type CodeUniqueReq struct { Code string `json:"code" v:"required#菜单编码不能为空" dc:"菜单编码"` Id int64 `json:"id" dc:"菜单ID"` } + type CodeUniqueRes struct { IsUnique bool `json:"is_unique" dc:"是否唯一"` } @@ -36,6 +38,7 @@ type NameUniqueReq struct { Name string `json:"name" v:"required#菜单名称不能为空" dc:"菜单名称"` Id int64 `json:"id" dc:"菜单ID"` } + type NameUniqueRes struct { IsUnique bool `json:"is_unique" dc:"是否唯一"` } @@ -45,6 +48,7 @@ type EditReq struct { g.Meta `path:"/menu/edit" method:"post" tags:"菜单" summary:"修改/新增菜单"` entity.AdminMenu } + type EditRes struct{} // DeleteReq 删除菜单 @@ -52,6 +56,7 @@ type DeleteReq struct { g.Meta `path:"/menu/delete" method:"post" tags:"菜单" summary:"删除菜单"` Id interface{} `json:"id" v:"required#菜单ID不能为空" dc:"菜单ID"` } + type DeleteRes struct{} // ViewReq 获取指定菜单信息 @@ -59,6 +64,7 @@ type ViewReq struct { g.Meta `path:"/menu/view" method:"get" tags:"菜单" summary:"获取指定菜单信息"` Id string `json:"id" v:"required#菜单ID不能为空" dc:"菜单ID"` } + type ViewRes struct { *entity.AdminMenu } diff --git a/server/api/admin/monitor/monitor.go b/server/api/admin/monitor/monitor.go index cf28a64..3b6061a 100644 --- a/server/api/admin/monitor/monitor.go +++ b/server/api/admin/monitor/monitor.go @@ -15,6 +15,7 @@ type OfflineReq struct { g.Meta `path:"/monitor/offline" method:"post" tags:"在线用户" summary:"下线用户"` Id string `json:"id" v:"required#SID不能为空" description:"SID"` } + type OfflineRes struct{} // OnlineListReq 获取在线用户列表 @@ -37,6 +38,7 @@ type OnlineViewReq struct { g.Meta `path:"/monitor/onlineView" method:"get" tags:"在线用户" summary:"获取指定用户信息"` Id string `json:"id" v:"required#SID不能为空" description:"SID"` } + type OnlineViewRes struct { *OnlineModel } diff --git a/server/api/admin/order/order.go b/server/api/admin/order/order.go index 21e6d13..c7908c5 100644 --- a/server/api/admin/order/order.go +++ b/server/api/admin/order/order.go @@ -33,6 +33,7 @@ type ApplyRefundRes struct { type OptionReq struct { g.Meta `path:"/order/option" method:"get" summary:"充值订单" tags:"获取订单状态选项"` } + type OptionRes struct { Status []g.Map `json:"status" dc:"订单状态"` AcceptRefundStatus []g.Map `json:"acceptRefundStatus" dc:"订单退款受理状态"` @@ -83,6 +84,7 @@ type EditReq struct { g.Meta `path:"/order/edit" method:"post" tags:"充值订单" summary:"修改/新增充值订单"` adminin.OrderEditInp } + type EditRes struct{} // DeleteReq 删除充值订单 diff --git a/server/api/admin/post/post.go b/server/api/admin/post/post.go index 87db8df..c153e3d 100644 --- a/server/api/admin/post/post.go +++ b/server/api/admin/post/post.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package post import ( @@ -18,6 +17,7 @@ type EditReq struct { g.Meta `path:"/post/edit" method:"post" tags:"岗位" summary:"修改/新增岗位"` entity.AdminPost } + type EditRes struct{} // DeleteReq 删除岗位 @@ -25,6 +25,7 @@ type DeleteReq struct { g.Meta `path:"/post/delete" method:"post" tags:"岗位" summary:"删除岗位"` Id interface{} `json:"id" v:"required#岗位ID不能为空" description:"岗位ID"` } + type DeleteRes struct{} // MaxSortReq 最大排序 @@ -32,6 +33,7 @@ type MaxSortReq struct { g.Meta `path:"/post/maxSort" method:"get" tags:"岗位" summary:"岗位最大排序"` Id int64 `json:"id" description:"岗位ID"` } + type MaxSortRes struct { Sort int `json:"sort" description:"排序"` } @@ -56,6 +58,7 @@ type ViewReq struct { g.Meta `path:"/post/view" method:"get" tags:"岗位" summary:"获取指定信息"` Id string `json:"id" v:"required#岗位ID不能为空" description:"岗位ID"` } + type ViewRes struct { *adminin.PostViewModel } @@ -66,6 +69,7 @@ type CodeUniqueReq struct { Code string `json:"code" v:"required#岗位编码不能为空" description:"岗位编码"` Id int64 `json:"id" description:"岗位ID"` } + type CodeUniqueRes struct { IsUnique bool `json:"is_unique" description:"是否唯一"` } @@ -76,6 +80,7 @@ type NameUniqueReq struct { Name string `json:"name" v:"required#岗位名称不能为空" description:"岗位名称"` Id int64 `json:"id" description:"岗位ID"` } + type NameUniqueRes struct { IsUnique bool `json:"is_unique" description:"是否唯一"` } @@ -85,4 +90,5 @@ type StatusReq struct { entity.AdminPost g.Meta `path:"/post/status" method:"post" tags:"岗位" summary:"更新岗位状态"` } + type StatusRes struct{} diff --git a/server/api/admin/provinces/provinces.go b/server/api/admin/provinces/provinces.go index 610af7c..93193f3 100644 --- a/server/api/admin/provinces/provinces.go +++ b/server/api/admin/provinces/provinces.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package provinces import ( @@ -33,6 +32,7 @@ type ViewReq struct { Id int64 `json:"id" v:"required#省市区ID不能为空" dc:"省市区ID"` g.Meta `path:"/provinces/view" method:"get" tags:"省市区" summary:"获取指定信息"` } + type ViewRes struct { *sysin.ProvincesViewModel } @@ -42,6 +42,7 @@ type EditReq struct { g.Meta `path:"/provinces/edit" method:"post" tags:"省市区" summary:"修改/新增省市区"` sysin.ProvincesEditInp } + type EditRes struct{} // DeleteReq 删除 @@ -49,12 +50,14 @@ type DeleteReq struct { g.Meta `path:"/provinces/delete" method:"post" tags:"省市区" summary:"删除省市区"` sysin.ProvincesDeleteInp } + type DeleteRes struct{} // MaxSortReq 最大排序 type MaxSortReq struct { g.Meta `path:"/provinces/maxSort" method:"get" tags:"省市区" summary:"省市区最大排序"` } + type MaxSortRes struct { *sysin.ProvincesMaxSortModel } @@ -64,12 +67,14 @@ type StatusReq struct { entity.SysProvinces g.Meta `path:"/provinces/status" method:"post" tags:"省市区" summary:"更新省市区状态"` } + type StatusRes struct{} // TreeReq 关系树选项列表 type TreeReq struct { g.Meta `path:"/provinces/tree" tags:"省市区" method:"get" summary:"省市区关系树选项列表"` } + type TreeRes struct { List []map[string]interface{} `json:"list" dc:"数据列表"` } @@ -90,6 +95,7 @@ type UniqueIdReq struct { g.Meta `path:"/provinces/uniqueId" method:"get" tags:"省市区" summary:"地区ID是否唯一"` sysin.ProvincesUniqueIdInp } + type UniqueIdRes struct { *sysin.ProvincesUniqueIdModel } @@ -99,6 +105,7 @@ type SelectReq struct { g.Meta `path:"/provinces/select" method:"get" summary:"省市区" tags:"省市区选项"` sysin.ProvincesSelectInp } + type SelectRes struct { *sysin.ProvincesSelectModel } @@ -108,4 +115,5 @@ type CityLabelReq struct { g.Meta `path:"/provinces/cityLabel" method:"get" summary:"省市区" tags:"获取指定城市标签"` sysin.ProvincesCityLabelInp } + type CityLabelRes sysin.ProvincesCityLabelModel diff --git a/server/api/admin/role/role.go b/server/api/admin/role/role.go index 159d2d3..692bd8c 100644 --- a/server/api/admin/role/role.go +++ b/server/api/admin/role/role.go @@ -78,6 +78,7 @@ type EditReq struct { g.Meta `path:"/role/edit" method:"post" tags:"角色" summary:"修改/新增角色"` adminin.RoleEditInp } + type EditRes struct{} // DeleteReq 删除角色 @@ -85,12 +86,14 @@ type DeleteReq struct { g.Meta `path:"/role/delete" method:"post" tags:"角色" summary:"删除角色"` adminin.RoleDeleteInp } + type DeleteRes struct{} // DataScopeSelectReq 获取数据权限选项 type DataScopeSelectReq struct { g.Meta `path:"/role/dataScope/select" method:"get" summary:"角色" tags:"获取数据权限选项"` } + type DataScopeSelectRes struct { List form.Selects `json:"list" dc:"数据选项"` } @@ -100,4 +103,5 @@ type DataScopeEditReq struct { g.Meta `path:"/role/dataScope/edit" method:"post" tags:"角色" summary:"修改指定角色的数据权限"` adminin.DataScopeEditInp } + type DataScopeEditRes struct{} diff --git a/server/api/admin/smslog/smslog.go b/server/api/admin/smslog/smslog.go index 3ffa1fc..170d549 100644 --- a/server/api/admin/smslog/smslog.go +++ b/server/api/admin/smslog/smslog.go @@ -23,6 +23,7 @@ type ViewReq struct { Id int64 `json:"id" v:"required#短信记录ID不能为空" dc:"短信记录ID"` g.Meta `path:"/smsLog/view" method:"get" tags:"短信记录" summary:"获取指定信息"` } + type ViewRes struct { *sysin.SmsLogViewModel } @@ -32,6 +33,7 @@ type EditReq struct { entity.SysSmsLog g.Meta `path:"/smsLog/edit" method:"post" tags:"短信记录" summary:"修改/新增短信记录"` } + type EditRes struct{} // DeleteReq 删除 @@ -39,6 +41,7 @@ type DeleteReq struct { Id interface{} `json:"id" v:"required#短信记录ID不能为空" dc:"短信记录ID"` g.Meta `path:"/smsLog/delete" method:"post" tags:"短信记录" summary:"删除短信记录"` } + type DeleteRes struct{} // MaxSortReq 最大排序 @@ -46,6 +49,7 @@ type MaxSortReq struct { Id int64 `json:"id" dc:"短信记录ID"` g.Meta `path:"/smsLog/maxSort" method:"get" tags:"短信记录" summary:"短信记录最大排序"` } + type MaxSortRes struct { Sort int `json:"sort" dc:"排序"` } @@ -55,6 +59,7 @@ type StatusReq struct { entity.SysSmsLog g.Meta `path:"/smsLog/status" method:"post" tags:"短信记录" summary:"更新短信记录状态"` } + type StatusRes struct{} // SendTestReq 更新状态 @@ -62,4 +67,5 @@ type SendTestReq struct { entity.SysSmsLog g.Meta `path:"/smsLog/sendTest" method:"post" tags:"短信记录" summary:"发送测试短信"` } + type SendTestRes struct{} diff --git a/server/api/admin/user/hello.go b/server/api/admin/user/hello.go index 0715d15..5645fd1 100644 --- a/server/api/admin/user/hello.go +++ b/server/api/admin/user/hello.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package user import ( @@ -13,6 +12,7 @@ import ( type HelloReq struct { g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"` } + type HelloRes struct { g.Meta `mime:"text/html" example:"string"` } diff --git a/server/api/api/member/member.go b/server/api/api/member/member.go index 03debe5..8816592 100644 --- a/server/api/api/member/member.go +++ b/server/api/api/member/member.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package member import "github.com/gogf/gf/v2/frame/g" @@ -13,4 +12,5 @@ type GetIdByCodeReq struct { g.Meta `path:"/member/getIdByCode" method:"post" tags:"用户" summary:"通过邀请码获取用户ID"` Code string `json:"code" dc:"邀请码"` } + type GetIdByCodeRes struct{} diff --git a/server/api/api/user/hello.go b/server/api/api/user/hello.go index 0715d15..5645fd1 100644 --- a/server/api/api/user/hello.go +++ b/server/api/api/user/hello.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package user import ( @@ -13,6 +12,7 @@ import ( type HelloReq struct { g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"` } + type HelloRes struct { g.Meta `mime:"text/html" example:"string"` } diff --git a/server/api/home/base/site.go b/server/api/home/base/site.go index e5600a0..4920b4f 100644 --- a/server/api/home/base/site.go +++ b/server/api/home/base/site.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package base import "github.com/gogf/gf/v2/frame/g" @@ -11,6 +10,7 @@ import "github.com/gogf/gf/v2/frame/g" type SiteIndexReq struct { g.Meta `path:"/index" method:"get" summary:"首页" tags:"首页"` } + type SiteIndexRes struct { g.Meta `mime:"text/html" type:"string" example:""` } diff --git a/server/go.mod b/server/go.mod index 6d7b519..ce3f36d 100644 --- a/server/go.mod +++ b/server/go.mod @@ -11,7 +11,6 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible github.com/apache/rocketmq-client-go/v2 v2.1.0 github.com/casbin/casbin/v2 v2.55.0 - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/forgoer/openssl v1.4.0 github.com/go-pay/gopay v1.5.91 github.com/gogf/gf/contrib/drivers/mysql/v2 v2.4.1 diff --git a/server/go.sum b/server/go.sum index 9420885..fa42596 100644 --- a/server/go.sum +++ b/server/go.sum @@ -108,8 +108,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/eapache/go-resiliency v1.2.0 h1:v7g92e/KSN71Rq7vSThKaWIq68fL4YHvWyiUKorFR1Q= diff --git a/server/internal/cmd/cron.go b/server/internal/cmd/cron.go index de04962..656fd29 100644 --- a/server/internal/cmd/cron.go +++ b/server/internal/cmd/cron.go @@ -7,9 +7,9 @@ package cmd import ( "context" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcmd" - "hotgo/internal/crons" + "hotgo/internal/global" + "hotgo/internal/library/cron" "hotgo/internal/service" ) @@ -19,6 +19,9 @@ var ( Brief: "定时任务,用来部署一些可独立运行的定时任务,通过tcp方式和后台保持长连接通讯,动态调整任务属性。", Description: ``, Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { + // 服务日志处理 + cron.Logger().SetHandlers(global.LoggingServeLogHandler) + // 启动定时任务 service.SysCron().StartCron(ctx) @@ -32,8 +35,8 @@ var ( <-serverCloseSignal service.CronClient().Stop(ctx) - crons.StopALL() - g.Log().Debug(ctx, "cron successfully closed ..") + cron.StopALL() + cron.Logger().Debug(ctx, "cron successfully closed ..") serverWg.Done() return }, diff --git a/server/internal/cmd/http.go b/server/internal/cmd/http.go index d932f49..70c7f15 100644 --- a/server/internal/cmd/http.go +++ b/server/internal/cmd/http.go @@ -10,8 +10,11 @@ import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gcmd" + "hotgo/internal/consts" "hotgo/internal/library/addons" "hotgo/internal/library/casbin" + "hotgo/internal/library/hggen" + "hotgo/internal/library/payment" "hotgo/internal/router" "hotgo/internal/service" "hotgo/internal/websocket" @@ -23,9 +26,7 @@ var ( Usage: "http", Brief: "HTTP服务,也可以称为主服务,包含http、websocket、tcpserver多个可对外服务", Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { - // 加载权限 - casbin.InitEnforcer(ctx) - + // 初始化http服务 s := g.Server() // 错误状态码接管 @@ -47,7 +48,7 @@ var ( // 注册全局中间件 group.Middleware( - service.Middleware().Ctx, //必须第一个加载 + service.Middleware().Ctx, // 必须第一个加载 service.Middleware().CORS, service.Middleware().Blacklist, service.Middleware().DemoLimit, @@ -70,11 +71,25 @@ var ( addons.RegisterModulesRouter(ctx, group) }) + // 初始化casbin权限 + casbin.InitEnforcer(ctx) + + // 初始化生成代码配置 + hggen.InIt(ctx) + // 启动tcp服务 service.TCPServer().Start(ctx) - // https - setSSL(ctx, s) + // 启动服务监控 + service.AdminMonitor().StartMonitor(ctx) + + // 加载ip访问黑名单 + service.SysBlacklist().Load(ctx) + + // 注册支付成功回调方法 + payment.RegisterNotifyCallMap(map[string]payment.NotifyCallFunc{ + consts.OrderGroupAdminOrder: service.AdminOrder().PayNotify, // 后台充值订单 + }) serverWg.Add(1) @@ -96,13 +111,3 @@ var ( }, } ) - -func setSSL(ctx context.Context, s *ghttp.Server) { - config, err := service.SysConfig().GetLoadSSL(ctx) - if err != nil { - g.Log().Fatal(ctx, "ssl配置获取失败:err:%+v", err) - } - if config != nil && config.Switch { - s.EnableHTTPS(config.CrtPath, config.KeyPath) - } -} diff --git a/server/internal/cmd/queue.go b/server/internal/cmd/queue.go index 42f85ee..c298ce0 100644 --- a/server/internal/cmd/queue.go +++ b/server/internal/cmd/queue.go @@ -7,8 +7,8 @@ package cmd import ( "context" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcmd" + "hotgo/internal/global" "hotgo/internal/library/queue" "hotgo/utility/simple" ) @@ -19,10 +19,13 @@ var ( Brief: "消息队列", Description: ``, Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { + // 服务日志处理 + queue.Logger().SetHandlers(global.LoggingServeLogHandler) + simple.SafeGo(ctx, func(ctx context.Context) { - g.Log().Debug(ctx, "start queue consumer..") + queue.Logger().Debug(ctx, "start queue consumer..") queue.StartConsumersListener(ctx) - g.Log().Debug(ctx, "start queue consumer success..") + queue.Logger().Debug(ctx, "start queue consumer success..") }) serverWg.Add(1) @@ -31,7 +34,7 @@ var ( signalListen(ctx, signalHandlerForOverall) <-serverCloseSignal - g.Log().Debug(ctx, "queue successfully closed ..") + queue.Logger().Debug(ctx, "queue successfully closed ..") serverWg.Done() return }, diff --git a/server/internal/controller/admin/admin/cash.go b/server/internal/controller/admin/admin/cash.go index d9bbdfa..126f4c7 100644 --- a/server/internal/controller/admin/admin/cash.go +++ b/server/internal/controller/admin/admin/cash.go @@ -50,7 +50,6 @@ func (c *cCash) List(ctx context.Context, req *cash.ListReq) (res *cash.ListRes, res.PageCount = form.CalPageCount(totalCount, req.PerPage) res.Page = req.Page res.PerPage = req.PerPage - return } diff --git a/server/internal/controller/admin/admin/monitor.go b/server/internal/controller/admin/admin/monitor.go index 6cdf84f..ac68e6a 100644 --- a/server/internal/controller/admin/admin/monitor.go +++ b/server/internal/controller/admin/admin/monitor.go @@ -41,7 +41,6 @@ func (c *cMonitor) Offline(ctx context.Context, req *monitor.OfflineReq) (res *m websocket.SendSuccess(client, "kick") websocket.Close(client) }) - return } @@ -94,18 +93,17 @@ func (c *cMonitor) OnlineList(ctx context.Context, req *monitor.OnlineListReq) ( res.PerPage = req.PerPage sort.Sort(monitor.OnlineModels(clients)) - isDemo := g.Cfg().MustGet(ctx, "hotgo.isDemo", false) + isDemo := g.Cfg().MustGet(ctx, "hotgo.isDemo", false).Bool() _, perPage, offset := form.CalPage(ctx, req.Page, req.PerPage) for k, v := range clients { if k >= offset && i <= perPage { - if isDemo.Bool() { + if isDemo { v.Addr = consts.DemoTips } res.List = append(res.List, v) i++ } } - return } diff --git a/server/internal/controller/admin/common/console.go b/server/internal/controller/admin/common/console.go index 30c44c8..9b2eaf6 100644 --- a/server/internal/controller/admin/common/console.go +++ b/server/internal/controller/admin/common/console.go @@ -18,6 +18,8 @@ type cConsole struct{} 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 diff --git a/server/internal/controller/admin/common/upload.go b/server/internal/controller/admin/common/upload.go index 9d13d5d..d02363e 100644 --- a/server/internal/controller/admin/common/upload.go +++ b/server/internal/controller/admin/common/upload.go @@ -24,7 +24,6 @@ func (c *cUpload) UploadImage(ctx context.Context, _ *common.UploadImageReq) (re err = gerror.New("没有找到上传的文件") return } - return service.CommonUpload().UploadImage(ctx, file) } @@ -35,6 +34,5 @@ func (c *cUpload) UploadFile(ctx context.Context, _ *common.UploadFileReq) (res err = gerror.New("没有找到上传的文件") return } - return service.CommonUpload().UploadFile(ctx, file) } diff --git a/server/internal/controller/admin/sys/dict_data.go b/server/internal/controller/admin/sys/dict_data.go index a218d86..d7b142b 100644 --- a/server/internal/controller/admin/sys/dict_data.go +++ b/server/internal/controller/admin/sys/dict_data.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package sys import ( @@ -94,6 +93,5 @@ func (c *cDictData) Selects(ctx context.Context, req *dict.DataSelectsReq) (res } res[v] = option } - return } diff --git a/server/internal/controller/api/pay/notify.go b/server/internal/controller/api/pay/notify.go index 15497d3..5205ccc 100644 --- a/server/internal/controller/api/pay/notify.go +++ b/server/internal/controller/api/pay/notify.go @@ -37,7 +37,6 @@ func (c *cNotify) WxPay(ctx context.Context, _ *pay.NotifyWxPayReq) (res *pay.No } res = &pay.NotifyWxPayRes{PayType: consts.PayTypeWxPay, Code: "SUCCESS", Message: "收单成功"} - return } diff --git a/server/internal/controller/websocket/handler/admin/monitor.go b/server/internal/controller/websocket/handler/admin/monitor.go index 6eb9037..48c6368 100644 --- a/server/internal/controller/websocket/handler/admin/monitor.go +++ b/server/internal/controller/websocket/handler/admin/monitor.go @@ -23,7 +23,6 @@ import ( "hotgo/utility/format" "os" "runtime" - "strconv" "time" ) @@ -77,8 +76,8 @@ func (c *cMonitor) RunInfo(client *websocket.Client, req *websocket.WRequest) { "goSize": file.DirSize(pwd), } - isDemo := g.Cfg().MustGet(client.Context(), "hotgo.isDemo", false) - if isDemo.Bool() { + isDemo := g.Cfg().MustGet(client.Context(), "hotgo.isDemo", false).Bool() + if isDemo { data["rootPath"] = consts.DemoTips data["pwd"] = consts.DemoTips data["intranet_ip"] = consts.DemoTips @@ -104,7 +103,7 @@ func (c *cMonitor) Trends(client *websocket.Client, req *websocket.WRequest) { mMem, memErr = mem.VirtualMemory() mMemUsed float64 mDisk, diskErr = disk.Usage("/") - mProcess, ProcessErr = process.Pids() + mProcess, processErr = process.Pids() mLoadAvg = new(model.LoadAvgStats) monitorHeads []MonitorHead nets []NetC @@ -112,32 +111,32 @@ func (c *cMonitor) Trends(client *websocket.Client, req *websocket.WRequest) { ) if cpuErr != nil { - g.Log().Infof(client.Context(), "read CPU info fail:%+v", cpuErr) + g.Log().Warningf(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) + g.Log().Warningf(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) + g.Log().Warningf(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) + if processErr != nil { + g.Log().Warningf(client.Context(), "read process.Pids fail:%+v", processErr) } // cpu使用率 cu, err := cpu.Percent(time.Second, false) if err == nil { - mCpuUsed, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cu[0]), 64) + mCpuUsed = gconv.Float64(fmt.Sprintf("%.2f", cu[0])) } // 内存使用率 - mMemUsed, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", mMem.UsedPercent), 64) + mMemUsed = gconv.Float64(fmt.Sprintf("%.2f", mMem.UsedPercent)) // 负载 if len(meta.LoadAvg) > 0 { diff --git a/server/internal/crons/close_order.go b/server/internal/crons/close_order.go index 4265944..2b92a30 100644 --- a/server/internal/crons/close_order.go +++ b/server/internal/crons/close_order.go @@ -11,11 +11,12 @@ import ( "github.com/gogf/gf/v2/os/gtime" "hotgo/internal/consts" "hotgo/internal/dao" + "hotgo/internal/library/cron" "hotgo/internal/service" ) func init() { - cronList = append(cronList, CloseOrder) + cron.Register(CloseOrder) } // CloseOrder 取消过期订单 @@ -38,6 +39,6 @@ func (c *cCloseOrder) Execute(ctx context.Context) { dao.AdminOrder.Columns().Status: consts.OrderStatusClose, }).Update() if err != nil { - g.Log().Warning(ctx, "cron CloseOrder Execute err:%+v", err) + cron.Logger().Warning(ctx, "cron CloseOrder Execute err:%+v", err) } } diff --git a/server/internal/crons/test.go b/server/internal/crons/test.go index 47870f8..7d243a6 100644 --- a/server/internal/crons/test.go +++ b/server/internal/crons/test.go @@ -3,17 +3,16 @@ // @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" + "hotgo/internal/library/cron" "time" ) func init() { - cronList = append(cronList, Test) + cron.Register(Test) } // Test 测试任务(无参数) @@ -29,5 +28,5 @@ func (c *cTest) GetName() string { // Execute 执行任务 func (c *cTest) Execute(ctx context.Context) { - g.Log().Infof(ctx, "cron test Execute:%v", time.Now()) + cron.Logger().Infof(ctx, "cron test Execute:%v", time.Now()) } diff --git a/server/internal/crons/test2.go b/server/internal/crons/test2.go index 554cf65..139c3bd 100644 --- a/server/internal/crons/test2.go +++ b/server/internal/crons/test2.go @@ -3,18 +3,17 @@ // @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" "hotgo/internal/consts" + "hotgo/internal/library/cron" "time" ) func init() { - cronList = append(cronList, Test2) + cron.Register(Test2) } // Test2 测试2任务(带参数) @@ -32,11 +31,11 @@ func (c *cTest2) GetName() string { func (c *cTest2) Execute(ctx context.Context) { args, ok := ctx.Value(consts.ContextKeyCronArgs).([]string) if !ok { - g.Log().Warning(ctx, "参数解析失败!") + cron.Logger().Warning(ctx, "参数解析失败!") return } if len(args) != 3 { - g.Log().Warning(ctx, "test2 传入参数不正确!") + cron.Logger().Warning(ctx, "test2 传入参数不正确!") return } @@ -46,5 +45,5 @@ func (c *cTest2) Execute(ctx context.Context) { msg = args[2] ) - g.Log().Infof(ctx, "cron test2 Execute:%v, name:%v, age:%v, msg:%v", time.Now(), name, age, msg) + cron.Logger().Infof(ctx, "cron test2 Execute:%v, name:%v, age:%v, msg:%v", time.Now(), name, age, msg) } diff --git a/server/internal/global/init.go b/server/internal/global/init.go index d6bafbd..5693eec 100644 --- a/server/internal/global/init.go +++ b/server/internal/global/init.go @@ -18,7 +18,6 @@ import ( "github.com/gogf/gf/v2/text/gstr" "hotgo/internal/consts" "hotgo/internal/library/cache" - "hotgo/internal/library/hggen" "hotgo/internal/library/queue" "hotgo/internal/model/entity" "hotgo/internal/service" @@ -47,22 +46,12 @@ func Init(ctx context.Context) { // 设置缓存适配器 cache.SetAdapter(ctx) - // 启动服务监控 - service.AdminMonitor().StartMonitor(ctx) - - // 加载ip访问黑名单 - service.SysBlacklist().Load(ctx) - // 初始化功能库配置 service.SysConfig().InitConfig(ctx) - - // 注册支付成功回调方法 - payNotifyCall() - - // 初始化生成代码配置 - hggen.InIt(ctx) } +// LoggingServeLogHandler 服务日志处理 +// 需要将异常日志保存到服务日志时可以通过SetHandlers设置此方法 func LoggingServeLogHandler(ctx context.Context, in *glog.HandlerInput) { in.Next(ctx) @@ -120,6 +109,6 @@ func LoggingServeLogHandler(ctx context.Context, in *glog.HandlerInput) { }) if err != nil { - g.Log("serveLog").Errorf(ctx, "LoggingServeLogHandler err:%+v", err) + g.Dump("LoggingServeLogHandler err:%+v", err) } } diff --git a/server/internal/global/pay.go b/server/internal/global/pay.go deleted file mode 100644 index ef21fa0..0000000 --- a/server/internal/global/pay.go +++ /dev/null @@ -1,13 +0,0 @@ -package global - -import ( - "hotgo/internal/consts" - "hotgo/internal/library/payment" - "hotgo/internal/service" -) - -// 注册支付成功回调方法 -func payNotifyCall() { - payment.RegisterNotifyCall(consts.OrderGroupAdminOrder, service.AdminOrder().PayNotify) // 后台充值订单 - // ... -} diff --git a/server/internal/crons/init.go b/server/internal/library/cron/cron.go similarity index 66% rename from server/internal/crons/init.go rename to server/internal/library/cron/cron.go index 6c9320a..a37ab44 100644 --- a/server/internal/crons/init.go +++ b/server/internal/library/cron/cron.go @@ -1,9 +1,9 @@ -// Package crons +// Package cron // @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 +package cron import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcron" "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gtime" "hotgo/internal/consts" "hotgo/internal/dao" @@ -20,19 +21,19 @@ import ( "sync" ) +var crons = &cronManager{ + tasks: make(map[string]*TaskItem), +} + +// cronStrategy 任务接口 type cronStrategy interface { GetName() string Execute(ctx context.Context) } -var ( - // 添加新的任务时,只需实现cronStrategy接口,并加入到cronList即可 - cronList []cronStrategy - inst = new(tasks) -) - -type tasks struct { - list []*TaskItem +// consumerManager 任务管理者 +type cronManager struct { + tasks map[string]*TaskItem sync.RWMutex } @@ -45,40 +46,40 @@ type TaskItem struct { Count int // 执行次数,仅Policy=4时有效 } -func LoadCronList() { - for _, cron := range cronList { - inst.Add(&TaskItem{ - Name: cron.GetName(), - Fun: cron.Execute, - }) - } +func Logger() *glog.Logger { + return g.Log("cron") } +// Register 注册任务 +func Register(c cronStrategy) { + crons.Lock() + defer crons.Unlock() + + name := c.GetName() + if _, ok := crons.tasks[name]; ok { + Logger().Debugf(gctx.GetInitCtx(), "cron.Register name:%v duplicate registration.", name) + return + } + crons.tasks[name] = &TaskItem{Name: c.GetName(), Fun: c.Execute} +} + +// StopALL 停止所有任务 func StopALL() { for _, v := range gcron.Entries() { gcron.Remove(v.Name) } } -// StartALL 启动任务 -func StartALL(sysCron []*entity.SysCron) error { - if len(inst.list) == 0 { - LoadCronList() - } - - var ( - err error - ct = gctx.New() - ) - - if len(sysCron) == 0 { - g.Log().Debug(ct, "no scheduled task is available.") - return nil +// StartALL 启动所有任务 +func StartALL(sysCron []*entity.SysCron) (err error) { + if len(crons.tasks) == 0 { + g.Log().Debug(gctx.GetInitCtx(), "no scheduled task is available.") + return } for _, cron := range sysCron { - f := inst.Get(cron.Name) - if f == nil { + f, ok := crons.tasks[cron.Name] + if !ok { return gerror.Newf("该任务没有加入任务列表:%v", cron.Name) } @@ -120,17 +121,14 @@ func StartALL(sysCron []*entity.SysCron) error { // 执行完毕,单次和多次执行的任务更新状态 if cron.Policy == consts.CronPolicyOnce || cron.Policy == consts.CronPolicyTimes { - _, err = dao.SysCron.Ctx(ct).Where("id", cron.Id). - Data(g.Map{"status": consts.StatusDisable, "updated_at": gtime.Now()}). - Update() - if err != nil { - err = gerror.Wrap(err, consts.ErrorORM) + if _, err = dao.SysCron.Ctx(gctx.GetInitCtx()).Where("id", cron.Id).Data(g.Map{"status": consts.StatusDisable, "updated_at": gtime.Now()}).Update(); err != nil { + err = gerror.Wrap(err, "定时任务执行失败!") return err } } } - g.Log().Debug(ct, "load cron success..") + Logger().Debug(gctx.GetInitCtx(), "load cron success..") return nil } @@ -143,7 +141,6 @@ func RefreshStatus(sysCron *entity.SysCron) (err error) { if sysCron.Status == consts.StatusEnabled { return Start(sysCron) } - return Stop(sysCron) } @@ -159,15 +156,14 @@ func Stop(sysCron *entity.SysCron) (err error) { // Once 立即执行一次某个任务 func Once(ctx context.Context, sysCron *entity.SysCron) error { - for _, v := range cronList { - if v.GetName() == sysCron.Name { + for _, v := range crons.tasks { + if v.Name == sysCron.Name { simple.SafeGo(ctx, func(ctx context.Context) { - v.Execute(ctx) + v.Fun(ctx) }) return nil } } - return gerror.Newf("定时任务不存在:%+v", sysCron.Name) } @@ -182,7 +178,6 @@ func Delete(sysCron *entity.SysCron) (err error) { gcron.Remove(v.Name) } } - return } @@ -191,53 +186,11 @@ func Start(sysCron *entity.SysCron) (err error) { if sysCron == nil { return } - cr := gcron.Search(sysCron.Name) - if cr != nil { - cr.Start() + + c := gcron.Search(sysCron.Name) + if c != nil { + c.Start() return } - return StartALL([]*entity.SysCron{sysCron}) } - -// Add 添加任务 -func (t *tasks) Add(task *TaskItem) *tasks { - if task.Name == "" || task.Fun == nil { - return t - } - t.Lock() - defer t.Unlock() - t.list = append(t.list, task) - return t -} - -// Get 找到任务 -func (t *tasks) Get(name string) *TaskItem { - if len(t.list) == 0 { - return nil - } - - for _, item := range t.list { - if item.Name == name { - return item - } - } - return nil -} - -// Del 删除任务 -func (t *tasks) Del(name string) (newList []*TaskItem) { - if len(t.list) == 0 { - return nil - } - t.Lock() - defer t.Unlock() - - for _, item := range t.list { - if item.Name == name { - continue - } - newList = append(newList, item) - } - return newList -} diff --git a/server/internal/library/ems/ems.go b/server/internal/library/ems/ems.go index f5615b9..e26fd45 100644 --- a/server/internal/library/ems/ems.go +++ b/server/internal/library/ems/ems.go @@ -19,10 +19,10 @@ func Send(config *model.EmailConfig, to string, subject string, body string) err } func sendToMail(config *model.EmailConfig, to, subject, body, mailType string) error { - if config == nil { return gerror.New("邮件配置不能为空") } + var ( contentType string auth = smtp.PlainAuth("", config.User, config.Password, config.Host) diff --git a/server/internal/library/location/location.go b/server/internal/library/location/location.go index a8e26c0..04fd8a3 100644 --- a/server/internal/library/location/location.go +++ b/server/internal/library/location/location.go @@ -99,17 +99,14 @@ func Cz88Find(ctx context.Context, ip string) (*IpLocationData, error) { if detail == nil { return nil, fmt.Errorf("no ip data is queried. procedure:%v", ip) } - - locationData := &IpLocationData{ + return &IpLocationData{ Ip: ip, Country: detail.Country, Region: detail.Region, Province: detail.Province, City: detail.City, Area: detail.County, - } - - return locationData, nil + }, nil } // IsJurisByIpTitle 判断地区名称是否为直辖市 diff --git a/server/internal/library/location/region.go b/server/internal/library/location/region.go index cd179eb..15a192e 100644 --- a/server/internal/library/location/region.go +++ b/server/internal/library/location/region.go @@ -8,6 +8,7 @@ package location import ( "context" "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "hotgo/internal/consts" @@ -15,6 +16,10 @@ import ( "hotgo/utility/tree" ) +func GetModel(ctx context.Context) *gdb.Model { + return g.Model("sys_provinces").Ctx(ctx) +} + // ParseSimpleRegion 通过地区ID解析地区名称,自动加入上级地区 func ParseSimpleRegion(ctx context.Context, id int64, spilt ...string) (string, error) { if id == 0 { @@ -25,7 +30,7 @@ func ParseSimpleRegion(ctx context.Context, id int64, spilt ...string) (string, err error ) - if err = g.Model("sys_provinces").Ctx(ctx).Fields("title,level,tree").Where("id", id).Scan(&models); err != nil { + if err = GetModel(ctx).Fields("title,level,tree").Where("id", id).Scan(&models); err != nil { return "", err } @@ -71,14 +76,14 @@ func ParseRegion(ctx context.Context, province int64, city int64, county int64, } if province > 0 && province < 999999 { - provinceName, err = g.Model("sys_provinces").Ctx(ctx).Where("id", province).Fields("title").Value() + provinceName, err = GetModel(ctx).Where("id", province).Fields("title").Value() if err != nil { err = gerror.Wrap(err, consts.ErrorORM) return "", err } if city > 0 { - cityName, err = g.Model("sys_provinces").Ctx(ctx).Where("id", city).Fields("title").Value() + cityName, err = GetModel(ctx).Where("id", city).Fields("title").Value() if err != nil { err = gerror.Wrap(err, consts.ErrorORM) return "", err @@ -86,7 +91,7 @@ func ParseRegion(ctx context.Context, province int64, city int64, county int64, } if county > 0 { - countyName, err = g.Model("sys_provinces").Ctx(ctx).Where("id", county).Fields("title").Value() + countyName, err = GetModel(ctx).Where("id", county).Fields("title").Value() if err != nil { err = gerror.Wrap(err, consts.ErrorORM) return "", err diff --git a/server/internal/library/network/tcp/client.go b/server/internal/library/network/tcp/client.go index fcd01e2..23c22cf 100644 --- a/server/internal/library/network/tcp/client.go +++ b/server/internal/library/network/tcp/client.go @@ -7,7 +7,6 @@ package tcp import ( "context" - "fmt" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gtcp" @@ -87,13 +86,7 @@ func NewClient(config *ClientConfig) (client *Client, err error) { client.auth = config.Auth client.loginEvent = config.LoginEvent client.closeEvent = config.CloseEvent - - logger := glog.New() - path := g.Cfg().MustGet(client.Ctx, "logger.path", "logs/logger").String() - if err = logger.SetPath(fmt.Sprintf("%s/tcp.client/%s.%s", path, config.Auth.Group, config.Auth.Name)); err != nil { - return - } - client.Logger = logger + client.Logger = g.Log("tcpClient") if config.ConnectInterval <= 0 { client.connectInterval = 5 * time.Second diff --git a/server/internal/library/network/tcp/server.go b/server/internal/library/network/tcp/server.go index fc76764..83cd939 100644 --- a/server/internal/library/network/tcp/server.go +++ b/server/internal/library/network/tcp/server.go @@ -7,7 +7,6 @@ package tcp import ( "context" - "fmt" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gtcp" @@ -73,17 +72,10 @@ func NewServer(config *ServerConfig) (server *Server, err error) { server.ln = gtcp.NewServer(server.addr, server.accept, config.Name) server.clients = make(map[string]*ClientConn) server.closeFlag = false - - logger := glog.New() - path := g.Cfg().MustGet(server.Ctx, "logger.path", "logs/logger").String() - if err = logger.SetPath(fmt.Sprintf("%s/tcp.server/%s", path, config.Name)); err != nil { - return - } - server.Logger = logger + server.Logger = g.Log("tcpServer") server.rpc = NewRpc(server.Ctx) server.startCron() - return } diff --git a/server/internal/library/payment/notifycall.go b/server/internal/library/payment/notifycall.go index 6077c4c..fdc34bb 100644 --- a/server/internal/library/payment/notifycall.go +++ b/server/internal/library/payment/notifycall.go @@ -29,6 +29,13 @@ func RegisterNotifyCall(group string, f NotifyCallFunc) { notifyCall[group] = f } +// RegisterNotifyCallMap 注册支付成功回调方法 +func RegisterNotifyCallMap(calls map[string]NotifyCallFunc) { + for group, f := range calls { + RegisterNotifyCall(group, f) + } +} + // NotifyCall 执行订单分组的异步回调 func NotifyCall(ctx context.Context, in payin.NotifyCallFuncInp) { f, ok := notifyCall[in.Pay.OrderGroup] diff --git a/server/internal/library/queue/consumer.go b/server/internal/library/queue/consumer.go index 89d16a0..87fdb49 100644 --- a/server/internal/library/queue/consumer.go +++ b/server/internal/library/queue/consumer.go @@ -2,7 +2,6 @@ package queue import ( "context" - "github.com/gogf/gf/v2/frame/g" "sync" ) @@ -28,7 +27,7 @@ func RegisterConsumer(cs consumerStrategy) { defer consumers.Unlock() topic := cs.GetTopic() if _, ok := consumers.list[topic]; ok { - g.Log().Debugf(ctx, "queue.RegisterConsumer topic:%v duplicate registration.", topic) + Logger().Debugf(ctx, "queue.RegisterConsumer topic:%v duplicate registration.", topic) return } consumers.list[topic] = cs @@ -51,7 +50,7 @@ func consumerListen(ctx context.Context, job consumerStrategy) { ) if err != nil { - g.Log().Fatalf(ctx, "InstanceConsumer %s err:%+v", topic, err) + Logger().Fatalf(ctx, "InstanceConsumer %s err:%+v", topic, err) return } @@ -67,6 +66,6 @@ func consumerListen(ctx context.Context, job consumerStrategy) { ConsumerLog(ctx, topic, mqMsg, err) }); listenErr != nil { - g.Log().Fatalf(ctx, "消费队列:%s 监听失败, err:%+v", topic, listenErr) + Logger().Fatalf(ctx, "消费队列:%s 监听失败, err:%+v", topic, listenErr) } } diff --git a/server/internal/library/queue/disk.go b/server/internal/library/queue/disk.go index a84f21a..9371eb3 100644 --- a/server/internal/library/queue/disk.go +++ b/server/internal/library/queue/disk.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "hotgo/internal/library/queue/disk" "sync" @@ -45,7 +44,7 @@ func (q *DiskConsumerMq) ListenReceiveMsgDo(topic string, receiveDo func(mqMsg M if index, offset, data, err := queue.Read(); err == nil { var mqMsg MqMsg if err = json.Unmarshal(data, &mqMsg); err != nil { - g.Log().Warningf(ctx, "disk.ListenReceiveMsgDo Unmarshal err:%+v, topic:%v, data:%+v .", err, topic, string(data)) + Logger().Warningf(ctx, "disk.ListenReceiveMsgDo Unmarshal err:%+v, topic:%v, data:%+v .", err, topic, string(data)) continue } if mqMsg.MsgId != "" { @@ -130,14 +129,14 @@ func NewDiskQueue(topic string, config *disk.Config) *disk.Queue { if !gfile.Exists(conf.Path) { if err := gfile.Mkdir(conf.Path); err != nil { - g.Log().Errorf(ctx, "NewDiskQueue Failed to create the cache directory. Procedure, err:%+v", err) + Logger().Errorf(ctx, "NewDiskQueue Failed to create the cache directory. Procedure, err:%+v", err) return nil } } queue, err := disk.New(conf) if err != nil { - g.Log().Errorf(ctx, "NewDiskQueue err:%v", err) + Logger().Errorf(ctx, "NewDiskQueue err:%v", err) return nil } return queue diff --git a/server/internal/library/queue/kafkamq.go b/server/internal/library/queue/kafkamq.go index f987265..7af4e88 100644 --- a/server/internal/library/queue/kafkamq.go +++ b/server/internal/library/queue/kafkamq.go @@ -71,7 +71,6 @@ func (r *KafkaMq) SendByteMsg(topic string, body []byte) (mqMsg MqMsg, err error case <-sendCtx.Done(): return mqMsg, gerror.New("send mqMst timeout") } - return mqMsg, nil } @@ -95,11 +94,11 @@ func (r *KafkaMq) ListenReceiveMsgDo(topic string, receiveDo func(mqMsg MqMsg)) go func(consumerCtx context.Context) { for { if err = r.consumerIns.Consume(consumerCtx, []string{topic}, &consumer); err != nil { - g.Log().Fatalf(ctx, "kafka Error from consumer, err%+v", err) + Logger().Fatalf(ctx, "kafka Error from consumer, err%+v", err) } if consumerCtx.Err() != nil { - g.Log().Debugf(ctx, fmt.Sprintf("kafka consoumer stop : %v", consumerCtx.Err())) + Logger().Debugf(ctx, fmt.Sprintf("kafka consoumer stop : %v", consumerCtx.Err())) return } consumer.ready = make(chan bool) @@ -108,13 +107,13 @@ func (r *KafkaMq) ListenReceiveMsgDo(topic string, receiveDo func(mqMsg MqMsg)) // await till the consumer has been set up <-consumer.ready - g.Log().Debug(ctx, "kafka consumer up and running!...") + Logger().Debug(ctx, "kafka consumer up and running!...") gproc.AddSigHandlerShutdown(func(sig os.Signal) { - g.Log().Debug(ctx, "kafka consumer close...") + Logger().Debug(ctx, "kafka consumer close...") cancel() if err = r.consumerIns.Close(); err != nil { - g.Log().Fatalf(ctx, "kafka Error closing client, err:%+v", err) + Logger().Fatalf(ctx, "kafka Error closing client, err:%+v", err) } }) return @@ -256,6 +255,5 @@ func (consumer *Consumer) ConsumeClaim(session sarama.ConsumerGroupSession, clai }) session.MarkMessage(message, "") } - return nil } diff --git a/server/internal/library/queue/logger.go b/server/internal/library/queue/logger.go index 0ff8c15..096b105 100644 --- a/server/internal/library/queue/logger.go +++ b/server/internal/library/queue/logger.go @@ -8,6 +8,7 @@ package queue import ( "context" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/glog" ) const ( @@ -15,16 +16,20 @@ const ( ProducerLogErrFormat = "生产 [%s] 失败, body:%+v, err:%+v" ) +func Logger() *glog.Logger { + return g.Log("queue") +} + // ConsumerLog 消费日志 func ConsumerLog(ctx context.Context, topic string, mqMsg MqMsg, err error) { if err != nil { - g.Log().Errorf(ctx, ConsumerLogErrFormat, topic, string(mqMsg.Body), err) + Logger().Errorf(ctx, ConsumerLogErrFormat, topic, string(mqMsg.Body), err) } } // ProducerLog 生产日志 func ProducerLog(ctx context.Context, topic string, mqMsg MqMsg, err error) { if err != nil { - g.Log().Errorf(ctx, ProducerLogErrFormat, topic, string(mqMsg.Body), err) + Logger().Errorf(ctx, ProducerLogErrFormat, topic, string(mqMsg.Body), err) } } diff --git a/server/internal/library/queue/queue.go b/server/internal/library/queue/queue.go index 7a4483a..c1967f8 100644 --- a/server/internal/library/queue/queue.go +++ b/server/internal/library/queue/queue.go @@ -79,7 +79,7 @@ func init() { mqProducerInstanceMap = make(map[string]MqProducer) mqConsumerInstanceMap = make(map[string]MqConsumer) if err := g.Cfg().MustGet(ctx, "queue").Scan(&config); err != nil { - g.Log().Warningf(ctx, "queue init err:%+v", err) + Logger().Warningf(ctx, "queue init err:%+v", err) } } @@ -207,7 +207,6 @@ func NewConsumer(groupName string) (mqClient MqConsumer, err error) { mutex.Lock() defer mutex.Unlock() mqConsumerInstanceMap[groupName] = mqClient - return } diff --git a/server/internal/library/queue/redismq.go b/server/internal/library/queue/redismq.go index 704a37e..55aa953 100644 --- a/server/internal/library/queue/redismq.go +++ b/server/internal/library/queue/redismq.go @@ -148,7 +148,7 @@ func (r *RedisMq) ListenReceiveMsgDo(topic string, receiveDo func(mqMsg MqMsg)) } for err = range errCh { if err != nil && err != context.Canceled && err != context.DeadlineExceeded { - g.Log().Infof(ctx, "ListenReceiveMsgDo Delay topic:%v, err:%+v", topic, err) + Logger().Infof(ctx, "ListenReceiveMsgDo Delay topic:%v, err:%+v", topic, err) } } }() @@ -166,7 +166,7 @@ func (r *RedisMq) loopReadQueue(key string) (mqMsgList []MqMsg) { for { data, err := conn.Do(ctx, "RPOP", key) if err != nil { - g.Log().Warningf(ctx, "loopReadQueue redis RPOP err:%+v", err) + Logger().Warningf(ctx, "loopReadQueue redis RPOP err:%+v", err) break } @@ -176,7 +176,7 @@ func (r *RedisMq) loopReadQueue(key string) (mqMsgList []MqMsg) { var mqMsg MqMsg if err = data.Scan(&mqMsg); err != nil { - g.Log().Warningf(ctx, "loopReadQueue Scan err:%+v", err) + Logger().Warningf(ctx, "loopReadQueue Scan err:%+v", err) break } diff --git a/server/internal/library/queue/rocketmq_logger.go b/server/internal/library/queue/rocketmq_logger.go index c85f4bf..3c9a038 100644 --- a/server/internal/library/queue/rocketmq_logger.go +++ b/server/internal/library/queue/rocketmq_logger.go @@ -3,13 +3,8 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package queue -import ( - "github.com/gogf/gf/v2/frame/g" -) - type RocketMqLogger struct { Flag string LevelLog string @@ -22,18 +17,17 @@ func (l *RocketMqLogger) Debug(msg string, fields map[string]interface{}) { if msg == "" && len(fields) == 0 { return } - if l.LevelLog == "debug" || l.LevelLog == "all" { - g.Log().Debug(ctx, msg) + Logger().Debug(ctx, msg) } } func (l *RocketMqLogger) Level(level string) { - g.Log().Info(ctx, level) + Logger().Info(ctx, level) } func (l *RocketMqLogger) OutputPath(path string) (err error) { - g.Log().Info(ctx, path) + Logger().Info(ctx, path) return nil } @@ -46,7 +40,7 @@ func (l *RocketMqLogger) Info(msg string, fields map[string]interface{}) { } if l.LevelLog == "info" || l.LevelLog == "all" { - g.Log().Info(ctx, msg) + Logger().Info(ctx, msg) } } @@ -59,7 +53,7 @@ func (l *RocketMqLogger) Warning(msg string, fields map[string]interface{}) { } if l.LevelLog == "warn" || l.LevelLog == "all" { - g.Log().Warning(ctx, msg) + Logger().Warning(ctx, msg) } } @@ -71,7 +65,7 @@ func (l *RocketMqLogger) Error(msg string, fields map[string]interface{}) { return } if l.LevelLog == "error" || l.LevelLog == "all" { - g.Log().Error(ctx, msg) + Logger().Error(ctx, msg) } } @@ -84,6 +78,6 @@ func (l *RocketMqLogger) Fatal(msg string, fields map[string]interface{}) { } if l.LevelLog == "fatal" || l.LevelLog == "all" { - g.Log().Fatal(ctx, msg) + Logger().Fatal(ctx, msg) } } diff --git a/server/internal/library/response/response.go b/server/internal/library/response/response.go index c6f0802..3651176 100644 --- a/server/internal/library/response/response.go +++ b/server/internal/library/response/response.go @@ -21,11 +21,6 @@ func JsonExit(r *ghttp.Request, code int, message string, data ...interface{}) { } // RJson 标准返回结果数据结构封装 -// @Description: 返回固定数据结构的JSON -// @param r -// @param code 状态码(200:成功,302跳转,和http请求状态码一至) -// @param message 请求结果信息 -// @param data 请求结果,根据不同接口返回结果的数据结构不同 func RJson(r *ghttp.Request, code int, message string, data ...interface{}) { responseData := interface{}(nil) if len(data) > 0 { diff --git a/server/internal/library/sms/sms.go b/server/internal/library/sms/sms.go index cac363a..e6274c8 100644 --- a/server/internal/library/sms/sms.go +++ b/server/internal/library/sms/sms.go @@ -33,6 +33,5 @@ func New(name ...string) Drive { default: panic(fmt.Sprintf("暂不支持短信驱动:%v", instanceName)) } - return drive } diff --git a/server/internal/library/sms/tencent/handle.go b/server/internal/library/sms/tencent/handle.go index 63459b2..a44b5f7 100644 --- a/server/internal/library/sms/tencent/handle.go +++ b/server/internal/library/sms/tencent/handle.go @@ -125,6 +125,5 @@ func (d *tencent) SendCode(ctx context.Context, in sysin.SendCodeInp, config *mo * [UnsupportedOperation.ContainDomesticAndInternationalPhoneNumber](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Aunsupportedoperation.containdomesticandinternationalphonenumber-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F) * 更多错误,可咨询[腾讯云助手](https://tccc.qcloud.com/web/im/index.html#/chat?webAppId=8fa15978f85cb41f7e2ea36920cb3ae1&title=Sms) */ - return } diff --git a/server/internal/library/token/token.go b/server/internal/library/token/token.go index bef294c..7356763 100644 --- a/server/internal/library/token/token.go +++ b/server/internal/library/token/token.go @@ -81,7 +81,6 @@ func Login(ctx context.Context, user *model.Identity) (string, int64, error) { if err = cache.Instance().Set(ctx, bindKey, tokenKey, duration); err != nil { return "", 0, err } - return header, config.Expires, nil } @@ -270,7 +269,6 @@ func parseToken(ctx context.Context, header string) (*Claims, error) { if !ok { return nil, errorLogin } - return claims, nil } @@ -283,7 +281,6 @@ func GetAuthorization(r *ghttp.Request) string { if authorization == "" { return r.Get("authorization").String() } - return gstr.Replace(authorization, "Bearer ", "") } diff --git a/server/internal/library/wechat/wechat.go b/server/internal/library/wechat/wechat.go index 057c1e6..595b8cc 100644 --- a/server/internal/library/wechat/wechat.go +++ b/server/internal/library/wechat/wechat.go @@ -68,7 +68,6 @@ func GetOpenUserAccessToken(ctx context.Context, code string) (accessToken offic err = gerror.Newf("GetOpenUserAccessToken err:%+v", accessToken.ErrMsg) return } - return } @@ -98,7 +97,6 @@ func GetUserAccessToken(ctx context.Context, code string) (accessToken officialO err = gerror.Newf("GetUserAccessToken err:%+v", accessToken.ErrMsg) return } - return } diff --git a/server/internal/logic/hook/last_active.go b/server/internal/logic/hook/last_active.go index 84ea7d0..10b4d8e 100644 --- a/server/internal/logic/hook/last_active.go +++ b/server/internal/logic/hook/last_active.go @@ -55,7 +55,6 @@ func allow(memberId int64) bool { v.lastSeen = gtime.Now() return true } - return false } diff --git a/server/internal/logic/sys/config.go b/server/internal/logic/sys/config.go index 335b6bf..428c9b1 100644 --- a/server/internal/logic/sys/config.go +++ b/server/internal/logic/sys/config.go @@ -172,12 +172,6 @@ func (s *sSysConfig) GetLoadToken(ctx context.Context) (conf *model.TokenConfig, return } -// GetLoadSSL 获取本地日志配置 -func (s *sSysConfig) GetLoadSSL(ctx context.Context) (conf *model.SSLConfig, err error) { - err = g.Cfg().MustGet(ctx, "hotgo.ssl").Scan(&conf) - return -} - // GetLoadLog 获取本地日志配置 func (s *sSysConfig) GetLoadLog(ctx context.Context) (conf *model.LogConfig, err error) { err = g.Cfg().MustGet(ctx, "hotgo.log").Scan(&conf) diff --git a/server/internal/logic/sys/cron.go b/server/internal/logic/sys/cron.go index a1b8fee..d404629 100644 --- a/server/internal/logic/sys/cron.go +++ b/server/internal/logic/sys/cron.go @@ -12,8 +12,8 @@ import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "hotgo/internal/consts" - "hotgo/internal/crons" "hotgo/internal/dao" + "hotgo/internal/library/cron" "hotgo/internal/model/entity" "hotgo/internal/model/input/form" "hotgo/internal/model/input/sysin" @@ -39,12 +39,12 @@ func (s *sSysCron) StartCron(ctx context.Context) { Where("status", consts.StatusEnabled). Order("sort asc,id desc"). Scan(&list); err != nil { - g.Log().Fatalf(ctx, "定时任务获取失败, err . %v", err) + cron.Logger().Fatalf(ctx, "定时任务获取失败, err . %v", err) return } - if err := crons.StartALL(list); err != nil { - g.Log().Fatalf(ctx, "定时任务启动失败, err . %v", err) + if err := cron.StartALL(list); err != nil { + cron.Logger().Fatalf(ctx, "定时任务启动失败, err . %v", err) return } } @@ -66,7 +66,7 @@ func (s *sSysCron) Delete(ctx context.Context, in sysin.CronDeleteInp) (err erro if _, err = dao.SysCron.Ctx(ctx).Where("id", in.Id).Delete(); err != nil { return } - return crons.Delete(models) + return cron.Delete(models) }) return } @@ -84,7 +84,7 @@ func (s *sSysCron) Edit(ctx context.Context, in sysin.CronEditInp) (err error) { return } simple.SafeGo(ctx, func(ctx context.Context) { - _ = crons.RefreshStatus(&in.SysCron) + _ = cron.RefreshStatus(&in.SysCron) }) return } @@ -128,7 +128,7 @@ func (s *sSysCron) Status(ctx context.Context, in sysin.CronStatusInp) (err erro models.Status = in.Status simple.SafeGo(ctx, func(ctx context.Context) { - _ = crons.RefreshStatus(models) + _ = cron.RefreshStatus(models) }) return } @@ -201,5 +201,5 @@ func (s *sSysCron) OnlineExec(ctx context.Context, in sysin.OnlineExecInp) (err } newCtx := context.WithValue(gctx.New(), consts.ContextKeyCronArgs, strings.Split(data.Params, consts.CronSplitStr)) - return crons.Once(newCtx, data) + return cron.Once(newCtx, data) } diff --git a/server/internal/logic/sys/dict_data.go b/server/internal/logic/sys/dict_data.go index 756744a..14cc01f 100644 --- a/server/internal/logic/sys/dict_data.go +++ b/server/internal/logic/sys/dict_data.go @@ -31,7 +31,6 @@ func (s *sSysDictData) Delete(ctx context.Context, in sysin.DictDataDeleteInp) e err = gerror.Wrap(err, consts.ErrorORM) return err } - return nil } @@ -110,7 +109,6 @@ func (s *sSysDictData) List(ctx context.Context, in sysin.DictDataListInp) (list for _, v := range list { v.TypeID, _ = dao.SysDictType.GetId(ctx, v.Type) } - return list, totalCount, err } diff --git a/server/internal/model/config.go b/server/internal/model/config.go index 9a7ff09..53f5571 100644 --- a/server/internal/model/config.go +++ b/server/internal/model/config.go @@ -1,5 +1,7 @@ package model +// 后台配置. + // BasicConfig 基础配置 type BasicConfig struct { CaptchaSwitch int `json:"basicCaptchaSwitch"` @@ -170,123 +172,3 @@ type LoginConfig struct { AutoOpenId int `json:"loginAutoOpenId"` ForceInvite int `json:"loginForceInvite"` } - -///////////// 以下是本地配置 - -// SSLConfig https配置 -type SSLConfig struct { - Switch bool `json:"switch"` - CrtPath string `json:"crtPath"` - KeyPath string `json:"keyPath"` -} - -// LogConfig 日志配置 -type LogConfig struct { - Switch bool `json:"switch"` - Queue bool `json:"queue"` - Module []string `json:"module"` - SkipCode []string `json:"skipCode"` -} - -// ServeLogConfig 服务日志配置 -type ServeLogConfig struct { - Switch bool `json:"switch"` - Queue bool `json:"queue"` - LevelFormat []string `json:"levelFormat"` -} - -// GenerateAppCrudTemplate curd模板 -type GenerateAppCrudTemplate struct { - Group string `json:"group"` - IsAddon bool `json:"isAddon"` - MasterPackage string `json:"masterPackage"` - TemplatePath string `json:"templatePath"` - ApiPath string `json:"apiPath"` - InputPath string `json:"inputPath"` - ControllerPath string `json:"controllerPath"` - LogicPath string `json:"logicPath"` - RouterPath string `json:"routerPath"` - SqlPath string `json:"sqlPath"` - WebApiPath string `json:"webApiPath"` - WebViewsPath string `json:"webViewsPath"` -} - -// GenerateAppQueueTemplate 消息队列模板 -type GenerateAppQueueTemplate struct { - Group string `json:"group"` - TemplatePath string `json:"templatePath"` -} - -// GenerateAppTreeTemplate 关系树列表模板 -type GenerateAppTreeTemplate struct { - Group string `json:"group"` - TemplatePath string `json:"templatePath"` -} - -// GenerateConfig 生成代码配置 -type GenerateConfig struct { - AllowedIPs []string `json:"allowedIPs"` - Application struct { - Crud struct { - Templates []*GenerateAppCrudTemplate `json:"templates"` - } `json:"crud"` - Queue struct { - Templates []*GenerateAppQueueTemplate `json:"templates"` - } `json:"queue"` - Tree struct { - Templates []*GenerateAppTreeTemplate `json:"templates"` - } `json:"tree"` - } `json:"application"` - Delimiters []string `json:"delimiters"` - DevPath string `json:"devPath"` - DisableTables []string `json:"disableTables"` - SelectDbs []string `json:"selectDbs"` - Addon *BuildAddonConfig `json:"addon"` -} - -// BuildAddonConfig 构建插件模块配置 -type BuildAddonConfig struct { - SrcPath string `json:"srcPath"` - TemplatePath string `json:"templatePath"` - WebApiPath string `json:"webApiPath"` - WebViewsPath string `json:"webViewsPath"` -} - -// CacheConfig 缓存配置 -type CacheConfig struct { - Adapter string `json:"adapter"` - FileDir string `json:"fileDir"` -} - -type TCPServerConfig struct { - Address string `json:"address"` -} - -type TCPClientConfig struct { - Cron *TCPClientConnConfig `json:"cron"` - Auth *TCPClientConnConfig `json:"auth"` -} - -type TCPClientConnConfig struct { - Group string `json:"group"` - Name string `json:"name"` - Address string `json:"address"` - AppId string `json:"appId"` - SecretKey string `json:"secretKey"` -} - -// TCPConfig tcp服务器配置 -type TCPConfig struct { - Server *TCPServerConfig `json:"server"` - Client *TCPClientConfig `json:"client"` -} - -// TokenConfig 登录令牌配置 -type TokenConfig struct { - SecretKey string `json:"secretKey"` - Expires int64 `json:"expires"` - AutoRefresh bool `json:"autoRefresh"` - RefreshInterval int64 `json:"refreshInterval"` - MaxRefreshTimes int64 `json:"maxRefreshTimes"` - MultiLogin bool `json:"multiLogin"` -} diff --git a/server/internal/model/config_load.go b/server/internal/model/config_load.go new file mode 100644 index 0000000..99bbd43 --- /dev/null +++ b/server/internal/model/config_load.go @@ -0,0 +1,117 @@ +package model + +// 本地配置. + +// LogConfig 日志配置 +type LogConfig struct { + Switch bool `json:"switch"` + Queue bool `json:"queue"` + Module []string `json:"module"` + SkipCode []string `json:"skipCode"` +} + +// ServeLogConfig 服务日志配置 +type ServeLogConfig struct { + Switch bool `json:"switch"` + Queue bool `json:"queue"` + LevelFormat []string `json:"levelFormat"` +} + +// GenerateAppCrudTemplate curd模板 +type GenerateAppCrudTemplate struct { + Group string `json:"group"` + IsAddon bool `json:"isAddon"` + MasterPackage string `json:"masterPackage"` + TemplatePath string `json:"templatePath"` + ApiPath string `json:"apiPath"` + InputPath string `json:"inputPath"` + ControllerPath string `json:"controllerPath"` + LogicPath string `json:"logicPath"` + RouterPath string `json:"routerPath"` + SqlPath string `json:"sqlPath"` + WebApiPath string `json:"webApiPath"` + WebViewsPath string `json:"webViewsPath"` +} + +// GenerateAppQueueTemplate 消息队列模板 +type GenerateAppQueueTemplate struct { + Group string `json:"group"` + TemplatePath string `json:"templatePath"` +} + +// GenerateAppTreeTemplate 关系树列表模板 +type GenerateAppTreeTemplate struct { + Group string `json:"group"` + TemplatePath string `json:"templatePath"` +} + +// GenerateConfig 生成代码配置 +type GenerateConfig struct { + AllowedIPs []string `json:"allowedIPs"` + Application struct { + Crud struct { + Templates []*GenerateAppCrudTemplate `json:"templates"` + } `json:"crud"` + Queue struct { + Templates []*GenerateAppQueueTemplate `json:"templates"` + } `json:"queue"` + Tree struct { + Templates []*GenerateAppTreeTemplate `json:"templates"` + } `json:"tree"` + } `json:"application"` + Delimiters []string `json:"delimiters"` + DevPath string `json:"devPath"` + DisableTables []string `json:"disableTables"` + SelectDbs []string `json:"selectDbs"` + Addon *BuildAddonConfig `json:"addon"` +} + +// BuildAddonConfig 构建插件模块配置 +type BuildAddonConfig struct { + SrcPath string `json:"srcPath"` + TemplatePath string `json:"templatePath"` + WebApiPath string `json:"webApiPath"` + WebViewsPath string `json:"webViewsPath"` +} + +// CacheConfig 缓存配置 +type CacheConfig struct { + Adapter string `json:"adapter"` + FileDir string `json:"fileDir"` +} + +// TCPServerConfig tcp服务器配置 +type TCPServerConfig struct { + Address string `json:"address"` +} + +// TCPClientConfig tcp客户端配置 +type TCPClientConfig struct { + Cron *TCPClientConnConfig `json:"cron"` + Auth *TCPClientConnConfig `json:"auth"` +} + +// TCPClientConnConfig tcp客户端认证 +type TCPClientConnConfig struct { + Group string `json:"group"` + Name string `json:"name"` + Address string `json:"address"` + AppId string `json:"appId"` + SecretKey string `json:"secretKey"` +} + +// TCPConfig tcp服务器配置 +type TCPConfig struct { + Server *TCPServerConfig `json:"server"` + Client *TCPClientConfig `json:"client"` +} + +// TokenConfig 登录令牌配置 +type TokenConfig struct { + SecretKey string `json:"secretKey"` + Expires int64 `json:"expires"` + AutoRefresh bool `json:"autoRefresh"` + RefreshInterval int64 `json:"refreshInterval"` + MaxRefreshTimes int64 `json:"maxRefreshTimes"` + MultiLogin bool `json:"multiLogin"` +} diff --git a/server/internal/service/admin.go b/server/internal/service/admin.go index 3a34375..81a67f1 100644 --- a/server/internal/service/admin.go +++ b/server/internal/service/admin.go @@ -19,32 +19,6 @@ import ( ) type ( - IAdminMember interface { - AddBalance(ctx context.Context, in adminin.MemberAddBalanceInp) (err error) - AddIntegral(ctx context.Context, in adminin.MemberAddIntegralInp) (err error) - UpdateCash(ctx context.Context, in adminin.MemberUpdateCashInp) (err error) - UpdateEmail(ctx context.Context, in adminin.MemberUpdateEmailInp) (err error) - UpdateMobile(ctx context.Context, in adminin.MemberUpdateMobileInp) (err error) - UpdateProfile(ctx context.Context, in adminin.MemberUpdateProfileInp) (err error) - UpdatePwd(ctx context.Context, in adminin.MemberUpdatePwdInp) (err error) - ResetPwd(ctx context.Context, in adminin.MemberResetPwdInp) (err error) - VerifyUnique(ctx context.Context, in adminin.VerifyUniqueInp) (err error) - Delete(ctx context.Context, in adminin.MemberDeleteInp) (err error) - Edit(ctx context.Context, in adminin.MemberEditInp) (err error) - View(ctx context.Context, in adminin.MemberViewInp) (res *adminin.MemberViewModel, err error) - List(ctx context.Context, in adminin.MemberListInp) (list []*adminin.MemberListModel, totalCount int, err error) - Status(ctx context.Context, in adminin.MemberStatusInp) (err error) - GenTree(ctx context.Context, pid int64) (level int, newTree string, err error) - LoginMemberInfo(ctx context.Context) (res *adminin.LoginMemberInfoModel, err error) - MemberLoginStat(ctx context.Context, in adminin.MemberLoginStatInp) (res *adminin.MemberLoginStatModel, err error) - GetIdByCode(ctx context.Context, in adminin.GetIdByCodeInp) (res *adminin.GetIdByCodeModel, err error) - Select(ctx context.Context, in adminin.MemberSelectInp) (res []*adminin.MemberSelectModel, err error) - VerifySuperId(ctx context.Context, verifyId int64) bool - FilterAuthModel(ctx context.Context, memberId int64) *gdb.Model - } - IAdminMemberPost interface { - UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error) - } IAdminMenu interface { MaxSort(ctx context.Context, req *menu.MaxSortReq) (res *menu.MaxSortRes, err error) NameUnique(ctx context.Context, req *menu.NameUniqueReq) (res *menu.NameUniqueRes, err error) @@ -56,48 +30,6 @@ type ( GetMenuList(ctx context.Context, memberId int64) (res *role.DynamicRes, err error) LoginPermissions(ctx context.Context, memberId int64) (lists adminin.MemberLoginPermissions, err error) } - IAdminNotice interface { - Model(ctx context.Context, option ...*handler.Option) *gdb.Model - Delete(ctx context.Context, in adminin.NoticeDeleteInp) (err error) - Edit(ctx context.Context, in adminin.NoticeEditInp) (err error) - Status(ctx context.Context, in adminin.NoticeStatusInp) (err error) - MaxSort(ctx context.Context, in adminin.NoticeMaxSortInp) (res *adminin.NoticeMaxSortModel, err error) - View(ctx context.Context, in adminin.NoticeViewInp) (res *adminin.NoticeViewModel, err error) - List(ctx context.Context, in adminin.NoticeListInp) (list []*adminin.NoticeListModel, totalCount int, err error) - PullMessages(ctx context.Context, in adminin.PullMessagesInp) (res *adminin.PullMessagesModel, err error) - UnreadCount(ctx context.Context, in adminin.NoticeUnreadCountInp) (res *adminin.NoticeUnreadCountModel, err error) - UpRead(ctx context.Context, in adminin.NoticeUpReadInp) (err error) - ReadAll(ctx context.Context, in adminin.NoticeReadAllInp) (err error) - MessageList(ctx context.Context, in adminin.NoticeMessageListInp) (list []*adminin.NoticeMessageListModel, totalCount int, err error) - } - IAdminSite interface { - Register(ctx context.Context, in adminin.RegisterInp) (err error) - AccountLogin(ctx context.Context, in adminin.AccountLoginInp) (res *adminin.LoginModel, err error) - MobileLogin(ctx context.Context, in adminin.MobileLoginInp) (res *adminin.LoginModel, err error) - } - IAdminCash interface { - View(ctx context.Context, in adminin.CashViewInp) (res *adminin.CashViewModel, err error) - List(ctx context.Context, in adminin.CashListInp) (list []*adminin.CashListModel, totalCount int, err error) - Apply(ctx context.Context, in adminin.CashApplyInp) (err error) - Payment(ctx context.Context, in adminin.CashPaymentInp) (err error) - } - IAdminCreditsLog interface { - Model(ctx context.Context, option ...*handler.Option) *gdb.Model - SaveBalance(ctx context.Context, in adminin.CreditsLogSaveBalanceInp) (res *adminin.CreditsLogSaveBalanceModel, err error) - SaveIntegral(ctx context.Context, in adminin.CreditsLogSaveIntegralInp) (res *adminin.CreditsLogSaveIntegralModel, err error) - List(ctx context.Context, in adminin.CreditsLogListInp) (list []*adminin.CreditsLogListModel, totalCount int, err error) - Export(ctx context.Context, in adminin.CreditsLogListInp) (err error) - } - IAdminDept interface { - Delete(ctx context.Context, in adminin.DeptDeleteInp) (err error) - Edit(ctx context.Context, in adminin.DeptEditInp) (err error) - Status(ctx context.Context, in adminin.DeptStatusInp) (err error) - MaxSort(ctx context.Context, in adminin.DeptMaxSortInp) (res *adminin.DeptMaxSortModel, err error) - View(ctx context.Context, in adminin.DeptViewInp) (res *adminin.DeptViewModel, err error) - Option(ctx context.Context, in adminin.DeptOptionInp) (res *adminin.DeptOptionModel, totalCount int, err error) - List(ctx context.Context, in adminin.DeptListInp) (res *adminin.DeptListModel, err error) - GetName(ctx context.Context, id int64) (name string, err error) - } IAdminMonitor interface { StartMonitor(ctx context.Context) GetMeta(ctx context.Context) *model.MonitorData @@ -138,56 +70,91 @@ type ( DataScopeSelect() (res form.Selects) DataScopeEdit(ctx context.Context, in *adminin.DataScopeEditInp) (err error) } + IAdminCash interface { + View(ctx context.Context, in adminin.CashViewInp) (res *adminin.CashViewModel, err error) + List(ctx context.Context, in adminin.CashListInp) (list []*adminin.CashListModel, totalCount int, err error) + Apply(ctx context.Context, in adminin.CashApplyInp) (err error) + Payment(ctx context.Context, in adminin.CashPaymentInp) (err error) + } + IAdminDept interface { + Delete(ctx context.Context, in adminin.DeptDeleteInp) (err error) + Edit(ctx context.Context, in adminin.DeptEditInp) (err error) + Status(ctx context.Context, in adminin.DeptStatusInp) (err error) + MaxSort(ctx context.Context, in adminin.DeptMaxSortInp) (res *adminin.DeptMaxSortModel, err error) + View(ctx context.Context, in adminin.DeptViewInp) (res *adminin.DeptViewModel, err error) + Option(ctx context.Context, in adminin.DeptOptionInp) (res *adminin.DeptOptionModel, totalCount int, err error) + List(ctx context.Context, in adminin.DeptListInp) (res *adminin.DeptListModel, err error) + GetName(ctx context.Context, id int64) (name string, err error) + } + IAdminMemberPost interface { + UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error) + } + IAdminSite interface { + Register(ctx context.Context, in adminin.RegisterInp) (err error) + AccountLogin(ctx context.Context, in adminin.AccountLoginInp) (res *adminin.LoginModel, err error) + MobileLogin(ctx context.Context, in adminin.MobileLoginInp) (res *adminin.LoginModel, err error) + } + IAdminCreditsLog interface { + Model(ctx context.Context, option ...*handler.Option) *gdb.Model + SaveBalance(ctx context.Context, in adminin.CreditsLogSaveBalanceInp) (res *adminin.CreditsLogSaveBalanceModel, err error) + SaveIntegral(ctx context.Context, in adminin.CreditsLogSaveIntegralInp) (res *adminin.CreditsLogSaveIntegralModel, err error) + List(ctx context.Context, in adminin.CreditsLogListInp) (list []*adminin.CreditsLogListModel, totalCount int, err error) + Export(ctx context.Context, in adminin.CreditsLogListInp) (err error) + } + IAdminMember interface { + AddBalance(ctx context.Context, in adminin.MemberAddBalanceInp) (err error) + AddIntegral(ctx context.Context, in adminin.MemberAddIntegralInp) (err error) + UpdateCash(ctx context.Context, in adminin.MemberUpdateCashInp) (err error) + UpdateEmail(ctx context.Context, in adminin.MemberUpdateEmailInp) (err error) + UpdateMobile(ctx context.Context, in adminin.MemberUpdateMobileInp) (err error) + UpdateProfile(ctx context.Context, in adminin.MemberUpdateProfileInp) (err error) + UpdatePwd(ctx context.Context, in adminin.MemberUpdatePwdInp) (err error) + ResetPwd(ctx context.Context, in adminin.MemberResetPwdInp) (err error) + VerifyUnique(ctx context.Context, in adminin.VerifyUniqueInp) (err error) + Delete(ctx context.Context, in adminin.MemberDeleteInp) (err error) + Edit(ctx context.Context, in adminin.MemberEditInp) (err error) + View(ctx context.Context, in adminin.MemberViewInp) (res *adminin.MemberViewModel, err error) + List(ctx context.Context, in adminin.MemberListInp) (list []*adminin.MemberListModel, totalCount int, err error) + Status(ctx context.Context, in adminin.MemberStatusInp) (err error) + GenTree(ctx context.Context, pid int64) (level int, newTree string, err error) + LoginMemberInfo(ctx context.Context) (res *adminin.LoginMemberInfoModel, err error) + MemberLoginStat(ctx context.Context, in adminin.MemberLoginStatInp) (res *adminin.MemberLoginStatModel, err error) + GetIdByCode(ctx context.Context, in adminin.GetIdByCodeInp) (res *adminin.GetIdByCodeModel, err error) + Select(ctx context.Context, in adminin.MemberSelectInp) (res []*adminin.MemberSelectModel, err error) + VerifySuperId(ctx context.Context, verifyId int64) bool + FilterAuthModel(ctx context.Context, memberId int64) *gdb.Model + } + IAdminNotice interface { + Model(ctx context.Context, option ...*handler.Option) *gdb.Model + Delete(ctx context.Context, in adminin.NoticeDeleteInp) (err error) + Edit(ctx context.Context, in adminin.NoticeEditInp) (err error) + Status(ctx context.Context, in adminin.NoticeStatusInp) (err error) + MaxSort(ctx context.Context, in adminin.NoticeMaxSortInp) (res *adminin.NoticeMaxSortModel, err error) + View(ctx context.Context, in adminin.NoticeViewInp) (res *adminin.NoticeViewModel, err error) + List(ctx context.Context, in adminin.NoticeListInp) (list []*adminin.NoticeListModel, totalCount int, err error) + PullMessages(ctx context.Context, in adminin.PullMessagesInp) (res *adminin.PullMessagesModel, err error) + UnreadCount(ctx context.Context, in adminin.NoticeUnreadCountInp) (res *adminin.NoticeUnreadCountModel, err error) + UpRead(ctx context.Context, in adminin.NoticeUpReadInp) (err error) + ReadAll(ctx context.Context, in adminin.NoticeReadAllInp) (err error) + MessageList(ctx context.Context, in adminin.NoticeMessageListInp) (list []*adminin.NoticeMessageListModel, totalCount int, err error) + } ) var ( - localAdminSite IAdminSite - localAdminCash IAdminCash - localAdminCreditsLog IAdminCreditsLog localAdminDept IAdminDept + localAdminMemberPost IAdminMemberPost + localAdminMenu IAdminMenu localAdminMonitor IAdminMonitor localAdminOrder IAdminOrder localAdminPost IAdminPost localAdminRole IAdminRole + localAdminCash IAdminCash + localAdminSite IAdminSite localAdminMember IAdminMember - localAdminMemberPost IAdminMemberPost - localAdminMenu IAdminMenu localAdminNotice IAdminNotice + localAdminCreditsLog IAdminCreditsLog ) -func AdminSite() IAdminSite { - if localAdminSite == nil { - panic("implement not found for interface IAdminSite, forgot register?") - } - return localAdminSite -} - -func RegisterAdminSite(i IAdminSite) { - localAdminSite = i -} - -func AdminCash() IAdminCash { - if localAdminCash == nil { - panic("implement not found for interface IAdminCash, forgot register?") - } - return localAdminCash -} - -func RegisterAdminCash(i IAdminCash) { - localAdminCash = i -} - -func AdminCreditsLog() IAdminCreditsLog { - if localAdminCreditsLog == nil { - panic("implement not found for interface IAdminCreditsLog, forgot register?") - } - return localAdminCreditsLog -} - -func RegisterAdminCreditsLog(i IAdminCreditsLog) { - localAdminCreditsLog = i -} - func AdminDept() IAdminDept { if localAdminDept == nil { panic("implement not found for interface IAdminDept, forgot register?") @@ -199,6 +166,28 @@ func RegisterAdminDept(i IAdminDept) { localAdminDept = i } +func AdminMemberPost() IAdminMemberPost { + if localAdminMemberPost == nil { + panic("implement not found for interface IAdminMemberPost, forgot register?") + } + return localAdminMemberPost +} + +func RegisterAdminMemberPost(i IAdminMemberPost) { + localAdminMemberPost = i +} + +func AdminMenu() IAdminMenu { + if localAdminMenu == nil { + panic("implement not found for interface IAdminMenu, forgot register?") + } + return localAdminMenu +} + +func RegisterAdminMenu(i IAdminMenu) { + localAdminMenu = i +} + func AdminMonitor() IAdminMonitor { if localAdminMonitor == nil { panic("implement not found for interface IAdminMonitor, forgot register?") @@ -243,6 +232,28 @@ func RegisterAdminRole(i IAdminRole) { localAdminRole = i } +func AdminCash() IAdminCash { + if localAdminCash == nil { + panic("implement not found for interface IAdminCash, forgot register?") + } + return localAdminCash +} + +func RegisterAdminCash(i IAdminCash) { + localAdminCash = i +} + +func AdminSite() IAdminSite { + if localAdminSite == nil { + panic("implement not found for interface IAdminSite, forgot register?") + } + return localAdminSite +} + +func RegisterAdminSite(i IAdminSite) { + localAdminSite = i +} + func AdminMember() IAdminMember { if localAdminMember == nil { panic("implement not found for interface IAdminMember, forgot register?") @@ -254,28 +265,6 @@ func RegisterAdminMember(i IAdminMember) { localAdminMember = i } -func AdminMemberPost() IAdminMemberPost { - if localAdminMemberPost == nil { - panic("implement not found for interface IAdminMemberPost, forgot register?") - } - return localAdminMemberPost -} - -func RegisterAdminMemberPost(i IAdminMemberPost) { - localAdminMemberPost = i -} - -func AdminMenu() IAdminMenu { - if localAdminMenu == nil { - panic("implement not found for interface IAdminMenu, forgot register?") - } - return localAdminMenu -} - -func RegisterAdminMenu(i IAdminMenu) { - localAdminMenu = i -} - func AdminNotice() IAdminNotice { if localAdminNotice == nil { panic("implement not found for interface IAdminNotice, forgot register?") @@ -286,3 +275,14 @@ func AdminNotice() IAdminNotice { func RegisterAdminNotice(i IAdminNotice) { localAdminNotice = i } + +func AdminCreditsLog() IAdminCreditsLog { + if localAdminCreditsLog == nil { + panic("implement not found for interface IAdminCreditsLog, forgot register?") + } + return localAdminCreditsLog +} + +func RegisterAdminCreditsLog(i IAdminCreditsLog) { + localAdminCreditsLog = i +} diff --git a/server/internal/service/sys.go b/server/internal/service/sys.go index 4f2a820..f6a80bc 100644 --- a/server/internal/service/sys.go +++ b/server/internal/service/sys.go @@ -17,71 +17,29 @@ import ( ) type ( - ISysSmsLog interface { - Delete(ctx context.Context, in sysin.SmsLogDeleteInp) (err error) - Edit(ctx context.Context, in sysin.SmsLogEditInp) (err error) - Status(ctx context.Context, in sysin.SmsLogStatusInp) (err error) - MaxSort(ctx context.Context, in sysin.SmsLogMaxSortInp) (res *sysin.SmsLogMaxSortModel, err error) - View(ctx context.Context, in sysin.SmsLogViewInp) (res *sysin.SmsLogViewModel, err error) - List(ctx context.Context, in sysin.SmsLogListInp) (list []*sysin.SmsLogListModel, totalCount int, err error) - SendCode(ctx context.Context, in sysin.SendCodeInp) (err error) - GetTemplate(ctx context.Context, template string, config *model.SmsConfig) (val string, err error) - AllowSend(ctx context.Context, models *entity.SysSmsLog, config *model.SmsConfig) (err error) - VerifyCode(ctx context.Context, in sysin.VerifyCodeInp) (err error) + ISysCronGroup interface { + Delete(ctx context.Context, in sysin.CronGroupDeleteInp) (err error) + Edit(ctx context.Context, in sysin.CronGroupEditInp) (err error) + Status(ctx context.Context, in sysin.CronGroupStatusInp) (err error) + MaxSort(ctx context.Context, in sysin.CronGroupMaxSortInp) (res *sysin.CronGroupMaxSortModel, err error) + View(ctx context.Context, in sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error) + List(ctx context.Context, in sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error) + Select(ctx context.Context, in sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error) } - ISysServeLog interface { - Model(ctx context.Context) *gdb.Model - List(ctx context.Context, in sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error) - Export(ctx context.Context, in sysin.ServeLogListInp) (err error) - Delete(ctx context.Context, in sysin.ServeLogDeleteInp) (err error) - View(ctx context.Context, in sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error) - RealWrite(ctx context.Context, models entity.SysServeLog) (err error) + ISysLog interface { + Export(ctx context.Context, in sysin.LogListInp) (err error) + RealWrite(ctx context.Context, log entity.SysLog) (err error) + AutoLog(ctx context.Context) error + AnalysisLog(ctx context.Context) entity.SysLog + View(ctx context.Context, in sysin.LogViewInp) (res *sysin.LogViewModel, err error) + Delete(ctx context.Context, in sysin.LogDeleteInp) (err error) + List(ctx context.Context, in sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error) } - ISysAddons interface { - List(ctx context.Context, in sysin.AddonsListInp) (list []*sysin.AddonsListModel, totalCount int, err error) - Selects(ctx context.Context, in sysin.AddonsSelectsInp) (res *sysin.AddonsSelectsModel, err error) - Build(ctx context.Context, in sysin.AddonsBuildInp) (err error) - Install(ctx context.Context, in sysin.AddonsInstallInp) (err error) - Upgrade(ctx context.Context, in sysin.AddonsUpgradeInp) (err error) - UnInstall(ctx context.Context, in sysin.AddonsUnInstallInp) (err error) - } - ISysCron interface { - StartCron(ctx context.Context) - Delete(ctx context.Context, in sysin.CronDeleteInp) (err error) - Edit(ctx context.Context, in sysin.CronEditInp) (err error) - Status(ctx context.Context, in sysin.CronStatusInp) (err error) - MaxSort(ctx context.Context, in sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error) - View(ctx context.Context, in sysin.CronViewInp) (res *sysin.CronViewModel, err error) - List(ctx context.Context, in sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error) - OnlineExec(ctx context.Context, in sysin.OnlineExecInp) (err error) - } - ISysCurdDemo interface { - Model(ctx context.Context, option ...*handler.Option) *gdb.Model - List(ctx context.Context, in sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error) - Export(ctx context.Context, in sysin.CurdDemoListInp) (err error) - Edit(ctx context.Context, in sysin.CurdDemoEditInp) (err error) - Delete(ctx context.Context, in sysin.CurdDemoDeleteInp) (err error) - MaxSort(ctx context.Context, in sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error) - View(ctx context.Context, in sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error) - Status(ctx context.Context, in sysin.CurdDemoStatusInp) (err error) - Switch(ctx context.Context, in sysin.CurdDemoSwitchInp) (err error) - } - ISysDictType interface { - Tree(ctx context.Context) (list []*sysin.DictTypeTree, err error) - Delete(ctx context.Context, in sysin.DictTypeDeleteInp) (err error) - Edit(ctx context.Context, in sysin.DictTypeEditInp) (err error) - TreeSelect(ctx context.Context, in sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error) - } - ISysEmsLog interface { - Delete(ctx context.Context, in sysin.EmsLogDeleteInp) (err error) - Edit(ctx context.Context, in sysin.EmsLogEditInp) (err error) - Status(ctx context.Context, in sysin.EmsLogStatusInp) (err error) - View(ctx context.Context, in sysin.EmsLogViewInp) (res *sysin.EmsLogViewModel, err error) - List(ctx context.Context, in sysin.EmsLogListInp) (list []*sysin.EmsLogListModel, totalCount int, err error) - Send(ctx context.Context, in sysin.SendEmsInp) (err error) - GetTemplate(ctx context.Context, template string, config *model.EmailConfig) (val string, err error) - AllowSend(ctx context.Context, models *entity.SysEmsLog, config *model.EmailConfig) (err error) - VerifyCode(ctx context.Context, in sysin.VerifyEmsCodeInp) (err error) + ISysDictData interface { + Delete(ctx context.Context, in sysin.DictDataDeleteInp) error + Edit(ctx context.Context, in sysin.DictDataEditInp) (err error) + List(ctx context.Context, in sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error) + Select(ctx context.Context, in sysin.DataSelectInp) (list sysin.DataSelectModel, err error) } ISysGenCodes interface { Delete(ctx context.Context, in sysin.GenCodesDeleteInp) (err error) @@ -97,12 +55,70 @@ type ( Preview(ctx context.Context, in sysin.GenCodesPreviewInp) (res *sysin.GenCodesPreviewModel, err error) Build(ctx context.Context, in sysin.GenCodesBuildInp) (err error) } + ISysLoginLog interface { + Model(ctx context.Context) *gdb.Model + List(ctx context.Context, in sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error) + Export(ctx context.Context, in sysin.LoginLogListInp) (err error) + Delete(ctx context.Context, in sysin.LoginLogDeleteInp) (err error) + View(ctx context.Context, in sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error) + Push(ctx context.Context, in sysin.LoginLogPushInp) + RealWrite(ctx context.Context, models entity.SysLoginLog) (err error) + } + ISysServeLog interface { + Model(ctx context.Context) *gdb.Model + List(ctx context.Context, in sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error) + Export(ctx context.Context, in sysin.ServeLogListInp) (err error) + Delete(ctx context.Context, in sysin.ServeLogDeleteInp) (err error) + View(ctx context.Context, in sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error) + RealWrite(ctx context.Context, models entity.SysServeLog) (err error) + } + ISysAddonsConfig interface { + GetConfigByGroup(ctx context.Context, in sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error) + ConversionType(ctx context.Context, models *entity.SysAddonsConfig) (value interface{}, err error) + UpdateConfigByGroup(ctx context.Context, in sysin.UpdateAddonsConfigInp) (err error) + } ISysAttachment interface { Model(ctx context.Context, option ...*handler.Option) *gdb.Model Delete(ctx context.Context, in sysin.AttachmentDeleteInp) (err error) View(ctx context.Context, in sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error) List(ctx context.Context, in sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error) } + ISysCron interface { + StartCron(ctx context.Context) + Delete(ctx context.Context, in sysin.CronDeleteInp) (err error) + Edit(ctx context.Context, in sysin.CronEditInp) (err error) + Status(ctx context.Context, in sysin.CronStatusInp) (err error) + MaxSort(ctx context.Context, in sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error) + View(ctx context.Context, in sysin.CronViewInp) (res *sysin.CronViewModel, err error) + List(ctx context.Context, in sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error) + OnlineExec(ctx context.Context, in sysin.OnlineExecInp) (err error) + } + ISysDictType interface { + Tree(ctx context.Context) (list []*sysin.DictTypeTree, err error) + Delete(ctx context.Context, in sysin.DictTypeDeleteInp) (err error) + Edit(ctx context.Context, in sysin.DictTypeEditInp) (err error) + TreeSelect(ctx context.Context, in sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error) + } + ISysSmsLog interface { + Delete(ctx context.Context, in sysin.SmsLogDeleteInp) (err error) + Edit(ctx context.Context, in sysin.SmsLogEditInp) (err error) + Status(ctx context.Context, in sysin.SmsLogStatusInp) (err error) + MaxSort(ctx context.Context, in sysin.SmsLogMaxSortInp) (res *sysin.SmsLogMaxSortModel, err error) + View(ctx context.Context, in sysin.SmsLogViewInp) (res *sysin.SmsLogViewModel, err error) + List(ctx context.Context, in sysin.SmsLogListInp) (list []*sysin.SmsLogListModel, totalCount int, err error) + SendCode(ctx context.Context, in sysin.SendCodeInp) (err error) + GetTemplate(ctx context.Context, template string, config *model.SmsConfig) (val string, err error) + AllowSend(ctx context.Context, models *entity.SysSmsLog, config *model.SmsConfig) (err error) + VerifyCode(ctx context.Context, in sysin.VerifyCodeInp) (err error) + } + ISysAddons interface { + List(ctx context.Context, in sysin.AddonsListInp) (list []*sysin.AddonsListModel, totalCount int, err error) + Selects(ctx context.Context, in sysin.AddonsSelectsInp) (res *sysin.AddonsSelectsModel, err error) + Build(ctx context.Context, in sysin.AddonsBuildInp) (err error) + Install(ctx context.Context, in sysin.AddonsInstallInp) (err error) + Upgrade(ctx context.Context, in sysin.AddonsUpgradeInp) (err error) + UnInstall(ctx context.Context, in sysin.AddonsUnInstallInp) (err error) + } ISysBlacklist interface { Delete(ctx context.Context, in sysin.BlacklistDeleteInp) (err error) Edit(ctx context.Context, in sysin.BlacklistEditInp) (err error) @@ -127,30 +143,33 @@ type ( GetLoadCache(ctx context.Context) (conf *model.CacheConfig, err error) GetLoadGenerate(ctx context.Context) (conf *model.GenerateConfig, err error) GetLoadToken(ctx context.Context) (conf *model.TokenConfig, err error) - GetLoadSSL(ctx context.Context) (conf *model.SSLConfig, err error) GetLoadLog(ctx context.Context) (conf *model.LogConfig, err error) GetLoadServeLog(ctx context.Context) (conf *model.ServeLogConfig, err error) GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp) (res *sysin.GetConfigModel, err error) ConversionType(ctx context.Context, models *entity.SysConfig) (value interface{}, err error) UpdateConfigByGroup(ctx context.Context, in sysin.UpdateConfigInp) (err error) } - ISysLog interface { - Export(ctx context.Context, in sysin.LogListInp) (err error) - RealWrite(ctx context.Context, log entity.SysLog) (err error) - AutoLog(ctx context.Context) error - AnalysisLog(ctx context.Context) entity.SysLog - View(ctx context.Context, in sysin.LogViewInp) (res *sysin.LogViewModel, err error) - Delete(ctx context.Context, in sysin.LogDeleteInp) (err error) - List(ctx context.Context, in sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error) + ISysCurdDemo interface { + Model(ctx context.Context, option ...*handler.Option) *gdb.Model + List(ctx context.Context, in sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error) + Export(ctx context.Context, in sysin.CurdDemoListInp) (err error) + Edit(ctx context.Context, in sysin.CurdDemoEditInp) (err error) + Delete(ctx context.Context, in sysin.CurdDemoDeleteInp) (err error) + MaxSort(ctx context.Context, in sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error) + View(ctx context.Context, in sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error) + Status(ctx context.Context, in sysin.CurdDemoStatusInp) (err error) + Switch(ctx context.Context, in sysin.CurdDemoSwitchInp) (err error) } - ISysLoginLog interface { - Model(ctx context.Context) *gdb.Model - List(ctx context.Context, in sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error) - Export(ctx context.Context, in sysin.LoginLogListInp) (err error) - Delete(ctx context.Context, in sysin.LoginLogDeleteInp) (err error) - View(ctx context.Context, in sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error) - Push(ctx context.Context, in sysin.LoginLogPushInp) - RealWrite(ctx context.Context, models entity.SysLoginLog) (err error) + ISysEmsLog interface { + Delete(ctx context.Context, in sysin.EmsLogDeleteInp) (err error) + Edit(ctx context.Context, in sysin.EmsLogEditInp) (err error) + Status(ctx context.Context, in sysin.EmsLogStatusInp) (err error) + View(ctx context.Context, in sysin.EmsLogViewInp) (res *sysin.EmsLogViewModel, err error) + List(ctx context.Context, in sysin.EmsLogListInp) (list []*sysin.EmsLogListModel, totalCount int, err error) + Send(ctx context.Context, in sysin.SendEmsInp) (err error) + GetTemplate(ctx context.Context, template string, config *model.EmailConfig) (val string, err error) + AllowSend(ctx context.Context, models *entity.SysEmsLog, config *model.EmailConfig) (err error) + VerifyCode(ctx context.Context, in sysin.VerifyEmsCodeInp) (err error) } ISysProvinces interface { Tree(ctx context.Context) (list []g.Map, err error) @@ -164,90 +183,37 @@ type ( UniqueId(ctx context.Context, in sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error) Select(ctx context.Context, in sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error) } - ISysAddonsConfig interface { - GetConfigByGroup(ctx context.Context, in sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error) - ConversionType(ctx context.Context, models *entity.SysAddonsConfig) (value interface{}, err error) - UpdateConfigByGroup(ctx context.Context, in sysin.UpdateAddonsConfigInp) (err error) - } - ISysCronGroup interface { - Delete(ctx context.Context, in sysin.CronGroupDeleteInp) (err error) - Edit(ctx context.Context, in sysin.CronGroupEditInp) (err error) - Status(ctx context.Context, in sysin.CronGroupStatusInp) (err error) - MaxSort(ctx context.Context, in sysin.CronGroupMaxSortInp) (res *sysin.CronGroupMaxSortModel, err error) - View(ctx context.Context, in sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error) - List(ctx context.Context, in sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error) - Select(ctx context.Context, in sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error) - } - ISysDictData interface { - Delete(ctx context.Context, in sysin.DictDataDeleteInp) error - Edit(ctx context.Context, in sysin.DictDataEditInp) (err error) - List(ctx context.Context, in sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error) - Select(ctx context.Context, in sysin.DataSelectInp) (list sysin.DataSelectModel, err error) - } ) var ( - localSysCron ISysCron + localSysConfig ISysConfig localSysCurdDemo ISysCurdDemo - localSysServeLog ISysServeLog + localSysEmsLog ISysEmsLog + localSysProvinces ISysProvinces localSysAddons ISysAddons localSysBlacklist ISysBlacklist - localSysConfig ISysConfig - localSysDictType ISysDictType - localSysEmsLog ISysEmsLog - localSysGenCodes ISysGenCodes - localSysAttachment ISysAttachment localSysCronGroup ISysCronGroup - localSysDictData ISysDictData localSysLog ISysLog localSysLoginLog ISysLoginLog - localSysProvinces ISysProvinces - localSysAddonsConfig ISysAddonsConfig + localSysServeLog ISysServeLog + localSysDictData ISysDictData + localSysGenCodes ISysGenCodes + localSysCron ISysCron + localSysDictType ISysDictType localSysSmsLog ISysSmsLog + localSysAddonsConfig ISysAddonsConfig + localSysAttachment ISysAttachment ) -func SysConfig() ISysConfig { - if localSysConfig == nil { - panic("implement not found for interface ISysConfig, forgot register?") +func SysAddonsConfig() ISysAddonsConfig { + if localSysAddonsConfig == nil { + panic("implement not found for interface ISysAddonsConfig, forgot register?") } - return localSysConfig + return localSysAddonsConfig } -func RegisterSysConfig(i ISysConfig) { - localSysConfig = i -} - -func SysDictType() ISysDictType { - if localSysDictType == nil { - panic("implement not found for interface ISysDictType, forgot register?") - } - return localSysDictType -} - -func RegisterSysDictType(i ISysDictType) { - localSysDictType = i -} - -func SysEmsLog() ISysEmsLog { - if localSysEmsLog == nil { - panic("implement not found for interface ISysEmsLog, forgot register?") - } - return localSysEmsLog -} - -func RegisterSysEmsLog(i ISysEmsLog) { - localSysEmsLog = i -} - -func SysGenCodes() ISysGenCodes { - if localSysGenCodes == nil { - panic("implement not found for interface ISysGenCodes, forgot register?") - } - return localSysGenCodes -} - -func RegisterSysGenCodes(i ISysGenCodes) { - localSysGenCodes = i +func RegisterSysAddonsConfig(i ISysAddonsConfig) { + localSysAddonsConfig = i } func SysAttachment() ISysAttachment { @@ -261,81 +227,26 @@ func RegisterSysAttachment(i ISysAttachment) { localSysAttachment = i } -func SysBlacklist() ISysBlacklist { - if localSysBlacklist == nil { - panic("implement not found for interface ISysBlacklist, forgot register?") +func SysCron() ISysCron { + if localSysCron == nil { + panic("implement not found for interface ISysCron, forgot register?") } - return localSysBlacklist + return localSysCron } -func RegisterSysBlacklist(i ISysBlacklist) { - localSysBlacklist = i +func RegisterSysCron(i ISysCron) { + localSysCron = i } -func SysDictData() ISysDictData { - if localSysDictData == nil { - panic("implement not found for interface ISysDictData, forgot register?") +func SysDictType() ISysDictType { + if localSysDictType == nil { + panic("implement not found for interface ISysDictType, forgot register?") } - return localSysDictData + return localSysDictType } -func RegisterSysDictData(i ISysDictData) { - localSysDictData = i -} - -func SysLog() ISysLog { - if localSysLog == nil { - panic("implement not found for interface ISysLog, forgot register?") - } - return localSysLog -} - -func RegisterSysLog(i ISysLog) { - localSysLog = i -} - -func SysLoginLog() ISysLoginLog { - if localSysLoginLog == nil { - panic("implement not found for interface ISysLoginLog, forgot register?") - } - return localSysLoginLog -} - -func RegisterSysLoginLog(i ISysLoginLog) { - localSysLoginLog = i -} - -func SysProvinces() ISysProvinces { - if localSysProvinces == nil { - panic("implement not found for interface ISysProvinces, forgot register?") - } - return localSysProvinces -} - -func RegisterSysProvinces(i ISysProvinces) { - localSysProvinces = i -} - -func SysAddonsConfig() ISysAddonsConfig { - if localSysAddonsConfig == nil { - panic("implement not found for interface ISysAddonsConfig, forgot register?") - } - return localSysAddonsConfig -} - -func RegisterSysAddonsConfig(i ISysAddonsConfig) { - localSysAddonsConfig = i -} - -func SysCronGroup() ISysCronGroup { - if localSysCronGroup == nil { - panic("implement not found for interface ISysCronGroup, forgot register?") - } - return localSysCronGroup -} - -func RegisterSysCronGroup(i ISysCronGroup) { - localSysCronGroup = i +func RegisterSysDictType(i ISysDictType) { + localSysDictType = i } func SysSmsLog() ISysSmsLog { @@ -349,6 +260,39 @@ func RegisterSysSmsLog(i ISysSmsLog) { localSysSmsLog = i } +func SysAddons() ISysAddons { + if localSysAddons == nil { + panic("implement not found for interface ISysAddons, forgot register?") + } + return localSysAddons +} + +func RegisterSysAddons(i ISysAddons) { + localSysAddons = i +} + +func SysBlacklist() ISysBlacklist { + if localSysBlacklist == nil { + panic("implement not found for interface ISysBlacklist, forgot register?") + } + return localSysBlacklist +} + +func RegisterSysBlacklist(i ISysBlacklist) { + localSysBlacklist = i +} + +func SysConfig() ISysConfig { + if localSysConfig == nil { + panic("implement not found for interface ISysConfig, forgot register?") + } + return localSysConfig +} + +func RegisterSysConfig(i ISysConfig) { + localSysConfig = i +} + func SysCurdDemo() ISysCurdDemo { if localSysCurdDemo == nil { panic("implement not found for interface ISysCurdDemo, forgot register?") @@ -360,6 +304,83 @@ func RegisterSysCurdDemo(i ISysCurdDemo) { localSysCurdDemo = i } +func SysEmsLog() ISysEmsLog { + if localSysEmsLog == nil { + panic("implement not found for interface ISysEmsLog, forgot register?") + } + return localSysEmsLog +} + +func RegisterSysEmsLog(i ISysEmsLog) { + localSysEmsLog = i +} + +func SysProvinces() ISysProvinces { + if localSysProvinces == nil { + panic("implement not found for interface ISysProvinces, forgot register?") + } + return localSysProvinces +} + +func RegisterSysProvinces(i ISysProvinces) { + localSysProvinces = i +} + +func SysCronGroup() ISysCronGroup { + if localSysCronGroup == nil { + panic("implement not found for interface ISysCronGroup, forgot register?") + } + return localSysCronGroup +} + +func RegisterSysCronGroup(i ISysCronGroup) { + localSysCronGroup = i +} + +func SysLog() ISysLog { + if localSysLog == nil { + panic("implement not found for interface ISysLog, forgot register?") + } + return localSysLog +} + +func RegisterSysLog(i ISysLog) { + localSysLog = i +} + +func SysDictData() ISysDictData { + if localSysDictData == nil { + panic("implement not found for interface ISysDictData, forgot register?") + } + return localSysDictData +} + +func RegisterSysDictData(i ISysDictData) { + localSysDictData = i +} + +func SysGenCodes() ISysGenCodes { + if localSysGenCodes == nil { + panic("implement not found for interface ISysGenCodes, forgot register?") + } + return localSysGenCodes +} + +func RegisterSysGenCodes(i ISysGenCodes) { + localSysGenCodes = i +} + +func SysLoginLog() ISysLoginLog { + if localSysLoginLog == nil { + panic("implement not found for interface ISysLoginLog, forgot register?") + } + return localSysLoginLog +} + +func RegisterSysLoginLog(i ISysLoginLog) { + localSysLoginLog = i +} + func SysServeLog() ISysServeLog { if localSysServeLog == nil { panic("implement not found for interface ISysServeLog, forgot register?") @@ -370,25 +391,3 @@ func SysServeLog() ISysServeLog { func RegisterSysServeLog(i ISysServeLog) { localSysServeLog = i } - -func SysAddons() ISysAddons { - if localSysAddons == nil { - panic("implement not found for interface ISysAddons, forgot register?") - } - return localSysAddons -} - -func RegisterSysAddons(i ISysAddons) { - localSysAddons = i -} - -func SysCron() ISysCron { - if localSysCron == nil { - panic("implement not found for interface ISysCron, forgot register?") - } - return localSysCron -} - -func RegisterSysCron(i ISysCron) { - localSysCron = i -} diff --git a/server/internal/service/tcpclient.go b/server/internal/service/tcpclient.go index fd094fa..f9bb607 100644 --- a/server/internal/service/tcpclient.go +++ b/server/internal/service/tcpclient.go @@ -28,8 +28,8 @@ type ( ) var ( - localCronClient ICronClient localAuthClient IAuthClient + localCronClient ICronClient ) func AuthClient() IAuthClient { diff --git a/server/manifest/config/config.example.yaml b/server/manifest/config/config.example.yaml index 55abb85..5ed0a10 100644 --- a/server/manifest/config/config.example.yaml +++ b/server/manifest/config/config.example.yaml @@ -6,11 +6,6 @@ hotgo: ipMethod: "whois" # 是否为演示系统 false|true isDemo: false - # https - ssl: - switch: false # 是否开启https访问,需要配置sslCrtPath、sslKeyPath证书夹 - crtPath: "storage/cert/ssl/server.crt" # 证书路径 - keyPath: "storage/cert/ssl/server.key" # 密钥路径 # 全局请求日志 log: switch: true # 日志开关,默认为true @@ -44,11 +39,19 @@ server: errorLogPattern: "error/{Y-m-d}.log" # 异常错误日志文件格式。默认为"error-{Ymd}.log" accessLogEnabled: true # 是否记录访问日志。默认为false accessLogPattern: "access/{Y-m-d}.log" # 访问日志文件格式。默认为"access-{Ymd}.log" + maxHeaderBytes: "100KB" # 请求头大小限制,请求头包括客户端提交的Cookie数据,默认设置为100KB + clientMaxBodySize: "200MB" # 客户端提交的Body大小限制,同时也影响文件上传大小,默认设置为200MB serverAgent: "HG HTTP Server" - # PProf配置 pprofEnabled: true # 是否开启PProf性能调试特性。默认为false pprofPattern: "/pprof" # 开启PProf时有效,表示PProf特性的页面访问路径,对当前Server绑定的所有域名有效。 + # 服务日志配置 + logger: + level: "all" + flags: 42 + rotateExpire: "7d" # 日志保留天数 + rotateBackupLimit: 2 # 最大备份数量 + rotateBackupCompress: 2 # 日志文件压缩级别,0-9,9最高 tcp: @@ -73,11 +76,10 @@ tcp: secretKey: "123456" # 密钥 -# Global logging. -logger: +# 统一默认日志配置 +defaultLogger: &defaultLogger level: "all" flags: 42 - path: "logs/logger" # 日志文件路径。默认为空,表示关闭,仅输出到终端 file: "{Y-m-d}.log" # 日志文件格式。默认为"{Y-m-d}.log" stdoutColorDisabled: false # 关闭终端的颜色打印。默认开启 writerColorEnable: false # 日志文件是否带上颜色。默认false,表示不带颜色 @@ -86,6 +88,29 @@ logger: rotateBackupCompress: 2 # 日志文件压缩级别,0-9,9最高 +# 日志配置 +logger: + # 全局日志:g.Log() + path: "logs/logger" # 日志文件路径。默认为空,表示关闭,仅输出到终端 + <<: *defaultLogger + # 定时任务:g.Log("cron") + cron: + path: "logs/cron" # 日志文件路径。默认为空,表示关闭,仅输出到终端 + <<: *defaultLogger + # 消息队列:g.Log("cron") + queue: + path: "logs/queue" # 日志文件路径。默认为空,表示关闭,仅输出到终端 + <<: *defaultLogger + # tcp服务器:g.Log("tcpServer") + tcpServer: + path: "logs/tcpServer" # 日志文件路径。默认为空,表示关闭,仅输出到终端 + <<: *defaultLogger + # tcp客户端:g.Log("tcpClient") + tcpClient: + path: "logs/tcpClient" # 日志文件路径。默认为空,表示关闭,仅输出到终端 + <<: *defaultLogger + + # 模板配置 viewer: paths: "resource/template" @@ -130,8 +155,8 @@ router: prefix: "/api" # 不需要验证登录的路由地址 exceptPath: [] - # ws - ws: + # websocket + websocket: # 前缀 prefix: "/socket" # 不需要验证登录的路由地址 diff --git a/server/resource/generate/default/addon/api/admin/config/config.go.template b/server/resource/generate/default/addon/api/admin/config/config.go.template index e8c7b60..5dbd15b 100644 --- a/server/resource/generate/default/addon/api/admin/config/config.go.template +++ b/server/resource/generate/default/addon/api/admin/config/config.go.template @@ -15,6 +15,7 @@ type GetReq struct { g.Meta `path:"/config/get" method:"get" tags:"@{.label}" summary:"获取指定分组的配置"` sysin.GetConfigInp } + type GetRes struct { *sysin.GetConfigModel } @@ -24,5 +25,6 @@ type UpdateReq struct { g.Meta `path:"/config/update" method:"post" tags:"@{.label}" summary:"获取指定分组的配置"` sysin.UpdateConfigInp } + type UpdateRes struct { } diff --git a/server/resource/generate/default/curd/api.go.template b/server/resource/generate/default/curd/api.go.template index 66d705d..0074d0e 100644 --- a/server/resource/generate/default/curd/api.go.template +++ b/server/resource/generate/default/curd/api.go.template @@ -49,6 +49,7 @@ type EditReq struct { g.Meta `path:"/@{.varName | LcFirst}/edit" method:"post" tags:"@{.tableComment}" summary:"修改/新增@{.tableComment}"` @{.templateGroup}in.@{.varName}EditInp } + type EditRes struct{} @{end} @{ if eq .options.Step.HasDel true }