云端数据 增加收藏

增加云端收藏列表
This commit is contained in:
chfei committed 2026-10-14 17:20:12 +08:00
1 parent 00f4aa2f64
commit 6e6ba151da
10 files changed
+1974 -548

No files matched your search

+81 -5
View File
@@ -1,4 +1,5 @@
using AllBase;
using AllBase.Helper;
using AllBase.Model.Result;
using Newtonsoft.Json;
using System;
@@ -14,11 +15,17 @@ namespace Work.Services
/// </summary>
public class CloudGoodsService
{
private const string ServerUrl = "http://103.90.155.78:14312";
private static string ServerUrl = "http://103.90.155.78:9001";
static CloudGoodsService()
{
if (EnvironmentHelper.IsDevelopment)
{
ServerUrl = "http://localhost:9001";
}
}
public static async Task<PageData<CloudGoods>> GetGoods(GoodsSearchRequest request)
{
string data = JsonHelper.SerializeObject(request);
var html = await GetHtml.PostUtf8Async(ServerUrl + "/Goods/SearchGoods", data, "application/json");
var html = await GetHtml.PostJsonAsync(ServerUrl + "/api/CloudGoods/SearchGoods", request);
var ret = JsonConvert.DeserializeObject<Result<PageData<CloudGoods>>>(html);
if (ret.Code != 200)
@@ -29,7 +36,7 @@ namespace Work.Services
}
public static string GetGoodsDetail(long goodsId)
{
var html = GetHtml.GetUtf8(ServerUrl + $"/Goods/GetGoodsRawData?goodsId={goodsId}", "application/json");
var html = GetHtml.PostJson(ServerUrl + $"/api/CloudGoods/GetGoodsRawData?goodsId={goodsId}", "");
var ret = JsonConvert.DeserializeObject<Result<string>>(html);
if (ret.Code != 200)
@@ -38,6 +45,72 @@ namespace Work.Services
}
return ret.Data;
}
#region user
/// <summary>
/// 搜索收藏
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static async Task<PageData<CloudGoods>> SearchFavorites(UserFavoritesGoodsSearchRequest request)
{
request.UserName = BaseClass.UserName;
var html = await GetHtml.PostJsonAsync(ServerUrl + "/api/CloudGoods/SearchFavorites", request);
var ret = JsonConvert.DeserializeObject<Result<PageData<CloudGoods>>>(html);
if (ret.Code != 200)
{
throw new Exception(ret.Msg);
}
return ret.Data;
}
/// <summary>
/// 收藏
/// </summary>
/// <param name="goodsIds"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static async Task<int> Favorite(List<long> goodsIds)
{
var html = await GetHtml.PostJsonAsync(ServerUrl + $"/api/CloudGoods/AddFavorite", new
{
UserName = BaseClass.UserName,
GoodsIds = goodsIds,
});
var ret = JsonConvert.DeserializeObject<Result<int>>(html);
if (ret.Code != 200)
{
throw new Exception(ret.Msg);
}
return ret.Data;
}
/// <summary>
/// 取消收藏
/// </summary>
/// <param name="goodsIds"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static async Task<int> RemoveFavorites(List<long> goodsIds)
{
var html = await GetHtml.PostJsonAsync(ServerUrl + $"/api/CloudGoods/RemoveFavorites", new
{
UserName = BaseClass.UserName,
GoodsIds = goodsIds,
});
var ret = JsonConvert.DeserializeObject<Result<int>>(html);
if (ret.Code != 200)
{
throw new Exception(ret.Msg);
}
return ret.Data;
}
#endregion
}
/// <summary>
/// 商品搜索请求
@@ -105,7 +178,10 @@ namespace Work.Services
public int PageSize { get; set; } = 20;
}
public class UserFavoritesGoodsSearchRequest : GoodsSearchRequest
{
public string UserName { get; set; }
}
/// <summary>
/// 商品搜索返回结果
/// </summary>