云商品增加分组
This commit is contained in:
1 parent
861732ab7f
commit
8a85c3365b
11 files changed
+622
-109
No files matched your search
@@ -9,6 +9,7 @@ using System.Linq;
|
||||
using Work.Store.Api;
|
||||
using System.Threading.Tasks;
|
||||
using Work.Api.Wx;
|
||||
using AllBase.Model;
|
||||
|
||||
namespace Work.Services
|
||||
{
|
||||
@@ -17,6 +18,23 @@ namespace Work.Services
|
||||
/// </summary>
|
||||
public class CloudGoodsService
|
||||
{
|
||||
public static List<UserFavoriteGroup> UserGroups { get; private set; }
|
||||
static CloudGoodsService()
|
||||
{
|
||||
GetGroups(BaseClass.UserName).ContinueWith(t =>
|
||||
{
|
||||
if (t.IsFaulted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (t.IsCanceled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UserGroups = t.Result;
|
||||
});
|
||||
}
|
||||
public static async Task<PageData<CloudGoods>> GetGoods(GoodsSearchRequest request)
|
||||
{
|
||||
return await StoreApiClient.Instance.CloudGoods.GetGoods(request);
|
||||
@@ -178,7 +196,10 @@ namespace Work.Services
|
||||
}
|
||||
logs.Add(new RecordViolationLogRequest
|
||||
{
|
||||
ShopId = shopId, GoodsId = item.GoodsId, ReasonId = reasonId, Action = ViolationLogAction.Report
|
||||
ShopId = shopId,
|
||||
GoodsId = item.GoodsId,
|
||||
ReasonId = reasonId,
|
||||
Action = ViolationLogAction.Report
|
||||
});
|
||||
}
|
||||
await TryRecordLogs(logs);
|
||||
@@ -351,7 +372,10 @@ namespace Work.Services
|
||||
}
|
||||
logs.AddRange(status.ReasonIds.Select(id => new RecordViolationLogRequest
|
||||
{
|
||||
ShopId = shopId, GoodsId = status.GoodsId, ReasonId = id, Action = action
|
||||
ShopId = shopId,
|
||||
GoodsId = status.GoodsId,
|
||||
ReasonId = id,
|
||||
Action = action
|
||||
}));
|
||||
}
|
||||
await TryRecordLogs(logs).ConfigureAwait(false);
|
||||
@@ -409,6 +433,49 @@ namespace Work.Services
|
||||
}
|
||||
|
||||
#region user
|
||||
/// <summary>
|
||||
/// 创建分组
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="groupName"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> CreateGroup(string userName, string groupName)
|
||||
{
|
||||
bool ret = await StoreApiClient.Instance.CloudGoods.CreateGroup(userName, groupName);
|
||||
if (ret)
|
||||
{
|
||||
UserGroups = await GetGroups(userName);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public static async Task<bool> DelGroupAsync(string userName, string groupName)
|
||||
{
|
||||
bool ret = await StoreApiClient.Instance.CloudGoods.DelGroupAsync(userName, groupName);
|
||||
if (ret)
|
||||
{
|
||||
UserGroups = await GetGroups(userName);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public static async Task<bool> SetFavoriteGroupAsync(string userName, int groupId, IEnumerable<long> goodsIds)
|
||||
{
|
||||
bool ret = await StoreApiClient.Instance.CloudGoods.SetFavoriteGroupAsync(userName, groupId, goodsIds);
|
||||
if (ret)
|
||||
{
|
||||
UserGroups = await GetGroups(userName);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取分组
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<List<UserFavoriteGroup>> GetGroups(string userName)
|
||||
{
|
||||
return await StoreApiClient.Instance.CloudGoods.GetGroups(userName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索收藏
|
||||
/// </summary>
|
||||
@@ -423,7 +490,7 @@ namespace Work.Services
|
||||
{
|
||||
item.DetectionResult = item.IsSafe == null ? "未检测" : item.IsSafe.Value ? "安全" : "违规";
|
||||
}
|
||||
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -434,9 +501,9 @@ namespace Work.Services
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
|
||||
public static async Task<int> Favorite(List<long> goodsIds)
|
||||
public static async Task<int> Favorite(List<long> goodsIds, int groupId)
|
||||
{
|
||||
return await StoreApiClient.Instance.CloudGoods.Favorite(GetUserName(), goodsIds);
|
||||
return await StoreApiClient.Instance.CloudGoods.Favorite(GetUserName(), goodsIds, groupId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 取消收藏
|
||||
@@ -537,7 +604,10 @@ namespace Work.Services
|
||||
/// 标题(模糊搜索)
|
||||
/// </summary>
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 分组ID
|
||||
/// </summary>
|
||||
public int? GroupId { get; set; }
|
||||
/// <summary>
|
||||
/// 最低价格(元)
|
||||
/// </summary>
|
||||
@@ -663,6 +733,9 @@ namespace Work.Services
|
||||
/// </summary>
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public int GroupId { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
@@ -742,4 +815,10 @@ namespace Work.Services
|
||||
set => SetValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
public class UserFavoriteGroup
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -131,8 +131,10 @@ public sealed class ApiTransport
|
||||
private HttpItem CreateRequest(string route, MethodType method, object body,
|
||||
IDictionary<string, string> query, int timeoutMilliseconds)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(route) ||
|
||||
!Regex.IsMatch(route, @"\A[A-Za-z0-9_-]+(/[A-Za-z0-9_-]+)*\z"))
|
||||
string pathOnly = route?.Split('?', '#')[0];
|
||||
|
||||
if (string.IsNullOrWhiteSpace(pathOnly) ||
|
||||
!Regex.IsMatch(pathOnly, @"\A[A-Za-z0-9_-]+(/[A-Za-z0-9_-]+)*\z"))
|
||||
throw new ArgumentException("接口必须使用相对路由,例如 Auth/Login。", nameof(route));
|
||||
if (body != null) Validator.ValidateObject(body, new ValidationContext(body), true);
|
||||
if (timeoutMilliseconds <= 0) throw new ArgumentOutOfRangeException(nameof(timeoutMilliseconds));
|
||||
|
||||
@@ -49,14 +49,40 @@ public sealed class CloudGoodsApi
|
||||
public Task<PageData<CloudGoods>> SearchFavorites(UserFavoritesGoodsSearchRequest request)
|
||||
=> _transport.GetRequiredAsync<PageData<CloudGoods>>("CloudGoods/SearchFavorites", MethodType.Post, request);
|
||||
|
||||
public Task<int> Favorite(string userName, List<long> goodsIds)
|
||||
public Task<int> Favorite(string userName, List<long> goodsIds,int groupId)
|
||||
=> _transport.SendAsync<int>("CloudGoods/AddFavorite", MethodType.Post,
|
||||
new { UserName = userName, GoodsIds = goodsIds });
|
||||
new { UserName = userName, GoodsIds = goodsIds, GroupId= groupId });
|
||||
|
||||
public Task<int> RemoveFavorites(string userName, List<long> goodsIds)
|
||||
=> _transport.SendAsync<int>("CloudGoods/RemoveFavorites", MethodType.Post,
|
||||
new { UserName = userName, GoodsIds = goodsIds });
|
||||
|
||||
/// <summary>
|
||||
/// 创建分组
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="groupName"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> CreateGroup(string userName, string groupName)
|
||||
{
|
||||
return await _transport.SendAsync<bool>("CloudGoods/CreateGroup", MethodType.Post,
|
||||
new { UserName = userName, GroupName = groupName });
|
||||
}
|
||||
public async Task<bool> DelGroupAsync(string userName, string groupName)
|
||||
{
|
||||
return await _transport.SendAsync<bool>("CloudGoods/DelGroup", MethodType.Post,
|
||||
new { UserName = userName, GroupName = groupName });
|
||||
}
|
||||
public async Task<bool> SetFavoriteGroupAsync(string userName, int groupId, IEnumerable<long> goodsIds)
|
||||
{
|
||||
return await _transport.SendAsync<bool>("CloudGoods/SetFavoriteGroup", MethodType.Post,
|
||||
new { UserName = userName, GroupId = groupId, GoodsIds = goodsIds });
|
||||
}
|
||||
public async Task<List<UserFavoriteGroup>> GetGroups(string userName)
|
||||
{
|
||||
return await _transport.SendAsync<List<UserFavoriteGroup>>($"CloudGoods/GetGroups?UserName={userName}", MethodType.Post);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>识别上传图片中的文字和品牌 Logo。</summary>
|
||||
public async Task<List<string>> RecognizeAsync(string urlMd5, byte[] jpeg)
|
||||
|
||||
Reference in new issue
Block a user