@Select({ "<script>", "select", "id, name, user_id", "from label", "where id in", "<foreach collection='ids' item='id' open='(' separator=',' close=')'>", "#{id}", "</foreach>", "</script>" }) List<LabelDTO> getLabelsByIds(@Param("ids") List<Long> ids);
注意:
1,@Select后面的括號包含大括號
2, 使用<script>標簽
3,@Select后面大括號中的代碼,每行后面使用逗號結束
2、當參數為空則不添加該參數的判斷
@Select({"<script>", "SELECT * FROM tbl_order", "WHERE 1=1", "<when test='title!=null'>", "AND mydate = #{mydate}", "</when>", "</script>"})