package repository

import (
	"cron_admin/app/models/cronreportchannelmodel"
	"xorm.io/xorm"
)

type ReportChannel struct {
	ICommonRepo[cronreportchannelmodel.CronReportChannel]
}

func NewReportChannelRepo() *ReportChannel {
	return &ReportChannel{
		ICommonRepo: NewCommonRepo[cronreportchannelmodel.CronReportChannel](),
	}
}

func (c *ReportChannel) WithByID(id uint) DBOption {
	return func(g *xorm.Session) *xorm.Session {
		return g.Where("report_channel_id = ?", id)
	}
}

func (c *ReportChannel) WithLikeClientKey(ClientKey string) DBOption {
	return func(g *xorm.Session) *xorm.Session {
		return g.Where("client_key like ?", "%"+ClientKey+"%")
	}
}

func (c *ReportChannel) WithLikeClientSecret(ClientSecret string) DBOption {
	return func(g *xorm.Session) *xorm.Session {
		return g.Where("client_secret like ?", "%"+ClientSecret+"%")
	}
}

func (c *ReportChannel) WithLikeConfig(config string) DBOption {
	return func(g *xorm.Session) *xorm.Session {
		return g.Where("config like ?", "%"+config+"%")
	}
}