2023-12-11 18:55:52 +08:00
|
|
|
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) {
|
2024-01-11 16:03:51 +08:00
|
|
|
err = global.GVA_DB.Updates(&poster).Error
|
2023-12-11 18:55:52 +08:00
|
|
|
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
|
|
|
|
}
|