Mybatis @Param注解
用来在DAO层标注入参对mapper层的名称,例如DAO层为
List<HourWorkReport> selectHourWorkReportList(@Param("startDate") String startDate, @Param("endDate") String endDate);
在mapper层会识别入参startDate和endDate:
<select id="selectHourWorkReportList" resultMap="BaseResultMap">
<include refid="selectHourWorkReportVo"></include>
<where>
<if test="startDate != null ">and date_format(DATE,'%Y-%m-%d') >= str_to_date(#{startDate},'%Y-%m-%d')</if>
<if test="endDate != null ">and date_format(DATE,'%Y-%m-%d') <= str_to_date(#{endDate},'%Y-%m-%d')</if>
</where>
</select>