public ActionResult <object> Post([FromBody] sys_userVM model) { sys_user_Entity entity = model.ConvertToT <sys_user_Entity>(); this.SetCreateUserInfo(entity); return(this._repository.Insert(entity).ResponseSuccess()); }
/// <summary> /// 修改 /// <summary> public bool Update(sys_user_Entity model) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic["User_ID"] = model.User_ID; if (model.Password != null) { dic["Password"] = model.Password; } if (model.User_Name != null) { dic["User_Name"] = model.User_Name; } if (model.User_Status != null && model.User_Status.HasValue) { dic["User_Status"] = model.User_Status; } if (model.Update_UserId != null) { dic["Update_UserId"] = model.Update_UserId; } if (model.Update_User != null) { dic["Update_User"] = model.Update_User; } return(SQLHelperFactory.Instance.ExecuteNonQuery("Update_sys_user", dic) > 0); }
public ActionResult <object> GetList([FromBody] sys_userVM model, int pageindex, int pagesize) { sys_user_Entity entity = model.ConvertToT <sys_user_Entity>(); var(list, total) = this._repository.GetList(entity, pageindex, pagesize); return(list.ResponseSuccess("", total)); }
public ActionResult <object> Delete(int User_ID) { sys_user_Entity entity = new sys_user_Entity(); this.SetUpdateUserInfo(entity); this._repository.Update(entity); return(this._repository.Delete(User_ID).ResponseSuccess()); }
public ActionResult <object> UpdateUserPassword([FromBody] sys_userVM model) { sys_user_Entity entity = this.GetLoginUser(); this.SetUpdateUserInfo(entity); entity.Password = model.Password; return(this._repository.Update(entity).ResponseSuccess()); }
public ActionResult <object> Login([FromBody] LoginVM model) { LoginVM login = new LoginVM(); sys_user_Entity user = this._repository.GetUserByAccount(model.User_Account); if (user == null || !model.Password.Equals(user.Password)) { return(login.ResponseNotLogin("登录失败")); } user.Password = ""; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(this._configuration["JWT:SecurityKey"])); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var claims = new[] { new Claim(ClaimTypes.Name, user.ToJson()) }; var authTime = DateTime.UtcNow; var expiresAt = authTime.AddDays(7); var token = new JwtSecurityToken(issuer: "*", audience: "*", claims: claims, expires: expiresAt, signingCredentials: creds); login.token = Constant.JwtTokenPrefix + new JwtSecurityTokenHandler().WriteToken(token); //HttpContext.Session.SetString(login.token, user.ToJson()); return(login.ResponseSuccess()); }
/// <summary> /// 获取列表 /// <summary> public (IEnumerable <sys_user_Entity>, int) GetList(sys_user_Entity model, int pageindex, int pagesize) { Dictionary <string, object> dic = new Dictionary <string, object>(); if (model.User_ID != 0) { dic["User_ID"] = model.User_ID; } if (model.User_Account != null) { dic["User_Account"] = model.User_Account; } if (model.Password != null) { dic["Password"] = model.Password; } if (model.User_Name != null) { dic["User_Name"] = model.User_Name; } if (model.User_Status != null && model.User_Status.HasValue) { dic["User_Status"] = model.User_Status; } if (pageindex >= 0) { dic["StartIndex"] = pageindex <= 1 ? 0 : (pageindex - 1) * pagesize; } if (pagesize > 0) { dic["SelectCount"] = pagesize; } var list = SQLHelperFactory.Instance.QueryMultipleByPage <sys_user_Entity>("Select_sys_user_List", dic, out int total); return(list, total); }