<?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.ruoyi.pda.mapper.LoginMapper">

    <!--登陆-->
    <select id="login_getUser" resultMap="com.ruoyi.system.mapper.SysUserMapper.SysUserResult">
        SELECT user_id,dept_id FROM sys_user where login_name=#{name} and `password`=#{passw}  limit 1;
    </select>
    <select id="login_findSalt" resultType="java.lang.String">

       SELECT salt FROM `sys_user` where login_name=#{name}
    </select>

    <select id="selectMenuName" resultType="java.lang.String">
        select menu_name
        from sys_menu where  parent_id=2185 order by order_num
    </select>
    <select id="selectMenuNameByUserID" resultType="java.lang.String">
        select menu_name
        from sys_role_menu r
                 left join sys_menu m on r.menu_id = m.menu_id
        where r.role_id in (select role_id from sys_user_role where user_id=#{userID})
          and parent_id=2185
        group by menu_name,m.menu_id,m.order_num
        order by m.order_num;
    </select>


    <resultMap type="com.ruoyi.pda.domain.APKVersion" id="PdaApkVersionResult">
        <result property="VersionCode"    column="version_code"    />
        <result property="VersionName"    column="version_name"    />
        <result property="ModifyContent"    column="modify_content"    />
        <result property="DownloadUrl"    column="download_url"    />
        <result property="ApkSize"    column="apk_size"    />
        <result property="ApkMd5"    column="apk_md5"    />
    </resultMap>


    <select id="getVersion" resultMap="PdaApkVersionResult">
        select version_code, version_name, modify_content, download_url, apk_size, apk_md5 from pda_apk_version order by create_time desc limit 1

    </select>


    <select id="apiLogin" resultType="com.ruoyi.pda.domain.ApiUser">
        select u.user_id as id, user_name as name, u.status, sr.role_key as role_name
        from sys_user u
                 left join sys_user_role ur on u.user_id = ur.user_id
                 left join sys_role sr on ur.role_id = sr.role_id and sr.role_name like '测方%'
        where login_name = #{name}
          and u.password = #{pass}
        limit 1;
    </select>
</mapper>