-- 班级命名空间
#namespace("class")

  -- 根据单位号获取下面正常班级的个数
  #sql("getClassCountByBureauId")
    select count(1) as c from t_base_class where bureau_id=? and b_use=1
  #end

  -- 根据单位ID、学段、入学年份获取班级List
  #sql("getClassListByBureauIdStageIdEntryYear")
    select class_name from t_base_class where b_use = 1 and bureau_id= ? and stage_id = ? and entry_year = ?
     order by class_num
  #end

  -- 获取班级列表
  #sql("getClassList")
    select class_id, class_name, coalesce(altas_name,'') as altas_name, entry_year,
      (select count(1) from t_sys_loginperson t2 where t2.b_use = 1 and identity_id = 6 and t2.s_class_id = t1.class_id)
      as studentcount, bureau_id
    from t_base_class t1 where b_use = 1 and bureau_id = #para(0) and stage_id = #para(1)
    and entry_year =#para(2) order by class_num
  #end

  -- 获取班级信息
  #sql("getClassInfoByClassId")
    select class_name,coalesce(altas_name,'') as altas_name, stage_id,entry_year, bureau_id, city_id, area_id, main_school_id
    from t_base_class where b_use = 1 and class_id = ?
  #end

  -- 检查重名班级
  #sql("checkClassNameExists")
    select class_id from t_base_class where b_use = 1 and bureau_id = ? and stage_id = ? and entry_year = ?
    and class_name = ? and class_id <> ?
  #end

  -- 修改班级名称
  #sql("updateClassName")
    update t_base_class set altas_name = ?,operator=?,ip_address=? where class_id = ?
  #end

  -- 删除班级
  #sql("deleteClassById")
    update t_base_class set b_use = 0,operator=?,ip_address=?,class_code=UPPER(UUID()) where class_id = ?
  #end

  #sql("getStudentCountByClassId")
    select person_id from t_sys_loginperson where b_use = 1 and identity_id=6 and s_class_id = ?
  #end

  -- 获取指定单位下有哪些班级名称
  #sql("getClassName")
      select class_id,class_name,stage_id from t_base_class where bureau_id=? and b_use=1
  #end
#end