Browse Source

added document management page to the admin side. closes volosoft/volo#2245

pull/4420/head
Alper Ebicoglu 6 years ago
parent
commit
a55b1db59c
  1. 22
      modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/GetAllInput.cs
  2. 12
      modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Localization/Resources/Docs/ApplicationContracts/en.json
  3. 36
      modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs
  4. 219
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml
  5. 3
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml.cs
  6. 3
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.css
  7. 71
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js
  8. 1
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.min.css
  9. 6
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.scss
  10. 8
      modules/docs/src/Volo.Docs.Admin.Web/Volo.Docs.Admin.Web.csproj
  11. 6
      modules/docs/src/Volo.Docs.Admin.Web/compilerconfig.json
  12. 63
      modules/docs/src/Volo.Docs.Admin.Web/compilerconfig.json.defaults
  13. 23
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs
  14. 103
      modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs
  15. 124
      modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs

22
modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/GetAllInput.cs

@ -12,10 +12,28 @@ namespace Volo.Docs.Admin.Documents
[StringLength(DocumentConsts.MaxNameLength)]
public string Name { get; set; }
[StringLength(DocumentConsts.MaxVersionNameLength)]
public string Version { get; set; }
[StringLength(DocumentConsts.MaxLanguageCodeNameLength)]
public string LanguageCode { get; set; }
[StringLength(DocumentConsts.MaxVersionNameLength)]
public string Version { get; set; }
[StringLength(DocumentConsts.MaxFileNameNameLength)]
public string FileName { get; set; }
[StringLength(DocumentConsts.MaxFormatNameLength)]
public string Format { get; set; }
public DateTime? CreationTimeMin { get; set; }
public DateTime? CreationTimeMax { get; set; }
public DateTime? LastUpdatedTimeMin { get; set; }
public DateTime? LastUpdatedTimeMax { get; set; }
public DateTime? LastSignificantUpdateTimeMin { get; set; }
public DateTime? LastSignificantUpdateTimeMax { get; set; }
public DateTime? LastCachedTimeMin { get; set; }
public DateTime? LastCachedTimeMax { get; set; }
}
}

12
modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Localization/Resources/Docs/ApplicationContracts/en.json

@ -43,6 +43,16 @@
"ReIndexDocumentConfirmation": "Are you sure you want to reindex this item?",
"DeleteDocumentFromDbConfirmation": "Are you sure you want to delete this item from database?",
"DeleteFromDatabase": "Delete from database",
"Deleted": "Deleted"
"Deleted": "Deleted",
"Search": "Search",
"StartDate": "Start date",
"EndDate": "End date",
"CreationTime": "Creation time",
"LastUpdateTime": "Last update",
"LastSignificantUpdateTime": "Last significant update",
"Version": "Version",
"LanguageCode": "Language code",
"FileName": "File name",
"LastCachedTime": "Cache time"
}
}

36
modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs

