mirror of https://github.com/1Panel-dev/1Panel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
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)
|
|
err := db.Debug().Limit(size).Offset(size * (page - 1)).Find(&accounts).Error
|
|
return count, accounts, err
|
|
}
|
|
|
|
func (w WebsiteDnsAccountRepo) GetFirst(opts ...DBOption) (model.WebsiteDnsAccount, error) {
|
|
var account model.WebsiteDnsAccount
|
|
db := getDb(opts...).Model(&model.WebsiteDnsAccount{})
|
|
if err := db.First(&account).Error; err != nil {
|
|
return account, err
|
|
}
|
|
return account, nil
|
|
}
|
|
|
|
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
|
|
}
|