声明变量 在sql标签中使用变量
<sql id="column_id">
ID, STATE, CREATE_TIME, UPDATE_TIME, SPIDER, VERSION, COMPLETED_AT, QUANTITY
<if test="role == '1'">,123 as role</if>
<if test="role == '2'">,456 as role</if>
</sql>
<select id="selectTest" resultType="com.test.entity.SpiderTaskEntity">
<if test="type == '0'.toString()">
<bind name="role" value="'1'"/>
select
<include refid="column_id"/>
from spider_task st
where st.state = 'OK'
and st.SPIDER = 'amac-pof-pe-issue'
</if>
<if test="type == '0'.toString()">
union
<bind name="role" value="'2'"/>
select
<include refid="column_id"/>
from spider_task st
where st.state = 'OK'
and st.SPIDER = 'amac-pof-off'
</if>
</select>