implement user_permission
This commit is contained in:
@@ -17,4 +17,5 @@ type CustomerUserRepository interface {
|
||||
RandomSvgInterface(entities.KeypadDimension) ([]string, error)
|
||||
RandomSvgIdxInterface(entities.KeypadDimension) (entities.SvgIdInterface, error)
|
||||
GetSvgStringInterface(entities.SvgIdInterface) ([]string, error)
|
||||
AddUserPermission(entities.UserEmail, entities.CustomerId, entities.UserPermission) error
|
||||
}
|
||||
|
||||
@@ -178,8 +178,7 @@ func (d *SqliteRepository) Renew(id entities.CustomerId) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
customerId := entities.CustomerIdToString(id)
|
||||
userRenewRows, err := d.Queue.Queries.GetUserRenew(d.ctx, customerId)
|
||||
userRenewRows, err := d.Queue.Queries.GetUserRenew(d.ctx, id.String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -376,6 +375,24 @@ func (d *SqliteRepository) RandomSvgIdxInterface(kp entities.KeypadDimension) (e
|
||||
func (d *SqliteRepository) GetSvgStringInterface(idxs entities.SvgIdInterface) ([]string, error) {
|
||||
return d.getSvgsById(idxs)
|
||||
}
|
||||
func (d *SqliteRepository) AddUserPermission(userEmail entities.UserEmail, customerId entities.CustomerId, permission entities.UserPermission) error {
|
||||
user, err := d.GetUser(userEmail, customerId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
queryFunc := func(q *sqlc.Queries, ctx context.Context, args any) error {
|
||||
params, ok := args.(sqlc.AddUserPermissionParams)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid argument type: expected AddUserPermissionParams")
|
||||
}
|
||||
return q.AddUserPermission(ctx, params)
|
||||
}
|
||||
params := sqlc.AddUserPermissionParams{
|
||||
UserID: user.Id.String(),
|
||||
Permission: permission.String(),
|
||||
}
|
||||
return d.Queue.EnqueueWriteTx(queryFunc, params)
|
||||
}
|
||||
|
||||
func (d *SqliteRepository) getSvgsById(ids []int) ([]string, error) {
|
||||
svgs := make([]string, len(ids))
|
||||
|
||||
Reference in New Issue
Block a user