模块化定时任务,方便在插件中注册任务;增加日志分组

This commit is contained in:
孟帅
2023-06-05 20:14:57 +08:00
parent 62ecbb7f26
commit 48f8c20d9c
79 changed files with 820 additions and 783 deletions

View File

@@ -99,17 +99,14 @@ func Cz88Find(ctx context.Context, ip string) (*IpLocationData, error) {
if detail == nil {
return nil, fmt.Errorf("no ip data is queried. procedure:%v", ip)
}
locationData := &IpLocationData{
return &IpLocationData{
Ip: ip,
Country: detail.Country,
Region: detail.Region,
Province: detail.Province,
City: detail.City,
Area: detail.County,
}
return locationData, nil
}, nil
}
// IsJurisByIpTitle 判断地区名称是否为直辖市

View File

@@ -8,6 +8,7 @@ package location
import (
"context"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/consts"
@@ -15,6 +16,10 @@ import (
"hotgo/utility/tree"
)
func GetModel(ctx context.Context) *gdb.Model {
return g.Model("sys_provinces").Ctx(ctx)
}
// ParseSimpleRegion 通过地区ID解析地区名称自动加入上级地区
func ParseSimpleRegion(ctx context.Context, id int64, spilt ...string) (string, error) {
if id == 0 {
@@ -25,7 +30,7 @@ func ParseSimpleRegion(ctx context.Context, id int64, spilt ...string) (string,
err error
)
if err = g.Model("sys_provinces").Ctx(ctx).Fields("title,level,tree").Where("id", id).Scan(&models); err != nil {
if err = GetModel(ctx).Fields("title,level,tree").Where("id", id).Scan(&models); err != nil {
return "", err
}
@@ -71,14 +76,14 @@ func ParseRegion(ctx context.Context, province int64, city int64, county int64,
}
if province > 0 && province < 999999 {
provinceName, err = g.Model("sys_provinces").Ctx(ctx).Where("id", province).Fields("title").Value()
provinceName, err = GetModel(ctx).Where("id", province).Fields("title").Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return "", err
}
if city > 0 {
cityName, err = g.Model("sys_provinces").Ctx(ctx).Where("id", city).Fields("title").Value()
cityName, err = GetModel(ctx).Where("id", city).Fields("title").Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return "", err
@@ -86,7 +91,7 @@ func ParseRegion(ctx context.Context, province int64, city int64, county int64,
}
if county > 0 {
countyName, err = g.Model("sys_provinces").Ctx(ctx).Where("id", county).Fields("title").Value()
countyName, err = GetModel(ctx).Where("id", county).Fields("title").Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return "", err