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 {