比如实现,添加字段,状态的功能!
一。后端:
1.数据库添加字段,domain 添加字段 private String state;
2. Controller,Service,Mapper都不用动,修改Mapper.xml
![](https://i-blog.csdnimg.cn/blog_migrate/49c7d14c263de5155358468f8d1d0e53.png)
3. 在Mappe.xml中resultMap和resultType不能同时使用
4. resultType需要满足(数据库表中的字段名和实体类中的属性完全一致)的情况,才能使用,否则会出现数据不显示的情况
<select id="findAll" resultType="Student">
sql语句
<select>
![](https://i-blog.csdnimg.cn/blog_migrate/72608d30d0b8bdb1e912c454179b8847.png)
5. resultMap可以理解成加强的resultType,resultMap 主要为了domain和数据库字段一 一对应。
6. <resultMap></resultMap>指的是主键的对应关系
column:数据库中表的字段名,property: 实体类中的字段名
<association></association> 配置一对一关系的放到<resultMap>和</resultMap>里面
![](https://i-blog.csdnimg.cn/blog_migrate/a1b079005e255b5de44834fc50e78bee.png)
二。前端
api中的接口不用动
views中的index.vue在类似的添加状态字段
![](https://i-blog.csdnimg.cn/blog_migrate/9c9f9a242133a01bbf571e6081e04c4b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0e88761121b509da2a0c0a6cbbad6d7d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/b174f214526aaf6112dd5d3b5764466f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/c72f9baa6f124b04ef84229591275f53.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e2965d684fd3ba5026f09fb928343e91.png)
这样就能实现现有功能,添加或减少字段的功能