/// <summary> /// 添加用户 /// </summary> /// <param name="userInfo">前端用户信息</param> /// <returns>OK</returns> public ActionResult Add(UserInfoRoleInfo userInfoRoleInfo) { var uCode = UserInfoService.GetEntities(u => (u.UCode == userInfoRoleInfo.UCode && u.IsDeleted == false)).FirstOrDefault(); if (uCode == null) { UserInfo userInfo = new UserInfo { UCode = userInfoRoleInfo.UCode, UName = userInfoRoleInfo.UName, Pwd = userInfoRoleInfo.Pwd.ToMD5(), //MD5加密 StatusFlag = userInfoRoleInfo.StatusFlag, Remark = userInfoRoleInfo.Remark, SubTime = DateTime.Now }; int insertedUserId = UserInfoService.Add(userInfo).Id; int roleId = userInfoRoleInfo.RId; //设置用户角色 R_UserInfo_RoleInfoService.ProcessSetRole(insertedUserId, roleId); //写操作日志 OperationLogService.Add("添加员工", "系统管理", LoginInfo, userInfoRoleInfo.UName, ""); return(Content("Ok")); } else { return(Content("fail")); } }
/// <summary> /// 查询用户详细信息 /// </summary> /// <param name="uName"></param> /// <returns></returns> public UserInfoRoleInfo GetUserDetailInfo(string uName) { var temp = DbSession.UserInfoDal.GetEntities((u => u.IsDeleted == false && u.UName == uName)).FirstOrDefault(); var roleId = DbSession.R_UserInfo_RoleInfoDal.GetEntities(r => (r.UserInfoId == temp.Id && r.IsDeleted == false)).FirstOrDefault(); var roleName = DbSession.RoleInfoDal.GetEntities(r => (r.Id == roleId.RoleInfoId && r.IsDeleted == false)).FirstOrDefault(); var data = new UserInfoRoleInfo { Email = temp.Email, Gender = temp.Gender, Phone = temp.Phone, Picture = temp.Picture, Remark = temp.Remark, UCode = temp.UCode, UName = temp.UName, RoleName = roleName.RoleName }; return(data); }