<?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.ytpm.middle.dao.AgentMapper">
    <insert id="addOneUser">
        insert into yt_platform_user
        (
         user_id,
         nick_name,
         head_image,
         login_name,
         encrypt_pwd,
         salt,
         phone,
         last_login_time,
         account_status,
         user_type,
         registry_time
        )
        values
        (
         #{userId},
         #{nickName},
         #{headImage},
         #{loginName},
         #{encryptPwd},
         #{salt},
         #{phone},
         #{lastLoginTime},
         #{accountStatus},
         #{userType},
         #{registryTime}
        );
    </insert>
    <update id="resetPwd">
        update yt_platform_user
        set encrypt_pwd = #{encrypt}
        where user_id = #{userId}
    </update>

    <select id="getBaseInfoList" resultType="com.ytpm.middle.view.AgentBaseInfoListVO">
        select
        me.enterprise_id,
        me.user_id,
        me.enterprise_name,
        me.enterprise_type,
        me.credit_code,
        me.legal,
        me.legal_card,
        me.concat_phone,
        me.business_licence,
        me.registry_address,
        me.create_time,
        me.create_user_id,
        me.update_time,
        me.update_user_id,
        me.available,
        pu.login_name,
        pu.user_type,
        me.taku_public_key,
        pu1.nick_name createUserName
        from yt_middle_enterprise me
        join yt_platform_user pu on me.user_id = pu.user_id
        join yt_platform_user pu1 on me.create_user_id = pu1.user_id
        <where>
            <if test="enterpriseName != null and enterpriseName != ''">
                and me.enterprise_name like concat('%',#{enterpriseName},'%')
            </if>
        </where>
    </select>
</mapper>