数据库字段

实体类
public class Article {//一定要记得加 要不然 会出现精度损失
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private String title;
private String summary;
private Integer commentCounts;
private Integer viewCounts;
@TableField("author_id")
private Long authorId;
private Long bodyId;
private Long categoryId;
private Integer weight;
private Long createDate;
}
ArticleMapper.xml文件中使用resultMap将字段意义对应
<resultMap id="articleMap" type="com.he.blogapi.pojo.Article">
<id column="id" property="id" />
<result column="author_id" property="authorId"/>
<result column="comment_counts" property="commentCounts"/>
<result column="create_date" property="createDate"/>
<result column="summary" property="summary"/>
<result column="title" property="title"/>
<result column="view_counts" property="viewCounts"/>
<result column="weight" property="weight"/>
<result column="body_id" property="bodyId"/>
<result column="category_id" property="categoryId"/>
</resultMap>
增删改查时使用resultMap如下调用即可
<select id="listArticle" resultMap="articleMap">