added method GetTimeslotsByIDYclients
This commit is contained in:
parent
24fe283ed2
commit
19196aa451
@ -1585,3 +1585,6 @@ VALUES ($1, $2, $3, $4, $5, $6,$7,$8,$9,$10,$11,$12);
|
||||
|
||||
-- name: DeleteYclientsServices :exec
|
||||
UPDATE YclientsServices SET Deleted = true WHERE ID = ANY($1::bigint[]);
|
||||
|
||||
-- name: GetTimeslotsByIDYclients :many
|
||||
SELECT * FROM YclientsTimeSlots WHERE SalonID = $1 AND Deleted = false;
|
||||
@ -4010,6 +4010,41 @@ func (q *Queries) GetTagsWithPagination(ctx context.Context, arg GetTagsWithPagi
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getTimeslotsByIDYclients = `-- name: GetTimeslotsByIDYclients :many
|
||||
SELECT id, salonid, isenabled, weekdayssettings, datessettings, deleted, createdat FROM YclientsTimeSlots WHERE SalonID = $1 AND Deleted = false
|
||||
`
|
||||
|
||||
func (q *Queries) GetTimeslotsByIDYclients(ctx context.Context, salonid int32) ([]Yclientstimeslot, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTimeslotsByIDYclients, salonid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Yclientstimeslot
|
||||
for rows.Next() {
|
||||
var i Yclientstimeslot
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Salonid,
|
||||
&i.Isenabled,
|
||||
&i.Weekdayssettings,
|
||||
&i.Datessettings,
|
||||
&i.Deleted,
|
||||
&i.Createdat,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getTimeslotsYclientsWithPagination = `-- name: GetTimeslotsYclientsWithPagination :many
|
||||
WITH user_data AS (
|
||||
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||
|
||||
@ -511,6 +511,39 @@ func (r *YclientsRepository) GettingTimeslotsWithPagination(ctx context.Context,
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (r *YclientsRepository) GetAccountTimeslotsByID(ctx context.Context, salonID int32) ([]model.Timeslots, error) {
|
||||
rows, err := r.queries.GetTimeslotsByIDYclients(ctx, salonID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var timeslots []model.Timeslots
|
||||
for _, row := range rows {
|
||||
var weekdaysSettings []model.WeekdaySetting
|
||||
err = json.Unmarshal(row.Weekdayssettings, &weekdaysSettings)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
}
|
||||
|
||||
var datesSettings model.DateSetting
|
||||
err = json.Unmarshal(row.Datessettings, &datesSettings)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
timeslots = append(timeslots, model.Timeslots{
|
||||
ID: row.ID,
|
||||
SalonID: row.Salonid,
|
||||
IsEnabled: row.Isenabled,
|
||||
WeekdaysSettings: weekdaysSettings,
|
||||
DatesSettings: datesSettings,
|
||||
Deleted: row.Deleted,
|
||||
CreatedAt: row.Createdat,
|
||||
})
|
||||
}
|
||||
return timeslots, nil
|
||||
}
|
||||
|
||||
// todo
|
||||
func (r *YclientsRepository) UpdateTimeslots() {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user