Skip to main content

Unlink Then Relink

This page explains focused correction flow where CTT moves from one NTT to another.

API Endpoints

  • POST /ticket/ctt/unlink-then-link

Purpose

Unlink-then-relink safely rewires wrong existing relationship without forcing operator to do two unrelated manual steps.

Business meaning

This flow:

  • resolves target NTT first
  • checks each CTT independently
  • skips relink when item already points to target
  • unlinks current NTT when needed
  • links to target NTT after cleanup
  • returns aggregated mixed result

Flow summary

StepBusiness meaning
receive target NTT ticket number and CTT idscorrection request starts
resolve target NTT by ticketNodestination must exist first
initialize result counterssuccess, failed, skipped tracked separately
loop each CTT iditems run independently
load current CTTsource item must exist
already linked to target?item is skipped as success
linked to another NTT?old relation must be removed first
run full unlink helper if neededcleanup uses normal unlink path
run full link helper to targetnew relation uses normal link path
capture success or failureaggregated result is built
any success at all?zero-success batch fails, mixed batch can still return

Implementation note

Current repo confirms:

  • controller exposes POST /ticket/ctt/unlink-then-link
  • service resolves target NTT before loop
  • service reuses both unlinkCttNttWithAudit(...) and linkCttNttWithAudit(...)

Code refs:

  • mvp3-ticket-service/src/modules/ctt/ctt.controller.ts:304
  • mvp3-ticket-service/src/modules/ctt/ctt.service.ts:2699