added method for update fields rule
This commit is contained in:
parent
ea584c78dc
commit
5d4453a673
@ -1652,4 +1652,8 @@ UPDATE YclientsFields SET Deleted = true WHERE ID = ANY($1::bigint[]);
|
||||
|
||||
-- name: AddYclientsAccountField :exec
|
||||
INSERT INTO YclientsFields (YclientsID, SalonID, FieldType, Code, Title, ShowInUI, UserCanEdit)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7);
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7);
|
||||
|
||||
-- name: UpdateYclientsFieldRules :exec
|
||||
UPDATE YclientsRules SET FieldsRule = $1
|
||||
WHERE SalonID = $2 AND QuizID = $3 AND Deleted = false;
|
||||
|
||||
@ -6512,6 +6512,22 @@ func (q *Queries) UpdateYclientsAccountUser(ctx context.Context, arg UpdateYclie
|
||||
return err
|
||||
}
|
||||
|
||||
const updateYclientsFieldRules = `-- name: UpdateYclientsFieldRules :exec
|
||||
UPDATE YclientsRules SET FieldsRule = $1
|
||||
WHERE SalonID = $2 AND QuizID = $3 AND Deleted = false
|
||||
`
|
||||
|
||||
type UpdateYclientsFieldRulesParams struct {
|
||||
Fieldsrule json.RawMessage `db:"fieldsrule" json:"fieldsrule"`
|
||||
Salonid int32 `db:"salonid" json:"salonid"`
|
||||
Quizid int32 `db:"quizid" json:"quizid"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateYclientsFieldRules(ctx context.Context, arg UpdateYclientsFieldRulesParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateYclientsFieldRules, arg.Fieldsrule, arg.Salonid, arg.Quizid)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateYclientsTokensAccessToken = `-- name: UpdateYclientsTokensAccessToken :one
|
||||
update YclientsTokens set AccessToken = $1, Active = true where AccountID = $2 and SalonID = $3 and Expiration = false RETURNING accountid, salonid, accesstoken, active, expiration, createdat
|
||||
`
|
||||
|
||||
@ -683,6 +683,24 @@ func (r *YclientsRepository) ChangeQuizSettings(ctx context.Context, rule model.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *YclientsRepository) UpdateFieldRules(ctx context.Context, fieldRules model.YclientsFieldRule, salonID int32, quizID int32) error {
|
||||
jsonFieldsRule, err := json.Marshal(fieldRules)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = r.queries.UpdateYclientsFieldRules(ctx, sqlcgen.UpdateYclientsFieldRulesParams{
|
||||
Fieldsrule: jsonFieldsRule,
|
||||
Salonid: salonID,
|
||||
Quizid: quizID,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// fields
|
||||
func (r *YclientsRepository) GetFieldsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListYclientsFieldsResp, error) {
|
||||
rows, err := r.queries.GetYclientsFieldsWithPagination(ctx, sqlcgen.GetYclientsFieldsWithPaginationParams{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user