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

  -- 获取学校办别
  #sql("getDmSchoolProperty")
    select property_id,property_name from t_dm_schoolproperty
  #end

   -- 获取学校隶属关系
  #sql("getDmSchoolLevel")
    select * from t_dm_schoollevel
  #end

  -- 获取编制的字典
  #sql("getDmBz")
      select bz_id,bz_name from t_dm_bz
  #end

  -- 获取性别的字典
  #sql("getDmXb")
      select xb_id,xb_name from t_dm_xb
  #end

  -- 获取民族的字典
  #sql("getDmMz")
      select mz_id,mz_name from t_dm_mz
  #end

  -- 获取学段字典
  #sql("getDmStage")
      select stage_id,stage_name from t_dm_stage where b_use=1 order by sort_id
  #end

  -- 获取指定学段下的学科
  #sql("getDmSubject")
      select subject_id,subject_name from t_dm_subject where stage_id=? order by sort_id
  #end

  --获取学历字典信息
  #sql("getDmXl")
       select xl_id,xl_name from t_dm_xl
  #end

  --获取职称字典信息
  #sql("getDmZc")
       select zc_id,zc_name from t_dm_zc
  #end

  --获取政治面貌字典信息
  #sql("getDmZzmm")
       select zzmm_id,zzmm_name from t_dm_zzmm
  #end

  -- 获取全量的行政区划树
  #sql("getAreaAll")
       select id,area_code,area_name,parent_id,(case when parent_id='-1' then 1 else 0 end ) as open  from t_dm_area order by area_code
  #end

  -- 获取指定父节点的行政区划
  #sql("getAreaByParentId")
       select t1.id,t1.area_code,t1.area_name,t1.parent_id,
          if(parent_id='-1', 1 , 0 ) as open,
          (select count(1) from t_dm_area as t2 where t2.parent_id=t1.id) as is_leaf
       from t_dm_area as t1 where t1.parent_id=? order by t1.area_code
  #end

  -- 获取指定节点的行政区划
  #sql("getAreaById")
       select t1.id,t1.area_code,t1.area_name,t1.parent_id,t1.province_id,
       (select area_name from t_dm_area as t2 where t1.province_id=t2.id) as province_name,t1.city_id,t1.area_id,t1.level_id,t1.sort_id from t_dm_area as t1
        where t1.id=? order by t1.sort_id
  #end

  -- 获取指定父节点的行政区划
  #sql("getOrgLevel")
      select org_id,org_code,org_name,parent_id,org_type_id,school_type_id,sort_id,create_time,update_ts,b_use,org_pk_num,city_id,area_id,main_school_id,bureau_id
      from t_base_organization where org_id=?
  #end

  -- 获取学校类型
  #sql("getSchoolType")
      select school_type_id,school_type_name from t_dm_schooltype
  #end

  -- 将学校类型换算成组织机构类型
  #sql("convertSchoolTypeToOrgType")
      select shi_org_type,area_org_type from t_dm_schooltype where school_type_id=?
  #end

  -- 通过ID获取区域的信息
  #sql("getAreaInfoById")
    select * from t_dm_area where id=?
  #end

  -- 获取学段下学科名称集合，用于EXCEL导入
  #sql("getStageSubjectNameRecord")
    select t2.stage_name,t1.subject_name from t_dm_subject as t1 inner join t_dm_stage as t2
      on t1.stage_id=t2.stage_id where t2.b_use=1
  #end

  -- 获取有哪些学生来源
  #sql("getStudentSource")
    select source_id,source_name from t_dm_student_source
  #end

  -- 获取当前安装市下有哪些县区
  #sql("getAllAreaInfoByInstallCity")
    select id,area_code,area_name from t_dm_area where parent_id=
        (select global_value from t_base_global where global_code='install_area') order by sort_id
  #end

  -- 系统中共有多少种身份
  #sql("getDmIdentity")
    select identity_id,identity_name from t_dm_identity
  #end

  -- 获取城市的坐标
  #sql("getCityCoordinate")
    select * from t_city_coordinate where city_id=?
  #end
#end