Fix mini-slider admin CRUD JSON encoding and drop seed data from the migration.

Encode title as JSON text so create/list work with pgx, and keep the table migration permission-free so rows are added from admin.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 19:04:48 +05:00
parent 82b1e903f6
commit 262292651a
7 changed files with 74 additions and 73 deletions

View File

@@ -162,11 +162,13 @@ func (r repository) GetMiniSliders(ctx context.Context, lang string) (users.Data
lang = users.NormalizeLang(lang)
q := ` SELECT
id, title, img
id,
COALESCE(NULLIF(title->>$1, ''), NULLIF(title->>'tm', ''), ''),
img
FROM mini_slider
ORDER BY created_at ASC;`
rows, err := r.client.Query(ctx, q)
rows, err := r.client.Query(ctx, q, lang)
if err != nil {
r.logger.Error("get mini sliders :::", err)
return dt, err
@@ -176,13 +178,11 @@ func (r repository) GetMiniSliders(ctx context.Context, lang string) (users.Data
ss := []users.MiniSliderDTO{}
for rows.Next() {
var s users.MiniSliderDTO
var title users.Language
errS := rows.Scan(&s.Id, &title, &s.Image)
errS := rows.Scan(&s.Id, &s.Title, &s.Image)
if errS != nil {
r.logger.Error("errS :::", errS)
continue
}
s.Title = title.Pick(lang)
ss = append(ss, s)
}
dt.MiniSliders = ss