import { DataSource } from 'typeorm';

export async function handler(dataSource: DataSource, { user, query }) {
  const [data] = await dataSource.query(`
    select count(id) total,sum(r.size) size from resource r
    where r.del_flag = 0 and r.type != 'folder' and r.creator = '${user.userId}'
      ${query.type && `and r.type in ('${query.type.replace(/,/g, "','")}')`}
  `);
  return data;
}
