-- 字典命名空间
#namespace("login")

  #sql("getPersonInfoByPersonId")
    select person_id,person_name,identity_id,login_name,b_use,city_id,area_id,main_school_id,bureau_id
     from t_sys_loginperson where person_id=?
  #end

  -- 获取整个单位类型与职务+分管信息树数据
  #sql("getLoginInfoByUserName")
      select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
       from t_sys_loginperson where b_use = 1 and login_name =?
  #end

  -- 根据手机号获取登录信息
  #sql("getLoginInfoByPhoneNum")
    select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
    from t_sys_loginperson where b_use = 1 and telephone =?
  #end

  -- 根据邮箱获取登录信息
  #sql("getLoginInfoByEmail")
    select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
     from t_sys_loginperson where b_use = 1 and email =?
  #end

  -- 根据QQ的openid获取登录信息
  #sql("getLoginInfoByQqOpenId")
    select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
    from t_sys_loginperson where b_use = 1 and qq_openid =?
  #end

  -- 根据微信的openid获取登录信息
  #sql("getLoginInfoByWxOpenId")
    select person_id,person_name,pwd,ifnull(wx_openid,0) as wx_openid,ifnull(qq_openid,0) as qq_openid,identity_id,bureau_id,city_id,area_id
    from t_sys_loginperson where b_use = 1 and wx_openid =?
  #end

  -- 手机号是否存在
  #sql("getPhoneNumberIsExist")
    select person_id from t_sys_loginperson where b_use = 1 and telephone =?
  #end

  -- 邮箱是否存在
  #sql("getEmailIsExist")
    select person_id from t_sys_loginperson where b_use = 1 and email =?
  #end

  -- 修改密码
  #sql("updatePwd")
    update t_sys_loginperson set pwd = ? where person_id = ?
  #end

  -- 更新人员的QQ open id
  #sql("UpdateQqOpenId")
    update t_sys_loginperson set qq_openid = ? where person_id = ?
  #end

  -- 更新人员的微信
  #sql("UpdateWeiXinOpenId")
    update t_sys_loginperson set wx_openid = ? where person_id = ?
  #end

  -- 根据全局变量的KEY获取VALUE
  #sql("getGlobalValueByKey")
    select ifnull(global_value,'') as global_value from t_base_global where global_code = ?
  #end  

  -- 根据IP获取SSO注册信息
  #sql("getSsoRegisterByIp")
    select service_id from t_sso_registerservice where b_use = 1 and  prefix = ?
  #end
  
  -- 根据人员ID获取账号挂载信息
  #sql("getAccountMountTypeBPersonId")
  	select account_type,main_person_id from t_sys_account_mount where person_id = ?
  #end

  -- 根据人员ID是否是主账号
  #sql("getIsMainAccountByPersonId")
    select id from t_sys_account_mount where main_person_id = ?
  #end

  -- 根据主帐号人员ID获取子账号信息
  #sql("getSubAccountInfoByMainAccountPersonId")
    select t2.person_id,t2.person_name,t2.identity_id from t_sys_account_mount t1 inner join t_sys_loginperson t2 on t1.person_id=t2.person_id and t2.b_use =1 where t1.main_person_id = ?
  #end




#end