Ejemplo n.º 1
0
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
		}
	}
}
Ejemplo n.º 2
0
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)
}
Ejemplo n.º 3
0
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标志。"}
	}
}
Ejemplo n.º 4
0
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标志。"}
	}
}
Ejemplo n.º 5
0
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标志。"}
	}
}
Ejemplo n.º 6
0
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
			}
		}
	}
}