Align schema, API routes, and auth with updated admin domain model.

Rename users table fields and loan documents table, expand branch billing credentials, switch to /api/admin prefix, refactor auth endpoints, replace PATCH with PUT for status updates, remove file upload APIs, and regenerate Swagger with ordered tags.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-06 14:09:45 +05:00
parent 0c717101da
commit 82e1aad016
22 changed files with 4248 additions and 418 deletions

View File

@@ -1,8 +1,8 @@
DROP TABLE IF EXISTS loans_documents;
DROP TABLE IF EXISTS loan_required_documents;
DROP TABLE IF EXISTS loan_types;
DROP TABLE IF EXISTS reasons_cards;
DROP TABLE IF EXISTS payment_cards;
DROP TABLE IF EXISTS branches;
DROP TABLE IF EXISTS location;
DROP TABLE IF EXISTS province;
DROP TABLE IF EXISTS admin;
DROP TABLE IF EXISTS provinces;
DROP TABLE IF EXISTS users;

View File

@@ -1,6 +1,6 @@
CREATE TABLE IF NOT EXISTS admin (
CREATE TABLE IF NOT EXISTS users (
"id" bigserial primary key,
"login" character varying(250) NOT NULL DEFAULT '',
"email" character varying(250) NOT NULL DEFAULT '',
"password" character varying(250) NOT NULL DEFAULT '',
"fullname" character varying(250) NOT NULL DEFAULT '',
"username" character varying(250) NOT NULL DEFAULT '',
@@ -14,8 +14,8 @@ CREATE TABLE IF NOT EXISTS admin (
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
insert into admin(
phone_number, password, fullname, login, role
insert into users(
phone_number, password, fullname, email, role
) values (
'61531216',
'$2a$12$8ZbKmoSwna4CASQptM2/SubwvsBUR1YhABULd.2/QJB.13Wi2v55m',
@@ -24,16 +24,17 @@ insert into admin(
'admin'
);
CREATE TABLE IF NOT EXISTS province (
CREATE TABLE IF NOT EXISTS provinces (
id bigserial PRIMARY KEY,
title json NOT NULL DEFAULT '{}'::json
title json NOT NULL DEFAULT '{}'::json,
status boolean NOT NULL DEFAULT true,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
CREATE TABLE IF NOT EXISTS location (
id bigserial PRIMARY KEY,
province_id bigint NOT NULL REFERENCES province(id) ON DELETE CASCADE,
province_id bigint NOT NULL REFERENCES provinces(id) ON DELETE CASCADE,
title json NOT NULL DEFAULT '{}'::json,
status boolean NOT NULL DEFAULT true,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
@@ -43,15 +44,18 @@ CREATE TABLE IF NOT EXISTS location (
CREATE TABLE IF NOT EXISTS branches (
id bigserial PRIMARY KEY,
title json NOT NULL DEFAULT '{}'::json,
province_id bigint NOT NULL REFERENCES province(id) ON DELETE CASCADE,
province_id bigint NOT NULL REFERENCES provinces(id) ON DELETE CASCADE,
location_id bigint NOT NULL REFERENCES location(id) ON DELETE CASCADE,
unikal_nomer character varying(250) NOT NULL UNIQUE,
address json NOT NULL DEFAULT '{}'::json,
billing_login character varying(250) NOT NULL DEFAULT '',
"address" text NOT NULL DEFAULT '',
billing_username character varying(250) NOT NULL DEFAULT '',
billing_password character varying(250) NOT NULL DEFAULT '',
billing_username_sber character varying(250) NOT NULL DEFAULT '',
billing_password_sber character varying(250) NOT NULL DEFAULT '',
billing_username_visa character varying(250) NOT NULL DEFAULT '',
billing_password_visa character varying(250) NOT NULL DEFAULT '',
billing_username_swift character varying(250) NOT NULL DEFAULT '',
billing_password_swift character varying(250) NOT NULL DEFAULT '',
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
@@ -85,7 +89,7 @@ CREATE TABLE IF NOT EXISTS loan_types (
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
CREATE TABLE IF NOT EXISTS loans_documents (
CREATE TABLE IF NOT EXISTS loan_required_documents (
id bigserial PRIMARY KEY,
title json NOT NULL DEFAULT '{}'::json,
content_en text NOT NULL DEFAULT '',