You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.8 KiB
64 lines
1.8 KiB
package app
|
|
|
|
import (
|
|
"ln/nft/global"
|
|
"ln/nft/model/app"
|
|
"ln/nft/model/common/request"
|
|
appReq "ln/nft/model/app/request"
|
|
)
|
|
|
|
type ArtsService struct {
|
|
}
|
|
|
|
// CreateArts 创建Arts记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (artsService *ArtsService) CreateArts(arts app.Arts) (err error) {
|
|
err = global.GVA_DB.Create(&arts).Error
|
|
return err
|
|
}
|
|
|
|
// DeleteArts 删除Arts记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (artsService *ArtsService)DeleteArts(arts app.Arts) (err error) {
|
|
err = global.GVA_DB.Delete(&arts).Error
|
|
return err
|
|
}
|
|
|
|
// DeleteArtsByIds 批量删除Arts记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (artsService *ArtsService)DeleteArtsByIds(ids request.IdsReq) (err error) {
|
|
err = global.GVA_DB.Delete(&[]app.Arts{},"id in ?",ids.Ids).Error
|
|
return err
|
|
}
|
|
|
|
// UpdateArts 更新Arts记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (artsService *ArtsService)UpdateArts(arts app.Arts) (err error) {
|
|
err = global.GVA_DB.Save(&arts).Error
|
|
return err
|
|
}
|
|
|
|
// GetArts 根据id获取Arts记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (artsService *ArtsService)GetArts(id uint) (arts app.Arts, err error) {
|
|
err = global.GVA_DB.Where("id = ?", id).First(&arts).Error
|
|
return
|
|
}
|
|
|
|
// GetArtsInfoList 分页获取Arts记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (artsService *ArtsService)GetArtsInfoList(info appReq.ArtsSearch) (list interface{}, total int64, err error) {
|
|
limit := info.PageSize
|
|
offset := info.PageSize * (info.Page - 1)
|
|
// 创建db
|
|
db := global.GVA_DB.Model(&app.Arts{})
|
|
var artss []app.Arts
|
|
// 如果有条件搜索 下方会自动创建搜索语句
|
|
err = db.Count(&total).Error
|
|
if err!=nil {
|
|
return
|
|
}
|
|
err = db.Limit(limit).Offset(offset).Find(&artss).Error
|
|
return artss, total, err
|
|
}
|