<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.crm.ucard.dao.mapper.CardFileMapper">
    <insert id="insert">
        INSERT INTO `ucard_file`
        (`tag`, `lang`,`pdf_path`,`pdf_password`, `file_info`, `add_time`, `add_user`, `add_ip`, `modify_time`, `modify_user`, `modify_ip`, `note`)
        VALUES
            (#{tag}, #{lang},#{pdfPath},#{pdfPassword}, #{fileInfo}, #{addTime}, #{addUser}, #{addIp}, #{modifyTime}, #{modifyUser}, #{modifyIp}, #{note})
            ON DUPLICATE KEY UPDATE
             `file_info` = VALUES(`file_info`),
             `pdf_path` = VALUES(`pdf_path`),
             `pdf_password` = VALUES(`pdf_password`),
             `modify_time` = VALUES(`modify_time`)
    </insert>

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.ucard.CardFilePageEntity">
        SELECT COUNT(*)
        FROM ucard_file
        <where>
            <if test="lang != null and lang != ''">
                and `lang` = #{lang}
            </if>
        </where>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.core.dto.ucard.CardFileDto"
            parameterType="com.crm.rely.backend.core.entity.ucard.CardFilePageEntity">
        SELECT
        *
        FROM ucard_file
        <where>
            <if test="lang != null and lang != ''">
                and `lang` = #{lang}
            </if>
        </where>
        ORDER BY id DESC
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>
    </select>


</mapper>