转自: https://blog.csdn.net/Appleyk/article/details/81360738
-
-
<dependency>
-
<groupId>tk.mybatis
groupId>
-
<artifactId>mapper-spring-boot-starter
artifactId>
-
<version>1.1.5
version>
-
dependency>
-
@Table(name =
"${tablename}")
-
public
class XXXEntity {
-
-
@Id
-
@GeneratedValue(strategy = GenerationType.IDENTITY)
-
private Long id;
-
}
-
import tk.mybatis.mapper.common.Mapper;
-
-
public
interface XXXMapper extends Mapper<XXXEntity> {
-
/**
-
* 什么都不用写,增删改查由底层的通用Mapper来为我们实现数据实体的增删改查
-
* 如果需要写复杂SQL,需结合XML来配合通用mapper
-
*/
-
}
-
int vID = XXXMapper.insert(XXXEntity);
-
if(vID<
0){
-
throw
new BaseException(ResponseMessage.FAIL,
"创建XXX失败");
-
}
-
-
System.out.println(XXXEntity.getId());
insert into user_content(id, u_id, title, category, content, personal,rpt_time ,img_url,nick_name,upvote,downvote,comment_num) values(#{id}, #{uId},#{title}, #{category},#{content},#{personal},#{rptTime}, #{imgUrl},#{nickName},#{upvote},#{downvote},#{commentNum})