Exemple #1
0
func (c PJ) Edit(inputDay string) revel.Result {
	common.WriteLogStr("Top", "PushEditButton", "Start", "startDay = "+inputDay)
	startDay := common.ConvertStrToDay(inputDay)

	// 該当の進捗情報取得
	report := services.GetReport(c.Connected().Id, startDay)

	if report == nil {
		// 前回の進捗を取得
		lastDay := startDay.AddDate(0, 0, -7)
		lastReport := services.GetReport(c.Connected().Id, lastDay)

		// 取得できた場合は、情報をセット
		if lastReport != nil {
			report = c.setLastReport(lastReport)
		}

		fmt.Print("------- Report.Kotei => " + report.Kotei)
	}

	// 日付設定
	days := c.setDays(startDay)

	common.WriteLogStr("Top", "PushEditButton", "End", "startDay = "+startDay.Format(constant.STR_TYPE_LAYOUT))
	return c.Render(report, days, inputDay)
}
Exemple #2
0
func (c PJ) Register(inputDay string, report models.Report) revel.Result {

	startDay := common.ConvertStrToDay(inputDay)
	fmt.Println("====inputDay ->  " + inputDay)

	// 曜日チェック
	if startDay.Weekday() != 1 {
		fmt.Println("===曜日チェックエラー!!!===")
	}

	// 該当の進捗情報取得
	userId := c.Connected().Id
	getReport := services.GetReport(userId, startDay)

	if getReport == nil {
		// 登録処理
		fmt.Println("===登録処理===")
		fmt.Println("koutei => " + report.Kotei + "  hokoku => " + report.Hokoku)
		services.InsertReport(userId, inputDay, report)

	} else {
		// 更新処理
		fmt.Println("===更新処理===")
		services.UpdateReport(getReport.Id, userId, inputDay, report)
	}

	// 日にち設定
	days := c.setDays(startDay)

	return c.Render(report, days)

}