mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 05:12:32 +08:00
代码规范过滤,移除冗余代码,替换掉不推荐的包
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user