feat: 添加联系我们配置接口和字典配置缓存
1. 新增DictionaryItem字典配置结构体 2. 添加字典配置缓存及失效逻辑 3. 实现联系我们接口的业务逻辑和测试用例 4. 注册联系我们API路由 5. 集成字典配置到admin内部客户端 6. 处理字典配置更新的kafka事件
This commit is contained in:
@@ -60,6 +60,7 @@ var (
|
||||
tenantByIDCache = newConfigCache[*types.Tenant]()
|
||||
registrationSMSCache = newConfigCache[bool]()
|
||||
thirdPartyConfigCache = newConfigCache[map[string]string]()
|
||||
dictConfigCache = newConfigCache[[]types.DictionaryItem]()
|
||||
appReleaseConfigCache = newConfigCache[*types.AppRelease]()
|
||||
moderationProviderCache = newConfigCache[*types.ModerationProviderConfig]()
|
||||
moderationPolicyCache = newConfigCache[*types.ModerationPolicy]()
|
||||
@@ -174,6 +175,29 @@ func InvalidateThirdPartyConfigCache(group string) {
|
||||
thirdPartyConfigCache.mu.Unlock()
|
||||
}
|
||||
|
||||
func dictConfigCacheKey(dictType string) string {
|
||||
return strings.TrimSpace(dictType)
|
||||
}
|
||||
|
||||
func cloneDictionaryItems(src []types.DictionaryItem) []types.DictionaryItem {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
dst := make([]types.DictionaryItem, len(src))
|
||||
copy(dst, src)
|
||||
return dst
|
||||
}
|
||||
|
||||
// InvalidateDictionaryConfigCache clears cached dictionary config. An empty
|
||||
// type clears all dictionary entries.
|
||||
func InvalidateDictionaryConfigCache(dictType string) {
|
||||
if strings.TrimSpace(dictType) == "" {
|
||||
dictConfigCache.clear()
|
||||
return
|
||||
}
|
||||
dictConfigCache.delete(strings.TrimSpace(dictType))
|
||||
}
|
||||
|
||||
func formatTenantIDForCache(id types.TenantID) string {
|
||||
return strconv.FormatInt(int64(id), 10)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user