refactor(idgen): centralize negative ID handling via panic

Restore NextUint64ID() to uint64-only API so callers need no error
checks. Retry logic stays in idgen; after 3 negative values it panics
instead of returning 0, preventing silent NULL primary keys.
This commit is contained in:
ryan
2026-06-17 13:14:17 +08:00
parent 92dc6a59c0
commit 3a05e7f09c
11 changed files with 17 additions and 68 deletions
+1 -5
View File
@@ -60,11 +60,7 @@ func (TaskExecution) TableName() string {
// CreateTaskExecution 创建任务执行记录
func CreateTaskExecution(ctx context.Context, execution *TaskExecution) error {
id, err := idgen.NextUint64ID()
if err != nil {
return err
}
execution.ID = id
execution.ID = idgen.NextUint64ID()
return db.DB(ctx).Create(execution).Error
}