feat: custom stickers apis
This commit is contained in:
@@ -187,6 +187,25 @@ func (r *RewardRepo) CreateGrant(ctx context.Context, userID, rewardID string, m
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateCustom adds a reward to the catalog from the admin panel.
|
||||
//
|
||||
// Custom entries survive re-seeding: Seed upserts only the keys in its
|
||||
// embedded JSON, and these keys are namespaced away from those.
|
||||
func (r *RewardRepo) CreateCustom(ctx context.Context, key, name, meaning, imageURL string) (*model.SadhnaReward, error) {
|
||||
var w model.SadhnaReward
|
||||
err := r.pg.Pool.QueryRow(ctx, `
|
||||
INSERT INTO sadhna_rewards (key, name, meaning, image_url, active, sort)
|
||||
-- Sorted after the seeded catalog so custom gifts don't reshuffle it.
|
||||
VALUES ($1, $2, $3, $4, true, 1000)
|
||||
RETURNING id, key, name, meaning, image_url, active, sort`,
|
||||
key, name, meaning, imageURL,
|
||||
).Scan(&w.ID, &w.Key, &w.Name, &w.Meaning, &w.ImageURL, &w.Active, &w.Sort)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("create custom reward: %w", err)
|
||||
}
|
||||
return &w, nil
|
||||
}
|
||||
|
||||
// ByKey looks up one reward from the catalog.
|
||||
func (r *RewardRepo) ByKey(ctx context.Context, key string) (*model.SadhnaReward, error) {
|
||||
var w model.SadhnaReward
|
||||
|
||||
Reference in New Issue
Block a user