feat: 为应用版本查询增加appCode参数支持
新增应用版本类型的AppCode字段,修改相关接口和实现以支持通过appCode查询指定应用的最新版本,增加appCode合法性校验,完善缓存键以区分不同应用的版本信息
This commit is contained in:
@@ -171,7 +171,7 @@ type AdminInternalConfigProvider interface {
|
||||
ListActiveTenants(limit int) ([]types.Tenant, error)
|
||||
RegistrationSMSEnabled() (bool, error)
|
||||
ThirdPartyConfig(group string, keys ...string) (map[string]string, error)
|
||||
LatestAppRelease(platform, channel string) (*types.AppRelease, error)
|
||||
LatestAppRelease(appCode, platform, channel string) (*types.AppRelease, error)
|
||||
ModerationProvider() (*types.ModerationProviderConfig, error)
|
||||
ModerationPolicy(tenantCode string) (*types.ModerationPolicy, error)
|
||||
SensitiveWords(tenantCode string) (*types.SensitiveWordSet, error)
|
||||
@@ -2654,20 +2654,21 @@ type profileMapper struct{}
|
||||
var Profiles ProfilePersistenceInterface
|
||||
|
||||
type AppReleasePersistenceInterface interface {
|
||||
Latest(platform, channel string) (*types.AppRelease, error)
|
||||
Latest(appCode, platform, channel string) (*types.AppRelease, error)
|
||||
}
|
||||
|
||||
type appReleaseMapper struct{}
|
||||
|
||||
var AppReleases AppReleasePersistenceInterface
|
||||
|
||||
func (appReleaseMapper) Latest(platform, channel string) (*types.AppRelease, error) {
|
||||
func (appReleaseMapper) Latest(appCode, platform, channel string) (*types.AppRelease, error) {
|
||||
platform = strings.ToLower(strings.TrimSpace(platform))
|
||||
channel = strings.ToLower(strings.TrimSpace(channel))
|
||||
if platform == "" || channel == "" {
|
||||
appCode = strings.ToLower(strings.TrimSpace(appCode))
|
||||
if platform == "" || channel == "" || appCode == "" {
|
||||
return nil, types.ErrMalformed
|
||||
}
|
||||
cacheKey := platform + ":" + channel
|
||||
cacheKey := appCode + ":" + platform + ":" + channel
|
||||
if cached, ok := appReleaseConfigCache.get(cacheKey); ok {
|
||||
copy := *cached
|
||||
return ©, nil
|
||||
@@ -2675,7 +2676,7 @@ func (appReleaseMapper) Latest(platform, channel string) (*types.AppRelease, err
|
||||
if adminInternalConfigProvider == nil {
|
||||
return nil, types.ErrUnsupported
|
||||
}
|
||||
release, err := adminInternalConfigProvider.LatestAppRelease(platform, channel)
|
||||
release, err := adminInternalConfigProvider.LatestAppRelease(appCode, platform, channel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ type UserPrivacyPatch struct {
|
||||
|
||||
type AppRelease struct {
|
||||
ID int64
|
||||
AppCode string
|
||||
Platform string
|
||||
Channel string
|
||||
LatestVersion string
|
||||
|
||||
Reference in New Issue
Block a user