xxxMapper.xml 文件中 sql 标签的使用

    <sql id="selectCenterSystemFileVo">
        select id, file_name, file_pattern, update_cycle, custom_time, create_time, modify_time, remark, status, del_flag from center_system_file
    </sql>
    <select id="selectCenterSystemFileList" parameterType="CenterSystemFile" resultMap="CenterSystemFileResult">
        <include refid="selectCenterSystemFileVo"/><!-- refid 重新定义 sql 里面为 id -->
        <where><!-- 条件 -->
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="filePattern != null "> and file_pattern = #{filePattern}</if>
            <if test="updateCycle != null "> and update_cycle = #{updateCycle}</if>
            <if test="customTime != null "> and custom_time = #{customTime}</if>
            <if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>

    <select id="selectCenterSystemFileById" parameterType="Long" resultMap="CenterSystemFileResult">
        <include refid="selectCenterSystemFileVo"/><!-- 同理 -->
        where id = #{id}
    </select>

    <insert id="insertCenterSystemFile" parameterType="CenterSystemFile" useGeneratedKeys="true" keyProperty="id">
        insert into center_system_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileName != null">file_name,</if>
            <if test="filePattern != null">file_pattern,</if>
            <if test="updateCycle != null">update_cycle,</if>
            <if test="customTime != null">custom_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="modifyTime != null">modify_time,</if>
            <if test="remark != null">remark,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileName != null">#{fileName},</if>
            <if test="filePattern != null">#{filePattern},</if>
            <if test="updateCycle != null">#{updateCycle},</if>
            <if test="customTime != null">#{customTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="modifyTime != null">#{modifyTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateCenterSystemFile" parameterType="CenterSystemFile">
        update center_system_file
        <trim prefix="SET" suffixOverrides=","><!-- trim 的用法 -->
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="filePattern != null">file_pattern = #{filePattern},</if>
            <if test="updateCycle != null">update_cycle = #{updateCycle},</if>
            <if test="customTime != null">custom_time = #{customTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="modifyTime != null">modify_time = #{modifyTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCenterSystemFileById" parameterType="Long">
        delete from center_system_file where id = #{id}
    </delete>

    <delete id="deleteCenterSystemFileByIds" parameterType="String">
        delete from center_system_file where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
posted @   村上春树的叶子  阅读(150)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示