// 列出所有新闻 //@URL: /admin/news/ @method: GET func (nc *AdminNews) List() { restweb.Logger.Debug("Admin News List") newsModel := model.NewsModel{} newlist, err := newsModel.List(-1, -1) if err != nil { nc.Error(err.Error(), 500) return } nc.Output["News"] = newlist nc.Output["Title"] = "Admin - News List" nc.Output["IsNews"] = true nc.Output["IsList"] = true nc.RenderTemplate("view/admin/layout.tpl", "view/admin/news_list.tpl") }
//列出所有新闻 //@URL: /news @method: GET func (nc *NewsController) List() { restweb.Logger.Debug("News List") newsModel := model.NewsModel{} newsList, err := newsModel.List(-1, -1) if err != nil { // http.Error(w, err.Error(), 500) return } nc.Output["News"] = newsList nc.Output["Title"] = "Welcome to ZJGSU Online Judge" nc.Output["IsNews"] = true nc.RenderTemplate("view/layout.tpl", "view/news_list.tpl") }
//列出所有新闻 func (this *NewsController) List(w http.ResponseWriter, r *http.Request) { class.Logger.Debug("News List") this.Init(w, r) newsModel := model.NewsModel{} newsList, err := newsModel.List(-1, -1) if err != nil { http.Error(w, err.Error(), 500) return } this.Data["News"] = newsList this.Data["Title"] = "Welcome to ZJGSU Online Judge" this.Data["IsNews"] = true err = this.Execute(w, "view/layout.tpl", "view/news_list.tpl") if err != nil { http.Error(w, "tpl error", 500) return } }
//@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") }