- mini program login

This commit is contained in:
gazebo
2018-12-27 16:49:32 +08:00
parent b1a7cfdaa8
commit 5adc5e61f3
16 changed files with 301 additions and 51 deletions

View File

@@ -1,6 +1,7 @@
package dao
import (
"fmt"
"reflect"
"strings"
"time"
@@ -130,3 +131,40 @@ func GetCategoryIDJsonField(prefix string) string {
func GetCategoryIDDBField(prefix string) string {
return ConvertDBFieldPrefix(prefix) + "_category_id"
}
func value2Value(srcValue, dstValue reflect.Value, copyType int) {
srcType := srcValue.Type()
for i := 0; i < srcType.NumField(); i++ {
fieldName := srcType.Field(i).Name
if dstFieldvalue := dstValue.FieldByName(fieldName); dstFieldvalue.IsValid() {
srcFieldValue := srcValue.FieldByName(fieldName)
if false { //dstFieldvalue.Kind() == reflect.Struct {
fmt.Printf("%v, %v\n", utils.Format4Output(srcFieldValue.Interface(), false), utils.Format4Output(dstFieldvalue.Interface(), false))
value2Value(srcFieldValue, dstFieldvalue, copyType)
} else {
// fmt.Printf("%v, %v\n", srcFieldValue.Interface(), dstFieldvalue.Interface())
dstFieldvalue.Set(srcFieldValue)
}
}
}
}
// func copyBetweenNoramAndNullObj(src, dst interface{}, copyType int) {
// dstValue := reflect.ValueOf(dst)
// if dstValue.Kind() != reflect.Ptr {
// panic("ObjNormal2Null dst must be ptr of struct")
// }
// srcValue := reflect.ValueOf(src)
// if srcValue.Kind() == reflect.Ptr {
// srcValue = srcValue.Elem()
// }
// value2Value(srcValue, dstValue.Elem(), copyType)
// }
// func ObjNormal2Null(src, dst interface{}) {
// copyBetweenNoramAndNullObj(src, dst, 1)
// }
// func ObjNull2Normal(src, dst interface{}) {
// copyBetweenNoramAndNullObj(src, dst, 2)
// }