feat: 添加联系我们配置接口和字典配置缓存

1. 新增DictionaryItem字典配置结构体
2. 添加字典配置缓存及失效逻辑
3. 实现联系我们接口的业务逻辑和测试用例
4. 注册联系我们API路由
5. 集成字典配置到admin内部客户端
6. 处理字典配置更新的kafka事件
This commit is contained in:
Austin
2026-09-21 13:11:42 +08:00
parent c891afba73
commit 7829990180
8 changed files with 196 additions and 0 deletions
+33
View File
@@ -1514,6 +1514,39 @@ func serveIMAbuseReports(wrt http.ResponseWriter, req *http.Request) {
writeIMSuccess(wrt, req, abuseReportPayload(report))
}
// imContactUsDictType is the admin dictionary type backing the mobile
// "contact us" entries.
const imContactUsDictType = "im_contact_us"
func serveIMContactUs(wrt http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodGet {
writeIMError(wrt, req, http.StatusMethodNotAllowed, 30002, imReasonMethodNotAllowed, "method not allowed", nil)
return
}
if _, ok := authenticateIMHTTPBearer(wrt, req); !ok {
return
}
items, err := store.DictionaryConfig.Get(imContactUsDictType)
if err != nil {
if errors.Is(err, types.ErrUnsupported) || errors.Is(err, types.ErrNotFound) {
items = nil
} else {
writeIMError(wrt, req, http.StatusInternalServerError, 90000, imReasonInternal, "internal error", nil)
return
}
}
payload := make([]map[string]any, 0, len(items))
for _, item := range items {
label := strings.TrimSpace(item.Label)
value := strings.TrimSpace(item.Value)
if label == "" || value == "" {
continue
}
payload = append(payload, map[string]any{"label": label, "value": value})
}
writeIMSuccess(wrt, req, map[string]any{"items": payload})
}
func serveIMFeedbackConfig(wrt http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodGet {
writeIMError(wrt, req, http.StatusMethodNotAllowed, 30002, imReasonMethodNotAllowed, "method not allowed", nil)