JM-WechatMini/service/system/poster.go

40 lines
1.0 KiB
Go

package system
import (
"miniapp/global"
"miniapp/model/common"
"miniapp/model/common/request"
)
type PosterService struct{}
// AddPoster 新增
func (p *PosterService) AddPoster(poster *common.Poster) (err error) {
err = global.GVA_DB.Create(&poster).Error
return
}
// UpdatePoster 更新
func (p *PosterService) UpdatePoster(poster *common.Poster) (err error) {
err = global.GVA_DB.Save(&poster).Error
return
}
// DeletePoster 删除
func (p *PosterService) DeletePoster(poster *common.Poster) (err error) {
err = global.GVA_DB.Delete(&poster).Error
return
}
// GetPosterList 获取列表
func (p *PosterService) GetPosterList(page request.PageInfo) (list []common.Poster, total int64, err error) {
err = global.GVA_DB.Scopes(Page(page.Page, page.PageSize)).Find(&list).Limit(-1).Offset(-1).Count(&total).Error
return
}
// GetPosterById 根据id获取
func (p *PosterService) GetPosterById(id string) (poster common.Poster, err error) {
err = global.GVA_DB.Where("id = ?", id).First(&poster).Error
return
}