mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2025-11-29 08:33:21 +00:00
46 lines
783 B
Go
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)
|
|
}
|
|
}
|