增加 新版本登录请求
This commit is contained in:
1 parent
afeb7e5d90
commit
b28940c02d
10 files changed
+865
-592
No files matched your search
@@ -1,14 +1,11 @@
|
||||
using AllBase;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.Result;
|
||||
using AllBase.Model.Result.PDDResult;
|
||||
using AllBase.Model.Result;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Work.Store.Api;
|
||||
|
||||
namespace Work.Services;
|
||||
|
||||
@@ -17,17 +14,6 @@ namespace Work.Services;
|
||||
/// </summary>
|
||||
public class ImageCacheService
|
||||
{
|
||||
private static string ServerUrl = "http://103.90.155.78:9001";
|
||||
static ImageCacheService()
|
||||
{
|
||||
if (EnvironmentHelper.IsDevelopment)
|
||||
{
|
||||
ServerUrl = "http://localhost:14312";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取图片缓存
|
||||
/// </summary>
|
||||
@@ -37,10 +23,6 @@ public class ImageCacheService
|
||||
Dictionary<string, ImageCache> wxImgMapDic = new Dictionary<string, ImageCache>(StringComparer.OrdinalIgnoreCase);
|
||||
try
|
||||
{
|
||||
//if (EnvironmentHelper.IsProduction)
|
||||
//{
|
||||
// return wxImgMapDic;
|
||||
//}
|
||||
List<string> imageUrls = new List<string>();
|
||||
imageUrls.AddRange(product.detail.galleries.Where(g => g.type == 1).Take(9).Select(a => a.url));
|
||||
var temp_detailGalleries = product.detail.galleries.Where(g => g.type == 2).ToList();
|
||||
@@ -58,16 +40,11 @@ public class ImageCacheService
|
||||
|
||||
List<string> imageUrlMd5s = imageUrls.Select(a => BaseClass.GetMd5(a)).ToList();
|
||||
|
||||
var url = ServerUrl + "/api/ImageCache/GetImageCache";//获取缓存
|
||||
var html = GetHtml.PostJson(url, new { md5s = imageUrlMd5s });
|
||||
var ret = JsonConvert.DeserializeObject<Result<List<ImageCache>>>(html);
|
||||
if (ret.Code == 200)
|
||||
var caches = StoreApiClient.Instance.ImageCache.GetImageCaches(imageUrlMd5s);
|
||||
foreach (var item in caches)
|
||||
{
|
||||
foreach (var item in ret.Data)
|
||||
{
|
||||
item.IsCache = true;
|
||||
wxImgMapDic[item.Md5] = item;
|
||||
}
|
||||
item.IsCache = true;
|
||||
wxImgMapDic[item.Md5] = item;
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
@@ -86,38 +63,9 @@ public class ImageCacheService
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (EnvironmentHelper.IsProduction)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
var data = "";
|
||||
data = JsonHelper.SerializeObject(images.Where(a => a.IsCache == false).Select(a =>
|
||||
new
|
||||
{
|
||||
md5 = a.Md5,
|
||||
Platform = platform,
|
||||
PlatformUrl = a.PlatformUrl
|
||||
}
|
||||
));
|
||||
|
||||
var url = ServerUrl + "/api/ImageCache/AddOrUpdate";
|
||||
var html = GetHtml.PostJson(url, data);
|
||||
|
||||
|
||||
var ret = JsonConvert.DeserializeObject<Result<JToken>>(html);
|
||||
List<string> failed = new List<string>();
|
||||
if (ret.Code == 500)
|
||||
{
|
||||
if (ret.Data is JArray jArray)
|
||||
{
|
||||
failed = jArray.ToObject<List<string>>() ?? new List<string>();
|
||||
}
|
||||
else if (ret.Data is JValue jValue && jValue.Value is string str)
|
||||
{
|
||||
failed.Add(str);
|
||||
}
|
||||
}
|
||||
foreach (ImageCache item in images)
|
||||
var pending = images.Where(image => !image.IsCache).ToList();
|
||||
var failed = StoreApiClient.Instance.ImageCache.SaveImageCaches((int)platform, pending);
|
||||
foreach (var item in pending)
|
||||
{
|
||||
item.IsCache = !failed.Contains(item.Md5, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user