@ -137,20 +137,40 @@ namespace Volo.Docs.Admin.Documents
public async Task<PagedResultDto<DocumentDto>> GetAllAsync(GetAllInput input)
{
var totalCount = await _documentRepository.GetAllCountAsync(
projectId: input.ProjectId,
name: input.Name,
version: input.Version,
languageCode: input.LanguageCode,
sorting: input.Sorting,
maxResultCount: input.MaxResultCount,
skipCount: input.SkipCount
);
projectId: input.ProjectId,
name: input.Name,
version: input.Version,
languageCode: input.LanguageCode,
fileName: input.FileName,
format: input.Format,
creationTimeMin: input.CreationTimeMin,
creationTimeMax: input.CreationTimeMax,
lastUpdatedTimeMin: input.LastUpdatedTimeMin,
lastUpdatedTimeMax: input.LastUpdatedTimeMax,
lastSignificantUpdateTimeMin: input.LastSignificantUpdateTimeMin,
lastSignificantUpdateTimeMax: input.LastSignificantUpdateTimeMax,
lastCachedTimeMin: input.LastCachedTimeMin,
lastCachedTimeMax: input.LastCachedTimeMax,
sorting: input.Sorting,
maxResultCount: input.MaxResultCount,
skipCount: input.SkipCount
);
var docs = await _documentRepository.GetAllAsync(
projectId: input.ProjectId,
name: input.Name,
version: input.Version,
languageCode: input.LanguageCode,
fileName: input.FileName,
format: input.Format,
creationTimeMin: input.CreationTimeMin,
creationTimeMax: input.CreationTimeMax,
lastUpdatedTimeMin: input.LastUpdatedTimeMin,
lastUpdatedTimeMax: input.LastUpdatedTimeMax,
lastSignificantUpdateTimeMin: input.LastSignificantUpdateTimeMin,
lastSignificantUpdateTimeMax: input.LastSignificantUpdateTimeMax,
lastCachedTimeMin: input.LastCachedTimeMin,
lastCachedTimeMax: input.LastCachedTimeMax,
sorting: input.Sorting,
maxResultCount: input.MaxResultCount,
skipCount: input.SkipCount

219
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml

@ -22,31 +22,194 @@
<abp-script src="/Pages/Docs/Admin/Documents/index.js" />
}
<abp-card>
<abp-card-header>
<abp-row>
<h2>Filters ...</h2>
@*<abp-column size-md="_6" class="text-right">
<abp-button button-type="Primary" icon="plus" text="@L["ReIndexAllProjects"].Value" id="ReIndexAllProjects" />
</abp-column>*@
</abp-row>
</abp-card-header>
<abp-card-body>
<abp-table striped-rows="true" id="DocumentsTable" class="nowrap">
<thead>
<tr>
<th>@L["Actions"]</th>
<th>@L["Name"]</th>
<th>@L["Version"]</th>
<th>@L["LanguageCode"]</th>
<th>@L["FileName"]</th>
<th>@L["Format"]</th>
<th>@L["CreationTime"]</th>
<th>@L["LastUpdatedTime"]</th>
<th>@L["LastSignificantUpdateTime"]</th>
<th>@L["LastCachedTime"]</th>
</tr>
</thead>
</abp-table>
</abp-card-body>
</abp-card>
@section styles {
<abp-style src="/Pages/Docs/Admin/Documents/index.min.css" />
}
<div id="DocumentsContainer">
<abp-card>
<abp-card-header>
<form class="form-inline" autocomplete="off" id="FilterForm">
<div class="form-row">
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@L["Name"].Value</div>
</div>
<input type="text"
id="Name"
name="Name"
class="form-control mr-sm-2">
</div>
</div>
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@L["Version"].Value</div>
</div>
<input type="text"
id="Version"
name="Version"
class="form-control mr-sm-2">
</div>
</div>
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@L["LanguageCode"].Value</div>
</div>
<input type="text"
id="LanguageCode"
name="LanguageCode"
class="form-control mr-sm-2">
</div>
</div>
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@L["FileName"].Value</div>
</div>
<input type="text"
id="FileName"
name="FileName"
class="form-control mr-sm-2">
</div>
</div>
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@L["Format"].Value</div>
</div>
<input type="text"
id="Format"
name="Format"
class="form-control mr-sm-2">
</div>
</div>
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@L["CreationTime"].Value</div>
</div>
<span>
<input type="date"
id="CreationTimeMin"
name="CreationTimeMin"
class="form-control datepicker"
placeholder="@L["StartDate"]">
<span>-</span>
<input type="date"
id="CreationTimeMax"
name="CreationTimeMax"
placeholder="@L["EndDate"]"
class="form-control datepicker">
</span>
</div>
</div>
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@L["LastUpdateTime"].Value</div>
</div>
<span>
<input type="date"
id="LastUpdatedTimeMin"
name="LastUpdatedTimeMin"
class="form-control datepicker"
placeholder="@L["StartDate"]">
<span>-</span>
<input type="date"
id="LastUpdatedTimeMax"
name="LastUpdatedTimeMax"
placeholder="@L["EndDate"]"
class="form-control datepicker">
</span>
</div>
</div>
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@L["LastSignificantUpdateTime"].Value</div>
</div>
<span>
<input type="date"
id="LastSignificantUpdateTimeMin"
name="LastSignificantUpdateTimeMin"
class="form-control datepicker"
placeholder="@L["StartDate"]">
<span>-</span>
<input type="date"
id="LastSignificantUpdateTimeMax"
name="LastSignificantUpdateTimeMax"
placeholder="@L["EndDate"]"
class="form-control datepicker">
</span>
</div>
</div>
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@L["LastCachedTime"].Value</div>
</div>
<span>
<input type="date"
id="LastCachedTimeMin"
name="LastCachedTimeMin"
class="form-control datepicker"
placeholder="@L["StartDate"]">
<span>-</span>
<input type="date"
id="LastCachedTimeMax"
name="LastCachedTimeMax"
placeholder="@L["EndDate"]"
class="form-control datepicker">
</span>
</div>
</div>
<div class="col-auto">
<abp-button button-type="Primary" icon="search" id="SearchButton" style="line-height: 25px;" text="@L["Search"].Value"></abp-button>
</div>
</div>
</form>
</abp-card-header>
<abp-card-body>
<abp-table striped-rows="true" id="DocumentsTable" class="nowrap">
<thead>
<tr>
<th>@L["Actions"]</th>
<th>@L["Name"]</th>
<th>@L["Version"]</th>
<th>@L["LanguageCode"]</th>
<th>@L["FileName"]</th>
<th>@L["Format"]</th>
<th>@L["CreationTime"]</th>
<th>@L["LastUpdatedTime"]</th>
<th>@L["LastSignificantUpdateTime"]</th>
<th>@L["LastCachedTime"]</th>
</tr>
</thead>
</abp-table>
</abp-card-body>
</abp-card>
</div>

