mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-09 04:21:08 +08:00
is all fields private
This commit is contained in:
parent
2966afca6b
commit
15610438d8
@ -12,7 +12,7 @@ type apiResponse struct {
|
|||||||
Data any `json:"data,omitempty"`
|
Data any `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func isEmptyStruct(v any) bool {
|
func isAllFieldsPrivate(v any) bool {
|
||||||
typeOf := reflect.TypeOf(v)
|
typeOf := reflect.TypeOf(v)
|
||||||
if typeOf.Kind() == reflect.Ptr {
|
if typeOf.Kind() == reflect.Ptr {
|
||||||
typeOf = typeOf.Elem()
|
typeOf = typeOf.Elem()
|
||||||
@ -22,8 +22,8 @@ func isEmptyStruct(v any) bool {
|
|||||||
}
|
}
|
||||||
num := typeOf.NumField()
|
num := typeOf.NumField()
|
||||||
for i := 0; i < num; i++ {
|
for i := 0; i < num; i++ {
|
||||||
v := typeOf.Field(i).Name[0]
|
c := typeOf.Field(i).Name[0]
|
||||||
if v >= 'A' && v <= 'Z' {
|
if c >= 'A' && c <= 'Z' {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ func isEmptyStruct(v any) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func apiSuccess(data any) *apiResponse {
|
func apiSuccess(data any) *apiResponse {
|
||||||
if isEmptyStruct(data) {
|
if isAllFieldsPrivate(data) {
|
||||||
return &apiResponse{}
|
return &apiResponse{}
|
||||||
}
|
}
|
||||||
return &apiResponse{
|
return &apiResponse{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user