广汽安道拓Acura项目MES后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
621 B

  1. package utils
  2. import (
  3. "reflect"
  4. )
  5. /***
  6. 从map中获取反射对象
  7. */
  8. func ReflectApi(index string, _map map[string]interface{}) *reflect.Value {
  9. data := _map[index]
  10. if data == nil {
  11. return nil
  12. }
  13. refUser := reflect.ValueOf(data)
  14. return &refUser
  15. }
  16. /***
  17. 调用反射方法 当反射对象为空 或者不存在反射方法 返回true 成功返回false
  18. */
  19. func ReflectApiCall(class *reflect.Value, value []reflect.Value) (bool, []reflect.Value) {
  20. defer func() {
  21. if err := recover(); err != nil {
  22. return
  23. }
  24. }()
  25. if class == nil {
  26. return true, nil
  27. }
  28. data := class.Call(value)
  29. return false, data
  30. }