完善C端功能、通知明细及接口文档

This commit is contained in:
richjohnrambo
2026-10-13 01:30:21 +08:00
parent 6d6b6a0b59
commit 32c6238751
954 changed files with 793 additions and 99 deletions
+34
View File
@@ -157,6 +157,36 @@ func (a *API) customerServices(w http.ResponseWriter, r *http.Request) {
writeSuccess(w, r, items)
}
func (a *API) notices(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
methodNotAllowed(w, r, http.MethodGet)
return
}
if !a.ensurePortal(w, r) {
return
}
principal, ok := a.authenticateMember(w, r)
if !ok {
return
}
page, ok := optionalPositiveInt(w, r, "page")
if !ok {
writePortalError(w, r, portal.ErrPageInvalid)
return
}
pageSize, ok := optionalPositiveInt(w, r, "page_size")
if !ok {
writePortalError(w, r, portal.ErrPageSizeInvalid)
return
}
result, err := a.portal.Notices(r.Context(), principal.TenantID, principal.MemberID, page, pageSize)
if err != nil {
writePortalError(w, r, err)
return
}
writeSuccess(w, r, result)
}
func (a *API) ensurePortal(w http.ResponseWriter, r *http.Request) bool {
if a.portal != nil {
return true
@@ -171,6 +201,10 @@ func writePortalError(w http.ResponseWriter, r *http.Request, err error) {
writeError(w, r, http.StatusBadRequest, 30000, "BANNER_POSITION_INVALID", "validation failed", map[string]any{"field": "position"})
case errors.Is(err, portal.ErrContentKeyInvalid):
writeError(w, r, http.StatusBadRequest, 30000, "CONTENT_KEY_INVALID", "validation failed", map[string]any{"field": "content_key"})
case errors.Is(err, portal.ErrPageInvalid):
writeError(w, r, http.StatusBadRequest, 30000, "PAGE_INVALID", "validation failed", map[string]any{"field": "page"})
case errors.Is(err, portal.ErrPageSizeInvalid):
writeError(w, r, http.StatusBadRequest, 30000, "PAGE_SIZE_INVALID", "validation failed", map[string]any{"field": "page_size"})
case errors.Is(err, store.ErrResourceNotFound):
writeError(w, r, http.StatusNotFound, 30044, "RESOURCE_NOT_FOUND", "resource not found", nil)
default: