<sql id="sql_count"> select count(*) </sql>
<sql id="sql_select"> select * </sql>
<sql id="sql_where">
from icp
<dynamic prepend="where">
<isNotEmpty prepend="and" property="name">
name like '%$name$%'
</isNotEmpty>
<isNotEmpty prepend="and" property="area_id">
area_id = #area_id#
</isNotEmpty>
</dynamic>
<dynamic prepend="">
<!--这里相当于if的and条件判断了,也即start和size都不能为空-->
<isNotNull property="_start">
<isNotNull property="_size">
limit #_start#, #_size#
</isNotNull>
</isNotNull>
</dynamic>
</sql>
<select id="findByParamsForCount" parameterClass="map" resultClass="int">
<include refid="sql_count"/>
<include refid="sql_where"/>
</select>
<!--这个判断了not null 和空串 功能比not null 标签强大-->
<isNotEmpty prepend="and" property="_img_size_ge">
<![CDATA[
img_size >= #_img_size_ge#
]]>
<isEqual prepend="and" property="_exeable" compareValue="Y">
<![CDATA[
t.finished in ('10','19') and t.failure<3
]]>
</isEqual>
<isNotEmpty prepend="" property="exprogramcode">
<isNotEmpty prepend="" property="isRational">
<isEqual prepend="and" property="isRational" compareValue="N">
code not in
(select t.contentcode from cms_ccm_programcontent t where t.contenttype='MZNRLX_MA'
and t.programcode = #exprogramcode#)
</isEqual>
</isNotEmpty>
</isNotEmpty>
<select id="idtet" parameterClass="map" resultClass="java.util.HashMap"> <include refid="sql_select"/>
<include refid="sql_where"/>
</select>
<insert id="insert" parameterClass="RuleMaster">
insert into rulemaster( name, createtime, updatetime, remark ) values ( #name#, now(), now(), #remark# )
<selectKey keyProperty="id" resultClass="long">
select LAST_INSERT_ID()
</selectKey>
</insert>