Skip to content

Commit

Permalink
修复周年庆随机评语的范围错误的bug,周年庆游戏列表添加分页
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleFish-233 committed Jul 1, 2022
1 parent 9520c20 commit 8e7850a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,9 @@ public async Task<ActionResult<Result>> TempFunction()
try
{
var url1 = await _fileService.TransferDepositFile("https://image.cngal.org/images/2022/06/30/0fbc4950e06e.png");
var url2 = await _fileService.TransferDepositFile("https://image.cngal.org/images/2022/06/30/b3ad65f2b76a.png");
var url2 = await _fileService.TransferDepositFile("https://image.cngal.org/images/2022/07/01/9b627a822af1.png");
var url3 = await _fileService.TransferDepositFile("https://image.cngal.org/images/2022/07/01/ac2ebf501a9b.png");
var url4 = await _fileService.TransferDepositFile("https://image.cngal.org/images/2022/07/01/7c6a07dfec91.png");

return new Result { Successful = true };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,15 @@ public AnniversariesAPIController(IRepository<UserOnlineInfor, long> userOnlineI
_playedGameRepository = playedGameRepository;
}


static readonly DateTime before = new DateTime(2022, 5, 31);
static readonly DateTime after = new DateTime(2021, 5, 31);

[AllowAnonymous]
[HttpGet]
public async Task<ActionResult<List<JudgableGameViewModel>>> GetAllJudgableGamesAsync()
{
var before = new DateTime(2022, 5, 31);
var after = new DateTime(2021, 5, 31);


var games = await _entryRepository.GetAll().AsNoTracking()
.Include(s => s.PlayedGames)
Expand Down Expand Up @@ -222,12 +225,10 @@ public async Task<ActionResult<List<JudgableGameViewModel>>> GetAllJudgableGames
[HttpGet]
public async Task<ActionResult<List<PlayedGameUserScoreRandomModel>>> GetRandomUserScoresAsync()
{
var before = new DateTime(2022, 5, 31);
var after = new DateTime(2021, 5, 31);

var games = await _playedGameRepository.GetAll().AsNoTracking()
.Include(s => s.ApplicationUser)
.Include(s=>s.Entry)
.Where(s => s.Entry.PubulishTime != null && s.Entry.PubulishTime.Value.Date <= before.Date && s.Entry.PubulishTime.Value.Date >= after.Date)
.Where(s =>s.ShowPublicly && s.MusicSocre != 0 && s.PaintSocre != 0 && s.CVSocre != 0 && s.SystemSocre != 0 && s.ScriptSocre != 0 && s.TotalSocre != 0 && s.CVSocre != 0 && string.IsNullOrWhiteSpace(s.PlayImpressions)==false && s.PlayImpressions.Length > 100)
.ToListAsync();
var model = new List<PlayedGameUserScoreRandomModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Linq.Dynamic.Core;

namespace CnGalWebSite.APIServer.Controllers
{
Expand Down Expand Up @@ -562,7 +563,7 @@ public async Task<ActionResult<Result>> ProcAsync(Models.ExaminedViewModel model
examine.IsPassed = false;
examine = await _examineRepository.UpdateAsync(examine);
//修改以其为前置审核的审核状态
if (await _examineRepository.CountAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) != 0)
if (await _examineRepository.GetAll().AnyAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id))
{
var temp = _examineRepository.GetAll().Where(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id);
foreach (var item in temp)
Expand All @@ -589,7 +590,7 @@ public async Task<ActionResult<Result>> ProcAsync(Models.ExaminedViewModel model
if (examine.PrepositionExamineId == null || examine.PrepositionExamineId <= 0)
{
//查找是否有以此为前置审核的审核 如果有 则代表第一次创建
if (await _examineRepository.CountAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) != 0)
if (await _examineRepository.GetAll().AnyAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) )
{
await _messageRepository.InsertAsync(new Message
{
Expand All @@ -601,7 +602,6 @@ await _messageRepository.InsertAsync(new Message
Link = "articles/index/" + examine.Article.Id,
LinkTitle = article.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -617,7 +617,6 @@ await _messageRepository.InsertAsync(new Message
Link = "articles/index/" + article.Id,
LinkTitle = article.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -629,7 +628,7 @@ await _messageRepository.InsertAsync(new Message
if (examine.PrepositionExamineId == null || examine.PrepositionExamineId <= 0)
{
//查找是否有以此为前置审核的审核 如果有 则代表第一此创建
if (await _examineRepository.CountAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) != 0)
if (await _examineRepository.GetAll().AnyAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) )
{
await _messageRepository.InsertAsync(new Message
{
Expand All @@ -641,7 +640,6 @@ await _messageRepository.InsertAsync(new Message
Link = "entries/index/" + entry.Id,
LinkTitle = entry.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -657,7 +655,6 @@ await _messageRepository.InsertAsync(new Message
Link = "entries/index/" + entry.Id,
LinkTitle = entry.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -668,7 +665,7 @@ await _messageRepository.InsertAsync(new Message
if (examine.PrepositionExamineId == null || examine.PrepositionExamineId <= 0)
{
//查找是否有以此为前置审核的审核 如果有 则代表第一此创建
if (await _examineRepository.CountAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) != 0)
if (await _examineRepository.GetAll().AnyAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) )
{
await _messageRepository.InsertAsync(new Message
{
Expand All @@ -680,7 +677,6 @@ await _messageRepository.InsertAsync(new Message
Link = "peripheries/index/" + periphery.Id,
LinkTitle = periphery.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -696,7 +692,6 @@ await _messageRepository.InsertAsync(new Message
Link = "peripheries/index/" + periphery.Id,
LinkTitle = periphery.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -707,7 +702,7 @@ await _messageRepository.InsertAsync(new Message
if (examine.PrepositionExamineId == null || examine.PrepositionExamineId <= 0)
{
//查找是否有以此为前置审核的审核 如果有 则代表第一此创建
if (await _examineRepository.CountAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) != 0)
if (await _examineRepository.GetAll().AnyAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id))
{
await _messageRepository.InsertAsync(new Message
{
Expand All @@ -719,7 +714,6 @@ await _messageRepository.InsertAsync(new Message
Link = "disambigs/index/" + disambig.Id,
LinkTitle = disambig.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -735,7 +729,6 @@ await _messageRepository.InsertAsync(new Message
Link = "disambigs/index/" + disambig.Id,
LinkTitle = examine.Entry.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -746,7 +739,7 @@ await _messageRepository.InsertAsync(new Message
if (examine.PrepositionExamineId == null || examine.PrepositionExamineId <= 0)
{
//查找是否有以此为前置审核的审核 如果有 则代表第一此创建
if (await _examineRepository.CountAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) != 0)
if (await _examineRepository.GetAll().AnyAsync(s => s.IsPassed == null && s.PrepositionExamineId == examine.Id) )
{
await _messageRepository.InsertAsync(new Message
{
Expand All @@ -758,7 +751,6 @@ await _messageRepository.InsertAsync(new Message
Link = "tags/index/" + tag.Id,
LinkTitle = tag.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -774,7 +766,6 @@ await _messageRepository.InsertAsync(new Message
Link = "tags/index/" + tag.Id,
LinkTitle = tag.Name,
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -792,7 +783,6 @@ await _messageRepository.InsertAsync(new Message
Link = "",
LinkTitle = "",
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});
}
Expand All @@ -808,7 +798,6 @@ await _messageRepository.InsertAsync(new Message
Link = "home/examined/" + examine.Id,
LinkTitle = "" + examine.Id + "条审核记录",
Type = (examine.IsPassed ?? false) ? MessageType.ExaminePassed : MessageType.ExamineUnPassed,
ApplicationUser = user,
ApplicationUserId = user.Id
});

Expand Down
10 changes: 10 additions & 0 deletions CnGalWebSite/CnGalWebSite.DataModel/ViewModel/Theme/ThemeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,15 @@ public class AnniversariesSetting
public string SearchString { get; set; }
public JudgableGamesSortType SortType { get; set; }
public JudgableGamesDisplayType DisplayType { get; set; }

public int TabIndex { get; set; } = 1;

public int MaxCount { get; set; } = 24;

public int Count { get; set; }

public int TotalPages => (Count / MaxCount) + 1;

public int CurrentPage { get; set; } = 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
<div class="col-12 p-0 pt-2" style="display: flex; justify-content: flex-end;">
@if (string.IsNullOrWhiteSpace(Model.Link) == false)
{
<CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaButton Text="查看" OnClick="@(()=>NavigationManager.NavigateTo(Model.Link))" XSmall Class="me-3" />
<CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaButton Text="查看" OnClick="@(()=>NavigationManager.NavigateTo(Model.Link))" XSmall/>
}
@if (CommentId != 0)
{
@if (IsReplying)
{
<CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaButton Text="取消回复" OnClick="OnUnReplyClick" XSmall />
<CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaButton Text="取消回复" OnClick="OnUnReplyClick" XSmall Class="ms-3" />
}
else
{
<CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaButton Text="回复" OnClick="OnReplyClick" XSmall />
<CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaButton Text="回复" OnClick="OnReplyClick" XSmall Class="ms-3" />
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<div class="rounded shadow-sm bg-opacity mb-4">
<a href="/Anniversaries/Lottery">
<img style="width:100%" src="https://tucang.cc/api/image/show/8394e75c9094cd50384bbf4358851991?https://image.cngal.org/images/2022/06/30/0fbc4950e06e.png" />
</a>
<a href="/Anniversaries/Rating">
<img style="width:100%" src="https://tucang.cc/api/image/show/0b3027f193cec504122c19b8e67f290e?https://image.cngal.org/images/2022/06/30/b3ad65f2b76a.png" />
</a>
<a href="/Anniversaries/Lottery">
<img loading="lazy" style="width:100%" src="https://tucang.cc/api/image/show/8394e75c9094cd50384bbf4358851991?https://image.cngal.org/images/2022/06/30/0fbc4950e06e.png">
</a>
<a target="_blank" href="//live.bilibili.com/4622426">
<img loading="lazy" style="width:100%" src="https://tucang.cc/api/image/show/9f18c012c7ebe683605d4db75eebd91d?https://image.cngal.org/images/2022/07/01/9b627a822af1.png">
</a>
<a href="/Anniversaries/Rating">
<img loading="lazy" style="width:100%" src="https://tucang.cc/api/image/show/f3418fd7a8c91882e76b39b00d35b928?https://image.cngal.org/images/2022/07/01/ac2ebf501a9b.png">
<img loading="lazy" style="width:100%" src="https://tucang.cc/api/image/show/e6bde7cd852902901a0f8ec1980e0001?https://image.cngal.org/images/2022/07/01/7c6a07dfec91.png">
</a>
</div>
@if (isReady)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@
</div>

<div class="row">
@foreach (var item in Items)
@foreach (var item in Items.Skip((_dataCacheService.ThemeSetting.AnniversariesSetting.CurrentPage - 1) * _dataCacheService.ThemeSetting.AnniversariesSetting.MaxCount).Take(_dataCacheService.ThemeSetting.AnniversariesSetting.MaxCount))
{
<GameCard Model="item" Class="col-12 col-md-6 col-lg-4 col-xxl-3 mb-4" Type="_dataCacheService.ThemeSetting.AnniversariesSetting.DisplayType" OnClick="OnClickMore" />
}

</div>
@if (Items.Any() == false&& isReady)

@if (_dataCacheService.ThemeSetting.AnniversariesSetting.TotalPages > 1)
{
<MPagination Value="@_dataCacheService.ThemeSetting.AnniversariesSetting.CurrentPage" Class="my-4" Length="@_dataCacheService.ThemeSetting.AnniversariesSetting.TotalPages" ValueChanged="OnPageClick" Color="@_dataCacheService.ThemeSetting.Theme"></MPagination>
}

@if (Items.Any() == false && isReady)
{
<NotFoundJudgableCard GameName="@_dataCacheService.ThemeSetting.AnniversariesSetting.SearchString" />
}
Expand Down Expand Up @@ -88,6 +95,8 @@
JudgableGamesSortType.ReadCount => Items.OrderByDescending(s => s.ReaderCount).ToList(),
_ => Items
};

_dataCacheService.ThemeSetting.AnniversariesSetting.Count = Items.Count;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -153,4 +162,14 @@
}
}

private async Task OnPageClick(int pageIndex)
{
_dataCacheService.ThemeSetting.AnniversariesSetting.CurrentPage = pageIndex;
if (CnGalRootTip != null)
{
await CnGalRootTip.SaveTheme();
}
StateHasChanged();
}

}
44 changes: 0 additions & 44 deletions CnGalWebSite/CnGalWebSite.Shared/Pages/Webs/Votes/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,6 @@ else
{
_dataCatcheService.VoteIndexPageCatche.Clean(Id);
}

try
{
await OnCommentPageClick(1);
}
catch (Exception ex)
{
ErrorHandler.ProcessError(ex, "获取投票评论列表失败");
}
}
catch (Exception exc)
{
Expand Down Expand Up @@ -229,39 +220,4 @@ else
return Task.CompletedTask;
}


private async Task OnCommentPageClick(int pageIndex)
{
try
{
ListComments = await Http.GetFromJsonAsync<PagedResultDto<CommentViewModel>>(ToolHelper.WebApiPath + "api/comments/GetComments/" + (int)CommentType.CommentVote + "/" + Id + "/" + pageIndex + "/8");
StateHasChanged();
}
catch (Exception ex)
{
ErrorHandler.ProcessError(ex, "获取评论列表失败");
}
}

private async Task OnRely()
{
Model.CommentCount++;
await OnCommentPageClick(ListComments.CurrentPage);
}
private async Task OnDeleted()
{
await OnCommentPageClick(ListComments.CurrentPage);
}

public async void OnClickUrl(NavigateModel model)
{
try
{
NavigationManager.NavigateTo(Provider, model.Url, model.Title, model.Icon);
}
catch
{
await ToastService.Error("导航失败", "请尝试刷新页面");
}
}
}

0 comments on commit 8e7850a

Please sign in to comment.