yjp преди 3 месеца
родител
ревизия
81ae7b9786
променени са 1 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 12 0
      convenient/entity_crud/service.go

+ 12 - 0
convenient/entity_crud/service.go

@@ -392,6 +392,18 @@ func CreateTx(tableName string, needCreateUserID bool, callbacks *CreateCallback
 			return callbackOnCreateErrorReturn(callbacks, c, params, 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, params, e, make(map[string]any), err, i)
+			}
+
+			err = domain.SetField(e, entity.FieldLastUpdateUserID, createUserID)
+			if err != nil {
+				return callbackOnCreateErrorReturn(callbacks, c, params, e, make(map[string]any), err, i)
+			}
+		}
+
 		err = database.Transaction(dbExecutor, func(tx database.Executor) error {
 			err = callbackBeforeCreate(callbacks, c, params, e, prepared, i, tx)
 			if err != nil {