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.
67 lines
2.1 KiB
67 lines
2.1 KiB
package app
|
|
|
|
import (
|
|
"ln/nft/global"
|
|
"ln/nft/model/app"
|
|
appReq "ln/nft/model/app/request"
|
|
"ln/nft/model/common/request"
|
|
)
|
|
|
|
type AppBannersService struct {
|
|
}
|
|
|
|
// CreateAppBanners 创建AppBanners记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (appBannersService *AppBannersService) CreateAppBanners(appBanners app.AppBanners) (err error) {
|
|
err = global.GVA_DB.Create(&appBanners).Error
|
|
return err
|
|
}
|
|
|
|
// DeleteAppBanners 删除AppBanners记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (appBannersService *AppBannersService) DeleteAppBanners(appBanners app.AppBanners) (err error) {
|
|
err = global.GVA_DB.Delete(&appBanners).Error
|
|
return err
|
|
}
|
|
|
|
// DeleteAppBannersByIds 批量删除AppBanners记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (appBannersService *AppBannersService) DeleteAppBannersByIds(ids request.IdsReq) (err error) {
|
|
err = global.GVA_DB.Delete(&[]app.AppBanners{}, "id in ?", ids.Ids).Error
|
|
return err
|
|
}
|
|
|
|
// UpdateAppBanners 更新AppBanners记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (appBannersService *AppBannersService) UpdateAppBanners(appBanners app.AppBanners) (err error) {
|
|
err = global.GVA_DB.Save(&appBanners).Error
|
|
return err
|
|
}
|
|
|
|
// GetAppBanners 根据id获取AppBanners记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (appBannersService *AppBannersService) GetAppBanners(id uint) (appBanners app.AppBanners, err error) {
|
|
err = global.GVA_DB.Where("id = ?", id).First(&appBanners).Error
|
|
return
|
|
}
|
|
|
|
// GetAppBannersInfoList 分页获取AppBanners记录
|
|
// Author [piexlmax](https://github.com/piexlmax)
|
|
func (appBannersService *AppBannersService) GetAppBannersInfoList(info appReq.AppBannersSearch) (list interface{}, total int64, err error) {
|
|
limit := info.PageSize
|
|
offset := info.PageSize * (info.Page - 1)
|
|
// 创建db
|
|
db := global.GVA_DB.Model(&app.AppBanners{})
|
|
var appBannerss []app.AppBanners
|
|
// 如果有条件搜索 下方会自动创建搜索语句
|
|
if info.Type != nil {
|
|
db = db.Where("type = ?", info.Type)
|
|
}
|
|
err = db.Count(&total).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = db.Limit(limit).Offset(offset).Find(&appBannerss).Error
|
|
return appBannerss, total, err
|
|
}
|