1.mapper.java中
List<MacTicket> selectByPrimaryKeyList(String[] stringArray);
mapper.xml中
<select id="selectByPrimaryKeyList" parameterType="int" resultMap="BaseResultMap">
<foreach collection="array" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
亲测,重点说下parameterType实际不写也可以,或者写其他的都行,但是collection="array"这个必须写,mapper.java中的String[]也必须写
2.mapper.xml中if判断
<sql> sql片段中表的别名例如ticket和sql语句中尽量统一,引用此sql片段的语句的别名遵循sql片段的表别名
<if test="statusCd!=null and statusCd!=''"></if> if判断时null和空串都要判断
<if test="name !=null and name!=''">and ticket.name like concat ('name',#{name},'%')</if> 模糊查询
<if test="createTimeStart=null and createTimeStart!=''">and ticket.create_time >#{createTimeStart}</if> 大于等于
<if test="createTimeEnd=null and createTimeEnd!=''">and ticket.create_time <#{createTimeEnd}</if> 小于等于
</sql>