comment system
This commit is contained in:
@@ -168,7 +168,7 @@ public class FlowerApiController : BaseController
|
||||
bool? includePhoto, double? latitude, double? longitude, int? distance,
|
||||
int? page = 0, int? pageSize = 20)
|
||||
{
|
||||
IEnumerable<FlowerItem> flowers;
|
||||
IQueryable<FlowerItem> flowers;
|
||||
if (userId != null)
|
||||
{
|
||||
flowers = database.Flowers.Where(f => f.OwnerId == userId);
|
||||
@@ -210,9 +210,17 @@ public class FlowerApiController : BaseController
|
||||
flowers = flowers.Where(f => database.Records.Any(r => r.FlowerId == f.Id && r.EventId == eventId));
|
||||
}
|
||||
|
||||
if (includePhoto == true)
|
||||
{
|
||||
flowers = flowers.Include(f => f.Photos);
|
||||
}
|
||||
|
||||
flowers = flowers.OrderByDescending(f => f.DateBuyUnixTime);
|
||||
|
||||
IEnumerable<FlowerItem> items;
|
||||
if (distance != null && latitude != null && longitude != null)
|
||||
{
|
||||
flowers = flowers.Where(f => f.Latitude != null && f.Longitude != null)
|
||||
items = flowers.Where(f => f.Latitude != null && f.Longitude != null)
|
||||
.AsEnumerable()
|
||||
.Where(f =>
|
||||
{
|
||||
@@ -221,18 +229,26 @@ public class FlowerApiController : BaseController
|
||||
return d <= distance;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
items = flowers;
|
||||
}
|
||||
|
||||
int count = flowers.Count();
|
||||
int count = items.Count();
|
||||
|
||||
var size = pageSize ?? 20;
|
||||
var p = page ?? 0;
|
||||
flowers = flowers.OrderByDescending(f => f.DateBuyUnixTime).Skip(p * size).Take(size);
|
||||
items = items.Skip(p * size).Take(size);
|
||||
|
||||
if (includePhoto == true)
|
||||
{
|
||||
foreach (var f in flowers)
|
||||
foreach (var f in items)
|
||||
{
|
||||
f.Photos = database.Photos.Where(p => p.FlowerId == f.Id && p.RecordId == null).ToList();
|
||||
//f.Photos = database.Photos.Where(p => p.FlowerId == f.Id && p.RecordId == null).ToList();
|
||||
if (f.Photos == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (var photo in f.Photos)
|
||||
{
|
||||
photo.Url = $"photo/flower/{f.Id}/{photo.Path}?thumb=1";
|
||||
@@ -242,7 +258,7 @@ public class FlowerApiController : BaseController
|
||||
|
||||
return new()
|
||||
{
|
||||
Flowers = flowers.ToArray(),
|
||||
Flowers = items.ToArray(),
|
||||
Count = count
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user