func (c Tasks) TaskOperate(id string, task models.Task) revel.Result { group := models.SelectTaskGroupListByUserId(c.SessionGetUser().UserId) if c.IsGet() { if id != "" { if task = models.SelectTaskOneById(id); task.TaskId == "" { return c.ErrDataBase(MsgSeleteError) } return c.Render(task, group) } return c.Render(group) } else { if task.TaskId != "" { task.ValidateUpdate(c.Validation) if c.Validation.HasErrors() { return c.Render(task, group) } if !models.UpdateTaskOne(&task) { return c.ErrDataBase(MsgUpdateError) } } else { task.UserId = c.SessionGetUser().UserId task.ValidateInsert(c.Validation) if c.Validation.HasErrors() { return c.Render(task, group) } if err := models.DBMap().Insert(&task); err != nil { return c.ErrDataBase(MsgInsertError) } } return c.Redirect(routes.Tasks.TaskList(task.GroupId)) } }
func (c Tasks) GroupList() revel.Result { user := c.SessionGetUser() taskGroups := models.SelectTaskGroupListByUserId(user.UserId) return c.Render(taskGroups) }