@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>"})

 

posted on 2020-10-26 11:49  dancser  阅读(1898)  评论(0编辑  收藏  举报