@dssp/project 0.0.2
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/CHANGELOG.md +8 -0
- package/assets/images/hatiolab-logo.png +0 -0
- package/assets/images/o-mark.png +0 -0
- package/assets/images/x-mark.png +0 -0
- package/client/bootstrap.ts +0 -0
- package/client/index.ts +0 -0
- package/client/pages/checklist/checklist-importer.ts +96 -0
- package/client/pages/checklist/checklist-list-page.ts +355 -0
- package/client/pages/lib/waether.ts +159 -0
- package/client/pages/project/ox-progress-circle.ts +133 -0
- package/client/pages/project/project-create-popup.ts +148 -0
- package/client/pages/project/project-detail.ts +618 -0
- package/client/pages/project/project-list.ts +354 -0
- package/client/pages/project/project-plan-management.ts +437 -0
- package/client/pages/project/project-schedule-list.ts +280 -0
- package/client/pages/project/project-schedule.ts +248 -0
- package/client/pages/project/project-setting-list.ts +298 -0
- package/client/pages/project/project-update.ts +797 -0
- package/client/pages/resource/resource-importer.ts +96 -0
- package/client/pages/resource/resource-list-page.ts +355 -0
- package/client/pages/task/task-importer.ts +96 -0
- package/client/pages/task/task-list-page.ts +355 -0
- package/client/route.ts +39 -0
- package/client/tsconfig.json +11 -0
- package/dist-client/bootstrap.d.ts +0 -0
- package/dist-client/bootstrap.js +2 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +0 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/checklist/checklist-importer.d.ts +9 -0
- package/dist-client/pages/checklist/checklist-importer.js +100 -0
- package/dist-client/pages/checklist/checklist-importer.js.map +1 -0
- package/dist-client/pages/checklist/checklist-list-page.d.ts +62 -0
- package/dist-client/pages/checklist/checklist-list-page.js +331 -0
- package/dist-client/pages/checklist/checklist-list-page.js.map +1 -0
- package/dist-client/pages/lib/waether.d.ts +6 -0
- package/dist-client/pages/lib/waether.js +152 -0
- package/dist-client/pages/lib/waether.js.map +1 -0
- package/dist-client/pages/project/ox-progress-circle.d.ts +41 -0
- package/dist-client/pages/project/ox-progress-circle.js +182 -0
- package/dist-client/pages/project/ox-progress-circle.js.map +1 -0
- package/dist-client/pages/project/project-create-popup.d.ts +14 -0
- package/dist-client/pages/project/project-create-popup.js +153 -0
- package/dist-client/pages/project/project-create-popup.js.map +1 -0
- package/dist-client/pages/project/project-detail.d.ts +35 -0
- package/dist-client/pages/project/project-detail.js +617 -0
- package/dist-client/pages/project/project-detail.js.map +1 -0
- package/dist-client/pages/project/project-list.d.ts +88 -0
- package/dist-client/pages/project/project-list.js +303 -0
- package/dist-client/pages/project/project-list.js.map +1 -0
- package/dist-client/pages/project/project-plan-management.d.ts +27 -0
- package/dist-client/pages/project/project-plan-management.js +438 -0
- package/dist-client/pages/project/project-plan-management.js.map +1 -0
- package/dist-client/pages/project/project-schedule-list.d.ts +18 -0
- package/dist-client/pages/project/project-schedule-list.js +292 -0
- package/dist-client/pages/project/project-schedule-list.js.map +1 -0
- package/dist-client/pages/project/project-schedule.d.ts +23 -0
- package/dist-client/pages/project/project-schedule.js +256 -0
- package/dist-client/pages/project/project-schedule.js.map +1 -0
- package/dist-client/pages/project/project-setting-list.d.ts +23 -0
- package/dist-client/pages/project/project-setting-list.js +307 -0
- package/dist-client/pages/project/project-setting-list.js.map +1 -0
- package/dist-client/pages/project/project-update.d.ts +24 -0
- package/dist-client/pages/project/project-update.js +797 -0
- package/dist-client/pages/project/project-update.js.map +1 -0
- package/dist-client/pages/resource/resource-importer.d.ts +9 -0
- package/dist-client/pages/resource/resource-importer.js +100 -0
- package/dist-client/pages/resource/resource-importer.js.map +1 -0
- package/dist-client/pages/resource/resource-list-page.d.ts +62 -0
- package/dist-client/pages/resource/resource-list-page.js +331 -0
- package/dist-client/pages/resource/resource-list-page.js.map +1 -0
- package/dist-client/pages/task/task-importer.d.ts +9 -0
- package/dist-client/pages/task/task-importer.js +100 -0
- package/dist-client/pages/task/task-importer.js.map +1 -0
- package/dist-client/pages/task/task-list-page.d.ts +62 -0
- package/dist-client/pages/task/task-list-page.js +331 -0
- package/dist-client/pages/task/task-list-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +32 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/controllers/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -0
- package/dist-server/controllers/project-to-excel.js +30 -0
- package/dist-server/controllers/project-to-excel.js.map +1 -0
- package/dist-server/index.js +6 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/middlewares/index.js +8 -0
- package/dist-server/middlewares/index.js.map +1 -0
- package/dist-server/routes.js +105 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/service/check-item/check-item-mutation.js +129 -0
- package/dist-server/service/check-item/check-item-mutation.js.map +1 -0
- package/dist-server/service/check-item/check-item-query.js +86 -0
- package/dist-server/service/check-item/check-item-query.js.map +1 -0
- package/dist-server/service/check-item/check-item-type.js +69 -0
- package/dist-server/service/check-item/check-item-type.js.map +1 -0
- package/dist-server/service/check-item/check-item.js +84 -0
- package/dist-server/service/check-item/check-item.js.map +1 -0
- package/dist-server/service/check-item/index.js +9 -0
- package/dist-server/service/check-item/index.js.map +1 -0
- package/dist-server/service/checklist/checklist-mutation.js +129 -0
- package/dist-server/service/checklist/checklist-mutation.js.map +1 -0
- package/dist-server/service/checklist/checklist-query.js +86 -0
- package/dist-server/service/checklist/checklist-query.js.map +1 -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.js +120 -0
- package/dist-server/service/checklist/checklist.js.map +1 -0
- package/dist-server/service/checklist/index.js +9 -0
- package/dist-server/service/checklist/index.js.map +1 -0
- package/dist-server/service/index.js +36 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/project/index.js +11 -0
- package/dist-server/service/project/index.js.map +1 -0
- package/dist-server/service/project/project-mutation.js +190 -0
- package/dist-server/service/project/project-mutation.js.map +1 -0
- package/dist-server/service/project/project-query.js +143 -0
- package/dist-server/service/project/project-query.js.map +1 -0
- package/dist-server/service/project/project-type.js +106 -0
- package/dist-server/service/project/project-type.js.map +1 -0
- package/dist-server/service/project/project.js +146 -0
- package/dist-server/service/project/project.js.map +1 -0
- package/dist-server/service/resource/index.js +9 -0
- package/dist-server/service/resource/index.js.map +1 -0
- package/dist-server/service/resource/resource-mutation.js +129 -0
- package/dist-server/service/resource/resource-mutation.js.map +1 -0
- package/dist-server/service/resource/resource-query.js +86 -0
- package/dist-server/service/resource/resource-query.js.map +1 -0
- package/dist-server/service/resource/resource-type.js +69 -0
- package/dist-server/service/resource/resource-type.js.map +1 -0
- package/dist-server/service/resource/resource.js +62 -0
- package/dist-server/service/resource/resource.js.map +1 -0
- package/dist-server/service/task/index.js +9 -0
- package/dist-server/service/task/index.js.map +1 -0
- package/dist-server/service/task/task-mutation.js +129 -0
- package/dist-server/service/task/task-mutation.js.map +1 -0
- package/dist-server/service/task/task-query.js +86 -0
- package/dist-server/service/task/task-query.js.map +1 -0
- package/dist-server/service/task/task-type.js +69 -0
- package/dist-server/service/task/task-type.js.map +1 -0
- package/dist-server/service/task/task.js +106 -0
- package/dist-server/service/task/task.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/helps/management/alarm.md +160 -0
- package/helps/management/alter-video.md +160 -0
- package/helps/management/cctv.md +160 -0
- package/helps/management/device.md +160 -0
- package/helps/management/parking.md +160 -0
- package/helps/management/site.md +160 -0
- package/helps/management/sun-pnl.md +160 -0
- package/helps/project/checklist.md +160 -0
- package/helps/project/project.md +160 -0
- package/helps/project/resource.md +160 -0
- package/helps/project/task.md +160 -0
- package/package.json +38 -0
- package/server/controllers/index.ts +0 -0
- package/server/controllers/project-to-excel.ts +40 -0
- package/server/index.ts +3 -0
- package/server/middlewares/index.ts +3 -0
- package/server/routes.ts +108 -0
- package/server/service/check-item/check-item-mutation.ts +142 -0
- package/server/service/check-item/check-item-query.ts +56 -0
- package/server/service/check-item/check-item-type.ts +49 -0
- package/server/service/check-item/check-item.ts +74 -0
- package/server/service/check-item/index.ts +6 -0
- package/server/service/checklist/checklist-mutation.ts +142 -0
- package/server/service/checklist/checklist-query.ts +56 -0
- package/server/service/checklist/checklist-type.ts +49 -0
- package/server/service/checklist/checklist.ts +105 -0
- package/server/service/checklist/index.ts +6 -0
- package/server/service/index.ts +35 -0
- package/server/service/project/index.ts +8 -0
- package/server/service/project/project-mutation.ts +201 -0
- package/server/service/project/project-query.ts +103 -0
- package/server/service/project/project-type.ts +71 -0
- package/server/service/project/project.ts +131 -0
- package/server/service/resource/index.ts +6 -0
- package/server/service/resource/resource-mutation.ts +139 -0
- package/server/service/resource/resource-query.ts +56 -0
- package/server/service/resource/resource-type.ts +49 -0
- package/server/service/resource/resource.ts +56 -0
- package/server/service/task/index.ts +6 -0
- package/server/service/task/task-mutation.ts +136 -0
- package/server/service/task/task-query.ts +56 -0
- package/server/service/task/task-type.ts +49 -0
- package/server/service/task/task.ts +97 -0
- package/server/tsconfig.json +10 -0
- package/things-factory.config.js +20 -0
- package/translations/en.json +1 -0
- package/translations/ja.json +1 -0
- package/translations/ko.json +9 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
8
|
+
const project_1 = require("./project");
|
|
9
|
+
const project_type_1 = require("./project-type");
|
|
10
|
+
const building_complex_1 = require("@dssp/building-complex");
|
|
11
|
+
let ProjectMutation = class ProjectMutation {
|
|
12
|
+
async createProject(project, context) {
|
|
13
|
+
const { domain, user, tx } = context.state;
|
|
14
|
+
const projectRepo = tx.getRepository(project_1.Project);
|
|
15
|
+
const buildingComplexRepo = tx.getRepository(building_complex_1.BuildingComplex);
|
|
16
|
+
const newBuildingComplex = await buildingComplexRepo.save({
|
|
17
|
+
domain,
|
|
18
|
+
creator: user,
|
|
19
|
+
updater: user
|
|
20
|
+
});
|
|
21
|
+
const result = await projectRepo.save({
|
|
22
|
+
name: project.name,
|
|
23
|
+
buildingComplex: newBuildingComplex,
|
|
24
|
+
domain,
|
|
25
|
+
creator: user,
|
|
26
|
+
updater: user
|
|
27
|
+
});
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
async updateProject(project, context) {
|
|
31
|
+
var _a;
|
|
32
|
+
const { user, tx } = context.state;
|
|
33
|
+
const projectRepo = tx.getRepository(project_1.Project);
|
|
34
|
+
const buildingComplexRepo = tx.getRepository(building_complex_1.BuildingComplex);
|
|
35
|
+
const buildingRepo = tx.getRepository(building_complex_1.Building);
|
|
36
|
+
const buildingLevelRepo = tx.getRepository(building_complex_1.BuildingLevel);
|
|
37
|
+
const buildingComplex = project.buildingComplex;
|
|
38
|
+
const buildings = ((_a = project.buildingComplex) === null || _a === void 0 ? void 0 : _a.buildings) || [];
|
|
39
|
+
// 1. 프로젝트 수정
|
|
40
|
+
const projectResult = await projectRepo.save(Object.assign(Object.assign({}, project), { updater: user }));
|
|
41
|
+
// 2. 단지 정보 수정
|
|
42
|
+
await buildingComplexRepo.save(Object.assign(Object.assign({}, buildingComplex), { updater: user }));
|
|
43
|
+
// 2-1. 프로젝트 메인 이미지 첨부파일 나머지 삭제 후 저장 (null로 오면 삭제만)
|
|
44
|
+
if (project.mainPhotoUpload !== undefined) {
|
|
45
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [project.id] }, context);
|
|
46
|
+
if (project.mainPhotoUpload) {
|
|
47
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
48
|
+
attachment: {
|
|
49
|
+
file: project.mainPhotoUpload,
|
|
50
|
+
refType: project_1.Project.name,
|
|
51
|
+
refBy: project.id
|
|
52
|
+
}
|
|
53
|
+
}, context);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// 2-2. 단지 BIM 이미지 첨부파일 나머지 삭제 후 저장 (null로 오면 삭제만)
|
|
57
|
+
if (buildingComplex.drawingUpload !== undefined) {
|
|
58
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [buildingComplex.id] }, context);
|
|
59
|
+
if (buildingComplex.drawingUpload) {
|
|
60
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
61
|
+
attachment: {
|
|
62
|
+
file: buildingComplex.drawingUpload,
|
|
63
|
+
refType: building_complex_1.BuildingComplex.name,
|
|
64
|
+
refBy: buildingComplex.id
|
|
65
|
+
}
|
|
66
|
+
}, context);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// 3. 동의 층 정보가 바뀌었으면 층 초기화 후 다시 생성
|
|
70
|
+
const originBuilding = await buildingRepo.findBy({ buildingComplex: { id: buildingComplex.id } }); // 이전 동 정보 가져오기
|
|
71
|
+
const afterBuilding = buildings.reduce((acc, building) => (Object.assign(Object.assign({}, acc), { [building.name]: building.floorCount })), {}); // 비교용으로 수정된 동 정보 데이터 파싱
|
|
72
|
+
const isBuidlingChanged = originBuilding.some(building => afterBuilding[building.name] !== building.floorCount); // 층 개수가 달라진 동이 있는지 확인
|
|
73
|
+
// 동의 층 개수가 달라지면 모든 층의 데이터 제거 후 생성
|
|
74
|
+
if (isBuidlingChanged || originBuilding.length !== buildings.length) {
|
|
75
|
+
// 3-1. 기존 동/층 첨부파일 및 데이터 제거
|
|
76
|
+
const buildingIds = originBuilding.map((building) => building.id);
|
|
77
|
+
const buildingLevels = await buildingLevelRepo.findBy({ building: { id: (0, typeorm_1.In)(buildingIds) } });
|
|
78
|
+
const buildingLevelIds = buildingLevels.map((buildingLevel) => buildingLevel.id);
|
|
79
|
+
await buildingLevelRepo.softDelete({ building: { id: (0, typeorm_1.In)(buildingIds) } });
|
|
80
|
+
await buildingRepo.softDelete({ id: (0, typeorm_1.In)(buildingIds) });
|
|
81
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [...buildingIds, ...buildingLevelIds] }, context);
|
|
82
|
+
buildings.forEach(async (building) => {
|
|
83
|
+
// 3-2. 단지 내 동 정보들 생성
|
|
84
|
+
const newBuilding = await buildingRepo.save({
|
|
85
|
+
buildingComplex: buildingComplex,
|
|
86
|
+
name: building.name,
|
|
87
|
+
floorCount: building.floorCount,
|
|
88
|
+
creator: user
|
|
89
|
+
});
|
|
90
|
+
// 3-3. 동별로 for문 돌면서 층 데이터 개수대로 생성
|
|
91
|
+
for (let i = 1; i <= building.floorCount; i++) {
|
|
92
|
+
await buildingLevelRepo.save({ building: newBuilding, floor: i, creator: user });
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return projectResult;
|
|
97
|
+
}
|
|
98
|
+
async updateProjectPlan(project, context) {
|
|
99
|
+
var _a;
|
|
100
|
+
const { user, tx } = context.state;
|
|
101
|
+
const projectRepo = tx.getRepository(project_1.Project);
|
|
102
|
+
const buildingComplexRepo = tx.getRepository(building_complex_1.BuildingComplex);
|
|
103
|
+
const buildingComplex = project.buildingComplex;
|
|
104
|
+
const buildings = ((_a = project.buildingComplex) === null || _a === void 0 ? void 0 : _a.buildings) || [];
|
|
105
|
+
// 1. 프로젝트 수정 시간 업데이트
|
|
106
|
+
const projectResult = await projectRepo.save(Object.assign(Object.assign({}, project), { updater: user }));
|
|
107
|
+
// 2. 단지 축척 정보 수정
|
|
108
|
+
await buildingComplexRepo.save(Object.assign(Object.assign({}, buildingComplex), { updater: user }));
|
|
109
|
+
for (let buildingKey in buildings) {
|
|
110
|
+
const building = buildings[buildingKey];
|
|
111
|
+
for (let buildingLevelKey in building.buildingLevels) {
|
|
112
|
+
const buildingLevel = building.buildingLevels[buildingLevelKey];
|
|
113
|
+
// 3. 층별 도면 이미지 저장 (null로 오면 삭제만)
|
|
114
|
+
if ((buildingLevel === null || buildingLevel === void 0 ? void 0 : buildingLevel.mainDrawingUpload) !== undefined) {
|
|
115
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [buildingLevel.id] }, context);
|
|
116
|
+
if (buildingLevel === null || buildingLevel === void 0 ? void 0 : buildingLevel.mainDrawingUpload) {
|
|
117
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
118
|
+
attachment: {
|
|
119
|
+
file: buildingLevel.mainDrawingUpload,
|
|
120
|
+
refType: building_complex_1.BuildingLevel.name,
|
|
121
|
+
refBy: buildingLevel.id
|
|
122
|
+
}
|
|
123
|
+
}, context);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// 4. 동별 도면 이미지 저장 (null로 오면 삭제만)
|
|
128
|
+
if ((building === null || building === void 0 ? void 0 : building.drawingUpload) !== undefined) {
|
|
129
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [building.id] }, context);
|
|
130
|
+
if (building === null || building === void 0 ? void 0 : building.drawingUpload) {
|
|
131
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
132
|
+
attachment: {
|
|
133
|
+
file: building.drawingUpload,
|
|
134
|
+
refType: building_complex_1.Building.name,
|
|
135
|
+
refBy: building.id
|
|
136
|
+
}
|
|
137
|
+
}, context);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return projectResult;
|
|
142
|
+
}
|
|
143
|
+
async deleteProject(id, context) {
|
|
144
|
+
const { domain, tx } = context.state;
|
|
145
|
+
await tx.getRepository(project_1.Project).delete({ domain: { id: domain.id }, id });
|
|
146
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
tslib_1.__decorate([
|
|
151
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
152
|
+
(0, type_graphql_1.Mutation)(returns => project_1.Project, { description: '프로젝트 생성' }),
|
|
153
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('project')),
|
|
154
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
155
|
+
tslib_1.__metadata("design:type", Function),
|
|
156
|
+
tslib_1.__metadata("design:paramtypes", [project_type_1.NewProject, Object]),
|
|
157
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
158
|
+
], ProjectMutation.prototype, "createProject", null);
|
|
159
|
+
tslib_1.__decorate([
|
|
160
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
161
|
+
(0, type_graphql_1.Mutation)(returns => project_1.Project, { description: '프로젝트 업데이트' }),
|
|
162
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('project')),
|
|
163
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
164
|
+
tslib_1.__metadata("design:type", Function),
|
|
165
|
+
tslib_1.__metadata("design:paramtypes", [project_type_1.ProjectPatch, Object]),
|
|
166
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
167
|
+
], ProjectMutation.prototype, "updateProject", null);
|
|
168
|
+
tslib_1.__decorate([
|
|
169
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
170
|
+
(0, type_graphql_1.Mutation)(returns => project_1.Project, { description: '프로젝트 도면 업데이트' }),
|
|
171
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('project')),
|
|
172
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
173
|
+
tslib_1.__metadata("design:type", Function),
|
|
174
|
+
tslib_1.__metadata("design:paramtypes", [project_type_1.ProjectPatch, Object]),
|
|
175
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
176
|
+
], ProjectMutation.prototype, "updateProjectPlan", null);
|
|
177
|
+
tslib_1.__decorate([
|
|
178
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
179
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Project' }),
|
|
180
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
181
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
182
|
+
tslib_1.__metadata("design:type", Function),
|
|
183
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
184
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
185
|
+
], ProjectMutation.prototype, "deleteProject", null);
|
|
186
|
+
ProjectMutation = tslib_1.__decorate([
|
|
187
|
+
(0, type_graphql_1.Resolver)(project_1.Project)
|
|
188
|
+
], ProjectMutation);
|
|
189
|
+
exports.ProjectMutation = ProjectMutation;
|
|
190
|
+
//# sourceMappingURL=project-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-mutation.js","sourceRoot":"","sources":["../../../server/service/project/project-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA4E;AAC5E,qCAAiC;AAEjC,qEAA0F;AAE1F,uCAAmC;AACnC,iDAAyD;AACzD,6DAAiF;AAG1E,IAAM,eAAe,GAArB,MAAM,eAAe;IAGpB,AAAN,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,WAAW,GAAG,EAAE,CAAC,aAAa,CAAC,iBAAO,CAAC,CAAA;QAC7C,MAAM,mBAAmB,GAAG,EAAE,CAAC,aAAa,CAAC,kCAAe,CAAC,CAAA;QAE7D,MAAM,kBAAkB,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC;YACxD,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC;YACpC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,eAAe,EAAE,kBAAkB;YACnC,MAAM;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AAO,CAAC,EAAE,CAAC,iBAAO,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;IACpC,mBAAA,IAAA,kBAAG,EAAC,SAAS,CAAC,CAAA;IAAuB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAlB,yBAAU;;oDAoBtD;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,iBAAO,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;IACtC,mBAAA,IAAA,kBAAG,EAAC,SAAS,CAAC,CAAA;IAAyB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAApB,2BAAY;;oDAuFxD;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,iBAAO,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;IACrC,mBAAA,IAAA,kBAAG,EAAC,SAAS,CAAC,CAAA;IAAyB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAApB,2BAAY;;wDA4D5D;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oDAOhD;AA7LU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,eAAe,CA8L3B;AA9LY,0CAAe","sourcesContent":["import { Resolver, Mutation, Arg, Args, Ctx, Directive } from 'type-graphql'\nimport { In, Not } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { Project } from './project'\nimport { NewProject, ProjectPatch } from './project-type'\nimport { BuildingComplex, Building, BuildingLevel } from '@dssp/building-complex'\n\n@Resolver(Project)\nexport class ProjectMutation {\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트 생성' })\n async createProject(@Arg('project') project: NewProject, @Ctx() context: ResolverContext): Promise<Project> {\n const { domain, user, tx } = context.state\n const projectRepo = tx.getRepository(Project)\n const buildingComplexRepo = tx.getRepository(BuildingComplex)\n\n const newBuildingComplex = await buildingComplexRepo.save({\n domain,\n creator: user,\n updater: user\n })\n\n const result = await projectRepo.save({\n name: project.name,\n buildingComplex: newBuildingComplex,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트 업데이트' })\n async updateProject(@Arg('project') project: ProjectPatch, @Ctx() context: ResolverContext): Promise<Project> {\n const { user, tx } = context.state\n const projectRepo = tx.getRepository(Project)\n const buildingComplexRepo = tx.getRepository(BuildingComplex)\n const buildingRepo = tx.getRepository(Building)\n const buildingLevelRepo = tx.getRepository(BuildingLevel)\n\n const buildingComplex = project.buildingComplex\n const buildings = project.buildingComplex?.buildings || []\n\n // 1. 프로젝트 수정\n const projectResult = await projectRepo.save({ ...project, updater: user })\n\n // 2. 단지 정보 수정\n await buildingComplexRepo.save({ ...buildingComplex, updater: user })\n\n // 2-1. 프로젝트 메인 이미지 첨부파일 나머지 삭제 후 저장 (null로 오면 삭제만)\n if (project.mainPhotoUpload !== undefined) {\n await deleteAttachmentsByRef(null, { refBys: [project.id] }, context)\n\n if (project.mainPhotoUpload) {\n await createAttachment(\n null,\n {\n attachment: {\n file: project.mainPhotoUpload,\n refType: Project.name,\n refBy: project.id\n }\n },\n context\n )\n }\n }\n\n // 2-2. 단지 BIM 이미지 첨부파일 나머지 삭제 후 저장 (null로 오면 삭제만)\n if (buildingComplex.drawingUpload !== undefined) {\n await deleteAttachmentsByRef(null, { refBys: [buildingComplex.id] }, context)\n\n if (buildingComplex.drawingUpload) {\n await createAttachment(\n null,\n {\n attachment: {\n file: buildingComplex.drawingUpload,\n refType: BuildingComplex.name,\n refBy: buildingComplex.id\n }\n },\n context\n )\n }\n }\n\n // 3. 동의 층 정보가 바뀌었으면 층 초기화 후 다시 생성\n const originBuilding = await buildingRepo.findBy({ buildingComplex: { id: buildingComplex.id } }) // 이전 동 정보 가져오기\n const afterBuilding = buildings.reduce((acc, building) => ({ ...acc, [building.name]: building.floorCount }), {}) // 비교용으로 수정된 동 정보 데이터 파싱\n const isBuidlingChanged = originBuilding.some(building => afterBuilding[building.name] !== building.floorCount) // 층 개수가 달라진 동이 있는지 확인\n\n // 동의 층 개수가 달라지면 모든 층의 데이터 제거 후 생성\n if (isBuidlingChanged || originBuilding.length !== buildings.length) {\n // 3-1. 기존 동/층 첨부파일 및 데이터 제거\n const buildingIds = originBuilding.map((building: Building) => building.id)\n const buildingLevels = await buildingLevelRepo.findBy({ building: { id: In(buildingIds) } })\n const buildingLevelIds = buildingLevels.map((buildingLevel: BuildingLevel) => buildingLevel.id)\n\n await buildingLevelRepo.softDelete({ building: { id: In(buildingIds) } })\n await buildingRepo.softDelete({ id: In(buildingIds) })\n await deleteAttachmentsByRef(null, { refBys: [...buildingIds, ...buildingLevelIds] }, context)\n\n buildings.forEach(async (building: Building) => {\n // 3-2. 단지 내 동 정보들 생성\n const newBuilding = await buildingRepo.save({\n buildingComplex: buildingComplex,\n name: building.name,\n floorCount: building.floorCount,\n creator: user\n })\n\n // 3-3. 동별로 for문 돌면서 층 데이터 개수대로 생성\n for (let i = 1; i <= building.floorCount; i++) {\n await buildingLevelRepo.save({ building: newBuilding, floor: i, creator: user })\n }\n })\n }\n\n return projectResult\n }\n\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트 도면 업데이트' })\n async updateProjectPlan(@Arg('project') project: ProjectPatch, @Ctx() context: ResolverContext): Promise<Project> {\n const { user, tx } = context.state\n const projectRepo = tx.getRepository(Project)\n const buildingComplexRepo = tx.getRepository(BuildingComplex)\n const buildingComplex = project.buildingComplex\n const buildings: Building[] = project.buildingComplex?.buildings || []\n\n // 1. 프로젝트 수정 시간 업데이트\n const projectResult = await projectRepo.save({ ...project, updater: user })\n\n // 2. 단지 축척 정보 수정\n await buildingComplexRepo.save({ ...buildingComplex, updater: user })\n\n for (let buildingKey in buildings) {\n const building = buildings[buildingKey]\n\n for (let buildingLevelKey in building.buildingLevels) {\n const buildingLevel = building.buildingLevels[buildingLevelKey]\n\n // 3. 층별 도면 이미지 저장 (null로 오면 삭제만)\n if (buildingLevel?.mainDrawingUpload !== undefined) {\n await deleteAttachmentsByRef(null, { refBys: [buildingLevel.id] }, context)\n\n if (buildingLevel?.mainDrawingUpload) {\n await createAttachment(\n null,\n {\n attachment: {\n file: buildingLevel.mainDrawingUpload,\n refType: BuildingLevel.name,\n refBy: buildingLevel.id\n }\n },\n context\n )\n }\n }\n }\n\n // 4. 동별 도면 이미지 저장 (null로 오면 삭제만)\n if (building?.drawingUpload !== undefined) {\n await deleteAttachmentsByRef(null, { refBys: [building.id] }, context)\n\n if (building?.drawingUpload) {\n await createAttachment(\n null,\n {\n attachment: {\n file: building.drawingUpload,\n refType: Building.name,\n refBy: building.id\n }\n },\n context\n )\n }\n }\n }\n\n return projectResult\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Project' })\n async deleteProject(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Project).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n}\n"]}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const shell_1 = require("@things-factory/shell");
|
|
7
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
8
|
+
const project_1 = require("./project");
|
|
9
|
+
const project_type_1 = require("./project-type");
|
|
10
|
+
const building_complex_1 = require("@dssp/building-complex");
|
|
11
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
12
|
+
let ProjectQuery = class ProjectQuery {
|
|
13
|
+
async project(id, context) {
|
|
14
|
+
const { domain } = context.state;
|
|
15
|
+
return await (0, shell_1.getRepository)(project_1.Project).findOne({
|
|
16
|
+
where: { domain: { id: domain.id }, id }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async projects(projectName, context) {
|
|
20
|
+
const { domain } = context.state;
|
|
21
|
+
// const { page = 1, limit = 0 } = params.pagination || {}
|
|
22
|
+
const queryBuilder = await (0, shell_1.getRepository)(project_1.Project)
|
|
23
|
+
.createQueryBuilder('p')
|
|
24
|
+
.innerJoinAndSelect('p.buildingComplex', 'bc')
|
|
25
|
+
.where('p.domain = :domain', { domain: domain.id })
|
|
26
|
+
.orderBy('p.created_at', 'DESC');
|
|
27
|
+
// .offset((page - 1) * limit)
|
|
28
|
+
// .limit(limit)
|
|
29
|
+
if (projectName) {
|
|
30
|
+
projectName = `%${projectName}%`;
|
|
31
|
+
queryBuilder.andWhere('p.name LIKE :projectName', { projectName });
|
|
32
|
+
}
|
|
33
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
34
|
+
return { items, total };
|
|
35
|
+
}
|
|
36
|
+
async inspectionSummary(projectId, context) {
|
|
37
|
+
const { domain } = context.state;
|
|
38
|
+
const queryBuilder = (0, shell_1.getRepository)(project_1.Project)
|
|
39
|
+
.createQueryBuilder('p')
|
|
40
|
+
.select(`COUNT(CASE WHEN bi.type="${building_complex_1.InspectionType.REQUEST}" THEN 1 ELSE NULL END) AS request`)
|
|
41
|
+
.addSelect(`COUNT(CASE WHEN bi.type="${building_complex_1.InspectionType.PASS}" THEN 1 ELSE NULL END) AS pass`)
|
|
42
|
+
.addSelect(`COUNT(CASE WHEN bi.type="${building_complex_1.InspectionType.FAIL}" THEN 1 ELSE NULL END) AS fail`)
|
|
43
|
+
.innerJoin('p.buildingComplex', 'bc')
|
|
44
|
+
.innerJoin('bc.buildings', 'b')
|
|
45
|
+
.innerJoin('b.buildingLevels', 'bl')
|
|
46
|
+
.innerJoin('bl.buildingInspections', 'bi')
|
|
47
|
+
.where('p.domain = :domain', { domain: domain.id })
|
|
48
|
+
.andWhere('p.id = :projectId', { projectId })
|
|
49
|
+
.groupBy('p.id');
|
|
50
|
+
const result = (await queryBuilder.getRawOne()) || {};
|
|
51
|
+
return {
|
|
52
|
+
request: result.request || 0,
|
|
53
|
+
pass: result.pass || 0,
|
|
54
|
+
fail: result.fail || 0
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async mainPhoto(project) {
|
|
58
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
59
|
+
where: {
|
|
60
|
+
domain: { id: project.domainId },
|
|
61
|
+
refBy: project.id
|
|
62
|
+
},
|
|
63
|
+
order: { createdAt: 'ASC' }
|
|
64
|
+
});
|
|
65
|
+
return attachment;
|
|
66
|
+
}
|
|
67
|
+
async buildingComplex(project) {
|
|
68
|
+
return await (0, shell_1.getRepository)(building_complex_1.BuildingComplex).findOneBy({ id: project.buildingComplexId });
|
|
69
|
+
}
|
|
70
|
+
async domain(project) {
|
|
71
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: project.domainId });
|
|
72
|
+
}
|
|
73
|
+
async updater(project) {
|
|
74
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: project.updaterId });
|
|
75
|
+
}
|
|
76
|
+
async creator(project) {
|
|
77
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: project.creatorId });
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
tslib_1.__decorate([
|
|
81
|
+
(0, type_graphql_1.Query)(returns => project_1.Project, { nullable: true, description: 'To fetch a Project' }),
|
|
82
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
83
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
84
|
+
tslib_1.__metadata("design:type", Function),
|
|
85
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
86
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
87
|
+
], ProjectQuery.prototype, "project", null);
|
|
88
|
+
tslib_1.__decorate([
|
|
89
|
+
(0, type_graphql_1.Query)(returns => project_type_1.ProjectList, { description: '프로젝트 리스트' }),
|
|
90
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('projectName')),
|
|
91
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
92
|
+
tslib_1.__metadata("design:type", Function),
|
|
93
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
94
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
95
|
+
], ProjectQuery.prototype, "projects", null);
|
|
96
|
+
tslib_1.__decorate([
|
|
97
|
+
(0, type_graphql_1.Query)(returns => project_type_1.InspectionSummary, { description: '프로젝트의 검측상태 별 카운트' }),
|
|
98
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('projectId')),
|
|
99
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
100
|
+
tslib_1.__metadata("design:type", Function),
|
|
101
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
102
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
103
|
+
], ProjectQuery.prototype, "inspectionSummary", null);
|
|
104
|
+
tslib_1.__decorate([
|
|
105
|
+
(0, type_graphql_1.FieldResolver)(type => attachment_base_1.Attachment),
|
|
106
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
107
|
+
tslib_1.__metadata("design:type", Function),
|
|
108
|
+
tslib_1.__metadata("design:paramtypes", [project_1.Project]),
|
|
109
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
110
|
+
], ProjectQuery.prototype, "mainPhoto", null);
|
|
111
|
+
tslib_1.__decorate([
|
|
112
|
+
(0, type_graphql_1.FieldResolver)(type => building_complex_1.BuildingComplex),
|
|
113
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
114
|
+
tslib_1.__metadata("design:type", Function),
|
|
115
|
+
tslib_1.__metadata("design:paramtypes", [project_1.Project]),
|
|
116
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
117
|
+
], ProjectQuery.prototype, "buildingComplex", null);
|
|
118
|
+
tslib_1.__decorate([
|
|
119
|
+
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
120
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
121
|
+
tslib_1.__metadata("design:type", Function),
|
|
122
|
+
tslib_1.__metadata("design:paramtypes", [project_1.Project]),
|
|
123
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
124
|
+
], ProjectQuery.prototype, "domain", null);
|
|
125
|
+
tslib_1.__decorate([
|
|
126
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
127
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
128
|
+
tslib_1.__metadata("design:type", Function),
|
|
129
|
+
tslib_1.__metadata("design:paramtypes", [project_1.Project]),
|
|
130
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
131
|
+
], ProjectQuery.prototype, "updater", null);
|
|
132
|
+
tslib_1.__decorate([
|
|
133
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
134
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
135
|
+
tslib_1.__metadata("design:type", Function),
|
|
136
|
+
tslib_1.__metadata("design:paramtypes", [project_1.Project]),
|
|
137
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
138
|
+
], ProjectQuery.prototype, "creator", null);
|
|
139
|
+
ProjectQuery = tslib_1.__decorate([
|
|
140
|
+
(0, type_graphql_1.Resolver)(project_1.Project)
|
|
141
|
+
], ProjectQuery);
|
|
142
|
+
exports.ProjectQuery = ProjectQuery;
|
|
143
|
+
//# sourceMappingURL=project-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-query.js","sourceRoot":"","sources":["../../../server/service/project/project-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA6E;AAC7E,iDAA6D;AAC7D,yDAAgD;AAChD,uCAAmC;AACnC,iDAA+D;AAC/D,6DAAwE;AACxE,qEAA4D;AAGrD,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEjB,AAAN,KAAK,CAAC,OAAO,CAAY,EAAU,EAAS,OAAwB;QAClE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ,CAAqB,WAAmB,EAAS,OAAwB;QACrF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,0DAA0D;QAE1D,MAAM,YAAY,GAAG,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC;aAC9C,kBAAkB,CAAC,GAAG,CAAC;aACvB,kBAAkB,CAAC,mBAAmB,EAAE,IAAI,CAAC;aAC7C,KAAK,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;aAClD,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;QAClC,8BAA8B;QAC9B,gBAAgB;QAEhB,IAAI,WAAW,EAAE;YACf,WAAW,GAAG,IAAI,WAAW,GAAG,CAAA;YAChC,YAAY,CAAC,QAAQ,CAAC,0BAA0B,EAAE,EAAE,WAAW,EAAE,CAAC,CAAA;SACnE;QAED,MAAM,CAAC,KAAK,EAAE,KAAK,C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O,CAAC,EAAE,CAAC,0BAAW,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;IAC3C,mBAAA,IAAA,kBAAG,EAAC,aAAa,CAAC,CAAA;IAAuB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;4CAoB7D;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,gCAAiB,EAAE,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAEtE,mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDAuBP;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,4BAAU,CAAC;IACjB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;6CAUvC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,kCAAe,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;mDAE7C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;0CAEpC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AA5FU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CA6FxB;AA7FY,oCAAY","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Arg, Ctx } from 'type-graphql'\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Project } from './project'\nimport { InspectionSummary, ProjectList } from './project-type'\nimport { BuildingComplex, InspectionType } from '@dssp/building-complex'\nimport { Attachment } from '@things-factory/attachment-base'\n\n@Resolver(Project)\nexport class ProjectQuery {\n @Query(returns => Project!, { nullable: true, description: 'To fetch a Project' })\n async project(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Project> {\n const { domain } = context.state\n\n return await getRepository(Project).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => ProjectList, { description: '프로젝트 리스트' })\n async projects(@Arg('projectName') projectName: string, @Ctx() context: ResolverContext): Promise<ProjectList> {\n const { domain } = context.state\n // const { page = 1, limit = 0 } = params.pagination || {}\n\n const queryBuilder = await getRepository(Project)\n .createQueryBuilder('p')\n .innerJoinAndSelect('p.buildingComplex', 'bc')\n .where('p.domain = :domain', { domain: domain.id })\n .orderBy('p.created_at', 'DESC')\n // .offset((page - 1) * limit)\n // .limit(limit)\n\n if (projectName) {\n projectName = `%${projectName}%`\n queryBuilder.andWhere('p.name LIKE :projectName', { projectName })\n }\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => InspectionSummary, { description: '프로젝트의 검측상태 별 카운트' })\n async inspectionSummary(\n @Arg('projectId') projectId: string,\n @Ctx() context: ResolverContext\n ): Promise<InspectionSummary> {\n const { domain } = context.state\n\n const queryBuilder = getRepository(Project)\n .createQueryBuilder('p')\n .select(`COUNT(CASE WHEN bi.type=\"${InspectionType.REQUEST}\" THEN 1 ELSE NULL END) AS request`)\n .addSelect(`COUNT(CASE WHEN bi.type=\"${InspectionType.PASS}\" THEN 1 ELSE NULL END) AS pass`)\n .addSelect(`COUNT(CASE WHEN bi.type=\"${InspectionType.FAIL}\" THEN 1 ELSE NULL END) AS fail`)\n .innerJoin('p.buildingComplex', 'bc')\n .innerJoin('bc.buildings', 'b')\n .innerJoin('b.buildingLevels', 'bl')\n .innerJoin('bl.buildingInspections', 'bi')\n .where('p.domain = :domain', { domain: domain.id })\n .andWhere('p.id = :projectId', { projectId })\n .groupBy('p.id')\n\n const result = (await queryBuilder.getRawOne()) || {}\n return {\n request: result.request || 0,\n pass: result.pass || 0,\n fail: result.fail || 0\n }\n }\n\n @FieldResolver(type => Attachment)\n async mainPhoto(@Root() project: Project): Promise<string | Attachment> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: project.domainId },\n refBy: project.id\n },\n order: { createdAt: 'ASC' }\n })\n\n return attachment\n }\n\n @FieldResolver(type => BuildingComplex)\n async buildingComplex(@Root() project: Project): Promise<BuildingComplex> {\n return await getRepository(BuildingComplex).findOneBy({ id: project.buildingComplexId })\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() project: Project): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: project.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() project: Project): Promise<User> {\n return await getRepository(User).findOneBy({ id: project.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() project: Project): Promise<User> {\n return await getRepository(User).findOneBy({ id: project.creatorId })\n }\n}\n"]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.InspectionSummary = exports.ProjectList = exports.ProjectPatch = exports.NewProject = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const project_1 = require("./project");
|
|
8
|
+
const building_complex_1 = require("@dssp/building-complex");
|
|
9
|
+
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
10
|
+
let NewProject = class NewProject {
|
|
11
|
+
};
|
|
12
|
+
tslib_1.__decorate([
|
|
13
|
+
(0, type_graphql_1.Field)({ nullable: false }),
|
|
14
|
+
tslib_1.__metadata("design:type", String)
|
|
15
|
+
], NewProject.prototype, "name", void 0);
|
|
16
|
+
NewProject = tslib_1.__decorate([
|
|
17
|
+
(0, type_graphql_1.InputType)()
|
|
18
|
+
], NewProject);
|
|
19
|
+
exports.NewProject = NewProject;
|
|
20
|
+
let ProjectPatch = class ProjectPatch {
|
|
21
|
+
};
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, type_graphql_1.Field)({ nullable: false }),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
25
|
+
], ProjectPatch.prototype, "id", void 0);
|
|
26
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, type_graphql_1.Field)({ nullable: false }),
|
|
28
|
+
tslib_1.__metadata("design:type", String)
|
|
29
|
+
], ProjectPatch.prototype, "name", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
33
|
+
], ProjectPatch.prototype, "startDate", void 0);
|
|
34
|
+
tslib_1.__decorate([
|
|
35
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
36
|
+
tslib_1.__metadata("design:type", String)
|
|
37
|
+
], ProjectPatch.prototype, "endDate", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
|
|
40
|
+
tslib_1.__metadata("design:type", Object)
|
|
41
|
+
], ProjectPatch.prototype, "mainPhotoUpload", void 0);
|
|
42
|
+
tslib_1.__decorate([
|
|
43
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
44
|
+
tslib_1.__metadata("design:type", Number)
|
|
45
|
+
], ProjectPatch.prototype, "totalProgress", void 0);
|
|
46
|
+
tslib_1.__decorate([
|
|
47
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
48
|
+
tslib_1.__metadata("design:type", Number)
|
|
49
|
+
], ProjectPatch.prototype, "weeklyProgress", void 0);
|
|
50
|
+
tslib_1.__decorate([
|
|
51
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
52
|
+
tslib_1.__metadata("design:type", Number)
|
|
53
|
+
], ProjectPatch.prototype, "kpi", void 0);
|
|
54
|
+
tslib_1.__decorate([
|
|
55
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
56
|
+
tslib_1.__metadata("design:type", Number)
|
|
57
|
+
], ProjectPatch.prototype, "inspPassRate", void 0);
|
|
58
|
+
tslib_1.__decorate([
|
|
59
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
60
|
+
tslib_1.__metadata("design:type", Number)
|
|
61
|
+
], ProjectPatch.prototype, "robotProgressRate", void 0);
|
|
62
|
+
tslib_1.__decorate([
|
|
63
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
64
|
+
tslib_1.__metadata("design:type", Number)
|
|
65
|
+
], ProjectPatch.prototype, "structuralSafetyRate", void 0);
|
|
66
|
+
tslib_1.__decorate([
|
|
67
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
68
|
+
tslib_1.__metadata("design:type", typeof (_a = typeof building_complex_1.BuildingComplexPatch !== "undefined" && building_complex_1.BuildingComplexPatch) === "function" ? _a : Object)
|
|
69
|
+
], ProjectPatch.prototype, "buildingComplex", void 0);
|
|
70
|
+
ProjectPatch = tslib_1.__decorate([
|
|
71
|
+
(0, type_graphql_1.InputType)()
|
|
72
|
+
], ProjectPatch);
|
|
73
|
+
exports.ProjectPatch = ProjectPatch;
|
|
74
|
+
let ProjectList = class ProjectList {
|
|
75
|
+
};
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, type_graphql_1.Field)(type => [project_1.Project]),
|
|
78
|
+
tslib_1.__metadata("design:type", Array)
|
|
79
|
+
], ProjectList.prototype, "items", void 0);
|
|
80
|
+
tslib_1.__decorate([
|
|
81
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
82
|
+
tslib_1.__metadata("design:type", Number)
|
|
83
|
+
], ProjectList.prototype, "total", void 0);
|
|
84
|
+
ProjectList = tslib_1.__decorate([
|
|
85
|
+
(0, type_graphql_1.ObjectType)()
|
|
86
|
+
], ProjectList);
|
|
87
|
+
exports.ProjectList = ProjectList;
|
|
88
|
+
let InspectionSummary = class InspectionSummary {
|
|
89
|
+
};
|
|
90
|
+
tslib_1.__decorate([
|
|
91
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
92
|
+
tslib_1.__metadata("design:type", Number)
|
|
93
|
+
], InspectionSummary.prototype, "request", void 0);
|
|
94
|
+
tslib_1.__decorate([
|
|
95
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
96
|
+
tslib_1.__metadata("design:type", Number)
|
|
97
|
+
], InspectionSummary.prototype, "pass", void 0);
|
|
98
|
+
tslib_1.__decorate([
|
|
99
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
100
|
+
tslib_1.__metadata("design:type", Number)
|
|
101
|
+
], InspectionSummary.prototype, "fail", void 0);
|
|
102
|
+
InspectionSummary = tslib_1.__decorate([
|
|
103
|
+
(0, type_graphql_1.ObjectType)()
|
|
104
|
+
], InspectionSummary);
|
|
105
|
+
exports.InspectionSummary = InspectionSummary;
|
|
106
|
+
//# sourceMappingURL=project-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-type.js","sourceRoot":"","sources":["../../../server/service/project/project-type.ts"],"names":[],"mappings":";;;;;AAAA,+CAAuE;AACvE,uCAAmC;AACnC,6DAA6D;AAE7D,+FAA2D;AAGpD,IAAM,UAAU,GAAhB,MAAM,UAAU;CAGtB,CAAA;AAFC;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;wCACf;AAFD,UAAU;IADtB,IAAA,wBAAS,GAAE;GACC,UAAU,CAGtB;AAHY,gCAAU;AAMhB,IAAM,YAAY,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oBAApB,uCAAoB;qDAAA;AAnC3B,YAAY;IADxB,IAAA,wBAAS,GAAE;GACC,YAAY,CAoCxB;AApCY,oCAAY;AAuClB,IAAM,WAAW,GAAjB,MAAM,WAAW;CAMvB,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,iBAAO,CAAC,CAAC;;0CACT;AAEhB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;0CACN;AALF,WAAW;IADvB,IAAA,yBAAU,GAAE;GACA,WAAW,CAMvB;AANY,kCAAW;AASjB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAS7B,CAAA;AARC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;kDACJ;AAEf;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;+CACP;AAEZ;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;+CACP;AARD,iBAAiB;IAD7B,IAAA,yBAAU,GAAE;GACA,iBAAiB,CAS7B;AATY,8CAAiB","sourcesContent":["import { ObjectType, Field, InputType, Int, Float } from 'type-graphql'\nimport { Project } from './project'\nimport { BuildingComplexPatch } from '@dssp/building-complex'\nimport type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\n\n@InputType()\nexport class NewProject {\n @Field({ nullable: false })\n name: string\n}\n\n@InputType()\nexport class ProjectPatch {\n @Field({ nullable: false })\n id: string\n\n @Field({ nullable: false })\n name: string\n\n @Field({ nullable: true })\n startDate?: string\n\n @Field({ nullable: true })\n endDate?: string\n\n @Field(type => GraphQLUpload, { nullable: true })\n mainPhotoUpload?: FileUpload\n\n @Field(type => Float, { nullable: true })\n totalProgress?: number\n\n @Field(type => Float, { nullable: true })\n weeklyProgress?: number\n\n @Field(type => Float, { nullable: true })\n kpi?: number\n\n @Field(type => Float, { nullable: true })\n inspPassRate?: number\n\n @Field(type => Float, { nullable: true })\n robotProgressRate?: number\n\n @Field(type => Float, { nullable: true })\n structuralSafetyRate?: number\n\n @Field({ nullable: true })\n buildingComplex?: BuildingComplexPatch\n}\n\n@ObjectType()\nexport class ProjectList {\n @Field(type => [Project])\n items: Project[]\n\n @Field(type => Int)\n total: number\n}\n\n@ObjectType()\nexport class InspectionSummary {\n @Field(type => Int)\n request: number\n\n @Field(type => Int)\n pass: number\n\n @Field(type => Int)\n fail: number\n}\n"]}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Project = exports.ProjectStatus = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const type_graphql_1 = require("type-graphql");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
10
|
+
const task_1 = require("../task/task");
|
|
11
|
+
const building_complex_1 = require("@dssp/building-complex");
|
|
12
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
13
|
+
var ProjectStatus;
|
|
14
|
+
(function (ProjectStatus) {
|
|
15
|
+
ProjectStatus["PROCEEDING"] = "10";
|
|
16
|
+
ProjectStatus["COMPLICATED"] = "20";
|
|
17
|
+
})(ProjectStatus = exports.ProjectStatus || (exports.ProjectStatus = {}));
|
|
18
|
+
(0, type_graphql_1.registerEnumType)(ProjectStatus, {
|
|
19
|
+
name: 'ProjectStatus',
|
|
20
|
+
description: '프로젝트 상태'
|
|
21
|
+
});
|
|
22
|
+
let Project = class Project {
|
|
23
|
+
};
|
|
24
|
+
tslib_1.__decorate([
|
|
25
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
26
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
27
|
+
tslib_1.__metadata("design:type", String)
|
|
28
|
+
], Project.prototype, "id", void 0);
|
|
29
|
+
tslib_1.__decorate([
|
|
30
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
31
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
32
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
33
|
+
], Project.prototype, "domain", void 0);
|
|
34
|
+
tslib_1.__decorate([
|
|
35
|
+
(0, typeorm_1.RelationId)((project) => project.domain),
|
|
36
|
+
tslib_1.__metadata("design:type", String)
|
|
37
|
+
], Project.prototype, "domainId", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ nullable: false, comment: '프로젝트 이름' }),
|
|
40
|
+
(0, type_graphql_1.Field)({ nullable: false }),
|
|
41
|
+
tslib_1.__metadata("design:type", String)
|
|
42
|
+
], Project.prototype, "name", void 0);
|
|
43
|
+
tslib_1.__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ nullable: false, default: ProjectStatus.PROCEEDING, comment: '프로젝트 상태 (10: 진행중, 20: 완료)' }),
|
|
45
|
+
(0, type_graphql_1.Field)({ nullable: false }),
|
|
46
|
+
tslib_1.__metadata("design:type", String)
|
|
47
|
+
], Project.prototype, "state", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, typeorm_1.Column)({ type: 'date', nullable: true, comment: '착공일정' }),
|
|
50
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
51
|
+
tslib_1.__metadata("design:type", String)
|
|
52
|
+
], Project.prototype, "startDate", void 0);
|
|
53
|
+
tslib_1.__decorate([
|
|
54
|
+
(0, typeorm_1.Column)({ type: 'date', nullable: true, comment: '준공일정' }),
|
|
55
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
56
|
+
tslib_1.__metadata("design:type", String)
|
|
57
|
+
], Project.prototype, "endDate", void 0);
|
|
58
|
+
tslib_1.__decorate([
|
|
59
|
+
(0, type_graphql_1.Field)(type => attachment_base_1.Attachment, { nullable: true }),
|
|
60
|
+
tslib_1.__metadata("design:type", attachment_base_1.Attachment)
|
|
61
|
+
], Project.prototype, "mainPhoto", void 0);
|
|
62
|
+
tslib_1.__decorate([
|
|
63
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0, transformer: shell_1.roundTransformer, comment: '전체 진행현황' }),
|
|
64
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
65
|
+
tslib_1.__metadata("design:type", Number)
|
|
66
|
+
], Project.prototype, "totalProgress", void 0);
|
|
67
|
+
tslib_1.__decorate([
|
|
68
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0, transformer: shell_1.roundTransformer, comment: '주간 진행현황' }),
|
|
69
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
70
|
+
tslib_1.__metadata("design:type", Number)
|
|
71
|
+
], Project.prototype, "weeklyProgress", void 0);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0, transformer: shell_1.roundTransformer, comment: 'KPI' }),
|
|
74
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
75
|
+
tslib_1.__metadata("design:type", Number)
|
|
76
|
+
], Project.prototype, "kpi", void 0);
|
|
77
|
+
tslib_1.__decorate([
|
|
78
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0, transformer: shell_1.roundTransformer, comment: '검측/통과 비율' }),
|
|
79
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
80
|
+
tslib_1.__metadata("design:type", Number)
|
|
81
|
+
], Project.prototype, "inspPassRate", void 0);
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0, transformer: shell_1.roundTransformer, comment: '로봇 작업 진행율' }),
|
|
84
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
85
|
+
tslib_1.__metadata("design:type", Number)
|
|
86
|
+
], Project.prototype, "robotProgressRate", void 0);
|
|
87
|
+
tslib_1.__decorate([
|
|
88
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0, transformer: shell_1.roundTransformer, comment: '구조 안전도' }),
|
|
89
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
90
|
+
tslib_1.__metadata("design:type", Number)
|
|
91
|
+
], Project.prototype, "structuralSafetyRate", void 0);
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
(0, typeorm_1.OneToOne)(type => building_complex_1.BuildingComplex),
|
|
94
|
+
(0, typeorm_1.JoinColumn)(),
|
|
95
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
96
|
+
tslib_1.__metadata("design:type", typeof (_a = typeof building_complex_1.BuildingComplex !== "undefined" && building_complex_1.BuildingComplex) === "function" ? _a : Object)
|
|
97
|
+
], Project.prototype, "buildingComplex", void 0);
|
|
98
|
+
tslib_1.__decorate([
|
|
99
|
+
(0, typeorm_1.RelationId)((project) => project.buildingComplex),
|
|
100
|
+
tslib_1.__metadata("design:type", String)
|
|
101
|
+
], Project.prototype, "buildingComplexId", void 0);
|
|
102
|
+
tslib_1.__decorate([
|
|
103
|
+
(0, type_graphql_1.Field)(() => [task_1.Task], { nullable: true }),
|
|
104
|
+
(0, typeorm_1.OneToMany)(() => task_1.Task, task => task.project),
|
|
105
|
+
tslib_1.__metadata("design:type", Array)
|
|
106
|
+
], Project.prototype, "tasks", void 0);
|
|
107
|
+
tslib_1.__decorate([
|
|
108
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
109
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
110
|
+
tslib_1.__metadata("design:type", Date)
|
|
111
|
+
], Project.prototype, "createdAt", void 0);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
114
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
115
|
+
tslib_1.__metadata("design:type", Date)
|
|
116
|
+
], Project.prototype, "updatedAt", void 0);
|
|
117
|
+
tslib_1.__decorate([
|
|
118
|
+
(0, typeorm_1.DeleteDateColumn)(),
|
|
119
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
120
|
+
tslib_1.__metadata("design:type", Date)
|
|
121
|
+
], Project.prototype, "deletedAt", void 0);
|
|
122
|
+
tslib_1.__decorate([
|
|
123
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
124
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
125
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
126
|
+
], Project.prototype, "creator", void 0);
|
|
127
|
+
tslib_1.__decorate([
|
|
128
|
+
(0, typeorm_1.RelationId)((project) => project.creator),
|
|
129
|
+
tslib_1.__metadata("design:type", String)
|
|
130
|
+
], Project.prototype, "creatorId", void 0);
|
|
131
|
+
tslib_1.__decorate([
|
|
132
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
133
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
134
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
135
|
+
], Project.prototype, "updater", void 0);
|
|
136
|
+
tslib_1.__decorate([
|
|
137
|
+
(0, typeorm_1.RelationId)((project) => project.updater),
|
|
138
|
+
tslib_1.__metadata("design:type", String)
|
|
139
|
+
], Project.prototype, "updaterId", void 0);
|
|
140
|
+
Project = tslib_1.__decorate([
|
|
141
|
+
(0, typeorm_1.Entity)(),
|
|
142
|
+
(0, typeorm_1.Index)('ix_project_0', (project) => [project.buildingComplex], { unique: true, where: '"deleted_at" IS NULL' }),
|
|
143
|
+
(0, type_graphql_1.ObjectType)({ description: '프로젝트' })
|
|
144
|
+
], Project);
|
|
145
|
+
exports.Project = Project;
|
|
146
|
+
//# sourceMappingURL=project.js.map
|