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.
36 lines
811 B
36 lines
811 B
package msg
|
|
|
|
import (
|
|
"recook/internal/libs/bean"
|
|
"recook/internal/v2/model/jyy"
|
|
|
|
"git.oa00.com/go/mysql"
|
|
)
|
|
|
|
type logic struct{}
|
|
|
|
var Logic = logic{}
|
|
|
|
type MessageReq struct {
|
|
bean.Page
|
|
UserID uint `json:"-"`
|
|
ID int `json:"id"`
|
|
IsAll bool `json:"-"`
|
|
}
|
|
|
|
func (o logic) List(args MessageReq) (data []jyy.AppUserMessage, total int64) {
|
|
query := mysql.Db.Table((&jyy.AppUserMessage{}).TableName()).Where("user_id=?", args.UserID)
|
|
query.Count(&total)
|
|
query.Order("created_at desc").Limit(args.GetLimit()).Offset(args.GetStart()).Find(&data)
|
|
return
|
|
}
|
|
|
|
func (o logic) Read(args MessageReq) error {
|
|
query := mysql.Db.Table((&jyy.AppUserMessage{}).TableName()).Where("user_id = ?", args.UserID)
|
|
if !args.IsAll {
|
|
query = query.Where("id = ?", args.ID)
|
|
}
|
|
query.Update("is_read", true)
|
|
return nil
|
|
}
|