feat: get user/staff profile

This commit is contained in:
ericprd
2025-02-27 18:59:58 +08:00
parent 290c0edff7
commit 5fb0764630
19 changed files with 426 additions and 4 deletions
+29
View File
@@ -0,0 +1,29 @@
package utils
import (
"errors"
"reflect"
)
func StructToMap(s any) (map[string]any, error) {
result := make(map[string]any)
val := reflect.ValueOf(s)
if val.Kind() != reflect.Struct {
return nil, errors.New("provided value is not struct")
}
for i := range val.NumField() {
field := val.Type().Field(i)
value := val.Field(i)
if value.IsZero() || value.IsNil() {
continue
}
result[field.Name] = value.Interface()
}
return result, nil
}