fix: harden platform response projections

This commit is contained in:
2026-07-27 10:42:16 +08:00
parent 7ebe25fe34
commit a545559fa8
4 changed files with 195 additions and 29 deletions

View File

@@ -47,7 +47,12 @@ func listPage[T any](ctx *gin.Context) {
infra.Response.Error(ctx, err)
return
}
infra.Response.Success(ctx, gin.H{"total": total, "list": publicResourceResponse(list)})
response, err := publicResourceResponse(list)
if err != nil {
infra.Response.Error(ctx, err)
return
}
infra.Response.Success(ctx, gin.H{"total": total, "list": response})
}
func getByIdentity[T any](ctx *gin.Context) {
@@ -56,7 +61,12 @@ func getByIdentity[T any](ctx *gin.Context) {
respondRecordError(ctx, err)
return
}
infra.Response.Success(ctx, publicResourceResponse(data))
response, err := publicResourceResponse(data)
if err != nil {
infra.Response.Error(ctx, err)
return
}
infra.Response.Success(ctx, response)
}
func updateAllowedByIdentity(ctx *gin.Context, model any, values map[string]any, allowedFields []string) {