예제 #1
0
파일: topics.go 프로젝트: deepzz0/goblog
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
		}
	}
}
예제 #2
0
파일: cmd_test.go 프로젝트: deepzz0/go-com
func TestExecCmd(t *testing.T) {
	// str, str1, err := execCmd("", "open", "../log/log.go")
	// log.Debugf(">>>%s", str)
	// log.Debugf(">>>%s", str1)
	// log.Debugf(">>>%#v", err)

	// mysqldump -uroot -proot gamecenter bag --where="" > /Users/chen/a.sql
	str, str1, _ := execCmd("", "mysqldump", "-uroot", "-proot", "gamecenter", "test", "--where=id>1 and id<5")
	log.Debugf(">>>%s,>>>>%s,%s", str, str1)
}
예제 #3
0
파일: basedata.go 프로젝트: deepzz0/goblog
func (this *DataController) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	flag := this.GetString("flag")
	log.Debugf("flag = %s", flag)
	switch flag {
	case "base":
		this.Base(resp)
	default:
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "参数错误|未知的flag标志。"}
	}
}
예제 #4
0
파일: blogroll.go 프로젝트: deepzz0/goblog
func (this *BlogrollController) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	flag := this.GetString("flag")
	log.Debugf("flag=%s", flag)
	switch flag {
	case "save":
		this.saveBlogroll(resp)
	case "modify":
		this.getBlogroll(resp)
	case "delete":
		this.doDelete(resp)
	default:
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "参数错误|未知的flag标志。"}
	}
}
예제 #5
0
파일: sysconfig.go 프로젝트: deepzz0/goblog
func (this *SysconfigController) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	flag := this.GetString("flag")
	log.Debugf("flag = %s", flag)
	switch flag {
	case "deleteverify":
		this.deleteVerify(resp)
	case "addverify":
		this.addVerify(resp)
	case "updatesitemap":
		this.updateSitemap(resp)
	case "getsitemap":
		this.getSitemap(resp)
	default:
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "参数错误|未知的flag标志。"}
	}
}
예제 #6
0
파일: topics.go 프로젝트: deepzz0/goblog
func (this *TopicsController) saveTopic(resp *helper.Response) {
	operate := this.GetString("operate")
	if operate == "" {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|操作类型错误。"}
		return
	}
	title := this.GetString("title")
	content := this.GetString("content")
	cat := this.GetString("cat")
	tags := this.GetString("tags")
	if title == "" || content == "" || cat == "" {
		log.Debugf("%s,%s,%s,%s, %s", title, content, cat, tags, operate)
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|请检查是否填写完整。"}
		return
	}
	if operate == "new" {
		topic := models.NewTopic()
		if strings.HasSuffix(title, "TAG:aboutme") {
			topic.ID = 1
			topic.Title = strings.Split(title, "-")[0]
		} else {
			if topic.ID == 1 {
				topic.ID = models.NextVal()
			}
			topic.Title = title
		}
		topic.Content = content
		if category := models.Blogger.GetCategoryByID(cat); category == nil {
			resp.Status = RS.RS_failed
			resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|查找不到该分类。"}
			return
		} else {
			topic.CategoryID = category.ID
		}
		if tags == "" {
			topic.TagIDs = make([]string, 0)
		} else {
			sliceTags := strings.Split(tags, ",")
			for _, tag := range sliceTags {
				topic.TagIDs = append(topic.TagIDs, tag)
			}
		}
		if err := models.TMgr.AddTopic(topic); err != nil {
			resp.Status = RS.RS_failed
			resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|" + err.Error()}
			return
		}
	} else {
		id, err := strconv.Atoi(operate)
		if err != nil {
			resp.Status = RS.RS_failed
			resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|修改文章ID解析失败。"}
			return
		}
		if t := models.TMgr.GetTopic(int32(id)); t == nil {
			resp.Status = RS.RS_failed
			resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|系统查找不到该文章ID。"}
			return
		} else {
			t.Title = title
			t.Content = content
			if err := models.TMgr.ModTopic(t, cat, tags); err != nil {
				resp.Status = RS.RS_failed
				resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|" + err.Error()}
				return
			}
		}
	}
}