<?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">
<!-- namespace必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.base.dao.ProblemFeedbackDAO">
    <resultMap id="ProblemFeedbackMap" type="com.jpsoft.shinestar.modules.base.entity.ProblemFeedback">
        <id property="id" column="id_" />
        <result property="problemContent" column="problem_content" />
        <result property="problemPic" column="problem_pic" />
        <result property="contactTelephone" column="contact_telephone" />
        <result property="remark" column="remark_" />
        <result property="createBy" column="create_by" />
        <result property="createTime" column="create_time" />
        <result property="updateBy" column="update_by" />
        <result property="updateTime" column="update_time" />
        <result property="delFlag" column="del_flag" />
        <result property="createByName" column="create_by_name" />
    </resultMap>
    <insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.ProblemFeedback">
        <!--
        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
            select sys_guid() from dual
        </selectKey>
        -->
        <![CDATA[
		insert into base_problem_feedback
	    (id_,problem_content,problem_pic,contact_telephone,remark_,create_by,create_time,update_by,update_time,del_flag)
		values
		(
#{id,jdbcType=VARCHAR}
,#{problemContent,jdbcType=VARCHAR}
,#{problemPic,jdbcType=VARCHAR}
,#{contactTelephone,jdbcType= VARCHAR }
,#{remark,jdbcType=VARCHAR}
,#{createBy,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
,#{delFlag,jdbcType= NUMERIC }
		)
	]]>
    </insert>
    <delete id="delete" parameterType="string">
        delete from base_problem_feedback where id_=#{id,jdbcType=VARCHAR}
    </delete>
    <update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.ProblemFeedback">
        update base_problem_feedback
        <set>
            <if test="problemContent!=null">
                problem_content=#{problemContent,jdbcType=VARCHAR},
            </if>
            <if test="problemPic!=null">
                problem_pic=#{problemPic,jdbcType=VARCHAR},
            </if>
            <if test="contactTelephone!=null">
                contact_telephone=#{contactTelephone,jdbcType= VARCHAR },
            </if>
            <if test="remark!=null">
                remark_=#{remark,jdbcType=VARCHAR},
            </if>
            <if test="createBy!=null">
                create_by=#{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime!=null">
                create_time=#{createTime,jdbcType= TIMESTAMP },
            </if>
            <if test="updateBy!=null">
                update_by=#{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime!=null">
                update_time=#{updateTime,jdbcType= TIMESTAMP },
            </if>
            <if test="delFlag!=null">
                del_flag=#{delFlag,jdbcType= NUMERIC },
            </if>
        </set>
        where id_=#{id}
    </update>
    <select id="get" parameterType="string" resultMap="ProblemFeedbackMap">
        select * from base_problem_feedback where id_=#{0} and del_flag = 0
    </select>
    <select id="exist" parameterType="string" resultType="int">
        select count(*) from base_problem_feedback where id_=#{0}
    </select>
    <select id="list" resultMap="ProblemFeedbackMap">
		select * from base_problem_feedback
	</select>
    <select id="search" parameterType="hashmap" resultMap="ProblemFeedbackMap">
        <![CDATA[
			select
			a.*,
			b.name_ as create_by_name
			from base_problem_feedback a
			left join base_person_info b on a.create_by = b.id_
		]]>
        <where>
            a.del_flag = 0
            <if test="searchParams.id != null">
                and a.ID_ like #{searchParams.id}
            </if>
            <if test="searchParams.name != null">
                and b.name_ like #{searchParams.name}
            </if>
            <if test="searchParams.phone != null">
                and a.contact_telephone like #{searchParams.phone}
            </if>
            <if test="searchParams.beginTime != null">
                <![CDATA[
                  and a.create_time >= #{searchParams.beginTime}
            	]]>
            </if>
            <if test="searchParams.endTime != null">
                <![CDATA[
                  and a.create_time <= #{searchParams.endTime}
            	]]>
            </if>
        </where>
        <foreach item="sort" collection="sortList"  open="order by" separator=",">
            ${sort.name} ${sort.order}
        </foreach>
    </select>
</mapper>