3
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml.cs

@ -1,6 +1,9 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Docs.Documents;
namespace Volo.Docs.Admin.Pages.Docs.Admin.Documents
{

3
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.css

@ -0,0 +1,3 @@
#DocumentsContainer .datepicker {
display: inline-block !important;
width: 7rem !important; }

71
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js

@ -1,8 +1,32 @@
$(function () {
var l = abp.localization.getResource('Docs');
var service = window.volo.docs.admin.documentsAdmin;
var _dataTable = $('#DocumentsTable').DataTable(abp.libs.datatables.normalizeConfiguration({
var getFormattedDate = function ($datePicker) {
return $datePicker.data().datepicker.getFormattedDate("yyyy-mm-dd");
};
var getFilter = function () {
return {
projectId: $("#ProjectId").val(),
name: $("#Name").val(),
version: $("#Version").val(),
languageCode: $("#LanguageCode").val(),
fileName: $("#FileName").val(),
format: $("#Format").val(),
creationTimeMin: getFormattedDate($("#CreationTimeMin")),
creationTimeMax: getFormattedDate($("#CreationTimeMax")),
lastUpdatedTimeMin: getFormattedDate($("#LastUpdatedTimeMin")),
lastUpdatedTimeMax: getFormattedDate($("#LastUpdatedTimeMax")),
lastSignificantUpdateTimeMin: getFormattedDate($("#LastSignificantUpdateTimeMin")),
lastSignificantUpdateTimeMax: getFormattedDate($("#LastSignificantUpdateTimeMax")),
lastCachedTimeMin: getFormattedDate($("#LastCachedTimeMin")),
lastCachedTimeMax: getFormattedDate($("#LastCachedTimeMax"))
};
};
var dataTable = $('#DocumentsTable').DataTable(abp.libs.datatables.normalizeConfiguration({
processing: true,
serverSide: true,
scrollX: true,
@ -10,7 +34,7 @@
searching: false,
autoWidth: false,
scrollCollapse: true,
ajax: abp.libs.datatables.createAjax(volo.docs.admin.documentsAdmin.getAll),
ajax: abp.libs.datatables.createAjax(service.getAll, getFilter),
columnDefs: [
{
rowAction: {
@ -21,11 +45,10 @@
visible: abp.auth.isGranted('Docs.Admin.Documents'),
confirmMessage: function (data) { return l('RemoveFromCacheConfirmation'); },
action: function (data) {
volo.docs.admin.documentsAdmin
.removeFromCache(data.record.id)
service.removeFromCache(data.record.id)
.then(function () {
abp.message.success(l('RemovedFromCache'));
_dataTable.ajax.reload();
dataTable.ajax.reload();
});
}
},
@ -34,11 +57,10 @@
visible: abp.auth.isGranted('Docs.Admin.Documents'),
confirmMessage: function (data) { return l('ReIndexDocumentConfirmation'); },
action: function (data) {
volo.docs.admin.documentsAdmin
.reindex(data.record.id)
service.reindex(data.record.id)
.then(function () {
abp.message.success(l('ReindexCompleted'));
_dataTable.ajax.reload();
dataTable.ajax.reload();
});
}
},
@ -47,11 +69,10 @@
visible: abp.auth.isGranted('Docs.Admin.Documents'),
confirmMessage: function (data) { return l('DeleteDocumentFromDbConfirmation'); },
action: function (data) {
volo.docs.admin.documentsAdmin
.deleteFromDatabase(data.record.id)
service.deleteFromDatabase(data.record.id)
.then(function () {
abp.message.success(l('Deleted'));
_dataTable.ajax.reload();
dataTable.ajax.reload();
});
}
}
@ -76,14 +97,7 @@
},
{
target: 5,
data: "format",
render: function (data) {
if (data === 'md') {
return 'markdown';
}
return data;
}
data: "format"
},
{
target: 6,
@ -136,18 +150,15 @@
]
}));
$("#FilterForm input[type='text']").keypress(function (e) {
if (e.which === 13) {
dataTable.ajax.reload();
}
});
$("#ReIndexAllProjects").click(function (event) {
abp.message.confirm(l('ReIndexAllProjectConfirmationMessage'))
.done(function (accepted) {
if (accepted) {
volo.docs.admin.projectsAdmin
.reindexAll()
.then(function () {
abp.message.success(l('SuccessfullyReIndexAllProject'));
});
}
});
$("#SearchButton").click(function (e) {
e.preventDefault();
dataTable.ajax.reload();
});
});

1
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.min.css

@ -0,0 +1 @@
#DocumentsContainer .datepicker{display:inline-block !important;width:7rem !important;}

6
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.scss

@ -0,0 +1,6 @@
#DocumentsContainer {
.datepicker {
display: inline-block !important;
width: 7rem !important;
}
}

8
modules/docs/src/Volo.Docs.Admin.Web/Volo.Docs.Admin.Web.csproj

@ -13,13 +13,16 @@
<TypeScriptToolsVersion>2.8</TypeScriptToolsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommonMark.NET" Version="0.15.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo.Abp.AspNetCore.Mvc.UI.Bundling.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Packages\Volo.Abp.AspNetCore.Mvc.UI.Packages.csproj" />
<ProjectReference Include="..\Volo.Docs.Admin.HttpApi\Volo.Docs.Admin.HttpApi.csproj" />
<PackageReference Include="CommonMark.NET" Version="0.15.1" />
</ItemGroup>
<ItemGroup>
@ -29,8 +32,7 @@
<Content Remove="Pages\**\*.js" />
<Content Remove="Properties\launchSettings.json" />
<Content Remove="compilerconfig.json" />
<Content Remove="compilerconfig.json.defaults" />
<None Remove="Pages\Docs\Admin\Documents\index.js" />
<Content Remove="compilerconfig.json.defaults" />
<None Include="compilerconfig.json" />
<None Include="Properties\launchSettings.json" />
</ItemGroup>

6
modules/docs/src/Volo.Docs.Admin.Web/compilerconfig.json

@ -0,0 +1,6 @@
[
{
"outputFile": "Pages/Docs/Admin/Documents/index.css",
"inputFile": "Pages/Docs/Admin/Documents/index.scss"
}
]

63
modules/docs/src/Volo.Docs.Admin.Web/compilerconfig.json.defaults

@ -0,0 +1,63 @@
{
"compilers": {
"less": {
"autoPrefix": "",
"cssComb": "none",
"ieCompat": true,
"strictMath": false,
"strictUnits": false,
"relativeUrls": true,
"rootPath": "",
"sourceMapRoot": "",
"sourceMapBasePath": "",
"sourceMap": false
},
"sass": {
"autoPrefix": "",
"includePath": "",
"indentType": "space",
"indentWidth": 2,
"outputStyle": "nested",
"Precision": 5,
"relativeUrls": true,
"sourceMapRoot": "",
"lineFeed": "",
"sourceMap": false
},
"stylus": {
"sourceMap": false
},
"babel": {
"sourceMap": false
},
"coffeescript": {
"bare": false,
"runtimeMode": "node",
"sourceMap": false
},
"handlebars": {
"root": "",
"noBOM": false,
"name": "",
"namespace": "",
"knownHelpersOnly": false,
"forcePartial": false,
"knownHelpers": [],
"commonjs": "",
"amd": false,
"sourceMap": false
}
},
"minifiers": {
"css": {
"enabled": true,
"termSemicolons": true,
"gzip": false
},
"javascript": {
"enabled": true,
"termSemicolons": true,
"gzip": false
}
}
}

23
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs

@ -23,10 +23,21 @@ namespace Volo.Docs.Documents
string version,
CancellationToken cancellationToken = default);
Task<List<Document>> GetAllAsync(Guid? projectId,
Task<List<Document>> GetAllAsync(
Guid? projectId,
string name,
string version,
string languageCode,
string fileName,
string format,
DateTime? creationTimeMin,
DateTime? creationTimeMax,
DateTime? lastUpdatedTimeMin,
DateTime? lastUpdatedTimeMax,
DateTime? lastSignificantUpdateTimeMin,
DateTime? lastSignificantUpdateTimeMax,
DateTime? lastCachedTimeMin,
DateTime? lastCachedTimeMax,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
@ -37,6 +48,16 @@ namespace Volo.Docs.Documents
string name,
string version,
string languageCode,
string fileName,
string format,
DateTime? creationTimeMin,
DateTime? creationTimeMax,
DateTime? lastUpdatedTimeMin,
DateTime? lastUpdatedTimeMax,
DateTime? lastSignificantUpdateTimeMin,
DateTime? lastSignificantUpdateTimeMax,
DateTime? lastCachedTimeMin,
DateTime? lastCachedTimeMax,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,

103
modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs

@ -24,16 +24,44 @@ namespace Volo.Docs.Documents
return await DbSet.Where(d => d.ProjectId == projectId).ToListAsync(cancellationToken: cancellationToken);
}
public async Task<List<Document>> GetAllAsync(Guid? projectId,
public async Task<List<Document>> GetAllAsync(
Guid? projectId,
string name,
string version,
string languageCode,
string fileName,
string format,
DateTime? creationTimeMin,
DateTime? creationTimeMax,
DateTime? lastUpdatedTimeMin,
DateTime? lastUpdatedTimeMax,
DateTime? lastSignificantUpdateTimeMin,
DateTime? lastSignificantUpdateTimeMax,
DateTime? lastCachedTimeMin,
DateTime? lastCachedTimeMax,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
var query = ApplyFilterForGetAll(DbSet, projectId, name, version, languageCode);
var query = ApplyFilterForGetAll(
DbSet,
projectId: projectId,
name: name,
version: version,
languageCode: languageCode,
format: format,
fileName: fileName,
creationTimeMin: creationTimeMin,
creationTimeMax: creationTimeMax,
lastUpdatedTimeMin: lastUpdatedTimeMin,
lastUpdatedTimeMax: lastUpdatedTimeMax,
lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin,
lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax,
lastCachedTimeMin: lastCachedTimeMin,
lastCachedTimeMax: lastCachedTimeMax
);
query = query.OrderBy(string.IsNullOrWhiteSpace(sorting) ? nameof(Document.Name) : sorting);
return await query.PageBy(skipCount, maxResultCount).ToListAsync(cancellationToken);
}
@ -43,12 +71,39 @@ namespace Volo.Docs.Documents
string name,
string version,
string languageCode,
string fileName,
string format,
DateTime? creationTimeMin,
DateTime? creationTimeMax,
DateTime? lastUpdatedTimeMin,
DateTime? lastUpdatedTimeMax,
DateTime? lastSignificantUpdateTimeMin,
DateTime? lastSignificantUpdateTimeMax,
DateTime? lastCachedTimeMin,
DateTime? lastCachedTimeMax,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
var query = ApplyFilterForGetAll(DbSet, projectId, name, version, languageCode);
var query = ApplyFilterForGetAll(
DbSet,
projectId: projectId,
name: name,
version: version,
languageCode: languageCode,
format: format,
fileName: fileName,
creationTimeMin: creationTimeMin,
creationTimeMax: creationTimeMax,
lastUpdatedTimeMin: lastUpdatedTimeMin,
lastUpdatedTimeMax: lastUpdatedTimeMax,
lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin,
lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax,
lastCachedTimeMin: lastCachedTimeMin,
lastCachedTimeMax: lastCachedTimeMax
);
return await query.LongCountAsync(GetCancellationToken(cancellationToken));
}
@ -81,13 +136,47 @@ namespace Volo.Docs.Documents
string name,
string version,
string languageCode,
string fileName,
string format,
DateTime? creationTimeMin,
DateTime? creationTimeMax,
DateTime? lastUpdatedTimeMin,
DateTime? lastUpdatedTimeMax,
DateTime? lastSignificantUpdateTimeMin,
DateTime? lastSignificantUpdateTimeMax,
DateTime? lastCachedTimeMin,
DateTime? lastCachedTimeMax,
CancellationToken cancellationToken = default)
{
return DbSet
.WhereIf(projectId.HasValue, d => d.ProjectId == projectId.Value)
.WhereIf(name != null, d => d.Name != null && d.Name.Contains(name))
.WhereIf(version != null, d => d.Version != null && d.Version == version)
.WhereIf(languageCode != null, d => d.LanguageCode != null && d.LanguageCode == languageCode);
.WhereIf(projectId.HasValue,
d => d.ProjectId == projectId.Value)
.WhereIf(name != null,
d => d.Name != null && d.Name.Contains(name))
.WhereIf(version != null,
d => d.Version != null && d.Version == version)
.WhereIf(languageCode != null,
d => d.LanguageCode != null && d.LanguageCode == languageCode)
.WhereIf(fileName != null,
d => d.FileName != null && d.FileName.Contains(fileName))
.WhereIf(format != null,
d => d.Format != null && d.Format == format)
.WhereIf(creationTimeMin.HasValue,
d => d.CreationTime.Date >= creationTimeMin.Value.Date)
.WhereIf(creationTimeMax.HasValue,
d => d.CreationTime.Date <= creationTimeMax.Value.Date)
.WhereIf(lastUpdatedTimeMin.HasValue,
d => d.LastUpdatedTime.Date >= lastUpdatedTimeMin.Value.Date)
.WhereIf(lastUpdatedTimeMax.HasValue,
d => d.LastUpdatedTime.Date <= lastUpdatedTimeMax.Value.Date)
.WhereIf(lastSignificantUpdateTimeMin.HasValue,
d => d.LastSignificantUpdateTime != null && d.LastSignificantUpdateTime.Value.Date >= lastSignificantUpdateTimeMin.Value.Date)
.WhereIf(lastSignificantUpdateTimeMax.HasValue,
d => d.LastSignificantUpdateTime != null && d.LastSignificantUpdateTime.Value.Date <= lastSignificantUpdateTimeMax.Value.Date)
.WhereIf(lastCachedTimeMin.HasValue,
d => d.LastCachedTime.Date >= lastCachedTimeMin.Value.Date)
.WhereIf(lastCachedTimeMax.HasValue,
d => d.LastCachedTime.Date <= lastCachedTimeMax.Value.Date);
}
}
}

