|
1 | | -import { Material_Type, User, Assembly, Material_Status, Material } from '@prisma/client'; |
| 1 | +import { Manufacturer, Role, Material_Type, User, Assembly, Material_Status, Material } from '@prisma/client'; |
2 | 2 | import { isAdmin, isGuest, isLeadership, isProject, LinkCreateArgs, LinkType, Project, WbsNumber, wbsPipe } from 'shared'; |
3 | 3 | import projectQueryArgs from '../prisma-query-args/projects.query-args'; |
4 | 4 | import prisma from '../prisma/prisma'; |
@@ -28,8 +28,10 @@ import { |
28 | 28 | } from '../utils/description-bullets.utils'; |
29 | 29 | import linkQueryArgs from '../prisma-query-args/links.query-args'; |
30 | 30 | import linkTypeQueryArgs from '../prisma-query-args/link-types.query-args'; |
| 31 | +import manufacturerQueryArgs from '../prisma-query-args/manufacturers.query-args'; |
31 | 32 | import { linkTypeTransformer } from '../transformers/links.transformer'; |
32 | 33 | import { updateLinks, linkToChangeListValue } from '../utils/links.utils'; |
| 34 | +import { manufacturerTransformer } from '../transformers/manufacturer.transformer'; |
33 | 35 | import { isUserPartOfTeams } from '../utils/teams.utils'; |
34 | 36 |
|
35 | 37 | export default class ProjectsService { |
@@ -783,6 +785,22 @@ export default class ProjectsService { |
783 | 785 | return newManufacturer; |
784 | 786 | } |
785 | 787 |
|
| 788 | + /** |
| 789 | + * Get all the manufacturers in the database. |
| 790 | + * @returns all the manufacturers |
| 791 | + */ |
| 792 | + static async getAllManufacturers(submitter: User): Promise<Manufacturer[]> { |
| 793 | + if (submitter.role === Role.GUEST) { |
| 794 | + throw new AccessDeniedGuestException('Get Manufacturers'); |
| 795 | + } |
| 796 | + |
| 797 | + return ( |
| 798 | + await prisma.manufacturer.findMany({ |
| 799 | + ...manufacturerQueryArgs |
| 800 | + }) |
| 801 | + ).map(manufacturerTransformer); |
| 802 | + } |
| 803 | + |
786 | 804 | /** |
787 | 805 | * Create a new material type |
788 | 806 | * @param name the name of the new material type |
|
0 commit comments