<?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="cn.com.ctop.common.module.mapper.BindAccountLoginMapper">

    <select id="getProjectByParams" resultType="cn.com.ctop.common.module.vo.PangolinProjectVO">
        select
            project.project_name,
            project.id as 'project_id'
        from
            ctop_bind_account_login login
            left join ctop_project project on login.project_id = project.id
        where 1=1
        <if test="userId!=null">
            and user_id = #{userId}
        </if>
        <if test="loginType!=null">
            and login_type = #{loginType}
        </if>
        group by project_id
    </select>
    <select id="getAccountByParams" resultType="cn.com.ctop.common.module.vo.PangolinAccountVO">
        select
        login.account_id,
        login.account_name
        from
        ctop_bind_account_login login
        left join ctop_project project on login.project_id = project.id
        where 1=1
        <if test="userId!=null">
            and login.user_id = #{userId}
        </if>
        <if test="loginType!=null">
            and login.login_type = #{loginType}
        </if>
        <if test="projectId!=null">
            and project.id = #{projectId}
        </if>
    </select>
</mapper>
