chore: seed migration objects batch 5
This commit is contained in:
@@ -6,10 +6,10 @@ import (
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/imtenant"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/service"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
@@ -39,7 +39,7 @@ func (c *cConfig) TenantList(ctx context.Context, req *api.TenantListReq) (res *
|
||||
if limit <= 0 || limit > 1000 {
|
||||
limit = 1000
|
||||
}
|
||||
mod := imtenant.RegistryDB(ctx).Model(dao.ImTenant.Table()).Safe().Ctx(ctx).Limit(limit)
|
||||
mod := imtenant.RegistryDB().Model(dao.ImTenant.Table()).Safe().Ctx(ctx).Limit(limit)
|
||||
if req.State != "" {
|
||||
if req.State == "active" {
|
||||
mod = mod.Where(dao.ImTenant.Columns().State, 1)
|
||||
@@ -59,7 +59,7 @@ func (c *cConfig) TenantList(ctx context.Context, req *api.TenantListReq) (res *
|
||||
}
|
||||
|
||||
func (c *cConfig) RegistrationSms(ctx context.Context, req *api.RegistrationSmsReq) (res *api.RegistrationSmsRes, err error) {
|
||||
var record g.Map
|
||||
var record *entity.SysConfig
|
||||
if err = dao.SysConfig.Ctx(ctx).
|
||||
Where(dao.SysConfig.Columns().Group, "im").
|
||||
Where(dao.SysConfig.Columns().Key, "register_sms_enabled").
|
||||
@@ -69,7 +69,7 @@ func (c *cConfig) RegistrationSms(ctx context.Context, req *api.RegistrationSmsR
|
||||
}
|
||||
enabled := true
|
||||
if record != nil {
|
||||
enabled = gconv.String(record[dao.SysConfig.Columns().Value]) != "0"
|
||||
enabled = gconv.String(record.Value) != "0"
|
||||
}
|
||||
return &api.RegistrationSmsRes{Enabled: enabled}, nil
|
||||
}
|
||||
@@ -91,9 +91,65 @@ func (c *cConfig) ThirdParty(ctx context.Context, req *api.ThirdPartyReq) (res *
|
||||
return &api.ThirdPartyRes{Values: values}, nil
|
||||
}
|
||||
|
||||
func (c *cConfig) TenantLoginIPWhitelist(ctx context.Context, req *api.TenantLoginIPWhitelistReq) (res *api.TenantLoginIPWhitelistRes, err error) {
|
||||
if _, err = getTenant(ctx, dao.ImTenant.Columns().Id, req.Id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data, err := service.SysImUserPolicyGroup().LoginIPWhitelistByTenant(ctx, req.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &api.TenantLoginIPWhitelistRes{TenantId: data.TenantId, AppList: data.AppList, WebList: data.WebList}, nil
|
||||
}
|
||||
|
||||
func (c *cConfig) AppReleaseLatest(ctx context.Context, req *api.AppReleaseLatestReq) (res *api.AppReleaseLatestRes, err error) {
|
||||
platform := strings.ToLower(strings.TrimSpace(req.Platform))
|
||||
channel := strings.ToLower(strings.TrimSpace(req.Channel))
|
||||
if platform != "ios" && platform != "android" {
|
||||
return nil, gerror.New("客户端平台不合法")
|
||||
}
|
||||
if channel == "" {
|
||||
channel = "stable"
|
||||
}
|
||||
if strings.ContainsAny(channel, " \t\r\n/") || len(channel) > 32 {
|
||||
return nil, gerror.New("客户端渠道不合法")
|
||||
}
|
||||
var row struct {
|
||||
ID int64 `json:"id"`
|
||||
Platform string `json:"platform"`
|
||||
Channel string `json:"channel"`
|
||||
LatestVersion string `json:"latest_version"`
|
||||
MinSupportedVersion string `json:"min_supported_version"`
|
||||
UpdateType string `json:"update_type"`
|
||||
ReleaseNotes string `json:"release_notes"`
|
||||
StoreURL string `json:"store_url"`
|
||||
PackageURL string `json:"package_url"`
|
||||
Checksum string `json:"checksum"`
|
||||
RemindAfterSeconds int `json:"remind_after_seconds"`
|
||||
PublishedAt *gtime.Time `json:"published_at"`
|
||||
CreatedAt *gtime.Time `json:"created_at"`
|
||||
UpdatedAt *gtime.Time `json:"updated_at"`
|
||||
}
|
||||
err = imtenant.RegistryDB().Model("im_app_releases").Safe().Ctx(ctx).
|
||||
Where("platform", platform).Where("channel", channel).Limit(1).Scan(&row)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrap(err, "获取IM客户端版本策略失败")
|
||||
}
|
||||
if row.ID <= 0 {
|
||||
return nil, gerror.New("IM客户端版本策略不存在")
|
||||
}
|
||||
return &api.AppReleaseLatestRes{
|
||||
ID: row.ID, Platform: row.Platform, Channel: row.Channel,
|
||||
LatestVersion: row.LatestVersion, MinSupportedVersion: row.MinSupportedVersion,
|
||||
UpdateType: row.UpdateType, ReleaseNotes: row.ReleaseNotes, StoreURL: row.StoreURL,
|
||||
PackageURL: row.PackageURL, Checksum: row.Checksum, RemindAfterSeconds: row.RemindAfterSeconds,
|
||||
PublishedAt: gtimeToRFC3339(row.PublishedAt), CreatedAt: gtimeToRFC3339(row.CreatedAt), UpdatedAt: gtimeToRFC3339(row.UpdatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getTenant(ctx context.Context, field string, value any) (*entity.ImTenant, error) {
|
||||
var tenant *entity.ImTenant
|
||||
if err := imtenant.RegistryDB(ctx).Model(dao.ImTenant.Table()).Safe().Ctx(ctx).Where(field, value).Scan(&tenant); err != nil {
|
||||
if err := imtenant.RegistryDB().Model(dao.ImTenant.Table()).Safe().Ctx(ctx).Where(field, value).Scan(&tenant); err != nil {
|
||||
return nil, gerror.Wrap(err, "获取IM租户配置失败")
|
||||
}
|
||||
if tenant == nil || tenant.Id <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user