27 lines
617 B
Go
27 lines
617 B
Go
package app
|
|
|
|
import (
|
|
"miniapp/global"
|
|
"miniapp/model/app"
|
|
"miniapp/model/app/request"
|
|
)
|
|
|
|
type VisionService struct{}
|
|
|
|
func (s *VisionService) GetVisionList(p request.VisionListRequest) (list *[]app.Vision, total int64, err error) {
|
|
limit := p.PageSize
|
|
offset := p.PageSize * (p.Page - 1)
|
|
db := global.GVA_DB.Model(&app.Vision{}).Where("user_id = ?", p.UserId)
|
|
err = db.Count(&total).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = db.Limit(limit).Offset(offset).Find(&list).Error
|
|
return
|
|
}
|
|
|
|
func (s *VisionService) CreateVision(vision *app.Vision) (err error) {
|
|
err = global.GVA_DB.Create(&vision).Error
|
|
return
|
|
}
|