コード例 #1
0
ファイル: day.go プロジェクト: tangseng/gtt
func (this *DayController) Add() {
	this.info = &map[string]string{
		"post": "所有信息必须填写",
		"day":  "添加今天的工作内容失败(day)",
		"work": "添加今天的工作内容失败(work)",
		"plan": "没有这个工作计划",
		"err":  "操作失败",
		"ok":   "操作成功",
	}
	this.prefixInit()
	content := this.GetString("content")
	startTime, _ := this.GetInt("startTime")
	endTime, _ := this.GetInt("endTime")
	status, _ := this.GetInt8("status")
	planId, _ := this.GetInt("planId")
	appId, _ := this.GetInt("appId")
	if len(content) == 0 || startTime == 0 || endTime == 0 || status == 0 {
		this.error("post")
		return
	}
	if planId != 0 {
		planOption := models.NewPlanOption()
		plan, err := planOption.Read(planId)
		if err != nil {
			this.error("plan")
			return
		}
		plan.Status = status
		if plan.Status == 100 {
			plan.RealTime = this.Today.Unix()
		}
		planOption.Update(plan)
	}
	dayOption := models.NewDayOption()
	day, err := dayOption.ReadDay(this.user.Id, this.Y, this.M, this.D)
	if err != nil {
		day = models.NewDay(this.user.Id, this.Y, this.M, this.D)
		_, err = dayOption.Insert(day)
		if err != nil {
			this.error("day")
			return
		}
	}
	workid, err := dayOption.InsertWork(models.NewDayWork(content, startTime, endTime, status, day, planId))
	if err != nil {
		this.error("work")
		return
	}
	if appId > 0 {
		models.NewAppOption().Insert(models.NewApp(this.user.Id, appId, content))
	}
	this.success(map[string]interface{}{"id": workid})
}
コード例 #2
0
ファイル: app.go プロジェクト: tangseng/gtt
func (this *AppController) Add() {
	if !this.check() {
		return
	}
	this.info = &map[string]string{
		"post": "内容必须填写",
		"err":  "操作失败",
		"ok":   "操作成功",
	}
	appid, _ := this.GetInt("appid")
	desc := this.GetString("desc")
	if len(desc) == 0 {
		this.error("post")
		return
	}
	id, err := models.NewAppOption().Insert(models.NewApp(this.user.Id, appid, desc))
	if err != nil {
		this.error("err")
		return
	}
	this.success(map[string]interface{}{"id": id})
}
コード例 #3
0
ファイル: app.go プロジェクト: tangseng/gtt
func (this *AppController) get(appid, page, offset int) ([]models.App, map[string]string) {
	logs := models.NewAppOption().ReadMore(appid, offset, page)
	pids := make([]int, 0)
	pidsCheck := make(map[string]bool)
	for _, tb := range logs {
		if tb.Uid != -1 {
			if _, ok := pidsCheck[strconv.Itoa(tb.Uid)]; !ok {
				pidsCheck[strconv.Itoa(tb.Uid)] = true
				pids = append(pids, tb.Uid)
			}
		}
	}
	outPersons := make(map[string]string)
	if len(pids) > 0 {
		persons := models.NewPersonOption().ReadByIds(pids)
		for _, person := range persons {
			outPersons[strconv.Itoa(person.Id)] = person.Name
		}
	}
	if len(outPersons) > 0 {
		outPersons["-1"] = "管理员"
	}
	return logs, outPersons
}