<?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.ejweb.modules.front.report.dao.FrontReportDao">
    <sql id="reportColumns">
        id,
        report_project,
        report_city,
        report_time,
        report_content,
        report_person_name,
        report_person_tel,
        report_person_email,
        report_source,
        report_status,
        supplement_company,
        supplement_department,
        supplement_informant,
        supplement_title,
        supplement_type,
        supplement_area,
        supplement_project,
        supplement_content,
        deal_person_name,
        deal_result,
        exchange_before_user,
        exchange_after_user,
        create_by,
        create_date,
        update_by,
        update_date
    </sql>
    <insert id="insertReport" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO ct_bbtc_report(
            id,
            report_project,
            report_city,
            report_time,
            report_content,
            report_person_name,
            report_person_tel,
            report_person_email,
            report_source,
            report_status,
            supplement_informant,
            supplement_title,
            exchange_before_user,
            exchange_after_user,
            create_by,
            create_date,
            update_by,
            update_date,
            oa_name,
            report_ip,
            ip_city,
            report_participants,
            report_insider,
            report_suggestion,
            report_Date,
            report_site,
            report_qq,
            report_weixin
        ) VALUES(
            #{id},
            #{reportProject},
            #{reportCity},
            #{reportTime},
            #{reportContent},
            #{reportPersonName},
            #{reportPersonTel},
            #{reportPersonEmail},
            #{reportSource},
            #{reportStatus},
            #{supplementInformant},
            #{supplementTitle},
            #{exchangeBeforeUser},
            #{exchangeAfterUser},
            #{createBy},
            #{createDate},
            #{updateBy},
            #{updateDate},
            #{oaName},
            #{reportIp},
            #{ipCity},
            #{participants},
            #{insider},
            #{suggestion},
            #{reportDate},
            #{site},
            #{qq},
            #{weixin}
        )
    </insert>

    <insert id="insertReportAttachment">
        INSERT INTO ct_bbtc_report_attachment(
            id,
            report_id,
            attachment_name,
            attachment_path,
            attachment_size,
            attachment_type
        )VALUES(
            #{id},
            #{reportId},
            #{attachmentName},
            #{attachmentPath},
            #{attachmentSize},
            #{attachmentType}
        )
    </insert>

    <select id="getUser" parameterType="com.ejweb.modules.sys.entity.User" resultType="com.ejweb.modules.sys.entity.User">
      SELECT u.id
      FROM ct_bbtc_sys_user u
      LEFT JOIN ct_bbtc_sys_user2role u2r ON  u2r.user_id = u.id
      LEFT JOIN ct_bbtc_sys_role r ON r.id = u2r.role_id
      WHERE r.enname = 'admin' AND u.del_flag = 0
        <if test="dbName == 'oracle'"> AND rownum &lt;= 1</if>
        <if test="dbName == 'mysql'"> limit 1</if>
    </select>

</mapper>