Exemplo n.º 1
0
//删除竞赛
//@URL: /admin/contests/(\d+)/delete/ @method:POST
func (cc *AdminContest) Delete(Cid string) {
	restweb.Logger.Debug("Admin Contest Delete")

	cid, err := strconv.Atoi(Cid)
	if err != nil {
		cc.Error("args error", 400)
		return
	}
	contestModel := model.ContestModel{}
	old, _ := contestModel.Detail(cid)
	if old.Creator != cc.Uid {
		cc.Error("privilege error", 400)
		return
	}

	err = contestModel.Delete(cid)
	if err != nil {
		cc.Error(err.Error(), 400)
		return
	}
	cc.W.WriteHeader(200)
}
Exemplo n.º 2
0
//删除竞赛 url:/admin/contest/delete/,method:POST
func (this *ContestController) Delete(w http.ResponseWriter, r *http.Request) {
	class.Logger.Debug("Admin Contest Delete")
	if r.Method != "POST" {
		this.Err400(w, r, "Error", "Error Method to Delete contest")
		return
	}

	this.Init(w, r)

	args := this.ParseURL(r.URL.String())
	cid, err := strconv.Atoi(args["cid"])
	if err != nil {
		http.Error(w, "args error", 400)
		return
	}

	contestModel := model.ContestModel{}
	err = contestModel.Delete(cid)
	if err != nil {
		http.Error(w, err.Error(), 400)
		return
	}
	w.WriteHeader(200)
}