Put the user's role and branch on GET /profile, upsert role_user and branch_user on POST, and drop their list endpoints.

Also accept flexible card-order form values, move mock seed under db/mock, and regenerate Swagger.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
guwandykandCursor committed 2026-08-22 17:56:07 +05:00
1 parent 7225dc0399
commit 8795ae2195
47 files changed
+1308 -1785

No files matched your search

+25 -10
View File
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strings"
"time"
"online-back/internal/cards/cardorder"
"online-back/pkg/client/postgresql"
@@ -25,8 +26,6 @@ func NewRepository(client postgresql.Client, logger *logging.Logger) cardorder.R
}
}
// cardOrderWritableColumns lists every card_orders column except id, created_at and
// updated_at, in the exact order CreateCardOrderDTO/UpdateCardOrderDTO fields are read.
var cardOrderWritableColumns = []string{
"unique_id", "card_state_id", "card_type_id", "region", "branch_id",
"customer_name", "customer_surname", "customer_patronic_name", "born_at", "old_surname", "citizenship",
@@ -58,24 +57,40 @@ func resolvePaid(paid *bool) bool {
func createArgs(dto cardorder.CreateCardOrderDTO) []interface{} {
return []interface{}{
dto.UniqueId, dto.CardStateId, dto.CardTypeId, dto.Region, dto.BranchId,
dto.CustomerName, dto.CustomerSurname, dto.CustomerPatronicName, dto.BornAt, dto.OldSurname, dto.Citizenship,
dto.PassportSerie, dto.PassportId, dto.PassportGivenAt, dto.PassportGivenBy, dto.BornPlace,
dto.UniqueId, dto.CardStateId.Int64(), dto.CardTypeId.Int64(), dto.Region, dto.BranchId.Int64(),
dto.CustomerName, dto.CustomerSurname, dto.CustomerPatronicName, optionalTime(dto.BornAt), dto.OldSurname, dto.Citizenship,
dto.PassportSerie, dto.PassportId, dto.PassportGivenAt.Time(), dto.PassportGivenBy, dto.BornPlace,
dto.JobLocation, dto.PassportAddress, dto.RealAddress, dto.Phone, dto.PhoneAdditional,
resolveStatus(dto.Status), dto.PassportOne, dto.PassportTwo, dto.PassportThree, dto.PassportFour, dto.Notes, dto.UserId, resolvePaid(dto.Paid),
resolveStatus(dto.Status), dto.PassportOne, dto.PassportTwo, dto.PassportThree, dto.PassportFour, dto.Notes, optionalInt64(dto.UserId), resolvePaid(dto.Paid),
}
}
func updateArgs(dto cardorder.UpdateCardOrderDTO) []interface{} {
return []interface{}{
dto.UniqueId, dto.CardStateId, dto.CardTypeId, dto.Region, dto.BranchId,
dto.CustomerName, dto.CustomerSurname, dto.CustomerPatronicName, dto.BornAt, dto.OldSurname, dto.Citizenship,
dto.PassportSerie, dto.PassportId, dto.PassportGivenAt, dto.PassportGivenBy, dto.BornPlace,
dto.UniqueId, dto.CardStateId.Int64(), dto.CardTypeId.Int64(), dto.Region, dto.BranchId.Int64(),
dto.CustomerName, dto.CustomerSurname, dto.CustomerPatronicName, optionalTime(dto.BornAt), dto.OldSurname, dto.Citizenship,
dto.PassportSerie, dto.PassportId, dto.PassportGivenAt.Time(), dto.PassportGivenBy, dto.BornPlace,
dto.JobLocation, dto.PassportAddress, dto.RealAddress, dto.Phone, dto.PhoneAdditional,
resolveStatus(dto.Status), dto.PassportOne, dto.PassportTwo, dto.PassportThree, dto.PassportFour, dto.Notes, dto.UserId, dto.Paid,
resolveStatus(dto.Status), dto.PassportOne, dto.PassportTwo, dto.PassportThree, dto.PassportFour, dto.Notes, optionalInt64(dto.UserId), dto.Paid,
}
}
func optionalTime(t *cardorder.FlexibleTime) *time.Time {
if t == nil || t.IsZero() {
return nil
}
tt := t.Time()
return &tt
}
func optionalInt64(n *cardorder.FlexibleInt64) *int64 {
if n == nil {
return nil
}
v := n.Int64()
return &v
}
func (r *repository) List(ctx context.Context, filter cardorder.ListFilter) (cardorder.ListCardOrderDTO, error) {
whereClause, args := buildListQuery(filter)