コード例 #1
0
ファイル: article.go プロジェクト: dw250100785/blog-1
func (this *DeleteArticleController) Post() {
	// if not login, permission deny
	user := this.GetSession("username")
	if user == nil {
		this.Data["json"] = map[string]interface{}{"result": false, "msg": "login first please", "refer": nil}
		this.ServeJson()
		return
	}

	id, err := this.GetInt64("id")
	title := this.Ctx.Input.Param(":title")

	if err != nil {
		id = 0
	}

	num, err := DeleteArticle(id, title)

	if nil != err {
		log.Fatal(err)
		this.Data["json"] = map[string]interface{}{"result": false, "msg": "delete faild", "refer": nil}
		this.ServeJson()
	} else if 0 == num {
		this.Data["json"] = map[string]interface{}{"result": false, "msg": "articles dose not exist", "refer": nil}
		this.ServeJson()
	} else {
		this.Data["json"] = map[string]interface{}{"result": true, "msg": fmt.Sprintf("[%d]", num) + " articles deleted", "refer": nil}
		this.ServeJson()
	}
}
コード例 #2
0
ファイル: init.go プロジェクト: jango2015/ojsite
// 模版与应用版本匹配检查
func CheckTplVersion() {
	tmpVer := com.ReadFile("views/VERSION")
	if AppVer == tmpVer {
		return
	} else {
		log.Fatal("Template Version[", tmpVer, "] Not Matched App Version[", AppVer, "], Update and Rebuild Please.")
		return
	}
}
コード例 #3
0
ファイル: admin.go プロジェクト: dw250100785/blog-1
func (this *AdminArticleController) DelArticle() {
	// if not login, permission deny
	user := this.GetSession("username")
	if user == nil {
		this.Data["json"] = map[string]interface{}{"result": false, "msg": "login first please", "refer": nil}
		this.ServeJson()
		return
	}

	paramsBody := string(this.Ctx.Input.RequestBody)
	var params map[string]interface{}
	p, err := com.JsonDecode(paramsBody)
	if err != nil {
		this.Data["json"] = map[string]interface{}{"result": false, "msg": "parse params failed", "refer": "/"}
		this.ServeJson()
		return
	} else {
		params = p.(map[string]interface{})["params"].(map[string]interface{})
	}

	id := int64(params["id"].(float64))
	// title := this.Ctx.Input.Param(":title")

	if id < 0 {
		id = 0
	}

	num, err := DeleteArticle(id, "")

	if nil != err {
		log.Fatal(err)
		this.Data["json"] = map[string]interface{}{"result": false, "msg": "delete faild", "refer": nil}
		this.ServeJson()
	} else if 0 == num {
		this.Data["json"] = map[string]interface{}{"result": false, "msg": "articles dose not exist", "refer": nil}
		this.ServeJson()
	} else {
		this.Data["json"] = map[string]interface{}{"result": true, "msg": fmt.Sprintf("[%d]", num) + " articles deleted", "refer": nil}
		this.ServeJson()
	}
}