package models

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type FeedBack struct {
	Id          int       ` description:"ID"`
	UserId      string    `description:"用户ID"`
	Mobile      string    `description:"手机号"`
	Message     string    `description:"反馈"`
	CreatedTime time.Time `description:"创建时间"`
}
type FeedBackView struct {
	Mobile      string `json:"Mobile"`
	Message     string `json:"Message"`
	CreatedTime string `json:"CreatedTime"`
}

func GetFeedBackCount() (count int, err error) {
	o := orm.NewOrm()
	sql := `SELECT COUNT(*) AS count FROM feed_backs`
	err = o.Raw(sql).QueryRow(&count)
	return
}

func GetFeedBackList(startSize, pageSize int) (item []*FeedBack, err error) {
	o := orm.NewOrm()
	sql := `SELECT * FROM feed_backs  ORDER BY created_time desc LIMIT ?,?`
	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&item)
	return
}
