Compare commits
No commits in common. "master" and "billing-view" have entirely different histories.
master
...
billing-vi
192 changed files with 2047 additions and 9315 deletions
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_billing_line_item_query\n SET\n version = $1,\n product_name = $2,\n product_id = $3,\n line_item_id = $4,\n quantity_minor_unit = $5,\n quantity_minor_number = $6,\n quantity_major_unit = $7,\n quantity_major_number = $8,\n created_time = $9,\n bill_id = $10,\n price_per_unit_minor = $11 ,\n price_per_unit_major = $12,\n price_per_unit_currency = $13,\n deleted = $14;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Timestamptz",
|
||||
"Uuid",
|
||||
"Int4",
|
||||
"Int4",
|
||||
"Text",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "0268f0c43abe34a3147f0a43f0e11bf302a3750ecadf28b1d6af62da62934f87"
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT \n emp_id, version\n FROM\n cqrs_identity_employee_query\n WHERE\n emp_id = $1;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "emp_id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "version",
|
||||
"type_info": "Int8"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "0bbafa839181369d932fb1deae71e2255c30d24779d37a703dcd3521fbac35cf"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_inventory_store_query\n SET\n version = $1,\n name = $2,\n address = $3,\n owner = $4,\n deleted = $5;",
|
||||
"query": "UPDATE\n cqrs_inventory_store_query\n SET\n version = $1,\n name = $2,\n address = $3,\n store_id = $4,\n owner = $5,\n deleted = $6;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -9,10 +9,11 @@
|
|||
"Text",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "8d62d7b612fd7f323aee586047dec9603f05782f55f72d21fc29954a65622b5d"
|
||||
"hash": "0ccd86643c13d9d7c793f362aedc2d720d9dda982a0416849bf97291fc645ea5"
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "DELETE FROM\n emp_verification_otp\n WHERE\n otp = $1\n AND\n emp_id = (\n SELECT emp_id\n FROM cqrs_identity_employee_query\n WHERE\n phone_number_number = $2\n AND\n phone_number_country_code = $3\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int4",
|
||||
"Int8",
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "0ce99350a114d2bc5876ca038f079aac489d27d89d164d07ded62c71e5237b10"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_inventory_category_query\n SET\n version = $1,\n name = $2,\n description = $3,\n store_id = $4,\n deleted = $5;",
|
||||
"query": "UPDATE\n cqrs_inventory_category_query\n SET\n version = $1,\n name = $2,\n description = $3,\n category_id = $4,\n store_id = $5,\n deleted = $6;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -9,10 +9,11 @@
|
|||
"Text",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "c9bee14e15dae80b7af9b0fdca43a97b964024252bed2d0caeebee175acd55d9"
|
||||
"hash": "14d111d7453b89f2346966a9fdd725d269ef36288ed5e7fe1f7ad452deaab0e6"
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n user_query\n SET\n version = $1, first_name = $2, email = $3,\n hashed_password = $4, is_admin = $5, is_verified = $6, deleted = $7,\n last_name=$8;",
|
||||
"query": "UPDATE\n user_query\n SET\n user_id = $1, version = $2, first_name = $3, email = $4,\n hashed_password = $5, is_admin = $6, is_verified = $7, deleted = $8,\n last_name=$9;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Int8",
|
||||
"Text",
|
||||
"Text",
|
||||
|
@ -17,5 +18,5 @@
|
|||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "8ae34e8c47972ce113f235888fd52ca6f48a6a6130538256827f03ea11b8cc78"
|
||||
"hash": "14e8d7a1c8f80701b76b2bac69b1ecd99f7694d620f1945ad5c4ae474a17be1b"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_billing_store_query\n SET\n version = $1,\n name = $2,\n address = $3,\n owner = $4,\n deleted = $5;",
|
||||
"query": "UPDATE\n cqrs_billing_store_query\n SET\n version = $1,\n name = $2,\n address = $3,\n store_id = $4,\n owner = $5,\n deleted = $6;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -9,10 +9,11 @@
|
|||
"Text",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "d7decc8f70fc4f12d7a1db5009d2190bb9746000067d53990eb7cd646ff5d252"
|
||||
"hash": "3811531518316435c32223582f9de6bdfefc19839129577407a1e4071f5c49f6"
|
||||
}
|
|
@ -1,17 +1,18 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_ordering_kot_query\n SET\n version = $1,\n order_id = $2,\n created_time = $3,\n deleted = $4;",
|
||||
"query": "UPDATE\n cqrs_ordering_kot_query\n SET\n version = $1,\n order_id = $2,\n kot_id = $3,\n created_time = $4,\n deleted = $5;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Timestamptz",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "97c136fd927b9a153a6093da6594e5fc2837b3943b8bbcbade97920a99019c86"
|
||||
"hash": "4b7100e5c7442066dbb4ea7c9733e038af635766f0be61a86ca7084b34a2109d"
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_identity_employee_query\n SET\n version = $1,\n\n created_time = $2,\n store_id = $3,\n first_name = $4,\n last_name = $5,\n phone_number_number = $6,\n phone_number_country_code = $7,\n phone_verified = $8,\n\n\n deleted = $9;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Timestamptz",
|
||||
"Uuid",
|
||||
"Text",
|
||||
"Text",
|
||||
"Int8",
|
||||
"Int4",
|
||||
"Bool",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "4b8bf25b161a8337bc1ee7bcfba5a065417280cbae1527d3363f6f7561cb50c3"
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT EXISTS (\n SELECT 1\n FROM cqrs_identity_employee_query\n WHERE\n emp_id = $1\n );",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "exists",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "5ed9222039eabd6e564c035aae83227f5a8398d4892d62185fbf911f16bde10d"
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT EXISTS (\n SELECT 1\n FROM cqrs_identity_employee_query\n WHERE\n phone_number_number = $1\n AND \n phone_number_country_code = $2\n );",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "exists",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "6059e6de1cb1aaca0df97b3f6f95b567f0786bacecd4658776aefcaae41ca679"
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO emp_verification_otp (otp, created_at, purpose, emp_id)\n VALUES ($1, $2, $3, $4);",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int4",
|
||||
"Timestamptz",
|
||||
"Text",
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "76b69da704bce81a71c5591ac3990a3dcbab3e9d8d67e71126a1ab1de99b839a"
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO cqrs_identity_employee_query (\n version,\n created_time,\n store_id,\n emp_id,\n first_name,\n last_name,\n phone_number_number,\n phone_number_country_code,\n phone_verified,\n deleted\n\n\n ) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8, $9, $10\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Timestamptz",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Text",
|
||||
"Text",
|
||||
"Int8",
|
||||
"Int4",
|
||||
"Bool",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "796be4344e585654ea27252b02239158ed4691448b33d4427bf70717aad41263"
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT \n created_time,\n store_id,\n emp_id,\n first_name,\n last_name,\n phone_number_number,\n phone_number_country_code,\n phone_verified,\n deleted\n FROM\n cqrs_identity_employee_query\n WHERE\n emp_id = $1;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "created_time",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "store_id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "emp_id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "first_name",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "last_name",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "phone_number_number",
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "phone_number_country_code",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "phone_verified",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "deleted",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "7c2fd6e897bf18b1f2229eec5fd12932a86d4e88f2fd4ab8ac32246a55303b03"
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT \n created_time,\n store_id,\n emp_id,\n first_name,\n last_name,\n phone_number_number,\n phone_number_country_code,\n phone_verified,\n deleted\n\n FROM\n cqrs_identity_employee_query\n WHERE\n emp_id = $1;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "created_time",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "store_id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "emp_id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "first_name",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "last_name",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "phone_number_number",
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "phone_number_country_code",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "phone_verified",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "deleted",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "848f7c8250f7aba08fcf11491ee1a80c9fd0bfb8e37ca1051604bc2bb25d5356"
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT emp_id\n FROM cqrs_identity_employee_query\n WHERE\n phone_number_number = $1\n AND\n phone_number_country_code = $2;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "emp_id",
|
||||
"type_info": "Uuid"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "901bd28d7ec82aae1b5b7a2add1f0b0bd8625c365a9de30b176d023333c3d266"
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_billing_line_item_query\n SET\n version = $1,\n product_name = $2,\n product_id = $3,\n quantity_minor_unit = $4,\n quantity_minor_number = $5,\n quantity_major_unit = $6,\n quantity_major_number = $7,\n created_time = $8,\n bill_id = $9,\n price_per_unit_minor = $10 ,\n price_per_unit_major = $11,\n price_per_unit_currency = $12,\n deleted = $13;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Timestamptz",
|
||||
"Uuid",
|
||||
"Int4",
|
||||
"Int4",
|
||||
"Text",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "995cca627c711a87b30723c6ceefd3fcdd1fc63bdcd95f8a974823089652aa51"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO cqrs_ordering_order_query (\n version,\n customer_name,\n order_id,\n created_time,\n store_id,\n deleted\n\n ) VALUES (\n $1, $2, $3, $4, $5, $6\n );",
|
||||
"query": "INSERT INTO cqrs_ordering_order_query (\n version,\n customer_name,\n order_id,\n created_time,\n deleted\n\n ) VALUES (\n $1, $2, $3, $4, $5\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -9,11 +9,10 @@
|
|||
"Text",
|
||||
"Uuid",
|
||||
"Timestamptz",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "7e2e91418e136fc5091b27c5f61158cca61e4853bee64e5afc44679e685cd744"
|
||||
"hash": "a342003149f2991ef0280d008f18e664c96299edfd9a11d08487e4db10a10e8b"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_billing_bill_query\n SET\n version = $1,\n\n created_time = $2,\n store_id = $3,\n token_number = $4,\n total_price_major = $5,\n total_price_minor = $6,\n total_price_currency = $7,\n deleted = $8;",
|
||||
"query": "UPDATE\n cqrs_billing_bill_query\n SET\n version = $1,\n\n created_time = $2,\n store_id = $3,\n bill_id = $4,\n token_number = $5,\n total_price_major = $6,\n total_price_minor = $7,\n total_price_currency = $8,\n\n deleted = $9;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -8,6 +8,7 @@
|
|||
"Int8",
|
||||
"Timestamptz",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Int4",
|
||||
"Int4",
|
||||
"Int4",
|
||||
|
@ -17,5 +18,5 @@
|
|||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "c30f49bb293ca6e184c5110bdfe1108b23bdf71dd904bdd5287155161138565d"
|
||||
"hash": "b335fc519289a42c707855b620a35433d3f8bd1e798772c05fc156494c036ef5"
|
||||
}
|
|
@ -1,18 +1,18 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_ordering_order_query\n SET\n version = $1,\n customer_name = $2,\n created_time = $3,\n store_id= $4,\n deleted = $5;",
|
||||
"query": "UPDATE\n cqrs_ordering_order_query\n SET\n version = $1,\n customer_name = $2,\n order_id = $3,\n created_time = $4,\n deleted = $5;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Text",
|
||||
"Timestamptz",
|
||||
"Uuid",
|
||||
"Timestamptz",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "876ca2c177175439a1604a2d5aeec785e41473116ceda238a8089bcb33588e3d"
|
||||
"hash": "bc7d17aab113d0519c53e5f612116a6e72bb0007a298cdba17f45f4b8bed5f56"
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_ordering_line_item_query\n SET\n version = $1,\n product_name = $2,\n product_id = $3,\n line_item_id = $4,\n quantity_minor_unit = $5,\n quantity_minor_number = $6,\n quantity_major_unit = $7,\n quantity_major_number = $8,\n created_time = $9,\n kot_id = $10,\n deleted = $11;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Timestamptz",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "c348d55dd91acb0d4697c433f61866b288fec93971bf9ab41faec21680e50f71"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_ordering_product_query\n SET\n version = $1,\n name = $2,\n description = $3,\n image = $4,\n category_id = $5,\n price_major = $6,\n price_minor = $7,\n price_currency = $8,\n sku_able = $9,\n quantity_minor_unit = $10,\n quantity_minor_number = $11,\n quantity_major_unit = $12,\n quantity_major_number = $13,\n deleted = $14;",
|
||||
"query": "UPDATE\n cqrs_ordering_product_query\n SET\n version = $1,\n name = $2,\n description = $3,\n image = $4,\n product_id = $5,\n category_id = $6,\n price_major = $7,\n price_minor = $8,\n price_currency = $9,\n sku_able = $10,\n quantity_minor_unit = $11,\n quantity_minor_number = $12,\n quantity_major_unit = $13,\n quantity_major_number = $14,\n deleted = $15;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -10,6 +10,7 @@
|
|||
"Text",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Int4",
|
||||
"Int4",
|
||||
"Text",
|
||||
|
@ -23,5 +24,5 @@
|
|||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "a3fa1c6271b85d23d70116363f19144190120c13752364bc3b78a92a08bd9157"
|
||||
"hash": "c3a3348990d0fea3225fd2be2ef883ca1649e21fd28c1a35a0ffffce6035fd75"
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT\n otp\n FROM\n emp_verification_otp\n WHERE\n emp_id = (\n SELECT emp_id\n FROM cqrs_identity_employee_query\n WHERE\n phone_number_number = $1\n AND\n phone_number_country_code = $2\n );",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "otp",
|
||||
"type_info": "Int4"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "cee6873f40b9a442ec4764e22a6885994c5fb3cd1f9367a073d6333eadbdb8e8"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_ordering_store_query\n SET\n version = $1,\n name = $2,\n address = $3,\n owner = $4,\n deleted = $5;",
|
||||
"query": "UPDATE\n cqrs_ordering_store_query\n SET\n version = $1,\n name = $2,\n address = $3,\n store_id = $4,\n owner = $5,\n deleted = $6;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -9,10 +9,11 @@
|
|||
"Text",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "8a7958c4f8419e1fd95b2d0c75a3bab76f5962f37e58c7dee4e5f9341dca8c0e"
|
||||
"hash": "d0580ff6dc77150cb00186302f20460dc3be59be1f8f5588bdc3d0f4489eb613"
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT\n otp\n FROM\n emp_login_otp\n WHERE\n emp_id = (\n SELECT emp_id\n FROM cqrs_identity_employee_query\n WHERE\n phone_number_number = $1\n AND\n phone_number_country_code = $2\n );",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "otp",
|
||||
"type_info": "Int4"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "d7ca0856c700be37f5ec475b8bbc2d4a443923c8afdd37742d75d381a8831873"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_ordering_category_query\n SET\n version = $1,\n name = $2,\n description = $3,\n store_id = $4,\n deleted = $5;",
|
||||
"query": "UPDATE\n cqrs_ordering_category_query\n SET\n version = $1,\n name = $2,\n description = $3,\n category_id = $4,\n store_id = $5,\n deleted = $6;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -9,10 +9,11 @@
|
|||
"Text",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "289e6d9fe105ae9e91d947c22d0a5979786aac15b0c78359b3f634b74c4686d4"
|
||||
"hash": "d896f6ffb486efad5ed10a9c824656d863de0c9140054de66eef32491ace9ddb"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_ordering_product_customizations_query\n SET\n version = $1,\n name = $2,\n product_id = $3,\n deleted = $4;",
|
||||
"query": "UPDATE\n cqrs_ordering_product_customizations_query\n SET\n version = $1,\n name = $2,\n customization_id = $3,\n product_id = $4,\n deleted = $5;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -8,10 +8,11 @@
|
|||
"Int8",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "a5a58d14ddbfa78cca3729392faecfab30cc8b01fed9b73b9cc0813750230314"
|
||||
"hash": "d9c625876e7d398cb48c6278e69b2eb6ad8515e68d5520013634415109309e6e"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT \n customer_name,\n order_id,\n created_time,\n store_id,\n deleted\n FROM\n cqrs_ordering_order_query\n WHERE\n order_id = $1;",
|
||||
"query": "SELECT \n customer_name,\n order_id,\n created_time,\n deleted\n FROM\n cqrs_ordering_order_query\n WHERE\n order_id = $1;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
@ -20,11 +20,6 @@
|
|||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "store_id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "deleted",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
|
@ -35,12 +30,11 @@
|
|||
]
|
||||
},
|
||||
"nullable": [
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "4f8a2294b40e4285fa6d4c7bcf648be7320f99002b9a9279981053a5062b0ed8"
|
||||
"hash": "dbe1e41f04a81b2a504b9179911201ec52340d09d45041addd54eb349af82488"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_inventory_product_query\n SET\n version = $1,\n name = $2,\n description = $3,\n image = $4,\n category_id = $5,\n price_major = $6,\n price_minor = $7,\n price_currency = $8,\n sku_able = $9,\n quantity_minor_unit = $10,\n quantity_minor_number = $11,\n quantity_major_unit = $12,\n quantity_major_number = $13,\n deleted = $14;",
|
||||
"query": "UPDATE\n cqrs_inventory_product_query\n SET\n version = $1,\n name = $2,\n description = $3,\n image = $4,\n product_id = $5,\n category_id = $6,\n price_major = $7,\n price_minor = $8,\n price_currency = $9,\n sku_able = $10,\n quantity_minor_unit = $11,\n quantity_minor_number = $12,\n quantity_major_unit = $13,\n quantity_major_number = $14,\n deleted = $15;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -10,6 +10,7 @@
|
|||
"Text",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Int4",
|
||||
"Int4",
|
||||
"Text",
|
||||
|
@ -23,5 +24,5 @@
|
|||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "c358d3b79d35668b3475f29f5bf6767f7209a2443fd944420baf1e1cf5c51ccb"
|
||||
"hash": "e2f9f291a20aac77851774ba8cd37325143a4d98e0980632f097c5885cc71094"
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO emp_login_otp (otp, created_at, purpose, emp_id)\n VALUES ($1, $2, $3, $4);",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int4",
|
||||
"Timestamptz",
|
||||
"Text",
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "e56fe1dadd3536ea549a30c36005982be07e3d34a1782399bee188dddd2c85a8"
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_ordering_line_item_query\n SET\n version = $1,\n product_name = $2,\n product_id = $3,\n quantity_minor_unit = $4,\n quantity_minor_number = $5,\n quantity_major_unit = $6,\n quantity_major_number = $7,\n created_time = $8,\n kot_id = $9,\n deleted = $10;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Timestamptz",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "e61db066fe7e66879f8ce8ccd3da94d89c30f8f5d633004ba16a6e971e041a14"
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "DELETE FROM\n emp_login_otp\n WHERE\n otp = $1\n AND\n emp_id = (\n SELECT emp_id\n FROM cqrs_identity_employee_query\n WHERE\n phone_number_number = $2\n AND\n phone_number_country_code = $3\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int4",
|
||||
"Int8",
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "e665b7147456bc27158a24a8bd705bcae867b257d0eb1f963c029a665e2b9f38"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE\n cqrs_inventory_product_customizations_query\n SET\n version = $1,\n name = $2,\n product_id = $3,\n deleted = $4;",
|
||||
"query": "UPDATE\n cqrs_inventory_product_customizations_query\n SET\n version = $1,\n name = $2,\n customization_id = $3,\n product_id = $4,\n deleted = $5;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
|
@ -8,10 +8,11 @@
|
|||
"Int8",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "d46bb69f4e2afbae01ab08beb48a67b2cade64d9ebd47f3fc6143b057671cc1b"
|
||||
"hash": "e88a5dae732c3f8180664f306b4bb1d21f97a2f1391860eb8714a52ef4439d81"
|
||||
}
|
|
@ -4,11 +4,11 @@ steps:
|
|||
when:
|
||||
event: [push, pull_request, tag, deployment]
|
||||
environment:
|
||||
DATABASE_URL: postgres://postgres:password@database:5432/postgres
|
||||
VANIKAM_email_URL: smtp://admin:password@email:10025
|
||||
VANIKAM_meili_API_KEY: 5c8eb5f46c148884fb64da09be211a18347fbba24435ca603adc9eba608ba66d
|
||||
VANIKAM_meili_URL: http://meilisearch:7700
|
||||
MAILPIT_URL: http://email:1080
|
||||
- DATABASE_URL=postgres://postgres:password@database:5432/postgres
|
||||
- VANIKAM_email_URL=smtp://admin:password@email:10025
|
||||
- VANIKAM_meili_API_KEY=5c8eb5f46c148884fb64da09be211a18347fbba24435ca603adc9eba608ba66d
|
||||
- VANIKAM_meili_URL=http://meilisearch:7700
|
||||
- MAILPIT_URL=http://email:1080
|
||||
commands:
|
||||
# - curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &&\
|
||||
# - apt update && apt-get -y --no-install-recommends install nodejs tar gpg curl wget
|
||||
|
@ -69,21 +69,32 @@ steps:
|
|||
# secrets: [RELEASE_BOT_GPG_SIGNING_KEY, DUMBSERVE_PASSWORD, GPG_PASSWORD]
|
||||
#
|
||||
services:
|
||||
# email:
|
||||
# image: axllent/mailpit
|
||||
# environment:
|
||||
# - MP_SMTP_AUTH=admin:password
|
||||
# - MP_MAX_MESSAGES=5000
|
||||
# - MP_SMTP_AUTH_ALLOW_INSECURE=1
|
||||
# - MP_SMTP_BIND_ADDR=0.0.0.0:10025
|
||||
# - MP_SMTP_AUTH_ALLOW_INSECURE=true
|
||||
# - MP_UI_BIND_ADDR=0.0.0.0:1080
|
||||
|
||||
|
||||
database:
|
||||
image: postgres
|
||||
environment:
|
||||
POSTGRES_PASSWORD: password
|
||||
- POSTGRES_PASSWORD=password
|
||||
|
||||
meilisearch:
|
||||
image: getmeili/meilisearch:v1.10
|
||||
environment:
|
||||
MEILI_ENV: development
|
||||
MEILI_MASTER_KEY: 5c8eb5f46c148884fb64da09be211a18347fbba24435ca603adc9eba608ba66d
|
||||
- MEILI_ENV=development
|
||||
- MEILI_MASTER_KEY=5c8eb5f46c148884fb64da09be211a18347fbba24435ca603adc9eba608ba66d
|
||||
|
||||
email:
|
||||
image: axllent/mailpit
|
||||
environment:
|
||||
MP_SMTP_BIND_ADDR: 0.0.0.0:10025
|
||||
MP_UI_BIND_ADDR: 0.0.0.0:1080
|
||||
MP_SMTP_AUTH_ACCEPT_ANY: true
|
||||
MP_SMTP_AUTH_ALLOW_INSECURE: true
|
||||
- MP_SMTP_BIND_ADDR=0.0.0.0:10025
|
||||
- MP_UI_BIND_ADDR=0.0.0.0:1080
|
||||
- MP_SMTP_AUTH_ACCEPT_ANY=true
|
||||
- MP_SMTP_AUTH_ALLOW_INSECURE=true
|
||||
|
|
838
Cargo.lock
generated
838
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -39,5 +39,5 @@ uuid = { version = "1.10.0", features = ["v4", "serde"] }
|
|||
validator = { version = "0.18.1", features = ["derive"] }
|
||||
|
||||
[dev-dependencies]
|
||||
#reqwest = { version = "0.12.4", features = ["json"] }
|
||||
reqwest = { version = "0.12.4", features = ["json"] }
|
||||
mailpit_client = { path = "./mailpit_client" }
|
||||
|
|
42
devenv.lock
42
devenv.lock
|
@ -3,11 +3,11 @@
|
|||
"devenv": {
|
||||
"locked": {
|
||||
"dir": "src/modules",
|
||||
"lastModified": 1734441494,
|
||||
"lastModified": 1726063457,
|
||||
"owner": "cachix",
|
||||
"repo": "devenv",
|
||||
"rev": "bdc1a2cefdda8f89e31b1a0f3771786ba9e5d052",
|
||||
"treeHash": "9f63e582153de59f2326d8efb83d2f8eedd71f58",
|
||||
"rev": "39bf6ce569103c9390d37322daa59468c31b3ce7",
|
||||
"treeHash": "839747a1cb35ba6d5b36cce9a739ab2ba5e4a5d4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -25,11 +25,11 @@
|
|||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1734503722,
|
||||
"lastModified": 1726116637,
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "07f1f47c8f634a5ec52a2ad1d14e7cc7521d9a4f",
|
||||
"treeHash": "2dbf42e1832bef3cd88faa0c6e8cb8214f605842",
|
||||
"rev": "96a04a213838c5001619ad57400c5a176fa040b1",
|
||||
"treeHash": "af83666a28d8bb6aa6d4c0e5f4a2a9c6c158e272",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -41,11 +41,11 @@
|
|||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1733328505,
|
||||
"lastModified": 1696426674,
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||
"treeHash": "d21e133bedc810d4a3aafe31710858e83fff682b",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -77,11 +77,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1733477122,
|
||||
"lastModified": 1716977621,
|
||||
"owner": "cachix",
|
||||
"repo": "devenv-nixpkgs",
|
||||
"rev": "7bd9e84d0452f6d2e63b6e6da29fe73fac951857",
|
||||
"treeHash": "032ee7a856bf5572e8f923acbe45fe22a955d16e",
|
||||
"rev": "4267e705586473d3e5c8d50299e71503f16a6fb6",
|
||||
"treeHash": "6d9f1f7ca0faf1bc2eeb397c78a49623260d3412",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -93,11 +93,11 @@
|
|||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1734202038,
|
||||
"lastModified": 1725930920,
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "bcba2fbf6963bf6bed3a749f9f4cf5bff4adb96d",
|
||||
"treeHash": "ed868e7045ff3d48595deec9ca09f1311c91e749",
|
||||
"rev": "44a71ff39c182edaf25a7ace5c9454e7cba2c658",
|
||||
"treeHash": "56e93544112b7bb7aa0c3093d537295683ef9148",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -117,11 +117,11 @@
|
|||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1734425854,
|
||||
"lastModified": 1725513492,
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "0ddd26d0925f618c3a5d85a4fa5eb1e23a09491d",
|
||||
"treeHash": "7180381e4de59f052b3a3134571af84dc523fd93",
|
||||
"rev": "7570de7b9b504cfe92025dd1be797bf546f66528",
|
||||
"treeHash": "4b46d77870afecd8f642541cb4f4927326343b59",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -141,11 +141,11 @@
|
|||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1734386068,
|
||||
"lastModified": 1726144767,
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "0a706f7d2ac093985eae317781200689cfd48b78",
|
||||
"treeHash": "3f8418c9949a4084758a307478884360952624d2",
|
||||
"rev": "fd243cd0fbad8297e7a3c86f18aa5f0a110bb85f",
|
||||
"treeHash": "8fbbce6f1b56bbcbe27c9af7f6298582c22ae34d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
pkgs.podman
|
||||
pkgs.podman-compose
|
||||
pkgs.openssl
|
||||
pkgs.openssl
|
||||
pkgs.direnv
|
||||
];
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ services:
|
|||
# - MAILDEV_INCOMING_PASS=password
|
||||
|
||||
postgres:
|
||||
image: postgres:17.0
|
||||
image: postgres:16.4
|
||||
network_mode: host
|
||||
environment:
|
||||
POSTGRES_PASSWORD: password
|
||||
|
|
|
@ -4,7 +4,7 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
reqwest = { version = "0.12.4", features = ["json", "native-tls-vendored"] }
|
||||
reqwest = { version = "0.12.4", features = ["json"] }
|
||||
serde = { version = "1.0.201", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
actix-rt = "2.9.0"
|
||||
|
|
|
@ -8,9 +8,8 @@ CREATE TABLE IF NOT EXISTS cqrs_ordering_order_query
|
|||
|
||||
created_time timestamp with time zone DEFAULT (CURRENT_TIMESTAMP) NOT NULL,
|
||||
order_id UUID NOT NULL UNIQUE,
|
||||
store_id UUID NOT NULL,
|
||||
|
||||
customer_name TEXT,
|
||||
customer_name TEXT NOT NULL,
|
||||
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
-- SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
--
|
||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
CREATE TABLE IF NOT EXISTS emp_login_otp (
|
||||
otp INTEGER NOT NULL UNIQUE,
|
||||
created_at timestamp with time zone DEFAULT (CURRENT_TIMESTAMP),
|
||||
purpose TEXT NOT NULL,
|
||||
emp_id UUID NOT NULL,
|
||||
ID SERIAL PRIMARY KEY NOT NULL
|
||||
);
|
|
@ -1,11 +0,0 @@
|
|||
-- SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
--
|
||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
CREATE TABLE IF NOT EXISTS emp_verification_otp (
|
||||
otp INTEGER NOT NULL UNIQUE,
|
||||
created_at timestamp with time zone DEFAULT (CURRENT_TIMESTAMP),
|
||||
purpose TEXT NOT NULL,
|
||||
emp_id UUID NOT NULL,
|
||||
ID SERIAL PRIMARY KEY NOT NULL
|
||||
);
|
|
@ -1,28 +0,0 @@
|
|||
-- SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
--
|
||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
CREATE TABLE IF NOT EXISTS cqrs_identity_employee_query
|
||||
(
|
||||
version bigint CHECK (version >= 0) NOT NULL,
|
||||
|
||||
created_time timestamp with time zone DEFAULT (CURRENT_TIMESTAMP) NOT NULL,
|
||||
|
||||
first_name TEXT NOT NULL,
|
||||
last_name TEXT NOT NULL,
|
||||
|
||||
emp_id UUID NOT NULL UNIQUE,
|
||||
|
||||
|
||||
|
||||
phone_number_country_code INTEGER NOT NULL,
|
||||
phone_number_number BIGINT NOT NULL,
|
||||
|
||||
phone_verified BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
store_id UUID DEFAULT NULL,
|
||||
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
PRIMARY KEY (emp_id)
|
||||
);
|
|
@ -1,37 +0,0 @@
|
|||
thread 'rustc' panicked at compiler/rustc_middle/src/query/on_disk_cache.rs:736:21:
|
||||
Failed to convert DefPathHash DefPathHash(Fingerprint(9597590199268592635, 17791879502897349522))
|
||||
stack backtrace:
|
||||
0: 0x7fbfbb48d025 - std::backtrace::Backtrace::create::hbc256ff4bc983c0b
|
||||
1: 0x7fbfb9c8c865 - std::backtrace::Backtrace::force_capture::h1ebb6042c5b424a8
|
||||
2: 0x7fbfb8db2217 - std[11ac8361619e45fd]::panicking::update_hook::<alloc[1ed43557cf619c2]::boxed::Box<rustc_driver_impl[8c32a9dec5e4d0f0]::install_ice_hook::{closure#0}>>::{closure#0}
|
||||
3: 0x7fbfb9ca3ee8 - std::panicking::rust_panic_with_hook::ha6cfc51100acb1ab
|
||||
4: 0x7fbfb9ca3cb7 - std::panicking::begin_panic_handler::{{closure}}::he56e1efe5ba67ce1
|
||||
5: 0x7fbfb9ca1699 - std::sys::backtrace::__rust_end_short_backtrace::hcc7bf1345a5f7ae3
|
||||
6: 0x7fbfb9ca3984 - rust_begin_unwind
|
||||
7: 0x7fbfb6ad55c3 - core::panicking::panic_fmt::h146c2ef4416c8c7b
|
||||
8: 0x7fbfba61abc5 - <rustc_middle[62c17eb200ed25ef]::query::on_disk_cache::CacheDecoder as rustc_span[e2902ef3f031f316]::SpanDecoder>::decode_span
|
||||
9: 0x7fbfba94bc1c - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||
10: 0x7fbfba94929a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::def_span::get_query_incr::__rust_end_short_backtrace
|
||||
11: 0x7fbfbaa190c0 - rustc_middle[62c17eb200ed25ef]::query::plumbing::query_get_at::<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>>
|
||||
12: 0x7fbfbacaaf7d - <rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::InherentOverlapChecker>::check_for_duplicate_items_in_impl
|
||||
13: 0x7fbfbb39e280 - rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::crate_inherent_impls_overlap_check
|
||||
14: 0x7fbfbb39dc6d - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||
15: 0x7fbfbb39d1fd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||
16: 0x7fbfbb39c867 - rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::get_query_incr::__rust_end_short_backtrace
|
||||
17: 0x7fbfba5bb6f3 - rustc_hir_analysis[198913e0276c9380]::check_crate
|
||||
18: 0x7fbfba5b1351 - rustc_interface[d7e86b952eb641e5]::passes::run_required_analyses
|
||||
19: 0x7fbfbb1bac1e - rustc_interface[d7e86b952eb641e5]::passes::analysis
|
||||
20: 0x7fbfbb1babf1 - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||
21: 0x7fbfbb39cecd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||
22: 0x7fbfbb39cb7a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
|
||||
23: 0x7fbfbb1b30bc - rustc_interface[d7e86b952eb641e5]::interface::run_compiler::<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}
|
||||
24: 0x7fbfbb2c0504 - std[11ac8361619e45fd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>
|
||||
25: 0x7fbfbb2c0b70 - <<std[11ac8361619e45fd]::thread::Builder>::spawn_unchecked_<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#1} as core[dcc560a250502550]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
|
||||
26: 0x7fbfbb2c0f6b - std::sys::pal::unix::thread::Thread::new::thread_start::h1921d0f3a7850262
|
||||
27: 0x7fbfbcbf8272 - start_thread
|
||||
28: 0x7fbfbcc73dcc - clone3
|
||||
29: 0x0 - <unknown>
|
||||
|
||||
|
||||
rustc version: 1.83.0-nightly (0ee7cb5e3 2024-09-10)
|
||||
platform: x86_64-unknown-linux-gnu
|
|
@ -1,37 +0,0 @@
|
|||
thread 'rustc' panicked at compiler/rustc_middle/src/query/on_disk_cache.rs:736:21:
|
||||
Failed to convert DefPathHash DefPathHash(Fingerprint(9597590199268592635, 17791879502897349522))
|
||||
stack backtrace:
|
||||
0: 0x77c2cca8d025 - std::backtrace::Backtrace::create::hbc256ff4bc983c0b
|
||||
1: 0x77c2cb28c865 - std::backtrace::Backtrace::force_capture::h1ebb6042c5b424a8
|
||||
2: 0x77c2ca3b2217 - std[11ac8361619e45fd]::panicking::update_hook::<alloc[1ed43557cf619c2]::boxed::Box<rustc_driver_impl[8c32a9dec5e4d0f0]::install_ice_hook::{closure#0}>>::{closure#0}
|
||||
3: 0x77c2cb2a3ee8 - std::panicking::rust_panic_with_hook::ha6cfc51100acb1ab
|
||||
4: 0x77c2cb2a3cb7 - std::panicking::begin_panic_handler::{{closure}}::he56e1efe5ba67ce1
|
||||
5: 0x77c2cb2a1699 - std::sys::backtrace::__rust_end_short_backtrace::hcc7bf1345a5f7ae3
|
||||
6: 0x77c2cb2a3984 - rust_begin_unwind
|
||||
7: 0x77c2c80d55c3 - core::panicking::panic_fmt::h146c2ef4416c8c7b
|
||||
8: 0x77c2cbc1abc5 - <rustc_middle[62c17eb200ed25ef]::query::on_disk_cache::CacheDecoder as rustc_span[e2902ef3f031f316]::SpanDecoder>::decode_span
|
||||
9: 0x77c2cbf4bc1c - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||
10: 0x77c2cbf4929a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::def_span::get_query_incr::__rust_end_short_backtrace
|
||||
11: 0x77c2cc0190c0 - rustc_middle[62c17eb200ed25ef]::query::plumbing::query_get_at::<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>>
|
||||
12: 0x77c2cc2aaf7d - <rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::InherentOverlapChecker>::check_for_duplicate_items_in_impl
|
||||
13: 0x77c2cc99e280 - rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::crate_inherent_impls_overlap_check
|
||||
14: 0x77c2cc99dc6d - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||
15: 0x77c2cc99d1fd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||
16: 0x77c2cc99c867 - rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::get_query_incr::__rust_end_short_backtrace
|
||||
17: 0x77c2cbbbb6f3 - rustc_hir_analysis[198913e0276c9380]::check_crate
|
||||
18: 0x77c2cbbb1351 - rustc_interface[d7e86b952eb641e5]::passes::run_required_analyses
|
||||
19: 0x77c2cc7bac1e - rustc_interface[d7e86b952eb641e5]::passes::analysis
|
||||
20: 0x77c2cc7babf1 - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||
21: 0x77c2cc99cecd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||
22: 0x77c2cc99cb7a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
|
||||
23: 0x77c2cc7b30bc - rustc_interface[d7e86b952eb641e5]::interface::run_compiler::<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}
|
||||
24: 0x77c2cc8c0504 - std[11ac8361619e45fd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>
|
||||
25: 0x77c2cc8c0b70 - <<std[11ac8361619e45fd]::thread::Builder>::spawn_unchecked_<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#1} as core[dcc560a250502550]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
|
||||
26: 0x77c2cc8c0f6b - std::sys::pal::unix::thread::Thread::new::thread_start::h1921d0f3a7850262
|
||||
27: 0x77c2ce089272 - start_thread
|
||||
28: 0x77c2ce104dcc - clone3
|
||||
29: 0x0 - <unknown>
|
||||
|
||||
|
||||
rustc version: 1.83.0-nightly (0ee7cb5e3 2024-09-10)
|
||||
platform: x86_64-unknown-linux-gnu
|
|
@ -1,37 +0,0 @@
|
|||
thread 'rustc' panicked at compiler/rustc_middle/src/query/on_disk_cache.rs:736:21:
|
||||
Failed to convert DefPathHash DefPathHash(Fingerprint(9597590199268592635, 17791879502897349522))
|
||||
stack backtrace:
|
||||
0: 0x704a8948d025 - std::backtrace::Backtrace::create::hbc256ff4bc983c0b
|
||||
1: 0x704a87c8c865 - std::backtrace::Backtrace::force_capture::h1ebb6042c5b424a8
|
||||
2: 0x704a86db2217 - std[11ac8361619e45fd]::panicking::update_hook::<alloc[1ed43557cf619c2]::boxed::Box<rustc_driver_impl[8c32a9dec5e4d0f0]::install_ice_hook::{closure#0}>>::{closure#0}
|
||||
3: 0x704a87ca3ee8 - std::panicking::rust_panic_with_hook::ha6cfc51100acb1ab
|
||||
4: 0x704a87ca3cb7 - std::panicking::begin_panic_handler::{{closure}}::he56e1efe5ba67ce1
|
||||
5: 0x704a87ca1699 - std::sys::backtrace::__rust_end_short_backtrace::hcc7bf1345a5f7ae3
|
||||
6: 0x704a87ca3984 - rust_begin_unwind
|
||||
7: 0x704a84ad55c3 - core::panicking::panic_fmt::h146c2ef4416c8c7b
|
||||
8: 0x704a8861abc5 - <rustc_middle[62c17eb200ed25ef]::query::on_disk_cache::CacheDecoder as rustc_span[e2902ef3f031f316]::SpanDecoder>::decode_span
|
||||
9: 0x704a8894bc1c - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||
10: 0x704a8894929a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::def_span::get_query_incr::__rust_end_short_backtrace
|
||||
11: 0x704a88a190c0 - rustc_middle[62c17eb200ed25ef]::query::plumbing::query_get_at::<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>>
|
||||
12: 0x704a88caaf7d - <rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::InherentOverlapChecker>::check_for_duplicate_items_in_impl
|
||||
13: 0x704a8939e280 - rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::crate_inherent_impls_overlap_check
|
||||
14: 0x704a8939dc6d - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||
15: 0x704a8939d1fd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||
16: 0x704a8939c867 - rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::get_query_incr::__rust_end_short_backtrace
|
||||
17: 0x704a885bb6f3 - rustc_hir_analysis[198913e0276c9380]::check_crate
|
||||
18: 0x704a885b1351 - rustc_interface[d7e86b952eb641e5]::passes::run_required_analyses
|
||||
19: 0x704a891bac1e - rustc_interface[d7e86b952eb641e5]::passes::analysis
|
||||
20: 0x704a891babf1 - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||
21: 0x704a8939cecd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||
22: 0x704a8939cb7a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
|
||||
23: 0x704a891b30bc - rustc_interface[d7e86b952eb641e5]::interface::run_compiler::<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}
|
||||
24: 0x704a892c0504 - std[11ac8361619e45fd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>
|
||||
25: 0x704a892c0b70 - <<std[11ac8361619e45fd]::thread::Builder>::spawn_unchecked_<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#1} as core[dcc560a250502550]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
|
||||
26: 0x704a892c0f6b - std::sys::pal::unix::thread::Thread::new::thread_start::h1921d0f3a7850262
|
||||
27: 0x704a8ac0b272 - start_thread
|
||||
28: 0x704a8ac86dcc - clone3
|
||||
29: 0x0 - <unknown>
|
||||
|
||||
|
||||
rustc version: 1.83.0-nightly (0ee7cb5e3 2024-09-10)
|
||||
platform: x86_64-unknown-linux-gnu
|
|
@ -36,7 +36,7 @@ pub mod tests {
|
|||
// use crate::billing::domain::add_product_command::tests::get_customizations;
|
||||
use crate::billing::domain::bill_aggregate::*;
|
||||
|
||||
pub async fn create_dummy_bill(bill: &Bill, db: &BillingDBPostgresAdapter) {
|
||||
async fn create_dummy_bill(bill: &Bill, db: &BillingDBPostgresAdapter) {
|
||||
sqlx::query!(
|
||||
"INSERT INTO cqrs_billing_bill_query (
|
||||
version,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use cqrs_es::persist::{PersistenceError, ViewContext, ViewRepository};
|
||||
use cqrs_es::{EventEnvelope, Query, View};
|
||||
|
@ -13,9 +11,8 @@ use uuid::Uuid;
|
|||
|
||||
use super::errors::*;
|
||||
use super::BillingDBPostgresAdapter;
|
||||
use crate::billing::domain::bill_aggregate::{Bill, BillBuilder};
|
||||
use crate::billing::domain::bill_aggregate::Bill;
|
||||
use crate::billing::domain::events::BillingEvent;
|
||||
use crate::types::currency::{self, Currency, PriceBuilder};
|
||||
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
||||
|
||||
pub const NEW_BILL_NON_UUID: &str = "billing_new_bill_non_uuid-asdfa";
|
||||
|
@ -37,36 +34,6 @@ pub struct BillView {
|
|||
deleted: bool,
|
||||
}
|
||||
|
||||
impl From<BillView> for Bill {
|
||||
fn from(v: BillView) -> Self {
|
||||
let price = match (
|
||||
v.total_price_minor,
|
||||
v.total_price_major,
|
||||
v.total_price_currency,
|
||||
) {
|
||||
(Some(minor), Some(major), Some(currency)) => Some(
|
||||
PriceBuilder::default()
|
||||
.major(major as usize)
|
||||
.minor(minor as usize)
|
||||
.currency(Currency::from_str(¤cy).unwrap())
|
||||
.build()
|
||||
.unwrap(),
|
||||
),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
BillBuilder::default()
|
||||
.created_time(v.created_time)
|
||||
.store_id(v.store_id)
|
||||
.bill_id(v.bill_id)
|
||||
.token_number(v.token_number as usize)
|
||||
.total_price(price)
|
||||
.deleted(v.deleted)
|
||||
.build()
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for BillView {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
@ -258,14 +225,17 @@ impl ViewRepository<BillView, Bill> for BillingDBPostgresAdapter {
|
|||
|
||||
created_time = $2,
|
||||
store_id = $3,
|
||||
token_number = $4,
|
||||
total_price_major = $5,
|
||||
total_price_minor = $6,
|
||||
total_price_currency = $7,
|
||||
deleted = $8;",
|
||||
bill_id = $4,
|
||||
token_number = $5,
|
||||
total_price_major = $6,
|
||||
total_price_minor = $7,
|
||||
total_price_currency = $8,
|
||||
|
||||
deleted = $9;",
|
||||
version,
|
||||
view.created_time,
|
||||
view.store_id,
|
||||
view.bill_id,
|
||||
view.token_number,
|
||||
view.total_price_major,
|
||||
view.total_price_minor,
|
||||
|
@ -311,136 +281,108 @@ impl Query<Bill> for BillingDBPostgresAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
// Our second query, this one will be handled with Postgres `GenericQuery`
|
||||
// which will serialize and persist our view after it is updated. It also
|
||||
// provides a `load` method to deserialize the view on request.
|
||||
//pub type BillQuery = GenericQuery<BillingDBPostgresAdapter, BillView, Bill>;
|
||||
//pub type BillQuery = Query<dyn BillingDBPostgresAdapter, BillView, Bill>;
|
||||
|
||||
use postgres_es::PostgresCqrs;
|
||||
|
||||
use crate::{
|
||||
billing::{
|
||||
application::services::{
|
||||
add_bill_service::AddBillServiceBuilder, update_bill_service::*,
|
||||
MockBillingServicesInterface,
|
||||
},
|
||||
domain::{
|
||||
add_bill_command::*, commands::BillingCommand, store_aggregate::Store,
|
||||
update_bill_command::*,
|
||||
},
|
||||
},
|
||||
db::migrate::*,
|
||||
tests::bdd::*,
|
||||
utils::uuid::tests::*,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn pg_query_billing_bill_view() {
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
//let settings = crate::settings::Settings::new().unwrap();
|
||||
settings.create_db().await;
|
||||
|
||||
let db = crate::db::sqlx_postgres::Postgres::init(&settings.database.url).await;
|
||||
db.migrate().await;
|
||||
let db = BillingDBPostgresAdapter::new(db.pool.clone());
|
||||
|
||||
let simple_query = SimpleLoggingQuery {};
|
||||
|
||||
let queries: Vec<Box<dyn Query<Bill>>> = vec![Box::new(simple_query), Box::new(db.clone())];
|
||||
|
||||
let mut mock_services = MockBillingServicesInterface::new();
|
||||
|
||||
let store = Store::default();
|
||||
crate::billing::adapters::output::db::postgres::store_id_exists::tests::create_dummy_store_record(&store, &db).await;
|
||||
|
||||
let db2 = db.clone();
|
||||
mock_services
|
||||
.expect_add_bill()
|
||||
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||
.returning(move || {
|
||||
Arc::new(
|
||||
AddBillServiceBuilder::default()
|
||||
.db_bill_id_exists(Arc::new(db2.clone()))
|
||||
.db_next_token_id(Arc::new(db2.clone()))
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
let db2 = db.clone();
|
||||
mock_services
|
||||
.expect_update_bill()
|
||||
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||
.returning(move || {
|
||||
Arc::new(
|
||||
UpdateBillServiceBuilder::default()
|
||||
.db_bill_id_exists(Arc::new(db2.clone()))
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
let (cqrs, bill_query): (
|
||||
Arc<PostgresCqrs<Bill>>,
|
||||
Arc<dyn ViewRepository<BillView, Bill>>,
|
||||
) = (
|
||||
Arc::new(postgres_es::postgres_cqrs(
|
||||
db.pool.clone(),
|
||||
queries,
|
||||
Arc::new(mock_services),
|
||||
)),
|
||||
Arc::new(db.clone()),
|
||||
);
|
||||
|
||||
let cmd = AddBillCommandBuilder::default()
|
||||
.adding_by(UUID)
|
||||
.bill_id(UUID)
|
||||
.store_id(*store.store_id())
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
cqrs.execute(
|
||||
&cmd.bill_id().to_string(),
|
||||
BillingCommand::AddBill(cmd.clone()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let bill = bill_query
|
||||
.load(&(*cmd.bill_id()).to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let bill: Bill = bill.into();
|
||||
assert_eq!(bill.store_id(), cmd.store_id());
|
||||
assert_eq!(bill.bill_id(), cmd.bill_id());
|
||||
assert!(!bill.deleted());
|
||||
|
||||
let update_bill_cmd = UpdateBillCommandBuilder::default()
|
||||
.adding_by(UUID)
|
||||
.store_id(*store.store_id())
|
||||
.total_price(None)
|
||||
.old_bill(bill.clone())
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
cqrs.execute(
|
||||
&cmd.bill_id().to_string(),
|
||||
BillingCommand::UpdateBill(update_bill_cmd.clone()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let bill = bill_query
|
||||
.load(&(*cmd.bill_id()).to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let bill: Bill = bill.into();
|
||||
assert_eq!(bill.store_id(), cmd.store_id());
|
||||
assert_eq!(bill.bill_id(), update_bill_cmd.old_bill().bill_id());
|
||||
assert_eq!(bill.total_price(), update_bill_cmd.total_price());
|
||||
assert!(!bill.deleted());
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
||||
//#[cfg(test)]
|
||||
//mod tests {
|
||||
// use super::*;
|
||||
//
|
||||
// use postgres_es::PostgresCqrs;
|
||||
//
|
||||
// use crate::{
|
||||
// db::migrate::*,
|
||||
// billing::{
|
||||
// application::services::{
|
||||
// add_category_service::tests::mock_add_category_service, add_customization_service::tests::mock_add_customization_service, add_line_item_service::tests::mock_add_line_item_service, add_product_service::tests::mock_add_product_service, add_bill_service::AddBillServiceBuilder, update_category_service::tests::mock_update_category_service, update_customization_service::tests::mock_update_customization_service, update_product_service::tests::mock_update_product_service, update_bill_service::tests::mock_update_bill_service, BillingServicesBuilder
|
||||
// },
|
||||
// domain::{
|
||||
// add_category_command::AddCategoryCommand, add_customization_command,
|
||||
// add_product_command::tests::get_command, add_bill_command::AddBillCommand,
|
||||
// commands::BillingCommand,
|
||||
// update_category_command::tests::get_update_category_command,
|
||||
// update_customization_command::tests::get_update_customization_command,
|
||||
// update_product_command, update_bill_command::tests::get_update_bill_cmd,
|
||||
// },
|
||||
// },
|
||||
// tests::bdd::IS_NEVER_CALLED,
|
||||
// utils::{random_string::GenerateRandomStringInterface, uuid::tests::UUID},
|
||||
// };
|
||||
// use std::sync::Arc;
|
||||
//
|
||||
// #[actix_rt::test]
|
||||
// async fn pg_query() {
|
||||
// let settings = crate::settings::tests::get_settings().await;
|
||||
// //let settings = crate::settings::Settings::new().unwrap();
|
||||
// settings.create_db().await;
|
||||
//
|
||||
// let db = crate::db::sqlx_postgres::Postgres::init(&settings.database.url).await;
|
||||
// db.migrate().await;
|
||||
// let db = BillingDBPostgresAdapter::new(db.pool.clone());
|
||||
//
|
||||
// let simple_query = SimpleLoggingQuery {};
|
||||
//
|
||||
// let queries: Vec<Box<dyn Query<Bill>>> =
|
||||
// vec![Box::new(simple_query), Box::new(db.clone())];
|
||||
//
|
||||
// let services = BillingServicesBuilder::default()
|
||||
// .add_bill(Arc::new(
|
||||
// AddBillServiceBuilder::default()
|
||||
// .db_bill_id_exists(Arc::new(db.clone()))
|
||||
// .db_bill_name_exists(Arc::new(db.clone()))
|
||||
// .get_uuid(Arc::new(crate::utils::uuid::GenerateUUID {}))
|
||||
// .build()
|
||||
// .unwrap(),
|
||||
// ))
|
||||
// .add_category(mock_add_category_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// AddCategoryCommand::new("foo".into(), None, UUID, UUID).unwrap(),
|
||||
// ))
|
||||
// .add_product(mock_add_product_service(IS_NEVER_CALLED, get_command()))
|
||||
// .add_customization(mock_add_customization_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// add_customization_command::tests::get_command(),
|
||||
// ))
|
||||
// .update_product(mock_update_product_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// update_product_command::tests::get_command(),
|
||||
// ))
|
||||
// .update_customization(mock_update_customization_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// get_update_customization_command(),
|
||||
// ))
|
||||
// .update_category(mock_update_category_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// get_update_category_command(),
|
||||
// ))
|
||||
// .update_bill(mock_update_bill_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// get_update_bill_cmd(),
|
||||
// ))
|
||||
// .build()
|
||||
// .unwrap();
|
||||
//
|
||||
// let (cqrs, _bill_query): (
|
||||
// Arc<PostgresCqrs<Bill>>,
|
||||
// Arc<dyn ViewRepository<BillView, Bill>>,
|
||||
// ) = (
|
||||
// Arc::new(postgres_es::postgres_cqrs(
|
||||
// db.pool.clone(),
|
||||
// queries,
|
||||
// Arc::new(services),
|
||||
// )),
|
||||
// Arc::new(db.clone()),
|
||||
// );
|
||||
//
|
||||
// let rand = crate::utils::random_string::GenerateRandomString {};
|
||||
// let cmd = AddBillCommand::new(rand.get_random(10), None, UUID).unwrap();
|
||||
// cqrs.execute("", BillingCommand::AddBill(cmd.clone()))
|
||||
// .await
|
||||
// .unwrap();
|
||||
//
|
||||
// settings.drop_db().await;
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -309,19 +309,21 @@ impl ViewRepository<LineItemView, LineItem> for BillingDBPostgresAdapter {
|
|||
version = $1,
|
||||
product_name = $2,
|
||||
product_id = $3,
|
||||
quantity_minor_unit = $4,
|
||||
quantity_minor_number = $5,
|
||||
quantity_major_unit = $6,
|
||||
quantity_major_number = $7,
|
||||
created_time = $8,
|
||||
bill_id = $9,
|
||||
price_per_unit_minor = $10 ,
|
||||
price_per_unit_major = $11,
|
||||
price_per_unit_currency = $12,
|
||||
deleted = $13;",
|
||||
line_item_id = $4,
|
||||
quantity_minor_unit = $5,
|
||||
quantity_minor_number = $6,
|
||||
quantity_major_unit = $7,
|
||||
quantity_major_number = $8,
|
||||
created_time = $9,
|
||||
bill_id = $10,
|
||||
price_per_unit_minor = $11 ,
|
||||
price_per_unit_major = $12,
|
||||
price_per_unit_currency = $13,
|
||||
deleted = $14;",
|
||||
version,
|
||||
view.product_name,
|
||||
view.product_id,
|
||||
view.line_item_id,
|
||||
view.quantity_minor_unit,
|
||||
view.quantity_minor_number,
|
||||
view.quantity_major_unit,
|
||||
|
@ -362,215 +364,3 @@ impl Query<LineItem> for BillingDBPostgresAdapter {
|
|||
self.update_view(view, view_context).await.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use postgres_es::PostgresCqrs;
|
||||
|
||||
use crate::{
|
||||
billing::{
|
||||
application::services::{
|
||||
add_line_item_service::AddLineItemServiceBuilder, delete_line_item_service::*,
|
||||
update_line_item_service::*, MockBillingServicesInterface,
|
||||
},
|
||||
domain::{
|
||||
add_line_item_command::*, bill_aggregate::Bill, commands::BillingCommand,
|
||||
delete_line_item_command::DeleteLineItemCommandBuilder,
|
||||
update_line_item_command::*,
|
||||
},
|
||||
},
|
||||
db::migrate::*,
|
||||
tests::bdd::*,
|
||||
types::quantity::*,
|
||||
utils::{
|
||||
random_string::GenerateRandomStringInterface,
|
||||
uuid::{tests::UUID, *},
|
||||
},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn pg_query_billing_line_item_view() {
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
//let settings = crate::settings::Settings::new().unwrap();
|
||||
settings.create_db().await;
|
||||
|
||||
let db = crate::db::sqlx_postgres::Postgres::init(&settings.database.url).await;
|
||||
db.migrate().await;
|
||||
let db = BillingDBPostgresAdapter::new(db.pool.clone());
|
||||
|
||||
let queries: Vec<Box<dyn Query<LineItem>>> = vec![Box::new(db.clone())];
|
||||
|
||||
let mut mock_services = MockBillingServicesInterface::new();
|
||||
|
||||
let bill = Bill::default();
|
||||
crate::billing::adapters::output::db::postgres::bill_id_exists::tests::create_dummy_bill(
|
||||
&bill, &db,
|
||||
)
|
||||
.await;
|
||||
|
||||
let db2 = db.clone();
|
||||
mock_services
|
||||
.expect_add_line_item()
|
||||
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||
.returning(move || {
|
||||
Arc::new(
|
||||
AddLineItemServiceBuilder::default()
|
||||
.db_line_item_id_exists(Arc::new(db2.clone()))
|
||||
.db_bill_id_exists(Arc::new(db2.clone()))
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
let db2 = db.clone();
|
||||
mock_services
|
||||
.expect_update_line_item()
|
||||
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||
.returning(move || {
|
||||
Arc::new(
|
||||
UpdateLineItemServiceBuilder::default()
|
||||
.db_line_item_id_exists(Arc::new(db2.clone()))
|
||||
.db_bill_id_exists(Arc::new(db2.clone()))
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
let db2 = db.clone();
|
||||
mock_services
|
||||
.expect_delete_line_item()
|
||||
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||
.returning(move || {
|
||||
Arc::new(
|
||||
DeleteLineItemServiceBuilder::default()
|
||||
.db_line_item_id_exists(Arc::new(db2.clone()))
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
let (cqrs, line_item_query): (
|
||||
Arc<PostgresCqrs<LineItem>>,
|
||||
Arc<dyn ViewRepository<LineItemView, LineItem>>,
|
||||
) = (
|
||||
Arc::new(postgres_es::postgres_cqrs(
|
||||
db.pool.clone(),
|
||||
queries,
|
||||
Arc::new(mock_services),
|
||||
)),
|
||||
Arc::new(db.clone()),
|
||||
);
|
||||
|
||||
let rand = crate::utils::random_string::GenerateRandomString {};
|
||||
let uuid = GenerateUUID {};
|
||||
let line_item_id = uuid.get_uuid();
|
||||
|
||||
let cmd = AddLineItemCommandBuilder::default()
|
||||
.product_name(rand.get_random(10))
|
||||
.adding_by(UUID)
|
||||
.price_per_unit(Price::default())
|
||||
.quantity(Quantity::get_quantity())
|
||||
.product_id(UUID)
|
||||
.bill_id(*bill.bill_id())
|
||||
.line_item_id(line_item_id)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
cqrs.execute(
|
||||
&cmd.line_item_id().to_string(),
|
||||
BillingCommand::AddLineItem(cmd.clone()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let line_item = line_item_query
|
||||
.load(&(*cmd.line_item_id()).to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let line_item: LineItem = line_item.into();
|
||||
assert_eq!(line_item.line_item_id(), cmd.line_item_id());
|
||||
assert_eq!(line_item.product_name(), cmd.product_name());
|
||||
assert_eq!(line_item.product_id(), cmd.product_id());
|
||||
assert_eq!(line_item.quantity(), cmd.quantity());
|
||||
assert!(!line_item.deleted());
|
||||
|
||||
let update_line_item_cmd = UnvalidatedUpdateLineItemCommandBuilder::default()
|
||||
.product_name(rand.get_random(10))
|
||||
.adding_by(UUID)
|
||||
.quantity(Quantity::get_quantity())
|
||||
.product_id(UUID)
|
||||
.bill_id(*bill.bill_id())
|
||||
.old_line_item(line_item.clone())
|
||||
.price_per_unit(Price::default())
|
||||
.build()
|
||||
.unwrap()
|
||||
.validate()
|
||||
.unwrap();
|
||||
|
||||
cqrs.execute(
|
||||
&cmd.line_item_id().to_string(),
|
||||
BillingCommand::UpdateLineItem(update_line_item_cmd.clone()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let line_item = line_item_query
|
||||
.load(&(*cmd.line_item_id()).to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let line_item: LineItem = line_item.into();
|
||||
assert_eq!(
|
||||
line_item.line_item_id(),
|
||||
update_line_item_cmd.old_line_item().line_item_id()
|
||||
);
|
||||
assert_eq!(
|
||||
line_item.product_name(),
|
||||
update_line_item_cmd.product_name()
|
||||
);
|
||||
assert_eq!(line_item.product_id(), update_line_item_cmd.product_id());
|
||||
assert_eq!(line_item.quantity(), update_line_item_cmd.quantity());
|
||||
assert!(!line_item.deleted());
|
||||
|
||||
// delete
|
||||
let delete_line_item_cmd = DeleteLineItemCommandBuilder::default()
|
||||
.line_item(line_item.clone())
|
||||
.adding_by(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
cqrs.execute(
|
||||
&cmd.line_item_id().to_string(),
|
||||
BillingCommand::DeleteLineItem(delete_line_item_cmd.clone()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let deleted_line_item = line_item_query
|
||||
.load(&(*cmd.line_item_id()).to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let deleted_line_item: LineItem = deleted_line_item.into();
|
||||
assert_eq!(
|
||||
deleted_line_item.line_item_id(),
|
||||
delete_line_item_cmd.line_item().line_item_id()
|
||||
);
|
||||
assert_eq!(
|
||||
deleted_line_item.product_name(),
|
||||
delete_line_item_cmd.line_item().product_name()
|
||||
);
|
||||
assert_eq!(
|
||||
deleted_line_item.product_id(),
|
||||
delete_line_item_cmd.line_item().product_id()
|
||||
);
|
||||
assert_eq!(
|
||||
deleted_line_item.quantity(),
|
||||
delete_line_item_cmd.line_item().quantity()
|
||||
);
|
||||
assert!(deleted_line_item.deleted());
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ pub mod tests {
|
|||
VALUES ($1, $2, $3, $4, $5 ,$6);",
|
||||
1,
|
||||
s.name(),
|
||||
s.address().as_ref().map(|s| s.as_str()),
|
||||
s.address().as_ref().unwrap(),
|
||||
s.store_id(),
|
||||
s.owner(),
|
||||
false
|
||||
|
|
|
@ -11,7 +11,7 @@ use uuid::Uuid;
|
|||
use super::errors::*;
|
||||
use super::BillingDBPostgresAdapter;
|
||||
use crate::billing::domain::events::BillingEvent;
|
||||
use crate::billing::domain::store_aggregate::*;
|
||||
use crate::billing::domain::store_aggregate::Store;
|
||||
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
||||
|
||||
pub const NEW_STORE_NON_UUID: &str = "billing_new_store_non_uuid-asdfa";
|
||||
|
@ -27,19 +27,6 @@ pub struct StoreView {
|
|||
deleted: bool,
|
||||
}
|
||||
|
||||
impl From<StoreView> for Store {
|
||||
fn from(value: StoreView) -> Self {
|
||||
StoreBuilder::default()
|
||||
.name(value.name)
|
||||
.address(value.address)
|
||||
.store_id(value.store_id)
|
||||
.owner(value.owner)
|
||||
.deleted(value.deleted)
|
||||
.build()
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
// This updates the view with events as they are committed.
|
||||
// The logic should be minimal here, e.g., don't calculate the account balance,
|
||||
// design the events to carry the balance information instead.
|
||||
|
@ -169,11 +156,13 @@ impl ViewRepository<StoreView, Store> for BillingDBPostgresAdapter {
|
|||
version = $1,
|
||||
name = $2,
|
||||
address = $3,
|
||||
owner = $4,
|
||||
deleted = $5;",
|
||||
store_id = $4,
|
||||
owner = $5,
|
||||
deleted = $6;",
|
||||
version,
|
||||
view.name,
|
||||
view.address,
|
||||
view.store_id,
|
||||
view.owner,
|
||||
view.deleted,
|
||||
)
|
||||
|
@ -216,138 +205,108 @@ impl Query<Store> for BillingDBPostgresAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
// Our second query, this one will be handled with Postgres `GenericQuery`
|
||||
// which will serialize and persist our view after it is updated. It also
|
||||
// provides a `load` method to deserialize the view on request.
|
||||
//pub type StoreQuery = GenericQuery<BillingDBPostgresAdapter, StoreView, Store>;
|
||||
//pub type StoreQuery = Query<dyn BillingDBPostgresAdapter, StoreView, Store>;
|
||||
|
||||
use postgres_es::PostgresCqrs;
|
||||
|
||||
use crate::{
|
||||
billing::{
|
||||
application::services::{
|
||||
add_store_service::AddStoreServiceBuilder, update_store_service::*,
|
||||
MockBillingServicesInterface,
|
||||
},
|
||||
domain::add_store_command::*,
|
||||
domain::commands::BillingCommand,
|
||||
domain::update_store_command::*,
|
||||
},
|
||||
db::migrate::*,
|
||||
tests::bdd::*,
|
||||
utils::{random_string::GenerateRandomStringInterface, uuid::tests::UUID},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn pg_query_billing_store_view() {
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
//let settings = crate::settings::Settings::new().unwrap();
|
||||
settings.create_db().await;
|
||||
|
||||
let db = crate::db::sqlx_postgres::Postgres::init(&settings.database.url).await;
|
||||
db.migrate().await;
|
||||
let db = BillingDBPostgresAdapter::new(db.pool.clone());
|
||||
|
||||
let simple_query = SimpleLoggingQuery {};
|
||||
|
||||
let queries: Vec<Box<dyn Query<Store>>> =
|
||||
vec![Box::new(simple_query), Box::new(db.clone())];
|
||||
|
||||
let mut mock_services = MockBillingServicesInterface::new();
|
||||
|
||||
let db2 = db.clone();
|
||||
mock_services
|
||||
.expect_add_store()
|
||||
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||
.returning(move || {
|
||||
Arc::new(
|
||||
AddStoreServiceBuilder::default()
|
||||
.db_store_id_exists(Arc::new(db2.clone()))
|
||||
.db_store_name_exists(Arc::new(db2.clone()))
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
let db2 = db.clone();
|
||||
mock_services
|
||||
.expect_update_store()
|
||||
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||
.returning(move || {
|
||||
Arc::new(
|
||||
UpdateStoreServiceBuilder::default()
|
||||
.db_store_id_exists(Arc::new(db2.clone()))
|
||||
.db_store_name_exists(Arc::new(db2.clone()))
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
let (cqrs, store_query): (
|
||||
Arc<PostgresCqrs<Store>>,
|
||||
Arc<dyn ViewRepository<StoreView, Store>>,
|
||||
) = (
|
||||
Arc::new(postgres_es::postgres_cqrs(
|
||||
db.pool.clone(),
|
||||
queries,
|
||||
Arc::new(mock_services),
|
||||
)),
|
||||
Arc::new(db.clone()),
|
||||
);
|
||||
|
||||
let rand = crate::utils::random_string::GenerateRandomString {};
|
||||
let cmd = AddStoreCommandBuilder::default()
|
||||
.name(rand.get_random(10))
|
||||
.address(None)
|
||||
.owner(UUID)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
cqrs.execute(
|
||||
&cmd.store_id().to_string(),
|
||||
BillingCommand::AddStore(cmd.clone()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let store = store_query
|
||||
.load(&(*cmd.store_id()).to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let store: Store = store.into();
|
||||
assert_eq!(store.name(), cmd.name());
|
||||
assert_eq!(store.address(), cmd.address());
|
||||
assert_eq!(store.owner(), cmd.owner());
|
||||
assert_eq!(store.store_id(), cmd.store_id());
|
||||
assert!(!store.deleted());
|
||||
|
||||
let update_store_cmd = UpdateStoreCommand::new(
|
||||
rand.get_random(10),
|
||||
Some(rand.get_random(10)),
|
||||
UUID,
|
||||
store,
|
||||
UUID,
|
||||
)
|
||||
.unwrap();
|
||||
cqrs.execute(
|
||||
&cmd.store_id().to_string(),
|
||||
BillingCommand::UpdateStore(update_store_cmd.clone()),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let store = store_query
|
||||
.load(&(*cmd.store_id()).to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let store: Store = store.into();
|
||||
assert_eq!(store.name(), update_store_cmd.name());
|
||||
assert_eq!(store.address(), update_store_cmd.address());
|
||||
assert_eq!(store.owner(), update_store_cmd.owner());
|
||||
assert_eq!(store.store_id(), update_store_cmd.old_store().store_id());
|
||||
assert!(!store.deleted());
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
||||
//#[cfg(test)]
|
||||
//mod tests {
|
||||
// use super::*;
|
||||
//
|
||||
// use postgres_es::PostgresCqrs;
|
||||
//
|
||||
// use crate::{
|
||||
// db::migrate::*,
|
||||
// billing::{
|
||||
// application::services::{
|
||||
// add_category_service::tests::mock_add_category_service, add_customization_service::tests::mock_add_customization_service, add_line_item_service::tests::mock_add_line_item_service, add_product_service::tests::mock_add_product_service, add_store_service::AddStoreServiceBuilder, update_category_service::tests::mock_update_category_service, update_customization_service::tests::mock_update_customization_service, update_product_service::tests::mock_update_product_service, update_store_service::tests::mock_update_store_service, BillingServicesBuilder
|
||||
// },
|
||||
// domain::{
|
||||
// add_category_command::AddCategoryCommand, add_customization_command,
|
||||
// add_product_command::tests::get_command, add_store_command::AddStoreCommand,
|
||||
// commands::BillingCommand,
|
||||
// update_category_command::tests::get_update_category_command,
|
||||
// update_customization_command::tests::get_update_customization_command,
|
||||
// update_product_command, update_store_command::tests::get_update_store_cmd,
|
||||
// },
|
||||
// },
|
||||
// tests::bdd::IS_NEVER_CALLED,
|
||||
// utils::{random_string::GenerateRandomStringInterface, uuid::tests::UUID},
|
||||
// };
|
||||
// use std::sync::Arc;
|
||||
//
|
||||
// #[actix_rt::test]
|
||||
// async fn pg_query() {
|
||||
// let settings = crate::settings::tests::get_settings().await;
|
||||
// //let settings = crate::settings::Settings::new().unwrap();
|
||||
// settings.create_db().await;
|
||||
//
|
||||
// let db = crate::db::sqlx_postgres::Postgres::init(&settings.database.url).await;
|
||||
// db.migrate().await;
|
||||
// let db = BillingDBPostgresAdapter::new(db.pool.clone());
|
||||
//
|
||||
// let simple_query = SimpleLoggingQuery {};
|
||||
//
|
||||
// let queries: Vec<Box<dyn Query<Store>>> =
|
||||
// vec![Box::new(simple_query), Box::new(db.clone())];
|
||||
//
|
||||
// let services = BillingServicesBuilder::default()
|
||||
// .add_store(Arc::new(
|
||||
// AddStoreServiceBuilder::default()
|
||||
// .db_store_id_exists(Arc::new(db.clone()))
|
||||
// .db_store_name_exists(Arc::new(db.clone()))
|
||||
// .get_uuid(Arc::new(crate::utils::uuid::GenerateUUID {}))
|
||||
// .build()
|
||||
// .unwrap(),
|
||||
// ))
|
||||
// .add_category(mock_add_category_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// AddCategoryCommand::new("foo".into(), None, UUID, UUID).unwrap(),
|
||||
// ))
|
||||
// .add_product(mock_add_product_service(IS_NEVER_CALLED, get_command()))
|
||||
// .add_customization(mock_add_customization_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// add_customization_command::tests::get_command(),
|
||||
// ))
|
||||
// .update_product(mock_update_product_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// update_product_command::tests::get_command(),
|
||||
// ))
|
||||
// .update_customization(mock_update_customization_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// get_update_customization_command(),
|
||||
// ))
|
||||
// .update_category(mock_update_category_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// get_update_category_command(),
|
||||
// ))
|
||||
// .update_store(mock_update_store_service(
|
||||
// IS_NEVER_CALLED,
|
||||
// get_update_store_cmd(),
|
||||
// ))
|
||||
// .build()
|
||||
// .unwrap();
|
||||
//
|
||||
// let (cqrs, _store_query): (
|
||||
// Arc<PostgresCqrs<Store>>,
|
||||
// Arc<dyn ViewRepository<StoreView, Store>>,
|
||||
// ) = (
|
||||
// Arc::new(postgres_es::postgres_cqrs(
|
||||
// db.pool.clone(),
|
||||
// queries,
|
||||
// Arc::new(services),
|
||||
// )),
|
||||
// Arc::new(db.clone()),
|
||||
// );
|
||||
//
|
||||
// let rand = crate::utils::random_string::GenerateRandomString {};
|
||||
// let cmd = AddStoreCommand::new(rand.get_random(10), None, UUID).unwrap();
|
||||
// cqrs.execute("", BillingCommand::AddStore(cmd.clone()))
|
||||
// .await
|
||||
// .unwrap();
|
||||
//
|
||||
// settings.drop_db().await;
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -17,6 +17,7 @@ use crate::billing::{
|
|||
bill_aggregate::*,
|
||||
},
|
||||
};
|
||||
use crate::utils::uuid::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
|
@ -30,19 +31,27 @@ pub type AddBillServiceObj = Arc<dyn AddBillUseCase>;
|
|||
pub struct AddBillService {
|
||||
db_bill_id_exists: BillIDExistsDBPortObj,
|
||||
db_next_token_id: NextTokenIDDBPortObj,
|
||||
get_uuid: GetUUIDInterfaceObj,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl AddBillUseCase for AddBillService {
|
||||
async fn add_bill(&self, cmd: AddBillCommand) -> BillingResult<BillAddedEvent> {
|
||||
if self.db_bill_id_exists.bill_id_exists(cmd.bill_id()).await? {
|
||||
return Err(BillingError::DuplicateBillID);
|
||||
let mut bill_id = self.get_uuid.get_uuid();
|
||||
|
||||
loop {
|
||||
if self.db_bill_id_exists.bill_id_exists(&bill_id).await? {
|
||||
bill_id = self.get_uuid.get_uuid();
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let token_number = self.db_next_token_id.next_token_id(cmd.store_id()).await?;
|
||||
|
||||
let bill = BillBuilder::default()
|
||||
.bill_id(*cmd.bill_id())
|
||||
.bill_id(bill_id)
|
||||
.token_number(token_number)
|
||||
.created_time(cmd.created_time().clone())
|
||||
.store_id(*cmd.store_id())
|
||||
|
@ -71,7 +80,7 @@ pub mod tests {
|
|||
let mut m = MockAddBillUseCase::new();
|
||||
|
||||
let bill = BillBuilder::default()
|
||||
.bill_id(*cmd.bill_id())
|
||||
.bill_id(UUID)
|
||||
.token_number(1)
|
||||
.total_price(None)
|
||||
.created_time(cmd.created_time().clone())
|
||||
|
@ -104,6 +113,7 @@ pub mod tests {
|
|||
let s = AddBillServiceBuilder::default()
|
||||
.db_bill_id_exists(mock_bill_id_exists_db_port_false(IS_CALLED_ONLY_ONCE))
|
||||
.db_next_token_id(mock_next_token_id_db_port(IS_CALLED_ONLY_ONCE))
|
||||
.get_uuid(mock_get_uuid(IS_CALLED_ONLY_ONCE))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ use crate::billing::{
|
|||
application::port::output::db::line_item_id_exists::*,
|
||||
domain::{add_line_item_command::*, line_item_added_event::*, line_item_aggregate::*},
|
||||
};
|
||||
use crate::utils::uuid::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
|
@ -28,6 +29,7 @@ pub type AddLineItemServiceObj = Arc<dyn AddLineItemUseCase>;
|
|||
pub struct AddLineItemService {
|
||||
db_line_item_id_exists: LineItemIDExistsDBPortObj,
|
||||
db_bill_id_exists: BillIDExistsDBPortObj,
|
||||
get_uuid: GetUUIDInterfaceObj,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -37,12 +39,19 @@ impl AddLineItemUseCase for AddLineItemService {
|
|||
return Err(BillingError::BillIDNotFound);
|
||||
}
|
||||
|
||||
if self
|
||||
.db_line_item_id_exists
|
||||
.line_item_id_exists(cmd.line_item_id())
|
||||
.await?
|
||||
{
|
||||
return Err(BillingError::DuplicateLineItemID);
|
||||
let mut line_item_id = self.get_uuid.get_uuid();
|
||||
|
||||
loop {
|
||||
if self
|
||||
.db_line_item_id_exists
|
||||
.line_item_id_exists(&line_item_id)
|
||||
.await?
|
||||
{
|
||||
line_item_id = self.get_uuid.get_uuid();
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let line_item = LineItemBuilder::default()
|
||||
|
@ -50,7 +59,7 @@ impl AddLineItemUseCase for AddLineItemService {
|
|||
.product_name(cmd.product_name().into())
|
||||
.product_id(*cmd.product_id())
|
||||
.bill_id(*cmd.bill_id())
|
||||
.line_item_id(*cmd.line_item_id())
|
||||
.line_item_id(line_item_id)
|
||||
.quantity(cmd.quantity().clone())
|
||||
.price_per_unit(cmd.price_per_unit().clone())
|
||||
.deleted(false)
|
||||
|
@ -70,7 +79,8 @@ pub mod tests {
|
|||
use super::*;
|
||||
|
||||
use crate::billing::domain::line_item_added_event::tests::get_added_line_item_event_from_command;
|
||||
use crate::tests::bdd::*;
|
||||
use crate::utils::uuid::tests::UUID;
|
||||
use crate::{tests::bdd::*, utils::uuid::tests::mock_get_uuid};
|
||||
|
||||
pub fn mock_add_line_item_service(
|
||||
times: Option<usize>,
|
||||
|
@ -97,6 +107,7 @@ pub mod tests {
|
|||
let s = AddLineItemServiceBuilder::default()
|
||||
.db_line_item_id_exists(mock_line_item_id_exists_db_port_false(IS_CALLED_ONLY_ONCE))
|
||||
.db_bill_id_exists(mock_bill_id_exists_db_port_true(IS_CALLED_ONLY_ONCE))
|
||||
.get_uuid(mock_get_uuid(IS_CALLED_ONLY_ONCE))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
@ -118,6 +129,7 @@ pub mod tests {
|
|||
let s = AddLineItemServiceBuilder::default()
|
||||
.db_line_item_id_exists(mock_line_item_id_exists_db_port_false(IS_NEVER_CALLED))
|
||||
.db_bill_id_exists(mock_bill_id_exists_db_port_false(IS_CALLED_ONLY_ONCE))
|
||||
.get_uuid(mock_get_uuid(IS_NEVER_CALLED))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -12,11 +12,12 @@ use super::errors::*;
|
|||
use crate::billing::{
|
||||
application::port::output::db::{store_id_exists::*, store_name_exists::*},
|
||||
domain::{
|
||||
add_store_command::*,
|
||||
add_store_command::AddStoreCommand,
|
||||
store_added_event::{StoreAddedEvent, StoreAddedEventBuilder},
|
||||
store_aggregate::*,
|
||||
},
|
||||
};
|
||||
use crate::utils::uuid::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
|
@ -30,24 +31,28 @@ pub type AddStoreServiceObj = Arc<dyn AddStoreUseCase>;
|
|||
pub struct AddStoreService {
|
||||
db_store_id_exists: StoreIDExistsDBPortObj,
|
||||
db_store_name_exists: StoreNameExistsDBPortObj,
|
||||
get_uuid: GetUUIDInterfaceObj,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl AddStoreUseCase for AddStoreService {
|
||||
async fn add_store(&self, cmd: AddStoreCommand) -> BillingResult<StoreAddedEvent> {
|
||||
if self
|
||||
.db_store_id_exists
|
||||
.store_id_exists(cmd.store_id())
|
||||
.await?
|
||||
{
|
||||
return Err(BillingError::DuplicateStoreID);
|
||||
let mut store_id = self.get_uuid.get_uuid();
|
||||
|
||||
loop {
|
||||
if self.db_store_id_exists.store_id_exists(&store_id).await? {
|
||||
store_id = self.get_uuid.get_uuid();
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let store = StoreBuilder::default()
|
||||
.name(cmd.name().into())
|
||||
.address(cmd.address().as_ref().map(|s| s.to_string()))
|
||||
.owner(*cmd.owner())
|
||||
.store_id(*cmd.store_id())
|
||||
.store_id(store_id)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
@ -59,7 +64,7 @@ impl AddStoreUseCase for AddStoreService {
|
|||
.name(store.name().into())
|
||||
.address(store.address().as_ref().map(|s| s.to_string()))
|
||||
.owner(*cmd.owner())
|
||||
.store_id(*cmd.store_id())
|
||||
.store_id(store_id)
|
||||
.build()
|
||||
.unwrap())
|
||||
}
|
||||
|
@ -82,7 +87,7 @@ pub mod tests {
|
|||
.name(cmd.name().into())
|
||||
.address(cmd.address().as_ref().map(|s| s.to_string()))
|
||||
.owner(*cmd.owner())
|
||||
.store_id(*cmd.store_id())
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
@ -103,17 +108,13 @@ pub mod tests {
|
|||
let address = "bar";
|
||||
let owner = UUID;
|
||||
|
||||
let cmd = AddStoreCommandBuilder::default()
|
||||
.name(name.into())
|
||||
.address(Some(address.into()))
|
||||
.owner(owner)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
// address = None
|
||||
let cmd = AddStoreCommand::new(name.into(), Some(address.into()), owner).unwrap();
|
||||
|
||||
let s = AddStoreServiceBuilder::default()
|
||||
.db_store_id_exists(mock_store_id_exists_db_port_false(IS_CALLED_ONLY_ONCE))
|
||||
.db_store_name_exists(mock_store_name_exists_db_port_false(IS_CALLED_ONLY_ONCE))
|
||||
.get_uuid(mock_get_uuid(IS_CALLED_ONLY_ONCE))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
@ -121,7 +122,7 @@ pub mod tests {
|
|||
assert_eq!(res.name(), cmd.name());
|
||||
assert_eq!(res.address(), cmd.address());
|
||||
assert_eq!(res.owner(), cmd.owner());
|
||||
assert_eq!(res.store_id(), cmd.store_id());
|
||||
assert_eq!(res.store_id(), &UUID);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
|
@ -130,17 +131,13 @@ pub mod tests {
|
|||
let address = "bar";
|
||||
let owner = UUID;
|
||||
|
||||
let cmd = AddStoreCommandBuilder::default()
|
||||
.name(name.into())
|
||||
.address(Some(address.into()))
|
||||
.owner(owner)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
// address = None
|
||||
let cmd = AddStoreCommand::new(name.into(), Some(address.into()), owner).unwrap();
|
||||
|
||||
let s = AddStoreServiceBuilder::default()
|
||||
.db_store_id_exists(mock_store_id_exists_db_port_false(IS_CALLED_ONLY_ONCE))
|
||||
.db_store_name_exists(mock_store_name_exists_db_port_true(IS_CALLED_ONLY_ONCE))
|
||||
.get_uuid(mock_get_uuid(IS_CALLED_ONLY_ONCE))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@ pub enum BillingError {
|
|||
BillIDNotFound,
|
||||
InternalError,
|
||||
DuplicateStoreName,
|
||||
DuplicateBillID,
|
||||
DuplicateLineItemID,
|
||||
DuplicateStoreID,
|
||||
StoreIDNotFound,
|
||||
LineItemIDNotFound,
|
||||
}
|
||||
|
@ -25,12 +22,21 @@ pub enum BillingError {
|
|||
impl From<BillingDBError> for BillingError {
|
||||
fn from(value: BillingDBError) -> Self {
|
||||
match value {
|
||||
BillingDBError::DuplicateBillID => Self::DuplicateBillID,
|
||||
BillingDBError::DuplicateBillID => {
|
||||
error!("DuplicateBillID");
|
||||
Self::InternalError
|
||||
}
|
||||
BillingDBError::DuplicateStoreName => Self::DuplicateStoreName,
|
||||
BillingDBError::DuplicateStoreID => Self::DuplicateStoreID,
|
||||
BillingDBError::DuplicateStoreID => {
|
||||
error!("DuplicateStoreID");
|
||||
Self::InternalError
|
||||
}
|
||||
BillingDBError::StoreIDNotFound => BillingError::StoreIDNotFound,
|
||||
BillingDBError::InternalError => BillingError::InternalError,
|
||||
BillingDBError::DuplicateLineItemID => Self::DuplicateLineItemID,
|
||||
BillingDBError::DuplicateLineItemID => {
|
||||
error!("DuplicateLineItemID");
|
||||
Self::InternalError
|
||||
}
|
||||
BillingDBError::LineItemIDNotFound => BillingError::LineItemIDNotFound,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,14 @@
|
|||
|
||||
use derive_builder::Builder;
|
||||
use derive_getters::Getters;
|
||||
use derive_more::{Display, Error};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::types::{currency::*, quantity::*};
|
||||
use crate::utils::string::empty_string_err;
|
||||
|
||||
#[derive(
|
||||
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||
)]
|
||||
|
@ -17,7 +21,6 @@ pub struct AddBillCommand {
|
|||
#[builder(default = "OffsetDateTime::now_utc()")]
|
||||
created_time: OffsetDateTime,
|
||||
|
||||
bill_id: Uuid,
|
||||
store_id: Uuid,
|
||||
}
|
||||
|
||||
|
@ -38,7 +41,6 @@ mod tests {
|
|||
.adding_by(adding_by)
|
||||
.created_time(datetime!(1970-01-01 0:00 UTC))
|
||||
.store_id(store_id)
|
||||
.bill_id(UUID)
|
||||
.build()
|
||||
.unwrap()
|
||||
}
|
||||
|
@ -52,7 +54,6 @@ mod tests {
|
|||
let cmd = AddBillCommandBuilder::default()
|
||||
.adding_by(adding_by)
|
||||
.store_id(store_id)
|
||||
.bill_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -19,42 +19,55 @@ pub enum AddLineItemCommandError {
|
|||
}
|
||||
|
||||
#[derive(
|
||||
Clone, Debug, Builder, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters,
|
||||
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||
)]
|
||||
#[builder(build_fn(validate = "Self::validate"))]
|
||||
pub struct AddLineItemCommand {
|
||||
pub struct UnvalidatedAddLineItemCommand {
|
||||
adding_by: Uuid,
|
||||
|
||||
#[builder(default = "OffsetDateTime::now_utc()")]
|
||||
created_time: OffsetDateTime,
|
||||
#[builder(setter(custom))]
|
||||
product_name: String,
|
||||
product_id: Uuid,
|
||||
bill_id: Uuid,
|
||||
line_item_id: Uuid,
|
||||
quantity: Quantity,
|
||||
price_per_unit: Price,
|
||||
}
|
||||
|
||||
impl UnvalidatedAddLineItemCommand {
|
||||
pub fn validate(self) -> Result<AddLineItemCommand, AddLineItemCommandError> {
|
||||
let product_name = empty_string_err(
|
||||
self.product_name,
|
||||
AddLineItemCommandError::ProductNameIsEmpty,
|
||||
)?;
|
||||
|
||||
if self.quantity.is_empty() {
|
||||
return Err(AddLineItemCommandError::QuantityIsEmpty);
|
||||
}
|
||||
|
||||
Ok(AddLineItemCommand {
|
||||
created_time: self.created_time,
|
||||
product_name,
|
||||
product_id: self.product_id,
|
||||
bill_id: self.bill_id,
|
||||
quantity: self.quantity,
|
||||
adding_by: self.adding_by,
|
||||
price_per_unit: self.price_per_unit,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters)]
|
||||
pub struct AddLineItemCommand {
|
||||
created_time: OffsetDateTime,
|
||||
product_name: String,
|
||||
product_id: Uuid,
|
||||
bill_id: Uuid,
|
||||
quantity: Quantity,
|
||||
price_per_unit: Price,
|
||||
|
||||
adding_by: Uuid,
|
||||
}
|
||||
|
||||
impl AddLineItemCommandBuilder {
|
||||
pub fn product_name(&mut self, product_name: String) -> &mut Self {
|
||||
self.product_name = Some(product_name.trim().to_owned());
|
||||
self
|
||||
}
|
||||
|
||||
fn validate(&self) -> Result<(), String> {
|
||||
let product_name = self.product_name.as_ref().unwrap().trim().to_owned();
|
||||
if product_name.is_empty() {
|
||||
return Err(AddLineItemCommandError::ProductNameIsEmpty.to_string());
|
||||
}
|
||||
|
||||
if self.quantity.as_ref().unwrap().is_empty() {
|
||||
return Err(AddLineItemCommandError::QuantityIsEmpty.to_string());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use time::macros::datetime;
|
||||
|
@ -71,7 +84,7 @@ mod tests {
|
|||
let adding_by = UUID;
|
||||
let quantity = Quantity::get_quantity();
|
||||
|
||||
AddLineItemCommandBuilder::default()
|
||||
UnvalidatedAddLineItemCommandBuilder::default()
|
||||
.product_name(product_name.into())
|
||||
.adding_by(adding_by)
|
||||
.created_time(datetime!(1970-01-01 0:00 UTC))
|
||||
|
@ -79,9 +92,10 @@ mod tests {
|
|||
.price_per_unit(Price::default())
|
||||
.product_id(product_id)
|
||||
.bill_id(bill_id)
|
||||
.line_item_id(UUID)
|
||||
.build()
|
||||
.unwrap()
|
||||
.validate()
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,15 +107,16 @@ mod tests {
|
|||
let adding_by = UUID;
|
||||
let quantity = Quantity::get_quantity();
|
||||
|
||||
let cmd = AddLineItemCommandBuilder::default()
|
||||
let cmd = UnvalidatedAddLineItemCommandBuilder::default()
|
||||
.product_name(product_name.into())
|
||||
.adding_by(adding_by)
|
||||
.price_per_unit(Price::default())
|
||||
.quantity(quantity.clone())
|
||||
.product_id(product_id)
|
||||
.bill_id(bill_id)
|
||||
.line_item_id(UUID)
|
||||
.build()
|
||||
.unwrap()
|
||||
.validate()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(cmd.quantity(), &quantity);
|
||||
|
@ -118,16 +133,19 @@ mod tests {
|
|||
let adding_by = UUID;
|
||||
let quantity = Quantity::get_quantity();
|
||||
|
||||
assert!(AddLineItemCommandBuilder::default()
|
||||
.product_name(product_name.into())
|
||||
.adding_by(adding_by)
|
||||
.quantity(quantity.clone())
|
||||
.price_per_unit(Price::default())
|
||||
.product_id(product_id)
|
||||
.line_item_id(UUID)
|
||||
.bill_id(bill_id)
|
||||
.build()
|
||||
.is_err());
|
||||
assert_eq!(
|
||||
UnvalidatedAddLineItemCommandBuilder::default()
|
||||
.product_name(product_name.into())
|
||||
.adding_by(adding_by)
|
||||
.quantity(quantity.clone())
|
||||
.price_per_unit(Price::default())
|
||||
.product_id(product_id)
|
||||
.bill_id(bill_id)
|
||||
.build()
|
||||
.unwrap()
|
||||
.validate(),
|
||||
Err(AddLineItemCommandError::ProductNameIsEmpty)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -139,14 +157,18 @@ mod tests {
|
|||
// minor = 0; major = 0;
|
||||
let quantity = Quantity::default();
|
||||
|
||||
assert!(AddLineItemCommandBuilder::default()
|
||||
.product_name(product_name.into())
|
||||
.adding_by(adding_by)
|
||||
.quantity(quantity.clone())
|
||||
.product_id(product_id)
|
||||
.bill_id(bill_id)
|
||||
.price_per_unit(Price::default())
|
||||
.build()
|
||||
.is_err());
|
||||
assert_eq!(
|
||||
UnvalidatedAddLineItemCommandBuilder::default()
|
||||
.product_name(product_name.into())
|
||||
.adding_by(adding_by)
|
||||
.quantity(quantity.clone())
|
||||
.product_id(product_id)
|
||||
.bill_id(bill_id)
|
||||
.price_per_unit(Price::default())
|
||||
.build()
|
||||
.unwrap()
|
||||
.validate(),
|
||||
Err(AddLineItemCommandError::QuantityIsEmpty)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use derive_getters::Getters;
|
||||
use derive_more::{Display, Error};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -13,52 +12,46 @@ pub enum AddStoreCommandError {
|
|||
NameIsEmpty,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone, Builder, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters,
|
||||
)]
|
||||
#[builder(build_fn(validate = "Self::validate"))]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters)]
|
||||
pub struct AddStoreCommand {
|
||||
#[builder(setter(custom))]
|
||||
name: String,
|
||||
#[builder(setter(custom))]
|
||||
address: Option<String>,
|
||||
store_id: Uuid,
|
||||
owner: Uuid,
|
||||
}
|
||||
|
||||
impl AddStoreCommandBuilder {
|
||||
pub fn address(&mut self, address: Option<String>) -> &mut Self {
|
||||
self.address = if let Some(address) = address {
|
||||
impl AddStoreCommand {
|
||||
pub fn new(
|
||||
name: String,
|
||||
address: Option<String>,
|
||||
owner: Uuid,
|
||||
) -> Result<Self, AddStoreCommandError> {
|
||||
let address: Option<String> = if let Some(address) = address {
|
||||
let address = address.trim();
|
||||
if address.is_empty() {
|
||||
Some(None)
|
||||
None
|
||||
} else {
|
||||
Some(Some(address.to_owned()))
|
||||
Some(address.to_owned())
|
||||
}
|
||||
} else {
|
||||
Some(None)
|
||||
None
|
||||
};
|
||||
self
|
||||
}
|
||||
|
||||
pub fn name(&mut self, name: String) -> &mut Self {
|
||||
self.name = Some(name.trim().to_owned());
|
||||
self
|
||||
}
|
||||
|
||||
fn validate(&self) -> Result<(), String> {
|
||||
let name = self.name.as_ref().unwrap().trim().to_owned();
|
||||
let name = name.trim().to_owned();
|
||||
if name.is_empty() {
|
||||
return Err(AddStoreCommandError::NameIsEmpty.to_string());
|
||||
return Err(AddStoreCommandError::NameIsEmpty);
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Ok(Self {
|
||||
name,
|
||||
address,
|
||||
owner,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tests::bdd::*;
|
||||
use crate::utils::uuid::tests::*;
|
||||
use crate::utils::uuid::tests::UUID;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -69,41 +62,21 @@ mod tests {
|
|||
let owner = UUID;
|
||||
|
||||
// address = None
|
||||
let cmd = AddStoreCommandBuilder::default()
|
||||
.name(name.into())
|
||||
.address(None)
|
||||
.owner(owner)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
// let cmd = AddStoreCommand::new(name.into(), None, owner, UUID).unwrap();
|
||||
let cmd = AddStoreCommand::new(name.into(), None, owner).unwrap();
|
||||
assert_eq!(cmd.name(), name);
|
||||
assert_eq!(cmd.address(), &None);
|
||||
assert_eq!(cmd.owner(), &owner);
|
||||
assert_eq!(*cmd.store_id(), UUID);
|
||||
|
||||
// address = Some
|
||||
let cmd = AddStoreCommandBuilder::default()
|
||||
.name(name.into())
|
||||
.address(Some(address.into()))
|
||||
.owner(owner)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
// let cmd = AddStoreCommand::new(name.into(), Some(address.into()), owner, UUID).unwrap();
|
||||
let cmd = AddStoreCommand::new(name.into(), Some(address.into()), owner).unwrap();
|
||||
assert_eq!(cmd.name(), name);
|
||||
assert_eq!(cmd.address(), &Some(address.to_owned()));
|
||||
assert_eq!(cmd.owner(), &owner);
|
||||
assert_eq!(*cmd.store_id(), UUID);
|
||||
|
||||
// AddStoreCommandError::NameIsEmpty
|
||||
|
||||
assert!(AddStoreCommandBuilder::default()
|
||||
.name("".into())
|
||||
.address(Some(address.into()))
|
||||
.owner(owner)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.is_err())
|
||||
assert_eq!(
|
||||
AddStoreCommand::new("".into(), Some(address.into()), owner),
|
||||
Err(AddStoreCommandError::NameIsEmpty)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ pub mod tests {
|
|||
.quantity(cmd.quantity().clone())
|
||||
.bill_id(*cmd.bill_id())
|
||||
.price_per_unit(cmd.price_per_unit().clone())
|
||||
.line_item_id(*cmd.line_item_id())
|
||||
.line_item_id(UUID)
|
||||
.build()
|
||||
.unwrap()
|
||||
}
|
||||
|
|
|
@ -113,13 +113,7 @@ mod tests {
|
|||
.unwrap();
|
||||
let expected = BillingEvent::StoreAdded(expected);
|
||||
|
||||
let cmd = AddStoreCommandBuilder::default()
|
||||
.name(name.into())
|
||||
.address(address.clone())
|
||||
.owner(owner)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
let cmd = AddStoreCommand::new(name.into(), address.clone(), owner).unwrap();
|
||||
|
||||
let mut services = MockBillingServicesInterface::new();
|
||||
services
|
||||
|
|
|
@ -21,6 +21,7 @@ pub struct UpdateBillCommand {
|
|||
created_time: OffsetDateTime,
|
||||
|
||||
store_id: Uuid,
|
||||
token_number: usize,
|
||||
total_price: Option<Price>,
|
||||
|
||||
old_bill: Bill,
|
||||
|
@ -44,6 +45,7 @@ mod tests {
|
|||
.adding_by(adding_by)
|
||||
.store_id(store_id)
|
||||
.total_price(None)
|
||||
.token_number(1)
|
||||
.old_bill(Bill::get_bill())
|
||||
.build()
|
||||
.unwrap()
|
||||
|
@ -60,6 +62,7 @@ mod tests {
|
|||
.adding_by(adding_by)
|
||||
.store_id(store_id)
|
||||
.total_price(None)
|
||||
.token_number(1)
|
||||
.old_bill(old_bill.clone())
|
||||
.build()
|
||||
.unwrap();
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use sqlx::types::time::OffsetDateTime;
|
||||
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::port::output::db::{create_login_otp::*, errors::*};
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl CreateLoginOTPOutDBPort for DBOutPostgresAdapter {
|
||||
async fn create_login_otp(&self, msg: CreateOTPMsg) -> OutDBPortResult<()> {
|
||||
sqlx::query!(
|
||||
"INSERT INTO emp_login_otp (otp, created_at, purpose, emp_id)
|
||||
VALUES ($1, $2, $3, $4);",
|
||||
msg.otp as i32,
|
||||
OffsetDateTime::now_utc(),
|
||||
REGISTRATION_OTP_PURPOSE,
|
||||
&msg.emp_id,
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::utils::uuid::tests::UUID;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_postgres_create_login_otp() {
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
settings.create_db().await;
|
||||
let db = super::DBOutPostgresAdapter::new(
|
||||
sqlx::postgres::PgPool::connect(&settings.database.url)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
let msg = CreateOTPMsgBuilder::default()
|
||||
.otp(1010)
|
||||
.emp_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
db.create_login_otp(msg.clone()).await.unwrap();
|
||||
|
||||
// duplicate: secret exists
|
||||
assert_eq!(
|
||||
db.create_login_otp(msg).await.err(),
|
||||
Some(OutDBPortError::DuplicateEmpLoginOTP)
|
||||
);
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use sqlx::types::time::OffsetDateTime;
|
||||
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::port::output::db::{create_verification_otp::*, errors::*};
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl CreateVerificationOTPOutDBPort for DBOutPostgresAdapter {
|
||||
async fn create_verification_otp(&self, msg: CreateOTPMsg) -> OutDBPortResult<()> {
|
||||
sqlx::query!(
|
||||
"INSERT INTO emp_verification_otp (otp, created_at, purpose, emp_id)
|
||||
VALUES ($1, $2, $3, $4);",
|
||||
msg.otp as i32,
|
||||
OffsetDateTime::now_utc(),
|
||||
REGISTRATION_OTP_PURPOSE,
|
||||
&msg.emp_id,
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::utils::uuid::tests::UUID;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_postgres_create_verification_otp() {
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
settings.create_db().await;
|
||||
let db = super::DBOutPostgresAdapter::new(
|
||||
sqlx::postgres::PgPool::connect(&settings.database.url)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
let msg = CreateOTPMsgBuilder::default()
|
||||
.otp(1010)
|
||||
.emp_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
db.create_verification_otp(msg.clone()).await.unwrap();
|
||||
|
||||
// duplicate: secret exists
|
||||
assert_eq!(
|
||||
db.create_verification_otp(msg).await.err(),
|
||||
Some(OutDBPortError::DuplicateEmpVerificationOTP)
|
||||
);
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::port::output::db::{delete_login_otp::*, errors::*};
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl DeleteLoginOTPOutDBPort for DBOutPostgresAdapter {
|
||||
async fn delete_login_otp(
|
||||
&self,
|
||||
otp: usize,
|
||||
phone_number: &PhoneNumber,
|
||||
) -> OutDBPortResult<()> {
|
||||
sqlx::query!(
|
||||
"DELETE FROM
|
||||
emp_login_otp
|
||||
WHERE
|
||||
otp = $1
|
||||
AND
|
||||
emp_id = (
|
||||
SELECT emp_id
|
||||
FROM cqrs_identity_employee_query
|
||||
WHERE
|
||||
phone_number_number = $2
|
||||
AND
|
||||
phone_number_country_code = $3
|
||||
);",
|
||||
otp as i32,
|
||||
*phone_number.number() as i64,
|
||||
*phone_number.country_code() as i32,
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
identity::{
|
||||
adapters::output::db::postgres::emp_id_exists::tests::create_dummy_employee,
|
||||
application::port::output::db::{
|
||||
create_login_otp::*, create_login_otp::*, get_login_otp::*,
|
||||
},
|
||||
},
|
||||
utils::uuid::tests::UUID,
|
||||
};
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_postgres_delete_login_otp() {
|
||||
let otp = 9999;
|
||||
let e = Employee::default();
|
||||
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
settings.create_db().await;
|
||||
let db = super::DBOutPostgresAdapter::new(
|
||||
sqlx::postgres::PgPool::connect(&settings.database.url)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
create_dummy_employee(&e, &db).await;
|
||||
|
||||
db.create_login_otp(
|
||||
CreateOTPMsgBuilder::default()
|
||||
.otp(otp)
|
||||
.emp_id(*e.emp_id())
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(db.get_login_otp(e.phone_number()).await.unwrap().is_some());
|
||||
|
||||
db.delete_login_otp(otp, e.phone_number()).await.unwrap();
|
||||
assert!(db.get_login_otp(e.phone_number()).await.unwrap().is_none());
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::port::output::db::{delete_verification_otp::*, errors::*};
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl DeleteVerificationOTPOutDBPort for DBOutPostgresAdapter {
|
||||
async fn delete_verification_otp(
|
||||
&self,
|
||||
otp: usize,
|
||||
phone_number: &PhoneNumber,
|
||||
) -> OutDBPortResult<()> {
|
||||
sqlx::query!(
|
||||
"DELETE FROM
|
||||
emp_verification_otp
|
||||
WHERE
|
||||
otp = $1
|
||||
AND
|
||||
emp_id = (
|
||||
SELECT emp_id
|
||||
FROM cqrs_identity_employee_query
|
||||
WHERE
|
||||
phone_number_number = $2
|
||||
AND
|
||||
phone_number_country_code = $3
|
||||
);",
|
||||
otp as i32,
|
||||
*phone_number.number() as i64,
|
||||
*phone_number.country_code() as i32,
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
identity::{
|
||||
adapters::output::db::postgres::emp_id_exists::tests::create_dummy_employee,
|
||||
application::port::output::db::{
|
||||
create_verification_otp::*, create_verification_otp::*, get_verification_otp::*,
|
||||
},
|
||||
},
|
||||
utils::uuid::tests::UUID,
|
||||
};
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_postgres_delete_verification_otp() {
|
||||
let otp = 9999;
|
||||
let e = Employee::default();
|
||||
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
settings.create_db().await;
|
||||
let db = super::DBOutPostgresAdapter::new(
|
||||
sqlx::postgres::PgPool::connect(&settings.database.url)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
create_dummy_employee(&e, &db).await;
|
||||
|
||||
db.create_verification_otp(
|
||||
CreateOTPMsgBuilder::default()
|
||||
.otp(otp)
|
||||
.emp_id(*e.emp_id())
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(db
|
||||
.get_verification_otp(e.phone_number())
|
||||
.await
|
||||
.unwrap()
|
||||
.is_some());
|
||||
|
||||
db.delete_verification_otp(otp, e.phone_number())
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(db
|
||||
.get_verification_otp(e.phone_number())
|
||||
.await
|
||||
.unwrap()
|
||||
.is_none());
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::port::output::db::{emp_id_exists::*, errors::*};
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl EmpIDExistsOutDBPort for DBOutPostgresAdapter {
|
||||
async fn emp_id_exists(&self, emp_id: &Uuid) -> OutDBPortResult<bool> {
|
||||
let res = sqlx::query!(
|
||||
"SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM cqrs_identity_employee_query
|
||||
WHERE
|
||||
emp_id = $1
|
||||
);",
|
||||
emp_id,
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await?;
|
||||
if let Some(x) = res.exists {
|
||||
Ok(x)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use crate::utils::uuid::tests::UUID;
|
||||
|
||||
use crate::identity::adapters::output::db::postgres::employee_view::EmployeeView;
|
||||
use crate::identity::domain::aggregate::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
pub async fn create_dummy_employee(e: &Employee, db: &DBOutPostgresAdapter) {
|
||||
sqlx::query!(
|
||||
"INSERT INTO cqrs_identity_employee_query (
|
||||
version,
|
||||
emp_id,
|
||||
first_name,
|
||||
last_name,
|
||||
phone_number_number,
|
||||
phone_number_country_code,
|
||||
phone_verified,
|
||||
deleted
|
||||
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6, $7, $8
|
||||
);",
|
||||
0,
|
||||
e.emp_id(),
|
||||
e.first_name(),
|
||||
e.last_name(),
|
||||
*e.phone_number().number() as i64,
|
||||
*e.phone_number().country_code() as i32,
|
||||
*e.phone_verified(),
|
||||
*e.deleted(),
|
||||
)
|
||||
.execute(&db.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_postgres_emp_id_exists() {
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
settings.create_db().await;
|
||||
let db = super::DBOutPostgresAdapter::new(
|
||||
sqlx::postgres::PgPool::connect(&settings.database.url)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
let e = Employee::default();
|
||||
|
||||
// state doesn't exist
|
||||
assert!(!db.emp_id_exists(e.emp_id()).await.unwrap());
|
||||
|
||||
create_dummy_employee(&e, &db).await;
|
||||
|
||||
// state exists
|
||||
assert!(db.emp_id_exists(e.emp_id()).await.unwrap());
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -1,430 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use cqrs_es::persist::{PersistenceError, ViewContext, ViewRepository};
|
||||
use cqrs_es::{EventEnvelope, Query, View};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::services::events::IdentityEvent;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
use crate::types::currency::{self, Currency, PriceBuilder};
|
||||
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
||||
|
||||
pub const NEW_BILL_NON_UUID: &str = "identity_new_bill_non_uuid-asdfa";
|
||||
|
||||
// The view for a Employee query, for a standard http application this should
|
||||
// be designed to reflect the response dto that will be returned to a user.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct EmployeeView {
|
||||
created_time: OffsetDateTime,
|
||||
first_name: String,
|
||||
last_name: String,
|
||||
emp_id: Uuid,
|
||||
phone_number_country_code: i32,
|
||||
phone_number_number: i64,
|
||||
|
||||
phone_verified: bool,
|
||||
store_id: Option<Uuid>,
|
||||
deleted: bool,
|
||||
}
|
||||
|
||||
impl From<EmployeeView> for Employee {
|
||||
fn from(v: EmployeeView) -> Self {
|
||||
EmployeeBuilder::default()
|
||||
.first_name(v.first_name)
|
||||
.last_name(v.last_name)
|
||||
.phone_number(
|
||||
PhoneNumberBuilder::default()
|
||||
.number(v.phone_number_number as u64)
|
||||
.country_code(v.phone_number_country_code as usize)
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
.emp_id(v.emp_id)
|
||||
.phone_verified(v.phone_verified)
|
||||
.store_id(v.store_id)
|
||||
.deleted(v.deleted)
|
||||
.build()
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EmployeeView {
|
||||
fn default() -> Self {
|
||||
let e = Employee::default();
|
||||
Self {
|
||||
created_time: OffsetDateTime::now_utc(),
|
||||
first_name: e.first_name().clone(),
|
||||
last_name: e.last_name().clone(),
|
||||
phone_number_number: *e.phone_number().number() as i64,
|
||||
phone_number_country_code: *e.phone_number().country_code() as i32,
|
||||
phone_verified: *e.phone_verified(),
|
||||
emp_id: *e.emp_id(),
|
||||
store_id: e.store_id().clone(),
|
||||
deleted: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EmployeeView {
|
||||
fn merge(&mut self, e: &Employee) {
|
||||
self.first_name = e.first_name().clone();
|
||||
self.last_name = e.last_name().clone();
|
||||
self.phone_number_number = *e.phone_number().number() as i64;
|
||||
self.phone_number_country_code = *e.phone_number().country_code() as i32;
|
||||
self.phone_verified = *e.phone_verified();
|
||||
self.emp_id = *e.emp_id();
|
||||
self.store_id = e.store_id().clone();
|
||||
self.deleted = *e.deleted();
|
||||
}
|
||||
}
|
||||
|
||||
// This updates the view with events as they are committed.
|
||||
// The logic should be minimal here, e.g., don't calculate the account balance,
|
||||
// design the events to carry the balance information instead.
|
||||
impl View<Employee> for EmployeeView {
|
||||
fn update(&mut self, event: &EventEnvelope<Employee>) {
|
||||
match &event.payload {
|
||||
IdentityEvent::EmployeeRegistered(e) => self.merge(e.employee()),
|
||||
IdentityEvent::EmployeeLoggedIn(e) => (),
|
||||
IdentityEvent::EmployeeInitLoggedIn(e) => (),
|
||||
IdentityEvent::ResentLoginOTP(e) => (),
|
||||
IdentityEvent::PhoneNumberVerified(e) => self.phone_verified = true,
|
||||
IdentityEvent::VerificationOTPResent(e) => (),
|
||||
IdentityEvent::PhoneNumberChanged(e) => unimplemented!(),
|
||||
IdentityEvent::InviteAccepted(e) => self.store_id = Some(*e.store_id()),
|
||||
IdentityEvent::OrganizationExited(e) => self.store_id = None,
|
||||
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ViewRepository<EmployeeView, Employee> for DBOutPostgresAdapter {
|
||||
async fn load(&self, emp_id: &str) -> Result<Option<EmployeeView>, PersistenceError> {
|
||||
let emp_id = match parse_aggregate_id(emp_id, NEW_BILL_NON_UUID)? {
|
||||
Some((val, _)) => return Ok(Some(val)),
|
||||
None => Uuid::parse_str(emp_id).unwrap(),
|
||||
};
|
||||
|
||||
let res = sqlx::query_as!(
|
||||
EmployeeView,
|
||||
"SELECT
|
||||
created_time,
|
||||
store_id,
|
||||
emp_id,
|
||||
first_name,
|
||||
last_name,
|
||||
phone_number_number,
|
||||
phone_number_country_code,
|
||||
phone_verified,
|
||||
deleted
|
||||
FROM
|
||||
cqrs_identity_employee_query
|
||||
WHERE
|
||||
emp_id = $1;",
|
||||
emp_id
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(PostgresAggregateError::from)?;
|
||||
Ok(Some(res))
|
||||
}
|
||||
|
||||
async fn load_with_context(
|
||||
&self,
|
||||
emp_id: &str,
|
||||
) -> Result<Option<(EmployeeView, ViewContext)>, PersistenceError> {
|
||||
let emp_id = match parse_aggregate_id(emp_id, NEW_BILL_NON_UUID)? {
|
||||
Some(val) => return Ok(Some(val)),
|
||||
None => Uuid::parse_str(emp_id).unwrap(),
|
||||
};
|
||||
|
||||
let res = sqlx::query_as!(
|
||||
EmployeeView,
|
||||
"SELECT
|
||||
created_time,
|
||||
store_id,
|
||||
emp_id,
|
||||
first_name,
|
||||
last_name,
|
||||
phone_number_number,
|
||||
phone_number_country_code,
|
||||
phone_verified,
|
||||
deleted
|
||||
|
||||
FROM
|
||||
cqrs_identity_employee_query
|
||||
WHERE
|
||||
emp_id = $1;",
|
||||
&emp_id,
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(PostgresAggregateError::from)?;
|
||||
|
||||
struct Context {
|
||||
version: i64,
|
||||
emp_id: Uuid,
|
||||
}
|
||||
|
||||
let ctx = sqlx::query_as!(
|
||||
Context,
|
||||
"SELECT
|
||||
emp_id, version
|
||||
FROM
|
||||
cqrs_identity_employee_query
|
||||
WHERE
|
||||
emp_id = $1;",
|
||||
emp_id
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(PostgresAggregateError::from)?;
|
||||
|
||||
let view_context = ViewContext::new(ctx.emp_id.to_string(), ctx.version);
|
||||
Ok(Some((res, view_context)))
|
||||
}
|
||||
|
||||
async fn update_view(
|
||||
&self,
|
||||
view: EmployeeView,
|
||||
context: ViewContext,
|
||||
) -> Result<(), PersistenceError> {
|
||||
match context.version {
|
||||
0 => {
|
||||
let version = context.version + 1;
|
||||
sqlx::query!(
|
||||
"INSERT INTO cqrs_identity_employee_query (
|
||||
version,
|
||||
created_time,
|
||||
store_id,
|
||||
emp_id,
|
||||
first_name,
|
||||
last_name,
|
||||
phone_number_number,
|
||||
phone_number_country_code,
|
||||
phone_verified,
|
||||
deleted
|
||||
|
||||
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10
|
||||
);",
|
||||
version,
|
||||
view.created_time,
|
||||
view.store_id,
|
||||
view.emp_id,
|
||||
view.first_name,
|
||||
view.last_name,
|
||||
view.phone_number_number,
|
||||
view.phone_number_country_code,
|
||||
view.phone_verified,
|
||||
view.deleted,
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_err(PostgresAggregateError::from)?;
|
||||
}
|
||||
_ => {
|
||||
let version = context.version + 1;
|
||||
sqlx::query!(
|
||||
"UPDATE
|
||||
cqrs_identity_employee_query
|
||||
SET
|
||||
version = $1,
|
||||
|
||||
created_time = $2,
|
||||
store_id = $3,
|
||||
first_name = $4,
|
||||
last_name = $5,
|
||||
phone_number_number = $6,
|
||||
phone_number_country_code = $7,
|
||||
phone_verified = $8,
|
||||
|
||||
|
||||
deleted = $9;",
|
||||
version,
|
||||
view.created_time,
|
||||
view.store_id,
|
||||
view.first_name,
|
||||
view.last_name,
|
||||
view.phone_number_number,
|
||||
view.phone_number_country_code,
|
||||
view.phone_verified,
|
||||
view.deleted,
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_err(PostgresAggregateError::from)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Query<Employee> for DBOutPostgresAdapter {
|
||||
async fn dispatch(&self, emp_id: &str, events: &[EventEnvelope<Employee>]) {
|
||||
let res = self.load_with_context(emp_id).await.unwrap_or_else(|_| {
|
||||
Some((EmployeeView::default(), ViewContext::new(emp_id.into(), 0)))
|
||||
});
|
||||
let (mut view, view_context): (EmployeeView, ViewContext) = res.unwrap();
|
||||
for event in events {
|
||||
view.update(event);
|
||||
}
|
||||
self.update_view(view, view_context).await.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use postgres_es::PostgresCqrs;
|
||||
|
||||
use crate::{
|
||||
db::migrate::*,
|
||||
identity::{
|
||||
application::{
|
||||
port::output::{
|
||||
db::get_verification_otp::GetVerificationOTPOutDBPort,
|
||||
phone::account_validation_otp::mock_account_validation_otp_phone_port,
|
||||
},
|
||||
services::{
|
||||
employee_register_service::*, employee_verify_phone_number_service::*,
|
||||
IdentityCommand, MockIdentityServicesInterface,
|
||||
},
|
||||
},
|
||||
domain::{
|
||||
employee_aggregate::*, employee_register_command::*, verify_phone_number_command::*,
|
||||
},
|
||||
},
|
||||
tests::bdd::*,
|
||||
utils::{random_number::tests::mock_generate_random_number, uuid::tests::*},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn pg_query_identity_employee_view() {
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
//let settings = crate::settings::Settings::new().unwrap();
|
||||
settings.create_db().await;
|
||||
|
||||
let db = crate::db::sqlx_postgres::Postgres::init(&settings.database.url).await;
|
||||
db.migrate().await;
|
||||
let db = DBOutPostgresAdapter::new(db.pool.clone());
|
||||
|
||||
let queries: Vec<Box<dyn Query<Employee>>> = vec![Box::new(db.clone())];
|
||||
|
||||
let mut mock_services = MockIdentityServicesInterface::new();
|
||||
|
||||
//let store = Store::default();
|
||||
//crate::identity::adapters::output::db::postgres::store_id_exists::tests::create_dummy_store_record(&store, &db).await;
|
||||
|
||||
let db2 = Arc::new(db.clone());
|
||||
mock_services
|
||||
.expect_employee_register_service()
|
||||
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||
.returning(move || {
|
||||
Arc::new(
|
||||
EmployeeRegisterUserServiceBuilder::default()
|
||||
.db_emp_id_exists_adapter(db2.clone())
|
||||
.db_create_verification_otp_adapter(db2.clone())
|
||||
.db_phone_exists_adapter(db2.clone())
|
||||
.random_number_adapter(mock_generate_random_number(
|
||||
IS_CALLED_ONLY_ONCE,
|
||||
999,
|
||||
))
|
||||
.phone_account_validation_otp_adapter(
|
||||
mock_account_validation_otp_phone_port(IS_CALLED_ONLY_ONCE),
|
||||
)
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
let db2 = Arc::new(db.clone());
|
||||
mock_services
|
||||
.expect_employee_verify_phone_number_service()
|
||||
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||
.returning(move || {
|
||||
Arc::new(
|
||||
EmployeeVerifyPhoneNumberServiceBuilder::default()
|
||||
.db_get_emp_id_from_phone_number_adapter(db2.clone())
|
||||
.db_delete_verification_otp(db2.clone())
|
||||
.db_get_verification_otp(db2.clone())
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
let (cqrs, employee_query): (
|
||||
Arc<PostgresCqrs<Employee>>,
|
||||
Arc<dyn ViewRepository<EmployeeView, Employee>>,
|
||||
) = (
|
||||
Arc::new(postgres_es::postgres_cqrs(
|
||||
db.pool.clone(),
|
||||
queries,
|
||||
Arc::new(mock_services),
|
||||
)),
|
||||
Arc::new(db.clone()),
|
||||
);
|
||||
|
||||
let cmd = EmployeeRegisterCommandBuilder::default()
|
||||
.first_name("foooint".into())
|
||||
.last_name("foooint".into())
|
||||
.phone_number(PhoneNumber::default())
|
||||
.emp_id(Uuid::new_v4())
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let emp_id_str = cmd.emp_id().to_string();
|
||||
|
||||
cqrs.execute(&emp_id_str, IdentityCommand::EmployeeRegister(cmd.clone()))
|
||||
.await
|
||||
.unwrap();
|
||||
let emp = employee_query.load(&emp_id_str).await.unwrap().unwrap();
|
||||
let emp: Employee = emp.into();
|
||||
assert_eq!(emp.first_name(), cmd.first_name());
|
||||
assert_eq!(emp.last_name(), cmd.last_name());
|
||||
assert_eq!(emp.emp_id(), cmd.emp_id());
|
||||
assert_eq!(emp.phone_number(), cmd.phone_number());
|
||||
assert!(!*emp.phone_verified());
|
||||
assert!(!*emp.deleted());
|
||||
assert!(emp.store_id().is_none());
|
||||
|
||||
let otp = db
|
||||
.get_verification_otp(emp.phone_number())
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
cqrs.execute(
|
||||
&emp_id_str,
|
||||
IdentityCommand::EmployeeVerifyPhoneNumber(
|
||||
VerifyPhoneNumberCommandBuilder::default()
|
||||
.otp(otp.into())
|
||||
.phone_number(emp.phone_number().clone())
|
||||
.build()
|
||||
.unwrap(),
|
||||
),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let emp = employee_query.load(&emp_id_str).await.unwrap().unwrap();
|
||||
assert!(emp.phone_verified);
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -21,10 +21,6 @@ impl From<SqlxError> for OutDBPortError {
|
|||
return Self::InternalError;
|
||||
} else if msg.contains("verification_otp_secret_key") {
|
||||
return Self::DuplicateVerificationOTPSecret;
|
||||
} else if msg.contains("emp_login_otp_otp_key") {
|
||||
return Self::DuplicateEmpLoginOTP;
|
||||
} else if msg.contains("emp_verification_otp_otp_key") {
|
||||
return Self::DuplicateEmpVerificationOTP;
|
||||
} else {
|
||||
println!("{msg}");
|
||||
}
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::map_row_not_found_err;
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::port::output::db::{errors::*, get_emp_id_from_phone_number::*};
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
struct EmpID {
|
||||
emp_id: Uuid,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl GetEmpIDFromPhoneNumberOutDBPort for DBOutPostgresAdapter {
|
||||
async fn get_emp_id_from_phone_number(
|
||||
&self,
|
||||
phone_number: &PhoneNumber,
|
||||
) -> OutDBPortResult<Uuid> {
|
||||
let res = sqlx::query_as!(
|
||||
EmpID,
|
||||
"SELECT emp_id
|
||||
FROM cqrs_identity_employee_query
|
||||
WHERE
|
||||
phone_number_number = $1
|
||||
AND
|
||||
phone_number_country_code = $2;",
|
||||
*phone_number.number() as i64,
|
||||
*phone_number.country_code() as i32,
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, OutDBPortError::PhoneNumberNotFound))?;
|
||||
Ok(res.emp_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use crate::identity::adapters::output::db::postgres::emp_id_exists::tests::create_dummy_employee;
|
||||
use crate::utils::uuid::tests::UUID;
|
||||
|
||||
use crate::identity::adapters::output::db::postgres::employee_view::EmployeeView;
|
||||
use crate::identity::domain::aggregate::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_postgres_get_emp_id_from_phone() {
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
settings.create_db().await;
|
||||
let db = super::DBOutPostgresAdapter::new(
|
||||
sqlx::postgres::PgPool::connect(&settings.database.url)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
let e = Employee::default();
|
||||
|
||||
// state doesn't exist
|
||||
assert_eq!(
|
||||
db.get_emp_id_from_phone_number(e.phone_number()).await,
|
||||
Err(OutDBPortError::PhoneNumberNotFound)
|
||||
);
|
||||
|
||||
create_dummy_employee(&e, &db).await;
|
||||
|
||||
// state exists
|
||||
assert_eq!(
|
||||
db.get_emp_id_from_phone_number(e.phone_number())
|
||||
.await
|
||||
.unwrap(),
|
||||
*e.emp_id()
|
||||
);
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::port::output::db::{errors::*, get_login_otp::*};
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl GetLoginOTPOutDBPort for DBOutPostgresAdapter {
|
||||
async fn get_login_otp(&self, phone_number: &PhoneNumber) -> OutDBPortResult<Option<usize>> {
|
||||
struct Secret {
|
||||
otp: i32,
|
||||
}
|
||||
let res = sqlx::query_as!(
|
||||
Secret,
|
||||
"SELECT
|
||||
otp
|
||||
FROM
|
||||
emp_login_otp
|
||||
WHERE
|
||||
emp_id = (
|
||||
SELECT emp_id
|
||||
FROM cqrs_identity_employee_query
|
||||
WHERE
|
||||
phone_number_number = $1
|
||||
AND
|
||||
phone_number_country_code = $2
|
||||
);",
|
||||
*phone_number.number() as i64,
|
||||
*phone_number.country_code() as i32,
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, OutDBPortError::EmpLoginOTPNotFound));
|
||||
|
||||
let res = match res {
|
||||
Ok(res) => Some(res.otp as usize),
|
||||
Err(OutDBPortError::EmpLoginOTPNotFound) => None,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
identity::{
|
||||
adapters::output::db::postgres::{
|
||||
create_login_otp::*, emp_id_exists::tests::create_dummy_employee,
|
||||
},
|
||||
application::port::output::db::create_login_otp::*,
|
||||
},
|
||||
utils::uuid::tests::UUID,
|
||||
};
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_postgres_get_verification_secret() {
|
||||
let otp = 999;
|
||||
let e = Employee::default();
|
||||
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
settings.create_db().await;
|
||||
let db = super::DBOutPostgresAdapter::new(
|
||||
sqlx::postgres::PgPool::connect(&settings.database.url)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
create_dummy_employee(&e, &db).await;
|
||||
|
||||
assert!(db.get_login_otp(e.phone_number()).await.unwrap().is_none(),);
|
||||
|
||||
db.create_login_otp(
|
||||
CreateOTPMsgBuilder::default()
|
||||
.otp(otp)
|
||||
.emp_id(*e.emp_id())
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
db.get_login_otp(e.phone_number()).await.unwrap(),
|
||||
Some(otp.into())
|
||||
);
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::port::output::db::{errors::*, get_verification_otp::*};
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl GetVerificationOTPOutDBPort for DBOutPostgresAdapter {
|
||||
async fn get_verification_otp(
|
||||
&self,
|
||||
phone_number: &PhoneNumber,
|
||||
) -> OutDBPortResult<Option<usize>> {
|
||||
struct Secret {
|
||||
otp: i32,
|
||||
}
|
||||
let res = sqlx::query_as!(
|
||||
Secret,
|
||||
"SELECT
|
||||
otp
|
||||
FROM
|
||||
emp_verification_otp
|
||||
WHERE
|
||||
emp_id = (
|
||||
SELECT emp_id
|
||||
FROM cqrs_identity_employee_query
|
||||
WHERE
|
||||
phone_number_number = $1
|
||||
AND
|
||||
phone_number_country_code = $2
|
||||
);",
|
||||
*phone_number.number() as i64,
|
||||
*phone_number.country_code() as i32,
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, OutDBPortError::EmpVerificationOTPNotFound));
|
||||
|
||||
let res = match res {
|
||||
Ok(res) => Some(res.otp as usize),
|
||||
Err(OutDBPortError::EmpVerificationOTPNotFound) => None,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
identity::{
|
||||
adapters::output::db::postgres::{
|
||||
create_verification_otp::*, emp_id_exists::tests::create_dummy_employee,
|
||||
},
|
||||
application::port::output::db::create_verification_otp::*,
|
||||
},
|
||||
utils::uuid::tests::UUID,
|
||||
};
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_postgres_get_verification_secret() {
|
||||
let otp = 999;
|
||||
let e = Employee::default();
|
||||
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
settings.create_db().await;
|
||||
let db = super::DBOutPostgresAdapter::new(
|
||||
sqlx::postgres::PgPool::connect(&settings.database.url)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
create_dummy_employee(&e, &db).await;
|
||||
|
||||
assert!(db
|
||||
.get_verification_otp(e.phone_number())
|
||||
.await
|
||||
.unwrap()
|
||||
.is_none(),);
|
||||
|
||||
db.create_verification_otp(
|
||||
CreateOTPMsgBuilder::default()
|
||||
.otp(otp)
|
||||
.emp_id(*e.emp_id())
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
db.get_verification_otp(e.phone_number()).await.unwrap(),
|
||||
Some(otp.into())
|
||||
);
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ impl GetVerificationSecretOutDBPort for DBOutPostgresAdapter {
|
|||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, OutDBPortError::VerificationOTPNotFound))?;
|
||||
.map_err(|e| map_row_not_found_err(e, OutDBPortError::VerificationOTPSecretNotFound))?;
|
||||
Ok(res.secret)
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
db.get_verification_secret(&user_id).await.err(),
|
||||
Some(OutDBPortError::VerificationOTPNotFound)
|
||||
Some(OutDBPortError::VerificationOTPSecretNotFound)
|
||||
);
|
||||
|
||||
let create_msg = CreateSecretMsgBuilder::default()
|
||||
|
|
|
@ -12,27 +12,12 @@ use crate::db::{migrate::RunMigrations, sqlx_postgres::Postgres};
|
|||
pub mod create_verification_secret;
|
||||
pub mod delete_verification_secret;
|
||||
pub mod email_exists;
|
||||
pub mod employee_view;
|
||||
mod errors;
|
||||
pub mod get_verification_secret;
|
||||
pub mod user_id_exists;
|
||||
pub mod user_view;
|
||||
pub mod verification_secret_exists;
|
||||
|
||||
pub mod create_login_otp;
|
||||
pub mod create_verification_otp;
|
||||
pub mod delete_login_otp;
|
||||
pub mod delete_verification_otp;
|
||||
pub mod emp_id_exists;
|
||||
pub mod get_emp_id_from_phone_number;
|
||||
pub mod get_login_otp;
|
||||
pub mod get_verification_otp;
|
||||
pub mod phone_exists;
|
||||
|
||||
//pub mod get_invite;
|
||||
//pub mod invite_id_exists;
|
||||
//pub mod store_id_exists;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DBOutPostgresAdapter {
|
||||
pool: PgPool,
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::port::output::db::{errors::*, phone_exists::*};
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl PhoneNumberExistsOutDBPort for DBOutPostgresAdapter {
|
||||
async fn phone_exists(&self, phone: &PhoneNumber) -> OutDBPortResult<bool> {
|
||||
let res = sqlx::query!(
|
||||
"SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM cqrs_identity_employee_query
|
||||
WHERE
|
||||
phone_number_number = $1
|
||||
AND
|
||||
phone_number_country_code = $2
|
||||
);",
|
||||
*phone.number() as i64,
|
||||
*phone.country_code() as i32,
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await?;
|
||||
if let Some(x) = res.exists {
|
||||
Ok(x)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use crate::identity::adapters::output::db::postgres::emp_id_exists::tests::create_dummy_employee;
|
||||
use crate::utils::uuid::tests::UUID;
|
||||
|
||||
use crate::identity::adapters::output::db::postgres::employee_view::EmployeeView;
|
||||
use crate::identity::domain::aggregate::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_postgres_phone_exists() {
|
||||
let settings = crate::settings::tests::get_settings().await;
|
||||
settings.create_db().await;
|
||||
let db = super::DBOutPostgresAdapter::new(
|
||||
sqlx::postgres::PgPool::connect(&settings.database.url)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
let e = Employee::default();
|
||||
|
||||
// state doesn't exist
|
||||
assert!(!db.phone_exists(e.phone_number()).await.unwrap());
|
||||
|
||||
create_dummy_employee(&e, &db).await;
|
||||
|
||||
// state exists
|
||||
assert!(db.phone_exists(e.phone_number()).await.unwrap());
|
||||
|
||||
settings.drop_db().await;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ use uuid::Uuid;
|
|||
|
||||
use super::errors::*;
|
||||
use super::DBOutPostgresAdapter;
|
||||
use crate::identity::application::services::events::IdentityEvent;
|
||||
use crate::identity::application::services::events::UserEvent;
|
||||
use crate::identity::domain::aggregate::User;
|
||||
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
||||
|
||||
|
@ -37,7 +37,7 @@ pub struct UserView {
|
|||
impl View<User> for UserView {
|
||||
fn update(&mut self, event: &EventEnvelope<User>) {
|
||||
match &event.payload {
|
||||
IdentityEvent::UserRegistered(val) => {
|
||||
UserEvent::UserRegistered(val) => {
|
||||
self.email = val.email().into();
|
||||
self.hashed_password = val.hashed_password().into();
|
||||
self.is_admin = val.is_admin().to_owned();
|
||||
|
@ -47,20 +47,19 @@ impl View<User> for UserView {
|
|||
self.last_name = val.last_name().into();
|
||||
self.user_id = *val.user_id();
|
||||
}
|
||||
IdentityEvent::UserDeleted => self.deleted = true,
|
||||
IdentityEvent::Loggedin(_) => (),
|
||||
IdentityEvent::PasswordUpdated(_) => (),
|
||||
IdentityEvent::EmailUpdated(val) => {
|
||||
UserEvent::UserDeleted => self.deleted = true,
|
||||
UserEvent::Loggedin(_) => (),
|
||||
UserEvent::PasswordUpdated(_) => (),
|
||||
UserEvent::EmailUpdated(val) => {
|
||||
self.email = val.new_email().into();
|
||||
}
|
||||
IdentityEvent::UserVerified => {
|
||||
UserEvent::UserVerified => {
|
||||
self.is_verified = true;
|
||||
}
|
||||
IdentityEvent::UserPromotedToAdmin(_) => {
|
||||
UserEvent::UserPromotedToAdmin(_) => {
|
||||
self.is_admin = true;
|
||||
}
|
||||
IdentityEvent::VerificationEmailResent => (),
|
||||
_ => (),
|
||||
UserEvent::VerificationEmailResent => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,9 +169,10 @@ impl ViewRepository<UserView, User> for DBOutPostgresAdapter {
|
|||
"UPDATE
|
||||
user_query
|
||||
SET
|
||||
version = $1, first_name = $2, email = $3,
|
||||
hashed_password = $4, is_admin = $5, is_verified = $6, deleted = $7,
|
||||
last_name=$8;",
|
||||
user_id = $1, version = $2, first_name = $3, email = $4,
|
||||
hashed_password = $5, is_admin = $6, is_verified = $7, deleted = $8,
|
||||
last_name=$9;",
|
||||
view.user_id,
|
||||
version,
|
||||
view.first_name,
|
||||
view.email,
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Builder)]
|
||||
pub struct CreateOTPMsg {
|
||||
pub otp: usize,
|
||||
pub emp_id: Uuid,
|
||||
}
|
||||
pub const REGISTRATION_OTP_PURPOSE: &str = "account_login";
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait CreateLoginOTPOutDBPort: Send + Sync {
|
||||
async fn create_login_otp(&self, msg: CreateOTPMsg) -> OutDBPortResult<()>;
|
||||
}
|
||||
|
||||
pub type CreateLoginOTPOutDBPortObj = std::sync::Arc<dyn CreateLoginOTPOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_create_login_otp_db_port(times: Option<usize>) -> CreateLoginOTPOutDBPortObj {
|
||||
let mut m = MockCreateLoginOTPOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_create_login_otp()
|
||||
.times(times)
|
||||
.returning(|_| Ok(()));
|
||||
} else {
|
||||
m.expect_create_login_otp().returning(|_| Ok(()));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Builder)]
|
||||
pub struct CreateOTPMsg {
|
||||
pub otp: usize,
|
||||
pub emp_id: Uuid,
|
||||
}
|
||||
pub const REGISTRATION_OTP_PURPOSE: &str = "account_validation";
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait CreateVerificationOTPOutDBPort: Send + Sync {
|
||||
async fn create_verification_otp(&self, msg: CreateOTPMsg) -> OutDBPortResult<()>;
|
||||
}
|
||||
|
||||
pub type CreateVerificationOTPOutDBPortObj = std::sync::Arc<dyn CreateVerificationOTPOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_create_verification_otp_db_port(
|
||||
times: Option<usize>,
|
||||
) -> CreateVerificationOTPOutDBPortObj {
|
||||
let mut m = MockCreateVerificationOTPOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_create_verification_otp()
|
||||
.times(times)
|
||||
.returning(|_| Ok(()));
|
||||
} else {
|
||||
m.expect_create_verification_otp().returning(|_| Ok(()));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub use super::create_login_otp::REGISTRATION_OTP_PURPOSE;
|
||||
use super::errors::*;
|
||||
use super::phone_exists;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait DeleteLoginOTPOutDBPort: Send + Sync {
|
||||
async fn delete_login_otp(&self, otp: usize, phone_number: &PhoneNumber)
|
||||
-> OutDBPortResult<()>;
|
||||
}
|
||||
|
||||
pub type DeleteLoginOTPOutDBPortObj = std::sync::Arc<dyn DeleteLoginOTPOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_delete_login_otp_db_port(times: Option<usize>) -> DeleteLoginOTPOutDBPortObj {
|
||||
let mut m = MockDeleteLoginOTPOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_delete_login_otp()
|
||||
.times(times)
|
||||
.returning(|_, _| Ok(()));
|
||||
} else {
|
||||
m.expect_delete_login_otp().returning(|_, _| Ok(()));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait DeleteVerificationOTPOutDBPort: Send + Sync {
|
||||
async fn delete_verification_otp(
|
||||
&self,
|
||||
otp: usize,
|
||||
phone_number: &PhoneNumber,
|
||||
) -> OutDBPortResult<()>;
|
||||
}
|
||||
|
||||
pub type DeleteVerificationOTPOutDBPortObj = std::sync::Arc<dyn DeleteVerificationOTPOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_delete_verification_otp_db_port(
|
||||
times: Option<usize>,
|
||||
) -> DeleteVerificationOTPOutDBPortObj {
|
||||
let mut m = MockDeleteVerificationOTPOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_delete_verification_otp()
|
||||
.times(times)
|
||||
.returning(|_, _| Ok(()));
|
||||
} else {
|
||||
m.expect_delete_verification_otp().returning(|_, _| Ok(()));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait EmpIDExistsOutDBPort: Send + Sync {
|
||||
async fn emp_id_exists(&self, emp_id: &Uuid) -> OutDBPortResult<bool>;
|
||||
}
|
||||
|
||||
pub type EmpIDExistsOutDBPortObj = std::sync::Arc<dyn EmpIDExistsOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_emp_id_exists_db_port(
|
||||
times: Option<usize>,
|
||||
returning: bool,
|
||||
) -> EmpIDExistsOutDBPortObj {
|
||||
let mut m = MockEmpIDExistsOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_emp_id_exists()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(returning));
|
||||
} else {
|
||||
m.expect_emp_id_exists().returning(move |_| Ok(returning));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -10,12 +10,6 @@ pub type OutDBPortResult<V> = Result<V, OutDBPortError>;
|
|||
#[derive(Debug, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum OutDBPortError {
|
||||
InternalError,
|
||||
DuplicateEmpLoginOTP,
|
||||
DuplicateEmpVerificationOTP,
|
||||
DuplicateVerificationOTPSecret,
|
||||
VerificationSecretNotFound,
|
||||
VerificationOTPNotFound,
|
||||
PhoneNumberNotFound,
|
||||
EmpLoginOTPNotFound,
|
||||
EmpVerificationOTPNotFound,
|
||||
VerificationOTPSecretNotFound,
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait GetEmpIDFromPhoneNumberOutDBPort: Send + Sync {
|
||||
async fn get_emp_id_from_phone_number(&self, phone: &PhoneNumber) -> OutDBPortResult<Uuid>;
|
||||
}
|
||||
|
||||
pub type GetEmpIDFromPhoneNumberOutDBPortObj = std::sync::Arc<dyn GetEmpIDFromPhoneNumberOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use crate::utils::uuid::tests::UUID;
|
||||
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_get_emp_id_from_phone_number_db_port(
|
||||
times: Option<usize>,
|
||||
) -> GetEmpIDFromPhoneNumberOutDBPortObj {
|
||||
let mut m = MockGetEmpIDFromPhoneNumberOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_get_emp_id_from_phone_number()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(UUID));
|
||||
} else {
|
||||
m.expect_get_emp_id_from_phone_number()
|
||||
.returning(move |_| Ok(UUID));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait GetInviteOutDBPort: Send + Sync {
|
||||
async fn get_invite(&self, invitge_id: Uuid) -> OutDBPortResult<Option<Uuid>>;
|
||||
}
|
||||
|
||||
pub type GetInviteOutDBPortObj = std::sync::Arc<dyn GetInviteOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::utils::uuid::tests::*;
|
||||
|
||||
pub fn mock_get_invite_db_port_returns_none(times: Option<usize>) -> GetInviteOutDBPortObj {
|
||||
let mut m = MockGetInviteOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_get_invite()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(None));
|
||||
} else {
|
||||
m.expect_get_invite().returning(move |_| Ok(None));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
|
||||
pub fn mock_get_invite_db_port(times: Option<usize>) -> GetInviteOutDBPortObj {
|
||||
let mut m = MockGetInviteOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_get_invite()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(Some(UUID)));
|
||||
} else {
|
||||
m.expect_get_invite().returning(move |_| Ok(Some(UUID)));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub use super::create_login_otp::REGISTRATION_OTP_PURPOSE;
|
||||
use super::errors::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait GetLoginOTPOutDBPort: Send + Sync {
|
||||
async fn get_login_otp(&self, phone_number: &PhoneNumber) -> OutDBPortResult<Option<usize>>;
|
||||
}
|
||||
|
||||
pub type GetLoginOTPOutDBPortObj = std::sync::Arc<dyn GetLoginOTPOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_get_login_otp_db_port_returns_none(
|
||||
times: Option<usize>,
|
||||
) -> GetLoginOTPOutDBPortObj {
|
||||
let mut m = MockGetLoginOTPOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_get_login_otp()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(None));
|
||||
} else {
|
||||
m.expect_get_login_otp().returning(move |_| Ok(None));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
|
||||
pub fn mock_get_login_otp_db_port(times: Option<usize>) -> GetLoginOTPOutDBPortObj {
|
||||
let mut m = MockGetLoginOTPOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_get_login_otp()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(Some(0)));
|
||||
} else {
|
||||
m.expect_get_login_otp().returning(move |_| Ok(Some(0)));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub use super::create_verification_otp::REGISTRATION_OTP_PURPOSE;
|
||||
use super::errors::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait GetVerificationOTPOutDBPort: Send + Sync {
|
||||
async fn get_verification_otp(
|
||||
&self,
|
||||
phone_number: &PhoneNumber,
|
||||
) -> OutDBPortResult<Option<usize>>;
|
||||
}
|
||||
|
||||
pub type GetVerificationOTPOutDBPortObj = std::sync::Arc<dyn GetVerificationOTPOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_get_verification_otp_db_port_returns_none(
|
||||
times: Option<usize>,
|
||||
) -> GetVerificationOTPOutDBPortObj {
|
||||
let mut m = MockGetVerificationOTPOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_get_verification_otp()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(None));
|
||||
} else {
|
||||
m.expect_get_verification_otp().returning(move |_| Ok(None));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
|
||||
pub fn mock_get_verification_otp_db_port(
|
||||
times: Option<usize>,
|
||||
) -> GetVerificationOTPOutDBPortObj {
|
||||
let mut m = MockGetVerificationOTPOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_get_verification_otp()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(Some(0)));
|
||||
} else {
|
||||
m.expect_get_verification_otp()
|
||||
.returning(move |_| Ok(Some(0)));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait InviteIDExistsDBPort: Send + Sync {
|
||||
async fn invite_id_exists(&self, invite_id: &Uuid) -> OutDBPortResult<bool>;
|
||||
}
|
||||
|
||||
pub type InviteIDExistsDBPortObj = std::sync::Arc<dyn InviteIDExistsDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_invite_id_exists_db_port_false(times: Option<usize>) -> InviteIDExistsDBPortObj {
|
||||
let mut m = MockInviteIDExistsDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_invite_id_exists()
|
||||
.times(times)
|
||||
.returning(|_| Ok(false));
|
||||
} else {
|
||||
m.expect_invite_id_exists().returning(|_| Ok(false));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
|
||||
pub fn mock_invite_id_exists_db_port_true(times: Option<usize>) -> InviteIDExistsDBPortObj {
|
||||
let mut m = MockInviteIDExistsDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_invite_id_exists()
|
||||
.times(times)
|
||||
.returning(|_| Ok(true));
|
||||
} else {
|
||||
m.expect_invite_id_exists().returning(|_| Ok(true));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub use super::create_login_otp::REGISTRATION_OTP_PURPOSE;
|
||||
use super::errors::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait LoginOTPExistsOutDBPort: Send + Sync {
|
||||
async fn login_otp_exists(
|
||||
&self,
|
||||
otp: usize,
|
||||
phone_number: &PhoneNumber,
|
||||
) -> OutDBPortResult<bool>;
|
||||
}
|
||||
|
||||
pub type LoginOTPExistsOutDBPortObj = std::sync::Arc<dyn LoginOTPExistsOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_login_otp_exists_db_port(
|
||||
times: Option<usize>,
|
||||
returning: bool,
|
||||
) -> LoginOTPExistsOutDBPortObj {
|
||||
let mut m = MockLoginOTPExistsOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_login_otp_exists()
|
||||
.times(times)
|
||||
.returning(move |_, _| Ok(returning));
|
||||
} else {
|
||||
m.expect_login_otp_exists()
|
||||
.returning(move |_, _| Ok(returning));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -2,23 +2,10 @@
|
|||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
pub mod create_login_otp;
|
||||
pub mod create_verification_otp;
|
||||
pub mod create_verification_secret;
|
||||
pub mod delete_login_otp;
|
||||
pub mod delete_verification_otp;
|
||||
pub mod delete_verification_secret;
|
||||
pub mod email_exists;
|
||||
pub mod emp_id_exists;
|
||||
pub mod errors;
|
||||
pub mod get_emp_id_from_phone_number;
|
||||
pub mod get_invite;
|
||||
pub mod get_login_otp;
|
||||
pub mod get_verification_otp;
|
||||
pub mod get_verification_secret;
|
||||
pub mod invite_id_exists;
|
||||
pub mod phone_exists;
|
||||
pub mod store_id_exists;
|
||||
pub mod user_id_exists;
|
||||
//pub mod verification_otp_exists;
|
||||
pub mod verification_secret_exists;
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
|
||||
use super::errors::*;
|
||||
use crate::identity::domain::employee_aggregate::*;
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait PhoneNumberExistsOutDBPort: Send + Sync {
|
||||
async fn phone_exists(&self, phone: &PhoneNumber) -> OutDBPortResult<bool>;
|
||||
}
|
||||
|
||||
pub type PhoneNumberExistsOutDBPortObj = std::sync::Arc<dyn PhoneNumberExistsOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_phone_exists_db_port(
|
||||
times: Option<usize>,
|
||||
returning: bool,
|
||||
) -> PhoneNumberExistsOutDBPortObj {
|
||||
let mut m = MockPhoneNumberExistsOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_phone_exists()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(returning));
|
||||
} else {
|
||||
m.expect_phone_exists().returning(move |_| Ok(returning));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::errors::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait StoreIDExistsDBPort: Send + Sync {
|
||||
async fn store_id_exists(&self, store_id: &Uuid) -> OutDBPortResult<bool>;
|
||||
}
|
||||
|
||||
pub type StoreIDExistsDBPortObj = std::sync::Arc<dyn StoreIDExistsDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_store_id_exists_db_port_false(times: Option<usize>) -> StoreIDExistsDBPortObj {
|
||||
let mut m = MockStoreIDExistsDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_store_id_exists()
|
||||
.times(times)
|
||||
.returning(|_| Ok(false));
|
||||
} else {
|
||||
m.expect_store_id_exists().returning(|_| Ok(false));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
|
||||
pub fn mock_store_id_exists_db_port_true(times: Option<usize>) -> StoreIDExistsDBPortObj {
|
||||
let mut m = MockStoreIDExistsDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_store_id_exists()
|
||||
.times(times)
|
||||
.returning(|_| Ok(true));
|
||||
} else {
|
||||
m.expect_store_id_exists().returning(|_| Ok(true));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub use super::create_verification_otp::REGISTRATION_OTP_PURPOSE;
|
||||
use super::errors::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Builder)]
|
||||
pub struct VerifyOTPExistsMsg {
|
||||
pub otp: String,
|
||||
pub emp_id: Uuid,
|
||||
}
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait VerificationOTPExistsOutDBPort: Send + Sync {
|
||||
async fn verification_otp_exists(&self, msg: &VerifyOTPExistsMsg) -> OutDBPortResult<bool>;
|
||||
}
|
||||
|
||||
pub type VerificationOTPExistsOutDBPortObj = std::sync::Arc<dyn VerificationOTPExistsOutDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_verification_otp_exists_db_port(
|
||||
times: Option<usize>,
|
||||
returning: bool,
|
||||
) -> VerificationOTPExistsOutDBPortObj {
|
||||
let mut m = MockVerificationOTPExistsOutDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_verification_otp_exists()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(returning));
|
||||
} else {
|
||||
m.expect_verification_otp_exists()
|
||||
.returning(move |_| Ok(returning));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -4,4 +4,3 @@
|
|||
|
||||
pub mod db;
|
||||
pub mod mailer;
|
||||
pub mod phone;
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
|
||||
use super::errors::*;
|
||||
use crate::identity::domain::employee_aggregate::PhoneNumber;
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait AccountLoginOTPOutPhonePort: Send + Sync {
|
||||
async fn account_login_otp(&self, to: &PhoneNumber, otp: usize) -> OutPhonePortResult<()>;
|
||||
}
|
||||
|
||||
pub type AccountLoginOTPOutPhonePortObj = std::sync::Arc<dyn AccountLoginOTPOutPhonePort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_account_login_otp_phone_port(
|
||||
times: Option<usize>,
|
||||
) -> AccountLoginOTPOutPhonePortObj {
|
||||
let mut m = MockAccountLoginOTPOutPhonePort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_account_login_otp()
|
||||
.times(times)
|
||||
.returning(|_, _| Ok(()));
|
||||
} else {
|
||||
m.expect_account_login_otp().returning(|_, _| Ok(()));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
|
||||
use super::errors::*;
|
||||
use crate::identity::domain::employee_aggregate::PhoneNumber;
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait AccountValidationOTPOutPhonePort: Send + Sync {
|
||||
async fn account_validation_otp(&self, to: &PhoneNumber, otp: usize) -> OutPhonePortResult<()>;
|
||||
}
|
||||
|
||||
pub type AccountValidationOTPOutPhonePortObj = std::sync::Arc<dyn AccountValidationOTPOutPhonePort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_account_validation_otp_phone_port(
|
||||
times: Option<usize>,
|
||||
) -> AccountValidationOTPOutPhonePortObj {
|
||||
let mut m = MockAccountValidationOTPOutPhonePort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_account_validation_otp()
|
||||
.times(times)
|
||||
.returning(|_, _| Ok(()));
|
||||
} else {
|
||||
m.expect_account_validation_otp().returning(|_, _| Ok(()));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_more::Display;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub type OutPhonePortResult<V> = Result<V, OutPhonePortError>;
|
||||
|
||||
#[derive(Debug, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum OutPhonePortError {
|
||||
InternalError,
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
pub mod account_login_otp;
|
||||
pub mod account_validation_otp;
|
||||
pub mod errors;
|
|
@ -1,151 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
|
||||
use crate::identity::application::port::output::db::{emp_id_exists::*, get_invite::*};
|
||||
use crate::identity::domain::{accept_invite_command::*, invite_accepted_event::*};
|
||||
|
||||
use super::errors::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait EmployeeAcceptInviteUseCase: Send + Sync {
|
||||
async fn accept_invite(&self, cmd: AcceptInviteCommand) -> IdentityResult<InviteAcceptedEvent>;
|
||||
async fn reject_invite(&self, cmd: AcceptInviteCommand) -> IdentityResult<InviteAcceptedEvent>;
|
||||
}
|
||||
|
||||
pub type EmployeeAcceptInviteServiceObj = std::sync::Arc<dyn EmployeeAcceptInviteUseCase>;
|
||||
|
||||
#[derive(Clone, Builder)]
|
||||
pub struct EmployeeAcceptInviteService {
|
||||
db_emp_id_exists_adapter: EmpIDExistsOutDBPortObj,
|
||||
db_get_invite_adapter: GetInviteOutDBPortObj,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl EmployeeAcceptInviteUseCase for EmployeeAcceptInviteService {
|
||||
async fn reject_invite(&self, cmd: AcceptInviteCommand) -> IdentityResult<InviteAcceptedEvent> {
|
||||
todo!("also change input and output types");
|
||||
}
|
||||
async fn accept_invite(&self, cmd: AcceptInviteCommand) -> IdentityResult<InviteAcceptedEvent> {
|
||||
if !self
|
||||
.db_emp_id_exists_adapter
|
||||
.emp_id_exists(cmd.emp_id())
|
||||
.await?
|
||||
{
|
||||
return Err(IdentityError::EmployeeNotFound);
|
||||
}
|
||||
|
||||
let invite = match self
|
||||
.db_get_invite_adapter
|
||||
.get_invite(*cmd.invite_id())
|
||||
.await?
|
||||
{
|
||||
None => return Err(IdentityError::InviteNotFound),
|
||||
Some(invite) => invite,
|
||||
};
|
||||
|
||||
Ok(InviteAcceptedEventBuilder::default()
|
||||
.emp_id(*cmd.emp_id())
|
||||
.invite_id(*cmd.invite_id())
|
||||
.store_id(invite)
|
||||
.build()
|
||||
.unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{tests::bdd::*, utils::uuid::tests::*};
|
||||
|
||||
use super::*;
|
||||
|
||||
impl EmployeeAcceptInviteService {
|
||||
pub fn mock_service(
|
||||
times: Option<usize>,
|
||||
cmd: AcceptInviteCommand,
|
||||
) -> EmployeeAcceptInviteServiceObj {
|
||||
let res = InviteAcceptedEvent::get_event(&cmd);
|
||||
let mut m = MockEmployeeAcceptInviteUseCase::default();
|
||||
|
||||
if let Some(times) = times {
|
||||
m.expect_accept_invite()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(res.clone()));
|
||||
} else {
|
||||
m.expect_accept_invite().returning(move |_| Ok(res.clone()));
|
||||
}
|
||||
|
||||
std::sync::Arc::new(m)
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_service() {
|
||||
let s = EmployeeAcceptInviteServiceBuilder::default()
|
||||
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||
.db_get_invite_adapter(mock_get_invite_db_port(IS_CALLED_ONLY_ONCE))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
let cmd = AcceptInviteCommandBuilder::default()
|
||||
.emp_id(UUID)
|
||||
.invite_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let res = s.accept_invite(cmd.clone()).await.unwrap();
|
||||
assert_eq!(*res.emp_id(), UUID);
|
||||
assert_eq!(*res.invite_id(), UUID);
|
||||
assert_eq!(*res.store_id(), UUID);
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_service_invite_no_exist() {
|
||||
let s = EmployeeAcceptInviteServiceBuilder::default()
|
||||
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||
.db_get_invite_adapter(mock_get_invite_db_port_returns_none(IS_CALLED_ONLY_ONCE))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
let cmd = AcceptInviteCommandBuilder::default()
|
||||
.emp_id(UUID)
|
||||
.invite_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
s.accept_invite(cmd.clone()).await.err(),
|
||||
Some(IdentityError::InviteNotFound)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_service_emp_no_exist() {
|
||||
let s = EmployeeAcceptInviteServiceBuilder::default()
|
||||
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, false))
|
||||
.db_get_invite_adapter(mock_get_invite_db_port(IS_NEVER_CALLED))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
let cmd = AcceptInviteCommandBuilder::default()
|
||||
.emp_id(UUID)
|
||||
.invite_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
s.accept_invite(cmd.clone()).await.err(),
|
||||
Some(IdentityError::EmployeeNotFound)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
|
||||
use crate::identity::application::port::output::db::{emp_id_exists::*, store_id_exists::*};
|
||||
use crate::identity::domain::{exit_organization_command::*, organization_exited_event::*};
|
||||
|
||||
use super::errors::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait EmployeeExitOrganizationUseCase: Send + Sync {
|
||||
async fn exit_organization(
|
||||
&self,
|
||||
cmd: ExitOrganizationCommand,
|
||||
) -> IdentityResult<OrganizationExitedEvent>;
|
||||
}
|
||||
|
||||
pub type EmployeeExitOrganizationServiceObj = std::sync::Arc<dyn EmployeeExitOrganizationUseCase>;
|
||||
|
||||
#[derive(Clone, Builder)]
|
||||
pub struct EmployeeExitOrganizationService {
|
||||
db_emp_id_exists_adapter: EmpIDExistsOutDBPortObj,
|
||||
db_store_id_exists_adapter: StoreIDExistsDBPortObj,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl EmployeeExitOrganizationUseCase for EmployeeExitOrganizationService {
|
||||
async fn exit_organization(
|
||||
&self,
|
||||
cmd: ExitOrganizationCommand,
|
||||
) -> IdentityResult<OrganizationExitedEvent> {
|
||||
if !self
|
||||
.db_emp_id_exists_adapter
|
||||
.emp_id_exists(cmd.emp_id())
|
||||
.await?
|
||||
{
|
||||
return Err(IdentityError::EmployeeNotFound);
|
||||
}
|
||||
|
||||
if !self
|
||||
.db_store_id_exists_adapter
|
||||
.store_id_exists(cmd.emp_id())
|
||||
.await?
|
||||
{
|
||||
return Err(IdentityError::StoreNotFound);
|
||||
}
|
||||
|
||||
Ok(OrganizationExitedEventBuilder::default()
|
||||
.emp_id(*cmd.emp_id())
|
||||
.store_id(*cmd.store_id())
|
||||
.build()
|
||||
.unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{tests::bdd::*, utils::uuid::tests::*};
|
||||
|
||||
use super::*;
|
||||
|
||||
impl EmployeeExitOrganizationService {
|
||||
pub fn mock_service(
|
||||
times: Option<usize>,
|
||||
cmd: ExitOrganizationCommand,
|
||||
) -> EmployeeExitOrganizationServiceObj {
|
||||
let res = OrganizationExitedEvent::get_event(&cmd);
|
||||
let mut m = MockEmployeeExitOrganizationUseCase::default();
|
||||
|
||||
if let Some(times) = times {
|
||||
m.expect_exit_organization()
|
||||
.times(times)
|
||||
.returning(move |_| Ok(res.clone()));
|
||||
} else {
|
||||
m.expect_exit_organization()
|
||||
.returning(move |_| Ok(res.clone()));
|
||||
}
|
||||
|
||||
std::sync::Arc::new(m)
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_service() {
|
||||
let s = EmployeeExitOrganizationServiceBuilder::default()
|
||||
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||
.db_store_id_exists_adapter(mock_store_id_exists_db_port_true(IS_CALLED_ONLY_ONCE))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
let cmd = ExitOrganizationCommandBuilder::default()
|
||||
.emp_id(UUID)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let res = s.exit_organization(cmd.clone()).await.unwrap();
|
||||
assert_eq!(*res.emp_id(), UUID);
|
||||
assert_eq!(*res.store_id(), UUID);
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_service_store_no_exist() {
|
||||
let s = EmployeeExitOrganizationServiceBuilder::default()
|
||||
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||
.db_store_id_exists_adapter(mock_store_id_exists_db_port_false(IS_CALLED_ONLY_ONCE))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
let cmd = ExitOrganizationCommandBuilder::default()
|
||||
.emp_id(UUID)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
s.exit_organization(cmd.clone()).await.err(),
|
||||
Some(IdentityError::StoreNotFound)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_service_emp_no_exist() {
|
||||
let s = EmployeeExitOrganizationServiceBuilder::default()
|
||||
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, false))
|
||||
.db_store_id_exists_adapter(mock_store_id_exists_db_port_true(IS_NEVER_CALLED))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
let cmd = ExitOrganizationCommandBuilder::default()
|
||||
.emp_id(UUID)
|
||||
.store_id(UUID)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
s.exit_organization(cmd.clone()).await.err(),
|
||||
Some(IdentityError::EmployeeNotFound)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue