diff --git a/package-lock.json b/package-lock.json index 7b5c8d4..33ef688 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,38 +9,38 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@elastic/elasticsearch": "~8.14.0", - "@nestjs/platform-express": "~10.3.9", - "@tsoa/runtime": "~6.0.0", - "amqplib": "~0.10.4", - "axios": "~1.7.2", - "cors": "~2.8.5", - "csv-parser": "~3.0.0", - "dotenv": "~16.3.1", - "express": "~4.18.2", - "fast-jwt": "~3.3.2", - "moment": "~2.30.1", - "mysql2": "~3.9.1", - "node-cron": "~3.0.3", - "promise.any": "~2.0.6", - "redis": "~3.1.2", - "reflect-metadata": "~0.2.1", - "swagger-ui-express": "~5.0.0", - "tsoa": "~6.0.1", - "typeorm": "~0.3.19", - "typeorm-cli": "~1.0.7" + "@elastic/elasticsearch": "^8.14.0", + "@nestjs/platform-express": "^10.3.9", + "@tsoa/runtime": "^6.0.0", + "amqplib": "^0.10.4", + "axios": "^1.7.2", + "cors": "^2.8.5", + "csv-parser": "^3.0.0", + "dotenv": "^16.3.1", + "express": "^4.18.2", + "fast-jwt": "^3.3.2", + "moment": "^2.30.1", + "mysql2": "^3.9.1", + "node-cron": "^3.0.3", + "promise.any": "^2.0.6", + "redis": "^3.1.2", + "reflect-metadata": "^0.2.1", + "swagger-ui-express": "^5.0.0", + "tsoa": "^6.0.1", + "typeorm": "^0.3.19", + "typeorm-cli": "^1.0.7" }, "devDependencies": { - "@types/amqplib": "~0.10.5", - "@types/cors": "~2.8.17", - "@types/express": "~4.17.21", - "@types/node": "~20.11.5", - "@types/node-cron": "~3.0.11", - "@types/swagger-ui-express": "~4.1.6", - "nodemon": "~3.0.3", - "prettier": "~3.2.2", - "ts-node": "~10.9.2", - "typescript": "~5.3.3" + "@types/amqplib": "^0.10.5", + "@types/cors": "^2.8.17", + "@types/express": "^4.17.21", + "@types/node": "^20.11.5", + "@types/node-cron": "^3.0.11", + "@types/swagger-ui-express": "^4.1.6", + "nodemon": "^3.0.3", + "prettier": "^3.2.2", + "ts-node": "^10.9.2", + "typescript": "^5.3.3" } }, "node_modules/@acuminous/bitsyntax": { @@ -56,11 +56,6 @@ "node": ">=0.8" } }, - "node_modules/@acuminous/bitsyntax/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -74,11 +69,11 @@ } }, "node_modules/@elastic/elasticsearch": { - "version": "8.14.1", - "resolved": "https://registry.npmjs.org/@elastic/elasticsearch/-/elasticsearch-8.14.1.tgz", - "integrity": "sha512-gRFtAt9ALUVhR7ngAh7MROMejE16viNHy6hluZc/mMO6IRFRqeFqa/NOqmvP5wK+2z8N8a73ebpMDOCuNrYUCQ==", + "version": "8.15.1", + "resolved": "https://registry.npmjs.org/@elastic/elasticsearch/-/elasticsearch-8.15.1.tgz", + "integrity": "sha512-L3YzSaxrasMMGtcxnktiUDjS5f177L0zpHsBH+jL0LgPhdMk9xN/VKrAaYzvri86IlV5IbveA0ANV6o/BDUmhQ==", "dependencies": { - "@elastic/transport": "^8.6.0", + "@elastic/transport": "^8.8.1", "tslib": "^2.4.0" }, "engines": { @@ -86,9 +81,9 @@ } }, "node_modules/@elastic/transport": { - "version": "8.7.1", - "resolved": "https://registry.npmjs.org/@elastic/transport/-/transport-8.7.1.tgz", - "integrity": "sha512-2eeMVkz57Ayxv+UAZkIKzzrUu7nm96jr3+N3kLfbBqALYe2jwDpLr9pR0jc/x9HyJKAM909YGaNlHFDZeb0+Mw==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/@elastic/transport/-/transport-8.8.1.tgz", + "integrity": "sha512-4RQIiChwNIx3B0O+2JdmTq/Qobj6+1g2RQnSv1gt4V2SVfAYjGwOKu0ZMKEHQOXYNG6+j/Chero2G9k3/wXLEw==", "dependencies": { "@opentelemetry/api": "1.x", "debug": "^4.3.4", @@ -448,13 +443,13 @@ } }, "node_modules/@nestjs/common": { - "version": "10.4.1", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.4.1.tgz", - "integrity": "sha512-4CkrDx0s4XuWqFjX8WvOFV7Y6RGJd0P2OBblkhZS7nwoctoSuW5pyEa8SWak6YHNGrHRpFb6ymm5Ai4LncwRVA==", + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.4.5.tgz", + "integrity": "sha512-N/yUyuYCBMb0+H6jHhntR7PURzji0usID/DByhOfooyk/aPGscI0aQKwOA6edlJlT92hHUvXYLJ5p3npj7KcjQ==", "peer": true, "dependencies": { "iterare": "1.2.1", - "tslib": "2.6.3", + "tslib": "2.7.0", "uid": "2.0.2" }, "funding": { @@ -477,23 +472,23 @@ } }, "node_modules/@nestjs/common/node_modules/tslib": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", "peer": true }, "node_modules/@nestjs/core": { - "version": "10.4.1", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.4.1.tgz", - "integrity": "sha512-9I1WdfOBCCHdUm+ClBJupOuZQS6UxzIWHIq6Vp1brAA5ZKl/Wq6BVwSsbnUJGBy3J3PM2XHmR0EQ4fwX3nR7lA==", + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.4.5.tgz", + "integrity": "sha512-wk0KJ+6tuidqAdeemsQ40BCp1BgMsSuSLG577aqXLxXYoa8FQYPrdxoSzd05znYLwJYM55fisZWb3FLF9HT2qw==", "hasInstallScript": true, "peer": true, "dependencies": { "@nuxtjs/opencollective": "0.3.2", "fast-safe-stringify": "2.1.1", "iterare": "1.2.1", - "path-to-regexp": "3.2.0", - "tslib": "2.6.3", + "path-to-regexp": "3.3.0", + "tslib": "2.7.0", "uid": "2.0.2" }, "funding": { @@ -521,21 +516,21 @@ } }, "node_modules/@nestjs/core/node_modules/tslib": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", "peer": true }, "node_modules/@nestjs/platform-express": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.3.10.tgz", - "integrity": "sha512-wK2ow3CZI2KFqWeEpPmoR300OB6BcBLxARV1EiClJLCj4S1mZsoCmS0YWgpk3j1j6mo0SI8vNLi/cC2iZPEPQA==", + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.4.5.tgz", + "integrity": "sha512-a629r8R8KC4skhdieQ0aIWH5vDBUFntWnWKFyDXQrll6/CllSchfWm87mWF39seaW6bXYtQtAEZY66JrngdrGA==", "dependencies": { - "body-parser": "1.20.2", + "body-parser": "1.20.3", "cors": "2.8.5", - "express": "4.19.2", + "express": "4.21.1", "multer": "1.4.4-lts.1", - "tslib": "2.6.3" + "tslib": "2.7.0" }, "funding": { "type": "opencollective", @@ -546,94 +541,10 @@ "@nestjs/core": "^10.0.0" } }, - "node_modules/@nestjs/platform-express/node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@nestjs/platform-express/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/@nestjs/platform-express/node_modules/express": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", - "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", - "dependencies": { - "accepts": "~1.3.8", - "array-flatten": "1.1.1", - "body-parser": "1.20.2", - "content-disposition": "0.5.4", - "content-type": "~1.0.4", - "cookie": "0.6.0", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "2.0.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "1.2.0", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.7", - "qs": "6.11.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "engines": { - "node": ">= 0.10.0" - } - }, - "node_modules/@nestjs/platform-express/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/@nestjs/platform-express/node_modules/multer": { - "version": "1.4.4-lts.1", - "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.4-lts.1.tgz", - "integrity": "sha512-WeSGziVj6+Z2/MwQo3GvqzgR+9Uc+qt8SwHKh3gvNPiISKfsMfG4SvCOFYlxxgkXt7yIV2i1yczehm0EOKIxIg==", - "dependencies": { - "append-field": "^1.0.0", - "busboy": "^1.0.0", - "concat-stream": "^1.5.2", - "mkdirp": "^0.5.4", - "object-assign": "^4.1.1", - "type-is": "^1.6.4", - "xtend": "^4.0.0" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/@nestjs/platform-express/node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" - }, "node_modules/@nestjs/platform-express/node_modules/tslib": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" }, "node_modules/@nuxtjs/opencollective": { "version": "0.3.2", @@ -705,21 +616,21 @@ "devOptional": true }, "node_modules/@tsoa/cli": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/@tsoa/cli/-/cli-6.4.0.tgz", - "integrity": "sha512-cuKqIAJ33enhXejMb04P2JF/SZdM3WLFE9Qg8s2dOVOrLbbZGK3H85YSORif0unxbre02psXuUyl3FwWBt0/pQ==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/@tsoa/cli/-/cli-6.5.1.tgz", + "integrity": "sha512-nvYI/kU0kI+uxvCUIEAYHDUpiekvZIt5AUUyJGObHQXyh62c7nK4U20bbowsjOx7A5uQE8SgodU227lcyk76YQ==", "dependencies": { - "@tsoa/runtime": "^6.4.0", - "@types/multer": "^1.4.11", + "@tsoa/runtime": "^6.5.1", + "@types/multer": "^1.4.12", "fs-extra": "^11.2.0", "glob": "^10.3.10", "handlebars": "^4.7.8", "merge-anything": "^5.1.4", "minimatch": "^9.0.1", - "ts-deepmerge": "^7.0.0", - "typescript": "^5.3.3", - "validator": "^13.11.0", - "yaml": "^2.4.1", + "ts-deepmerge": "^7.0.1", + "typescript": "^5.6.2", + "validator": "^13.12.0", + "yaml": "^2.5.1", "yargs": "^17.7.1" }, "bin": { @@ -730,47 +641,6 @@ "yarn": ">=1.9.4" } }, - "node_modules/@tsoa/cli/node_modules/@tsoa/runtime": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/@tsoa/runtime/-/runtime-6.5.1.tgz", - "integrity": "sha512-fllTz/LrHw+BJvKTREGyrnnfkusHdPivsHNNfwy5v1ZaKfxTFjSSADwm8mu64zw/SFrNeyx8N7Mr9z1ujeV1Rw==", - "dependencies": { - "@hapi/boom": "^10.0.1", - "@hapi/hapi": "^21.3.10", - "@types/koa": "^2.15.0", - "@types/multer": "^1.4.12", - "express": "^4.21.0", - "reflect-metadata": "^0.2.2", - "validator": "^13.12.0" - }, - "engines": { - "node": ">=18.0.0", - "yarn": ">=1.9.4" - } - }, - "node_modules/@tsoa/cli/node_modules/body-parser": { - "version": "1.20.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", - "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.5", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.13.0", - "raw-body": "2.5.2", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, "node_modules/@tsoa/cli/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -779,101 +649,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/@tsoa/cli/node_modules/cookie": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", - "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@tsoa/cli/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/@tsoa/cli/node_modules/debug/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/@tsoa/cli/node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/@tsoa/cli/node_modules/express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", - "dependencies": { - "accepts": "~1.3.8", - "array-flatten": "1.1.1", - "body-parser": "1.20.3", - "content-disposition": "0.5.4", - "content-type": "~1.0.4", - "cookie": "0.7.1", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "2.0.0", - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "1.3.1", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "merge-descriptors": "1.0.3", - "methods": "~1.1.2", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", - "proxy-addr": "~2.0.7", - "qs": "6.13.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.2.1", - "send": "0.19.0", - "serve-static": "1.16.2", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "engines": { - "node": ">= 0.10.0" - } - }, - "node_modules/@tsoa/cli/node_modules/finalhandler": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", - "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", - "dependencies": { - "debug": "2.6.9", - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "statuses": "2.0.1", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/@tsoa/cli/node_modules/merge-descriptors": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", - "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@tsoa/cli/node_modules/minimatch": { "version": "9.0.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", @@ -888,78 +663,18 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@tsoa/cli/node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==" - }, - "node_modules/@tsoa/cli/node_modules/qs": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", - "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", - "dependencies": { - "side-channel": "^1.0.6" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/@tsoa/cli/node_modules/send": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", - "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", - "dependencies": { - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "mime": "1.6.0", - "ms": "2.1.3", - "on-finished": "2.4.1", - "range-parser": "~1.2.1", - "statuses": "2.0.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/@tsoa/cli/node_modules/send/node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/@tsoa/cli/node_modules/serve-static": { - "version": "1.16.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", - "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", - "dependencies": { - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.19.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/@tsoa/runtime": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@tsoa/runtime/-/runtime-6.0.0.tgz", - "integrity": "sha512-n0LYcjII313kDn3M4bZdAjU+sX7595sIEA3bw4pvxWRrkandyDdDFNrfQL8nZ3Pw6dkTmK7brZi0YBBDhe0Rzw==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/@tsoa/runtime/-/runtime-6.5.1.tgz", + "integrity": "sha512-fllTz/LrHw+BJvKTREGyrnnfkusHdPivsHNNfwy5v1ZaKfxTFjSSADwm8mu64zw/SFrNeyx8N7Mr9z1ujeV1Rw==", "dependencies": { - "@types/multer": "^1.4.11", - "reflect-metadata": "^0.2.1", - "validator": "^13.11.0" + "@hapi/boom": "^10.0.1", + "@hapi/hapi": "^21.3.10", + "@types/koa": "^2.15.0", + "@types/multer": "^1.4.12", + "express": "^4.21.0", + "reflect-metadata": "^0.2.2", + "validator": "^13.12.0" }, "engines": { "node": ">=18.0.0", @@ -1037,9 +752,9 @@ } }, "node_modules/@types/express-serve-static-core": { - "version": "4.19.5", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.5.tgz", - "integrity": "sha512-y6W03tvrACO72aijJ5uF02FRq5cgDR9lUxddQ8vyF+GvmjJQqbzDcJngEjURc+ZsG31VI3hODNZJ2URj86pzmg==", + "version": "4.19.6", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.6.tgz", + "integrity": "sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==", "dependencies": { "@types/node": "*", "@types/qs": "*", @@ -1099,11 +814,11 @@ } }, "node_modules/@types/node": { - "version": "20.11.30", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz", - "integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==", + "version": "20.16.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.12.tgz", + "integrity": "sha512-LfPFB0zOeCeCNQV3i+67rcoVvoN5n0NVuR2vLG0O5ySQMgchuZlC4lgz546ZOJyDtj5KIgOxy+lacOimfqZAIA==", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } }, "node_modules/@types/node-cron": { @@ -1113,9 +828,9 @@ "dev": true }, "node_modules/@types/qs": { - "version": "6.9.15", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz", - "integrity": "sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==" + "version": "6.9.16", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.16.tgz", + "integrity": "sha512-7i+zxXdPD0T4cKDuxCUXJ4wHcsJLwENa6Z3dCu8cfCK743OGy5Nu1RmAGqDPsoTDINVEcdXKRvR/zre+P2Ku1A==" }, "node_modules/@types/range-parser": { "version": "1.2.7", @@ -1177,9 +892,9 @@ } }, "node_modules/acorn": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", - "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.13.0.tgz", + "integrity": "sha512-8zSiw54Oxrdym50NlZ9sUusyO1Z1ZchgRLWRaK6c86XJFClyCgFKetdowBg5bKxyp/u+CDBJG4Mpp0m3HLZl9w==", "devOptional": true, "bin": { "acorn": "bin/acorn" @@ -1189,9 +904,9 @@ } }, "node_modules/acorn-walk": { - "version": "8.3.3", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", - "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", "devOptional": true, "dependencies": { "acorn": "^8.11.0" @@ -1227,27 +942,6 @@ "node": ">=10" } }, - "node_modules/amqplib/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" - }, - "node_modules/amqplib/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/amqplib/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==" - }, "node_modules/ansi-escapes": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", @@ -1257,9 +951,9 @@ } }, "node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", "engines": { "node": ">=12" }, @@ -1417,6 +1111,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/aws-ssl-profiles": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz", + "integrity": "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==", + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/axios": { "version": "1.7.7", "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", @@ -1477,9 +1179,9 @@ "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" }, "node_modules/body-parser": { - "version": "1.20.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", - "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", "dependencies": { "bytes": "3.1.2", "content-type": "~1.0.5", @@ -1489,7 +1191,7 @@ "http-errors": "2.0.0", "iconv-lite": "0.4.24", "on-finished": "2.4.1", - "qs": "6.11.0", + "qs": "6.13.0", "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" @@ -1913,6 +1615,33 @@ "typedarray": "^0.0.6" } }, + "node_modules/concat-stream/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, + "node_modules/concat-stream/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/concat-stream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/config-chain": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz", @@ -1939,6 +1668,25 @@ "node": ">= 0.6" } }, + "node_modules/content-disposition/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/content-type": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", @@ -1948,9 +1696,9 @@ } }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", "engines": { "node": ">= 0.6" } @@ -2064,11 +1812,11 @@ "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==" }, "node_modules/debug": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", - "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "engines": { "node": ">=6.0" @@ -2079,11 +1827,6 @@ } } }, - "node_modules/debug/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, "node_modules/decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", @@ -2166,14 +1909,14 @@ } }, "node_modules/dotenv": { - "version": "16.3.2", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.2.tgz", - "integrity": "sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ==", + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", "engines": { "node": ">=12" }, "funding": { - "url": "https://github.com/motdotla/dotenv?sponsor=1" + "url": "https://dotenvx.com" } }, "node_modules/eastasianwidth": { @@ -2247,9 +1990,9 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" }, "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", "engines": { "node": ">= 0.8" } @@ -2447,36 +2190,36 @@ } }, "node_modules/express": { - "version": "4.18.3", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.3.tgz", - "integrity": "sha512-6VyCijWQ+9O7WuVMTRBTl+cjNNIzD5cY5mQ1WM8r/LEkI2u8EYpOotESNwzNlyCn3g+dmjKYI6BmNneSr/FSRw==", + "version": "4.21.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", + "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.2", + "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.7.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.2.0", + "finalhandler": "1.3.1", "fresh": "0.5.2", "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", + "merge-descriptors": "1.0.3", "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", + "path-to-regexp": "0.1.10", "proxy-addr": "~2.0.7", - "qs": "6.11.0", + "qs": "6.13.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", + "send": "0.19.0", + "serve-static": "1.16.2", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "~1.6.18", @@ -2501,9 +2244,28 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/express/node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", + "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==" + }, + "node_modules/express/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, "node_modules/external-editor": { "version": "3.1.0", @@ -2562,12 +2324,12 @@ } }, "node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", "dependencies": { "debug": "2.6.9", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "on-finished": "2.4.1", "parseurl": "~1.3.3", @@ -2592,9 +2354,9 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/follow-redirects": { - "version": "1.15.8", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.8.tgz", - "integrity": "sha512-xgrmBhBToVKay1q2Tao5LI26B83UhrB/vM1avwVSDzt8rx3rO6AizBAaF46EgksTVr+rFTQaqZZ9MVBfUe4nig==", + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", "funding": [ { "type": "individual", @@ -2634,9 +2396,9 @@ } }, "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -2680,6 +2442,20 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -3654,11 +3430,25 @@ } }, "node_modules/lru-cache": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-8.0.5.tgz", - "integrity": "sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==", + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", "engines": { - "node": ">=16.14" + "node": ">=12" + } + }, + "node_modules/lru.min": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.1.tgz", + "integrity": "sha512-FbAj6lXil6t8z4z3j0E5mfRlPzxkySotzUHwRXjlpRh10vc6AI6WN62ehZj82VG7M20rqogJ0GLwar2Xa05a8Q==", + "engines": { + "bun": ">=1.0.0", + "deno": ">=1.30.0", + "node": ">=8.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wellwelwel" } }, "node_modules/make-error": { @@ -3689,9 +3479,12 @@ } }, "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/methods": { "version": "1.1.2", @@ -3811,6 +3604,23 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, + "node_modules/multer": { + "version": "1.4.4-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.4-lts.1.tgz", + "integrity": "sha512-WeSGziVj6+Z2/MwQo3GvqzgR+9Uc+qt8SwHKh3gvNPiISKfsMfG4SvCOFYlxxgkXt7yIV2i1yczehm0EOKIxIg==", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", @@ -3849,11 +3659,6 @@ "util-deprecate": "~1.0.1" } }, - "node_modules/mysql/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, "node_modules/mysql/node_modules/sqlstring": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz", @@ -3862,16 +3667,25 @@ "node": ">= 0.6" } }, - "node_modules/mysql2": { - "version": "3.9.9", - "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.9.9.tgz", - "integrity": "sha512-Qtb2RUxwWMFkWXqF7Rd/7ySkupbQnNY7O0zQuQYgPcuJZ06M36JG3HIDEh/pEeq7LImcvA6O3lOVQ9XQK+HEZg==", + "node_modules/mysql/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/mysql2": { + "version": "3.11.3", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.11.3.tgz", + "integrity": "sha512-Qpu2ADfbKzyLdwC/5d4W7+5Yz7yBzCU05YWt5npWzACST37wJsB23wgOSo00qi043urkiRwXtEvJc9UnuLX/MQ==", + "dependencies": { + "aws-ssl-profiles": "^1.1.1", "denque": "^2.1.0", "generate-function": "^2.3.1", "iconv-lite": "^0.6.3", "long": "^5.2.1", - "lru-cache": "^8.0.0", + "lru.min": "^1.0.0", "named-placeholders": "^1.1.3", "seq-queue": "^0.0.5", "sqlstring": "^2.3.2" @@ -3912,14 +3726,6 @@ "node": ">=12.0.0" } }, - "node_modules/named-placeholders/node_modules/lru-cache": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", - "engines": { - "node": ">=12" - } - }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -3965,9 +3771,9 @@ } }, "node_modules/nodemon": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.3.tgz", - "integrity": "sha512-7jH/NXbFPxVaMwmBCC2B9F/V6X1VkEdNgx3iu9jji8WxWcvhMWkmhNWhI5077zknOnZnBzba9hZP6bCPJLSReQ==", + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", + "integrity": "sha512-hLj7fuMow6f0lbB0cD14Lz2xNjwsyruH251Pk4t/yIitCFJbmY1myuLlHm/q06aST4jg6EgAh74PIBBrRqpVAQ==", "dev": true, "dependencies": { "chokidar": "^3.5.2", @@ -4146,9 +3952,9 @@ } }, "node_modules/package-json-from-dist": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", - "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==" }, "node_modules/parse5": { "version": "5.1.1", @@ -4213,9 +4019,9 @@ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==" }, "node_modules/path-to-regexp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.2.0.tgz", - "integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.3.0.tgz", + "integrity": "sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==", "peer": true }, "node_modules/picomatch": { @@ -4239,9 +4045,9 @@ } }, "node_modules/prettier": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", - "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" @@ -4307,11 +4113,11 @@ "dev": true }, "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", "dependencies": { - "side-channel": "^1.0.4" + "side-channel": "^1.0.6" }, "engines": { "node": ">=0.6" @@ -4348,28 +4154,20 @@ } }, "node_modules/readable-stream": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", "dependencies": { "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" } }, "node_modules/readable-stream/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" - }, - "node_modules/readable-stream/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" }, "node_modules/readdirp": { "version": "3.6.0", @@ -4439,14 +4237,14 @@ "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==" }, "node_modules/regexp.prototype.flags": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.2.tgz", - "integrity": "sha512-NcDiDkTLuPR+++OCKB0nWafEmhg/Da8aUPLPMQbK+bxKKCm1/S5he+AqYa4PlMCVBalb4/yxIRub6qkEx5yJbw==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.3.tgz", + "integrity": "sha512-vqlC04+RQoFalODCbCumG2xIOvapzVMHwsyIGM/SIE8fRhFFsXeH8/QQ+s0T0kDAhKc4k30s73/0ydkHQz6HlQ==", "dependencies": { - "call-bind": "^1.0.6", + "call-bind": "^1.0.7", "define-properties": "^1.2.1", "es-errors": "^1.3.0", - "set-function-name": "^2.0.1" + "set-function-name": "^2.0.2" }, "engines": { "node": ">= 0.4" @@ -4539,23 +4337,9 @@ } }, "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "node_modules/safe-regex-test": { "version": "1.0.3", @@ -4600,9 +4384,9 @@ } }, "node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", "dependencies": { "debug": "2.6.9", "depd": "2.0.0", @@ -4635,20 +4419,28 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/seq-queue": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz", "integrity": "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q==" }, "node_modules/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", "dependencies": { - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.18.0" + "send": "0.19.0" }, "engines": { "node": ">= 0.8.0" @@ -4813,17 +4605,9 @@ } }, "node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/string_decoder/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==" }, "node_modules/string-width": { "version": "5.1.2", @@ -5181,17 +4965,17 @@ } }, "node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz", + "integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==" }, "node_modules/tsoa": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/tsoa/-/tsoa-6.0.1.tgz", - "integrity": "sha512-Far5BFpFvMYVMZxt87O7hOFGpa6dALQ8XHhdDytry0IhIUJnRliVXLZ2t2KGcgNw0bIwsk+2XkWra18LL6cORA==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/tsoa/-/tsoa-6.5.1.tgz", + "integrity": "sha512-NnsrtNj2iWoQkQ4sX9sNtX60uOsBxZVOZX4WzUTJC24lrxeh0amywYVTKfdspfCyQsy6YjK53pK4A9+My1cEjw==", "dependencies": { - "@tsoa/cli": "^6.0.1", - "@tsoa/runtime": "^6.0.0" + "@tsoa/cli": "^6.5.1", + "@tsoa/runtime": "^6.5.1" }, "bin": { "tsoa": "dist/cli.js" @@ -5674,9 +5458,9 @@ } }, "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -5735,17 +5519,17 @@ "dev": true }, "node_modules/undici": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.8.tgz", - "integrity": "sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==", + "version": "6.20.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.20.1.tgz", + "integrity": "sha512-AjQF1QsmqfJys+LXfGTNum+qw4S88CojRInG/6t31W/1fk6G59s92bnAvGz5Cmur+kQv2SURXEvvudLmbrE8QA==", "engines": { "node": ">=18.17" } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" }, "node_modules/universalify": { "version": "2.0.1", @@ -6029,9 +5813,9 @@ "peer": true }, "node_modules/yaml": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz", - "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.0.tgz", + "integrity": "sha512-a6ae//JvKDEra2kdi1qzCyrJW/WZCgFi8ydDV+eXExl95t+5R+ijnqHJbz9tmMh8FUjx3iv2fCQ4dclAQlO2UQ==", "bin": { "yaml": "bin.mjs" }, diff --git a/src/controllers/AppointController.ts b/src/controllers/AppointController.ts index df96c49..7b47b87 100644 --- a/src/controllers/AppointController.ts +++ b/src/controllers/AppointController.ts @@ -1,172 +1,150 @@ -import { - Controller, - Route, - Security, - Tags, - Body, - Request, - SuccessResponse, - Response, - Get, - Put, - Post, - Path, - Delete, -} from "tsoa"; -import { setLogDataDiff } from "../interfaces/utils"; +import { Controller, Route, Security, Tags, Body, Request, SuccessResponse, Response, Get, Put, Post, Path, Delete } from "tsoa" +import { setLogDataDiff } from "../interfaces/utils" -import { AppDataSource } from "../database/data-source"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatusCode from "../interfaces/http-status"; -import HttpError from "../interfaces/http-error"; -import permission from "../interfaces/permission"; -import { RequestWithUser } from "../middlewares/user"; -import { Appoint, CreateAppoint, Person, UpdateAppoint } from "../entities/Appoint"; -import { AppointDirector } from "../entities/AppointDirector"; +import { AppDataSource } from "../database/data-source" +import HttpSuccess from "../interfaces/http-success" +import HttpStatusCode from "../interfaces/http-status" +import HttpError from "../interfaces/http-error" +import permission from "../interfaces/permission" +import { RequestWithUser } from "../middlewares/user" +import { Appoint, CreateAppoint, Person, UpdateAppoint } from "../entities/Appoint" +import { AppointDirector } from "../entities/AppointDirector" @Route("api/v1/probation/appoint") @Tags("Appoint Director") @Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") export class AppointController extends Controller { - private appointRepository = AppDataSource.getRepository(Appoint); - private appointDirectorRepository = AppDataSource.getRepository(AppointDirector); + private appointRepository = AppDataSource.getRepository(Appoint) + private appointDirectorRepository = AppDataSource.getRepository(AppointDirector) - /** - * API รายการแต่งตั้งคณะกรรมการฯ ทดลองงาน - * - * @summary รายการแต่งตั้งคณะกรรมการฯ - * - */ - @Get("") - async GetList(@Request() request: RequestWithUser) { - await new permission().PermissionList(request, "SYS_PROBATION"); + /** + * API รายการแต่งตั้งคณะกรรมการฯ ทดลองงาน + * + * @summary รายการแต่งตั้งคณะกรรมการฯ + * + */ + @Get("") + async GetList(@Request() request: RequestWithUser) { + await new permission().PermissionList(request, "SYS_PROBATION") - const appoint = await this.appointRepository.find({}); + const appoint = await this.appointRepository.find({}) - return new HttpSuccess(appoint); - } + return new HttpSuccess(appoint) + } - /** - * API รายการแต่งตั้งคณะกรรมการฯ ที่ออกคำสั่งแล้วทดลองงาน - * - * @summary รายการแต่งตั้งคณะกรรมการฯ ที่ออกคำสั่งแล้ว - * - */ - @Get("list/{id}") - async GetListCommand(@Request() request: RequestWithUser, @Path() id: string) { - const appoint = await this.appointRepository.find({ - relations: ["directors"], - where: { profileId: id, status: "DONE" }, - }); + /** + * API รายการแต่งตั้งคณะกรรมการฯ ที่ออกคำสั่งแล้วทดลองงาน + * + * @summary รายการแต่งตั้งคณะกรรมการฯ ที่ออกคำสั่งแล้ว + * + */ + @Get("list/{id}") + async GetListCommand(@Request() request: RequestWithUser, @Path() id: string) { + const appoint = await this.appointRepository.find({ + relations: ["directors"], + where: { profileId: id, status: "DONE" }, + }) - return new HttpSuccess(appoint); - } + return new HttpSuccess(appoint) + } - /** - * API สร้างการแต่งตั้งคณะกรรมการฯ ทดลองงาน - * - * @summary สร้างการแต่งตั้งคณะกรรมการฯ - * - */ - @Post("") - async Create(@Request() request: RequestWithUser, @Body() requestBody: CreateAppoint) { - await new permission().PermissionCreate(request, "SYS_PROBATION"); + /** + * API สร้างการแต่งตั้งคณะกรรมการฯ ทดลองงาน + * + * @summary สร้างการแต่งตั้งคณะกรรมการฯ + * + */ + @Post("") + async Create(@Request() request: RequestWithUser, @Body() requestBody: CreateAppoint) { + await new permission().PermissionCreate(request, "SYS_PROBATION") - const data: any = { - topic: requestBody.topic, - profileId: requestBody.profileId, - createdUserId: request.user.sub, - createdFullName: request.user.name, - }; - const before = null; - const appoint = await this.appointRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: appoint }); + const data: any = { + topic: requestBody.topic, + profileId: requestBody.profileId, + createdUserId: request.user.sub, + createdFullName: request.user.name, + } + const before = null + const appoint = await this.appointRepository.save(data, { data: request }) + setLogDataDiff(request, { before, after: appoint }) - return new HttpSuccess(appoint.id); - } + return new HttpSuccess(appoint.id) + } - /** - * API ดึงข้อมูลแต่งตั้งคณะกรรมการฯ - * - * @summary API ดึงข้อมูลแต่งตั้งคณะกรรมการฯ ตาม id - * - */ - @Get("{id}") - async GetById(@Request() request: RequestWithUser, @Path() id: string) { - await new permission().PermissionGet(request, "SYS_PROBATION"); + /** + * API ดึงข้อมูลแต่งตั้งคณะกรรมการฯ + * + * @summary API ดึงข้อมูลแต่งตั้งคณะกรรมการฯ ตาม id + * + */ + @Get("{id}") + async GetById(@Request() request: RequestWithUser, @Path() id: string) { + await new permission().PermissionGet(request, "SYS_PROBATION") - const appoint = await this.appointRepository.findOne({ - select: ["id", "topic", "status", "profileId"], - where: { id }, - relations: ["directors"], - }); + const appoint = await this.appointRepository.findOne({ + select: ["id", "topic", "status", "profileId"], + where: { id }, + relations: ["directors"], + }) - return new HttpSuccess(appoint); - } + return new HttpSuccess(appoint) + } - /** - * API แก้ไขการแต่งตั้งคณะกรรมการฯ ทดลองงาน - * - * @summary แก้ไขการแต่งตั้งคณะกรรมการฯ - * - */ - @Put("{id}") - async Update( - @Request() request: RequestWithUser, - @Body() requestBody: UpdateAppoint, - @Path() id: string, - ) { - await new permission().PermissionUpdate(request, "SYS_PROBATION"); + /** + * API แก้ไขการแต่งตั้งคณะกรรมการฯ ทดลองงาน + * + * @summary แก้ไขการแต่งตั้งคณะกรรมการฯ + * + */ + @Put("{id}") + async Update(@Request() request: RequestWithUser, @Body() requestBody: UpdateAppoint, @Path() id: string) { + await new permission().PermissionUpdate(request, "SYS_PROBATION") - const appoint: any = await this.appointRepository.findOne({ where: { id } }); + const appoint: any = await this.appointRepository.findOne({ where: { id } }) - if (!appoint) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการแต่งตั้งคณะกรรมการฯ"); - } + if (!appoint) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการแต่งตั้งคณะกรรมการฯ") + } - const before = appoint; + const before = appoint - appoint.topic = requestBody.topic; - appoint.updateUserId = request.user.sub; - appoint.updateFullName = request.user.name; + appoint.topic = requestBody.topic + appoint.updateUserId = request.user.sub + appoint.updateFullName = request.user.name - await this.appointDirectorRepository.delete({ appointId: id }); - const directors = await requestBody.persons.map((x: Person) => ({ - ...x, - appointId: id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - })); - await this.appointDirectorRepository.save(directors); + await this.appointDirectorRepository.delete({ appointId: id }) + const directors = await requestBody.persons.map((x: Person) => ({ + ...x, + appointId: id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.appointDirectorRepository.save(directors) - await this.appointRepository.save(appoint, { data: request }); - setLogDataDiff(request, { before, after: appoint }); + await this.appointRepository.save(appoint, { data: request }) + setLogDataDiff(request, { before, after: appoint }) - return new HttpSuccess(); - } + return new HttpSuccess() + } - /** - * API ลบรายการแต่งตั้งคณะกรรมการฯ - * - * @summary ลบรายการแต่งตั้งคณะกรรมการฯ - * - */ - @Delete("{id}") - public async deleteRole(@Path() id: string, @Request() request: RequestWithUser) { - await new permission().PermissionDelete(request, "SYS_PROBATION"); + /** + * API ลบรายการแต่งตั้งคณะกรรมการฯ + * + * @summary ลบรายการแต่งตั้งคณะกรรมการฯ + * + */ + @Delete("{id}") + public async deleteRole(@Path() id: string, @Request() request: RequestWithUser) { + await new permission().PermissionDelete(request, "SYS_PROBATION") - await this.appointDirectorRepository.delete({ appointId: id }); + await this.appointDirectorRepository.delete({ appointId: id }) - const result = await this.appointRepository.delete({ id }); - if (!result) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); + const result = await this.appointRepository.delete({ id }) + if (!result) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล") - return new HttpSuccess(); - } + return new HttpSuccess() + } } diff --git a/src/controllers/AssignController.ts b/src/controllers/AssignController.ts index fe86297..735bf15 100644 --- a/src/controllers/AssignController.ts +++ b/src/controllers/AssignController.ts @@ -1,717 +1,634 @@ -import { - Controller, - Post, - Put, - Route, - Security, - Tags, - Body, - Request, - SuccessResponse, - Response, - Get, - Query, -} from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatusCode from "../interfaces/http-status"; -import HttpError from "../interfaces/http-error"; -import { RequestWithUser } from "../middlewares/user"; -import { findEndDate, setLogDataDiff } from "../interfaces/utils"; -import { Personal } from "../entities/Personal"; -import permission from "../interfaces/permission"; -import { Assign, CreateAssign } from "../entities/Assign"; -import { AssignDirector, CreateAssignDirector } from "../entities/AssignDirector"; -import { AssignJob, CreateAssignJob } from "../entities/AssignJob"; -import { AssignKnowledge, CreateAssignKnowledge } from "../entities/AssignKnowledge"; -import { AssignLaw, CreateAssignLaw } from "../entities/AssignLaw"; -import { AssignSkill, CreateAssignSkill } from "../entities/AssignSkill"; -import { AssignCompetency, CreateAssignCompetency } from "../entities/AssignCompetency"; -import { - AssignCompetencyGroup, - CreateAssignCompetencyGroup, -} from "../entities/AssignCompetencyGroup"; -import { AssignOutput, CreateAssignOutput } from "../entities/AssignOutput"; -import { Law } from "../entities/Law"; -import CallAPI from "../interfaces/call-api"; +import { Controller, Post, Put, Route, Security, Tags, Body, Request, SuccessResponse, Response, Get, Query } from "tsoa" +import { AppDataSource } from "../database/data-source" +import HttpSuccess from "../interfaces/http-success" +import HttpStatusCode from "../interfaces/http-status" +import HttpError from "../interfaces/http-error" +import { RequestWithUser } from "../middlewares/user" +import { findEndDate, setLogDataDiff } from "../interfaces/utils" +import { Personal } from "../entities/Personal" +import permission from "../interfaces/permission" +import { Assign, CreateAssign } from "../entities/Assign" +import { AssignDirector, CreateAssignDirector } from "../entities/AssignDirector" +import { AssignJob, CreateAssignJob } from "../entities/AssignJob" +import { AssignKnowledge, CreateAssignKnowledge } from "../entities/AssignKnowledge" +import { AssignLaw, CreateAssignLaw } from "../entities/AssignLaw" +import { AssignSkill, CreateAssignSkill } from "../entities/AssignSkill" +import { AssignCompetency, CreateAssignCompetency } from "../entities/AssignCompetency" +import { AssignCompetencyGroup, CreateAssignCompetencyGroup } from "../entities/AssignCompetencyGroup" +import { AssignOutput, CreateAssignOutput } from "../entities/AssignOutput" +import { Law } from "../entities/Law" +import CallAPI from "../interfaces/call-api" @Route("api/v1/probation/assign") @Tags("ฟอร์มมอบหมายงาน") @Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") export class AssignController extends Controller { - private assignRepository = AppDataSource.getRepository(Assign); - private personalRepository = AppDataSource.getRepository(Personal); - private assignDirectorRepository = AppDataSource.getRepository(AssignDirector); - private assignJobRepository = AppDataSource.getRepository(AssignJob); - private assignKnowledgeRepository = AppDataSource.getRepository(AssignKnowledge); - private assignLawRepository = AppDataSource.getRepository(AssignLaw); - private assignSkillRepository = AppDataSource.getRepository(AssignSkill); - private assignCompetencyRepository = AppDataSource.getRepository(AssignCompetency); - private assignCompetencyGroupRepository = AppDataSource.getRepository(AssignCompetencyGroup); - private assignOutputRepository = AppDataSource.getRepository(AssignOutput); - private lawsRepository = AppDataSource.getRepository(Law); + private assignRepository = AppDataSource.getRepository(Assign) + private personalRepository = AppDataSource.getRepository(Personal) + private assignDirectorRepository = AppDataSource.getRepository(AssignDirector) + private assignJobRepository = AppDataSource.getRepository(AssignJob) + private assignKnowledgeRepository = AppDataSource.getRepository(AssignKnowledge) + private assignLawRepository = AppDataSource.getRepository(AssignLaw) + private assignSkillRepository = AppDataSource.getRepository(AssignSkill) + private assignCompetencyRepository = AppDataSource.getRepository(AssignCompetency) + private assignCompetencyGroupRepository = AppDataSource.getRepository(AssignCompetencyGroup) + private assignOutputRepository = AppDataSource.getRepository(AssignOutput) + private lawsRepository = AppDataSource.getRepository(Law) - /** - * API เพิ่มข้อมูลการมอบหมายงาน - * - * @summary เพิ่มข้อมูลการมอบหมายงาน - * - */ - @Post("") - async AddAssign(@Request() request: RequestWithUser, @Body() requestBody: CreateAssign) { - await new permission().PermissionUpdate(request, "SYS_PROBATION"); - const person = await this.personalRepository.findOne({ - where: { - personal_id: requestBody.personalId, - }, - }); + /** + * API เพิ่มข้อมูลการมอบหมายงาน + * + * @summary เพิ่มข้อมูลการมอบหมายงาน + * + */ + @Post("") + async AddAssign(@Request() request: RequestWithUser, @Body() requestBody: CreateAssign) { + await new permission().PermissionUpdate(request, "SYS_PROBATION") + const person = await this.personalRepository.findOne({ + where: { + personal_id: requestBody.personalId, + }, + }) - if (!person) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); - } + if (!person) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล") + } - const roundNo = await this.assignRepository.count({ - where: { - active: 1, - personal_id: requestBody.personalId, - }, - }); + const roundNo = await this.assignRepository.count({ + where: { + active: 1, + personal_id: requestBody.personalId, + }, + }) - const data: any = { - ...requestBody, - round_no: roundNo + 1, - personal_id: requestBody.personalId, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }; - const before = null; - const assign = await this.assignRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: data }); + const data: any = { + ...requestBody, + round_no: roundNo + 1, + personal_id: requestBody.personalId, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + } + const before = null + const assign = await this.assignRepository.save(data, { data: request }) + setLogDataDiff(request, { before, after: data }) - const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({ - ...x, - id: index + 1, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - })); - await this.assignJobRepository.save(jobs, { data: request }); - setLogDataDiff(request, { before, after: jobs }); + const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({ + ...x, + id: index + 1, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignJobRepository.save(jobs, { data: request }) + setLogDataDiff(request, { before, after: jobs }) - const knowledges = await requestBody.assign_knowledges.map( - (x: CreateAssignKnowledge, index: number) => ({ - knowledge_level: x.level, - knowledge_id: x.id, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignKnowledgeRepository.save(knowledges, { data: request }); - setLogDataDiff(request, { before, after: knowledges }); + const knowledges = await requestBody.assign_knowledges.map((x: CreateAssignKnowledge, index: number) => ({ + knowledge_level: x.level, + knowledge_id: x.id, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignKnowledgeRepository.save(knowledges, { data: request }) + setLogDataDiff(request, { before, after: knowledges }) - const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({ - ordering: index + 1, - law_id: x.id, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - })); - await this.assignLawRepository.save(laws, { data: request }); - setLogDataDiff(request, { before, after: laws }); + const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({ + ordering: index + 1, + law_id: x.id, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignLawRepository.save(laws, { data: request }) + setLogDataDiff(request, { before, after: laws }) - const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({ - skill_id: index + 1, - skill_level: x.level, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - })); - await this.assignSkillRepository.save(skills, { data: request }); - setLogDataDiff(request, { before, after: skills }); + const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({ + skill_id: index + 1, + skill_level: x.level, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignSkillRepository.save(skills, { data: request }) + setLogDataDiff(request, { before, after: skills }) - const competencise = await requestBody.assign_competency.map( - (x: CreateAssignCompetency, index: number) => ({ - competency_id: x.id, - competency_level: x.level, - competency_name: x.name, - competency_description: x.description, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignCompetencyRepository.save(competencise, { data: request }); - setLogDataDiff(request, { before, after: competencise }); + const competencise = await requestBody.assign_competency.map((x: CreateAssignCompetency, index: number) => ({ + competency_id: x.id, + competency_level: x.level, + competency_name: x.name, + competency_description: x.description, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignCompetencyRepository.save(competencise, { data: request }) + setLogDataDiff(request, { before, after: competencise }) - const competencyGroups = await requestBody.assign_competency_group.map( - (x: CreateAssignCompetencyGroup, index: number) => ({ - competency_group_id: x.id, - competency_group_level: x.level, - competency_group_name: x.name, - competency_group_description: x.description, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignCompetencyGroupRepository.save(competencyGroups, { - data: request, - }); - setLogDataDiff(request, { before, after: competencyGroups }); + const competencyGroups = await requestBody.assign_competency_group.map((x: CreateAssignCompetencyGroup, index: number) => ({ + competency_group_id: x.id, + competency_group_level: x.level, + competency_group_name: x.name, + competency_group_description: x.description, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignCompetencyGroupRepository.save(competencyGroups, { + data: request, + }) + setLogDataDiff(request, { before, after: competencyGroups }) - const outputs = await requestBody.assign_outputs.map( - (x: CreateAssignOutput, index: number) => ({ - ...x, - id: index + 1, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignOutputRepository.save(outputs, { data: request }); - setLogDataDiff(request, { before, after: outputs }); + const outputs = await requestBody.assign_outputs.map((x: CreateAssignOutput, index: number) => ({ + ...x, + id: index + 1, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignOutputRepository.save(outputs, { data: request }) + setLogDataDiff(request, { before, after: outputs }) - const directors = await requestBody.assign_director.map( - (x: CreateAssignDirector, index: number) => ({ - ...x, - assign_id: assign.id, - fullname: x.name, - ordering: index + 1, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignDirectorRepository.save(directors, { data: request }); - setLogDataDiff(request, { before, after: directors }); + const directors = await requestBody.assign_director.map((x: CreateAssignDirector, index: number) => ({ + ...x, + assign_id: assign.id, + fullname: x.name, + ordering: index + 1, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignDirectorRepository.save(directors, { data: request }) + setLogDataDiff(request, { before, after: directors }) - return new HttpSuccess(); - } + return new HttpSuccess() + } - /** - * API แก้ไขข้อมูลการมอบหมายงาน - * - * @summary แก้ไขแบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ - * - */ - @Put("") - async EditAssign( - @Query() assign_id: string, - @Request() request: RequestWithUser, - @Body() requestBody: CreateAssign, - ) { - await new permission().PermissionUpdate(request, "SYS_PROBATION"); + /** + * API แก้ไขข้อมูลการมอบหมายงาน + * + * @summary แก้ไขแบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ + * + */ + @Put("") + async EditAssign(@Query() assign_id: string, @Request() request: RequestWithUser, @Body() requestBody: CreateAssign) { + await new permission().PermissionUpdate(request, "SYS_PROBATION") - const assign = await this.assignRepository.findOne({ - where: { id: assign_id }, - }); - let before = assign; + const assign = await this.assignRepository.findOne({ + where: { id: assign_id }, + }) + let before = assign - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const person = await this.personalRepository.findOne({ - where: { - personal_id: requestBody.personalId, - }, - }); + const person = await this.personalRepository.findOne({ + where: { + personal_id: requestBody.personalId, + }, + }) - if (!person) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); - } + if (!person) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล") + } - const data: any = { - ...requestBody, - id: assign_id, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }; + const data: any = { + ...requestBody, + id: assign_id, + updateUserId: request.user.sub, + updateFullName: request.user.name, + } - await this.assignJobRepository.delete({ assign_id }); - const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({ - ...x, - id: index + 1, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - })); - await this.assignJobRepository.save(jobs); + await this.assignJobRepository.delete({ assign_id }) + const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({ + ...x, + id: index + 1, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignJobRepository.save(jobs) - await this.assignKnowledgeRepository.delete({ assign_id }); - const knowledges = await requestBody.assign_knowledges.map( - (x: CreateAssignKnowledge, index: number) => ({ - knowledge_level: x.level, - knowledge_id: x.id, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignKnowledgeRepository.save(knowledges); + await this.assignKnowledgeRepository.delete({ assign_id }) + const knowledges = await requestBody.assign_knowledges.map((x: CreateAssignKnowledge, index: number) => ({ + knowledge_level: x.level, + knowledge_id: x.id, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignKnowledgeRepository.save(knowledges) - await this.assignLawRepository.delete({ assign_id }); - const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({ - ordering: index + 1, - law_id: x.id, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - })); - await this.assignLawRepository.save(laws); + await this.assignLawRepository.delete({ assign_id }) + const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({ + ordering: index + 1, + law_id: x.id, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignLawRepository.save(laws) - await this.assignSkillRepository.delete({ assign_id }); - const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({ - skill_id: index + 1, - skill_level: x.level, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - })); - await this.assignSkillRepository.save(skills); + await this.assignSkillRepository.delete({ assign_id }) + const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({ + skill_id: index + 1, + skill_level: x.level, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignSkillRepository.save(skills) - await this.assignCompetencyRepository.delete({ assign_id }); - const competencise = await requestBody.assign_competency.map( - (x: CreateAssignCompetency, index: number) => ({ - competency_id: x.id, - competency_level: x.level, - competency_name: x.name, - competency_description: x.description, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignCompetencyRepository.save(competencise); + await this.assignCompetencyRepository.delete({ assign_id }) + const competencise = await requestBody.assign_competency.map((x: CreateAssignCompetency, index: number) => ({ + competency_id: x.id, + competency_level: x.level, + competency_name: x.name, + competency_description: x.description, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignCompetencyRepository.save(competencise) - await this.assignCompetencyGroupRepository.delete({ assign_id }); - const competencyGroups = await requestBody.assign_competency_group.map( - (x: CreateAssignCompetencyGroup, index: number) => ({ - competency_group_id: x.id, - competency_group_level: x.level, - competency_group_name: x.name, - competency_group_description: x.description, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignCompetencyGroupRepository.save(competencyGroups); + await this.assignCompetencyGroupRepository.delete({ assign_id }) + const competencyGroups = await requestBody.assign_competency_group.map((x: CreateAssignCompetencyGroup, index: number) => ({ + competency_group_id: x.id, + competency_group_level: x.level, + competency_group_name: x.name, + competency_group_description: x.description, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignCompetencyGroupRepository.save(competencyGroups) - await this.assignOutputRepository.delete({ assign_id }); - const outputs = await requestBody.assign_outputs.map( - (x: CreateAssignOutput, index: number) => ({ - ...x, - id: index + 1, - assign_id: assign.id, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignOutputRepository.save(outputs); + await this.assignOutputRepository.delete({ assign_id }) + const outputs = await requestBody.assign_outputs.map((x: CreateAssignOutput, index: number) => ({ + ...x, + id: index + 1, + assign_id: assign.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignOutputRepository.save(outputs) - await this.assignDirectorRepository.delete({ assign_id }); - const directors = await requestBody.assign_director.map( - (x: CreateAssignDirector, index: number) => ({ - ...x, - assign_id: assign.id, - fullname: x.name, - ordering: index + 1, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }), - ); - await this.assignDirectorRepository.save(directors); + await this.assignDirectorRepository.delete({ assign_id }) + const directors = await requestBody.assign_director.map((x: CreateAssignDirector, index: number) => ({ + ...x, + assign_id: assign.id, + fullname: x.name, + ordering: index + 1, + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + })) + await this.assignDirectorRepository.save(directors) - await this.assignRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: data }); + await this.assignRepository.save(data, { data: request }) + setLogDataDiff(request, { before, after: data }) - // #noted cronjob - // แจ้งผู้ดูแลและผู้บังคับบัญชาเข้ามาบันทึกผลทุก 2 เดือน - const dateSaveForm = await findEndDate(2, requestBody.date_start); - requestBody.assign_director - .filter((x) => x.role == "mentor" || x.role == "commander") - .map(async (director) => { - await new CallAPI() - .PostData(request, "/placement/noti", { - subject: `ถึงกำหนดบันทึกผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`, - body: `ถึงกำหนดบันทึกผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`, - receiverUserId: director.personal_id, - payload: "", - isSendMail: true, - isSendInbox: true, - receiveDate: dateSaveForm, - }) - .catch((error) => { - console.error("Error calling API:", error); - }); - }); + // #noted cronjob + // แจ้งผู้ดูแลและผู้บังคับบัญชาเข้ามาบันทึกผลทุก 2 เดือน + const dateSaveForm = await findEndDate(2, requestBody.date_start) + requestBody.assign_director + .filter(x => x.role == "mentor" || x.role == "commander") + .map(async director => { + await new CallAPI() + .PostData(request, "/placement/noti", { + subject: `ถึงกำหนดบันทึกผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`, + body: `ถึงกำหนดบันทึกผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`, + receiverUserId: director.personal_id, + payload: "", + isSendMail: true, + isSendInbox: true, + receiveDate: dateSaveForm, + }) + .catch(error => { + console.error("Error calling API:", error) + }) + }) - // แจ้งผู้บังคับบัญชา และคณะกรรมการเข้ามาประเมินทุก 3 เดือน - const dateEvaluate = await findEndDate(3, requestBody.date_start); - requestBody.assign_director - .filter((x) => x.role == "commander" || x.role == "chairman") - .map(async (director) => { - await new CallAPI() - .PostData(request, "/placement/noti", { - subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`, - body: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`, - receiverUserId: director.personal_id, - payload: "", - isSendMail: true, - isSendInbox: true, - receiveDate: dateEvaluate, - }) - .catch((error) => { - console.error("Error calling API:", error); - }); - }); + // แจ้งผู้บังคับบัญชา และคณะกรรมการเข้ามาประเมินทุก 3 เดือน + const dateEvaluate = await findEndDate(3, requestBody.date_start) + requestBody.assign_director + .filter(x => x.role == "commander" || x.role == "chairman") + .map(async director => { + await new CallAPI() + .PostData(request, "/placement/noti", { + subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`, + body: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`, + receiverUserId: director.personal_id, + payload: "", + isSendMail: true, + isSendInbox: true, + receiveDate: dateEvaluate, + }) + .catch(error => { + console.error("Error calling API:", error) + }) + }) - // แจ้งประธาน 6 เดือน - const dateResult = await findEndDate(6, requestBody.date_start); - requestBody.assign_director - .filter((x) => x.role == "chairman") - .map(async (director) => { - await new CallAPI() - .PostData(request, "/placement/noti", { - subject: `ถึงกำหนดรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ ${requestBody.fullname}`, - body: `ถึงกำหนดรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ ${requestBody.fullname}`, - receiverUserId: director.personal_id, - payload: "", - isSendMail: true, - isSendInbox: true, - // isSendNotification: true - receiveDate: dateResult, - }) - .catch((error) => { - console.error("Error calling API:", error); - }); - }); + // แจ้งประธาน 6 เดือน + const dateResult = await findEndDate(6, requestBody.date_start) + requestBody.assign_director + .filter(x => x.role == "chairman") + .map(async director => { + await new CallAPI() + .PostData(request, "/placement/noti", { + subject: `ถึงกำหนดรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ ${requestBody.fullname}`, + body: `ถึงกำหนดรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ ${requestBody.fullname}`, + receiverUserId: director.personal_id, + payload: "", + isSendMail: true, + isSendInbox: true, + // isSendNotification: true + receiveDate: dateResult, + }) + .catch(error => { + console.error("Error calling API:", error) + }) + }) - return new HttpSuccess(); - } + return new HttpSuccess() + } - /** - * API รายการข้อมูลการมอบหมายงาน - * - * @summary รายการการมอบหมายงาน - * - */ - @Get("assign-list") - async ListPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) { - await new permission().PermissionGet(request, "SYS_PROBATION"); - const lists = await this.assignRepository.find({ - select: ["id", "round_no", "date_start", "date_finish"], - where: { personal_id }, - order: { round_no: "ASC" }, - }); + /** + * API รายการข้อมูลการมอบหมายงาน + * + * @summary รายการการมอบหมายงาน + * + */ + @Get("assign-list") + async ListPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) { + await new permission().PermissionGet(request, "SYS_PROBATION") + const lists = await this.assignRepository.find({ + select: ["id", "round_no", "date_start", "date_finish"], + where: { personal_id }, + order: { round_no: "ASC" }, + }) - let result: any = []; + let result: any = [] - await Promise.all( - lists.map(async (item) => { - const director = await this.assignDirectorRepository.find({ - where: { assign_id: item.id }, - order: { ordering: "ASC" }, - }); + await Promise.all( + lists.map(async item => { + const director = await this.assignDirectorRepository.find({ + where: { assign_id: item.id }, + order: { ordering: "ASC" }, + }) - let mentors = ""; - const mentorList = await director.filter((x) => x.role == "mentor"); - if (mentorList.length > 0) { - for (let index = 0; index < mentorList.length; index++) { - const e = await mentorList[index]; - mentors += e.fullname; - if (index < mentorList.length - 1) { - mentors += ", "; - } - } - } + let mentors = "" + const mentorList = await director.filter(x => x.role == "mentor") + if (mentorList.length > 0) { + for (let index = 0; index < mentorList.length; index++) { + const e = await mentorList[index] + mentors += e.fullname + if (index < mentorList.length - 1) { + mentors += ", " + } + } + } - const commanderData = await (director.find((x) => x.role == "commander") ?? null); - const commander = commanderData ? commanderData.fullname : null; + const commanderData = await (director.find(x => x.role == "commander") ?? null) + const commander = commanderData ? commanderData.fullname : null - const chairmanData = await (director.find((x) => x.role == "chairman") ?? null); - const chairman = chairmanData ? chairmanData.fullname : null; + const chairmanData = await (director.find(x => x.role == "chairman") ?? null) + const chairman = chairmanData ? chairmanData.fullname : null - await result.push({ - ...item, - mentors: mentors, - commander: commander, - chairman: chairman, - }); - }), - ); + await result.push({ + ...item, + mentors: mentors, + commander: commander, + chairman: chairman, + }) + }) + ) - return new HttpSuccess(result); - } + return new HttpSuccess(result) + } - /** - * API ดึงข้อมูลแบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ - * - * @summary ดึงข้อมูลแบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ - * - */ - @Get("") - async GetAssign(@Query() assign_id: string, @Request() request: RequestWithUser) { - await new permission().PermissionGet(request, "SYS_PROBATION"); + /** + * API ดึงข้อมูลแบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ + * + * @summary ดึงข้อมูลแบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ + * + */ + @Get("") + async GetAssign(@Query() assign_id: string, @Request() request: RequestWithUser) { + await new permission().PermissionGet(request, "SYS_PROBATION") - const assign = await this.assignRepository.findOne({ - select: [ - "id", - "personal_id", - "round_no", - "date_start", - "date_finish", - "other_desc", - "other4_desc", - "other5_no1_desc", - "experimenter_dated", - "active", - "createdAt", - "updatedAt", - ], - where: { id: assign_id }, - }); + const assign = await this.assignRepository.findOne({ + select: ["id", "personal_id", "round_no", "date_start", "date_finish", "other_desc", "other4_desc", "other5_no1_desc", "experimenter_dated", "active", "createdAt", "updatedAt"], + where: { id: assign_id }, + }) - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const profileData = await this.personalRepository.findOne({ - select: [ - "personal_id", - "prefixName", - "firstName", - "lastName", - "positionName", - "positionLevelName", - "positionLineName", - "orgRootName", - "organization", - ], - where: { - personal_id: assign.personal_id, - }, - }); + const profileData = await this.personalRepository.findOne({ + select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "positionLineName", "orgRootName", "organization"], + where: { + personal_id: assign.personal_id, + }, + }) - if (!profileData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); - } + if (!profileData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล") + } - const profile = { - ...profileData, - name: `${profileData.prefixName}${profileData.firstName} ${profileData.lastName}`, - Position: profileData.positionName, - Department: "-", - OrganizationOrganization: profileData.orgRootName, - Oc: profileData.organization, - }; + const profile = { + ...profileData, + name: `${profileData.prefixName}${profileData.firstName} ${profileData.lastName}`, + Position: profileData.positionName, + Department: "-", + OrganizationOrganization: profileData.orgRootName, + Oc: profileData.organization, + } - const jobs = await this.assignJobRepository.find({ - select: ["id", "activity_desc", "goal_desc"], - where: { assign_id }, - }); + const jobs = await this.assignJobRepository.find({ + select: ["id", "activity_desc", "goal_desc"], + where: { assign_id }, + }) - const knowledgeData = await this.assignKnowledgeRepository.find({ - relations: ["knowledge"], - where: { assign_id }, - }); - const knowledges = await knowledgeData.map((x) => ({ - id: x.knowledge_id, - level: x.knowledge_level, - title: x.knowledge.title, - description: - x.knowledge_level == 1 - ? x.knowledge.level1 - : x.knowledge_level == 2 - ? x.knowledge.level2 - : x.knowledge_level == 3 - ? x.knowledge.level3 - : x.knowledge_level == 4 - ? x.knowledge.level4 - : x.knowledge_level == 5 - ? x.knowledge.level5 - : "", - })); + const knowledgeData = await this.assignKnowledgeRepository.find({ + relations: ["knowledge"], + where: { assign_id }, + }) + const knowledges = await knowledgeData.map(x => ({ + id: x.knowledge_id, + level: x.knowledge_level, + title: x.knowledge.title, + description: + x.knowledge_level == 1 + ? x.knowledge.level1 + : x.knowledge_level == 2 + ? x.knowledge.level2 + : x.knowledge_level == 3 + ? x.knowledge.level3 + : x.knowledge_level == 4 + ? x.knowledge.level4 + : x.knowledge_level == 5 + ? x.knowledge.level5 + : "", + })) - const lawData = await this.lawsRepository.find({ - where: { active: 1 }, - }); + const lawData = await this.lawsRepository.find({ + where: { active: 1 }, + }) - const laws = await Promise.all( - lawData.map(async (x) => { - const assignLaw = await this.assignLawRepository.countBy({ - assign_id: assign_id, - law_id: x.id, - }); + const laws = await Promise.all( + lawData.map(async x => { + const assignLaw = await this.assignLawRepository.countBy({ + assign_id: assign_id, + law_id: x.id, + }) - return { - id: x.id, - selected: assignLaw > 0 ? 1 : 0, - description: x.description, - status_select: x.status_select, - }; - }), - ); + return { + id: x.id, + selected: assignLaw > 0 ? 1 : 0, + description: x.description, + status_select: x.status_select, + } + }) + ) - const skillsData = await this.assignSkillRepository.find({ - relations: ["skill"], - where: { assign_id }, - }); + const skillsData = await this.assignSkillRepository.find({ + relations: ["skill"], + where: { assign_id }, + }) - const skills = await skillsData.map((x) => ({ - id: x.skill_id, - level: x.skill_level, - title: x.skill.title, - description: - x.skill_level == 1 - ? x.skill.level1 - : x.skill_level == 2 - ? x.skill.level2 - : x.skill_level == 3 - ? x.skill.level3 - : x.skill_level == 4 - ? x.skill.level4 - : x.skill_level == 5 - ? x.skill.level5 - : "", - })); + const skills = await skillsData.map(x => ({ + id: x.skill_id, + level: x.skill_level, + title: x.skill.title, + description: + x.skill_level == 1 + ? x.skill.level1 + : x.skill_level == 2 + ? x.skill.level2 + : x.skill_level == 3 + ? x.skill.level3 + : x.skill_level == 4 + ? x.skill.level4 + : x.skill_level == 5 + ? x.skill.level5 + : "", + })) - const competencyData = await this.assignCompetencyRepository.find({ - select: ["competency_id", "competency_level", "competency_name", "competency_description"], - where: { assign_id }, - }); + const competencyData = await this.assignCompetencyRepository.find({ + select: ["competency_id", "competency_level", "competency_name", "competency_description"], + where: { assign_id }, + }) - const competencys = await competencyData.map((x) => ({ - id: x.competency_id, - level: x.competency_level, - name: x.competency_name, - description: x.competency_description, - })); + const competencys = await competencyData.map(x => ({ + id: x.competency_id, + level: x.competency_level, + name: x.competency_name, + description: x.competency_description, + })) - const competencyGroupData = await this.assignCompetencyGroupRepository.find({ - select: [ - "competency_group_id", - "competency_group_level", - "competency_group_name", - "competency_group_description", - ], - where: { assign_id }, - }); - const competency_groups = await competencyGroupData.map((x) => ({ - id: x.competency_group_id, - level: x.competency_group_level, - name: x.competency_group_name, - description: x.competency_group_description, - })); + const competencyGroupData = await this.assignCompetencyGroupRepository.find({ + select: ["competency_group_id", "competency_group_level", "competency_group_name", "competency_group_description"], + where: { assign_id }, + }) + const competency_groups = await competencyGroupData.map(x => ({ + id: x.competency_group_id, + level: x.competency_group_level, + name: x.competency_group_name, + description: x.competency_group_description, + })) - const outputs = await this.assignOutputRepository.find({ - select: ["id", "output_desc", "indicator_desc"], - where: { assign_id }, - }); + const outputs = await this.assignOutputRepository.find({ + select: ["id", "output_desc", "indicator_desc"], + where: { assign_id }, + }) - const director = await this.assignDirectorRepository.find({ - where: { assign_id }, - order: { ordering: "ASC" }, - }); + const director = await this.assignDirectorRepository.find({ + where: { assign_id }, + order: { ordering: "ASC" }, + }) - let mentors = []; - const mentorList = await director.filter((x) => x.role == "mentor"); - if (mentorList.length > 0) { - for (let index = 0; index < mentorList.length; index++) { - const e = await mentorList[index]; - mentors.push({ - ...e, - name: e.fullname, - label: - e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), - Position: e.position, // report - }); - } - } + let mentors = [] + const mentorList = await director.filter(x => x.role == "mentor") + if (mentorList.length > 0) { + for (let index = 0; index < mentorList.length; index++) { + const e = await mentorList[index] + mentors.push({ + ...e, + name: e.fullname, + label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), + Position: e.position, // report + }) + } + } - const commanderData = await (director.find((x) => x.role == "commander") ?? null); - const commander = await (commanderData - ? { - ...commanderData, - name: commanderData.fullname, - label: - commanderData.fullname + - " " + - (commanderData.position - ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` - : ""), - Position: commanderData.position, // report - } - : null); + const commanderData = await (director.find(x => x.role == "commander") ?? null) + const commander = await (commanderData + ? { + ...commanderData, + name: commanderData.fullname, + label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""), + Position: commanderData.position, // report + } + : null) - const chairmanData = await (director.find((x) => x.role == "chairman") ?? null); - const chairman = await (chairmanData - ? { - ...chairmanData, - name: chairmanData.fullname, - label: - chairmanData.fullname + - " " + - (chairmanData.position - ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` - : ""), - Position: chairmanData.position, // report - } - : null); + const chairmanData = await (director.find(x => x.role == "chairman") ?? null) + const chairman = await (chairmanData + ? { + ...chairmanData, + name: chairmanData.fullname, + label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""), + Position: chairmanData.position, // report + } + : null) - return new HttpSuccess({ - assign, - profile, - jobs, - knowledges, - laws, - skills, - competencys, - competency_groups, - outputs, - mentors, - commander, - chairman, - }); - } + return new HttpSuccess({ + assign, + profile, + jobs, + knowledges, + laws, + skills, + competencys, + competency_groups, + outputs, + mentors, + commander, + chairman, + }) + } } diff --git a/src/controllers/CalculateController.ts b/src/controllers/CalculateController.ts index 0ace989..27ce24b 100644 --- a/src/controllers/CalculateController.ts +++ b/src/controllers/CalculateController.ts @@ -1,47 +1,32 @@ -import { - Controller, - Route, - Security, - Tags, - Request, - SuccessResponse, - Response, - Get, - Post, - Body, -} from "tsoa"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatusCode from "../interfaces/http-status"; -import { RequestWithUser } from "../middlewares/user"; -import { findEndDate } from "../interfaces/utils"; +import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body } from "tsoa" +import HttpSuccess from "../interfaces/http-success" +import HttpStatusCode from "../interfaces/http-status" +import { RequestWithUser } from "../middlewares/user" +import { findEndDate } from "../interfaces/utils" @Route("api/v1/probation/calculate") @Tags("ฟอร์มมอบหมายงาน") @Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") export class CalculateController extends Controller { - /** - * API คำนวนวันสิ้นสุดตามวันที่เริ่มและระยะเวลาเดือนตามที่ส่งค่ามา - * - * @summary คำนวนวันสิ้นสุดตามวันที่เริ่มและระยะเวลาเดือนตามที่ส่งค่ามา - * - */ - @Post("assign-finish") - async AssignFinish( - @Body() - requestBody: { - month: number; - start_date: Date; - }, - @Request() request: RequestWithUser, - ) { - const { month, start_date } = requestBody; - const finish_date = findEndDate(month, start_date); + /** + * API คำนวนวันสิ้นสุดตามวันที่เริ่มและระยะเวลาเดือนตามที่ส่งค่ามา + * + * @summary คำนวนวันสิ้นสุดตามวันที่เริ่มและระยะเวลาเดือนตามที่ส่งค่ามา + * + */ + @Post("assign-finish") + async AssignFinish( + @Body() + requestBody: { + month: number + start_date: Date + }, + @Request() request: RequestWithUser + ) { + const { month, start_date } = requestBody + const finish_date = findEndDate(month, start_date) - return new HttpSuccess({ finish_date }); - } + return new HttpSuccess({ finish_date }) + } } diff --git a/src/controllers/DataOptionsController.ts b/src/controllers/DataOptionsController.ts index 994ed7d..14969ee 100644 --- a/src/controllers/DataOptionsController.ts +++ b/src/controllers/DataOptionsController.ts @@ -1,331 +1,307 @@ -import { - Controller, - Route, - Security, - Tags, - Request, - SuccessResponse, - Response, - Get, - Query, -} from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatusCode from "../interfaces/http-status"; -import HttpError from "../interfaces/http-error"; -import { RequestWithUser } from "../middlewares/user"; -import { Knowledge, TypeKnowledge } from "../entities/Knowledge"; -import { Skill, TypeSkill } from "../entities/Skill"; -import { MapKnowledgeSkill } from "../entities/MapKnowledgeSkill"; -import { Personal } from "../entities/Personal"; -import { Law } from "../entities/Law"; -import { Assign } from "../entities/Assign"; -import permission from "../interfaces/permission"; +import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Query } from "tsoa" +import { AppDataSource } from "../database/data-source" +import HttpSuccess from "../interfaces/http-success" +import HttpStatusCode from "../interfaces/http-status" +import HttpError from "../interfaces/http-error" +import { RequestWithUser } from "../middlewares/user" +import { Knowledge, TypeKnowledge } from "../entities/Knowledge" +import { Skill, TypeSkill } from "../entities/Skill" +import { MapKnowledgeSkill } from "../entities/MapKnowledgeSkill" +import { Personal } from "../entities/Personal" +import { Law } from "../entities/Law" +import { Assign } from "../entities/Assign" +import permission from "../interfaces/permission" @Route("api/v1/probation/data-options") @Tags("Data Options") @Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") export class DataOptionController extends Controller { - private personalRepository = AppDataSource.getRepository(Personal); - private knowledgeRepository = AppDataSource.getRepository(Knowledge); - private mapKnowledgeSkillRepository = AppDataSource.getRepository(MapKnowledgeSkill); - private skillRepository = AppDataSource.getRepository(Skill); - private lawRepository = AppDataSource.getRepository(Law); - private assignRepository = AppDataSource.getRepository(Assign); + private personalRepository = AppDataSource.getRepository(Personal) + private knowledgeRepository = AppDataSource.getRepository(Knowledge) + private mapKnowledgeSkillRepository = AppDataSource.getRepository(MapKnowledgeSkill) + private skillRepository = AppDataSource.getRepository(Skill) + private lawRepository = AppDataSource.getRepository(Law) + private assignRepository = AppDataSource.getRepository(Assign) - /** - * API list รายการความรู้ - * - * @summary options ความรู้ - * - */ - @Get("knowledge") - async GetKnowledge(@Query() personal_id: string) { - const person = await this.personalRepository.findOne({ - where: { personal_id }, - }); + /** + * API list รายการความรู้ + * + * @summary options ความรู้ + * + */ + @Get("knowledge") + async GetKnowledge(@Query() personal_id: string) { + const person = await this.personalRepository.findOne({ + where: { personal_id }, + }) - if (!person) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); - } + if (!person) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล") + } - let result = await this.mapKnowledgeSkillRepository.findOne({ - where: { - positionName: person.positionName, - positionLevelName: person.positionLevelName, - active: 1, - }, - }); + let result = await this.mapKnowledgeSkillRepository.findOne({ + where: { + positionName: person.positionName, + positionLevelName: person.positionLevelName, + active: 1, + }, + }) - if (!result) { - // ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้ - result = await this.mapKnowledgeSkillRepository.findOne({ - where: { - positionLevelName: person.positionLevelName, - active: 1, - }, - }); - } + if (!result) { + // ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้ + result = await this.mapKnowledgeSkillRepository.findOne({ + where: { + positionLevelName: person.positionLevelName, + active: 1, + }, + }) + } - if (!result) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง"); - } + if (!result) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง") + } - const knowledges = await this.knowledgeRepository.find({ - where: { type: TypeKnowledge.PERFORMANCE, active: 1 }, - }); + const knowledges = await this.knowledgeRepository.find({ + where: { type: TypeKnowledge.PERFORMANCE, active: 1 }, + }) - const knowledge = knowledges.map((knowledge) => ({ - id: knowledge.id, - title: knowledge.title, - description: - result.knowlage_performance_level == 1 - ? knowledge.level1 - : result.knowlage_performance_level == 2 - ? knowledge.level2 - : result.knowlage_performance_level == 3 - ? knowledge.level3 - : result.knowlage_performance_level == 4 - ? knowledge.level4 - : knowledge.level5, - level: result.knowlage_performance_level, - })); + const knowledge = knowledges.map(knowledge => ({ + id: knowledge.id, + title: knowledge.title, + description: + result.knowlage_performance_level == 1 + ? knowledge.level1 + : result.knowlage_performance_level == 2 + ? knowledge.level2 + : result.knowlage_performance_level == 3 + ? knowledge.level3 + : result.knowlage_performance_level == 4 + ? knowledge.level4 + : knowledge.level5, + level: result.knowlage_performance_level, + })) - return new HttpSuccess(knowledge); - } + return new HttpSuccess(knowledge) + } - /** - * API ข้อมูลทักษะ - * - * @summary options ทักษะ - * - */ - @Get("skill") - async GetSkill(@Query() personal_id: string) { - const person = await this.personalRepository.findOne({ - where: { personal_id }, - }); + /** + * API ข้อมูลทักษะ + * + * @summary options ทักษะ + * + */ + @Get("skill") + async GetSkill(@Query() personal_id: string) { + const person = await this.personalRepository.findOne({ + where: { personal_id }, + }) - if (!person) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); - } + if (!person) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล") + } - let result = await this.mapKnowledgeSkillRepository.findOne({ - select: [ - "skill_computer_level", - "skill_english_level", - "skill_information_level", - "skill_resourse_level", - ], - where: { - positionName: person.positionName, - positionLevelName: person.positionLevelName, - active: 1, - }, - }); + let result = await this.mapKnowledgeSkillRepository.findOne({ + select: ["skill_computer_level", "skill_english_level", "skill_information_level", "skill_resourse_level"], + where: { + positionName: person.positionName, + positionLevelName: person.positionLevelName, + active: 1, + }, + }) - if (!result) { - // ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้ - result = await this.mapKnowledgeSkillRepository.findOne({ - select: [ - "skill_computer_level", - "skill_english_level", - "skill_information_level", - "skill_resourse_level", - ], - where: { - positionLevelName: person.positionLevelName, - active: 1, - }, - }); - } + if (!result) { + // ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้ + result = await this.mapKnowledgeSkillRepository.findOne({ + select: ["skill_computer_level", "skill_english_level", "skill_information_level", "skill_resourse_level"], + where: { + positionLevelName: person.positionLevelName, + active: 1, + }, + }) + } - if (!result) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง"); - } + if (!result) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง") + } - const computerData = await this.skillRepository.findOne({ - where: { type: TypeSkill.COMPUTER, active: 1 }, - }); + const computerData = await this.skillRepository.findOne({ + where: { type: TypeSkill.COMPUTER, active: 1 }, + }) - if (!computerData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะคอมพิวเตอร์"); - } - const computer = await { - id: computerData.id, - title: computerData.title, - level_description: - result.skill_computer_level == 1 - ? computerData.level1 - : result.skill_computer_level == 2 - ? computerData.level2 - : result.skill_computer_level == 3 - ? computerData.level3 - : result.skill_computer_level == 4 - ? computerData.level4 - : computerData.level5, - level: result.skill_computer_level, - }; + if (!computerData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะคอมพิวเตอร์") + } + const computer = await { + id: computerData.id, + title: computerData.title, + level_description: + result.skill_computer_level == 1 + ? computerData.level1 + : result.skill_computer_level == 2 + ? computerData.level2 + : result.skill_computer_level == 3 + ? computerData.level3 + : result.skill_computer_level == 4 + ? computerData.level4 + : computerData.level5, + level: result.skill_computer_level, + } - const englishData = await this.skillRepository.findOne({ - where: { type: TypeSkill.ENG, active: 1 }, - }); + const englishData = await this.skillRepository.findOne({ + where: { type: TypeSkill.ENG, active: 1 }, + }) - if (!englishData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะภาษาอังกฤษ"); - } + if (!englishData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะภาษาอังกฤษ") + } - const english = await { - id: englishData.id, - title: englishData.title, - level_description: - result.skill_english_level == 1 - ? englishData.level1 - : result.skill_english_level == 2 - ? englishData.level2 - : result.skill_english_level == 3 - ? englishData.level3 - : result.skill_english_level == 4 - ? englishData.level4 - : englishData.level5, - level: result.skill_english_level, - }; + const english = await { + id: englishData.id, + title: englishData.title, + level_description: + result.skill_english_level == 1 + ? englishData.level1 + : result.skill_english_level == 2 + ? englishData.level2 + : result.skill_english_level == 3 + ? englishData.level3 + : result.skill_english_level == 4 + ? englishData.level4 + : englishData.level5, + level: result.skill_english_level, + } - const informationData = await this.skillRepository.findOne({ - where: { type: TypeSkill.INFORMATION, active: 1 }, - }); + const informationData = await this.skillRepository.findOne({ + where: { type: TypeSkill.INFORMATION, active: 1 }, + }) - if (!informationData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); - } + if (!informationData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล") + } - const information = await { - id: informationData.id, - title: informationData.title, - level_description: - result.skill_information_level == 1 - ? informationData.level1 - : result.skill_information_level == 2 - ? informationData.level2 - : result.skill_information_level == 3 - ? informationData.level3 - : result.skill_information_level == 4 - ? informationData.level4 - : informationData.level5, - level: result.skill_information_level, - }; + const information = await { + id: informationData.id, + title: informationData.title, + level_description: + result.skill_information_level == 1 + ? informationData.level1 + : result.skill_information_level == 2 + ? informationData.level2 + : result.skill_information_level == 3 + ? informationData.level3 + : result.skill_information_level == 4 + ? informationData.level4 + : informationData.level5, + level: result.skill_information_level, + } - const resourseData = await this.skillRepository.findOne({ - where: { type: TypeSkill.RESOURSE, active: 1 }, - }); - if (!resourseData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); - } + const resourseData = await this.skillRepository.findOne({ + where: { type: TypeSkill.RESOURSE, active: 1 }, + }) + if (!resourseData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล") + } - const resourse = await { - id: resourseData.id, - title: resourseData.title, - level_description: - result.skill_resourse_level == 1 - ? resourseData.level1 - : result.skill_resourse_level == 2 - ? resourseData.level2 - : result.skill_resourse_level == 3 - ? resourseData.level3 - : result.skill_resourse_level == 4 - ? resourseData.level4 - : resourseData.level5, - level: result.skill_resourse_level, - }; + const resourse = await { + id: resourseData.id, + title: resourseData.title, + level_description: + result.skill_resourse_level == 1 + ? resourseData.level1 + : result.skill_resourse_level == 2 + ? resourseData.level2 + : result.skill_resourse_level == 3 + ? resourseData.level3 + : result.skill_resourse_level == 4 + ? resourseData.level4 + : resourseData.level5, + level: result.skill_resourse_level, + } - return new HttpSuccess({ - computer, - english, - information, - resourse, - }); - } + return new HttpSuccess({ + computer, + english, + information, + resourse, + }) + } - /** - * API list รายการกฎหมาย - * - * @summary options กฎหมาย - * - */ - @Get("law") - async GetLaw(@Query() personal_id: string) { - const results = await this.lawRepository.find({ - select: ["id", "parent_id", "description", "status_select"], - where: { - active: 1, - }, - }); + /** + * API list รายการกฎหมาย + * + * @summary options กฎหมาย + * + */ + @Get("law") + async GetLaw(@Query() personal_id: string) { + const results = await this.lawRepository.find({ + select: ["id", "parent_id", "description", "status_select"], + where: { + active: 1, + }, + }) - if (!results) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); - } + if (!results) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล") + } - const result = await results.map((v) => ({ - ...v, - checked: 0, - })); + const result = await results.map(v => ({ + ...v, + checked: 0, + })) - return new HttpSuccess(result); - } + return new HttpSuccess(result) + } - /** - * API ดึงข้อมูลจำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง - * - * @summary จำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง - * - */ - @Get("new-assign") - async NewAssign(@Query() personal_id: string, @Request() request: RequestWithUser) { - await new permission().PermissionGet(request, "SYS_PROBATION"); + /** + * API ดึงข้อมูลจำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง + * + * @summary จำนวนครั้งแบบมอบหมายงานและข้อมูลผู้ทดลอง + * + */ + @Get("new-assign") + async NewAssign(@Query() personal_id: string, @Request() request: RequestWithUser) { + await new permission().PermissionGet(request, "SYS_PROBATION") - const person = await this.personalRepository.findOne({ - select: [ - "personal_id", - "prefixName", - "firstName", - "lastName", - "posNo", - "positionName", - "positionLevelName", - "positionLineName", - "isProbation", - "orgRootName", - "organization", - "createdAt", - "updatedAt", - ], - where: { personal_id }, - }); + const person = await this.personalRepository.findOne({ + select: [ + "personal_id", + "prefixName", + "firstName", + "lastName", + "posNo", + "positionName", + "positionLevelName", + "positionLineName", + "isProbation", + "orgRootName", + "organization", + "createdAt", + "updatedAt", + ], + where: { personal_id }, + }) - if (!person) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); - } + if (!person) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล") + } - const assign = await this.assignRepository.count({ - where: { - personal_id, - }, - }); + const assign = await this.assignRepository.count({ + where: { + personal_id, + }, + }) - const responsePerson = { - id: person.personal_id, - ...person, - }; + const responsePerson = { + id: person.personal_id, + ...person, + } - return new HttpSuccess({ - person: responsePerson, - assign_no: assign + 1, - assign_month: 6, - }); - } + return new HttpSuccess({ + person: responsePerson, + assign_no: assign + 1, + assign_month: 6, + }) + } } diff --git a/src/controllers/EvaluateChairmanController.ts b/src/controllers/EvaluateChairmanController.ts index a104dc7..a7d1812 100644 --- a/src/controllers/EvaluateChairmanController.ts +++ b/src/controllers/EvaluateChairmanController.ts @@ -1,496 +1,428 @@ -import { - Controller, - Route, - Security, - Tags, - Request, - SuccessResponse, - Response, - Get, - Post, - Body, - Query, - Put, -} from "tsoa"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatusCode from "../interfaces/http-status"; -import { RequestWithUser } from "../middlewares/user"; -import { findEndDate, setLogDataDiff } from "../interfaces/utils"; -import { AppDataSource } from "../database/data-source"; -import { AssignDirector } from "../entities/AssignDirector"; -import HttpError from "../interfaces/http-error"; -import { Assign } from "../entities/Assign"; -import { Personal } from "../entities/Personal"; -import CallAPI from "../interfaces/call-api"; -import { CreateEvaluateChairman, EvaluateChairman } from "../entities/EvaluateChairman"; -import permission from "../interfaces/permission"; +import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query, Put } from "tsoa" +import HttpSuccess from "../interfaces/http-success" +import HttpStatusCode from "../interfaces/http-status" +import { RequestWithUser } from "../middlewares/user" +import { findEndDate, setLogDataDiff } from "../interfaces/utils" +import { AppDataSource } from "../database/data-source" +import { AssignDirector } from "../entities/AssignDirector" +import HttpError from "../interfaces/http-error" +import { Assign } from "../entities/Assign" +import { Personal } from "../entities/Personal" +import CallAPI from "../interfaces/call-api" +import { CreateEvaluateChairman, EvaluateChairman } from "../entities/EvaluateChairman" +import permission from "../interfaces/permission" @Route("api/v1/probation/evaluate-chairman") @Tags("แบบประเมินผล (คณะกรรมการ)") @Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") export class EvaluateChairmanController extends Controller { - private assignDirectorRepository = AppDataSource.getRepository(AssignDirector); - private assignRepository = AppDataSource.getRepository(Assign); - private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman); - private personalRepository = AppDataSource.getRepository(Personal); + private assignDirectorRepository = AppDataSource.getRepository(AssignDirector) + private assignRepository = AppDataSource.getRepository(Assign) + private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman) + private personalRepository = AppDataSource.getRepository(Personal) - /** - * API ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ) - * - * @summary ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ) - * - */ - @Get("create") - async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) { - await new permission().PermissionGet(request, "SYS_PROBATION"); + /** + * API ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ) + * + * @summary ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ) + * + */ + @Get("create") + async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) { + await new permission().PermissionGet(request, "SYS_PROBATION") - const director = await this.assignDirectorRepository.findOne({ - select: ["personal_id"], - where: { - assign_id, - role: "chairman", - }, - }); - if (!director) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); - } - const director_id = director.personal_id; + const director = await this.assignDirectorRepository.findOne({ + select: ["personal_id"], + where: { + assign_id, + role: "chairman", + }, + }) + if (!director) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล") + } + const director_id = director.personal_id - const assign = await this.assignRepository.findOne({ - relations: ["profile"], - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + const assign = await this.assignRepository.findOne({ + relations: ["profile"], + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const profile = await (assign.profile - ? { - ...assign.profile, - id: assign.profile.personal_id, - name: - assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName, - Oc: assign.profile.organization, - } - : null); + const profile = await (assign.profile + ? { + ...assign.profile, + id: assign.profile.personal_id, + name: assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName, + Oc: assign.profile.organization, + } + : null) - const evaluate_amount = await this.evaluateChairmanRepository.count({ - where: { - assign_id, - director_id, - }, - }); - const evaluate_no = await (evaluate_amount + 1); - const start_date = - evaluate_amount == 0 - ? assign.date_start - : findEndDate(evaluate_amount * 3, assign.date_start); + const evaluate_amount = await this.evaluateChairmanRepository.count({ + where: { + assign_id, + director_id, + }, + }) + const evaluate_no = await (evaluate_amount + 1) + const start_date = evaluate_amount == 0 ? assign.date_start : findEndDate(evaluate_amount * 3, assign.date_start) - const directorData = await this.assignDirectorRepository.find({ - where: { assign_id }, - order: { ordering: "ASC" }, - }); + const directorData = await this.assignDirectorRepository.find({ + where: { assign_id }, + order: { ordering: "ASC" }, + }) - if (!directorData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"); - } + if (!directorData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน") + } - let mentors = []; - const mentorList = await directorData.filter((x) => x.role == "mentor"); - if (mentorList.length > 0) { - for (let index = 0; index < mentorList.length; index++) { - const e = await mentorList[index]; + let mentors = [] + const mentorList = await directorData.filter(x => x.role == "mentor") + if (mentorList.length > 0) { + for (let index = 0; index < mentorList.length; index++) { + const e = await mentorList[index] - mentors.push({ - personal_id: e.personal_id, - dated: e.dated, - name: e.fullname, - label: - e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), - position: e.position, - posType: e.posType, - posLevel: e.posLevel, - }); - } - } + mentors.push({ + personal_id: e.personal_id, + dated: e.dated, + name: e.fullname, + label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), + position: e.position, + posType: e.posType, + posLevel: e.posLevel, + }) + } + } - const commanderData = await (directorData.find((x) => x.role == "commander") ?? null); + const commanderData = await (directorData.find(x => x.role == "commander") ?? null) - const commander = - commanderData != null - ? { - personal_id: commanderData.personal_id, - dated: commanderData.dated, - name: commanderData.fullname, - label: - commanderData.fullname + - " " + - (commanderData.position - ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` - : ""), - position: commanderData.position, - posType: commanderData.posType, - posLevel: commanderData.posLevel, - } - : null; + const commander = + commanderData != null + ? { + personal_id: commanderData.personal_id, + dated: commanderData.dated, + name: commanderData.fullname, + label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""), + position: commanderData.position, + posType: commanderData.posType, + posLevel: commanderData.posLevel, + } + : null - const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null); - const chairman = - chairmanData != null - ? { - personal_id: chairmanData.personal_id, - dated: chairmanData.dated, - name: chairmanData.fullname, - label: - chairmanData.fullname + - " " + - (chairmanData.position - ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` - : ""), - position: chairmanData.position, - posType: chairmanData.posType, - posLevel: chairmanData.posLevel, - } - : null; + const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null) + const chairman = + chairmanData != null + ? { + personal_id: chairmanData.personal_id, + dated: chairmanData.dated, + name: chairmanData.fullname, + label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""), + position: chairmanData.position, + posType: chairmanData.posType, + posLevel: chairmanData.posLevel, + } + : null - return new HttpSuccess({ - person: profile ? profile : null, - assign, - evaluate_no: evaluate_no, - start_date: start_date, - end_date: findEndDate(3, start_date), - commander, - mentors, - chairman, - }); - } + return new HttpSuccess({ + person: profile ? profile : null, + assign, + evaluate_no: evaluate_no, + start_date: start_date, + end_date: findEndDate(3, start_date), + commander, + mentors, + chairman, + }) + } - /** - * API ข้อมูลแบบประเมินผล (คณะกรรมการ) - * - * @summary ข้อมูลแบบประเมินผล (คณะกรรมการ) - * - */ - @Get("") - async GetEvaluate( - @Request() request: RequestWithUser, - @Query() assign_id: string, - @Query() evaluate_no?: string, - ) { - await new permission().PermissionGet(request, "SYS_PROBATION"); - // ต้องปรับเป็น id ของคนที่ access เข้ามา - const director = await this.assignDirectorRepository.findOne({ - select: ["personal_id"], - where: { - assign_id, - role: "chairman", - }, - }); - if (!director) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); - } - const director_id = director.personal_id; - let evaluate: any = null; - if (evaluate_no) { - evaluate = await this.evaluateChairmanRepository.findOne({ - where: { - director_id, - assign_id, - no: evaluate_no, - }, - }); - } else { - evaluate = await this.evaluateChairmanRepository.find({ - where: { - director_id, - assign_id, - }, - }); + /** + * API ข้อมูลแบบประเมินผล (คณะกรรมการ) + * + * @summary ข้อมูลแบบประเมินผล (คณะกรรมการ) + * + */ + @Get("") + async GetEvaluate(@Request() request: RequestWithUser, @Query() assign_id: string, @Query() evaluate_no?: string) { + await new permission().PermissionGet(request, "SYS_PROBATION") + // ต้องปรับเป็น id ของคนที่ access เข้ามา + const director = await this.assignDirectorRepository.findOne({ + select: ["personal_id"], + where: { + assign_id, + role: "chairman", + }, + }) + if (!director) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล") + } + const director_id = director.personal_id + let evaluate: any = null + if (evaluate_no) { + evaluate = await this.evaluateChairmanRepository.findOne({ + where: { + director_id, + assign_id, + no: evaluate_no, + }, + }) + } else { + evaluate = await this.evaluateChairmanRepository.find({ + where: { + director_id, + assign_id, + }, + }) - if (evaluate) - evaluate = await evaluate.map((element: EvaluateChairman) => ({ - ...element, - no: Number(element.no), - })); - } + if (evaluate) + evaluate = await evaluate.map((element: EvaluateChairman) => ({ + ...element, + no: Number(element.no), + })) + } - if (!evaluate) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน"); - } + if (!evaluate) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน") + } - const assign = await this.assignRepository.findOne({ - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + const assign = await this.assignRepository.findOne({ + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const experimenteeData = await this.personalRepository.find({ - select: [ - "personal_id", - "prefixName", - "firstName", - "lastName", - "positionName", - "positionLevelName", - "organization", - ], - where: { personal_id: assign.personal_id }, - }); + const experimenteeData = await this.personalRepository.find({ + select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "organization"], + where: { personal_id: assign.personal_id }, + }) - const experimentee = await experimenteeData.map((element) => ({ - ...element, - name: element.prefixName + element.firstName + " " + element.lastName, - Oc: element.organization, - })); + const experimentee = await experimenteeData.map(element => ({ + ...element, + name: element.prefixName + element.firstName + " " + element.lastName, + Oc: element.organization, + })) - const directorData = await this.assignDirectorRepository.find({ - where: { assign_id }, - order: { ordering: "ASC" }, - }); + const directorData = await this.assignDirectorRepository.find({ + where: { assign_id }, + order: { ordering: "ASC" }, + }) - if (!directorData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"); - } + if (!directorData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน") + } - let mentors = []; - const mentorList = await directorData.filter((x) => x.role == "mentor"); - if (mentorList.length > 0) { - for (let index = 0; index < mentorList.length; index++) { - const e = await mentorList[index]; + let mentors = [] + const mentorList = await directorData.filter(x => x.role == "mentor") + if (mentorList.length > 0) { + for (let index = 0; index < mentorList.length; index++) { + const e = await mentorList[index] - mentors.push({ - personal_id: e.personal_id, - dated: e.dated, - name: e.fullname, - label: - e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), - position: e.position, - posType: e.posType, - posLevel: e.posLevel, - }); - } - } + mentors.push({ + personal_id: e.personal_id, + dated: e.dated, + name: e.fullname, + label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), + position: e.position, + posType: e.posType, + posLevel: e.posLevel, + }) + } + } - const commanderData = await (directorData.find((x) => x.role == "commander") ?? null); + const commanderData = await (directorData.find(x => x.role == "commander") ?? null) - const commander = - commanderData != null - ? { - personal_id: commanderData.personal_id, - dated: commanderData.dated, - name: commanderData.fullname, - label: - commanderData.fullname + - " " + - (commanderData.position - ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` - : ""), - position: commanderData.position, - posType: commanderData.posType, - posLevel: commanderData.posLevel, - } - : null; + const commander = + commanderData != null + ? { + personal_id: commanderData.personal_id, + dated: commanderData.dated, + name: commanderData.fullname, + label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""), + position: commanderData.position, + posType: commanderData.posType, + posLevel: commanderData.posLevel, + } + : null - const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null); - const chairman = - chairmanData != null - ? { - personal_id: chairmanData.personal_id, - dated: chairmanData.dated, - name: chairmanData.fullname, - label: - chairmanData.fullname + - " " + - (chairmanData.position - ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` - : ""), - position: chairmanData.position, - posType: chairmanData.posType, - posLevel: chairmanData.posLevel, - } - : null; + const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null) + const chairman = + chairmanData != null + ? { + personal_id: chairmanData.personal_id, + dated: chairmanData.dated, + name: chairmanData.fullname, + label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""), + position: chairmanData.position, + posType: chairmanData.posType, + posLevel: chairmanData.posLevel, + } + : null - return new HttpSuccess({ - experimentee: experimentee, - mentors: mentors, - commander: commander, - chairman: chairman, - assign, - evaluate, - }); - } + return new HttpSuccess({ + experimentee: experimentee, + mentors: mentors, + commander: commander, + chairman: chairman, + assign, + evaluate, + }) + } - /** - * API บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - * @summary บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - */ - @Post("") - async PostData( - @Query() assign_id: string, - @Body() requestBody: CreateEvaluateChairman, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_PROBATION"); + /** + * API บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + * @summary บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + */ + @Post("") + async PostData(@Query() assign_id: string, @Body() requestBody: CreateEvaluateChairman, @Request() request: RequestWithUser) { + await new permission().PermissionUpdate(request, "SYS_PROBATION") - const director = await this.assignDirectorRepository.findOne({ - select: ["personal_id"], - where: { - assign_id, - role: "chairman", - }, - }); - if (!director) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); - } + const director = await this.assignDirectorRepository.findOne({ + select: ["personal_id"], + where: { + assign_id, + role: "chairman", + }, + }) + if (!director) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล") + } - const director_id = director.personal_id; + const director_id = director.personal_id - const assign = await this.assignRepository.findOne({ - relations: ["profile"], - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + const assign = await this.assignRepository.findOne({ + relations: ["profile"], + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const postData: any = await { - assign_id, - ...requestBody, - director_id, - no: requestBody.evaluate_no, - date_start: requestBody.start_date, - personal_id: assign.personal_id, + const postData: any = await { + assign_id, + ...requestBody, + director_id, + no: requestBody.evaluate_no, + date_start: requestBody.start_date, + personal_id: assign.personal_id, - achievement_other_desc: requestBody.achievement_other - ? requestBody.achievement_other.text - : "", - achievement_other_level: requestBody.achievement_other - ? Number(requestBody.achievement_other.level) - : 0, - behavior_other_desc: requestBody.behavior_orther.text, - behavior_other_level: - requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0, + achievement_other_desc: requestBody.achievement_other ? requestBody.achievement_other.text : "", + achievement_other_level: requestBody.achievement_other ? Number(requestBody.achievement_other.level) : 0, + behavior_other_desc: requestBody.behavior_orther.text, + behavior_other_level: requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }; + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + } - await this.evaluateChairmanRepository.save(postData, { - data: request, - }); - setLogDataDiff(request, { before: null, after: postData }); + await this.evaluateChairmanRepository.save(postData, { + data: request, + }) + setLogDataDiff(request, { before: null, after: postData }) - if (Number(requestBody.evaluate_no) < 2) { - // #noted cronjob - // แจ้งประธานเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง - var dateSend = await findEndDate(3, requestBody.start_date); - const nextNo = await (Number(requestBody.evaluate_no) + 1); - await new CallAPI() - .PostData(request, "/placement/noti", { - subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`, - body: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการ (สำหรับคณะกรรมการ) ครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`, - receiverUserId: director_id, - payload: "", - isSendMail: true, - isSendInbox: true, - receiveDate: dateSend, - }) - .catch((error) => { - console.error("Error calling API:", error); - }); - } + if (Number(requestBody.evaluate_no) < 2) { + // #noted cronjob + // แจ้งประธานเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง + var dateSend = await findEndDate(3, requestBody.start_date) + const nextNo = await (Number(requestBody.evaluate_no) + 1) + await new CallAPI() + .PostData(request, "/placement/noti", { + subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`, + body: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการ (สำหรับคณะกรรมการ) ครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`, + receiverUserId: director_id, + payload: "", + isSendMail: true, + isSendInbox: true, + receiveDate: dateSend, + }) + .catch(error => { + console.error("Error calling API:", error) + }) + } - return new HttpSuccess(); - } + return new HttpSuccess() + } - /** - * API แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - * @summary แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - */ - @Put("") - async UpdateData( - // @Query() assign_id: string, - @Query() evaluate_id: string, - @Body() requestBody: CreateEvaluateChairman, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_PROBATION"); + /** + * API แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + * @summary แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + */ + @Put("") + async UpdateData( + // @Query() assign_id: string, + @Query() evaluate_id: string, + @Body() requestBody: CreateEvaluateChairman, + @Request() request: RequestWithUser + ) { + await new permission().PermissionUpdate(request, "SYS_PROBATION") - let evaluate = await this.evaluateChairmanRepository.findOne({ - where: { id: evaluate_id }, - }); + let evaluate = await this.evaluateChairmanRepository.findOne({ + where: { id: evaluate_id }, + }) - const before = evaluate; + const before = evaluate - if (!evaluate) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); - } + if (!evaluate) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน") + } - evaluate.chairman_dated = requestBody.chairman_dated; - evaluate.director1_dated = requestBody.director1_dated; - evaluate.director2_dated = requestBody.director2_dated; - evaluate.knowledge_level = requestBody.knowledge_level; - evaluate.apply_level = requestBody.apply_level; - evaluate.success_level = requestBody.success_level; - evaluate.achievement_other_desc = requestBody.achievement_other - ? requestBody.achievement_other.text - : ""; - evaluate.achievement_other_level = - requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0; + evaluate.chairman_dated = requestBody.chairman_dated + evaluate.director1_dated = requestBody.director1_dated + evaluate.director2_dated = requestBody.director2_dated + evaluate.knowledge_level = requestBody.knowledge_level + evaluate.apply_level = requestBody.apply_level + evaluate.success_level = requestBody.success_level + evaluate.achievement_other_desc = requestBody.achievement_other ? requestBody.achievement_other.text : "" + evaluate.achievement_other_level = requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0 - evaluate.conduct1_level = requestBody.conduct1_level; - evaluate.conduct2_level = requestBody.conduct2_level; - evaluate.conduct3_level = requestBody.conduct3_level; - evaluate.conduct4_level = requestBody.conduct4_level; - evaluate.moral1_level = requestBody.moral1_level; - evaluate.moral2_level = requestBody.moral2_level; - evaluate.moral3_level = requestBody.moral3_level; - evaluate.discipline1_level = requestBody.discipline1_level; - evaluate.discipline2_level = requestBody.discipline2_level; - evaluate.discipline3_level = requestBody.discipline3_level; - evaluate.discipline4_level = requestBody.discipline4_level; - evaluate.discipline5_level = requestBody.discipline5_level; - evaluate.behavior_other_desc = requestBody.behavior_orther.text; - evaluate.behavior_other_level = - requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0; - evaluate.develop_orientation_score = requestBody.develop_orientation_score; - evaluate.develop_self_learning_score = requestBody.develop_self_learning_score; - evaluate.develop_training_seminar_score = requestBody.develop_training_seminar_score; - evaluate.develop_other_training_score = requestBody.develop_other_training_score; - evaluate.develop_orientation_percent = requestBody.develop_orientation_percent; - evaluate.develop_self_learning_percent = requestBody.develop_self_learning_percent; - evaluate.develop_training_seminar_percent = requestBody.develop_training_seminar_percent; - evaluate.develop_other_training_percent = requestBody.develop_other_training_percent; - evaluate.develop_result = requestBody.develop_result; - evaluate.achievement_score = requestBody.achievement_score; - evaluate.achievement_score_total = requestBody.achievement_score_total; - evaluate.achievement_percent = requestBody.achievement_percent; - evaluate.achievement_result = requestBody.achievement_result; - evaluate.behavior_score = requestBody.behavior_score; - evaluate.behavior_score_total = requestBody.behavior_score_total; - evaluate.behavior_percent = requestBody.behavior_percent; - evaluate.behavior_result = requestBody.behavior_result; - evaluate.sum_score = requestBody.sum_score; - evaluate.sum_percent = requestBody.sum_percent; - evaluate.evaluate_result = requestBody.evaluate_result; + evaluate.conduct1_level = requestBody.conduct1_level + evaluate.conduct2_level = requestBody.conduct2_level + evaluate.conduct3_level = requestBody.conduct3_level + evaluate.conduct4_level = requestBody.conduct4_level + evaluate.moral1_level = requestBody.moral1_level + evaluate.moral2_level = requestBody.moral2_level + evaluate.moral3_level = requestBody.moral3_level + evaluate.discipline1_level = requestBody.discipline1_level + evaluate.discipline2_level = requestBody.discipline2_level + evaluate.discipline3_level = requestBody.discipline3_level + evaluate.discipline4_level = requestBody.discipline4_level + evaluate.discipline5_level = requestBody.discipline5_level + evaluate.behavior_other_desc = requestBody.behavior_orther.text + evaluate.behavior_other_level = requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0 + evaluate.develop_orientation_score = requestBody.develop_orientation_score + evaluate.develop_self_learning_score = requestBody.develop_self_learning_score + evaluate.develop_training_seminar_score = requestBody.develop_training_seminar_score + evaluate.develop_other_training_score = requestBody.develop_other_training_score + evaluate.develop_orientation_percent = requestBody.develop_orientation_percent + evaluate.develop_self_learning_percent = requestBody.develop_self_learning_percent + evaluate.develop_training_seminar_percent = requestBody.develop_training_seminar_percent + evaluate.develop_other_training_percent = requestBody.develop_other_training_percent + evaluate.develop_result = requestBody.develop_result + evaluate.achievement_score = requestBody.achievement_score + evaluate.achievement_score_total = requestBody.achievement_score_total + evaluate.achievement_percent = requestBody.achievement_percent + evaluate.achievement_result = requestBody.achievement_result + evaluate.behavior_score = requestBody.behavior_score + evaluate.behavior_score_total = requestBody.behavior_score_total + evaluate.behavior_percent = requestBody.behavior_percent + evaluate.behavior_result = requestBody.behavior_result + evaluate.sum_score = requestBody.sum_score + evaluate.sum_percent = requestBody.sum_percent + evaluate.evaluate_result = requestBody.evaluate_result - evaluate.updateUserId = request.user.sub; - evaluate.updateFullName = request.user.name; + evaluate.updateUserId = request.user.sub + evaluate.updateFullName = request.user.name - await this.evaluateChairmanRepository.save(evaluate, { data: request }); - setLogDataDiff(request, { before, after: evaluate }); + await this.evaluateChairmanRepository.save(evaluate, { data: request }) + setLogDataDiff(request, { before, after: evaluate }) - return new HttpSuccess(); - } + return new HttpSuccess() + } } diff --git a/src/controllers/EvaluateController.ts b/src/controllers/EvaluateController.ts index a784d44..b08d60f 100644 --- a/src/controllers/EvaluateController.ts +++ b/src/controllers/EvaluateController.ts @@ -1,394 +1,348 @@ -import { - Controller, - Route, - Security, - Tags, - Request, - SuccessResponse, - Response, - Get, - Post, - Body, - Query, - Put, -} from "tsoa"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatusCode from "../interfaces/http-status"; -import { RequestWithUser } from "../middlewares/user"; -import { findEndDate, setLogDataDiff } from "../interfaces/utils"; -import { AppDataSource } from "../database/data-source"; -import { AssignDirector } from "../entities/AssignDirector"; -import HttpError from "../interfaces/http-error"; -import { Assign } from "../entities/Assign"; -import { CreateEvaluateCommander, EvaluateCommander } from "../entities/EvaluateCommander"; -import { Personal } from "../entities/Personal"; -import CallAPI from "../interfaces/call-api"; -import permission from "../interfaces/permission"; +import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query, Put } from "tsoa" +import HttpSuccess from "../interfaces/http-success" +import HttpStatusCode from "../interfaces/http-status" +import { RequestWithUser } from "../middlewares/user" +import { findEndDate, setLogDataDiff } from "../interfaces/utils" +import { AppDataSource } from "../database/data-source" +import { AssignDirector } from "../entities/AssignDirector" +import HttpError from "../interfaces/http-error" +import { Assign } from "../entities/Assign" +import { CreateEvaluateCommander, EvaluateCommander } from "../entities/EvaluateCommander" +import { Personal } from "../entities/Personal" +import CallAPI from "../interfaces/call-api" +import permission from "../interfaces/permission" @Route("api/v1/probation/evaluate") @Tags("แบบประเมินผล (ผู้บังคับบัญชา)") @Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") export class EvaluateController extends Controller { - private assignDirectorRepository = AppDataSource.getRepository(AssignDirector); - private assignRepository = AppDataSource.getRepository(Assign); - private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander); - private personalRepository = AppDataSource.getRepository(Personal); + private assignDirectorRepository = AppDataSource.getRepository(AssignDirector) + private assignRepository = AppDataSource.getRepository(Assign) + private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander) + private personalRepository = AppDataSource.getRepository(Personal) - /** - * API ข้อมูลตอนกดสร้างแบบประเมินผล (ผู้บังคับบัญชา) - * - * @summary ข้อมูลตอนกดสร้างแบบประเมินผล (ผู้บังคับบัญชา) - * - */ - @Get("create") - async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) { - await new permission().PermissionGet(request, "SYS_PROBATION"); + /** + * API ข้อมูลตอนกดสร้างแบบประเมินผล (ผู้บังคับบัญชา) + * + * @summary ข้อมูลตอนกดสร้างแบบประเมินผล (ผู้บังคับบัญชา) + * + */ + @Get("create") + async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) { + await new permission().PermissionGet(request, "SYS_PROBATION") - const director = await this.assignDirectorRepository.findOne({ - select: ["personal_id"], - where: { - assign_id, - role: "commander", - }, - }); - if (!director) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); - } - const director_id = director.personal_id; + const director = await this.assignDirectorRepository.findOne({ + select: ["personal_id"], + where: { + assign_id, + role: "commander", + }, + }) + if (!director) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล") + } + const director_id = director.personal_id - const assign = await this.assignRepository.findOne({ - relations: ["profile"], - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + const assign = await this.assignRepository.findOne({ + relations: ["profile"], + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const profile = await (assign.profile - ? { - ...assign.profile, - id: assign.profile.personal_id, - name: - assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName, - Oc: assign.profile.organization, - } - : null); + const profile = await (assign.profile + ? { + ...assign.profile, + id: assign.profile.personal_id, + name: assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName, + Oc: assign.profile.organization, + } + : null) - const evaluate_amount = await this.evaluateCommanderRepository.count({ - where: { - assign_id, - director_id, - }, - }); - const evaluate_no = await (evaluate_amount + 1); - const start_date = - evaluate_amount == 0 - ? assign.date_start - : findEndDate(evaluate_amount * 3, assign.date_start); + const evaluate_amount = await this.evaluateCommanderRepository.count({ + where: { + assign_id, + director_id, + }, + }) + const evaluate_no = await (evaluate_amount + 1) + const start_date = evaluate_amount == 0 ? assign.date_start : findEndDate(evaluate_amount * 3, assign.date_start) - const commanderData = await this.assignDirectorRepository.findOne({ - select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"], - where: { personal_id: director_id }, - }); - if (!commanderData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา"); - } - const commander = await { - ...commanderData, - name: commanderData.fullname, - label: `${commanderData.fullname} (${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`, - }; + const commanderData = await this.assignDirectorRepository.findOne({ + select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"], + where: { personal_id: director_id }, + }) + if (!commanderData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา") + } + const commander = await { + ...commanderData, + name: commanderData.fullname, + label: `${commanderData.fullname} (${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`, + } - return new HttpSuccess({ - person: profile, - assign, - evaluate_no: evaluate_no, - start_date: start_date, - end_date: findEndDate(3, start_date), - director: commander, - }); - } + return new HttpSuccess({ + person: profile, + assign, + evaluate_no: evaluate_no, + start_date: start_date, + end_date: findEndDate(3, start_date), + director: commander, + }) + } - /** - * API ข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - * @summary ข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - */ - @Get("") - async GetEvaluate( - @Request() request: RequestWithUser, - @Query() assign_id: string, - @Query() evaluate_no?: string, - ) { - await new permission().PermissionGet(request, "SYS_PROBATION"); + /** + * API ข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + * @summary ข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + */ + @Get("") + async GetEvaluate(@Request() request: RequestWithUser, @Query() assign_id: string, @Query() evaluate_no?: string) { + await new permission().PermissionGet(request, "SYS_PROBATION") - // ต้องปรับเป็น id ของคนที่ access เข้ามา - const director = await this.assignDirectorRepository.findOne({ - select: ["personal_id"], - where: { - assign_id, - role: "commander", - }, - }); - if (!director) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); - } - const director_id = director.personal_id; - let evaluate: any = null; - if (evaluate_no) { - evaluate = await this.evaluateCommanderRepository.findOne({ - where: { - director_id, - assign_id, - no: evaluate_no, - }, - }); - } else { - evaluate = await this.evaluateCommanderRepository.find({ - where: { - director_id, - assign_id, - }, - }); + // ต้องปรับเป็น id ของคนที่ access เข้ามา + const director = await this.assignDirectorRepository.findOne({ + select: ["personal_id"], + where: { + assign_id, + role: "commander", + }, + }) + if (!director) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล") + } + const director_id = director.personal_id + let evaluate: any = null + if (evaluate_no) { + evaluate = await this.evaluateCommanderRepository.findOne({ + where: { + director_id, + assign_id, + no: evaluate_no, + }, + }) + } else { + evaluate = await this.evaluateCommanderRepository.find({ + where: { + director_id, + assign_id, + }, + }) - if (evaluate) - evaluate = await evaluate.map((element: EvaluateCommander) => ({ - ...element, - no: Number(element.no), - })); - } + if (evaluate) + evaluate = await evaluate.map((element: EvaluateCommander) => ({ + ...element, + no: Number(element.no), + })) + } - if (!evaluate) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน"); - } + if (!evaluate) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน") + } - const assign = await this.assignRepository.findOne({ - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + const assign = await this.assignRepository.findOne({ + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - // const profile = await (assign.profile - // ? { - // ...assign.profile, - // id: assign.profile.personal_id, - // name: - // assign.profile.prefixName + - // assign.profile.firstName + - // " " + - // assign.profile.lastName, - // Oc: assign.profile.organization, - // } - // : null); + // const profile = await (assign.profile + // ? { + // ...assign.profile, + // id: assign.profile.personal_id, + // name: + // assign.profile.prefixName + + // assign.profile.firstName + + // " " + + // assign.profile.lastName, + // Oc: assign.profile.organization, + // } + // : null); - // const evaluate_amount = await this.evaluateCommanderRepository.count({ - // where: { - // assign_id, - // director_id, - // }, - // }); - // const evaluate_no = await (evaluate_amount + 1); - // const start_date = - // evaluate_amount == 0 - // ? assign.date_start - // : findEndDate(evaluate_amount * 3, assign.date_start); + // const evaluate_amount = await this.evaluateCommanderRepository.count({ + // where: { + // assign_id, + // director_id, + // }, + // }); + // const evaluate_no = await (evaluate_amount + 1); + // const start_date = + // evaluate_amount == 0 + // ? assign.date_start + // : findEndDate(evaluate_amount * 3, assign.date_start); - const directorData = await this.assignDirectorRepository.find({ - select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"], - where: { personal_id: director_id }, - }); + const directorData = await this.assignDirectorRepository.find({ + select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"], + where: { personal_id: director_id }, + }) - const directors = await directorData.map((element) => ({ - ...element, - name: element.fullname, - label: `${element.fullname} (${element.position}, ${element.posType}: ${element.posLevel})`, - })); + const directors = await directorData.map(element => ({ + ...element, + name: element.fullname, + label: `${element.fullname} (${element.position}, ${element.posType}: ${element.posLevel})`, + })) - const experimenteeData = await this.personalRepository.find({ - select: [ - "personal_id", - "prefixName", - "firstName", - "lastName", - "positionName", - "positionLevelName", - "organization", - ], - where: { personal_id: assign.personal_id }, - }); + const experimenteeData = await this.personalRepository.find({ + select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "organization"], + where: { personal_id: assign.personal_id }, + }) - const experimentee = await experimenteeData.map((element) => ({ - ...element, - name: element.prefixName + element.firstName + " " + element.lastName, - Oc: element.organization, - })); + const experimentee = await experimenteeData.map(element => ({ + ...element, + name: element.prefixName + element.firstName + " " + element.lastName, + Oc: element.organization, + })) - return new HttpSuccess({ - experimentee: experimentee, - director: directors ? directors : null, - assign, - evaluate, - }); - } + return new HttpSuccess({ + experimentee: experimentee, + director: directors ? directors : null, + assign, + evaluate, + }) + } - /** - * API บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - * @summary บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - */ - @Post("") - async PostData( - @Query() assign_id: string, - @Body() requestBody: CreateEvaluateCommander, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_PROBATION"); + /** + * API บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + * @summary บันทึกข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + */ + @Post("") + async PostData(@Query() assign_id: string, @Body() requestBody: CreateEvaluateCommander, @Request() request: RequestWithUser) { + await new permission().PermissionUpdate(request, "SYS_PROBATION") - const director = await this.assignDirectorRepository.findOne({ - select: ["personal_id"], - where: { - assign_id, - role: "commander", - }, - }); - if (!director) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); - } + const director = await this.assignDirectorRepository.findOne({ + select: ["personal_id"], + where: { + assign_id, + role: "commander", + }, + }) + if (!director) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล") + } - const director_id = director.personal_id; + const director_id = director.personal_id - const assign = await this.assignRepository.findOne({ - relations: ["profile"], - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + const assign = await this.assignRepository.findOne({ + relations: ["profile"], + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const postData: any = await { - assign_id, - ...requestBody, - director_id, - no: requestBody.evaluate_no, - date_start: requestBody.start_date, - personal_id: assign.personal_id, + const postData: any = await { + assign_id, + ...requestBody, + director_id, + no: requestBody.evaluate_no, + date_start: requestBody.start_date, + personal_id: assign.personal_id, - achievement_other_desc: requestBody.achievement_other - ? requestBody.achievement_other.text - : "", - achievement_other_level: requestBody.achievement_other - ? Number(requestBody.achievement_other.level) - : 0, - behavior_other_desc: requestBody.behavior_orther.text, - behavior_other_level: - requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0, + achievement_other_desc: requestBody.achievement_other ? requestBody.achievement_other.text : "", + achievement_other_level: requestBody.achievement_other ? Number(requestBody.achievement_other.level) : 0, + behavior_other_desc: requestBody.behavior_orther.text, + behavior_other_level: requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }; + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + } - await this.evaluateCommanderRepository.save(postData, { - data: request, - }); - setLogDataDiff(request, { before: null, after: postData }); + await this.evaluateCommanderRepository.save(postData, { + data: request, + }) + setLogDataDiff(request, { before: null, after: postData }) - if (Number(requestBody.evaluate_no) < 2) { - // #noted cronjob - // แจ้งผู้บังคับบัญชาเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง - var dateSend = await findEndDate(3, requestBody.start_date); - const nextNo = await (Number(requestBody.evaluate_no) + 1); - await new CallAPI() - .PostData(request, "/placement/noti", { - subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`, - body: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการ (สำหรับผู้บังคับบัญชา) ครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`, - receiverUserId: director_id, - payload: "", - isSendMail: true, - isSendInbox: true, - receiveDate: dateSend, - }) - .catch((error) => { - console.error("Error calling API:", error); - }); - } + if (Number(requestBody.evaluate_no) < 2) { + // #noted cronjob + // แจ้งผู้บังคับบัญชาเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง + var dateSend = await findEndDate(3, requestBody.start_date) + const nextNo = await (Number(requestBody.evaluate_no) + 1) + await new CallAPI() + .PostData(request, "/placement/noti", { + subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`, + body: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการ (สำหรับผู้บังคับบัญชา) ครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`, + receiverUserId: director_id, + payload: "", + isSendMail: true, + isSendInbox: true, + receiveDate: dateSend, + }) + .catch(error => { + console.error("Error calling API:", error) + }) + } - return new HttpSuccess(); - } + return new HttpSuccess() + } - /** - * API แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - * @summary แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) - * - */ - @Put("") - async UpdateData( - // @Query() assign_id: string, - @Query() evaluate_id: string, - @Body() requestBody: CreateEvaluateCommander, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_PROBATION"); + /** + * API แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + * @summary แก้ไขข้อมูลแบบประเมินผล (ผู้บังคับบัญชา) + * + */ + @Put("") + async UpdateData( + // @Query() assign_id: string, + @Query() evaluate_id: string, + @Body() requestBody: CreateEvaluateCommander, + @Request() request: RequestWithUser + ) { + await new permission().PermissionUpdate(request, "SYS_PROBATION") - let evaluate = await this.evaluateCommanderRepository.findOne({ - where: { id: evaluate_id }, - }); + let evaluate = await this.evaluateCommanderRepository.findOne({ + where: { id: evaluate_id }, + }) - const before = evaluate; + const before = evaluate - if (!evaluate) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); - } + if (!evaluate) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน") + } - evaluate.commander_dated = requestBody.commander_dated; - evaluate.knowledge_level = requestBody.knowledge_level; - evaluate.skill_level = requestBody.skill_level; - evaluate.competency_level = requestBody.competency_level; - evaluate.learn_level = requestBody.learn_level; - evaluate.apply_level = requestBody.apply_level; - evaluate.success_level = requestBody.success_level; - evaluate.achievement_other_desc = requestBody.achievement_other - ? requestBody.achievement_other.text - : ""; - evaluate.achievement_other_level = - requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0; + evaluate.commander_dated = requestBody.commander_dated + evaluate.knowledge_level = requestBody.knowledge_level + evaluate.skill_level = requestBody.skill_level + evaluate.competency_level = requestBody.competency_level + evaluate.learn_level = requestBody.learn_level + evaluate.apply_level = requestBody.apply_level + evaluate.success_level = requestBody.success_level + evaluate.achievement_other_desc = requestBody.achievement_other ? requestBody.achievement_other.text : "" + evaluate.achievement_other_level = requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0 - evaluate.conduct1_level = requestBody.conduct1_level; - evaluate.conduct2_level = requestBody.conduct2_level; - evaluate.conduct3_level = requestBody.conduct3_level; - evaluate.conduct4_level = requestBody.conduct4_level; - evaluate.moral1_level = requestBody.moral1_level; - evaluate.moral2_level = requestBody.moral2_level; - evaluate.moral3_level = requestBody.moral3_level; - evaluate.discipline1_level = requestBody.discipline1_level; - evaluate.discipline2_level = requestBody.discipline2_level; - evaluate.discipline3_level = requestBody.discipline3_level; - evaluate.discipline4_level = requestBody.discipline4_level; - evaluate.discipline5_level = requestBody.discipline5_level; - evaluate.behavior_other_desc = requestBody.behavior_orther.text; - evaluate.behavior_other_level = - requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0; - evaluate.behavior_strength_desc = requestBody.behavior_strength_desc; - evaluate.behavior_improve_desc = requestBody.behavior_improve_desc; - evaluate.orientation = requestBody.orientation; - evaluate.self_learning = requestBody.self_learning; - evaluate.training_seminar = requestBody.training_seminar; - evaluate.other_training = requestBody.other_training; - evaluate.updateUserId = request.user.sub; - evaluate.updateFullName = request.user.name; + evaluate.conduct1_level = requestBody.conduct1_level + evaluate.conduct2_level = requestBody.conduct2_level + evaluate.conduct3_level = requestBody.conduct3_level + evaluate.conduct4_level = requestBody.conduct4_level + evaluate.moral1_level = requestBody.moral1_level + evaluate.moral2_level = requestBody.moral2_level + evaluate.moral3_level = requestBody.moral3_level + evaluate.discipline1_level = requestBody.discipline1_level + evaluate.discipline2_level = requestBody.discipline2_level + evaluate.discipline3_level = requestBody.discipline3_level + evaluate.discipline4_level = requestBody.discipline4_level + evaluate.discipline5_level = requestBody.discipline5_level + evaluate.behavior_other_desc = requestBody.behavior_orther.text + evaluate.behavior_other_level = requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0 + evaluate.behavior_strength_desc = requestBody.behavior_strength_desc + evaluate.behavior_improve_desc = requestBody.behavior_improve_desc + evaluate.orientation = requestBody.orientation + evaluate.self_learning = requestBody.self_learning + evaluate.training_seminar = requestBody.training_seminar + evaluate.other_training = requestBody.other_training + evaluate.updateUserId = request.user.sub + evaluate.updateFullName = request.user.name - await this.evaluateCommanderRepository.save(evaluate, { data: request }); - setLogDataDiff(request, { before, after: evaluate }); + await this.evaluateCommanderRepository.save(evaluate, { data: request }) + setLogDataDiff(request, { before, after: evaluate }) - return new HttpSuccess(); - } + return new HttpSuccess() + } } diff --git a/src/controllers/EvaluateRecordController.ts b/src/controllers/EvaluateRecordController.ts index 48c01af..33f1f81 100644 --- a/src/controllers/EvaluateRecordController.ts +++ b/src/controllers/EvaluateRecordController.ts @@ -33,7 +33,6 @@ import permission from "../interfaces/permission"; HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", ) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") export class EvaluateRecordController extends Controller { private assignDirectorRepository = AppDataSource.getRepository(AssignDirector); private assignRepository = AppDataSource.getRepository(Assign); diff --git a/src/controllers/EvaluateResultController.ts b/src/controllers/EvaluateResultController.ts index c740f2e..a6e23b5 100644 --- a/src/controllers/EvaluateResultController.ts +++ b/src/controllers/EvaluateResultController.ts @@ -1,502 +1,418 @@ -import { - Controller, - Route, - Security, - Tags, - Request, - SuccessResponse, - Response, - Get, - Post, - Body, - Query, - Put, -} from "tsoa"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatusCode from "../interfaces/http-status"; -import { RequestWithUser } from "../middlewares/user"; -import { setLogDataDiff } from "../interfaces/utils"; -import { AppDataSource } from "../database/data-source"; -import { AssignDirector } from "../entities/AssignDirector"; -import HttpError from "../interfaces/http-error"; -import { Assign } from "../entities/Assign"; -import { Personal } from "../entities/Personal"; -import CallAPI from "../interfaces/call-api"; -import { EvaluateChairman } from "../entities/EvaluateChairman"; -import { CreateEvaluateResult, EvaluateResult } from "../entities/EvaluateResult"; -import permission from "../interfaces/permission"; +import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query, Put } from "tsoa" +import HttpSuccess from "../interfaces/http-success" +import HttpStatusCode from "../interfaces/http-status" +import { RequestWithUser } from "../middlewares/user" +import { setLogDataDiff } from "../interfaces/utils" +import { AppDataSource } from "../database/data-source" +import { AssignDirector } from "../entities/AssignDirector" +import HttpError from "../interfaces/http-error" +import { Assign } from "../entities/Assign" +import { Personal } from "../entities/Personal" +import CallAPI from "../interfaces/call-api" +import { EvaluateChairman } from "../entities/EvaluateChairman" +import { CreateEvaluateResult, EvaluateResult } from "../entities/EvaluateResult" +import permission from "../interfaces/permission" @Route("api/v1/probation/evaluate-result") @Tags("แบบรายงานการประเมินฯ") @Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") export class EvaluateResultController extends Controller { - private assignDirectorRepository = AppDataSource.getRepository(AssignDirector); - private assignRepository = AppDataSource.getRepository(Assign); - private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman); - private personalRepository = AppDataSource.getRepository(Personal); - private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult); + private assignDirectorRepository = AppDataSource.getRepository(AssignDirector) + private assignRepository = AppDataSource.getRepository(Assign) + private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman) + private personalRepository = AppDataSource.getRepository(Personal) + private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult) - /** - * API ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ - * - * @summary ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ - * - */ - @Get("create") - async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) { - await new permission().PermissionGet(request, "SYS_PROBATION"); + /** + * API ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ + * + * @summary ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ + * + */ + @Get("create") + async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) { + await new permission().PermissionGet(request, "SYS_PROBATION") - const assign = await this.assignRepository.findOne({ - relations: ["profile"], - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + const assign = await this.assignRepository.findOne({ + relations: ["profile"], + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const profile = await (assign.profile - ? { - ...assign.profile, - id: assign.profile.personal_id, - name: - assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName, - Oc: assign.profile.organization, - } - : null); + const profile = await (assign.profile + ? { + ...assign.profile, + id: assign.profile.personal_id, + name: assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName, + Oc: assign.profile.organization, + } + : null) - const directorData = await this.assignDirectorRepository.find({ - where: { assign_id }, - order: { ordering: "ASC" }, - }); + const directorData = await this.assignDirectorRepository.find({ + where: { assign_id }, + order: { ordering: "ASC" }, + }) - if (!directorData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"); - } + if (!directorData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน") + } - let mentors = []; - const mentorList = await directorData.filter((x) => x.role == "mentor"); - if (mentorList.length > 0) { - for (let index = 0; index < mentorList.length; index++) { - const e = await mentorList[index]; + let mentors = [] + const mentorList = await directorData.filter(x => x.role == "mentor") + if (mentorList.length > 0) { + for (let index = 0; index < mentorList.length; index++) { + const e = await mentorList[index] - mentors.push({ - personal_id: e.personal_id, - dated: e.dated, - name: e.fullname, - label: - e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), - position: e.position, - posType: e.posType, - posLevel: e.posLevel, - }); - } - } + mentors.push({ + personal_id: e.personal_id, + dated: e.dated, + name: e.fullname, + label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), + position: e.position, + posType: e.posType, + posLevel: e.posLevel, + }) + } + } - const commanderData = await (directorData.find((x) => x.role == "commander") ?? null); + const commanderData = await (directorData.find(x => x.role == "commander") ?? null) - const commander = - commanderData != null - ? { - personal_id: commanderData.personal_id, - dated: commanderData.dated, - name: commanderData.fullname, - label: - commanderData.fullname + - " " + - (commanderData.position - ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` - : ""), - position: commanderData.position, - posType: commanderData.posType, - posLevel: commanderData.posLevel, - } - : null; + const commander = + commanderData != null + ? { + personal_id: commanderData.personal_id, + dated: commanderData.dated, + name: commanderData.fullname, + label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""), + position: commanderData.position, + posType: commanderData.posType, + posLevel: commanderData.posLevel, + } + : null - const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null); - const chairman = - chairmanData != null - ? { - personal_id: chairmanData.personal_id, - dated: chairmanData.dated, - name: chairmanData.fullname, - label: - chairmanData.fullname + - " " + - (chairmanData.position - ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` - : ""), - position: chairmanData.position, - posType: chairmanData.posType, - posLevel: chairmanData.posLevel, - } - : null; + const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null) + const chairman = + chairmanData != null + ? { + personal_id: chairmanData.personal_id, + dated: chairmanData.dated, + name: chairmanData.fullname, + label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""), + position: chairmanData.position, + posType: chairmanData.posType, + posLevel: chairmanData.posLevel, + } + : null - const resultData = await this.evaluateChairmanRepository.findOne({ - select: [ - "develop_orientation_score", - "develop_self_learning_score", - "develop_training_seminar_score", - "evaluate_result", - ], - where: { - assign_id, - }, - }); + const resultData = await this.evaluateChairmanRepository.findOne({ + select: ["develop_orientation_score", "develop_self_learning_score", "develop_training_seminar_score", "evaluate_result"], + where: { + assign_id, + }, + }) - if (!resultData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมินผล"); - } + if (!resultData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมินผล") + } - const develop_complete = await (resultData.develop_orientation_score > 0 && - resultData.develop_self_learning_score > 0 && - resultData.develop_training_seminar_score > 0 - ? 1 - : 2); + const develop_complete = await (resultData.develop_orientation_score > 0 && resultData.develop_self_learning_score > 0 && resultData.develop_training_seminar_score > 0 ? 1 : 2) - const evaluate_result = await (resultData.evaluate_result == 1 ? 1 : 2); + const evaluate_result = await (resultData.evaluate_result == 1 ? 1 : 2) - const result = await { - develop_complete: develop_complete, - evaluate_result: evaluate_result, - }; + const result = await { + develop_complete: develop_complete, + evaluate_result: evaluate_result, + } - return new HttpSuccess({ - person: profile, - assign, - result, - mentors, - commander, - chairman, - }); - } + return new HttpSuccess({ + person: profile, + assign, + result, + mentors, + commander, + chairman, + }) + } - /** - * API ข้อมูลแบบรายงานการประเมินฯ - * - * @summary ข้อมูลแบบรายงานการประเมินฯ - * - */ - @Get("") - async GetEvaluate( - @Request() request: RequestWithUser, - @Query() assign_id: string, - @Query() evaluate_no?: string, - ) { - await new permission().PermissionGet(request, "SYS_PROBATION"); + /** + * API ข้อมูลแบบรายงานการประเมินฯ + * + * @summary ข้อมูลแบบรายงานการประเมินฯ + * + */ + @Get("") + async GetEvaluate(@Request() request: RequestWithUser, @Query() assign_id: string, @Query() evaluate_no?: string) { + await new permission().PermissionGet(request, "SYS_PROBATION") - // ต้องปรับเป็น id ของคนที่ access เข้ามา - const director = await this.assignDirectorRepository.findOne({ - select: ["personal_id"], - where: { - assign_id, - role: "chairman", - }, - }); - if (!director) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); - } - const director_id = director.personal_id; + // ต้องปรับเป็น id ของคนที่ access เข้ามา + const director = await this.assignDirectorRepository.findOne({ + select: ["personal_id"], + where: { + assign_id, + role: "chairman", + }, + }) + if (!director) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล") + } + const director_id = director.personal_id - const evaluate = await this.evaluateResultRepository.findOne({ - where: { - director_id, - assign_id, - }, - }); + const evaluate = await this.evaluateResultRepository.findOne({ + where: { + director_id, + assign_id, + }, + }) - if (!evaluate) { - return new HttpSuccess(null); - } + if (!evaluate) { + return new HttpSuccess(null) + } - const assign = await this.assignRepository.findOne({ - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + const assign = await this.assignRepository.findOne({ + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const experimenteeData = await this.personalRepository.findOne({ - select: [ - "personal_id", - "prefixName", - "firstName", - "lastName", - "positionName", - "positionLevelName", - "organization", - ], - where: { personal_id: assign.personal_id }, - }); + const experimenteeData = await this.personalRepository.findOne({ + select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "organization"], + where: { personal_id: assign.personal_id }, + }) - if (!experimenteeData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); - } - const experimentee = await { - ...experimenteeData, - name: - experimenteeData.prefixName + experimenteeData.firstName + " " + experimenteeData.lastName, - Oc: experimenteeData.organization, - }; + if (!experimenteeData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล") + } + const experimentee = await { + ...experimenteeData, + name: experimenteeData.prefixName + experimenteeData.firstName + " " + experimenteeData.lastName, + Oc: experimenteeData.organization, + } - const directorData = await this.assignDirectorRepository.find({ - where: { assign_id }, - order: { ordering: "ASC" }, - }); + const directorData = await this.assignDirectorRepository.find({ + where: { assign_id }, + order: { ordering: "ASC" }, + }) - if (!directorData) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน"); - } + if (!directorData) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน") + } - let mentors = []; - const mentorList = await directorData.filter((x) => x.role == "mentor"); - if (mentorList.length > 0) { - for (let index = 0; index < mentorList.length; index++) { - const e = await mentorList[index]; + let mentors = [] + const mentorList = await directorData.filter(x => x.role == "mentor") + if (mentorList.length > 0) { + for (let index = 0; index < mentorList.length; index++) { + const e = await mentorList[index] - mentors.push({ - personal_id: e.personal_id, - dated: e.dated, - name: e.fullname, - label: - e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), - position: e.position, - posType: e.posType, - posLevel: e.posLevel, - }); - } - } + mentors.push({ + personal_id: e.personal_id, + dated: e.dated, + name: e.fullname, + label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""), + position: e.position, + posType: e.posType, + posLevel: e.posLevel, + }) + } + } - const commanderData = await (directorData.find((x) => x.role == "commander") ?? null); + const commanderData = await (directorData.find(x => x.role == "commander") ?? null) - const commander = - commanderData != null - ? { - personal_id: commanderData.personal_id, - dated: commanderData.dated, - name: commanderData.fullname, - label: - commanderData.fullname + - " " + - (commanderData.position - ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` - : ""), - position: commanderData.position, - posType: commanderData.posType, - posLevel: commanderData.posLevel, - } - : null; + const commander = + commanderData != null + ? { + personal_id: commanderData.personal_id, + dated: commanderData.dated, + name: commanderData.fullname, + label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""), + position: commanderData.position, + posType: commanderData.posType, + posLevel: commanderData.posLevel, + } + : null - const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null); - const chairman = - chairmanData != null - ? { - personal_id: chairmanData.personal_id, - dated: chairmanData.dated, - name: chairmanData.fullname, - label: - chairmanData.fullname + - " " + - (chairmanData.position - ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` - : ""), - position: chairmanData.position, - posType: chairmanData.posType, - posLevel: chairmanData.posLevel, - } - : null; + const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null) + const chairman = + chairmanData != null + ? { + personal_id: chairmanData.personal_id, + dated: chairmanData.dated, + name: chairmanData.fullname, + label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""), + position: chairmanData.position, + posType: chairmanData.posType, + posLevel: chairmanData.posLevel, + } + : null - return new HttpSuccess({ - commander, - chairman, - mentors, - experimentee, - assign, - evaluate: evaluate, - }); - } + return new HttpSuccess({ + commander, + chairman, + mentors, + experimentee, + assign, + evaluate: evaluate, + }) + } - /** - * API บันทึกข้อมูลแบบรายงานการประเมินฯ - * - * @summary บันทึกข้อมูลแบบรายงานการประเมินฯ - * - */ - @Post("") - async PostData( - @Query() assign_id: string, - @Body() requestBody: CreateEvaluateResult, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_PROBATION"); + /** + * API บันทึกข้อมูลแบบรายงานการประเมินฯ + * + * @summary บันทึกข้อมูลแบบรายงานการประเมินฯ + * + */ + @Post("") + async PostData(@Query() assign_id: string, @Body() requestBody: CreateEvaluateResult, @Request() request: RequestWithUser) { + await new permission().PermissionUpdate(request, "SYS_PROBATION") - const director = await this.assignDirectorRepository.findOne({ - select: ["personal_id"], - where: { - assign_id, - role: "chairman", - }, - }); - if (!director) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล"); - } + const director = await this.assignDirectorRepository.findOne({ + select: ["personal_id"], + where: { + assign_id, + role: "chairman", + }, + }) + if (!director) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล") + } - const director_id = director.personal_id; + const director_id = director.personal_id - const assign = await this.assignRepository.findOne({ - relations: ["profile"], - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } + const assign = await this.assignRepository.findOne({ + relations: ["profile"], + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } - const postData: any = await { - assign_id, - ...requestBody, - director_id, - no: 1, - personal_id: assign.personal_id, - date_start: requestBody.start_date, - expand_month: requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0, + const postData: any = await { + assign_id, + ...requestBody, + director_id, + no: 1, + personal_id: assign.personal_id, + date_start: requestBody.start_date, + expand_month: requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0, - createdUserId: request.user.sub, - createdFullName: request.user.name, - updateUserId: request.user.sub, - updateFullName: request.user.name, - }; + createdUserId: request.user.sub, + createdFullName: request.user.name, + updateUserId: request.user.sub, + updateFullName: request.user.name, + } - await this.evaluateResultRepository.save(postData, { - data: request, - }); - setLogDataDiff(request, { before: null, after: postData }); + await this.evaluateResultRepository.save(postData, { + data: request, + }) + setLogDataDiff(request, { before: null, after: postData }) - const personal = await this.personalRepository.findOne({ - where: { personal_id: assign.personal_id }, - }); + const personal = await this.personalRepository.findOne({ + where: { personal_id: assign.personal_id }, + }) - if (!personal) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); - } - personal.probation_status = - requestBody.pass_result == 1 - ? 2 - : requestBody.pass_result == 2 - ? 3 - : personal.probation_status; + if (!personal) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล") + } + personal.probation_status = requestBody.pass_result == 1 ? 2 : requestBody.pass_result == 2 ? 3 : personal.probation_status - if (requestBody.pass_result == 3) { - personal.probation_status = 7; - // #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา - await new CallAPI() - .PostData(request, "/placement/noti", { - subject: "ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ", - body: `ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ เห็นควรให้ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก ${requestBody.expand_month} เดือน`, - receiverUserId: assign.personal_id, - payload: "", - isSendMail: false, - isSendInbox: true, - isSendNotification: true, - }) - .catch((error) => { - console.error("Error calling API:", error); - }); - } + if (requestBody.pass_result == 3) { + personal.probation_status = 7 + // #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา + await new CallAPI() + .PostData(request, "/placement/noti", { + subject: "ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ", + body: `ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ เห็นควรให้ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก ${requestBody.expand_month} เดือน`, + receiverUserId: assign.personal_id, + payload: "", + isSendMail: false, + isSendInbox: true, + isSendNotification: true, + }) + .catch(error => { + console.error("Error calling API:", error) + }) + } - await this.personalRepository.save(personal, { data: request }); + await this.personalRepository.save(personal, { data: request }) - return new HttpSuccess(); - } + return new HttpSuccess() + } - /** - * API แก้ไขข้อมูลแบบรายงานการประเมินฯ - * - * @summary แก้ไขข้อมูลแบบรายงานการประเมินฯ - * - */ - @Put("") - async UpdateData( - @Query() assign_id: string, - @Query() evaluate_id: string, - @Body() requestBody: CreateEvaluateResult, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_PROBATION"); + /** + * API แก้ไขข้อมูลแบบรายงานการประเมินฯ + * + * @summary แก้ไขข้อมูลแบบรายงานการประเมินฯ + * + */ + @Put("") + async UpdateData(@Query() assign_id: string, @Query() evaluate_id: string, @Body() requestBody: CreateEvaluateResult, @Request() request: RequestWithUser) { + await new permission().PermissionUpdate(request, "SYS_PROBATION") - let evaluate = await this.evaluateResultRepository.findOne({ - where: { id: evaluate_id }, - }); + let evaluate = await this.evaluateResultRepository.findOne({ + where: { id: evaluate_id }, + }) - const before = evaluate; + const before = evaluate - if (!evaluate) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); - } + if (!evaluate) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน") + } - evaluate.date_start = requestBody.start_date; - evaluate.date_finish = requestBody.date_finish; - evaluate.develop_complete = requestBody.develop_complete; - evaluate.pass_result = requestBody.pass_result; - evaluate.expand_month = - requestBody.pass_result && requestBody.pass_result == 3 - ? Number(requestBody.expand_month) - : 0; - evaluate.reson = requestBody.reson; - evaluate.chairman_dated = requestBody.chairman_dated; + evaluate.date_start = requestBody.start_date + evaluate.date_finish = requestBody.date_finish + evaluate.develop_complete = requestBody.develop_complete + evaluate.pass_result = requestBody.pass_result + evaluate.expand_month = requestBody.pass_result && requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0 + evaluate.reson = requestBody.reson + evaluate.chairman_dated = requestBody.chairman_dated - evaluate.director1_dated = requestBody.director1_dated; - evaluate.director2_dated = requestBody.director2_dated; - evaluate.updateUserId = request.user.sub; - evaluate.updateFullName = request.user.name; + evaluate.director1_dated = requestBody.director1_dated + evaluate.director2_dated = requestBody.director2_dated + evaluate.updateUserId = request.user.sub + evaluate.updateFullName = request.user.name - await this.evaluateResultRepository.save(evaluate, { data: request }); - setLogDataDiff(request, { before, after: evaluate }); + await this.evaluateResultRepository.save(evaluate, { data: request }) + setLogDataDiff(request, { before, after: evaluate }) - const assign = await this.assignRepository.findOne({ - relations: ["profile"], - where: { id: assign_id }, - }); - if (!assign) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน"); - } - const personal = await this.personalRepository.findOne({ - where: { personal_id: assign.personal_id }, - }); + const assign = await this.assignRepository.findOne({ + relations: ["profile"], + where: { id: assign_id }, + }) + if (!assign) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน") + } + const personal = await this.personalRepository.findOne({ + where: { personal_id: assign.personal_id }, + }) - if (!personal) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); - } - personal.probation_status = - requestBody.pass_result == 1 - ? 2 - : requestBody.pass_result == 2 - ? 3 - : personal.probation_status; + if (!personal) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล") + } + personal.probation_status = requestBody.pass_result == 1 ? 2 : requestBody.pass_result == 2 ? 3 : personal.probation_status - if (requestBody.pass_result == 3) { - personal.probation_status = 7; - // #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา - await new CallAPI() - .PostData(request, "/placement/noti", { - subject: "ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ", - body: `ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ เห็นควรให้ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก ${requestBody.expand_month} เดือน`, - receiverUserId: assign.personal_id, - payload: "", - isSendMail: false, - isSendInbox: true, - isSendNotification: true, - }) - .catch((error) => { - console.error("Error calling API:", error); - }); - } + if (requestBody.pass_result == 3) { + personal.probation_status = 7 + // #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา + await new CallAPI() + .PostData(request, "/placement/noti", { + subject: "ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ", + body: `ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ เห็นควรให้ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการต่อไปอีก ${requestBody.expand_month} เดือน`, + receiverUserId: assign.personal_id, + payload: "", + isSendMail: false, + isSendInbox: true, + isSendNotification: true, + }) + .catch(error => { + console.error("Error calling API:", error) + }) + } - await this.personalRepository.save(personal, { data: request }); + await this.personalRepository.save(personal, { data: request }) - return new HttpSuccess(); - } + return new HttpSuccess() + } } diff --git a/src/controllers/PersonalController.ts b/src/controllers/PersonalController.ts index d4e4af0..21c015c 100644 --- a/src/controllers/PersonalController.ts +++ b/src/controllers/PersonalController.ts @@ -1,215 +1,166 @@ -import { - Controller, - Post, - Route, - Security, - Tags, - Body, - Request, - SuccessResponse, - Response, - Get, - Query, -} from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatusCode from "../interfaces/http-status"; -import HttpError from "../interfaces/http-error"; -import { RequestWithUser } from "../middlewares/user"; -import { setLogDataDiff } from "../interfaces/utils"; -import { Personal, PostPersonal } from "../entities/Personal"; -import permission from "../interfaces/permission"; -import { Assign } from "../entities/Assign"; +import { Controller, Post, Route, Security, Tags, Body, Request, SuccessResponse, Response, Get, Query } from "tsoa" +import { AppDataSource } from "../database/data-source" +import HttpSuccess from "../interfaces/http-success" +import HttpStatusCode from "../interfaces/http-status" +import HttpError from "../interfaces/http-error" +import { RequestWithUser } from "../middlewares/user" +import { setLogDataDiff } from "../interfaces/utils" +import { Personal, PostPersonal } from "../entities/Personal" +import permission from "../interfaces/permission" +import { Assign } from "../entities/Assign" @Route("api/v1/probation/personal") @Tags("Personal") @Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง" -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") export class PersonalController extends Controller { - private personalRepository = AppDataSource.getRepository(Personal); - private assignRepository = AppDataSource.getRepository(Assign); + private personalRepository = AppDataSource.getRepository(Personal) + private assignRepository = AppDataSource.getRepository(Assign) - /** - * API ข้อมูลบุคคลในระบบทดลองงาน - * - * @summary เพิ่มคนเข้าระบบทดลองงาน - * - */ - @Post("add") - async AddPersonal( - @Body() requestBody: PostPersonal, - @Request() request: RequestWithUser - ) { - await new permission().PermissionCreate(request, "SYS_PROBATION"); + /** + * API ข้อมูลบุคคลในระบบทดลองงาน + * + * @summary เพิ่มคนเข้าระบบทดลองงาน + * + */ + @Post("add") + async AddPersonal(@Body() requestBody: PostPersonal, @Request() request: RequestWithUser) { + await new permission().PermissionCreate(request, "SYS_PROBATION") - const checkPersonal: number = await this.personalRepository.count({ - where: { personal_id: requestBody.id }, - }); - if (checkPersonal > 0) { - throw new HttpError( - HttpStatusCode.BAD_REQUEST, - "ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว" - ); - } + const checkPersonal: number = await this.personalRepository.count({ + where: { personal_id: requestBody.id }, + }) + if (checkPersonal > 0) { + throw new HttpError(HttpStatusCode.BAD_REQUEST, "ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว") + } - let organization = await (requestBody.orgChild4Name - ? requestBody.orgChild4Name + "/" - : ""); - organization += await (requestBody.orgChild3Name - ? requestBody.orgChild3Name + "/" - : ""); - organization += await (requestBody.orgChild2Name - ? requestBody.orgChild2Name + "/" - : ""); - organization += await (requestBody.orgChild1Name - ? requestBody.orgChild1Name + "/" - : ""); - organization += await (requestBody.orgRootName - ? requestBody.orgRootName - : ""); + let organization = await (requestBody.orgChild4Name ? requestBody.orgChild4Name + "/" : "") + organization += await (requestBody.orgChild3Name ? requestBody.orgChild3Name + "/" : "") + organization += await (requestBody.orgChild2Name ? requestBody.orgChild2Name + "/" : "") + organization += await (requestBody.orgChild1Name ? requestBody.orgChild1Name + "/" : "") + organization += await (requestBody.orgRootName ? requestBody.orgRootName : "") - const personalData = Object.assign(new Personal()); - personalData.personal_id = requestBody.id; - personalData.order_number = requestBody.order_number - ? requestBody.order_number - : ""; - personalData.probation_status = 1; - personalData.createdUserId = request.user.sub; - personalData.createdFullName = request.user.name; - personalData.updateUserId = request.user.sub; - personalData.updateFullName = request.user.name; + const personalData = Object.assign(new Personal()) + personalData.personal_id = requestBody.id + personalData.order_number = requestBody.order_number ? requestBody.order_number : "" + personalData.probation_status = 1 + personalData.createdUserId = request.user.sub + personalData.createdFullName = request.user.name + personalData.updateUserId = request.user.sub + personalData.updateFullName = request.user.name - personalData.idcard = requestBody.idcard; - personalData.prefixName = requestBody.prefix; - personalData.firstName = requestBody.firstName; - personalData.lastName = requestBody.lastName; - personalData.isProbation = requestBody.isProbation ? 1 : 0; - personalData.positionLevelName = requestBody.posLevelName - ? requestBody.posLevelName - : ""; - personalData.positionName = requestBody.position - ? requestBody.position - : ""; - personalData.positionLineName = requestBody.posLineName; - personalData.positionTypeName = requestBody.posTypeName; - personalData.posNo = requestBody.posNo ? requestBody.posNo : ""; - personalData.orgRootName = requestBody.orgRootName; - personalData.organization = organization; + personalData.idcard = requestBody.idcard + personalData.prefixName = requestBody.prefix + personalData.firstName = requestBody.firstName + personalData.lastName = requestBody.lastName + personalData.isProbation = requestBody.isProbation ? 1 : 0 + personalData.positionLevelName = requestBody.posLevelName ? requestBody.posLevelName : "" + personalData.positionName = requestBody.position ? requestBody.position : "" + personalData.positionLineName = requestBody.posLineName + personalData.positionTypeName = requestBody.posTypeName + personalData.posNo = requestBody.posNo ? requestBody.posNo : "" + personalData.orgRootName = requestBody.orgRootName + personalData.organization = organization - const before = null; - const personal = await this.personalRepository.save(personalData, { - data: request, - }); - setLogDataDiff(request, { before, after: personal }); + const before = null + const personal = await this.personalRepository.save(personalData, { + data: request, + }) + setLogDataDiff(request, { before, after: personal }) - return new HttpSuccess(); - } + return new HttpSuccess() + } - /** - * API รายการบุคคลในระบบทดลองงาน - * - * @summary รายชื่อคนที่อยู่ในระบบทดลองงาน - * - */ - @Get("list") - async ListPersonal( - @Query() status: string = "", - @Query("page") page: number = 1, - @Query("pageSize") pageSize: number = 10, - @Request() request: RequestWithUser - ) { - await new permission().PermissionList(request, "SYS_PROBATION"); - const conditions: any = {}; - if (status) { - conditions.probation_status = status; - } + /** + * API รายการบุคคลในระบบทดลองงาน + * + * @summary รายชื่อคนที่อยู่ในระบบทดลองงาน + * + */ + @Get("list") + async ListPersonal(@Query() status: string = "", @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Request() request: RequestWithUser) { + await new permission().PermissionList(request, "SYS_PROBATION") + const conditions: any = {} + if (status) { + conditions.probation_status = status + } - const [lists, total] = await this.personalRepository.findAndCount({ - order: { createdAt: "DESC" }, - where: conditions, - skip: (page - 1) * pageSize, - take: pageSize, - }); + const [lists, total] = await this.personalRepository.findAndCount({ + order: { createdAt: "DESC" }, + where: conditions, + skip: (page - 1) * pageSize, + take: pageSize, + }) - if (!lists) { - throw new HttpError( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "ไม่สามารถแสดงข้อมูลได้" - ); - } + if (!lists) { + throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ไม่สามารถแสดงข้อมูลได้") + } - let result: any = []; + let result: any = [] - await Promise.all( - lists.map(async (item, index) => { - const probation_no = await this.assignRepository.count({ - where: { - personal_id: item.personal_id, - }, - }); + await Promise.all( + lists.map(async (item, index) => { + const probation_no = await this.assignRepository.count({ + where: { + personal_id: item.personal_id, + }, + }) - await result.push({ - personal_id: item.personal_id, - ordering: index + 1, - name: item.prefixName + item.firstName + " " + item.lastName, - idcard: item.idcard, - prefixName: item.prefixName, - firstName: item.firstName, - lastName: item.lastName, - position_line: item.positionName, - position_level: item.positionLevelName, - position_type: item.positionTypeName, - organization: item.organization, - probation_no: probation_no, - order_number: item.order_number, - probation_status: item.probation_status, - }); - }) - ); + await result.push({ + personal_id: item.personal_id, + ordering: index + 1, + name: item.prefixName + item.firstName + " " + item.lastName, + idcard: item.idcard, + prefixName: item.prefixName, + firstName: item.firstName, + lastName: item.lastName, + position_line: item.positionName, + position_level: item.positionLevelName, + position_type: item.positionTypeName, + organization: item.organization, + probation_no: probation_no, + order_number: item.order_number, + probation_status: item.probation_status, + }) + }) + ) - return new HttpSuccess({ data: result, total: total }); - } + return new HttpSuccess({ data: result, total: total }) + } - /** - * API ข้อมูลบุคคลในระบบทดลองงาน - * - * @summary ข้อมูลคนที่อยูาในระบบทดลองงาน - * - */ - @Get("") - async GetPersonal( - @Request() request: RequestWithUser, - @Query() personal_id: string - ) { - await new permission().PermissionGet(request, "SYS_PROBATION"); - const person = await this.personalRepository.findOne({ - where: { personal_id: personal_id }, - }); + /** + * API ข้อมูลบุคคลในระบบทดลองงาน + * + * @summary ข้อมูลคนที่อยูาในระบบทดลองงาน + * + */ + @Get("") + async GetPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) { + await new permission().PermissionGet(request, "SYS_PROBATION") + const person = await this.personalRepository.findOne({ + where: { personal_id: personal_id }, + }) - if (!person) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล"); - } + if (!person) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล") + } - const probation_no = await this.assignRepository.count({ - where: { personal_id: person.personal_id }, - }); + const probation_no = await this.assignRepository.count({ + where: { personal_id: person.personal_id }, + }) - const result = await { - personal_id: person.personal_id, - name: person.prefixName + person.firstName + " " + person.lastName, - position_line: person.positionName, - position_level: person.positionLevelName, - position_type: person.positionTypeName, - organization: person.organization, - probation_no: probation_no, - order_number: person.order_number, - probation_status: person.probation_status, - }; + const result = await { + personal_id: person.personal_id, + name: person.prefixName + person.firstName + " " + person.lastName, + position_line: person.positionName, + position_level: person.positionLevelName, + position_type: person.positionTypeName, + organization: person.organization, + probation_no: probation_no, + order_number: person.order_number, + probation_status: person.probation_status, + } - return new HttpSuccess(result); - } + return new HttpSuccess(result) + } } diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index d708e8d..48627c3 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -22,7 +22,6 @@ import { Appoint } from "../entities/Appoint" @Tags("Report") @Security("bearerAuth") @Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") export class ReportController extends Controller { private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman) private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult) diff --git a/src/controllers/SurveyController.ts b/src/controllers/SurveyController.ts index 3a471fb..1b7933b 100644 --- a/src/controllers/SurveyController.ts +++ b/src/controllers/SurveyController.ts @@ -1,67 +1,47 @@ -import { - Controller, - Route, - Security, - Tags, - Request, - SuccessResponse, - Response, - Get, - Post, - Body, - Query, -} from "tsoa"; -import HttpSuccess from "../interfaces/http-success"; -import HttpStatusCode from "../interfaces/http-status"; -import { RequestWithUser } from "../middlewares/user"; -import { setLogDataDiff } from "../interfaces/utils"; -import { Survey } from "../entities/Survey"; -import { AppDataSource } from "../database/data-source"; +import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query } from "tsoa" +import HttpSuccess from "../interfaces/http-success" +import HttpStatusCode from "../interfaces/http-status" +import { RequestWithUser } from "../middlewares/user" +import { setLogDataDiff } from "../interfaces/utils" +import { Survey } from "../entities/Survey" +import { AppDataSource } from "../database/data-source" @Route("api/v1/probation/survey") @Tags("Survey") @Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง") export class SurveyController extends Controller { - private surveyRepository = AppDataSource.getRepository(Survey); + private surveyRepository = AppDataSource.getRepository(Survey) - /** - * API แบบสำรวจความคิดเห็น - * - * @summary แบบสำรวจความคิดเห็น - * - */ - @Get("") - async GetSurvey(@Query() assign_id: string) { - const data = await this.surveyRepository.findOne({ - where: { - assign_id, - }, - }); - return new HttpSuccess(data); - } + /** + * API แบบสำรวจความคิดเห็น + * + * @summary แบบสำรวจความคิดเห็น + * + */ + @Get("") + async GetSurvey(@Query() assign_id: string) { + const data = await this.surveyRepository.findOne({ + where: { + assign_id, + }, + }) + return new HttpSuccess(data) + } - /** - * API บันทึกแบบสำรวจความคิดเห็น - * - * @summary บันทึกแบบสำรวจความคิดเห็น - * - */ - @Post("") - async PostSurvey( - @Query() assign_id: string, - @Body() requestBody: any, - @Request() request: RequestWithUser, - ) { - const before = null; - const data = await { ...requestBody, personal_id: request.user.sub, assign_id }; - await this.surveyRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: data }); + /** + * API บันทึกแบบสำรวจความคิดเห็น + * + * @summary บันทึกแบบสำรวจความคิดเห็น + * + */ + @Post("") + async PostSurvey(@Query() assign_id: string, @Body() requestBody: any, @Request() request: RequestWithUser) { + const before = null + const data = await { ...requestBody, personal_id: request.user.sub, assign_id } + await this.surveyRepository.save(data, { data: request }) + setLogDataDiff(request, { before, after: data }) - return new HttpSuccess(); - } + return new HttpSuccess() + } }