#namespace("student")

  -- 根据学生的ID获取家长的信息
  #sql("getParentByChildId")
   select * from t_sys_loginperson where p_child_id=?
  #end

  -- 获取学生列表
  #sql("getStudentOrParentList")
      SELECT
        t1.person_id,
        t1.person_name,
        t1.login_name,
        coalesce(t1.xb, '1') AS xb,
        t1.original_pwd,
        t1.pwd,
          (select count(*) as c from t_transfer_apply as t2  where t2.person_id=t1.person_id and t2.status_id=1 and t2.b_use=1)
        as apply_status
      FROM
        t_sys_loginperson as t1
      WHERE
        t1.b_use = 1
      AND t1.identity_id = #para(0)
      AND t1.s_class_id = #para(1) order by t1.sort_id
  #end

  -- 获取学生列表按学生姓名
  #sql("getStudentOrParentListByPersonName")
      SELECT
        t1.person_id,
        t1.person_name,
        t1.login_name,
        coalesce(t1.xb, '1') AS xb,
        t1.original_pwd,
         (select count(*) as c from t_transfer_apply as t2  where t2.person_id=t1.person_id and t2.status_id=1 and t2.b_use=1)
        as apply_status
      FROM
        t_sys_loginperson as t1
      WHERE
        t1.b_use = 1
      AND t1.identity_id = #para(0)
      AND t1.s_class_id = #para(1)
      AND t1.person_name LIKE concat('%',#para(2),'%') order by t1.sort_id
  #end


  -- 根据学生ID获取学生信息
  #sql("getStudentInfoByPersonId")
    SELECT
        person_id,
        person_name,
        coalesce(xb, '1') AS xb,
        coalesce(mz, '01') AS mz,
        idcard_code,
        birthday,
        zzmm,
        (case when s_xjh='-1' then '' else s_xjh end) AS xjh,
        (case when s_xjfh='-1' then '' else s_xjfh end) AS xjfh,
        s_source AS stu_source,
        sort_id
      FROM
        t_sys_loginperson
      WHERE
        b_use = 1
      AND person_id = ?
  #end
#end