mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 05:12:32 +08:00
优化服务监控定时器,移除notify
功能包
This commit is contained in:
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -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 == "" {
|
||||
|
@@ -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 == "" {
|
||||
|
Reference in New Issue
Block a user