package models import "kefu/types" //评价表 type Rate struct { ID uint `gorm:"primary_key" json:"id"` EntId string `json:"ent_id"` KefuName string `json:"kefu_name"` KefuNickname string `json:"kefu_nickname"` Score uint `json:"score"` CreatedAt types.Time `json:"created_at"` VisitorId string `json:"visitor_id"` Content string `json:"content"` } func (a *Rate) AddRate() uint { DB.Create(a) return a.ID } func CountRateWhere(query interface{}, args ...interface{}) uint { var v uint DB.Model(&Rate{}).Where(query, args...).Count(&v) return v } func FindRateByWhere(page uint, pagesize uint, query interface{}, args ...interface{}) []Rate { if page <= 0 { page = 1 } offset := (page - 1) * pagesize if offset <= 0 { offset = 0 } var v []Rate DB.Model(&Rate{}).Where(query, args...).Order("id desc").Offset(offset).Limit(pagesize).Find(&v) return v }