import { DataSource } from 'typeorm';

export async function handler(dataSource: DataSource) {
  const [data] = await dataSource.query(`
    SELECT

    -- ------ 系统角色
    (
      select count(id) from role where del_flag=0
    ) system_role

    -- ------ 系统用户
    ,(
      select count(id) from user where del_flag=0
    ) system_user

    -- ------ 组织机构
    ,(
      select count(id) from org where del_flag=0
    ) system_org

    -- ------ 系统资源
    ,(
      select count(id) from resource where type!='folder' and del_flag=0
    ) resources

    -- ------ 系统使用
    ,(
      select count(id) from report_data where type='SYSTEM_USE'
    ) sustem_use
  `);
  return data;
}
