yjp hace 3 meses
padre
commit
81ae7b9786
Se han modificado 1 ficheros con 12 adiciones y 0 borrados
  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 {