當前位置: 首頁>>代碼示例>>Golang>>正文


Golang helper.Response類代碼示例

本文整理匯總了Golang中github.com/deepzz0/goblog/helper.Response的典型用法代碼示例。如果您正苦於以下問題:Golang Response類的具體用法?Golang Response怎麽用?Golang Response使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Response類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: updateSitemap

func (this *SysconfigController) updateSitemap(resp *helper.Response) {
	content := this.GetString("content")
	if content == "" {
		resp.Status = RS.RS_params_error
		resp.Tips(helper.WARNING, RS.RS_params_error)
		return
	}
	_, err := os.Stat(models.SiteFile)
	if err != nil && !strings.Contains(err.Error(), "no such file") {
		log.Error(err)
		return
	} else {
		os.Remove(models.SiteFile)
	}
	f, err := os.Create(models.SiteFile)
	if err != nil {
		log.Error(err)
		return
	}
	defer f.Close()
	_, err = f.WriteString(content)
	if err != nil {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "錯誤|" + err.Error()}
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:26,代碼來源:sysconfig.go

示例2: deleteVerify

func (this *SysconfigController) deleteVerify(resp *helper.Response) {
	name := this.GetString("name")
	if name == "" {
		resp.Status = RS.RS_params_error
		resp.Tips(helper.WARNING, RS.RS_params_error)
		return
	}
	models.ManageConf.DelVerification(name)
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:9,代碼來源:sysconfig.go

示例3: getSitemap

func (this *SysconfigController) getSitemap(resp *helper.Response) {
	f, err := os.Open(models.SiteFile)
	if err != nil {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "錯誤|" + err.Error()}
		return
	}
	defer f.Close()
	data, _ := ioutil.ReadAll(f)
	resp.Data = string(data)
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:11,代碼來源:sysconfig.go

示例4: getCategory

func (this *CategoryController) getCategory(resp *helper.Response) {
	id := this.GetString("id")
	if id != "" {
		if cat := models.Blogger.GetCategoryByID(id); cat != nil {
			b, _ := json.Marshal(cat)
			resp.Data = string(b)
		}
	} else {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "錯誤|參數錯誤。"}
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:12,代碼來源:category.go

示例5: getBlogroll

func (this *BlogrollController) getBlogroll(resp *helper.Response) {
	id := this.GetString("id")
	if id != "" {
		if br := models.Blogger.GetBlogrollByID(id); br != nil {
			b, _ := json.Marshal(br)
			resp.Data = string(b)
		}
	} else {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "錯誤|參數錯誤。"}
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:12,代碼來源:blogroll.go

示例6: doDeleteTag

func (this *CategoryController) doDeleteTag(resp *helper.Response) {
	id := this.GetString("id")
	if id == "" {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "哦噢。。。|參數錯誤。"}
		return
	}
	if code := models.Blogger.DelTagByID(id); code != RS.RS_success {
		resp.Status = code
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "抱歉|係統沒有找到該標簽。"}
		return
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:13,代碼來源:category.go

示例7: doDeleteTopic

func (this *TopicsController) doDeleteTopic(resp *helper.Response) {
	id, err := this.GetInt("id")
	if err != nil {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "ID錯誤|走正常途徑哦。"}
		return
	}
	err = models.TMgr.DelTopic(int32(id))
	if err != nil {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "刪除失敗|" + err.Error()}
		return
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:14,代碼來源:topics.go

示例8: getTopic

func (this *TopicsController) getTopic(resp *helper.Response) {
	id, err := this.GetInt("id")
	if err != nil {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "錯誤|ID格式不正確。"}
		return
	}
	if topic, err := models.TMgr.LoadTopic(int32(id)); err != nil || topic == nil {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "錯誤|係統未查詢到該文章。"}
		return
	} else {
		resp.Data = topic
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:15,代碼來源:topics.go

示例9: modifyPasswd

func (this *UserController) modifyPasswd(resp *helper.Response) {
	modifypasswdT, err := template.ParseFiles("views/manage/user/modifypasswd.html")
	if err != nil {
		panic(err)
	}
	var buffer bytes.Buffer
	modifypasswdT.Execute(&buffer, nil)
	resp.Data = buffer.String()
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:9,代碼來源:user.go

示例10: doDeleteTopics

func (this *TopicsController) doDeleteTopics(resp *helper.Response) {
	ids := this.GetString("ids")
	log.Debugf("%s", ids)
	if ids == "" {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "ID錯誤|走正常途徑哦。"}
		return
	}
	sliceID := strings.Split(ids, ",")
	for _, v := range sliceID {
		id, err := strconv.Atoi(v)
		if err != nil {
			log.Error(err)
			resp.Status = RS.RS_failed
			resp.Err = helper.Error{Level: helper.WARNING, Msg: "ID錯誤|走正常途徑哦。"}
			return
		}
		err = models.TMgr.DelTopic(int32(id))
		if err != nil {
			resp.Status = RS.RS_failed
			resp.Err = helper.Error{Level: helper.WARNING, Msg: "刪除失敗|" + err.Error()}
			return
		}
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:25,代碼來源:topics.go

示例11: doRestore

func (this *TrashController) doRestore(resp *helper.Response) {
	id, err := this.GetInt32("id")
	if err != nil {
		resp.Status = RS.RS_failed
		resp.Tips(helper.WARNING, RS.RS_params_error)
		return
	}
	if topic := models.TMgr.GetWaitDelTopic(id); topic == nil {
		resp.Status = RS.RS_not_found
		resp.Tips(helper.WARNING, RS.RS_not_found)
		return
	} else {
		if code := models.TMgr.RestoreTopic(topic); code != RS.RS_success {
			resp.Status = code
			resp.Tips(helper.WARNING, code)
			return
		}
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:19,代碼來源:trash.go

示例12: saveBlogroll

func (this *BlogrollController) saveBlogroll(resp *helper.Response) {
	content := this.GetString("json")
	var br models.Blogroll
	err := json.Unmarshal([]byte(content), &br)
	if err != nil {
		log.Error(err)
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "內容錯誤|要仔細檢查哦。"}
		return
	}
	if br.ID == "TEST" {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "內容錯誤|請修改你需要添加的工具。"}
		return
	}
	if blogroll := models.Blogger.GetBlogrollByID(br.ID); blogroll != nil {
		*blogroll = br
		sort.Sort(models.Blogger.Blogrolls)
	} else {
		br.CreateTime = time.Now()
		models.Blogger.AddBlogroll(&br)
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:23,代碼來源:blogroll.go

示例13: saveCategory

func (this *CategoryController) saveCategory(resp *helper.Response) {
	content := this.GetString("json")
	var cat models.Category
	err := json.Unmarshal([]byte(content), &cat)
	if err != nil {
		log.Error(err)
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "內容錯誤|要仔細檢查哦。"}
		return
	}
	if cat.ID == "TEST" {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "內容錯誤|請修改你需要添加的分類。"}
		return
	}
	if category := models.Blogger.GetCategoryByID(cat.ID); category != nil {
		*category = cat
		sort.Sort(models.Blogger.Categories)
	} else {
		cat.CreateTime = time.Now()
		models.Blogger.AddCategory(&cat)
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:23,代碼來源:category.go

示例14: saveSocial

func (this *SocialController) saveSocial(resp *helper.Response) {
	content := this.GetString("json")
	var sc models.Social
	err := json.Unmarshal([]byte(content), &sc)
	if err != nil {
		log.Error(err)
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "內容錯誤|要仔細檢查哦。"}
		return
	}
	if sc.ID == "TEST" {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "內容錯誤|請修改你需要添加的社交。"}
		return
	}
	if social := models.Blogger.GetSocialByID(sc.ID); social != nil {
		*social = sc
		sort.Sort(models.Blogger.Socials)
	} else {
		sc.CreateTime = time.Now()
		models.Blogger.AddSocial(&sc)
	}
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:23,代碼來源:social.go

示例15: doModifyInfo

func (this *UserController) doModifyInfo(resp *helper.Response) {
	if blogname := this.GetString("blogname"); blogname != "" {
		models.Blogger.BlogName = blogname
	}
	if icon := this.GetString("icon"); icon != "" {
		models.Blogger.HeadIcon = icon
	}
	if introduce := this.GetString("introduce"); introduce != "" {
		models.Blogger.Introduce = introduce
	}
	if sex := this.GetString("sex"); sex != "" {
		models.Blogger.Sex = sex
	}
	if email := this.GetString("email"); email != "" {
		models.Blogger.Email = email
	}
	if address := this.GetString("address"); address != "" {
		models.Blogger.Address = address
	}
	if education := this.GetString("education"); education != "" {
		models.Blogger.Education = education
	}
	resp.Success()
}
開發者ID:deepzz0,項目名稱:goblog,代碼行數:24,代碼來源:user.go


注:本文中的github.com/deepzz0/goblog/helper.Response類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。