mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-02-02 18:28:41 +08:00
代码规范过滤,移除冗余代码,替换掉不推荐的包
This commit is contained in:
parent
c8a808fcfd
commit
b2ef3487d3
@ -24,13 +24,11 @@ var (
|
||||
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
select {
|
||||
case <-serverCloseSignal:
|
||||
service.AuthClient().Stop(ctx)
|
||||
g.Log().Debug(ctx, "auth successfully closed ..")
|
||||
serverWg.Done()
|
||||
}
|
||||
|
||||
<-serverCloseSignal
|
||||
service.AuthClient().Stop(ctx)
|
||||
g.Log().Debug(ctx, "auth successfully closed ..")
|
||||
serverWg.Done()
|
||||
return
|
||||
},
|
||||
}
|
||||
|
@ -67,11 +67,8 @@ var (
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
|
||||
select {
|
||||
case <-serverCloseSignal:
|
||||
serverWg.Wait()
|
||||
}
|
||||
|
||||
<-serverCloseSignal
|
||||
serverWg.Wait()
|
||||
g.Log().Debug(ctx, "all service successfully closed ..")
|
||||
return
|
||||
},
|
||||
|
@ -29,14 +29,12 @@ var (
|
||||
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
select {
|
||||
case <-serverCloseSignal:
|
||||
service.CronClient().Stop(ctx)
|
||||
crons.StopALL()
|
||||
g.Log().Debug(ctx, "cron successfully closed ..")
|
||||
serverWg.Done()
|
||||
}
|
||||
|
||||
<-serverCloseSignal
|
||||
service.CronClient().Stop(ctx)
|
||||
crons.StopALL()
|
||||
g.Log().Debug(ctx, "cron successfully closed ..")
|
||||
serverWg.Done()
|
||||
return
|
||||
},
|
||||
}
|
||||
|
@ -79,20 +79,18 @@ var (
|
||||
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
|
||||
go func() {
|
||||
select {
|
||||
case <-serverCloseSignal:
|
||||
websocket.Stop()
|
||||
service.TCPServer().Stop(ctx)
|
||||
s.Shutdown() // 主服务建议放在最后一个关闭
|
||||
g.Log().Debug(ctx, "http successfully closed ..")
|
||||
serverWg.Done()
|
||||
}
|
||||
<-serverCloseSignal
|
||||
websocket.Stop()
|
||||
service.TCPServer().Stop(ctx)
|
||||
_ = s.Shutdown() // 主服务建议放在最后一个关闭
|
||||
g.Log().Debug(ctx, "http successfully closed ..")
|
||||
serverWg.Done()
|
||||
}()
|
||||
|
||||
// Just run the server.
|
||||
s.Run()
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
|
@ -30,12 +30,9 @@ var (
|
||||
// 信号监听
|
||||
signalListen(ctx, signalHandlerForOverall)
|
||||
|
||||
select {
|
||||
case <-serverCloseSignal:
|
||||
g.Log().Debug(ctx, "queue successfully closed ..")
|
||||
serverWg.Done()
|
||||
}
|
||||
|
||||
<-serverCloseSignal
|
||||
g.Log().Debug(ctx, "queue successfully closed ..")
|
||||
serverWg.Done()
|
||||
return
|
||||
},
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ package consts
|
||||
// ContextKey 上下文
|
||||
const (
|
||||
ContextKey = "HotGoContext" // http上下文变量名称
|
||||
ContextKeyCronArgs = "args" // 定时任务参数上下文变量名称
|
||||
ContextKeyCronArgs = "cronArgs" // 定时任务参数上下文变量名称
|
||||
ContextTCPKey = "HotGoTCPContext" // tcp上下文变量名称
|
||||
)
|
||||
|
@ -24,16 +24,16 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
OrderStatusALL int64 = -1 // 全部状态
|
||||
OrderStatusNotPay = 1 // 待付款
|
||||
OrderStatusPay = 2 // 已付款
|
||||
OrderStatusShipments = 3 // 已发货
|
||||
OrderStatusDone = 4 // 已完成
|
||||
OrderStatusClose = 5 // 已关闭
|
||||
OrderStatusReturnRequest = 6 // 申请退款
|
||||
OrderStatusReturning = 7 // 退款中
|
||||
OrderStatusReturned = 8 // 已退款
|
||||
OrderStatusReturnReject = 9 // 拒绝退款
|
||||
OrderStatusALL = -1 // 全部状态
|
||||
OrderStatusNotPay = 1 // 待付款
|
||||
OrderStatusPay = 2 // 已付款
|
||||
OrderStatusShipments = 3 // 已发货
|
||||
OrderStatusDone = 4 // 已完成
|
||||
OrderStatusClose = 5 // 已关闭
|
||||
OrderStatusReturnRequest = 6 // 申请退款
|
||||
OrderStatusReturning = 7 // 退款中
|
||||
OrderStatusReturned = 8 // 已退款
|
||||
OrderStatusReturnReject = 9 // 拒绝退款
|
||||
)
|
||||
|
||||
var OrderStatusSlice = []int64{
|
||||
|
@ -61,7 +61,7 @@ func (c *cMonitor) OnlineList(ctx context.Context, req *monitor.OnlineListReq) (
|
||||
return
|
||||
}
|
||||
|
||||
for conn, _ := range c.wsManager.GetClients() {
|
||||
for conn := range c.wsManager.GetClients() {
|
||||
if conn.SendClose || conn.User == nil {
|
||||
continue
|
||||
}
|
||||
|
@ -143,11 +143,11 @@ func (c *cNotice) Letter(ctx context.Context, req *notice.EditLetterReq) (res *n
|
||||
func (c *cNotice) UpRead(ctx context.Context, req *notice.UpReadReq) (res *notice.UpReadRes, err error) {
|
||||
var in adminin.NoticeUpReadInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
err = service.AdminNotice().UpRead(ctx, in)
|
||||
return res, nil
|
||||
return
|
||||
}
|
||||
|
||||
// PullMessages 拉取未读消息列表
|
||||
|
@ -44,7 +44,7 @@ func (c *cCronGroup) Edit(ctx context.Context, req *cron.GroupEditReq) (res *cro
|
||||
}
|
||||
|
||||
err = service.SysCronGroup().Edit(ctx, in)
|
||||
return res, nil
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
@ -103,7 +103,7 @@ func (c *cCronGroup) Status(ctx context.Context, req *cron.GroupStatusReq) (res
|
||||
}
|
||||
|
||||
err = service.SysCronGroup().Status(ctx, in)
|
||||
return res, nil
|
||||
return
|
||||
}
|
||||
|
||||
// Select 选项
|
||||
|
@ -49,7 +49,6 @@ type MonitorHead struct {
|
||||
// RunInfo 运行信息
|
||||
func (c *cMonitor) RunInfo(client *websocket.Client, req *websocket.WRequest) {
|
||||
var (
|
||||
data = g.Map{}
|
||||
meta = service.AdminMonitor().GetMeta(client.Context())
|
||||
mHost, _ = host.Info()
|
||||
pwd, _ = os.Getwd()
|
||||
@ -58,7 +57,7 @@ func (c *cMonitor) RunInfo(client *websocket.Client, req *websocket.WRequest) {
|
||||
|
||||
runtime.ReadMemStats(&gm)
|
||||
|
||||
data = g.Map{
|
||||
data := g.Map{
|
||||
// 服务器信息
|
||||
"hostname": mHost.Hostname,
|
||||
"os": mHost.OS,
|
||||
@ -107,7 +106,6 @@ func (c *cMonitor) Trends(client *websocket.Client, req *websocket.WRequest) {
|
||||
mDisk, diskErr = disk.Usage("/")
|
||||
mProcess, ProcessErr = process.Pids()
|
||||
mLoadAvg = new(model.LoadAvgStats)
|
||||
data = g.Map{}
|
||||
monitorHeads []MonitorHead
|
||||
nets []NetC
|
||||
meta = service.AdminMonitor().GetMeta(client.Context())
|
||||
@ -193,11 +191,9 @@ func (c *cMonitor) Trends(client *websocket.Client, req *websocket.WRequest) {
|
||||
})
|
||||
}
|
||||
|
||||
data = g.Map{
|
||||
websocket.SendSuccess(client, req.Event, g.Map{
|
||||
"head": monitorHeads,
|
||||
"load": meta.LoadAvg,
|
||||
"net": nets,
|
||||
}
|
||||
|
||||
websocket.SendSuccess(client, req.Event, data)
|
||||
})
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ func Build(ctx context.Context, sk Skeleton, conf *model.BuildAddonConfig) (err
|
||||
return path
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, path := range list {
|
||||
if !gfile.IsReadable(path) {
|
||||
err = fmt.Errorf("file:%v is unreadable, please check permissions", path)
|
||||
|
@ -89,7 +89,7 @@ func GetModule(name string) Module {
|
||||
// GetSkeletons 获取所有模块骨架
|
||||
func GetSkeletons() (list []*Skeleton) {
|
||||
var keys []string
|
||||
for k, _ := range modules {
|
||||
for k := range modules {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
|
1
server/internal/library/cache/cache.go
vendored
1
server/internal/library/cache/cache.go
vendored
@ -66,5 +66,4 @@ func SetAdapter(ctx context.Context) {
|
||||
// 通用缓存
|
||||
cache = gcache.New()
|
||||
cache.SetAdapter(adapter)
|
||||
return
|
||||
}
|
||||
|
1
server/internal/library/cache/file/file.go
vendored
1
server/internal/library/cache/file/file.go
vendored
@ -120,7 +120,6 @@ func (c *AdapterFile) UpdateExpire(ctx context.Context, key interface{}, duratio
|
||||
oldTTL = int64(expire)
|
||||
if oldTTL == -2 {
|
||||
// It does not exist.
|
||||
oldTTL = -1
|
||||
return
|
||||
}
|
||||
oldDuration = time.Duration(oldTTL) * time.Second
|
||||
|
@ -286,7 +286,9 @@ func (a *adapter) loadPolicyRule(rule policyRule, model model.Model) {
|
||||
ruleText += ", " + rule.V5
|
||||
}
|
||||
|
||||
persist.LoadPolicyLine(ruleText, model)
|
||||
if err := persist.LoadPolicyLine(ruleText, model); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// 构建策略规则
|
||||
|
@ -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 views
|
||||
|
||||
import (
|
||||
@ -236,7 +235,6 @@ func setDefaultList(field *sysin.GenCodesColumnListModel) {
|
||||
if df, ok := defaultListSwitch[field.Name]; ok {
|
||||
field.IsList = df
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// setDefaultExport 设置默认导出
|
||||
@ -256,7 +254,6 @@ func setDefaultExport(field *sysin.GenCodesColumnListModel) {
|
||||
if df, ok := defaultExportSwitch[field.Name]; ok {
|
||||
field.IsExport = df
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// setDefaultQuery 设置默认查询
|
||||
|
@ -97,12 +97,14 @@ func (l *gCurd) initInput(ctx context.Context, in *CurdPreviewInput) (err error)
|
||||
in.content.Views = make(map[string]*sysin.GenFile)
|
||||
|
||||
// 加载主表配置
|
||||
err = in.In.MasterColumns.Scan(&in.masterFields)
|
||||
if err != nil {
|
||||
return err
|
||||
if err = in.In.MasterColumns.Scan(&in.masterFields); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if len(in.masterFields) == 0 {
|
||||
in.masterFields, err = DoTableColumns(ctx, sysin.GenCodesColumnListInp{Name: in.In.DbName, Table: in.In.TableName}, in.DaoConfig)
|
||||
if in.masterFields, err = DoTableColumns(ctx, sysin.GenCodesColumnListInp{Name: in.In.DbName, Table: in.In.TableName}, in.DaoConfig); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 主键属性
|
||||
@ -112,9 +114,8 @@ func (l *gCurd) initInput(ctx context.Context, in *CurdPreviewInput) (err error)
|
||||
}
|
||||
|
||||
// 加载选项
|
||||
err = in.In.Options.Scan(&in.options)
|
||||
if err != nil {
|
||||
return err
|
||||
if err = in.In.Options.Scan(&in.options); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
initStep(in)
|
||||
@ -131,8 +132,7 @@ func (l *gCurd) initInput(ctx context.Context, in *CurdPreviewInput) (err error)
|
||||
}
|
||||
in.options.ApiPrefix = apiPrefix
|
||||
|
||||
err = checkCurdPath(in.Config.Application.Crud.Templates[in.In.GenTemplate], in.In.AddonName)
|
||||
if err != nil {
|
||||
if err = checkCurdPath(in.Config.Application.Crud.Templates[in.In.GenTemplate], in.In.AddonName); err != nil {
|
||||
return
|
||||
}
|
||||
in.options.TemplateGroup = in.Config.Application.Crud.Templates[in.In.GenTemplate].MasterPackage
|
||||
@ -338,9 +338,7 @@ func (l *gCurd) DoPreview(ctx context.Context, in *CurdPreviewInput) (res *sysin
|
||||
}
|
||||
|
||||
in.content.Config = in.Config
|
||||
res = new(sysin.GenCodesPreviewModel)
|
||||
res = in.content
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ const (
|
||||
LogicWhereComments = "\n\t// 查询%s\n"
|
||||
LogicWhereNoSupport = "\t// TODO 暂不支持生成[ %s ]查询方式,请自行补充此处代码!"
|
||||
LogicListSimpleSelect = "\tfields, err := hgorm.GenSelect(ctx, sysin.%sListModel{}, dao.%s)\n\tif err != nil {\n\t\treturn\n\t}"
|
||||
LogicListJoinSelect = "\t//关联表select\n\tfields, err := hgorm.GenJoinSelect(ctx, %sin.%sListModel{}, dao.%s, []*hgorm.Join{\n%v\t})"
|
||||
LogicListJoinSelect = "\t//关联表select\n\tfields, err := hgorm.GenJoinSelect(ctx, %sin.%sListModel{}, dao.%s, []*hgorm.Join{\n%v\t})\n\n\tif err != nil {\n\t\treturn\n\t}"
|
||||
LogicListJoinOnRelation = "\t// 关联表%s\n\tmod = mod.%s(hgorm.GenJoinOnRelation(\n\t\tdao.%s.Table(), dao.%s.Columns().%s, // 主表表名,关联字段\n\t\tdao.%s.Table(), \"%s\", dao.%s.Columns().%s, // 关联表表名,别名,关联字段\n\t)...)\n\n"
|
||||
LogicEditUpdate = "\t\t_, err = s.Model(ctx%s).\n\t\t\tFields(%sin.%sUpdateFields{}).\n\t\t\tWherePri(in.%s).Data(in).Update()\n\t\treturn "
|
||||
LogicEditInsert = "\t_, err = s.Model(ctx, &handler.Option{FilterAuth: false}).\n\t\tFields(%sin.%sInsertFields{}).\n\t\tData(in).Insert()"
|
||||
|
@ -31,9 +31,9 @@ func (l *gCurd) webIndexTplData(ctx context.Context, in *CurdPreviewInput) (g.Ma
|
||||
iconsImport = append(iconsImport, " PlusOutlined")
|
||||
}
|
||||
|
||||
// 编辑
|
||||
if in.options.Step.HasEdit {
|
||||
}
|
||||
//// 编辑
|
||||
//if in.options.Step.HasEdit {
|
||||
//}
|
||||
|
||||
// 导出
|
||||
if in.options.Step.HasExport {
|
||||
@ -64,17 +64,17 @@ func (l *gCurd) webIndexTplData(ctx context.Context, in *CurdPreviewInput) (g.Ma
|
||||
// 没有需要查询的字段则隐藏搜索表单
|
||||
isSearchForm := false
|
||||
for _, field := range in.masterFields {
|
||||
if field.IsQuery == true {
|
||||
if field.IsQuery {
|
||||
isSearchForm = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if isSearchForm == false {
|
||||
if !isSearchForm {
|
||||
if len(in.options.Join) > 0 {
|
||||
LoopOut:
|
||||
for _, v := range in.options.Join {
|
||||
for _, column := range v.Columns {
|
||||
if column.IsQuery == true {
|
||||
if column.IsQuery {
|
||||
isSearchForm = true
|
||||
break LoopOut
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -77,7 +77,7 @@ func removeEndWrap(comment string) string {
|
||||
|
||||
// ImportSql 导出sql文件
|
||||
func ImportSql(ctx context.Context, path string) error {
|
||||
rows, err := ioutil.ReadFile(path)
|
||||
rows, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -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 hgorm
|
||||
|
||||
// dao.
|
||||
@ -195,7 +194,7 @@ func IsUnique(ctx context.Context, dao interface{}, where g.Map, message string,
|
||||
|
||||
if count > 0 {
|
||||
if message == "" {
|
||||
for k, _ := range where {
|
||||
for k := range where {
|
||||
message = fmt.Sprintf("in the table:%s, %v not uniqued", d.Table(), where[k])
|
||||
break
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ var CityLabel = gdb.HookHandler{
|
||||
g.Log().Warningf(ctx, "hook.CityLabel parse err:%+v", err)
|
||||
}
|
||||
result[index]["cityLabel"] = gvar.New(cityLabel)
|
||||
return
|
||||
}
|
||||
|
||||
for i, record := range result {
|
||||
|
@ -96,14 +96,12 @@ func NewClient(config *ClientConfig) (client *Client, err error) {
|
||||
|
||||
if config.ConnectInterval <= 0 {
|
||||
client.connectInterval = 5 * time.Second
|
||||
//client.Logger.Debugf(client.Ctx, "invalid connectInterval, reset to %v", client.connectInterval)
|
||||
} else {
|
||||
client.connectInterval = config.ConnectInterval
|
||||
}
|
||||
|
||||
if config.Timeout <= 0 {
|
||||
client.timeout = 10 * time.Second
|
||||
//client.Logger.Debugf(client.Ctx, "invalid timeout, reset to %v", client.timeout)
|
||||
} else {
|
||||
client.timeout = config.Timeout
|
||||
}
|
||||
@ -204,7 +202,7 @@ reconnect:
|
||||
client.Lock()
|
||||
if client.closeFlag {
|
||||
client.Unlock()
|
||||
conn.Close()
|
||||
_ = conn.Close()
|
||||
client.Logger.Debugf(client.Ctx, "client connect but closeFlag is true")
|
||||
return
|
||||
}
|
||||
@ -226,7 +224,7 @@ func (client *Client) read() {
|
||||
client.Close()
|
||||
client.Logger.Debugf(client.Ctx, "client are about to be reconnected..")
|
||||
time.Sleep(client.connectInterval)
|
||||
client.Start()
|
||||
_ = client.Start()
|
||||
}()
|
||||
|
||||
for {
|
||||
@ -383,6 +381,6 @@ func (client *Client) RpcRequest(ctx context.Context, data interface{}) (res int
|
||||
}
|
||||
|
||||
return client.rpc.Request(key, func() {
|
||||
client.Write(data)
|
||||
_ = client.Write(data)
|
||||
})
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func (client *Client) stopCron() {
|
||||
func (client *Client) startCron() {
|
||||
// 心跳超时检查
|
||||
if gcron.Search(client.getCronKey(consts.TCPCronHeartbeatVerify)) == nil {
|
||||
gcron.AddSingleton(client.Ctx, "@every 600s", func(ctx context.Context) {
|
||||
_, _ = gcron.AddSingleton(client.Ctx, "@every 600s", func(ctx context.Context) {
|
||||
if client.heartbeat < gtime.Timestamp()-600 {
|
||||
client.Logger.Debugf(client.Ctx, "client heartbeat timeout, about to reconnect..")
|
||||
client.Destroy()
|
||||
@ -36,7 +36,7 @@ func (client *Client) startCron() {
|
||||
|
||||
// 心跳
|
||||
if gcron.Search(client.getCronKey(consts.TCPCronHeartbeat)) == nil {
|
||||
gcron.AddSingleton(client.Ctx, "@every 120s", func(ctx context.Context) {
|
||||
_, _ = gcron.AddSingleton(client.Ctx, "@every 120s", func(ctx context.Context) {
|
||||
client.serverHeartbeat()
|
||||
}, client.getCronKey(consts.TCPCronHeartbeat))
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ package tcp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/gtcp"
|
||||
"github.com/gogf/gf/v2/net/gtrace"
|
||||
"hotgo/internal/consts"
|
||||
)
|
||||
@ -24,11 +23,6 @@ func initCtx(ctx context.Context, model *Context) (newCtx context.Context, cance
|
||||
return
|
||||
}
|
||||
|
||||
// SetCtx 设置上下文变量
|
||||
func SetCtx(ctx context.Context, model *Context) {
|
||||
context.WithValue(ctx, consts.ContextTCPKey, model)
|
||||
}
|
||||
|
||||
// GetCtx 获得上下文变量,如果没有设置,那么返回nil
|
||||
func GetCtx(ctx context.Context) *Context {
|
||||
value := ctx.Value(consts.ContextTCPKey)
|
||||
@ -40,23 +34,3 @@ func GetCtx(ctx context.Context) *Context {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetCtxConn .
|
||||
func GetCtxConn(ctx context.Context) *gtcp.Conn {
|
||||
c := GetCtx(ctx)
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.Conn
|
||||
}
|
||||
|
||||
// GetCtxAuth 认证元数据
|
||||
func GetCtxAuth(ctx context.Context) *AuthMeta {
|
||||
c := GetCtx(ctx)
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.Auth
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func MsgPkg(data interface{}, auth *AuthMeta, traceID string) string {
|
||||
|
||||
// doHandleRouterMsg 处理路由消息
|
||||
func doHandleRouterMsg(fun RouterHandler, ctx context.Context, cancel context.CancelFunc, args ...interface{}) {
|
||||
GoPool.Add(ctx, func(ctx context.Context) {
|
||||
_ = GoPool.Add(ctx, func(ctx context.Context) {
|
||||
fun(ctx, args...)
|
||||
cancel()
|
||||
})
|
||||
|
@ -23,7 +23,6 @@ type ClientConn struct {
|
||||
Conn *gtcp.Conn
|
||||
Auth *AuthMeta
|
||||
heartbeat int64
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@ -88,11 +87,9 @@ func NewServer(config *ServerConfig) (server *Server, err error) {
|
||||
func (server *Server) accept(conn *gtcp.Conn) {
|
||||
defer func() {
|
||||
server.mutexConns.Lock()
|
||||
conn.Close()
|
||||
_ = conn.Close()
|
||||
// 从登录列表中移除
|
||||
if _, ok := server.clients[conn.RemoteAddr().String()]; ok {
|
||||
delete(server.clients, conn.RemoteAddr().String())
|
||||
}
|
||||
delete(server.clients, conn.RemoteAddr().String())
|
||||
server.mutexConns.Unlock()
|
||||
}()
|
||||
|
||||
@ -282,14 +279,14 @@ func (server *Server) Close() {
|
||||
|
||||
server.mutexConns.Lock()
|
||||
for _, client := range server.clients {
|
||||
client.Conn.Close()
|
||||
_ = client.Conn.Close()
|
||||
}
|
||||
server.clients = nil
|
||||
server.mutexConns.Unlock()
|
||||
server.wgConns.Wait()
|
||||
|
||||
if server.ln != nil {
|
||||
server.ln.Close()
|
||||
_ = server.ln.Close()
|
||||
}
|
||||
server.wgLn.Wait()
|
||||
}
|
||||
@ -345,6 +342,6 @@ func (server *Server) RpcRequest(ctx context.Context, client *ClientConn, data i
|
||||
}
|
||||
|
||||
return server.rpc.Request(key, func() {
|
||||
server.Write(client.Conn, data)
|
||||
_ = server.Write(client.Conn, data)
|
||||
})
|
||||
}
|
||||
|
@ -26,13 +26,13 @@ func (server *Server) stopCron() {
|
||||
func (server *Server) startCron() {
|
||||
// 心跳超时检查
|
||||
if gcron.Search(server.getCronKey(consts.TCPCronHeartbeatVerify)) == nil {
|
||||
gcron.AddSingleton(server.Ctx, "@every 300s", func(ctx context.Context) {
|
||||
_, _ = gcron.AddSingleton(server.Ctx, "@every 300s", func(ctx context.Context) {
|
||||
if server.clients == nil {
|
||||
return
|
||||
}
|
||||
for _, client := range server.clients {
|
||||
if client.heartbeat < gtime.Timestamp()-300 {
|
||||
client.Conn.Close()
|
||||
_ = client.Conn.Close()
|
||||
server.Logger.Debugf(server.Ctx, "client heartbeat timeout, close conn. auth:%+v", client.Auth)
|
||||
}
|
||||
}
|
||||
@ -41,13 +41,13 @@ func (server *Server) startCron() {
|
||||
|
||||
// 认证检查
|
||||
if gcron.Search(server.getCronKey(consts.TCPCronAuthVerify)) == nil {
|
||||
gcron.AddSingleton(server.Ctx, "@every 300s", func(ctx context.Context) {
|
||||
_, _ = gcron.AddSingleton(server.Ctx, "@every 300s", func(ctx context.Context) {
|
||||
if server.clients == nil {
|
||||
return
|
||||
}
|
||||
for _, client := range server.clients {
|
||||
if client.Auth.EndAt.Before(gtime.Now()) {
|
||||
client.Conn.Close()
|
||||
_ = client.Conn.Close()
|
||||
server.Logger.Debugf(server.Ctx, "client auth expired, close conn. auth:%+v", client.Auth)
|
||||
}
|
||||
}
|
||||
|
@ -37,14 +37,14 @@ func (server *Server) onServerLogin(ctx context.Context, args ...interface{}) {
|
||||
if err != nil {
|
||||
res.Code = 1
|
||||
res.Message = err.Error()
|
||||
server.Write(user.Conn, res)
|
||||
_ = server.Write(user.Conn, res)
|
||||
return
|
||||
}
|
||||
|
||||
if models == nil {
|
||||
res.Code = 2
|
||||
res.Message = "授权信息不存在"
|
||||
server.Write(user.Conn, res)
|
||||
_ = server.Write(user.Conn, res)
|
||||
return
|
||||
}
|
||||
|
||||
@ -52,28 +52,28 @@ func (server *Server) onServerLogin(ctx context.Context, args ...interface{}) {
|
||||
if _, err = VerifySign(in, models.Appid, models.SecretKey); err != nil {
|
||||
res.Code = 3
|
||||
res.Message = "签名错误,请联系管理员"
|
||||
server.Write(user.Conn, res)
|
||||
_ = server.Write(user.Conn, res)
|
||||
return
|
||||
}
|
||||
|
||||
if models.Status != consts.StatusEnabled {
|
||||
res.Code = 4
|
||||
res.Message = "授权已禁用,请联系管理员"
|
||||
server.Write(user.Conn, res)
|
||||
_ = server.Write(user.Conn, res)
|
||||
return
|
||||
}
|
||||
|
||||
if models.Group != in.Group {
|
||||
res.Code = 5
|
||||
res.Message = "你登录的授权分组未得到授权,请联系管理员"
|
||||
server.Write(user.Conn, res)
|
||||
_ = server.Write(user.Conn, res)
|
||||
return
|
||||
}
|
||||
|
||||
if models.EndAt.Before(gtime.Now()) {
|
||||
res.Code = 6
|
||||
res.Message = "授权已过期,请联系管理员"
|
||||
server.Write(user.Conn, res)
|
||||
_ = server.Write(user.Conn, res)
|
||||
return
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ func (server *Server) onServerLogin(ctx context.Context, args ...interface{}) {
|
||||
if _, ok2 := allowedIps[ip]; !ok2 {
|
||||
res.Code = 7
|
||||
res.Message = "IP(" + ip + ")未授权,请联系管理员"
|
||||
server.Write(user.Conn, res)
|
||||
_ = server.Write(user.Conn, res)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -92,18 +92,17 @@ func (server *Server) onServerLogin(ctx context.Context, args ...interface{}) {
|
||||
clients := server.getAppIdClients(models.Appid)
|
||||
online := len(clients) + 1
|
||||
if online > models.OnlineLimit {
|
||||
online = 0
|
||||
res2 := new(msgin.ResponseServerLogin)
|
||||
res2.Code = 8
|
||||
res2.Message = "授权登录端超出上限已进行记录。请立即终止操作。如有疑问请联系管理员"
|
||||
for _, client := range clients {
|
||||
server.Write(client.Conn, res2)
|
||||
client.Conn.Close()
|
||||
_ = server.Write(client.Conn, res2)
|
||||
_ = client.Conn.Close()
|
||||
}
|
||||
|
||||
// 当前连接也踢掉
|
||||
server.Write(user.Conn, res2)
|
||||
user.Conn.Close()
|
||||
_ = server.Write(user.Conn, res2)
|
||||
_ = user.Conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
@ -135,7 +134,7 @@ func (server *Server) onServerLogin(ctx context.Context, args ...interface{}) {
|
||||
|
||||
res.AppId = in.AppId
|
||||
res.Code = consts.TCPMsgCodeSuccess
|
||||
server.Write(user.Conn, res)
|
||||
_ = server.Write(user.Conn, res)
|
||||
}
|
||||
|
||||
func (server *Server) onServerHeartbeat(ctx context.Context, args ...interface{}) {
|
||||
@ -161,6 +160,5 @@ func (server *Server) onServerHeartbeat(ctx context.Context, args ...interface{}
|
||||
}
|
||||
|
||||
res.Code = consts.TCPMsgCodeSuccess
|
||||
server.Write(client.Conn, res)
|
||||
|
||||
_ = server.Write(client.Conn, res)
|
||||
}
|
||||
|
@ -40,5 +40,4 @@ func NotifyCall(ctx context.Context, in payin.NotifyCallFuncInp) {
|
||||
}
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ func consumerListen(ctx context.Context, job consumerStrategy) {
|
||||
if listenErr := consumer.ListenReceiveMsgDo(topic, func(mqMsg MqMsg) {
|
||||
err = job.Handle(ctx, mqMsg)
|
||||
|
||||
if err != nil {
|
||||
// 遇到错误,重新加入到队列
|
||||
//queue.Push(topic, mqMsg.Body)
|
||||
}
|
||||
//if err != nil {
|
||||
// // 遇到错误,重新加入到队列
|
||||
// //queue.Push(topic, mqMsg.Body)
|
||||
//}
|
||||
|
||||
// 记录消费队列日志
|
||||
ConsumerLog(ctx, topic, mqMsg, err)
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@ -119,7 +118,7 @@ func (r *reader) close() {
|
||||
func (r *reader) sync() {
|
||||
name := path.Join(r.config.Path, indexFile)
|
||||
data, _ := json.Marshal(&r.checkpoint)
|
||||
_ = ioutil.WriteFile(name, data, filePerm)
|
||||
_ = os.WriteFile(name, data, filePerm)
|
||||
}
|
||||
|
||||
// restore index and offset
|
||||
@ -131,7 +130,7 @@ func (r *reader) restore() (err error) {
|
||||
r.sync()
|
||||
}
|
||||
|
||||
data, _ := ioutil.ReadFile(name)
|
||||
data, _ := os.ReadFile(name)
|
||||
|
||||
_ = json.Unmarshal(data, &r.checkpoint)
|
||||
r.index, r.offset = r.checkpoint.Index, r.checkpoint.Offset
|
||||
|
@ -16,7 +16,6 @@ import (
|
||||
)
|
||||
|
||||
type KafkaMq struct {
|
||||
endPoints []string
|
||||
Partitions int32
|
||||
producerIns sarama.AsyncProducer
|
||||
consumerIns sarama.ConsumerGroup
|
||||
@ -128,7 +127,7 @@ func RegisterKafkaMqConsumer(connOpt KafkaConfig) (client MqConsumer, err error)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if validateVersion(kfkVersion) == false {
|
||||
if !validateVersion(kfkVersion) {
|
||||
kfkVersion = sarama.V2_4_0_0
|
||||
}
|
||||
|
||||
@ -175,7 +174,7 @@ func doRegisterKafkaProducer(connOpt KafkaConfig, mqIns *KafkaMq) (err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if validateVersion(kfkVersion) == false {
|
||||
if !validateVersion(kfkVersion) {
|
||||
kfkVersion = sarama.V2_4_0_0
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ func NewConsumer(groupName string) (mqClient MqConsumer, err error) {
|
||||
|
||||
randTag := string(charset.RandomCreateBytes(6))
|
||||
// 是否支持创建多个消费者
|
||||
if config.Kafka.MultiConsumer == false {
|
||||
if !config.Kafka.MultiConsumer {
|
||||
randTag = "001"
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ func (r *RedisMq) SendByteMsg(topic string, body []byte) (mqMsg MqMsg, err error
|
||||
if r.poolName == "" {
|
||||
return mqMsg, gerror.New("RedisMq producer not register")
|
||||
}
|
||||
|
||||
|
||||
if topic == "" {
|
||||
return mqMsg, gerror.New("RedisMq topic is empty")
|
||||
}
|
||||
@ -213,7 +213,7 @@ func getRandMsgId() string {
|
||||
}
|
||||
|
||||
func (r *RedisMq) loopReadDelayQueue(key string) (resCh chan MqMsg, errCh chan error) {
|
||||
resCh = make(chan MqMsg, 0)
|
||||
resCh = make(chan MqMsg)
|
||||
errCh = make(chan error, 1)
|
||||
|
||||
go func() {
|
||||
@ -245,8 +245,8 @@ func (r *RedisMq) loopReadDelayQueue(key string) (resCh chan MqMsg, errCh chan e
|
||||
errCh <- err
|
||||
return
|
||||
} else if pop.IsEmpty() {
|
||||
conn.ZRem(ctx, key, listK)
|
||||
conn.Del(ctx, listK)
|
||||
_, _ = conn.ZRem(ctx, key, listK)
|
||||
_, _ = conn.Del(ctx, listK)
|
||||
break
|
||||
} else {
|
||||
var mqMsg MqMsg
|
||||
|
@ -7,8 +7,6 @@ package queue
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/apache/rocketmq-client-go/v2"
|
||||
"github.com/apache/rocketmq-client-go/v2/consumer"
|
||||
"github.com/apache/rocketmq-client-go/v2/primitive"
|
||||
@ -57,7 +55,7 @@ func (r *RocketMq) SendMsg(topic string, body string) (mqMsg MqMsg, err error) {
|
||||
// SendByteMsg 生产数据
|
||||
func (r *RocketMq) SendByteMsg(topic string, body []byte) (mqMsg MqMsg, err error) {
|
||||
if r.producerIns == nil {
|
||||
return mqMsg, errors.New("RocketMq producer not register")
|
||||
return mqMsg, gerror.New("rocketMq producer not register")
|
||||
}
|
||||
|
||||
result, err := r.producerIns.SendSync(context.Background(), &primitive.Message{
|
||||
@ -69,7 +67,7 @@ func (r *RocketMq) SendByteMsg(topic string, body []byte) (mqMsg MqMsg, err erro
|
||||
return
|
||||
}
|
||||
if result.Status != primitive.SendOK {
|
||||
return mqMsg, errors.New(fmt.Sprintf("RocketMq producer send msg error status:%v", result.Status))
|
||||
return mqMsg, gerror.Newf("rocketMq producer send msg error status:%v", result.Status)
|
||||
}
|
||||
|
||||
mqMsg = MqMsg{
|
||||
@ -89,7 +87,7 @@ func (r *RocketMq) SendDelayMsg(topic string, body string, delaySecond int64) (m
|
||||
// ListenReceiveMsgDo 消费数据
|
||||
func (r *RocketMq) ListenReceiveMsgDo(topic string, receiveDo func(mqMsg MqMsg)) (err error) {
|
||||
if r.consumerIns == nil {
|
||||
return errors.New("RocketMq consumer not register")
|
||||
return gerror.New("rocketMq consumer not register")
|
||||
}
|
||||
|
||||
err = r.consumerIns.Subscribe(topic, consumer.MessageSelector{}, func(ctx context.Context, msgs ...*primitive.MessageExt) (consumer.ConsumeResult, error) {
|
||||
@ -105,15 +103,13 @@ func (r *RocketMq) ListenReceiveMsgDo(topic string, receiveDo func(mqMsg MqMsg))
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
err = r.consumerIns.Start()
|
||||
if err != nil {
|
||||
r.consumerIns.Unsubscribe(topic)
|
||||
return err
|
||||
if err = r.consumerIns.Start(); err != nil {
|
||||
_ = r.consumerIns.Unsubscribe(topic)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -145,7 +141,6 @@ func RegisterRocketMqProducer(endPoints []string, groupName string, retry int) (
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mqIns, nil
|
||||
}
|
||||
|
||||
@ -167,6 +162,5 @@ func RegisterRocketMqConsumer(endPoints []string, groupName string) (mqIns *Rock
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mqIns, nil
|
||||
}
|
||||
|
@ -70,7 +70,6 @@ func CreateClient(accessKeyId *string, accessKeySecret *string) (_result *dysmsa
|
||||
}
|
||||
// 访问的域名
|
||||
config.Endpoint = tea.String("dysmsapi.aliyuncs.com")
|
||||
_result = &dysmsapi20170525.Client{}
|
||||
_result, _err = dysmsapi20170525.NewClient(config)
|
||||
return _result, _err
|
||||
}
|
||||
|
@ -247,7 +247,6 @@ func ParseLoginUser(r *ghttp.Request) (user *model.Identity, err error) {
|
||||
refreshToken()
|
||||
})
|
||||
|
||||
user = new(model.Identity)
|
||||
user = claims.Identity
|
||||
return
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
@ -241,7 +240,7 @@ func (s *sAdminCash) Apply(ctx context.Context, in adminin.CashApplyInp) (err er
|
||||
CreditGroup: consts.CreditGroupApplyCash,
|
||||
Num: -in.Money,
|
||||
MapId: lastInsertId,
|
||||
Remark: fmt.Sprintf("后台申请提现"),
|
||||
Remark: "后台申请提现",
|
||||
})
|
||||
|
||||
return
|
||||
|
@ -298,6 +298,10 @@ func (s *sAdminOrder) List(ctx context.Context, in adminin.OrderListInp) (list [
|
||||
{Dao: dao.PayLog, Alias: "payLog"},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = mod.Fields(fields).Page(in.Page, in.PerPage).OrderDesc(dao.AdminOrder.Columns().Id).Scan(&list)
|
||||
return
|
||||
}
|
||||
|
@ -192,8 +192,7 @@ func (s *sCommonUpload) UploadUCloud(ctx context.Context, conf *model.UploadConf
|
||||
}
|
||||
|
||||
nowDate := time.Now().Format("2006-01-02")
|
||||
fileName := gfile.Basename(file.Filename)
|
||||
fileName = strings.ToLower(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.S(6))
|
||||
fileName := strings.ToLower(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.S(6))
|
||||
fileName = fileName + gfile.Ext(file.Filename)
|
||||
fullPath := conf.UCloudPath + nowDate + "/" + fileName
|
||||
config := &ufile.Config{
|
||||
@ -213,7 +212,7 @@ func (s *sCommonUpload) UploadUCloud(ctx context.Context, conf *model.UploadConf
|
||||
|
||||
// 流式上传本地小文件
|
||||
f2, err := file.Open()
|
||||
defer f2.Close()
|
||||
defer func() { _ = f2.Close() }()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -243,14 +242,13 @@ func (s *sCommonUpload) UploadCOS(ctx context.Context, conf *model.UploadConfig,
|
||||
}
|
||||
|
||||
nowDate := time.Now().Format("2006-01-02")
|
||||
fileName := gfile.Basename(file.Filename)
|
||||
fileName = strings.ToLower(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.S(6))
|
||||
fileName := strings.ToLower(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.S(6))
|
||||
fileName = fileName + gfile.Ext(file.Filename)
|
||||
fullPath := conf.CosPath + nowDate + "/" + fileName
|
||||
|
||||
// 流式上传本地小文件
|
||||
f2, err := file.Open()
|
||||
defer f2.Close()
|
||||
defer func() { _ = f2.Close() }()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -289,14 +287,13 @@ func (s *sCommonUpload) UploadOSS(ctx context.Context, conf *model.UploadConfig,
|
||||
}
|
||||
|
||||
nowDate := time.Now().Format("2006-01-02")
|
||||
fileName := gfile.Basename(file.Filename)
|
||||
fileName = strings.ToLower(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.S(6))
|
||||
fileName := strings.ToLower(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.S(6))
|
||||
fileName = fileName + gfile.Ext(file.Filename)
|
||||
fullPath := conf.OssPath + nowDate + "/" + fileName
|
||||
|
||||
// 流式上传本地小文件
|
||||
f2, err := file.Open()
|
||||
defer f2.Close()
|
||||
defer func() { _ = f2.Close() }()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -336,14 +333,13 @@ func (s *sCommonUpload) UploadQiNiu(ctx context.Context, conf *model.UploadConfi
|
||||
}
|
||||
|
||||
nowDate := time.Now().Format("2006-01-02")
|
||||
fileName := gfile.Basename(file.Filename)
|
||||
fileName = strings.ToLower(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.S(6))
|
||||
fileName := strings.ToLower(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.S(6))
|
||||
fileName = fileName + gfile.Ext(file.Filename)
|
||||
fullPath := conf.QiNiuPath + nowDate + "/" + fileName
|
||||
|
||||
// 流式上传本地小文件
|
||||
f2, err := file.Open()
|
||||
defer f2.Close()
|
||||
defer func() { _ = f2.Close() }()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ func NewCommonWechat() *sCommonWechat {
|
||||
func init() {
|
||||
serv := NewCommonWechat()
|
||||
service.RegisterCommonWechat(serv)
|
||||
gcron.Add(gctx.New(), "@every 300s", serv.CleanTempMap, "WechatCleanTempMap")
|
||||
_, _ = gcron.Add(gctx.New(), "@every 300s", serv.CleanTempMap, "WechatCleanTempMap")
|
||||
}
|
||||
|
||||
// Authorize 微信用户授权
|
||||
@ -116,7 +116,7 @@ func (s *sCommonWechat) AuthorizeCall(ctx context.Context, in commonin.WechatAut
|
||||
|
||||
switch data.Type {
|
||||
case consts.WechatAuthorizeOpenId: // 设置openid
|
||||
cache.Instance().Set(ctx, data.State, tk.OpenID, time.Hour*24*7)
|
||||
_ = cache.Instance().Set(ctx, data.State, tk.OpenID, time.Hour*24*7)
|
||||
case consts.WechatAuthorizeBindLogin: // 绑定微信登录
|
||||
// ...
|
||||
default:
|
||||
|
@ -80,10 +80,10 @@ func (s *sSysAddons) List(ctx context.Context, in sysin.AddonsListInp) (list []*
|
||||
}
|
||||
|
||||
if row.Skeleton.Logo == "" {
|
||||
row.Skeleton.Logo, _ = consts.AddonsGroupIconMap[row.Skeleton.Group]
|
||||
row.Skeleton.Logo = consts.AddonsGroupIconMap[row.Skeleton.Group]
|
||||
}
|
||||
|
||||
row.GroupName, _ = consts.AddonsGroupNameMap[row.Skeleton.Group]
|
||||
row.GroupName = consts.AddonsGroupNameMap[row.Skeleton.Group]
|
||||
|
||||
list = append(list, row)
|
||||
i++
|
||||
|
@ -158,7 +158,7 @@ func (s *sSysBlacklist) Load(ctx context.Context) {
|
||||
for _, v := range array {
|
||||
list := convert.IpFilterStrategy(v.String())
|
||||
if len(list) > 0 {
|
||||
for k, _ := range list {
|
||||
for k := range list {
|
||||
global.Blacklists[k] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
_ = crons.RefreshStatus(&in.SysCron)
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -123,11 +123,12 @@ func (s *sSysCron) Status(ctx context.Context, in sysin.CronStatusInp) (err erro
|
||||
|
||||
_, err = dao.SysCron.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
models.Status = in.Status
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
crons.RefreshStatus(models)
|
||||
_ = crons.RefreshStatus(models)
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -151,7 +152,6 @@ func (s *sSysCron) View(ctx context.Context, in sysin.CronViewInp) (res *sysin.C
|
||||
if err = dao.SysCron.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,10 @@ func (s *sSysCurdDemo) List(ctx context.Context, in sysin.CurdDemoListInp) (list
|
||||
{Dao: dao.TestCategory, Alias: "testCategory"},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = mod.Fields(fields).Page(in.Page, in.PerPage).OrderAsc(dao.SysGenCurdDemo.Columns().Sort).OrderDesc(dao.SysGenCurdDemo.Columns().Id).Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, "获取生成演示列表失败,请稍后重试!")
|
||||
return
|
||||
|
@ -281,7 +281,6 @@ func (s *sSysEmsLog) newView(ctx context.Context, in sysin.SendEmsInp, config *m
|
||||
}
|
||||
view.Assign("passwordResetLink", passwordResetLink)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -308,7 +307,6 @@ func (s *sSysEmsLog) GetTemplate(ctx context.Context, template string, config *m
|
||||
return v.Value, nil
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -346,7 +344,6 @@ func (s *sSysEmsLog) AllowSend(ctx context.Context, models *entity.SysEmsLog, co
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -400,7 +397,7 @@ func (s *sSysEmsLog) VerifyCode(ctx context.Context, in sysin.VerifyEmsCodeInp)
|
||||
}
|
||||
|
||||
if models.Code != in.Code {
|
||||
dao.SysEmsLog.Ctx(ctx).Where("id", models.Id).Increment("times", 1)
|
||||
_, _ = dao.SysEmsLog.Ctx(ctx).Where("id", models.Id).Increment("times", 1)
|
||||
err = gerror.New("验证码错误!")
|
||||
return
|
||||
}
|
||||
|
@ -238,11 +238,10 @@ func (s *sSysGenCodes) TableSelect(ctx context.Context, in sysin.GenCodesTableSe
|
||||
bt, err := gregex.Replace(patternStr, []byte(repStr), []byte(newValue))
|
||||
if err != nil {
|
||||
err = gerror.Newf("表名[%v] gregex.Replace err:%v", v.Value, err.Error())
|
||||
break
|
||||
return nil, err
|
||||
}
|
||||
|
||||
row := new(sysin.GenCodesTableSelectModel)
|
||||
row = v
|
||||
row := v
|
||||
row.DefTableComment = v.Label
|
||||
row.DaoName = gstr.CaseCamel(newValue)
|
||||
row.DefVarName = gstr.CaseCamel(string(bt))
|
||||
@ -252,7 +251,6 @@ func (s *sSysGenCodes) TableSelect(ctx context.Context, in sysin.GenCodesTableSe
|
||||
|
||||
res = append(res, row)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,6 @@ func (s *sSysLog) AutoLog(ctx context.Context) error {
|
||||
}
|
||||
|
||||
err = s.RealWrite(ctx, data)
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
@ -331,14 +330,14 @@ func (s *sSysLog) List(ctx context.Context, in sysin.LogListInp) (list []*sysin.
|
||||
list[i].MemberName = memberName.String()
|
||||
}
|
||||
|
||||
// 接口
|
||||
if list[i].AppId == consts.AppApi {
|
||||
//memberName, err = dao.Member.Ctx(ctx).Fields("realname").Where("id", res.List[i].MemberId).Value()
|
||||
//if err != nil {
|
||||
// err = gerror.Wrap(err, consts.ErrorORM)
|
||||
// return nil, err
|
||||
//}
|
||||
}
|
||||
//// 接口
|
||||
//if list[i].AppId == consts.AppApi {
|
||||
// //memberName, err = dao.Member.Ctx(ctx).Fields("realname").Where("id", res.List[i].MemberId).Value()
|
||||
// //if err != nil {
|
||||
// // err = gerror.Wrap(err, consts.ErrorORM)
|
||||
// // return nil, err
|
||||
// //}
|
||||
//}
|
||||
|
||||
if list[i].MemberName == "" {
|
||||
list[i].MemberName = "游客"
|
||||
|
@ -88,6 +88,10 @@ func (s *sSysLoginLog) List(ctx context.Context, in sysin.LoginLogListInp) (list
|
||||
{Dao: dao.SysLog, Alias: "sysLog"},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = mod.Fields(fields).Hook(hook.CityLabel).Handler(handler.FilterAuth).Page(in.Page, in.PerPage).OrderDesc(dao.SysLoginLog.Columns().Id).Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
@ -172,7 +176,6 @@ func (s *sSysLoginLog) Push(ctx context.Context, in sysin.LoginLogPushInp) {
|
||||
if err := queue.Push(consts.QueueLoginLogTopic, models); err != nil {
|
||||
g.Log().Warningf(ctx, "push err:%+v, models:%+v", err, models)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// RealWrite 真实写入
|
||||
|
@ -77,6 +77,10 @@ func (s *sSysServeLog) List(ctx context.Context, in sysin.ServeLogListInp) (list
|
||||
{Dao: dao.SysLog, Alias: "sysLog"},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = mod.Fields(fields).Handler(handler.FilterAuth).Page(in.Page, in.PerPage).OrderDesc(dao.SysServeLog.Columns().Id).Scan(&list)
|
||||
return
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/location"
|
||||
"hotgo/internal/library/sms"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
@ -140,7 +141,6 @@ func (s *sSysSmsLog) List(ctx context.Context, in sysin.SmsLogListInp) (list []*
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
@ -179,9 +179,9 @@ func (s *sSysSmsLog) SendCode(ctx context.Context, in sysin.SendCodeInp) (err er
|
||||
in.Code = grand.Digits(4)
|
||||
}
|
||||
|
||||
//if err = sms.New(config.SmsDrive).SendCode(ctx, in, config); err != nil {
|
||||
// return
|
||||
//}
|
||||
if err = sms.New(config.SmsDrive).SendCode(ctx, in, config); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var data = new(entity.SysSmsLog)
|
||||
data.Event = in.Event
|
||||
@ -237,7 +237,6 @@ func (s *sSysSmsLog) GetTemplate(ctx context.Context, template string, config *m
|
||||
err = gerror.Newf("暂不支持短信驱动:%v", config.SmsDrive)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -269,7 +268,6 @@ func (s *sSysSmsLog) AllowSend(ctx context.Context, models *entity.SysSmsLog, co
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -319,7 +317,7 @@ func (s *sSysSmsLog) VerifyCode(ctx context.Context, in sysin.VerifyCodeInp) (er
|
||||
}
|
||||
|
||||
if models.Code != in.Code {
|
||||
dao.SysSmsLog.Ctx(ctx).Where("id", models.Id).Increment("times", 1)
|
||||
_, _ = dao.SysSmsLog.Ctx(ctx).Where("id", models.Id).Increment("times", 1)
|
||||
err = gerror.New("验证码错误!")
|
||||
return
|
||||
}
|
||||
@ -329,6 +327,5 @@ func (s *sSysSmsLog) VerifyCode(ctx context.Context, in sysin.VerifyCodeInp) (er
|
||||
"status": consts.SmsStatusUsed,
|
||||
"updated_at": gtime.Now(),
|
||||
}).Update()
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ func (s *sAuthClient) IsLogin() bool {
|
||||
func (s *sAuthClient) onLoginEvent() {
|
||||
|
||||
// 获取授权数据
|
||||
s.client.Send(s.client.Ctx, &msgin.AuthSummary{})
|
||||
_ = s.client.Send(s.client.Ctx, &msgin.AuthSummary{})
|
||||
}
|
||||
|
||||
// onCloseEvent 连接关闭回调事件
|
||||
|
@ -10,12 +10,12 @@ import (
|
||||
func (s *sAuthClient) OnResponseAuthSummary(ctx context.Context, args ...interface{}) {
|
||||
var in *msgin.ResponseAuthSummary
|
||||
if err := gconv.Scan(args[0], &in); err != nil {
|
||||
s.client.Logger.Warningf(ctx, "OnResponseAuthSummary Scan err:+v", err)
|
||||
s.client.Logger.Warningf(ctx, "OnResponseAuthSummary Scan err:%+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := in.GetError(); err != nil {
|
||||
s.client.Logger.Warningf(ctx, "OnResponseAuthSummary GetError :+v", err)
|
||||
s.client.Logger.Warningf(ctx, "OnResponseAuthSummary GetError:%+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ func (s *sCronClient) OnCronDelete(ctx context.Context, args ...interface{}) {
|
||||
if err := gconv.Scan(args[0], &in); err != nil {
|
||||
res.Code = 1
|
||||
res.Message = err.Error()
|
||||
s.client.Reply(ctx, res)
|
||||
_ = s.client.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ func (s *sCronClient) OnCronDelete(ctx context.Context, args ...interface{}) {
|
||||
res.Message = err.Error()
|
||||
}
|
||||
|
||||
s.client.Reply(ctx, res)
|
||||
_ = s.client.Reply(ctx, res)
|
||||
}
|
||||
|
||||
// OnCronEdit 编辑任务
|
||||
@ -39,7 +39,7 @@ func (s *sCronClient) OnCronEdit(ctx context.Context, args ...interface{}) {
|
||||
if err := gconv.Scan(args[0], &in); err != nil {
|
||||
res.Code = 1
|
||||
res.Message = err.Error()
|
||||
s.client.Reply(ctx, res)
|
||||
_ = s.client.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ func (s *sCronClient) OnCronEdit(ctx context.Context, args ...interface{}) {
|
||||
res.Message = err.Error()
|
||||
}
|
||||
|
||||
s.client.Reply(ctx, res)
|
||||
_ = s.client.Reply(ctx, res)
|
||||
}
|
||||
|
||||
// OnCronStatus 修改任务状态
|
||||
@ -61,7 +61,7 @@ func (s *sCronClient) OnCronStatus(ctx context.Context, args ...interface{}) {
|
||||
if err := gconv.Scan(args[0], &in); err != nil {
|
||||
res.Code = 1
|
||||
res.Message = err.Error()
|
||||
s.client.Reply(ctx, res)
|
||||
_ = s.client.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ func (s *sCronClient) OnCronStatus(ctx context.Context, args ...interface{}) {
|
||||
res.Message = err.Error()
|
||||
}
|
||||
|
||||
s.client.Reply(ctx, res)
|
||||
_ = s.client.Reply(ctx, res)
|
||||
}
|
||||
|
||||
// OnCronOnlineExec 执行一次任务
|
||||
@ -83,7 +83,7 @@ func (s *sCronClient) OnCronOnlineExec(ctx context.Context, args ...interface{})
|
||||
if err := gconv.Scan(args[0], &in); err != nil {
|
||||
res.Code = 1
|
||||
res.Message = err.Error()
|
||||
s.client.Reply(ctx, res)
|
||||
_ = s.client.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
@ -92,5 +92,5 @@ func (s *sCronClient) OnCronOnlineExec(ctx context.Context, args ...interface{})
|
||||
res.Message = err.Error()
|
||||
}
|
||||
|
||||
s.client.Reply(ctx, res)
|
||||
_ = s.client.Reply(ctx, res)
|
||||
}
|
||||
|
@ -23,54 +23,54 @@ func (s *sTCPServer) OnAuthSummary(ctx context.Context, args ...interface{}) {
|
||||
if err := gconv.Scan(args, &in); err != nil {
|
||||
res.Code = 1
|
||||
res.Message = err.Error()
|
||||
s.serv.Reply(ctx, res)
|
||||
_ = s.serv.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
if user.Auth == nil {
|
||||
res.Code = 2
|
||||
res.Message = "登录信息获取失败,请重新登录"
|
||||
s.serv.Reply(ctx, res)
|
||||
_ = s.serv.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
if err := dao.SysServeLicense.Ctx(ctx).Where("appid = ?", user.Auth.AppId).Scan(&models); err != nil {
|
||||
res.Code = 3
|
||||
res.Message = err.Error()
|
||||
s.serv.Reply(ctx, res)
|
||||
_ = s.serv.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
if models == nil {
|
||||
res.Code = 4
|
||||
res.Message = "授权信息不存在"
|
||||
s.serv.Reply(ctx, res)
|
||||
_ = s.serv.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
if models.Status != consts.StatusEnabled {
|
||||
res.Code = 5
|
||||
res.Message = "授权已禁用,请联系管理员"
|
||||
s.serv.Reply(ctx, res)
|
||||
_ = s.serv.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
if models.Group != user.Auth.Group {
|
||||
res.Code = 6
|
||||
res.Message = "你登录的授权分组未得到授权,请联系管理员"
|
||||
s.serv.Reply(ctx, res)
|
||||
_ = s.serv.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
if models.EndAt.Before(gtime.Now()) {
|
||||
res.Code = 7
|
||||
res.Message = "授权已过期,请联系管理员"
|
||||
s.serv.Reply(ctx, res)
|
||||
_ = s.serv.Reply(ctx, res)
|
||||
return
|
||||
}
|
||||
|
||||
res.Data = new(msgin.AuthSummaryData)
|
||||
res.Data.EndAt = models.EndAt
|
||||
res.Data.Online = models.Online
|
||||
s.serv.Reply(ctx, res)
|
||||
_ = s.serv.Reply(ctx, res)
|
||||
}
|
||||
|
@ -3,14 +3,11 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package view
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/service"
|
||||
@ -42,9 +39,8 @@ func (s *sView) GetTitle(ctx context.Context, in *model.ViewGetTitleInput) strin
|
||||
// RenderTpl 渲染指定模板页面
|
||||
func (s *sView) RenderTpl(ctx context.Context, tpl string, data ...model.View) {
|
||||
var (
|
||||
viewObj = model.View{}
|
||||
viewData = make(g.Map)
|
||||
request = g.RequestFromCtx(ctx)
|
||||
viewObj = model.View{}
|
||||
request = g.RequestFromCtx(ctx)
|
||||
)
|
||||
if len(data) > 0 {
|
||||
viewObj = data[0]
|
||||
@ -69,7 +65,7 @@ func (s *sView) RenderTpl(ctx context.Context, tpl string, data ...model.View) {
|
||||
}
|
||||
|
||||
// 去掉空数据
|
||||
viewData = gconv.Map(viewObj)
|
||||
viewData := gconv.Map(viewObj)
|
||||
for k, v := range viewData {
|
||||
if g.IsEmpty(v) {
|
||||
delete(viewData, k)
|
||||
@ -96,8 +92,6 @@ func (s *sView) Render302(ctx context.Context, data ...model.View) {
|
||||
if view.Title == "" {
|
||||
view.Title = "页面跳转中"
|
||||
}
|
||||
//view.MainTpl = s.getViewFolderName(ctx) + "/pages/302.html"
|
||||
//s.Render(ctx, view)
|
||||
s.RenderTpl(ctx, "default/pages/302.html", view)
|
||||
}
|
||||
|
||||
@ -156,37 +150,3 @@ func (s *sView) Error(ctx context.Context, err error) {
|
||||
}
|
||||
s.RenderTpl(ctx, "default/pages/500.html", view)
|
||||
}
|
||||
|
||||
// 获取视图存储目录
|
||||
func (s *sView) getViewFolderName(ctx context.Context) string {
|
||||
return gstr.Split(g.Cfg().MustGet(ctx, "viewer.indexLayout").String(), "/")[0]
|
||||
}
|
||||
|
||||
// 获取自动设置的MainTpl
|
||||
func (s *sView) getDefaultMainTpl(ctx context.Context) string {
|
||||
var (
|
||||
viewFolderPrefix = s.getViewFolderName(ctx)
|
||||
urlPathArray = gstr.SplitAndTrim(g.RequestFromCtx(ctx).URL.Path, "/")
|
||||
mainTpl string
|
||||
)
|
||||
if len(urlPathArray) > 0 && urlPathArray[0] == viewFolderPrefix {
|
||||
urlPathArray = urlPathArray[1:]
|
||||
}
|
||||
|
||||
switch {
|
||||
case len(urlPathArray) == 2:
|
||||
// 如果2级路由为数字,那么为模块的详情页面,那么路由固定为/xxx/detail。
|
||||
// 如果需要定制化内容模板,请在具体路由方法中设置MainTpl。
|
||||
if gstr.IsNumeric(urlPathArray[1]) {
|
||||
urlPathArray[1] = "detail"
|
||||
}
|
||||
mainTpl = viewFolderPrefix + "/" + gfile.Join(urlPathArray[0], urlPathArray[1]) + ".html"
|
||||
case len(urlPathArray) == 1:
|
||||
mainTpl = viewFolderPrefix + "/" + urlPathArray[0] + "/index.html"
|
||||
default:
|
||||
// 默认首页内容
|
||||
mainTpl = viewFolderPrefix + "/index/index.html"
|
||||
}
|
||||
|
||||
return gstr.TrimLeft(mainTpl, "/")
|
||||
}
|
||||
|
@ -57,8 +57,6 @@ func (m *Response) SetCode(code ...int) {
|
||||
if m.Code == 0 {
|
||||
m.Code = consts.TCPMsgCodeSuccess
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetError 获取响应中的错误
|
||||
|
@ -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 router
|
||||
|
||||
import (
|
||||
@ -19,7 +18,6 @@ func Home(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
// 注册首页路由
|
||||
group.ALL("/", func(r *ghttp.Request) {
|
||||
_, _ = base.Site.Index(r.Context(), &api.SiteIndexReq{})
|
||||
return
|
||||
})
|
||||
|
||||
prefix := g.Cfg().MustGet(ctx, "router.home.prefix", "/home")
|
||||
|
@ -19,13 +19,6 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
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)
|
||||
@ -59,10 +52,6 @@ type (
|
||||
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)
|
||||
GetMemberByIds(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)
|
||||
@ -74,6 +63,48 @@ type (
|
||||
GetMenuList(ctx context.Context, memberId int64) (res *role.DynamicRes, err error)
|
||||
LoginPermissions(ctx context.Context, memberId int64) (lists adminin.MemberLoginPermissions, err error)
|
||||
}
|
||||
IAdminOrder interface {
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
AcceptRefund(ctx context.Context, in adminin.OrderAcceptRefundInp) (err error)
|
||||
ApplyRefund(ctx context.Context, in adminin.OrderApplyRefundInp) (err error)
|
||||
PayNotify(ctx context.Context, in payin.NotifyCallFuncInp) (err error)
|
||||
Create(ctx context.Context, in adminin.OrderCreateInp) (res *adminin.OrderCreateModel, err error)
|
||||
List(ctx context.Context, in adminin.OrderListInp) (list []*adminin.OrderListModel, totalCount int, err error)
|
||||
Export(ctx context.Context, in adminin.OrderListInp) (err error)
|
||||
Edit(ctx context.Context, in adminin.OrderEditInp) (err error)
|
||||
Delete(ctx context.Context, in adminin.OrderDeleteInp) (err error)
|
||||
View(ctx context.Context, in adminin.OrderViewInp) (res *adminin.OrderViewModel, err error)
|
||||
Status(ctx context.Context, in adminin.OrderStatusInp) (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)
|
||||
}
|
||||
IAdminMemberPost interface {
|
||||
UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error)
|
||||
GetMemberByIds(ctx context.Context, memberId int64) (postIds []int64, err error)
|
||||
}
|
||||
IAdminMonitor interface {
|
||||
StartMonitor(ctx context.Context)
|
||||
GetMeta(ctx context.Context) *model.MonitorData
|
||||
}
|
||||
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)
|
||||
}
|
||||
IAdminPost interface {
|
||||
Delete(ctx context.Context, in adminin.PostDeleteInp) (err error)
|
||||
Edit(ctx context.Context, in adminin.PostEditInp) (err error)
|
||||
@ -97,98 +128,34 @@ type (
|
||||
DataScopeSelect() (res form.Selects)
|
||||
DataScopeEdit(ctx context.Context, in *adminin.DataScopeEditInp) (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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
IAdminOrder interface {
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
AcceptRefund(ctx context.Context, in adminin.OrderAcceptRefundInp) (err error)
|
||||
ApplyRefund(ctx context.Context, in adminin.OrderApplyRefundInp) (err error)
|
||||
PayNotify(ctx context.Context, in payin.NotifyCallFuncInp) (err error)
|
||||
Create(ctx context.Context, in adminin.OrderCreateInp) (res *adminin.OrderCreateModel, err error)
|
||||
List(ctx context.Context, in adminin.OrderListInp) (list []*adminin.OrderListModel, totalCount int, err error)
|
||||
Export(ctx context.Context, in adminin.OrderListInp) (err error)
|
||||
Edit(ctx context.Context, in adminin.OrderEditInp) (err error)
|
||||
Delete(ctx context.Context, in adminin.OrderDeleteInp) (err error)
|
||||
View(ctx context.Context, in adminin.OrderViewInp) (res *adminin.OrderViewModel, err error)
|
||||
Status(ctx context.Context, in adminin.OrderStatusInp) (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)
|
||||
}
|
||||
IAdminMonitor interface {
|
||||
StartMonitor(ctx context.Context)
|
||||
GetMeta(ctx context.Context) *model.MonitorData
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localAdminCash IAdminCash
|
||||
localAdminCreditsLog IAdminCreditsLog
|
||||
localAdminDept IAdminDept
|
||||
localAdminMember IAdminMember
|
||||
localAdminMemberPost IAdminMemberPost
|
||||
localAdminMenu IAdminMenu
|
||||
localAdminPost IAdminPost
|
||||
localAdminOrder IAdminOrder
|
||||
localAdminRole IAdminRole
|
||||
localAdminSite IAdminSite
|
||||
localAdminCash IAdminCash
|
||||
localAdminMemberPost IAdminMemberPost
|
||||
localAdminMonitor IAdminMonitor
|
||||
localAdminNotice IAdminNotice
|
||||
localAdminOrder IAdminOrder
|
||||
localAdminSite IAdminSite
|
||||
localAdminPost IAdminPost
|
||||
)
|
||||
|
||||
func AdminPost() IAdminPost {
|
||||
if localAdminPost == nil {
|
||||
panic("implement not found for interface IAdminPost, forgot register?")
|
||||
}
|
||||
return localAdminPost
|
||||
}
|
||||
|
||||
func RegisterAdminPost(i IAdminPost) {
|
||||
localAdminPost = i
|
||||
}
|
||||
|
||||
func AdminRole() IAdminRole {
|
||||
if localAdminRole == nil {
|
||||
panic("implement not found for interface IAdminRole, forgot register?")
|
||||
}
|
||||
return localAdminRole
|
||||
}
|
||||
|
||||
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 AdminCreditsLog() IAdminCreditsLog {
|
||||
if localAdminCreditsLog == nil {
|
||||
panic("implement not found for interface IAdminCreditsLog, forgot register?")
|
||||
@ -222,17 +189,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?")
|
||||
@ -244,6 +200,61 @@ func RegisterAdminMenu(i IAdminMenu) {
|
||||
localAdminMenu = i
|
||||
}
|
||||
|
||||
func AdminOrder() IAdminOrder {
|
||||
if localAdminOrder == nil {
|
||||
panic("implement not found for interface IAdminOrder, forgot register?")
|
||||
}
|
||||
return localAdminOrder
|
||||
}
|
||||
|
||||
func RegisterAdminOrder(i IAdminOrder) {
|
||||
localAdminOrder = i
|
||||
}
|
||||
|
||||
func AdminRole() IAdminRole {
|
||||
if localAdminRole == nil {
|
||||
panic("implement not found for interface IAdminRole, forgot register?")
|
||||
}
|
||||
return localAdminRole
|
||||
}
|
||||
|
||||
func RegisterAdminRole(i IAdminRole) {
|
||||
localAdminRole = 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 AdminCash() IAdminCash {
|
||||
if localAdminCash == nil {
|
||||
panic("implement not found for interface IAdminCash, forgot register?")
|
||||
}
|
||||
return localAdminCash
|
||||
}
|
||||
|
||||
func RegisterAdminCash(i IAdminCash) {
|
||||
localAdminCash = 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 AdminMonitor() IAdminMonitor {
|
||||
if localAdminMonitor == nil {
|
||||
panic("implement not found for interface IAdminMonitor, forgot register?")
|
||||
@ -266,24 +277,13 @@ func RegisterAdminNotice(i IAdminNotice) {
|
||||
localAdminNotice = i
|
||||
}
|
||||
|
||||
func AdminOrder() IAdminOrder {
|
||||
if localAdminOrder == nil {
|
||||
panic("implement not found for interface IAdminOrder, forgot register?")
|
||||
func AdminPost() IAdminPost {
|
||||
if localAdminPost == nil {
|
||||
panic("implement not found for interface IAdminPost, forgot register?")
|
||||
}
|
||||
return localAdminOrder
|
||||
return localAdminPost
|
||||
}
|
||||
|
||||
func RegisterAdminOrder(i IAdminOrder) {
|
||||
localAdminOrder = 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 RegisterAdminPost(i IAdminPost) {
|
||||
localAdminPost = i
|
||||
}
|
||||
|
@ -17,15 +17,10 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
ISysAttachment interface {
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
Delete(ctx context.Context, in sysin.AttachmentDeleteInp) (err error)
|
||||
Edit(ctx context.Context, in sysin.AttachmentEditInp) (err error)
|
||||
Status(ctx context.Context, in sysin.AttachmentStatusInp) (err error)
|
||||
MaxSort(ctx context.Context, in sysin.AttachmentMaxSortInp) (res *sysin.AttachmentMaxSortModel, 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)
|
||||
Add(ctx context.Context, meta *sysin.UploadFileMeta, fullPath, drive string) (models *entity.SysAttachment, 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)
|
||||
}
|
||||
ISysBlacklist interface {
|
||||
Delete(ctx context.Context, in sysin.BlacklistDeleteInp) (err error)
|
||||
@ -37,25 +32,82 @@ type (
|
||||
VariableLoad(ctx context.Context, err error)
|
||||
Load(ctx context.Context)
|
||||
}
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
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)
|
||||
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)
|
||||
}
|
||||
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)
|
||||
ISysProvinces interface {
|
||||
Tree(ctx context.Context) (list []g.Map, err error)
|
||||
Delete(ctx context.Context, in sysin.ProvincesDeleteInp) (err error)
|
||||
Edit(ctx context.Context, in sysin.ProvincesEditInp) (err error)
|
||||
Status(ctx context.Context, in sysin.ProvincesStatusInp) (err error)
|
||||
MaxSort(ctx context.Context, in sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error)
|
||||
View(ctx context.Context, in sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error)
|
||||
List(ctx context.Context, in sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error)
|
||||
ChildrenList(ctx context.Context, in sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error)
|
||||
UniqueId(ctx context.Context, in sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error)
|
||||
Select(ctx context.Context, in sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, 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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
ISysConfig interface {
|
||||
InitConfig(ctx context.Context)
|
||||
@ -78,74 +130,35 @@ type (
|
||||
ConversionType(ctx context.Context, models *entity.SysConfig) (value interface{}, err error)
|
||||
UpdateConfigByGroup(ctx context.Context, in sysin.UpdateConfigInp) (err error)
|
||||
}
|
||||
ISysProvinces interface {
|
||||
Tree(ctx context.Context) (list []g.Map, err error)
|
||||
Delete(ctx context.Context, in sysin.ProvincesDeleteInp) (err error)
|
||||
Edit(ctx context.Context, in sysin.ProvincesEditInp) (err error)
|
||||
Status(ctx context.Context, in sysin.ProvincesStatusInp) (err error)
|
||||
MaxSort(ctx context.Context, in sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error)
|
||||
View(ctx context.Context, in sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error)
|
||||
List(ctx context.Context, in sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error)
|
||||
ChildrenList(ctx context.Context, in sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error)
|
||||
UniqueId(ctx context.Context, in sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error)
|
||||
Select(ctx context.Context, in sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, 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)
|
||||
ISysGenCodes interface {
|
||||
Delete(ctx context.Context, in sysin.GenCodesDeleteInp) (err error)
|
||||
Edit(ctx context.Context, in sysin.GenCodesEditInp) (res *sysin.GenCodesEditModel, err error)
|
||||
Status(ctx context.Context, in sysin.GenCodesStatusInp) (err error)
|
||||
MaxSort(ctx context.Context, in sysin.GenCodesMaxSortInp) (res *sysin.GenCodesMaxSortModel, err error)
|
||||
View(ctx context.Context, in sysin.GenCodesViewInp) (res *sysin.GenCodesViewModel, err error)
|
||||
List(ctx context.Context, in sysin.GenCodesListInp) (list []*sysin.GenCodesListModel, totalCount int, err error)
|
||||
Selects(ctx context.Context, in sysin.GenCodesSelectsInp) (res *sysin.GenCodesSelectsModel, err error)
|
||||
TableSelect(ctx context.Context, in sysin.GenCodesTableSelectInp) (res []*sysin.GenCodesTableSelectModel, err error)
|
||||
ColumnSelect(ctx context.Context, in sysin.GenCodesColumnSelectInp) (res []*sysin.GenCodesColumnSelectModel, err error)
|
||||
ColumnList(ctx context.Context, in sysin.GenCodesColumnListInp) (res []*sysin.GenCodesColumnListModel, err error)
|
||||
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)
|
||||
}
|
||||
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)
|
||||
ISysAttachment interface {
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
Delete(ctx context.Context, in sysin.AttachmentDeleteInp) (err error)
|
||||
Edit(ctx context.Context, in sysin.AttachmentEditInp) (err error)
|
||||
Status(ctx context.Context, in sysin.AttachmentStatusInp) (err error)
|
||||
MaxSort(ctx context.Context, in sysin.AttachmentMaxSortInp) (res *sysin.AttachmentMaxSortModel, 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)
|
||||
Add(ctx context.Context, meta *sysin.UploadFileMeta, fullPath, drive string) (models *entity.SysAttachment, err error)
|
||||
}
|
||||
ISysCron interface {
|
||||
StartCron(ctx context.Context)
|
||||
@ -166,59 +179,46 @@ type (
|
||||
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)
|
||||
}
|
||||
ISysGenCodes interface {
|
||||
Delete(ctx context.Context, in sysin.GenCodesDeleteInp) (err error)
|
||||
Edit(ctx context.Context, in sysin.GenCodesEditInp) (res *sysin.GenCodesEditModel, err error)
|
||||
Status(ctx context.Context, in sysin.GenCodesStatusInp) (err error)
|
||||
MaxSort(ctx context.Context, in sysin.GenCodesMaxSortInp) (res *sysin.GenCodesMaxSortModel, err error)
|
||||
View(ctx context.Context, in sysin.GenCodesViewInp) (res *sysin.GenCodesViewModel, err error)
|
||||
List(ctx context.Context, in sysin.GenCodesListInp) (list []*sysin.GenCodesListModel, totalCount int, err error)
|
||||
Selects(ctx context.Context, in sysin.GenCodesSelectsInp) (res *sysin.GenCodesSelectsModel, err error)
|
||||
TableSelect(ctx context.Context, in sysin.GenCodesTableSelectInp) (res []*sysin.GenCodesTableSelectModel, err error)
|
||||
ColumnSelect(ctx context.Context, in sysin.GenCodesColumnSelectInp) (res []*sysin.GenCodesColumnSelectModel, err error)
|
||||
ColumnList(ctx context.Context, in sysin.GenCodesColumnListInp) (res []*sysin.GenCodesColumnListModel, err error)
|
||||
Preview(ctx context.Context, in sysin.GenCodesPreviewInp) (res *sysin.GenCodesPreviewModel, err error)
|
||||
Build(ctx context.Context, in sysin.GenCodesBuildInp) (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)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localSysDictData ISysDictData
|
||||
localSysEmsLog ISysEmsLog
|
||||
localSysProvinces ISysProvinces
|
||||
localSysCurdDemo ISysCurdDemo
|
||||
localSysConfig ISysConfig
|
||||
localSysDictType ISysDictType
|
||||
localSysGenCodes ISysGenCodes
|
||||
localSysServeLog ISysServeLog
|
||||
localSysSmsLog ISysSmsLog
|
||||
localSysAddons ISysAddons
|
||||
localSysCron ISysCron
|
||||
localSysCronGroup ISysCronGroup
|
||||
localSysGenCodes ISysGenCodes
|
||||
localSysServeLog ISysServeLog
|
||||
localSysLog ISysLog
|
||||
localSysAttachment ISysAttachment
|
||||
localSysBlacklist ISysBlacklist
|
||||
localSysDictData ISysDictData
|
||||
localSysLog ISysLog
|
||||
localSysAddonsConfig ISysAddonsConfig
|
||||
localSysConfig ISysConfig
|
||||
localSysProvinces ISysProvinces
|
||||
localSysCurdDemo ISysCurdDemo
|
||||
localSysDictType ISysDictType
|
||||
localSysEmsLog ISysEmsLog
|
||||
localSysLoginLog ISysLoginLog
|
||||
localSysSmsLog ISysSmsLog
|
||||
localSysAddonsConfig ISysAddonsConfig
|
||||
)
|
||||
|
||||
func SysAddons() ISysAddons {
|
||||
if localSysAddons == nil {
|
||||
panic("implement not found for interface ISysAddons, forgot register?")
|
||||
func SysAttachment() ISysAttachment {
|
||||
if localSysAttachment == nil {
|
||||
panic("implement not found for interface ISysAttachment, forgot register?")
|
||||
}
|
||||
return localSysAddons
|
||||
return localSysAttachment
|
||||
}
|
||||
|
||||
func RegisterSysAddons(i ISysAddons) {
|
||||
localSysAddons = i
|
||||
func RegisterSysAttachment(i ISysAttachment) {
|
||||
localSysAttachment = i
|
||||
}
|
||||
|
||||
func SysCron() ISysCron {
|
||||
@ -243,61 +243,6 @@ func RegisterSysCronGroup(i ISysCronGroup) {
|
||||
localSysCronGroup = 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 SysServeLog() ISysServeLog {
|
||||
if localSysServeLog == nil {
|
||||
panic("implement not found for interface ISysServeLog, forgot register?")
|
||||
}
|
||||
return localSysServeLog
|
||||
}
|
||||
|
||||
func RegisterSysServeLog(i ISysServeLog) {
|
||||
localSysServeLog = i
|
||||
}
|
||||
|
||||
func SysAttachment() ISysAttachment {
|
||||
if localSysAttachment == nil {
|
||||
panic("implement not found for interface ISysAttachment, forgot register?")
|
||||
}
|
||||
return localSysAttachment
|
||||
}
|
||||
|
||||
func RegisterSysAttachment(i ISysAttachment) {
|
||||
localSysAttachment = 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 SysDictData() ISysDictData {
|
||||
if localSysDictData == nil {
|
||||
panic("implement not found for interface ISysDictData, forgot register?")
|
||||
}
|
||||
return localSysDictData
|
||||
}
|
||||
|
||||
func RegisterSysDictData(i ISysDictData) {
|
||||
localSysDictData = i
|
||||
}
|
||||
|
||||
func SysLog() ISysLog {
|
||||
if localSysLog == nil {
|
||||
panic("implement not found for interface ISysLog, forgot register?")
|
||||
@ -320,59 +265,15 @@ func RegisterSysAddonsConfig(i ISysAddonsConfig) {
|
||||
localSysAddonsConfig = i
|
||||
}
|
||||
|
||||
func SysConfig() ISysConfig {
|
||||
if localSysConfig == nil {
|
||||
panic("implement not found for interface ISysConfig, forgot register?")
|
||||
func SysBlacklist() ISysBlacklist {
|
||||
if localSysBlacklist == nil {
|
||||
panic("implement not found for interface ISysBlacklist, forgot register?")
|
||||
}
|
||||
return localSysConfig
|
||||
return localSysBlacklist
|
||||
}
|
||||
|
||||
func RegisterSysConfig(i ISysConfig) {
|
||||
localSysConfig = 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 SysCurdDemo() ISysCurdDemo {
|
||||
if localSysCurdDemo == nil {
|
||||
panic("implement not found for interface ISysCurdDemo, forgot register?")
|
||||
}
|
||||
return localSysCurdDemo
|
||||
}
|
||||
|
||||
func RegisterSysCurdDemo(i ISysCurdDemo) {
|
||||
localSysCurdDemo = 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 RegisterSysBlacklist(i ISysBlacklist) {
|
||||
localSysBlacklist = i
|
||||
}
|
||||
|
||||
func SysLoginLog() ISysLoginLog {
|
||||
@ -386,6 +287,50 @@ func RegisterSysLoginLog(i ISysLoginLog) {
|
||||
localSysLoginLog = i
|
||||
}
|
||||
|
||||
func SysCurdDemo() ISysCurdDemo {
|
||||
if localSysCurdDemo == nil {
|
||||
panic("implement not found for interface ISysCurdDemo, forgot register?")
|
||||
}
|
||||
return localSysCurdDemo
|
||||
}
|
||||
|
||||
func RegisterSysCurdDemo(i ISysCurdDemo) {
|
||||
localSysCurdDemo = 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 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 SysSmsLog() ISysSmsLog {
|
||||
if localSysSmsLog == nil {
|
||||
panic("implement not found for interface ISysSmsLog, forgot register?")
|
||||
@ -396,3 +341,58 @@ func SysSmsLog() ISysSmsLog {
|
||||
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 SysConfig() ISysConfig {
|
||||
if localSysConfig == nil {
|
||||
panic("implement not found for interface ISysConfig, forgot register?")
|
||||
}
|
||||
return localSysConfig
|
||||
}
|
||||
|
||||
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 SysGenCodes() ISysGenCodes {
|
||||
if localSysGenCodes == nil {
|
||||
panic("implement not found for interface ISysGenCodes, forgot register?")
|
||||
}
|
||||
return localSysGenCodes
|
||||
}
|
||||
|
||||
func RegisterSysGenCodes(i ISysGenCodes) {
|
||||
localSysGenCodes = i
|
||||
}
|
||||
|
||||
func SysServeLog() ISysServeLog {
|
||||
if localSysServeLog == nil {
|
||||
panic("implement not found for interface ISysServeLog, forgot register?")
|
||||
}
|
||||
return localSysServeLog
|
||||
}
|
||||
|
||||
func RegisterSysServeLog(i ISysServeLog) {
|
||||
localSysServeLog = i
|
||||
}
|
||||
|
@ -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 websocket
|
||||
|
||||
import (
|
||||
@ -105,7 +104,7 @@ func (c *Client) write() {
|
||||
}()
|
||||
defer func() {
|
||||
clientManager.Unregister <- c
|
||||
c.Socket.Close()
|
||||
_ = c.Socket.Close()
|
||||
}()
|
||||
for {
|
||||
select {
|
||||
@ -118,7 +117,7 @@ func (c *Client) write() {
|
||||
g.Log().Warningf(ctxManager, "client write message, user:%+v", c.User)
|
||||
return
|
||||
}
|
||||
c.Socket.WriteJSON(message)
|
||||
_ = c.Socket.WriteJSON(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,7 +146,6 @@ func (c *Client) Context() context.Context {
|
||||
// Heartbeat 心跳更新
|
||||
func (c *Client) Heartbeat(currentTime uint64) {
|
||||
c.HeartbeatTime = currentTime
|
||||
return
|
||||
}
|
||||
|
||||
// IsHeartbeatTimeout 心跳是否超时
|
||||
|
@ -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 websocket
|
||||
|
||||
import (
|
||||
@ -79,12 +78,10 @@ func (manager *ClientManager) ClientsRange(f func(client *Client, value bool) (r
|
||||
manager.ClientsLock.RLock()
|
||||
defer manager.ClientsLock.RUnlock()
|
||||
for key, value := range manager.Clients {
|
||||
result := f(key, value)
|
||||
if result == false {
|
||||
if !f(key, value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetClientsLen 获取客户端总数
|
||||
@ -104,14 +101,12 @@ func (manager *ClientManager) AddClients(client *Client) {
|
||||
func (manager *ClientManager) DelClients(client *Client) {
|
||||
manager.ClientsLock.Lock()
|
||||
defer manager.ClientsLock.Unlock()
|
||||
if _, ok := manager.Clients[client]; ok {
|
||||
delete(manager.Clients, client)
|
||||
}
|
||||
delete(manager.Clients, client)
|
||||
}
|
||||
|
||||
// GetClient 通过socket ID获取客户端的连接
|
||||
func (manager *ClientManager) GetClient(ID string) (client *Client) {
|
||||
for c, _ := range manager.Clients {
|
||||
for c := range manager.Clients {
|
||||
if c.ID == ID {
|
||||
return c
|
||||
}
|
||||
@ -187,7 +182,7 @@ func (manager *ClientManager) EventUnregister(client *Client) {
|
||||
manager.DelClients(client)
|
||||
// 删除用户连接
|
||||
deleteResult := manager.DelUsers(client)
|
||||
if deleteResult == false {
|
||||
if !deleteResult {
|
||||
// 不是当前连接的客户端
|
||||
return
|
||||
}
|
||||
@ -202,7 +197,7 @@ func (manager *ClientManager) clearTimeoutConnections() {
|
||||
for client := range clients {
|
||||
if client.IsHeartbeatTimeout(currentTime) {
|
||||
//fmt.Println("心跳时间超时 关闭连接", client.Addr, client.UserId, client.LoginTime, client.HeartbeatTime)
|
||||
client.Socket.Close()
|
||||
_ = client.Socket.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -224,7 +219,7 @@ func (manager *ClientManager) ping() {
|
||||
// SendToAll(res)
|
||||
//})
|
||||
// 定时任务,清理超时连接
|
||||
gcron.Add(ctxManager, "*/30 * * * * *", func(ctx context.Context) {
|
||||
_, _ = gcron.Add(ctxManager, "*/30 * * * * *", func(ctx context.Context) {
|
||||
manager.clearTimeoutConnections()
|
||||
})
|
||||
}
|
||||
|
@ -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 charset
|
||||
|
||||
import (
|
||||
@ -30,7 +29,6 @@ func SplitMemberIds(str, pos string) (memberIds []int64) {
|
||||
for _, memberId := range receiver {
|
||||
memberIds = append(memberIds, gconv.Int64(strings.TrimSpace(memberId)))
|
||||
}
|
||||
|
||||
return convert.UniqueSliceInt64(memberIds)
|
||||
}
|
||||
|
||||
|
@ -3,14 +3,12 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package convert
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/utility/validate"
|
||||
"reflect"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
@ -45,20 +43,7 @@ func UniqueSliceString(languages []string) []string {
|
||||
return result
|
||||
}
|
||||
|
||||
// UnderlineToUpperCamelCase 下划线单词转为大写驼峰单词
|
||||
func UnderlineToUpperCamelCase(s string) string {
|
||||
s = strings.Replace(s, "_", " ", -1)
|
||||
s = strings.Title(s)
|
||||
return strings.Replace(s, " ", "", -1)
|
||||
}
|
||||
|
||||
// UnderlineToLowerCamelCase 下划线单词转为小写驼峰单词
|
||||
func UnderlineToLowerCamelCase(s string) string {
|
||||
s = UnderlineToUpperCamelCase(s)
|
||||
return string(unicode.ToLower(rune(s[0]))) + s[1:]
|
||||
}
|
||||
|
||||
//CamelCaseToUnderline 驼峰单词转下划线单词
|
||||
// CamelCaseToUnderline 驼峰单词转下划线单词
|
||||
func CamelCaseToUnderline(s string) string {
|
||||
var output []rune
|
||||
for i, r := range s {
|
||||
|
@ -27,7 +27,6 @@ func IpFilterStrategy(originIp string) (list map[string]struct{}) {
|
||||
list[ip] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -51,7 +50,6 @@ func IpFilterStrategy(originIp string) (list map[string]struct{}) {
|
||||
for i := index; i <= 254; i++ {
|
||||
list[prefix+gconv.String(i)] = struct{}{}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -97,6 +95,5 @@ func IpFilterStrategy(originIp string) (list map[string]struct{}) {
|
||||
list[originIp] = struct{}{}
|
||||
return
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
@ -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 excel
|
||||
|
||||
import (
|
||||
@ -34,16 +33,12 @@ func ExportByStructs(ctx context.Context, tags []string, list interface{}, fileN
|
||||
f := excelize.NewFile()
|
||||
f.SetSheetName("Sheet1", sheetName)
|
||||
_ = f.SetRowHeight("Sheet1", 1, 30)
|
||||
header := make([]string, 0)
|
||||
for _, v := range tags {
|
||||
header = append(header, v)
|
||||
}
|
||||
|
||||
rowStyleID, _ := f.NewStyle(defaultRowStyle)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_ = f.SetSheetRow(sheetName, "A1", &header)
|
||||
_ = f.SetSheetRow(sheetName, "A1", &tags)
|
||||
|
||||
var (
|
||||
length = len(tags)
|
||||
@ -73,10 +68,10 @@ func ExportByStructs(ctx context.Context, tags []string, list interface{}, fileN
|
||||
}
|
||||
rowNum++
|
||||
if err = f.SetSheetRow(sheetName, "A"+gconv.String(rowNum), &row); err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
if err = f.SetCellStyle(sheetName, fmt.Sprintf("A%d", rowNum), fmt.Sprintf("%s", lastRow), rowStyleID); err != nil {
|
||||
return err
|
||||
if err = f.SetCellStyle(sheetName, fmt.Sprintf("A%d", rowNum), lastRow, rowStyleID); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,8 +86,8 @@ func ExportByStructs(ctx context.Context, tags []string, list interface{}, fileN
|
||||
w.Header().Set("Content-Transfer-Encoding", "binary")
|
||||
w.Header().Set("Access-Control-Expose-Headers", "Content-Disposition")
|
||||
|
||||
if err := f.Write(w); err != nil {
|
||||
return err
|
||||
if err = f.Write(w); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 加入到上下文
|
||||
@ -102,8 +97,7 @@ func ExportByStructs(ctx context.Context, tags []string, list interface{}, fileN
|
||||
Timestamp: time.Now().Unix(),
|
||||
TraceID: gctx.CtxId(ctx),
|
||||
})
|
||||
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
// letter 生成完整的表头
|
||||
|
@ -3,13 +3,12 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package file
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
"hotgo/utility/format"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
@ -30,7 +29,7 @@ func WalkDir(dirname string) (error, []fileInfo) {
|
||||
if nil != err {
|
||||
return err, nil
|
||||
}
|
||||
files, err := ioutil.ReadDir(op) //获取目录下所有文件的信息,包括文件和文件夹
|
||||
files, err := os.ReadDir(op) //获取目录下所有文件的信息,包括文件和文件夹
|
||||
if nil != err {
|
||||
return err, nil
|
||||
}
|
||||
@ -44,7 +43,11 @@ func WalkDir(dirname string) (error, []fileInfo) {
|
||||
}
|
||||
fileInfos = append(fileInfos, fs...) //将 slice 添加到 slice
|
||||
} else {
|
||||
fi := fileInfo{op + `/` + f.Name(), f.Size()}
|
||||
info, err := f.Info()
|
||||
if nil != err {
|
||||
return err, nil
|
||||
}
|
||||
fi := fileInfo{op + `/` + f.Name(), info.Size()}
|
||||
fileInfos = append(fileInfos, fi) //slice 中添加成员
|
||||
}
|
||||
}
|
||||
|
@ -8,15 +8,9 @@ package format
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"math"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// RoundInt64 四舍五入
|
||||
func RoundInt64(x float64) int64 {
|
||||
return int64(math.Floor(x + 0/5))
|
||||
}
|
||||
|
||||
// Round2String 四舍五入保留小数,默认2位
|
||||
func Round2String(value float64, args ...interface{}) (v string) {
|
||||
var places = 2
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
|
||||
// FilterMaskDemo 过滤演示环境下的配置隐藏字段
|
||||
func FilterMaskDemo(ctx context.Context, src g.Map) g.Map {
|
||||
if src == nil || len(src) == 0 {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ func FilterMaskDemo(ctx context.Context, src g.Map) g.Map {
|
||||
return src
|
||||
}
|
||||
|
||||
for k, _ := range src {
|
||||
for k := range src {
|
||||
if _, ok := consts.ConfigMaskDemoField[k]; ok {
|
||||
src[k] = consts.DemoTips
|
||||
}
|
||||
@ -88,45 +88,22 @@ func SafeGo(ctx context.Context, f func(ctx context.Context), level ...interface
|
||||
func Logf(level int, ctx context.Context, format string, v ...interface{}) {
|
||||
switch level {
|
||||
case glog.LEVEL_DEBU:
|
||||
g.Log().Debugf(ctx, format, v)
|
||||
g.Log().Debugf(ctx, format, v...)
|
||||
case glog.LEVEL_INFO:
|
||||
g.Log().Infof(ctx, format, v)
|
||||
g.Log().Infof(ctx, format, v...)
|
||||
case glog.LEVEL_NOTI:
|
||||
g.Log().Noticef(ctx, format, v)
|
||||
g.Log().Noticef(ctx, format, v...)
|
||||
case glog.LEVEL_WARN:
|
||||
g.Log().Warningf(ctx, format, v)
|
||||
g.Log().Warningf(ctx, format, v...)
|
||||
case glog.LEVEL_ERRO:
|
||||
g.Log().Errorf(ctx, format, v)
|
||||
g.Log().Errorf(ctx, format, v...)
|
||||
case glog.LEVEL_CRIT:
|
||||
g.Log().Critical(ctx, format, v)
|
||||
g.Log().Criticalf(ctx, format, v...)
|
||||
case glog.LEVEL_PANI:
|
||||
g.Log().Panicf(ctx, format, v)
|
||||
g.Log().Panicf(ctx, format, v...)
|
||||
case glog.LEVEL_FATA:
|
||||
g.Log().Fatalf(ctx, format, v)
|
||||
g.Log().Fatalf(ctx, format, v...)
|
||||
default:
|
||||
g.Log().Error(ctx, "Logf level not find")
|
||||
}
|
||||
}
|
||||
|
||||
func Log(level int, ctx context.Context, v ...interface{}) {
|
||||
switch level {
|
||||
case glog.LEVEL_DEBU:
|
||||
g.Log().Debug(ctx, v)
|
||||
case glog.LEVEL_INFO:
|
||||
g.Log().Info(ctx, v)
|
||||
case glog.LEVEL_NOTI:
|
||||
g.Log().Notice(ctx, v)
|
||||
case glog.LEVEL_WARN:
|
||||
g.Log().Warning(ctx, v)
|
||||
case glog.LEVEL_ERRO:
|
||||
g.Log().Error(ctx, v)
|
||||
case glog.LEVEL_CRIT:
|
||||
g.Log().Critical(ctx, v)
|
||||
case glog.LEVEL_PANI:
|
||||
g.Log().Panic(ctx, v)
|
||||
case glog.LEVEL_FATA:
|
||||
g.Log().Fatal(ctx, v)
|
||||
default:
|
||||
g.Log().Error(ctx, "Logf level not find")
|
||||
g.Log().Errorf(ctx, format, v...)
|
||||
}
|
||||
}
|
||||
|
@ -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 tree
|
||||
|
||||
import (
|
||||
@ -54,8 +53,6 @@ func GetIds(tree string) (ids []int64) {
|
||||
return
|
||||
}
|
||||
|
||||
/////////////////////////// 转换类
|
||||
|
||||
// GenTree 生成关系树
|
||||
func GenTree(menus []map[string]interface{}) (realMenu []map[string]interface{}) {
|
||||
return GenTreeWithField(menus, GenOption{
|
||||
|
@ -18,7 +18,7 @@ func GetOs(userAgent string) string {
|
||||
return osName
|
||||
}
|
||||
|
||||
strRe, _ := regexp.Compile("(?i:\\((.*?)\\))")
|
||||
strRe, _ := regexp.Compile(`(?i:((.*?)))`)
|
||||
userAgent = strRe.FindString(userAgent)
|
||||
|
||||
levelNames := ":micromessenger:dart:Windows NT:Windows Mobile:Windows Phone:Windows Phone OS:Macintosh|Macintosh:Mac OS:CrOS|CrOS:iPhone OS:iPad|iPad:OS:Android:Linux:blackberry:hpwOS:Series:Symbian:PalmOS:SymbianOS:J2ME:Sailfish:Bada:MeeGo:webOS|hpwOS:Maemo:"
|
||||
@ -83,7 +83,7 @@ func GetBrowser(userAgent string) string {
|
||||
|
||||
level := 0
|
||||
for _, name := range names {
|
||||
replaceRe, _ := regexp.Compile("(?i:[\\s?\\/0-9.]+)")
|
||||
replaceRe, _ := regexp.Compile(`(?i:[\s?\/0-9.]+)`)
|
||||
n := replaceRe.ReplaceAllString(name, "")
|
||||
l := strings.Index(levelNames, fmt.Sprintf(":%s:", n))
|
||||
if level == 0 {
|
||||
|
@ -33,16 +33,12 @@ func IsHTTPS(ctx context.Context) bool {
|
||||
g.Log().Info(ctx, "IsHTTPS ctx not request")
|
||||
return false
|
||||
}
|
||||
|
||||
return r.TLS != nil || gstr.Equal(r.Header.Get("X-Forwarded-Proto"), "https")
|
||||
}
|
||||
|
||||
// IsIp 是否为ipv4
|
||||
func IsIp(ip string) bool {
|
||||
if net.ParseIP(ip) != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return net.ParseIP(ip) != nil
|
||||
}
|
||||
|
||||
// IsPublicIp 是否是公网IP
|
||||
@ -56,9 +52,7 @@ func IsPublicIp(Ip string) bool {
|
||||
if ip4 := ip.To4(); ip4 != nil {
|
||||
return !ip.Equal(net.IPv4bcast)
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
// IsLocalIPAddr 检测 IP 地址字符串是否是内网地址
|
||||
@ -150,16 +144,15 @@ func IsMobileVisit(userAgent string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
isMobile := false
|
||||
is := false
|
||||
mobileKeywords := []string{"Mobile", "Android", "Silk/", "Kindle", "BlackBerry", "Opera Mini", "Opera Mobi"}
|
||||
for i := 0; i < len(mobileKeywords); i++ {
|
||||
if strings.Contains(userAgent, mobileKeywords[i]) {
|
||||
isMobile = true
|
||||
is = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return isMobile
|
||||
return is
|
||||
}
|
||||
|
||||
// IsWxBrowserVisit 是否为微信访问
|
||||
@ -177,7 +170,6 @@ func IsWxBrowserVisit(userAgent string) bool {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return is
|
||||
}
|
||||
|
||||
@ -196,6 +188,5 @@ func IsWxMiniProgramVisit(userAgent string) bool {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return is
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user