@things-factory/print-base 9.0.0-beta.76 → 9.0.0
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.
|
@@ -8,7 +8,12 @@ const printer_device_type_1 = require("./printer-device-type");
|
|
|
8
8
|
let PrinterDeviceMutation = class PrinterDeviceMutation {
|
|
9
9
|
async createPrinterDevice(printerDevice, context) {
|
|
10
10
|
const { domain, user, tx } = context.state;
|
|
11
|
-
return await tx.getRepository(printer_device_1.PrinterDevice).save(
|
|
11
|
+
return await tx.getRepository(printer_device_1.PrinterDevice).save({
|
|
12
|
+
...printerDevice,
|
|
13
|
+
domain,
|
|
14
|
+
creator: user,
|
|
15
|
+
updater: user
|
|
16
|
+
});
|
|
12
17
|
}
|
|
13
18
|
async updatePrinterDevice(id, patch, context) {
|
|
14
19
|
const { domain, user, tx } = context.state;
|
|
@@ -17,7 +22,11 @@ let PrinterDeviceMutation = class PrinterDeviceMutation {
|
|
|
17
22
|
where: { domain: { id: domain.id }, id },
|
|
18
23
|
relations: ['domain', 'updater', 'creator']
|
|
19
24
|
});
|
|
20
|
-
return await repository.save(
|
|
25
|
+
return await repository.save({
|
|
26
|
+
...printerDevice,
|
|
27
|
+
...patch,
|
|
28
|
+
updater: user
|
|
29
|
+
});
|
|
21
30
|
}
|
|
22
31
|
async updateMultiplePrinterDevice(patches, context) {
|
|
23
32
|
const { domain, user, tx } = context.state;
|
|
@@ -28,8 +37,13 @@ let PrinterDeviceMutation = class PrinterDeviceMutation {
|
|
|
28
37
|
if (_createRecords.length > 0) {
|
|
29
38
|
for (let i = 0; i < _createRecords.length; i++) {
|
|
30
39
|
const newRecord = _createRecords[i];
|
|
31
|
-
const result = await printerDeviceRepo.save(
|
|
32
|
-
|
|
40
|
+
const result = await printerDeviceRepo.save({
|
|
41
|
+
...newRecord,
|
|
42
|
+
domain,
|
|
43
|
+
creator: user,
|
|
44
|
+
updater: user
|
|
45
|
+
});
|
|
46
|
+
results.push({ ...result, cuFlag: '+' });
|
|
33
47
|
}
|
|
34
48
|
}
|
|
35
49
|
if (_updateRecords.length > 0) {
|
|
@@ -39,8 +53,12 @@ let PrinterDeviceMutation = class PrinterDeviceMutation {
|
|
|
39
53
|
where: { domain: { id: domain.id }, id: updRecord.id },
|
|
40
54
|
relations: ['domain', 'updater', 'creator']
|
|
41
55
|
});
|
|
42
|
-
const result = await printerDeviceRepo.save(
|
|
43
|
-
|
|
56
|
+
const result = await printerDeviceRepo.save({
|
|
57
|
+
...printerDevice,
|
|
58
|
+
...updRecord,
|
|
59
|
+
updater: user
|
|
60
|
+
});
|
|
61
|
+
results.push({ ...result, cuFlag: 'M' });
|
|
44
62
|
}
|
|
45
63
|
}
|
|
46
64
|
return results;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printer-device-mutation.js","sourceRoot":"","sources":["../../../server/service/printer-device/printer-device-mutation.ts"],"names":[],"mappings":";;;;AACA,+CAAsE;AAEtE,qDAAgD;AAChD,+DAA4E;AAKrE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAG1B,AAAN,KAAK,CAAC,mBAAmB,CAAuB,aAA+B,EAAS,OAAY;QAClG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,8BAAa,CAAC,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"printer-device-mutation.js","sourceRoot":"","sources":["../../../server/service/printer-device/printer-device-mutation.ts"],"names":[],"mappings":";;;;AACA,+CAAsE;AAEtE,qDAAgD;AAChD,+DAA4E;AAKrE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAG1B,AAAN,KAAK,CAAC,mBAAmB,CAAuB,aAA+B,EAAS,OAAY;QAClG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,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C;IAExF,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;qDADe,wCAAkB;;gEAkBxC;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,8BAAa,CAAC,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;IAErG,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,wCAAkB,CAAC,CAAC,CAAA;IAC5C,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wEA2CP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAItD;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,mCAAmC,EAAE,CAAC;IAEhF,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iEAWP;gCA9GU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,qBAAqB,CA+GjC","sourcesContent":["\nimport { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { PrinterDevice } from './printer-device'\nimport { NewPrinterDevice, PrinterDevicePatch } from './printer-device-type'\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\n@Resolver(PrinterDevice)\nexport class PrinterDeviceMutation {\n @Directive('@transaction')\n @Mutation(returns => PrinterDevice, { description: 'To create new PrinterDevice' })\n async createPrinterDevice(@Arg('printerDevice') printerDevice: NewPrinterDevice, @Ctx() context: any): Promise<PrinterDevice> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(PrinterDevice).save({\n ...printerDevice,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => PrinterDevice, { description: 'To modify PrinterDevice information' })\n async updatePrinterDevice(\n @Arg('id') id: string,\n @Arg('patch') patch: PrinterDevicePatch,\n @Ctx() context: any\n ): Promise<PrinterDevice> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(PrinterDevice)\n const printerDevice = await repository.findOne(\n {\n where: { domain: { id: domain.id }, id },\n relations: ['domain','updater','creator']\n }\n )\n\n return await repository.save({\n ...printerDevice,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [PrinterDevice], { description: \"To modify multiple PrinterDevices' information\" })\n async updateMultiplePrinterDevice(\n @Arg('patches', type => [PrinterDevicePatch]) patches: PrinterDevicePatch[],\n @Ctx() context: any\n ): Promise<PrinterDevice[]> {\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 printerDeviceRepo = tx.getRepository(PrinterDevice)\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 printerDeviceRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\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 updRecord = _updateRecords[i]\n const printerDevice = await printerDeviceRepo.findOne({\n where: { domain: { id: domain.id }, id:updRecord.id },\n relations: ['domain','updater','creator']\n })\n \n const result = await printerDeviceRepo.save({\n ...printerDevice,\n ...updRecord,\n updater: user\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 PrinterDevice' })\n async deletePrinterDevice(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {\n const { domain, tx, user } = context.state\n await tx.getRepository(PrinterDevice).remove({ domain, id, updater:user })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple printerDevices' })\n async deletePrinterDevices(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: any\n ): Promise<boolean> {\n const { domain, tx, user } = context.state\n\n let delEntitis = ids.map(id=>{\n return {domain,id,updater:user}\n })\n\n await tx.getRepository(PrinterDevice).remove(delEntitis)\n\n return true\n }\n}\n"]}
|