/// <summary> /// 新增用户信息 /// </summary> /// <param name="user"></param> /// <param name="id"></param> /// <returns></returns> public bool AddUserInfo(T_Sys_User user, out string msg) { msg = string.Empty; //检验该账户是否已存在 var existUser = Db.Select<T_Sys_User>() .Where(i => i.Account.Equals(user.Account, StringComparison.CurrentCultureIgnoreCase)).First(); if (existUser != null) { msg = "该账号已存在!"; return false; } //密码MD5加密 user.Password = EncryptHelper.MD5Encrypt(user.Password); user.CreateTime = DateTime.Now; user.UpdateTime = DateTime.Now; long id = Db.Insert<T_Sys_User>(user).ExecuteIdentity(); if (id <= 0) { msg = "新增用户失败,请联系系统管理员!"; return false; } //写入缓存 using (RedisHashService service = new RedisHashService()) { user.Id = id; service.StoreAsHash(user); } return true; }
public ActionResult ModifyPassword(T_Sys_User user) { Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("success", true); string oldPassword = Request.Form["OldPassword"].ToString().Trim(); string newPassowrd = Request.Form["NewPassowrd"].ToString().Trim(); string newPassword2 = Request.Form["NewPassword2"].ToString().Trim(); var resultUser = _userService.GetModel(o => o.F_Id == user.F_Id && o.F_Password == oldPassword); if (resultUser == null) { result["success"] = false; result.Add("msg", "原始密码不正确!"); } else if (!newPassowrd.Equals(newPassword2)) { result["success"] = false; result.Add("msg", "输入两次密码不一致!"); } else { resultUser.F_Password = newPassword2; int b = _userService.Update(resultUser); if (b == 0) { result["success"] = false; result.Add("msg", "密码修改失败!"); } } return(Json(result)); }
public IActionResult AddUserInfo(string sUserInfo) { T_Sys_User userInfo = JsonConvert.DeserializeObject <T_Sys_User>(sUserInfo); if (userInfo == null) { return(new JsonResult(new ReturnResultModel() { StatusCode = 200, Status = ReturnStatus.Fail, Msg = "传入数据格式不正确,请检查数据是否正确" })); } if (_user.AddUserInfo(userInfo, out string msg)) { return(new JsonResult(new ReturnResultModel() { StatusCode = 200, Status = ReturnStatus.Success, Msg = "添加成功" })); } return(new JsonResult(new ReturnResultModel() { StatusCode = 200, Status = ReturnStatus.Fail, Msg = msg })); }
public IActionResult GetUserInfoById(long id) { if (id == 0) { return(new JsonResult(new ReturnResultModel() { StatusCode = 200, Status = ReturnStatus.Fail, Msg = "传入的Id不可为空" })); } T_Sys_User userInfo = _user.GetUserInfoById(id); if (userInfo == null) { return(new JsonResult(new ReturnResultModel() { StatusCode = 200, Status = ReturnStatus.Success, Msg = "查询结果为空" })); } return(new JsonResult(JsonConvert.SerializeObject(new ReturnResultModel() { StatusCode = 200, Status = ReturnStatus.Success, Data = userInfo, Msg = "" }))); }
/// <summary> /// 用户登录 /// </summary> /// <param name="account"></param> /// <param name="password"></param> /// <param name="userInfo"></param> /// <returns></returns> public bool UserLogin(string account, string password, out T_Sys_User userInfo) { string encryptPassword = EncryptHelper.MD5Encrypt(password); userInfo = Db.Select<T_Sys_User>().Where(i => i.Account == account && i.Password.Equals(encryptPassword, StringComparison.CurrentCultureIgnoreCase) && i.Status.Equals("1")) .ToList() .FirstOrDefault(); return userInfo != null ? true : false; }
public ActionResult Edit(T_Sys_User user) { Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("success", true); if (string.IsNullOrEmpty(user.F_Account)) { result["success"] = false; result.Add("msg", "用户名不能为空!"); } else { int b = _userService.Update(user); if (b == 0) { result["success"] = false; result.Add("msg", "修改失败!"); } } return(Json(result)); }
/// <summary> /// 更新 /// </summary> /// <param name="entity"></param> /// <param name="isSave"></param> /// <returns></returns> public int Update(T_Sys_User entity, bool isSave = true) { return(_repository.Update(entity, isSave)); }
/// <summary> /// 插入 /// </summary> /// <param name="entity"></param> /// <param name="isSave"></param> /// <returns></returns> public int Insert(T_Sys_User entity, bool isSave = true) { return(_repository.Insert(entity, isSave)); }
public static T_Sys_User ToEntity(this UserViewModel userView, T_Sys_User user) { return(userView.MapTo <UserViewModel, T_Sys_User>(user)); }
public static UserViewModel ToModel(this T_Sys_User user) { return(user.MapTo <T_Sys_User, UserViewModel>()); }