first
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"Gwen/model"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
//AdminService *AdminService
|
||||
//AdminRoleService *AdminRoleService
|
||||
*UserService
|
||||
*AddressBookService
|
||||
*TagService
|
||||
*PeerService
|
||||
*GroupService
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user