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.
63 lines
1.9 KiB
63 lines
1.9 KiB
package goods
|
|
|
|
import (
|
|
"github.com/golangkit/formatime"
|
|
"recook/internal/v2/lib/db"
|
|
)
|
|
|
|
const (
|
|
RecookGoodsNoticeTypeHead = 1
|
|
RecookGoodsNoticeTypeFoot = 2
|
|
RecookGoodsNoticeTypeBoth = 3
|
|
)
|
|
|
|
type RecookGoodsNoticeModel struct {
|
|
db.BaseModel
|
|
Id uint `gorm:"column:id;primary_key" json:"id"`
|
|
Title string `json:"title"`
|
|
Img string `json:"img"`
|
|
Type int `json:"type"`
|
|
StartTime formatime.Second `json:"startTime"`
|
|
EndTime formatime.Second `json:"endTime"`
|
|
CreatedAt formatime.Second `json:"createdAt"`
|
|
VendorId uint `json:"vendorId"`
|
|
}
|
|
|
|
// TableName sets the insert table name for this struct type
|
|
func (r *RecookGoodsNoticeModel) TableName() string {
|
|
return "recook_goods_notice"
|
|
}
|
|
|
|
// @Style 添加
|
|
func (r *RecookGoodsNoticeModel) Create(data *RecookGoodsNoticeModel) {
|
|
r.GetDb().Create(data)
|
|
}
|
|
|
|
// @Style 获取列表
|
|
func (r *RecookGoodsNoticeModel) GetLists(start, limit int, order string, query interface{}, args ...interface{}) (result []RecookGoodsNoticeModel) {
|
|
r.GetDb().Model(&RecookGoodsNoticeModel{}).Where(query, args...).Offset(start).Limit(limit).Order(order).Find(&result)
|
|
return
|
|
}
|
|
|
|
// @Style 获取总数
|
|
func (r *RecookGoodsNoticeModel) GetListsTotal(query interface{}, args ...interface{}) (result int) {
|
|
r.GetDb().Model(&RecookGoodsNoticeModel{}).Where(query, args...).Count(&result)
|
|
return
|
|
}
|
|
|
|
// @Style 获取单条数据
|
|
func (r *RecookGoodsNoticeModel) FindById(id uint) (result RecookGoodsNoticeModel) {
|
|
r.GetDb().Model(&RecookGoodsNoticeModel{}).First(&result, "id = ?", id)
|
|
return
|
|
}
|
|
|
|
// @Style 获取单条数据
|
|
func (r *RecookGoodsNoticeModel) DeleteById(id uint) error {
|
|
return r.GetDb().Delete(&RecookGoodsNoticeModel{}, "id = ?", id).Error
|
|
}
|
|
|
|
// @Style 获取单条数据
|
|
func (r *RecookGoodsNoticeModel) UpdateById(id uint, data *RecookGoodsNoticeModel) error {
|
|
return r.GetDb().Model(&RecookGoodsNoticeModel{}).Where("id = ?", id).Update(data).Error
|
|
}
|