Cron_Admin/app/services/cron_report_channel_service.go

37 lines
975 B
Go

package services
import (
"cron_admin/app/http/entities/backend"
"cron_admin/app/models/cronreportchannelmodel"
"cron_admin/app/repository"
)
func ReportChannelCreate(param *cronreportchannelmodel.CronReportChannel) (err error) {
var (
repo = repository.NewCommonRepo[cronreportchannelmodel.CronReportChannel]()
)
_, err = repo.InsertOne(param)
return
}
func ReportChannelList(param backend.ReportChannelListRequest) (list []cronreportchannelmodel.CronReportChannel, total int64, err error) {
var (
repo = repository.NewCommonRepo[cronreportchannelmodel.CronReportChannel]()
opts = make([]repository.DBOption, 0)
)
if param.ReportChannelId > 0 {
opts = append(opts, repo.WithByID(uint(param.ReportChannelId)))
}
if param.Status > 0 {
opts = append(opts, repo.WithByStatus(param.Status))
}
if param.Page > 0 || param.Limit > 0 {
opts = append(opts, repo.WithPage(param.PageRequest))
}
total, err = repo.FindAndCount(&list, opts...)
return
}