func (c Users) Operate(id string, user models.User) revel.Result { if c.IsGet() { if id != "" { if user = models.SelectUserOneByUserId(id); user.UserId == "" { return c.ErrDataBase(MsgSeleteError) } return c.Render(user) } return c.Render() } else { if user.UserId != "" { user.ValidateUpdate(c.Validation) if c.Validation.HasErrors() { return c.Render(user) } if !models.UpdateUserOne(&user) { return c.ErrDataBase(MsgUpdateError) } } else { user.ValidateInsert(c.Validation) if c.Validation.HasErrors() { return c.Render(user) } if !models.InsertUserOne(&user) { return c.ErrDataBase(MsgInsertError) } } return c.Redirect(routes.Users.List()) } }
func (c *Super) SessionSetUser(user models.User) { c.Session[LOGIN_USERID] = user.UserId c.Session[LOGIN_USERNAME] = user.Username c.Session[LOGIN_USERROLE] = user.GetRole() }