加一个参数控制sql查询语句条件

想要用一个参数控制sql查询语句的where条件,当传入的参数为1是where后面加条件一,参数为2时where后面加条件二
目前sql语句写好了,想问一下在dao层如何修改
原先的sql语句会用到两个string类参数,现在加一个string类名为type来控制调用哪个条件
type的值我想在dao层调用这个语句时自己确定
这要怎么写来传参


 <select id="selectByType" resultType="com.example.xxx.test">
        select * from test where 1=1
        <if test="type!= null and type!='' and type== 1">
            and xxx1=xxxx1
        </if>
        <if test="type!= null and type!='' and type== 2">
            and xxx2=xxxx2
        </if>
    </select>

第一种是dao层传参 直接传两个参数(@Param(”id”)String id, @Param(”item_id”)String item_id) 但是需要加上@Param
第二种是dao层直接传一个实体类,实体类的属性包含你这两个属性


<select id="queryAllByItem" resultMap="ItemParamItemMap">
        select
          id, item_id, param_data, created, updated
        from tb_item_param_item
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="itemId != null">
                and item_id = #{itemId}
            </if>
            <if test="paramData != null and paramData != ''">
                and param_data = #{paramData}
            </if>
            <if test="created != null">
                and created = #{created}
            </if>
            <if test="updated != null">
                and updated = #{updated}
            </if>
        </where>
    </select>

用mybatis的吗?