Last active
February 5, 2022 03:25
-
-
Save lomeat/6de617fea2cd42bc02d70f357efec19b to your computer and use it in GitHub Desktop.
passport pop crud rest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ? SWAGGER API | |
// Если нет query, то все сущности, что есть у номенклатуры | |
// Если agent_id, то сущности агента | |
// Если contract_uuid, то сущности контракта | |
// Если nomenclature_id[], то все сущности, что есть у всех номенклатур с этими id | |
// offset, limit - пагинация | |
// from, to - сущности с .. по .. дате | |
const urls = { | |
agent: { | |
get: "/passports/{passport_id}/agents ?nomenclature_id=123 ?agent_id=123", | |
post: "/passports/{passport_id}/agents", | |
patch: "/passports/{passport_id}/agents/{agent_id}", | |
delete: "/passports/{passport_id}/agents/{agent_id} ?status=soft|delete", | |
// Варианты как можно реализовать ручку. | |
// Первый мне кажется более подходящим, тк квери опционально, но в контексте не может не быть указана номенклатура | |
// Второй, как сделано сейчас на v1 | |
// Третий копия get выше, но с доп квери | |
get_accredited: | |
"/passpots/{passport_id}/nomenclatures/{project_nomenclature_id}/agents_accredited", | |
get_accredited2: | |
"/passpots/{passport_id}/agents_accredited ?nomenclature_id=123", | |
get_accredited3: | |
"/passpots/{passport_id}/agents ?nomenclature_id=123 ?agent_id=123 ?accredited=true|false", | |
}, | |
contract: { | |
get: "/passports/{passport_id}/contracts ?agent_id=123 ?contract_uuid=1w3", | |
post: "/passports/{passport_id}/contracts", | |
patch: "/passports/{passport_id}/contracts/{contract_uuid}", | |
delete: | |
"/passports/{passport_id}/contracts/{contract_uuid} ?status=soft|force", | |
}, | |
payment: { | |
get: "/passports/{passport_id}/payments ?agent_id=123 ?contract_uuid=1w3 ?payment_uuid=1w3", | |
post: "/passports/{passport_id}/payments", | |
patch: "/passports/{passport_id}/payments/{payment_uuid}", | |
delete: | |
"/passports/{passport_id}/payments/{payment_uuid} ?status=soft|force", | |
}, | |
invoice: { | |
get: "/passports/{passport_id}/invoices ?agent_id=123 ?contract_uuid=1w3 ?invoice_uuid=1w3 ?nomenclature_id[]=123&nomenclature_id[]=321 ?limit=12 ?offset=20 ?from=2021-12-10T00:15:00.056Z ?to=2021-12-10T00:15:00.056Z", | |
post: "/passports/{passport_id}/invoices", | |
patch: "/passports/{passport_id}/invoices/{invoice_uuid}", | |
delete: | |
"/passports/{passport_id}/invoices/{invoice_uuid} ?status=soft|delete", | |
post_bind: "/passports/{passport_id}/invoices/bind", | |
post_unbind: "/passports/{passport_id}/invoices/unbind", | |
}, | |
ttn: { | |
get: "/passports/{passport_id}/ttns ?agent_id=123 ?contract_uuid=1w3 ?ttn_uuid=1w3 ?nomenclature_id[]=123&nomenclature_id[]=321 ?limit=12 ?offset=20 ?from=2021-12-10T00:15:00.056Z ?to=2021-12-10T00:15:00.056Z", | |
post: "/passports/{passport_id}/ttns", | |
patch: "/passports/{passport_id}/ttns/{ttn_uuid}", | |
delete: "/passports/{passport_id}/ttns/{ttn_uuid} ?status=soft|force", | |
}, | |
}; | |
// ? --- GET QUIERIES --- | |
type AgentQuery = { | |
nomenclature_id: number; | |
agent_id: number; | |
}; | |
type ContractQuery = { | |
agent_id: number; | |
contract_uuid: string; | |
}; | |
type PaymentQuery = { | |
agent_id: number; | |
contract_uuid: string; | |
payment_uuid: string; | |
}; | |
type InvoiceQuery = { | |
agent_id: number; | |
contract_uuid: string; | |
invoice_uuid: string; | |
nomenclature_ids: number[]; | |
limit: number; | |
offset: number; | |
from: string; | |
to: string; | |
}; | |
type TTNQuery = { | |
agent_id: number; | |
contract_uuid: string; | |
ttn_uuid: string; | |
nomenclature_ids: number[]; | |
limit: number; | |
offset: number; | |
from: string; | |
to: string; | |
}; | |
// ? --- AGENT --- | |
type AgentGet = [ | |
{ | |
id: number; // or uuid: string | |
nomenclature_id: number; | |
type: "ts" | "account" | "internal"; | |
title: string; | |
amount: number; | |
price_unit: number; | |
price_sum: number; | |
count: number; | |
inn: number; | |
organization_form: string | null; | |
status: { | |
title: string; | |
amount: string; | |
price_sum: string; | |
price_unit: string; | |
}; | |
} | |
]; | |
type AgentAccreditedGet = [ | |
{ | |
id: number; | |
title: string; | |
inn: number; | |
contracts_count: number; | |
// Эти 3 ниже в контексте таски не нужны, но можно оставить, тк они уже есть на v1 | |
contracts_amount: number; | |
price_unit_max: number; | |
price_sum: number; | |
} | |
]; | |
type AgentPost = { | |
nomenclature_id: number; | |
agent_id: number; | |
}; | |
type AgentPatch = { | |
nomenclature_id: number; | |
}; | |
type AgentDelete = number; | |
// ? --- CONTRACT --- | |
type ContractGet = [ | |
{ | |
uuid: string; | |
title: string; | |
amount: number; | |
price_unit: number; | |
price_sum: number; | |
date: string; | |
file?: { | |
uuid: string; | |
url: string; | |
title: string; | |
}; | |
status: { | |
title: string; | |
amount: string; | |
price_unit: string; | |
price_sum: string; | |
date: string; | |
}; | |
} | |
]; | |
type ContractPostPatch = { | |
title: string; | |
date: string; | |
amount: number; | |
price_unit: number; | |
agent_id: number; | |
file?: object; | |
}; | |
type ContractDelete = string; | |
// ? --- PAYMENT --- | |
type PaymentGet = { | |
uuid: string; | |
date: string; | |
title: string; | |
amount_to: number; | |
amount_now: number; | |
price_unit: number; | |
price_sum_to: number; | |
price_sum_now: number; | |
percent_to: number; | |
percent_now: number; | |
file: { | |
uuid: string; | |
url: string; | |
title: string; | |
}; | |
agreement: { | |
comment?: string; | |
status: "at_work" | "agreed" | "for_payment" | "is_paid" | "denied"; | |
}; | |
status: { | |
title: string; | |
amount_to: string; | |
amount_now: string; | |
price_sum_to: string; | |
price_sum_now: string; | |
status: string; | |
}; | |
}; | |
type PaymentPostPatch = { | |
title: string; | |
date: string; | |
amount: number; | |
price_unit: number; | |
agent_id: number; | |
contract_uuid: string; | |
file?: object; | |
}; | |
type PaymentDelete = string; | |
// ? --- INVOICE --- | |
type InvoiceGet = [ | |
{ | |
uuid: string; | |
title: string; | |
amount: number; | |
price_unit: number; | |
price_sum: number; | |
file: { | |
url: string; | |
uuid: string; | |
title: string; | |
}; | |
} | |
]; | |
type InvoicePostPatch = { | |
title: string; | |
date: string; | |
price_unit: string; | |
amount: number; | |
contract_uuid: string; | |
agent_id: number; | |
file: object; | |
ttn_uuids?: string[]; | |
}; | |
type InvoiceBind = { | |
invoice_uuid: string; | |
ttn_uuids: string[]; | |
}; | |
type InvoiceDelete = string; | |
// ? --- ТТН --- | |
type TTNGet = [ | |
{ | |
uuid: string; | |
amount: number; | |
date: string; | |
price_sum: number; | |
percent: number; | |
title: string; | |
count: number; | |
contract_uuid: number; | |
agent_id: number; | |
nomenclature_id: number; | |
status: { | |
id: number; | |
title: string; | |
}; | |
file: { | |
title: string; | |
url: string; | |
uuid: string; | |
}; | |
} | |
]; | |
type TTNNomenclaturesGet = [ | |
{ | |
nomenclature_id: number; | |
nomenclature_title: string; | |
ttns: [ | |
{ | |
uuid: string; | |
amount: number; | |
date: string; | |
price_sum: number; | |
percent: number; | |
title: string; | |
count: number; | |
contract_uuid: number; | |
agent_id: number; | |
nomenclature_id: number; | |
status: { | |
id: number; | |
title: string; | |
}; | |
file: { | |
title: string; | |
url: string; | |
uuid: string; | |
}; | |
} | |
]; | |
} | |
]; | |
type TTNPostPatch = { | |
title: string; | |
date: string; | |
amount: number; | |
invoice_uuid: string; | |
agent_id?: number; | |
contract_uuid?: string; | |
file: object; | |
}; | |
type TTNDelete = string; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment