本文整理汇总了Golang中GoOnlineJudge/model.SolutionModel.Achieve方法的典型用法代码示例。如果您正苦于以下问题:Golang SolutionModel.Achieve方法的具体用法?Golang SolutionModel.Achieve怎么用?Golang SolutionModel.Achieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GoOnlineJudge/model.SolutionModel
的用法示例。
在下文中一共展示了SolutionModel.Achieve方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Detail
func (this *UserController) Detail(w http.ResponseWriter, r *http.Request) {
class.Logger.Debug("User Detail")
this.Init(w, r)
args := this.ParseURL(r.URL.String())
uid := args["uid"]
userModel := model.UserModel{}
one, err := userModel.Detail(uid)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
this.Data["Detail"] = one
solutionModle := model.SolutionModel{}
solvedList, err := solutionModle.Achieve(uid)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
this.Data["List"] = solvedList
//class.Logger.Debug(solvedList)
this.Data["Title"] = "User Detail"
if uid != "" && uid == this.Uid {
this.Data["IsSettings"] = true
this.Data["IsSettingsDetail"] = true
}
err = this.Execute(w, "view/layout.tpl", "view/user_detail.tpl")
if err != nil {
http.Error(w, err.Error(), 500)
return
}
}
示例2: Detail
//@URL: /users/(.+) @method: GET
func (uc *UserController) Detail(uid string) {
restweb.Logger.Debug("User Detail", uid)
userModel := model.UserModel{}
one, err := userModel.Detail(uid)
if err != nil {
uc.Error(err.Error(), 400)
return
}
uc.Output["Detail"] = one
solutionModle := model.SolutionModel{}
solvedList, err := solutionModle.Achieve(uid, config.ModuleP, config.ModuleP)
if err != nil {
uc.Error(err.Error(), 400)
return
}
type IPs struct {
Time int64
IP string
}
var ips []IPs
ipo := IPs{}
for i, lenth := 0, len(one.IPRecord); i < lenth; i++ {
ipo.Time = one.TimeRecord[i]
ipo.IP = one.IPRecord[i]
ips = append(ips, ipo)
}
achieveList := sort.IntSlice(solvedList)
achieveList.Sort()
uc.Output["List"] = achieveList
uc.Output["IpList"] = ips
uc.Output["Title"] = "User Detail"
if uid != "" && uid == uc.Uid {
uc.Output["IsSettings"] = true
uc.Output["IsSettingsDetail"] = true
}
uc.RenderTemplate("view/layout.tpl", "view/user_detail.tpl")
}
示例3: Settings
func (this *UserController) Settings(w http.ResponseWriter, r *http.Request) {
class.Logger.Debug("User Settings")
this.Init(w, r)
if this.Privilege == config.PrivilegeNA {
this.Data["Title"] = "Warning"
this.Data["Info"] = "You must login!"
err := this.Execute(w, "view/layout.tpl", "view/400.tpl")
if err != nil {
http.Error(w, "tpl error", 500)
return
}
return
}
userModel := model.UserModel{}
one, err := userModel.Detail(this.Uid)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
this.Data["Detail"] = one
solutionModel := model.SolutionModel{}
solvedList, err := solutionModel.Achieve(this.Uid)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
this.Data["List"] = solvedList
this.Data["Title"] = "User Settings"
this.Data["IsSettings"] = true
this.Data["IsSettingsDetail"] = true
err = this.Execute(w, "view/layout.tpl", "view/user_detail.tpl")
if err != nil {
http.Error(w, "tpl error", 500)
return
}
}
示例4: 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)
}
}