-- 全局变量命名空间
#namespace("global")

  -- 获取全局变量的分类类型
  #sql("getGlobalType")
      select global_type_id,global_type_name from t_base_global_type
  #end

  -- 获取所有分类
  #sql("getGlobalList")
    select global_id,global_type_id,global_code,global_value,global_name,sort_id from t_base_global order by sort_id
  #end

  -- 检查一个globalCode是不是重复
  #sql("checkGlobalCodeCount")
    select count(1) as c from t_base_global where global_id!=? and global_code=?
  #end

  -- 增加一个全局变量设置
  #sql("addGlobal")
    insert into t_base_global(global_type_id,global_code,global_value,global_name,sort_id) values(?,?,?,?,?)
  #end

  -- 修改一个全局变量设置
  #sql("updateGlobalById")
    update t_base_global set global_type_id=?,global_code=?,global_value=?,global_name=?,sort_id=? where global_id=?
  #end

  -- 删除一个全局变量设置
  #sql("delGlobalById")
    delete from t_base_global  where global_id=?
  #end

  -- 获取一个全局变量设置
  #sql("getGlobalById")
    select global_type_id,global_code,global_value,global_name from t_base_global  where global_id=?
  #end

  -- 传入一组global_code 返回对应的数据
  #sql("getGlobalByCodes")
    select global_id,global_type_id,global_code,global_value,global_name from t_base_global where global_code=?
  #end

  -- 获取area_id通过area_name
  #sql("getAreaIdByAreaName")
    select id from t_dm_area as t2 where t2.area_name=? and parent_id=(select id from t_dm_area as t1 where t1.area_name=?)
  #end
  #sql("getAreaIdByAreaNameOnlyCityName")
    select id  from t_dm_area as t1 where t1.area_name=?
  #end
  -- 保存设置安装地区
  #sql("saveInstallArea")
    update  t_base_global set global_value=? where global_code='install_area'
  #end
  -- 根据全局变量的KEY获取VALUE
  #sql("getGlobalValueByKey")
        select ifnull(global_value,'') as global_value from t_base_global where global_code = ?
  #end
#end