<?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.ProjectInfoDAO">
    <resultMap id="ProjectInfoMap" type="com.jpsoft.shinestar.modules.base.entity.ProjectInfo">
        <id property="id" column="id_"/>
        <result property="projectCode" column="project_code"/>
        <result property="appId" column="app_id"/>
        <result property="appSecret" column="app_secret"/>
        <result property="companyId" column="company_id"/>
        <result property="socialCreditCode" column="social_credit_code"/>
        <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"/>
    </resultMap>
    <insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.ProjectInfo">
        <!--
        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
            select sys_guid() from dual
        </selectKey>
        -->
        <![CDATA[
		insert into base_project_info
	    (id_,project_code,app_id,app_secret,company_id,social_credit_code,create_by,create_time,update_by,update_time,del_flag)
		values
		(
			#{id,jdbcType=VARCHAR}
			,#{projectCode,jdbcType=VARCHAR}
			,#{appId,jdbcType=VARCHAR}
			,#{appSecret,jdbcType=VARCHAR}
			,#{companyId,jdbcType=VARCHAR}
			,#{socialCreditCode,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_project_info where id_=#{id,jdbcType=VARCHAR}
    </delete>
    <update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.ProjectInfo">
        update base_project_info
        <set>
            <if test="projectCode!=null">
                project_code=#{projectCode,jdbcType=VARCHAR},
            </if>
            <if test="appId!=null">
                app_id=#{appId,jdbcType=VARCHAR},
            </if>
            <if test="appSecret!=null">
                app_secret=#{appSecret,jdbcType=VARCHAR},
            </if>
            <if test="companyId!=null">
                company_id=#{companyId,jdbcType=VARCHAR},
            </if>
            <if test="socialCreditCode!=null">
                social_credit_code=#{socialCreditCode,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="ProjectInfoMap">
        select
        id_,project_code,app_id,app_secret,company_id,social_credit_code,create_by,create_time,update_by,update_time,del_flag
        from base_project_info where id_=#{0}
    </select>
    <select id="exist" parameterType="string" resultType="int">
        select count(*) from base_project_info where id_=#{0}
    </select>
    <select id="list" resultMap="ProjectInfoMap">
        select * from base_project_info
    </select>
    <select id="search" parameterType="hashmap" resultMap="ProjectInfoMap">
        <![CDATA[
			select * from base_project_info
		]]>
        <where>
            <if test="searchParams.id != null">
                and ID_ like #{searchParams.id}
            </if>
        </where>
        <foreach item="sort" collection="sortList" open="order by" separator=",">
            ${sort.name} ${sort.order}
        </foreach>
    </select>
    <select id="findOneByCompanyId" parameterType="string" resultMap="ProjectInfoMap">
        select *
        from base_project_info where company_id=#{0} and del_flag=0 limit 1
    </select>
    <select id="findOneByProjectCode" parameterType="string" resultMap="ProjectInfoMap">
        select *
        from base_project_info where project_code=#{0} and del_flag=0 limit 1
    </select>
</mapper>