Files
rustdesk-api/service/service.go
2024-10-18 15:05:58 +08:00

46 lines
783 B
Go

package service
import (
"Gwen/model"
"gorm.io/gorm"
)
type Service struct {
//AdminService *AdminService
//AdminRoleService *AdminRoleService
*UserService
*AddressBookService
*TagService
*PeerService
*GroupService
*OauthService
*LoginLogService
*AuditService
}
func New() *Service {
all := new(Service)
return all
}
var AllService = New()
func Paginate(page, pageSize uint) func(db *gorm.DB) *gorm.DB {
return func(db *gorm.DB) *gorm.DB {
if page == 0 {
page = 1
}
if pageSize == 0 {
pageSize = 10
}
offset := (page - 1) * pageSize
return db.Offset(int(offset)).Limit(int(pageSize))
}
}
func CommonEnable() func(db *gorm.DB) *gorm.DB {
return func(db *gorm.DB) *gorm.DB {
return db.Where("status = ?", model.COMMON_STATUS_ENABLE)
}
}