@dssp/supervision 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/pages/building-inspection/building-inspection-detail-checklist.ts +186 -0
- package/client/pages/building-inspection/building-inspection-detail-drawing.ts +160 -0
- package/client/pages/building-inspection/building-inspection-list.ts +430 -0
- package/client/pages/building-inspection/component/building-inspection-detail-header.ts +94 -0
- package/client/pages/building-inspection/inspection-create-popup.ts +696 -0
- package/client/pages/checklist/checklist-view.ts +443 -0
- package/client/pages/checklist-template/checklist-template-item.ts +240 -0
- package/client/pages/checklist-template/checklist-template-list.ts +271 -0
- package/client/pages/checklist-template/checklist-type-management.ts +242 -0
- package/client/route.ts +14 -18
- package/dist-client/pages/building-inspection/building-inspection-detail-checklist.d.ts +21 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js +187 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js.map +1 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-drawing.d.ts +21 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js +169 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js.map +1 -0
- package/dist-client/pages/building-inspection/building-inspection-list.d.ts +67 -0
- package/dist-client/pages/building-inspection/building-inspection-list.js +434 -0
- package/dist-client/pages/building-inspection/building-inspection-list.js.map +1 -0
- package/dist-client/pages/building-inspection/component/building-inspection-detail-header.d.ts +1 -0
- package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js +118 -0
- package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js.map +1 -0
- package/dist-client/pages/building-inspection/inspection-create-popup.d.ts +3 -0
- package/dist-client/pages/building-inspection/inspection-create-popup.js +735 -0
- package/dist-client/pages/building-inspection/inspection-create-popup.js.map +1 -0
- package/dist-client/pages/checklist/checklist-view.d.ts +6 -0
- package/dist-client/pages/checklist/checklist-view.js +434 -0
- package/dist-client/pages/checklist/checklist-view.js.map +1 -0
- package/dist-client/pages/checklist-template/checklist-template-item.d.ts +2 -0
- package/dist-client/pages/checklist-template/checklist-template-item.js +237 -0
- package/dist-client/pages/checklist-template/checklist-template-item.js.map +1 -0
- package/dist-client/pages/{check-item/check-item-list-page.d.ts → checklist-template/checklist-template-list.d.ts} +8 -27
- package/dist-client/pages/checklist-template/checklist-template-list.js +259 -0
- package/dist-client/pages/checklist-template/checklist-template-list.js.map +1 -0
- package/dist-client/pages/checklist-template/checklist-type-management.d.ts +48 -0
- package/dist-client/pages/checklist-template/checklist-type-management.js +229 -0
- package/dist-client/pages/checklist-template/checklist-type-management.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +10 -13
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/index.d.ts +1 -1
- package/dist-server/index.js +1 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/building-inspection/building-inspection-history.d.ts +17 -0
- package/dist-server/service/building-inspection/building-inspection-history.js +85 -0
- package/dist-server/service/building-inspection/building-inspection-history.js.map +1 -0
- package/dist-server/service/building-inspection/building-inspection-mutation.d.ts +8 -0
- package/dist-server/service/building-inspection/building-inspection-mutation.js +148 -0
- package/dist-server/service/building-inspection/building-inspection-mutation.js.map +1 -0
- package/dist-server/service/building-inspection/building-inspection-query.d.ts +20 -0
- package/dist-server/service/building-inspection/building-inspection-query.js +235 -0
- package/dist-server/service/building-inspection/building-inspection-query.js.map +1 -0
- package/dist-server/service/building-inspection/building-inspection-type.d.ts +43 -0
- package/dist-server/service/building-inspection/building-inspection-type.js +153 -0
- package/dist-server/service/building-inspection/building-inspection-type.js.map +1 -0
- package/dist-server/service/building-inspection/building-inspection.d.ts +26 -0
- package/dist-server/service/building-inspection/building-inspection.js +113 -0
- package/dist-server/service/building-inspection/building-inspection.js.map +1 -0
- package/dist-server/service/building-inspection/event-subscriber.d.ts +7 -0
- package/dist-server/service/building-inspection/event-subscriber.js +21 -0
- package/dist-server/service/building-inspection/event-subscriber.js.map +1 -0
- package/dist-server/service/building-inspection/index.d.ts +10 -0
- package/dist-server/service/building-inspection/index.js +14 -0
- package/dist-server/service/building-inspection/index.js.map +1 -0
- package/dist-server/service/checklist/checklist-history.d.ts +24 -0
- package/dist-server/service/checklist/checklist-history.js +120 -0
- package/dist-server/service/checklist/checklist-history.js.map +1 -0
- package/dist-server/service/checklist/checklist-mutation.d.ts +8 -0
- package/dist-server/service/checklist/checklist-mutation.js +96 -0
- package/dist-server/service/checklist/checklist-mutation.js.map +1 -0
- package/dist-server/service/checklist/checklist-query.d.ts +12 -0
- package/dist-server/service/checklist/checklist-query.js +83 -0
- package/dist-server/service/checklist/checklist-query.js.map +1 -0
- package/dist-server/service/checklist/checklist-type.d.ts +18 -0
- package/dist-server/service/checklist/checklist-type.js +69 -0
- package/dist-server/service/checklist/checklist-type.js.map +1 -0
- package/dist-server/service/checklist/checklist.d.ts +31 -0
- package/dist-server/service/checklist/checklist.js +143 -0
- package/dist-server/service/checklist/checklist.js.map +1 -0
- package/dist-server/service/checklist/event-subscriber.d.ts +7 -0
- package/dist-server/service/checklist/event-subscriber.js +21 -0
- package/dist-server/service/checklist/event-subscriber.js.map +1 -0
- package/dist-server/service/checklist/index.d.ts +8 -0
- package/dist-server/service/checklist/index.js +12 -0
- package/dist-server/service/checklist/index.js.map +1 -0
- package/dist-server/service/checklist-item/checklist-item-mutation.d.ts +2 -0
- package/dist-server/service/checklist-item/checklist-item-mutation.js +13 -0
- package/dist-server/service/checklist-item/checklist-item-mutation.js.map +1 -0
- package/dist-server/service/checklist-item/checklist-item-query.d.ts +10 -0
- package/dist-server/service/checklist-item/checklist-item-query.js +68 -0
- package/dist-server/service/checklist-item/checklist-item-query.js.map +1 -0
- package/dist-server/service/checklist-item/checklist-item-type.d.ts +5 -0
- package/dist-server/service/checklist-item/checklist-item-type.js +21 -0
- package/dist-server/service/checklist-item/checklist-item-type.js.map +1 -0
- package/dist-server/service/checklist-item/checklist-item.d.ts +26 -0
- package/dist-server/service/checklist-item/checklist-item.js +113 -0
- package/dist-server/service/checklist-item/checklist-item.js.map +1 -0
- package/dist-server/service/checklist-item/index.d.ts +5 -0
- package/dist-server/service/checklist-item/index.js +10 -0
- package/dist-server/service/checklist-item/index.js.map +1 -0
- package/dist-server/service/checklist-template/checklist-template-mutation.d.ts +6 -0
- package/dist-server/service/checklist-template/checklist-template-mutation.js +64 -0
- package/dist-server/service/checklist-template/checklist-template-mutation.js.map +1 -0
- package/dist-server/service/checklist-template/checklist-template-query.d.ts +10 -0
- package/dist-server/service/checklist-template/checklist-template-query.js +65 -0
- package/dist-server/service/checklist-template/checklist-template-query.js.map +1 -0
- package/dist-server/service/checklist-template/checklist-template-type.d.ts +10 -0
- package/dist-server/service/checklist-template/checklist-template-type.js +39 -0
- package/dist-server/service/checklist-template/checklist-template-type.js.map +1 -0
- package/dist-server/service/checklist-template/checklist-template.d.ts +17 -0
- package/dist-server/service/checklist-template/checklist-template.js +78 -0
- package/dist-server/service/checklist-template/checklist-template.js.map +1 -0
- package/dist-server/service/checklist-template/index.d.ts +5 -0
- package/dist-server/service/checklist-template/index.js +9 -0
- package/dist-server/service/checklist-template/index.js.map +1 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-mutation.d.ts +7 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js +68 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js.map +1 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-query.d.ts +10 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-query.js +66 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-query.js.map +1 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-type.d.ts +16 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-type.js +60 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-type.js.map +1 -0
- package/dist-server/service/checklist-template-item/checklist-template-item.d.ts +19 -0
- package/dist-server/service/checklist-template-item/checklist-template-item.js +87 -0
- package/dist-server/service/checklist-template-item/checklist-template-item.js.map +1 -0
- package/dist-server/service/checklist-template-item/index.d.ts +5 -0
- package/dist-server/service/checklist-template-item/index.js +9 -0
- package/dist-server/service/checklist-template-item/index.js.map +1 -0
- package/dist-server/service/checklist-type/checklist-type-mutation.d.ts +6 -0
- package/dist-server/service/checklist-type/checklist-type-mutation.js +64 -0
- package/dist-server/service/checklist-type/checklist-type-mutation.js.map +1 -0
- package/dist-server/service/checklist-type/checklist-type-query.d.ts +10 -0
- package/dist-server/service/checklist-type/checklist-type-query.js +65 -0
- package/dist-server/service/checklist-type/checklist-type-query.js.map +1 -0
- package/dist-server/service/checklist-type/checklist-type-type.d.ts +11 -0
- package/dist-server/service/checklist-type/checklist-type-type.js +43 -0
- package/dist-server/service/checklist-type/checklist-type-type.js.map +1 -0
- package/dist-server/service/checklist-type/checklist-type.d.ts +19 -0
- package/dist-server/service/checklist-type/checklist-type.js +78 -0
- package/dist-server/service/checklist-type/checklist-type.js.map +1 -0
- package/dist-server/service/checklist-type/index.d.ts +5 -0
- package/dist-server/service/checklist-type/index.js +9 -0
- package/dist-server/service/checklist-type/index.js.map +1 -0
- package/dist-server/service/index.d.ts +8 -3
- package/dist-server/service/index.js +25 -5
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/issue/issue.d.ts +1 -3
- package/dist-server/service/issue/issue.js +1 -7
- package/dist-server/service/issue/issue.js.map +1 -1
- package/dist-server/service/supervisor/supervisor.d.ts +1 -3
- package/dist-server/service/supervisor/supervisor.js +1 -7
- package/dist-server/service/supervisor/supervisor.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/supervision/checklist-item.md +160 -0
- package/helps/supervision/checklist.md +160 -0
- package/package.json +11 -7
- package/server/index.ts +1 -1
- package/server/service/building-inspection/building-inspection-history.ts +70 -0
- package/server/service/building-inspection/building-inspection-mutation.ts +147 -0
- package/server/service/building-inspection/building-inspection-query.ts +202 -0
- package/server/service/building-inspection/building-inspection-type.ts +101 -0
- package/server/service/building-inspection/building-inspection.ts +106 -0
- package/server/service/building-inspection/event-subscriber.ts +20 -0
- package/server/service/building-inspection/index.ts +11 -0
- package/server/service/checklist/checklist-history.ts +96 -0
- package/server/service/checklist/checklist-mutation.ts +103 -0
- package/server/service/checklist/checklist-query.ts +52 -0
- package/server/service/{check-item/check-item-type.ts → checklist/checklist-type.ts} +6 -18
- package/server/service/checklist/checklist.ts +127 -0
- package/server/service/checklist/event-subscriber.ts +17 -0
- package/server/service/checklist/index.ts +9 -0
- package/server/service/checklist-item/checklist-item-mutation.ts +5 -0
- package/server/service/checklist-item/checklist-item-query.ts +43 -0
- package/server/service/checklist-item/checklist-item-type.ts +12 -0
- package/server/service/checklist-item/checklist-item.ts +100 -0
- package/server/service/checklist-item/index.ts +7 -0
- package/server/service/checklist-template/checklist-template-mutation.ts +66 -0
- package/server/service/checklist-template/checklist-template-query.ts +39 -0
- package/server/service/checklist-template/checklist-template-type.ts +23 -0
- package/server/service/checklist-template/checklist-template.ts +71 -0
- package/server/service/checklist-template/index.ts +6 -0
- package/server/service/checklist-template-item/checklist-template-item-mutation.ts +64 -0
- package/server/service/checklist-template-item/checklist-template-item-query.ts +39 -0
- package/server/service/checklist-template-item/checklist-template-item-type.ts +39 -0
- package/server/service/checklist-template-item/checklist-template-item.ts +67 -0
- package/server/service/checklist-template-item/index.ts +6 -0
- package/server/service/checklist-type/checklist-type-mutation.ts +66 -0
- package/server/service/checklist-type/checklist-type-query.ts +39 -0
- package/server/service/checklist-type/checklist-type-type.ts +26 -0
- package/server/service/checklist-type/checklist-type.ts +64 -0
- package/server/service/checklist-type/index.ts +6 -0
- package/server/service/index.ts +59 -23
- package/server/service/issue/issue.ts +1 -6
- package/server/service/supervisor/supervisor.ts +1 -6
- package/things-factory.config.js +11 -7
- package/client/pages/check-item/check-item-importer.ts +0 -94
- package/client/pages/check-item/check-item-list-page.ts +0 -340
- package/dist-client/pages/check-item/check-item-importer.d.ts +0 -10
- package/dist-client/pages/check-item/check-item-importer.js +0 -101
- package/dist-client/pages/check-item/check-item-importer.js.map +0 -1
- package/dist-client/pages/check-item/check-item-list-page.js +0 -323
- package/dist-client/pages/check-item/check-item-list-page.js.map +0 -1
- package/dist-server/service/check-item/check-item-mutation.d.ts +0 -10
- package/dist-server/service/check-item/check-item-mutation.js +0 -168
- package/dist-server/service/check-item/check-item-mutation.js.map +0 -1
- package/dist-server/service/check-item/check-item-query.d.ts +0 -12
- package/dist-server/service/check-item/check-item-query.js +0 -97
- package/dist-server/service/check-item/check-item-query.js.map +0 -1
- package/dist-server/service/check-item/check-item-type.d.ts +0 -23
- package/dist-server/service/check-item/check-item-type.js +0 -86
- package/dist-server/service/check-item/check-item-type.js.map +0 -1
- package/dist-server/service/check-item/check-item.d.ts +0 -28
- package/dist-server/service/check-item/check-item.js +0 -117
- package/dist-server/service/check-item/check-item.js.map +0 -1
- package/dist-server/service/check-item/index.d.ts +0 -6
- package/dist-server/service/check-item/index.js +0 -10
- package/dist-server/service/check-item/index.js.map +0 -1
- package/server/service/check-item/check-item-mutation.ts +0 -198
- package/server/service/check-item/check-item-query.ts +0 -62
- package/server/service/check-item/check-item.ts +0 -111
- package/server/service/check-item/index.ts +0 -7
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { Resolver, Query, FieldResolver, Root, Arg, Args, Ctx } from 'type-graphql'
|
|
2
|
+
import { Attachment } from '@things-factory/attachment-base'
|
|
3
|
+
import { getRepository, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { BuildingInspection, BuildingInspectionStatus } from './building-inspection'
|
|
5
|
+
import {
|
|
6
|
+
BuildingInspectionList,
|
|
7
|
+
BuildingInspectionsOfBuildingLevel,
|
|
8
|
+
BuildingInspectionsOfProject,
|
|
9
|
+
BuildingInspectionSummary
|
|
10
|
+
} from './building-inspection-type'
|
|
11
|
+
import { BuildingLevel } from '@dssp/building-complex'
|
|
12
|
+
import { Checklist } from '../checklist/checklist'
|
|
13
|
+
import { Project } from '@dssp/project'
|
|
14
|
+
|
|
15
|
+
@Resolver(BuildingInspection)
|
|
16
|
+
export class BuildingInspectionQuery {
|
|
17
|
+
@Query(returns => BuildingInspection!, { nullable: true, description: 'To fetch a BuildingInspection' })
|
|
18
|
+
async buildingInspection(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<BuildingInspection> {
|
|
19
|
+
return await getRepository(BuildingInspection).findOne({
|
|
20
|
+
where: { id }
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Query(returns => BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' })
|
|
25
|
+
async buildingInspections(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<BuildingInspectionList> {
|
|
26
|
+
const { domain } = context.state
|
|
27
|
+
|
|
28
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
29
|
+
params,
|
|
30
|
+
repository: await getRepository(BuildingInspection),
|
|
31
|
+
searchables: ['name']
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
35
|
+
|
|
36
|
+
return { items, total }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Query(returns => BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' })
|
|
40
|
+
async buildingInspectionsOfProject(
|
|
41
|
+
@Arg('params') params: BuildingInspectionsOfProject,
|
|
42
|
+
@Ctx() context: ResolverContext
|
|
43
|
+
): Promise<BuildingInspectionList> {
|
|
44
|
+
const { domain } = context.state
|
|
45
|
+
const { projectId, limit } = params
|
|
46
|
+
|
|
47
|
+
const queryBuilder = getRepository(BuildingInspection)
|
|
48
|
+
.createQueryBuilder('bi')
|
|
49
|
+
.innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')
|
|
50
|
+
.innerJoin('buildings', 'b', 'bl.building_id = b.id')
|
|
51
|
+
.innerJoin('building_complexes', 'bc', 'b.building_complex_id = bc.id')
|
|
52
|
+
.innerJoin('projects', 'p', 'bc.id = p.building_complex_id')
|
|
53
|
+
.innerJoin('checklists', 'c', 'bi.checklist_id = c.id')
|
|
54
|
+
.where('p.domain = :domain', { domain: domain.id })
|
|
55
|
+
.andWhere('p.id = :projectId', { projectId })
|
|
56
|
+
.orderBy('bi.created_at', 'DESC')
|
|
57
|
+
|
|
58
|
+
if (limit) {
|
|
59
|
+
queryBuilder.limit(limit)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
63
|
+
|
|
64
|
+
return { items, total }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Query(returns => Project!, { description: 'To fetch Project' })
|
|
68
|
+
async projectByBuildingLevelId(
|
|
69
|
+
@Arg('buildingLevelId') buildingLevelId: string,
|
|
70
|
+
@Ctx() context: ResolverContext
|
|
71
|
+
): Promise<Project> {
|
|
72
|
+
const queryBuilder = getRepository(Project)
|
|
73
|
+
.createQueryBuilder('p')
|
|
74
|
+
.innerJoin('building_complexes', 'bc', 'p.building_complex_id = bc.id')
|
|
75
|
+
.innerJoin('buildings', 'b', 'b.building_complex_id = bc.id')
|
|
76
|
+
.innerJoin('building_levels', 'bl', 'bl.building_id = b.id')
|
|
77
|
+
.where('bl.id = :buildingLevelId', { buildingLevelId })
|
|
78
|
+
|
|
79
|
+
const result = await queryBuilder.getOne()
|
|
80
|
+
|
|
81
|
+
return result
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Query(returns => BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' })
|
|
85
|
+
async buildingInspectionsOfBuildingLevel(
|
|
86
|
+
@Arg('params') params: BuildingInspectionsOfBuildingLevel,
|
|
87
|
+
@Ctx() context: ResolverContext
|
|
88
|
+
): Promise<BuildingInspectionList> {
|
|
89
|
+
const { buildingLevelId, limit } = params
|
|
90
|
+
|
|
91
|
+
const queryBuilder = getRepository(BuildingInspection)
|
|
92
|
+
.createQueryBuilder('bi')
|
|
93
|
+
.innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')
|
|
94
|
+
.innerJoin('checklists', 'c', 'bi.checklist_id = c.id')
|
|
95
|
+
.where('bl.id = :buildingLevelId', { buildingLevelId })
|
|
96
|
+
.orderBy('bi.updated_at', 'DESC')
|
|
97
|
+
|
|
98
|
+
if (limit) {
|
|
99
|
+
queryBuilder.limit(limit)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
103
|
+
|
|
104
|
+
return { items, total }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 층 별로 검수 개수 써머리
|
|
108
|
+
@Query(returns => BuildingInspectionSummary!, { nullable: true, description: 'To fetch a BuildingInspection Summary' })
|
|
109
|
+
async buildingInspectionSummaryOfBuildingLevel(
|
|
110
|
+
@Arg('buildingLevelId') buildingLevelId: string,
|
|
111
|
+
@Ctx() context: ResolverContext
|
|
112
|
+
): Promise<BuildingInspectionSummary> {
|
|
113
|
+
const buildingInspectionSummary = await getRepository(BuildingInspection)
|
|
114
|
+
.createQueryBuilder('bi')
|
|
115
|
+
.select(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)
|
|
116
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)
|
|
117
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
|
|
118
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
|
|
119
|
+
.where('bi.building_level_id = :buildingLevelId', { buildingLevelId })
|
|
120
|
+
.groupBy('bi.building_level_id')
|
|
121
|
+
.getRawOne()
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
wait: buildingInspectionSummary?.wait || 0,
|
|
125
|
+
request: buildingInspectionSummary?.request || 0,
|
|
126
|
+
pass: buildingInspectionSummary?.pass || 0,
|
|
127
|
+
fail: buildingInspectionSummary?.fail || 0
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// 층 별로 검수 개수 써머리
|
|
132
|
+
@FieldResolver(type => BuildingInspectionSummary)
|
|
133
|
+
async buildingInspectionSummary(@Root() buildingLevel: BuildingLevel): Promise<BuildingInspectionSummary> {
|
|
134
|
+
const buildingInspectionSummary = await getRepository(BuildingInspection)
|
|
135
|
+
.createQueryBuilder('bi')
|
|
136
|
+
.select(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)
|
|
137
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)
|
|
138
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
|
|
139
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
|
|
140
|
+
.where('bi.building_level_id = :buildingLevelId', { buildingLevelId: buildingLevel.id })
|
|
141
|
+
.groupBy('bi.building_level_id')
|
|
142
|
+
.getRawOne()
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
wait: buildingInspectionSummary?.wait || 0,
|
|
146
|
+
request: buildingInspectionSummary?.request || 0,
|
|
147
|
+
pass: buildingInspectionSummary?.pass || 0,
|
|
148
|
+
fail: buildingInspectionSummary?.fail || 0
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@Query(returns => BuildingInspectionSummary, { description: '프로젝트의 검측상태 별 카운트' })
|
|
153
|
+
async buildingInspectionSummaryOfProject(
|
|
154
|
+
@Arg('projectId') projectId: string,
|
|
155
|
+
@Ctx() context: ResolverContext
|
|
156
|
+
): Promise<BuildingInspectionSummary> {
|
|
157
|
+
const { domain } = context.state
|
|
158
|
+
|
|
159
|
+
const result = await getRepository(Project)
|
|
160
|
+
.createQueryBuilder('p')
|
|
161
|
+
.select(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)
|
|
162
|
+
.addSelect(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)
|
|
163
|
+
.addSelect(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
|
|
164
|
+
.addSelect(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
|
|
165
|
+
.innerJoin('p.buildingComplex', 'bc')
|
|
166
|
+
.innerJoin('bc.buildings', 'b')
|
|
167
|
+
.innerJoin('b.buildingLevels', 'bl')
|
|
168
|
+
.leftJoin('building_inspections', 'bi', 'bi.building_level_id = bl.id AND bi.deleted_at IS NULL')
|
|
169
|
+
.where('p.domain = :domain', { domain: domain.id })
|
|
170
|
+
.andWhere('p.id = :projectId', { projectId })
|
|
171
|
+
.groupBy('p.id')
|
|
172
|
+
.getRawOne()
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
wait: result.wait || 0,
|
|
176
|
+
request: result.request || 0,
|
|
177
|
+
pass: result.pass || 0,
|
|
178
|
+
fail: result.fail || 0
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@FieldResolver(type => Checklist)
|
|
183
|
+
async checklist(@Root() buildingInspection: BuildingInspection): Promise<Checklist> {
|
|
184
|
+
return await getRepository(Checklist).findOneBy({ id: buildingInspection.checklistId })
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@FieldResolver(type => BuildingLevel)
|
|
188
|
+
async buildingLevel(@Root() buildingInspection: BuildingInspection): Promise<BuildingLevel> {
|
|
189
|
+
return await getRepository(BuildingLevel).findOneBy({ id: buildingInspection.buildingLevelId })
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@FieldResolver(type => [Attachment])
|
|
193
|
+
async attatchments(@Root() buildingInspection: BuildingInspection): Promise<Attachment[] | undefined> {
|
|
194
|
+
const attachment: Attachment[] = await getRepository(Attachment).find({
|
|
195
|
+
where: {
|
|
196
|
+
refType: BuildingInspection.name,
|
|
197
|
+
refBy: buildingInspection.id
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
return attachment
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
|
|
2
|
+
import { BuildingInspection } from './building-inspection'
|
|
3
|
+
|
|
4
|
+
@InputType()
|
|
5
|
+
class ChecklistInputType {
|
|
6
|
+
@Field({ nullable: false })
|
|
7
|
+
name: string
|
|
8
|
+
|
|
9
|
+
@Field({ nullable: false })
|
|
10
|
+
constructionType: string
|
|
11
|
+
|
|
12
|
+
@Field({ nullable: false })
|
|
13
|
+
constructionDetailType: string
|
|
14
|
+
|
|
15
|
+
@Field({ nullable: false })
|
|
16
|
+
location?: string
|
|
17
|
+
|
|
18
|
+
@Field({ nullable: false })
|
|
19
|
+
inspectionDrawingType?: string
|
|
20
|
+
|
|
21
|
+
@Field(type => [String], { nullable: false })
|
|
22
|
+
inspectionParts?: string[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@InputType()
|
|
26
|
+
class ChecklistItemInputType {
|
|
27
|
+
@Field({ nullable: false })
|
|
28
|
+
name: string
|
|
29
|
+
|
|
30
|
+
@Field({ nullable: false })
|
|
31
|
+
mainType: string
|
|
32
|
+
|
|
33
|
+
@Field({ nullable: false })
|
|
34
|
+
detailType: string
|
|
35
|
+
|
|
36
|
+
@Field({ nullable: true })
|
|
37
|
+
inspctionCriteria: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@InputType()
|
|
41
|
+
export class NewBuildingInspection {
|
|
42
|
+
@Field({ nullable: false })
|
|
43
|
+
buildingLevelId: string
|
|
44
|
+
|
|
45
|
+
@Field(type => ChecklistInputType, { nullable: false })
|
|
46
|
+
checklist: ChecklistInputType
|
|
47
|
+
|
|
48
|
+
@Field(type => [ChecklistItemInputType], { nullable: false })
|
|
49
|
+
checklistItem: ChecklistItemInputType[]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@InputType()
|
|
53
|
+
export class UpdateBuildingInspection {
|
|
54
|
+
@Field({ nullable: false })
|
|
55
|
+
id: string
|
|
56
|
+
|
|
57
|
+
@Field(type => String, { nullable: true })
|
|
58
|
+
drawingMarker?: string
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@InputType()
|
|
62
|
+
export class BuildingInspectionsOfProject {
|
|
63
|
+
@Field({ nullable: false })
|
|
64
|
+
projectId: string
|
|
65
|
+
|
|
66
|
+
@Field({ nullable: true })
|
|
67
|
+
limit: number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@InputType()
|
|
71
|
+
export class BuildingInspectionsOfBuildingLevel {
|
|
72
|
+
@Field({ nullable: false })
|
|
73
|
+
buildingLevelId: string
|
|
74
|
+
|
|
75
|
+
@Field({ nullable: true })
|
|
76
|
+
limit: number
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@ObjectType()
|
|
80
|
+
export class BuildingInspectionSummary {
|
|
81
|
+
@Field(type => Int, { description: '검측 대기 수' })
|
|
82
|
+
wait: number
|
|
83
|
+
|
|
84
|
+
@Field(type => Int, { description: '검측 요청 수' })
|
|
85
|
+
request: number
|
|
86
|
+
|
|
87
|
+
@Field(type => Int, { description: '검측 통과 수' })
|
|
88
|
+
pass: number
|
|
89
|
+
|
|
90
|
+
@Field(type => Int, { description: '검측 실패 수' })
|
|
91
|
+
fail: number
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@ObjectType()
|
|
95
|
+
export class BuildingInspectionList {
|
|
96
|
+
@Field(type => [BuildingInspection])
|
|
97
|
+
items: BuildingInspection[]
|
|
98
|
+
|
|
99
|
+
@Field(type => Int)
|
|
100
|
+
total: number
|
|
101
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateDateColumn,
|
|
3
|
+
UpdateDateColumn,
|
|
4
|
+
DeleteDateColumn,
|
|
5
|
+
Entity,
|
|
6
|
+
Index,
|
|
7
|
+
Column,
|
|
8
|
+
RelationId,
|
|
9
|
+
ManyToOne,
|
|
10
|
+
OneToOne,
|
|
11
|
+
PrimaryGeneratedColumn,
|
|
12
|
+
JoinColumn
|
|
13
|
+
} from 'typeorm'
|
|
14
|
+
import { ObjectType, Field, ID, registerEnumType } from 'type-graphql'
|
|
15
|
+
|
|
16
|
+
import { User } from '@things-factory/auth-base'
|
|
17
|
+
import { BuildingLevel } from '@dssp/building-complex'
|
|
18
|
+
import { Checklist } from '../checklist/checklist'
|
|
19
|
+
|
|
20
|
+
export enum BuildingInspectionStatus {
|
|
21
|
+
WAIT = 'WAIT',
|
|
22
|
+
REQUEST = 'REQUEST',
|
|
23
|
+
PASS = 'PASS',
|
|
24
|
+
FAIL = 'FAIL'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
registerEnumType(BuildingInspectionStatus, {
|
|
28
|
+
name: 'BuildingInspectionStatus',
|
|
29
|
+
description: '검측 상태'
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
@Entity({ comment: '시공 검측 (층별 도면의 검측 리스트)' })
|
|
33
|
+
@Index('ix_building_inspection_0', (buildingInspection: BuildingInspection) => [buildingInspection.buildingLevel], {
|
|
34
|
+
where: '"deleted_at" IS NULL'
|
|
35
|
+
})
|
|
36
|
+
@Index('ix_building_inspection_1', (buildingInspection: BuildingInspection) => [buildingInspection.checklist], {
|
|
37
|
+
where: '"deleted_at" IS NULL'
|
|
38
|
+
})
|
|
39
|
+
@Index('ix_building_inspection_2', (buildingInspection: BuildingInspection) => [buildingInspection.requestDate], {
|
|
40
|
+
where: '"deleted_at" IS NULL'
|
|
41
|
+
})
|
|
42
|
+
@ObjectType()
|
|
43
|
+
export class BuildingInspection {
|
|
44
|
+
@PrimaryGeneratedColumn('uuid')
|
|
45
|
+
@Field(type => ID)
|
|
46
|
+
readonly id: string
|
|
47
|
+
|
|
48
|
+
@Column({
|
|
49
|
+
nullable: false,
|
|
50
|
+
comment: '상태(WAIT: 검측 대기, REQUEST: 검측 요청, PASS: 합격, FAIL: 불합격)',
|
|
51
|
+
default: 'WAIT'
|
|
52
|
+
})
|
|
53
|
+
@Field({ nullable: true })
|
|
54
|
+
status?: BuildingInspectionStatus
|
|
55
|
+
|
|
56
|
+
@Column({ nullable: false, comment: '검측 요청일' })
|
|
57
|
+
@Field({ nullable: true })
|
|
58
|
+
requestDate?: Date
|
|
59
|
+
|
|
60
|
+
@Column({ type: 'simple-json', nullable: true, comment: '도면 마커' })
|
|
61
|
+
@Field(type => String, { nullable: true })
|
|
62
|
+
drawingMarker?: string
|
|
63
|
+
|
|
64
|
+
// 층 정보 (1:1 상위 테이블 참조)
|
|
65
|
+
@ManyToOne(type => BuildingLevel)
|
|
66
|
+
@Field(() => BuildingLevel, { nullable: true })
|
|
67
|
+
buildingLevel?: BuildingLevel
|
|
68
|
+
|
|
69
|
+
@RelationId((buildingInspection: BuildingInspection) => buildingInspection.buildingLevel)
|
|
70
|
+
buildingLevelId?: string
|
|
71
|
+
|
|
72
|
+
// 체크리스트 (1:1 상위 테이블 참조)
|
|
73
|
+
@OneToOne(type => Checklist)
|
|
74
|
+
@JoinColumn()
|
|
75
|
+
@Field(() => Checklist, { nullable: true })
|
|
76
|
+
checklist?: Checklist
|
|
77
|
+
|
|
78
|
+
@RelationId((buildingInspection: BuildingInspection) => buildingInspection.checklist)
|
|
79
|
+
checklistId?: string
|
|
80
|
+
|
|
81
|
+
@CreateDateColumn()
|
|
82
|
+
@Field({ nullable: true })
|
|
83
|
+
createdAt?: Date
|
|
84
|
+
|
|
85
|
+
@UpdateDateColumn()
|
|
86
|
+
@Field({ nullable: true })
|
|
87
|
+
updatedAt?: Date
|
|
88
|
+
|
|
89
|
+
@DeleteDateColumn()
|
|
90
|
+
@Field({ nullable: true })
|
|
91
|
+
deletedAt?: Date
|
|
92
|
+
|
|
93
|
+
@ManyToOne(type => User, { nullable: true })
|
|
94
|
+
@Field(type => User, { nullable: true })
|
|
95
|
+
creator?: User
|
|
96
|
+
|
|
97
|
+
@RelationId((buildingInspection: BuildingInspection) => buildingInspection.creator)
|
|
98
|
+
creatorId?: string
|
|
99
|
+
|
|
100
|
+
@ManyToOne(type => User, { nullable: true })
|
|
101
|
+
@Field(type => User, { nullable: true })
|
|
102
|
+
updater?: User
|
|
103
|
+
|
|
104
|
+
@RelationId((buildingInspection: BuildingInspection) => buildingInspection.updater)
|
|
105
|
+
updaterId?: string
|
|
106
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EventSubscriber } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { HistoryEntitySubscriber } from '@operato/typeorm-history'
|
|
4
|
+
|
|
5
|
+
import { BuildingInspection } from './building-inspection'
|
|
6
|
+
import { BuildingInspectionHistory } from './building-inspection-history'
|
|
7
|
+
|
|
8
|
+
@EventSubscriber()
|
|
9
|
+
export class BuildingInspectionHistoryEntitySubscriber extends HistoryEntitySubscriber<
|
|
10
|
+
BuildingInspection,
|
|
11
|
+
BuildingInspectionHistory
|
|
12
|
+
> {
|
|
13
|
+
public get entity() {
|
|
14
|
+
return BuildingInspection
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public get historyEntity() {
|
|
18
|
+
return BuildingInspectionHistory
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BuildingInspection, BuildingInspectionStatus } from './building-inspection'
|
|
2
|
+
import { BuildingInspectionQuery } from './building-inspection-query'
|
|
3
|
+
import { BuildingInspectionMutation } from './building-inspection-mutation'
|
|
4
|
+
import { BuildingInspectionSummary } from './building-inspection-type'
|
|
5
|
+
import { BuildingInspectionHistory } from './building-inspection-history'
|
|
6
|
+
import { BuildingInspectionHistoryEntitySubscriber } from './event-subscriber'
|
|
7
|
+
|
|
8
|
+
export const entities = [BuildingInspection, BuildingInspectionHistory]
|
|
9
|
+
export const resolvers = [BuildingInspectionQuery, BuildingInspectionMutation]
|
|
10
|
+
export const subscribers = [BuildingInspectionHistoryEntitySubscriber]
|
|
11
|
+
export const types = [BuildingInspectionStatus, BuildingInspectionSummary]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Field, ID, ObjectType } from 'type-graphql'
|
|
2
|
+
import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'
|
|
3
|
+
import { HistoryActionColumn, HistoryActionType, HistoryEntityInterface, HistoryOriginalIdColumn } from '@operato/typeorm-history'
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { config } from '@things-factory/env'
|
|
6
|
+
import { Checklist } from './checklist'
|
|
7
|
+
|
|
8
|
+
const ORMCONFIG = config.get('ormconfig', {})
|
|
9
|
+
const DATABASE_TYPE = ORMCONFIG.type
|
|
10
|
+
|
|
11
|
+
@Entity()
|
|
12
|
+
@Index('ix_checklist_history_0', (checklistHistory: ChecklistHistory) => [checklistHistory.originalId])
|
|
13
|
+
@ObjectType({ description: 'History Entity of Checklist' })
|
|
14
|
+
export class ChecklistHistory implements HistoryEntityInterface<Checklist> {
|
|
15
|
+
@PrimaryGeneratedColumn('uuid')
|
|
16
|
+
@Field(type => ID)
|
|
17
|
+
readonly id: string
|
|
18
|
+
|
|
19
|
+
@Column({ nullable: true, comment: '이름' })
|
|
20
|
+
@Field({ nullable: true })
|
|
21
|
+
name?: string
|
|
22
|
+
|
|
23
|
+
@Column({ nullable: true, comment: '문서 번호 동(4자리)-층(3자리)-시퀀스(6자리)' })
|
|
24
|
+
@Field({ nullable: true })
|
|
25
|
+
documentNo?: string
|
|
26
|
+
|
|
27
|
+
@Column({ nullable: false, comment: '공종' })
|
|
28
|
+
@Field({ nullable: true })
|
|
29
|
+
constructionType?: string
|
|
30
|
+
|
|
31
|
+
@Column({ nullable: false, comment: '세부 공종' })
|
|
32
|
+
@Field({ nullable: true })
|
|
33
|
+
constructionDetailType?: string
|
|
34
|
+
|
|
35
|
+
@Column({ nullable: false, comment: '위치 (x동 x층)' })
|
|
36
|
+
@Field({ nullable: true })
|
|
37
|
+
location?: string
|
|
38
|
+
|
|
39
|
+
@Column({ nullable: false, comment: '검측 도면 타입', default: '' })
|
|
40
|
+
@Field({ nullable: true })
|
|
41
|
+
inspectionDrawingType?: string
|
|
42
|
+
|
|
43
|
+
@Column('simple-array', { nullable: true, comment: '검측 부위' })
|
|
44
|
+
@Field(() => [String], { nullable: true })
|
|
45
|
+
inspectionParts?: string[]
|
|
46
|
+
|
|
47
|
+
@Column({ nullable: true, comment: '시공자 점검일' })
|
|
48
|
+
@Field({ nullable: true })
|
|
49
|
+
constructionInsprctionDate?: Date
|
|
50
|
+
|
|
51
|
+
@Column({ nullable: true, comment: '감리자 점검일' })
|
|
52
|
+
@Field({ nullable: true })
|
|
53
|
+
supervisorInsprctionDate?: Date
|
|
54
|
+
|
|
55
|
+
@Column({ nullable: true, comment: '총괄 시공 책임자 사인' })
|
|
56
|
+
@Field({ nullable: true })
|
|
57
|
+
overallConstructorSignature?: string
|
|
58
|
+
|
|
59
|
+
@Column({ nullable: true, comment: '공종별 시공 관리자 사인' })
|
|
60
|
+
@Field({ nullable: true })
|
|
61
|
+
taskConstructorSignature?: string
|
|
62
|
+
|
|
63
|
+
@Column({ nullable: true, comment: '총괄 감리 책임자 사인' })
|
|
64
|
+
@Field({ nullable: true })
|
|
65
|
+
overallSupervisorySignature?: string
|
|
66
|
+
|
|
67
|
+
@Column({ nullable: true, comment: '건축사보 (공종별 감리 관리자) 사인' })
|
|
68
|
+
@Field({ nullable: true })
|
|
69
|
+
taskSupervisorySignature?: string
|
|
70
|
+
|
|
71
|
+
@Column({ nullable: true })
|
|
72
|
+
@Field({ nullable: true })
|
|
73
|
+
createdAt?: Date
|
|
74
|
+
|
|
75
|
+
@ManyToOne(type => User, { nullable: true })
|
|
76
|
+
@Field(type => User, { nullable: true })
|
|
77
|
+
creator?: User
|
|
78
|
+
|
|
79
|
+
@RelationId((checklist: Checklist) => checklist.creator)
|
|
80
|
+
creatorId?: string
|
|
81
|
+
|
|
82
|
+
@HistoryOriginalIdColumn()
|
|
83
|
+
public originalId!: string
|
|
84
|
+
|
|
85
|
+
@HistoryActionColumn({
|
|
86
|
+
nullable: false,
|
|
87
|
+
type:
|
|
88
|
+
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
89
|
+
? 'enum'
|
|
90
|
+
: DATABASE_TYPE == 'oracle'
|
|
91
|
+
? 'varchar2'
|
|
92
|
+
: 'smallint',
|
|
93
|
+
enum: HistoryActionType
|
|
94
|
+
})
|
|
95
|
+
public action!: HistoryActionType
|
|
96
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { In } from 'typeorm'
|
|
3
|
+
import { Checklist } from './checklist'
|
|
4
|
+
import { NewChecklist, ChecklistPatch } from './checklist-type'
|
|
5
|
+
|
|
6
|
+
@Resolver(Checklist)
|
|
7
|
+
export class ChecklistMutation {
|
|
8
|
+
@Directive('@transaction')
|
|
9
|
+
@Mutation(returns => Checklist, { description: 'To create new Checklist' })
|
|
10
|
+
async createChecklist(@Arg('checklist') checklist: NewChecklist, @Ctx() context: ResolverContext): Promise<Checklist> {
|
|
11
|
+
const { domain, user, tx } = context.state
|
|
12
|
+
|
|
13
|
+
const result = await tx.getRepository(Checklist).save({
|
|
14
|
+
...checklist,
|
|
15
|
+
domain,
|
|
16
|
+
creator: user,
|
|
17
|
+
updater: user
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
return result
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Directive('@transaction')
|
|
24
|
+
@Mutation(returns => Checklist, { description: 'To modify Checklist information' })
|
|
25
|
+
async updateChecklist(
|
|
26
|
+
@Arg('id') id: string,
|
|
27
|
+
@Arg('patch') patch: ChecklistPatch,
|
|
28
|
+
@Ctx() context: ResolverContext
|
|
29
|
+
): Promise<Checklist> {
|
|
30
|
+
const { domain, user, tx } = context.state
|
|
31
|
+
|
|
32
|
+
const repository = tx.getRepository(Checklist)
|
|
33
|
+
const checklist = await repository.findOne({
|
|
34
|
+
where: { id }
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const result = await repository.save({
|
|
38
|
+
...checklist,
|
|
39
|
+
...patch,
|
|
40
|
+
updater: user
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return result
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Directive('@transaction')
|
|
47
|
+
@Mutation(returns => [Checklist], { description: "To modify multiple Checklists' information" })
|
|
48
|
+
async updateMultipleChecklist(
|
|
49
|
+
@Arg('patches', type => [ChecklistPatch]) patches: ChecklistPatch[],
|
|
50
|
+
@Ctx() context: ResolverContext
|
|
51
|
+
): Promise<Checklist[]> {
|
|
52
|
+
const { domain, user, tx } = context.state
|
|
53
|
+
|
|
54
|
+
let results = []
|
|
55
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
56
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
57
|
+
const checklistRepo = tx.getRepository(Checklist)
|
|
58
|
+
|
|
59
|
+
if (_createRecords.length > 0) {
|
|
60
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
61
|
+
const newRecord = _createRecords[i]
|
|
62
|
+
|
|
63
|
+
const result = await checklistRepo.save({
|
|
64
|
+
...newRecord,
|
|
65
|
+
domain,
|
|
66
|
+
creator: user,
|
|
67
|
+
updater: user
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
results.push({ ...result, cuFlag: '+' })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (_updateRecords.length > 0) {
|
|
75
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
76
|
+
const updateRecord = _updateRecords[i]
|
|
77
|
+
const checklist = await checklistRepo.findOneBy({ id: updateRecord.id })
|
|
78
|
+
|
|
79
|
+
const result = await checklistRepo.save({
|
|
80
|
+
...checklist,
|
|
81
|
+
...updateRecord,
|
|
82
|
+
updater: user
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
results.push({ ...result, cuFlag: 'M' })
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return results
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Directive('@transaction')
|
|
93
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple Checklists' })
|
|
94
|
+
async deleteChecklists(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
|
|
95
|
+
const { domain, tx } = context.state
|
|
96
|
+
|
|
97
|
+
await tx.getRepository(Checklist).softDelete({
|
|
98
|
+
id: In(ids)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
return true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graphql'
|
|
2
|
+
import { getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import { Checklist } from './checklist'
|
|
5
|
+
import { ChecklistList } from './checklist-type'
|
|
6
|
+
import { ChecklistItem } from '../checklist-item/checklist-item'
|
|
7
|
+
|
|
8
|
+
@Resolver(Checklist)
|
|
9
|
+
export class ChecklistQuery {
|
|
10
|
+
@Query(returns => Checklist!, { nullable: true, description: 'To fetch a Checklist' })
|
|
11
|
+
async checklist(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Checklist> {
|
|
12
|
+
const { domain } = context.state
|
|
13
|
+
|
|
14
|
+
return await getRepository(Checklist).findOne({
|
|
15
|
+
where: { id }
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Query(returns => ChecklistList, { description: 'To fetch multiple Checklists' })
|
|
20
|
+
async checklists(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ChecklistList> {
|
|
21
|
+
const { domain } = context.state
|
|
22
|
+
|
|
23
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
24
|
+
params,
|
|
25
|
+
repository: await getRepository(Checklist),
|
|
26
|
+
searchables: ['name', 'description']
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
30
|
+
|
|
31
|
+
return { items, total }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@FieldResolver(type => [ChecklistItem])
|
|
35
|
+
async checklistItems(@Root() checklist: Checklist): Promise<ChecklistItem[]> {
|
|
36
|
+
return await getRepository(ChecklistItem)
|
|
37
|
+
.createQueryBuilder('ci')
|
|
38
|
+
.where('ci.checklist_id = :checklistId', { checklistId: checklist.id })
|
|
39
|
+
.orderBy('ci.sequence', 'ASC')
|
|
40
|
+
.getMany()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@FieldResolver(type => User)
|
|
44
|
+
async updater(@Root() checklist: Checklist): Promise<User> {
|
|
45
|
+
return await getRepository(User).findOneBy({ id: checklist.updaterId })
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@FieldResolver(type => User)
|
|
49
|
+
async creator(@Root() checklist: Checklist): Promise<User> {
|
|
50
|
+
return await getRepository(User).findOneBy({ id: checklist.creatorId })
|
|
51
|
+
}
|
|
52
|
+
}
|