diff --git a/handler/component_attribute_query.go b/handler/component_attribute_query.go index f6296f4..44e9462 100644 --- a/handler/component_attribute_query.go +++ b/handler/component_attribute_query.go @@ -159,7 +159,20 @@ func ComponentAttributeQueryHandler(c *gin.Context) { } payload := genQueryRespPayload(queryResults, tokenSlice) - renderRespSuccess(c, constants.RespCodeSuccess, "process completed", payload) + if hasAnyError(queryResults) { + renderRespFailure(c, constants.RespCodeFailed, "query completed with partial failures", payload) + } else { + renderRespSuccess(c, constants.RespCodeSuccess, "query completed successfully", payload) + } +} + +func hasAnyError(results map[string]queryResult) bool { + for _, res := range results { + if res.err != nil && res.err.Code() != constants.RespCodeSuccess { + return true + } + } + return false } func fillRemainingErrors(results map[string]queryResult, tokens []string, err *errcode.AppError) { diff --git a/handler/component_attribute_update.go b/handler/component_attribute_update.go index 585f5ad..778fb42 100644 --- a/handler/component_attribute_update.go +++ b/handler/component_attribute_update.go @@ -158,7 +158,11 @@ func ComponentAttributeUpdateHandler(c *gin.Context) { } payload := genUpdateRespPayload(updateResults, request.AttributeConfigs) - renderRespSuccess(c, constants.RespCodeSuccess, "process completed", payload) + if len(updateResults) > 0 { + renderRespFailure(c, constants.RespCodeFailed, "process completed with partial failures", payload) + return + } + renderRespSuccess(c, constants.RespCodeSuccess, "process completed successfully", payload) } type attributeModifyConfig struct {