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.

66 lines
1.3 KiB

package msg
import (
"recook/internal/back"
"recook/internal/libs/bean"
"recook/internal/v2/lib/common"
"recook/internal/v2/logic/msg"
"recook/tools"
"github.com/gin-gonic/gin"
)
type Proxy struct{}
func (o Proxy) List(c *gin.Context) {
var args msg.MessageReq
if err := tools.ParseParams(&args, c); err != nil {
back.Fail(c, err.Error())
}
id, _ := common.GetAppUserId(c)
args.UserID = id
data, total := msg.Logic.List(args)
back.Suc(c, "ok", bean.ResultLists{
List: data,
Total: int(total),
})
}
func (o Proxy) Count(c *gin.Context) {
id, _ := common.GetAppUserId(c)
back.Suc(c, "ok", gin.H{
"count": msg.Logic.Count(id),
})
}
func (o Proxy) Read(c *gin.Context) {
var args msg.MessageReq
if err := tools.ParseParams(&args, c); err != nil {
back.Fail(c, err.Error())
}
id, _ := common.GetAppUserId(c)
args.UserID = id
if err := msg.Logic.Read(args); err != nil {
back.Fail(c, err.Error())
} else {
back.Suc(c, "ok", "")
}
}
func (o Proxy) ReadAll(c *gin.Context) {
var args msg.MessageReq
if err := tools.ParseParams(&args, c); err != nil {
back.Fail(c, err.Error())
}
id, _ := common.GetAppUserId(c)
args.UserID = id
args.IsAll = true
if err := msg.Logic.Read(args); err != nil {
back.Fail(c, err.Error())
} else {
back.Suc(c, "ok", "")
}
}