2024-08-09 10:06:17 +08:00
|
|
|
|
using Bunny.Common.Connect;
|
2024-08-09 00:16:40 +08:00
|
|
|
|
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();
|
|
|
|
|
}
|
2024-08-09 09:26:32 +08:00
|
|
|
|
|
|
|
|
|
/// <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();
|
|
|
|
|
}
|
2024-08-09 00:16:40 +08:00
|
|
|
|
}
|