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

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

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

View File

@@ -2,7 +2,6 @@ package db
import (
"context"
"strconv"
"online-back/internal/admin/auth"
"online-back/pkg/client/postgresql"
@@ -22,32 +21,27 @@ func NewRepository(client postgresql.Client, logger *logging.Logger) auth.Reposi
}
const (
loginQuery = `SELECT id, password FROM admin WHERE login = $1`
adminQuery = `SELECT id, password FROM admin WHERE id = $1`
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
FROM admin WHERE id = $1`
FROM users WHERE id = $1`
)
func (r *repository) Login(ctx context.Context, dto auth.LoginDTO) (auth.ResLoginDTO, error) {
var result auth.ResLoginDTO
err := r.client.QueryRow(ctx, loginQuery, dto.Login).Scan(&result.Id, &result.Password)
func (r *repository) Login(ctx context.Context, dto auth.LoginDTO) (auth.UserCredentials, error) {
var result auth.UserCredentials
err := r.client.QueryRow(ctx, loginQuery, dto.Email).Scan(&result.Id, &result.Password)
return result, err
}
func (r *repository) CheckAdmin(ctx context.Context, id int) (auth.ResLoginDTO, error) {
var result auth.ResLoginDTO
err := r.client.QueryRow(ctx, adminQuery, id).Scan(&result.Id, &result.Password)
func (r *repository) GetUserByID(ctx context.Context, id int) (auth.UserCredentials, error) {
var result auth.UserCredentials
err := r.client.QueryRow(ctx, userByIDQuery, id).Scan(&result.Id, &result.Password)
return result, err
}
func (r *repository) GetProfile(ctx context.Context, id string) (auth.ResUserDTO, error) {
var profile auth.ResUserDTO
adminID, err := strconv.Atoi(id)
if err != nil {
return profile, err
}
err = r.client.QueryRow(ctx, profileQuery, adminID).Scan(
func (r *repository) GetProfile(ctx context.Context, id int) (auth.UserProfileDTO, error) {
var profile auth.UserProfileDTO
err := r.client.QueryRow(ctx, profileQuery, id).Scan(
&profile.Id,
&profile.FullName,
&profile.PhoneNumber,