1.对应xml文件
<insert id="insert" parameterType="DetectStandard"
useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into t_detect_standard
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="standardCode != null" >
standard_code,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="standardCode != null" >
#{standardCode,jdbcType=VARCHAR},
</if>
</trim>
</insert>
2.后台对应获取主键ID:
//添加检测标准
detectStandardMapper.insert(ds);
int standardId = ds.getId();//获得标准ID