feat(t215): add admin order authorization
This commit is contained in:
@@ -192,6 +192,33 @@ func (s *Store) StoreExecutionCandidates(
|
||||
); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if candidate.ReadyEvent != nil && !expired {
|
||||
result, err := tx.ExecContext(
|
||||
ctx,
|
||||
`UPDATE purchase_tasks
|
||||
SET status = 'WAITING_CONFIRMATION',
|
||||
version = version + 1,
|
||||
updated_at = ?
|
||||
WHERE id = ? AND status = 'RUNNING'
|
||||
AND version = ? AND cancel_requested_at IS NULL`,
|
||||
formatTimestamp(write.Now),
|
||||
write.TaskID,
|
||||
task.Version,
|
||||
)
|
||||
if err != nil {
|
||||
return false, repositoryFailure(err)
|
||||
}
|
||||
affected, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return false, repositoryFailure(err)
|
||||
}
|
||||
if affected != 1 {
|
||||
return false, usecase.ErrTaskStateConflict
|
||||
}
|
||||
if err := insertTaskEvent(ctx, tx, *candidate.ReadyEvent); err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
if err := insertExecutionResultRequest(ctx, tx, write, nil); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user