mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 06:30:22 +00:00
NOISSUE - Limit listing based on domain (#41)
* add domain_id as a page metadata Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * add missing created_by Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> --------- Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>
This commit is contained in:
committed by
GitHub
parent
17e59d2beb
commit
96158cdc8e
@@ -20,7 +20,7 @@ const (
|
||||
INSERT INTO rules (id, name, domain_id, metadata, input_channel, input_topic, logic_type, logic_value,
|
||||
output_channel, output_topic, recurring_time, recurring_type, recurring_period, created_at, created_by, updated_at, updated_by, status)
|
||||
VALUES (:id, :name, :domain_id, :metadata, :input_channel, :input_topic, :logic_type, :logic_value,
|
||||
:output_channel, :output_topic, :recurring_time, :recurring_type, :recurring_period, :created_at, :updated_at, :updated_by, :status)
|
||||
:output_channel, :output_topic, :recurring_time, :recurring_type, :recurring_period, :created_at, :created_by, :updated_at, :updated_by, :status)
|
||||
RETURNING id, name, domain_id, metadata, input_channel, input_topic, logic_type, logic_value,
|
||||
output_channel, output_topic, recurring_time, recurring_type, recurring_period, created_at, created_by, updated_at, updated_by, status;
|
||||
`
|
||||
@@ -229,6 +229,10 @@ func pageQuery(pm re.PageMeta) string {
|
||||
query = append(query, "r.status = :status")
|
||||
}
|
||||
|
||||
if pm.Domain != "" {
|
||||
query = append(query, "r.domain_id = :domain_id")
|
||||
}
|
||||
|
||||
var q string
|
||||
if len(query) > 0 {
|
||||
q = fmt.Sprintf("WHERE %s", strings.Join(query, " AND "))
|
||||
|
||||
@@ -77,6 +77,7 @@ type PageMeta struct {
|
||||
InputChannel string `json:"input_channel,omitempty" db:"input_channel"`
|
||||
OutputChannel string `json:"output_channel,omitempty" db:"output_channel"`
|
||||
Status Status `json:"status,omitempty" db:"status"`
|
||||
Domain string `json:"domain_id,omitempty" db:"domain_id"`
|
||||
}
|
||||
|
||||
type Page struct {
|
||||
@@ -135,6 +136,7 @@ func (re *re) UpdateRule(ctx context.Context, session authn.Session, r Rule) (Ru
|
||||
}
|
||||
|
||||
func (re *re) ListRules(ctx context.Context, session authn.Session, pm PageMeta) (Page, error) {
|
||||
pm.Domain = session.DomainID
|
||||
return re.repo.ListRules(ctx, pm)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user