Skip to content

Commit

Permalink
修复游戏发行列表意外消失的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleFish-233 committed Aug 25, 2023
1 parent f4b9493 commit 020aade
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 271 deletions.
2 changes: 1 addition & 1 deletion CnGalWebSite.sln
Expand Up @@ -81,7 +81,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CnGalWebSite.Shared.MasaCom
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "测试", "测试", "{A6CEAA1A-85A3-4760-A958-37B1A92D840D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CnGalWebSite.UnitTest", "CnGalWebSite\CnGalWebSite.UnitTest\CnGalWebSite.UnitTest.csproj", "{4012E05C-ADF4-43A6-B7CC-5DF56BBDC9E4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CnGalWebSite.UnitTest", "CnGalWebSite\CnGalWebSite.UnitTest\CnGalWebSite.UnitTest.csproj", "{4012E05C-ADF4-43A6-B7CC-5DF56BBDC9E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Expand Up @@ -41,55 +41,6 @@ public class EditRecordService : IEditRecordService
_examineService = examineService;
}

public async Task<QueryData<ListUserMonitorAloneModel>> GetPaginatedResult(CnGalWebSite.DataModel.ViewModel.Search.QueryPageOptions options, ListUserMonitorAloneModel searchModel, string userId)
{
var items = _userMonitorsRepository.GetAll().Include(s => s.Entry).Where(s => s.EntryId != null && s.ApplicationUserId == userId).AsNoTracking();

// 处理 SearchText 模糊搜索
if (!string.IsNullOrWhiteSpace(options.SearchText))
{
items = items.Where(item => item.Id.ToString().Contains(options.SearchText)
|| item.EntryId.ToString().Contains(options.SearchText));
}


// 排序
var isSorted = false;
if (!string.IsNullOrWhiteSpace(options.SortName))
{
items = items.OrderBy(s => s.Id).Sort(options.SortName, (BootstrapBlazor.Components.SortOrder)options.SortOrder);
isSorted = true;
}

// 设置记录总数
var total = items.Count();

// 内存分页
var list = await items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems).ToListAsync();

//复制数据
var resultItems = new List<ListUserMonitorAloneModel>();
foreach (var item in list)
{
resultItems.Add(new ListUserMonitorAloneModel
{
Id = item.Id,
CreateTime = item.CreateTime,
EntryId = item.Entry.Id,
EntryName = item.Entry.DisplayName,
Type = item.Entry.Type
});
}

return new QueryData<ListUserMonitorAloneModel>()
{
Items = resultItems,
TotalCount = total,
IsSorted = isSorted,
// IsFiltered = isFiltered
};
}

public async Task<QueryData<ListUserReviewEditRecordAloneModel>> GetPaginatedResult(CnGalWebSite.DataModel.ViewModel.Search.QueryPageOptions options, ListUserReviewEditRecordAloneModel searchModel, string userId)
{
var items = _userReviewEditRecordRepository.GetAll().AsNoTracking()
Expand Down Expand Up @@ -131,7 +82,8 @@ public async Task<QueryData<ListUserReviewEditRecordAloneModel>> GetPaginatedRes
EntryName = item.Examine.Entry.DisplayName,
Operation = item.Examine.Operation,
UserId = item.Examine.ApplicationUserId,
UserName = item.Examine.ApplicationUser.UserName
UserName = item.Examine.ApplicationUser.UserName,
ReviewedTime=item.ReviewedTime
});
}

