55 lines
1.2 KiB
C#
55 lines
1.2 KiB
C#
using Bunny.Common.EFCore;
|
|
using Bunny.Dao.Models.System;
|
|
|
|
namespace Bunny.Service.IService.Service;
|
|
|
|
public class BlogService : IBlogService
|
|
{
|
|
private readonly EfCoreContext _dbContext;
|
|
|
|
public BlogService(EfCoreContext dbContext)
|
|
{
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加Blog
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public void AddBlog(Blog dto)
|
|
{
|
|
_dbContext.Add(dto);
|
|
_dbContext.SaveChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询BLog
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<Blog> QueryBlog()
|
|
{
|
|
return _dbContext.Blogs.ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新Blog内容
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
public void UpdateBlog(Blog dto)
|
|
{
|
|
_dbContext.Blogs.Update(dto);
|
|
_dbContext.SaveChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除BLog
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
public void DeleteBlog(string id)
|
|
{
|
|
var blog = new Blog { Id = id };
|
|
_dbContext.Blogs.Remove(blog);
|
|
_dbContext.SaveChanges();
|
|
}
|
|
} |