2022-11-10 09:44:38 +00:00
|
|
|
package repo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
type WebsiteDnsAccountRepo struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w WebsiteDnsAccountRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebsiteDnsAccount, error) {
|
|
|
|
var accounts []model.WebsiteDnsAccount
|
|
|
|
db := getDb(opts...).Model(&model.WebsiteDnsAccount{})
|
|
|
|
count := int64(0)
|
|
|
|
db = db.Count(&count)
|
2023-02-09 08:13:06 +00:00
|
|
|
err := db.Limit(size).Offset(size * (page - 1)).Find(&accounts).Error
|
2022-11-10 09:44:38 +00:00
|
|
|
return count, accounts, err
|
|
|
|
}
|
|
|
|
|
2023-02-20 09:09:40 +00:00
|
|
|
func (w WebsiteDnsAccountRepo) GetFirst(opts ...DBOption) (*model.WebsiteDnsAccount, error) {
|
2022-11-16 02:31:35 +00:00
|
|
|
var account model.WebsiteDnsAccount
|
|
|
|
db := getDb(opts...).Model(&model.WebsiteDnsAccount{})
|
|
|
|
if err := db.First(&account).Error; err != nil {
|
2023-02-20 09:09:40 +00:00
|
|
|
return nil, err
|
2022-11-16 02:31:35 +00:00
|
|
|
}
|
2023-02-20 09:09:40 +00:00
|
|
|
return &account, nil
|
2022-11-16 02:31:35 +00:00
|
|
|
}
|
|
|
|
|
2023-02-20 09:24:26 +00:00
|
|
|
func (w WebsiteDnsAccountRepo) List(opts ...DBOption) ([]model.WebsiteDnsAccount, error) {
|
|
|
|
var accounts []model.WebsiteDnsAccount
|
|
|
|
db := getDb(opts...).Model(&model.WebsiteDnsAccount{})
|
|
|
|
if err := db.Find(&accounts).Error; err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return accounts, nil
|
|
|
|
}
|
|
|
|
|
2022-11-10 09:44:38 +00:00
|
|
|
func (w WebsiteDnsAccountRepo) Create(account model.WebsiteDnsAccount) error {
|
|
|
|
return getDb().Create(&account).Error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w WebsiteDnsAccountRepo) Save(account model.WebsiteDnsAccount) error {
|
|
|
|
return getDb().Save(&account).Error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w WebsiteDnsAccountRepo) DeleteBy(opts ...DBOption) error {
|
|
|
|
return getDb(opts...).Delete(&model.WebsiteDnsAccount{}).Error
|
|
|
|
}
|