Beispiel #1
0
        /// <summary>
        /// 首页我的信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public GetMyInfoResponse GetMyInfo(int id)
        {
            GetMyInfoResponse result = null;

            using (var conn = DapperHelper.CreateConnection())
            {
                var users = conn.Query <TRightsUser, TRightsUserOrganization, TRightsOrganization, TRightsUserRole, TRightsRole, TRightsUser>(@"SELECT u.user_id AS UserId, u.user_name AS UserName, u.created_time AS CreatedTime,* 
                    FROM dbo.t_rights_user AS u
                    LEFT JOIN dbo.t_rights_user_organization AS userOrg ON u.id= userOrg.user_id
                    LEFT JOIN dbo.t_rights_organization AS org ON userOrg.organization_id= org.id
                    LEFT JOIN dbo.t_rights_user_role AS userRole ON u.id= userRole.user_id
                    LEFT JOIN dbo.t_rights_role AS r ON userRole.role_id= r.id
                    WHERE u.id= @Id;", (user, userOrg, org, userRole, role) =>
                {
                    user.Organization = org;
                    user.Role         = role;
                    return(user);
                }, new { @Id = id }).ToList();
                if (users.HasValue())
                {
                    result = new GetMyInfoResponse
                    {
                        UserId      = users.First().UserId,
                        UserName    = users.First().UserName,
                        CreatedTime = users.First().CreatedTime.ToString(DateTimeTypeConst.DATETIME),
                        RolesName   = users.First().Role != null?string.Join(",", users.Select(p => p.Role.Name).Distinct()) : "",
                                          DepartmentsName = users.First().Organization != null?string.Join(",", users.Select(p => p.Organization.Name).Distinct()) : ""
                    };
                }
            }

            return(result);
        }
Beispiel #2
0
        public ActionResult GetMyInfoPost()
        {
            var flag = false;
            var msg  = string.Empty;
            var data = new GetMyInfoResponse();

            var result = _accountService.GetMyInfo(base.loginInfo.Id);

            if (result.ReturnCode == ReturnCodeType.Success)
            {
                flag = true;
                data = result.Content;
            }
            else
            {
                msg = result.Message;
            }

            return(Json(new { success = flag, msg = msg, data = data }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 我的信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public GetMyInfoResponse GetMyInfo(int id)
        {
            var result = new GetMyInfoResponse();

            DBHelper.NoLockInvokeDB(() =>
            {
                using (var db = new WebFrameworksDB())
                {
                    var query = from emp in db.User
                                join empRole in db.UserRole on emp.Id equals empRole.UserId into aa
                                from empRole in aa.DefaultIfEmpty()
                                join role in db.Role on empRole.RoleId equals role.Id into bb
                                from role in bb.DefaultIfEmpty()
                                join empDepartment in db.UserDepartment on emp.Id equals empDepartment.UserId into cc
                                from empDepartment in cc.DefaultIfEmpty()
                                join depart in db.Department on empDepartment.DepartmentId equals depart.Id into dd
                                from depart in dd.DefaultIfEmpty()
                                where emp.Id == id
                                select new
                    {
                        UserId          = emp.UserId,
                        UserName        = emp.UserName,
                        CreatedTime     = emp.CreatedTime,
                        RolesName       = role.Name,
                        DepartmentsName = depart.Name
                    };
                    if (query != null && query.Count() > 0)
                    {
                        var list               = query.ToList();
                        result.UserId          = list[0].UserId;
                        result.UserName        = list[0].UserName;
                        result.CreatedTime     = list[0].CreatedTime.ToString(DateFormat.DATETIME);
                        result.RolesName       = string.Join(",", list.Select(p => p.RolesName));
                        result.DepartmentsName = string.Join(",", list.Select(p => p.DepartmentsName));
                    }
                }
            });

            return(result);
        }
        public ActionResult GetMyInfoPost()
        {
            var flag = false;
            var msg  = string.Empty;
            var data = new GetMyInfoResponse();

            using (var factory = new ChannelFactory <IWebFxsCommonService>("*"))
            {
                var client = factory.CreateChannel();
                var result = client.GetMyInfo(CurrentUserInfo.Id);
                if (result.ReturnCode == ReturnCodeType.Success)
                {
                    flag = true;
                    data = result.Content;
                }
                else
                {
                    msg = result.Message;
                }
            }

            return(Json(new { success = flag, msg = msg, data = data }, JsonRequestBehavior.AllowGet));
        }