浏览代码

修改bug

yjp 4 月之前
父节点
当前提交
8aafaca277
共有 1 个文件被更改,包括 12 次插入0 次删除
  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)
 		}
 
+		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)
 		if err != nil {
 			return callbackOnCreateErrorReturn(callbacks, c, e, prepared, err, i)