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:
@@ -63,7 +63,7 @@ func (r *repository) List(ctx context.Context, filter loansdocument.ListFilter)
|
||||
}
|
||||
|
||||
func buildListQuery(filter loansdocument.ListFilter) (fromClause, whereClause string, args []interface{}) {
|
||||
fromClause = ` FROM loans_documents d`
|
||||
fromClause = ` FROM loan_required_documents d`
|
||||
|
||||
var conditions []string
|
||||
|
||||
@@ -95,7 +95,7 @@ func likePattern(term string) string {
|
||||
}
|
||||
|
||||
func (r *repository) GetByID(ctx context.Context, id int64) (loansdocument.LoanDocumentDTO, error) {
|
||||
query := fmt.Sprintf(`SELECT %s FROM loans_documents d WHERE d.id = $1`, documentColumns)
|
||||
query := fmt.Sprintf(`SELECT %s FROM loan_required_documents d WHERE d.id = $1`, documentColumns)
|
||||
item, err := scanLoanDocument(r.client.QueryRow(ctx, query, id))
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return loansdocument.LoanDocumentDTO{}, err
|
||||
@@ -115,7 +115,7 @@ func (r *repository) Create(ctx context.Context, dto loansdocument.CreateLoanDoc
|
||||
}
|
||||
|
||||
query := fmt.Sprintf(`
|
||||
INSERT INTO loans_documents (title, content_en, content_ru, content_tm, status)
|
||||
INSERT INTO loan_required_documents (title, content_en, content_ru, content_tm, status)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
RETURNING %s`, documentColumns)
|
||||
|
||||
@@ -129,7 +129,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto loansdocument.Upd
|
||||
}
|
||||
|
||||
query := fmt.Sprintf(`
|
||||
UPDATE loans_documents SET
|
||||
UPDATE loan_required_documents SET
|
||||
title = $1, content_en = $2, content_ru = $3, content_tm = $4, status = $5,
|
||||
updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
|
||||
WHERE id = $6
|
||||
@@ -144,7 +144,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto loansdocument.Upd
|
||||
|
||||
func (r *repository) UpdateStatus(ctx context.Context, id int64, status bool) (loansdocument.LoanDocumentDTO, error) {
|
||||
query := fmt.Sprintf(`
|
||||
UPDATE loans_documents SET
|
||||
UPDATE loan_required_documents SET
|
||||
status = $1,
|
||||
updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
|
||||
WHERE id = $2
|
||||
@@ -158,7 +158,7 @@ func (r *repository) UpdateStatus(ctx context.Context, id int64, status bool) (l
|
||||
}
|
||||
|
||||
func (r *repository) Delete(ctx context.Context, id int64) error {
|
||||
tag, err := r.client.Exec(ctx, `DELETE FROM loans_documents WHERE id = $1`, id)
|
||||
tag, err := r.client.Exec(ctx, `DELETE FROM loan_required_documents WHERE id = $1`, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
||||
group.GET("/:id", h.getByID)
|
||||
group.POST("", h.create)
|
||||
group.PUT("/:id", h.update)
|
||||
group.PATCH("/:id/status", h.updateStatus)
|
||||
group.PUT("/:id/status", h.updateStatus)
|
||||
group.DELETE("/:id", h.delete)
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ func (h *handler) update(c *gin.Context) {
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 404 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loans-documents/{id}/status [patch]
|
||||
// @Router /loans-documents/{id}/status [put]
|
||||
func (h *handler) updateStatus(c *gin.Context) {
|
||||
id, ok := parseID(c.Param("id"))
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user