mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
parent
7bcd1ba389
commit
31d65ec2b7
6 changed files with 77 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"id": 1,
|
||||
"name": "crypto",
|
||||
"description": "Blocks cryptomining and/or cryptojacking"
|
||||
"description": "Blocks cryptomining and/or cryptojacking",
|
||||
"name": "crypto"
|
||||
}
|
||||
]
|
||||
27
src/FilterLists.Api/V1/Controllers/ListsTagsController.cs
Normal file
27
src/FilterLists.Api/V1/Controllers/ListsTagsController.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models.Junctions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class ListsTagsController : BaseController
|
||||
{
|
||||
public ListsTagsController(IMemoryCache memoryCache, SeedService seedService)
|
||||
: base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("ListsTagsController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<FilterListTag, FilterListTagSeedDto>(
|
||||
typeof(FilterListTag).GetProperty("FilterListId"),
|
||||
typeof(FilterListTag).GetProperty("TagId"));
|
||||
}));
|
||||
}
|
||||
}
|
||||
24
src/FilterLists.Api/V1/Controllers/TagsController.cs
Normal file
24
src/FilterLists.Api/V1/Controllers/TagsController.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class TagsController : BaseController
|
||||
{
|
||||
public TagsController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("TagsController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<Tag, TagSeedDto>();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@ namespace FilterLists.Data.Entities
|
|||
{
|
||||
public class Tag : BaseEntity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public ICollection<FilterListTag> FilterListTags { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.Seed.Models.Junctions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class FilterListTagSeedDto
|
||||
{
|
||||
public uint FilterListId { get; set; }
|
||||
public uint TagId { get; set; }
|
||||
}
|
||||
}
|
||||
12
src/FilterLists.Services/Seed/Models/TagSeedDto.cs
Normal file
12
src/FilterLists.Services/Seed/Models/TagSeedDto.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.Seed.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class TagSeedDto
|
||||
{
|
||||
public uint Id { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue