Browse Source

修改bug

yjp 4 months ago
parent
commit
8aafaca277
1 changed files with 12 additions and 0 deletions
  1. 12 0
      convenient/entity_crud/service.go

+ 12 - 0
convenient/entity_crud/service.go

@@ -53,6 +53,18 @@ func Create(tableName string, needCreateUserID bool, callbacks *CreateCallbacks)
 			return callbackOnCreateErrorReturn(callbacks, c, e, make(map[string]any), err, i)
 			return callbackOnCreateErrorReturn(callbacks, c, e, make(map[string]any), err, i)
 		}
 		}
 
 
+		if domain.HasField(e, entity.FieldCreateUserID) && domain.HasField(e, entity.FieldLastUpdateUserID) {
+			createUserID, err := domain.Field[string](e, entity.FieldCreateUserID)
+			if err != nil {
+				return callbackOnCreateErrorReturn(callbacks, c, e, make(map[string]any), err, i)
+			}
+
+			err = domain.SetField(e, entity.FieldLastUpdateUserID, createUserID)
+			if err != nil {
+				return callbackOnCreateErrorReturn(callbacks, c, e, make(map[string]any), err, i)
+			}
+		}
+
 		err = callbackBeforeCreate(callbacks, c, e, prepared, i, nil)
 		err = callbackBeforeCreate(callbacks, c, e, prepared, i, nil)
 		if err != nil {
 		if err != nil {
 			return callbackOnCreateErrorReturn(callbacks, c, e, prepared, err, i)
 			return callbackOnCreateErrorReturn(callbacks, c, e, prepared, err, i)