comment system
This commit is contained in:
@@ -20,7 +20,7 @@ public class EventApiController : BaseController
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户相关所有符合条件的事件
|
||||
/// 获取符合条件的公共事件
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 请求示例:
|
||||
@@ -30,11 +30,13 @@ public class EventApiController : BaseController
|
||||
///
|
||||
/// 参数:
|
||||
///
|
||||
/// fid: int?
|
||||
/// eid: int?
|
||||
/// key: string?
|
||||
/// from: long?
|
||||
/// to: long?
|
||||
/// p: bool?
|
||||
/// size: int?
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="flowerId">花草唯一 id</param>
|
||||
@@ -43,8 +45,9 @@ public class EventApiController : BaseController
|
||||
/// <param name="from">起始日期</param>
|
||||
/// <param name="to">结束日期</param>
|
||||
/// <param name="includePhoto">是否包含图片</param>
|
||||
/// <returns>会话有效则返回符合条件的花草集</returns>
|
||||
/// <response code="200">返回符合条件的花草集</response>
|
||||
/// <param name="pageSize">分页大小</param>
|
||||
/// <returns>会话有效则返回符合条件的事件集</returns>
|
||||
/// <response code="200">返回符合条件的事件集</response>
|
||||
/// <response code="401">未找到登录会话或已过期</response>
|
||||
/// <response code="403">用户已禁用</response>
|
||||
/// <response code="404">未找到关联用户</response>
|
||||
@@ -62,7 +65,8 @@ public class EventApiController : BaseController
|
||||
[FromQuery] string? key,
|
||||
[FromQuery] long? from,
|
||||
[FromQuery] long? to,
|
||||
[FromQuery(Name = "p")] bool? includePhoto)
|
||||
[FromQuery(Name = "p")] bool? includePhoto,
|
||||
[FromQuery(Name = "size")] int? pageSize = 20)
|
||||
{
|
||||
var (result, user) = CheckPermission();
|
||||
if (result != null)
|
||||
@@ -76,21 +80,8 @@ public class EventApiController : BaseController
|
||||
|
||||
SaveDatabase();
|
||||
|
||||
var records = database.Records.Where(r => r.OwnerId == user.Id).Select(r => new RecordItem
|
||||
{
|
||||
Id = r.Id,
|
||||
OwnerId = r.OwnerId,
|
||||
ByUserId = r.ByUserId,
|
||||
DateUnixTime = r.DateUnixTime,
|
||||
EventId = r.EventId,
|
||||
FlowerId = r.FlowerId,
|
||||
IsHidden = r.IsHidden,
|
||||
Latitude = r.Latitude,
|
||||
Longitude = r.Longitude,
|
||||
Title = r.Title,
|
||||
Memo = r.Memo,
|
||||
ByUserName = string.IsNullOrEmpty(r.ByUserName) && r.ByUserId != null ? database.Users.Single(u => u.Id == r.ByUserId).Name : r.ByUserName
|
||||
});
|
||||
var records = database.Records.Where(r => r.IsHidden != true);
|
||||
|
||||
if (flowerId != null)
|
||||
{
|
||||
records = records.Where(r => r.FlowerId == flowerId);
|
||||
@@ -116,23 +107,48 @@ public class EventApiController : BaseController
|
||||
|
||||
if (includePhoto == true)
|
||||
{
|
||||
foreach (var r in records)
|
||||
{
|
||||
r.Photos = database.Photos.Where(p => p.RecordId == r.Id).ToList();
|
||||
foreach (var photo in r.Photos)
|
||||
{
|
||||
photo.Url = $"photo/flower/{r.FlowerId}/{photo.Path}?thumb=1";
|
||||
}
|
||||
}
|
||||
records = records.Include(r => r.Photos);
|
||||
}
|
||||
|
||||
records = records.Select(r => new RecordItem
|
||||
{
|
||||
Id = r.Id,
|
||||
OwnerId = r.OwnerId,
|
||||
ByUserId = r.ByUserId,
|
||||
DateUnixTime = r.DateUnixTime,
|
||||
EventId = r.EventId,
|
||||
FlowerId = r.FlowerId,
|
||||
IsHidden = r.IsHidden,
|
||||
Latitude = r.Latitude,
|
||||
Longitude = r.Longitude,
|
||||
Title = r.Title,
|
||||
Memo = r.Memo,
|
||||
ByUserName = string.IsNullOrEmpty(r.ByUserName) && r.ByUserId != null ? database.Users.Single(u => u.Id == r.ByUserId).Name : r.ByUserName,
|
||||
Photos = r.Photos,
|
||||
LikeCount = r.LikeCount,
|
||||
FavoriteCount = r.FavoriteCount,
|
||||
CommentCount = r.CommentCount
|
||||
});
|
||||
|
||||
var size = pageSize ?? 20;
|
||||
records = records.OrderByDescending(r => r.DateUnixTime).Take(size);
|
||||
|
||||
var array = records.ToArray();
|
||||
|
||||
foreach (var r in array)
|
||||
{
|
||||
if (string.IsNullOrEmpty(r.ByUserName))
|
||||
{
|
||||
r.ByUserName = user.Name;
|
||||
}
|
||||
if (r.Photos == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (var photo in r.Photos)
|
||||
{
|
||||
photo.Url = $"photo/flower/{r.FlowerId}/{photo.Path}?thumb=1";
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(array);
|
||||
@@ -306,7 +322,7 @@ public class EventApiController : BaseController
|
||||
/// 参数:
|
||||
///
|
||||
/// flowerId: 1
|
||||
/// eventId": 4 // 浇水
|
||||
/// eventId: 4 // 浇水
|
||||
/// byUser: "朋友"
|
||||
/// memo: "快干死了"
|
||||
/// lon: 29.5462794
|
||||
|
Reference in New Issue
Block a user