@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,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmployeeHistory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const typeorm_history_1 = require("@anchan828/typeorm-history");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
const env_1 = require("@things-factory/env");
|
|
10
|
+
const shell_1 = require("@things-factory/shell");
|
|
11
|
+
const employee_1 = require("./employee");
|
|
12
|
+
const department_1 = require("../department/department");
|
|
13
|
+
const ORMCONFIG = env_1.config.get('ormconfig', {});
|
|
14
|
+
const DATABASE_TYPE = ORMCONFIG.type;
|
|
15
|
+
let EmployeeHistory = class EmployeeHistory {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.version = 1;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
tslib_1.__decorate([
|
|
21
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
22
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
23
|
+
tslib_1.__metadata("design:type", String)
|
|
24
|
+
], EmployeeHistory.prototype, "id", void 0);
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
(0, typeorm_1.Column)({ nullable: true, default: 1 }),
|
|
27
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
28
|
+
tslib_1.__metadata("design:type", Number)
|
|
29
|
+
], EmployeeHistory.prototype, "version", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
32
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
33
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
34
|
+
], EmployeeHistory.prototype, "domain", void 0);
|
|
35
|
+
tslib_1.__decorate([
|
|
36
|
+
(0, typeorm_1.RelationId)((employee) => employee.domain),
|
|
37
|
+
tslib_1.__metadata("design:type", String)
|
|
38
|
+
], EmployeeHistory.prototype, "domainId", void 0);
|
|
39
|
+
tslib_1.__decorate([
|
|
40
|
+
(0, typeorm_1.Column)(),
|
|
41
|
+
(0, type_graphql_1.Field)(),
|
|
42
|
+
tslib_1.__metadata("design:type", String)
|
|
43
|
+
], EmployeeHistory.prototype, "controlNo", 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
|
+
], EmployeeHistory.prototype, "name", void 0);
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
51
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
52
|
+
tslib_1.__metadata("design:type", String)
|
|
53
|
+
], EmployeeHistory.prototype, "description", void 0);
|
|
54
|
+
tslib_1.__decorate([
|
|
55
|
+
(0, typeorm_1.ManyToOne)(type => employee_1.Employee, supervisor => supervisor.supervises, { nullable: true }),
|
|
56
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
57
|
+
tslib_1.__metadata("design:type", employee_1.Employee)
|
|
58
|
+
], EmployeeHistory.prototype, "supervisor", void 0);
|
|
59
|
+
tslib_1.__decorate([
|
|
60
|
+
(0, typeorm_1.RelationId)((employee) => employee.supervisor),
|
|
61
|
+
tslib_1.__metadata("design:type", String)
|
|
62
|
+
], EmployeeHistory.prototype, "supervisorId", void 0);
|
|
63
|
+
tslib_1.__decorate([
|
|
64
|
+
(0, typeorm_1.OneToMany)(type => employee_1.Employee, employee => employee.supervisor),
|
|
65
|
+
(0, type_graphql_1.Field)(type => [employee_1.Employee]),
|
|
66
|
+
tslib_1.__metadata("design:type", Array)
|
|
67
|
+
], EmployeeHistory.prototype, "supervises", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, typeorm_1.OneToMany)(type => department_1.Department, department => department.manager),
|
|
70
|
+
(0, type_graphql_1.Field)(type => [department_1.Department]),
|
|
71
|
+
tslib_1.__metadata("design:type", Array)
|
|
72
|
+
], EmployeeHistory.prototype, "manages", void 0);
|
|
73
|
+
tslib_1.__decorate([
|
|
74
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
75
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
76
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
77
|
+
], EmployeeHistory.prototype, "active", void 0);
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
80
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
81
|
+
tslib_1.__metadata("design:type", String)
|
|
82
|
+
], EmployeeHistory.prototype, "state", void 0);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
85
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
86
|
+
tslib_1.__metadata("design:type", String)
|
|
87
|
+
], EmployeeHistory.prototype, "extension", void 0);
|
|
88
|
+
tslib_1.__decorate([
|
|
89
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
90
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
91
|
+
tslib_1.__metadata("design:type", Date)
|
|
92
|
+
], EmployeeHistory.prototype, "createdAt", void 0);
|
|
93
|
+
tslib_1.__decorate([
|
|
94
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
95
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
96
|
+
tslib_1.__metadata("design:type", Date)
|
|
97
|
+
], EmployeeHistory.prototype, "updatedAt", void 0);
|
|
98
|
+
tslib_1.__decorate([
|
|
99
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
100
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
101
|
+
tslib_1.__metadata("design:type", Date)
|
|
102
|
+
], EmployeeHistory.prototype, "deletedAt", void 0);
|
|
103
|
+
tslib_1.__decorate([
|
|
104
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
105
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
106
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
107
|
+
], EmployeeHistory.prototype, "creator", void 0);
|
|
108
|
+
tslib_1.__decorate([
|
|
109
|
+
(0, typeorm_1.RelationId)((employee) => employee.creator),
|
|
110
|
+
tslib_1.__metadata("design:type", String)
|
|
111
|
+
], EmployeeHistory.prototype, "creatorId", void 0);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
114
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
115
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
116
|
+
], EmployeeHistory.prototype, "updater", void 0);
|
|
117
|
+
tslib_1.__decorate([
|
|
118
|
+
(0, typeorm_1.RelationId)((employee) => employee.updater),
|
|
119
|
+
tslib_1.__metadata("design:type", String)
|
|
120
|
+
], EmployeeHistory.prototype, "updaterId", void 0);
|
|
121
|
+
tslib_1.__decorate([
|
|
122
|
+
(0, type_graphql_1.Field)(type => String, { nullable: true }),
|
|
123
|
+
tslib_1.__metadata("design:type", String)
|
|
124
|
+
], EmployeeHistory.prototype, "photo", 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
|
+
], EmployeeHistory.prototype, "user", void 0);
|
|
130
|
+
tslib_1.__decorate([
|
|
131
|
+
(0, typeorm_1.RelationId)((employee) => employee.user),
|
|
132
|
+
tslib_1.__metadata("design:type", String)
|
|
133
|
+
], EmployeeHistory.prototype, "userId", void 0);
|
|
134
|
+
tslib_1.__decorate([
|
|
135
|
+
(0, typeorm_history_1.HistoryOriginalIdColumn)(),
|
|
136
|
+
tslib_1.__metadata("design:type", String)
|
|
137
|
+
], EmployeeHistory.prototype, "originalId", void 0);
|
|
138
|
+
tslib_1.__decorate([
|
|
139
|
+
(0, typeorm_history_1.HistoryActionColumn)({
|
|
140
|
+
nullable: false,
|
|
141
|
+
type: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
142
|
+
? 'enum'
|
|
143
|
+
: DATABASE_TYPE == 'oracle'
|
|
144
|
+
? 'varchar2'
|
|
145
|
+
: 'smallint',
|
|
146
|
+
enum: typeorm_history_1.HistoryActionType
|
|
147
|
+
}),
|
|
148
|
+
tslib_1.__metadata("design:type", String)
|
|
149
|
+
], EmployeeHistory.prototype, "action", void 0);
|
|
150
|
+
EmployeeHistory = tslib_1.__decorate([
|
|
151
|
+
(0, typeorm_1.Entity)(),
|
|
152
|
+
(0, typeorm_1.Index)('ix_employee_history_0', (employeeHistory) => [employeeHistory.originalId, employeeHistory.version], { unique: true }),
|
|
153
|
+
(0, typeorm_1.Index)('ix_employee_history_1', (employeeHistory) => [employeeHistory.domain, employeeHistory.originalId, employeeHistory.version], { unique: true }),
|
|
154
|
+
(0, type_graphql_1.ObjectType)({ description: 'History Entity of Employee' })
|
|
155
|
+
], EmployeeHistory);
|
|
156
|
+
exports.EmployeeHistory = EmployeeHistory;
|
|
157
|
+
//# sourceMappingURL=employee-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"employee-history.js","sourceRoot":"","sources":["../../../server/service/employee/employee-history.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAAyG;AAEzG,gEAKmC;AACnC,yDAAsD;AACtD,6CAA4C;AAC5C,iDAA8C;AAE9C,yCAAqD;AACrD,yDAAqD;AAErD,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAc7B,IAAM,eAAe,GAArB,MAAM,eAAe;IAArB;QAOL,YAAO,GAAY,CAAC,CAAA;IAkGtB,CAAC;CAAA,CAAA;AAxGC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;2CACC;AAEnB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACtC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAEpB;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,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AC,EACnH,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;GAC7C,eAAe,CAyG3B;AAzGY,0CAAe","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@anchan828/typeorm-history'\nimport { Role, User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { Employee, EmployeeStatus } from './employee'\nimport { Department } from '../department/department'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index(\n 'ix_employee_history_0',\n (employeeHistory: EmployeeHistory) => [employeeHistory.originalId, employeeHistory.version],\n { unique: true }\n)\n@Index(\n 'ix_employee_history_1',\n (employeeHistory: EmployeeHistory) => [employeeHistory.domain, employeeHistory.originalId, employeeHistory.version],\n { unique: true }\n)\n@ObjectType({ description: 'History Entity of Employee' })\nexport class EmployeeHistory implements HistoryEntityInterface<Employee> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((employee: Employee) => employee.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 => Employee, supervisor => supervisor.supervises, { nullable: true })\n @Field({ nullable: true })\n supervisor?: Employee\n\n @RelationId((employee: Employee) => employee.supervisor)\n supervisorId?: string\n\n @OneToMany(type => Employee, employee => employee.supervisor)\n @Field(type => [Employee])\n supervises?: Employee[]\n\n @OneToMany(type => Department, department => department.manager)\n @Field(type => [Department])\n manages?: Department[]\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n state?: EmployeeStatus\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n extension?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n updatedAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator?: User\n\n @RelationId((employee: Employee) => employee.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater?: User\n\n @RelationId((employee: Employee) => employee.updater)\n updaterId?: string\n\n @Field(type => String, { nullable: true })\n photo?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n user?: User\n\n @RelationId((employee: Employee) => employee.user)\n userId?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : 'smallint',\n enum: HistoryActionType\n })\n public action!: HistoryActionType\n}\n"]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmployeeMutation = 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 employee_1 = require("./employee");
|
|
9
|
+
const employee_type_1 = require("./employee-type");
|
|
10
|
+
let EmployeeMutation = class EmployeeMutation {
|
|
11
|
+
async createEmployee(employee, context) {
|
|
12
|
+
const { domain, user, tx } = context.state;
|
|
13
|
+
const result = await tx.getRepository(employee_1.Employee).save(Object.assign(Object.assign({}, employee), { domain, creator: user, updater: user }));
|
|
14
|
+
if (employee.photo) {
|
|
15
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
16
|
+
attachment: {
|
|
17
|
+
file: employee.photo,
|
|
18
|
+
refType: employee_1.Employee.name,
|
|
19
|
+
refBy: result.id
|
|
20
|
+
}
|
|
21
|
+
}, context);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
async updateEmployee(id, patch, context) {
|
|
26
|
+
const { domain, user, tx } = context.state;
|
|
27
|
+
const repository = tx.getRepository(employee_1.Employee);
|
|
28
|
+
const employee = await repository.findOne({
|
|
29
|
+
where: { domain: { id: domain.id }, id }
|
|
30
|
+
});
|
|
31
|
+
const result = await repository.save(Object.assign(Object.assign(Object.assign({}, employee), patch), { updater: user }));
|
|
32
|
+
if (patch.photo) {
|
|
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.photo,
|
|
37
|
+
refType: employee_1.Employee.name,
|
|
38
|
+
refBy: result.id
|
|
39
|
+
}
|
|
40
|
+
}, context);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
async updateMultipleEmployee(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 employeeRepo = tx.getRepository(employee_1.Employee);
|
|
50
|
+
if (_createRecords.length > 0) {
|
|
51
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
52
|
+
const newRecord = _createRecords[i];
|
|
53
|
+
const result = await employeeRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
|
|
54
|
+
if (newRecord.photo) {
|
|
55
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
56
|
+
attachment: {
|
|
57
|
+
file: newRecord.photo,
|
|
58
|
+
refType: employee_1.Employee.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 employee = await employeeRepo.findOneBy({ id: updateRecord.id });
|
|
70
|
+
const result = await employeeRepo.save(Object.assign(Object.assign(Object.assign({}, employee), updateRecord), { updater: user }));
|
|
71
|
+
if (updateRecord.photo) {
|
|
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.photo,
|
|
76
|
+
refType: employee_1.Employee.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 deleteEmployee(id, context) {
|
|
87
|
+
const { domain, tx } = context.state;
|
|
88
|
+
await tx.getRepository(employee_1.Employee).delete({ domain: { id: domain.id }, id });
|
|
89
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
async deleteEmployees(ids, context) {
|
|
93
|
+
const { domain, tx } = context.state;
|
|
94
|
+
await tx.getRepository(employee_1.Employee).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 importEmployees(employees, context) {
|
|
102
|
+
const { domain, tx } = context.state;
|
|
103
|
+
await Promise.all(employees.map(async (employee) => {
|
|
104
|
+
const createdEmployee = await tx.getRepository(employee_1.Employee).save(Object.assign({ domain }, employee));
|
|
105
|
+
}));
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
tslib_1.__decorate([
|
|
110
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
111
|
+
(0, type_graphql_1.Mutation)(returns => employee_1.Employee, { description: 'To create new Employee' }),
|
|
112
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('employee')),
|
|
113
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
114
|
+
tslib_1.__metadata("design:type", Function),
|
|
115
|
+
tslib_1.__metadata("design:paramtypes", [employee_type_1.NewEmployee, Object]),
|
|
116
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
117
|
+
], EmployeeMutation.prototype, "createEmployee", null);
|
|
118
|
+
tslib_1.__decorate([
|
|
119
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
120
|
+
(0, type_graphql_1.Mutation)(returns => employee_1.Employee, { description: 'To modify Employee 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, employee_type_1.EmployeePatch, Object]),
|
|
126
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
127
|
+
], EmployeeMutation.prototype, "updateEmployee", null);
|
|
128
|
+
tslib_1.__decorate([
|
|
129
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
130
|
+
(0, type_graphql_1.Mutation)(returns => [employee_1.Employee], { description: "To modify multiple Employees' information" }),
|
|
131
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [employee_type_1.EmployeePatch])),
|
|
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
|
+
], EmployeeMutation.prototype, "updateMultipleEmployee", null);
|
|
137
|
+
tslib_1.__decorate([
|
|
138
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
139
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Employee' }),
|
|
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
|
+
], EmployeeMutation.prototype, "deleteEmployee", null);
|
|
146
|
+
tslib_1.__decorate([
|
|
147
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
148
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple Employees' }),
|
|
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
|
+
], EmployeeMutation.prototype, "deleteEmployees", null);
|
|
155
|
+
tslib_1.__decorate([
|
|
156
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
157
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple Employees' }),
|
|
158
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('employees', type => [employee_type_1.EmployeePatch])),
|
|
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
|
+
], EmployeeMutation.prototype, "importEmployees", null);
|
|
164
|
+
EmployeeMutation = tslib_1.__decorate([
|
|
165
|
+
(0, type_graphql_1.Resolver)(employee_1.Employee)
|
|
166
|
+
], EmployeeMutation);
|
|
167
|
+
exports.EmployeeMutation = EmployeeMutation;
|
|
168
|
+
//# sourceMappingURL=employee-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"employee-mutation.js","sourceRoot":"","sources":["../../../server/service/employee/employee-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,yCAAqC;AACrC,mDAA4D;AAGrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGrB,AAAN,KAAK,CAAC,cAAc,CAAkB,QAAqB,EAAS,OAAwB;QAC1F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,IAAI,iCAC/C,QAAQ,KACX,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,IAAI,QAAQ,CAA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8B,EAAE,CAAC;IAE3E,mBAAA,IAAA,kBAAG,EAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,6BAAa,CAAC,CAAC,CAAA;IACzC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;uDAWP;AA3LU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CA4L5B;AA5LY,4CAAgB","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { Employee } from './employee'\nimport { NewEmployee, EmployeePatch } from './employee-type'\n\n@Resolver(Employee)\nexport class EmployeeMutation {\n @Directive('@transaction')\n @Mutation(returns => Employee, { description: 'To create new Employee' })\n async createEmployee(@Arg('employee') employee: NewEmployee, @Ctx() context: ResolverContext): Promise<Employee> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(Employee).save({\n ...employee,\n domain,\n creator: user,\n updater: user\n })\n\n if (employee.photo) {\n await createAttachment(\n null,\n {\n attachment: {\n file: employee.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Employee, { description: 'To modify Employee information' })\n async updateEmployee(\n @Arg('id') id: string,\n @Arg('patch') patch: EmployeePatch,\n @Ctx() context: ResolverContext\n ): Promise<Employee> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Employee)\n const employee = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...employee,\n ...patch,\n updater: user\n })\n\n if (patch.photo) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Employee], { description: \"To modify multiple Employees' information\" })\n async updateMultipleEmployee(\n @Arg('patches', type => [EmployeePatch]) patches: EmployeePatch[],\n @Ctx() context: ResolverContext\n ): Promise<Employee[]> {\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 employeeRepo = tx.getRepository(Employee)\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 employeeRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.photo) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.photo,\n refType: Employee.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 employee = await employeeRepo.findOneBy({ id: updateRecord.id })\n\n const result = await employeeRepo.save({\n ...employee,\n ...updateRecord,\n updater: user\n })\n\n if (updateRecord.photo) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.photo,\n refType: Employee.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 Employee' })\n async deleteEmployee(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Employee).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 Employees' })\n async deleteEmployees(\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(Employee).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 Employees' })\n async importEmployees(\n @Arg('employees', type => [EmployeePatch]) employees: EmployeePatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n employees.map(async (employee: EmployeePatch) => {\n const createdEmployee: Employee = await tx.getRepository(Employee).save({ domain, ...employee })\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.EmployeeQuery = 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 employee_1 = require("./employee");
|
|
10
|
+
const employee_type_1 = require("./employee-type");
|
|
11
|
+
let EmployeeQuery = class EmployeeQuery {
|
|
12
|
+
async employee(id, context) {
|
|
13
|
+
const { domain } = context.state;
|
|
14
|
+
return await (0, shell_1.getRepository)(employee_1.Employee).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async employees(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)(employee_1.Employee),
|
|
24
|
+
searchables: ['name', 'description']
|
|
25
|
+
});
|
|
26
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
27
|
+
return { items, total };
|
|
28
|
+
}
|
|
29
|
+
async photo(employee) {
|
|
30
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
31
|
+
where: {
|
|
32
|
+
domain: { id: employee.domainId },
|
|
33
|
+
refType: employee_1.Employee.name,
|
|
34
|
+
refBy: employee.id
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return attachment === null || attachment === void 0 ? void 0 : attachment.fullpath;
|
|
38
|
+
}
|
|
39
|
+
async domain(employee) {
|
|
40
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: employee.domainId });
|
|
41
|
+
}
|
|
42
|
+
async updater(employee) {
|
|
43
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: employee.updaterId });
|
|
44
|
+
}
|
|
45
|
+
async creator(employee) {
|
|
46
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: employee.creatorId });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, type_graphql_1.Query)(returns => employee_1.Employee, { nullable: true, description: 'To fetch a Employee' }),
|
|
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
|
+
], EmployeeQuery.prototype, "employee", null);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, type_graphql_1.Query)(returns => employee_type_1.EmployeeList, { description: 'To fetch multiple Employees' }),
|
|
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
|
+
], EmployeeQuery.prototype, "employees", 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", [employee_1.Employee]),
|
|
70
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
71
|
+
], EmployeeQuery.prototype, "photo", 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", [employee_1.Employee]),
|
|
77
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
78
|
+
], EmployeeQuery.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", [employee_1.Employee]),
|
|
84
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
85
|
+
], EmployeeQuery.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", [employee_1.Employee]),
|
|
91
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
92
|
+
], EmployeeQuery.prototype, "creator", null);
|
|
93
|
+
EmployeeQuery = tslib_1.__decorate([
|
|
94
|
+
(0, type_graphql_1.Resolver)(employee_1.Employee)
|
|
95
|
+
], EmployeeQuery);
|
|
96
|
+
exports.EmployeeQuery = EmployeeQuery;
|
|
97
|
+
//# sourceMappingURL=employee-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"employee-query.js","sourceRoot":"","sources":["../../../server/service/employee/employee-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qEAA4D;AAC5D,iDAAuG;AACvG,yDAAgD;AAChD,yCAAqC;AACrC,mDAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAa;IAElB,AAAN,KAAK,CAAC,QAAQ,CAAY,EAAU,EAAS,OAAwB;QACnE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;YAC3C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,SAAS,CAAS,MAAiB,EAAS,OAAwB;QACxE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC;YACzC,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;SACrC,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAE3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGK,AAAN,KAAK,CAAC,KAAK,CAAS,QAAkB;QACpC,MAAM,UAAU,GAAe,MAAM,IAAA,qBAAa,EAA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,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;8CAaxC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACjB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;0CAUrC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;2CAEtC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;AApDU,aAAa;IADzB,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,aAAa,CAqDzB;AArDY,sCAAa","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 { Employee } from './employee'\nimport { EmployeeList } from './employee-type'\n\n@Resolver(Employee)\nexport class EmployeeQuery {\n @Query(returns => Employee!, { nullable: true, description: 'To fetch a Employee' })\n async employee(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Employee> {\n const { domain } = context.state\n\n return await getRepository(Employee).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => EmployeeList, { description: 'To fetch multiple Employees' })\n async employees(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<EmployeeList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(Employee),\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 photo(@Root() employee: Employee): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: employee.domainId },\n refType: Employee.name,\n refBy: employee.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() employee: Employee): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: employee.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() employee: Employee): Promise<User> {\n return await getRepository(User).findOneBy({ id: employee.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() employee: Employee): Promise<User> {\n return await getRepository(User).findOneBy({ id: employee.creatorId })\n }\n}\n"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmployeeList = exports.EmployeePatch = exports.NewEmployee = 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 employee_1 = require("./employee");
|
|
8
|
+
let NewEmployee = class NewEmployee {
|
|
9
|
+
};
|
|
10
|
+
tslib_1.__decorate([
|
|
11
|
+
(0, type_graphql_1.Field)(),
|
|
12
|
+
tslib_1.__metadata("design:type", String)
|
|
13
|
+
], NewEmployee.prototype, "controlNo", void 0);
|
|
14
|
+
tslib_1.__decorate([
|
|
15
|
+
(0, type_graphql_1.Field)(),
|
|
16
|
+
tslib_1.__metadata("design:type", String)
|
|
17
|
+
], NewEmployee.prototype, "name", void 0);
|
|
18
|
+
tslib_1.__decorate([
|
|
19
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
20
|
+
tslib_1.__metadata("design:type", String)
|
|
21
|
+
], NewEmployee.prototype, "description", void 0);
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, type_graphql_1.Field)(type => employee_1.EmployeeStatus, { nullable: true }),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
25
|
+
], NewEmployee.prototype, "state", void 0);
|
|
26
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
28
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
29
|
+
], NewEmployee.prototype, "active", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
33
|
+
], NewEmployee.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
|
+
], NewEmployee.prototype, "photo", void 0);
|
|
38
|
+
NewEmployee = tslib_1.__decorate([
|
|
39
|
+
(0, type_graphql_1.InputType)()
|
|
40
|
+
], NewEmployee);
|
|
41
|
+
exports.NewEmployee = NewEmployee;
|
|
42
|
+
let EmployeePatch = class EmployeePatch {
|
|
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
|
+
], EmployeePatch.prototype, "id", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
51
|
+
], EmployeePatch.prototype, "name", void 0);
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
54
|
+
tslib_1.__metadata("design:type", String)
|
|
55
|
+
], EmployeePatch.prototype, "description", void 0);
|
|
56
|
+
tslib_1.__decorate([
|
|
57
|
+
(0, type_graphql_1.Field)(type => employee_1.EmployeeStatus, { nullable: true }),
|
|
58
|
+
tslib_1.__metadata("design:type", String)
|
|
59
|
+
], EmployeePatch.prototype, "state", void 0);
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
62
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
63
|
+
], EmployeePatch.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
|
+
], EmployeePatch.prototype, "photo", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
70
|
+
tslib_1.__metadata("design:type", String)
|
|
71
|
+
], EmployeePatch.prototype, "cuFlag", void 0);
|
|
72
|
+
EmployeePatch = tslib_1.__decorate([
|
|
73
|
+
(0, type_graphql_1.InputType)()
|
|
74
|
+
], EmployeePatch);
|
|
75
|
+
exports.EmployeePatch = EmployeePatch;
|
|
76
|
+
let EmployeeList = class EmployeeList {
|
|
77
|
+
};
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, type_graphql_1.Field)(type => [employee_1.Employee]),
|
|
80
|
+
tslib_1.__metadata("design:type", Array)
|
|
81
|
+
], EmployeeList.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
|
+
], EmployeeList.prototype, "total", void 0);
|
|
86
|
+
EmployeeList = tslib_1.__decorate([
|
|
87
|
+
(0, type_graphql_1.ObjectType)()
|
|
88
|
+
], EmployeeList);
|
|
89
|
+
exports.EmployeeList = EmployeeList;
|
|
90
|
+
//# sourceMappingURL=employee-type.js.map
|
|
@@ -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CAAC;;4CAC5B;AAEtB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,0BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CAC/B;AAElB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACX;AApBJ,aAAa;IADzB,IAAA,wBAAS,GAAE;GACC,aAAa,CAqBzB;AArBY,sCAAa;AAwBnB,IAAM,YAAY,GAAlB,MAAM,YAAY;CAMxB,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,mBAAQ,CAAC,CAAC;;2CACT;AAEjB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;2CACN;AALF,YAAY;IADxB,IAAA,yBAAU,GAAE;GACA,YAAY,CAMxB;AANY,oCAAY","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 { Employee, EmployeeStatus } from './employee'\n\n@InputType()\nexport class NewEmployee {\n @Field()\n controlNo: string\n\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => EmployeeStatus, { nullable: true })\n state?: EmployeeStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n extension?: string\n\n @Field(type => GraphQLUpload, { nullable: true })\n photo?: FileUpload\n}\n\n@InputType()\nexport class EmployeePatch {\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 => EmployeeStatus, { nullable: true })\n state?: EmployeeStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field(type => GraphQLUpload, { nullable: true })\n photo?: FileUpload\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class EmployeeList {\n @Field(type => [Employee])\n items: Employee[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|