@things-factory/organization 6.0.0-zeta.26
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/client/bootstrap.ts +1 -0
- package/client/index.ts +0 -0
- package/client/pages/department/department-importer.ts +97 -0
- package/client/pages/department/department-list-page.ts +348 -0
- package/client/pages/employee/employee-importer.ts +97 -0
- package/client/pages/employee/employee-list-page.ts +348 -0
- package/client/pages/main.ts +25 -0
- package/client/route.ts +11 -0
- package/client/tsconfig.json +11 -0
- package/dist-client/actions/main.d.ts +1 -0
- package/dist-client/actions/main.js +2 -0
- package/dist-client/actions/main.js.map +1 -0
- package/dist-client/bootstrap.d.ts +1 -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/department/department-importer.d.ts +22 -0
- package/dist-client/pages/department/department-importer.js +100 -0
- package/dist-client/pages/department/department-importer.js.map +1 -0
- package/dist-client/pages/department/department-list-page.d.ts +62 -0
- package/dist-client/pages/department/department-list-page.js +326 -0
- package/dist-client/pages/department/department-list-page.js.map +1 -0
- package/dist-client/pages/employee/employee-importer.d.ts +22 -0
- package/dist-client/pages/employee/employee-importer.js +100 -0
- package/dist-client/pages/employee/employee-importer.js.map +1 -0
- package/dist-client/pages/employee/employee-list-page.d.ts +62 -0
- package/dist-client/pages/employee/employee-list-page.js +326 -0
- package/dist-client/pages/employee/employee-list-page.js.map +1 -0
- package/dist-client/pages/main.d.ts +1 -0
- package/dist-client/pages/main.js +27 -0
- package/dist-client/pages/main.js.map +1 -0
- package/dist-client/reducers/main.d.ts +6 -0
- package/dist-client/reducers/main.js +14 -0
- package/dist-client/reducers/main.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +11 -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/index.js +7 -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/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/routes.js +25 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/service/department/department-history.js +156 -0
- package/dist-server/service/department/department-history.js.map +1 -0
- package/dist-server/service/department/department-mutation.js +168 -0
- package/dist-server/service/department/department-mutation.js.map +1 -0
- package/dist-server/service/department/department-query.js +97 -0
- package/dist-server/service/department/department-query.js.map +1 -0
- package/dist-server/service/department/department-type.js +90 -0
- package/dist-server/service/department/department-type.js.map +1 -0
- package/dist-server/service/department/department.js +145 -0
- package/dist-server/service/department/department.js.map +1 -0
- package/dist-server/service/department/event-subscriber.js +21 -0
- package/dist-server/service/department/event-subscriber.js.map +1 -0
- package/dist-server/service/department/index.js +12 -0
- package/dist-server/service/department/index.js.map +1 -0
- package/dist-server/service/employee/employee-history.js +157 -0
- package/dist-server/service/employee/employee-history.js.map +1 -0
- package/dist-server/service/employee/employee-mutation.js +168 -0
- package/dist-server/service/employee/employee-mutation.js.map +1 -0
- package/dist-server/service/employee/employee-query.js +97 -0
- package/dist-server/service/employee/employee-query.js.map +1 -0
- package/dist-server/service/employee/employee-type.js +90 -0
- package/dist-server/service/employee/employee-type.js.map +1 -0
- package/dist-server/service/employee/employee.js +148 -0
- package/dist-server/service/employee/employee.js.map +1 -0
- package/dist-server/service/employee/event-subscriber.js +21 -0
- package/dist-server/service/employee/event-subscriber.js.map +1 -0
- package/dist-server/service/employee/index.js +12 -0
- package/dist-server/service/employee/index.js.map +1 -0
- package/dist-server/service/index.js +28 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/helps/organization/department.md +160 -0
- package/helps/organization/employee.md +160 -0
- package/package.json +35 -0
- package/server/controllers/index.ts +0 -0
- package/server/index.ts +4 -0
- package/server/middlewares/index.ts +3 -0
- package/server/migrations/index.ts +9 -0
- package/server/routes.ts +28 -0
- package/server/service/department/department-history.ts +137 -0
- package/server/service/department/department-mutation.ts +201 -0
- package/server/service/department/department-query.ts +62 -0
- package/server/service/department/department-type.ts +64 -0
- package/server/service/department/department.ts +124 -0
- package/server/service/department/event-subscriber.ts +17 -0
- package/server/service/department/index.ts +9 -0
- package/server/service/employee/employee-history.ts +137 -0
- package/server/service/employee/employee-mutation.ts +198 -0
- package/server/service/employee/employee-query.ts +62 -0
- package/server/service/employee/employee-type.ts +64 -0
- package/server/service/employee/employee.ts +126 -0
- package/server/service/employee/event-subscriber.ts +17 -0
- package/server/service/employee/index.ts +9 -0
- package/server/service/index.ts +27 -0
- package/server/tsconfig.json +10 -0
- package/things-factory.config.js +11 -0
- package/translations/en.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DepartmentMutation = 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 department_1 = require("./department");
|
|
9
|
+
const department_type_1 = require("./department-type");
|
|
10
|
+
let DepartmentMutation = class DepartmentMutation {
|
|
11
|
+
async createDepartment(department, context) {
|
|
12
|
+
const { domain, user, tx } = context.state;
|
|
13
|
+
const result = await tx.getRepository(department_1.Department).save(Object.assign(Object.assign({}, department), { domain, creator: user, updater: user }));
|
|
14
|
+
if (department.picture) {
|
|
15
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
16
|
+
attachment: {
|
|
17
|
+
file: department.picture,
|
|
18
|
+
refType: department_1.Department.name,
|
|
19
|
+
refBy: result.id
|
|
20
|
+
}
|
|
21
|
+
}, context);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
async updateDepartment(id, patch, context) {
|
|
26
|
+
const { domain, user, tx } = context.state;
|
|
27
|
+
const repository = tx.getRepository(department_1.Department);
|
|
28
|
+
const department = await repository.findOne({
|
|
29
|
+
where: { domain: { id: domain.id }, id }
|
|
30
|
+
});
|
|
31
|
+
const result = await repository.save(Object.assign(Object.assign(Object.assign({}, department), patch), { updater: user }));
|
|
32
|
+
if (patch.picture) {
|
|
33
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
|
|
34
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
35
|
+
attachment: {
|
|
36
|
+
file: patch.picture,
|
|
37
|
+
refType: department_1.Department.name,
|
|
38
|
+
refBy: result.id
|
|
39
|
+
}
|
|
40
|
+
}, context);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
async updateMultipleDepartment(patches, context) {
|
|
45
|
+
const { domain, user, tx } = context.state;
|
|
46
|
+
let results = [];
|
|
47
|
+
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
48
|
+
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
49
|
+
const departmentRepo = tx.getRepository(department_1.Department);
|
|
50
|
+
if (_createRecords.length > 0) {
|
|
51
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
52
|
+
const newRecord = _createRecords[i];
|
|
53
|
+
const result = await departmentRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
|
|
54
|
+
if (newRecord.picture) {
|
|
55
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
56
|
+
attachment: {
|
|
57
|
+
file: newRecord.picture,
|
|
58
|
+
refType: department_1.Department.name,
|
|
59
|
+
refBy: result.id
|
|
60
|
+
}
|
|
61
|
+
}, context);
|
|
62
|
+
}
|
|
63
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (_updateRecords.length > 0) {
|
|
67
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
68
|
+
const updateRecord = _updateRecords[i];
|
|
69
|
+
const department = await departmentRepo.findOneBy({ id: updateRecord.id });
|
|
70
|
+
const result = await departmentRepo.save(Object.assign(Object.assign(Object.assign({}, department), updateRecord), { updater: user }));
|
|
71
|
+
if (updateRecord.picture) {
|
|
72
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
|
|
73
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
74
|
+
attachment: {
|
|
75
|
+
file: updateRecord.picture,
|
|
76
|
+
refType: department_1.Department.name,
|
|
77
|
+
refBy: result.id
|
|
78
|
+
}
|
|
79
|
+
}, context);
|
|
80
|
+
}
|
|
81
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return results;
|
|
85
|
+
}
|
|
86
|
+
async deleteDepartment(id, context) {
|
|
87
|
+
const { domain, tx } = context.state;
|
|
88
|
+
await tx.getRepository(department_1.Department).delete({ domain: { id: domain.id }, id });
|
|
89
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
async deleteDepartments(ids, context) {
|
|
93
|
+
const { domain, tx } = context.state;
|
|
94
|
+
await tx.getRepository(department_1.Department).delete({
|
|
95
|
+
domain: { id: domain.id },
|
|
96
|
+
id: (0, typeorm_1.In)(ids)
|
|
97
|
+
});
|
|
98
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
async importDepartments(departments, context) {
|
|
102
|
+
const { domain, tx } = context.state;
|
|
103
|
+
await Promise.all(departments.map(async (department) => {
|
|
104
|
+
const createdDepartment = await tx.getRepository(department_1.Department).save(Object.assign({ domain }, department));
|
|
105
|
+
}));
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
tslib_1.__decorate([
|
|
110
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
111
|
+
(0, type_graphql_1.Mutation)(returns => department_1.Department, { description: 'To create new Department' }),
|
|
112
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('department')),
|
|
113
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
114
|
+
tslib_1.__metadata("design:type", Function),
|
|
115
|
+
tslib_1.__metadata("design:paramtypes", [department_type_1.NewDepartment, Object]),
|
|
116
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
117
|
+
], DepartmentMutation.prototype, "createDepartment", null);
|
|
118
|
+
tslib_1.__decorate([
|
|
119
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
120
|
+
(0, type_graphql_1.Mutation)(returns => department_1.Department, { description: 'To modify Department information' }),
|
|
121
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
122
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
123
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
124
|
+
tslib_1.__metadata("design:type", Function),
|
|
125
|
+
tslib_1.__metadata("design:paramtypes", [String, department_type_1.DepartmentPatch, Object]),
|
|
126
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
127
|
+
], DepartmentMutation.prototype, "updateDepartment", null);
|
|
128
|
+
tslib_1.__decorate([
|
|
129
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
130
|
+
(0, type_graphql_1.Mutation)(returns => [department_1.Department], { description: "To modify multiple Departments' information" }),
|
|
131
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [department_type_1.DepartmentPatch])),
|
|
132
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
133
|
+
tslib_1.__metadata("design:type", Function),
|
|
134
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
135
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
136
|
+
], DepartmentMutation.prototype, "updateMultipleDepartment", null);
|
|
137
|
+
tslib_1.__decorate([
|
|
138
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
139
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Department' }),
|
|
140
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
141
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
142
|
+
tslib_1.__metadata("design:type", Function),
|
|
143
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
144
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
145
|
+
], DepartmentMutation.prototype, "deleteDepartment", null);
|
|
146
|
+
tslib_1.__decorate([
|
|
147
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
148
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple Departments' }),
|
|
149
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
150
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
151
|
+
tslib_1.__metadata("design:type", Function),
|
|
152
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
153
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
154
|
+
], DepartmentMutation.prototype, "deleteDepartments", null);
|
|
155
|
+
tslib_1.__decorate([
|
|
156
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
157
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple Departments' }),
|
|
158
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('departments', type => [department_type_1.DepartmentPatch])),
|
|
159
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
160
|
+
tslib_1.__metadata("design:type", Function),
|
|
161
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
162
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
163
|
+
], DepartmentMutation.prototype, "importDepartments", null);
|
|
164
|
+
DepartmentMutation = tslib_1.__decorate([
|
|
165
|
+
(0, type_graphql_1.Resolver)(department_1.Department)
|
|
166
|
+
], DepartmentMutation);
|
|
167
|
+
exports.DepartmentMutation = DepartmentMutation;
|
|
168
|
+
//# sourceMappingURL=department-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"department-mutation.js","sourceRoot":"","sources":["../../../server/service/department/department-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,6CAAyC;AACzC,uDAAkE;AAG3D,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,gBAAgB,CACD,UAAyB,EACrC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,uBAAU,CAAC,CAAC,IAAI,iCACjD,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,IAAI,UAAU,CAAC,OAAO,EAAE;YACtB,MAAM,IAAA,kCAAgB,EACpB,IAAI,EACJ;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,UAAU,CAAC,OAAO;oBACxB,OAAO,EAAE,uBAAU,CAAC,IAAI;oBACxB,KAAK,EAAE,MAAM,CAAC,EAAE;iBACjB;aACF,EACD,OAAO,CACR,CAAA;SACF;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAIK,AAAN,KAAK,CAAC,g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x, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { Department } from './department'\nimport { NewDepartment, DepartmentPatch } from './department-type'\n\n@Resolver(Department)\nexport class DepartmentMutation {\n @Directive('@transaction')\n @Mutation(returns => Department, { description: 'To create new Department' })\n async createDepartment(\n @Arg('department') department: NewDepartment,\n @Ctx() context: ResolverContext\n ): Promise<Department> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(Department).save({\n ...department,\n domain,\n creator: user,\n updater: user\n })\n\n if (department.picture) {\n await createAttachment(\n null,\n {\n attachment: {\n file: department.picture,\n refType: Department.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Department, { description: 'To modify Department information' })\n async updateDepartment(\n @Arg('id') id: string,\n @Arg('patch') patch: DepartmentPatch,\n @Ctx() context: ResolverContext\n ): Promise<Department> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Department)\n const department = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...department,\n ...patch,\n updater: user\n })\n\n if (patch.picture) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.picture,\n refType: Department.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Department], { description: \"To modify multiple Departments' information\" })\n async updateMultipleDepartment(\n @Arg('patches', type => [DepartmentPatch]) patches: DepartmentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Department[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const departmentRepo = tx.getRepository(Department)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await departmentRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.picture) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.picture,\n refType: Department.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const department = await departmentRepo.findOneBy({ id: updateRecord.id })\n\n const result = await departmentRepo.save({\n ...department,\n ...updateRecord,\n updater: user\n })\n\n if (updateRecord.picture) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.picture,\n refType: Department.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Department' })\n async deleteDepartment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Department).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple Departments' })\n async deleteDepartments(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Department).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple Departments' })\n async importDepartments(\n @Arg('departments', type => [DepartmentPatch]) departments: DepartmentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n departments.map(async (department: DepartmentPatch) => {\n const createdDepartment: Department = await tx.getRepository(Department).save({ domain, ...department })\n })\n )\n\n return true\n }\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DepartmentQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
const department_1 = require("./department");
|
|
10
|
+
const department_type_1 = require("./department-type");
|
|
11
|
+
let DepartmentQuery = class DepartmentQuery {
|
|
12
|
+
async department(id, context) {
|
|
13
|
+
const { domain } = context.state;
|
|
14
|
+
return await (0, shell_1.getRepository)(department_1.Department).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async departments(params, context) {
|
|
19
|
+
const { domain } = context.state;
|
|
20
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
21
|
+
domain,
|
|
22
|
+
params,
|
|
23
|
+
repository: await (0, shell_1.getRepository)(department_1.Department),
|
|
24
|
+
searchables: ['name', 'description']
|
|
25
|
+
});
|
|
26
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
27
|
+
return { items, total };
|
|
28
|
+
}
|
|
29
|
+
async picture(department) {
|
|
30
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
31
|
+
where: {
|
|
32
|
+
domain: { id: department.domainId },
|
|
33
|
+
refType: department_1.Department.name,
|
|
34
|
+
refBy: department.id
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return attachment === null || attachment === void 0 ? void 0 : attachment.fullpath;
|
|
38
|
+
}
|
|
39
|
+
async domain(department) {
|
|
40
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: department.domainId });
|
|
41
|
+
}
|
|
42
|
+
async updater(department) {
|
|
43
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: department.updaterId });
|
|
44
|
+
}
|
|
45
|
+
async creator(department) {
|
|
46
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: department.creatorId });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, type_graphql_1.Query)(returns => department_1.Department, { nullable: true, description: 'To fetch a Department' }),
|
|
51
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
52
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
53
|
+
tslib_1.__metadata("design:type", Function),
|
|
54
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
55
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
56
|
+
], DepartmentQuery.prototype, "department", null);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, type_graphql_1.Query)(returns => department_type_1.DepartmentList, { description: 'To fetch multiple Departments' }),
|
|
59
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
60
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
61
|
+
tslib_1.__metadata("design:type", Function),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
63
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
64
|
+
], DepartmentQuery.prototype, "departments", null);
|
|
65
|
+
tslib_1.__decorate([
|
|
66
|
+
(0, type_graphql_1.FieldResolver)(type => String),
|
|
67
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
68
|
+
tslib_1.__metadata("design:type", Function),
|
|
69
|
+
tslib_1.__metadata("design:paramtypes", [department_1.Department]),
|
|
70
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
71
|
+
], DepartmentQuery.prototype, "picture", null);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
74
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
75
|
+
tslib_1.__metadata("design:type", Function),
|
|
76
|
+
tslib_1.__metadata("design:paramtypes", [department_1.Department]),
|
|
77
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
78
|
+
], DepartmentQuery.prototype, "domain", null);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
81
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
82
|
+
tslib_1.__metadata("design:type", Function),
|
|
83
|
+
tslib_1.__metadata("design:paramtypes", [department_1.Department]),
|
|
84
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
85
|
+
], DepartmentQuery.prototype, "updater", null);
|
|
86
|
+
tslib_1.__decorate([
|
|
87
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
88
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
89
|
+
tslib_1.__metadata("design:type", Function),
|
|
90
|
+
tslib_1.__metadata("design:paramtypes", [department_1.Department]),
|
|
91
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
92
|
+
], DepartmentQuery.prototype, "creator", null);
|
|
93
|
+
DepartmentQuery = tslib_1.__decorate([
|
|
94
|
+
(0, type_graphql_1.Resolver)(department_1.Department)
|
|
95
|
+
], DepartmentQuery);
|
|
96
|
+
exports.DepartmentQuery = DepartmentQuery;
|
|
97
|
+
//# sourceMappingURL=department-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"department-query.js","sourceRoot":"","sources":["../../../server/service/department/department-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qEAA4D;AAC5D,iDAAuG;AACvG,yDAAgD;AAChD,6CAAyC;AACzC,uDAAkD;AAG3C,IAAM,eAAe,GAArB,MAAM,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AAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,uBAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,uBAAU;;8CAE3C;AApDU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,eAAe,CAqD3B;AArDY,0CAAe","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Department } from './department'\nimport { DepartmentList } from './department-type'\n\n@Resolver(Department)\nexport class DepartmentQuery {\n @Query(returns => Department!, { nullable: true, description: 'To fetch a Department' })\n async department(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Department> {\n const { domain } = context.state\n\n return await getRepository(Department).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => DepartmentList, { description: 'To fetch multiple Departments' })\n async departments(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<DepartmentList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(Department),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async picture(@Root() department: Department): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: department.domainId },\n refType: Department.name,\n refBy: department.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() department: Department): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: department.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() department: Department): Promise<User> {\n return await getRepository(User).findOneBy({ id: department.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() department: Department): Promise<User> {\n return await getRepository(User).findOneBy({ id: department.creatorId })\n }\n}\n"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DepartmentList = exports.DepartmentPatch = exports.NewDepartment = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const department_1 = require("./department");
|
|
8
|
+
let NewDepartment = class NewDepartment {
|
|
9
|
+
};
|
|
10
|
+
tslib_1.__decorate([
|
|
11
|
+
(0, type_graphql_1.Field)(),
|
|
12
|
+
tslib_1.__metadata("design:type", String)
|
|
13
|
+
], NewDepartment.prototype, "controlNo", void 0);
|
|
14
|
+
tslib_1.__decorate([
|
|
15
|
+
(0, type_graphql_1.Field)(),
|
|
16
|
+
tslib_1.__metadata("design:type", String)
|
|
17
|
+
], NewDepartment.prototype, "name", void 0);
|
|
18
|
+
tslib_1.__decorate([
|
|
19
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
20
|
+
tslib_1.__metadata("design:type", String)
|
|
21
|
+
], NewDepartment.prototype, "description", void 0);
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, type_graphql_1.Field)(type => department_1.DepartmentStatus, { nullable: true }),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
25
|
+
], NewDepartment.prototype, "state", void 0);
|
|
26
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
28
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
29
|
+
], NewDepartment.prototype, "active", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
33
|
+
], NewDepartment.prototype, "extension", void 0);
|
|
34
|
+
tslib_1.__decorate([
|
|
35
|
+
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
|
|
36
|
+
tslib_1.__metadata("design:type", Object)
|
|
37
|
+
], NewDepartment.prototype, "picture", void 0);
|
|
38
|
+
NewDepartment = tslib_1.__decorate([
|
|
39
|
+
(0, type_graphql_1.InputType)()
|
|
40
|
+
], NewDepartment);
|
|
41
|
+
exports.NewDepartment = NewDepartment;
|
|
42
|
+
let DepartmentPatch = class DepartmentPatch {
|
|
43
|
+
};
|
|
44
|
+
tslib_1.__decorate([
|
|
45
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
|
|
46
|
+
tslib_1.__metadata("design:type", String)
|
|
47
|
+
], DepartmentPatch.prototype, "id", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
51
|
+
], DepartmentPatch.prototype, "name", void 0);
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
54
|
+
tslib_1.__metadata("design:type", String)
|
|
55
|
+
], DepartmentPatch.prototype, "description", void 0);
|
|
56
|
+
tslib_1.__decorate([
|
|
57
|
+
(0, type_graphql_1.Field)(type => department_1.DepartmentStatus, { nullable: true }),
|
|
58
|
+
tslib_1.__metadata("design:type", String)
|
|
59
|
+
], DepartmentPatch.prototype, "state", void 0);
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
62
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
63
|
+
], DepartmentPatch.prototype, "active", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
|
|
66
|
+
tslib_1.__metadata("design:type", Object)
|
|
67
|
+
], DepartmentPatch.prototype, "picture", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
70
|
+
tslib_1.__metadata("design:type", String)
|
|
71
|
+
], DepartmentPatch.prototype, "cuFlag", void 0);
|
|
72
|
+
DepartmentPatch = tslib_1.__decorate([
|
|
73
|
+
(0, type_graphql_1.InputType)()
|
|
74
|
+
], DepartmentPatch);
|
|
75
|
+
exports.DepartmentPatch = DepartmentPatch;
|
|
76
|
+
let DepartmentList = class DepartmentList {
|
|
77
|
+
};
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, type_graphql_1.Field)(type => [department_1.Department]),
|
|
80
|
+
tslib_1.__metadata("design:type", Array)
|
|
81
|
+
], DepartmentList.prototype, "items", void 0);
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
84
|
+
tslib_1.__metadata("design:type", Number)
|
|
85
|
+
], DepartmentList.prototype, "total", void 0);
|
|
86
|
+
DepartmentList = tslib_1.__decorate([
|
|
87
|
+
(0, type_graphql_1.ObjectType)()
|
|
88
|
+
], DepartmentList);
|
|
89
|
+
exports.DepartmentList = DepartmentList;
|
|
90
|
+
//# sourceMappingURL=department-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"department-type.js","sourceRoot":"","sources":["../../../server/service/department/department-type.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAsF;AAItF,6CAA2D;AAGpD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAqBzB,CAAA;AApBC;IAAC,IAAA,oBAAK,GAAE;;gDACS;AAEjB;IAAC,IAAA,oBAAK,GAAE;;2CACI;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,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M1B,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,uBAAU,CAAC,CAAC;;6CACT;AAEnB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;6CACN;AALF,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAM1B;AANY,wCAAc","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Department, DepartmentStatus } from './department'\n\n@InputType()\nexport class NewDepartment {\n @Field()\n controlNo: string\n\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => DepartmentStatus, { nullable: true })\n state?: DepartmentStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n extension?: string\n\n @Field(type => GraphQLUpload, { nullable: true })\n picture?: FileUpload\n}\n\n@InputType()\nexport class DepartmentPatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => DepartmentStatus, { nullable: true })\n state?: DepartmentStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field(type => GraphQLUpload, { nullable: true })\n picture?: FileUpload\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class DepartmentList {\n @Field(type => [Department])\n items: Department[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var Department_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Department = exports.DepartmentStatus = 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 employee_1 = require("../employee/employee");
|
|
11
|
+
var DepartmentStatus;
|
|
12
|
+
(function (DepartmentStatus) {
|
|
13
|
+
DepartmentStatus["STATUS_A"] = "STATUS_A";
|
|
14
|
+
DepartmentStatus["STATUS_B"] = "STATUS_B";
|
|
15
|
+
})(DepartmentStatus = exports.DepartmentStatus || (exports.DepartmentStatus = {}));
|
|
16
|
+
(0, type_graphql_1.registerEnumType)(DepartmentStatus, {
|
|
17
|
+
name: 'DepartmentStatus',
|
|
18
|
+
description: 'state enumeration of a department'
|
|
19
|
+
});
|
|
20
|
+
let Department = Department_1 = class Department {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.version = 1;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
27
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
28
|
+
tslib_1.__metadata("design:type", String)
|
|
29
|
+
], Department.prototype, "id", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, typeorm_1.VersionColumn)(),
|
|
32
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
33
|
+
tslib_1.__metadata("design:type", Number)
|
|
34
|
+
], Department.prototype, "version", void 0);
|
|
35
|
+
tslib_1.__decorate([
|
|
36
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
37
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
38
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
39
|
+
], Department.prototype, "domain", void 0);
|
|
40
|
+
tslib_1.__decorate([
|
|
41
|
+
(0, typeorm_1.RelationId)((department) => department.domain),
|
|
42
|
+
tslib_1.__metadata("design:type", String)
|
|
43
|
+
], Department.prototype, "domainId", void 0);
|
|
44
|
+
tslib_1.__decorate([
|
|
45
|
+
(0, typeorm_1.Column)(),
|
|
46
|
+
(0, type_graphql_1.Field)(),
|
|
47
|
+
tslib_1.__metadata("design:type", String)
|
|
48
|
+
], Department.prototype, "controlNo", void 0);
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, typeorm_1.Column)(),
|
|
51
|
+
(0, type_graphql_1.Field)(),
|
|
52
|
+
tslib_1.__metadata("design:type", String)
|
|
53
|
+
], Department.prototype, "name", void 0);
|
|
54
|
+
tslib_1.__decorate([
|
|
55
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
56
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
57
|
+
tslib_1.__metadata("design:type", String)
|
|
58
|
+
], Department.prototype, "description", void 0);
|
|
59
|
+
tslib_1.__decorate([
|
|
60
|
+
(0, typeorm_1.ManyToOne)(type => Department_1, department => department.children, { nullable: true }),
|
|
61
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
62
|
+
tslib_1.__metadata("design:type", Department)
|
|
63
|
+
], Department.prototype, "parent", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, typeorm_1.RelationId)((department) => department.parent),
|
|
66
|
+
tslib_1.__metadata("design:type", String)
|
|
67
|
+
], Department.prototype, "parentId", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, typeorm_1.OneToMany)(type => Department_1, department => department.parent),
|
|
70
|
+
(0, type_graphql_1.Field)(type => [Department_1]),
|
|
71
|
+
tslib_1.__metadata("design:type", Array)
|
|
72
|
+
], Department.prototype, "children", void 0);
|
|
73
|
+
tslib_1.__decorate([
|
|
74
|
+
(0, typeorm_1.ManyToOne)(type => employee_1.Employee, manager => manager.manages, { nullable: true }),
|
|
75
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
76
|
+
tslib_1.__metadata("design:type", employee_1.Employee)
|
|
77
|
+
], Department.prototype, "manager", void 0);
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, typeorm_1.RelationId)((department) => department.manager),
|
|
80
|
+
tslib_1.__metadata("design:type", String)
|
|
81
|
+
], Department.prototype, "managerId", void 0);
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
84
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
85
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
86
|
+
], Department.prototype, "active", void 0);
|
|
87
|
+
tslib_1.__decorate([
|
|
88
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
89
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
90
|
+
tslib_1.__metadata("design:type", String)
|
|
91
|
+
], Department.prototype, "state", void 0);
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
94
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
95
|
+
tslib_1.__metadata("design:type", String)
|
|
96
|
+
], Department.prototype, "extension", void 0);
|
|
97
|
+
tslib_1.__decorate([
|
|
98
|
+
(0, type_graphql_1.Field)(type => String, { nullable: true }),
|
|
99
|
+
tslib_1.__metadata("design:type", String)
|
|
100
|
+
], Department.prototype, "picture", void 0);
|
|
101
|
+
tslib_1.__decorate([
|
|
102
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
103
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
104
|
+
tslib_1.__metadata("design:type", Date)
|
|
105
|
+
], Department.prototype, "createdAt", void 0);
|
|
106
|
+
tslib_1.__decorate([
|
|
107
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
108
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
109
|
+
tslib_1.__metadata("design:type", Date)
|
|
110
|
+
], Department.prototype, "updatedAt", void 0);
|
|
111
|
+
tslib_1.__decorate([
|
|
112
|
+
(0, typeorm_1.DeleteDateColumn)(),
|
|
113
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
114
|
+
tslib_1.__metadata("design:type", Date)
|
|
115
|
+
], Department.prototype, "deletedAt", void 0);
|
|
116
|
+
tslib_1.__decorate([
|
|
117
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
118
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
119
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
120
|
+
], Department.prototype, "creator", void 0);
|
|
121
|
+
tslib_1.__decorate([
|
|
122
|
+
(0, typeorm_1.RelationId)((department) => department.creator),
|
|
123
|
+
tslib_1.__metadata("design:type", String)
|
|
124
|
+
], Department.prototype, "creatorId", void 0);
|
|
125
|
+
tslib_1.__decorate([
|
|
126
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
127
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
128
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
129
|
+
], Department.prototype, "updater", void 0);
|
|
130
|
+
tslib_1.__decorate([
|
|
131
|
+
(0, typeorm_1.RelationId)((department) => department.updater),
|
|
132
|
+
tslib_1.__metadata("design:type", String)
|
|
133
|
+
], Department.prototype, "updaterId", void 0);
|
|
134
|
+
Department = Department_1 = tslib_1.__decorate([
|
|
135
|
+
(0, typeorm_1.Entity)(),
|
|
136
|
+
(0, typeorm_1.Index)('ix_department_0', (department) => [department.domain, department.name, department.deletedAt], {
|
|
137
|
+
unique: true
|
|
138
|
+
}),
|
|
139
|
+
(0, typeorm_1.Index)('ix_department_1', (department) => [department.domain, department.controlNo, department.deletedAt], {
|
|
140
|
+
unique: true
|
|
141
|
+
}),
|
|
142
|
+
(0, type_graphql_1.ObjectType)({ description: 'Entity for Department' })
|
|
143
|
+
], Department);
|
|
144
|
+
exports.Department = Department;
|
|
145
|
+
//# sourceMappingURL=department.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"department.js","sourceRoot":"","sources":["../../../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,SAAS,CAAC,EAAE;QAChH,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE;QACrH,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;GACxC,UAAU,CAsFtB;AAtFY,gCAAU","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n OneToMany,\n PrimaryGeneratedColumn,\n VersionColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Employee } from '../employee/employee'\n\nexport enum DepartmentStatus {\n STATUS_A = 'STATUS_A',\n STATUS_B = 'STATUS_B'\n}\n\nregisterEnumType(DepartmentStatus, {\n name: 'DepartmentStatus',\n description: 'state enumeration of a department'\n})\n\n@Entity()\n@Index('ix_department_0', (department: Department) => [department.domain, department.name, department.deletedAt], {\n unique: true\n})\n@Index('ix_department_1', (department: Department) => [department.domain, department.controlNo, department.deletedAt], {\n unique: true\n})\n@ObjectType({ description: 'Entity for Department' })\nexport class Department {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @VersionColumn()\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((department: Department) => department.domain)\n domainId?: string\n\n @Column()\n @Field()\n controlNo: string\n\n @Column()\n @Field()\n name: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description?: string\n\n @ManyToOne(type => Department, department => department.children, { nullable: true })\n @Field({ nullable: true })\n parent?: Department\n\n @RelationId((department: Department) => department.parent)\n parentId?: string\n\n @OneToMany(type => Department, department => department.parent)\n @Field(type => [Department])\n children?: Department[]\n\n @ManyToOne(type => Employee, manager => manager.manages, { nullable: true })\n @Field({ nullable: true })\n manager?: Employee\n\n @RelationId((department: Department) => department.manager)\n managerId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n state?: DepartmentStatus\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n extension?: string\n\n @Field(type => String, { nullable: true })\n picture?: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator?: User\n\n @RelationId((department: Department) => department.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater?: User\n\n @RelationId((department: Department) => department.updater)\n updaterId?: string\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DepartmentHistoryEntitySubscriber = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const typeorm_history_1 = require("@anchan828/typeorm-history");
|
|
7
|
+
const department_1 = require("./department");
|
|
8
|
+
const department_history_1 = require("./department-history");
|
|
9
|
+
let DepartmentHistoryEntitySubscriber = class DepartmentHistoryEntitySubscriber extends typeorm_history_1.HistoryEntitySubscriber {
|
|
10
|
+
get entity() {
|
|
11
|
+
return department_1.Department;
|
|
12
|
+
}
|
|
13
|
+
get historyEntity() {
|
|
14
|
+
return department_history_1.DepartmentHistory;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
DepartmentHistoryEntitySubscriber = tslib_1.__decorate([
|
|
18
|
+
(0, typeorm_1.EventSubscriber)()
|
|
19
|
+
], DepartmentHistoryEntitySubscriber);
|
|
20
|
+
exports.DepartmentHistoryEntitySubscriber = DepartmentHistoryEntitySubscriber;
|
|
21
|
+
//# sourceMappingURL=event-subscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-subscriber.js","sourceRoot":"","sources":["../../../server/service/department/event-subscriber.ts"],"names":[],"mappings":";;;;AAAA,qCAAyC;AAEzC,gEAAoE;AAEpE,6CAAyC;AACzC,6DAAwD;AAGjD,IAAM,iCAAiC,GAAvC,MAAM,iCAAkC,SAAQ,yCAAsD;IAC3G,IAAW,MAAM;QACf,OAAO,uBAAU,CAAA;IACnB,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,sCAAiB,CAAA;IAC1B,CAAC;CACF,CAAA;AARY,iCAAiC;IAD7C,IAAA,yBAAe,GAAE;GACL,iCAAiC,CAQ7C;AARY,8EAAiC","sourcesContent":["import { EventSubscriber } from 'typeorm'\n\nimport { HistoryEntitySubscriber } from '@anchan828/typeorm-history'\n\nimport { Department } from './department'\nimport { DepartmentHistory } from './department-history'\n\n@EventSubscriber()\nexport class DepartmentHistoryEntitySubscriber extends HistoryEntitySubscriber<Department, DepartmentHistory> {\n public get entity() {\n return Department\n }\n\n public get historyEntity() {\n return DepartmentHistory\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subscribers = exports.resolvers = exports.entities = void 0;
|
|
4
|
+
const department_1 = require("./department");
|
|
5
|
+
const department_history_1 = require("./department-history");
|
|
6
|
+
const department_query_1 = require("./department-query");
|
|
7
|
+
const department_mutation_1 = require("./department-mutation");
|
|
8
|
+
const event_subscriber_1 = require("./event-subscriber");
|
|
9
|
+
exports.entities = [department_1.Department, department_history_1.DepartmentHistory];
|
|
10
|
+
exports.resolvers = [department_query_1.DepartmentQuery, department_mutation_1.DepartmentMutation];
|
|
11
|
+
exports.subscribers = [event_subscriber_1.DepartmentHistoryEntitySubscriber];
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/department/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,6DAAwD;AACxD,yDAAoD;AACpD,+DAA0D;AAC1D,yDAAsE;AAEzD,QAAA,QAAQ,GAAG,CAAC,uBAAU,EAAE,sCAAiB,CAAC,CAAA;AAC1C,QAAA,SAAS,GAAG,CAAC,kCAAe,EAAE,wCAAkB,CAAC,CAAA;AACjD,QAAA,WAAW,GAAG,CAAC,oDAAiC,CAAC,CAAA","sourcesContent":["import { Department } from './department'\nimport { DepartmentHistory } from './department-history'\nimport { DepartmentQuery } from './department-query'\nimport { DepartmentMutation } from './department-mutation'\nimport { DepartmentHistoryEntitySubscriber } from './event-subscriber'\n\nexport const entities = [Department, DepartmentHistory]\nexport const resolvers = [DepartmentQuery, DepartmentMutation]\nexport const subscribers = [DepartmentHistoryEntitySubscriber]\n"]}
|