<insert id=”insert2 ” useGeneratedKeys=” true keyProperty
insert into sys user(
user_name, user_password,
<if test=”userEmail != null and userEmail != ””>
useremail ,
</if>
userinfo, headimg, createtime)
values(
#{userName}, #{userPassword},
<if test=”userEmail != null and userEmail != ””>
#{userEmail} ,
</if>
#{userinfo}, #{headimg,]dbcType=BLOB} ,
#{createTime, jdbcType= TIMESTAMP})
</ insert>
或者 條件拼接
<where>
<!--管理單位 -->
<if test="provinceLevelOrgCode !=null and provinceLevelOrgCode !=''">
and pb.province_level_org_code=#{provinceLevelOrgCode}
</if>
<!--站等級 -->
<if test="stationLevelType !=null and stationLevelType !=''">
and pa.station_level_type=#{stationLevelType}
</if>
<!--廠商 -->
<if test="manufactureName !=null and manufactureName !=''">
and pa.manufacture_name=#{manufactureName}
</if>
<!--產權單位 找不見-->
<if test="">
and
</if>
<!-- 運維單位 -->
<if test="provinceOmOrgName !=null and provinceOmOrgName !=''">
and pb.province_om_org_name=#{provinceOmOrgName}
</if>
<!-- 時間段 開始時間 -->
<if test="stakeDateStart !=null">
and pb.stake_date >=#{stakeDateStart}
</if>
<!-- 時間段 結束時間 -->
<if test="stakeDateEnd !=null">
and pb.stake_date <=#{stakeDateEnd}
</if>
and pa.station_uuid=pb.station_uuid
</where>