This commit is contained in:
suyl
2021-07-21 14:26:05 +08:00
parent 5a46ee4264
commit b5355149e7

View File

@@ -78,7 +78,7 @@ func Update(db *sqlx.DB, obj interface{}, fields ...string) (err error) {
}
sql.WriteString(strings.Join(fieldsStr, ","))
sql.WriteString(" WHERE id = ?")
for i := 0; i < stype.NumField()-1; i++ {
for i := 1; i < stype.NumField(); i++ {
if fieldsMap[stype.Field(i).Tag.Get("json")] != "" {
if stype.Field(i).Type.String() == "*time.Time" {
if direct.Field(i).Interface().(*time.Time) != nil {
@@ -94,6 +94,7 @@ func Update(db *sqlx.DB, obj interface{}, fields ...string) (err error) {
if direct.Field(0).Int() == 0 {
return err
} else {
fmt.Println("11111111", direct.Field(0).Int())
sqlParams = append(sqlParams, direct.Field(0).Int())
}
fmt.Println(sql.String())