This commit is contained in:
tangpanqing
2023-01-10 09:52:08 +08:00
parent bc43028389
commit 10a7bc9230
8 changed files with 45 additions and 60 deletions

View File

@@ -130,13 +130,12 @@ func getFieldName(field interface{}) string {
}
//反射表名,优先从方法获取,没有方法则从名字获取
func getTableNameByReflect(typeOf reflect.Type) string {
func getTableNameByReflect(typeOf reflect.Type, valueOf reflect.Value) string {
method, isSet := typeOf.MethodByName("TableName")
fmt.Println("=isSet=")
fmt.Println(typeOf)
fmt.Println(isSet)
if isSet {
res := method.Func.Call(nil)
var paramList []reflect.Value
paramList = append(paramList, valueOf)
res := method.Func.Call(paramList)
return res[0].String()
} else {
arr := strings.Split(typeOf.String(), ".")