【项目实战】个人博客系统(4)——博客管理

本文详述了个人博客系统的各个核心功能模块,包括博客的新增、查询、删除、编辑和搜索管理。通过MVC架构,涉及实体类、持久层、业务层接口及实现、mapper映射以及控制器的实现,确保了系统的完整性和可操作性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、博客的主要功能模块

  • 博客新增
  • 博客查询
  • 删除博客
  • 编辑修改
  • 搜索博客

老样子:实体类、控制层、持久层、业务层(接口和实现类)、mapper齐活

二、博客新增、查询

新增博客包括:标题、内容、分类、首图地址、博客描述、推荐、转载、赞赏、评论、原创等设置。
博客查询的内容包括:主键、标题、更新时间、是否推荐、是否发布、分类id、分类

1、博客查询实体类(BlogQuery)

public class BlogQuery {
   

    private Long id;
    private String title;
    private Date updateTime;
    private Boolean recommend;
    private Boolean published;
    private Long typeId;
    private Type type;
    
}

2、持久层接口(BlogDao)

//保存新增博客
int saveBlog(Blog blog);

//查询文章管理列表
List<BlogQuery> getAllBlogQuery();

3、mapper

在mapper定义专门的resultMap用于映射多对一的关系

<!--新增保存文章-->
<insert id="saveBlog" parameterType="com.star.entity.Blog">
    insert into myblog.t_blog (id,title, content, first_picture, flag,
    views, comment_count, appreciation, share_statement, commentabled, published,
    recommend, create_time, update_time, type_id, user_id, description)
    values (#{id},#{title},#{content},#{firstPicture},#{flag},#{views},#{commentCount},#{appreciation},
    #{shareStatement},#{commentabled},#{published},#{recommend},#{createTime},
    #{updateTime},#{typeId},#{userId},#{description});
</insert>

<!--查询文章管理列表多对一配置-->
<resultMap id="blog" type="com.star.queryvo.BlogQuery">
    <id property="id" column="id"/>
    <result property="title" column="title"/>
    <result property="updateTime" column="update_time"/>
    <result property="recommend" column="recommend"/>
    <result property="published" column="published"/>
    <result property="typeId" column="type_id"/>
    <association property="type" javaType=<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值