Expand Down
Expand Up @@ -8,8 +8,6 @@ namespace CnGalWebSite.APIServer.Application.Examines
{
public interface IEditRecordService
{
Task<QueryData<ListUserMonitorAloneModel>> GetPaginatedResult(CnGalWebSite.DataModel.ViewModel.Search.QueryPageOptions options, ListUserMonitorAloneModel searchModel, string userId);

Task<QueryData<ListUserReviewEditRecordAloneModel>> GetPaginatedResult(CnGalWebSite.DataModel.ViewModel.Search.QueryPageOptions options, ListUserReviewEditRecordAloneModel searchModel, string userId);

/// <summary>
Expand Down
Expand Up @@ -33,6 +33,10 @@
using CnGalWebSite.DataModel.ExamineModel.Shared;
using CnGalWebSite.DataModel.ExamineModel.Videos;
using CnGalWebSite.DataModel.ExamineModel.FavoriteFolders;
using CnGalWebSite.Core.Models;
using CnGalWebSite.DataModel.ViewModel.Entries;
using CnGalWebSite.Core.Services.Query;
using Result = CnGalWebSite.DataModel.Model.Result;

namespace CnGalWebSite.APIServer.Controllers
{
Expand Down Expand Up @@ -62,11 +66,11 @@ public class ExaminesAPIController : ControllerBase
private readonly IRankService _rankService;
private readonly IEditRecordService _editRecordService;
private readonly IUserService _userService;

private readonly IQueryService _queryService;

public ExaminesAPIController(IRepository<Disambig, int> disambigRepository, IRankService rankService, IRepository<Comment, long> commentRepository, IUserService userService, IRepository<Video, long> videoRepository,
IRepository<Message, long> messageRepository, IRepository<ApplicationUser, string> userRepository, IRepository<UserReviewEditRecord, long> userReviewEditRecordRepository, IRepository<FavoriteFolder, long> favoriteFolderRepository,
IExamineService examineService, IRepository<UserMonitor, long> userMonitorsRepository, IEditRecordService editRecordService, IRepository<UserCertification, long> userCertificationRepository,
IExamineService examineService, IRepository<UserMonitor, long> userMonitorsRepository, IEditRecordService editRecordService, IRepository<UserCertification, long> userCertificationRepository, IQueryService queryService,
IRepository<Article, long> articleRepository, IAppHelper appHelper, IRepository<Entry, int> entryRepository, IRepository<Periphery, long> peripheryRepository, IRepository<Examine, long> examineRepository, IRepository<Tag, int> tagRepository, IRepository<PlayedGame, long> playedGameRepository)
{

Expand All @@ -90,6 +94,7 @@ public class ExaminesAPIController : ControllerBase
_userService = userService;
_videoRepository = videoRepository;
_favoriteFolderRepository = favoriteFolderRepository;
_queryService = queryService;
}


Expand Down Expand Up @@ -718,6 +723,10 @@ public async Task<ActionResult<Result>> EditUserReviewEditRecordState(EditUserRe
.Where(s => s.ApplicationUserId == user.Id && s.ExamineId != null && model.ExamineIds.Contains(s.ExamineId.Value))
.ExecuteUpdateAsync(s => s.SetProperty(s => s.State, b => model.State));

var now = DateTime.Now.ToCstTime();
await _userReviewEditRecordRepository.GetAll()
.Where(s => s.ApplicationUserId == user.Id && s.ExamineId != null && model.ExamineIds.Contains(s.ExamineId.Value))
.ExecuteUpdateAsync(s => s.SetProperty(s => s.ReviewedTime, b => now));

return new Result { Successful = true };

Expand Down Expand Up @@ -787,22 +796,28 @@ public async Task<ActionResult<UserContentCenterViewModel>> GetUserContentCenter
/// <summary>
/// 获取用户所有监视列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[Authorize]
[HttpPost]
public async Task<ActionResult<BootstrapBlazor.Components.QueryData<ListUserMonitorAloneModel>>> GetUserMonitorListAsync(UserMonitorsPagesInfor input)
public async Task<QueryResultModel<UserMonitorOverviewModel>> ListUserMonitors(QueryParameterModel model)
{
var user = await _appHelper.GetAPICurrentUserAsync(HttpContext);
var (items, total) = await _queryService.QueryAsync<UserMonitor, long>(_userMonitorsRepository.GetAll().Include(s=>s.Entry).AsSingleQuery().Where(s=>s.Entry!=null).Where(s=>s.ApplicationUserId== user.Id), model,
s => string.IsNullOrWhiteSpace(model.SearchText) || (s.Entry.Name.Contains(model.SearchText)));

if (user == null)
return new QueryResultModel<UserMonitorOverviewModel>
{
return NotFound();
}

var dtos = await _editRecordService.GetPaginatedResult(input.Options, input.SearchModel, user.Id);

return dtos;
Items = await items.Select(s => new UserMonitorOverviewModel
{
CreateTime = s.CreateTime,
EntryId=s.Entry.Id,
EntryName=s.Entry.Name,
Type=s.Entry.Type,
Id = s.Id,
}).ToListAsync(),
Total = total,
Parameter = model
};
}

/// <summary>
Expand Down

This file was deleted.

@@ -0,0 +1,30 @@
using CnGalWebSite.DataModel.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using System.Xml.Linq;

namespace CnGalWebSite.DataModel.ViewModel.EditRecords
{
public class UserMonitorOverviewModel
{
public long Id { get; set; }
/// <summary>
/// 词条Id
/// </summary>
public int EntryId { get; set; }
/// <summary>
/// 类型
/// </summary>
public EntryType Type { get; set; }
/// <summary>
/// 名称
/// </summary>
public string EntryName { get; set; }
/// <summary>
/// 添加监视的时间
/// </summary>
public DateTime CreateTime { get; set; }
}
}
Expand Up @@ -155,7 +155,8 @@ public enum IconType
Store,
Hide,
Refresh,
Prize
Prize,
Look
}

public static class IconTypeHelper
Expand Down Expand Up @@ -334,6 +335,8 @@ public static string ToIconString(this IconType type)
return "mdi-nature-people ";
case IconType.Pupil:
return "mdi-eye ";
case IconType.Look:
return "mdi-eye ";
case IconType.Clothes:
return "mdi-hanger ";
case IconType.Hair:
Expand Down
@@ -1,8 +1,4 @@
@page "/admin/apiscopes"

@attribute [Authorize(Roles = "Admin")]

@inject IHttpService _httpService
@inject IHttpService _httpService
@inject IPopupService PopupService

<DataTableCard TModel="EntryInformationTypeOverviewModel" Headers="_headers" ApiUrl="@(_baseUrl)" Title="@($"{_name}列表")" OnClickAdd="AddItem" @ref="dataTableCard">
Expand Down

0 comments on commit 020aade

Please sign in to comment.