成功方法:
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND unix_timestamp(enter_time) >= unix_timestamp(#{beginTime})
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND unix_timestamp(enter_time) <= unix_timestamp(#{endTime})
</if>
一开始用的方法是下面这种,通过继承的baseEntity的beginTime和endTime来筛选时间范围内的数据,但是遇到了问题,当开始时间选择19++年这样时,返回数据就为空。而选择时间为2000-2020这个区间时方法就能正常使用。
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(build_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(build_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>