started to update articlesTable with entities
This commit is contained in:
parent
ae8b0266e5
commit
a343fa2d7f
@ -1,3 +1,4 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Dto;
|
namespace Newsbot.Collector.Domain.Dto;
|
||||||
@ -17,7 +18,7 @@ public class ArticleDto
|
|||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
public string? AuthorName { get; set; }
|
public string? AuthorName { get; set; }
|
||||||
public string? AuthorImage { get; set; }
|
public string? AuthorImage { get; set; }
|
||||||
public static ArticleDto Convert(ArticlesModel article)
|
public static ArticleDto Convert(ArticlesModel article)
|
||||||
{
|
{
|
||||||
return new ArticleDto
|
return new ArticleDto
|
||||||
{
|
{
|
||||||
@ -36,4 +37,24 @@ public class ArticleDto
|
|||||||
AuthorImage = article.AuthorImage,
|
AuthorImage = article.AuthorImage,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArticleDto Convert(ArticlesEntity article)
|
||||||
|
{
|
||||||
|
return new ArticleDto
|
||||||
|
{
|
||||||
|
ID = article.Id,
|
||||||
|
SourceID = article.SourceId,
|
||||||
|
Tags = article.Tags.Split(','),
|
||||||
|
Title = article.Title,
|
||||||
|
Url = article.Url,
|
||||||
|
PubDate = article.PubDate,
|
||||||
|
Video = article.Video,
|
||||||
|
VideoHeight = article.VideoHeight,
|
||||||
|
VideoWidth = article.VideoWidth,
|
||||||
|
Thumbnail = article.Thumbnail,
|
||||||
|
Description = article.Description,
|
||||||
|
AuthorName = article.AuthorName,
|
||||||
|
AuthorImage = article.AuthorImage,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,13 +1,14 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Interfaces;
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
public interface IArticlesRepository : ITableRepository
|
public interface IArticlesRepository : ITableRepository
|
||||||
{
|
{
|
||||||
List<ArticlesModel> List(int page, int count);
|
List<ArticlesEntity> List(int page, int count);
|
||||||
List<ArticlesModel> ListBySourceId(Guid id, int page = 0, int count = 25);
|
List<ArticlesModel> ListBySourceId(Guid id, int page = 0, int count = 25);
|
||||||
ArticlesModel GetById(Guid ID);
|
ArticlesModel GetById(Guid ID);
|
||||||
ArticlesModel GetByUrl(string url);
|
ArticlesModel GetByUrl(string url);
|
||||||
ArticlesModel New(ArticlesModel model);
|
ArticlesEntity New(ArticlesEntity model);
|
||||||
void DeleteAllBySourceId(Guid sourceId);
|
void DeleteAllBySourceId(Guid sourceId);
|
||||||
}
|
}
|
15
makefile
15
makefile
@ -21,14 +21,9 @@ docker-run: ## Runs the docker compose
|
|||||||
docker-migrate: ## Runs the migrations stored in the Docker image
|
docker-migrate: ## Runs the migrations stored in the Docker image
|
||||||
docker run -it --env-file .env ghcr.io/jtom38/newsbot.collector:master /app/goose --dir "/app/migrations" up
|
docker run -it --env-file .env ghcr.io/jtom38/newsbot.collector:master /app/goose --dir "/app/migrations" up
|
||||||
|
|
||||||
migrate-dev: ## Apply sql migrations to dev db
|
ef-build: ## Builds migration artifact
|
||||||
goose -dir "./Newsbot.Collector.Database/Migrations" postgres "host=localhost user=postgres password=postgres dbname=postgres sslmode=disable" up
|
dotnet ef migrations bundle --project "Newsbot.Collector.Database"
|
||||||
|
|
||||||
migrate-dev-down: ## revert sql migrations to dev db
|
ef-migrate: ## Runs migrations based on the newest artifact
|
||||||
goose -dir "./Newsbot.Collector.Database/Migrations" postgres "host=localhost user=postgres password=postgres dbname=postgres sslmode=disable" down
|
dotnet ef migrations bundle --project "Newsbot.Collector.Database" --force
|
||||||
|
./efbundle --connection "Host=localhost;Username=postgres;Password=postgres;Database=postgres;sslmode=disable"
|
||||||
migrate-refresh: ## Rolls back all migrations
|
|
||||||
goose -dir "./Newsbot.Collector.Database/Migrations" postgres "host=localhost user=postgres password=postgres dbname=postgres sslmode=disable" reset
|
|
||||||
|
|
||||||
ef-bundle: ## Create a migration bundle
|
|
||||||
dotnet ef migrations bundle --project Newsbot.Collector.Database
|
|
||||||
|
Loading…
Reference in New Issue
Block a user