xml代码笔记(无废话,直接cv)

<select id="pageQuery" resultType="com.sky.entity.Category">
    select * from category
    <where>
        <if test="name != null and name != ''">
            and name like concat('%',#{name},'%')
        </if>
        <if test="type != null">
            and type = #{type}
        </if>
    </where>
    order by sort asc , create_time desc
</select>

<update id="update" parameterType="Category">
    update category
    <set>
        <if test="type != null">
            type = #{type},
        </if>
        <if test="name != null">
            name = #{name},
        </if>
        <if test="sort != null">
            sort = #{sort},
        </if>
        <if test="status != null">
            status = #{status},
        </if>
        <if test="updateTime != null">
            update_time = #{updateTime},
        </if>
        <if test="updateUser != null">
            update_user = #{updateUser}
        </if>
    </set>
    where id = #{id}
</update>

<select id="list" resultType="Category">
    select * from category
    where status = 1
    <if test="type != null">
        and type = #{type}
    </if>
    order by sort asc,create_time desc
</select>
posted @ 2025-07-30 14:36  张大帅Java  阅读(6)  评论(0)    收藏  举报