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lC;AAID;IADC,kBAAQ,CAAC,4BAA4B,CAAC;;;;sEAQtC;AAID;IADC,kBAAQ,CAAC,6BAA6B,CAAC;;;;uEAQvC;AA9HQ,oBAAoB;IAFhC,kBAAQ,CAAC,cAAc,CAAC;IACxB,wBAAe,CAAC,4CAAoB,CAAC;IAI7B,WAAA,eAAM,CAAC,0CAAmB,CAAC,CAAA;qCAAuC,0CAAmB;GAHjF,oBAAoB,CAgIhC;AAhIY,oDAAoB","file":"organization.resolver.js","sourcesContent":["import { UsersInOrganizationData } from \"../interface/organization/users.in.organization.data\";\nimport { OrganizationsData } from \"../interface/organization/organizations.data\";\nimport { ExceptionInterceptor } from \"../interceptor/exception.interceptor\";\nimport { HttpException, Inject, UseInterceptors } from \"@nestjs/common\";\nimport { ChildrenData } from \"../interface/organization/children.data\";\nimport { OrganizationService } from \"../service/organization.service\";\nimport { RootsData } from \"../interface/organization/roots.data\";\nimport { Mutation, Query, Resolver } from \"@nestjs/graphql\";\nimport { Data } from \"../interface/data\";\nimport { Request } from \"express\";\n\n@Resolver(\"Organization\")\n@UseInterceptors(ExceptionInterceptor)\nexport class OrganizationResolver {\n\n constructor(\n @Inject(OrganizationService) private readonly organizationService: OrganizationService\n ) {\n }\n\n /* 查找所有根组织 */\n @Query(\"roots\")\n async roots(): Promise<RootsData> {\n const roots = await this.organizationService.getRoots();\n return { code: 200, message: \"获取所有根组织成功\", roots };\n }\n\n /* 查找指定组织的所有子组织 */\n @Query(\"children\")\n async children(req: Request, body: { id: number }): Promise<ChildrenData> {\n const { id } = body;\n if (!id) {\n throw new HttpException(\"缺少参数\", 400);\n }\n const children = await this.organizationService.getChildren(id);\n return { code: 200, message: \"获取子组织成功\", children };\n }\n\n /* 查找所有现存组织 */\n @Query(\"organizations\")\n async organizations(): Promise<OrganizationsData> {\n const organizations = await this.organizationService.getAll();\n return { code: 200, message: \"获取所有组织成功\", organizations: [] };\n }\n\n /* 创建指定名称组织,可选是否指定父组织id */\n @Mutation(\"createOrganization\")\n async createOrganization(req: Request, body: { name: string, parentId: number }): Promise<Data> {\n const { name, parentId } = body;\n if (!name) {\n throw new HttpException(\"缺少参数\", 400);\n }\n if (parentId && !Number.isInteger(parentId)) {\n throw new HttpException(\"父组织Id不是整数\", 401);\n }\n await this.organizationService.createOrganization(name, parentId);\n return { code: 200, message: \"创建组织成功\" };\n }\n\n /* 更新指定id组织,可更新组织名、父组织 */\n @Mutation(\"updateOrganization\")\n async updateOrganization(req: Request, body: { id: number, name: string, parentId: number }): Promise<Data> {\n const { id, name, parentId } = body;\n if (!id || !name) {\n throw new HttpException(\"缺少参数\", 400);\n }\n if (parentId && !Number.isInteger(parentId)) {\n throw new HttpException(\"父组织Id不是整数\", 401);\n }\n await this.organizationService.updateOrganization(id, name, parentId);\n return { code: 200, message: \"更新组织成功\" };\n }\n\n /* 删除指定id组织,默认情况下有子组织会报错,不能删除\n 可以指定force=true,强制删除组织及其子孙组织\n */\n @Mutation(\"deleteOrganization\")\n async deleteOrganization(req: Request, body: { id: number }): Promise<Data> {\n const { id } = body;\n if (!id) {\n throw new HttpException(\"缺少参数\", 400);\n }\n await this.organizationService.deleteOrganization(id);\n return { code: 200, message: \"删除组织成功\" };\n }\n\n /* 查找指定组织下所有用户 */\n @Query(\"usersInOrganization\")\n async usersInOrganization(req: Request, body: { id: number }): Promise<UsersInOrganizationData> {\n const { id } = body;\n if (!id) {\n throw new HttpException(\"缺少参数\", 400);\n }\n const users = await this.organizationService.getUsersInOrganization(id);\n return { code: 200, message: \"获取组织用户成功\", users };\n }\n\n /* 向指定组织添加一个指定用户 */\n @Mutation(\"addUserToOrganization\")\n async addUserToOrganization(req: Request, body: { id: number, userId: number }): Promise<Data> {\n const { id, userId } = body;\n if (!id || !userId) {\n throw new HttpException(\"缺少参数\", 400);\n }\n await this.organizationService.addUserToOrganization(id, userId);\n return { code: 200, message: \"向组织添加用户成功\", };\n }\n\n /* 向指定组织添加多个指定用户 */\n @Mutation(\"addUsersToOrganization\")\n async addUsersToOrganization(req: Request, body: { id: number, userIds: Array<number> }): Promise<Data> {\n const { id, userIds } = body;\n if (!id || !userIds || userIds.length === 0) {\n throw new HttpException(\"缺少参数\", 400);\n }\n await this.organizationService.addUsersToOrganization(id, userIds);\n return { code: 200, message: \"向组织添加多个用户成功\" };\n }\n\n /* 将指定用户从组织中移除 */\n @Mutation(\"removeUserFromOrganization\")\n async removeUserFromOrganization(req: Request, body: { id: number, userId: number }): Promise<Data> {\n const { id, userId } = body;\n if (!id || !userId) {\n throw new HttpException(\"缺少参数\", 400);\n }\n await this.organizationService.removeUserFromOrganization(id, userId);\n return { code: 200, message: \"从组织移除用户成功\" };\n }\n\n /* 将指定多个用户从组织中移除 */\n @Mutation(\"removeUsersFromOrganization\")\n async removeUsersFromOrganization(req: Request, body: { id: number, userIds: Array<number> }): Promise<Data> {\n const { id, userIds } = body;\n if (!id || !userIds || userIds.length === 0) {\n throw new HttpException(\"缺少参数\", 400);\n }\n await this.organizationService.removeUsersFromOrganization(id, userIds);\n return { code: 200, message: \"从组织移除多个用户成功\" };\n }\n\n}\n"]}
\No newline at end of file