change users table
This commit is contained in:
2
app.go
2
app.go
@@ -37,6 +37,8 @@ import (
|
||||
// @tag.description Loan types
|
||||
// @tag.name loan-document
|
||||
// @tag.description Loan required documents
|
||||
// @tag.name loans-repayment
|
||||
// @tag.description Loan repayments
|
||||
func main() {
|
||||
docs.SwaggerInfo.Title = "Service APIs"
|
||||
docs.SwaggerInfo.Version = "1.0"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
DROP TABLE IF EXISTS loan_paid_off_letters;
|
||||
DROP TABLE IF EXISTS loans;
|
||||
DROP TABLE IF EXISTS loan_orders;
|
||||
DROP TABLE IF EXISTS branch_user;
|
||||
DROP TABLE IF EXISTS loan_order_required_docs;
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
CREATE TABLE IF NOT EXISTS roles (
|
||||
id bigserial PRIMARY KEY,
|
||||
code character varying(255) NOT NULL DEFAULT '',
|
||||
name character varying(255) NOT NULL,
|
||||
guard_name character varying(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
"id" bigserial primary key,
|
||||
"email" character varying(250) NOT NULL DEFAULT '',
|
||||
"name" character varying(250) NOT NULL DEFAULT '',
|
||||
"password" character varying(250) NOT NULL DEFAULT '',
|
||||
"first_name" character varying(250) NOT NULL DEFAULT '',
|
||||
"last_name" character varying(250) NOT NULL DEFAULT '',
|
||||
"name" character varying(255) NOT NULL DEFAULT '',
|
||||
"first_name" character varying(255) NOT NULL DEFAULT '',
|
||||
"last_name" character varying(255) NOT NULL DEFAULT '',
|
||||
"username" character varying(250) NOT NULL DEFAULT '',
|
||||
"phone" character varying(250) NOT NULL DEFAULT '',
|
||||
"avatar" character varying(250) NOT NULL DEFAULT '',
|
||||
"social_media" json NOT NULL DEFAULT '{}'::json,
|
||||
"light_mode" integer DEFAULT 1 NOT NULL,
|
||||
"role" character varying(250) NOT NULL DEFAULT 'user',
|
||||
"role_id" bigint,
|
||||
"active" 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,
|
||||
CONSTRAINT users_role_id_fkey
|
||||
FOREIGN KEY ("role_id")
|
||||
REFERENCES roles("id")
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
);
|
||||
|
||||
insert into users(
|
||||
@@ -60,7 +66,7 @@ CREATE TABLE IF NOT EXISTS branches (
|
||||
CONSTRAINT branches_province_id_fkey
|
||||
FOREIGN KEY ("province_id")
|
||||
REFERENCES provinces("id")
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS card_types (
|
||||
@@ -83,6 +89,23 @@ CREATE TABLE IF NOT EXISTS card_states (
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permissions (
|
||||
id bigserial PRIMARY KEY,
|
||||
code character varying(255) NOT NULL DEFAULT '',
|
||||
name character varying(255) NOT NULL,
|
||||
guard_name character varying(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS branch_user (
|
||||
id bigserial PRIMARY KEY,
|
||||
branch_id bigint REFERENCES branches(id),
|
||||
user_id bigint REFERENCES users(id),
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS loan_types (
|
||||
id bigserial PRIMARY KEY,
|
||||
name json NOT NULL DEFAULT '{}'::json,
|
||||
@@ -103,33 +126,6 @@ CREATE TABLE IF NOT EXISTS loan_order_required_docs (
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS roles (
|
||||
id bigserial PRIMARY KEY,
|
||||
code character varying(255) NOT NULL DEFAULT '',
|
||||
name character varying(255) NOT NULL,
|
||||
guard_name character varying(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permissions (
|
||||
id bigserial PRIMARY KEY,
|
||||
code character varying(255) NOT NULL DEFAULT '',
|
||||
name character varying(255) NOT NULL,
|
||||
guard_name character varying(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS branch_user (
|
||||
id bigserial PRIMARY KEY,
|
||||
branch_id bigint REFERENCES branches(id) ON DELETE CASCADE,
|
||||
user_id bigint REFERENCES users(id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS loan_orders (
|
||||
id bigserial PRIMARY KEY,
|
||||
unique_id character varying(255),
|
||||
@@ -200,7 +196,47 @@ CREATE TABLE IF NOT EXISTS loan_orders (
|
||||
satisfiable character varying(255),
|
||||
notes text,
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
|
||||
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS loans (
|
||||
id bigserial PRIMARY KEY,
|
||||
user_id bigint,
|
||||
passport_serie character varying(255) NOT NULL,
|
||||
passport_id character varying(255) NOT NULL,
|
||||
account_number character varying(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
CONSTRAINT loans_user_id_fkey
|
||||
FOREIGN KEY ("user_id") REFERENCES users(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS loan_paid_off_letters (
|
||||
id bigserial PRIMARY KEY,
|
||||
unique_id character varying(255),
|
||||
region character varying(2) NOT NULL,
|
||||
branch_id bigint NOT NULL,
|
||||
user_id bigint,
|
||||
customer_name character varying(255) NOT NULL,
|
||||
customer_surname character varying(255) NOT NULL,
|
||||
customer_patronic_name character varying(255),
|
||||
born_at date,
|
||||
phone character varying(255) NOT NULL,
|
||||
passport_serie character varying(255) NOT NULL,
|
||||
passport_id character varying(255) NOT NULL,
|
||||
status character varying(255),
|
||||
notes text,
|
||||
loan_contract_number character varying(255),
|
||||
loan_contract_date date,
|
||||
loan_amount character varying(255),
|
||||
loan_reason character varying(255),
|
||||
loan_file text,
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
CONSTRAINT loan_paid_off_letters_branch_id_fkey
|
||||
FOREIGN KEY ("branch_id") REFERENCES branches(id),
|
||||
CONSTRAINT loan_paid_off_letters_user_id_fkey
|
||||
FOREIGN KEY ("user_id") REFERENCES users(id)
|
||||
);
|
||||
|
||||
|
||||
768
docs/docs.go
768
docs/docs.go
@@ -822,6 +822,296 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loan-paid-off-letters": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated loan paid off letters with optional filters",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "List loan paid off letters",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by passport ID",
|
||||
"name": "passport_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by status",
|
||||
"name": "status",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Filter by branch ID",
|
||||
"name": "branch_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by region",
|
||||
"name": "region",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 1,
|
||||
"description": "Page number",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 10,
|
||||
"description": "Items per page",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Creates a new loan paid off letter",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "Create loan paid off letter",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Loan paid off letter payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/loanpaidletter.CreateLoanPaidLetterDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loan-paid-off-letters/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns a single loan paid off letter",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "Get loan paid off letter by ID",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan paid off letter ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Updates an existing loan paid off letter",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "Update loan paid off letter",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan paid off letter ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Loan paid off letter payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/loanpaidletter.UpdateLoanPaidLetterDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Deletes a loan paid off letter",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "Delete loan paid off letter",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan paid off letter ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loan-types": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -1436,6 +1726,278 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loans-repayment": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated loan repayments with optional filters",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "List loan repayments",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by passport ID",
|
||||
"name": "passport_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 1,
|
||||
"description": "Page number",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 10,
|
||||
"description": "Items per page",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Creates a new loan repayment record",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "Create loan repayment",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Loan repayment payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/loansrepayment.CreateLoanRepaymentDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loans-repayment/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns a single loan repayment",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "Get loan repayment by ID",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan repayment ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Updates an existing loan repayment record",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "Update loan repayment",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan repayment ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Loan repayment payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/loansrepayment.UpdateLoanRepaymentDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Deletes a loan repayment record",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "Delete loan repayment",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan repayment ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/login": {
|
||||
"post": {
|
||||
"description": "Authenticates a user by email and password",
|
||||
@@ -3909,6 +4471,142 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"loanpaidletter.CreateLoanPaidLetterDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"branchId",
|
||||
"customerName",
|
||||
"customerSurname",
|
||||
"passportId",
|
||||
"passportSerie",
|
||||
"phone",
|
||||
"region"
|
||||
],
|
||||
"properties": {
|
||||
"bornAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"branchId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"customerName": {
|
||||
"type": "string"
|
||||
},
|
||||
"customerPatronicName": {
|
||||
"type": "string"
|
||||
},
|
||||
"customerSurname": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanAmount": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanContractDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanContractNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanFile": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanReason": {
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportId": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportSerie": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"uniqueId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"loanpaidletter.UpdateLoanPaidLetterDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"branchId",
|
||||
"customerName",
|
||||
"customerSurname",
|
||||
"passportId",
|
||||
"passportSerie",
|
||||
"phone",
|
||||
"region"
|
||||
],
|
||||
"properties": {
|
||||
"bornAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"branchId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"customerName": {
|
||||
"type": "string"
|
||||
},
|
||||
"customerPatronicName": {
|
||||
"type": "string"
|
||||
},
|
||||
"customerSurname": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanAmount": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanContractDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanContractNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanFile": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanReason": {
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportId": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportSerie": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"uniqueId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"loansdocument.CreateLoanDocumentDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -3953,6 +4651,52 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"loansrepayment.CreateLoanRepaymentDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"accountNumber",
|
||||
"passportId",
|
||||
"passportSerie",
|
||||
"userId"
|
||||
],
|
||||
"properties": {
|
||||
"accountNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportId": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportSerie": {
|
||||
"type": "string"
|
||||
},
|
||||
"userId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"loansrepayment.UpdateLoanRepaymentDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"accountNumber",
|
||||
"passportId",
|
||||
"passportSerie",
|
||||
"userId"
|
||||
],
|
||||
"properties": {
|
||||
"accountNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportId": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportSerie": {
|
||||
"type": "string"
|
||||
},
|
||||
"userId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"loantype.CreateLoanTypeDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -4269,7 +5013,7 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"email",
|
||||
"fullname",
|
||||
"name",
|
||||
"password",
|
||||
"username"
|
||||
],
|
||||
@@ -4283,16 +5027,22 @@ const docTemplate = `{
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"fullname": {
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightMode": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"phoneNumber": {
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"role": {
|
||||
@@ -4324,7 +5074,7 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"email",
|
||||
"fullname",
|
||||
"name",
|
||||
"username"
|
||||
],
|
||||
"properties": {
|
||||
@@ -4337,13 +5087,19 @@ const docTemplate = `{
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"fullname": {
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightMode": {
|
||||
"type": "integer"
|
||||
},
|
||||
"phoneNumber": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"role": {
|
||||
|
||||
@@ -816,6 +816,296 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loan-paid-off-letters": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated loan paid off letters with optional filters",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "List loan paid off letters",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by passport ID",
|
||||
"name": "passport_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by status",
|
||||
"name": "status",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Filter by branch ID",
|
||||
"name": "branch_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by region",
|
||||
"name": "region",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 1,
|
||||
"description": "Page number",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 10,
|
||||
"description": "Items per page",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Creates a new loan paid off letter",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "Create loan paid off letter",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Loan paid off letter payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/loanpaidletter.CreateLoanPaidLetterDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loan-paid-off-letters/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns a single loan paid off letter",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "Get loan paid off letter by ID",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan paid off letter ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Updates an existing loan paid off letter",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "Update loan paid off letter",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan paid off letter ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Loan paid off letter payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/loanpaidletter.UpdateLoanPaidLetterDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Deletes a loan paid off letter",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loan-paid-off-letters"
|
||||
],
|
||||
"summary": "Delete loan paid off letter",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan paid off letter ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loan-types": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -1430,6 +1720,278 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loans-repayment": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated loan repayments with optional filters",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "List loan repayments",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by passport ID",
|
||||
"name": "passport_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 1,
|
||||
"description": "Page number",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 10,
|
||||
"description": "Items per page",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Creates a new loan repayment record",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "Create loan repayment",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Loan repayment payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/loansrepayment.CreateLoanRepaymentDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loans-repayment/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns a single loan repayment",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "Get loan repayment by ID",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan repayment ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Updates an existing loan repayment record",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "Update loan repayment",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan repayment ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Loan repayment payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/loansrepayment.UpdateLoanRepaymentDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Deletes a loan repayment record",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"loans-repayment"
|
||||
],
|
||||
"summary": "Delete loan repayment",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Loan repayment ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/login": {
|
||||
"post": {
|
||||
"description": "Authenticates a user by email and password",
|
||||
@@ -3903,6 +4465,142 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"loanpaidletter.CreateLoanPaidLetterDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"branchId",
|
||||
"customerName",
|
||||
"customerSurname",
|
||||
"passportId",
|
||||
"passportSerie",
|
||||
"phone",
|
||||
"region"
|
||||
],
|
||||
"properties": {
|
||||
"bornAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"branchId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"customerName": {
|
||||
"type": "string"
|
||||
},
|
||||
"customerPatronicName": {
|
||||
"type": "string"
|
||||
},
|
||||
"customerSurname": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanAmount": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanContractDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanContractNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanFile": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanReason": {
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportId": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportSerie": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"uniqueId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"loanpaidletter.UpdateLoanPaidLetterDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"branchId",
|
||||
"customerName",
|
||||
"customerSurname",
|
||||
"passportId",
|
||||
"passportSerie",
|
||||
"phone",
|
||||
"region"
|
||||
],
|
||||
"properties": {
|
||||
"bornAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"branchId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"customerName": {
|
||||
"type": "string"
|
||||
},
|
||||
"customerPatronicName": {
|
||||
"type": "string"
|
||||
},
|
||||
"customerSurname": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanAmount": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanContractDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanContractNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanFile": {
|
||||
"type": "string"
|
||||
},
|
||||
"loanReason": {
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportId": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportSerie": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"uniqueId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"loansdocument.CreateLoanDocumentDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -3947,6 +4645,52 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"loansrepayment.CreateLoanRepaymentDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"accountNumber",
|
||||
"passportId",
|
||||
"passportSerie",
|
||||
"userId"
|
||||
],
|
||||
"properties": {
|
||||
"accountNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportId": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportSerie": {
|
||||
"type": "string"
|
||||
},
|
||||
"userId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"loansrepayment.UpdateLoanRepaymentDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"accountNumber",
|
||||
"passportId",
|
||||
"passportSerie",
|
||||
"userId"
|
||||
],
|
||||
"properties": {
|
||||
"accountNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportId": {
|
||||
"type": "string"
|
||||
},
|
||||
"passportSerie": {
|
||||
"type": "string"
|
||||
},
|
||||
"userId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"loantype.CreateLoanTypeDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -4263,7 +5007,7 @@
|
||||
"type": "object",
|
||||
"required": [
|
||||
"email",
|
||||
"fullname",
|
||||
"name",
|
||||
"password",
|
||||
"username"
|
||||
],
|
||||
@@ -4277,16 +5021,22 @@
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"fullname": {
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightMode": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"phoneNumber": {
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"role": {
|
||||
@@ -4318,7 +5068,7 @@
|
||||
"type": "object",
|
||||
"required": [
|
||||
"email",
|
||||
"fullname",
|
||||
"name",
|
||||
"username"
|
||||
],
|
||||
"properties": {
|
||||
@@ -4331,13 +5081,19 @@
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"fullname": {
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lightMode": {
|
||||
"type": "integer"
|
||||
},
|
||||
"phoneNumber": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"role": {
|
||||
|
||||
@@ -449,6 +449,100 @@ definitions:
|
||||
- realAddress
|
||||
- region
|
||||
type: object
|
||||
loanpaidletter.CreateLoanPaidLetterDTO:
|
||||
properties:
|
||||
bornAt:
|
||||
type: string
|
||||
branchId:
|
||||
type: integer
|
||||
customerName:
|
||||
type: string
|
||||
customerPatronicName:
|
||||
type: string
|
||||
customerSurname:
|
||||
type: string
|
||||
loanAmount:
|
||||
type: string
|
||||
loanContractDate:
|
||||
type: string
|
||||
loanContractNumber:
|
||||
type: string
|
||||
loanFile:
|
||||
type: string
|
||||
loanReason:
|
||||
type: string
|
||||
notes:
|
||||
type: string
|
||||
passportId:
|
||||
type: string
|
||||
passportSerie:
|
||||
type: string
|
||||
phone:
|
||||
type: string
|
||||
region:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
uniqueId:
|
||||
type: string
|
||||
userId:
|
||||
type: integer
|
||||
required:
|
||||
- branchId
|
||||
- customerName
|
||||
- customerSurname
|
||||
- passportId
|
||||
- passportSerie
|
||||
- phone
|
||||
- region
|
||||
type: object
|
||||
loanpaidletter.UpdateLoanPaidLetterDTO:
|
||||
properties:
|
||||
bornAt:
|
||||
type: string
|
||||
branchId:
|
||||
type: integer
|
||||
customerName:
|
||||
type: string
|
||||
customerPatronicName:
|
||||
type: string
|
||||
customerSurname:
|
||||
type: string
|
||||
loanAmount:
|
||||
type: string
|
||||
loanContractDate:
|
||||
type: string
|
||||
loanContractNumber:
|
||||
type: string
|
||||
loanFile:
|
||||
type: string
|
||||
loanReason:
|
||||
type: string
|
||||
notes:
|
||||
type: string
|
||||
passportId:
|
||||
type: string
|
||||
passportSerie:
|
||||
type: string
|
||||
phone:
|
||||
type: string
|
||||
region:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
uniqueId:
|
||||
type: string
|
||||
userId:
|
||||
type: integer
|
||||
required:
|
||||
- branchId
|
||||
- customerName
|
||||
- customerSurname
|
||||
- passportId
|
||||
- passportSerie
|
||||
- phone
|
||||
- region
|
||||
type: object
|
||||
loansdocument.CreateLoanDocumentDTO:
|
||||
properties:
|
||||
active:
|
||||
@@ -478,6 +572,38 @@ definitions:
|
||||
- name
|
||||
- value
|
||||
type: object
|
||||
loansrepayment.CreateLoanRepaymentDTO:
|
||||
properties:
|
||||
accountNumber:
|
||||
type: string
|
||||
passportId:
|
||||
type: string
|
||||
passportSerie:
|
||||
type: string
|
||||
userId:
|
||||
type: integer
|
||||
required:
|
||||
- accountNumber
|
||||
- passportId
|
||||
- passportSerie
|
||||
- userId
|
||||
type: object
|
||||
loansrepayment.UpdateLoanRepaymentDTO:
|
||||
properties:
|
||||
accountNumber:
|
||||
type: string
|
||||
passportId:
|
||||
type: string
|
||||
passportSerie:
|
||||
type: string
|
||||
userId:
|
||||
type: integer
|
||||
required:
|
||||
- accountNumber
|
||||
- passportId
|
||||
- passportSerie
|
||||
- userId
|
||||
type: object
|
||||
loantype.CreateLoanTypeDTO:
|
||||
properties:
|
||||
active:
|
||||
@@ -695,13 +821,17 @@ definitions:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
fullname:
|
||||
firstName:
|
||||
type: string
|
||||
lastName:
|
||||
type: string
|
||||
lightMode:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
phoneNumber:
|
||||
phone:
|
||||
type: string
|
||||
role:
|
||||
type: string
|
||||
@@ -711,7 +841,7 @@ definitions:
|
||||
type: string
|
||||
required:
|
||||
- email
|
||||
- fullname
|
||||
- name
|
||||
- password
|
||||
- username
|
||||
type: object
|
||||
@@ -732,11 +862,15 @@ definitions:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
fullname:
|
||||
firstName:
|
||||
type: string
|
||||
lastName:
|
||||
type: string
|
||||
lightMode:
|
||||
type: integer
|
||||
phoneNumber:
|
||||
name:
|
||||
type: string
|
||||
phone:
|
||||
type: string
|
||||
role:
|
||||
type: string
|
||||
@@ -746,7 +880,7 @@ definitions:
|
||||
type: string
|
||||
required:
|
||||
- email
|
||||
- fullname
|
||||
- name
|
||||
- username
|
||||
type: object
|
||||
host: localhost:5050
|
||||
@@ -1270,6 +1404,192 @@ paths:
|
||||
summary: Update loan order
|
||||
tags:
|
||||
- loan-orders
|
||||
/loan-paid-off-letters:
|
||||
get:
|
||||
description: Returns paginated loan paid off letters with optional filters
|
||||
parameters:
|
||||
- description: Filter by passport ID
|
||||
in: query
|
||||
name: passport_id
|
||||
type: string
|
||||
- description: Filter by status
|
||||
in: query
|
||||
name: status
|
||||
type: string
|
||||
- description: Filter by branch ID
|
||||
in: query
|
||||
name: branch_id
|
||||
type: integer
|
||||
- description: Filter by region
|
||||
in: query
|
||||
name: region
|
||||
type: string
|
||||
- default: 1
|
||||
description: Page number
|
||||
in: query
|
||||
name: page
|
||||
type: integer
|
||||
- default: 10
|
||||
description: Items per page
|
||||
in: query
|
||||
name: limit
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: List loan paid off letters
|
||||
tags:
|
||||
- loan-paid-off-letters
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Creates a new loan paid off letter
|
||||
parameters:
|
||||
- description: Loan paid off letter payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/loanpaidletter.CreateLoanPaidLetterDTO'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"201":
|
||||
description: Created
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Create loan paid off letter
|
||||
tags:
|
||||
- loan-paid-off-letters
|
||||
/loan-paid-off-letters/{id}:
|
||||
delete:
|
||||
description: Deletes a loan paid off letter
|
||||
parameters:
|
||||
- description: Loan paid off letter ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Delete loan paid off letter
|
||||
tags:
|
||||
- loan-paid-off-letters
|
||||
get:
|
||||
description: Returns a single loan paid off letter
|
||||
parameters:
|
||||
- description: Loan paid off letter ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Get loan paid off letter by ID
|
||||
tags:
|
||||
- loan-paid-off-letters
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Updates an existing loan paid off letter
|
||||
parameters:
|
||||
- description: Loan paid off letter ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
- description: Loan paid off letter payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/loanpaidletter.UpdateLoanPaidLetterDTO'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Update loan paid off letter
|
||||
tags:
|
||||
- loan-paid-off-letters
|
||||
/loan-types:
|
||||
get:
|
||||
description: Returns paginated loan types with optional filters
|
||||
@@ -1663,6 +1983,180 @@ paths:
|
||||
summary: Update loan document active
|
||||
tags:
|
||||
- loan-document
|
||||
/loans-repayment:
|
||||
get:
|
||||
description: Returns paginated loan repayments with optional filters
|
||||
parameters:
|
||||
- description: Filter by passport ID
|
||||
in: query
|
||||
name: passport_id
|
||||
type: string
|
||||
- default: 1
|
||||
description: Page number
|
||||
in: query
|
||||
name: page
|
||||
type: integer
|
||||
- default: 10
|
||||
description: Items per page
|
||||
in: query
|
||||
name: limit
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: List loan repayments
|
||||
tags:
|
||||
- loans-repayment
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Creates a new loan repayment record
|
||||
parameters:
|
||||
- description: Loan repayment payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/loansrepayment.CreateLoanRepaymentDTO'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"201":
|
||||
description: Created
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Create loan repayment
|
||||
tags:
|
||||
- loans-repayment
|
||||
/loans-repayment/{id}:
|
||||
delete:
|
||||
description: Deletes a loan repayment record
|
||||
parameters:
|
||||
- description: Loan repayment ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Delete loan repayment
|
||||
tags:
|
||||
- loans-repayment
|
||||
get:
|
||||
description: Returns a single loan repayment
|
||||
parameters:
|
||||
- description: Loan repayment ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Get loan repayment by ID
|
||||
tags:
|
||||
- loans-repayment
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Updates an existing loan repayment record
|
||||
parameters:
|
||||
- description: Loan repayment ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
- description: Loan repayment payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/loansrepayment.UpdateLoanRepaymentDTO'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Update loan repayment
|
||||
tags:
|
||||
- loans-repayment
|
||||
/login:
|
||||
post:
|
||||
consumes:
|
||||
|
||||
@@ -14,6 +14,7 @@ var swaggerTagOrder = []struct {
|
||||
{Name: "reason-card", Description: "Reason cards"},
|
||||
{Name: "loan-type", Description: "Loan types"},
|
||||
{Name: "loan-document", Description: "Loan required documents"},
|
||||
{Name: "loans-repayment", Description: "Loan repayments"},
|
||||
}
|
||||
|
||||
func applySwaggerTagOrder() {
|
||||
|
||||
@@ -26,7 +26,7 @@ func NewRepository(client postgresql.Client, logger *logging.Logger) auth.Reposi
|
||||
const (
|
||||
loginQuery = `SELECT id, password FROM users WHERE email = $1`
|
||||
userByIDQuery = `SELECT id, password FROM users WHERE id = $1`
|
||||
profileQuery = `SELECT id, fullname, phone_number, avatar, created_at
|
||||
profileQuery = `SELECT id, name, first_name, last_name, phone, avatar, created_at
|
||||
FROM users WHERE id = $1`
|
||||
)
|
||||
|
||||
@@ -46,8 +46,10 @@ func (r *repository) GetProfile(ctx context.Context, id int) (auth.UserProfileDT
|
||||
var profile auth.UserProfileDTO
|
||||
err := r.client.QueryRow(ctx, profileQuery, id).Scan(
|
||||
&profile.Id,
|
||||
&profile.FullName,
|
||||
&profile.PhoneNumber,
|
||||
&profile.Name,
|
||||
&profile.FirstName,
|
||||
&profile.LastName,
|
||||
&profile.Phone,
|
||||
&profile.Avatar,
|
||||
&profile.CreatedAt,
|
||||
)
|
||||
|
||||
@@ -12,11 +12,13 @@ type RefreshTokenDTO struct {
|
||||
}
|
||||
|
||||
type UserProfileDTO struct {
|
||||
Id int `json:"id"`
|
||||
FullName string `json:"fullName"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Avatar string `json:"avatar"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Id int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
FirstName string `json:"firstName"`
|
||||
LastName string `json:"lastName"`
|
||||
Phone string `json:"phone"`
|
||||
Avatar string `json:"avatar"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
type UserCredentials struct {
|
||||
|
||||
@@ -165,7 +165,7 @@ func (r *repository) Create(ctx context.Context, dto branches.CreateBranchDTO) (
|
||||
billing_username, billing_password, billing_sber_username, billing_sber_password,
|
||||
billing_visa_master_username, billing_visa_master_password,
|
||||
billing_swift_username, billing_swift_password, active
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16)
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)
|
||||
RETURNING ` + branchReturningColumns + `
|
||||
)
|
||||
SELECT ` + branchReturnedSelectColumns + `
|
||||
|
||||
@@ -174,7 +174,9 @@ func (r *repository) GetByID(ctx context.Context, id int64) (loanorders.LoanOrde
|
||||
const nextUniqueIDSQL = `(SELECT LPAD((COALESCE(MAX(unique_id::bigint), 0) + 1)::text, 4, '0') FROM loan_orders)`
|
||||
|
||||
func (r *repository) Create(ctx context.Context, dto loanorders.CreateLoanOrderDTO) (loanorders.LoanOrderDTO, error) {
|
||||
args := createArgs(dto)
|
||||
// unique_id is supplied positionally via nextUniqueIDSQL below, so drop it
|
||||
// from the bound args to avoid double-supplying the first column.
|
||||
args := createArgs(dto)[1:]
|
||||
|
||||
placeholders := make([]string, len(args))
|
||||
for i := range args {
|
||||
|
||||
210
internal/admin/loanpaidletter/db/postgresql.go
Normal file
210
internal/admin/loanpaidletter/db/postgresql.go
Normal file
@@ -0,0 +1,210 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"online-back/internal/admin/loanpaidletter"
|
||||
"online-back/pkg/client/postgresql"
|
||||
"online-back/pkg/logging"
|
||||
|
||||
"github.com/jackc/pgx/v4"
|
||||
)
|
||||
|
||||
type repository struct {
|
||||
client postgresql.Client
|
||||
logger *logging.Logger
|
||||
}
|
||||
|
||||
func NewRepository(client postgresql.Client, logger *logging.Logger) loanpaidletter.Repository {
|
||||
return &repository{client: client, logger: logger}
|
||||
}
|
||||
|
||||
// letterWritableColumns lists every loan_paid_off_letters column except id, created_at
|
||||
// and updated_at, in the exact order CreateLoanPaidLetterDTO/UpdateLoanPaidLetterDTO fields are read.
|
||||
var letterWritableColumns = []string{
|
||||
"unique_id", "region", "branch_id", "user_id",
|
||||
"customer_name", "customer_surname", "customer_patronic_name", "born_at",
|
||||
"phone", "passport_serie", "passport_id",
|
||||
"status", "notes", "loan_contract_number", "loan_contract_date",
|
||||
"loan_amount", "loan_reason", "loan_file",
|
||||
}
|
||||
|
||||
var letterColumns = append(append([]string{"id"}, letterWritableColumns...), "created_at", "updated_at")
|
||||
|
||||
var letterColumnsSQL = strings.Join(letterColumns, ", ")
|
||||
|
||||
var letterWritableColumnsSQL = strings.Join(letterWritableColumns, ", ")
|
||||
|
||||
func createArgs(dto loanpaidletter.CreateLoanPaidLetterDTO) []interface{} {
|
||||
return []interface{}{
|
||||
dto.UniqueId, dto.Region, dto.BranchId, dto.UserId,
|
||||
dto.CustomerName, dto.CustomerSurname, dto.CustomerPatronicName, dto.BornAt,
|
||||
dto.Phone, dto.PassportSerie, dto.PassportId,
|
||||
dto.Status, dto.Notes, dto.LoanContractNumber, dto.LoanContractDate,
|
||||
dto.LoanAmount, dto.LoanReason, dto.LoanFile,
|
||||
}
|
||||
}
|
||||
|
||||
func updateArgs(dto loanpaidletter.UpdateLoanPaidLetterDTO) []interface{} {
|
||||
return []interface{}{
|
||||
dto.UniqueId, dto.Region, dto.BranchId, dto.UserId,
|
||||
dto.CustomerName, dto.CustomerSurname, dto.CustomerPatronicName, dto.BornAt,
|
||||
dto.Phone, dto.PassportSerie, dto.PassportId,
|
||||
dto.Status, dto.Notes, dto.LoanContractNumber, dto.LoanContractDate,
|
||||
dto.LoanAmount, dto.LoanReason, dto.LoanFile,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *repository) List(ctx context.Context, filter loanpaidletter.ListFilter) (loanpaidletter.ListLoanPaidLetterDTO, error) {
|
||||
whereClause, args := buildListQuery(filter)
|
||||
|
||||
var count int64
|
||||
countQuery := `SELECT COUNT(*) FROM loan_paid_off_letters` + whereClause
|
||||
if err := r.client.QueryRow(ctx, countQuery, args...).Scan(&count); err != nil {
|
||||
return loanpaidletter.ListLoanPaidLetterDTO{}, err
|
||||
}
|
||||
|
||||
offset := (filter.Page - 1) * filter.Limit
|
||||
limitPlaceholder := len(args) + 1
|
||||
offsetPlaceholder := len(args) + 2
|
||||
listQuery := fmt.Sprintf(
|
||||
`SELECT %s FROM loan_paid_off_letters%s ORDER BY id DESC LIMIT $%d OFFSET $%d`,
|
||||
letterColumnsSQL, whereClause, limitPlaceholder, offsetPlaceholder,
|
||||
)
|
||||
|
||||
rows, err := r.client.Query(ctx, listQuery, append(args, filter.Limit, offset)...)
|
||||
if err != nil {
|
||||
return loanpaidletter.ListLoanPaidLetterDTO{}, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var items []loanpaidletter.LoanPaidLetterDTO
|
||||
for rows.Next() {
|
||||
item, err := scanLoanPaidLetter(rows)
|
||||
if err != nil {
|
||||
return loanpaidletter.ListLoanPaidLetterDTO{}, err
|
||||
}
|
||||
items = append(items, item)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return loanpaidletter.ListLoanPaidLetterDTO{}, err
|
||||
}
|
||||
|
||||
return loanpaidletter.ListLoanPaidLetterDTO{Count: count, LoanPaidLetters: items}, nil
|
||||
}
|
||||
|
||||
func buildListQuery(filter loanpaidletter.ListFilter) (whereClause string, args []interface{}) {
|
||||
var conditions []string
|
||||
|
||||
if filter.PassportId != "" {
|
||||
args = append(args, likePattern(filter.PassportId))
|
||||
conditions = append(conditions, fmt.Sprintf("passport_id ILIKE $%d", len(args)))
|
||||
}
|
||||
|
||||
if filter.Status != nil {
|
||||
args = append(args, *filter.Status)
|
||||
conditions = append(conditions, fmt.Sprintf("status = $%d", len(args)))
|
||||
}
|
||||
|
||||
if filter.BranchId != nil {
|
||||
args = append(args, *filter.BranchId)
|
||||
conditions = append(conditions, fmt.Sprintf("branch_id = $%d", len(args)))
|
||||
}
|
||||
|
||||
if filter.Region != "" {
|
||||
args = append(args, filter.Region)
|
||||
conditions = append(conditions, fmt.Sprintf("region = $%d", len(args)))
|
||||
}
|
||||
|
||||
if len(conditions) == 0 {
|
||||
return "", args
|
||||
}
|
||||
|
||||
return " WHERE " + strings.Join(conditions, " AND "), args
|
||||
}
|
||||
|
||||
func likePattern(term string) string {
|
||||
term = strings.ReplaceAll(term, `\`, `\\`)
|
||||
term = strings.ReplaceAll(term, `%`, `\%`)
|
||||
term = strings.ReplaceAll(term, `_`, `\_`)
|
||||
return "%" + term + "%"
|
||||
}
|
||||
|
||||
func (r *repository) GetByID(ctx context.Context, id int64) (loanpaidletter.LoanPaidLetterDTO, error) {
|
||||
query := fmt.Sprintf(`SELECT %s FROM loan_paid_off_letters WHERE id = $1`, letterColumnsSQL)
|
||||
item, err := scanLoanPaidLetter(r.client.QueryRow(ctx, query, id))
|
||||
if err != nil {
|
||||
return loanpaidletter.LoanPaidLetterDTO{}, err
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
func (r *repository) Create(ctx context.Context, dto loanpaidletter.CreateLoanPaidLetterDTO) (loanpaidletter.LoanPaidLetterDTO, error) {
|
||||
args := createArgs(dto)
|
||||
|
||||
placeholders := make([]string, len(args))
|
||||
for i := range args {
|
||||
placeholders[i] = fmt.Sprintf("$%d", i+1)
|
||||
}
|
||||
|
||||
query := fmt.Sprintf(
|
||||
`INSERT INTO loan_paid_off_letters (%s) VALUES (%s) RETURNING %s`,
|
||||
letterWritableColumnsSQL, strings.Join(placeholders, ", "), letterColumnsSQL,
|
||||
)
|
||||
|
||||
return scanLoanPaidLetter(r.client.QueryRow(ctx, query, args...))
|
||||
}
|
||||
|
||||
func (r *repository) Update(ctx context.Context, id int64, dto loanpaidletter.UpdateLoanPaidLetterDTO) (loanpaidletter.LoanPaidLetterDTO, error) {
|
||||
args := updateArgs(dto)
|
||||
|
||||
assignments := make([]string, len(letterWritableColumns))
|
||||
for i, column := range letterWritableColumns {
|
||||
assignments[i] = fmt.Sprintf("%s = $%d", column, i+1)
|
||||
}
|
||||
args = append(args, id)
|
||||
|
||||
query := fmt.Sprintf(
|
||||
`UPDATE loan_paid_off_letters SET %s, updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') WHERE id = $%d RETURNING %s`,
|
||||
strings.Join(assignments, ", "), len(args), letterColumnsSQL,
|
||||
)
|
||||
|
||||
item, err := scanLoanPaidLetter(r.client.QueryRow(ctx, query, args...))
|
||||
if err != nil {
|
||||
return loanpaidletter.LoanPaidLetterDTO{}, err
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
func (r *repository) Delete(ctx context.Context, id int64) error {
|
||||
tag, err := r.client.Exec(ctx, `DELETE FROM loan_paid_off_letters WHERE id = $1`, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if tag.RowsAffected() == 0 {
|
||||
return pgx.ErrNoRows
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type scannable interface {
|
||||
Scan(dest ...interface{}) error
|
||||
}
|
||||
|
||||
func scanLoanPaidLetter(row scannable) (loanpaidletter.LoanPaidLetterDTO, error) {
|
||||
var item loanpaidletter.LoanPaidLetterDTO
|
||||
err := row.Scan(
|
||||
&item.Id, &item.UniqueId, &item.Region, &item.BranchId, &item.UserId,
|
||||
&item.CustomerName, &item.CustomerSurname, &item.CustomerPatronicName, &item.BornAt,
|
||||
&item.Phone, &item.PassportSerie, &item.PassportId,
|
||||
&item.Status, &item.Notes, &item.LoanContractNumber, &item.LoanContractDate,
|
||||
&item.LoanAmount, &item.LoanReason, &item.LoanFile,
|
||||
&item.CreatedAt, &item.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return loanpaidletter.LoanPaidLetterDTO{}, err
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
83
internal/admin/loanpaidletter/dto.go
Normal file
83
internal/admin/loanpaidletter/dto.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package loanpaidletter
|
||||
|
||||
import "time"
|
||||
|
||||
type LoanPaidLetterDTO struct {
|
||||
Id int64 `json:"id"`
|
||||
UniqueId *string `json:"uniqueId"`
|
||||
Region string `json:"region"`
|
||||
BranchId int64 `json:"branchId"`
|
||||
UserId *int64 `json:"userId"`
|
||||
CustomerName string `json:"customerName"`
|
||||
CustomerSurname string `json:"customerSurname"`
|
||||
CustomerPatronicName *string `json:"customerPatronicName"`
|
||||
BornAt *time.Time `json:"bornAt"`
|
||||
Phone string `json:"phone"`
|
||||
PassportSerie string `json:"passportSerie"`
|
||||
PassportId string `json:"passportId"`
|
||||
Status *string `json:"status"`
|
||||
Notes *string `json:"notes"`
|
||||
LoanContractNumber *string `json:"loanContractNumber"`
|
||||
LoanContractDate *time.Time `json:"loanContractDate"`
|
||||
LoanAmount *string `json:"loanAmount"`
|
||||
LoanReason *string `json:"loanReason"`
|
||||
LoanFile *string `json:"loanFile"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type CreateLoanPaidLetterDTO struct {
|
||||
UniqueId *string `json:"uniqueId"`
|
||||
Region string `json:"region" binding:"required"`
|
||||
BranchId int64 `json:"branchId" binding:"required"`
|
||||
UserId *int64 `json:"userId"`
|
||||
CustomerName string `json:"customerName" binding:"required"`
|
||||
CustomerSurname string `json:"customerSurname" binding:"required"`
|
||||
CustomerPatronicName *string `json:"customerPatronicName"`
|
||||
BornAt *time.Time `json:"bornAt"`
|
||||
Phone string `json:"phone" binding:"required"`
|
||||
PassportSerie string `json:"passportSerie" binding:"required"`
|
||||
PassportId string `json:"passportId" binding:"required"`
|
||||
Status *string `json:"status"`
|
||||
Notes *string `json:"notes"`
|
||||
LoanContractNumber *string `json:"loanContractNumber"`
|
||||
LoanContractDate *time.Time `json:"loanContractDate"`
|
||||
LoanAmount *string `json:"loanAmount"`
|
||||
LoanReason *string `json:"loanReason"`
|
||||
LoanFile *string `json:"loanFile"`
|
||||
}
|
||||
|
||||
type UpdateLoanPaidLetterDTO struct {
|
||||
UniqueId *string `json:"uniqueId"`
|
||||
Region string `json:"region" binding:"required"`
|
||||
BranchId int64 `json:"branchId" binding:"required"`
|
||||
UserId *int64 `json:"userId"`
|
||||
CustomerName string `json:"customerName" binding:"required"`
|
||||
CustomerSurname string `json:"customerSurname" binding:"required"`
|
||||
CustomerPatronicName *string `json:"customerPatronicName"`
|
||||
BornAt *time.Time `json:"bornAt"`
|
||||
Phone string `json:"phone" binding:"required"`
|
||||
PassportSerie string `json:"passportSerie" binding:"required"`
|
||||
PassportId string `json:"passportId" binding:"required"`
|
||||
Status *string `json:"status"`
|
||||
Notes *string `json:"notes"`
|
||||
LoanContractNumber *string `json:"loanContractNumber"`
|
||||
LoanContractDate *time.Time `json:"loanContractDate"`
|
||||
LoanAmount *string `json:"loanAmount"`
|
||||
LoanReason *string `json:"loanReason"`
|
||||
LoanFile *string `json:"loanFile"`
|
||||
}
|
||||
|
||||
type ListFilter struct {
|
||||
PassportId string
|
||||
Status *string
|
||||
BranchId *int64
|
||||
Region string
|
||||
Page int
|
||||
Limit int
|
||||
}
|
||||
|
||||
type ListLoanPaidLetterDTO struct {
|
||||
Count int64 `json:"count"`
|
||||
LoanPaidLetters []LoanPaidLetterDTO `json:"loanPaidLetters"`
|
||||
}
|
||||
261
internal/admin/loanpaidletter/handler.go
Normal file
261
internal/admin/loanpaidletter/handler.go
Normal file
@@ -0,0 +1,261 @@
|
||||
package loanpaidletter
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"online-back/internal/appresult"
|
||||
"online-back/internal/handlers"
|
||||
"online-back/pkg/logging"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jackc/pgx/v4"
|
||||
)
|
||||
|
||||
const baseURL = "/loan-paid-off-letters"
|
||||
|
||||
type handler struct {
|
||||
logger *logging.Logger
|
||||
repository Repository
|
||||
}
|
||||
|
||||
func NewHandler(logger *logging.Logger, repository Repository) handlers.Handler {
|
||||
return &handler{logger: logger, repository: repository}
|
||||
}
|
||||
|
||||
func (h *handler) Register(router *gin.RouterGroup) {
|
||||
group := router.Group(baseURL, appresult.JwtTokenCheck())
|
||||
group.GET("", h.list)
|
||||
group.GET("/:id", h.getByID)
|
||||
group.POST("", h.create)
|
||||
group.PUT("/:id", h.update)
|
||||
group.DELETE("/:id", h.delete)
|
||||
}
|
||||
|
||||
// list godoc
|
||||
// @Summary List loan paid off letters
|
||||
// @Description Returns paginated loan paid off letters with optional filters
|
||||
// @Tags loan-paid-off-letters
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param passport_id query string false "Filter by passport ID"
|
||||
// @Param status query string false "Filter by status"
|
||||
// @Param branch_id query int false "Filter by branch ID"
|
||||
// @Param region query string false "Filter by region"
|
||||
// @Param page query int false "Page number" default(1)
|
||||
// @Param limit query int false "Items per page" default(10)
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loan-paid-off-letters [get]
|
||||
func (h *handler) list(c *gin.Context) {
|
||||
filter, ok := parseListFilter(c)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.repository.List(c.Request.Context(), filter)
|
||||
if err != nil {
|
||||
h.logger.Errorf("list loan paid off letters failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||
}
|
||||
|
||||
// getByID godoc
|
||||
// @Summary Get loan paid off letter by ID
|
||||
// @Description Returns a single loan paid off letter
|
||||
// @Tags loan-paid-off-letters
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "Loan paid off letter ID"
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 404 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loan-paid-off-letters/{id} [get]
|
||||
func (h *handler) getByID(c *gin.Context) {
|
||||
id, ok := parseID(c.Param("id"))
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.repository.GetByID(c.Request.Context(), id)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
h.logger.Errorf("get loan paid off letter failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(item))
|
||||
}
|
||||
|
||||
// create godoc
|
||||
// @Summary Create loan paid off letter
|
||||
// @Description Creates a new loan paid off letter
|
||||
// @Tags loan-paid-off-letters
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param body body CreateLoanPaidLetterDTO true "Loan paid off letter payload"
|
||||
// @Success 201 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loan-paid-off-letters [post]
|
||||
func (h *handler) create(c *gin.Context) {
|
||||
var dto CreateLoanPaidLetterDTO
|
||||
if err := c.ShouldBindJSON(&dto); err != nil {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.repository.Create(c.Request.Context(), dto)
|
||||
if err != nil {
|
||||
h.logger.Errorf("create loan paid off letter failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, appresult.SuccessWithData(item))
|
||||
}
|
||||
|
||||
// update godoc
|
||||
// @Summary Update loan paid off letter
|
||||
// @Description Updates an existing loan paid off letter
|
||||
// @Tags loan-paid-off-letters
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "Loan paid off letter ID"
|
||||
// @Param body body UpdateLoanPaidLetterDTO true "Loan paid off letter payload"
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 404 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loan-paid-off-letters/{id} [put]
|
||||
func (h *handler) update(c *gin.Context) {
|
||||
id, ok := parseID(c.Param("id"))
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
var dto UpdateLoanPaidLetterDTO
|
||||
if err := c.ShouldBindJSON(&dto); err != nil {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.repository.Update(c.Request.Context(), id, dto)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
h.logger.Errorf("update loan paid off letter failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(item))
|
||||
}
|
||||
|
||||
// delete godoc
|
||||
// @Summary Delete loan paid off letter
|
||||
// @Description Deletes a loan paid off letter
|
||||
// @Tags loan-paid-off-letters
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "Loan paid off letter ID"
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 404 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loan-paid-off-letters/{id} [delete]
|
||||
func (h *handler) delete(c *gin.Context) {
|
||||
id, ok := parseID(c.Param("id"))
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.repository.Delete(c.Request.Context(), id); errors.Is(err, pgx.ErrNoRows) {
|
||||
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||
return
|
||||
} else if err != nil {
|
||||
h.logger.Errorf("delete loan paid off letter failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData("loan paid off letter removed"))
|
||||
}
|
||||
|
||||
func parseID(raw string) (int64, bool) {
|
||||
id, err := strconv.ParseInt(raw, 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
return 0, false
|
||||
}
|
||||
return id, true
|
||||
}
|
||||
|
||||
const (
|
||||
defaultPage = 1
|
||||
defaultLimit = 10
|
||||
maxLimit = 100
|
||||
)
|
||||
|
||||
func parseListFilter(c *gin.Context) (ListFilter, bool) {
|
||||
filter := ListFilter{
|
||||
Page: defaultPage,
|
||||
Limit: defaultLimit,
|
||||
}
|
||||
|
||||
if raw := c.Query("page"); raw != "" {
|
||||
page, err := strconv.Atoi(raw)
|
||||
if err != nil || page < 1 {
|
||||
return ListFilter{}, false
|
||||
}
|
||||
filter.Page = page
|
||||
}
|
||||
|
||||
if raw := c.Query("limit"); raw != "" {
|
||||
limit, err := strconv.Atoi(raw)
|
||||
if err != nil || limit < 1 || limit > maxLimit {
|
||||
return ListFilter{}, false
|
||||
}
|
||||
filter.Limit = limit
|
||||
}
|
||||
|
||||
if raw := strings.TrimSpace(c.Query("passport_id")); raw != "" {
|
||||
filter.PassportId = raw
|
||||
}
|
||||
|
||||
if raw := strings.TrimSpace(c.Query("status")); raw != "" {
|
||||
filter.Status = &raw
|
||||
}
|
||||
|
||||
if raw := strings.TrimSpace(c.Query("region")); raw != "" {
|
||||
filter.Region = raw
|
||||
}
|
||||
|
||||
if raw := c.Query("branch_id"); raw != "" {
|
||||
id, ok := parseID(raw)
|
||||
if !ok {
|
||||
return ListFilter{}, false
|
||||
}
|
||||
filter.BranchId = &id
|
||||
}
|
||||
|
||||
return filter, true
|
||||
}
|
||||
11
internal/admin/loanpaidletter/storage.go
Normal file
11
internal/admin/loanpaidletter/storage.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package loanpaidletter
|
||||
|
||||
import "context"
|
||||
|
||||
type Repository interface {
|
||||
List(ctx context.Context, filter ListFilter) (ListLoanPaidLetterDTO, error)
|
||||
GetByID(ctx context.Context, id int64) (LoanPaidLetterDTO, error)
|
||||
Create(ctx context.Context, dto CreateLoanPaidLetterDTO) (LoanPaidLetterDTO, error)
|
||||
Update(ctx context.Context, id int64, dto UpdateLoanPaidLetterDTO) (LoanPaidLetterDTO, error)
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
146
internal/admin/loansrepayment/db/postgresql.go
Normal file
146
internal/admin/loansrepayment/db/postgresql.go
Normal file
@@ -0,0 +1,146 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"online-back/internal/admin/loansrepayment"
|
||||
"online-back/pkg/client/postgresql"
|
||||
"online-back/pkg/logging"
|
||||
|
||||
"github.com/jackc/pgx/v4"
|
||||
)
|
||||
|
||||
type repository struct {
|
||||
client postgresql.Client
|
||||
logger *logging.Logger
|
||||
}
|
||||
|
||||
func NewRepository(client postgresql.Client, logger *logging.Logger) loansrepayment.Repository {
|
||||
return &repository{client: client, logger: logger}
|
||||
}
|
||||
|
||||
const loanColumns = `l.id, l.user_id, l.passport_serie, l.passport_id, l.account_number, l.created_at, l.updated_at`
|
||||
|
||||
const loanReturningColumns = `id, user_id, passport_serie, passport_id, account_number, created_at, updated_at`
|
||||
|
||||
func (r *repository) List(ctx context.Context, filter loansrepayment.ListFilter) (loansrepayment.ListLoanRepaymentDTO, error) {
|
||||
fromClause, whereClause, args := buildListQuery(filter)
|
||||
|
||||
var count int64
|
||||
if err := r.client.QueryRow(ctx, `SELECT COUNT(*) `+fromClause+whereClause, args...).Scan(&count); err != nil {
|
||||
return loansrepayment.ListLoanRepaymentDTO{}, err
|
||||
}
|
||||
|
||||
offset := (filter.Page - 1) * filter.Limit
|
||||
limitPlaceholder := len(args) + 1
|
||||
offsetPlaceholder := len(args) + 2
|
||||
listQuery := fmt.Sprintf(
|
||||
`SELECT %s%s%s ORDER BY l.id LIMIT $%d OFFSET $%d`,
|
||||
loanColumns, fromClause, whereClause, limitPlaceholder, offsetPlaceholder,
|
||||
)
|
||||
|
||||
rows, err := r.client.Query(ctx, listQuery, append(args, filter.Limit, offset)...)
|
||||
if err != nil {
|
||||
return loansrepayment.ListLoanRepaymentDTO{}, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var items []loansrepayment.LoanRepaymentDTO
|
||||
for rows.Next() {
|
||||
item, err := scanLoanRepayment(rows)
|
||||
if err != nil {
|
||||
return loansrepayment.ListLoanRepaymentDTO{}, err
|
||||
}
|
||||
items = append(items, item)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return loansrepayment.ListLoanRepaymentDTO{}, err
|
||||
}
|
||||
|
||||
return loansrepayment.ListLoanRepaymentDTO{Count: count, Loans: items}, nil
|
||||
}
|
||||
|
||||
func buildListQuery(filter loansrepayment.ListFilter) (fromClause, whereClause string, args []interface{}) {
|
||||
fromClause = ` FROM loans l`
|
||||
|
||||
var conditions []string
|
||||
if filter.PassportId != "" {
|
||||
args = append(args, likePattern(filter.PassportId))
|
||||
conditions = append(conditions, fmt.Sprintf("l.passport_id ILIKE $%d", len(args)))
|
||||
}
|
||||
|
||||
if len(conditions) == 0 {
|
||||
return fromClause, "", args
|
||||
}
|
||||
|
||||
return fromClause, " WHERE " + strings.Join(conditions, " AND "), args
|
||||
}
|
||||
|
||||
func likePattern(term string) string {
|
||||
term = strings.ReplaceAll(term, `\`, `\\`)
|
||||
term = strings.ReplaceAll(term, `%`, `\%`)
|
||||
term = strings.ReplaceAll(term, `_`, `\_`)
|
||||
return "%" + term + "%"
|
||||
}
|
||||
|
||||
func (r *repository) GetByID(ctx context.Context, id int64) (loansrepayment.LoanRepaymentDTO, error) {
|
||||
query := fmt.Sprintf(`SELECT %s FROM loans l WHERE l.id = $1`, loanColumns)
|
||||
item, err := scanLoanRepayment(r.client.QueryRow(ctx, query, id))
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return loansrepayment.LoanRepaymentDTO{}, err
|
||||
}
|
||||
return item, err
|
||||
}
|
||||
|
||||
func (r *repository) Create(ctx context.Context, dto loansrepayment.CreateLoanRepaymentDTO) (loansrepayment.LoanRepaymentDTO, error) {
|
||||
query := fmt.Sprintf(`
|
||||
INSERT INTO loans (user_id, passport_serie, passport_id, account_number)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING %s`, loanReturningColumns)
|
||||
|
||||
return scanLoanRepayment(r.client.QueryRow(ctx, query, dto.UserId, dto.PassportSerie, dto.PassportId, dto.AccountNumber))
|
||||
}
|
||||
|
||||
func (r *repository) Update(ctx context.Context, id int64, dto loansrepayment.UpdateLoanRepaymentDTO) (loansrepayment.LoanRepaymentDTO, error) {
|
||||
query := fmt.Sprintf(`
|
||||
UPDATE loans SET
|
||||
user_id = $1, passport_serie = $2, passport_id = $3, account_number = $4,
|
||||
updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
|
||||
WHERE id = $5
|
||||
RETURNING %s`, loanReturningColumns)
|
||||
|
||||
item, err := scanLoanRepayment(r.client.QueryRow(ctx, query, dto.UserId, dto.PassportSerie, dto.PassportId, dto.AccountNumber, id))
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return loansrepayment.LoanRepaymentDTO{}, err
|
||||
}
|
||||
return item, err
|
||||
}
|
||||
|
||||
func (r *repository) Delete(ctx context.Context, id int64) error {
|
||||
tag, err := r.client.Exec(ctx, `DELETE FROM loans WHERE id = $1`, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if tag.RowsAffected() == 0 {
|
||||
return pgx.ErrNoRows
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type scannable interface {
|
||||
Scan(dest ...interface{}) error
|
||||
}
|
||||
|
||||
func scanLoanRepayment(row scannable) (loansrepayment.LoanRepaymentDTO, error) {
|
||||
var item loansrepayment.LoanRepaymentDTO
|
||||
|
||||
if err := row.Scan(
|
||||
&item.Id, &item.UserId, &item.PassportSerie, &item.PassportId, &item.AccountNumber, &item.CreatedAt, &item.UpdatedAt,
|
||||
); err != nil {
|
||||
return loansrepayment.LoanRepaymentDTO{}, err
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
38
internal/admin/loansrepayment/dto.go
Normal file
38
internal/admin/loansrepayment/dto.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package loansrepayment
|
||||
|
||||
import "time"
|
||||
|
||||
type LoanRepaymentDTO struct {
|
||||
Id int64 `json:"id"`
|
||||
UserId int64 `json:"userId"`
|
||||
PassportSerie string `json:"passportSerie"`
|
||||
PassportId string `json:"passportId"`
|
||||
AccountNumber string `json:"accountNumber"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type CreateLoanRepaymentDTO struct {
|
||||
UserId int64 `json:"userId" binding:"required"`
|
||||
PassportSerie string `json:"passportSerie" binding:"required"`
|
||||
PassportId string `json:"passportId" binding:"required"`
|
||||
AccountNumber string `json:"accountNumber" binding:"required"`
|
||||
}
|
||||
|
||||
type UpdateLoanRepaymentDTO struct {
|
||||
UserId int64 `json:"userId" binding:"required"`
|
||||
PassportSerie string `json:"passportSerie" binding:"required"`
|
||||
PassportId string `json:"passportId" binding:"required"`
|
||||
AccountNumber string `json:"accountNumber" binding:"required"`
|
||||
}
|
||||
|
||||
type ListFilter struct {
|
||||
PassportId string
|
||||
Page int
|
||||
Limit int
|
||||
}
|
||||
|
||||
type ListLoanRepaymentDTO struct {
|
||||
Count int64 `json:"count"`
|
||||
Loans []LoanRepaymentDTO `json:"loans"`
|
||||
}
|
||||
242
internal/admin/loansrepayment/handler.go
Normal file
242
internal/admin/loansrepayment/handler.go
Normal file
@@ -0,0 +1,242 @@
|
||||
package loansrepayment
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"online-back/internal/appresult"
|
||||
"online-back/internal/handlers"
|
||||
"online-back/pkg/logging"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jackc/pgx/v4"
|
||||
)
|
||||
|
||||
const baseURL = "/loans-repayment"
|
||||
|
||||
type handler struct {
|
||||
logger *logging.Logger
|
||||
repository Repository
|
||||
}
|
||||
|
||||
func NewHandler(logger *logging.Logger, repository Repository) handlers.Handler {
|
||||
return &handler{logger: logger, repository: repository}
|
||||
}
|
||||
|
||||
func (h *handler) Register(router *gin.RouterGroup) {
|
||||
group := router.Group(baseURL, appresult.JwtTokenCheck())
|
||||
group.GET("", h.list)
|
||||
group.GET("/:id", h.getByID)
|
||||
group.POST("", h.create)
|
||||
group.PUT("/:id", h.update)
|
||||
group.DELETE("/:id", h.delete)
|
||||
}
|
||||
|
||||
// list godoc
|
||||
// @Summary List loan repayments
|
||||
// @Description Returns paginated loan repayments with optional filters
|
||||
// @Tags loans-repayment
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param passport_id query string false "Filter by passport ID"
|
||||
// @Param page query int false "Page number" default(1)
|
||||
// @Param limit query int false "Items per page" default(10)
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loans-repayment [get]
|
||||
func (h *handler) list(c *gin.Context) {
|
||||
filter, ok := parseListFilter(c)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.repository.List(c.Request.Context(), filter)
|
||||
if err != nil {
|
||||
h.logger.Errorf("list loan repayments failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||
}
|
||||
|
||||
// getByID godoc
|
||||
// @Summary Get loan repayment by ID
|
||||
// @Description Returns a single loan repayment
|
||||
// @Tags loans-repayment
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "Loan repayment ID"
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 404 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loans-repayment/{id} [get]
|
||||
func (h *handler) getByID(c *gin.Context) {
|
||||
id, ok := parseID(c.Param("id"))
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.repository.GetByID(c.Request.Context(), id)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
h.logger.Errorf("get loan repayment failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(item))
|
||||
}
|
||||
|
||||
// create godoc
|
||||
// @Summary Create loan repayment
|
||||
// @Description Creates a new loan repayment record
|
||||
// @Tags loans-repayment
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param body body CreateLoanRepaymentDTO true "Loan repayment payload"
|
||||
// @Success 201 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loans-repayment [post]
|
||||
func (h *handler) create(c *gin.Context) {
|
||||
var dto CreateLoanRepaymentDTO
|
||||
if err := c.ShouldBindJSON(&dto); err != nil {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.repository.Create(c.Request.Context(), dto)
|
||||
if err != nil {
|
||||
h.logger.Errorf("create loan repayment failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, appresult.SuccessWithData(item))
|
||||
}
|
||||
|
||||
// update godoc
|
||||
// @Summary Update loan repayment
|
||||
// @Description Updates an existing loan repayment record
|
||||
// @Tags loans-repayment
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "Loan repayment ID"
|
||||
// @Param body body UpdateLoanRepaymentDTO true "Loan repayment payload"
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 404 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loans-repayment/{id} [put]
|
||||
func (h *handler) update(c *gin.Context) {
|
||||
id, ok := parseID(c.Param("id"))
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
var dto UpdateLoanRepaymentDTO
|
||||
if err := c.ShouldBindJSON(&dto); err != nil {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.repository.Update(c.Request.Context(), id, dto)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
h.logger.Errorf("update loan repayment failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(item))
|
||||
}
|
||||
|
||||
// delete godoc
|
||||
// @Summary Delete loan repayment
|
||||
// @Description Deletes a loan repayment record
|
||||
// @Tags loans-repayment
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "Loan repayment ID"
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 404 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loans-repayment/{id} [delete]
|
||||
func (h *handler) delete(c *gin.Context) {
|
||||
id, ok := parseID(c.Param("id"))
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.repository.Delete(c.Request.Context(), id); errors.Is(err, pgx.ErrNoRows) {
|
||||
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||
return
|
||||
} else if err != nil {
|
||||
h.logger.Errorf("delete loan repayment failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData("loan repayment removed"))
|
||||
}
|
||||
|
||||
func parseID(raw string) (int64, bool) {
|
||||
id, err := strconv.ParseInt(raw, 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
return 0, false
|
||||
}
|
||||
return id, true
|
||||
}
|
||||
|
||||
const (
|
||||
defaultPage = 1
|
||||
defaultLimit = 10
|
||||
maxLimit = 100
|
||||
)
|
||||
|
||||
func parseListFilter(c *gin.Context) (ListFilter, bool) {
|
||||
filter := ListFilter{
|
||||
Page: defaultPage,
|
||||
Limit: defaultLimit,
|
||||
}
|
||||
|
||||
if raw := c.Query("page"); raw != "" {
|
||||
page, err := strconv.Atoi(raw)
|
||||
if err != nil || page < 1 {
|
||||
return ListFilter{}, false
|
||||
}
|
||||
filter.Page = page
|
||||
}
|
||||
|
||||
if raw := c.Query("limit"); raw != "" {
|
||||
limit, err := strconv.Atoi(raw)
|
||||
if err != nil || limit < 1 || limit > maxLimit {
|
||||
return ListFilter{}, false
|
||||
}
|
||||
filter.Limit = limit
|
||||
}
|
||||
|
||||
if raw := strings.TrimSpace(c.Query("passport_id")); raw != "" {
|
||||
filter.PassportId = raw
|
||||
}
|
||||
|
||||
return filter, true
|
||||
}
|
||||
11
internal/admin/loansrepayment/storage.go
Normal file
11
internal/admin/loansrepayment/storage.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package loansrepayment
|
||||
|
||||
import "context"
|
||||
|
||||
type Repository interface {
|
||||
List(ctx context.Context, filter ListFilter) (ListLoanRepaymentDTO, error)
|
||||
GetByID(ctx context.Context, id int64) (LoanRepaymentDTO, error)
|
||||
Create(ctx context.Context, dto CreateLoanRepaymentDTO) (LoanRepaymentDTO, error)
|
||||
Update(ctx context.Context, id int64, dto UpdateLoanRepaymentDTO) (LoanRepaymentDTO, error)
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
@@ -24,9 +24,9 @@ func NewRepository(client postgresql.Client, logger *logging.Logger) user.Reposi
|
||||
return &repository{client: client, logger: logger}
|
||||
}
|
||||
|
||||
const userColumns = `u.id, u.email, u.fullname, u.username, u.phone_number, u.avatar, u.social_media, u.light_mode, u.role, u.active, u.created_at, u.updated_at`
|
||||
const userColumns = `u.id, u.email, u.name, u.first_name, u.last_name, u.username, u.phone, u.avatar, u.social_media, u.light_mode, u.role, u.active, u.created_at, u.updated_at`
|
||||
|
||||
const userReturningColumns = `id, email, fullname, username, phone_number, avatar, social_media, light_mode, role, active, created_at, updated_at`
|
||||
const userReturningColumns = `id, email, name, first_name, last_name, username, phone, avatar, social_media, light_mode, role, active, created_at, updated_at`
|
||||
|
||||
func (r *repository) List(ctx context.Context, filter user.ListFilter) (user.ListUserDTO, error) {
|
||||
fromClause, whereClause, args := buildListQuery(filter)
|
||||
@@ -115,12 +115,12 @@ func (r *repository) Create(ctx context.Context, dto user.CreateUserDTO) (user.U
|
||||
}
|
||||
|
||||
query := fmt.Sprintf(`
|
||||
INSERT INTO users (email, password, fullname, username, phone_number, avatar, social_media, light_mode, role, active)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||
INSERT INTO users (email, password, name, first_name, last_name, username, phone, avatar, social_media, light_mode, role, active)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
|
||||
RETURNING %s`, userReturningColumns)
|
||||
|
||||
return scanUser(r.client.QueryRow(ctx, query,
|
||||
dto.Email, hashedPassword, dto.Fullname, dto.Username, dto.PhoneNumber, dto.Avatar, socialMedia, dto.LightMode, dto.Role, active,
|
||||
dto.Email, hashedPassword, dto.Name, dto.FirstName, dto.LastName, dto.Username, dto.Phone, dto.Avatar, socialMedia, dto.LightMode, dto.Role, active,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -132,14 +132,14 @@ func (r *repository) Update(ctx context.Context, id int64, dto user.UpdateUserDT
|
||||
|
||||
query := fmt.Sprintf(`
|
||||
UPDATE users SET
|
||||
email = $1, fullname = $2, username = $3, phone_number = $4, avatar = $5,
|
||||
social_media = $6, light_mode = $7, role = $8, active = $9,
|
||||
email = $1, name = $2, first_name = $3, last_name = $4, username = $5, phone = $6, avatar = $7,
|
||||
social_media = $8, light_mode = $9, role = $10, active = $11,
|
||||
updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
|
||||
WHERE id = $10
|
||||
WHERE id = $12
|
||||
RETURNING %s`, userReturningColumns)
|
||||
|
||||
item, err := scanUser(r.client.QueryRow(ctx, query,
|
||||
dto.Email, dto.Fullname, dto.Username, dto.PhoneNumber, dto.Avatar, socialMedia, dto.LightMode, dto.Role, dto.Active, id,
|
||||
dto.Email, dto.Name, dto.FirstName, dto.LastName, dto.Username, dto.Phone, dto.Avatar, socialMedia, dto.LightMode, dto.Role, dto.Active, id,
|
||||
))
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return user.UserDTO{}, err
|
||||
@@ -166,7 +166,7 @@ func scanUser(row scannable) (user.UserDTO, error) {
|
||||
var item user.UserDTO
|
||||
var socialMedia []byte
|
||||
if err := row.Scan(
|
||||
&item.Id, &item.Email, &item.Fullname, &item.Username, &item.PhoneNumber, &item.Avatar,
|
||||
&item.Id, &item.Email, &item.Name, &item.FirstName, &item.LastName, &item.Username, &item.Phone, &item.Avatar,
|
||||
&socialMedia, &item.LightMode, &item.Role, &item.Active, &item.CreatedAt, &item.UpdatedAt,
|
||||
); err != nil {
|
||||
return user.UserDTO{}, err
|
||||
|
||||
@@ -11,9 +11,11 @@ type SocialMedia struct {
|
||||
type UserDTO struct {
|
||||
Id int64 `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Fullname string `json:"fullname"`
|
||||
Name string `json:"name"`
|
||||
FirstName string `json:"firstName"`
|
||||
LastName string `json:"lastName"`
|
||||
Username string `json:"username"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Phone string `json:"phone"`
|
||||
Avatar string `json:"avatar"`
|
||||
SocialMedia SocialMedia `json:"socialMedia"`
|
||||
LightMode int `json:"lightMode"`
|
||||
@@ -26,9 +28,11 @@ type UserDTO struct {
|
||||
type CreateUserDTO struct {
|
||||
Email string `json:"email" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Fullname string `json:"fullname" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
FirstName string `json:"firstName"`
|
||||
LastName string `json:"lastName"`
|
||||
Username string `json:"username" binding:"required"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Phone string `json:"phone"`
|
||||
Avatar string `json:"avatar"`
|
||||
SocialMedia SocialMedia `json:"socialMedia"`
|
||||
LightMode int `json:"lightMode"`
|
||||
@@ -38,9 +42,11 @@ type CreateUserDTO struct {
|
||||
|
||||
type UpdateUserDTO struct {
|
||||
Email string `json:"email" binding:"required"`
|
||||
Fullname string `json:"fullname" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
FirstName string `json:"firstName"`
|
||||
LastName string `json:"lastName"`
|
||||
Username string `json:"username" binding:"required"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
Phone string `json:"phone"`
|
||||
Avatar string `json:"avatar"`
|
||||
SocialMedia SocialMedia `json:"socialMedia"`
|
||||
LightMode int `json:"lightMode"`
|
||||
|
||||
@@ -9,8 +9,12 @@ import (
|
||||
branchesdb "online-back/internal/admin/branches/db"
|
||||
"online-back/internal/admin/loanorders"
|
||||
loanordersdb "online-back/internal/admin/loanorders/db"
|
||||
"online-back/internal/admin/loanpaidletter"
|
||||
loanpaidletterdb "online-back/internal/admin/loanpaidletter/db"
|
||||
"online-back/internal/admin/loansdocument"
|
||||
loansdocumentdb "online-back/internal/admin/loansdocument/db"
|
||||
"online-back/internal/admin/loansrepayment"
|
||||
loansrepaymentdb "online-back/internal/admin/loansrepayment/db"
|
||||
"online-back/internal/admin/loantype"
|
||||
loantypedb "online-back/internal/admin/loantype/db"
|
||||
"online-back/internal/admin/paymentcard"
|
||||
@@ -78,7 +82,9 @@ func adminHandlers(client *pgxpool.Pool, logger *logging.Logger) []handlers.Hand
|
||||
reasonscard.NewHandler(logger, reasonscarddb.NewRepository(client, logger)),
|
||||
loantype.NewHandler(logger, loantypedb.NewRepository(client, logger)),
|
||||
loansdocument.NewHandler(logger, loansdocumentdb.NewRepository(client, logger)),
|
||||
loansrepayment.NewHandler(logger, loansrepaymentdb.NewRepository(client, logger)),
|
||||
loanorders.NewHandler(logger, loanordersdb.NewRepository(client, logger)),
|
||||
loanpaidletter.NewHandler(logger, loanpaidletterdb.NewRepository(client, logger)),
|
||||
role.NewHandler(logger, roledb.NewRepository(client, logger)),
|
||||
permission.NewHandler(logger, permissiondb.NewRepository(client, logger)),
|
||||
user.NewHandler(logger, userdb.NewRepository(client, logger)),
|
||||
|
||||
Reference in New Issue
Block a user