public static UserInfoType BuildUserInfo(UserInfoEntity userInfo, RequestHead head, int count = 3) { if (userInfo == null) { return(null); } var result = new UserInfoType { UId = userInfo.UId, Platform = userInfo.Platform, OpenId = userInfo.OpenId, Gender = userInfo.Gender, Latitude = userInfo.Latitude, UserType = userInfo.UserType, Longitude = userInfo.Longitude, NickName = userInfo.NickName, Portrait = userInfo.Portrait, Signature = userInfo.Signature, IsRegister = userInfo.IsRegister, TagList = new List <TagItem>() }; if (head.UId == userInfo.UId) { result.NickName = string.Format("{0}(我)", result.NickName); } if (userInfo.Gender == GenderEnum.Man) { result.GenderIcon = CommonConst.Man_GenderIcon; result.GenderColor = CommonConst.Color_Man_GenderIcon; } if (userInfo.Gender == GenderEnum.Woman) { result.GenderIcon = CommonConst.WoMan_GenderIcon; result.GenderColor = CommonConst.Color_WoMan_GenderIcon; } var distance = LocationHelper.GetDistanceDesc(userInfo.Latitude, userInfo.Longitude, head.Latitude, head.Longitude); if (!string.IsNullOrEmpty(distance)) { result.TagList.Add(new TagItem() { Type = TagTypeEnum.LocationInfo, Content = distance, Index = 1 }); } if (!userInfo.SchoolName.IsNullOrEmpty()) { AddTag(result.TagList, TagTypeEnum.Default, userInfo.SchoolName, 3); } if (userInfo.BirthDate.HasValue && userInfo.BirthDate.Value > Convert.ToDateTime("1990-01-01")) { AddTag(result.TagList, TagTypeEnum.AgeGrade, userInfo.BirthDate.GetAgeYear(), 2); AddTag(result.TagList, TagTypeEnum.Constellation, userInfo.BirthDate.GetConstellation(), 4); } AddTag(result.TagList, TagTypeEnum.Default, GetLocationInfo(userInfo), 5); if (result.TagList.Count > count) { result.TagList = result.TagList.OrderBy(a => a.Index).Take(count).ToList(); } return(result); }