mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 05:12:32 +08:00
This commit is contained in:
@@ -73,7 +73,7 @@ func (s *sSysAttachment) Status(ctx context.Context, in sysin.AttachmentStatusIn
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ func (s *sSysBlacklist) Status(ctx context.Context, in sysin.BlacklistStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
@@ -83,27 +83,13 @@ func (s *sSysConfig) InitConfig(ctx context.Context) {
|
||||
|
||||
}
|
||||
|
||||
// GetLoadTCP 获取本地tcp配置
|
||||
func (s *sSysConfig) GetLoadTCP(ctx context.Context) (conf *model.TCPConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "tcp").Scan(&conf)
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadCache 获取本地缓存配置
|
||||
func (s *sSysConfig) GetLoadCache(ctx context.Context) (conf *model.CacheConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "cache").Scan(&conf)
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadGenerate 获取本地生成配置
|
||||
func (s *sSysConfig) GetLoadGenerate(ctx context.Context) (conf *model.GenerateConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "hggen").Scan(&conf)
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadToken 获取本地token配置
|
||||
func (s *sSysConfig) GetLoadToken(ctx context.Context) (conf *model.TokenConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "token").Scan(&conf)
|
||||
// GetLogin 获取登录配置
|
||||
func (s *sSysConfig) GetLogin(ctx context.Context) (conf *model.LoginConfig, err error) {
|
||||
models, err := s.GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "login"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = gconv.Scan(models.List, &conf)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -182,6 +168,30 @@ func (s *sSysConfig) GetBasic(ctx context.Context) (conf *model.BasicConfig, err
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadTCP 获取本地tcp配置
|
||||
func (s *sSysConfig) GetLoadTCP(ctx context.Context) (conf *model.TCPConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "tcp").Scan(&conf)
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadCache 获取本地缓存配置
|
||||
func (s *sSysConfig) GetLoadCache(ctx context.Context) (conf *model.CacheConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "cache").Scan(&conf)
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadGenerate 获取本地生成配置
|
||||
func (s *sSysConfig) GetLoadGenerate(ctx context.Context) (conf *model.GenerateConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "hggen").Scan(&conf)
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadToken 获取本地token配置
|
||||
func (s *sSysConfig) GetLoadToken(ctx context.Context) (conf *model.TokenConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "token").Scan(&conf)
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadSSL 获取本地日志配置
|
||||
func (s *sSysConfig) GetLoadSSL(ctx context.Context) (conf *model.SSLConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "hotgo.ssl").Scan(&conf)
|
||||
|
@@ -107,7 +107,7 @@ func (s *sSysCron) Status(ctx context.Context, in sysin.CronStatusInp) (err erro
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ func (s *sSysCronGroup) Status(ctx context.Context, in sysin.CronGroupStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
@@ -180,7 +180,7 @@ func (s *sSysCurdDemo) Status(ctx context.Context, in sysin.CurdDemoStatusInp) (
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
@@ -76,7 +76,7 @@ func (s *sSysEmsLog) Status(ctx context.Context, in sysin.EmsLogStatusInp) (err
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ func (s *sSysGenCodes) Status(ctx context.Context, in sysin.GenCodesStatusInp) (
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import (
|
||||
"hotgo/internal/library/location"
|
||||
"hotgo/internal/library/queue"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/adminin"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
@@ -147,10 +148,14 @@ func (s *sSysLoginLog) View(ctx context.Context, in sysin.LoginLogViewInp) (res
|
||||
|
||||
// Push 推送登录日志
|
||||
func (s *sSysLoginLog) Push(ctx context.Context, in sysin.LoginLogPushInp) {
|
||||
g.DumpWithType(in)
|
||||
if in.Response == nil {
|
||||
in.Response = new(adminin.LoginModel)
|
||||
}
|
||||
var models entity.SysLoginLog
|
||||
models.ReqId = gctx.CtxId(ctx)
|
||||
models.MemberId = in.Response.Id
|
||||
models.Username = in.Input.Username
|
||||
models.Username = in.Response.Username
|
||||
models.LoginAt = gtime.Now()
|
||||
models.LoginIp = location.GetClientIp(ghttp.RequestFromCtx(ctx))
|
||||
models.Status = consts.StatusEnabled
|
||||
@@ -161,12 +166,12 @@ func (s *sSysLoginLog) Push(ctx context.Context, in sysin.LoginLogPushInp) {
|
||||
}
|
||||
|
||||
models.Response = gjson.New(consts.NilJsonToString)
|
||||
if in.Response != nil && in.Response.Id > 0 {
|
||||
if in.Response != nil {
|
||||
models.Response = gjson.New(in.Response)
|
||||
}
|
||||
|
||||
if err := queue.Push(consts.QueueLoginLogTopic, models); err != nil {
|
||||
g.Log().Warningf(ctx, "sSysLoginLog.Push err:%+v, models:%+v", err, models)
|
||||
g.Log().Warningf(ctx, "push err:%+v, models:%+v", err, models)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sys
|
||||
|
||||
import (
|
||||
@@ -127,7 +126,7 @@ func (s *sSysProvinces) Status(ctx context.Context, in sysin.ProvincesStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ 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"
|
||||
@@ -71,7 +70,7 @@ func (s *sSysSmsLog) Status(ctx context.Context, in sysin.SmsLogStatusInp) (err
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
@@ -180,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
|
||||
|
Reference in New Issue
Block a user