1.dao传参

    long commDeleteByConditions(@Param("tableName") String tableName, @Param("condition") Map conditions);

2. mapper.xml

<delete id="commDeleteByConditions">
        delete from ${tableName}
        <where>
            <foreach collection="condition.keys" item="k1" separator="and">
                <if test="@com.xxx.common.utils.SysUtils@isNotNullOrEmpty(condition[k1])">
                    <choose>
                        <when test="@com.xxx.common.utils.SysUtils@isCollection(condition[k1])">
                            ${k1} in
                            <foreach collection="condition[k1]" item="v" separator="," open="(" close=")">
                                #{v}
                            </foreach>
                        </when>
                        <otherwise>
                            ${k1} = #{condition[${k1}]}
                        </otherwise>
                    </choose>
                </if>
                <if test="@com.xxx.common.utils.SysUtils@isNullOrEmpty(condition[k1])">
                    (${k1} is null or ${k1} = '')
                </if>
            </foreach>
        </where>       
    </delete>

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