@@ -387,7 +387,7 @@ func (lib *SpAdmin) addData(routerName string, data reflect.Value) error {
387
387
388
388
// 数据修改
389
389
func (lib * SpAdmin ) editData (routerName string , id uint64 , data reflect.Value ) error {
390
- singleData := data .Interface ()
390
+ singleData := lib . incrSetValue ( data , routerName , id ) .Interface ()
391
391
392
392
// 更新之前的事件
393
393
if processor , ok := singleData .(SpUpdateBeforeProcess ); ok {
@@ -526,7 +526,7 @@ func (lib *SpAdmin) getCtxValues(routerName string, ctx iris.Context) (reflect.V
526
526
}
527
527
if len (cb .FieldList .Created ) >= 1 {
528
528
var equal = false
529
- for k , _ := range cb .FieldList .Created {
529
+ for k := range cb .FieldList .Created {
530
530
if column .MapName == k {
531
531
equal = true
532
532
break
@@ -595,6 +595,25 @@ func (lib *SpAdmin) getCtxValues(routerName string, ctx iris.Context) (reflect.V
595
595
return newInstance , nil
596
596
}
597
597
598
+ // id赋值
599
+ func (lib * SpAdmin ) incrSetValue (data reflect.Value , routerName string , id uint64 ) reflect.Value {
600
+ cb , _ := lib .config .tableNameGetModelInfo (routerName )
601
+ for _ , column := range cb .FieldList .Fields {
602
+ if column .MapName == cb .FieldList .AutoIncrement {
603
+ switch column .Types {
604
+ case "int" , "int8" , "int16" , "int32" , "int64" :
605
+ data .Elem ().FieldByName (column .Name ).SetInt (int64 (id ))
606
+ return data
607
+ case "uint" , "uint8" , "uint16" , "uint32" , "uint64" :
608
+ data .Elem ().FieldByName (column .Name ).SetUint (id )
609
+ return data
610
+ }
611
+
612
+ }
613
+ }
614
+ return data
615
+ }
616
+
598
617
// 变更用户密码
599
618
func (lib * SpAdmin ) changeUserPassword (id uint64 , password string ) error {
600
619
ps , salt := lib .config .passwordSalt (password )
0 commit comments