/// <summary> /// web登录验证 /// </summary> /// <param name="query"></param> /// <returns></returns> public ReturnMsg Login(SysUsrMstrQuery query) { var rm = new ReturnMsg(); try { query.USR_NAME.Trim(); query.USR_PWD.Trim(); var isCheck = CheckLoginInfo(query, ref rm); if (!isCheck) { rm.code = 28600; rm.IsSuccess = false; return(rm); } query.USR_PWD = Encrypt.Md5Hash(query.USR_PWD); var userInfo = _sysUsrMstrRepository.FirstOrDefault(c => c.USR_NAME == query.USR_NAME && c.USR_PWD == query.USR_PWD && c.USR_STATUS == 1 && c.DEL_FLAG == 1); if (userInfo != null && userInfo.Id > 0) { var tree = _sysNavTreeRepository.GetSysUsrMstrNavTree(userInfo.Id); var dic = new Dictionary <string, object>(); dic.Add("UserInfo", userInfo); dic.Add("NavTree", tree); rm.code = 28000; rm.IsSuccess = true; rm.msg = "登录成功"; rm.result = JsonConvert.SerializeObject(dic); return(rm); } else { rm.code = 28600; rm.IsSuccess = false; rm.msg = "用户名或密码错误"; return(rm); } } catch (Exception ex) { rm.code = 28600; rm.IsSuccess = false; rm.msg = ex.Message; return(rm); } }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="userId"></param> /// <returns></returns> public SysUsrMstr GetUserInfo(string userId) { var user = new SysUsrMstr(); if (decimal.TryParse(userId, out var result)) { user = _sysUsrMstrRepository.FirstOrDefault(c => c.Id == result && c.DEL_FLAG == 1 && c.USR_STATUS == 1); if (user == null) { user = _sysUsrMstrRepository.FirstOrDefault(c => c.ERP_EMP_ID == userId && c.DEL_FLAG == 1 && c.USR_STATUS == 1); } } else { user = _sysUsrMstrRepository.FirstOrDefault(c => c.ERP_EMP_ID == userId && c.DEL_FLAG == 1 && c.USR_STATUS == 1); } return(user); }
public ActionResult GetSysUsrInfo(decimal userId) { try { if (userId == 0) { return(Fail("数据传输异常")); } var result = _sysUsrMstrRepository.FirstOrDefault(c => c.Id == userId && c.DEL_FLAG == 1).ToDto(); return(Success("获取成功", result)); } catch (Exception ex) { return(Fail(ex.Message)); } }