懒得勤快 %!s(int64=4) %!d(string=hai) anos
pai
achega
b2a8f29396

+ 0 - 2
src/Masuit.MyBlogs.Core/Controllers/AdvertisementController.cs

@@ -63,8 +63,6 @@ namespace Masuit.MyBlogs.Core.Controllers
             foreach (var ad in list.Data.Where(ad => !string.IsNullOrEmpty(ad.CategoryIds)))
             {
                 ad.CategoryNames = JiebaNet.Segmenter.Common.Extensions.Join(ad.CategoryIds.Split(",").Select(c => dic.GetValueOrDefault(c)), ",");
-                ad.CreateTime = ad.CreateTime.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
-                ad.UpdateTime = ad.UpdateTime.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
             }
 
             return Ok(list);

+ 1 - 8
src/Masuit.MyBlogs.Core/Controllers/LoginController.cs

@@ -1,7 +1,5 @@
-using Masuit.MyBlogs.Core.Common;
-using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
+using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.ViewModel;
-using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Threading.Tasks;
@@ -30,11 +28,6 @@ namespace Masuit.MyBlogs.Core.Controllers
         {
             var time = DateTime.Now.AddMonths(-1);
             var list = await LoginRecordService.GetQueryFromCacheAsync<DateTime, LoginRecordViewModel>(r => r.UserInfoId == id && r.LoginTime >= time, r => r.LoginTime, false);
-            foreach (var item in list)
-            {
-                item.LoginTime = item.LoginTime.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
-            }
-
             return ResultData(list);
         }
     }

+ 33 - 8
src/Masuit.MyBlogs.Core/Controllers/ToolsController.cs

@@ -97,7 +97,21 @@ namespace Masuit.MyBlogs.Core.Controllers
                 var r = new Random();
                 ip = $"{r.Next(210)}.{r.Next(255)}.{r.Next(255)}.{r.Next(255)}";
 #endif
-                var address = await ip.GetPhysicsAddressInfo();
+                var location = Policy<CityResponse>.Handle<AddressNotFoundException>().Fallback(() => new CityResponse()).Execute(() => CommonHelper.MaxmindReader.City(ip));
+                var address = await ip.GetPhysicsAddressInfo() ?? new PhysicsAddress()
+                {
+                    Status = 0,
+                    AddressResult = new AddressResult()
+                    {
+                        AddressComponent = new AddressComponent(),
+                        FormattedAddress = ip.GetIPLocation(),
+                        Location = new Location()
+                        {
+                            Lng = location.Location.Longitude ?? 0,
+                            Lat = location.Location.Latitude ?? 0
+                        }
+                    }
+                };
                 return View(address);
             }
 
@@ -129,17 +143,28 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Random r = new Random();
                 ip = $"{r.Next(210)}.{r.Next(255)}.{r.Next(255)}.{r.Next(255)}";
 #endif
-                var address = await ip.GetPhysicsAddressInfo();
-                if (address?.Status == 0)
+                var location = Policy<CityResponse>.Handle<AddressNotFoundException>().Fallback(() => new CityResponse()).Execute(() => CommonHelper.MaxmindReader.City(ip));
+                var address = await ip.GetPhysicsAddressInfo() ?? new PhysicsAddress()
                 {
-                    ViewBag.Address = address.AddressResult.FormattedAddress;
-                    if (Request.Method.Equals(HttpMethods.Get))
+                    Status = 0,
+                    AddressResult = new AddressResult()
                     {
-                        return View(address.AddressResult.Location);
+                        AddressComponent = new AddressComponent(),
+                        FormattedAddress = ip.GetIPLocation(),
+                        Location = new Location()
+                        {
+                            Lng = location.Location.Longitude ?? 0,
+                            Lat = location.Location.Latitude ?? 0
+                        }
                     }
-
-                    return Json(address.AddressResult.Location);
+                };
+                ViewBag.Address = address.AddressResult.FormattedAddress;
+                if (Request.Method.Equals(HttpMethods.Get))
+                {
+                    return View(address.AddressResult.Location);
                 }
+
+                return Json(address.AddressResult.Location);
             }
 
             ViewBag.Address = addr;