-
Notifications
You must be signed in to change notification settings - Fork 30
/
notice.go
50 lines (37 loc) · 1.04 KB
/
notice.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package frontend
import (
"github.com/gin-gonic/gin"
fe "github.com/hhandhuan/ku-bbs/internal/entity/frontend"
sv "github.com/hhandhuan/ku-bbs/internal/service"
"github.com/hhandhuan/ku-bbs/internal/service/frontend"
)
var Notice = cNotice{}
type cNotice struct{}
func (*cNotice) HomePage(ctx *gin.Context) {
s := sv.Context(ctx)
if !s.Check() {
s.To("/login").WithError("请登录后,再继续操作").Redirect()
return
}
var req fe.GetRemindListReq
err := ctx.ShouldBind(&req)
if err != nil {
s.To("/").WithError(err).Redirect()
return
}
nsv := frontend.NoticeService(ctx)
data, err := nsv.GetList(&req)
if err != nil {
s.To("/").WithError(err.Error()).Redirect()
return
}
// 提醒未读数量
remindUnread, _ := frontend.NoticeService(ctx).GetRemindUnread()
// 系统未读数量
systemUnread, _ := frontend.NoticeService(ctx).GetSystemUnread()
data["remindUnread"] = remindUnread
data["systemUnread"] = systemUnread
// 更新未读消息状态
nsv.ReadAll(req.Type)
s.View("frontend.notice.home", data)
}