Align schema, API routes, and auth with updated admin domain model.
Rename users table fields and loan documents table, expand branch billing credentials, switch to /api/admin prefix, refactor auth endpoints, replace PATCH with PUT for status updates, remove file upload APIs, and regenerate Swagger with ordered tags. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -25,8 +25,9 @@ func NewRepository(client postgresql.Client, logger *logging.Logger) branches.Re
|
||||
}
|
||||
|
||||
const branchColumns = `b.id, b.title, b.province_id, b.location_id, b.unikal_nomer, b.address,
|
||||
b.billing_login, b.billing_password, b.billing_username_sber, b.billing_password_sber,
|
||||
b.billing_username_visa, b.billing_password_visa`
|
||||
b.billing_username, b.billing_password, b.billing_username_sber, b.billing_password_sber,
|
||||
b.billing_username_visa, b.billing_password_visa,
|
||||
b.billing_username_swift, b.billing_password_swift`
|
||||
|
||||
func (r *repository) List(ctx context.Context, filter branches.ListFilter) (branches.ListBranchDTO, error) {
|
||||
fromClause, whereClause, args := buildListQuery(filter)
|
||||
@@ -71,7 +72,7 @@ func buildListQuery(filter branches.ListFilter) (fromClause, whereClause string,
|
||||
fromClause = ` FROM branches b`
|
||||
|
||||
if filter.ProvinceName != "" {
|
||||
fromClause += ` JOIN province p ON p.id = b.province_id`
|
||||
fromClause += ` JOIN provinces p ON p.id = b.province_id`
|
||||
}
|
||||
|
||||
var conditions []string
|
||||
@@ -145,15 +146,17 @@ func (r *repository) Create(ctx context.Context, dto branches.CreateBranchDTO) (
|
||||
query := fmt.Sprintf(`
|
||||
INSERT INTO branches (
|
||||
title, province_id, location_id, unikal_nomer, address,
|
||||
billing_login, billing_password, billing_username_sber, billing_password_sber,
|
||||
billing_username_visa, billing_password_visa
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)
|
||||
billing_username, billing_password, billing_username_sber, billing_password_sber,
|
||||
billing_username_visa, billing_password_visa,
|
||||
billing_username_swift, billing_password_swift
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13)
|
||||
RETURNING %s`, branchColumns)
|
||||
|
||||
row := r.client.QueryRow(ctx, query,
|
||||
title, dto.ProvinceId, dto.LocationId, dto.UnikalNomer, address,
|
||||
dto.BillingLogin, dto.BillingPassword, dto.BillingUsernameSber, dto.BillingPasswordSber,
|
||||
dto.BillingUsername, dto.BillingPassword, dto.BillingUsernameSber, dto.BillingPasswordSber,
|
||||
dto.BillingUsernameVisa, dto.BillingPasswordVisa,
|
||||
dto.BillingUsernameSwift, dto.BillingPasswordSwift,
|
||||
)
|
||||
item, err := scanBranch(row)
|
||||
if isUniqueViolation(err) {
|
||||
@@ -175,15 +178,17 @@ func (r *repository) Update(ctx context.Context, id int64, dto branches.UpdateBr
|
||||
query := fmt.Sprintf(`
|
||||
UPDATE branches SET
|
||||
title = $1, province_id = $2, location_id = $3, unikal_nomer = $4, address = $5,
|
||||
billing_login = $6, billing_password = $7, billing_username_sber = $8,
|
||||
billing_password_sber = $9, billing_username_visa = $10, billing_password_visa = $11
|
||||
WHERE id = $12
|
||||
billing_username = $6, billing_password = $7, billing_username_sber = $8,
|
||||
billing_password_sber = $9, billing_username_visa = $10, billing_password_visa = $11,
|
||||
billing_username_swift = $12, billing_password_swift = $13
|
||||
WHERE id = $14
|
||||
RETURNING %s`, branchColumns)
|
||||
|
||||
row := r.client.QueryRow(ctx, query,
|
||||
title, dto.ProvinceId, dto.LocationId, dto.UnikalNomer, address,
|
||||
dto.BillingLogin, dto.BillingPassword, dto.BillingUsernameSber, dto.BillingPasswordSber,
|
||||
dto.BillingUsernameVisa, dto.BillingPasswordVisa, id,
|
||||
dto.BillingUsername, dto.BillingPassword, dto.BillingUsernameSber, dto.BillingPasswordSber,
|
||||
dto.BillingUsernameVisa, dto.BillingPasswordVisa,
|
||||
dto.BillingUsernameSwift, dto.BillingPasswordSwift, id,
|
||||
)
|
||||
item, err := scanBranch(row)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
@@ -244,8 +249,9 @@ func scanBranch(row scannable) (branches.BranchDTO, error) {
|
||||
|
||||
err := row.Scan(
|
||||
&item.Id, &titleJSON, &item.ProvinceId, &item.LocationId, &item.UnikalNomer, &addressJSON,
|
||||
&item.BillingLogin, &item.BillingPassword, &item.BillingUsernameSber, &item.BillingPasswordSber,
|
||||
&item.BillingUsername, &item.BillingPassword, &item.BillingUsernameSber, &item.BillingPasswordSber,
|
||||
&item.BillingUsernameVisa, &item.BillingPasswordVisa,
|
||||
&item.BillingUsernameSwift, &item.BillingPasswordSwift,
|
||||
)
|
||||
if err != nil {
|
||||
return branches.BranchDTO{}, err
|
||||
|
||||
@@ -13,12 +13,14 @@ type BranchDTO struct {
|
||||
LocationId int64 `json:"locationId"`
|
||||
UnikalNomer string `json:"unikalNomer"`
|
||||
Address LocalizedText `json:"address"`
|
||||
BillingLogin string `json:"billingLogin"`
|
||||
BillingUsername string `json:"billingUsername"`
|
||||
BillingPassword string `json:"billingPassword"`
|
||||
BillingUsernameSber string `json:"billingUsernameSber"`
|
||||
BillingPasswordSber string `json:"billingPasswordSber"`
|
||||
BillingUsernameVisa string `json:"billingUsernameVisa"`
|
||||
BillingPasswordVisa string `json:"billingPasswordVisa"`
|
||||
BillingUsernameVisa string `json:"billingUsernameVisa"`
|
||||
BillingPasswordVisa string `json:"billingPasswordVisa"`
|
||||
BillingUsernameSwift string `json:"billingUsernameSwift"`
|
||||
BillingPasswordSwift string `json:"billingPasswordSwift"`
|
||||
}
|
||||
|
||||
type CreateBranchDTO struct {
|
||||
@@ -27,12 +29,14 @@ type CreateBranchDTO struct {
|
||||
LocationId int64 `json:"locationId" binding:"required"`
|
||||
UnikalNomer string `json:"unikalNomer" binding:"required"`
|
||||
Address LocalizedText `json:"address" binding:"required"`
|
||||
BillingLogin string `json:"billingLogin"`
|
||||
BillingUsername string `json:"billingUsername"`
|
||||
BillingPassword string `json:"billingPassword"`
|
||||
BillingUsernameSber string `json:"billingUsernameSber"`
|
||||
BillingPasswordSber string `json:"billingPasswordSber"`
|
||||
BillingUsernameVisa string `json:"billingUsernameVisa"`
|
||||
BillingPasswordVisa string `json:"billingPasswordVisa"`
|
||||
BillingUsernameVisa string `json:"billingUsernameVisa"`
|
||||
BillingPasswordVisa string `json:"billingPasswordVisa"`
|
||||
BillingUsernameSwift string `json:"billingUsernameSwift"`
|
||||
BillingPasswordSwift string `json:"billingPasswordSwift"`
|
||||
}
|
||||
|
||||
type UpdateBranchDTO struct {
|
||||
@@ -41,12 +45,14 @@ type UpdateBranchDTO struct {
|
||||
LocationId int64 `json:"locationId" binding:"required"`
|
||||
UnikalNomer string `json:"unikalNomer" binding:"required"`
|
||||
Address LocalizedText `json:"address" binding:"required"`
|
||||
BillingLogin string `json:"billingLogin"`
|
||||
BillingUsername string `json:"billingUsername"`
|
||||
BillingPassword string `json:"billingPassword"`
|
||||
BillingUsernameSber string `json:"billingUsernameSber"`
|
||||
BillingPasswordSber string `json:"billingPasswordSber"`
|
||||
BillingUsernameVisa string `json:"billingUsernameVisa"`
|
||||
BillingPasswordVisa string `json:"billingPasswordVisa"`
|
||||
BillingUsernameVisa string `json:"billingUsernameVisa"`
|
||||
BillingPasswordVisa string `json:"billingPasswordVisa"`
|
||||
BillingUsernameSwift string `json:"billingUsernameSwift"`
|
||||
BillingPasswordSwift string `json:"billingPasswordSwift"`
|
||||
}
|
||||
|
||||
type ListFilter struct {
|
||||
|
||||
Reference in New Issue
Block a user