124
modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs

@ -43,33 +43,88 @@ namespace Volo.Docs.Documents
x.Version == version, cancellationToken: cancellationToken);
}
public async Task<List<Document>> GetAllAsync(Guid? projectId,
public async Task<List<Document>> GetAllAsync(
Guid? projectId,
string name,
string version,
string languageCode,
string fileName,
string format,
DateTime? creationTimeMin,
DateTime? creationTimeMax,
DateTime? lastUpdatedTimeMin,
DateTime? lastUpdatedTimeMax,
DateTime? lastSignificantUpdateTimeMin,
DateTime? lastSignificantUpdateTimeMax,
DateTime? lastCachedTimeMin,
DateTime? lastCachedTimeMax,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
return await
ApplyFilterForGetAll(GetMongoQueryable(), projectId, name, version, languageCode)
.OrderBy(string.IsNullOrWhiteSpace(sorting) ? "name asc" : sorting).As<IMongoQueryable<Document>>()
.PageBy<Document, IMongoQueryable<Document>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
ApplyFilterForGetAll(
GetMongoQueryable(),
projectId: projectId,
name: name,
version: version,
languageCode: languageCode,
format: format,
fileName: fileName,
creationTimeMin: creationTimeMin,
creationTimeMax: creationTimeMax,
lastUpdatedTimeMin: lastUpdatedTimeMin,
lastUpdatedTimeMax: lastUpdatedTimeMax,
lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin,
lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax,
lastCachedTimeMin: lastCachedTimeMin,
lastCachedTimeMax: lastCachedTimeMax)
.OrderBy(string.IsNullOrWhiteSpace(sorting) ? "name asc" : sorting).As<IMongoQueryable<Document>>()
.PageBy<Document, IMongoQueryable<Document>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetAllCountAsync(Guid? projectId,
public async Task<long> GetAllCountAsync(
Guid? projectId,
string name,
string version,
string languageCode,
string fileName,
string format,
DateTime? creationTimeMin,
DateTime? creationTimeMax,
DateTime? lastUpdatedTimeMin,
DateTime? lastUpdatedTimeMax,
DateTime? lastSignificantUpdateTimeMin,
DateTime? lastSignificantUpdateTimeMax,
DateTime? lastCachedTimeMin,
DateTime? lastCachedTimeMax,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
return await
ApplyFilterForGetAll(GetMongoQueryable(), projectId, name, version, languageCode)
ApplyFilterForGetAll(
GetMongoQueryable(),
projectId: projectId,
name: name,
version: version,
languageCode: languageCode,
format: format,
fileName: fileName,
creationTimeMin: creationTimeMin,
creationTimeMax: creationTimeMax,
lastUpdatedTimeMin: lastUpdatedTimeMin,
lastUpdatedTimeMax: lastUpdatedTimeMax,
lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin,
lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax,
lastCachedTimeMin: lastCachedTimeMin,
lastCachedTimeMax: lastCachedTimeMax)
.OrderBy(string.IsNullOrWhiteSpace(sorting) ? "name asc" : sorting).As<IMongoQueryable<Document>>()
.PageBy<Document, IMongoQueryable<Document>>(skipCount, maxResultCount)
.LongCountAsync(GetCancellationToken(cancellationToken));
@ -86,6 +141,16 @@ namespace Volo.Docs.Documents
string name,
string version,
string languageCode,
string fileName,
string format,
DateTime? creationTimeMin,
DateTime? creationTimeMax,
DateTime? lastUpdatedTimeMin,
DateTime? lastUpdatedTimeMax,
DateTime? lastSignificantUpdateTimeMin,
DateTime? lastSignificantUpdateTimeMax,
DateTime? lastCachedTimeMin,
DateTime? lastCachedTimeMax,
CancellationToken cancellationToken = default)
{
if (projectId.HasValue)
@ -108,6 +173,51 @@ namespace Volo.Docs.Documents
query = query.Where(d => d.LanguageCode != null && d.LanguageCode == languageCode);
}
if (fileName != null)
{
query = query.Where(d => d.FileName != null && d.FileName.Contains(fileName));
}
if (creationTimeMin.HasValue)
{
query = query.Where(d => d.CreationTime.Date >= creationTimeMin.Value.Date);
}
if (creationTimeMax.HasValue)
{
query = query.Where(d => d.CreationTime.Date <= creationTimeMax.Value.Date);
}
if (lastUpdatedTimeMin.HasValue)
{
query = query.Where(d => d.LastUpdatedTime.Date >= lastUpdatedTimeMin.Value.Date);
}
if (lastUpdatedTimeMax.HasValue)
{
query = query.Where(d => d.LastUpdatedTime.Date <= lastUpdatedTimeMax.Value.Date);
}
if (lastSignificantUpdateTimeMin.HasValue)
{
query = query.Where(d => d.LastSignificantUpdateTime != null && d.LastSignificantUpdateTime.Value.Date >= lastSignificantUpdateTimeMin.Value.Date);
}
if (lastSignificantUpdateTimeMax.HasValue)
{
query = query.Where(d => d.LastSignificantUpdateTime != null && d.LastSignificantUpdateTime.Value.Date <= lastSignificantUpdateTimeMax.Value.Date);
}
if (lastCachedTimeMin.HasValue)
{
query = query.Where(d => d.LastCachedTime.Date >= lastCachedTimeMin.Value.Date);
}
if (lastCachedTimeMax.HasValue)
{
query = query.Where(d => d.LastCachedTime.Date <= lastCachedTimeMax.Value.Date);
}
return query;
}
}

Loading…
Cancel
Save