namespace YD_Event.Application.Blog;
///
/// 文章所属栏目管理
///
public class ArticleCategoryService : ITransient
{
private readonly ISqlSugarRepository _repository;
public ArticleCategoryService(ISqlSugarRepository repository)
{
_repository = repository;
}
///
/// 添加文章所属栏目
///
/// 文章ID
/// 栏目ID
///
public async Task Add(long articleId, long categoryId)
{
await _repository.InsertAsync(new ArticleCategory()
{
ArticleId = articleId,
CategoryId = categoryId
});
}
///
/// 更新文章所属栏目
///
/// 文章ID
/// 栏目ID
///
public async Task Update(long articleId, long categoryId)
{
await _repository.UpdateAsync(x => new ArticleCategory()
{
CategoryId = categoryId
}, x => x.ArticleId == articleId);
}
}