forked from ZJGSU-Open-Source/GoOnlineJudge
-
Notifications
You must be signed in to change notification settings - Fork 5
/
home.go
37 lines (31 loc) · 781 Bytes
/
home.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
package controller
import (
"github.com/ZJGSU-ACM/GoOnlineJudge/class"
"github.com/ZJGSU-ACM/GoOnlineJudge/model"
"github.com/ZJGSU-ACM/restweb"
)
type HomeController struct {
class.Controller
} //@Controller
//@URL: / @method: GET
func (hc *HomeController) Index() {
restweb.Logger.Debug("Home")
newsModel := model.NewsModel{}
newsList, err := newsModel.List(-1, -1)
if err != nil {
hc.Error(err.Error(), 500)
return
}
hc.Output["News"] = newsList
hc.Output["Title"] = "Welcome to ZJGSU Online Judge"
hc.Output["IsNews"] = true
ojModel := &model.OJModel{}
list, err := ojModel.List()
if err == nil {
for _, l := range list {
restweb.Logger.Debug(*l)
}
hc.Output["OJStatus"] = list
}
hc.RenderTemplate("view/layout.tpl", "view/news_list.tpl")
}