import { ACCEPT_MAP } from 'src/resource/service/resource.service';
import { DataSource } from 'typeorm';

export async function handler(dataSource: DataSource, { user }) {
  return dataSource.query(`
    select count(id) count, type from resource r
    where type in('${Object.keys(ACCEPT_MAP).join("','")}') and r.del_flag=0
    ${user ? `and creator='${user.userId}'` : ''}
    group by type
    order by type
  `);
}
