当前位置: 首页>>代码示例>>Golang>>正文


Golang Response.Status方法代码示例

本文整理汇总了Golang中github.com/deepzz0/goblog/helper.Response.Status方法的典型用法代码示例。如果您正苦于以下问题:Golang Response.Status方法的具体用法?Golang Response.Status怎么用?Golang Response.Status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/deepzz0/goblog/helper.Response的用法示例。


在下文中一共展示了Response.Status方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: doModifyPasswd

func (this *UserController) doModifyPasswd(resp *helper.Response) {
	oldPasswd := this.GetString("old")
	newPasswd := this.GetString("new")
	if oldPasswd == "" || newPasswd == "" {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|参数错误。"}
		return
	}
	if !helper.VerifyPasswd(models.Blogger.PassWord, models.Blogger.UserName, oldPasswd, models.Blogger.Salt) {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|原密码错误。"}
		return
	}
	models.Blogger.ChangePassword(newPasswd)
	resp.Success()
}
开发者ID:deepzz0,项目名称:goblog,代码行数:16,代码来源:user.go

示例7: 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

示例8: doDelete

func (this *TrashController) doDelete(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)
	} else {
		if err := models.TMgr.ImmeDelTopic(topic); err != nil {
			resp.Status = RS.RS_failed
			resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|" + err.Error()}
			return
		}
	}
}
开发者ID:deepzz0,项目名称:goblog,代码行数:18,代码来源:trash.go

示例9: 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

示例10: addVerify

func (this *SysconfigController) addVerify(resp *helper.Response) {
	name := this.GetString("name")
	content := this.GetString("content")
	if name == "" || content == "" {
		resp.Status = RS.RS_params_error
		resp.Tips(helper.WARNING, RS.RS_params_error)
		return
	}
	verify := models.ManageConf.GetVerification(name)
	if verify != nil {
		resp.Status = RS.RS_duplicate_add
		resp.Tips(helper.WARNING, RS.RS_duplicate_add)
		return
	}
	verify = models.NewVerify()
	verify.Name = name
	verify.Content = content
	models.ManageConf.AddVerification(verify)
}
开发者ID:deepzz0,项目名称:goblog,代码行数:19,代码来源:sysconfig.go

示例11: 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

示例12: 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

示例13: 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

示例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: 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


注:本文中的github.com/deepzz0/goblog/helper.Response.Status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。