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

@@ -188,46 +188,6 @@ func likePattern(term string) string {
return "%" + term + "%"
}
func (r *repository) ListBranchesByProvince(ctx context.Context, provinceID int64, activeOnly bool) (visamaster.ListBranchesByProvinceDTO, error) {
args := []interface{}{provinceID}
where := ` WHERE province_id = $1`
if activeOnly {
where += ` AND active = true`
}
query := `
SELECT id, COALESCE(unique_code, ''), name, region, province_id, active
FROM branches` + where + `
ORDER BY name->>'tm', name->>'en', id`
rows, err := r.client.Query(ctx, query, args...)
if err != nil {
return visamaster.ListBranchesByProvinceDTO{}, err
}
defer rows.Close()
branches := make([]visamaster.BranchByProvinceDTO, 0)
for rows.Next() {
var item visamaster.BranchByProvinceDTO
var nameJSON []byte
if err := rows.Scan(&item.Id, &item.UniqueCode, &nameJSON, &item.Region, &item.ProvinceId, &item.Active); err != nil {
return visamaster.ListBranchesByProvinceDTO{}, err
}
if err := json.Unmarshal(nameJSON, &item.Name); err != nil {
return visamaster.ListBranchesByProvinceDTO{}, err
}
branches = append(branches, item)
}
if err := rows.Err(); err != nil {
return visamaster.ListBranchesByProvinceDTO{}, err
}
return visamaster.ListBranchesByProvinceDTO{
Count: int64(len(branches)),
Branches: branches,
}, nil
}
func (r *repository) GetByID(ctx context.Context, id int64) (visamaster.VisaMasterPaymentOrderDTO, error) {
query := `SELECT ` + orderSelectColumns + orderFromClause + ` WHERE o.id = $1`
return scanOrder(r.client.QueryRow(ctx, query, id))