本文整理汇总了Golang中GoOnlineJudge/model.SolutionModel.Count方法的典型用法代码示例。如果您正苦于以下问题:Golang SolutionModel.Count方法的具体用法?Golang SolutionModel.Count怎么用?Golang SolutionModel.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GoOnlineJudge/model.SolutionModel
的用法示例。
在下文中一共展示了SolutionModel.Count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetCount
func (this *Contest) GetCount(qry map[string]string) (int, error) {
if qry == nil {
qry = make(map[string]string)
}
qry["module"] = strconv.Itoa(config.ModuleC)
qry["mid"] = strconv.Itoa(this.Cid)
solutionModel := model.SolutionModel{}
count, err := solutionModel.Count(qry)
if err != nil {
return 0, err
}
return count, nil
}
示例2: UpdateRecord
func (this *solution) UpdateRecord() {
if this.Module != config.ModuleP {
return
}
solutionModel := model.SolutionModel{}
qry := make(map[string]string)
qry["module"] = strconv.Itoa(config.ModuleP)
qry["action"] = "submit"
qry["pid"] = strconv.Itoa(this.Pid)
submit, _ := solutionModel.Count(qry)
qry["action"] = "solve"
solve, _ := solutionModel.Count(qry)
proModel := model.ProblemModel{}
err := proModel.Record(this.Pid, solve, submit)
if err != nil {
logger.Println(err)
}
qry["action"] = "submit"
qry["uid"] = this.Uid
delete(qry, "pid")
delete(qry, "module")
submit, _ = solutionModel.Count(qry)
solvelist, err := solutionModel.Achieve(this.Uid, config.ModuleP, config.ModuleP)
if err != nil {
logger.Println(err)
}
solve = len(solvelist)
userModel := model.UserModel{}
err = userModel.Record(this.Uid, solve, submit)
if err != nil {
logger.Println(err)
}
}
示例3: List
//@URL: /status @method: GET
func (sc *StatusController) List() {
restweb.Logger.Debug("Status List")
searchUrl := ""
qry := make(map[string]string)
// Search
if v, ok := sc.Input["uid"]; ok {
searchUrl += "uid=" + v[0] + "&"
sc.Output["SearchUid"] = v[0]
qry["uid"] = v[0]
}
if v, ok := sc.Input["pid"]; ok {
searchUrl += "pid=" + v[0] + "&"
sc.Output["SearchPid"] = v[0]
qry["pid"] = v[0]
}
if v, ok := sc.Input["judge"]; ok {
searchUrl += "judge=" + v[0] + "&"
sc.Output["SearchJudge"+v[0]] = v[0]
qry["judge"] = v[0]
}
if v, ok := sc.Input["language"]; ok {
searchUrl += "language=" + v[0] + "&"
sc.Output["SearchLanguage"+v[0]] = v[0]
qry["language"] = v[0]
}
sc.Output["URL"] = "/status?" + searchUrl
// Page
qry["page"] = "1"
if v, ok := sc.Input["page"]; ok {
qry["page"] = v[0]
}
solutionModel := model.SolutionModel{}
qry["module"] = strconv.Itoa(config.ModuleP)
qry["action"] = "submit"
count, err := solutionModel.Count(qry)
if err != nil {
sc.Error(err.Error(), 400)
return
}
var pageCount = (count-1)/config.SolutionPerPage + 1
page, err := strconv.Atoi(qry["page"])
if err != nil {
sc.Error("args error", 400)
return
}
if page > pageCount {
sc.Error("args error", 400)
return
}
qry["offset"] = strconv.Itoa((page - 1) * config.SolutionPerPage)
qry["limit"] = strconv.Itoa(config.SolutionPerPage)
pageData := sc.GetPage(page, pageCount)
for k, v := range pageData {
sc.Output[k] = v
}
list, err := solutionModel.List(qry)
if err != nil {
sc.Error(err.Error(), 500)
return
}
sc.Output["Solution"] = list
sc.Output["Title"] = "Status List"
sc.Output["IsStatus"] = true
sc.Output["Privilege"] = sc.Privilege
sc.Output["Uid"] = sc.Uid
sc.RenderTemplate("view/layout.tpl", "view/status_list.tpl")
}
示例4: List
//@URL: /contests/(\d+)/status @method: GET
func (sc *ContestStatus) List(Cid string) {
restweb.Logger.Debug("Contest Status List")
sc.InitContest(Cid)
solutionModel := model.SolutionModel{}
qry := make(map[string]string)
qry["module"] = strconv.Itoa(config.ModuleC)
qry["mid"] = Cid
searchUrl := ""
// Search
if v, ok := sc.Input["uid"]; ok {
searchUrl += "uid=" + v[0] + "&"
sc.Output["SearchUid"] = v[0]
qry["uid"] = v[0]
}
if v, ok := sc.Input["pid"]; ok {
searchUrl += "pid=" + v[0] + "&"
sc.Output["SearchPid"] = v[0]
idx, _ := strconv.Atoi(v[0])
if idx < len(sc.ContestDetail.List) {
qry["pid"] = strconv.Itoa(sc.ContestDetail.List[idx])
restweb.Logger.Debug(qry["pid"], idx)
}
}
if v, ok := sc.Input["judge"]; ok {
searchUrl += "judge=" + v[0] + "&"
sc.Output["SearchJudge"+v[0]] = v[0]
qry["judge"] = v[0]
}
if v, ok := sc.Input["language"]; ok {
searchUrl += "language=" + v[0] + "&"
sc.Output["SearchLanguage"+v[0]] = v[0]
qry["language"] = v[0]
}
qry["page"] = "1"
if v, ok := sc.Input["page"]; ok {
qry["page"] = v[0]
}
sc.Output["URL"] = "/contests/" + Cid + "/status?" + searchUrl
qry["action"] = "submit"
count, err := solutionModel.Count(qry)
if err != nil {
sc.Error(err.Error(), 400)
return
}
var pageCount = (count-1)/config.SolutionPerPage + 1
page, err := strconv.Atoi(qry["page"])
if err != nil {
sc.Error("args error", 400)
return
}
if page > pageCount {
sc.Error("args error", 400)
return
}
qry["offset"] = strconv.Itoa((page - 1) * config.SolutionPerPage)
qry["limit"] = strconv.Itoa(config.SolutionPerPage)
pageData := sc.GetPage(page, pageCount)
for k, v := range pageData {
sc.Output[k] = v
}
solutionList, err := solutionModel.List(qry)
if err != nil {
sc.Error("load error", 400)
return
}
for i, v := range solutionList {
solutionList[i].Pid = sc.Index[v.Pid]
}
sc.Output["Solution"] = solutionList
sc.Output["Privilege"] = sc.Privilege
sc.Output["IsContestStatus"] = true
sc.Output["Privilege"] = sc.Privilege
sc.Output["Uid"] = sc.Uid
sc.RenderTemplate("view/layout.tpl", "view/contest/status_list.tpl")
}
示例5: List
func (this *StatusController) List(w http.ResponseWriter, r *http.Request) {
class.Logger.Debug("Status List")
this.Init(w, r)
args := this.ParseURL(r.URL.String())
url := "/solution?list"
searchUrl := ""
qry := make(map[string]string)
// Search
if v, ok := args["uid"]; ok {
searchUrl += "/uid?" + v
this.Data["SearchUid"] = v
qry["uid"] = v
}
if v, ok := args["pid"]; ok {
searchUrl += "/pid?" + v
this.Data["SearchPid"] = v
qry["pid"] = v
}
if v, ok := args["judge"]; ok {
searchUrl += "/judge?" + v
this.Data["SearchJudge"+v] = v
qry["judge"] = v
}
if v, ok := args["language"]; ok {
searchUrl += "/language?" + v
this.Data["SearchLanguage"+v] = v
qry["language"] = v
}
url += searchUrl
this.Data["URL"] = "/status?list" + searchUrl
// Page
if _, ok := args["page"]; !ok {
args["page"] = "1"
}
solutionModel := model.SolutionModel{}
qry["module"] = strconv.Itoa(config.ModuleP)
qry["action"] = "submit"
count, err := solutionModel.Count(qry)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
var pageCount = (count-1)/config.SolutionPerPage + 1
page, err := strconv.Atoi(args["page"])
if err != nil {
http.Error(w, "args error", 400)
return
}
if page > pageCount {
http.Error(w, "args error", 400)
return
}
qry["offset"] = strconv.Itoa((page - 1) * config.SolutionPerPage)
qry["limit"] = strconv.Itoa(config.SolutionPerPage)
pageData := this.GetPage(page, pageCount)
for k, v := range pageData {
this.Data[k] = v
}
list, err := solutionModel.List(qry)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
this.Data["Solution"] = list
this.Data["Title"] = "Status List"
this.Data["IsStatus"] = true
err = this.Execute(w, "view/layout.tpl", "view/status_list.tpl")
if err != nil {
http.Error(w, "tpl error", 500)
return
}
}