diff --git a/server/api/admin/smslog/smslog.go b/server/api/admin/smslog/smslog.go index a5d0362..004b31d 100644 --- a/server/api/admin/smslog/smslog.go +++ b/server/api/admin/smslog/smslog.go @@ -1,3 +1,8 @@ +// Package smslog +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package smslog import ( diff --git a/server/api/api/pay/notify.go b/server/api/api/pay/notify.go index 4c3f9e5..bd0448e 100644 --- a/server/api/api/pay/notify.go +++ b/server/api/api/pay/notify.go @@ -1,3 +1,8 @@ +// Package pay +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package pay import ( diff --git a/server/api/servmsg/auth.go b/server/api/servmsg/auth.go index ab3fe96..e071144 100644 --- a/server/api/servmsg/auth.go +++ b/server/api/servmsg/auth.go @@ -1,3 +1,8 @@ +// Package servmsg +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package servmsg import ( diff --git a/server/api/servmsg/cron.go b/server/api/servmsg/cron.go index 01ee439..f5ed466 100644 --- a/server/api/servmsg/cron.go +++ b/server/api/servmsg/cron.go @@ -1,3 +1,8 @@ +// Package servmsg +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package servmsg import ( diff --git a/server/api/servmsg/example.go b/server/api/servmsg/example.go index e09fb27..c469ebf 100644 --- a/server/api/servmsg/example.go +++ b/server/api/servmsg/example.go @@ -1,3 +1,8 @@ +// Package servmsg +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package servmsg import ( diff --git a/server/api/websocket/base/send.go b/server/api/websocket/base/send.go index 13a8d40..b67d70b 100644 --- a/server/api/websocket/base/send.go +++ b/server/api/websocket/base/send.go @@ -1,3 +1,8 @@ +// Package base +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package base import ( diff --git a/server/internal/consts/event.go b/server/internal/consts/event.go index 1386a00..e3e6ca3 100644 --- a/server/internal/consts/event.go +++ b/server/internal/consts/event.go @@ -1,3 +1,8 @@ +// Package consts +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package consts const ( diff --git a/server/internal/consts/http.go b/server/internal/consts/http.go index 212aa25..27fdae8 100644 --- a/server/internal/consts/http.go +++ b/server/internal/consts/http.go @@ -1,3 +1,8 @@ +// Package consts +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package consts const ( diff --git a/server/internal/consts/servelicense.go b/server/internal/consts/servelicense.go index 5d938c0..c3f2791 100644 --- a/server/internal/consts/servelicense.go +++ b/server/internal/consts/servelicense.go @@ -1,3 +1,8 @@ +// Package consts +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package consts // 授权分组 diff --git a/server/internal/consts/wechat.go b/server/internal/consts/wechat.go index 8bbca67..54565fd 100644 --- a/server/internal/consts/wechat.go +++ b/server/internal/consts/wechat.go @@ -1,3 +1,8 @@ +// Package consts +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package consts // 授权类型 diff --git a/server/internal/controller/admin/admin/monitor.go b/server/internal/controller/admin/admin/monitor.go index 1d5cc81..839f5fb 100644 --- a/server/internal/controller/admin/admin/monitor.go +++ b/server/internal/controller/admin/admin/monitor.go @@ -130,6 +130,8 @@ func (c *cMonitor) NetOnlineList(ctx context.Context, req *monitor.NetOnlineList conns := serv.GetClients() if len(conns) == 0 { + res = new(monitor.NetOnlineListRes) + res.PageRes.Pack(req, 0) return } diff --git a/server/internal/controller/admin/admin/role.go b/server/internal/controller/admin/admin/role.go index c7dbfb0..92e626c 100644 --- a/server/internal/controller/admin/admin/role.go +++ b/server/internal/controller/admin/admin/role.go @@ -70,7 +70,7 @@ func (c *cRole) UpdatePermissions(ctx context.Context, req *role.UpdatePermissio // DataScopeSelect 获取数据权限选项 func (c *cRole) DataScopeSelect(_ context.Context, _ *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) { res = new(role.DataScopeSelectRes) - res.List = consts.DataScopeSelect //service.AdminRole().DataScopeSelect() + res.List = consts.DataScopeSelect return } diff --git a/server/internal/dao/admin_dept.go b/server/internal/dao/admin_dept.go index 63c0b4b..d684b0f 100644 --- a/server/internal/dao/admin_dept.go +++ b/server/internal/dao/admin_dept.go @@ -5,11 +5,7 @@ package dao import ( - "context" - "github.com/gogf/gf/v2/errors/gerror" - "hotgo/internal/consts" "hotgo/internal/dao/internal" - "hotgo/internal/model/entity" ) // internalAdminDeptDao is internal type for wrapping internal DAO implements. @@ -28,23 +24,4 @@ var ( } ) -// IsUniqueName 判断名称是否唯一 -func (dao *adminDeptDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) { - var data *entity.AdminDept - m := dao.Ctx(ctx).Where("name", name) - - if id > 0 { - m = m.WhereNot("id", id) - } - - if err := m.Scan(&data); err != nil { - err = gerror.Wrap(err, consts.ErrorORM) - return false, err - } - - if data == nil { - return true, nil - } - - return false, nil -} +// Fill with you ideas below. diff --git a/server/internal/dao/admin_member_post.go b/server/internal/dao/admin_member_post.go index 1afd6f3..9dfa331 100644 --- a/server/internal/dao/admin_member_post.go +++ b/server/internal/dao/admin_member_post.go @@ -5,10 +5,7 @@ package dao import ( - "context" - "github.com/gogf/gf/v2/errors/gerror" "hotgo/internal/dao/internal" - "hotgo/internal/model/entity" ) // internalAdminMemberPostDao is internal type for wrapping internal DAO implements. @@ -27,27 +24,4 @@ var ( } ) -// UpdatePostIds 更新管理员岗位 -func (dao *adminMemberPostDao) UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error) { - _, err = dao.Ctx(ctx). - Where("member_id", memberId). - Delete() - if err != nil { - err = gerror.Wrap(err, "删除失败") - return err - } - - for i := 0; i < len(postIds); i++ { - _, err = dao.Ctx(ctx). - Insert(entity.AdminMemberPost{ - MemberId: memberId, - PostId: postIds[i], - }) - if err != nil { - err = gerror.Wrap(err, "插入用户岗位失败") - return err - } - } - - return nil -} +// Fill with you ideas below. diff --git a/server/internal/dao/admin_menu.go b/server/internal/dao/admin_menu.go index 7a82873..3699ed2 100644 --- a/server/internal/dao/admin_menu.go +++ b/server/internal/dao/admin_menu.go @@ -23,3 +23,5 @@ var ( internal.NewAdminMenuDao(), } ) + +// Fill with you ideas below. diff --git a/server/internal/dao/admin_post.go b/server/internal/dao/admin_post.go index 9d706c5..bb8cdc0 100644 --- a/server/internal/dao/admin_post.go +++ b/server/internal/dao/admin_post.go @@ -5,11 +5,7 @@ package dao import ( - "context" - "github.com/gogf/gf/v2/errors/gerror" - "hotgo/internal/consts" "hotgo/internal/dao/internal" - "hotgo/internal/model/entity" ) // internalAdminPostDao is internal type for wrapping internal DAO implements. @@ -28,44 +24,4 @@ var ( } ) -// IsUniqueName 判断名称是否唯一 -func (dao *adminPostDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) { - var data *entity.AdminPost - m := dao.Ctx(ctx).Where("name", name) - - if id > 0 { - m = m.WhereNot("id", id) - } - - if err := m.Scan(&data); err != nil { - err = gerror.Wrap(err, consts.ErrorORM) - return false, err - } - - if data == nil { - return true, nil - } - - return false, nil -} - -// IsUniqueCode 判断编码是否唯一 -func (dao *adminPostDao) IsUniqueCode(ctx context.Context, id int64, code string) (bool, error) { - var data *entity.AdminPost - m := dao.Ctx(ctx).Where("code", code) - - if id > 0 { - m = m.WhereNot("id", id) - } - - if err := m.Scan(&data); err != nil { - err = gerror.Wrap(err, consts.ErrorORM) - return false, err - } - - if data == nil { - return true, nil - } - - return false, nil -} +// Fill with you ideas below. diff --git a/server/internal/dao/admin_role.go b/server/internal/dao/admin_role.go index c95a299..890b17e 100644 --- a/server/internal/dao/admin_role.go +++ b/server/internal/dao/admin_role.go @@ -5,11 +5,7 @@ package dao import ( - "context" - "github.com/gogf/gf/v2/errors/gerror" - "hotgo/internal/consts" "hotgo/internal/dao/internal" - "hotgo/internal/model/entity" ) // internalAdminRoleDao is internal type for wrapping internal DAO implements. @@ -28,44 +24,4 @@ var ( } ) -// IsUniqueName 判断名称是否唯一 -func (dao *adminRoleDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) { - var data *entity.AdminRole - m := dao.Ctx(ctx).Where("name", name) - - if id > 0 { - m = m.WhereNot("id", id) - } - - if err := m.Scan(&data); err != nil { - err = gerror.Wrap(err, consts.ErrorORM) - return false, err - } - - if data == nil { - return true, nil - } - - return false, nil -} - -// IsUniqueCode 判断编码是否唯一 -func (dao *adminRoleDao) IsUniqueCode(ctx context.Context, id int64, code string) (bool, error) { - var data *entity.AdminRole - m := dao.Ctx(ctx).Where("key", code) - - if id > 0 { - m = m.WhereNot("id", id) - } - - if err := m.Scan(&data); err != nil { - err = gerror.Wrap(err, consts.ErrorORM) - return false, err - } - - if data == nil { - return true, nil - } - - return false, nil -} +// Fill with you ideas below. diff --git a/server/internal/dao/sys_attachment.go b/server/internal/dao/sys_attachment.go index 4be9a29..42777e5 100644 --- a/server/internal/dao/sys_attachment.go +++ b/server/internal/dao/sys_attachment.go @@ -23,3 +23,5 @@ var ( internal.NewSysAttachmentDao(), } ) + +// Fill with you ideas below. diff --git a/server/internal/dao/sys_cron_group.go b/server/internal/dao/sys_cron_group.go index c8c69ee..0946320 100644 --- a/server/internal/dao/sys_cron_group.go +++ b/server/internal/dao/sys_cron_group.go @@ -5,9 +5,6 @@ package dao import ( - "context" - "github.com/gogf/gf/v2/errors/gerror" - "hotgo/internal/consts" "hotgo/internal/dao/internal" ) @@ -27,14 +24,4 @@ var ( } ) -// GetName 获取分组名称 -func (dao *sysCronGroupDao) GetName(ctx context.Context, id int64) (name string, err error) { - m := dao.Ctx(ctx).Fields("name").Where("id", id) - list, err := m.Value() - if err != nil { - err = gerror.Wrap(err, consts.ErrorORM) - return name, err - } - - return list.String(), nil -} +// Fill with you ideas below. diff --git a/server/internal/dao/sys_dict_type.go b/server/internal/dao/sys_dict_type.go index d5a1a9b..00b691f 100644 --- a/server/internal/dao/sys_dict_type.go +++ b/server/internal/dao/sys_dict_type.go @@ -5,12 +5,7 @@ package dao import ( - "context" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" - "hotgo/internal/consts" "hotgo/internal/dao/internal" - "hotgo/internal/model/entity" ) // internalSysDictTypeDao is internal type for wrapping internal DAO implements. @@ -30,60 +25,3 @@ var ( ) // Fill with you ideas below. - -// IsUniqueType 判断类型是否唯一 -func (dao *sysDictTypeDao) IsUniqueType(ctx context.Context, id int64, typeName string) (bool, error) { - var data *entity.SysDictType - m := dao.Ctx(ctx).Where("type", typeName) - - if id > 0 { - m = m.WhereNot("id", id) - } - - if err := m.Scan(&data); err != nil { - err = gerror.Wrap(err, consts.ErrorORM) - return false, err - } - - if data == nil { - return true, nil - } - - return false, nil -} - -// GetTypes 获取指定ID的所有类型标识,包含下级 -func (dao *sysDictTypeDao) GetTypes(ctx context.Context, id int64) (types []string, err error) { - columns, err := dao.Ctx(ctx).Fields("type"). - Where("id", id). - WhereOr("pid", id). - Where("status", consts.StatusEnabled).Array() - types = g.NewVar(columns).Strings() - return -} - -// GetType 获取指定ID的类型标识 -func (dao *sysDictTypeDao) GetType(ctx context.Context, id int64) (types string, err error) { - m := dao.Ctx(ctx).Fields("type").Where("id", id). - Where("status", consts.StatusEnabled) - list, err := m.Value() - if err != nil { - err = gerror.Wrap(err, consts.ErrorORM) - return types, err - } - - return list.String(), nil -} - -// GetId 获取指定类型的ID -func (dao *sysDictTypeDao) GetId(ctx context.Context, t string) (id int64, err error) { - m := dao.Ctx(ctx).Fields("id").Where("type", t). - Where("status", consts.StatusEnabled) - list, err := m.Value() - if err != nil { - err = gerror.Wrap(err, consts.ErrorORM) - return 0, err - } - - return list.Int64(), nil -} diff --git a/server/internal/dao/sys_ems_log.go b/server/internal/dao/sys_ems_log.go index af48dd5..3e09d80 100644 --- a/server/internal/dao/sys_ems_log.go +++ b/server/internal/dao/sys_ems_log.go @@ -5,8 +5,6 @@ package dao import ( - "context" - "github.com/gogf/gf/v2/os/gtime" "hotgo/internal/dao/internal" ) @@ -27,17 +25,3 @@ var ( ) // Fill with you ideas below. - -// NowDayCount 当天发送次数 -func (dao *sysEmsLogDao) NowDayCount(ctx context.Context, event, email string) (count int, err error) { - count, err = dao.Ctx(ctx). - Where("email", email). - Where("event", event). - WhereGTE("created_at", gtime.Now().Format("Y-m-d")). - Count() - if err != nil { - return 0, err - } - - return -} diff --git a/server/internal/dao/sys_sms_log.go b/server/internal/dao/sys_sms_log.go index 335b26f..c763917 100644 --- a/server/internal/dao/sys_sms_log.go +++ b/server/internal/dao/sys_sms_log.go @@ -5,8 +5,6 @@ package dao import ( - "context" - "github.com/gogf/gf/v2/os/gtime" "hotgo/internal/dao/internal" ) @@ -27,17 +25,3 @@ var ( ) // Fill with you ideas below. - -// NowDayCount 当天发送次数 -func (dao *sysSmsLogDao) NowDayCount(ctx context.Context, event, mobile string) (count int, err error) { - count, err = dao.Ctx(ctx). - Where("mobile", mobile). - Where("event", event). - WhereGTE("created_at", gtime.Now().Format("Y-m-d")). - Count() - if err != nil { - return 0, err - } - - return -} diff --git a/server/internal/global/cluster.go b/server/internal/global/cluster.go index d4baf0f..4720804 100644 --- a/server/internal/global/cluster.go +++ b/server/internal/global/cluster.go @@ -41,14 +41,13 @@ func PublishClusterSync(ctx context.Context, channel string, message interface{} } mutex := lock.Mutex(fmt.Sprintf("%s:%s", "lock", channel)) - if err := mutex.Lock(ctx); err != nil { - g.Log().Warningf(ctx, "PublishClusterSync %v lock err:%v", channel, err) - return - } - _ = mutex.Unlock(ctx) - - if _, err := pubsub.Publish(ctx, channel, message); err != nil { - g.Log().Warningf(ctx, "PublishClusterSync %v err:%v", channel, err) + err := mutex.LockFunc(ctx, func() { + if _, err := pubsub.Publish(ctx, channel, message); err != nil { + g.Log().Warningf(ctx, "PublishClusterSync %v err:%v", channel, err) + } + }) + if err != nil { + g.Log().Warningf(ctx, "PublishClusterSync %v LockFunc err:%v", channel, err) } return } diff --git a/server/internal/library/addons/build.go b/server/internal/library/addons/build.go index 0b00756..9dc29cd 100644 --- a/server/internal/library/addons/build.go +++ b/server/internal/library/addons/build.go @@ -1,3 +1,8 @@ +// Package addons +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package addons import ( diff --git a/server/internal/library/addons/build_layout.go b/server/internal/library/addons/build_layout.go index d5d8c75..9efd77a 100644 --- a/server/internal/library/addons/build_layout.go +++ b/server/internal/library/addons/build_layout.go @@ -1,3 +1,8 @@ +// Package addons +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package addons const ( diff --git a/server/internal/library/cache/file/file.go b/server/internal/library/cache/file/file.go index 4c88d7f..361dad1 100644 --- a/server/internal/library/cache/file/file.go +++ b/server/internal/library/cache/file/file.go @@ -1,3 +1,8 @@ +// Package file +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package file import ( diff --git a/server/internal/library/contexts/detached.go b/server/internal/library/contexts/detached.go index f8ad1ba..e7c1310 100644 --- a/server/internal/library/contexts/detached.go +++ b/server/internal/library/contexts/detached.go @@ -1,3 +1,8 @@ +// Package contexts +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package contexts import ( diff --git a/server/internal/library/hgrds/lock/lock.go b/server/internal/library/hgrds/lock/lock.go index 87c9e6a..667cd86 100644 --- a/server/internal/library/hgrds/lock/lock.go +++ b/server/internal/library/hgrds/lock/lock.go @@ -116,6 +116,33 @@ func (l *Lock) Unlock(ctx context.Context) error { return err } +func (l *Lock) LockFunc(ctx context.Context, f func()) error { + if err := l.Lock(ctx); err != nil { + return err + } + defer func() { + _ = l.Unlock(ctx) + }() + f() + return nil +} + +// TryLockFunc tries locking the mutex for writing with given callback function `f`. +// it returns true immediately if success, or if there's a lock on the mutex, +// it returns error immediately. +// +// It releases the lock after `f` is executed. +func (l *Lock) TryLockFunc(ctx context.Context, f func()) error { + err := l.TryLock(ctx) + if err != nil { + defer func() { + _ = l.Unlock(ctx) + }() + f() + } + return err +} + // startWatchDog 看门狗 func (l *Lock) startWatchDog() { resetTTLInterval := l.ttl / 3 diff --git a/server/internal/library/hgrds/pubsub/subscribe.go b/server/internal/library/hgrds/pubsub/subscribe.go index 525ffb7..dffe360 100644 --- a/server/internal/library/hgrds/pubsub/subscribe.go +++ b/server/internal/library/hgrds/pubsub/subscribe.go @@ -32,9 +32,6 @@ func SubscribeMap(channels map[string]SubHandler) (err error) { return } - subscribes.mutex.Lock() - defer subscribes.mutex.Unlock() - for channel, hr := range channels { if err = Subscribe(channel, hr); err != nil { return diff --git a/server/internal/library/notify/feishu/client.go b/server/internal/library/notify/feishu/client.go deleted file mode 100644 index 7d6d073..0000000 --- a/server/internal/library/notify/feishu/client.go +++ /dev/null @@ -1,79 +0,0 @@ -package feishu - -import ( - "encoding/json" - "fmt" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - "strconv" - "time" - - "hotgo/internal/library/notify/feishu/internal/security" -) - -const feishuAPI = "https://open.feishu.cn/open-apis/bot/v2/hook/" - -// Client feishu client -type Client struct { - AccessToken string - Secret string -} - -// NewClient new client -func NewClient(accessToken, secret string) *Client { - return &Client{ - AccessToken: accessToken, - Secret: secret, - } -} - -// Response response struct -type Response struct { - Code int64 `json:"code"` - Msg string `json:"msg"` - Data interface{} `json:"data"` - - Extra interface{} `json:"Extra"` - StatusCode int64 `json:"StatusCode"` - StatusMessage string `json:"StatusMessage"` -} - -// Send send message -func (d *Client) Send(message Message) (string, *Response, error) { - res := &Response{} - - if len(d.AccessToken) < 1 { - return "", res, fmt.Errorf("accessToken is empty") - } - - timestamp := time.Now().Unix() - sign, err := security.GenSign(d.Secret, timestamp) - if err != nil { - return "", res, err - } - - body := message.Body() - body["timestamp"] = strconv.FormatInt(timestamp, 10) - body["sign"] = sign - - reqBytes, err := json.Marshal(body) - if err != nil { - return "", res, err - } - - var ( - result *Response - URL = fmt.Sprintf("%v%v", feishuAPI, d.AccessToken) - reqString = string(reqBytes) - ) - - g.Client(). - Retry(3, time.Second). - SetHeader("Accept", "application/json"). - SetHeader("Content-Type", "application/json"). - PostVar(gctx.New(), URL, &result) - if result.Code != 0 { - return reqString, result, fmt.Errorf("send message to feishu error = %s", result.Msg) - } - return reqString, result, nil -} diff --git a/server/internal/library/notify/feishu/image.go b/server/internal/library/notify/feishu/image.go deleted file mode 100644 index 26a2919..0000000 --- a/server/internal/library/notify/feishu/image.go +++ /dev/null @@ -1,24 +0,0 @@ -package feishu - -type ImageMessage struct { - MsgType MsgType `json:"msg_type"` - Content ImageContent `json:"content"` -} - -type ImageContent struct { - ImageKey string `json:"image_key"` -} - -func (m *ImageMessage) Body() map[string]interface{} { - m.MsgType = MsgTypeImage - return structToMap(m) -} - -func NewImageMessage() *ImageMessage { - return &ImageMessage{} -} - -func (m *ImageMessage) SetImageKey(key string) *ImageMessage { - m.Content.ImageKey = key - return m -} diff --git a/server/internal/library/notify/feishu/interactive.go b/server/internal/library/notify/feishu/interactive.go deleted file mode 100644 index aabf642..0000000 --- a/server/internal/library/notify/feishu/interactive.go +++ /dev/null @@ -1,21 +0,0 @@ -package feishu - -type InteractiveMessage struct { - MsgType MsgType `json:"msg_type"` - Card string `json:"card"` -} - -func (m *InteractiveMessage) Body() map[string]interface{} { - m.MsgType = MsgTypeInteractive - return structToMap(m) -} - -func NewInteractiveMessage() *InteractiveMessage { - return &InteractiveMessage{} -} - -// SetCard set card with cardbuilder https://open.feishu.cn/tool/cardbuilder?from=custom_bot_doc -func (m *InteractiveMessage) SetCard(card string) *InteractiveMessage { - m.Card = card - return m -} diff --git a/server/internal/library/notify/feishu/internal/security/security.go b/server/internal/library/notify/feishu/internal/security/security.go deleted file mode 100644 index e6d5380..0000000 --- a/server/internal/library/notify/feishu/internal/security/security.go +++ /dev/null @@ -1,21 +0,0 @@ -package security - -import ( - "crypto/hmac" - "crypto/sha256" - "encoding/base64" - "fmt" -) - -// GenSign generate sign -func GenSign(secret string, timestamp int64) (string, error) { - stringToSign := fmt.Sprintf("%v", timestamp) + "\n" + secret - var data []byte - h := hmac.New(sha256.New, []byte(stringToSign)) - _, err := h.Write(data) - if err != nil { - return "", err - } - signature := base64.StdEncoding.EncodeToString(h.Sum(nil)) - return signature, nil -} diff --git a/server/internal/library/notify/feishu/message.go b/server/internal/library/notify/feishu/message.go deleted file mode 100644 index 3bcfd57..0000000 --- a/server/internal/library/notify/feishu/message.go +++ /dev/null @@ -1,66 +0,0 @@ -package feishu - -import ( - "reflect" - "strings" -) - -type MsgType string - -// MsgType -const ( - MsgTypeText MsgType = "text" - MsgTypePost MsgType = "post" - MsgTypeImage MsgType = "image" - MsgTypeShareChat MsgType = "share_chat" - MsgTypeInteractive MsgType = "interactive" -) - -// Message interface -type Message interface { - Body() map[string]interface{} -} - -func structToMap(item interface{}) map[string]interface{} { - res := map[string]interface{}{} - if item == nil { - return res - } - v := reflect.TypeOf(item) - reflectValue := reflect.ValueOf(item) - reflectValue = reflect.Indirect(reflectValue) - - if v.Kind() == reflect.Ptr { - v = v.Elem() - } - - for i := 0; i < v.NumField(); i++ { - tag := v.Field(i).Tag.Get("json") - - // remove omitEmpty - omitEmpty := false - if strings.HasSuffix(tag, "omitempty") { - omitEmpty = true - idx := strings.Index(tag, ",") - if idx > 0 { - tag = tag[:idx] - } else { - tag = "" - } - } - - field := reflectValue.Field(i).Interface() - if tag != "" && tag != "-" { - if omitEmpty && reflectValue.Field(i).IsZero() { - continue - } - - if v.Field(i).Type.Kind() == reflect.Struct { - res[tag] = structToMap(field) - } else { - res[tag] = field - } - } - } - return res -} diff --git a/server/internal/library/notify/feishu/post.go b/server/internal/library/notify/feishu/post.go deleted file mode 100644 index 3e75cf7..0000000 --- a/server/internal/library/notify/feishu/post.go +++ /dev/null @@ -1,170 +0,0 @@ -package feishu - -import ( - "encoding/json" - "log" -) - -type PostMessage struct { - MsgType MsgType `json:"msg_type"` - Content PostContent `json:"content"` -} - -func NewPostMessage() *PostMessage { - return &PostMessage{} -} - -func (m *PostMessage) Body() map[string]interface{} { - m.MsgType = MsgTypePost - return structToMap(m) -} - -func (m *PostMessage) SetZH(u PostUnit) *PostMessage { - m.Content.Post.ZH = u - return m -} - -func (m *PostMessage) SetZHTitle(t string) *PostMessage { - m.Content.Post.ZH.Title = t - return m -} - -func (m *PostMessage) AppendZHContent(i []PostItem) *PostMessage { - m.Content.Post.ZH.Content = append(m.Content.Post.ZH.Content, i) - return m -} - -func (m *PostMessage) SetJA(u PostUnit) *PostMessage { - m.Content.Post.JA = u - return m -} - -func (m *PostMessage) SetJATitle(t string) *PostMessage { - m.Content.Post.JA.Title = t - return m -} - -func (m *PostMessage) AppendJAContent(i []PostItem) *PostMessage { - m.Content.Post.JA.Content = append(m.Content.Post.JA.Content, i) - return m -} - -func (m *PostMessage) SetEN(u PostUnit) *PostMessage { - m.Content.Post.EN = u - return m -} - -func (m *PostMessage) SetENTitle(t string) *PostMessage { - m.Content.Post.EN.Title = t - return m -} - -func (m *PostMessage) AppendENContent(i []PostItem) *PostMessage { - m.Content.Post.EN.Content = append(m.Content.Post.EN.Content, i) - return m -} - -type PostContent struct { - Post PostBody `json:"post"` -} - -type PostBody struct { - ZH PostUnit `json:"zh_cn,omitempty"` - JA PostUnit `json:"ja_jp,omitempty"` - EN PostUnit `json:"en_us,omitempty"` -} - -type PostUnit struct { - Title string `json:"title,omitempty"` - Content [][]PostItem `json:"content"` -} - -type PostItem interface{} - -type Text struct { - Tag string `json:"tag"` - Text string `json:"text"` - UnEscape bool `json:"un_escape,omitempty"` -} - -func NewText(text string) Text { - t := Text{ - Tag: "text", - Text: text, - } - return t -} - -type A struct { - Tag string `json:"tag"` - Text string `json:"text"` - Href string `json:"href"` - UnEscape bool `json:"un_escape,omitempty"` -} - -func NewA(text, href string) A { - t := A{ - Tag: "a", - Text: text, - Href: href, - } - return t -} - -type AT struct { - Tag string `json:"tag"` - UserID string `json:"user_id"` -} - -func NewAT(userID string) AT { - t := AT{ - Tag: "at", - UserID: userID, - } - return t -} - -type Image struct { - Tag string `json:"tag"` - ImageKey string `json:"image_key"` - Height int `json:"height"` - Width int `json:"width"` -} - -func NewImage(imageKey string, height, width int) Image { - t := Image{ - Tag: "image", - ImageKey: imageKey, - Height: height, - Width: width, - } - return t -} - -type PostCMDMessage struct { - MsgType MsgType `json:"msg_type"` - Content PostCMDContent `json:"content"` -} - -func (m *PostCMDMessage) Body() map[string]interface{} { - m.MsgType = MsgTypePost - return structToMap(m) -} - -type PostCMDContent struct { - Post map[string]interface{} `json:"post"` -} - -func NewPostCMDMessage() *PostCMDMessage { - return &PostCMDMessage{} -} - -func (m *PostCMDMessage) SetPost(post string) *PostCMDMessage { - var result map[string]interface{} - err := json.Unmarshal([]byte(post), &result) - if err != nil { - log.Print("SetPost err: ", err) - } - m.Content.Post = result - return m -} diff --git a/server/internal/library/notify/feishu/sharechat.go b/server/internal/library/notify/feishu/sharechat.go deleted file mode 100644 index 55ed165..0000000 --- a/server/internal/library/notify/feishu/sharechat.go +++ /dev/null @@ -1,24 +0,0 @@ -package feishu - -type ShareChatMessage struct { - MsgType MsgType `json:"msg_type"` - Content ShareChatContent `json:"content"` -} - -type ShareChatContent struct { - ShareChatID string `json:"share_chat_id"` -} - -func (m *ShareChatMessage) Body() map[string]interface{} { - m.MsgType = MsgTypeShareChat - return structToMap(m) -} - -func NewShareChatMessage() *ShareChatMessage { - return &ShareChatMessage{} -} - -func (m *ShareChatMessage) SetShareChatID(id string) *ShareChatMessage { - m.Content.ShareChatID = id - return m -} diff --git a/server/internal/library/notify/feishu/text.go b/server/internal/library/notify/feishu/text.go deleted file mode 100644 index 811562f..0000000 --- a/server/internal/library/notify/feishu/text.go +++ /dev/null @@ -1,24 +0,0 @@ -package feishu - -type TextMessage struct { - MsgType MsgType `json:"msg_type"` - Content Content `json:"content"` -} - -type Content struct { - Text string `json:"text"` -} - -func (m *TextMessage) Body() map[string]interface{} { - m.MsgType = MsgTypeText - return structToMap(m) -} - -func NewTextMessage() *TextMessage { - return &TextMessage{} -} - -func (m *TextMessage) SetText(text string) *TextMessage { - m.Content.Text = text - return m -} diff --git a/server/internal/library/payment/alipay/handle.go b/server/internal/library/payment/alipay/handle.go index 045321a..627e004 100644 --- a/server/internal/library/payment/alipay/handle.go +++ b/server/internal/library/payment/alipay/handle.go @@ -1,3 +1,8 @@ +// Package alipay +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package alipay import ( diff --git a/server/internal/library/payment/alipay/model.go b/server/internal/library/payment/alipay/model.go index f98814f..c5f8a73 100644 --- a/server/internal/library/payment/alipay/model.go +++ b/server/internal/library/payment/alipay/model.go @@ -1,3 +1,8 @@ +// Package alipay +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package alipay import "github.com/gogf/gf/v2/os/gtime" diff --git a/server/internal/library/payment/config.go b/server/internal/library/payment/config.go index 169098c..e3c3fd1 100644 --- a/server/internal/library/payment/config.go +++ b/server/internal/library/payment/config.go @@ -1,3 +1,8 @@ +// Package payment +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package payment import "hotgo/internal/model" diff --git a/server/internal/library/payment/notifycall.go b/server/internal/library/payment/notifycall.go index 975ce87..3e90225 100644 --- a/server/internal/library/payment/notifycall.go +++ b/server/internal/library/payment/notifycall.go @@ -1,3 +1,8 @@ +// Package payment +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package payment import ( diff --git a/server/internal/library/payment/payment.go b/server/internal/library/payment/payment.go index 94d85d1..792dcd4 100644 --- a/server/internal/library/payment/payment.go +++ b/server/internal/library/payment/payment.go @@ -1,3 +1,8 @@ +// Package payment +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package payment import ( diff --git a/server/internal/library/payment/qqpay/handle.go b/server/internal/library/payment/qqpay/handle.go index ccb1d74..d853cd5 100644 --- a/server/internal/library/payment/qqpay/handle.go +++ b/server/internal/library/payment/qqpay/handle.go @@ -1,3 +1,8 @@ +// Package qqpay +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package qqpay import ( diff --git a/server/internal/library/payment/qqpay/model.go b/server/internal/library/payment/qqpay/model.go index bd433f5..1f01836 100644 --- a/server/internal/library/payment/qqpay/model.go +++ b/server/internal/library/payment/qqpay/model.go @@ -1,3 +1,8 @@ +// Package qqpay +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package qqpay // NotifyRequest QQ支付异步通知参数 diff --git a/server/internal/library/payment/wxpay/handle.go b/server/internal/library/payment/wxpay/handle.go index ee199e6..367d6af 100644 --- a/server/internal/library/payment/wxpay/handle.go +++ b/server/internal/library/payment/wxpay/handle.go @@ -1,3 +1,8 @@ +// Package wxpay +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package wxpay import ( diff --git a/server/internal/library/payment/wxpay/model.go b/server/internal/library/payment/wxpay/model.go index e024b05..1ba3471 100644 --- a/server/internal/library/payment/wxpay/model.go +++ b/server/internal/library/payment/wxpay/model.go @@ -1 +1,6 @@ +// Package wxpay +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package wxpay diff --git a/server/internal/library/queue/consumer.go b/server/internal/library/queue/consumer.go index ca6b84f..3955b00 100644 --- a/server/internal/library/queue/consumer.go +++ b/server/internal/library/queue/consumer.go @@ -1,3 +1,8 @@ +// Package queue +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package queue import ( diff --git a/server/internal/library/queue/disk.go b/server/internal/library/queue/disk.go index 9371eb3..7102af9 100644 --- a/server/internal/library/queue/disk.go +++ b/server/internal/library/queue/disk.go @@ -1,3 +1,8 @@ +// Package queue +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package queue import ( diff --git a/server/internal/library/queue/disk/disk.go b/server/internal/library/queue/disk/disk.go index 0ee3bac..770f42f 100644 --- a/server/internal/library/queue/disk/disk.go +++ b/server/internal/library/queue/disk/disk.go @@ -1,3 +1,8 @@ +// Package disk +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package disk import ( diff --git a/server/internal/library/queue/disk/reader.go b/server/internal/library/queue/disk/reader.go index a4c77c3..3556d35 100644 --- a/server/internal/library/queue/disk/reader.go +++ b/server/internal/library/queue/disk/reader.go @@ -1,3 +1,8 @@ +// Package disk +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package disk import ( diff --git a/server/internal/library/queue/disk/writer.go b/server/internal/library/queue/disk/writer.go index 64a3f12..fb27a52 100644 --- a/server/internal/library/queue/disk/writer.go +++ b/server/internal/library/queue/disk/writer.go @@ -1,3 +1,8 @@ +// Package disk +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package disk import ( diff --git a/server/internal/library/queue/producer.go b/server/internal/library/queue/producer.go index 5bc44a0..6e60e81 100644 --- a/server/internal/library/queue/producer.go +++ b/server/internal/library/queue/producer.go @@ -1,3 +1,8 @@ +// Package queue +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package queue import ( diff --git a/server/internal/library/queue/redismq.go b/server/internal/library/queue/redismq.go index 55aa953..2493d49 100644 --- a/server/internal/library/queue/redismq.go +++ b/server/internal/library/queue/redismq.go @@ -1,3 +1,8 @@ +// Package queue +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package queue import ( diff --git a/server/internal/library/sms/config.go b/server/internal/library/sms/config.go index bd5a958..6118345 100644 --- a/server/internal/library/sms/config.go +++ b/server/internal/library/sms/config.go @@ -1,3 +1,8 @@ +// Package sms +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package sms import ( diff --git a/server/internal/library/sms/sms.go b/server/internal/library/sms/sms.go index 985c532..4276efe 100644 --- a/server/internal/library/sms/sms.go +++ b/server/internal/library/sms/sms.go @@ -1,3 +1,8 @@ +// Package sms +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package sms import ( diff --git a/server/internal/library/sms/sms_aliyun.go b/server/internal/library/sms/sms_aliyun.go index 566932b..3de288f 100644 --- a/server/internal/library/sms/sms_aliyun.go +++ b/server/internal/library/sms/sms_aliyun.go @@ -1,3 +1,8 @@ +// Package sms +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package sms import ( diff --git a/server/internal/library/sms/sms_tencent.go b/server/internal/library/sms/sms_tencent.go index 91d359b..90c52bb 100644 --- a/server/internal/library/sms/sms_tencent.go +++ b/server/internal/library/sms/sms_tencent.go @@ -1,3 +1,8 @@ +// Package sms +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package sms import ( diff --git a/server/internal/library/storager/config.go b/server/internal/library/storager/config.go index 0314161..9687818 100644 --- a/server/internal/library/storager/config.go +++ b/server/internal/library/storager/config.go @@ -1,3 +1,8 @@ +// Package storager +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package storager import ( diff --git a/server/internal/library/storager/model.go b/server/internal/library/storager/model.go index 8331d75..4b38fec 100644 --- a/server/internal/library/storager/model.go +++ b/server/internal/library/storager/model.go @@ -1,3 +1,8 @@ +// Package storager +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package storager // FileMeta 文件元数据 diff --git a/server/internal/library/storager/upload.go b/server/internal/library/storager/upload.go index 7affbfb..d3cfae1 100644 --- a/server/internal/library/storager/upload.go +++ b/server/internal/library/storager/upload.go @@ -1,3 +1,8 @@ +// Package storager +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package storager import ( diff --git a/server/internal/library/storager/upload_cos.go b/server/internal/library/storager/upload_cos.go index 2a25e73..c62fec5 100644 --- a/server/internal/library/storager/upload_cos.go +++ b/server/internal/library/storager/upload_cos.go @@ -1,3 +1,8 @@ +// Package storager +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package storager import ( diff --git a/server/internal/library/storager/upload_local.go b/server/internal/library/storager/upload_local.go index 8c57022..0153124 100644 --- a/server/internal/library/storager/upload_local.go +++ b/server/internal/library/storager/upload_local.go @@ -1,3 +1,8 @@ +// Package storager +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package storager import ( diff --git a/server/internal/library/storager/upload_oss.go b/server/internal/library/storager/upload_oss.go index 8011fe7..c111313 100644 --- a/server/internal/library/storager/upload_oss.go +++ b/server/internal/library/storager/upload_oss.go @@ -1,3 +1,8 @@ +// Package storager +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package storager import ( diff --git a/server/internal/library/storager/upload_qiniu.go b/server/internal/library/storager/upload_qiniu.go index 5eedde6..3ab7c78 100644 --- a/server/internal/library/storager/upload_qiniu.go +++ b/server/internal/library/storager/upload_qiniu.go @@ -1,3 +1,8 @@ +// Package storager +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package storager import ( diff --git a/server/internal/library/storager/upload_ucloud.go b/server/internal/library/storager/upload_ucloud.go index e91ebe7..f227816 100644 --- a/server/internal/library/storager/upload_ucloud.go +++ b/server/internal/library/storager/upload_ucloud.go @@ -1,3 +1,8 @@ +// Package storager +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package storager import ( diff --git a/server/internal/library/token/token.go b/server/internal/library/token/token.go index 7356763..35cc70f 100644 --- a/server/internal/library/token/token.go +++ b/server/internal/library/token/token.go @@ -1,3 +1,8 @@ +// Package token +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package token import ( diff --git a/server/internal/library/wechat/cache.go b/server/internal/library/wechat/cache.go index 84741b7..41c5ff3 100644 --- a/server/internal/library/wechat/cache.go +++ b/server/internal/library/wechat/cache.go @@ -1,3 +1,8 @@ +// Package wechat +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package wechat import ( diff --git a/server/internal/library/wechat/config.go b/server/internal/library/wechat/config.go index 2334e95..eda8f1e 100644 --- a/server/internal/library/wechat/config.go +++ b/server/internal/library/wechat/config.go @@ -1,3 +1,8 @@ +// Package wechat +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package wechat import "hotgo/internal/model" diff --git a/server/internal/library/wechat/wechat.go b/server/internal/library/wechat/wechat.go index 595b8cc..fde0c35 100644 --- a/server/internal/library/wechat/wechat.go +++ b/server/internal/library/wechat/wechat.go @@ -1,3 +1,8 @@ +// Package wechat +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package wechat import ( diff --git a/server/internal/logic/admin/member.go b/server/internal/logic/admin/member.go index eae598a..d9dd4a7 100644 --- a/server/internal/logic/admin/member.go +++ b/server/internal/logic/admin/member.go @@ -521,7 +521,7 @@ func (s *sAdminMember) Edit(ctx context.Context, in *adminin.MemberEditInp) (err } // 更新岗位 - if err = dao.AdminMemberPost.UpdatePostIds(ctx, in.Id, in.PostIds); err != nil { + if err = service.AdminMemberPost().UpdatePostIds(ctx, in.Id, in.PostIds); err != nil { err = gerror.Wrap(err, "更新用户岗位失败,请稍后重试!") } @@ -557,7 +557,7 @@ func (s *sAdminMember) Edit(ctx context.Context, in *adminin.MemberEditInp) (err } // 更新岗位 - if err = dao.AdminMemberPost.UpdatePostIds(ctx, id, in.PostIds); err != nil { + if err = service.AdminMemberPost().UpdatePostIds(ctx, id, in.PostIds); err != nil { err = gerror.Wrap(err, "新增用户岗位失败,请稍后重试!") } diff --git a/server/internal/logic/admin/site.go b/server/internal/logic/admin/site.go index b9221d2..3b89b2d 100644 --- a/server/internal/logic/admin/site.go +++ b/server/internal/logic/admin/site.go @@ -132,7 +132,7 @@ func (s *sAdminSite) Register(ctx context.Context, in *adminin.RegisterInp) (err } // 更新岗位 - if err = dao.AdminMemberPost.UpdatePostIds(ctx, id, config.PostIds); err != nil { + if err = service.AdminMemberPost().UpdatePostIds(ctx, id, config.PostIds); err != nil { err = gerror.Wrap(err, consts.ErrorORM) } return diff --git a/server/internal/logic/sys/cron.go b/server/internal/logic/sys/cron.go index a0cb559..e88657f 100644 --- a/server/internal/logic/sys/cron.go +++ b/server/internal/logic/sys/cron.go @@ -183,11 +183,22 @@ func (s *sSysCron) List(ctx context.Context, in *sysin.CronListInp) (list []*sys } for _, v := range list { - v.GroupName, _ = dao.SysCronGroup.GetName(ctx, v.GroupId) + v.GroupName, _ = s.GetName(ctx, v.GroupId) } return } +// GetName 获取分组名称 +func (s *sSysCron) GetName(ctx context.Context, id int64) (name string, err error) { + m := dao.SysCronGroup.Ctx(ctx).Fields("name").Where("id", id) + list, err := m.Value() + if err != nil { + err = gerror.Wrap(err, consts.ErrorORM) + return name, err + } + return list.String(), nil +} + // OnlineExec 在线执行 func (s *sSysCron) OnlineExec(ctx context.Context, in *sysin.OnlineExecInp) (err error) { var data *entity.SysCron diff --git a/server/internal/logic/sys/dict_data.go b/server/internal/logic/sys/dict_data.go index 4bfeecf..f881f23 100644 --- a/server/internal/logic/sys/dict_data.go +++ b/server/internal/logic/sys/dict_data.go @@ -8,6 +8,7 @@ package sys import ( "context" "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" "hotgo/internal/consts" "hotgo/internal/dao" "hotgo/internal/model/input/sysin" @@ -47,7 +48,7 @@ func (s *sSysDictData) Edit(ctx context.Context, in *sysin.DictDataEditInp) (err } // 新增 - in.Type, err = dao.SysDictType.GetType(ctx, in.TypeID) + in.Type, err = s.GetType(ctx, in.TypeID) if err != nil { err = gerror.Wrap(err, consts.ErrorORM) return err @@ -70,7 +71,7 @@ func (s *sSysDictData) List(ctx context.Context, in *sysin.DictDataListInp) (lis mod := dao.SysDictData.Ctx(ctx) // 类型ID if in.TypeID > 0 { - types, err := dao.SysDictType.GetTypes(ctx, in.TypeID) + types, err := s.GetTypes(ctx, in.TypeID) if err != nil { return list, totalCount, err } @@ -107,11 +108,42 @@ func (s *sSysDictData) List(ctx context.Context, in *sysin.DictDataListInp) (lis } for _, v := range list { - v.TypeID, _ = dao.SysDictType.GetId(ctx, v.Type) + v.TypeID, _ = s.GetId(ctx, v.Type) } return list, totalCount, err } +// GetId 获取指定类型的ID +func (s *sSysDictData) GetId(ctx context.Context, t string) (id int64, err error) { + m := dao.SysDictType.Ctx(ctx).Fields("id").Where("type", t).Where("status", consts.StatusEnabled) + val, err := m.Value() + if err != nil { + err = gerror.Wrap(err, consts.ErrorORM) + return 0, err + } + return val.Int64(), nil +} + +// GetType 获取指定ID的类型标识 +func (s *sSysDictData) GetType(ctx context.Context, id int64) (types string, err error) { + m := dao.SysDictType.Ctx(ctx).Fields("type").Where("id", id).Where("status", consts.StatusEnabled) + val, err := m.Value() + if err != nil { + err = gerror.Wrap(err, consts.ErrorORM) + return types, err + } + return val.String(), nil +} + +// GetTypes 获取指定ID的所有类型标识,包含下级 +func (s *sSysDictData) GetTypes(ctx context.Context, id int64) (types []string, err error) { + columns, err := dao.SysDictType.Ctx(ctx).Fields("type"). + Where("id", id).WhereOr("pid", id).Where("status", consts.StatusEnabled). + Array() + types = g.NewVar(columns).Strings() + return +} + // Select 获取列表 func (s *sSysDictData) Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error) { mod := dao.SysDictData.Ctx(ctx).Where("type", in.Type) diff --git a/server/internal/logic/sys/ems_log.go b/server/internal/logic/sys/ems_log.go index 733d479..cafa2eb 100644 --- a/server/internal/logic/sys/ems_log.go +++ b/server/internal/logic/sys/ems_log.go @@ -335,7 +335,7 @@ func (s *sSysEmsLog) AllowSend(ctx context.Context, models *entity.SysEmsLog, co } if config.MaxIpLimit > 0 { - count, err := dao.SysEmsLog.NowDayCount(ctx, models.Event, models.Email) + count, err := s.NowDayCount(ctx, models.Event, models.Email) if err != nil { return err } @@ -348,6 +348,15 @@ func (s *sSysEmsLog) AllowSend(ctx context.Context, models *entity.SysEmsLog, co return } +// NowDayCount 当天发送次数 +func (s *sSysEmsLog) NowDayCount(ctx context.Context, event, email string) (count int, err error) { + return dao.SysEmsLog.Ctx(ctx). + Where("email", email). + Where("event", event). + WhereGTE("created_at", gtime.Now().Format("Y-m-d")). + Count() +} + // VerifyCode 效验验证码 func (s *sSysEmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) (err error) { if in.Event == "" { diff --git a/server/internal/logic/sys/sms_log.go b/server/internal/logic/sys/sms_log.go index 2e17531..f363ace 100644 --- a/server/internal/logic/sys/sms_log.go +++ b/server/internal/logic/sys/sms_log.go @@ -245,7 +245,7 @@ func (s *sSysSmsLog) AllowSend(ctx context.Context, models *entity.SysSmsLog, co } if config.SmsMaxIpLimit > 0 { - count, err := dao.SysSmsLog.NowDayCount(ctx, models.Event, models.Mobile) + count, err := s.NowDayCount(ctx, models.Event, models.Mobile) if err != nil { return err } @@ -258,6 +258,15 @@ func (s *sSysSmsLog) AllowSend(ctx context.Context, models *entity.SysSmsLog, co return } +// NowDayCount 当天发送次数 +func (s *sSysSmsLog) NowDayCount(ctx context.Context, event, mobile string) (count int, err error) { + return dao.SysSmsLog.Ctx(ctx). + Where("mobile", mobile). + Where("event", event). + WhereGTE("created_at", gtime.Now().Format("Y-m-d")). + Count() +} + // VerifyCode 效验验证码 func (s *sSysSmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (err error) { if in.Event == "" { diff --git a/server/internal/model/config.go b/server/internal/model/config.go index 53f5571..c6e8cbc 100644 --- a/server/internal/model/config.go +++ b/server/internal/model/config.go @@ -1,3 +1,8 @@ +// Package model +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package model // 后台配置. diff --git a/server/internal/model/config_load.go b/server/internal/model/config_load.go index c22e44f..2d65faf 100644 --- a/server/internal/model/config_load.go +++ b/server/internal/model/config_load.go @@ -1,3 +1,8 @@ +// Package model +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package model // 本地配置. diff --git a/server/internal/model/gen_codes.go b/server/internal/model/gen_codes.go index 7e38c3e..881f1e1 100644 --- a/server/internal/model/gen_codes.go +++ b/server/internal/model/gen_codes.go @@ -1,3 +1,8 @@ +// Package model +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package model // GenCodesColumn 生成表字段属性 diff --git a/server/internal/model/input/form/page.go b/server/internal/model/input/form/page.go index a5ed967..93f7af3 100644 --- a/server/internal/model/input/form/page.go +++ b/server/internal/model/input/form/page.go @@ -1,3 +1,8 @@ +// Package form +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package form import ( diff --git a/server/internal/model/input/form/select.go b/server/internal/model/input/form/select.go index 0a07d3a..8a9b9ad 100644 --- a/server/internal/model/input/form/select.go +++ b/server/internal/model/input/form/select.go @@ -1,3 +1,8 @@ +// Package form +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package form import "github.com/gogf/gf/v2/util/gconv" diff --git a/server/internal/model/input/payin/general.go b/server/internal/model/input/payin/general.go index 86c40ea..9293fcd 100644 --- a/server/internal/model/input/payin/general.go +++ b/server/internal/model/input/payin/general.go @@ -1,3 +1,8 @@ +// Package payin +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package payin import ( diff --git a/server/internal/model/input/servmsgin/auth.go b/server/internal/model/input/servmsgin/auth.go index 05295cc..5dab41f 100644 --- a/server/internal/model/input/servmsgin/auth.go +++ b/server/internal/model/input/servmsgin/auth.go @@ -1,3 +1,8 @@ +// Package servmsgin +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package servmsgin import "github.com/gogf/gf/v2/os/gtime" diff --git a/server/internal/model/input/servmsgin/example.go b/server/internal/model/input/servmsgin/example.go index e064025..e91054d 100644 --- a/server/internal/model/input/servmsgin/example.go +++ b/server/internal/model/input/servmsgin/example.go @@ -1,3 +1,8 @@ +// Package servmsgin +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package servmsgin import "github.com/gogf/gf/v2/os/gtime" diff --git a/server/utility/convert/match.go b/server/utility/convert/match.go index a5224b5..edb4bf0 100644 --- a/server/utility/convert/match.go +++ b/server/utility/convert/match.go @@ -1,3 +1,8 @@ +// Package convert +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package convert import ( diff --git a/server/utility/simple/event.go b/server/utility/simple/event.go index 0822822..39d04ab 100644 --- a/server/utility/simple/event.go +++ b/server/utility/simple/event.go @@ -1,3 +1,8 @@ +// Package simple +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package simple import ( diff --git a/server/utility/url/url.go b/server/utility/url/url.go index 87cd3fc..4d979e1 100644 --- a/server/utility/url/url.go +++ b/server/utility/url/url.go @@ -1,3 +1,8 @@ +// Package url +// @Link https://github.com/bufanyun/hotgo +// @Copyright Copyright (c) 2023 HotGo CLI +// @Author Ms <133814250@qq.com> +// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE package url import ( diff --git a/web/src/views/monitor/netconn/index.vue b/web/src/views/monitor/netconn/index.vue index 1733b52..bec7499 100644 --- a/web/src/views/monitor/netconn/index.vue +++ b/web/src/views/monitor/netconn/index.vue @@ -56,7 +56,7 @@ import GroupModal from './modal/modal.vue'; import Edit from '@/views/monitor/netconn/modal/edit.vue'; import { newState, options, State } from '@/views/monitor/netconn/modal/model'; - import { defRangeShortcuts } from "@/utils/dateUtil"; + import { defRangeShortcuts } from '@/utils/dateUtil'; const message = useMessage(); const dialog = useDialog(); diff --git a/web/src/views/monitor/serve-monitor/index.vue b/web/src/views/monitor/serve-monitor/index.vue index 1093a46..d1c17bf 100644 --- a/web/src/views/monitor/serve-monitor/index.vue +++ b/web/src/views/monitor/serve-monitor/index.vue @@ -93,7 +93,7 @@ import DataItem from './components/DataItem.vue'; import LoadChart from './components/chart/LoadChart.vue'; import FullYearSalesChart from './components/chart/FullYearSalesChart.vue'; - import { defineComponent, inject, onMounted, ref, onUpdated } from 'vue'; + import { defineComponent, inject, onMounted, ref, onUnmounted } from 'vue'; import { SocketEnum } from '@/enums/socketEnum'; import { addOnMessage, sendMsg } from '@/utils/websocket'; import { formatBefore } from '@/utils/dateUtil'; @@ -107,6 +107,7 @@ FullYearSalesChart, }, setup() { + const timer = ref(0); const dataRunInfo = ref({ arch: '', goMem: '0MB', @@ -180,7 +181,7 @@ const fullYearSalesChartRef = ref>(); const onMessageList = inject('onMessageList'); - const onAdminMonitor = (res) => { + const onAdminMonitor = (res: { data: string }) => { const data = JSON.parse(res.data); if (data.event === SocketEnum.EventAdminMonitorRunInfo) { loading.value = false; @@ -207,7 +208,14 @@ addOnMessage(onMessageList, onAdminMonitor); onMounted(() => { - getInfo(); + loading.value = true; + sendMsg(SocketEnum.EventAdminMonitorTrends); + sendMsg(SocketEnum.EventAdminMonitorRunInfo); + + timer.value = window.setInterval(function () { + sendMsg(SocketEnum.EventAdminMonitorTrends); + sendMsg(SocketEnum.EventAdminMonitorRunInfo); + }, 2000); setTimeout(() => { if (loading.value) { @@ -221,28 +229,10 @@ }, 5000); }); - onUpdated(() => { - // 切换页面后直接出发一次 - if (loading.value === false) { - sendMsg(SocketEnum.EventAdminMonitorTrends); - sendMsg(SocketEnum.EventAdminMonitorRunInfo); - } + onUnmounted(() => { + window.clearInterval(timer.value); }); - function getInfo() { - loading.value = true; - sendMsg(SocketEnum.EventAdminMonitorTrends); - sendMsg(SocketEnum.EventAdminMonitorRunInfo); - - setInterval(function () { - sendMsg(SocketEnum.EventAdminMonitorTrends); - }, 1000 * 2); - - setInterval(function () { - sendMsg(SocketEnum.EventAdminMonitorRunInfo); - }, 1000 * 10); - } - return { loading, collapse,