(1)在使用<where></where>,<if></if>等标签符号时一定要加<script></script>标签,其他情况可加可不加。
(2)里面牵涉的大于、小于、大于等于、小于等于符号要分别使用>、<、>=、<=表示否则会出错。
(3)换行结尾可用逗号或者加号。
@Insert({
"<script>",
"insert into phone (",
"id," ,
"phone," ,
"phone_type, " ,
"insert_time," ,
"insert_user ) (" ,
"<foreach collection='phoneInfos' item='phone' index='index' separator='union all'>",
" (select #{phone.id,jdbcType=VARCHAR}, " ,
" #{phone.phone,jdbcType=VARCHAR}, " ,
" #{phone.phone_type,jdbcType=VARCHAR}, " ,
" to_date(#{phone.insert_time,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss'), " ,
" #{phone.insert_user,jdbcType=VARCHAR} from dual)" ,
"</foreach> )",
"</script>"
})
int betchInsertPhone(@Param("phoneInfos")List<PhoneInfo> phoneInfos);
@Select(" <script> " +
" select count(*) from phone t " +
" <where>"+
" <if test='phone !=null and phone!=\"\"'>" +
" and t.phone like '%${phone}%'" +
" </if> " +
" <if test='startDate !=null and startDate!=\"\"'> " +
" and t.insert_time >= to_date('${startDate}','yyyy-mm-dd hh24:mi:ss') " +
" </if> " +
" <if test='endDate !=null and endDate!=\"\"'> " +
" and t.insert_time <= to_date('${endDate}','yyyy-mm-dd hh24:mi:ss') " +
" </if>" +
" </where>" +
" </script>")
int countPhoneManager(@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("phone") String phone);