diff --git a/.forejo/workflows/build.yml b/.forejo/workflows/build.yml new file mode 100644 index 0000000..c4746ff --- /dev/null +++ b/.forejo/workflows/build.yml @@ -0,0 +1,50 @@ +# /.forgejo/workflows/build.yml +name: Build + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + - "v[0-9]+.[0-9]+.[0-9]+*" + workflow_dispatch: + +env: + REGISTRY: ${{ vars.CONTAINER_REGISTRY }} + REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}/${{ vars.CONTAINER_IMAGE_NAME }} + IMAGE_VERSION: build + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + config-inline: | + [registry."${{ env.REGISTRY }}"] + ca=["/etc/ssl/certs/ca-certificates.crt"] + - name: Tag Version + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + echo "IMAGE_VERSION=${{ github.ref_name }}" | sed 's/v//g' >> $GITHUB_ENV + else + echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV + fi + - name: Login in to registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ env.REGISTRY_PASSWORD }} + - name: Build and push docker image + uses: docker/build-push-action@v3 + with: + platforms: linux/amd64 + context: . + file: ./docker/Dockerfile + tags: ${{ env.CONTAINER_IMAGE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}:${{ env.IMAGE_VERSION }} + push: true \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0d19c5a..59bae3b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,5 +1,5 @@ -name: release -run-name: release ${{ github.actor }} +name: release-test +run-name: release-test ${{ github.actor }} on: push: tags: @@ -7,13 +7,12 @@ on: workflow_dispatch: env: REGISTRY: docker.frappet.com - IMAGE_NAME: ehr/bma-ehr-development-service - DEPLOY_HOST: frappet.com - COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-development - + IMAGE_NAME: ehr/bma-ehr-org-service + DEPLOY_HOST: 192.168.1.80 + COMPOSE_PATH: /home/frappet/docker/bma-ehr jobs: # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd - release: + release-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -52,7 +51,6 @@ jobs: with: context: . platforms: linux/amd64 - file: docker/Dockerfile push: true tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest - name: Remote Deployment @@ -61,46 +59,27 @@ jobs: host: ${{env.DEPLOY_HOST}} username: frappet password: ${{ secrets.SSH_PASSWORD }} - port: 10102 + port: 22 script: | cd "${{env.COMPOSE_PATH}}" - docker compose pull - docker compose up -d + docker-compose pull + docker-compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - name: Notify Discord Success + - uses: snow-actions/line-notify@v1.1.0 if: success() - run: | - curl -H "Content-Type: application/json" \ - -X POST \ - -d '{ - "embeds": [{ - "title": "✅ Deployment Success!", - "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`", - "color": 3066993, - "footer": { - "text": "Release Notification", - "icon_url": "https://example.com/success-icon.png" - }, - "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" - }] - }' \ - ${{ secrets.DISCORD_WEBHOOK }} - - - name: Notify Discord Failure + with: + access_token: ${{ secrets.TOKEN_LINE }} + message: | + -Success✅✅✅ + Image: ${{env.IMAGE_NAME}} + Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} + By: ${{secrets.DOCKER_USER}} + - uses: snow-actions/line-notify@v1.1.0 if: failure() - run: | - curl -H "Content-Type: application/json" \ - -X POST \ - -d '{ - "embeds": [{ - "title": "❌ Deployment Failed!", - "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`", - "color": 15158332, - "footer": { - "text": "Release Notification", - "icon_url": "https://example.com/failure-icon.png" - }, - "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" - }] - }' \ - ${{ secrets.DISCORD_WEBHOOK }} + with: + access_token: ${{ secrets.TOKEN_LINE }} + message: | + -Failure❌❌❌ + Image: ${{env.IMAGE_NAME}} + Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} + By: ${{secrets.DOCKER_USER}} diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml deleted file mode 100644 index 0eef9fb..0000000 --- a/.onedev-buildspec.yml +++ /dev/null @@ -1,102 +0,0 @@ -version: 37 -jobs: -- name: CI for UAT - steps: - - !CheckoutStep - name: checkout code - cloneCredential: !DefaultCredential {} - withLfs: false - withSubmodules: false - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !GenerateChecksumStep - name: generate package checksum - files: package-lock.json yarn.lock - targetFile: checksum - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !SetupCacheStep - name: set up npm cache - key: node_modules_@file:checksum@ - loadKeys: - - node_modules - paths: - - node_modules - uploadStrategy: UPLOAD_IF_NOT_HIT - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !SetBuildVersionStep - name: set build version - buildVersion: '@tag@' - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !CommandStep - name: build & test - runInContainer: true - image: node - interpreter: !DefaultInterpreter - commands: | - npm install - npm run build - useTTY: true - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !BuildImageStep - name: build docker image - dockerfile: ./docker/Dockerfile - output: !RegistryOutput - tags: hrms-git.chin.in.th/bma-hrms/hrms-api-dev:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-dev:latest - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - triggers: - - !TagCreateTrigger - tags: uat-* - branches: main - retryCondition: never - maxRetries: 3 - retryDelay: 30 - timeout: 14400 -- name: CI for PROD - steps: - - !CheckoutStep - name: checkout code - cloneCredential: !DefaultCredential {} - withLfs: false - withSubmodules: false - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !GenerateChecksumStep - name: generate package checksum - files: package-lock.json yarn.lock - targetFile: checksum - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !SetupCacheStep - name: set up npm cache - key: node_modules_@file:checksum@ - loadKeys: - - node_modules - paths: - - node_modules - uploadStrategy: UPLOAD_IF_NOT_HIT - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !SetBuildVersionStep - name: set build version - buildVersion: '@tag@' - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !CommandStep - name: build & test - runInContainer: true - image: node - interpreter: !DefaultInterpreter - commands: | - npm install - npm run build - useTTY: true - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !BuildImageStep - name: build docker image - dockerfile: ./docker/Dockerfile - output: !RegistryOutput - tags: hrms-git.bangkok.go.th/bma-hrms/hrms-api-dev:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-api-dev:latest - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - triggers: - - !TagCreateTrigger - tags: prod-* - branches: main - retryCondition: never - maxRetries: 3 - retryDelay: 30 - timeout: 14400 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4ca0f48 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM node:18-alpine as builder + +# Create app directory +WORKDIR /app + +# Install app dependencies +COPY package*.json ./ + +RUN npm ci + +COPY . . + +RUN npm run build + +FROM node:18-alpine + +ENV NODE_ENV production +USER node + +# Create app directory +WORKDIR /app + +# Install app dependencies +COPY package*.json ./ +# COPY .env ./ + +RUN npm ci --production + +COPY --from=builder /app/dist ./dist + +# COPY entrypoint.sh /usr/local/bin/entrypoint.sh +# RUN chmod u+x /usr/local/bin/entrypoint.sh + +# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] +CMD [ "node", "dist/app.js" ] \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 07492be..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Build Stage -FROM node:lts-alpine AS build-stage - -# Create app directory -WORKDIR /app - -# Install app dependencies -COPY package*.json ./ - -RUN npm ci - -# Copy source files and build the app -COPY . . -RUN npm run build - -# Production Stage -FROM node:lts-alpine - -ENV NODE_ENV production -USER node - -# Create app directory -WORKDIR /app - -# Copy built app from build stage -COPY --from=build-stage /app/dist ./dist - -# Install only production dependencies -COPY package*.json ./ -RUN npm ci --production - -# Define the entrypoint and default command -# If you have a custom entrypoint script -CMD [ "node", "dist/app.js" ] diff --git a/package-lock.json b/package-lock.json index 4ec9070..303f4cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,25 +9,19 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@elastic/elasticsearch": "^8.14.0", - "@nestjs/platform-express": "^10.3.7", "@tsoa/runtime": "^6.0.0", - "axios": "^1.6.8", "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.18.2", "fast-jwt": "^3.3.2", - "multer": "^1.4.5-lts.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", - "xlsx": "^0.18.5" + "typeorm-cli": "^1.0.7" }, "devDependencies": { "@types/cors": "^2.8.17", @@ -53,66 +47,6 @@ "node": ">=12" } }, - "node_modules/@elastic/elasticsearch": { - "version": "8.14.0", - "resolved": "https://registry.npmjs.org/@elastic/elasticsearch/-/elasticsearch-8.14.0.tgz", - "integrity": "sha512-MGrgCI4y+Ozssf5Q2IkVJlqt5bUMnKIICG2qxeOfrJNrVugMCBCAQypyesmSSocAtNm8IX3LxfJ3jQlFHmKe2w==", - "license": "Apache-2.0", - "dependencies": { - "@elastic/transport": "^8.6.0", - "tslib": "^2.4.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@elastic/transport": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@elastic/transport/-/transport-8.7.0.tgz", - "integrity": "sha512-IqXT7a8DZPJtqP2qmX1I2QKmxYyN27kvSW4g6pInESE1SuGwZDp2FxHJ6W2kwmYOJwQdAt+2aWwzXO5jHo9l4A==", - "license": "Apache-2.0", - "dependencies": { - "@opentelemetry/api": "1.x", - "debug": "^4.3.4", - "hpagent": "^1.0.0", - "ms": "^2.1.3", - "secure-json-parse": "^2.4.0", - "tslib": "^2.4.0", - "undici": "^6.12.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@elastic/transport/node_modules/debug": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", - "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/@elastic/transport/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==", - "license": "MIT" - }, - "node_modules/@elastic/transport/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -154,15 +88,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "node_modules/@lukeed/csprng": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.1.0.tgz", - "integrity": "sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==", - "peer": true, - "engines": { - "node": ">=8" - } - }, "node_modules/@lukeed/ms": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@lukeed/ms/-/ms-2.0.2.tgz", @@ -171,159 +96,11 @@ "node": ">=8" } }, - "node_modules/@nestjs/common": { - "version": "10.3.7", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.3.7.tgz", - "integrity": "sha512-gKFtFzcJznrwsRYjtNZoPAvSOPYdNgxbTYoAyLTpoy393cIKgLmJTHu6ReH8/qIB9AaZLdGaFLkx98W/tFWFUw==", - "peer": true, - "dependencies": { - "iterare": "1.2.1", - "tslib": "2.6.2", - "uid": "2.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nest" - }, - "peerDependencies": { - "class-transformer": "*", - "class-validator": "*", - "reflect-metadata": "^0.1.12 || ^0.2.0", - "rxjs": "^7.1.0" - }, - "peerDependenciesMeta": { - "class-transformer": { - "optional": true - }, - "class-validator": { - "optional": true - } - } - }, - "node_modules/@nestjs/core": { - "version": "10.3.7", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.3.7.tgz", - "integrity": "sha512-hsdlnfiQ3kgqHL5k7js3CU0PV7hBJVi+LfFMgCkoagRxNMf67z0GFGeOV2jk5d65ssB19qdYsDa1MGVuEaoUpg==", - "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.2", - "uid": "2.0.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nest" - }, - "peerDependencies": { - "@nestjs/common": "^10.0.0", - "@nestjs/microservices": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "@nestjs/websockets": "^10.0.0", - "reflect-metadata": "^0.1.12 || ^0.2.0", - "rxjs": "^7.1.0" - }, - "peerDependenciesMeta": { - "@nestjs/microservices": { - "optional": true - }, - "@nestjs/platform-express": { - "optional": true - }, - "@nestjs/websockets": { - "optional": true - } - } - }, - "node_modules/@nestjs/core/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==", - "peer": true - }, - "node_modules/@nestjs/platform-express": { - "version": "10.3.7", - "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.3.7.tgz", - "integrity": "sha512-noNJ+PyIxQJLCKfuXz0tcQtlVAynfLIuKy62g70lEZ86UrIqSrZFqvWs/rFUgkbT6J8H7Rmv11hASOnX+7M2rA==", - "dependencies": { - "body-parser": "1.20.2", - "cors": "2.8.5", - "express": "4.19.2", - "multer": "1.4.4-lts.1", - "tslib": "2.6.2" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nest" - }, - "peerDependencies": { - "@nestjs/common": "^10.0.0", - "@nestjs/core": "^10.0.0" - } - }, - "node_modules/@nestjs/platform-express/node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, - "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/@nuxtjs/opencollective": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz", - "integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==", - "peer": true, - "dependencies": { - "chalk": "^4.1.0", - "consola": "^2.15.0", - "node-fetch": "^2.6.1" - }, - "bin": { - "opencollective": "bin/opencollective.js" - }, - "engines": { - "node": ">=8.0.0", - "npm": ">=5.0.0" - } - }, "node_modules/@one-ini/wasm": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@one-ini/wasm/-/wasm-0.1.1.tgz", "integrity": "sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw==" }, - "node_modules/@opentelemetry/api": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", - "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", - "license": "Apache-2.0", - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -587,14 +364,6 @@ "node": ">=0.4.0" } }, - "node_modules/adler-32": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", - "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", @@ -667,11 +436,6 @@ "node": ">= 6.0.0" } }, - "node_modules/append-field": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", - "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" - }, "node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -756,11 +520,6 @@ "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", "integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==" }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, "node_modules/available-typed-arrays": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", @@ -772,16 +531,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/axios": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", - "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", - "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -829,12 +578,12 @@ "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.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.5", + "content-type": "~1.0.4", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -842,7 +591,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.2", + "raw-body": "2.5.1", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -900,17 +649,6 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, - "node_modules/busboy": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", - "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", - "dependencies": { - "streamsearch": "^1.1.0" - }, - "engines": { - "node": ">=10.16.0" - } - }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -952,18 +690,6 @@ "node": ">=0.10.0" } }, - "node_modules/cfb": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", - "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", - "dependencies": { - "adler-32": "~1.3.0", - "crc-32": "~1.2.0" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -1220,14 +946,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/codepage": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", - "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1249,17 +967,6 @@ "resolved": "https://registry.npmjs.org/colors-console/-/colors-console-1.0.3.tgz", "integrity": "sha512-Q31K32UwadWqAxs+Iu46gNm4HJqUwrTJT2zen5NnhkKE5w7uqeZQZiuODUOxM/zOtHfiUTkia0io6zbN/VcCUQ==" }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", @@ -1270,20 +977,6 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, - "node_modules/concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "engines": [ - "node >= 0.8" - ], - "dependencies": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, "node_modules/config-chain": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz", @@ -1293,12 +986,6 @@ "proto-list": "~1.2.1" } }, - "node_modules/consola": { - "version": "2.15.3", - "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", - "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==", - "peer": true - }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -1319,9 +1006,9 @@ } }, "node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", "engines": { "node": ">= 0.6" } @@ -1348,17 +1035,6 @@ "node": ">= 0.10" } }, - "node_modules/crc-32": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", - "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", - "bin": { - "crc32": "bin/crc32.njs" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -1436,14 +1112,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/denque": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", @@ -1722,16 +1390,16 @@ } }, "node_modules/express": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", - "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.2", + "body-parser": "1.20.1", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.6.0", + "cookie": "0.5.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -1789,12 +1457,6 @@ "node": ">=16 <22" } }, - "node_modules/fast-safe-stringify": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", - "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", - "peer": true - }, "node_modules/figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", @@ -1835,25 +1497,6 @@ "node": ">= 0.8" } }, - "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -1877,19 +1520,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "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==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -1898,14 +1528,6 @@ "node": ">= 0.6" } }, - "node_modules/frac": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", - "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", @@ -2211,15 +1833,6 @@ "node": "*" } }, - "node_modules/hpagent": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/hpagent/-/hpagent-1.2.0.tgz", - "integrity": "sha512-A91dYTeIB6NoXG+PxTQpCCDDnfHsW9kc06Lvpu1TEe9gnd6ZFeiBoRO9JvzEv6xK7EX97/dUE8g/vBMTqTS3CA==", - "license": "MIT", - "engines": { - "node": ">=14" - } - }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -2366,17 +1979,6 @@ "node": ">=4" } }, - "node_modules/inquirer/node_modules/rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", - "dependencies": { - "tslib": "^1.9.0" - }, - "engines": { - "npm": ">=2.0.0" - } - }, "node_modules/inquirer/node_modules/string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -2419,11 +2021,6 @@ "node": ">=6" } }, - "node_modules/inquirer/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, "node_modules/internal-slot": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.6.tgz", @@ -2725,15 +2322,6 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, - "node_modules/iterare": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz", - "integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==", - "peer": true, - "engines": { - "node": ">=6" - } - }, "node_modules/iterate-iterator": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/iterate-iterator/-/iterate-iterator-1.0.2.tgz", @@ -3037,34 +2625,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, - "node_modules/multer": { - "version": "1.4.5-lts.1", - "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", - "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", - "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/multer/node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, "node_modules/mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", @@ -3187,26 +2747,6 @@ "uuid": "dist/bin/uuid" } }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "peer": true, - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/nodemon": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.3.tgz", @@ -3527,11 +3067,6 @@ "node": ">= 0.10" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, "node_modules/pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", @@ -3561,9 +3096,9 @@ } }, "node_modules/raw-body": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", - "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -3610,56 +3145,6 @@ "node": ">=8.10.0" } }, - "node_modules/redis": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", - "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", - "dependencies": { - "denque": "^1.5.0", - "redis-commands": "^1.7.0", - "redis-errors": "^1.2.0", - "redis-parser": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-redis" - } - }, - "node_modules/redis-commands": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", - "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" - }, - "node_modules/redis-errors": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", - "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==", - "engines": { - "node": ">=4" - } - }, - "node_modules/redis-parser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", - "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", - "dependencies": { - "redis-errors": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/redis/node_modules/denque": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz", - "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==", - "engines": { - "node": ">=0.10" - } - }, "node_modules/reflect-metadata": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.1.tgz", @@ -3734,14 +3219,21 @@ } }, "node_modules/rxjs": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", - "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", - "peer": true, + "version": "6.6.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", + "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", "dependencies": { - "tslib": "^2.1.0" + "tslib": "^1.9.0" + }, + "engines": { + "npm": ">=2.0.0" } }, + "node_modules/rxjs/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + }, "node_modules/safe-array-concat": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.0.tgz", @@ -3804,12 +3296,6 @@ "resolved": "https://registry.npmjs.org/sax/-/sax-1.3.0.tgz", "integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==" }, - "node_modules/secure-json-parse": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.7.0.tgz", - "integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==", - "license": "BSD-3-Clause" - }, "node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", @@ -4012,17 +3498,6 @@ "node": ">= 0.6" } }, - "node_modules/ssf": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", - "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", - "dependencies": { - "frac": "~1.1.2" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -4042,14 +3517,6 @@ "node": ">= 0.4" } }, - "node_modules/streamsearch": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", - "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -4360,12 +3827,6 @@ "nodetouch": "bin/nodetouch.js" } }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "peer": true - }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", @@ -4503,11 +3964,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" - }, "node_modules/typeorm": { "version": "0.3.19", "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.19.tgz", @@ -4962,18 +4418,6 @@ "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", "integrity": "sha512-vb2s1lYx2xBtUgy+ta+b2J/GLVUR+wmpINwHePmPRhOsIVCG2wDzKJ0n14GslH1BifsqVzSOwQhRaCAsZ/nI4Q==" }, - "node_modules/uid": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/uid/-/uid-2.0.2.tgz", - "integrity": "sha512-u3xV3X7uzvi5b1MncmZo3i2Aw222Zk1keqLA1YkHldREkAhAqi65wuPfe7lHx8H/Wzy+8CE7S7uS3jekIM5s8g==", - "peer": true, - "dependencies": { - "@lukeed/csprng": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -4994,15 +4438,6 @@ "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", "dev": true }, - "node_modules/undici": { - "version": "6.19.2", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.2.tgz", - "integrity": "sha512-JfjKqIauur3Q6biAtHJ564e3bWa8VvT+7cSiOJHFbX4Erv6CLGDpg8z+Fmg/1OI/47RA+GI2QZaF48SSaLvyBA==", - "license": "MIT", - "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", @@ -5079,22 +4514,6 @@ "loose-envify": "^1.0.0" } }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "peer": true - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "peer": true, - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -5150,22 +4569,6 @@ "node": ">= 0.8.0" } }, - "node_modules/wmf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", - "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==", - "engines": { - "node": ">=0.8" - } - }, - "node_modules/word": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", - "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", @@ -5257,26 +4660,6 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, - "node_modules/xlsx": { - "version": "0.18.5", - "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz", - "integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==", - "dependencies": { - "adler-32": "~1.3.0", - "cfb": "~1.2.1", - "codepage": "~1.15.0", - "crc-32": "~1.2.1", - "ssf": "~0.11.2", - "wmf": "~1.0.1", - "word": "~0.3.0" - }, - "bin": { - "xlsx": "bin/xlsx.njs" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/xml2js": { "version": "0.4.23", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", @@ -5297,14 +4680,6 @@ "node": ">=4.0" } }, - "node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "engines": { - "node": ">=0.4" - } - }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index 9f2d6c7..f5a8240 100644 --- a/package.json +++ b/package.json @@ -27,15 +27,11 @@ "typescript": "^5.3.3" }, "dependencies": { - "@elastic/elasticsearch": "^8.14.0", - "@nestjs/platform-express": "^10.3.7", "@tsoa/runtime": "^6.0.0", - "axios": "^1.6.8", "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.18.2", "fast-jwt": "^3.3.2", - "multer": "^1.4.5-lts.1", "mysql2": "^3.9.1", "node-cron": "^3.0.3", "promise.any": "^2.0.6", @@ -43,8 +39,6 @@ "swagger-ui-express": "^5.0.0", "tsoa": "^6.0.1", "typeorm": "^0.3.19", - "typeorm-cli": "^1.0.7", - "xlsx": "^0.18.5", - "redis": "~3.1.2" + "typeorm-cli": "^1.0.7" } } diff --git a/src/app.ts b/src/app.ts index 2580fda..6efbcf9 100644 --- a/src/app.ts +++ b/src/app.ts @@ -8,7 +8,6 @@ import * as cron from "node-cron"; import error from "./middlewares/error"; import { AppDataSource } from "./database/data-source"; import { RegisterRoutes } from "./routes"; -import logMiddleware from "./middlewares/logs"; async function main() { await AppDataSource.initialize(); @@ -22,7 +21,6 @@ async function main() { ); app.use(express.json()); app.use(express.urlencoded({ extended: true })); - app.use(logMiddleware); app.use("/", express.static("static")); app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument)); diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts deleted file mode 100644 index 0642d60..0000000 --- a/src/controllers/DevelopmentController.ts +++ /dev/null @@ -1,3365 +0,0 @@ -import { - Controller, - Get, - Post, - Put, - Delete, - Route, - Security, - Tags, - Body, - Path, - Request, - Query, - UploadedFile, -} from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import { In, Not } from "typeorm"; -import HttpSuccess from "../interfaces/http-success"; -import HttpError from "../interfaces/http-error"; -import HttpStatusCode from "../interfaces/http-status"; -import { - Development, - CreateDevelopment, - UpdateDevelopment1, - UpdateDevelopment3, - UpdateDevelopment4, - UpdateDevelopment5, - UpdateDevelopment7, - UpdateDevelopment8, -} from "../entities/Development"; -import { ActualPeople, CreateActualPeople } from "../entities/ActualPeople"; -import { CreatePlannedPeople, PlannedPeople } from "../entities/PlannedPeople"; -import { ActualGoal, CreateActualGoal } from "../entities/ActualGoal"; -import { CreatePlannedGoal, PlannedGoal } from "../entities/PlannedGoal"; -import { PosType } from "../entities/PosType"; -import { PosLevel } from "../entities/PosLevel"; -import { EmployeePosType } from "../entities/EmployeePosType"; -import { EmployeePosLevel } from "../entities/EmployeePosLevel"; -import { PlannedGoalPosition } from "../entities/PlannedGoalPosition"; -import { CreateDevelopmentHistoryOBO, DevelopmentHistory } from "../entities/DevelopmentHistory"; -import { DevelopmentProjectType } from "../entities/DevelopmentProjectType"; -import { - CreateDevelopmentEvaluation, - DevelopmentEvaluation, -} from "../entities/DevelopmentEvaluation"; -import { DevelopmentAddress } from "../entities/DevelopmentAddress"; -import { DevelopmentProjectTechniquePlanned } from "../entities/DevelopmentProjectTechniquePlanned"; -import { DevelopmentProjectTechniqueActual } from "../entities/DevelopmentProjectTechniqueActual"; -import { StrategyChild1 } from "../entities/StrategyChild1"; -import { StrategyChild2 } from "../entities/StrategyChild2"; -import { StrategyChild3 } from "../entities/StrategyChild3"; -import { StrategyChild4 } from "../entities/StrategyChild4"; -import { StrategyChild5 } from "../entities/StrategyChild5"; -import CallAPI from "../interfaces/call-api"; -import { UseInterceptors } from "@nestjs/common"; -import { FileInterceptor } from "@nestjs/platform-express"; -import * as xlsx from "xlsx"; -import { setLogDataDiff } from "../interfaces/utils"; -import { RequestWithUser } from "../middlewares/user"; -import { DevelopmentRisk, UpdateDevelopmentRisk } from "../entities/DevelopmentRisk"; -import { DevelopmentOther, UpdateDevelopmentOther } from "../entities/DevelopmentOther"; -import permission from "../interfaces/permission"; -import { Brackets } from "typeorm"; - -@Route("api/v1/development/main") -@Tags("Development") -@Security("bearerAuth") -export class DevelopmentController extends Controller { - private developmentRepository = AppDataSource.getRepository(Development); - private developmentRiskRepository = AppDataSource.getRepository(DevelopmentRisk); - private developmentOtherRepository = AppDataSource.getRepository(DevelopmentOther); - private developmentAddresssRepository = AppDataSource.getRepository(DevelopmentAddress); - private developmentEvaluationRepository = AppDataSource.getRepository(DevelopmentEvaluation); - private developmentProjectTypeRepository = AppDataSource.getRepository(DevelopmentProjectType); - private developmentProjectTechniquePlannedRepository = AppDataSource.getRepository( - DevelopmentProjectTechniquePlanned, - ); - private developmentProjectTechniqueActualRepository = AppDataSource.getRepository( - DevelopmentProjectTechniqueActual, - ); - private developmentHistoryRepository = AppDataSource.getRepository(DevelopmentHistory); - private actualPeopleRepository = AppDataSource.getRepository(ActualPeople); - private plannedPeopleRepository = AppDataSource.getRepository(PlannedPeople); - private actualGoalRepository = AppDataSource.getRepository(ActualGoal); - private plannedGoalRepository = AppDataSource.getRepository(PlannedGoal); - private plannedGoalPositionRepository = AppDataSource.getRepository(PlannedGoalPosition); - private posTypeRepository = AppDataSource.getRepository(PosType); - private posLevelRepository = AppDataSource.getRepository(PosLevel); - private empPosTypeRepository = AppDataSource.getRepository(EmployeePosType); - private empPosLevelRepository = AppDataSource.getRepository(EmployeePosLevel); - private strategyChild1Repository = AppDataSource.getRepository(StrategyChild1); - private strategyChild2Repository = AppDataSource.getRepository(StrategyChild2); - private strategyChild3Repository = AppDataSource.getRepository(StrategyChild3); - private strategyChild4Repository = AppDataSource.getRepository(StrategyChild4); - private strategyChild5Repository = AppDataSource.getRepository(StrategyChild5); - - /** - * API ล้างข้อมูล - * - * @summary ล้างข้อมูล - * - */ - @Get("clear-db") - async ClearDb() { - return new HttpSuccess(); - } - - /** - * API เพิ่มโครงการ/หลักสูตรการฝึกอบรม - * - * @summary DEV_001 - เพิ่มโครงการ/หลักสูตรการฝึกอบรม#1 - * - */ - @Post() - async CreateDevelopment( - @Body() requestBody: CreateDevelopment, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_PROJECT"); - const chk_name = await this.developmentRepository.find({ - where: { - projectName: requestBody.projectName, - year: requestBody.year, - }, - }); - if (chk_name.length > 0) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "โครงการ/หลักสูตรการฝึกอบรม: " + - requestBody.projectName + - " ปีงบประมาณ: " + - (requestBody.year + 543) + - " มีอยู่ในระบบแล้ว", - ); - } - - const development = Object.assign(new Development(), requestBody); - await new CallAPI() - .PostData(request, "/org/find/all", { - node: requestBody.node, - nodeId: requestBody.nodeId, - }) - .then((x) => { - development.root = x.root; - development.rootId = x.rootId; - development.rootDnaId = x.rootDnaId; - development.rootShortName = x.rootShortName; - development.child1 = x.child1; - development.child1Id = x.child1Id; - development.child1DnaId = x.child1DnaId; - development.child1ShortName = x.child1ShortName; - development.child2 = x.child2; - development.child2Id = x.child2Id; - development.child2DnaId = x.child2DnaId; - development.child2ShortName = x.child2ShortName; - development.child3 = x.child3; - development.child3Id = x.child3Id; - development.child3DnaId = x.child3DnaId; - development.child3ShortName = x.child3ShortName; - development.child4 = x.child4; - development.child4Id = x.child4Id; - development.child4DnaId = x.child4DnaId; - development.child4ShortName = x.child4ShortName; - }) - .catch((error) => { - console.error("Error calling API:", error); - }); - - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Development.", - // }); - const before = null; - - await this.developmentRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรม Tab1 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมTab1 # - * - * @param {string} id Id โครงการ - */ - @Put("tab1/{id}") - async UpdateDevelopmentTab1( - @Path() id: string, - @Body() requestBody: UpdateDevelopment1, - @Request() request: RequestWithUser, - ) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const chk_name = await this.developmentRepository.find({ - where: { - projectName: requestBody.projectName, - year: requestBody.year, - id: Not(id), - }, - }); - if (chk_name.length > 0) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "โครงการ/หลักสูตรการฝึกอบรม: " + - requestBody.projectName + - " ปีงบประมาณ: " + - (requestBody.year + 543) + - " มีอยู่ในระบบแล้ว", - ); - } - const before = structuredClone(development); - Object.assign(development, requestBody); - await new CallAPI() - .PostData(request, "/org/find/all", { - node: requestBody.node, - nodeId: requestBody.nodeId, - }) - .then((x) => { - development.root = x.root; - development.rootId = x.rootId; - development.rootDnaId = x.rootDnaId; - development.rootShortName = x.rootShortName; - development.child1 = x.child1; - development.child1Id = x.child1Id; - development.child1DnaId = x.child1DnaId; - development.child1ShortName = x.child1ShortName; - development.child2 = x.child2; - development.child2Id = x.child2Id; - development.child2DnaId = x.child2DnaId; - development.child2ShortName = x.child2ShortName; - development.child3 = x.child3; - development.child3Id = x.child3Id; - development.child3DnaId = x.child3DnaId; - development.child3ShortName = x.child3ShortName; - development.child4 = x.child4; - development.child4Id = x.child4Id; - development.child4DnaId = x.child4DnaId; - development.child4ShortName = x.child4ShortName; - }) - .catch((x) => {}); - const _null: any = null; - switch (requestBody.node) { - case 0: { - development.child1 = _null; - development.child1Id = _null; - development.child1DnaId = _null; - development.child1ShortName = _null; - development.child2 = _null; - development.child2Id = _null; - development.child2DnaId = _null; - development.child2ShortName = _null; - development.child3 = _null; - development.child3Id = _null; - development.child3DnaId = _null; - development.child3ShortName = _null; - development.child4 = _null; - development.child4Id = _null; - development.child4DnaId = _null; - development.child4ShortName = _null; - break; - } - case 1: { - development.child2 = _null; - development.child2Id = _null; - development.child2DnaId = _null; - development.child2ShortName = _null; - development.child3 = _null; - development.child3Id = _null; - development.child3DnaId = _null; - development.child3ShortName = _null; - development.child4 = _null; - development.child4Id = _null; - development.child4DnaId = _null; - development.child4ShortName = _null; - break; - } - case 2: { - development.child3 = _null; - development.child3Id = _null; - development.child3DnaId = _null; - development.child3ShortName = _null; - development.child4 = _null; - development.child4Id = _null; - development.child4DnaId = _null; - development.child4ShortName = _null; - break; - } - case 3: { - development.child4 = _null; - development.child4Id = _null; - development.child4DnaId = _null; - development.child4ShortName = _null; - break; - } - default: - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม"); - } - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Development.", - // }); - await this.developmentRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab2-1 - * - * @summary DEV_00 - เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab2-1 # - * - * @param {string} id Id โครงการ - */ - @Put("tab2_1_add/{id}") - async CreateDevelopmenttab2_1( - @Path() id: string, - @Body() requestBody: CreatePlannedGoal, - @Request() request: RequestWithUser, - ) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionCreate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const data = Object.assign(new PlannedGoal(), { ...requestBody, positions: [] }); - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentPlannedGoalId = development.id; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Development.", - // }); - await this.plannedGoalRepository.save(data, { data: request }); - - await Promise.all( - requestBody.positions.map(async (x) => { - const _data = Object.assign(new PlannedGoalPosition(), x); - let checkPosType: any = null; - let posTypeShortName: any = null; - if (x.posTypePlanned) { - if ( - requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || - requestBody.groupTargetSub == "EMPLOYEETEMP") - ) { - checkPosType = await this.empPosTypeRepository.findOne({ - where: { posTypeName: x.posTypePlanned }, - }); - if (!checkPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); - } - posTypeShortName = checkPosType.posTypeShortName; - } else { - checkPosType = await this.posTypeRepository.findOne({ - where: { posTypeName: x.posTypePlanned }, - }); - if (!checkPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - } - if (x.posLevelPlanned) { - let checkPosLevel: any; - if ( - requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || - requestBody.groupTargetSub == "EMPLOYEETEMP") - ) { - checkPosLevel = await this.empPosLevelRepository.find({ - where: { - posTypeId: checkPosType.id, - }, - }); - const mapShortName = checkPosLevel.flatMap( - (x: any) => `${posTypeShortName} ${x.posLevelName}`, - ); - if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); - } - } else { - checkPosLevel = await this.posLevelRepository.findOne({ - where: { - posLevelName: x.posLevelPlanned, - posTypeId: checkPosType.id, - }, - }); - if (!checkPosLevel) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - } - const before = structuredClone(development); - _data.createdUserId = request.user.sub; - _data.createdFullName = request.user.name; - _data.lastUpdateUserId = request.user.sub; - _data.lastUpdateFullName = request.user.name; - _data.createdAt = new Date(); - _data.lastUpdatedAt = new Date(); - _data.plannedGoalId = data.id; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Development.", - // }); - await this.plannedGoalPositionRepository.save(_data, { data: request }); - setLogDataDiff(request, { before, after: development }); - }), - ); - return new HttpSuccess(data.id); - } - - /** - * API เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab2-2 - * - * @summary DEV_00 - เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab2-2 # - * - * @param {string} id Id โครงการ - */ - @Put("tab2_2_add/{id}") - async CreateDevelopmenttab2_2( - @Path() id: string, - @Body() requestBody: CreatePlannedPeople, - @Request() request: RequestWithUser, - ) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionCreate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const before = structuredClone(development); - const data = Object.assign(new PlannedPeople(), requestBody); - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentPlannedPeopleId = development.id; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Development.", - // }); - await this.plannedPeopleRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(data.id); - } - - /** - * API เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab2-3 - * - * @summary DEV_00 - เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab2-3 # - * - * @param {string} id Id โครงการ - */ - @Put("tab2_3_add/{id}") - async CreateDevelopmenttab2_3( - @Path() id: string, - @Body() requestBody: CreateActualGoal, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let checkPosType: any = null; - let posTypeShortName: any = null; - if (requestBody.posTypeActual) { - if ( - requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP") - ) { - checkPosType = await this.empPosTypeRepository.findOne({ - where: { posTypeName: requestBody.posTypeActual }, - }); - if (!checkPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); - } - posTypeShortName = checkPosType.posTypeShortName; - } else { - checkPosType = await this.posTypeRepository.findOne({ - where: { posTypeName: requestBody.posTypeActual }, - }); - if (!checkPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - } - if (requestBody.posLevelActual) { - let checkPosLevel: any; - if ( - requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP") - ) { - checkPosLevel = await this.empPosLevelRepository.find({ - where: { - posTypeId: checkPosType.id, - }, - }); - const mapShortName = checkPosLevel.flatMap( - (x: any) => `${posTypeShortName} ${x.posLevelName}`, - ); - if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); - } - } else { - checkPosLevel = await this.posLevelRepository.findOne({ - where: { - posLevelName: requestBody.posLevelActual, - posTypeId: checkPosType.id, - }, - }); - if (!checkPosLevel) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - } - const before = structuredClone(development); - const data = Object.assign(new ActualGoal(), requestBody); - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentActualGoalId = development.id; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store ActualGoal.", - // }); - await this.actualGoalRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(data.id); - } - - /** - * API เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab2-4 - * - * @summary DEV_00 - เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab2-4 # - * - * @param {string} id Id โครงการ - */ - @Put("tab2_4_add/{id}") - async CreateDevelopmenttab2_4( - @Path() id: string, - @Body() requestBody: CreateActualPeople, - @Request() request: RequestWithUser, - ) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const before = structuredClone(development); - const data = Object.assign(new ActualPeople(), requestBody); - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentActualPeopleId = development.id; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store ActualPeople.", - // }); - await this.actualPeopleRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(data.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-1 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-1 # - * - * @param {string} id Id รายการ - */ - @Put("tab2_1_edit/{id}") - async UpdateDevelopmenttab2_1( - @Path() id: string, - @Body() requestBody: CreatePlannedGoal, - @Request() request: RequestWithUser, - ) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.plannedGoalRepository.findOne({ - where: { id }, - relations: { - plannedGoalPositions: true, - }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const before = structuredClone(development); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove data in the field on the PlannedGoalPosition.", - // }); - await this.plannedGoalPositionRepository.remove(development.plannedGoalPositions, { - data: request, - }); - Object.assign(development, { ...requestBody, positions: [] }); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store PlannedGoal.", - // }); - await this.plannedGoalRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - if (requestBody.positions != null) { - await Promise.all( - requestBody.positions.map(async (x) => { - const _data = Object.assign(new PlannedGoalPosition(), x); - let checkPosType: any = null; - let posTypeShortName: any = null; - if (x.posTypePlanned) { - if ( - requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || - requestBody.groupTargetSub == "EMPLOYEETEMP") - ) { - checkPosType = await this.empPosTypeRepository.findOne({ - where: { posTypeName: x.posTypePlanned }, - }); - if (!checkPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); - } - posTypeShortName = checkPosType.posTypeShortName; - } else { - checkPosType = await this.posTypeRepository.findOne({ - where: { posTypeName: x.posTypePlanned }, - }); - if (!checkPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - } - if (x.posLevelPlanned) { - let checkPosLevel: any; - if ( - requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || - requestBody.groupTargetSub == "EMPLOYEETEMP") - ) { - checkPosLevel = await this.empPosLevelRepository.find({ - where: { - posTypeId: checkPosType.id, - }, - }); - const mapShortName = checkPosLevel.flatMap( - (x: any) => `${posTypeShortName} ${x.posLevelName}`, - ); - if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); - } - } else { - checkPosLevel = await this.posLevelRepository.findOne({ - where: { - posLevelName: x.posLevelPlanned, - posTypeId: checkPosType.id, - }, - }); - if (!checkPosLevel) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - } - _data.createdUserId = request.user.sub; - _data.createdFullName = request.user.name; - _data.lastUpdateUserId = request.user.sub; - _data.lastUpdateFullName = request.user.name; - _data.createdAt = new Date(); - _data.lastUpdatedAt = new Date(); - _data.plannedGoalId = development.id; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Planned Goal Position.", - // }); - await this.plannedGoalPositionRepository.save(_data, { - data: { - request: request, - }, - }); - }), - ); - } - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-2 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-2 # - * - * @param {string} id Id รายการ - */ - @Put("tab2_2_edit/{id}") - async UpdateDevelopmenttab2_2( - @Path() id: string, - @Body() requestBody: CreatePlannedPeople, - @Request() request: RequestWithUser, - ) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.plannedPeopleRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const before = structuredClone(development); - Object.assign(development, requestBody); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store PlannedPeople.", - // }); - await this.plannedPeopleRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-3 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-3 # - * - * @param {string} id Id รายการ - */ - @Put("tab2_3_edit/{id}") - async UpdateDevelopmenttab2_3( - @Path() id: string, - @Body() requestBody: CreateActualGoal, - @Request() request: RequestWithUser, - ) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.actualGoalRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let checkPosType: any = null; - let posTypeShortName: any = null; - if (requestBody.posTypeActual) { - if ( - requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP") - ) { - checkPosType = await this.empPosTypeRepository.findOne({ - where: { posTypeName: requestBody.posTypeActual }, - }); - if (!checkPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); - } - posTypeShortName = checkPosType.posTypeShortName; - } else { - checkPosType = await this.posTypeRepository.findOne({ - where: { posTypeName: requestBody.posTypeActual }, - }); - if (!checkPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - } - if (requestBody.posLevelActual) { - let checkPosLevel: any; - if ( - requestBody.groupTarget == "PERSONNEL" && - (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP") - ) { - checkPosLevel = await this.empPosLevelRepository.find({ - where: { - posTypeId: checkPosType.id, - }, - }); - const mapShortName = checkPosLevel.flatMap( - (x: any) => `${posTypeShortName} ${x.posLevelName}`, - ); - if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); - } - } else { - checkPosLevel = await this.posLevelRepository.findOne({ - where: { - posLevelName: requestBody.posLevelActual, - posTypeId: checkPosType.id, - }, - }); - if (!checkPosLevel) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - } - const before = structuredClone(development); - Object.assign(development, requestBody); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store ActualGoal.", - // }); - await this.actualGoalRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-4 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab2-4 # - * - * @param {string} id Id รายการ - */ - @Put("tab2_4_edit/{id}") - async UpdateDevelopmenttab2_4( - @Path() id: string, - @Body() requestBody: CreateActualPeople, - @Request() request: RequestWithUser, - ) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.actualPeopleRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const before = structuredClone(development); - Object.assign(development, requestBody); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store ActualPeople.", - // }); - await this.actualPeopleRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API ลบโครงการ/หลักสูตรการฝึกอบรมtab2-1 - * - * @summary DEV_00 - ลบโครงการ/หลักสูตรการฝึกอบรมtab2-1 # - * - * @param {string} id Id รายการ - */ - @Delete("tab2_1/{id}") - async DeleteDevelopmenttab2_1(@Path() id: string, @Request() request: RequestWithUser) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionDelete(request, "SYS_DEV_PROJECT"); - const development = await this.plannedGoalRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มเป้าหมายตามแผน"); - } - const _development = await this.plannedGoalPositionRepository.find({ - where: { plannedGoalId: id }, - }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove data in PlannedGoalPosition.", - // }); - await this.plannedGoalPositionRepository.remove(_development, { data: request }); - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove data in PlannedGoal.", - // }); - await this.plannedGoalRepository.remove(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API ลบโครงการ/หลักสูตรการฝึกอบรมtab2-2 - * - * @summary DEV_00 - ลบโครงการ/หลักสูตรการฝึกอบรมtab2-2 # - * - * @param {string} id Id รายการ - */ - @Delete("tab2_2/{id}") - async DeleteDevelopmenttab2_2(@Path() id: string, @Request() request: RequestWithUser) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionDelete(request, "SYS_DEV_PROJECT"); - const development = await this.plannedPeopleRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้เกี่ยวข้องเป้าหมายตามแผน"); - } - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove data in PlannedPeople.", - // }); - await this.plannedPeopleRepository.remove(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API ลบโครงการ/หลักสูตรการฝึกอบรมtab2-3 - * - * @summary DEV_00 - ลบโครงการ/หลักสูตรการฝึกอบรมtab2-3 # - * - * @param {string} id Id รายการ - */ - @Delete("tab2_3/{id}") - async DeleteDevelopmenttab2_3(@Path() id: string, @Request() request: RequestWithUser) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionDelete(request, "SYS_DEV_PROJECT"); - const development = await this.actualGoalRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มเป้าหมายตามจริง"); - } - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove data in ActualGoal.", - // }); - await this.actualGoalRepository.remove(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API ลบโครงการ/หลักสูตรการฝึกอบรมtab2-4 - * - * @summary DEV_00 - ลบโครงการ/หลักสูตรการฝึกอบรมtab2-4 # - * - * @param {string} id Id รายการ - */ - @Delete("tab2_4/{id}") - async DeleteDevelopmenttab2_4(@Path() id: string, @Request() request: RequestWithUser) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development.", - // }); - await new permission().PermissionDelete(request, "SYS_DEV_PROJECT"); - const development = await this.actualPeopleRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้เกี่ยวข้องเป้าหมายตามจริง"); - } - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove data in ActualPeople.", - // }); - await this.actualPeopleRepository.remove(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab3 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab3 # - * - * @param {string} id Id โครงการ - */ - @Put("tab3/{id}") - async UpdateDevelopmentTab3( - @Path() id: string, - @Body() requestBody: UpdateDevelopment3, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - relations: { - developmentProjectTypes: true, - developmentProjectTechniquePlanneds: true, - developmentProjectTechniqueActuals: true, - developmentAddresss: true, - }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - Object.assign(development, { - ...requestBody, - developmentProjectTypes: [], - developmentProjectTechniquePlanneds: [], - developmentProjectTechniqueActuals: [], - developmentAddresss: [], - }); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - await this.developmentProjectTypeRepository.remove(development.developmentProjectTypes, { - data: request, - }); - await this.developmentProjectTechniquePlannedRepository.remove( - development.developmentProjectTechniquePlanneds, - { - data: request, - }, - ); - await this.developmentProjectTechniqueActualRepository.remove( - development.developmentProjectTechniqueActuals, - { - data: request, - }, - ); - const _null: any = null; - if ( - requestBody.strategyChildPlannedNode != undefined && - requestBody.strategyChildPlannedNode != null - ) { - switch (requestBody.strategyChildPlannedNode) { - case 1: { - if (requestBody.strategyChildPlannedId) { - const checkId = await this.strategyChild1Repository.findOne({ - where: { id: requestBody.strategyChildPlannedId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 1", - ); - } - development.strategyChild1PlannedId = checkId.id; - development.strategyChild2PlannedId = _null; - development.strategyChild3PlannedId = _null; - development.strategyChild4PlannedId = _null; - development.strategyChild5PlannedId = _null; - } - break; - } - case 2: { - if (requestBody.strategyChildPlannedId) { - const checkId = await this.strategyChild2Repository.findOne({ - where: { id: requestBody.strategyChildPlannedId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2", - ); - } - development.strategyChild1PlannedId = checkId.strategyChild1Id; - development.strategyChild2PlannedId = checkId.id; - development.strategyChild3PlannedId = _null; - development.strategyChild4PlannedId = _null; - development.strategyChild5PlannedId = _null; - } - break; - } - case 3: { - if (requestBody.strategyChildPlannedId) { - const checkId = await this.strategyChild3Repository.findOne({ - where: { id: requestBody.strategyChildPlannedId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2", - ); - } - development.strategyChild1PlannedId = checkId.strategyChild1Id; - development.strategyChild2PlannedId = checkId.strategyChild2Id; - development.strategyChild3PlannedId = checkId.id; - development.strategyChild4PlannedId = _null; - development.strategyChild5PlannedId = _null; - } - break; - } - case 4: { - if (requestBody.strategyChildPlannedId) { - const checkId = await this.strategyChild4Repository.findOne({ - where: { id: requestBody.strategyChildPlannedId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 3", - ); - } - development.strategyChild1PlannedId = checkId.strategyChild1Id; - development.strategyChild2PlannedId = checkId.strategyChild2Id; - development.strategyChild3PlannedId = checkId.strategyChild3Id; - development.strategyChild4PlannedId = checkId.id; - development.strategyChild5PlannedId = _null; - } - break; - } - case 5: { - if (requestBody.strategyChildPlannedId) { - const checkId = await this.strategyChild5Repository.findOne({ - where: { id: requestBody.strategyChildPlannedId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2", - ); - } - development.strategyChild1PlannedId = checkId.strategyChild1Id; - development.strategyChild2PlannedId = checkId.strategyChild2Id; - development.strategyChild3PlannedId = checkId.strategyChild3Id; - development.strategyChild4PlannedId = checkId.strategyChild4Id; - development.strategyChild5PlannedId = checkId.id; - } - break; - } - - default: - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผน"); - } - } - if ( - requestBody.strategyChildActualNode != undefined && - requestBody.strategyChildActualNode != null - ) { - switch (requestBody.strategyChildActualNode) { - case 1: { - if (requestBody.strategyChildActualId) { - const checkId = await this.strategyChild1Repository.findOne({ - where: { id: requestBody.strategyChildActualId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 1", - ); - } - development.strategyChild1ActualId = checkId.id; - development.strategyChild2ActualId = _null; - development.strategyChild3ActualId = _null; - development.strategyChild4ActualId = _null; - development.strategyChild5ActualId = _null; - } - break; - } - case 2: { - if (requestBody.strategyChildActualId) { - const checkId = await this.strategyChild2Repository.findOne({ - where: { id: requestBody.strategyChildActualId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 2", - ); - } - development.strategyChild1ActualId = checkId.strategyChild1Id; - development.strategyChild2ActualId = checkId.id; - development.strategyChild3ActualId = _null; - development.strategyChild4ActualId = _null; - development.strategyChild5ActualId = _null; - } - break; - } - case 3: { - if (requestBody.strategyChildActualId) { - const checkId = await this.strategyChild3Repository.findOne({ - where: { id: requestBody.strategyChildActualId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 3", - ); - } - development.strategyChild1ActualId = checkId.strategyChild1Id; - development.strategyChild2ActualId = checkId.strategyChild2Id; - development.strategyChild3ActualId = checkId.id; - development.strategyChild4ActualId = _null; - development.strategyChild5ActualId = _null; - } - break; - } - case 4: { - if (requestBody.strategyChildActualId) { - const checkId = await this.strategyChild4Repository.findOne({ - where: { id: requestBody.strategyChildActualId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 4", - ); - } - development.strategyChild1ActualId = checkId.strategyChild1Id; - development.strategyChild2ActualId = checkId.strategyChild2Id; - development.strategyChild3ActualId = checkId.strategyChild3Id; - development.strategyChild4ActualId = checkId.id; - development.strategyChild5ActualId = _null; - } - break; - } - case 5: { - if (requestBody.strategyChildActualId) { - const checkId = await this.strategyChild5Repository.findOne({ - where: { id: requestBody.strategyChildActualId }, - }); - if (!checkId) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 5", - ); - } - development.strategyChild1ActualId = checkId.strategyChild1Id; - development.strategyChild2ActualId = checkId.strategyChild2Id; - development.strategyChild3ActualId = checkId.strategyChild3Id; - development.strategyChild4ActualId = checkId.strategyChild4Id; - development.strategyChild5ActualId = checkId.id; - } - break; - } - - default: - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริง"); - } - } - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - await this.developmentRepository.save(development, { data: request }); - if (requestBody.developmentProjectTypes != null) { - await Promise.all( - requestBody.developmentProjectTypes.map(async (x) => { - let data = new DevelopmentProjectType(); - data.name = x; - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentId = development.id; - await this.developmentProjectTypeRepository.save(data, { data: request }); - }), - ); - } - if (requestBody.developmentProjectTechniquePlanneds != null) { - await Promise.all( - requestBody.developmentProjectTechniquePlanneds.map(async (x) => { - let data = new DevelopmentProjectTechniquePlanned(); - data.name = x; - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentId = development.id; - await this.developmentProjectTechniquePlannedRepository.save(data, { data: request }); - }), - ); - } - if (requestBody.developmentProjectTechniqueActuals != null) { - await Promise.all( - requestBody.developmentProjectTechniqueActuals.map(async (x) => { - let data = new DevelopmentProjectTechniquePlanned(); - data.name = x; - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentId = development.id; - await this.developmentProjectTechniqueActualRepository.save(data, { data: request }); - }), - ); - } - //move from tab5 - await this.developmentAddresssRepository.remove(development.developmentAddresss, { - data: request, - }); - - // const before = structuredClone(development); - await Promise.all( - requestBody.developmentAddresss.map(async (x) => { - const data = Object.assign(new DevelopmentAddress(), x); - if (x.address) { - await new CallAPI() - .GetData(request, `/org/metadata/province/${x.provinceId}`) - .then(async (item) => { - data.provinceName = item.name; - }) - .catch(async (x) => {}); - data.developmentId = development.id; - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - await this.developmentAddresssRepository.save(data, { data: request }); - } - // setLogDataDiff(request, { before, after: development }); - }), - ); - - //End - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab4 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab4 # - * - * @param {string} id Id โครงการ - */ - @Put("tab4/{id}") - async UpdateDevelopmentTab4( - @Path() id: string, - @Body() requestBody: UpdateDevelopment4, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const before = structuredClone(development); - Object.assign(development, requestBody); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - await this.developmentRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab4-1 - * - * @summary DEV_00 - เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab4-1 # - * - * @param {string} id Id โครงการ - */ - @Put("tab4_1_add/{id}") - async CreateDevelopmenttab4_1( - @Path() id: string, - @Body() requestBody: CreateDevelopmentEvaluation, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let results: any = - requestBody.results && requestBody.results != "" ? requestBody.results : null; - const before = structuredClone(development); - const data = Object.assign(new DevelopmentEvaluation(), requestBody); - data.results = results; - data.createdUserId = request.user.sub; - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentId = development.id; - await this.developmentEvaluationRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(data.id); - } - - /** - * API ลบโครงการ/หลักสูตรการฝึกอบรมtab4-1 - * - * @summary DEV_00 - ลบโครงการ/หลักสูตรการฝึกอบรมtab4-1 # - * - * @param {string} id Id รายการ - */ - @Delete("tab4_1/{id}") - async DeleteDevelopmenttab4_1(@Path() id: string, @Request() request: RequestWithUser) { - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Get Development Evaluation By ID.", - // }); - await new permission().PermissionDelete(request, "SYS_DEV_PROJECT"); - const development = await this.developmentEvaluationRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้เกี่ยวข้องเป้าหมายตามแผน"); - } - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove Development Evaluation By ID.", - // }); - await this.developmentEvaluationRepository.remove(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab4-1 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab4-1 # - * - * @param {string} id Id รายการ - */ - @Put("tab4_1_edit/{id}") - async UpdateDevelopmenttab4_1( - @Path() id: string, - @Body() requestBody: CreateDevelopmentEvaluation, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentEvaluationRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - Object.assign(development, requestBody); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentEvaluation.", - // }); - await this.developmentEvaluationRepository.save(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab5 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab5 # - * - * @param {string} id Id โครงการ - */ - @Put("tab5/{id}") - async UpdateDevelopmentTab5( - @Path() id: string, - @Body() requestBody: UpdateDevelopment5, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - relations: { developmentAddresss: true }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - Object.assign(development, { ...requestBody}); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - await this.developmentRepository.save(development, { data: request }); - return new HttpSuccess(development.id); - } - /** - * API เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab5-1 - * - * @summary DEV_00 - เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab5-1 # - * - * @param {string} id Id โครงการ - */ - @Put("tab5_1_add/{id}") - async CreateDevelopmenttab5_1( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentOther, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const before = structuredClone(development); - const data = Object.assign(new DevelopmentOther(), requestBody); - await new CallAPI() - .GetData(request, `/org/metadata/province/${requestBody.provinceActualId}`) - .then(async (item) => { - data.provinceActualName = item.name; - }) - .catch(async (x) => {}); - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentId = development.id; - await this.developmentOtherRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(data.id); - } - - /** - * API ลบโครงการ/หลักสูตรการฝึกอบรมtab5-1 - * - * @summary DEV_00 - ลบโครงการ/หลักสูตรการฝึกอบรมtab5-1 # - * - * @param {string} id Id รายการ - */ - @Delete("tab5_1/{id}") - async DeleteDevelopmenttab5_1(@Path() id: string, @Request() request: RequestWithUser) { - await new permission().PermissionDelete(request, "SYS_DEV_PROJECT"); - const development = await this.developmentOtherRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความเสี่ยงของโครงการ"); - } - await this.developmentOtherRepository.remove(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab5-1 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab5-1 # - * - * @param {string} id Id รายการ - */ - @Put("tab5_1_edit/{id}") - async UpdateDevelopmenttab5_1( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentOther, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentOtherRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความเสี่ยงของโครงการ"); - } - Object.assign(development, requestBody); - await new CallAPI() - .GetData(request, `/org/metadata/province/${requestBody.provinceActualId}`) - .then(async (item) => { - development.provinceActualName = item.name; - }) - .catch(async (x) => {}); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - - await this.developmentOtherRepository.save(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab7 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab7 # - * - * @param {string} id Id โครงการ - */ - @Put("tab7/{id}") - async UpdateDevelopmentTab7( - @Path() id: string, - @Body() requestBody: UpdateDevelopment7, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - relations: { developmentAddresss: true }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - Object.assign(development, { ...requestBody }); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - await this.developmentRepository.save(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab7 - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab7 # - * - * @param {string} id Id โครงการ - */ - @Get("tab7/{id}") - async GetDevelopemtTab7ById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_PROJECT"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); - const getDevelopment = await this.developmentRepository.findOne({ - where: { id }, - }); - const _getDevelopment = { - id: getDevelopment ? getDevelopment.id : null, - accept: getDevelopment ? getDevelopment.accept : null, - receive: getDevelopment ? getDevelopment.receive : null, - approved: getDevelopment ? getDevelopment.approved : null, - budget: getDevelopment ? getDevelopment.budget : null, - budgetSub: getDevelopment ? getDevelopment.budgetSub : null, - budgetPay: getDevelopment ? getDevelopment.budgetPay : null, - }; - return new HttpSuccess(_getDevelopment); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab8 - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab8 # - * - * @param {string} id Id โครงการ - */ - @Get("tab8/{id}") - async GetDevelopemtTab8ById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_PROJECT"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); - const getDevelopment = await this.developmentRepository.findOne({ - relations: ["developmentRisks"], - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let _getDevelopment = { - developmentRisks: - getDevelopment.developmentRisks == null - ? null - : getDevelopment.developmentRisks.sort((a, b) => - (a.createdAt.toString() == null ? "" : a.createdAt.toString()).localeCompare( - b.createdAt.toString() == null ? "" : b.createdAt.toString(), - ), - ), - expect: getDevelopment.expect, - }; - - return new HttpSuccess(_getDevelopment); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab8 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab8 # - * - * @param {string} id Id โครงการ - */ - @Put("tab8/{id}") - async UpdateDevelopmentTab8( - @Path() id: string, - @Body() requestBody: UpdateDevelopment8, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - relations: { developmentAddresss: true }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - Object.assign(development, { ...requestBody }); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - await this.developmentRepository.save(development, { data: request }); - return new HttpSuccess(development.id); - } - /** - * API เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab8-1 - * - * @summary DEV_00 - เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab8-1 # - * - * @param {string} id Id โครงการ - */ - @Put("tab8_1_add/{id}") - async CreateDevelopmenttab8_1( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentRisk, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const before = structuredClone(development); - const data = Object.assign(new DevelopmentRisk(), requestBody); - data.createdUserId = request.user.sub; - data.createdFullName = request.user.name; - data.lastUpdateUserId = request.user.sub; - data.lastUpdateFullName = request.user.name; - data.createdAt = new Date(); - data.lastUpdatedAt = new Date(); - data.developmentId = development.id; - await this.developmentRiskRepository.save(data, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(data.id); - } - - /** - * API ลบโครงการ/หลักสูตรการฝึกอบรมtab8-1 - * - * @summary DEV_00 - ลบโครงการ/หลักสูตรการฝึกอบรมtab8-1 # - * - * @param {string} id Id รายการ - */ - @Delete("tab8_1/{id}") - async DeleteDevelopmenttab8_1(@Path() id: string, @Request() request: RequestWithUser) { - await new permission().PermissionDelete(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRiskRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความเสี่ยงของโครงการ"); - } - await this.developmentRiskRepository.remove(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab8-1 - * - * @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab8-1 # - * - * @param {string} id Id รายการ - */ - @Put("tab8_1_edit/{id}") - async UpdateDevelopmenttab8_1( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentRisk, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRiskRepository.findOne({ - where: { id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความเสี่ยงของโครงการ"); - } - Object.assign(development, requestBody); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - - await this.developmentRiskRepository.save(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API ค้นหาโครงการ - * - * @summary DEV_00 - ค้นหาโครงการ # - * - */ - @Get("search") - async ListDevelopemt( - @Query("page") page: number = 1, - @Query("pageSize") pageSize: number = 10, - @Query() searchField?: "year" | "projectName", - @Query() searchKeyword: string = "", - ) { - let queryLike = "development.projectName LIKE :keyword"; - if (searchField == "year") { - queryLike = "development.year LIKE :keyword"; - } - const [record, total] = await this.developmentRepository - .createQueryBuilder("development") - .andWhere( - searchKeyword != undefined && searchKeyword != null && searchKeyword != "" - ? queryLike - : "1=1", - { - keyword: `%${searchKeyword}%`, - }, - ) - .skip((page - 1) * pageSize) - .take(pageSize) - .getManyAndCount(); - - const data = await Promise.all( - record.map((_data) => { - return { - id: _data.id, - year: _data.year, - projectName: _data.projectName, - dateStart: _data.dateStart, - dateEnd: _data.dateEnd, - totalDate: _data.totalDate, - addressAcademic: _data.addressAcademic, - topicAcademic: _data.topicAcademic, - }; - }), - ); - return new HttpSuccess({ data: data, total }); - } - - /** - * API รายการโครงการ/หลักสูตรการฝึกอบรมที่เสร็จสิ้น - * - * @summary DEV_004 - รายการโครงการ/หลักสูตรการฝึกอบรมที่เสร็จสิ้น - * - */ - @Get("done") - async GetDevelopmentListsDone(@Query("year") year: number) { - const [development, total] = await AppDataSource.getRepository(Development) - .createQueryBuilder("development") - .andWhere(year > 0 ? "development.year LIKE :year" : "1=1", { - year: `${year.toString()}`, - }) - .andWhere("development.status LIKE :status", { - status: `%FINISH%`, - }) - .select(["development.id", "development.projectName", "development.year"]) - .orderBy("development.year", "DESC") - .addOrderBy("development.createdAt", "DESC") - .getManyAndCount(); - - return new HttpSuccess({ data: development, total }); - } - - /** - * API ลบโครงการ/หลักสูตรการฝึกอบรม - * - * @summary DEV_003 - ลบโครงการ/หลักสูตรการฝึกอบรม #3 - * - * @param {string} id Id รายการ - */ - @Delete("{id}") - async DeleteDevelopment(@Path() id: string, @Request() request: RequestWithUser) { - await new permission().PermissionDelete(request, "SYS_DEV_PROJECT"); - const development = await this.developmentRepository.findOne({ - where: { id }, - relations: { - developmentActualPeoples: true, - developmentPlannedPeoples: true, - developmentActualGoals: true, - developmentPlannedGoals: true, - developmentProjectTypes: true, - developmentProjectTechniquePlanneds: true, - developmentProjectTechniqueActuals: true, - developmentEvaluations: true, - developmentAddresss: true, - developmentRisks: true, - developmentHistorys: true, - developmentOthers: true, - }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - - if ( - development.developmentPlannedGoals != null && - development.developmentPlannedGoals.length > 0 - ) { - const plannedGoalPosition = await this.plannedGoalPositionRepository.find({ - where: { plannedGoalId: In(development.developmentPlannedGoals.map((x) => x.id)) }, - }); - await this.plannedGoalPositionRepository.remove(plannedGoalPosition, { data: request }); - } - await this.actualPeopleRepository.remove(development.developmentActualPeoples, { - data: request, - }); - await this.plannedPeopleRepository.remove(development.developmentPlannedPeoples, { - data: request, - }); - await this.actualGoalRepository.remove(development.developmentActualGoals, { data: request }); - await this.plannedGoalRepository.remove(development.developmentPlannedGoals, { data: request }); - await this.developmentProjectTypeRepository.remove(development.developmentProjectTypes, { - data: request, - }); - await this.developmentProjectTechniquePlannedRepository.remove( - development.developmentProjectTechniquePlanneds, - { - data: request, - }, - ); - await this.developmentProjectTechniqueActualRepository.remove( - development.developmentProjectTechniqueActuals, - { - data: request, - }, - ); - await this.developmentEvaluationRepository.remove(development.developmentEvaluations, { - data: request, - }); - await this.developmentAddresssRepository.remove(development.developmentAddresss, { - data: request, - }); - await this.developmentRiskRepository.remove(development.developmentRisks, { - data: request, - }); - await this.developmentHistoryRepository.remove(development.developmentHistorys, { - data: request, - }); - await this.developmentOtherRepository.remove(development.developmentOthers, { - data: request, - }); - await this.developmentRepository.remove(development, { data: request }); - return new HttpSuccess(); - } - - /** - * API รายการโครงการ/หลักสูตรการฝึกอบรม - * - * @summary DEV_004 - รายการโครงการ/หลักสูตรการฝึกอบรม #4 - * - */ - @Get() - async GetDevelopmentLists( - @Request() request: RequestWithUser, - @Query("page") page: number = 1, - @Query("pageSize") pageSize: number = 10, - @Query("year") year: number, - @Query("status") status: string, - @Query("nodeId") nodeId?: string | null, - @Query("node") node?: number | null, - @Query("keyword") keyword?: string, - ) { - let _data = await new permission().PermissionOrgList(request, "SYS_DEV_PROJECT"); - await new CallAPI() - .PostData(request, "/org/finddna", _data) - .then((x) => { - _data = x; - }) - .catch((x) => {}); - const [development, total] = await AppDataSource.getRepository(Development) - .createQueryBuilder("development") - .andWhere(year > 0 ? "development.year LIKE :year" : "1=1", { - year: `${year.toString()}`, - }) - .andWhere( - node != undefined && node != null - ? node == 4 - ? "development.child4DnaId LIKE :nodeId" - : node == 3 - ? "development.child3DnaId LIKE :nodeId" - : node == 2 - ? "development.child2DnaId LIKE :nodeId" - : node == 1 - ? "development.child1DnaId LIKE :nodeId" - : "development.rootDnaId LIKE :nodeId" - : "1=1", - { - nodeId: `${nodeId}`, - }, - ) - .andWhere(status != undefined ? "development.status LIKE :status" : "1=1", { - status: `%${status}%`, - }) - .andWhere( - keyword != undefined - ? new Brackets((qb) => { - qb.where("development.projectName LIKE :keyword") - .orWhere("development.root LIKE :keyword") - .orWhere("development.child1 LIKE :keyword") - .orWhere("development.child2 LIKE :keyword") - .orWhere("development.child3 LIKE :keyword") - .orWhere("development.child4 LIKE :keyword"); - }) - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .andWhere( - _data.root != undefined && _data.root != null - ? _data.root[0] != null - ? `development.rootDnaId IN (:...root)` - : `development.rootDnaId is null` - : "1=1", - { - root: _data.root, - }, - ) - .andWhere( - _data.child1 != undefined && _data.child1 != null - ? _data.child1[0] != null - ? `development.child1DnaId IN (:...child1)` - : `development.child1DnaId is null` - : "1=1", - { - child1: _data.child1, - }, - ) - .andWhere( - _data.child2 != undefined && _data.child2 != null - ? _data.child2[0] != null - ? `development.child2DnaId IN (:...child2)` - : `development.child2DnaId is null` - : "1=1", - { - child2: _data.child2, - }, - ) - .andWhere( - _data.child3 != undefined && _data.child3 != null - ? _data.child3[0] != null - ? `development.child3DnaId IN (:...child3)` - : `development.child3DnaId is null` - : "1=1", - { - child3: _data.child3, - }, - ) - .andWhere( - _data.child4 != undefined && _data.child4 != null - ? _data.child4[0] != null - ? `development.child4DnaId IN (:...child4)` - : `development.child4DnaId is null` - : "1=1", - { - child4: _data.child4, - }, - ) - .select([ - "development.id", - "development.projectName", - "development.year", - "development.root", - "development.child1", - "development.child2", - "development.child3", - "development.child4", - ]) - .orderBy("development.year", "DESC") - .addOrderBy("development.createdAt", "DESC") - .skip((page - 1) * pageSize) - .take(pageSize) - .getManyAndCount(); - - return new HttpSuccess({ data: development, total }); - } - - /** - * API ปิดโครงการ - * - * @summary DEV_00 - ปิดโครงการ # - * - * @param {string} id Id โครงการ - */ - @Get("finish/{id}") - async FinishDevelopemtById(@Path() id: string, @Request() request: RequestWithUser) { - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - getDevelopment.status = "FINISH"; - getDevelopment.lastUpdateUserId = request.user.sub; - getDevelopment.lastUpdateFullName = request.user.name; - getDevelopment.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Development.", - // }); - await this.developmentRepository.save(getDevelopment, { data: request }); - return new HttpSuccess(getDevelopment); - } - - /** - * API สถานะโครงการ - * - * @summary DEV_00 - สถานะโครงการ # - * - * @param {string} id Id โครงการ - */ - @Get("status/{id}") - async StatusDevelopemtById(@Path() id: string) { - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - select: ["id", "status"], - }); - return new HttpSuccess(getDevelopment); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab1 - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab1 # - * - * @param {string} id Id โครงการ - */ - @Get("tab1/{id}") - async GetDevelopemtTab1ById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_PROJECT"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let node = null; - let nodeId = null; - let nodeDnaId = null; - if (getDevelopment.child4Id != null) { - node = 4; - nodeId = getDevelopment.child4Id; - nodeDnaId = getDevelopment.child4DnaId; - } else if (getDevelopment.child3Id != null) { - node = 3; - nodeId = getDevelopment.child3Id; - nodeDnaId = getDevelopment.child3DnaId; - } else if (getDevelopment.child2Id != null) { - node = 2; - nodeId = getDevelopment.child2Id; - nodeDnaId = getDevelopment.child2DnaId; - } else if (getDevelopment.child1Id != null) { - node = 1; - nodeId = getDevelopment.child1Id; - nodeDnaId = getDevelopment.child1DnaId; - } else if (getDevelopment.rootId != null) { - node = 0; - nodeId = getDevelopment.rootId; - nodeDnaId = getDevelopment.rootDnaId; - } - - const formattedData = { - id: getDevelopment.id, - revisionId: getDevelopment.orgRevisionId, - year: getDevelopment.year, - projectName: getDevelopment.projectName, - reason: getDevelopment.reason, - objective: getDevelopment.objective, - node: node, - nodeId: nodeId, - nodeDnaId: nodeDnaId, - root: getDevelopment.rootId, - child1: getDevelopment.child1Id, - child2: getDevelopment.child2Id, - child3: getDevelopment.child3Id, - child4: getDevelopment.child4Id, - rootDna: getDevelopment.rootDnaId, - child1Dna: getDevelopment.child1DnaId, - child2Dna: getDevelopment.child2DnaId, - child3Dna: getDevelopment.child3DnaId, - child4Dna: getDevelopment.child4DnaId, - }; - return new HttpSuccess(formattedData); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab2 - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab2 # - * - * @param {string} id Id โครงการ - */ - @Get("tab2/{id}") - async GetDevelopemtTab2ById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_PROJECT"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - //posTypeActual - relations: [ - "developmentActualPeoples", - "developmentPlannedPeoples", - "developmentActualGoals", - // "developmentActualGoals.posTypeActual", - // "developmentActualGoals.posLevelActual", - "developmentActualGoals", - "developmentPlannedGoals", - "developmentPlannedGoals.plannedGoalPositions", - // "developmentPlannedGoals.plannedGoalPositions.posTypePlanned", - // "developmentPlannedGoals.plannedGoalPositions.posLevelPlanned", - ], - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let _getDevelopment: any = { - id: getDevelopment.id, - actualPeoples: - getDevelopment.developmentActualPeoples == null - ? null - : getDevelopment.developmentActualPeoples.sort((a, b) => - (a.groupTarget == null ? "" : a.groupTarget).localeCompare( - b.groupTarget == null ? "" : b.groupTarget, - ), - ), - plannedPeoples: - getDevelopment.developmentPlannedPeoples == null - ? null - : getDevelopment.developmentPlannedPeoples.sort((a, b) => - (a.groupTarget == null ? "" : a.groupTarget).localeCompare( - b.groupTarget == null ? "" : b.groupTarget, - ), - ), - actualGoals: - getDevelopment.developmentActualGoals == null - ? null - : getDevelopment.developmentActualGoals - .sort((a, b) => - (a.groupTarget == null ? "" : a.groupTarget).localeCompare( - b.groupTarget == null ? "" : b.groupTarget, - ), - ) - .map((x) => ({ - id: x.id, - groupTarget: x.groupTarget, - groupTargetSub: x.groupTargetSub, - position: x.position, - // posTypeId: x.posTypeActualId, - // posType: x.posTypeActual == null ? null : x.posTypeActual.posTypeName, - // posLevelId: x.posLevelActualId, - // posLevel: x.posLevelActual == null ? null : x.posLevelActual.posLevelName, - posType: x.posTypeActual, - posLevel: x.posLevelActual, - type: x.type, - amount: x.amount, - })), - plannedGoals: - getDevelopment.developmentPlannedGoals == null - ? null - : getDevelopment.developmentPlannedGoals - .sort((a, b) => - (a.groupTarget == null ? "" : a.groupTarget).localeCompare( - b.groupTarget == null ? "" : b.groupTarget, - ), - ) - .map((x) => ({ - id: x.id, - groupTarget: x.groupTarget, - groupTargetSub: x.groupTargetSub, - type: x.type, - position: x.plannedGoalPositions.map((y) => ({ - id: y.id, - position: y.position, - posExecutive: y.posExecutive, - // posTypeId: y.posTypePlannedId, - // posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName, - // posLevelId: y.posLevelPlannedId, - // posLevel: y.posLevelPlanned == null ? null : y.posLevelPlanned.posLevelName, - posType: y.posTypePlanned, - posLevel: y.posLevelPlanned, - })), - amount: x.amount, - })), - }; - return new HttpSuccess(_getDevelopment); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab3 - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab3 # - * - * @param {string} id Id โครงการ - */ - @Get("tab3/{id}") - async GetDevelopemtTab3ById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_PROJECT"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - relations: [ - "developmentProjectTypes", - "developmentProjectTechniquePlanneds", - "developmentProjectTechniqueActuals", - "developmentAddresss", - ], - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let _getDevelopment: any = { - developmentProjectTypes: getDevelopment.developmentProjectTypes.map((x) => x.name).sort(), - projectModalActual: getDevelopment.projectModalActual, - projectModalPlanned: getDevelopment.projectModalPlanned, - isBackPlanned: getDevelopment.isBackPlanned, - isHoldPlanned: getDevelopment.isHoldPlanned, - projectDayBackPlanned: getDevelopment.projectDayBackPlanned, - projectDayHoldPlanned: getDevelopment.projectDayHoldPlanned, - projectNigthHoldPlanned: getDevelopment.projectNigthHoldPlanned, - developmentProjectTechniquePlanneds: getDevelopment.developmentProjectTechniquePlanneds - .map((x) => x.name) - .sort(), - isBackActual: getDevelopment.isBackActual, - isHoldActual: getDevelopment.isHoldActual, - projectDayBackActual: getDevelopment.projectDayBackActual, - projectDayHoldActual: getDevelopment.projectDayHoldActual, - projectNigthHoldActual: getDevelopment.projectNigthHoldActual, - reasonActual70: getDevelopment.reasonActual70, - reasonActual20: getDevelopment.reasonActual20, - reasonActual10: getDevelopment.reasonActual10, - isReasonActual70: getDevelopment.isReasonActual70, - isReasonActual20: getDevelopment.isReasonActual20, - isReasonActual10: getDevelopment.isReasonActual10, - reasonPlanned70: getDevelopment.reasonPlanned70, - reasonPlanned20: getDevelopment.reasonPlanned20, - reasonPlanned10: getDevelopment.reasonPlanned10, - isReasonPlanned70: getDevelopment.isReasonPlanned70, - isReasonPlanned20: getDevelopment.isReasonPlanned20, - isReasonPlanned10: getDevelopment.isReasonPlanned10, - developmentProjectTechniqueActuals: getDevelopment.developmentProjectTechniqueActuals - .map((x) => x.name) - .sort(), - strategyChild1Planned: getDevelopment.strategyChild1PlannedId, - strategyChild2Planned: getDevelopment.strategyChild2PlannedId, - strategyChild3Planned: getDevelopment.strategyChild3PlannedId, - strategyChild4Planned: getDevelopment.strategyChild4PlannedId, - strategyChild5Planned: getDevelopment.strategyChild5PlannedId, - strategyChild1Actual: getDevelopment.strategyChild1ActualId, - strategyChild2Actual: getDevelopment.strategyChild2ActualId, - strategyChild3Actual: getDevelopment.strategyChild3ActualId, - strategyChild4Actual: getDevelopment.strategyChild4ActualId, - strategyChild5Actual: getDevelopment.strategyChild5ActualId, - dateStart: getDevelopment.dateStart, - dateEnd: getDevelopment.dateEnd, - totalDate: getDevelopment.totalDate, - developmentAddresss: - getDevelopment.developmentAddresss == null - ? null - : getDevelopment.developmentAddresss.sort( - (a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(), - ), - }; - return new HttpSuccess(_getDevelopment); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab3 - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab3 # - * - * @param {string} id Id โครงการ - */ - @Get("tab3_1/{id}") - async GetDevelopemtTab3_1ById(@Path() id: string) { - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - relations: [ - "developmentProjectTypes", - "developmentProjectTechniquePlanneds", - "developmentProjectTechniqueActuals", - ], - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let _getDevelopment: any = { - projectModalActual: getDevelopment.projectModalActual, - isBackActual: getDevelopment.isBackActual, - isHoldActual: getDevelopment.isHoldActual, - projectDayBackActual: getDevelopment.projectDayBackActual, - projectDayHoldActual: getDevelopment.projectDayHoldActual, - projectNigthHoldActual: getDevelopment.projectNigthHoldActual, - reasonActual70: getDevelopment.reasonActual70, - reasonActual20: getDevelopment.reasonActual20, - reasonActual10: getDevelopment.reasonActual10, - isReasonActual70: getDevelopment.isReasonActual70, - isReasonActual20: getDevelopment.isReasonActual20, - isReasonActual10: getDevelopment.isReasonActual10, - developmentProjectTechniqueActuals: getDevelopment.developmentProjectTechniqueActuals - .map((x) => x.name) - .sort(), - strategyChild1Actual: getDevelopment.strategyChild1ActualId, - strategyChild2Actual: getDevelopment.strategyChild2ActualId, - strategyChild3Actual: getDevelopment.strategyChild3ActualId, - strategyChild4Actual: getDevelopment.strategyChild4ActualId, - strategyChild5Actual: getDevelopment.strategyChild5ActualId, - }; - return new HttpSuccess(_getDevelopment); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab4 - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab4 # - * - * @param {string} id Id โครงการ - */ - @Get("tab4/{id}") - async GetDevelopemtTab4ById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_PROJECT"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - relations: ["developmentEvaluations"], - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let _getDevelopment = { - developmentEvaluations: - getDevelopment.developmentEvaluations == null - ? null - : getDevelopment.developmentEvaluations.sort((a, b) => - (a.indicators == null ? "" : a.indicators).localeCompare( - b.indicators == null ? "" : b.indicators, - ), - ), - progressTracking: getDevelopment.progressTracking, - projectEvaluation: getDevelopment.projectEvaluation, - }; - - return new HttpSuccess(_getDevelopment); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab5 - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab5 # - * - * @param {string} id Id โครงการ - */ - @Get("tab5/{id}") - async GetDevelopemtTab5ById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_PROJECT"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); - const getDevelopment = await this.developmentRepository.findOne({ - relations: ["developmentOthers"], - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - let _getDevelopment = { - developmentOthers: - getDevelopment.developmentOthers == null - ? null - : getDevelopment.developmentOthers.sort((a, b) => - (a.createdAt.toString() == null ? "" : a.createdAt.toString()).localeCompare( - b.createdAt.toString() == null ? "" : b.createdAt.toString(), - ), - ), - obstacle: getDevelopment.obstacle, - suggestion: getDevelopment.suggestion, - project: getDevelopment.project, - isPassAllocate: getDevelopment.isPassAllocate, - isPassNoAllocate: getDevelopment.isPassNoAllocate, - isNoPass: getDevelopment.isNoPass, - isBudget: getDevelopment.isBudget, - isOutBudget: getDevelopment.isOutBudget, - }; - - return new HttpSuccess(_getDevelopment); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6 - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 # - * - * @param {string} id Id โครงการ - */ - @Get("tab6/{id}") - async GetDevelopemtTab6ById(@Path() id: string) { - const getDevelopment = await this.developmentHistoryRepository.find({ - where: { developmentId: id }, - relations: ["posLevel", "posType", "employeePosLevel", "employeePosType"], - order: { - isDone: "ASC", - isDoneIDP: "ASC", - citizenId: "ASC", - }, - }); - const _getDevelopment = getDevelopment.map((item) => ({ - id: item.id, - type: item.type, - idcard: item.citizenId, - fullName: item.prefix + item.firstName + " " + item.lastName, - prefix: item.prefix, - firstName: item.firstName, - lastName: item.lastName, - position: item.position, - posTypeName: - item.type == "OFFICER" - ? item.posType - ? item.posType.posTypeName - : null - : item.employeePosType - ? item.employeePosType.posTypeName - : null, - posLevelName: - item.type == "OFFICER" - ? item.posLevel - ? item.posLevel.posLevelName - : null - : item.employeePosLevel - ? `${item.employeePosType.posTypeShortName ?? ""} ${item.employeePosLevel.posLevelName ?? ""}` - : null, - posExecutive: item.posExecutive, - org: item.org, - trainingDays: item.trainingDays, - commandNumber: item.order, - commandDate: item.dateOrder, - dateStart: item.dateStart, - dateEnd: item.dateEnd, - isDone: item.isDone, - isDoneIDP: item.isDoneIDP, - isProfile: item.isProfile, - })); - return new HttpSuccess(_getDevelopment); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6 ส่งบันทึกทะเบียนประวัติ (ข้อมูลผลงาน>การฝึกอบรม/ดูงาน) - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 ส่งบันทึกทะเบียนประวัติ (ข้อมูลผลงาน>การฝึกอบรม/ดูงาน) # - * - * @param {string} id Id โครงการ - */ - @Get("tab6/done/{id}") - async GetDevelopemtTab6DoneById(@Path() id: string, @Request() request: RequestWithUser) { - const getDevelopment = await this.developmentHistoryRepository.find({ - where: { developmentId: id, isDone: false }, - relations: ["development"], - }); - await Promise.all( - getDevelopment.map(async (x) => { - const _data = Object.assign(new DevelopmentHistory(), x); - if (x.type == "OFFICER") { - await new CallAPI() - .PostData(request, "/org/profile/training", { - profileId: x.profileId, - name: x.development == null ? null : x.development.projectName, - topic: x.development == null ? null : x.development.topicAcademic, - yearly: x.development == null ? null : x.development.year, - place: x.development == null ? null : x.development.addressAcademic, - duration: x.trainingDays, - department: x.development == null ? null : x.development.root, - numberOrder: x.order, - dateOrder: x.dateOrder, - startDate: x.dateStart, - endDate: x.dateEnd, - isDate: true, - developmentId: id, - }) - .then((x) => { - _data.isDone = true; - }) - .catch((x) => { - _data.isDone = false; - }); - } else if (x.type == "EMPLOYEE") { - await new CallAPI() - .PostData(request, "/org/profile-employee/training", { - profileEmployeeId: x.profileId, - name: x.development == null ? null : x.development.projectName, - topic: x.development == null ? null : x.development.topicAcademic, - yearly: x.development == null ? null : x.development.year, - place: x.development == null ? null : x.development.addressAcademic, - duration: x.trainingDays, - department: x.development == null ? null : x.development.root, - numberOrder: x.order, - dateOrder: x.dateOrder, - startDate: x.dateStart, - endDate: x.dateEnd, - isDate: true, - developmentId: id, - }) - .then((x) => { - _data.isDone = true; - }) - .catch((x) => { - _data.isDone = false; - }); - } - - _data.lastUpdateUserId = request.user.sub; - _data.lastUpdateFullName = request.user.name; - _data.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(_data, { data: request }); - }), - ); - return new HttpSuccess(getDevelopment); - } - - /** - * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6 IDP ส่งบันทึกทะเบียนประวัติ (ข้อมูลผลงาน>ผลการประเมินการปฏิบัติราชการ) - * - * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 IDP ส่งบันทึกทะเบียนประวัติ (ข้อมูลผลงาน>ผลการประเมินการปฏิบัติราชการ)# - * - * @param {string} id Id โครงการ - */ - @Get("tab6/done-idp/{id}") - async GetDevelopemtTab6IDPDoneById(@Path() id: string, @Request() request: RequestWithUser) { - const getDevelopment = await this.developmentHistoryRepository.find({ - where: { developmentId: id, isDoneIDP: false }, - relations: ["development", "development.developmentProjectTechniqueActuals"], - }); - - let isDevelopment70: boolean = false; - const dev70Lists = [ - "on_the_job_training", - "job_project_assignment", - "job_shadowing", - "job_enlargement", - "internal_trainer", - "rotation", - "activity", - "site_visit", - "benchmarking", - "problem_solving", - "team_working", - "other1", - ]; - let isDevelopment20: boolean = false; - const dev20Lists = [ - "coaching", - "mentoring", - "team_meeting", - "consulting", - "feedback", - "other2", - ]; - let isDevelopment10: boolean = false; - const dev10Lists = [ - "self_learning", - "classroom_training", - "in_house_training", - "public_training", - "e_training", - "meeting", - "seminar", - "other3", - ]; - await Promise.all( - getDevelopment.map(async (x) => { - const _data = Object.assign(new DevelopmentHistory(), x); - - const techniqueActuals = - x.development?.developmentProjectTechniqueActuals.flatMap((x) => x.name) || []; - isDevelopment70 = - techniqueActuals.length > 0 && dev70Lists.some((item) => techniqueActuals.includes(item)); - isDevelopment20 = - techniqueActuals.length > 0 && dev20Lists.some((item) => techniqueActuals.includes(item)); - isDevelopment10 = - techniqueActuals.length > 0 && dev10Lists.some((item) => techniqueActuals.includes(item)); - - if (x.type == "OFFICER") { - await new CallAPI() - .PostData(request, "/org/profile/development", { - type: "DEVELOP", - profileId: x.profileId, - name: x.development.projectName, - achievement10: null, - achievement5: null, - achievement0: null, - kpiDevelopmentId: x.development.id, - reasonDevelopment70: x.development.reasonActual70, - reasonDevelopment20: x.development.reasonActual20, - reasonDevelopment10: x.development.reasonActual10, - isDevelopment70: isDevelopment70, - isDevelopment20: isDevelopment20, - isDevelopment10: isDevelopment10, - developmentTarget: null, - developmentResults: null, - developmentReport: null, - developmentProjects: x.development.developmentProjectTechniqueActuals.map( - (x) => x.name, - ), - }) - .then((x) => { - _data.isDoneIDP = true; - }) - .catch((x) => { - _data.isDoneIDP = false; - }); - } else if (x.type == "EMPLOYEE") { - await new CallAPI() - .PostData(request, "/org/profile-employee/development", { - type: "DEVELOP", - profileEmployeeId: x.profileId, - name: x.development.projectName, - achievement10: null, - achievement5: null, - achievement0: null, - kpiDevelopmentId: x.development.id, - reasonDevelopment70: x.development.reasonActual70, - reasonDevelopment20: x.development.reasonActual20, - reasonDevelopment10: x.development.reasonActual10, - isDevelopment70: isDevelopment70, - isDevelopment20: isDevelopment20, - isDevelopment10: isDevelopment10, - developmentTarget: null, - developmentResults: null, - developmentReport: null, - developmentProjects: x.development.developmentProjectTechniqueActuals.map( - (x) => x.name, - ), - }) - .then((x) => { - _data.isDoneIDP = true; - }) - .catch((x) => { - _data.isDoneIDP = false; - }); - } - - _data.lastUpdateUserId = request.user.sub; - _data.lastUpdateFullName = request.user.name; - _data.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(_data, { data: request }); - }), - ); - return new HttpSuccess(getDevelopment); - } - - /** - * API list หน่วยงาน - * - * @summary DEV_00 - list หน่วยงาน # - * - */ - @Get("org/root") - async GetOrgDevelopemt() { - const getOrg = await this.developmentRepository - .createQueryBuilder("development") - .select("development.root") - .groupBy("development.root") - .getRawMany(); - if (getOrg.length > 0) { - return new HttpSuccess(getOrg.map((x) => x.development_root)); - } - - return new HttpSuccess(getOrg); - } - - @Get("registry/{type}/{developmentId}") - async developmentDetail( - @Path() developmentId: string, - @Path() type: string, - @Request() request: RequestWithUser, - ) { - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: developmentId }, - relations: [ - "developmentProjectTypes", - "developmentProjectTechniquePlanneds", - "developmentProjectTechniqueActuals", - "developmentAddresss", - ], - }); - if (!getDevelopment) - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - - if (type.trim().toLocaleUpperCase() == "OFFICER") { - let _workflow = await new permission().Workflow( - request, - developmentId, - "SYS_REGISTRY_OFFICER", - ); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_REGISTRY_OFFICER"); - } else if (type.trim().toLocaleUpperCase() == "USER") { - } else { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถเข้าถึงข้อมูลนี้ได้"); - } - - let _getDevelopment: any = { - id: getDevelopment.id, - evaluationId: null, - target: null, - summary: null, - point: null, - name: getDevelopment.projectName, - achievement10: "มีผลการพัฒนาและมีการดำเนินการตามเป้าหมายการนำไปพัฒนางาน", - achievement5: "มีผลการพัฒนาแต่ยังไม่ได้ดำเนินการตามเป้าหมายการนำไปพัฒนางาน", - achievement0: "ไม่ได้ดำเนินการพัฒนา", - isDevelopment70: getDevelopment.isReasonActual70, - isDevelopment20: getDevelopment.isReasonActual20, - isDevelopment10: getDevelopment.isReasonActual10, - reasonDevelopment70: getDevelopment.reasonActual70, - reasonDevelopment20: getDevelopment.reasonActual20, - reasonDevelopment10: getDevelopment.reasonActual10, - selectType: "PROJECT", - selectTypeYear: getDevelopment.year, - selectTypeId: null, - developmentProjects: getDevelopment.developmentProjectTechniqueActuals - .map((x) => x.name) - .sort(), - }; - return new HttpSuccess(_getDevelopment); - } - - /** - * API upload User - * - * @summary DEV_0 - upload User # - * - * @param {string} id Id โครงการ - */ - @Post("tab6/{id}") - @UseInterceptors(FileInterceptor("file")) - async UploadUserDevelopemtById( - @Path() id: string, - @UploadedFile() file: Express.Multer.File, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_PROJECT"); - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - relations: { - developmentHistorys: true, - }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const workbook = xlsx.read(file.buffer, { type: "buffer" }); - const sheetName = workbook.SheetNames[0]; // Assuming we're reading the first sheet - const sheet = workbook.Sheets[sheetName]; - const getDevelopments = xlsx.utils.sheet_to_json(sheet); - const before = null; - await Promise.all( - getDevelopments.map(async (item: any) => { - if (item["รหัสประจำตัวประชาชน"] == undefined || item["รหัสประจำตัวประชาชน"].length != 13) - return; - const oldProfile: any = getDevelopment.developmentHistorys.find( - (x) => x.citizenId == item["รหัสประจำตัวประชาชน"], - ); - if (oldProfile != null) { - if (oldProfile.isDone == true) return; - } - if (item["ประเภท"] == undefined) return; - let development = Object.assign(new DevelopmentHistory(), oldProfile); - if (item["ประเภท"] == "ข้าราชการกรุงเทพมหานครสามัญ" || item["ประเภท"] == "ขรก.กทม. สามัญ") { - await new CallAPI() - .GetData(request, `/org/unauthorize/officer/citizen/${item["รหัสประจำตัวประชาชน"]}`) - .then(async (x: any) => { - development = Object.assign(development, x); - development.dateStart = - item["วันที่เริ่มต้น"] == undefined ? null : item["วันที่เริ่มต้น"]; - development.dateEnd = - item["วันที่สิ้นสุด"] == undefined ? null : item["วันที่สิ้นสุด"]; - development.order = - item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"] == undefined - ? null - : item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"]; - development.dateOrder = - item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"] == undefined - ? null - : new Date(item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"]); - development.trainingDays = - item["จำนวนวันที่อบรม"] == undefined ? null : item["จำนวนวันที่อบรม"]; - development.posLevelId = x.posLevelId; - development.posTypeId = x.posTypeId; - development.employeePosLevelId = null; - development.employeePosTypeId = null; - development.developmentId = id; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - development.isProfile = true; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - }) - .catch(async (x) => { - let _null: any = null; - development.prefix = item["คำนำหน้า"] == undefined ? null : item["คำนำหน้า"]; - development.firstName = item["ชื่อ"] == undefined ? null : item["ชื่อ"]; - development.lastName = item["นามสกุล"] == undefined ? null : item["นามสกุล"]; - development.position = item["ตำแหน่ง"] == undefined ? null : item["ตำแหน่ง"]; - development.org = item["สังกัด"] == undefined ? null : item["สังกัด"]; - development.dateStart = - item["วันที่เริ่มต้น"] == undefined ? null : item["วันที่เริ่มต้น"]; - development.dateEnd = - item["วันที่สิ้นสุด"] == undefined ? null : item["วันที่สิ้นสุด"]; - development.citizenId = - item["รหัสประจำตัวประชาชน"] == undefined ? _null : item["รหัสประจำตัวประชาชน"]; - development.type = "OFFICER" == undefined ? _null : "OFFICER"; - development.order = - item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"] == undefined - ? null - : item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"]; - development.dateOrder = - item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"] == undefined - ? _null - : new Date(item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"]); - development.trainingDays = - item["จำนวนวันที่อบรม"] == undefined ? null : item["จำนวนวันที่อบรม"]; - development.posLevelId = x.posLevelId; - development.posTypeId = x.posTypeId; - development.employeePosLevelId = null; - development.employeePosTypeId = null; - development.developmentId = id; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - development.isProfile = false; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - }); - } else if (item["ประเภท"] == "ลูกจ้างประจำ") { - await new CallAPI() - .GetData(request, `/org/unauthorize/employee/citizen/${item["รหัสประจำตัวประชาชน"]}`) - .then(async (x: any) => { - development = Object.assign(development, x); - development.dateStart = - item["วันที่เริ่มต้น"] == undefined ? null : item["วันที่เริ่มต้น"]; - development.dateEnd = - item["วันที่สิ้นสุด"] == undefined ? null : item["วันที่สิ้นสุด"]; - development.order = - item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"] == undefined - ? null - : item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"]; - development.dateOrder = - item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"] == undefined - ? null - : new Date(item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"]); - development.trainingDays = - item["จำนวนวันที่อบรม"] == undefined ? null : item["จำนวนวันที่อบรม"]; - development.posLevelId = null; - development.posTypeId = null; - development.employeePosLevelId = x.posLevelId; - development.employeePosTypeId = x.posTypeId; - development.developmentId = id; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - development.isProfile = true; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - }) - .catch(async (x) => { - let _null: any = null; - development.prefix = item["คำนำหน้า"] == undefined ? null : item["คำนำหน้า"]; - development.firstName = item["ชื่อ"] == undefined ? null : item["ชื่อ"]; - development.lastName = item["นามสกุล"] == undefined ? null : item["นามสกุล"]; - development.position = item["ตำแหน่ง"] == undefined ? null : item["ตำแหน่ง"]; - development.org = item["สังกัด"] == undefined ? null : item["สังกัด"]; - development.dateStart = - item["วันที่เริ่มต้น"] == undefined ? null : item["วันที่เริ่มต้น"]; - development.dateEnd = - item["วันที่สิ้นสุด"] == undefined ? null : item["วันที่สิ้นสุด"]; - development.citizenId = - item["รหัสประจำตัวประชาชน"] == undefined ? _null : item["รหัสประจำตัวประชาชน"]; - development.type = "EMPLOYEE" == undefined ? _null : "EMPLOYEE"; - development.order = - item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"] == undefined - ? null - : item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"]; - development.dateOrder = - item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"] == undefined - ? _null - : new Date(item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"]); - development.trainingDays = - item["จำนวนวันที่อบรม"] == undefined ? null : item["จำนวนวันที่อบรม"]; - development.posLevelId = x.posLevelId; - development.posTypeId = x.posTypeId; - development.employeePosLevelId = null; - development.employeePosTypeId = null; - development.developmentId = id; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - development.isProfile = false; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - }); - } else { - let development = new DevelopmentHistory(); - let _null: any = null; - development.prefix = item["คำนำหน้า"] == undefined ? null : item["คำนำหน้า"]; - development.firstName = item["ชื่อ"] == undefined ? null : item["ชื่อ"]; - development.lastName = item["นามสกุล"] == undefined ? null : item["นามสกุล"]; - development.position = item["ตำแหน่ง"] == undefined ? null : item["ตำแหน่ง"]; - development.org = item["สังกัด"] == undefined ? null : item["สังกัด"]; - development.dateStart = - item["วันที่เริ่มต้น"] == undefined ? null : item["วันที่เริ่มต้น"]; - development.dateEnd = item["วันที่สิ้นสุด"] == undefined ? null : item["วันที่สิ้นสุด"]; - development.citizenId = - item["รหัสประจำตัวประชาชน"] == undefined ? _null : item["รหัสประจำตัวประชาชน"]; - development.type = "OTHER"; - development.order = - item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"] == undefined - ? null - : item["เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"]; - development.dateOrder = - item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"] == undefined - ? _null - : new Date(item["คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"]); - development.trainingDays = - item["จำนวนวันที่อบรม"] == undefined ? null : item["จำนวนวันที่อบรม"]; - development.posLevelId = null; - development.posTypeId = null; - development.employeePosLevelId = null; - development.employeePosTypeId = null; - development.developmentId = id; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - development.isProfile = false; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - } - }), - ); - return new HttpSuccess(getDevelopments); - } - /** - * API upload User One by one - * - * @summary DEV_0 - upload User One by one # - * - * @param {string} id Id โครงการ - */ - @Post("uploadUser/{id}") - async UploadUserDevelopemtOBO( - @Path() id: string, - @Body() requestBody: CreateDevelopmentHistoryOBO, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_PROJECT"); - const getDevelopment = await this.developmentRepository.findOne({ - where: { id: id }, - relations: { - developmentHistorys: true, - }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); - } - const oldProfile: any = await this.developmentHistoryRepository.findOne({ - where: { citizenId: requestBody.citizenId }, - }); - - const before = null; - let status = null; - let _null: any = null; - if (oldProfile != null) { - if (oldProfile.isDone == true) - throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ข้อมูลนี้ได้ถูกบันทึกแล้ว"); - oldProfile.dateStart = requestBody.dateStart == undefined ? _null : requestBody.dateStart; - oldProfile.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; - oldProfile.order = requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; - oldProfile.dateOrder = - requestBody.commandDate == undefined ? _null : new Date(requestBody.commandDate); - oldProfile.trainingDays = - requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; - oldProfile.createdUserId = request.user.sub; - oldProfile.createdFullName = request.user.name; - oldProfile.lastUpdateUserId = request.user.sub; - oldProfile.lastUpdateFullName = request.user.name; - oldProfile.createdAt = new Date(); - oldProfile.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(oldProfile, { data: request }); - setLogDataDiff(request, { before, after: oldProfile }); - status = oldProfile.isProfile; - } - - if (requestBody.type == "OFFICER") { - await new CallAPI() - .GetData(request, `/org/unauthorize/officer/citizen/${requestBody.citizenId}`) - .then(async (x: any) => { - let development = Object.assign(new DevelopmentHistory(), x); - development.dateStart = - requestBody.dateStart == undefined ? _null : requestBody.dateStart; - development.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; - development.order = - requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; - development.dateOrder = - requestBody.commandDate == undefined ? _null : requestBody.commandDate; - development.trainingDays = - requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; - development.posLevelId = x.posLevelId == undefined ? _null : x.posLevelId; - development.posTypeId = x.posTypeId == undefined ? _null : x.posTypeId; - development.employeePosLevelId = null; - development.employeePosTypeId = null; - development.developmentId = id; - development.isProfile = true; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - status = development.isProfile; - }) - .catch(async (x) => { - let development = new DevelopmentHistory(); - let _null: any = null; - development.prefix = requestBody.prefix == undefined ? _null : requestBody.prefix; - development.firstName = - requestBody.firstName == undefined ? _null : requestBody.firstName; - development.lastName = requestBody.lastName == undefined ? _null : requestBody.lastName; - development.position = requestBody.position == undefined ? _null : requestBody.position; - development.org = requestBody.org == undefined ? _null : requestBody.org; - development.dateStart = - requestBody.dateStart == undefined ? _null : requestBody.dateStart; - development.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; - development.citizenId = - requestBody.citizenId == undefined ? _null : requestBody.citizenId; - development.type = requestBody.type == undefined ? _null : requestBody.type; - development.order = - requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; - development.dateOrder = - requestBody.commandDate == undefined ? _null : requestBody.commandDate; - development.trainingDays = - requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; - development.posLevelId = x.posLevelId == undefined ? _null : x.posLevelId; - development.posTypeId = x.posTypeId == undefined ? _null : x.posTypeId; - development.employeePosLevelId = null; - development.employeePosTypeId = null; - development.developmentId = id; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - development.isProfile = false; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - status = development.isProfile; - }); - } else { - await new CallAPI() - .GetData(request, `/org/unauthorize/employee/citizen/${requestBody.citizenId}`) - .then(async (x: any) => { - let development = Object.assign(new DevelopmentHistory(), x); - development.dateStart = - requestBody.dateStart == undefined ? _null : requestBody.dateStart; - development.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; - development.order = - requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; - development.dateOrder = - requestBody.commandDate == undefined ? _null : requestBody.commandDate; - development.trainingDays = - requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; - development.posLevelId = null; - development.posTypeId = null; - development.employeePosLevelId = x.posLevelId; - development.employeePosTypeId = x.posTypeId; - development.developmentId = id; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - development.isProfile = true; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - status = development.isProfile; - }) - .catch(async (x) => { - let development = new DevelopmentHistory(); - let _null: any = null; - development.prefix = requestBody.prefix == undefined ? _null : requestBody.prefix; - development.firstName = - requestBody.firstName == undefined ? _null : requestBody.firstName; - development.lastName = requestBody.lastName == undefined ? _null : requestBody.lastName; - development.position = requestBody.position == undefined ? _null : requestBody.position; - development.org = requestBody.org == undefined ? _null : requestBody.org; - development.dateStart = - requestBody.dateStart == undefined ? _null : requestBody.dateStart; - development.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; - development.citizenId = - requestBody.citizenId == undefined ? _null : requestBody.citizenId; - development.type = requestBody.type == undefined ? _null : requestBody.type; - development.order = - requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; - development.dateOrder = - requestBody.commandDate == undefined ? _null : requestBody.commandDate; - development.trainingDays = - requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; - development.posLevelId = x.posLevelId; - development.posTypeId = x.posTypeId; - development.employeePosLevelId = null; - development.employeePosTypeId = null; - development.developmentId = id; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - development.isProfile = false; - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - status = development.isProfile; - }); - } - return new HttpSuccess(status); - } -} diff --git a/src/controllers/DevelopmentEmployeeHistoryController.ts b/src/controllers/DevelopmentEmployeeHistoryController.ts deleted file mode 100644 index 007d978..0000000 --- a/src/controllers/DevelopmentEmployeeHistoryController.ts +++ /dev/null @@ -1,434 +0,0 @@ -import { - Controller, - Get, - Post, - Put, - Delete, - Route, - Security, - Tags, - Body, - Path, - Request, -} from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import { Brackets, Not } from "typeorm"; -import HttpSuccess from "../interfaces/http-success"; -import HttpError from "../interfaces/http-error"; -import HttpStatusCode from "../interfaces/http-status"; -import { Development } from "../entities/Development"; -import { - CreateDevelopmentHistory, - DevelopmentHistory, - UpdateDevelopmentHistory, -} from "../entities/DevelopmentHistory"; -import { EmployeePosType } from "../entities/EmployeePosType"; -import { EmployeePosLevel } from "../entities/EmployeePosLevel"; -import { RequestWithUser } from "../middlewares/user"; -import { setLogDataDiff } from "../interfaces/utils"; -import permission from "../interfaces/permission"; - -@Route("api/v1/development/history/employee") -@Tags("DevelopmentEmployeeHistory") -@Security("bearerAuth") -export class DevelopmentEmployeeHistoryController extends Controller { - private developmentHistoryRepository = AppDataSource.getRepository(DevelopmentHistory); - private developmentRepository = AppDataSource.getRepository(Development); - private posTypeRepository = AppDataSource.getRepository(EmployeePosType); - private posLevelRepository = AppDataSource.getRepository(EmployeePosLevel); - - /** - * API list หน่วยงาน - * - * @summary DEV_00 - list หน่วยงาน # - * - */ - @Get("org/{year}") - async GetOrgDevelopemt(@Request() request: RequestWithUser, @Path() year: number) { - await new permission().PermissionList(request, "SYS_DEV_HISTORY_EMP"); - const type = "EMPLOYEE"; - const getOrg = await this.developmentHistoryRepository - .createQueryBuilder("developmentHistory") - .leftJoinAndSelect("developmentHistory.development", "development") - .andWhere("developmentHistory.root IS NOT NULL") - .andWhere(year > 0 ? "development.year LIKE :year" : "1=1", { - year: `${year.toString()}`, - }) - .andWhere("developmentHistory.type LIKE :type", { - type: `${type}`, - }) - .select("developmentHistory.root") - .groupBy("developmentHistory.root") - .getRawMany(); - if (getOrg.length > 0) { - return new HttpSuccess(getOrg.map((x) => x.developmentHistory_root)); - } - return new HttpSuccess(getOrg); - } - - /** - * API เพิ่มประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_006 - เพิ่มประวัติการฝึกอบรม/ดูงาน#6 - * - */ - @Post() - async CreateDevelopmentHistory( - @Body() requestBody: CreateDevelopmentHistory, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_HISTORY_EMP"); - const type = "EMPLOYEE"; - const chk_name = await this.developmentHistoryRepository.find({ - where: { - citizenId: requestBody.citizenId, - developmentId: requestBody.developmentId, - type: type, - }, - }); - if (chk_name.length > 0) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว"); - } - - const checkId = await this.developmentRepository.findOne({ - where: { id: requestBody.developmentId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม"); - } - if (requestBody.posTypeId != null) { - const checkId = await this.posTypeRepository.findOne({ - where: { id: requestBody.posTypeId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - if (requestBody.posLevelId != null) { - const checkId = await this.posLevelRepository.findOne({ - where: { id: requestBody.posLevelId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - const before = null; - const development = Object.assign(new DevelopmentHistory(), requestBody); - development.type = type; - development.employeePosTypeId = requestBody.posTypeId; - development.employeePosLevelId = requestBody.posLevelId; - development.posTypeId = null; - development.posLevelId = null; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_007 - แก้ไขประวัติการฝึกอบรม/ดูงาน #7 - * - * @param {string} id Id โครงการ - */ - @Put("{id}") - async UpdateDevelopmentHistory( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentHistory, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_HISTORY_EMP"); - const type = "EMPLOYEE"; - const development = await this.developmentHistoryRepository.findOne({ - where: { id: id, type: type }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้"); - } - const chk_name = await this.developmentHistoryRepository.find({ - where: { - citizenId: requestBody.citizenId, - developmentId: requestBody.developmentId, - type: type, - id: Not(id), - }, - }); - if (chk_name.length > 0) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว"); - } - const checkId = await this.developmentRepository.findOne({ - where: { id: requestBody.developmentId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม"); - } - if (requestBody.posTypeId != null) { - const checkId = await this.posTypeRepository.findOne({ - where: { id: requestBody.posTypeId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - if (requestBody.posLevelId != null) { - const checkId = await this.posLevelRepository.findOne({ - where: { id: requestBody.posLevelId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - Object.assign(development, requestBody); - development.type = type; - development.employeePosTypeId = requestBody.posTypeId; - development.employeePosLevelId = requestBody.posLevelId; - development.posTypeId = null; - development.posLevelId = null; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API ลบประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_008 - ลบประวัติการฝึกอบรม/ดูงาน #8 - * - * @param {string} id Id โครงการ - */ - @Delete("{id}") - async DeleteDevelopmentHistory(@Path() id: string, @Request() request: RequestWithUser) { - await new permission().PermissionDelete(request, "SYS_DEV_HISTORY_EMP"); - const type = "EMPLOYEE"; - const development = await this.developmentHistoryRepository.findOne({ - where: { id: id, type: type }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้"); - } - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Remove DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.remove(development, { data: request }); - return new HttpSuccess(); - } - - /** - * API รายการประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_009 - รายการประวัติการฝึกอบรม/ดูงาน #9 - * - */ - @Post("filter") - async GetDevelopmentHistoryLists( - @Request() request: RequestWithUser, - @Body() - body: { - page: number; - pageSize: number; - keyword?: string; - year?: number; - root: string | null; - }, - ) { - await new permission().PermissionList(request, "SYS_DEV_HISTORY_EMP"); - const type = "EMPLOYEE"; - const [development, total] = await AppDataSource.getRepository(DevelopmentHistory) - .createQueryBuilder("developmentHistory") - .leftJoinAndSelect("developmentHistory.development", "development") - .leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel") - .leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType") - .andWhere( - body.year != 0 && body.year != null && body.year != undefined - ? "development.year = :year" - : "1=1", - { year: body.year }, - ) - .andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", { root: body.root }) - .andWhere("developmentHistory.type = :type", { type: type }) - .andWhere( - new Brackets((qb) => { - qb.where( - body.keyword != null && body.keyword != "" - ? "CONCAT(developmentHistory.prefix, developmentHistory.firstName, ' ', developmentHistory.lastName) LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "CONCAT(employeePosType.posTypeShortName,' ',employeePosLevel.posLevelName) LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "developmentHistory.position LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "development.projectName LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "employeePosType.posTypeName LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "employeePosLevel.posLevelName LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "developmentHistory.citizenId LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ); - }), - ) - .orderBy("development.year", "DESC") - .addOrderBy("developmentHistory.createdAt", "DESC") - .skip((body.page - 1) * body.pageSize) - .take(body.pageSize) - .getManyAndCount(); - - const formattedData = development.map((item) => ({ - id: item.id, - citizenId: item.citizenId, - fullName: - item.prefix != null && item.firstName != null && item.lastName != null - ? `${item?.prefix}${item?.firstName} ${item?.lastName}` - : "", - position: item.position, - year: item.development.year, - posType: item.employeePosType ? item.employeePosType.posTypeName : null, - posLevel: - item.employeePosType && item.employeePosLevel - ? `${item.employeePosType.posTypeShortName} ${item.employeePosLevel.posLevelName}` - : null, - projectName: item.development.projectName, - })); - - return new HttpSuccess({ data: formattedData, total }); - } - - /** - * API รายละเอียดประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_010 - รายละเอียดประวัติการฝึกอบรม/ดูงาน #10 - * - * @param {string} id Id โครงการ - */ - @Get("{id}") - async GetDevelopemtHistoryById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_HISTORY_EMP"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_HISTORY_EMP"); - const type = "EMPLOYEE"; - const getDevelopment = await this.developmentHistoryRepository.findOne({ - relations: [ - "development", - "development.developmentOthers", - "employeePosLevel", - "employeePosType", - ], - where: { id: id, type: type }, - order: { - development: { - developmentOthers: { - createdAt: "ASC", - }, - }, - }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้"); - } - - const formattedData = { - rank: getDevelopment.rank, - org: getDevelopment.org, - prefix: getDevelopment.prefix, - firstName: getDevelopment.firstName, - lastName: getDevelopment.lastName, - citizenId: getDevelopment.citizenId, - position: getDevelopment.position, - posLevelId: getDevelopment.employeePosLevelId, - posLevelName: - getDevelopment.employeePosType != null && getDevelopment.employeePosLevel != null - ? `${getDevelopment.employeePosType.posTypeShortName} ${getDevelopment.employeePosLevel.posLevelName}` - : null, - posTypeId: getDevelopment.employeePosTypeId, - posTypeName: - getDevelopment.employeePosType != null ? getDevelopment.employeePosType.posTypeName : null, - developmentId: getDevelopment.developmentId, - order: getDevelopment.order, - dateOrder: getDevelopment.dateOrder, - dateHisStart: getDevelopment.dateStart, - dateHisEnd: getDevelopment.dateEnd, - year: getDevelopment.development != null ? getDevelopment.development.year : null, - projectName: - getDevelopment.development != null ? getDevelopment.development.projectName : null, - dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null, - dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null, - totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null, - trainingDays: getDevelopment.development != null ? getDevelopment.trainingDays : null, - // addressAcademic: - // getDevelopment.development != null ? getDevelopment.development.addressAcademic : null, - // topicAcademic: - // getDevelopment.development != null ? getDevelopment.development.topicAcademic : null, - dateStudyStart: - getDevelopment.development != null ? getDevelopment.development.dateStudyStart : null, - dateStudyEnd: - getDevelopment.development != null ? getDevelopment.development.dateStudyEnd : null, - academic: getDevelopment.development?.developmentOthers - ? getDevelopment.development.developmentOthers.map((dev) => ({ - topicAcademic: dev.topicAcademic, - addressAcademic: dev.addressAcademic, - province: dev.provinceActualName, - })) - : [], - }; - - return new HttpSuccess(formattedData); - } -} diff --git a/src/controllers/DevelopmentHistoryController.ts b/src/controllers/DevelopmentHistoryController.ts deleted file mode 100644 index edb65eb..0000000 --- a/src/controllers/DevelopmentHistoryController.ts +++ /dev/null @@ -1,413 +0,0 @@ -import { - Controller, - Get, - Post, - Put, - Delete, - Route, - Security, - Tags, - Body, - Path, - Request, -} from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import { Brackets, Not } from "typeorm"; -import HttpSuccess from "../interfaces/http-success"; -import HttpError from "../interfaces/http-error"; -import HttpStatusCode from "../interfaces/http-status"; -import { Development } from "../entities/Development"; -import { - CreateDevelopmentHistory, - DevelopmentHistory, - UpdateDevelopmentHistory, -} from "../entities/DevelopmentHistory"; -import { PosType } from "../entities/PosType"; -import { PosLevel } from "../entities/PosLevel"; -import { RequestWithUser } from "../middlewares/user"; -import { setLogDataDiff } from "../interfaces/utils"; -import permission from "../interfaces/permission"; - -@Route("api/v1/development/history/officer") -@Tags("DevelopmentOfficerHistory") -@Security("bearerAuth") -export class DevelopmentOfficerHistoryController extends Controller { - private developmentHistoryRepository = AppDataSource.getRepository(DevelopmentHistory); - private developmentRepository = AppDataSource.getRepository(Development); - private posTypeRepository = AppDataSource.getRepository(PosType); - private posLevelRepository = AppDataSource.getRepository(PosLevel); - - /** - * API list หน่วยงาน - * - * @summary DEV_00 - list หน่วยงาน # - * - */ - @Get("org/{year}") - async GetOrgDevelopemt(@Request() request: RequestWithUser, @Path() year: number) { - await new permission().PermissionList(request, "SYS_DEV_HISTORY_OFFICER"); - const type = "OFFICER"; - const getOrg = await this.developmentHistoryRepository - .createQueryBuilder("developmentHistory") - .leftJoinAndSelect("developmentHistory.development", "development") - .andWhere("developmentHistory.root IS NOT NULL") - .andWhere(year > 0 ? "development.year LIKE :year" : "1=1", { - year: `${year.toString()}`, - }) - .andWhere("developmentHistory.type LIKE :type", { - type: `${type}`, - }) - .select("developmentHistory.root") - .groupBy("developmentHistory.root") - .getRawMany(); - if (getOrg.length > 0) { - return new HttpSuccess(getOrg.map((x) => x.developmentHistory_root)); - } - return new HttpSuccess(getOrg); - } - - /** - * API เพิ่มประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_006 - เพิ่มประวัติการฝึกอบรม/ดูงาน#6 - * - */ - @Post() - async CreateDevelopmentHistory( - @Body() requestBody: CreateDevelopmentHistory, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_HISTORY_OFFICER"); - const type = "OFFICER"; - const chk_name = await this.developmentHistoryRepository.find({ - where: { - citizenId: requestBody.citizenId, - developmentId: requestBody.developmentId, - type: type, - }, - }); - if (chk_name.length > 0) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว"); - } - - const checkId = await this.developmentRepository.findOne({ - where: { id: requestBody.developmentId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม"); - } - if (requestBody.posTypeId != null) { - const checkId = await this.posTypeRepository.findOne({ - where: { id: requestBody.posTypeId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - if (requestBody.posLevelId != null) { - const checkId = await this.posLevelRepository.findOne({ - where: { id: requestBody.posLevelId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - const before = null; - const development = Object.assign(new DevelopmentHistory(), requestBody); - development.type = type; - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_007 - แก้ไขประวัติการฝึกอบรม/ดูงาน #7 - * - * @param {string} id Id โครงการ - */ - @Put("{id}") - async UpdateDevelopmentHistory( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentHistory, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_HISTORY_OFFICER"); - const type = "OFFICER"; - const development = await this.developmentHistoryRepository.findOne({ - where: { id: id, type: type }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้"); - } - const chk_name = await this.developmentHistoryRepository.find({ - where: { - citizenId: requestBody.citizenId, - developmentId: requestBody.developmentId, - type: type, - id: Not(id), - }, - }); - if (chk_name.length > 0) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว"); - } - const checkId = await this.developmentRepository.findOne({ - where: { id: requestBody.developmentId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม"); - } - if (requestBody.posTypeId != null) { - const checkId = await this.posTypeRepository.findOne({ - where: { id: requestBody.posTypeId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - if (requestBody.posLevelId != null) { - const checkId = await this.posLevelRepository.findOne({ - where: { id: requestBody.posLevelId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - Object.assign(development, requestBody); - development.type = type; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(development, { data: request }); - return new HttpSuccess(development.id); - } - - /** - * API ลบประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_008 - ลบประวัติการฝึกอบรม/ดูงาน #8 - * - * @param {string} id Id โครงการ - */ - @Delete("{id}") - async DeleteDevelopmentHistory(@Path() id: string, @Request() request: RequestWithUser) { - await new permission().PermissionDelete(request, "SYS_DEV_HISTORY_OFFICER"); - const type = "OFFICER"; - const development = await this.developmentHistoryRepository.findOne({ - where: { id: id, type: type }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้"); - } - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.remove(development, { data: request }); - return new HttpSuccess(); - } - - /** - * API รายการประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_009 - รายการประวัติการฝึกอบรม/ดูงาน #9 - * - */ - @Post("filter") - async GetDevelopmentHistoryLists( - @Request() request: RequestWithUser, - @Body() - body: { - page: number; - pageSize: number; - keyword?: string; - year?: number; - root: string | null; - }, - ) { - await new permission().PermissionList(request, "SYS_DEV_HISTORY_OFFICER"); - const type = "OFFICER"; - const [development, total] = await AppDataSource.getRepository(DevelopmentHistory) - .createQueryBuilder("developmentHistory") - .leftJoinAndSelect("developmentHistory.development", "development") - .leftJoinAndSelect("developmentHistory.posLevel", "posLevel") - .leftJoinAndSelect("developmentHistory.posType", "posType") - .where("developmentHistory.profileId IS NOT NULL") - .andWhere( - body.year != 0 && body.year != null && body.year != undefined - ? "development.year = :year" - : "1=1", - { year: body.year }, - ) - // .andWhere(body.root != null && body.root != undefined ? "development.root = :root" : "1=1", { - // root: body.root, - // }) - .andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", { root: body.root }) - .andWhere("developmentHistory.type = :type", { type: type }) - .andWhere( - new Brackets((qb) => { - qb.where( - body.keyword != null && body.keyword != "" - ? "CONCAT(developmentHistory.prefix, developmentHistory.firstName, ' ', developmentHistory.lastName) LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "developmentHistory.position LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "development.projectName LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "posType.posTypeName LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "posLevel.posLevelName LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ) - .orWhere( - body.keyword != null && body.keyword != "" - ? "developmentHistory.citizenId LIKE :keyword" - : "1=1", - { - keyword: `%${body.keyword}%`, - }, - ); - }), - ) - .orderBy("development.year", "DESC") - .addOrderBy("developmentHistory.createdAt", "DESC") - .skip((body.page - 1) * body.pageSize) - .take(body.pageSize) - .getManyAndCount(); - const formattedData = development.map((item) => ({ - id: item.id, - citizenId: item.citizenId, - fullName: - item.prefix == null && item.firstName == null && item.lastName == null - ? "" - : `${item?.prefix}${item?.firstName} ${item?.lastName}`, - position: item.position, - year: item.development.year, - root: item.development.root, //test - posType: item.posType ? item.posType.posTypeName : null, - posLevel: item.posLevel ? item.posLevel.posLevelName : null, - posExecutive: item.posExecutive, - projectName: item.development.projectName, - })); - - return new HttpSuccess({ data: formattedData, total }); - } - - /** - * API รายละเอียดประวัติการฝึกอบรม/ดูงาน - * - * @summary DEV_010 - รายละเอียดประวัติการฝึกอบรม/ดูงาน #10 - * - * @param {string} id Id โครงการ - */ - @Get("{id}") - async GetDevelopemtHistoryById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_HISTORY_OFFICER"); - if (_workflow == false) - await new permission().PermissionGet(request, "SYS_DEV_HISTORY_OFFICER"); - const type = "OFFICER"; - const getDevelopment = await this.developmentHistoryRepository.findOne({ - relations: ["development", "development.developmentOthers", "posLevel", "posType"], - where: { id: id, type: type }, - order: { - development: { - developmentOthers: { - createdAt: "ASC", - }, - }, - }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้"); - } - - const formattedData = { - rank: getDevelopment.rank, - org: getDevelopment.org, - prefix: getDevelopment.prefix, - firstName: getDevelopment.firstName, - lastName: getDevelopment.lastName, - citizenId: getDevelopment.citizenId, - position: getDevelopment.position, - posLevelId: getDevelopment.posLevelId, - posLevelName: getDevelopment.posLevel != null ? getDevelopment.posLevel.posLevelName : null, - posTypeId: getDevelopment.posTypeId, - posTypeName: getDevelopment.posType != null ? getDevelopment.posType.posTypeName : null, - posExecutive: getDevelopment.posExecutive, - developmentId: getDevelopment.developmentId, - order: getDevelopment.order, - dateOrder: getDevelopment.dateOrder, - dateHisStart: getDevelopment.dateStart, - dateHisEnd: getDevelopment.dateEnd, - year: getDevelopment.development != null ? getDevelopment.development.year : null, - projectName: - getDevelopment.development != null ? getDevelopment.development.projectName : null, - dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null, - dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null, - totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null, - trainingDays: getDevelopment.development != null ? getDevelopment.trainingDays : null, - // addressAcademic: - // getDevelopment.development != null ? getDevelopment.development.addressAcademic : null, - // topicAcademic: - // getDevelopment.development != null ? getDevelopment.development.topicAcademic : null, - dateStudyStart: - getDevelopment.development != null ? getDevelopment.development.dateStudyStart : null, - dateStudyEnd: - getDevelopment.development != null ? getDevelopment.development.dateStudyEnd : null, - academic: getDevelopment.development?.developmentOthers - ? getDevelopment.development.developmentOthers.map((dev) => ({ - topicAcademic: dev.topicAcademic, - addressAcademic: dev.addressAcademic, - province: dev.provinceActualName, - })) - : [], - }; - - return new HttpSuccess(formattedData); - } -} diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts deleted file mode 100644 index af23f0a..0000000 --- a/src/controllers/DevelopmentScholarshipController.ts +++ /dev/null @@ -1,805 +0,0 @@ -import { - Controller, - Get, - Post, - Put, - Delete, - Route, - Security, - Tags, - Body, - Path, - Request, - Query, -} from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import { Brackets } from "typeorm"; -import HttpSuccess from "../interfaces/http-success"; -import HttpError from "../interfaces/http-error"; -import HttpStatusCode from "../interfaces/http-status"; -import { - CreateDevelopmentScholarship, - DevelopmentScholarship, - UpdateDevelopmentScholarship, - UpdateDevelopmentScholarshipUser, -} from "../entities/DevelopmentScholarship"; -import { PosType } from "../entities/PosType"; -import { PosLevel } from "../entities/PosLevel"; -import CallAPI from "../interfaces/call-api"; -import { RequestWithUser } from "../middlewares/user"; -import { setLogDataDiff } from "../interfaces/utils"; -import permission from "../interfaces/permission"; - -@Route("api/v1/development/scholarship") -@Tags("DevelopmentScholarship") -@Security("bearerAuth") -export class DevelopmentScholarshipController extends Controller { - private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship); - private posTypeRepository = AppDataSource.getRepository(PosType); - private posLevelRepository = AppDataSource.getRepository(PosLevel); - - /** - * API เพิ่มทุนการศึกษา/ฝึกอบรม - * - * @summary DEV_011 - เพิ่มทุนการศึกษา/ฝึกอบรม#11 - * - */ - @Post() - async CreateDevelopmentScholarship( - @Body() requestBody: CreateDevelopmentScholarship, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionCreate(request, "SYS_DEV_SCHOLARSHIP"); - if (requestBody.posTypeId != null) { - const checkId = await this.posTypeRepository.findOne({ - where: { id: requestBody.posTypeId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - if (requestBody.posLevelId != null) { - const checkId = await this.posLevelRepository.findOne({ - where: { id: requestBody.posLevelId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - const before = null; - const development = Object.assign(new DevelopmentScholarship(), requestBody); - development.createdUserId = request.user.sub; - development.createdFullName = request.user.name; - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.createdAt = new Date(); - development.lastUpdatedAt = new Date(); - await this.developmentScholarshipRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API แก้ไขทุนการศึกษา/ฝึกอบรม - * - * @summary DEV_012 - แก้ไขทุนการศึกษา/ฝึกอบรม #12 - * - * @param {string} id Id ข้าราชการฯที่ได้รับทุนการศึกษา - */ - @Put("{id}") - async UpdateDevelopmentScholarship( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentScholarship, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP"); - const development = await this.developmentScholarshipRepository.findOne({ - where: { id: id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - if (requestBody.posTypeId != null) { - const checkId = await this.posTypeRepository.findOne({ - where: { id: requestBody.posTypeId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - if (requestBody.posLevelId != null) { - const checkId = await this.posLevelRepository.findOne({ - where: { id: requestBody.posLevelId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - const before = structuredClone(development); - Object.assign(development, requestBody); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - await this.developmentScholarshipRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API ลบทุนการศึกษา/ฝึกอบรม - * - * @summary DEV_013 - ลบทุนการศึกษา/ฝึกอบรม #13 - * - * @param {string} id Id ข้าราชการฯที่ได้รับทุนการศึกษา - */ - @Delete("{id}") - async DeleteDevelopmentScholarship(@Path() id: string, @Request() request: RequestWithUser) { - await new permission().PermissionDelete(request, "SYS_DEV_SCHOLARSHIP"); - const development = await this.developmentScholarshipRepository.findOne({ - where: { id: id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - - await this.developmentScholarshipRepository.remove(development, { data: request }); - return new HttpSuccess(); - } - - /** - * API รายการทุนการศึกษา/ฝึกอบรม - * - * @summary DEV_014 - รายการทุนการศึกษา/ฝึกอบรม #14 - * - */ - @Get() - async GetDevelopmentScholarshipLists( - @Request() request: RequestWithUser, - @Query("page") page: number = 1, - @Query("pageSize") pageSize: number = 10, - @Query("keyword") keyword?: string, - @Query("year") year?: number, - @Query("scholarshipType") scholarshipType?: string, - ) { - let _data = await new permission().PermissionOrgList(request, "SYS_DEV_SCHOLARSHIP"); - await new CallAPI() - .PostData(request, "/org/finddna", _data) - .then((x) => { - _data = x; - }) - .catch((x) => {}); - const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship) - .createQueryBuilder("developmentScholarship") - .leftJoinAndSelect("developmentScholarship.posLevel", "posLevel") - .leftJoinAndSelect("developmentScholarship.posType", "posType") - .andWhere( - year !== 0 && year != null && year != undefined - ? "developmentScholarship.scholarshipYear = :scholarshipYear" - : "1=1", - { scholarshipYear: year }, - ) - .andWhere( - scholarshipType != null && scholarshipType != undefined - ? "developmentScholarship.scholarshipType = :scholarshipType" - : "1=1", - { scholarshipType: scholarshipType }, - ) - .andWhere( - new Brackets((qb) => { - qb.where( - keyword != null && keyword != "" - ? `CONCAT(developmentScholarship.prefix, developmentScholarship.firstName," ",developmentScholarship.lastName) like '%${keyword}%'` - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.citizenId LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.position LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.posExecutive LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1", - { - keyword: `%${keyword}%`, - }, - ); - }), - ) - .andWhere( - _data.root != undefined && _data.root != null - ? _data.root[0] != null - ? `developmentScholarship.rootDnaId IN (:...root)` - : `developmentScholarship.rootDnaId is null` - : "1=1", - { - root: _data.root, - }, - ) - .orderBy("developmentScholarship.scholarshipYear", "DESC") - .addOrderBy("developmentScholarship.createdAt", "DESC") - .skip((page - 1) * pageSize) - .take(pageSize) - .getManyAndCount(); - const formattedData = development.map((item) => ({ - id: item.id, - year: item.scholarshipYear, - citizenId: item.citizenId, - fullName: item.prefix + item.firstName + " " + item.lastName, - position: item.position, - posType: item.posType ? item.posType.posTypeName : null, - posLevel: item.posLevel ? item.posLevel.posLevelName : null, - posExecutive: item.posExecutive, - status: item.status, - })); - - return new HttpSuccess({ data: formattedData, total }); - } - - /** - * API รายละเอียดทุนการศึกษา/ฝึกอบรม - * - * @summary DEV_015 - รายละเอียดทุนการศึกษา/ฝึกอบรม #15 - * - * @param {string} id Id ข้าราชการฯที่ได้รับทุนการศึกษา - */ - @Get("{id}") - async GetDevelopemtScholarshipById(@Request() request: RequestWithUser, @Path() id: string) { - //await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP"); //USER - const getDevelopment = await this.developmentScholarshipRepository.findOne({ - relations: ["posLevel", "posType", "posLevelguarantor", "posTypeguarantor"], - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - const formattedData = { - rootDnaId: getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null, - rootId: getDevelopment.rootId ? getDevelopment.rootId : null, - root: getDevelopment.root ? getDevelopment.root : null, - org: getDevelopment.org ? getDevelopment.org : null, - orgRootShortName: getDevelopment.orgRootShortName ? getDevelopment.orgRootShortName : null, - orgRevisionId: getDevelopment.orgRevisionId ? getDevelopment.orgRevisionId : null, - rank: getDevelopment.rank ? getDevelopment.rank : null, - prefix: getDevelopment.prefix ? getDevelopment.prefix : null, - firstName: getDevelopment.firstName ? getDevelopment.firstName : null, - lastName: getDevelopment.lastName ? getDevelopment.lastName : null, - citizenId: getDevelopment.citizenId ? getDevelopment.citizenId : null, - position: getDevelopment.position ? getDevelopment.position : null, - posExecutive: getDevelopment.posExecutive ? getDevelopment.posExecutive : null, - posLevelId: getDevelopment.posLevelId ? getDevelopment.posLevelId : null, - posLevelName: getDevelopment.posLevel?.posLevelName - ? getDevelopment.posLevel?.posLevelName - : null, - posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null, - posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null, - guarantorRootDnaId: getDevelopment.guarantorRootDnaId - ? getDevelopment.guarantorRootDnaId - : null, - guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null, - guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null, - guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null, - guarantorOrgRootShortName: getDevelopment.guarantorOrgRootShortName - ? getDevelopment.guarantorOrgRootShortName - : null, - guarantorOrgRevisionId: getDevelopment.guarantorOrgRevisionId - ? getDevelopment.guarantorOrgRevisionId - : null, - guarantorRank: getDevelopment.guarantorRank ? getDevelopment.guarantorRank : null, - guarantorPrefix: getDevelopment.guarantorPrefix ? getDevelopment.guarantorPrefix : null, - guarantorFirstName: getDevelopment.guarantorFirstName - ? getDevelopment.guarantorFirstName - : null, - guarantorLastName: getDevelopment.guarantorLastName ? getDevelopment.guarantorLastName : null, - guarantorCitizenId: getDevelopment.guarantorCitizenId - ? getDevelopment.guarantorCitizenId - : null, - guarantorPosition: getDevelopment.guarantorPosition ? getDevelopment.guarantorPosition : null, - guarantorPosExecutive: getDevelopment.guarantorPosExecutive - ? getDevelopment.guarantorPosExecutive - : null, - posLevelguarantorId: getDevelopment.posLevelguarantorId - ? getDevelopment.posLevelguarantorId - : null, - posLevelguarantorName: getDevelopment.posLevelguarantor?.posLevelName - ? getDevelopment.posLevelguarantor?.posLevelName - : null, - posTypeguarantorId: getDevelopment.posTypeguarantorId - ? getDevelopment.posTypeguarantorId - : null, - posTypeguarantorName: getDevelopment.posTypeguarantor?.posTypeName - ? getDevelopment.posTypeguarantor?.posTypeName - : null, - scholarshipYear: getDevelopment.scholarshipYear ? getDevelopment.scholarshipYear : null, - budgetSource: getDevelopment.budgetSource ? getDevelopment.budgetSource : null, - budgetApprove: getDevelopment.budgetApprove ? getDevelopment.budgetApprove : null, - bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null, - bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null, - bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null, - useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null, - changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null, - scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null, - fundType: getDevelopment.fundType ? getDevelopment.fundType : null, - contractNo: getDevelopment.contractNo ? getDevelopment.contractNo : null, - contractDate: getDevelopment.contractDate ? getDevelopment.contractDate : null, - reportBackNo: getDevelopment.reportBackNo ? getDevelopment.reportBackNo : null, - reportBackNoDate: getDevelopment.reportBackNoDate ? getDevelopment.reportBackNoDate : null, - reportBackDate: getDevelopment.reportBackDate ? getDevelopment.reportBackDate : null, - degreeLevel: getDevelopment.degreeLevel ? getDevelopment.degreeLevel : null, - course: getDevelopment.course ? getDevelopment.course : null, - field: getDevelopment.field ? getDevelopment.field : null, - faculty: getDevelopment.faculty ? getDevelopment.faculty : null, - educationalInstitution: getDevelopment.educationalInstitution - ? getDevelopment.educationalInstitution - : null, - startDate: getDevelopment.startDate ? getDevelopment.startDate : null, - endDate: getDevelopment.endDate ? getDevelopment.endDate : null, - studyPlace: getDevelopment.studyPlace ? getDevelopment.studyPlace : null, - studyTopic: getDevelopment.studyTopic ? getDevelopment.studyTopic : null, - studyStartDate: getDevelopment.studyStartDate ? getDevelopment.studyStartDate : null, - studyEndDate: getDevelopment.studyEndDate ? getDevelopment.studyEndDate : null, - studyCountry: getDevelopment.studyCountry ? getDevelopment.studyCountry : null, - studyAbroadTopic: getDevelopment.studyAbroadTopic ? getDevelopment.studyAbroadTopic : null, - studyAbroadStartDate: getDevelopment.studyAbroadStartDate - ? getDevelopment.studyAbroadStartDate - : null, - studyAbroadEndDate: getDevelopment.studyAbroadEndDate - ? getDevelopment.studyAbroadEndDate - : null, - totalPeriod: getDevelopment.totalPeriod ? getDevelopment.totalPeriod : null, - status: getDevelopment.status ? getDevelopment.status : null, - profileId: getDevelopment.profileId ? getDevelopment.profileId : null, - planType: getDevelopment.planType ? getDevelopment.planType : null, - isNoUseBudget: getDevelopment.isNoUseBudget ? getDevelopment.isNoUseBudget : null, - }; - return new HttpSuccess(formattedData); - } - - /** - * API แก้ไขทุนการศึกษา/ฝึกอบรม - * - * @summary DEV_012 - แก้ไขทุนการศึกษา/ฝึกอบรม #12 - * - * @param {string} id Id ข้าราชการฯที่ได้รับทุนการศึกษา - */ - @Put("admin/{id}") - async UpdateDevelopmentScholarshipAdminById( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentScholarship, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP"); - const development = await this.developmentScholarshipRepository.findOne({ - where: { id: id }, - }); - if (!development) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - if (requestBody.posTypeId != null) { - const checkId = await this.posTypeRepository.findOne({ - where: { id: requestBody.posTypeId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); - } - } - if (requestBody.posLevelId != null) { - const checkId = await this.posLevelRepository.findOne({ - where: { id: requestBody.posLevelId }, - }); - if (!checkId) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); - } - } - const before = structuredClone(development); - Object.assign(development, requestBody); - development.lastUpdateUserId = request.user.sub; - development.lastUpdateFullName = request.user.name; - development.lastUpdatedAt = new Date(); - await this.developmentScholarshipRepository.save(development, { data: request }); - setLogDataDiff(request, { before, after: development }); - return new HttpSuccess(development.id); - } - - /** - * API รายละเอียดทุนการศึกษา/ฝึกอบรม ADMIN - * - * @summary DEV_015 - รายละเอียดทุนการศึกษา/ฝึกอบรม #15 ADMIN - * - * @param {string} id Id ข้าราชการฯที่ได้รับทุนการศึกษา ADMIN - */ - @Get("admin/{id}") - async GetDevelopemtScholarshipAdminById(@Request() request: RequestWithUser, @Path() id: string) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_SCHOLARSHIP"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP"); - const getDevelopment = await this.developmentScholarshipRepository.findOne({ - relations: ["posLevel", "posType", "posLevelguarantor", "posTypeguarantor"], - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - const formattedData = { - rootDnaId: getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null, - rootId: getDevelopment.rootId ? getDevelopment.rootId : null, - root: getDevelopment.root ? getDevelopment.root : null, - org: getDevelopment.org ? getDevelopment.org : null, - orgRootShortName: getDevelopment.orgRootShortName ? getDevelopment.orgRootShortName : null, - orgRevisionId: getDevelopment.orgRevisionId ? getDevelopment.orgRevisionId : null, - rank: getDevelopment.rank ? getDevelopment.rank : null, - prefix: getDevelopment.prefix ? getDevelopment.prefix : null, - firstName: getDevelopment.firstName ? getDevelopment.firstName : null, - lastName: getDevelopment.lastName ? getDevelopment.lastName : null, - citizenId: getDevelopment.citizenId ? getDevelopment.citizenId : null, - position: getDevelopment.position ? getDevelopment.position : null, - posExecutive: getDevelopment.posExecutive ? getDevelopment.posExecutive : null, - posLevelId: getDevelopment.posLevelId ? getDevelopment.posLevelId : null, - posLevelName: getDevelopment.posLevel?.posLevelName - ? getDevelopment.posLevel?.posLevelName - : null, - posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null, - posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null, - guarantorRootDnaId: getDevelopment.guarantorRootDnaId - ? getDevelopment.guarantorRootDnaId - : null, - guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null, - guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null, - guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null, - guarantorOrgRootShortName: getDevelopment.guarantorOrgRootShortName - ? getDevelopment.guarantorOrgRootShortName - : null, - guarantorOrgRevisionId: getDevelopment.guarantorOrgRevisionId - ? getDevelopment.guarantorOrgRevisionId - : null, - guarantorRank: getDevelopment.guarantorRank ? getDevelopment.guarantorRank : null, - guarantorPrefix: getDevelopment.guarantorPrefix ? getDevelopment.guarantorPrefix : null, - guarantorFirstName: getDevelopment.guarantorFirstName - ? getDevelopment.guarantorFirstName - : null, - guarantorLastName: getDevelopment.guarantorLastName ? getDevelopment.guarantorLastName : null, - guarantorCitizenId: getDevelopment.guarantorCitizenId - ? getDevelopment.guarantorCitizenId - : null, - guarantorPosition: getDevelopment.guarantorPosition ? getDevelopment.guarantorPosition : null, - guarantorPosExecutive: getDevelopment.guarantorPosExecutive - ? getDevelopment.guarantorPosExecutive - : null, - posLevelguarantorId: getDevelopment.posLevelguarantorId - ? getDevelopment.posLevelguarantorId - : null, - posLevelguarantorName: getDevelopment.posLevelguarantor?.posLevelName - ? getDevelopment.posLevelguarantor?.posLevelName - : null, - posTypeguarantorId: getDevelopment.posTypeguarantorId - ? getDevelopment.posTypeguarantorId - : null, - posTypeguarantorName: getDevelopment.posTypeguarantor?.posTypeName - ? getDevelopment.posTypeguarantor?.posTypeName - : null, - scholarshipYear: getDevelopment.scholarshipYear ? getDevelopment.scholarshipYear : null, - budgetSource: getDevelopment.budgetSource ? getDevelopment.budgetSource : null, - budgetApprove: getDevelopment.budgetApprove ? getDevelopment.budgetApprove : null, - bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null, - bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null, - bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null, - useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null, - changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null, - scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null, - fundType: getDevelopment.fundType ? getDevelopment.fundType : null, - contractNo: getDevelopment.contractNo ? getDevelopment.contractNo : null, - contractDate: getDevelopment.contractDate ? getDevelopment.contractDate : null, - reportBackNo: getDevelopment.reportBackNo ? getDevelopment.reportBackNo : null, - reportBackNoDate: getDevelopment.reportBackNoDate ? getDevelopment.reportBackNoDate : null, - reportBackDate: getDevelopment.reportBackDate ? getDevelopment.reportBackDate : null, - degreeLevel: getDevelopment.degreeLevel ? getDevelopment.degreeLevel : null, - course: getDevelopment.course ? getDevelopment.course : null, - field: getDevelopment.field ? getDevelopment.field : null, - faculty: getDevelopment.faculty ? getDevelopment.faculty : null, - educationalInstitution: getDevelopment.educationalInstitution - ? getDevelopment.educationalInstitution - : null, - startDate: getDevelopment.startDate ? getDevelopment.startDate : null, - endDate: getDevelopment.endDate ? getDevelopment.endDate : null, - studyPlace: getDevelopment.studyPlace ? getDevelopment.studyPlace : null, - studyTopic: getDevelopment.studyTopic ? getDevelopment.studyTopic : null, - studyStartDate: getDevelopment.studyStartDate ? getDevelopment.studyStartDate : null, - studyEndDate: getDevelopment.studyEndDate ? getDevelopment.studyEndDate : null, - studyCountry: getDevelopment.studyCountry ? getDevelopment.studyCountry : null, - studyAbroadTopic: getDevelopment.studyAbroadTopic ? getDevelopment.studyAbroadTopic : null, - studyAbroadStartDate: getDevelopment.studyAbroadStartDate - ? getDevelopment.studyAbroadStartDate - : null, - studyAbroadEndDate: getDevelopment.studyAbroadEndDate - ? getDevelopment.studyAbroadEndDate - : null, - totalPeriod: getDevelopment.totalPeriod ? getDevelopment.totalPeriod : null, - status: getDevelopment.status ? getDevelopment.status : null, - profileId: getDevelopment.profileId ? getDevelopment.profileId : null, - planType: getDevelopment.planType ? getDevelopment.planType : null, - isNoUseBudget: getDevelopment.isNoUseBudget ? getDevelopment.isNoUseBudget : null, - budgetSourceOther: getDevelopment.budgetSourceOther ? getDevelopment.budgetSourceOther : null, - }; - return new HttpSuccess(formattedData); - } - - /** - * API รายการทุนของ user - * - * @summary DEV_0 - รายการทุนของ user # - * - * @param {string} profileId profileId ข้าราชการฯที่ได้รับทุนการศึกษา - */ - @Get("user/{profileId}") - async GetDevelopemtScholarshipUserById( - @Path() profileId: string, - @Query("type") type?: string | null, - @Query("year") year?: number | null, - ) { - const getDevelopment = await AppDataSource.getRepository(DevelopmentScholarship) - .createQueryBuilder("developmentScholarship") - .andWhere("developmentScholarship.profileId = :profileId", { profileId: profileId }) - .andWhere( - year !== 0 && year != null && year != undefined - ? "developmentScholarship.scholarshipYear = :scholarshipYear" - : "1=1", - { scholarshipYear: year }, - ) - .andWhere( - type != null && type != undefined - ? "developmentScholarship.scholarshipType = :scholarshipType" - : "1=1", - { scholarshipType: type }, - ) - .select(["id", "scholarshipYear", "scholarshipYear", "scholarshipType", "fundType"]) - .orderBy("developmentScholarship.createdAt", "DESC") - .getRawMany(); - - return new HttpSuccess(getDevelopment); - } - - /** - * API รายละเอียดทุนของ admin - * - * @summary DEV_0 - รายละเอียดทุนของ admin # - * - * @param {string} id id รายการ - */ - @Get("admin/detail/{id}") - async GetDevelopemtScholarshipUserDetailAdminById( - @Request() request: RequestWithUser, - @Path() id: string, - ) { - let _workflow = await new permission().Workflow(request, id, "SYS_DEV_SCHOLARSHIP"); - if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP"); - const getDevelopment = await this.developmentScholarshipRepository.findOne({ - where: { id: id }, - select: [ - "id", - "scholarshipYear", - "scholarshipType", - "fundType", - "bookNumber", - "bookDate", - "governmentDate", - "governmentEndDate", - "isGraduated", - "graduatedDate", - "graduatedReason", - "org", - ], - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - - return new HttpSuccess(getDevelopment); - } - - /** - * API รายละเอียดทุนของ user - * - * @summary DEV_0 - รายละเอียดทุนของ user # - * - * @param {string} id id รายการ - */ - @Get("user/detail/{id}") - async GetDevelopemtScholarshipUserDetailById(@Path() id: string) { - const getDevelopment = await this.developmentScholarshipRepository.findOne({ - where: { id: id }, - select: [ - "id", - "scholarshipYear", - "scholarshipType", - "fundType", - "bookNumber", - "bookDate", - "governmentDate", - "governmentEndDate", - "isGraduated", - "graduatedDate", - "graduatedReason", - "org", - ], - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - - return new HttpSuccess(getDevelopment); - } - - /** - * API แก้ไขรายการทุนของ user - * - * @summary DEV_015 - แก้ไขรายการทุนของ user #15 - * - * @param {string} id รายการ - */ - @Put("user/detail/{id}") - async UpdateDevelopemtScholarshipUserById( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentScholarshipUser, - @Request() request: RequestWithUser, - ) { - // await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP"); - const getDevelopment = await this.developmentScholarshipRepository.findOne({ - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - const before = structuredClone(getDevelopment); - Object.assign(getDevelopment, requestBody); - getDevelopment.lastUpdateUserId = request.user.sub; - getDevelopment.lastUpdateFullName = request.user.name; - getDevelopment.lastUpdatedAt = new Date(); - await this.developmentScholarshipRepository.save(getDevelopment, { data: request }); - setLogDataDiff(request, { before, after: getDevelopment }); - return new HttpSuccess(getDevelopment.id); - } - - /** - * API แก้ไขรายการทุนของ admin - * - * @summary DEV_015 - แก้ไขรายการทุนของ admin #15 - * - * @param {string} id รายการ - */ - @Put("admin/detail/{id}") - async UpdateDevelopemtScholarshipAdminById( - @Path() id: string, - @Body() requestBody: UpdateDevelopmentScholarshipUser, - @Request() request: RequestWithUser, - ) { - await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP"); - const getDevelopment = await this.developmentScholarshipRepository.findOne({ - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - const before = structuredClone(getDevelopment); - Object.assign(getDevelopment, requestBody); - getDevelopment.lastUpdateUserId = request.user.sub; - getDevelopment.lastUpdateFullName = request.user.name; - getDevelopment.lastUpdatedAt = new Date(); - await this.developmentScholarshipRepository.save(getDevelopment, { data: request }); - setLogDataDiff(request, { before, after: getDevelopment }); - return new HttpSuccess(getDevelopment.id); - } - - /** - * API เปลี่ยนสถานะ - * - * @summary DEV_0 - เปลี่ยนสถานะ # - * - * @param {string} id Id ข้าราชการฯที่ได้รับทุนการศึกษา - * @param {string} status status สถานะ - */ - @Get("status/{id}/{status}") - async ChangeStatusDevelopemtScholarshipById( - @Path() id: string, - @Path() status: string, - @Request() request: RequestWithUser, - ) { - const getDevelopment = await this.developmentScholarshipRepository.findOne({ - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - const _status = status.trim().toUpperCase(); - getDevelopment.status = _status; - getDevelopment.lastUpdateUserId = request.user.sub; - getDevelopment.lastUpdateFullName = request.user.name; - let scholarshipType = ""; - if (_status == "GRADUATE") { - if (getDevelopment.scholarshipType != null) { - switch (getDevelopment.scholarshipType.trim().toUpperCase()) { - case "DOMESTICE": - scholarshipType = "การศึกษาในประเทศ"; - break; - case "NOABROAD": - scholarshipType = - "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)"; - break; - case "ABROAD": - scholarshipType = - "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)"; - break; - case "EXECUTIVE": - scholarshipType = - "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)"; - break; - default: - break; - } - } - let profileEdu = await new CallAPI() - .PostData(request, "/org/profile/educations", { - profileId: getDevelopment.profileId, - institute: getDevelopment.educationalInstitution, - startDate: getDevelopment.startDate, - endDate: getDevelopment.endDate, - finishDate: null, - isEducation: false, - degree: null, - field: getDevelopment.field, - fundName: scholarshipType, - gpa: null, - country: getDevelopment.studyCountry, - other: null, - duration: getDevelopment.totalPeriod, - durationYear: 0, - note: null, - educationLevel: getDevelopment.degreeLevel, - educationLevelId: null, - isDate: false, - positionPath: null, - positionPathId: null, - }) - .then(async (x) => { - await this.developmentScholarshipRepository.save(getDevelopment, { data: request }); - }) - .catch((error) => { - console.error("ไม่สามารถบันทึกลงทะเบียนประวัติได้"); - }); - } else if (_status == "NOTGRADUATE") { - getDevelopment.status = _status; - getDevelopment.lastUpdateUserId = request.user.sub; - getDevelopment.lastUpdateFullName = request.user.name; - getDevelopment.lastUpdatedAt = new Date(); - await this.developmentScholarshipRepository.save(getDevelopment, { data: request }); - } else { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบสถานะนี้ในระบบ"); - } - - return new HttpSuccess(); - } -} diff --git a/src/controllers/MyController.ts b/src/controllers/MyController.ts index 7f14906..2e5f1bd 100644 --- a/src/controllers/MyController.ts +++ b/src/controllers/MyController.ts @@ -1,4 +1,4 @@ -import { Controller, Get, Route, Security, Tags } from "tsoa"; +import { Controller, Get, Post, Put, Delete, Patch, Route, Security, Tags } from "tsoa"; @Route("/hello") @Tags("Test") diff --git a/src/controllers/PortfolioController.ts b/src/controllers/PortfolioController.ts deleted file mode 100644 index eecf28a..0000000 --- a/src/controllers/PortfolioController.ts +++ /dev/null @@ -1,234 +0,0 @@ -import { - Controller, - Post, - Put, - Delete, - Route, - Security, - Tags, - Body, - Path, - 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 { Not } from "typeorm"; -import { CreatePortfolio, Portfolio } from "../entities/Portfolio"; -import { RequestWithUser } from "../middlewares/user"; -import { setLogDataDiff } from "../interfaces/utils"; -import { Brackets } from "typeorm"; - -@Route("api/v1/development/portfolio") -@Tags("Portfolio") -@Security("bearerAuth") -@Response( - HttpStatusCode.INTERNAL_SERVER_ERROR, - "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", -) -@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") -export class PortfolioController extends Controller { - private portfolioRepository = AppDataSource.getRepository(Portfolio); - - /** - * API list รายการผลงาน - * - * @summary ORG_058 - CRUD ผลงาน (ADMIN) #62 - * - */ - @Get() - async GetResult(@Request() request: RequestWithUser) { - const _portfolio = await this.portfolioRepository.find({ - where: { createdUserId: request.user.sub }, - select: [ - "id", - "name", - "detail", - "createdAt", - "lastUpdatedAt", - "createdFullName", - "lastUpdateFullName", - ], - order: { createdAt: "DESC" }, - }); - return new HttpSuccess(_portfolio); - } - - /** - * API list รายการผลงานสำหรับระบบประเมิน - * - * @summary list รายการผลงานสำหรับระบบประเมิน - * - */ - @Get("user") - async GetResultForEva(@Request() request: RequestWithUser) { - const _portfolio = await this.portfolioRepository.find({ - where: { createdUserId: request.user.sub }, - select: [ - "id", - "name", - "detail", - "createdAt", - "lastUpdatedAt", - "createdFullName", - "lastUpdateFullName", - ], - order: { createdAt: "DESC" }, - }); - return new HttpSuccess(_portfolio); - } - - /** - * API รายละเอียดรายการผลงาน - * - * @summary ORG_058 - CRUD ผลงาน (ADMIN) #62 - * - * @param {string} id Id ผลงาน - */ - @Get("{id}") - async GetById(@Path() id: string, @Request() request: RequestWithUser) { - const _portfolio = await this.portfolioRepository.findOne({ - where: { id: id, createdUserId: request.user.sub }, - select: ["id", "name", "detail"], - }); - if (!_portfolio) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลงานนี้"); - } - - return new HttpSuccess(_portfolio); - } - - /** - * API รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ก.พ.7/ก.ก.1 - * - * @summary รายละเอียดรายการผลงาน ใช้แสดงในรายงาน ก.พ.7/ก.ก.1 - * - */ - @Get("kk1/{keycloak}") - async GetPortfolio(@Path() keycloak: string, @Request() request: RequestWithUser) { - const _portfolio = await this.portfolioRepository.find({ - where: { createdUserId: keycloak }, - select: [ - "name", - "createdAt" - ], - order: { createdAt: "DESC" }, - }); - const result = - _portfolio.map(x => ({ - name: x.name, - year: x.createdAt.getFullYear() > 2500 - ? x.createdAt.getFullYear() - : x.createdAt.getFullYear()+543 - })); - return new HttpSuccess(result); - } - - /** - * API สร้างรายการ body ผลงาน - * - * @summary ORG_058 - CRUD ผลงาน (ADMIN) #62 - * - */ - @Post() - async Post( - @Body() - requestBody: CreatePortfolio, - @Request() request: RequestWithUser, - ) { - const _portfolio = Object.assign(new Portfolio(), requestBody); - if (!_portfolio) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลงานนี้"); - } - - const checkName = await this.portfolioRepository.findOne({ - where: { name: requestBody.name, createdUserId: request.user.sub }, - }); - - if (checkName) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว"); - } - const before = null; - _portfolio.createdUserId = request.user.sub; - _portfolio.createdFullName = request.user.name; - _portfolio.lastUpdateUserId = request.user.sub; - _portfolio.lastUpdateFullName = request.user.name; - _portfolio.createdAt = new Date(); - _portfolio.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Portfolio.", - // }); - await this.portfolioRepository.save(_portfolio, { data: request }); - setLogDataDiff(request, { before, after: _portfolio }); - return new HttpSuccess(_portfolio.id); - } - - /** - * API แก้ไขรายการ body ผลงาน - * - * @summary ORG_058 - CRUD ผลงาน (ADMIN) #62 - * - * @param {string} id Id ผลงาน - */ - @Put("{id}") - async Put( - @Path() id: string, - @Body() - requestBody: CreatePortfolio, - @Request() request: RequestWithUser, - ) { - const _portfolio = await this.portfolioRepository.findOne({ where: { id: id } }); - if (!_portfolio) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลงานนี้"); - } - const checkName = await this.portfolioRepository.findOne({ - where: { id: Not(id), name: requestBody.name, createdUserId: request.user.sub }, - }); - if (checkName) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว"); - } - - _portfolio.lastUpdateUserId = request.user.sub; - _portfolio.lastUpdateFullName = request.user.name; - _portfolio.lastUpdatedAt = new Date(); - Object.assign(_portfolio, requestBody); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Portfolio.", - // }); - await this.portfolioRepository.save(_portfolio, { data: request }); - return new HttpSuccess(_portfolio.id); - } - - /** - * API ลบรายการผลงาน - * - * @summary ORG_058 - CRUD ผลงาน (ADMIN) #62 - * - * @param {string} id Id ผลงาน - */ - @Delete("{id}") - async Delete(@Path() id: string, @Request() request: RequestWithUser) { - const _delPortfolio = await this.portfolioRepository.findOne({ - where: { id: id, createdUserId: request.user.sub }, - }); - if (!_delPortfolio) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลงานนี้"); - } - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Portfolio.", - // }); - await this.portfolioRepository.delete(_delPortfolio.id), { data: request }; - return new HttpSuccess(); - } -} diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts deleted file mode 100644 index e6b9826..0000000 --- a/src/controllers/ReportController.ts +++ /dev/null @@ -1,1174 +0,0 @@ -import { Controller, Get, Post, Route, Security, Tags, Body, Path, Query } from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import HttpSuccess from "../interfaces/http-success"; -import HttpError from "../interfaces/http-error"; -import HttpStatusCode from "../interfaces/http-status"; -import { Development } from "../entities/Development"; -import { DevelopmentHistory } from "../entities/DevelopmentHistory"; -import { PosType } from "../entities/PosType"; -import { PosLevel } from "../entities/PosLevel"; -import Extension from "../interfaces/extension"; -import { DevelopmentScholarship } from "../entities/DevelopmentScholarship"; -import { In, IsNull, Not } from "typeorm"; -import { viewDevScholarship } from "../entities/view/viewDevScholarship"; -import { isNotEmittedStatement } from "typescript"; -@Route("api/v1/development/report") -@Tags("Report") -@Security("bearerAuth") -export class ReportController extends Controller { - private developmentRepository = AppDataSource.getRepository(Development); - private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship); - private viewDevScholarship = AppDataSource.getRepository(viewDevScholarship); - /** - * API Report รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด - * - * @summary DEV_0xx - Report รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด #xx - * - * @param {string} type type ประเภท report - */ - @Get("main") - async GetReportDevelopemtMain(@Query("year") year?: number, @Query("rootId") rootId?: string) { - // const _type = type.trim().toUpperCase(); - const formattedData = { - org: "_type", - }; - - //ตารางรายละเอียด กับ แบบรายงาน - const dataDevelopment = await AppDataSource.getRepository(Development) - .createQueryBuilder("development") - .leftJoinAndSelect("development.developmentHistorys", "history") - .leftJoinAndSelect("development.developmentPlannedGoals", "planGoals") - .leftJoinAndSelect("development.strategyChild1Actual", "strategy1") - .leftJoinAndSelect("development.strategyChild2Actual", "strategy2") - .leftJoinAndSelect("development.strategyChild3Actual", "strategy3") - .leftJoinAndSelect("development.strategyChild4Actual", "strategy4") - .leftJoinAndSelect("development.strategyChild5Actual", "strategy5") - .where("development.status = :status", { status: "FINISH" }) - .andWhere("development.strategyChild1ActualId IS NOT NULL") - .andWhere("development.rootDnaId = :rootDnaId", { rootDnaId: rootId }) - .select([ - "development.id AS id", - "development.projectName AS projectName", - "development.year AS year", - "development.totalDate AS totalDate", - "development.budget AS budget", - "SUM(DISTINCT planGoals.amount) AS goalParticipants", - "COUNT(DISTINCT history.id) AS actualParticipants", - "strategy1.strategyChild1Name AS strategy1", - "strategy2.strategyChild2Name AS strategy2", - "strategy3.strategyChild3Name AS strategy3", - "strategy4.strategyChild4Name AS strategy4", - "strategy5.strategyChild5Name AS strategy5", - "development.accept AS acceptBudget", - "development.receive AS receiveBudget", - "development.obstacle AS obstacle", - "development.root AS root", - ]) - .groupBy("development.id") - .getRawMany(); - - const mappedDataDev = dataDevelopment.map((item, index) => { - let budget = null; - if (item.budget == "REGULATIONBUDGET") { - budget = "งบตามข้อบัญญัติ"; - } else if (item.budget == "OTHERBUDGET") { - budget = "เงินนอกงบประมาณ"; - } else if (item.budget == "BANGKOKBUDGET") { - budget = "ไม่ใช้งบประมาณ"; - } - return { - strategy: item.strategy1, - projectName: item.projectName, - totalDate: - item.totalDate != null && item.totalDate != "" - ? Extension.ToThaiNumber(item.totalDate.toLocaleString()) - : "-", - goalParticipants: - item.goalParticipants != null && item.goalParticipants != "" - ? Extension.ToThaiNumber(item.goalParticipants.toLocaleString()) - : "-", - actualParticipants: - item.actualParticipants != null && item.actualParticipants != "" - ? Extension.ToThaiNumber(item.actualParticipants.toLocaleString()) - : "-", - budget: budget, - acceptBudget: - item.acceptBudget != null && item.acceptBudget != "" - ? Extension.ToThaiNumber(item.acceptBudget.toLocaleString()) - : "-", - receiveBudget: - item.receiveBudget != null && item.receiveBudget != "" - ? Extension.ToThaiNumber(item.receiveBudget.toLocaleString()) - : "-", - obstacle: item.obstacle, - root: item.root, - output: "-", - outcome: "-", - position: "-", - indicators: "-", - devResult: "-", - positionActual: "-", - }; - }); - - const resultAllStrategy = await AppDataSource.getRepository(Development) - .createQueryBuilder("development") - .leftJoinAndSelect("development.strategyChild1Actual", "strategy1") - .where("development.status = :status", { status: "FINISH" }) - .andWhere("development.strategyChild1ActualId IS NOT NULL") - .andWhere("development.rootDnaId = :rootDnaId", { rootDnaId: rootId }) - .select([ - "development.rootId AS rootId", - "development.strategyChild1ActualId AS strategyId", - "strategy1.strategyChild1Name AS strategyName", - "COUNT(development.id) AS devCount", - "SUM(development.receive) AS receiveBudget", - "development.root AS root", - ]) - .groupBy( - "development.rootId, development.strategyChild1ActualId, strategy1.strategyChild1Name, development.root", - ) - .orderBy("strategy1.createdAt", "ASC") - .getRawMany(); - - interface Strategy { - strategyId: string; - strategyName: string; - devCount: string; - receiveBudget: string; - sumDev: string; - sumTraget: string; - sumBudget: string; - sumRowDev: string; - sumRowTarget: string; - sumRowBudget: string; - } - - interface GroupedData { - rootId: string; - root: string; - strategy: Strategy[]; - } - - const groupedData: GroupedData[] = resultAllStrategy.reduce((acc: GroupedData[], item) => { - const existingRoot = acc.find((entry) => entry.rootId === item.rootId); - - if (existingRoot) { - existingRoot.strategy.push({ - strategyId: item.strategyId, - strategyName: item.strategyName, - devCount: item.devCount ? item.devCount : "-", - receiveBudget: item.receiveBudget ? item.receiveBudget : "-", - sumDev: "", - sumTraget: "", - sumBudget: "", - sumRowDev: "", - sumRowTarget: "", - sumRowBudget: "", - }); - } else { - acc.push({ - rootId: item.rootId, - root: item.root, - strategy: [ - { - strategyId: item.strategyId, - strategyName: item.strategyName, - devCount: item.devCount ? item.devCount : "-", - receiveBudget: item.receiveBudget ? item.receiveBudget : "-", - sumDev: "", - sumTraget: "", - sumBudget: "", - sumRowDev: "", - sumRowTarget: "", - sumRowBudget: "", - }, - ], - }); - } - - return acc; - }, []); - let sumDev1 = 0; - let sumTraget1 = 0; - let sumBudget1 = 0; - let sumDev2 = 0; - let sumTraget2 = 0; - let sumBudget2 = 0; - let sumDev3 = 0; - let sumTraget3 = 0; - let sumBudget3 = 0; - let sumDev4 = 0; - let sumTraget4 = 0; - let sumBudget4 = 0; - const reformattedData = groupedData.map((group, x) => { - const sumRowDev = - (group.strategy[0] && group.strategy[0].devCount !== "-" - ? Number(group.strategy[0].devCount) - : 0) + - (group.strategy[1] && group.strategy[1].devCount !== "-" - ? Number(group.strategy[1].devCount) - : 0) + - (group.strategy[2] && group.strategy[2].devCount !== "-" - ? Number(group.strategy[2].devCount) - : 0); - group.strategy[3] && group.strategy[3].devCount !== "-" - ? Number(group.strategy[3].devCount) - : 0; - const sumRowBudget = - (group.strategy[0] && group.strategy[0].receiveBudget !== "-" - ? Number(group.strategy[0].receiveBudget) - : 0) + - (group.strategy[1] && group.strategy[1].receiveBudget !== "-" - ? Number(group.strategy[1].receiveBudget) - : 0) + - (group.strategy[2] && group.strategy[2].receiveBudget !== "-" - ? Number(group.strategy[2].receiveBudget) - : 0); - group.strategy[3] && group.strategy[3].receiveBudget !== "-" - ? Number(group.strategy[3].receiveBudget) - : 0; - sumDev1 = groupedData.reduce((sum, group) => { - const devCount = - group.strategy[0] && group.strategy[0].devCount !== "-" - ? Number(group.strategy[0].devCount) - : 0; - return sum + devCount; - }, 0); - sumBudget1 = groupedData.reduce((sum, group) => { - const devCount = - group.strategy[0] && group.strategy[0].receiveBudget !== "-" - ? Number(group.strategy[0].receiveBudget) - : 0; - return sum + devCount; - }, 0); - sumDev2 = groupedData.reduce((sum, group) => { - const devCount = - group.strategy[1] && group.strategy[1].devCount !== "-" - ? Number(group.strategy[1].devCount) - : 0; - return sum + devCount; - }, 0); - sumBudget2 = groupedData.reduce((sum, group) => { - const devCount = - group.strategy[1] && group.strategy[1].receiveBudget !== "-" - ? Number(group.strategy[1].receiveBudget) - : 0; - return sum + devCount; - }, 0); - sumDev3 = groupedData.reduce((sum, group) => { - const devCount = - group.strategy[2] && group.strategy[2].devCount !== "-" - ? Number(group.strategy[2].devCount) - : 0; - return sum + devCount; - }, 0); - sumBudget3 = groupedData.reduce((sum, group) => { - const devCount = - group.strategy[2] && group.strategy[2].receiveBudget !== "-" - ? Number(group.strategy[2].receiveBudget) - : 0; - return sum + devCount; - }, 0); - sumDev4 = groupedData.reduce((sum, group) => { - const devCount = - group.strategy[3] && group.strategy[3].devCount !== "-" - ? Number(group.strategy[3].devCount) - : 0; - return sum + devCount; - }, 0); - sumBudget4 = groupedData.reduce((sum, group) => { - const devCount = - group.strategy[3] && group.strategy[3].receiveBudget !== "-" - ? Number(group.strategy[3].receiveBudget) - : 0; - return sum + devCount; - }, 0); - - const formattedGroup = { - rowNo: x ? Extension.ToThaiNumber((x + 1).toString()) : Extension.ToThaiNumber("๑"), - rootId: group.rootId, - root: group.root, - strategyName1: - group.strategy[0] && group.strategy[0].strategyName - ? group.strategy[0].strategyName - : "-", - devCount1: - group.strategy[0] && group.strategy[0].devCount - ? Extension.ToThaiNumber(group.strategy[0].devCount.toLocaleString()) - : "-", - target1: "-", - receiveBudget1: - group.strategy[0] && group.strategy[0].receiveBudget - ? Extension.ToThaiNumber(group.strategy[0].receiveBudget.toLocaleString()) - : "-", - - strategyName2: - group.strategy[1] && group.strategy[1].strategyName - ? group.strategy[1].strategyName - : "-", - devCount2: - group.strategy[1] && group.strategy[1].devCount - ? Extension.ToThaiNumber(group.strategy[1].devCount.toLocaleString()) - : "-", - target2: "-", - receiveBudget2: - group.strategy[1] && group.strategy[1].receiveBudget - ? Extension.ToThaiNumber(group.strategy[1].receiveBudget.toLocaleString()) - : "-", - - strategyName3: - group.strategy[2] && group.strategy[2].strategyName - ? group.strategy[2].strategyName - : "-", - devCount3: - group.strategy[2] && group.strategy[2].devCount - ? Extension.ToThaiNumber(group.strategy[2].devCount.toLocaleString()) - : "-", - target3: "-", - receiveBudget3: - group.strategy[2] && group.strategy[2].receiveBudget - ? Extension.ToThaiNumber(group.strategy[2].receiveBudget.toLocaleString()) - : "-", - - strategyName4: - group.strategy[3] && group.strategy[3].strategyName - ? group.strategy[3].strategyName - : "-", - devCount4: - group.strategy[3] && group.strategy[3].devCount - ? Extension.ToThaiNumber(group.strategy[3].devCount.toLocaleString()) - : "-", - target4: "-", - receiveBudget4: - group.strategy[3] && group.strategy[3].receiveBudget - ? Extension.ToThaiNumber(group.strategy[3].receiveBudget.toLocaleString()) - : "-", - - sumRowDev: sumRowDev ? Extension.ToThaiNumber(sumRowDev.toLocaleString()) : "-", - sumRowTarget: "-", - sumRowBudget: sumRowBudget ? Extension.ToThaiNumber(sumRowBudget.toLocaleString()) : "-", - // strategy: Array(4).fill(null).map((_, index) => { - // const strategy = group.strategy[index] || { - // strategyName: "", - // devCount: "", - // target: "", - // receiveBudget: "", - // sumDev: "", - // sumTraget: "", - // sumBudget: "", - // sumRowDev: "", - // sumRowTarget: "", - // sumRowBudget: "", - // }; - - // return { - // [`strategyName${index + 1}`]: strategy.strategyName ?? "", - // [`devCount${index + 1}`]: strategy.devCount ?? "", - // [`target${index + 1}`]: "", - // [`receiveBudget${index + 1}`]: strategy.receiveBudget ?? "", - // [`sumDev${index + 1}`]: strategy.sumDev ?? "", - // [`sumTraget${index + 1}`]: strategy.sumTraget ?? "", - // [`sumBudget${index + 1}`]: strategy.sumBudget ?? "", - // [`sumRowDev`]: strategy.sumRowDev ?? "", - // [`sumRowTarget`]: strategy.sumRowTarget ?? "", - // [`sumRowBudget`]: strategy.sumRowBudget ?? "", - // }; - // }), - }; - - return formattedGroup; - }); - - const dev = await this.developmentRepository.findOne({ - where: { rootDnaId: rootId }, - select: ["root", "year"] - }) - - return new HttpSuccess({ - template: "development", - reportName: "development", - data: { - root: dev && dev.root ? dev.root : "-", - year: dev && dev.year ? Extension.ToThaiNumber((dev.year+543).toString()) : "-", - data: mappedDataDev, - resultAllStrategy: reformattedData, - sumDev1: Extension.ToThaiNumber(sumDev1.toLocaleString()) ?? "-", - sumTraget1: Extension.ToThaiNumber(sumTraget1.toLocaleString()) ?? "-", - sumBudget1: Extension.ToThaiNumber(sumBudget1.toLocaleString()) ?? "-", - sumDev2: Extension.ToThaiNumber(sumDev2.toLocaleString()) ?? "-", - sumTraget2: Extension.ToThaiNumber(sumTraget2.toLocaleString()) ?? "-", - sumBudget2: Extension.ToThaiNumber(sumBudget2.toLocaleString()) ?? "-", - sumDev3: Extension.ToThaiNumber(sumDev3.toLocaleString()) ?? "-", - sumTraget3: Extension.ToThaiNumber(sumTraget3.toLocaleString()) ?? "-", - sumBudget3: Extension.ToThaiNumber(sumBudget3.toLocaleString()) ?? "-", - sumDev4: Extension.ToThaiNumber(sumDev4.toLocaleString()) ?? "-", - sumTraget4: Extension.ToThaiNumber(sumTraget4.toLocaleString()) ?? "-", - sumBudget4: Extension.ToThaiNumber(sumBudget4.toLocaleString()) ?? "-", - sumAllDev: - Extension.ToThaiNumber((sumDev1 + sumDev2 + sumDev3 + sumDev4).toLocaleString()) ?? "-", - sumTraget: - Extension.ToThaiNumber( - (sumTraget1 + sumTraget2 + sumTraget3 + sumTraget4).toLocaleString(), - ) ?? "-", - sumAllBudget: - Extension.ToThaiNumber( - (sumBudget1 + sumBudget2 + sumBudget3 + sumBudget4).toLocaleString(), - ) ?? "-", - }, - }); - } - - /** - * API Report รายการประวัติการฝึกอบรม/ดูงานของข้าราชการกรุงเทพมหานครสามัญ - * - * @summary DEV_0xx - Report รายการประวัติการฝึกอบรม/ดูงานของข้าราชการกรุงเทพมหานครสามัญ #xx - * - */ - @Post("history-officer") - async PostReportDevelopemtHistoryOfficer( - @Body() - body: { - year: number; - root: string; - }, - ) { - const development = await AppDataSource.getRepository(DevelopmentHistory) - .createQueryBuilder("developmentHistory") - .leftJoinAndSelect("developmentHistory.posLevel", "posLevel") - .leftJoinAndSelect("developmentHistory.posType", "posType") - .leftJoinAndSelect("developmentHistory.development", "development") - .andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", { - year: body.year, - }) - .andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", { - root: body.root, - }) - .andWhere("developmentHistory.type = :type", { type: "OFFICER" }) - .select([ - "developmentHistory.citizenId", - "developmentHistory.rank", - "developmentHistory.position", - "developmentHistory.posExecutive", - "developmentHistory.developmentId", - "developmentHistory.prefix", - "developmentHistory.firstName", - "developmentHistory.lastName", - "posLevel.posLevelName", - "posType.posTypeName", - "development.projectName", - "development.root", - ]) - .getMany(); - - const formattedData = development.map((item) => ({ - id: item.id, - citizenId: Extension.ToThaiNumber(item.citizenId.toString()), - fullName: item.prefix + item.firstName + " " + item.lastName, - position: item.position, - posType: item.posType ? item.posType.posTypeName : null, - posLevel: item.posLevel ? item.posLevel.posLevelName : null, - posExecutive: item.posExecutive, - projectName: item.development ? item.development.projectName : null, - root: item.root, - })); - - return new HttpSuccess({ - template: "developmentHistoryOfficer", - reportName: "developmentHistoryOfficer", - data: { - data: formattedData, - }, - }); - } - - /** - * API Report รายการประวัติฝึกอบรม/ดูงานลูกจ้าง - * - * @summary DEV_0xx - Report รายการประวัติฝึกอบรม/ดูงานลูกจ้าง #xx - * - * @param {number} year year ปี report - */ - @Post("history-employee") - async PostReportDevelopemtHistoryEmployee( - @Body() - body: { - year: number; - root: string; - }, - ) { - const development = await AppDataSource.getRepository(DevelopmentHistory) - .createQueryBuilder("developmentHistory") - .leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel") - .leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType") - .leftJoinAndSelect("developmentHistory.development", "development") - .andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", { - year: body.year, - }) - .andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", { - root: body.root, - }) - .andWhere("developmentHistory.type = :type", { type: "EMPLOYEE" }) - .select([ - "developmentHistory.citizenId", - "developmentHistory.position", - "developmentHistory.developmentId", - "developmentHistory.prefix", - "developmentHistory.firstName", - "developmentHistory.lastName", - "employeePosLevel.posLevelName", - "employeePosType.posTypeName", - "employeePosType.posTypeShortName", - "development.projectName", - "development.root", - ]) - .getMany(); - - const formattedData = development.map((item) => ({ - id: item.id, - citizenId: Extension.ToThaiNumber(item.citizenId.toString()), - fullName: item.prefix + item.firstName + " " + item.lastName, - position: item.position, - employeePosType: item.employeePosType ? item.employeePosType.posTypeName : null, - employeePosLevel: - item.employeePosType.posTypeShortName + - " " + - Extension.ToThaiNumber(item.employeePosLevel.posLevelName.toString()), - projectName: item.development ? item.development.projectName : null, - root: item.root, - })); - - return new HttpSuccess({ - template: "developmentHistoryEmployee", - reportName: "developmentHistoryEmployee", - data: { - data: formattedData, - }, - }); - } - - /** - * API Report รายการข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรม - * - * @summary DEV_0xx - Report รายการข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรม #xx - * - */ - @Get("scholarship") - async GetReportDevelopemtScholarship() { - const formattedData = { - org: "_type", - }; - - return new HttpSuccess({ - template: "development", - reportName: "development", - data: { - data: formattedData, - }, - }); - } - - /** - * API Report ข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรมใน detail - * - * @summary DEV_0xx - Report ข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรมใน detail #xx - * - * @param {string} id Id scholarship - */ - @Get("scholarship/{id}") - async GetReportDevelopemtScholarshipDetail(@Path() id: string) { - const getDevelopment = await this.developmentScholarshipRepository.findOne({ - where: { id: id }, - }); - if (!getDevelopment) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); - } - if (getDevelopment.scholarshipType != null) { - switch (getDevelopment.scholarshipType.trim().toUpperCase()) { - case "DOMESTICE": - getDevelopment.scholarshipType = "การศึกษาในประเทศ"; - break; - case "NOABROAD": - getDevelopment.scholarshipType = - "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)"; - break; - case "ABROAD": - getDevelopment.scholarshipType = - "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)"; - break; - case "EXECUTIVE": - getDevelopment.scholarshipType = - "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรประเภทนักบริหาร)"; - break; - case "RESEARCH": - getDevelopment.scholarshipType = - "ศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ"; - break; - case "STUDY": - getDevelopment.scholarshipType = - "ทุนการศึกษา ณ ต่างประเทศ"; - break; - case "TRAINING": - getDevelopment.scholarshipType = - "ทุนฝึกอบรม ณ ต่างประเทศ"; - break; - default: - break; - } - } - let _orgNoNewLine = (getDevelopment.org ? getDevelopment.org : "-").replace(/\n/g, " "); - const formattedData = { - id: getDevelopment.id, - firstName: getDevelopment.firstName, - lastName: getDevelopment.lastName, - position: getDevelopment.position, - org: _orgNoNewLine, - degreeLevel: getDevelopment.degreeLevel, - course: getDevelopment.course, - field: getDevelopment.field, - studyPlace: getDevelopment.studyPlace, - scholarshipType: getDevelopment.scholarshipType, - bookNoDate: - getDevelopment.bookNoDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.bookNoDate)), - startDate: - getDevelopment.startDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.startDate)), - endDate: - getDevelopment.endDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.endDate)), - reportBackNo: - getDevelopment.reportBackNo == null - ? "" - : Extension.ToThaiNumber(getDevelopment.reportBackNo), - reportBackNoDate: - getDevelopment.reportBackNoDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.reportBackNoDate)), - governmentDate: - getDevelopment.governmentDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.governmentDate)), - graduatedDate: - getDevelopment.graduatedDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.graduatedDate)), - graduatedReason: getDevelopment.graduatedReason == null ? "" : getDevelopment.graduatedReason, - useOfficialTime: getDevelopment.useOfficialTime, - useOffTime: getDevelopment.useOfficialTime == "NOUSETIME" ? "🗹 ใช้ ☐ ไม่ใช้" : "☐ ใช้ 🗹 ไม่ใช้", - isGraduated: getDevelopment.isGraduated, - isG1: getDevelopment.isGraduated == true ? "🗹" : "☐", - isG2: getDevelopment.isGraduated == true ? "☐" : "🗹", - totalPeriod: - getDevelopment.totalPeriod == null || getDevelopment.totalPeriod == "" - ? "" - : Extension.ToThaiNumber(getDevelopment.totalPeriod), - }; - - return new HttpSuccess({ - template: "repatriation", - reportName: "repatriation", - data: formattedData, - }); - } - - /** - * API Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญที่ได้รับทุนการศึกษา - * - * @summary DEV_0xx - Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญที่ได้รับทุนการศึกษา #xx - * - */ - @Get("report3") - async report3(@Query("year") year?: number, @Query("rootId") rootId?: string) { - const developments = await AppDataSource.getRepository(DevelopmentScholarship) - .createQueryBuilder("developmentScholarship") - .leftJoinAndSelect("developmentScholarship.posLevel", "posLevel") - .leftJoinAndSelect("developmentScholarship.posType", "posType") - .andWhere( - year !== 0 && year != null && year != undefined - ? "developmentScholarship.scholarshipYear = :scholarshipYear" - : "1=1", - { scholarshipYear: year }, - ) - .andWhere( - rootId != "" && rootId != null && rootId != undefined - ? "developmentScholarship.rootId = :rootId" - : "1=1", - { rootId: rootId }, - ) - .orderBy("developmentScholarship.scholarshipYear", "DESC") - .addOrderBy("developmentScholarship.createdAt", "DESC") - .getMany(); - - const mapData = developments.map((item, idx: number) => ({ - no: Extension.ToThaiNumber((idx + 1).toString()), - institution: item.educationalInstitution ? item.educationalInstitution : "-", - scholarshipType: item.scholarshipType - ? item.scholarshipType == "DOMESTICE" - ? "การศึกษาในประเทศ" - : item.scholarshipType == "NOABROAD" - ? "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)" - : item.scholarshipType == "ABROAD" - ? "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)" - : item.scholarshipType == "EXECUTIVE" - ? "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)" - : item.scholarshipType == "RESEARCH" - ? "ศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ" - : "-" - : "-", - degreeLevel: item.degreeLevel ? item.degreeLevel : "-", - course: item.course ? item.course : "-", - field: item.field ? item.field : "-", - fullName: `${item.prefix}${item.firstName} ${item.lastName}`, - position: item.position ? item.position : "-", - posLevel: item.posLevel ? item.posLevel.posLevelName : "-", - totalPeriod: item.totalPeriod ? item.totalPeriod : "-", - budgetApprove: item.budgetApprove - ? Extension.ToThaiNumber(item.budgetApprove.toLocaleString()) - : "๐", - })); - - const sum = developments - .filter((x) => x.budgetApprove) - .reduce((acc, item) => acc + Number(item.budgetApprove), 0); - - return new HttpSuccess({ - template: "reportFund3", - reportName: "reportFund3", - data: { - year: year ? Extension.ToThaiNumber((year + 543).toString()) : "", - root: rootId - ? developments.length > 0 - ? developments.find((x) => x.root != "")?.root - : "" - : "", - data: - mapData.length > 0 - ? mapData - : [ - { - no: "", - institution: "", - scholarshipType: "", - degreeLevel: "", - course: "", - field: "", - fullName: "", - position: "", - posLevel: "", - totalPeriod: "", - budgetApprove: "", - }, - ], - sum: sum ? Extension.ToThaiNumber(sum.toLocaleString()) : "-", - }, - }); - } - /** - * API Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญ ที่ส่งไปพัฒนากับหน่วยงานภายนอก - * - * @summary DEV_0xx - Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญ ที่ส่งไปพัฒนากับหน่วยงานภายนอก #xx - * - */ - @Get("report4") - async report4(@Query("year") year?: number) { - const developments = await AppDataSource.getRepository(DevelopmentScholarship) - .createQueryBuilder("developmentScholarship") - .andWhere( - year !== 0 && year != null && year != undefined - ? "developmentScholarship.scholarshipYear = :scholarshipYear" - : "1=1", - { scholarshipYear: year }, - ) - .orderBy("developmentScholarship.scholarshipYear", "DESC") - .addOrderBy("developmentScholarship.createdAt", "DESC") - .getMany(); - - // const _develop = await this.developmentScholarshipRepository.find({ - // where: { - // scholarshipYear: year ? year : Not(IsNull()) - // }, - // order: { "scholarshipYear" : "DESC" } - // }) - - const groupDevelopment = - Array.isArray(developments) && developments.length > 0 - ? developments.reduce((acc: any, current: any, idx: number) => { - const root = current.root || ""; - if (!acc[root]) { - acc[root] = { - no: idx + 1, - root: root, - Bachelor: 0, - BachelorHight: 0, - Master: 0, - Doctor: 0, - DomesticeCourseCount: 0, - DomesticeProfileCount: 0, - DomesticeBudgetApprove: 0, - NoAbroadCourseCount: 0, - NoAbroadDProfileCount: 0, - NoAbroadBudgetApprove: 0, - AbroadCourseCount: 0, - AbroadProfileCount: 0, - AbroadBudgetApprove: 0, - ExecutiveCourseCount: 0, - ExecutiveProfileCount: 0, - ExecutiveBudgetApprove: 0, - TotalCourseCount: 0, - TotalProfileCount: 0, - TotalBudgetApprove: 0, - }; - } - - switch (current.scholarshipType) { - case "DOMESTICE": - acc[root].DomesticeCourseCount++; - acc[root].DomesticeProfileCount++; - acc[root].DomesticeBudgetApprove += current.budgetApprove || 0; - break; - case "NOABROAD": - acc[root].NoAbroadCourseCount++; - acc[root].NoAbroadProfileCount++; - acc[root].NoAbroadBudgetApprove += current.budgetApprove || 0; - break; - case "ABROAD": - acc[root].AbroadCourseCount++; - acc[root].AbroadProfileCount++; - acc[root].AbroadBudgetApprove += current.budgetApprove || 0; - break; - case "EXECUTIVE": - acc[root].ExecutiveCourseCount++; - acc[root].ExecutiveProfileCount++; - acc[root].ExecutiveBudgetApprove += current.budgetApprove || 0; - break; - } - - acc[root].TotalCourseCount = - acc[root].DomesticeCourseCount + - acc[root].NoAbroadCourseCount + - acc[root].AbroadCourseCount + - acc[root].ExecutiveCourseCount; - acc[root].TotalProfileCount = - acc[root].DomesticeProfileCount + - acc[root].NoAbroadProfileCount + - acc[root].AbroadProfileCount + - acc[root].ExecutiveProfileCount; - acc[root].TotalBudgetApprove = - acc[root].DomesticeBudgetApprove + - acc[root].NoAbroadBudgetApprove + - acc[root].AbroadBudgetApprove + - acc[root].ExecutiveBudgetApprove; - - return acc; - }, {}) - : []; - - const _group = Object.values(groupDevelopment); - return new HttpSuccess({ - template: "reportFund4", - reportName: "reportFund4", - data: { - year: year ? Extension.ToThaiNumber((year + 543).toString()) : "-", - data: Array.isArray(_group) - ? // ? _group - _group.map((x: any) => ({ - no: x.no ? Extension.ToThaiNumber(x.no.toString()) : "-", - root: x.root ? x.root : "ไม่พบหน่วยงาน", - Bachelor: "-", - BachelorHight: "-", - Master: "-", - Doctor: "-", - DomesticeCourseCount: x.DomesticeCourseCount - ? Extension.ToThaiNumber(x.DomesticeCourseCount.toLocaleString()) - : "-", - DomesticeProfileCount: x.DomesticeProfileCount - ? Extension.ToThaiNumber(x.DomesticeProfileCount.toLocaleString()) - : "-", - DomesticeBudgetApprove: x.DomesticeBudgetApprove - ? Extension.ToThaiNumber(x.DomesticeBudgetApprove.toLocaleString()) - : "-", - NoAbroadCourseCount: x.NoAbroadCourseCount - ? Extension.ToThaiNumber(x.NoAbroadCourseCount.toLocaleString()) - : "-", - NoAbroadDProfileCount: x.NoAbroadDProfileCount - ? Extension.ToThaiNumber(x.NoAbroadDProfileCount.toLocaleString()) - : "-", - NoAbroadBudgetApprove: x.NoAbroadBudgetApprove - ? Extension.ToThaiNumber(x.NoAbroadBudgetApprove.toLocaleString()) - : "-", - AbroadCourseCount: x.AbroadCourseCount - ? Extension.ToThaiNumber(x.AbroadCourseCount.toLocaleString()) - : "-", - AbroadProfileCount: x.AbroadProfileCount - ? Extension.ToThaiNumber(x.AbroadProfileCount.toLocaleString()) - : "-", - AbroadBudgetApprove: x.AbroadBudgetApprove - ? Extension.ToThaiNumber(x.AbroadBudgetApprove.toLocaleString()) - : "-", - ExecutiveCourseCount: x.ExecutiveCourseCount - ? Extension.ToThaiNumber(x.ExecutiveCourseCount.toLocaleString()) - : "-", - ExecutiveProfileCount: x.ExecutiveProfileCount - ? Extension.ToThaiNumber(x.ExecutiveProfileCount.toLocaleString()) - : "-", - ExecutiveBudgetApprove: x.ExecutiveBudgetApprove - ? Extension.ToThaiNumber(x.ExecutiveBudgetApprove.toLocaleString()) - : "-", - TotalCourseCount: x.TotalCourseCount - ? Extension.ToThaiNumber(x.TotalCourseCount.toLocaleString()) - : "-", - TotalProfileCount: x.TotalProfileCount - ? Extension.ToThaiNumber(x.TotalProfileCount.toLocaleString()) - : "-", - TotalBudgetApprove: x.TotalBudgetApprove - ? Extension.ToThaiNumber(x.TotalBudgetApprove.toLocaleString()) - : "-", - })) - : [ - { - no: "-", - root: "-", - Bachelor: "-", - BachelorHight: "-", - Master: "-", - Doctor: "-", - DomesticeCourseCount: "-", - DomesticeProfileCount: "-", - DomesticeBudgetApprove: "-", - NoAbroadCourseCount: "-", - NoAbroadDProfileCount: "-", - NoAbroadBudgetApprove: "-", - AbroadCourseCount: "-", - AbroadProfileCount: "-", - AbroadBudgetApprove: "-", - ExecutiveCourseCount: "-", - ExecutiveProfileCount: "-", - ExecutiveBudgetApprove: "-", - TotalCourseCount: "-", - TotalProfileCount: "-", - TotalBudgetApprove: "-", - }, - ], - totalRoot: Array.isArray(_group) - ? Extension.ToThaiNumber(_group.length.toLocaleString()) - : "-", - }, - }); - } - /** - * API Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญที่ไปศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ - * - * @summary DEV_0xx - Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญที่ไปศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ #xx - * - */ - @Get("report5") - async report5( - @Query("year") year?: number, - // @Query("rootId") rootId: string, - ) { - const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship) - .createQueryBuilder("developmentScholarship") - .leftJoinAndSelect("developmentScholarship.posLevel", "posLevel") - .leftJoinAndSelect("developmentScholarship.posType", "posType") - .leftJoinAndSelect("developmentScholarship.posLevelguarantor", "posLevelguarantor") - .leftJoinAndSelect("developmentScholarship.posTypeguarantor", "posTypeguarantor") - // .where("developmentScholarship.rootId = :rootId", { rootId: rootId }) - .andWhere( - year !== 0 && year != null && year != undefined - ? "developmentScholarship.scholarshipYear = :scholarshipYear" - : "1=1", - { scholarshipYear: year }, - ) - .andWhere("developmentScholarship.scholarshipType = :scholarshipType", { - scholarshipType: "RESEARCH", - }) - .orderBy("developmentScholarship.scholarshipYear", "DESC") - .addOrderBy("developmentScholarship.createdAt", "DESC") - .getManyAndCount(); - - const totalBudgetApprove = development.reduce( - (sum, item) => sum + Number(item.budgetApprove), - 0, - ); - const formattedData = development.map((item, index) => { - const rawPath = [ - item.course == "-" ? null : item.course, - item.field == "-" ? null : item.course, - ]; - - const courseAndfield = rawPath - .filter((path) => path !== undefined && path !== null) - .join("/"); - - const date = [ - Extension.ToThaiNumber(Extension.ToThaiShortDate(item.startDate)), - Extension.ToThaiNumber(Extension.ToThaiShortDate(item.endDate)), - ]; - - const dateDulation = date.filter((path) => path !== undefined && path !== null).join(" - "); - - return { - no: Extension.ToThaiNumber((index + 1).toString()), - id: item.id, - studyTopic: item.studyTopic ? item.studyTopic : "-", - fullName: item.prefix + item.firstName + " " + item.lastName, - position: item.position, - posLevel: item.posLevel ? item.posLevel.posLevelName : "-", - courseAndfield: courseAndfield ?? "-", - place: item.studyPlace ? item.studyPlace : "-", - country: item.studyCountry ? item.studyCountry : "-", - startAndendDate: dateDulation, - budgetApprove: item.budgetApprove - ? Extension.ToThaiNumber(item.budgetApprove.toLocaleString()) - : "-", - }; - }); - - return new HttpSuccess({ - template: "reportFund5", - reportName: "reportFund5", - data: { - year: year ? Extension.ToThaiNumber((year + 543).toString()) : "", - data: formattedData, - total: Extension.ToThaiNumber(total.toLocaleString()), - totalBudgetApprove: Extension.ToThaiNumber(totalBudgetApprove.toLocaleString()), - }, - }); - } - /** - * API Report รายงานสถิติข้อมูลการศึกษาต่อ การฝึกอบรม ศึกษาดูงาน ของข้าราชการกรุงเทพมหานครสามัญ - * - * @summary DEV_0xx - Report รายงานสถิติข้อมูลการศึกษาต่อ การฝึกอบรม ศึกษาดูงาน ของข้าราชการกรุงเทพมหานครสามัญ #xx - * - */ - @Get("report6") - async report6(@Query("year") year?: number) { - const degree = ["ปริญญาเอก", "ปริญญาโท", "ปริญญาตรี"]; - - const development = await this.viewDevScholarship.find({ - where: { - rootId: Not(IsNull()), - degreeLevel: In(degree), - }, - }); - - const groupedData = development.reduce((acc: any, item: any) => { - const { rootId, root, degreeLevel, scholarshipType, budgetApprove } = item; - - if (!acc[rootId]) { - acc[rootId] = { - root, - rootId, - degreeLevel1: { - numberOfRecords: 0, - numberOfScholarshipTypes: 0, - totalBudgetApprove: 0, - }, - degreeLevel2: { - numberOfRecords: 0, - numberOfScholarshipTypes: 0, - totalBudgetApprove: 0, - }, - degreeLevel3: { - numberOfRecords: 0, - numberOfScholarshipTypes: 0, - totalBudgetApprove: 0, - }, - }; - } - - if (degreeLevel === "ปริญญาตรี") { - acc[rootId].degreeLevel1.numberOfRecords += Number(item.numberOfRecords); - acc[rootId].degreeLevel1.numberOfScholarshipTypes += Number(item.numberOfScholarshipTypes); - acc[rootId].degreeLevel1.totalBudgetApprove += Number(item.totalBudgetApprove); - } else if (degreeLevel === "ปริญญาโท") { - acc[rootId].degreeLevel2.numberOfRecords += Number(item.numberOfRecords); - acc[rootId].degreeLevel2.numberOfScholarshipTypes += Number(item.numberOfScholarshipTypes); - acc[rootId].degreeLevel2.totalBudgetApprove += Number(item.totalBudgetApprove); - } else if (degreeLevel === "ปริญญาเอก") { - acc[rootId].degreeLevel3.numberOfRecords += Number(item.numberOfRecords); - acc[rootId].degreeLevel3.numberOfScholarshipTypes += Number(item.numberOfScholarshipTypes); - acc[rootId].degreeLevel3.totalBudgetApprove += Number(item.totalBudgetApprove); - } - - return acc; - }, {}); - - const formattedData = Object.values(groupedData).map((item: any, index: any) => { - const sumnumberOfRecords = - item.degreeLevel1.numberOfRecords + - item.degreeLevel2.numberOfRecords + - item.degreeLevel3.numberOfRecords; - const sumnumberOfScholarshipTypes = - item.degreeLevel1.numberOfScholarshipTypes + - item.degreeLevel2.numberOfScholarshipTypes + - item.degreeLevel3.numberOfScholarshipTypes; - const sumtotalBudgetApprove = - item.degreeLevel1.totalBudgetApprove + - item.degreeLevel2.totalBudgetApprove + - item.degreeLevel3.totalBudgetApprove; - - return { - no: index ? Extension.ToThaiNumber((index + 1).toString()) : "๑", - rootId: item.rootId ? item.rootId : "-", - root: item.root ? item.root : "-", - degreeLevel1: "ปริญญาตรี", - numberOfRecords1: item.degreeLevel1.numberOfRecords - ? Extension.ToThaiNumber(item.degreeLevel1.numberOfRecords.toString()) - : "-", - numberOfScholarshipTypes1: item.degreeLevel1.numberOfScholarshipTypes - ? Extension.ToThaiNumber(item.degreeLevel1.numberOfScholarshipTypes.toString()) - : "-", - totalBudgetApprove1: item.degreeLevel1.totalBudgetApprove - ? Extension.ToThaiNumber(item.degreeLevel1.totalBudgetApprove.toLocaleString()) - : "-", - - degreeLevel2: "ปริญญาโท", - numberOfRecords2: item.degreeLevel2.numberOfRecords - ? Extension.ToThaiNumber(item.degreeLevel2.numberOfRecords.toString()) - : "-", - numberOfScholarshipTypes2: item.degreeLevel2.numberOfScholarshipTypes - ? Extension.ToThaiNumber(item.degreeLevel2.numberOfScholarshipTypes.toString()) - : "-", - totalBudgetApprove2: item.degreeLevel2.totalBudgetApprove - ? Extension.ToThaiNumber(item.degreeLevel2.totalBudgetApprove.toLocaleString()) - : "-", - - degreeLevel3: "ปริญญาเอก", - numberOfRecords3: item.degreeLevel3.numberOfRecords - ? Extension.ToThaiNumber(item.degreeLevel3.numberOfRecords.toString()) - : "-", - numberOfScholarshipTypes3: item.degreeLevel3.numberOfScholarshipTypes - ? Extension.ToThaiNumber(item.degreeLevel3.numberOfScholarshipTypes.toString()) - : "-", - totalBudgetApprove3: item.degreeLevel3.totalBudgetApprove - ? Extension.ToThaiNumber(item.degreeLevel3.totalBudgetApprove.toLocaleString()) - : "-", - - totalNumberOfRecords: Extension.ToThaiNumber(sumnumberOfRecords.toString()), - totalNumberOfScholarshipTypes: Extension.ToThaiNumber( - sumnumberOfScholarshipTypes.toString(), - ), - totalTotalBudgetApprove: Extension.ToThaiNumber(sumtotalBudgetApprove.toLocaleString()), - }; - }); - const uniqueRoots = new Set(formattedData.map((item) => item.root)); - const numberOfORG = uniqueRoots.size; - - return new HttpSuccess({ - template: "reportFund6", - reportName: "reportFund6", - data: { - year: year ? Extension.ToThaiNumber((year + 543).toString()) : "", - data: formattedData, - coutOrg: numberOfORG - ? Extension.ToThaiNumber(numberOfORG.toString()) + " หน่วยงาน" - : "๐ หน่วยงาน", - }, - }); - } -} diff --git a/src/controllers/StrategyController.ts b/src/controllers/StrategyController.ts deleted file mode 100644 index 1f5b4c0..0000000 --- a/src/controllers/StrategyController.ts +++ /dev/null @@ -1,743 +0,0 @@ -import { - Body, - Controller, - Delete, - Get, - Patch, - Path, - Post, - Put, - Request, - Route, - Security, - Tags, -} from "tsoa"; -import { AppDataSource } from "../database/data-source"; -import { StrategyChild1 } from "../entities/StrategyChild1"; -import { StrategyChild2 } from "../entities/StrategyChild2"; -import { StrategyChild3 } from "../entities/StrategyChild3"; -import { StrategyChild4 } from "../entities/StrategyChild4"; -import { StrategyChild5 } from "../entities/StrategyChild5"; -import HttpError from "../interfaces/http-error"; -import HttpStatus from "../interfaces/http-status"; -import HttpSuccess from "../interfaces/http-success"; -import { setLogDataDiff } from "../interfaces/utils"; -import { RequestWithUser } from "../middlewares/user"; -import permission from "../interfaces/permission"; -@Route("api/v1/development/strategy") -@Tags("Strategy") -@Security("bearerAuth") -export class StrategyController extends Controller { - private strategy1Repo = AppDataSource.getRepository(StrategyChild1); - private strategy2Repo = AppDataSource.getRepository(StrategyChild2); - private strategy3Repo = AppDataSource.getRepository(StrategyChild3); - private strategy4Repo = AppDataSource.getRepository(StrategyChild4); - private strategy5Repo = AppDataSource.getRepository(StrategyChild5); - - @Get("indicator") - public async listStrategyChild(@Request() request: RequestWithUser) { - let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR"); - const listStrategyChild1 = await this.strategy1Repo.find({ - relations: [ - "strategyChild2s", - "strategyChild2s.strategyChild3s", - "strategyChild2s.strategyChild3s.strategyChild4s", - "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", - ], - order: { - order: "ASC", - strategyChild2s: { - order: "ASC", - strategyChild3s: { - order: "ASC", - strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } }, - }, - }, - }, - }); - - const formattedData = listStrategyChild1.map((item) => ({ - id: item.id, - level: 1, - name: item.strategyChild1Name, - order: item.order, - children: item.strategyChild2s.map((child2) => ({ - id: child2.id, - level: 2, - name: child2.strategyChild2Name, - order: child2.order, - children: child2.strategyChild3s - ? child2.strategyChild3s.map((child3) => ({ - id: child3.id, - level: 3, - name: child3.strategyChild3Name, - order: child3.order, - children: child3.strategyChild4s - ? child3.strategyChild4s.map((child4) => ({ - id: child4.id, - level: 4, - name: child4.strategyChild4Name, - order: child4.order, - children: child4.strategyChild5s - ? child4.strategyChild5s.map((child5) => ({ - id: child5.id, - level: 5, - name: child5.strategyChild5Name, - order: child5.order, - })) - : [], - })) - : [], - })) - : [], - })), - })); - - return new HttpSuccess(formattedData); - } - - @Get("edit/{page}") - public async listStrategyChild1Edit(@Request() request: RequestWithUser, @Path() page: string) { - let _page = page.trim().toUpperCase(); - if (_page == "STRATEGIC") { - await new permission().PermissionList(request, "SYS_EVA_STRATIGIC"); - } else if (_page == "DEVELOP") { - await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); - } else if (_page == "INDICATOR") { - await new permission().PermissionGet(request, "SYS_EVA_INDICATOR"); - } else { - await new permission().PermissionList(request, "SYS_EVA_STRATIGIC"); - } - const listStrategyChild1 = await this.strategy1Repo.find({ - relations: [ - "strategyChild2s", - "strategyChild2s.strategyChild3s", - "strategyChild2s.strategyChild3s.strategyChild4s", - "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", - ], - order: { - order: "ASC", - strategyChild2s: { - order: "ASC", - strategyChild3s: { - order: "ASC", - strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } }, - }, - }, - }, - }); - - // if (!listStrategyChild1 || listStrategyChild1.length === 0) { - // throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - // } - - const formattedData = listStrategyChild1.map((item) => ({ - id: item.id, - level: 1, - name: item.strategyChild1Name, - order: item.order, - children: item.strategyChild2s.map((child2) => ({ - id: child2.id, - level: 2, - name: child2.strategyChild2Name, - order: child2.order, - children: child2.strategyChild3s - ? child2.strategyChild3s.map((child3) => ({ - id: child3.id, - level: 3, - name: child3.strategyChild3Name, - order: child3.order, - children: child3.strategyChild4s - ? child3.strategyChild4s.map((child4) => ({ - id: child4.id, - level: 4, - name: child4.strategyChild4Name, - order: child4.order, - children: child4.strategyChild5s - ? child4.strategyChild5s.map((child5) => ({ - id: child5.id, - level: 5, - name: child5.strategyChild5Name, - order: child5.order, - })) - : [], - })) - : [], - })) - : [], - })), - })); - - return new HttpSuccess(formattedData); - } - - @Get() - public async listStrategyChild1(@Request() request: RequestWithUser) { - const listStrategyChild1 = await this.strategy1Repo.find({ - relations: [ - "strategyChild2s", - "strategyChild2s.strategyChild3s", - "strategyChild2s.strategyChild3s.strategyChild4s", - "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", - ], - order: { - order: "ASC", - strategyChild2s: { - order: "ASC", - strategyChild3s: { - order: "ASC", - strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } }, - }, - }, - }, - }); - - // if (!listStrategyChild1 || listStrategyChild1.length === 0) { - // throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - // } - - const formattedData = listStrategyChild1.map((item) => ({ - id: item.id, - level: 1, - name: item.strategyChild1Name, - order: item.order, - children: item.strategyChild2s.map((child2) => ({ - id: child2.id, - level: 2, - name: child2.strategyChild2Name, - order: child2.order, - children: child2.strategyChild3s - ? child2.strategyChild3s.map((child3) => ({ - id: child3.id, - level: 3, - name: child3.strategyChild3Name, - order: child3.order, - children: child3.strategyChild4s - ? child3.strategyChild4s.map((child4) => ({ - id: child4.id, - level: 4, - name: child4.strategyChild4Name, - order: child4.order, - children: child4.strategyChild5s - ? child4.strategyChild5s.map((child5) => ({ - id: child5.id, - level: 5, - name: child5.strategyChild5Name, - order: child5.order, - })) - : [], - })) - : [], - })) - : [], - })), - })); - - return new HttpSuccess(formattedData); - } - - @Post() - public async newStrategyChild( - @Request() request: RequestWithUser, - @Body() - body: { - name: string; - levelnode: number; - idnode?: string | null; - }, - ) { - await new permission().PermissionCreate(request, "SYS_EVA_STRATIGIC"); - let strategyRepo: any; - let strategyChild: any; - let repoSave: any; - - switch (body.levelnode) { - case 0: - const ckOrder = await this.strategy1Repo.findOne({ - where: {}, - order: { order: "DESC" }, - }); - strategyRepo = this.strategy1Repo; - strategyRepo = this.strategy1Repo; - repoSave = this.strategy1Repo; - strategyChild = new StrategyChild1(); - strategyChild.strategyChild1Name = body.name; - strategyChild.order = ckOrder ? ckOrder.order + 1 : 1; - break; - case 1: - strategyRepo = this.strategy1Repo; - repoSave = this.strategy2Repo; - strategyChild = new StrategyChild2(); - strategyChild.strategyChild2Name = body.name; - strategyChild.order = 1; - if (body.idnode) { - const chk1 = await this.strategy1Repo.findOne({ - where: { id: body.idnode }, - order: { order: "DESC" }, - }); - if (chk1) { - strategyChild.strategyChild1Id = chk1.id; - strategyChild.order = chk1 ? chk1.order + 1 : 1; - } else { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - } - break; - case 2: - strategyRepo = this.strategy2Repo; - repoSave = this.strategy3Repo; - strategyChild = new StrategyChild3(); - strategyChild.strategyChild3Name = body.name; - strategyChild.order = 1; - if (body.idnode) { - const chk2 = await this.strategy2Repo.findOne({ - where: { id: body.idnode }, - order: { order: "DESC" }, - }); - if (chk2) { - strategyChild.strategyChild1Id = chk2.strategyChild1Id; - strategyChild.strategyChild2Id = chk2.id; - strategyChild.order = chk2 ? chk2.order + 1 : 1; - } else { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - } - break; - case 3: - strategyRepo = this.strategy3Repo; - repoSave = this.strategy4Repo; - strategyChild = new StrategyChild4(); - strategyChild.strategyChild4Name = body.name; - strategyChild.order = 1; - if (body.idnode) { - const chk3 = await this.strategy3Repo.findOne({ - where: { id: body.idnode }, - order: { order: "DESC" }, - }); - if (chk3) { - strategyChild.strategyChild1Id = chk3.strategyChild1Id; - strategyChild.strategyChild2Id = chk3.strategyChild2Id; - strategyChild.strategyChild3Id = chk3.id; - strategyChild.order = chk3 ? chk3.order + 1 : 1; - } else { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - } - break; - case 4: - strategyRepo = this.strategy4Repo; - repoSave = this.strategy5Repo; - strategyChild = new StrategyChild5(); - strategyChild.strategyChild5Name = body.name; - strategyChild.order = 1; - if (body.idnode) { - const chk4 = await this.strategy4Repo.findOne({ - where: { id: body.idnode }, - order: { order: "DESC" }, - }); - if (chk4) { - strategyChild.strategyChild1Id = chk4.strategyChild1Id; - strategyChild.strategyChild2Id = chk4.strategyChild2Id; - strategyChild.strategyChild3Id = chk4.strategyChild3Id; - strategyChild.strategyChild4Id = chk4.id; - strategyChild.order = chk4 ? chk4.order + 1 : 1; - } else { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - } - break; - default: - throw new HttpError(HttpStatus.BAD_REQUEST, "levelnode ไม่ถูกต้อง"); - } - const before = null; - strategyChild.createdUserId = request.user.sub; - strategyChild.createdFullName = request.user.name; - strategyChild.lastUpdateUserId = request.user.sub; - strategyChild.lastUpdateFullName = request.user.name; - strategyChild.createdAt = new Date(); - strategyChild.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store Strategy.", - // }); - await repoSave.save(strategyChild, { data: request }); - setLogDataDiff(request, { before, after: strategyChild }); - - return new HttpSuccess(strategyChild.id); - } - - @Patch() - public async editStrategyChild1( - @Request() request: RequestWithUser, - @Body() - body: { - name: string; - levelnode: number; - idnode: string; - }, - ) { - await new permission().PermissionUpdate(request, "SYS_EVA_STRATIGIC"); - let strategyRepo: any; - let strategyChild: any; - - switch (body.levelnode) { - case 1: - strategyRepo = this.strategy1Repo; - strategyChild = await strategyRepo.findOne({ - where: { id: body.idnode }, - }); - if (!strategyChild) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - strategyChild.strategyChild1Name = body.name; - break; - case 2: - strategyRepo = this.strategy2Repo; - strategyChild = await strategyRepo.findOne({ - where: { id: body.idnode }, - }); - if (!strategyChild) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - strategyChild.strategyChild2Name = body.name; - break; - case 3: - strategyRepo = this.strategy3Repo; - strategyChild = await strategyRepo.findOne({ - where: { id: body.idnode }, - }); - if (!strategyChild) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - strategyChild.strategyChild3Name = body.name; - break; - case 4: - strategyRepo = this.strategy4Repo; - strategyChild = await strategyRepo.findOne({ - where: { id: body.idnode }, - }); - if (!strategyChild) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - strategyChild.strategyChild4Name = body.name; - break; - case 5: - strategyRepo = this.strategy5Repo; - strategyChild = await this.strategy5Repo.findOne({ - where: { id: body.idnode }, - }); - if (!strategyChild) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - strategyChild.strategyChild5Name = body.name; - break; - default: - throw new HttpError(HttpStatus.BAD_REQUEST, "levelnode ไม่ถูกต้อง"); - } - strategyChild.lastUpdateUserId = request.user.sub; - strategyChild.lastUpdateFullName = request.user.name; - strategyChild.lastUpdatedAt = new Date(); - - // addLogSequence(request, { - // action: "remove", - // status: "success", - // description: "Edit Strategy by ID.", - // }); - await strategyRepo.save(strategyChild, { data: request }); - - return new HttpSuccess(); - } - - @Delete() - public async deleteStrategyChild( - @Request() request: RequestWithUser, - @Body() - body: { - levelnode: number; - idnode: string; - }, - ) { - await new permission().PermissionDelete(request, "SYS_EVA_STRATIGIC"); - let strategyRepo: any; - let data: any; - - switch (body.levelnode) { - case 1: - strategyRepo = this.strategy1Repo; - data = await strategyRepo.find({ - where: { id: body.idnode }, - }); - if (!data) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - await this.strategy5Repo.delete({ strategyChild1Id: body.idnode }); - await this.strategy4Repo.delete({ strategyChild1Id: body.idnode }); - await this.strategy3Repo.delete({ strategyChild1Id: body.idnode }); - await this.strategy2Repo.delete({ strategyChild1Id: body.idnode }); - await this.strategy1Repo.delete({ id: body.idnode }); - break; - case 2: - strategyRepo = this.strategy2Repo; - data = await strategyRepo.find({ - where: { id: body.idnode }, - }); - if (!data) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - await this.strategy5Repo.delete({ strategyChild2Id: body.idnode }); - await this.strategy4Repo.delete({ strategyChild2Id: body.idnode }); - await this.strategy3Repo.delete({ strategyChild2Id: body.idnode }); - await this.strategy2Repo.delete({ id: body.idnode }); - break; - case 3: - strategyRepo = this.strategy3Repo; - data = await strategyRepo.find({ - where: { id: body.idnode }, - }); - if (!data) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - await this.strategy5Repo.delete({ strategyChild3Id: body.idnode }); - await this.strategy4Repo.delete({ strategyChild3Id: body.idnode }); - await this.strategy3Repo.delete({ id: body.idnode }); - break; - case 4: - strategyRepo = this.strategy4Repo; - data = await strategyRepo.find({ - where: { id: body.idnode }, - }); - if (!data) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - await this.strategy5Repo.delete({ strategyChild4Id: body.idnode }); - await this.strategy4Repo.delete({ id: body.idnode }); - break; - case 5: - strategyRepo = this.strategy5Repo; - data = await strategyRepo.find({ - where: { id: body.idnode }, - }); - if (!data) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); - } - await this.strategy5Repo.delete({ id: body.idnode }); - break; - default: - throw new HttpError(HttpStatus.BAD_REQUEST, "levelnode ไม่ถูกต้อง"); - } - - if (!data) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - - return new HttpSuccess(); - } - - /** - * API เช็ค node detail - * - * @summary เช็ค node detail (ADMIN) - * - */ - @Post("find/all") - async findNodeAllDetail(@Body() requestBody: { strategy: number; strategyId: string }) { - switch (requestBody.strategy) { - case 1: { - const data = await this.strategy1Repo.findOne({ - where: { id: requestBody.strategyId }, - }); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found rootId."); - } - return new HttpSuccess({ - strategyChild1Id: data.id, - strategyChild1: data.strategyChild1Name, - }); - } - case 2: { - const data = await this.strategy2Repo.findOne({ - where: { id: requestBody.strategyId }, - relations: { - strategyChild1: true, - }, - }); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found child1."); - } - return new HttpSuccess({ - strategyChild1Id: data.strategyChild1Id, - strategyChild1: - data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name, - strategyChild2Id: data.id, - strategyChild2: data.strategyChild2Name, - }); - } - case 3: { - const data = await this.strategy3Repo.findOne({ - where: { id: requestBody.strategyId }, - relations: { - strategyChild1: true, - strategyChild2: true, - }, - }); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found child2."); - } - return new HttpSuccess({ - strategyChild1Id: data.strategyChild1Id, - strategyChild1: - data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name, - strategyChild2Id: data.strategyChild2Id, - strategyChild2: - data.strategyChild2 == null ? null : data.strategyChild2.strategyChild2Name, - strategyChild3Id: data.id, - strategyChild3: data.strategyChild3Name, - }); - } - case 4: { - const data = await this.strategy4Repo.findOne({ - where: { id: requestBody.strategyId }, - relations: { - strategyChild1: true, - strategyChild2: true, - strategyChild3: true, - }, - }); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found child3."); - } - return new HttpSuccess({ - strategyChild1Id: data.strategyChild1Id, - strategyChild1: - data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name, - strategyChild2Id: data.strategyChild2Id, - strategyChild2: - data.strategyChild2 == null ? null : data.strategyChild2.strategyChild2Name, - strategyChild3Id: data.strategyChild3Id, - strategyChild3: - data.strategyChild3 == null ? null : data.strategyChild3.strategyChild3Name, - strategyChild4Id: data.id, - strategyChild4: data.strategyChild4Name, - }); - } - case 5: { - const data = await this.strategy5Repo.findOne({ - where: { id: requestBody.strategyId }, - relations: { - strategyChild1: true, - strategyChild2: true, - strategyChild3: true, - strategyChild4: true, - }, - }); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found child4."); - } - return new HttpSuccess({ - strategyChild1Id: data.strategyChild1Id, - strategyChild1: - data.strategyChild1 == null ? null : data.strategyChild1.strategyChild1Name, - strategyChild2Id: data.strategyChild2Id, - strategyChild2: - data.strategyChild2 == null ? null : data.strategyChild2.strategyChild2Name, - strategyChild3Id: data.strategyChild3Id, - strategyChild3: - data.strategyChild3 == null ? null : data.strategyChild3.strategyChild3Name, - strategyChild4Id: data.strategyChild4Id, - strategyChild4: - data.strategyChild4 == null ? null : data.strategyChild4.strategyChild4Name, - strategyChild5Id: data.id, - strategyChild5: data.strategyChild5Name, - }); - } - default: - throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy); - } - } - - /** - * API เรียงลำดับ - * - * @summary เรียงลำดับ (ADMIN) - * - */ - @Post("sort") - async sortNode( - @Body() requestBody: { strategy: number; strategyId: string[]; id: string | null }, - @Request() request: RequestWithUser, - ) { - switch (requestBody.strategy) { - case 1: { - const data = await this.strategy1Repo.find(); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy1."); - } - const sortLevel = data.map((data) => ({ - ...data, - order: requestBody.strategyId.indexOf(data.id) + 1, - })); - await this.strategy1Repo.save(sortLevel); - return new HttpSuccess(sortLevel); - } - case 2: { - const data = await this.strategy2Repo.find({ - where: { strategyChild1Id: requestBody.id ?? "" }, - }); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy2."); - } - const sortLevel = data.map((data) => ({ - ...data, - order: requestBody.strategyId.indexOf(data.id) + 1, - })); - await this.strategy2Repo.save(sortLevel); - return new HttpSuccess(sortLevel); - } - case 3: { - const data = await this.strategy3Repo.find({ - where: { strategyChild2Id: requestBody.id ?? "" }, - }); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy3."); - } - const sortLevel = data.map((data) => ({ - ...data, - order: requestBody.strategyId.indexOf(data.id) + 1, - })); - await this.strategy3Repo.save(sortLevel); - return new HttpSuccess(sortLevel); - } - case 4: { - const data = await this.strategy4Repo.find({ - where: { strategyChild3Id: requestBody.id ?? "" }, - }); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy4."); - } - const sortLevel = data.map((data) => ({ - ...data, - order: requestBody.strategyId.indexOf(data.id) + 1, - })); - await this.strategy4Repo.save(sortLevel); - return new HttpSuccess(sortLevel); - } - case 5: { - const data = await this.strategy5Repo.find({ - where: { strategyChild4Id: requestBody.id ?? "" }, - }); - if (data == null) { - throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy5."); - } - const sortLevel = data.map((data) => ({ - ...data, - order: requestBody.strategyId.indexOf(data.id) + 1, - })); - await this.strategy5Repo.save(sortLevel); - return new HttpSuccess(sortLevel); - } - default: - throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy); - } - } -} diff --git a/src/database/data-source.ts b/src/database/data-source.ts index d713314..7c70f52 100644 --- a/src/database/data-source.ts +++ b/src/database/data-source.ts @@ -1,46 +1,6 @@ import "dotenv/config"; import "reflect-metadata"; -import { DataSource, LogLevel, LogMessage } from "typeorm"; -import { Logger } from "typeorm"; -import { QueryRunner } from "typeorm/browser"; -import { RequestWithUser } from "../middlewares/user"; -import { addLogSequence } from "../interfaces/utils"; - -export class MyCustomLogger implements Logger { - log(level: "log" | "info" | "warn", message: any, queryRunner?: QueryRunner) {} - - logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner): void { - const req = queryRunner?.data as RequestWithUser; - if (req?.app?.locals.logData?.sequence) { - addLogSequence(req, { - action: "database", - status: "success", - description: "Query Data.", - query: [ - "Query: " + query + (parameters ? " - Parameters:" + JSON.stringify(parameters) : ""), - ], - }); - } - - // const req = queryRunner?.data as RequestWithUser | undefined; - // const logData = req?.app?.locals.logData?.sequence?.at(-1); - - // if (logData && !logData.query) logData.query = []; - // if (logData) logData.query.push( - // "Query: " + query + (parameters ? (" - Parameters:" + JSON.stringify(parameters)) : '') - // ); - } - - logMigration(message: string, queryRunner?: QueryRunner) {} - logQueryError( - error: string | Error, - query: string, - parameters?: any[], - queryRunner?: QueryRunner, - ) {} - logQuerySlow(time: number, query: string, parameters?: any[], queryRunner?: QueryRunner) {} - logSchemaBuild(message: string, queryRunner?: QueryRunner) {} -} +import { DataSource } from "typeorm"; export const AppDataSource = new DataSource({ type: "mysql", @@ -51,7 +11,7 @@ export const AppDataSource = new DataSource({ password: process.env.DB_PASSWORD, connectorPackage: "mysql2", synchronize: false, - logging: ["query", "error"], + logging: true, entities: process.env.NODE_ENV !== "production" ? ["src/entities/**/*.ts"] @@ -61,5 +21,7 @@ export const AppDataSource = new DataSource({ ? ["src/migration/**/*.ts"] : ["dist/migration/**/*{.ts,.js}"], subscribers: [], - logger: new MyCustomLogger(), }); +// console.log(AppDataSource); + +// export default database; diff --git a/src/entities/ActualGoal.ts b/src/entities/ActualGoal.ts deleted file mode 100644 index 2fe2589..0000000 --- a/src/entities/ActualGoal.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; -import { PosLevel } from "./PosLevel"; -import { PosType } from "./PosType"; - -@Entity("actualGoal") -export class ActualGoal extends EntityBase { - @Column({ - nullable: true, - comment: "กลุ่มเป้าหมาย", - default: null, - }) - groupTarget: string; - - @Column({ - nullable: true, - comment: "กลุ่มเป้าหมายย่อย", - default: null, - }) - groupTargetSub: string; - - @Column({ - nullable: true, - comment: "ตำแหน่ง", - default: null, - }) - position: string; - - @Column({ - nullable: true, - comment: "ประเภทตำแหน่ง & กลุ่มงาน", - default: null, - }) - posTypeActual: string; - - // @Column({ - // nullable: true, - // comment: "ประเภทตำแหน่ง", - // default: null, - // }) - // posTypeActualId: string; - - // @ManyToOne(() => PosType, (posType: PosType) => posType.actualGoals) - // @JoinColumn({ name: "posTypeActualId" }) - // posTypeActual: PosType; - - @Column({ - nullable: true, - comment: "ระดับตำแหน่ง & ระดับชั้นงาน", - default: null, - }) - posLevelActual: string; - - // @Column({ - // nullable: true, - // comment: "ระดับตำแหน่ง", - // default: null, - // }) - // posLevelActualId: string; - - // @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.actualGoals) - // @JoinColumn({ name: "posLevelActualId" }) - // posLevelActual: PosLevel; - - @Column({ - nullable: true, - comment: "ประเภท(กลุ่มอาชีพ คุณสมบัติ)", - default: null, - }) - type: string; - - @Column({ - nullable: true, - comment: "จำนวน(คน)", - default: null, - }) - amount: number; - - @Column({ - nullable: true, - comment: "id โครงการ", - default: null, - }) - developmentActualGoalId: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentActualGoals) - @JoinColumn({ name: "developmentActualGoalId" }) - developmentActualGoal: Development; -} - -export class CreateActualGoal { - @Column() - groupTarget: string | null; - @Column() - groupTargetSub: string | null; - @Column() - position: string | null; - // @Column() - // posTypeActualId: string | null; - // @Column() - // posLevelActualId: string | null; - @Column() - posTypeActual: string | null; - @Column() - posLevelActual: string | null; - @Column() - type: string | null; - @Column() - amount: number | null; -} - -export type UpdateActualGoal = Partial; diff --git a/src/entities/ActualPeople.ts b/src/entities/ActualPeople.ts deleted file mode 100644 index 8050810..0000000 --- a/src/entities/ActualPeople.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; - -@Entity("actualPeople") -export class ActualPeople extends EntityBase { - @Column({ - nullable: true, - comment: "ผู้เกี่ยวข้อง", - default: null, - }) - groupTarget: string; - - @Column({ - nullable: true, - comment: "จำนวน(คน)", - default: null, - }) - amount: number; - - @Column({ - nullable: true, - comment: "id โครงการ", - default: null, - }) - developmentActualPeopleId: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentActualPeoples) - @JoinColumn({ name: "developmentActualPeopleId" }) - developmentActualPeople: Development; -} - -export class CreateActualPeople { - @Column() - groupTarget: string | null; - @Column() - amount: number | null; -} - -export type UpdateActualPeople = Partial; diff --git a/src/entities/Development.ts b/src/entities/Development.ts deleted file mode 100644 index 94f773b..0000000 --- a/src/entities/Development.ts +++ /dev/null @@ -1,949 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany, Double } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { ActualPeople, CreateActualPeople } from "./ActualPeople"; -import { CreatePlannedPeople, PlannedPeople } from "./PlannedPeople"; -import { ActualGoal, CreateActualGoal } from "./ActualGoal"; -import { CreatePlannedGoal, PlannedGoal } from "./PlannedGoal"; -import { DevelopmentHistory } from "./DevelopmentHistory"; -import { DevelopmentProjectType } from "./DevelopmentProjectType"; -import { DevelopmentProjectTechniquePlanned } from "./DevelopmentProjectTechniquePlanned"; -import { DevelopmentEvaluation } from "./DevelopmentEvaluation"; -import { CreateDevelopmentAddress, DevelopmentAddress } from "./DevelopmentAddress"; -import { DevelopmentProjectTechniqueActual } from "./DevelopmentProjectTechniqueActual"; -import { StrategyChild5 } from "./StrategyChild5"; -import { StrategyChild4 } from "./StrategyChild4"; -import { StrategyChild3 } from "./StrategyChild3"; -import { StrategyChild2 } from "./StrategyChild2"; -import { StrategyChild1 } from "./StrategyChild1"; -import { DevelopmentRisk } from "./DevelopmentRisk"; -import { DevelopmentOther } from "./DevelopmentOther"; - -@Entity("development") -export class Development extends EntityBase { - @Column({ - nullable: true, - comment: "id หน่วยงาน", - default: null, - }) - rootId: string; - - @Column({ - nullable: true, - comment: "id Dna หน่วยงาน", - default: null, - }) - rootDnaId: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน", - default: null, - }) - root: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน", - default: null, - }) - rootShortName: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน child1", - default: null, - }) - child1Id: string; - - @Column({ - nullable: true, - comment: "id Dna หน่วยงาน child1", - default: null, - }) - child1DnaId: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน child1", - default: null, - }) - child1: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน child1", - default: null, - }) - child1ShortName: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน child2", - default: null, - }) - child2Id: string; - - @Column({ - nullable: true, - comment: "id Dna หน่วยงาน child2", - default: null, - }) - child2DnaId: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน child2", - default: null, - }) - child2: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน child2", - default: null, - }) - child2ShortName: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน child3", - default: null, - }) - child3Id: string; - - @Column({ - nullable: true, - comment: "id Dna หน่วยงาน child3", - default: null, - }) - child3DnaId: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน child3", - default: null, - }) - child3: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน child3", - default: null, - }) - child3ShortName: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน child4", - default: null, - }) - child4Id: string; - - @Column({ - nullable: true, - comment: "id Dna หน่วยงาน child4", - default: null, - }) - child4DnaId: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน child4", - default: null, - }) - child4: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน child4", - default: null, - }) - child4ShortName: string; - - @Column({ - nullable: true, - comment: "id revision", - default: null, - }) - orgRevisionId: string; - - @Column({ - // กำลังดำเนินการ (ONGOING) - // เสร็จสิ้น (FINISH) - nullable: true, - comment: "สถานะ", - default: "ONGOING", - }) - status: string; - ////////////////////////////////////////tab ข้อมูลเบื้องต้น - @Column({ - nullable: true, - comment: "ปีงบประมาณ", - }) - year: number; - - @Column({ - comment: "ชื่อโครงการ/กิจกรรม/หลักสูตร", - length: 255, - }) - projectName: string; - - @Column({ - nullable: true, - comment: "หลักการและเหตุผล", - default: null, - type: "text", - }) - reason: string; - - @Column({ - nullable: true, - comment: "วัตถุประสงค์", - default: null, - type: "text", - }) - objective: string; - - ////////////////////////////////////////tab เป้าหมาย - @OneToMany( - () => ActualPeople, - (actualPeople: ActualPeople) => actualPeople.developmentActualPeople, - ) - developmentActualPeoples: ActualPeople[]; - - @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.developmentActualGoal) - developmentActualGoals: ActualGoal[]; - - @OneToMany( - () => PlannedPeople, - (plannedPeople: PlannedPeople) => plannedPeople.developmentPlannedPeople, - ) - developmentPlannedPeoples: PlannedPeople[]; - - @OneToMany(() => PlannedGoal, (plannedGoal: PlannedGoal) => plannedGoal.developmentPlannedGoal) - developmentPlannedGoals: PlannedGoal[]; - - @OneToMany( - () => DevelopmentRisk, - (developmentRisk: DevelopmentRisk) => developmentRisk.development, - ) - developmentRisks: DevelopmentRisk[]; - - @OneToMany( - () => DevelopmentOther, - (developmentOther: DevelopmentOther) => developmentOther.development, - ) - developmentOthers: DevelopmentOther[]; - - @OneToMany( - () => DevelopmentProjectType, - (developmentProjectType: DevelopmentProjectType) => developmentProjectType.development, - ) - developmentProjectTypes: DevelopmentProjectType[]; - - @Column({ - comment: "ไป-กลับ", - default: false, - }) - isBackPlanned: boolean; - - @Column({ - comment: "พักค้าง", - default: false, - }) - isHoldPlanned: boolean; - - @Column({ - nullable: true, - comment: "จำนวน(วัน)(ไป-กลับ)", - default: null, - }) - projectDayBackPlanned: number; - - @Column({ - nullable: true, - comment: "จำนวน(วัน)(พักค้าง)", - default: null, - }) - projectDayHoldPlanned: number; - - @Column({ - nullable: true, - comment: "จำนวน(คืน)(พักค้าง)", - default: null, - }) - projectNigthHoldPlanned: number; - - @Column({ - comment: "ไป-กลับ", - default: false, - }) - isBackActual: boolean; - - @Column({ - comment: "พักค้าง", - default: false, - }) - isHoldActual: boolean; - - @Column({ - nullable: true, - comment: "จำนวน(วัน)(ไป-กลับ)", - default: null, - }) - projectDayBackActual: number; - - @Column({ - nullable: true, - comment: "จำนวน(วัน)(พักค้าง)", - default: null, - }) - projectDayHoldActual: number; - - @Column({ - nullable: true, - comment: "จำนวน(คืน)(พักค้าง)", - default: null, - }) - projectNigthHoldActual: number; - - @Column({ - nullable: true, - comment: "รายละเอียดอื่นๆ 70 แผน", - default: null, - }) - reasonPlanned70: string; - - @Column({ - nullable: true, - comment: "รายละเอียดอื่นๆ 20 แผน", - default: null, - }) - reasonPlanned20: string; - - @Column({ - nullable: true, - comment: "รายละเอียดอื่นๆ 10 แผน", - default: null, - }) - reasonPlanned10: string; - - @Column({ - comment: "รายละเอียดอื่นๆ 70 แผน", - default: false, - }) - isReasonPlanned70: boolean; - - @Column({ - comment: "รายละเอียดอื่นๆ 20 แผน", - default: false, - }) - isReasonPlanned20: boolean; - - @Column({ - comment: "รายละเอียดอื่นๆ 10 แผน", - default: false, - }) - isReasonPlanned10: boolean; - - @OneToMany( - () => DevelopmentProjectTechniquePlanned, - (developmentProjectTechniquePlanned: DevelopmentProjectTechniquePlanned) => - developmentProjectTechniquePlanned.development, - ) - developmentProjectTechniquePlanneds: DevelopmentProjectTechniquePlanned[]; - - @Column({ - nullable: true, - comment: "รายละเอียดอื่นๆ 70 จริง", - default: null, - }) - reasonActual70: string; - - @Column({ - nullable: true, - comment: "รายละเอียดอื่นๆ 20 จริง", - default: null, - }) - reasonActual20: string; - - @Column({ - nullable: true, - comment: "รายละเอียดอื่นๆ 10 จริง", - default: null, - }) - reasonActual10: string; - - @Column({ - comment: "รายละเอียดอื่นๆ 70 จริง", - default: false, - }) - isReasonActual70: boolean; - - @Column({ - comment: "รายละเอียดอื่นๆ 20 จริง", - default: false, - }) - isReasonActual20: boolean; - - @Column({ - comment: "รายละเอียดอื่นๆ 10 จริง", - default: false, - }) - isReasonActual10: boolean; - - @OneToMany( - () => DevelopmentProjectTechniqueActual, - (developmentProjectTechniqueActual: DevelopmentProjectTechniqueActual) => - developmentProjectTechniqueActual.development, - ) - developmentProjectTechniqueActuals: DevelopmentProjectTechniqueActual[]; - - @Column({ - nullable: true, - comment: "จำนวน(รุ่น)ตามแผน", - default: null, - }) - projectModalPlanned: number; - - @Column({ - nullable: true, - comment: "จำนวน(รุ่น)ตามจริง", - default: null, - }) - projectModalActual: number; - - ////////////////////////////////////////tab ผลประเมิน - @OneToMany( - () => DevelopmentEvaluation, - (developmentEvaluation: DevelopmentEvaluation) => developmentEvaluation.development, - ) - developmentEvaluations: DevelopmentEvaluation[]; - - @Column({ - nullable: true, - comment: "ประเภทโครงการ", - default: null, - }) - project: string; - - @Column({ - comment: "ผ่านการพิจาณา ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ", - default: false, - }) - isPassAllocate: boolean; - - @Column({ - comment: - "ผ่านการพิจารณา ไม่ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ แต่ได้รับการจัดสรรเงินนอกงบประมาณ", - default: false, - }) - isPassNoAllocate: boolean; - - @Column({ - comment: "ไม่ผ่านการพิจารณา แต่ได้รับการจัดสรรเงินนอกงบประมาณ", - default: false, - }) - isNoPass: boolean; - - @Column({ - comment: "แต่ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ", - default: false, - }) - isBudget: boolean; - - @Column({ - comment: "แต่ได้รับการจัดสรรเงินนอกงบประมาณ", - default: false, - }) - isOutBudget: boolean; - - ////////////////////////////////////////tab อื่นๆ - @Column({ - nullable: true, - type: "datetime", - comment: "วันที่เริ่มต้น", - default: null, - }) - dateStart: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันที่สิ้นสุด", - default: null, - }) - dateEnd: Date; - - @Column({ - nullable: true, - comment: "รวมระยะเวลา (วัน)", - default: null, - }) - totalDate: number; - - @OneToMany( - () => DevelopmentAddress, - (developmentAddress: DevelopmentAddress) => developmentAddress.development, - ) - developmentAddresss: DevelopmentAddress[]; - - @Column({ - nullable: true, - comment: "ประเภทงบประมาณ", - default: null, - }) - budget: string; - - @Column({ - // เงินบำรุง = MAINTENANCE - // เงินกองทุน = FUND - // เงินอุดหนุน = SUBSIDY - nullable: true, - comment: "ประเภทย่อย", - default: null, - }) - budgetSub: string; - - @Column({ - nullable: true, - comment: "จํานวนงบประมาณที่ขอรับการจัดสรรฯ", - default: 0, - type: "double", - }) - accept: Double; - - @Column({ - nullable: true, - comment: "จํานวนงบประมาณที่ได้รับการจัดสรรฯ", - default: 0, - type: "double", - }) - receive: Double; - - @Column({ - nullable: true, - comment: "จํานวนงบประมาณที่ได้รับอนุมัติ", - default: 0, - type: "double", - }) - approved: Double; - - @Column({ - nullable: true, - comment: "จํานวนงบประมาณที่จ่ายจริง", - default: 0, - type: "double", - }) - budgetPay: Double; - - @Column({ - nullable: true, - comment: "ประเด็นความเสี่ยง", - default: null, - }) - issues: string; - - @Column({ - nullable: true, - comment: "โอกาสที่จะเกิด", - default: null, - }) - chance: number; - - @Column({ - nullable: true, - comment: "ผลกระทบจากการเกิด", - default: null, - }) - effects: number; - - @Column({ - nullable: true, - comment: "ระดับความเสี่ยง", - default: null, - }) - riskLevel: string; - - @Column({ - nullable: true, - comment: "เเนวทางการบริหารความเสี่ยง", - default: null, - }) - riskManagement: string; - - @Column({ - nullable: true, - comment: "ประโยชน์ที่คาดว่าจะได้รับ", - default: null, - }) - expect: string; - - @Column({ - nullable: true, - comment: "หัวข้อ/ประเด็นการฝึกอบรม ศึกษาดูงาน", - default: null, - }) - topicAcademic: string; - - @Column({ - nullable: true, - comment: "สถานที่ฝึกอบรม ศึกษาดูงาน", - default: null, - }) - addressAcademic: string; - - @Column({ - nullable: true, - comment: "จังหวัด(ข้อมูลวิชาการ)", - default: null, - }) - provinceActualId: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันเริ่มต้นการศึกษาดูงาน", - default: null, - }) - dateStudyStart: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันสิ้นสุดการศึกษาดูงาน", - default: null, - }) - dateStudyEnd: Date; - - @OneToMany( - () => DevelopmentHistory, - (developmentHistory: DevelopmentHistory) => developmentHistory.development, - ) - developmentHistorys: DevelopmentHistory[]; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามแผน", - default: null, - }) - strategyChild1PlannedId: string; - @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.developmentPlanneds) - @JoinColumn({ name: "strategyChild1PlannedId" }) - strategyChild1Planned: StrategyChild1; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามแผน", - default: null, - }) - strategyChild2PlannedId: string; - @ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.developmentPlanneds) - @JoinColumn({ name: "strategyChild2PlannedId" }) - strategyChild2Planned: StrategyChild2; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามแผน", - default: null, - }) - strategyChild3PlannedId: string; - @ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.developmentPlanneds) - @JoinColumn({ name: "strategyChild3PlannedId" }) - strategyChild3Planned: StrategyChild3; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามแผน", - default: null, - }) - strategyChild4PlannedId: string; - @ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.developmentPlanneds) - @JoinColumn({ name: "strategyChild4PlannedId" }) - strategyChild4Planned: StrategyChild4; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามแผน", - default: null, - }) - strategyChild5PlannedId: string; - @ManyToOne(() => StrategyChild5, (strategyChild5) => strategyChild5.developmentPlanneds) - @JoinColumn({ name: "strategyChild5PlannedId" }) - strategyChild5Planned: StrategyChild5; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามจริง", - default: null, - }) - strategyChild1ActualId: string; - @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.developmentActuals) - @JoinColumn({ name: "strategyChild1ActualId" }) - strategyChild1Actual: StrategyChild1; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามจริง", - default: null, - }) - strategyChild2ActualId: string; - @ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.developmentActuals) - @JoinColumn({ name: "strategyChild2ActualId" }) - strategyChild2Actual: StrategyChild2; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามจริง", - default: null, - }) - strategyChild3ActualId: string; - @ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.developmentActuals) - @JoinColumn({ name: "strategyChild3ActualId" }) - strategyChild3Actual: StrategyChild3; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามจริง", - default: null, - }) - strategyChild4ActualId: string; - @ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.developmentActuals) - @JoinColumn({ name: "strategyChild4ActualId" }) - strategyChild4Actual: StrategyChild4; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามจริง", - default: null, - }) - strategyChild5ActualId: string; - @ManyToOne(() => StrategyChild5, (strategyChild5) => strategyChild5.developmentActuals) - @JoinColumn({ name: "strategyChild5ActualId" }) - strategyChild5Actual: StrategyChild5; - - @Column({ - type: "longtext", - nullable: true, - comment: "การติดตามความก้าวหน้า", - default: null, - }) - progressTracking: string; - - @Column({ - type: "longtext", - nullable: true, - comment: "การประเมินผลโครงการ", - default: null, - }) - projectEvaluation: string; - - @Column({ - type: "longtext", - nullable: true, - comment: "ปัญหาอุปสรรค", - default: null, - }) - obstacle: string; - - @Column({ - type: "longtext", - nullable: true, - comment: "ข้อเสนอแนะ", - default: null, - }) - suggestion: string; -} -export class CreateDevelopment { - @Column() - year: number; - @Column() - projectName: string; - @Column() - node: number; - @Column() - nodeId: string; - @Column() - orgRevisionId: string; -} - -export class UpdateDevelopment1 { - @Column() - year: number; - @Column() - projectName: string; - @Column() - reason: string | null; - @Column() - objective: string | null; - @Column() - node: number; - @Column() - nodeId: string; - @Column() - orgRevisionId: string; -} -export class UpdateDevelopment2_1 { - @Column() - actualGoals: CreateActualGoal[]; - @Column() - plannedGoals: CreatePlannedGoal[]; -} -export class UpdateDevelopment2_2 { - @Column() - actualPeoples: CreateActualPeople[]; - @Column() - plannedPeoples: CreatePlannedPeople[]; -} -export class UpdateDevelopment3 { - //move from tab5 - @Column() - dateStart: Date | null; - @Column() - dateEnd: Date | null; - @Column() - totalDate: number | null; - @Column() - developmentAddresss: CreateDevelopmentAddress[]; - //end - @Column() - developmentProjectTypes?: string[]; - @Column() - projectModalActual?: number | null; - @Column() - projectModalPlanned?: number | null; - @Column() - isBackPlanned?: boolean | null; - @Column() - isHoldPlanned?: boolean | null; - @Column() - projectDayBackPlanned?: number | null; - @Column() - projectDayHoldPlanned?: number | null; - @Column() - projectNigthHoldPlanned?: number | null; - @Column() - developmentProjectTechniquePlanneds?: string[]; - @Column() - reasonPlanned70?: string; - @Column() - reasonPlanned20?: string; - @Column() - reasonPlanned10?: string; - @Column() - isReasonPlanned70?: string; - @Column() - isReasonPlanned20?: string; - @Column() - isReasonPlanned10?: string; - @Column() - isBackActual?: boolean | null; - @Column() - isHoldActual?: boolean | null; - @Column() - projectDayBackActual?: number | null; - @Column() - projectDayHoldActual?: number | null; - @Column() - projectNigthHoldActual?: number | null; - @Column() - developmentProjectTechniqueActuals?: string[]; - @Column() - reasonActual70?: string; - @Column() - reasonActual20?: string; - @Column() - reasonActual10?: string; - @Column() - isReasonActual70?: boolean; - @Column() - isReasonActual20?: boolean; - @Column() - isReasonActual10?: boolean; - @Column() - strategyChildPlannedId?: string | null; - @Column() - strategyChildPlannedNode?: number | null; - @Column() - strategyChildActualId?: string | null; - @Column() - strategyChildActualNode?: number | null; -} -export class UpdateDevelopment4 { - // @Column() - // developmentEvaluations: CreateDevelopmentEvaluation[]; - //new - @Column() - progressTracking: string | null; - @Column() - projectEvaluation: string | null; - //end -} -export class UpdateDevelopment5 { - //new - @Column() - obstacle: string | null; - @Column() - suggestion: string | null; - //end - //move from tab4 - @Column() - project: string | null; - @Column() - isPassAllocate: boolean; - @Column() - isPassNoAllocate: boolean; - @Column() - isNoPass: boolean; - @Column() - isBudget: boolean; - @Column() - isOutBudget: boolean; - //end -} - -export class UpdateDevelopment7 { - //move from tab5 - @Column() - budget: string | null; - @Column() - budgetSub: string | null; - @Column() - budgetPay: Double | null; - @Column() - accept: Double | null; - @Column() - receive: Double | null; - @Column() - approved: Double | null; - //end -} -export class UpdateDevelopment8_1 { - //move from tab5 - @Column() - issues: string | null; - @Column() - chance: number | null; - @Column() - effects: number | null; - @Column() - riskLevel: string | null; - @Column() - riskManagement: string | null; - //end -} - -export class UpdateDevelopment8 { - @Column() - expect: string | null; -} diff --git a/src/entities/DevelopmentAddress.ts b/src/entities/DevelopmentAddress.ts deleted file mode 100644 index 8de2fa8..0000000 --- a/src/entities/DevelopmentAddress.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; - -@Entity("developmentAddress") -export class DevelopmentAddress extends EntityBase { - @Column({ - nullable: true, - comment: "ที่อยู่", - default: null, - }) - address: string; - - @Column({ - nullable: true, - comment: "โครงการ/หลักสูตรการฝึกอบรม", - default: null, - }) - provinceId: string; - - @Column({ - nullable: true, - comment: "ชื่อจังหวัด (กรณีเลือกสถานที่ดำเนินการในประเทศ)", - default: null, - }) - provinceName: string; - - @Column({ - nullable: true, - comment: "โครงการ/หลักสูตรการฝึกอบรม", - default: null, - }) - developmentId: string; - - @Column({ - nullable: true, - comment: "สถานที่ดำเนินการ ในประเทศ(IN_COUNTRY) หรือ ต่างประเทศ(ABROAD)", - default: null, - }) - addressType: string; - - @Column({ - nullable: true, - comment: "ชื่อประเทศ (กรณีเลือกสถานที่ดำเนินการต่างประเทศ)", - default: null, - }) - country: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentAddresss) - @JoinColumn({ name: "developmentId" }) - development: Development; -} -export class CreateDevelopmentAddress { - @Column() - address: string | null; - - @Column() - provinceId: string | null; - - @Column() - addressType?: string | null; - - @Column() - provinceName?: string | null; - - @Column() - country?: string | null; -} diff --git a/src/entities/DevelopmentEvaluation.ts b/src/entities/DevelopmentEvaluation.ts deleted file mode 100644 index 6dff8d6..0000000 --- a/src/entities/DevelopmentEvaluation.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; - -@Entity("developmentEvaluation") -export class DevelopmentEvaluation extends EntityBase { - @Column({ - nullable: true, - comment: "ตัวชี้วัด", - default: null, - }) - indicators: string; - - @Column({ - nullable: true, - comment: "เป้าหมาย", - default: null, - }) - target: number; - - @Column({ - nullable: true, - comment: "ประเภทตัวชี้วัด", - default: null, - }) - metricType: string; - - @Column({ - nullable: true, - comment: "วิธีการคำนวณ/เครื่องมือ", - default: null, - }) - calculation: string; - - @Column({ - nullable: true, - comment: "ระยะเวลาวัดผล", - default: null, - }) - measuRement: string; - - @Column({ - nullable: true, - comment: "ผลการดำเนิน", - default: null, - }) - results: string; - - @Column({ - nullable: true, - comment: "ปัญหาอุปสรรค", - default: null, - }) - obstacles: string; - - @Column({ - nullable: true, - comment: "ข้อเสนอเเนะ", - default: null, - }) - suggestions: string; - @Column({ - nullable: true, - comment: "โครงการ/หลักสูตรการฝึกอบรม", - default: null, - }) - developmentId: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentEvaluations) - @JoinColumn({ name: "developmentId" }) - development: Development; -} -export class CreateDevelopmentEvaluation { - @Column() - indicators: string | null; - @Column() - target: number | null; - @Column() - metricType: string | null; - @Column() - calculation: string | null; - @Column() - measuRement: string | null; - @Column() - results?: string | null; - @Column() - obstacles: string | null; - @Column() - suggestions: string | null; -} diff --git a/src/entities/DevelopmentHistory.ts b/src/entities/DevelopmentHistory.ts deleted file mode 100644 index eeb61a1..0000000 --- a/src/entities/DevelopmentHistory.ts +++ /dev/null @@ -1,328 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { PosLevel } from "./PosLevel"; -import { PosType } from "./PosType"; -import { Development } from "./Development"; -import { EmployeePosType } from "./EmployeePosType"; -import { EmployeePosLevel } from "./EmployeePosLevel"; - -@Entity("developmentHistory") -export class DevelopmentHistory extends EntityBase { - @Column({ - nullable: true, - comment: "id หน่วยงาน", - default: null, - }) - rootId: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน", - default: null, - }) - root: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงานที่สังกัด", - default: null, - }) - org: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน", - default: null, - }) - orgRootShortName: string; - - @Column({ - nullable: true, - comment: "id revision", - default: null, - }) - orgRevisionId: string; - - @Column({ - nullable: true, - comment: "id profile", - length: 40, - default: null, - }) - profileId: string; - - @Column({ - nullable: true, - comment: "ประเภทราชการ", - length: 40, - default: null, - }) - type: string; - - @Column({ - nullable: true, - comment: "ยศ", - length: 40, - default: null, - }) - rank: string; - - @Column({ - nullable: true, - comment: "คำนำหน้าชื่อ", - length: 40, - default: null, - }) - prefix: string; - - @Column({ - nullable: true, - comment: "ชื่อ", - length: 255, - default: null, - }) - firstName: string; - - @Column({ - nullable: true, - comment: "นามสกุล", - length: 255, - default: null, - }) - lastName: string; - - @Column({ - nullable: true, - comment: "เลขประจำตัวประชาชน", - default: null, - length: 13, - }) - citizenId: string; - - @Column({ - nullable: true, - comment: "ตำแหน่ง", - default: null, - length: 255, - }) - position: string; - - @Column({ - nullable: true, - comment: "ชื่อตำแหน่งทางการบริหาร", - length: 255, - default: null, - }) - posExecutive: string; - - @Column({ - nullable: true, - length: 40, - comment: "ไอดีระดับตำแหน่ง", - }) - posLevelId: string | null; - - @ManyToOne(() => PosLevel, (posLevel) => posLevel.developmentHistorys) - @JoinColumn({ name: "posLevelId" }) - posLevel: PosLevel; - - @Column({ - nullable: true, - length: 40, - comment: "ไอดีประเภทตำแหน่ง", - }) - posTypeId: string | null; - - @ManyToOne(() => PosType, (posType) => posType.developmentHistorys) - @JoinColumn({ name: "posTypeId" }) - posType: PosType; - - @Column({ - nullable: true, - length: 40, - comment: "ไอดีระดับตำแหน่ง", - }) - employeePosLevelId: string | null; - - @ManyToOne(() => EmployeePosLevel, (employeePosLevel) => employeePosLevel.developmentHistorys) - @JoinColumn({ name: "employeePosLevelId" }) - employeePosLevel: EmployeePosLevel; - - @Column({ - nullable: true, - length: 40, - comment: "ไอดีประเภทตำแหน่ง", - }) - employeePosTypeId: string | null; - - @ManyToOne(() => EmployeePosType, (employeePosType) => employeePosType.developmentHistorys) - @JoinColumn({ name: "employeePosTypeId" }) - employeePosType: EmployeePosType; - - @Column({ - nullable: true, - comment: "โครงการ/หลักสูตรการฝึกอบรม", - default: null, - }) - developmentId: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentHistorys) - @JoinColumn({ name: "developmentId" }) - development: Development; - - @Column({ - nullable: true, - comment: "จำนวนวันที่อบรม", - default: null, - length: 255, - }) - trainingDays: string; - - @Column({ - nullable: true, - comment: "เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ", - default: null, - length: 255, - }) - order: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันที่เริ่มต้น", - default: null, - }) - dateStart: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันที่สิ้นสุด", - default: null, - }) - dateEnd: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่", - default: null, - }) - dateOrder: Date; - - @Column({ - comment: "บันทึกลงทะเบียนประวัติ", - default: false, - }) - isDone: boolean; - - @Column({ - comment: "บันทึก IDP ที่ทะเบียนประวัติ", - default: false, - }) - isDoneIDP: boolean; - - @Column({ - comment: "มีข้อมูลอยู่ในทะเบียนประวัติ", - default: false, - }) - isProfile: boolean; -} -export class CreateDevelopmentHistory { - @Column() - rank: string | null; - @Column() - prefix: string | null; - @Column() - firstName: string | null; - @Column() - lastName: string | null; - @Column() - citizenId: string; - @Column() - position: string | null; - @Column() - posExecutive: string | null; - @Column() - posLevelId: string | null; - @Column() - posTypeId: string | null; - @Column() - developmentId: string; - @Column() - order: string | null; - @Column() - dateOrder: Date | null; - @Column() - dateStart: Date | null; - @Column() - dateEnd: Date | null; -} - -export class UpdateDevelopmentHistory { - @Column() - rank: string | null; - @Column() - prefix: string | null; - @Column() - firstName: string | null; - @Column() - lastName: string | null; - @Column() - citizenId: string; - @Column() - position: string | null; - @Column() - posExecutive: string | null; - @Column() - posLevelId: string | null; - @Column() - posTypeId: string | null; - @Column() - developmentId: string; - @Column() - order: string | null; - @Column() - dateOrder: Date | null; - @Column() - dateStart: Date | null; - @Column() - dateEnd: Date | null; -} - -export class CreateDevelopmentHistoryOBO { - // @Column() - // rank: string | null; - @Column() - prefix: string | null; - @Column() - firstName: string | null; - @Column() - lastName: string | null; - @Column() - citizenId: string; - @Column() - position: string | null; - @Column() - posExecutive?: string | null; - @Column() - posLevelId?: string | null; - @Column() - posTypeId?: string | null; - // @Column() - // developmentId: string; - @Column() - commandNumber: string | null; - @Column() - commandDate: Date | null; - @Column() - trainingDays: string | null; - @Column() - org: string | null; - @Column() - type: string | null; - @Column() - dateStart: Date | null; - @Column() - dateEnd: Date | null; -} diff --git a/src/entities/DevelopmentOther.ts b/src/entities/DevelopmentOther.ts deleted file mode 100644 index 98e145a..0000000 --- a/src/entities/DevelopmentOther.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; - -@Entity("developmentOther") -export class DevelopmentOther extends EntityBase { - @Column({ - nullable: true, - comment: "หัวข้อ/ประเด็นการฝึกอบรม ศึกษาดูงาน", - default: null, - }) - topicAcademic: string; - - @Column({ - nullable: true, - comment: "สถานที่ฝึกอบรม ศึกษาดูงาน", - default: null, - }) - addressAcademic: string; - - @Column({ - nullable: true, - comment: "จังหวัด(ข้อมูลวิชาการ)", - default: null, - }) - provinceActualId: string; - - @Column({ - nullable: true, - comment: "จังหวัด(ข้อมูลวิชาการ)", - default: null, - }) - provinceActualName: string; - - @Column({ - nullable: true, - comment: "คีย์นอก(FK)ของตาราง development", - default: null, - }) - developmentId: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentOthers) - @JoinColumn({ name: "developmentId" }) - development: Development; -} - -export class UpdateDevelopmentOther { - @Column() - topicAcademic: string | null; - @Column() - addressAcademic: string | null; - @Column() - provinceActualId: string | null; -} diff --git a/src/entities/DevelopmentProjectTechniqueActual.ts b/src/entities/DevelopmentProjectTechniqueActual.ts deleted file mode 100644 index 0fa3b08..0000000 --- a/src/entities/DevelopmentProjectTechniqueActual.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; - -@Entity("developmentProjectTechniqueActual") -export class DevelopmentProjectTechniqueActual extends EntityBase { - @Column({ - // TRAINING = การอบรม - // MEETING = การประชุม - // SEMINAR = การสัมมนา - // STUDY_TOUR = การศึกษาดูงาน - // ACADEMIC_SEMINAR = การสัมมนาทางวิชาการ - // WORKSHOP = การสัมมนาเชิงปฏิบัติการ - // SPECIAL_LECTURE = การบรรยายพิเศษ - // LECTURE = การบรรยาย - // STUDY_TRAINING = การฝึกศึกษา - // OTHER = อื่น - nullable: true, - comment: "เทคนิควิธีการที่ใช้ในการพัฒนา", - default: null, - }) - name: string; - - @Column({ - nullable: true, - comment: "โครงการ/หลักสูตรการฝึกอบรม", - default: null, - }) - developmentId: string; - - @ManyToOne( - () => Development, - (development: Development) => development.developmentProjectTechniqueActuals, - ) - @JoinColumn({ name: "developmentId" }) - development: Development; -} -export class CreateDevelopmentProjectTechniqueActual { - @Column() - name: string; -} diff --git a/src/entities/DevelopmentProjectTechniquePlanned.ts b/src/entities/DevelopmentProjectTechniquePlanned.ts deleted file mode 100644 index 7ba3c7c..0000000 --- a/src/entities/DevelopmentProjectTechniquePlanned.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; - -@Entity("developmentProjectTechniquePlanned") -export class DevelopmentProjectTechniquePlanned extends EntityBase { - @Column({ - // TRAINING = การอบรม - // MEETING = การประชุม - // SEMINAR = การสัมมนา - // STUDY_TOUR = การศึกษาดูงาน - // ACADEMIC_SEMINAR = การสัมมนาทางวิชาการ - // WORKSHOP = การสัมมนาเชิงปฏิบัติการ - // SPECIAL_LECTURE = การบรรยายพิเศษ - // LECTURE = การบรรยาย - // STUDY_TRAINING = การฝึกศึกษา - // OTHER = อื่น - nullable: true, - comment: "เทคนิควิธีการที่ใช้ในการพัฒนา", - default: null, - }) - name: string; - - @Column({ - nullable: true, - comment: "โครงการ/หลักสูตรการฝึกอบรม", - default: null, - }) - developmentId: string; - - @ManyToOne( - () => Development, - (development: Development) => development.developmentProjectTechniquePlanneds, - ) - @JoinColumn({ name: "developmentId" }) - development: Development; -} -export class CreateDevelopmentProjectTechniquePlanned { - @Column() - name: string; -} diff --git a/src/entities/DevelopmentProjectType.ts b/src/entities/DevelopmentProjectType.ts deleted file mode 100644 index 447dbbd..0000000 --- a/src/entities/DevelopmentProjectType.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; - -@Entity("developmentProjectType") -export class DevelopmentProjectType extends EntityBase { - @Column({ - // STRATEGIC_PROJECT = โครงการตามยุทธศาสตร์ - // MISSION_PROJECT = โครงการตามภารกิจประจำของหน่วยงาน - // NEW_PROJECT = โครงการใหม่ - // ONGOING_PROJECT = โครงการต่อเนื่อง - nullable: true, - comment: "ประเภทโครงการ", - default: null, - }) - name: string; - - @Column({ - nullable: true, - comment: "โครงการ/หลักสูตรการฝึกอบรม", - default: null, - }) - developmentId: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentProjectTypes) - @JoinColumn({ name: "developmentId" }) - development: Development; -} -export class CreateDevelopmentProjectType { - @Column() - name: string; -} diff --git a/src/entities/DevelopmentRisk.ts b/src/entities/DevelopmentRisk.ts deleted file mode 100644 index b146cba..0000000 --- a/src/entities/DevelopmentRisk.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; - -@Entity("developmentRisk") -export class DevelopmentRisk extends EntityBase { - @Column({ - nullable: true, - comment: "ประเด็นความเสี่ยง", - default: null, - }) - issues: string; - - @Column({ - nullable: true, - comment: "โอกาสที่จะเกิด", - default: null, - }) - chance: number; - - @Column({ - nullable: true, - comment: "ผลกระทบจากการเกิด", - default: null, - }) - effects: number; - - @Column({ - nullable: true, - comment: "ระดับความเสี่ยง", - default: null, - }) - riskLevel: string; - - @Column({ - nullable: true, - comment: "เเนวทางการบริหารความเสี่ยง", - default: null, - }) - riskManagement: string; - - @Column({ - nullable: true, - comment: "คีย์นอก(FK)ของตาราง development", - default: null, - }) - developmentId: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentRisks) - @JoinColumn({ name: "developmentId" }) - development: Development; -} - -export class UpdateDevelopmentRisk { - @Column() - issues: string | null; - @Column() - chance: number | null; - @Column() - effects: number | null; - @Column() - riskLevel: string | null; - @Column() - riskManagement: string | null; -} diff --git a/src/entities/DevelopmentScholarship.ts b/src/entities/DevelopmentScholarship.ts deleted file mode 100644 index 24745ae..0000000 --- a/src/entities/DevelopmentScholarship.ts +++ /dev/null @@ -1,737 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, Double } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { PosLevel } from "./PosLevel"; -import { PosType } from "./PosType"; - -@Entity("developmentScholarship") -export class DevelopmentScholarship extends EntityBase { - @Column({ - nullable: true, - comment: "id dna หน่วยงาน", - default: null, - }) - rootDnaId: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน", - default: null, - }) - rootId: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน", - default: null, - }) - root: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงานที่สังกัด", - default: null, - }) - org: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน", - default: null, - }) - orgRootShortName: string; - - @Column({ - nullable: true, - comment: "id revision", - default: null, - }) - orgRevisionId: string; - - @Column({ - nullable: true, - comment: "id profile", - length: 40, - default: null, - }) - profileId: string; - - @Column({ - // PENDING = ค่าเริ่มต้น - // GRADUATE = สำเร็จการศึกษา - // NOTGRADUATE = ไม่จบการศึกษา - nullable: true, - comment: "สถานะ", - length: 40, - default: "PENDING", - }) - status: string; - - @Column({ - nullable: true, - comment: "ยศ", - length: 40, - default: null, - }) - rank: string; - - @Column({ - nullable: true, - comment: "คำนำหน้าชื่อ", - length: 40, - default: null, - }) - prefix: string; - - @Column({ - nullable: true, - comment: "ชื่อ", - length: 255, - default: null, - }) - firstName: string; - - @Column({ - nullable: true, - comment: "นามสกุล", - length: 255, - default: null, - }) - lastName: string; - - @Column({ - nullable: true, - comment: "เลขประจำตัวประชาชน", - default: null, - length: 13, - }) - citizenId: string; - - @Column({ - nullable: true, - comment: "ตำแหน่ง", - default: null, - length: 255, - }) - position: string; - - @Column({ - nullable: true, - comment: "ชื่อตำแหน่งทางการบริหาร", - length: 255, - default: null, - }) - posExecutive: string; - - @Column({ - nullable: true, - length: 40, - comment: "ไอดีระดับตำแหน่ง", - }) - posLevelId: string | null; - - @ManyToOne(() => PosLevel, (posLevel) => posLevel.developmentScholars) - @JoinColumn({ name: "posLevelId" }) - posLevel: PosLevel; - - @Column({ - nullable: true, - length: 40, - comment: "ไอดีประเภทตำแหน่ง", - }) - posTypeId: string | null; - - @ManyToOne(() => PosType, (posType) => posType.developmentScholars) - @JoinColumn({ name: "posTypeId" }) - posType: PosType; - - @Column({ - nullable: true, - comment: "id Dna หน่วยงาน", - default: null, - }) - guarantorRootDnaId: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน", - default: null, - }) - guarantorRootId: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน", - default: null, - }) - guarantorRoot: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงานที่สังกัด", - default: null, - }) - guarantorOrg: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน", - default: null, - }) - guarantorOrgRootShortName: string; - - @Column({ - nullable: true, - comment: "id revision", - default: null, - }) - guarantorOrgRevisionId: string; - - @Column({ - nullable: true, - comment: "ยศ(ผู้ค้ำ)", - length: 40, - default: null, - }) - guarantorRank: string; - - @Column({ - nullable: true, - comment: "คำนำหน้าชื่อ(ผู้ค้ำ)", - length: 40, - default: null, - }) - guarantorPrefix: string; - - @Column({ - nullable: true, - comment: "ชื่อ(ผู้ค้ำ)", - length: 255, - default: null, - }) - guarantorFirstName: string; - - @Column({ - nullable: true, - comment: "นามสกุล(ผู้ค้ำ)", - length: 255, - default: null, - }) - guarantorLastName: string; - - @Column({ - nullable: true, - comment: "เลขประจำตัวประชาชน(ผู้ค้ำ)", - default: null, - length: 13, - }) - guarantorCitizenId: string; - - @Column({ - nullable: true, - comment: "ตำแหน่ง(ผู้ค้ำ)", - default: null, - length: 255, - }) - guarantorPosition: string; - - @Column({ - nullable: true, - comment: "ชื่อตำแหน่งทางการบริหาร(ผู้ค้ำ)", - length: 255, - default: null, - }) - guarantorPosExecutive: string; - - @Column({ - nullable: true, - length: 40, - comment: "ไอดีระดับตำแหน่ง(ผู้ค้ำ)", - }) - posLevelguarantorId: string | null; - - @ManyToOne(() => PosLevel, (posLevel) => posLevel.developmentScholarGuarantors) - @JoinColumn({ name: "posLevelguarantorId" }) - posLevelguarantor: PosLevel; - - @Column({ - nullable: true, - length: 40, - comment: "ไอดีประเภทตำแหน่ง(ผู้ค้ำ)", - }) - posTypeguarantorId: string | null; - - @ManyToOne(() => PosType, (posType) => posType.developmentScholarGuarantors) - @JoinColumn({ name: "posTypeguarantorId" }) - posTypeguarantor: PosType; - - @Column({ - nullable: true, - comment: "ปีงบประมาณที่ได้รับทุน", - }) - scholarshipYear: number; - - @Column({ - //แหล่งงบประมาณกทม = BKK , แหล่งงบประมาณอื่นๆ = OTHER - nullable: true, - comment: "แหล่งงบประมาณ", - length: 10, - default: null, - }) - budgetSource: string; - - @Column({ - comment: "งบประมาณที่ได้รับอนุมัติตลอดหลักสูตร", - default: 0, - nullable: true, - type: "double", - }) - budgetApprove: Double; - - @Column({ - nullable: true, - comment: "เลขที่หนังสืออนุมัติ", - length: 40, - default: null, - }) - bookNo: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "ลงวันที่(หนังสือ)", - default: null, - }) - bookNoDate: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "หนังสืออนุมัติเมื่อวันที่", - default: null, - }) - bookApproveDate: Date; - - @Column({ - comment: "ใช้เวลาราชการ", - default: false, - }) - useOfficialTime: string; - - @Column({ - nullable: true, - comment: "เปลี่ยนแปลงรายละเอียด", - type: "text", - default: null, - }) - changeDetail: string; - - @Column({ - //การศึกษาในประเทศ = DOMESTICE - //ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ) = NOABROAD - //ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ) = ABROAD - //ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร) = EXECUTIVE - nullable: true, - comment: "เลือกประเภททุน", - length: 40, - default: null, - }) - scholarshipType: string; - - @Column({ - //ทุน 1 (ก)(ข)(ค) = FUND1 , ทุน 2 (ก)(ข) = FUND2 - nullable: true, - comment: "ประเภททุน", - length: 40, - default: null, - }) - fundType: string; - - @Column({ - nullable: true, - comment: "เลขที่สัญญา", - length: 40, - default: null, - }) - contractNo: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "ลงวันที่(เลขที่สัญญา)", - default: null, - }) - contractDate: Date; - - @Column({ - nullable: true, - comment: "เลขที่หนังสือรายงานตัวกลับ", - length: 40, - default: null, - }) - reportBackNo: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)", - default: null, - }) - reportBackNoDate: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "รายงานตัวกลับวันที่", - default: null, - }) - reportBackDate: Date; - - @Column({ - nullable: true, - comment: "ระดับปริญญา", - length: 255, - default: null, - }) - degreeLevel: string; - - @Column({ - nullable: true, - comment: "หลักสูตรการศึกษา/หลักสูตรการฝึกอบรม", - length: 255, - default: null, - }) - course: string; - - @Column({ - nullable: true, - comment: "สาขาวิชา/สาขา", - length: 255, - default: null, - }) - field: string; - - @Column({ - nullable: true, - comment: "คณะ", - length: 255, - default: null, - }) - faculty: string; - - @Column({ - nullable: true, - comment: "สถาบันการศึกษา/สถาบันการศึกษา_หน่วยงานผู้จัดการฝึกอบรม/สถานที่ไปศึกษาดูงานในประเทศ", - length: 255, - default: null, - }) - educationalInstitution: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันเริ่มต้นการศึกษา/วันเริ่มต้นการฝึกอบรม/วันเริ่มต้นการศึกษาดูงานในประเทศ", - default: null, - }) - startDate: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันสิ้นสุดการศึกษา/วันสิ้นสุดการฝึกอบรม/วันสิ้นสุดการศึกษาดูงานในประเทศ", - default: null, - }) - endDate: Date; - - @Column({ - nullable: true, - comment: "สถานที่ไปศึกษาดูงาน", - length: 255, - default: null, - }) - studyPlace: string; - - @Column({ - nullable: true, - comment: "หัวข้อการไปศึกษาดูงาน/หัวข้อการไปศึกษาดูงานในประเทศ", - length: 255, - default: null, - }) - studyTopic: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันเริ่มต้นการศึกษาดูงาน", - default: null, - }) - studyStartDate: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันสิ้นสุดการศึกษาดูงาน", - default: null, - }) - studyEndDate: Date; - - @Column({ - nullable: true, - comment: "ประเทศที่เดินทางไปศึกษาดูงาน", - length: 255, - default: null, - }) - studyCountry: string; - - @Column({ - nullable: true, - comment: "หัวข้อการไปศึกษาดูงานต่างประเทศ", - length: 255, - default: null, - }) - studyAbroadTopic: string; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันเริ่มต้นการศึกษาดูงานต่างประเทศ", - default: null, - }) - studyAbroadStartDate: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันสิ้นสุดการศึกษาดูงานต่างประเทศ", - default: null, - }) - studyAbroadEndDate: Date; - - @Column({ - nullable: true, - comment: "รวมระยะเวลาในการศึกษา/รวมระยะเวลาในการฝึกอบรม", - length: 40, - default: null, - }) - totalPeriod: string; - - @Column({ - // ในแผนฯ (INPLAN) - // นอกแผนฯ (OUTPLAN) - nullable: true, - comment: "ในแผนฯ", - length: 40, - default: null, - }) - planType: string; - - @Column({ - comment: "ไม่ใช้งบประมาณ", - default: false, - }) - isNoUseBudget: boolean; - - @Column({ - nullable: true, - comment: "เลขที่หนังสือรายงานตัวกลับเข้าปฏิบัติราชการ", - default: null, - }) - bookNumber: string; - - @Column({ - nullable: true, - type: "datetime", - comment: " หนังสือรายงานตัวกลับเข้าปฏิบัติราชการลงวันที่", - default: null, - }) - bookDate: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันที่กลับเข้าปฏิบัติราชการ", - default: null, - }) - governmentDate: Date; - - @Column({ - nullable: true, - type: "datetime", - comment: "วันสิ้นสุดภาระผูกพัน", - default: null, - }) - governmentEndDate: Date; - - @Column({ - comment: "สำเร็จการศึกษาตามที่หลักสูตรกำหนด", - default: false, - }) - isGraduated: boolean; - - @Column({ - nullable: true, - type: "datetime", - comment: "ตั้งแต่", - default: null, - }) - graduatedDate: Date; - - @Column({ - nullable: true, - comment: "เนื่องจาก", - default: null, - }) - graduatedReason: string; - - @Column({ - nullable: true, - comment: "เงินอื่นๆ", - default: null, - }) - budgetSourceOther: string; -} -export class CreateDevelopmentScholarship { - rootDnaId?: string | null; - rootId: string | null; - root: string | null; - org: string | null; - orgRootShortName: string | null; - orgRevisionId: string | null; - profileId: string | null; - rank?: string | null; - prefix: string | null; - firstName: string | null; - lastName: string | null; - citizenId: string | null; - position: string | null; - posExecutive: string | null; - posLevelId: string | null; - posTypeId: string | null; - guarantorRootDnaId?: string | null; - guarantorRootId: string | null; - guarantorRoot: string | null; - guarantorOrg: string | null; - guarantorOrgRootShortName: string | null; - guarantorOrgRevisionId: string | null; - guarantorRank?: string | null; - guarantorPrefix: string | null; - guarantorFirstName: string | null; - guarantorLastName: string | null; - guarantorCitizenId: string | null; - guarantorPosition: string | null; - guarantorPosExecutive: string | null; - posLevelguarantorId: string | null; - posTypeguarantorId: string | null; - scholarshipYear: number | null; - budgetSource: string | null; - budgetApprove: Double | null; - bookNo: string | null; - bookNoDate: Date | null; - bookApproveDate: Date | null; - useOfficialTime: string | null; - changeDetail: string | null; - scholarshipType: string | null; - fundType: string | null; - contractNo: string | null; - contractDate: Date | null; - reportBackNo: string | null; - reportBackNoDate: Date | null; - reportBackDate: Date | null; - degreeLevel: string | null; - course: string | null; - field: string | null; - faculty: string | null; - educationalInstitution: string | null; - startDate: Date | null; - endDate: Date | null; - studyPlace: string | null; - studyTopic: string | null; - studyStartDate: Date | null; - studyEndDate: Date | null; - studyCountry: string | null; - studyAbroadTopic: string | null; - studyAbroadStartDate: Date | null; - studyAbroadEndDate: Date | null; - totalPeriod: string | null; - planType: string | null; - isNoUseBudget: boolean | null; - budgetSourceOther?: string | null; -} - -export class UpdateDevelopmentScholarship { - rootDnaId?: string | null; - rootId: string | null; - root: string | null; - org: string | null; - orgRootShortName: string | null; - orgRevisionId: string | null; - profileId: string | null; - rank?: string | null; - prefix: string | null; - firstName: string | null; - lastName: string | null; - citizenId: string | null; - position: string | null; - posExecutive: string | null; - posLevelId: string | null; - posTypeId: string | null; - guarantorRootDnaId?: string | null; - guarantorRootId?: string | null; - guarantorRoot?: string | null; - guarantorOrg?: string | null; - guarantorOrgRootShortName?: string | null; - guarantorOrgRevisionId?: string | null; - guarantorRank?: string | null; - guarantorPrefix: string | null; - guarantorFirstName: string | null; - guarantorLastName: string | null; - guarantorCitizenId: string | null; - guarantorPosition: string | null; - guarantorPosExecutive: string | null; - posLevelguarantorId: string | null; - posTypeguarantorId: string | null; - scholarshipYear: number | null; - budgetSource: string | null; - budgetApprove: Double | null; - bookNo: string | null; - bookNoDate: Date | null; - bookApproveDate: Date | null; - useOfficialTime: string | null; - changeDetail: string | null; - scholarshipType: string | null; - fundType: string | null; - contractNo: string | null; - contractDate: Date | null; - reportBackNo: string | null; - reportBackNoDate: Date | null; - reportBackDate: Date | null; - degreeLevel: string | null; - course: string | null; - field: string | null; - faculty: string | null; - educationalInstitution: string | null; - startDate: Date | null; - endDate: Date | null; - studyPlace: string | null; - studyTopic: string | null; - studyStartDate: Date | null; - studyEndDate: Date | null; - studyCountry: string | null; - studyAbroadTopic: string | null; - studyAbroadStartDate: Date | null; - studyAbroadEndDate: Date | null; - totalPeriod: string | null; - planType: string | null; - isNoUseBudget: boolean | null; - budgetSourceOther?: string | null; -} - -export class UpdateDevelopmentScholarshipUser { - bookNumber: string | null; - bookDate: Date | null; - governmentDate: Date | null; - governmentEndDate: Date | null; - isGraduated: boolean | null; - graduatedDate: Date | null; - graduatedReason: string | null; - budgetSourceOther?: string | null; -} diff --git a/src/entities/EmployeePosLevel.ts b/src/entities/EmployeePosLevel.ts deleted file mode 100644 index e84960f..0000000 --- a/src/entities/EmployeePosLevel.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { EmployeePosType } from "./EmployeePosType"; -import { DevelopmentHistory } from "./DevelopmentHistory"; - -enum EmployeePosLevelAuthoritys { - HEAD = "HEAD", - DEPUTY = "DEPUTY", - GOVERNOR = "GOVERNOR", -} -@Entity("employeePosLevel") -export class EmployeePosLevel extends EntityBase { - @Column({ - comment: "ชื่อระดับชั้นงาน", - type: "int", - }) - posLevelName: number; - - @Column({ - comment: "ระดับของระดับชั้นงาน", - type: "int", - }) - posLevelRank: number; - - @Column({ - nullable: true, - comment: - "ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ", - type: "enum", - enum: EmployeePosLevelAuthoritys, - default: null, - }) - posLevelAuthority: EmployeePosLevelAuthoritys; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง employeePosType", - }) - posTypeId: string; - - @ManyToOne(() => EmployeePosType, (posType: EmployeePosType) => posType.posLevels) - @JoinColumn({ name: "posTypeId" }) - posType: EmployeePosType; - - @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.employeePosLevel) - developmentHistorys: DevelopmentHistory[]; -} - -export class CreateEmployeePosLevel { - @Column() - posLevelName: number; - - @Column() - posLevelRank: number; - - @Column() - posLevelAuthority: string; - - @Column("uuid") - posTypeId: string; -} - -export type UpdateEmployeePosLevel = Partial & { - posLevelAuthority: EmployeePosLevelAuthoritys; -}; diff --git a/src/entities/EmployeePosType.ts b/src/entities/EmployeePosType.ts deleted file mode 100644 index cafb49d..0000000 --- a/src/entities/EmployeePosType.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Entity, Column, OneToMany } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { EmployeePosLevel } from "./EmployeePosLevel"; -import { DevelopmentHistory } from "./DevelopmentHistory"; - -@Entity("employeePosType") -export class EmployeePosType extends EntityBase { - @Column({ - nullable: true, - comment: "ชื่อกลุ่มงาน", - length: 255, - default: null, - }) - posTypeName: string; - - @Column({ - comment: "ระดับของกลุ่มงาน", - }) - posTypeRank: number; - - @Column({ - nullable: true, - comment: "ชื่อย่อกลุ่มงาน", - length: 255, - default: null, - }) - posTypeShortName: string; - - @OneToMany(() => EmployeePosLevel, (posLevel: EmployeePosLevel) => posLevel.posType) - posLevels: EmployeePosLevel[]; - - @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.employeePosType) - developmentHistorys: DevelopmentHistory[]; -} - -export class CreateEmployeePosType { - @Column() - posTypeName: string; - - @Column() - posTypeRank: number; - - @Column() - posTypeShortName: string; -} - -export type UpdateEmployeePosType = Partial; diff --git a/src/entities/PlannedGoal.ts b/src/entities/PlannedGoal.ts deleted file mode 100644 index 4e070fb..0000000 --- a/src/entities/PlannedGoal.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; -import { CreatePlannedGoalPosition, PlannedGoalPosition } from "./PlannedGoalPosition"; - -@Entity("plannedGoal") -export class PlannedGoal extends EntityBase { - @Column({ - nullable: true, - comment: "กลุ่มเป้าหมาย", - default: null, - }) - groupTarget: string; - - @Column({ - nullable: true, - comment: "กลุ่มเป้าหมายย่อย", - default: null, - }) - groupTargetSub: string; - - // @Column({ - // nullable: true, - // comment: "ตำแหน่ง", - // default: null, - // }) - // position: string; - - // @Column({ - // nullable: true, - // comment: "ประเภทตำแหน่ง", - // default: null, - // }) - // posTypePlannedId: string; - - // @ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoals) - // @JoinColumn({ name: "posTypePlannedId" }) - // posTypePlanned: PosType; - - // @Column({ - // nullable: true, - // comment: "ระดับตำแหน่ง", - // default: null, - // }) - // posLevelPlannedId: string; - - // @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoals) - // @JoinColumn({ name: "posLevelPlannedId" }) - // posLevelPlanned: PosLevel; - - @Column({ - nullable: true, - comment: "ประเภท(กลุ่มอาชีพ คุณสมบัติ)", - default: null, - }) - type: string; - - @Column({ - nullable: true, - comment: "จำนวน(คน)", - default: null, - }) - amount: number; - - @Column({ - nullable: true, - comment: "id โครงการ", - default: null, - }) - developmentPlannedGoalId: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentPlannedGoals) - @JoinColumn({ name: "developmentPlannedGoalId" }) - developmentPlannedGoal: Development; - - @OneToMany( - () => PlannedGoalPosition, - (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.plannedGoal, - ) - plannedGoalPositions: PlannedGoalPosition[]; -} - -export class CreatePlannedGoal { - @Column() - groupTarget: string | null; - @Column() - groupTargetSub: string | null; - @Column() - positions: CreatePlannedGoalPosition[]; - // @Column() - // posTypePlannedId: string | null; - // @Column() - // posLevelPlannedId: string | null; - @Column() - type: string | null; - @Column() - amount: number | null; -} - -export type UpdatePlannedGoal = Partial; diff --git a/src/entities/PlannedGoalPosition.ts b/src/entities/PlannedGoalPosition.ts deleted file mode 100644 index a5df81d..0000000 --- a/src/entities/PlannedGoalPosition.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { PosType } from "./PosType"; -import { PosLevel } from "./PosLevel"; -import { PlannedGoal } from "./PlannedGoal"; - -@Entity("plannedGoalPosition") -export class PlannedGoalPosition extends EntityBase { - @Column({ - nullable: true, - comment: "ตำแหน่ง", - default: null, - }) - position: string; - - @Column({ - nullable: true, - comment: "ตำแหน่งทางการบริหาร", - default: null, - }) - posExecutive: string; - - @Column({ - nullable: true, - comment: "ประเภทตำแหน่ง & กลุ่มงาน", - default: null, - }) - posTypePlanned: string; - - // @Column({ - // nullable: true, - // comment: "ประเภทตำแหน่ง", - // default: null, - // }) - // posTypePlannedId: string; - - // @ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoalPositions) - // @JoinColumn({ name: "posTypePlannedId" }) - // posTypePlanned: PosType; - - @Column({ - nullable: true, - comment: "ระดับตำแหน่ง & ระดับชั้นงาน", - default: null, - }) - posLevelPlanned: string; - - // @Column({ - // nullable: true, - // comment: "ระดับตำแหน่ง", - // default: null, - // }) - // posLevelPlannedId: string; - - // @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoalPositions) - // @JoinColumn({ name: "posLevelPlannedId" }) - // posLevelPlanned: PosLevel; - - @Column({ - nullable: true, - comment: "id โครงการ", - default: null, - }) - plannedGoalId: string; - - @ManyToOne(() => PlannedGoal, (plannedGoal: PlannedGoal) => plannedGoal.plannedGoalPositions) - @JoinColumn({ name: "plannedGoalId" }) - plannedGoal: PlannedGoal; -} - -export class CreatePlannedGoalPosition { - @Column() - position: string | null; - @Column() - posExecutive: string | null; - // @Column() - // posTypePlannedId: string | null; - // @Column() - // posLevelPlannedId: string | null; - @Column() - posTypePlanned: string | null; - @Column() - posLevelPlanned: string | null; -} - -export type UpdatePlannedGoalPosition = Partial; diff --git a/src/entities/PlannedPeople.ts b/src/entities/PlannedPeople.ts deleted file mode 100644 index 8743fd1..0000000 --- a/src/entities/PlannedPeople.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; - -@Entity("plannedPeople") -export class PlannedPeople extends EntityBase { - @Column({ - nullable: true, - comment: "ผู้เกี่ยวข้อง", - default: null, - }) - groupTarget: string; - - @Column({ - nullable: true, - comment: "จำนวน(คน)", - default: null, - }) - amount: number; - - @Column({ - nullable: true, - comment: "id โครงการ", - default: null, - }) - developmentPlannedPeopleId: string; - - @ManyToOne(() => Development, (development: Development) => development.developmentPlannedPeoples) - @JoinColumn({ name: "developmentPlannedPeopleId" }) - developmentPlannedPeople: Development; -} - -export class CreatePlannedPeople { - @Column() - groupTarget: string | null; - @Column() - amount: number | null; -} - -export type UpdatePlannedPeople = Partial; diff --git a/src/entities/Portfolio.ts b/src/entities/Portfolio.ts deleted file mode 100644 index 074dd08..0000000 --- a/src/entities/Portfolio.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Entity, Column } from "typeorm"; -import { EntityBase } from "./base/Base"; - -@Entity("portfolio") -export class Portfolio extends EntityBase { - @Column({ - nullable: true, - comment: "ชื่อเอกสาร/ผลงาน", - default: null, - }) - name: string; - - @Column({ - type: "longtext", - nullable: true, - comment: "รายละเอียดเอกสาร/ผลงาน", - default: null, - }) - detail: string; -} -export class CreatePortfolio { - @Column() - name: string; - @Column() - detail: string | null; -} diff --git a/src/entities/PosLevel.ts b/src/entities/PosLevel.ts deleted file mode 100644 index 3c686fa..0000000 --- a/src/entities/PosLevel.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { PosType } from "./PosType"; -import { ActualGoal } from "./ActualGoal"; -import { DevelopmentHistory } from "./DevelopmentHistory"; -import { DevelopmentScholarship } from "./DevelopmentScholarship"; -import { PlannedGoalPosition } from "./PlannedGoalPosition"; - -enum PosLevelAuthority { - HEAD = "HEAD", - DEPUTY = "DEPUTY", - GOVERNOR = "GOVERNOR", -} -@Entity("posLevel") -export class PosLevel extends EntityBase { - @Column({ - nullable: true, - comment: "ชื่อระดับตำแหน่ง", - length: 255, - default: null, - }) - posLevelName: string; - - @Column({ - nullable: true, - comment: "ระดับของระดับตำแหน่ง", - default: null, - }) - posLevelRank: number; - - @Column({ - nullable: true, - comment: - "ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ", - type: "enum", - enum: PosLevelAuthority, - default: null, - }) - posLevelAuthority: PosLevelAuthority; - - @Column({ - length: 40, - comment: "เป็นระดับของประเภทตำแหน่งใด", - }) - posTypeId: string; - - @ManyToOne(() => PosType, (posType: PosType) => posType.posLevels) - @JoinColumn({ name: "posTypeId" }) - posType: PosType; - - // @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posLevelActual) - // actualGoals: ActualGoal[]; - - // @OneToMany( - // () => PlannedGoalPosition, - // (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posLevelPlanned, - // ) - // plannedGoalPositions: PlannedGoalPosition[]; - - @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posLevel) - developmentHistorys: DevelopmentHistory[]; - - @OneToMany( - () => DevelopmentScholarship, - (developmentScholarship) => developmentScholarship.posLevel, - ) - developmentScholars: DevelopmentScholarship[]; - - @OneToMany( - () => DevelopmentScholarship, - (developmentScholarship) => developmentScholarship.posLevelguarantor, - ) - developmentScholarGuarantors: DevelopmentScholarship[]; -} - -export class CreatePosLevel { - @Column() - posLevelName: string; - - @Column() - posLevelRank: number; - - @Column() - posLevelAuthority: string; - - @Column("uuid") - posTypeId: string; -} - -export type UpdatePosLevel = Partial & { posLevelAuthority?: PosLevelAuthority }; diff --git a/src/entities/PosType.ts b/src/entities/PosType.ts deleted file mode 100644 index b28047b..0000000 --- a/src/entities/PosType.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { Entity, Column, OneToMany } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { PosLevel } from "./PosLevel"; -import { ActualGoal } from "./ActualGoal"; -import { PlannedGoal } from "./PlannedGoal"; -import { DevelopmentHistory } from "./DevelopmentHistory"; -import { DevelopmentScholarship } from "./DevelopmentScholarship"; -import { PlannedGoalPosition } from "./PlannedGoalPosition"; - -@Entity("posType") -export class PosType extends EntityBase { - @Column({ - nullable: true, - comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)", - length: 255, - default: null, - }) - posTypeName: string; - - @Column({ - nullable: true, - comment: - "ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4", - default: null, - }) - posTypeRank: number; - - @OneToMany(() => PosLevel, (posLevel: PosLevel) => posLevel.posType) - posLevels: PosLevel[]; - - // @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posTypeActual) - // actualGoals: ActualGoal[]; - - // @OneToMany( - // () => PlannedGoalPosition, - // (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posTypePlanned, - // ) - // plannedGoalPositions: PlannedGoalPosition[]; - - @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posType) - developmentHistorys: DevelopmentHistory[]; - - @OneToMany( - () => DevelopmentScholarship, - (developmentScholarship) => developmentScholarship.posType, - ) - developmentScholars: DevelopmentScholarship[]; - - @OneToMany( - () => DevelopmentScholarship, - (developmentScholarship) => developmentScholarship.posTypeguarantor, - ) - developmentScholarGuarantors: DevelopmentScholarship[]; -} - -export class CreatePosType { - @Column() - posTypeName: string; - - @Column() - posTypeRank: number; -} - -export type UpdatePosType = Partial; diff --git a/src/entities/Province.ts b/src/entities/Province.ts deleted file mode 100644 index 080a8c6..0000000 --- a/src/entities/Province.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Entity, Column, OneToMany } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Development } from "./Development"; -import { DevelopmentAddress } from "./DevelopmentAddress"; -import { DevelopmentOther } from "./DevelopmentOther"; - -@Entity("province") -export class Province extends EntityBase { - @Column({ - nullable: true, - comment: "จังหวัด", - length: 255, - default: null, - }) - name: string; -} - -export class CreateProvince { - @Column() - name: string; -} - -export type UpdateProvince = Partial; diff --git a/src/entities/StrategyChild1.ts b/src/entities/StrategyChild1.ts deleted file mode 100644 index 8bc9803..0000000 --- a/src/entities/StrategyChild1.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { StrategyChild2 } from "./StrategyChild2"; -import { StrategyChild3 } from "./StrategyChild3"; -import { StrategyChild4 } from "./StrategyChild4"; -import { StrategyChild5 } from "./StrategyChild5"; -import { Development } from "./Development"; - -@Entity("strategyChild1") -export class StrategyChild1 extends EntityBase { - @Column({ - nullable: true, - comment: "ชื่อยุทธศาสตร์", - length: 255, - default: null, - }) - strategyChild1Name: string; - - @Column({ - nullable: true, - comment: "ลำดับความสำคัญ", - default: null, - }) - order: number; - - @OneToMany(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild1) - strategyChild2s: StrategyChild2[]; - - @OneToMany(() => StrategyChild3, (strategyChild3) => strategyChild3.strategyChild1) - strategyChild3s: StrategyChild3[]; - - @OneToMany(() => StrategyChild4, (strategyChild4) => strategyChild4.strategyChild1) - strategyChild4s: StrategyChild4[]; - - @OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild1) - strategyChild5s: StrategyChild5[]; - - @OneToMany(() => Development, (development) => development.strategyChild1Planned) - developmentPlanneds: Development[]; - @OneToMany(() => Development, (development) => development.strategyChild1Actual) - developmentActuals: Development[]; -} - -export class CreateStrategyChild1 { - @Column() - strategyChild1Name: string; -} - -export type UpdateStrategyChild1 = Partial; diff --git a/src/entities/StrategyChild2.ts b/src/entities/StrategyChild2.ts deleted file mode 100644 index 0f57eef..0000000 --- a/src/entities/StrategyChild2.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { StrategyChild1 } from "./StrategyChild1"; -import { StrategyChild3 } from "./StrategyChild3"; -import { StrategyChild4 } from "./StrategyChild4"; -import { StrategyChild5 } from "./StrategyChild5"; -import { Development } from "./Development"; - -@Entity("strategyChild2") -export class StrategyChild2 extends EntityBase { - @Column({ - nullable: true, - comment: "ชื่อยุทธศาสตร์/แผน", - length: 255, - default: null, - }) - strategyChild2Name: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild1", - }) - strategyChild1Id: string; - - @Column({ - nullable: true, - comment: "ลำดับความสำคัญ", - default: null, - }) - order: number; - - @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild2s) - @JoinColumn({ name: "strategyChild1Id" }) - strategyChild1: StrategyChild1; - - @OneToMany(() => StrategyChild3, (strategyChild3) => strategyChild3.strategyChild2) - strategyChild3s: StrategyChild3[]; - - @OneToMany(() => StrategyChild4, (strategyChild4) => strategyChild4.strategyChild2) - strategyChild4s: StrategyChild4[]; - - @OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild2) - strategyChild5s: StrategyChild5[]; - - @OneToMany(() => Development, (development) => development.strategyChild2Planned) - developmentPlanneds: Development[]; - @OneToMany(() => Development, (development) => development.strategyChild2Actual) - developmentActuals: Development[]; -} - -export class CreateStrategyChild2 { - @Column() - strategyChild2Name: string; - - @Column("uuid") - strategyChild1Id: string; -} - -export type UpdateStrategyChild2 = Partial; diff --git a/src/entities/StrategyChild3.ts b/src/entities/StrategyChild3.ts deleted file mode 100644 index d8c5ba7..0000000 --- a/src/entities/StrategyChild3.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { StrategyChild1 } from "./StrategyChild1"; -import { StrategyChild2 } from "./StrategyChild2"; -import { StrategyChild4 } from "./StrategyChild4"; -import { StrategyChild5 } from "./StrategyChild5"; -import { Development } from "./Development"; - -@Entity("strategyChild3") -export class StrategyChild3 extends EntityBase { - @Column({ - nullable: true, - comment: "ยุทธศาสตร์ที่", - length: 255, - default: null, - }) - strategyChild3Name: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild1", - }) - strategyChild1Id: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild2", - }) - strategyChild2Id: string; - - @Column({ - nullable: true, - comment: "ลำดับความสำคัญ", - default: null, - }) - order: number; - - @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild3s) - @JoinColumn({ name: "strategyChild1Id" }) - strategyChild1: StrategyChild1; - - @ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild3s) - @JoinColumn({ name: "strategyChild2Id" }) - strategyChild2: StrategyChild2; - - @OneToMany(() => StrategyChild4, (strategyChild4) => strategyChild4.strategyChild3) - strategyChild4s: StrategyChild4[]; - - @OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild3) - strategyChild5s: StrategyChild5[]; - - @OneToMany(() => Development, (development) => development.strategyChild3Planned) - developmentPlanneds: Development[]; - @OneToMany(() => Development, (development) => development.strategyChild3Actual) - developmentActuals: Development[]; -} - -export class CreateStrategyChild3 { - @Column() - strategyChild3Name: string; - - @Column("uuid") - strategyChild2Id: string; -} - -export type UpdateStrategyChild3 = Partial; diff --git a/src/entities/StrategyChild4.ts b/src/entities/StrategyChild4.ts deleted file mode 100644 index 6c5d58e..0000000 --- a/src/entities/StrategyChild4.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { StrategyChild1 } from "./StrategyChild1"; -import { StrategyChild2 } from "./StrategyChild2"; -import { StrategyChild3 } from "./StrategyChild3"; -import { StrategyChild5 } from "./StrategyChild5"; -import { Development } from "./Development"; - -@Entity("strategyChild4") -export class StrategyChild4 extends EntityBase { - @Column({ - nullable: true, - comment: "ยุทธศาสตร์ย่อยที่", - length: 255, - default: null, - }) - strategyChild4Name: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild1", - }) - strategyChild1Id: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild2", - }) - strategyChild2Id: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild3", - }) - strategyChild3Id: string; - - @Column({ - nullable: true, - comment: "ลำดับความสำคัญ", - default: null, - }) - order: number; - - @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild4s) - @JoinColumn({ name: "strategyChild1Id" }) - strategyChild1: StrategyChild1; - - @ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild4s) - @JoinColumn({ name: "strategyChild2Id" }) - strategyChild2: StrategyChild2; - - @ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.strategyChild4s) - @JoinColumn({ name: "strategyChild3Id" }) - strategyChild3: StrategyChild3; - - @OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild4) - strategyChild5s: StrategyChild5[]; - - @OneToMany(() => Development, (development) => development.strategyChild4Planned) - developmentPlanneds: Development[]; - @OneToMany(() => Development, (development) => development.strategyChild4Actual) - developmentActuals: Development[]; -} - -export class CreateStrategyChild4 { - @Column() - strategyChild4Name: string; - - @Column("uuid") - strategyChild3Id: string; -} - -export type UpdateStrategyChild4 = Partial; diff --git a/src/entities/StrategyChild5.ts b/src/entities/StrategyChild5.ts deleted file mode 100644 index 9d3f413..0000000 --- a/src/entities/StrategyChild5.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { StrategyChild1 } from "./StrategyChild1"; -import { StrategyChild2 } from "./StrategyChild2"; -import { StrategyChild3 } from "./StrategyChild3"; -import { StrategyChild4 } from "./StrategyChild4"; -import { Development } from "./Development"; - -@Entity("strategyChild5") -export class StrategyChild5 extends EntityBase { - @Column({ - nullable: true, - comment: "กลยุทธ์ที่/เป้าประสงค์ที่", - length: 255, - default: null, - }) - strategyChild5Name: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild1", - }) - strategyChild1Id: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild2", - }) - strategyChild2Id: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild3", - }) - strategyChild3Id: string; - - @Column({ - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild4", - }) - strategyChild4Id: string; - - @Column({ - nullable: true, - comment: "ลำดับความสำคัญ", - default: null, - }) - order: number; - - @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild5s) - @JoinColumn({ name: "strategyChild1Id" }) - strategyChild1: StrategyChild1; - - @ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild5s) - @JoinColumn({ name: "strategyChild2Id" }) - strategyChild2: StrategyChild2; - - @ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.strategyChild5s) - @JoinColumn({ name: "strategyChild3Id" }) - strategyChild3: StrategyChild3; - - @ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.strategyChild5s) - @JoinColumn({ name: "strategyChild4Id" }) - strategyChild4: StrategyChild4; - - @OneToMany(() => Development, (development) => development.strategyChild5Planned) - developmentPlanneds: Development[]; - @OneToMany(() => Development, (development) => development.strategyChild5Actual) - developmentActuals: Development[]; -} - -export class CreateStrategyChild5 { - @Column() - strategyChild5Name: string; - - @Column("uuid") - strategyChild4Id: string; -} - -export type UpdateStrategyChild5 = Partial; diff --git a/src/entities/view/viewDevScholarship.ts b/src/entities/view/viewDevScholarship.ts deleted file mode 100644 index 5d3ea65..0000000 --- a/src/entities/view/viewDevScholarship.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ViewColumn, ViewEntity } from "typeorm"; - -@ViewEntity({ - expression: `SELECT MAX(\`rootId\`) AS rootId, - MAX(\`root\`) AS root,\`degreeLevel\`, - COUNT(*) AS numberOfRecords, - COUNT(DISTINCT \`scholarshipType\`) AS numberOfScholarshipTypes, - SUM(\`budgetApprove\`) AS totalBudgetApprove - FROM \`developmentScholarship\` - GROUP BY \`rootId\`,\`degreeLevel\` - `, -}) - -export class viewDevScholarship { - @ViewColumn() - rootId: string; - @ViewColumn() - root: string; - @ViewColumn() - degreeLevel: string; - @ViewColumn() - numberOfRecords: number; - @ViewColumn() - numberOfScholarshipTypes: number; - @ViewColumn() - totalBudgetApprove: number; - } - diff --git a/src/interfaces/call-api.ts b/src/interfaces/call-api.ts deleted file mode 100644 index 3748715..0000000 --- a/src/interfaces/call-api.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { Path } from "tsoa"; -import axios from "axios"; -import { addLogSequence } from "./utils"; - -class CallAPI { - //Get - public async GetData(request: any, @Path() path: any, log = true) { - const token = "Bearer " + request.headers.authorization.replace("Bearer ", ""); - const url = process.env.API_URL + path; - try { - const response = await axios.get(url, { - headers: { - Authorization: `${token}`, - "Content-Type": "application/json", - api_key: process.env.API_KEY, - }, - }); - if(log) addLogSequence(request, { - action: "request", - status: "success", - description: "connected", - request: { - method: "GET", - url: url, - response: JSON.stringify(response.data.result), - }, - }); - return response.data.result; - } catch (error) { - if(log) addLogSequence(request, { - action: "request", - status: "error", - description: "unconnected", - request: { - method: "GET", - url: url, - response: JSON.stringify(error), - }, - }); - throw error; - } - } - //Post - public async PostData(request: any, @Path() path: any, sendData: any) { - const token = "Bearer " + request.headers.authorization.replace("Bearer ", ""); - const url = process.env.API_URL + path; - try { - const response = await axios.post(url, sendData, { - headers: { - Authorization: `${token}`, - "Content-Type": "application/json", - api_key: process.env.API_KEY, - }, - }); - addLogSequence(request, { - action: "request", - status: "success", - description: "connected", - request: { - method: "POST", - url: url, - payload: JSON.stringify(sendData), - response: JSON.stringify(response.data.result), - }, - }); - return response.data.result; - } catch (error) { - addLogSequence(request, { - action: "request", - status: "error", - description: "unconnected", - request: { - method: "POST", - url: url, - payload: JSON.stringify(sendData), - response: JSON.stringify(error), - }, - }); - throw error; - } - } -} - -export default CallAPI; diff --git a/src/interfaces/extension.ts b/src/interfaces/extension.ts deleted file mode 100644 index f8a28d1..0000000 --- a/src/interfaces/extension.ts +++ /dev/null @@ -1,134 +0,0 @@ -class Extension { - public static ToThaiMonth(value: number) { - switch (value) { - case 1: - return "มกราคม"; - case 2: - return "กุมภาพันธ์"; - case 3: - return "มีนาคม"; - case 4: - return "เมษายน"; - case 5: - return "พฤษภาคม"; - case 6: - return "มิถุนายน"; - case 7: - return "กรกฎาคม"; - case 8: - return "สิงหาคม"; - case 9: - return "กันยายน"; - case 10: - return "ตุลาคม"; - case 11: - return "พฤศจิกายน"; - case 12: - return "ธันวาคม"; - default: - return ""; - } - } - - public static ToThaiShortMonth(value: number) { - switch (value) { - case 1: - return "ม.ค."; - case 2: - return "ก.พ."; - case 3: - return "มี.ค."; - case 4: - return "เม.ย."; - case 5: - return "พ.ค."; - case 6: - return "มิ.ย."; - case 7: - return "ก.ค."; - case 8: - return "ส.ค."; - case 9: - return "ก.ย."; - case 10: - return "ต.ค."; - case 11: - return "พ.ย."; - case 12: - return "ธ.ค."; - default: - return ""; - } - } - - public static ToThaiYear(value: number) { - if (value < 2400) return value + 543; - else return value; - } - - public static ToCeYear(value: number) { - if (value >= 2400) return value - 543; - else return value; - } - - public static ToThaiNumber(value: string) { - let arabicNumbers = "0123456789"; - let thaiNumbers = "๐๑๒๓๔๕๖๗๘๙"; - let result = ""; - for (let digit of value) { - let index = arabicNumbers.indexOf(digit); - if (index >= 0) { - result += thaiNumbers[index]; - } else { - result += digit; - } - } - return result; - } - - public static ToThaiFullDate(value: Date) { - let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear(); - return ( - "วันที่ " + - value.getDate() + - " เดือน " + - Extension.ToThaiMonth(value.getMonth() + 1) + - " พ.ศ. " + - yy - ); - } - - public static ToThaiFullDate2(value: Date) { - let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear(); - return value.getDate() + " " + Extension.ToThaiMonth(value.getMonth() + 1) + " " + yy; - } - - public static ToThaiFullDate3(value: Date) { - let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear(); - return value.getDate() + " เดือน " + Extension.ToThaiMonth(value.getMonth() + 1) + " พ.ศ. " + yy; - } - - public static sumObjectValues(array: any, propertyName: any) { - let sum = 0; - for (let i = 0; i < array.length; i++) { - if (array[i][propertyName] !== undefined) { - sum += array[i][propertyName]; - } - } - return sum; - } - - public static ToThaiShortDate(value: Date) { - let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear(); - return ( - value.getDate() + - " " + - Extension.ToThaiShortMonth(value.getMonth() + 1) + - " " + - yy.toString().slice(-2) - ); - } - -} - -export default Extension; diff --git a/src/interfaces/http-success.ts b/src/interfaces/http-success.ts index 3d931f6..514f576 100644 --- a/src/interfaces/http-success.ts +++ b/src/interfaces/http-success.ts @@ -1,6 +1,4 @@ -import { RequestWithUser } from "../middlewares/user"; import HttpStatus from "./http-status"; -import { addLogSequence } from "./utils"; class HttpSuccess { /** @@ -16,4 +14,5 @@ class HttpSuccess { this.result = result; } } + export default HttpSuccess; diff --git a/src/interfaces/permission.ts b/src/interfaces/permission.ts deleted file mode 100644 index cfe76e6..0000000 --- a/src/interfaces/permission.ts +++ /dev/null @@ -1,292 +0,0 @@ -import axios from "axios"; -import { RequestWithUser } from "../middlewares/user"; -import CallAPI from "./call-api"; -import HttpError from "./http-error"; -import HttpStatus from "./http-status"; -import { promisify } from "util"; - -class CheckAuth { - private redis = require("redis"); - - public async Permission(req: RequestWithUser, system: string, action: string) { - if ( - req.headers.hasOwnProperty("api_key") && - req.headers["api_key"] && - req.headers["api_key"] == process.env.API_KEY - ) { - return null; - } - return await new CallAPI() - .GetData(req, "/org/permission") - .then((x) => { - let permission = false; - let role = x.roles.find((x: any) => x.authSysId == system); - if (!role) throw "ไม่มีสิทธิ์เข้าระบบ"; - if (role.attrOwnership == "OWNER") return "OWNER"; - if (action.trim().toLocaleUpperCase() == "CREATE") permission = role.attrIsCreate; - if (action.trim().toLocaleUpperCase() == "DELETE") permission = role.attrIsDelete; - if (action.trim().toLocaleUpperCase() == "GET") permission = role.attrIsGet; - if (action.trim().toLocaleUpperCase() == "LIST") permission = role.attrIsList; - if (action.trim().toLocaleUpperCase() == "UPDATE") permission = role.attrIsUpdate; - if (permission == false) throw "ไม่มีสิทธิ์ใช้งานระบบนี้"; - return role.attrPrivilege; - }) - .catch((x) => { - if (x.status != undefined) { - throw new HttpError(x.status, x.message); - } else { - throw new HttpError(HttpStatus.FORBIDDEN, x); - } - }); - } - public async PermissionOrg(req: RequestWithUser, system: string, action: string) { - if ( - req.headers.hasOwnProperty("api_key") && - req.headers["api_key"] && - req.headers["api_key"] == process.env.API_KEY - ) { - return { - root: null, - child1: null, - child2: null, - child3: null, - child4: null, - }; - } - return await new CallAPI() - .GetData(req, `/org/permission/org/${system}/${action}`) - .then(async (x) => { - let privilege = x.privilege; - - let data: any = { - root: [null], - child1: [null], - child2: [null], - child3: [null], - child4: [null], - privilege: [null], - }; - let node = 4; - if (x.orgChild1Id == null) { - node = 0; - } else if (x.orgChild2Id == null) { - node = 1; - } else if (x.orgChild3Id == null) { - node = 2; - } else if (x.orgChild4Id == null) { - node = 3; - } - if (privilege == "OWNER") { - data = { - root: null, - child1: null, - child2: null, - child3: null, - child4: null, - privilege: "OWNER", - }; - } else if (privilege == "ROOT") { - data = { - root: [x.orgRootId], - child1: null, - child2: null, - child3: null, - child4: null, - privilege: "ROOT", - }; - } else if (privilege == "CHILD") { - data = { - root: node >= 0 ? [x.orgRootId] : null, - child1: node >= 1 ? [x.orgChild1Id] : null, - child2: node >= 2 ? [x.orgChild2Id] : null, - child3: node >= 3 ? [x.orgChild3Id] : null, - child4: node >= 4 ? [x.orgChild4Id] : null, - privilege: "CHILD", - }; - } else if (privilege == "NORMAL") { - data = { - root: [x.orgRootId], - child1: [x.orgChild1Id], - child2: [x.orgChild2Id], - child3: [x.orgChild3Id], - child4: [x.orgChild4Id], - privilege: "NORMAL", - }; - } else if (privilege == "SPECIFIC") { - } - - return data; - }) - .catch((x) => { - if (x.status != undefined) { - throw new HttpError(x.status, x.message); - } else { - throw new HttpError(HttpStatus.FORBIDDEN, x); - } - }); - } - public async PermissionOrgByUser( - req: RequestWithUser, - system: string, - action: string, - profileId: string, - ) { - if ( - req.headers.hasOwnProperty("api_key") && - req.headers["api_key"] && - req.headers["api_key"] == process.env.API_KEY - ) { - return true; - } - return await new CallAPI() - .GetData(req, `/org/permission/user/${system}/${action}/${profileId}`) - .then(async (x) => { - let org = x.org; - - if (org.root != null) if (x.orgRootId != org.root[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"; - if (org.child1 != null) - if (x.orgChild1Id != org.child1[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"; - if (org.child2 != null) - if (x.orgChild2Id != org.child2[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"; - if (org.child3 != null) - if (x.orgChild3Id != org.child3[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"; - if (org.child4 != null) - if (x.orgChild4Id != org.child4[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล"; - - return true; - }) - .catch((x) => { - if (x.status != undefined) { - throw new HttpError(x.status, x.message); - } else { - throw new HttpError(HttpStatus.FORBIDDEN, x); - } - }); - } - public async Workflow(req: RequestWithUser, id: string, sysName: string) { - if ( - req.headers.hasOwnProperty("api_key") && - req.headers["api_key"] && - req.headers["api_key"] == process.env.API_KEY - ) { - return null; - } - return await new CallAPI() - .PostData(req, "/org/workflow/keycloak/isofficer", { - refId: id, - sysName: sysName, - }) - .then((x) => { - return true; - }) - .catch((x) => { - return false; - }); - } - public async checkOrg(token: any, keycloakId: string) { - try { - // Validate required environment variables - const REDIS_HOST = process.env.REDIS_HOST; - const REDIS_PORT = process.env.REDIS_PORT ? Number(process.env.REDIS_PORT) : 6379; - - if (!REDIS_HOST) { - throw new Error("REDIS_HOST is not set in environment variables"); - } - - console.log(`[REDIS] Connecting to Redis at ${REDIS_HOST}:${REDIS_PORT}`); - - // Create Redis client - const redisClient = this.redis.createClient({ - socket: { - host: REDIS_HOST, - port: REDIS_PORT, - }, - }); - - redisClient.on("error", (err: any) => { - console.error("[REDIS] Connection error:", err.message); - }); - - await redisClient.connect(); - console.log("[REDIS] Connected successfully!"); - - const getAsync = promisify(redisClient.get).bind(redisClient); - - let reply = await getAsync("org_" + keycloakId); - if (reply != null) { - reply = JSON.parse(reply); - } else { - if (!keycloakId) throw new Error("No KeycloakId provided"); - const x = await new CallAPI().GetData( - { - headers: { authorization: token }, - }, - `/org/permission/checkOrg/${keycloakId}`, - false, - ); - - const data = { - orgRootId: x.orgRootId, - orgChild1Id: x.orgChild1Id, - orgChild2Id: x.orgChild2Id, - orgChild3Id: x.orgChild3Id, - orgChild4Id: x.orgChild4Id, - }; - - return data; - } - } catch (error) { - console.error("Error calling API:", error); - throw error; - } - } - public async PermissionCreate(req: RequestWithUser, system: string) { - return await this.Permission(req, system, "CREATE"); - } - public async PermissionDelete(req: RequestWithUser, system: string) { - return await this.Permission(req, system, "DELETE"); - } - public async PermissionGet(req: RequestWithUser, system: string) { - return await this.Permission(req, system, "GET"); - } - public async PermissionList(req: RequestWithUser, system: string) { - return await this.Permission(req, system, "LIST"); - } - public async PermissionUpdate(req: RequestWithUser, system: string) { - return await this.Permission(req, system, "UPDATE"); - } - - public async PermissionOrgCreate(req: RequestWithUser, system: string) { - return await this.PermissionOrg(req, system, "CREATE"); - } - public async PermissionOrgDelete(req: RequestWithUser, system: string) { - return await this.PermissionOrg(req, system, "DELETE"); - } - public async PermissionOrgGet(req: RequestWithUser, system: string) { - return await this.PermissionOrg(req, system, "GET"); - } - public async PermissionOrgList(req: RequestWithUser, system: string) { - return await this.PermissionOrg(req, system, "LIST"); - } - public async PermissionOrgUpdate(req: RequestWithUser, system: string) { - return await this.PermissionOrg(req, system, "UPDATE"); - } - - public async PermissionOrgUserCreate(req: RequestWithUser, system: string, profileId: string) { - return await this.PermissionOrgByUser(req, system, "CREATE", profileId); - } - public async PermissionOrgUserDelete(req: RequestWithUser, system: string, profileId: string) { - return await this.PermissionOrgByUser(req, system, "DELETE", profileId); - } - public async PermissionOrgUserGet(req: RequestWithUser, system: string, profileId: string) { - return await this.PermissionOrgByUser(req, system, "GET", profileId); - } - public async PermissionOrgUserList(req: RequestWithUser, system: string, profileId: string) { - return await this.PermissionOrgByUser(req, system, "LIST", profileId); - } - public async PermissionOrgUserUpdate(req: RequestWithUser, system: string, profileId: string) { - return await this.PermissionOrgByUser(req, system, "UPDATE", profileId); - } -} - -export default CheckAuth; diff --git a/src/interfaces/storage-fs.ts b/src/interfaces/storage-fs.ts deleted file mode 100644 index 63d0769..0000000 --- a/src/interfaces/storage-fs.ts +++ /dev/null @@ -1,39 +0,0 @@ -export interface StorageFolder { - /** - * @prop Full path to this folder. It is used as key as there are no files or directories at the same location. - */ - pathname: string; - /** - * @prop Directory / Folder name. - */ - name: string; - - createdAt: string | Date; - createdBy: string | Date; -} - -export interface StorageFile { - /** - * @prop Full path to this folder. It is used as key as there are no files or directories at the same location. - */ - pathname: string; - - fileName: string; - fileSize: number; - fileType: string; - - title: string; - description: string; - author: string; - category: string[]; - keyword: string[]; - metadata: Record; - - path: string; - upload: boolean; - - updatedAt: string | Date; - updatedBy: string; - createdAt: string | Date; - createdBy: string; -} diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts deleted file mode 100644 index c667f54..0000000 --- a/src/interfaces/utils.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { RequestWithUser } from "../middlewares/user"; - -export type DataDiff = { - before: any; - after: any; -}; - -export type LogSequence = { - action: string; - status: "success" | "error"; - description: string; - query?: any; - request?: { - method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; - url?: string; - payload?: string; - response?: string; - }; -}; - -export function setLogDataDiff(req: RequestWithUser, data: DataDiff) { - // Check if data.before and data.after are valid objects - if ( - data.before && - typeof data.before === "object" && - data.after && - typeof data.after === "object" - ) { - req.app.locals.logData.dataDiff = { - before: JSON.stringify(data.before), - after: JSON.stringify(data.after), - }; - } else { - console.error("Invalid data provided: both before and after must be valid objects."); - } -} - -export function addLogSequence(req: RequestWithUser, data: LogSequence) { - if (!req?.app?.locals?.logData?.sequence) { - req.app.locals.logData.sequence = []; - } - req.app.locals.logData.sequence = req.app.locals.logData.sequence.concat(data); -} - -export function editLogSequence(req: RequestWithUser, index: number, data: LogSequence) { - req.app.locals.logData.sequence[index] = data; -} diff --git a/src/middlewares/auth.ts b/src/middlewares/auth.ts index de43a0c..e81aa15 100644 --- a/src/middlewares/auth.ts +++ b/src/middlewares/auth.ts @@ -3,13 +3,15 @@ import { createDecoder, createVerifier } from "fast-jwt"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; -import { addLogSequence } from "../interfaces/utils"; -import { RequestWithUser } from "./user"; if (!process.env.AUTH_PUBLIC_KEY && !process.env.AUTH_REALM_URL) { throw new Error("Require keycloak AUTH_PUBLIC_KEY or AUTH_REALM_URL."); } -if (process.env.AUTH_PUBLIC_KEY && process.env.AUTH_REALM_URL && !process.env.AUTH_PREFERRED_MODE) { +if ( + process.env.AUTH_PUBLIC_KEY && + process.env.AUTH_REALM_URL && + !process.env.AUTH_PREFERRED_MODE +) { throw new Error( "AUTH_PREFFERRED must be specified if AUTH_PUBLIC_KEY and AUTH_REALM_URL is provided.", ); @@ -24,7 +26,7 @@ const jwtVerify = createVerifier({ const jwtDecode = createDecoder(); export async function expressAuthentication( - request: RequestWithUser, + request: express.Request, securityName: string, _scopes?: string[], ) { @@ -54,18 +56,6 @@ export async function expressAuthentication( if (process.env.AUTH_PUBLIC_KEY) payload = await verifyOffline(token); break; } - if (!request.app.locals.logData) { - request.app.locals.logData = {}; - } - - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Query Data.", - // }); - request.app.locals.logData.userId = payload.sub; - request.app.locals.logData.userName = payload.name; - request.app.locals.logData.user = payload.preferred_username; return payload; } diff --git a/src/middlewares/error.ts b/src/middlewares/error.ts index f8d0b56..b010f0a 100644 --- a/src/middlewares/error.ts +++ b/src/middlewares/error.ts @@ -4,12 +4,6 @@ import HttpStatus from "../interfaces/http-status"; import { ValidateError } from "tsoa"; function error(error: Error, _req: Request, res: Response, _next: NextFunction) { - const logData = _req.app.locals.logData.sequence?.at(-1); - if (logData) { - logData.status = "error"; - logData.description = error.message; - } - if (error instanceof HttpError) { return res.status(error.status).json({ status: error.status, diff --git a/src/middlewares/logs.ts b/src/middlewares/logs.ts deleted file mode 100644 index fb2b6e2..0000000 --- a/src/middlewares/logs.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { NextFunction, Request, Response } from "express"; -import { Client } from "@elastic/elasticsearch"; -import permission from "../interfaces/permission"; - -if (!process.env.ELASTICSEARCH_INDEX) { - throw new Error("Require ELASTICSEARCH_INDEX to store log."); -} - -const ELASTICSEARCH_INDEX = process.env.ELASTICSEARCH_INDEX; - -const LOG_LEVEL_MAP: Record = { - debug: 4, - info: 3, - warning: 2, - error: 1, - none: 0, -}; - -const elasticsearch = new Client({ - node: `${process.env.ELASTICSEARCH_PROTOCOL}://${process.env.ELASTICSEARCH_HOST}:${process.env.ELASTICSEARCH_PORT}`, -}); -async function logMiddleware(req: Request, res: Response, next: NextFunction) { - if (!req.url.startsWith("/api/")) return next(); - - let data: any; - const originalJson = res.json; - - res.json = function (v: any) { - data = v; - return originalJson.call(this, v); - }; - - const timestamp = new Date().toISOString(); - const start = performance.now(); - - req.app.locals.logData = {}; - - res.on("finish", async () => { - try { - if (!req.url.startsWith("/api/")) return; - - const level = LOG_LEVEL_MAP[process.env.LOG_LEVEL ?? "debug"] || 4; - - if (level === 1 && res.statusCode < 500) return; - if (level === 2 && res.statusCode < 400) return; - if (level === 3 && res.statusCode < 200) return; - - const token = req.headers["authorization"]; - let rootId = null; - - try { - rootId = token - ? await new permission().checkOrg(token, req.app.locals.logData.userId) - : null; - } catch (err) { - console.warn("Error fetching rootId:", err); - } - - const obj = { - logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info", - ip: req.ip, - rootId: rootId?.orgRootId ?? null, - systemName: "development", - startTimeStamp: timestamp, - endTimeStamp: new Date().toISOString(), - processTime: performance.now() - start, - host: req.hostname, - method: req.method, - endpoint: req.url, - responseCode: String(res.statusCode === 304 ? 200 : res.statusCode), - responseDescription: data?.message, - input: level === 4 ? JSON.stringify(req.body, null, 2) : undefined, - output: level === 4 ? JSON.stringify(data, null, 2) : undefined, - ...req.app.locals.logData, - }; - - // Send log to Elasticsearch - await elasticsearch.index({ - index: ELASTICSEARCH_INDEX, - document: obj, - }); - } catch (err) { - console.error("Error in logMiddleware:", err); - } - }); - - return next(); -} - -export default logMiddleware; diff --git a/src/middlewares/user.ts b/src/middlewares/user.ts deleted file mode 100644 index a35cdc4..0000000 --- a/src/middlewares/user.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Request } from "express"; - -export type RequestWithUser = Request & { - user: { - sub: string; - name: string; - given_name: string; - familiy_name: string; - preferred_username: string; - email: string; - role: string[]; - }; -}; diff --git a/src/migration/1712050402784-add_table_development.ts b/src/migration/1712050402784-add_table_development.ts deleted file mode 100644 index 35b2cf5..0000000 --- a/src/migration/1712050402784-add_table_development.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDevelopment1712050402784 implements MigrationInterface { - name = 'AddTableDevelopment1712050402784' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`development\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NOT NULL COMMENT 'ชื่อโครงการ/กิจกรรม/หลักสูตร', \`year\` int NULL COMMENT 'ปีงบประมาณ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP TABLE \`development\``); - } - -} diff --git a/src/migration/1712060108057-add_table_development.ts b/src/migration/1712060108057-add_table_development.ts deleted file mode 100644 index cdca497..0000000 --- a/src/migration/1712060108057-add_table_development.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDevelopment1712060108057 implements MigrationInterface { - name = 'AddTableDevelopment1712060108057' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`actualPeople\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`groupTarget\` varchar(255) NULL COMMENT 'ผู้เกี่ยวข้อง', \`amount\` int NULL COMMENT 'จำนวน(คน)', \`developmentActualPeopleId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`plannedPeople\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`groupTarget\` varchar(255) NULL COMMENT 'ผู้เกี่ยวข้อง', \`amount\` int NULL COMMENT 'จำนวน(คน)', \`developmentPlannedPeopleId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`plannedGoal\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`groupTarget\` varchar(255) NULL COMMENT 'กลุ่มเป้าหมาย', \`groupTargetSub\` varchar(255) NULL COMMENT 'กลุ่มเป้าหมายย่อย', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง', \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง', \`type\` varchar(255) NULL COMMENT 'ประเภท(กลุ่มอาชีพ คุณสมบัติ)', \`amount\` int NULL COMMENT 'จำนวน(คน)', \`developmentPlannedGoalId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`posType\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`posTypeName\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)', \`posTypeRank\` int NULL COMMENT 'ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`posLevel\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`posLevelName\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง', \`posLevelRank\` int NULL COMMENT 'ระดับของระดับตำแหน่ง', \`posLevelAuthority\` enum ('HEAD', 'DEPUTY', 'GOVERNOR') NULL COMMENT 'ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ', \`posTypeId\` varchar(40) NOT NULL COMMENT 'เป็นระดับของประเภทตำแหน่งใด', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`actualGoal\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`groupTarget\` varchar(255) NULL COMMENT 'กลุ่มเป้าหมาย', \`groupTargetSub\` varchar(255) NULL COMMENT 'กลุ่มเป้าหมายย่อย', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posTypeActualId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง', \`posLevelActualId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง', \`type\` varchar(255) NULL COMMENT 'ประเภท(กลุ่มอาชีพ คุณสมบัติ)', \`amount\` int NULL COMMENT 'จำนวน(คน)', \`developmentActualGoalId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`province\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'จังหวัด', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`employeePosType\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`posTypeName\` varchar(255) NULL COMMENT 'ชื่อกลุ่มงาน', \`posTypeRank\` int NOT NULL COMMENT 'ระดับของกลุ่มงาน', \`posTypeShortName\` varchar(255) NULL COMMENT 'ชื่อย่อกลุ่มงาน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`employeePosLevel\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`posLevelName\` int NOT NULL COMMENT 'ชื่อระดับชั้นงาน', \`posLevelRank\` int NOT NULL COMMENT 'ระดับของระดับชั้นงาน', \`posLevelAuthority\` enum ('HEAD', 'DEPUTY', 'GOVERNOR') NULL COMMENT 'ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ', \`posTypeId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosType', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`name\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectName\` varchar(255) NOT NULL COMMENT 'ชื่อโครงการ/กิจกรรม/หลักสูตร'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reason\` varchar(255) NULL COMMENT 'หลักการและเหตุผล'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`objective\` varchar(255) NULL COMMENT 'วัตถุประสงค์'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`metricType\` varchar(255) NULL COMMENT 'ประเภทตัวชี้วัด'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`indicators\` varchar(255) NULL COMMENT 'ตัวชี้วัด'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`target\` varchar(255) NULL COMMENT 'เป้าหมาย'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`calculation\` varchar(255) NULL COMMENT 'วิธีการคำนวณ/เครื่องมือ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`measuRement\` varchar(255) NULL COMMENT 'ระยะเวลาวัดผล'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`results\` varchar(255) NULL COMMENT 'ผลการดำเนิน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`obstacles\` varchar(255) NULL COMMENT 'ปัญหาอุปสรรค'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`suggestions\` varchar(255) NULL COMMENT 'ข้อเสนอเเนะ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`project\` varchar(255) NULL COMMENT 'ประเภทโครงการ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isPassAllocate\` tinyint NOT NULL COMMENT 'ผ่านการพิจาณา ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isPassNoAllocate\` tinyint NOT NULL COMMENT 'ผ่านการพิจารณา ไม่ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ แต่ได้รับการจัดสรรเงินนอกงบประมาณ' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isNoPass\` tinyint NOT NULL COMMENT 'ไม่ผ่านการพิจารณา แต่ได้รับการจัดสรรเงินนอกงบประมาณ' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isBudget\` tinyint NOT NULL COMMENT 'แต่ได้รับการจัดสรรงบประมาณตามข้อบัญญัติ' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isOutBudget\` tinyint NOT NULL COMMENT 'แต่ได้รับการจัดสรรเงินนอกงบประมาณ' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStart\` datetime NULL COMMENT 'วันที่เริ่มต้น'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateEnd\` datetime NULL COMMENT 'วันที่สิ้นสุด'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`totalDate\` int NULL COMMENT 'รวมระยะเวลา (วัน)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`address\` varchar(255) NULL COMMENT 'ที่อยู่'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`provinceId\` varchar(255) NULL COMMENT 'จังหวัด'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`budget\` varchar(255) NULL COMMENT 'ประเภทงบประมาณ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`accept\` double NULL COMMENT 'จํานวนงบประมาณที่ขอรับการจัดสรรฯ' DEFAULT '0'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`receive\` double NULL COMMENT 'จํานวนงบประมาณที่ได้รับการจัดสรรฯ' DEFAULT '0'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`approved\` double NULL COMMENT 'จํานวนงบประมาณที่ได้รับอนุมัติ' DEFAULT '0'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`budgetPay\` double NULL COMMENT 'จํานวนงบประมาณที่จ่ายจริง' DEFAULT '0'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`issues\` varchar(255) NULL COMMENT 'ประเด็นความเสี่ยง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`chance\` varchar(255) NULL COMMENT 'โอกาศที่จะเกิด'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`effects\` varchar(255) NULL COMMENT 'ผลกระทบจากการเกิด'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`riskLevel\` varchar(255) NULL COMMENT 'ระดับความเสี่ยง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`riskManagement\` varchar(255) NULL COMMENT 'เเนวทางการบริหารความเสี่ยง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`expect\` varchar(255) NULL COMMENT 'ประโยชน์ที่คาดว่าจะได้รับ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`topicAcademic\` varchar(255) NULL COMMENT 'หัวข้อ/ประเด็นการฝึกอบรม ศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`addressAcademic\` varchar(255) NULL COMMENT 'สถานที่ฝึกอบรม ศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`provinceActualId\` varchar(255) NULL COMMENT 'จังหวัด(ข้อมูลวิชาการ)'`); - await queryRunner.query(`ALTER TABLE \`actualPeople\` ADD CONSTRAINT \`FK_f829036b60eabcca870d5e9242e\` FOREIGN KEY (\`developmentActualPeopleId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`plannedPeople\` ADD CONSTRAINT \`FK_b508fdcde0693754799a9a75603\` FOREIGN KEY (\`developmentPlannedPeopleId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_308d02f616b878261a3890b4d40\` FOREIGN KEY (\`posTypePlannedId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_0e6aba627301f35aa3570b44bf5\` FOREIGN KEY (\`posLevelPlannedId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_14f48058eff5d24c8be711ae92b\` FOREIGN KEY (\`developmentPlannedGoalId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`posLevel\` ADD CONSTRAINT \`FK_66caa3d974b67a8a8b343d029b2\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_e08e337e5ddeb4942c72393ff58\` FOREIGN KEY (\`posTypeActualId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_a9a864dd06eaa25edba8be8f24c\` FOREIGN KEY (\`posLevelActualId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_5fc0017c134049b436d20ee81b4\` FOREIGN KEY (\`developmentActualGoalId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_c7552b4624cc7347144be758e6e\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_bdafbb824b88c3bdb73adf7f220\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`employeePosLevel\` ADD CONSTRAINT \`FK_7fb9ab868f3f46b44f460c984f1\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`employeePosLevel\` DROP FOREIGN KEY \`FK_7fb9ab868f3f46b44f460c984f1\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_bdafbb824b88c3bdb73adf7f220\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_c7552b4624cc7347144be758e6e\``); - await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_5fc0017c134049b436d20ee81b4\``); - await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_a9a864dd06eaa25edba8be8f24c\``); - await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_e08e337e5ddeb4942c72393ff58\``); - await queryRunner.query(`ALTER TABLE \`posLevel\` DROP FOREIGN KEY \`FK_66caa3d974b67a8a8b343d029b2\``); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_14f48058eff5d24c8be711ae92b\``); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_0e6aba627301f35aa3570b44bf5\``); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_308d02f616b878261a3890b4d40\``); - await queryRunner.query(`ALTER TABLE \`plannedPeople\` DROP FOREIGN KEY \`FK_b508fdcde0693754799a9a75603\``); - await queryRunner.query(`ALTER TABLE \`actualPeople\` DROP FOREIGN KEY \`FK_f829036b60eabcca870d5e9242e\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`provinceActualId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`addressAcademic\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`topicAcademic\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`expect\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`riskManagement\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`riskLevel\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`effects\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`chance\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`issues\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`budgetPay\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`approved\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`receive\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`accept\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`budget\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`provinceId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`address\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`totalDate\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateEnd\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStart\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isOutBudget\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isBudget\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isNoPass\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isPassNoAllocate\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isPassAllocate\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`project\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`suggestions\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`obstacles\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`results\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`measuRement\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`calculation\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`target\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`indicators\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`metricType\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`objective\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reason\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectName\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`name\` varchar(255) NOT NULL COMMENT 'ชื่อโครงการ/กิจกรรม/หลักสูตร'`); - await queryRunner.query(`DROP TABLE \`employeePosLevel\``); - await queryRunner.query(`DROP TABLE \`employeePosType\``); - await queryRunner.query(`DROP TABLE \`province\``); - await queryRunner.query(`DROP TABLE \`actualGoal\``); - await queryRunner.query(`DROP TABLE \`posLevel\``); - await queryRunner.query(`DROP TABLE \`posType\``); - await queryRunner.query(`DROP TABLE \`plannedGoal\``); - await queryRunner.query(`DROP TABLE \`plannedPeople\``); - await queryRunner.query(`DROP TABLE \`actualPeople\``); - } - -} diff --git a/src/migration/1712076616416-add_table_developmentHistory.ts b/src/migration/1712076616416-add_table_developmentHistory.ts deleted file mode 100644 index 1a5e76e..0000000 --- a/src/migration/1712076616416-add_table_developmentHistory.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDevelopmentHistory1712076616416 implements MigrationInterface { - name = 'AddTableDevelopmentHistory1712076616416' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`developmentHistory\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`rank\` varchar(40) NULL COMMENT 'ยศ', \`prefix\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อ', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'นามสกุล', \`citizenId\` varchar(13) NULL COMMENT 'เลขประจำตัวประชาชน', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง', \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`chance\` \`chance\` varchar(255) NULL COMMENT 'โอกาสที่จะเกิด'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_d786f60dffba2d9a24c3bd3921b\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_d4e7a95f885bd0bd26c9ec1dba2\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_405574443eb92d4cdd8a88a22e6\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_405574443eb92d4cdd8a88a22e6\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_d4e7a95f885bd0bd26c9ec1dba2\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_d786f60dffba2d9a24c3bd3921b\``); - await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`chance\` \`chance\` varchar(255) NULL COMMENT 'โอกาศที่จะเกิด'`); - await queryRunner.query(`DROP TABLE \`developmentHistory\``); - } - -} diff --git a/src/migration/1712078526676-add_table_developmentHistory1.ts b/src/migration/1712078526676-add_table_developmentHistory1.ts deleted file mode 100644 index 0f832c9..0000000 --- a/src/migration/1712078526676-add_table_developmentHistory1.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDevelopmentHistory11712078526676 implements MigrationInterface { - name = 'AddTableDevelopmentHistory11712078526676' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`order\` varchar(255) NULL COMMENT 'เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateOrder\` varchar(255) NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateOrder\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`order\``); - } - -} diff --git a/src/migration/1712119650901-add_table_developmentHistory2.ts b/src/migration/1712119650901-add_table_developmentHistory2.ts deleted file mode 100644 index c7dc6d5..0000000 --- a/src/migration/1712119650901-add_table_developmentHistory2.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDevelopmentHistory21712119650901 implements MigrationInterface { - name = 'AddTableDevelopmentHistory21712119650901' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`type\` varchar(40) NULL COMMENT 'ประเภทราชการ'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`type\``); - } - -} diff --git a/src/migration/1712120794817-update_table_developmentHistory_add_type.ts b/src/migration/1712120794817-update_table_developmentHistory_add_type.ts deleted file mode 100644 index 52e2b57..0000000 --- a/src/migration/1712120794817-update_table_developmentHistory_add_type.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentHistoryAddType1712120794817 implements MigrationInterface { - name = 'UpdateTableDevelopmentHistoryAddType1712120794817' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`employeePosLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`employeePosTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_a905f077069e27d2fc9bb8f5f5c\` FOREIGN KEY (\`employeePosLevelId\`) REFERENCES \`employeePosLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD CONSTRAINT \`FK_25dd3134b725bb2ec455872374f\` FOREIGN KEY (\`employeePosTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_25dd3134b725bb2ec455872374f\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP FOREIGN KEY \`FK_a905f077069e27d2fc9bb8f5f5c\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`employeePosTypeId\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`employeePosLevelId\``); - } - -} diff --git a/src/migration/1712126314212-update_table_developmentHistory_add_type1.ts b/src/migration/1712126314212-update_table_developmentHistory_add_type1.ts deleted file mode 100644 index 440e577..0000000 --- a/src/migration/1712126314212-update_table_developmentHistory_add_type1.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentHistoryAddType11712126314212 implements MigrationInterface { - name = 'UpdateTableDevelopmentHistoryAddType11712126314212' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`posExecutive\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งทางการบริหาร'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`posExecutive\``); - } - -} diff --git a/src/migration/1712135164363-update_table_development_add_dateStudyStart.ts b/src/migration/1712135164363-update_table_development_add_dateStudyStart.ts deleted file mode 100644 index 87d7c30..0000000 --- a/src/migration/1712135164363-update_table_development_add_dateStudyStart.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentAddDateStudyStart1712135164363 implements MigrationInterface { - name = 'UpdateTableDevelopmentAddDateStudyStart1712135164363' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyStart\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyEnd\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyEnd\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyStart\``); - } - -} diff --git a/src/migration/1712135296648-update_table_development_add_dateStudyStart1.ts b/src/migration/1712135296648-update_table_development_add_dateStudyStart1.ts deleted file mode 100644 index 1819ff4..0000000 --- a/src/migration/1712135296648-update_table_development_add_dateStudyStart1.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentAddDateStudyStart11712135296648 implements MigrationInterface { - name = 'UpdateTableDevelopmentAddDateStudyStart11712135296648' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateOrder\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateOrder\` datetime NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateOrder\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateOrder\` varchar(255) NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่'`); - } - -} diff --git a/src/migration/1712227929512-add_table_devscholar.ts b/src/migration/1712227929512-add_table_devscholar.ts deleted file mode 100644 index 8cb8817..0000000 --- a/src/migration/1712227929512-add_table_devscholar.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDevscholar1712227929512 implements MigrationInterface { - name = 'AddTableDevscholar1712227929512' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`developmentScholarship\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`rank\` varchar(40) NULL COMMENT 'ยศ', \`prefix\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อ', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'นามสกุล', \`citizenId\` varchar(13) NULL COMMENT 'เลขประจำตัวประชาชน', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posExecutive\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งทางการบริหาร', \`guarantorRank\` varchar(40) NULL COMMENT 'ยศ(ผู้ค้ำ)', \`guarantorPrefix\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อ(ผู้ค้ำ)', \`guarantorFirstName\` varchar(255) NULL COMMENT 'ชื่อ(ผู้ค้ำ)', \`guarantorLastName\` varchar(255) NULL COMMENT 'นามสกุล(ผู้ค้ำ)', \`guarantorCitizenId\` varchar(13) NULL COMMENT 'เลขประจำตัวประชาชน(ผู้ค้ำ)', \`guarantorPosition\` varchar(255) NULL COMMENT 'ตำแหน่ง(ผู้ค้ำ)', \`guarantorPosExecutive\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งทางการบริหาร(ผู้ค้ำ)', \`scholarshipYear\` int NULL COMMENT 'ปีงบประมาณที่ได้รับทุน', \`budgetSource\` varchar(10) NULL COMMENT 'แหล่งงบประมาณ', \`budgetApprove\` double NULL COMMENT 'งบประมาณที่ได้รับอนุมัติตลอดหลักสูตร' DEFAULT '0', \`bookNo\` varchar(40) NULL COMMENT 'เลขที่หนังสืออนุมัติ', \`bookNoDate\` date NULL COMMENT 'ลงวันที่(หนังสือ)', \`bookApproveDate\` date NULL COMMENT 'หนังสืออนุมัติเมื่อวันที่', \`useOfficialTime\` tinyint NOT NULL COMMENT 'ใช้เวลาราชการ' DEFAULT 0, \`changeDetail\` text NULL COMMENT 'เปลี่ยนแปลงรายละเอียด', \`scholarshipType\` varchar(40) NULL COMMENT 'เลือกประเภททุน', \`fundType\` varchar(40) NULL COMMENT 'ประเภททุน', \`contractNo\` varchar(40) NULL COMMENT 'เลขที่สัญญา', \`contractDate\` date NULL COMMENT 'ลงวันที่(เลขที่สัญญา)', \`reportBackNo\` varchar(40) NULL COMMENT 'เลขที่หนังสือรายงานตัวกลับ', \`reportBackNoDate\` date NULL COMMENT 'ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)', \`reportBackDate\` date NULL COMMENT 'รายงานตัวกลับวันที่', \`degreeLevel\` varchar(10) NULL COMMENT 'ระดับปริญญา', \`courseOfStudy\` varchar(255) NULL COMMENT 'หลักสูตรการศึกษา', \`fieldOfStudy\` varchar(255) NULL COMMENT 'สาขาวิชา', \`faculty\` varchar(255) NULL COMMENT 'คณะ', \`educationalInstitution\` varchar(255) NULL COMMENT 'สถาบันการศึกษา', \`studyStartDate\` varchar(255) NULL COMMENT 'วันเริ่มต้นการศึกษา', \`studyEndDate\` varchar(255) NULL COMMENT 'วันสิ้นสุดการศึกษา', \`studyTourPlace\` datetime NULL COMMENT 'สถานที่ไปศึกษาดูงาน', \`studyTourTopic\` datetime NULL COMMENT 'หัวข้อการไปศึกษาดูงาน', \`studyTourStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน', \`studyTourEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน', \`studyTourCountry\` varchar(255) NULL COMMENT 'ประเทศที่เดินทางไปศึกษาดูงาน', \`studyTourAbroadTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงานต่างประเทศ', \`studyTourAbroadStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงานต่างประเทศ', \`studyTourAbroadEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงานต่างประเทศ', \`totalStudyPeriod\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการศึกษา', \`trainingCourseName\` varchar(255) NULL COMMENT 'หลักสูตรการฝึกอบรม', \`trainingStartDate\` date NULL COMMENT 'วันเริ่มต้นการฝึกอบรม', \`trainingEndDate\` date NULL COMMENT 'วันสิ้นสุดการฝึกอบรม', \`totalTrainingTime\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการฝึกอบรม', \`order\` varchar(255) NULL COMMENT 'เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ', \`dateOrder\` datetime NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP TABLE \`developmentScholarship\``); - } - -} diff --git a/src/migration/1712235509538-add_table_devscholar1.ts b/src/migration/1712235509538-add_table_devscholar1.ts deleted file mode 100644 index 214598c..0000000 --- a/src/migration/1712235509538-add_table_devscholar1.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDevscholar11712235509538 implements MigrationInterface { - name = 'AddTableDevscholar11712235509538' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`courseOfStudy\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`dateOrder\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`fieldOfStudy\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`order\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourAbroadEndDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourAbroadStartDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourAbroadTopic\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourCountry\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourEndDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourPlace\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourStartDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourTopic\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`totalStudyPeriod\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`totalTrainingTime\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`trainingCourseName\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`trainingEndDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`trainingStartDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posLevelguarantorId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง(ผู้ค้ำ)'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posTypeguarantorId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง(ผู้ค้ำ)'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`course\` varchar(255) NULL COMMENT 'หลักสูตรการศึกษา/หลักสูตรการฝึกอบรม'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`field\` varchar(255) NULL COMMENT 'สาขาวิชา/สาขา'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`startDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษา/วันเริ่มต้นการฝึกอบรม/วันเริ่มต้นการศึกษาดูงานในประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`endDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษา/วันสิ้นสุดการฝึกอบรม/วันสิ้นสุดการศึกษาดูงานในประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyPlace\` varchar(255) NULL COMMENT 'สถานที่ไปศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงาน/หัวข้อการไปศึกษาดูงานในประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyCountry\` varchar(255) NULL COMMENT 'ประเทศที่เดินทางไปศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyAbroadTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงานต่างประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyAbroadStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงานต่างประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyAbroadEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงานต่างประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`totalPeriod\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการศึกษา/รวมระยะเวลาในการฝึกอบรม'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`degreeLevel\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`degreeLevel\` varchar(255) NULL COMMENT 'ระดับปริญญา'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`educationalInstitution\` \`educationalInstitution\` varchar(255) NULL COMMENT 'สถาบันการศึกษา/สถาบันการศึกษา_หน่วยงานผู้จัดการฝึกอบรม/สถานที่ไปศึกษาดูงานในประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyStartDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyEndDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_c95a104dc1c147cd9ffe676097a\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_4f93cbcfe04f319f043ca6bafe8\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_264f2b2fc644c7173484c3b67d9\` FOREIGN KEY (\`posLevelguarantorId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_5a83bbe2bac1e79113df21ed6ef\` FOREIGN KEY (\`posTypeguarantorId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_5a83bbe2bac1e79113df21ed6ef\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_264f2b2fc644c7173484c3b67d9\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_4f93cbcfe04f319f043ca6bafe8\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_c95a104dc1c147cd9ffe676097a\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyEndDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyEndDate\` varchar(255) NULL COMMENT 'วันสิ้นสุดการศึกษา'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyStartDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyStartDate\` varchar(255) NULL COMMENT 'วันเริ่มต้นการศึกษา'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`educationalInstitution\` \`educationalInstitution\` varchar(255) NULL COMMENT 'สถาบันการศึกษา'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`degreeLevel\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`degreeLevel\` varchar(10) NULL COMMENT 'ระดับปริญญา'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`totalPeriod\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyAbroadEndDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyAbroadStartDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyAbroadTopic\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyCountry\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTopic\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyPlace\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`endDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`startDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`field\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`course\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posTypeguarantorId\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posLevelguarantorId\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posTypeId\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posLevelId\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`trainingStartDate\` date NULL COMMENT 'วันเริ่มต้นการฝึกอบรม'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`trainingEndDate\` date NULL COMMENT 'วันสิ้นสุดการฝึกอบรม'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`trainingCourseName\` varchar(255) NULL COMMENT 'หลักสูตรการฝึกอบรม'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`totalTrainingTime\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการฝึกอบรม'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`totalStudyPeriod\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการศึกษา'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourTopic\` datetime NULL COMMENT 'หัวข้อการไปศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourPlace\` datetime NULL COMMENT 'สถานที่ไปศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourCountry\` varchar(255) NULL COMMENT 'ประเทศที่เดินทางไปศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourAbroadTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงานต่างประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourAbroadStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงานต่างประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourAbroadEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงานต่างประเทศ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`order\` varchar(255) NULL COMMENT 'เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`fieldOfStudy\` varchar(255) NULL COMMENT 'สาขาวิชา'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`dateOrder\` datetime NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`courseOfStudy\` varchar(255) NULL COMMENT 'หลักสูตรการศึกษา'`); - } - -} diff --git a/src/migration/1712670681087-update_table_developement_add_projectType.ts b/src/migration/1712670681087-update_table_developement_add_projectType.ts deleted file mode 100644 index f9ee7ca..0000000 --- a/src/migration/1712670681087-update_table_developement_add_projectType.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopementAddProjectType1712670681087 implements MigrationInterface { - name = 'UpdateTableDevelopementAddProjectType1712670681087' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_0e6aba627301f35aa3570b44bf5\``); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP FOREIGN KEY \`FK_308d02f616b878261a3890b4d40\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_c7552b4624cc7347144be758e6e\``); - await queryRunner.query(`CREATE TABLE \`plannedGoalPosition\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง', \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง', \`plannedGoalId\` varchar(255) NULL COMMENT 'id โครงการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`province_development_provinces_development\` (\`provinceId\` varchar(36) NOT NULL, \`developmentId\` varchar(36) NOT NULL, INDEX \`IDX_32e044775dec4423645a09d90e\` (\`provinceId\`), INDEX \`IDX_66246e941aca36d81e7c8e0c88\` (\`developmentId\`), PRIMARY KEY (\`provinceId\`, \`developmentId\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`position\``); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`posTypePlannedId\``); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`posLevelPlannedId\``); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`type\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`provinceId\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectType\` varchar(255) NULL COMMENT 'ประเภทโครงการ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectCharacteristics\` varchar(255) NULL COMMENT 'ลักษณะ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDay\` int NULL COMMENT 'จำนวน(วัน)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectNigth\` int NULL COMMENT 'จำนวน(คืน)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectTechniques\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectModal\` int NULL COMMENT 'จำนวน(รุ่น)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`budgetSub\` varchar(255) NULL COMMENT 'ประเภทย่อย'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`status\` varchar(40) NULL COMMENT 'สถานะ' DEFAULT 'PENDING'`); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_4eef5d8c3ab92f7af4a762150a4\` FOREIGN KEY (\`posTypePlannedId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_8e7e0bf6eebd99f58e9b47c6b05\` FOREIGN KEY (\`posLevelPlannedId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_f2fad93b1a4a3454f0de1c12c62\` FOREIGN KEY (\`plannedGoalId\`) REFERENCES \`plannedGoal\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`province_development_provinces_development\` ADD CONSTRAINT \`FK_32e044775dec4423645a09d90e6\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE \`province_development_provinces_development\` ADD CONSTRAINT \`FK_66246e941aca36d81e7c8e0c888\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`province_development_provinces_development\` DROP FOREIGN KEY \`FK_66246e941aca36d81e7c8e0c888\``); - await queryRunner.query(`ALTER TABLE \`province_development_provinces_development\` DROP FOREIGN KEY \`FK_32e044775dec4423645a09d90e6\``); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_f2fad93b1a4a3454f0de1c12c62\``); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_8e7e0bf6eebd99f58e9b47c6b05\``); - await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_4eef5d8c3ab92f7af4a762150a4\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`status\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`budgetSub\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectModal\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectTechniques\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectNigth\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDay\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectCharacteristics\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectType\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`provinceId\` varchar(255) NULL COMMENT 'จังหวัด'`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`type\` varchar(255) NULL COMMENT 'ประเภท(กลุ่มอาชีพ คุณสมบัติ)'`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง'`); - await queryRunner.query(`DROP INDEX \`IDX_66246e941aca36d81e7c8e0c88\` ON \`province_development_provinces_development\``); - await queryRunner.query(`DROP INDEX \`IDX_32e044775dec4423645a09d90e\` ON \`province_development_provinces_development\``); - await queryRunner.query(`DROP TABLE \`province_development_provinces_development\``); - await queryRunner.query(`DROP TABLE \`plannedGoalPosition\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_c7552b4624cc7347144be758e6e\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_308d02f616b878261a3890b4d40\` FOREIGN KEY (\`posTypePlannedId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD CONSTRAINT \`FK_0e6aba627301f35aa3570b44bf5\` FOREIGN KEY (\`posLevelPlannedId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} diff --git a/src/migration/1712721970803-update_table_scholarship_add_ProfileId.ts b/src/migration/1712721970803-update_table_scholarship_add_ProfileId.ts deleted file mode 100644 index 6cb2892..0000000 --- a/src/migration/1712721970803-update_table_scholarship_add_ProfileId.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableScholarshipAddProfileId1712721970803 implements MigrationInterface { - name = 'UpdateTableScholarshipAddProfileId1712721970803' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`profileId\` varchar(40) NULL COMMENT 'id profile'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`profileId\``); - } - -} diff --git a/src/migration/1712778363784-update_table_dev_refresh1.ts b/src/migration/1712778363784-update_table_dev_refresh1.ts deleted file mode 100644 index 859005e..0000000 --- a/src/migration/1712778363784-update_table_dev_refresh1.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevRefresh11712778363784 implements MigrationInterface { - name = 'UpdateTableDevRefresh11712778363784' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`developmentAddress\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`address\` varchar(255) NULL COMMENT 'ที่อยู่', \`provinceId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`developmentProjectType\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'ประเภทโครงการ', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`developmentProjectTechnique\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`developmentEvaluation\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`indicators\` varchar(255) NULL COMMENT 'ตัวชี้วัด', \`target\` int NULL COMMENT 'เป้าหมาย', \`metricType\` varchar(255) NULL COMMENT 'ประเภทตัวชี้วัด', \`calculation\` varchar(255) NULL COMMENT 'วิธีการคำนวณ/เครื่องมือ', \`measuRement\` varchar(255) NULL COMMENT 'ระยะเวลาวัดผล', \`results\` varchar(255) NULL COMMENT 'ผลการดำเนิน', \`obstacles\` varchar(255) NULL COMMENT 'ปัญหาอุปสรรค', \`suggestions\` varchar(255) NULL COMMENT 'ข้อเสนอเเนะ', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`metricType\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`indicators\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`target\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`calculation\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`measuRement\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`results\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`obstacles\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`suggestions\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`address\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyStart\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyEnd\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectType\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectCharacteristics\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDay\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectNigth\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectTechniques\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`status\` varchar(255) NULL COMMENT 'สถานะ' DEFAULT 'ONGOING'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isBackPlanned\` tinyint NOT NULL COMMENT 'ไป-กลับ' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isHoldPlanned\` tinyint NOT NULL COMMENT 'พักค้าง' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDayBackPlanned\` int NULL COMMENT 'จำนวน(วัน)(ไป-กลับ)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDayHoldPlanned\` int NULL COMMENT 'จำนวน(วัน)(พักค้าง)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectNigthHoldPlanned\` int NULL COMMENT 'จำนวน(คืน)(พักค้าง)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isBackActual\` tinyint NOT NULL COMMENT 'ไป-กลับ' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`isHoldActual\` tinyint NOT NULL COMMENT 'พักค้าง' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDayBackActual\` int NULL COMMENT 'จำนวน(วัน)(ไป-กลับ)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDayHoldActual\` int NULL COMMENT 'จำนวน(วัน)(พักค้าง)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectNigthHoldActual\` int NULL COMMENT 'จำนวน(คืน)(พักค้าง)'`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`chance\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`chance\` int NULL COMMENT 'โอกาสที่จะเกิด'`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`effects\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`effects\` int NULL COMMENT 'ผลกระทบจากการเกิด'`); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD CONSTRAINT \`FK_e2721b3f440256b56ce83a04fb2\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD CONSTRAINT \`FK_de5eb0e55892aa0cf019afb284d\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentProjectType\` ADD CONSTRAINT \`FK_e9c5a726024b87bb10f23570a98\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechnique\` ADD CONSTRAINT \`FK_902408e69fa1cf0ed815859e089\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentEvaluation\` ADD CONSTRAINT \`FK_1714596cf3e3e8311a766800289\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentEvaluation\` DROP FOREIGN KEY \`FK_1714596cf3e3e8311a766800289\``); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechnique\` DROP FOREIGN KEY \`FK_902408e69fa1cf0ed815859e089\``); - await queryRunner.query(`ALTER TABLE \`developmentProjectType\` DROP FOREIGN KEY \`FK_e9c5a726024b87bb10f23570a98\``); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP FOREIGN KEY \`FK_de5eb0e55892aa0cf019afb284d\``); - await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP FOREIGN KEY \`FK_e2721b3f440256b56ce83a04fb2\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`effects\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`effects\` varchar(255) NULL COMMENT 'ผลกระทบจากการเกิด'`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`chance\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`chance\` varchar(255) NULL COMMENT 'โอกาสที่จะเกิด'`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectNigthHoldActual\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDayHoldActual\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDayBackActual\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isHoldActual\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isBackActual\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectNigthHoldPlanned\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDayHoldPlanned\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectDayBackPlanned\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isHoldPlanned\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isBackPlanned\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`status\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectTechniques\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectNigth\` int NULL COMMENT 'จำนวน(คืน)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectDay\` int NULL COMMENT 'จำนวน(วัน)'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectCharacteristics\` varchar(255) NULL COMMENT 'ลักษณะ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectType\` varchar(255) NULL COMMENT 'ประเภทโครงการ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyEnd\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyStart\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`address\` varchar(255) NULL COMMENT 'ที่อยู่'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`suggestions\` varchar(255) NULL COMMENT 'ข้อเสนอเเนะ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`obstacles\` varchar(255) NULL COMMENT 'ปัญหาอุปสรรค'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`results\` varchar(255) NULL COMMENT 'ผลการดำเนิน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`measuRement\` varchar(255) NULL COMMENT 'ระยะเวลาวัดผล'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`calculation\` varchar(255) NULL COMMENT 'วิธีการคำนวณ/เครื่องมือ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`target\` varchar(255) NULL COMMENT 'เป้าหมาย'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`indicators\` varchar(255) NULL COMMENT 'ตัวชี้วัด'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`metricType\` varchar(255) NULL COMMENT 'ประเภทตัวชี้วัด'`); - await queryRunner.query(`DROP TABLE \`developmentEvaluation\``); - await queryRunner.query(`DROP TABLE \`developmentProjectTechnique\``); - await queryRunner.query(`DROP TABLE \`developmentProjectType\``); - await queryRunner.query(`DROP TABLE \`developmentAddress\``); - } - -} diff --git a/src/migration/1712779710145-update_table_dev_refresh2.ts b/src/migration/1712779710145-update_table_dev_refresh2.ts deleted file mode 100644 index 74635f4..0000000 --- a/src/migration/1712779710145-update_table_dev_refresh2.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevRefresh21712779710145 implements MigrationInterface { - name = 'UpdateTableDevRefresh21712779710145' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyStart\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`dateStudyEnd\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyEnd\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`dateStudyStart\``); - } - -} diff --git a/src/migration/1712810427265-add_table_starty.ts b/src/migration/1712810427265-add_table_starty.ts deleted file mode 100644 index 24355e3..0000000 --- a/src/migration/1712810427265-add_table_starty.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableStarty1712810427265 implements MigrationInterface { - name = 'AddTableStarty1712810427265' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`strategyChild4\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`strategyChild4Name\` varchar(255) NULL COMMENT 'ยุทธศาสตร์ย่อยที่', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', \`strategyChild2Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2', \`strategyChild3Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`strategyChild3\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`strategyChild3Name\` varchar(255) NULL COMMENT 'ยุทธศาสตร์ที่', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', \`strategyChild2Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`strategyChild2\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`strategyChild2Name\` varchar(255) NULL COMMENT 'ชื่อยุทธศาสตร์/แผน', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`strategyChild1\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`strategyChild1Name\` varchar(255) NULL COMMENT 'ชื่อยุทธศาสตร์', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`strategyChild5\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`strategyChild5Name\` varchar(255) NULL COMMENT 'กลยุทธ์ที่', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', \`strategyChild2Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2', \`strategyChild3Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3', \`strategyChild4Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD CONSTRAINT \`FK_0066b72a1b1e1832ee4e19f1962\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD CONSTRAINT \`FK_f22f3637349caf8ba4e96bef6a6\` FOREIGN KEY (\`strategyChild2Id\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD CONSTRAINT \`FK_a02975074aac7445aced33ab99d\` FOREIGN KEY (\`strategyChild3Id\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD CONSTRAINT \`FK_678c2b72214a00ba380affeb574\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD CONSTRAINT \`FK_441c2fc2b760d1d0dfb9faca4bc\` FOREIGN KEY (\`strategyChild2Id\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`strategyChild2\` ADD CONSTRAINT \`FK_5dd11a1dac02f7368d6cd5bba34\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_2f396ec33e0f571a4e913ca30f3\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_2c2a8b73ea0fa93ebbd4d81229b\` FOREIGN KEY (\`strategyChild2Id\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_67d08068d52226bb028a0d25d36\` FOREIGN KEY (\`strategyChild3Id\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_ad2b70c3a8955e67eec6ce85085\` FOREIGN KEY (\`strategyChild4Id\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_ad2b70c3a8955e67eec6ce85085\``); - await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_67d08068d52226bb028a0d25d36\``); - await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_2c2a8b73ea0fa93ebbd4d81229b\``); - await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_2f396ec33e0f571a4e913ca30f3\``); - await queryRunner.query(`ALTER TABLE \`strategyChild2\` DROP FOREIGN KEY \`FK_5dd11a1dac02f7368d6cd5bba34\``); - await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP FOREIGN KEY \`FK_441c2fc2b760d1d0dfb9faca4bc\``); - await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP FOREIGN KEY \`FK_678c2b72214a00ba380affeb574\``); - await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP FOREIGN KEY \`FK_a02975074aac7445aced33ab99d\``); - await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP FOREIGN KEY \`FK_f22f3637349caf8ba4e96bef6a6\``); - await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP FOREIGN KEY \`FK_0066b72a1b1e1832ee4e19f1962\``); - await queryRunner.query(`DROP TABLE \`strategyChild5\``); - await queryRunner.query(`DROP TABLE \`strategyChild1\``); - await queryRunner.query(`DROP TABLE \`strategyChild2\``); - await queryRunner.query(`DROP TABLE \`strategyChild3\``); - await queryRunner.query(`DROP TABLE \`strategyChild4\``); - } - -} diff --git a/src/migration/1712815316667-add_table_starty1.ts b/src/migration/1712815316667-add_table_starty1.ts deleted file mode 100644 index 3a5d95f..0000000 --- a/src/migration/1712815316667-add_table_starty1.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableStarty11712815316667 implements MigrationInterface { - name = 'AddTableStarty11712815316667' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`developmentProjectTechniquePlanned\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`developmentProjectTechniqueActual\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'เทคนิควิธีการที่ใช้ในการพัฒนา', \`developmentId\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` ADD CONSTRAINT \`FK_7166cc94112552ea072a2cc6134\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` ADD CONSTRAINT \`FK_aaaee1c5fb44bef093ed78a0c32\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` DROP FOREIGN KEY \`FK_aaaee1c5fb44bef093ed78a0c32\``); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` DROP FOREIGN KEY \`FK_7166cc94112552ea072a2cc6134\``); - await queryRunner.query(`DROP TABLE \`developmentProjectTechniqueActual\``); - await queryRunner.query(`DROP TABLE \`developmentProjectTechniquePlanned\``); - } - -} diff --git a/src/migration/1712824449740-update_table_developmentScholarship_add_planType.ts b/src/migration/1712824449740-update_table_developmentScholarship_add_planType.ts deleted file mode 100644 index e9bce7e..0000000 --- a/src/migration/1712824449740-update_table_developmentScholarship_add_planType.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentScholarshipAddPlanType1712824449740 implements MigrationInterface { - name = 'UpdateTableDevelopmentScholarshipAddPlanType1712824449740' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`planType\` varchar(40) NULL COMMENT 'ในแผนฯ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isNoUseBudget\` tinyint NOT NULL COMMENT 'ไม่ใช้งบประมาณ' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`governmentDate\` datetime NULL COMMENT 'กลับเข้ารับราชการตั้งแต่'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isGraduated\` tinyint NOT NULL COMMENT 'สำเร็จการศึกษาตามที่หลักสูตรกำหนด' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`graduatedDate\` datetime NULL COMMENT 'ตั้งแต่'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isNoGraduated\` tinyint NOT NULL COMMENT 'เสร็จสิ้นการศึกษาตามที่หลักสูตรกำหนดแล้วแต่ยังไม่สำเร็จการศึกษา' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`graduatedReason\` varchar(255) NULL COMMENT 'เนื่องจาก'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`graduatedReason\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isNoGraduated\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`graduatedDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isGraduated\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`governmentDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isNoUseBudget\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`planType\``); - } - -} diff --git a/src/migration/1712904313381-update_table_development_add_root.ts b/src/migration/1712904313381-update_table_development_add_root.ts deleted file mode 100644 index 1644d26..0000000 --- a/src/migration/1712904313381-update_table_development_add_root.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentAddRoot1712904313381 implements MigrationInterface { - name = 'UpdateTableDevelopmentAddRoot1712904313381' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`root\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootId\``); - } - -} diff --git a/src/migration/1712904744359-update_table_development_add_rootshortname.ts b/src/migration/1712904744359-update_table_development_add_rootshortname.ts deleted file mode 100644 index 2fa0f19..0000000 --- a/src/migration/1712904744359-update_table_development_add_rootshortname.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentAddRootshortname1712904744359 implements MigrationInterface { - name = 'UpdateTableDevelopmentAddRootshortname1712904744359' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRevisionId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRootShortName\``); - } - -} diff --git a/src/migration/1712927871127-update_table_development_add_strategyChild.ts b/src/migration/1712927871127-update_table_development_add_strategyChild.ts deleted file mode 100644 index 69dda24..0000000 --- a/src/migration/1712927871127-update_table_development_add_strategyChild.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentAddStrategyChild1712927871127 implements MigrationInterface { - name = 'UpdateTableDevelopmentAddStrategyChild1712927871127' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild1PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามแผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild2PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามแผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild3PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามแผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild4PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามแผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild5PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามแผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild1ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามจริง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild2ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามจริง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild3ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามจริง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild4ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามจริง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild5ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามจริง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_10ff41d23b977cf8dce92e9b167\` FOREIGN KEY (\`strategyChild1PlannedId\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_593bc4c0cda43a2bee2928bda49\` FOREIGN KEY (\`strategyChild2PlannedId\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_231ce173640401d258c977aae79\` FOREIGN KEY (\`strategyChild3PlannedId\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_44fb0c37a11d7ad9b8ca98aaa08\` FOREIGN KEY (\`strategyChild4PlannedId\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_4cd86d57223a295e6de3c42cb61\` FOREIGN KEY (\`strategyChild5PlannedId\`) REFERENCES \`strategyChild5\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_a54d96cd5fda35d92815f7f65eb\` FOREIGN KEY (\`strategyChild1ActualId\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_8a8b6b92dfd3f78d012300524df\` FOREIGN KEY (\`strategyChild2ActualId\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_9ee4f1c6a2f2c86760da928f01a\` FOREIGN KEY (\`strategyChild3ActualId\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_adf3d238b02f5806c9ed1e9b90b\` FOREIGN KEY (\`strategyChild4ActualId\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_f078e198298457e517c8d90e337\` FOREIGN KEY (\`strategyChild5ActualId\`) REFERENCES \`strategyChild5\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_f078e198298457e517c8d90e337\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_adf3d238b02f5806c9ed1e9b90b\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_9ee4f1c6a2f2c86760da928f01a\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_8a8b6b92dfd3f78d012300524df\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_a54d96cd5fda35d92815f7f65eb\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_4cd86d57223a295e6de3c42cb61\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_44fb0c37a11d7ad9b8ca98aaa08\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_231ce173640401d258c977aae79\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_593bc4c0cda43a2bee2928bda49\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_10ff41d23b977cf8dce92e9b167\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild5ActualId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild4ActualId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild3ActualId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild2ActualId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild1ActualId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild5PlannedId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild4PlannedId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild3PlannedId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild2PlannedId\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild1PlannedId\``); - } - -} diff --git a/src/migration/1712930900458-update_table_development_add_strategyChild1.ts b/src/migration/1712930900458-update_table_development_add_strategyChild1.ts deleted file mode 100644 index f96285a..0000000 --- a/src/migration/1712930900458-update_table_development_add_strategyChild1.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentAddStrategyChild11712930900458 implements MigrationInterface { - name = 'UpdateTableDevelopmentAddStrategyChild11712930900458' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`isDone\` tinyint NOT NULL COMMENT 'บันทึกลงทะเบียนประวัติ' DEFAULT 0`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`isDone\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`orgRevisionId\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`orgRootShortName\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`root\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`rootId\``); - } - -} diff --git a/src/migration/1713012352435-update_table_developmentscholar_add_rootid.ts b/src/migration/1713012352435-update_table_developmentscholar_add_rootid.ts deleted file mode 100644 index 734ee75..0000000 --- a/src/migration/1713012352435-update_table_developmentscholar_add_rootid.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentscholarAddRootid1713012352435 implements MigrationInterface { - name = 'UpdateTableDevelopmentscholarAddRootid1713012352435' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`orgRevisionId\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`orgRootShortName\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`root\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`rootId\``); - } - -} diff --git a/src/migration/1713014657464-update_table_developmentscholar_date_to_datetime.ts b/src/migration/1713014657464-update_table_developmentscholar_date_to_datetime.ts deleted file mode 100644 index 8e468ea..0000000 --- a/src/migration/1713014657464-update_table_developmentscholar_date_to_datetime.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentscholarDateToDatetime1713014657464 implements MigrationInterface { - name = 'UpdateTableDevelopmentscholarDateToDatetime1713014657464' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNoDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNoDate\` datetime NULL COMMENT 'ลงวันที่(หนังสือ)'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookApproveDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookApproveDate\` datetime NULL COMMENT 'หนังสืออนุมัติเมื่อวันที่'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`contractDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`contractDate\` datetime NULL COMMENT 'ลงวันที่(เลขที่สัญญา)'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackNoDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackNoDate\` datetime NULL COMMENT 'ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackDate\` datetime NULL COMMENT 'รายงานตัวกลับวันที่'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackDate\` date NULL COMMENT 'รายงานตัวกลับวันที่'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackNoDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackNoDate\` date NULL COMMENT 'ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`contractDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`contractDate\` date NULL COMMENT 'ลงวันที่(เลขที่สัญญา)'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookApproveDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookApproveDate\` date NULL COMMENT 'หนังสืออนุมัติเมื่อวันที่'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNoDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNoDate\` date NULL COMMENT 'ลงวันที่(หนังสือ)'`); - } - -} diff --git a/src/migration/1713163199894-update_table_developmentHistory_add_profileId.ts b/src/migration/1713163199894-update_table_developmentHistory_add_profileId.ts deleted file mode 100644 index 32b0753..0000000 --- a/src/migration/1713163199894-update_table_developmentHistory_add_profileId.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentHistoryAddProfileId1713163199894 implements MigrationInterface { - name = 'UpdateTableDevelopmentHistoryAddProfileId1713163199894' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`profileId\` varchar(40) NULL COMMENT 'id profile'`); - await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`profileId\``); - } - -} diff --git a/src/migration/1713179439957-update_table_developmentHistory_add_trainingDays.ts b/src/migration/1713179439957-update_table_developmentHistory_add_trainingDays.ts deleted file mode 100644 index 34f36e9..0000000 --- a/src/migration/1713179439957-update_table_developmentHistory_add_trainingDays.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevelopmentHistoryAddTrainingDays1713179439957 implements MigrationInterface { - name = 'UpdateTableDevelopmentHistoryAddTrainingDays1713179439957' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`trainingDays\` varchar(255) NULL COMMENT 'จำนวนวันที่อบรม'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`trainingDays\``); - } - -} diff --git a/src/migration/1713332483208-update_table_dev_add_governmentEndDate.ts b/src/migration/1713332483208-update_table_dev_add_governmentEndDate.ts deleted file mode 100644 index 4b62df6..0000000 --- a/src/migration/1713332483208-update_table_dev_add_governmentEndDate.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevAddGovernmentEndDate1713332483208 implements MigrationInterface { - name = 'UpdateTableDevAddGovernmentEndDate1713332483208' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNumber\` varchar(255) NULL COMMENT 'เลขที่หนังสือรายงานตัวกลับเข้าปฏิบัติราชการ'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookDate\` datetime NULL COMMENT ' หนังสือรายงานตัวกลับเข้าปฏิบัติราชการลงวันที่'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`governmentEndDate\` datetime NULL COMMENT 'วันสิ้นสุดภาระผูกพัน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`governmentDate\` \`governmentDate\` datetime NULL COMMENT 'วันที่กลับเข้าปฏิบัติราชการ'`); - await queryRunner.query(`ALTER TABLE \`strategyChild5\` CHANGE \`strategyChild5Name\` \`strategyChild5Name\` varchar(255) NULL COMMENT 'กลยุทธ์ที่/เป้าประสงค์ที่'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`strategyChild5\` CHANGE \`strategyChild5Name\` \`strategyChild5Name\` varchar(255) NULL COMMENT 'กลยุทธ์ที่'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`governmentDate\` \`governmentDate\` datetime NULL COMMENT 'กลับเข้ารับราชการตั้งแต่'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`governmentEndDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookDate\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNumber\``); - } - -} diff --git a/src/migration/1713334672151-update_table_dev_add_governmentEndDate1.ts b/src/migration/1713334672151-update_table_dev_add_governmentEndDate1.ts deleted file mode 100644 index 07d2359..0000000 --- a/src/migration/1713334672151-update_table_dev_add_governmentEndDate1.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevAddGovernmentEndDate11713334672151 implements MigrationInterface { - name = 'UpdateTableDevAddGovernmentEndDate11713334672151' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`isNoGraduated\``); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`isNoGraduated\` tinyint NOT NULL COMMENT 'เสร็จสิ้นการศึกษาตามที่หลักสูตรกำหนดแล้วแต่ยังไม่สำเร็จการศึกษา' DEFAULT '0'`); - } - -} diff --git a/src/migration/1713338710965-update_table_dev_add_governmentEndDate2.ts b/src/migration/1713338710965-update_table_dev_add_governmentEndDate2.ts deleted file mode 100644 index a0f4111..0000000 --- a/src/migration/1713338710965-update_table_dev_add_governmentEndDate2.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevAddGovernmentEndDate21713338710965 implements MigrationInterface { - name = 'UpdateTableDevAddGovernmentEndDate21713338710965' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectModal\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectModalPlanned\` int NULL COMMENT 'จำนวน(รุ่น)ตามแผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectModalActual\` int NULL COMMENT 'จำนวน(รุ่น)ตามจริง'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectModalActual\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectModalPlanned\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectModal\` int NULL COMMENT 'จำนวน(รุ่น)'`); - } - -} diff --git a/src/migration/1713340723367-update_table_devhis_add_dateStart.ts b/src/migration/1713340723367-update_table_devhis_add_dateStart.ts deleted file mode 100644 index 1b3d4c7..0000000 --- a/src/migration/1713340723367-update_table_devhis_add_dateStart.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevhisAddDateStart1713340723367 implements MigrationInterface { - name = 'UpdateTableDevhisAddDateStart1713340723367' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateStart\` datetime NULL COMMENT 'วันที่เริ่มต้น'`); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`dateEnd\` datetime NULL COMMENT 'วันที่สิ้นสุด'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateEnd\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`dateStart\``); - } - -} diff --git a/src/migration/1713341677475-update_table_devhis_add_type.ts b/src/migration/1713341677475-update_table_devhis_add_type.ts deleted file mode 100644 index 3446563..0000000 --- a/src/migration/1713341677475-update_table_devhis_add_type.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevhisAddType1713341677475 implements MigrationInterface { - name = 'UpdateTableDevhisAddType1713341677475' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`plannedGoal\` ADD \`type\` varchar(255) NULL COMMENT 'ประเภท(กลุ่มอาชีพ คุณสมบัติ)'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`plannedGoal\` DROP COLUMN \`type\``); - } - -} diff --git a/src/migration/1713347839774-update_table_devhis_add_org.ts b/src/migration/1713347839774-update_table_devhis_add_org.ts deleted file mode 100644 index 029260d..0000000 --- a/src/migration/1713347839774-update_table_devhis_add_org.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevhisAddOrg1713347839774 implements MigrationInterface { - name = 'UpdateTableDevhisAddOrg1713347839774' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`org\` varchar(255) NULL COMMENT 'ชื่อหน่วยงานที่สังกัด'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`org\` varchar(255) NULL COMMENT 'ชื่อหน่วยงานที่สังกัด'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`org\``); - await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`org\``); - } - -} diff --git a/src/migration/1713366798329-update_table_dev_add_child1.ts b/src/migration/1713366798329-update_table_dev_add_child1.ts deleted file mode 100644 index ff3817b..0000000 --- a/src/migration/1713366798329-update_table_dev_add_child1.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevAddChild11713366798329 implements MigrationInterface { - name = 'UpdateTableDevAddChild11713366798329' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`orgRootShortName\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child1'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child1'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child1'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child2'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child2'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child2'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child3'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child3'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child3'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child4'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child4'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child4'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4ShortName\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4Id\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3ShortName\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3Id\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2ShortName\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2Id\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1ShortName\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1Id\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootShortName\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); - } - -} diff --git a/src/migration/1713431125506-update_table_devscholar_add_guarantorOrg.ts b/src/migration/1713431125506-update_table_devscholar_add_guarantorOrg.ts deleted file mode 100644 index 7d2ff87..0000000 --- a/src/migration/1713431125506-update_table_devscholar_add_guarantorOrg.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevscholarAddGuarantorOrg1713431125506 implements MigrationInterface { - name = 'UpdateTableDevscholarAddGuarantorOrg1713431125506' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRoot\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorOrg\` varchar(255) NULL COMMENT 'ชื่อหน่วยงานที่สังกัด'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorOrgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorOrgRevisionId\` varchar(255) NULL COMMENT 'id revision'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorOrgRevisionId\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorOrgRootShortName\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorOrg\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRoot\``); - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRootId\``); - } - -} diff --git a/src/migration/1716270845115-update_table_dev_reason_text.ts b/src/migration/1716270845115-update_table_dev_reason_text.ts deleted file mode 100644 index ca35c0c..0000000 --- a/src/migration/1716270845115-update_table_dev_reason_text.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableDevReasonText1716270845115 implements MigrationInterface { - name = 'UpdateTableDevReasonText1716270845115' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reason\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reason\` text NULL COMMENT 'หลักการและเหตุผล'`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`objective\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`objective\` text NULL COMMENT 'วัตถุประสงค์'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`objective\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`objective\` varchar(255) NULL COMMENT 'วัตถุประสงค์'`); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reason\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reason\` varchar(255) NULL COMMENT 'หลักการและเหตุผล'`); - } - -} diff --git a/src/migration/1719477296897-add_table_Portfolio.ts b/src/migration/1719477296897-add_table_Portfolio.ts deleted file mode 100644 index e904ba2..0000000 --- a/src/migration/1719477296897-add_table_Portfolio.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTablePortfolio1719477296897 implements MigrationInterface { - name = 'AddTablePortfolio1719477296897' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`portfolio\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`name\` varchar(255) NULL COMMENT 'ชื่อเอกสาร/ผลงาน', \`detail\` varchar(255) NULL COMMENT 'รายละเอียดเอกสาร/ผลงาน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP TABLE \`portfolio\``); - } - -} diff --git a/src/migration/1720165194013-update_field.ts b/src/migration/1720165194013-update_field.ts deleted file mode 100644 index aa53008..0000000 --- a/src/migration/1720165194013-update_field.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateField1720165194013 implements MigrationInterface { - name = 'UpdateField1720165194013' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`portfolio\` DROP COLUMN \`detail\``); - await queryRunner.query(`ALTER TABLE \`portfolio\` ADD \`detail\` longtext NULL COMMENT 'รายละเอียดเอกสาร/ผลงาน'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`portfolio\` DROP COLUMN \`detail\``); - await queryRunner.query(`ALTER TABLE \`portfolio\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียดเอกสาร/ผลงาน'`); - } - -} diff --git a/src/migration/1720174912913-add_table_dev1.ts b/src/migration/1720174912913-add_table_dev1.ts deleted file mode 100644 index 9b89534..0000000 --- a/src/migration/1720174912913-add_table_dev1.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDev11720174912913 implements MigrationInterface { - name = 'AddTableDev11720174912913' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียด'`); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียด'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` DROP COLUMN \`detail\``); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` DROP COLUMN \`detail\``); - } - -} diff --git a/src/migration/1720175549705-add_table_dev2.ts b/src/migration/1720175549705-add_table_dev2.ts deleted file mode 100644 index 4204f05..0000000 --- a/src/migration/1720175549705-add_table_dev2.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDev21720175549705 implements MigrationInterface { - name = 'AddTableDev21720175549705' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` DROP COLUMN \`detail\``); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` DROP COLUMN \`detail\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ แผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ จริง'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned\``); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniqueActual\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียด'`); - await queryRunner.query(`ALTER TABLE \`developmentProjectTechniquePlanned\` ADD \`detail\` varchar(255) NULL COMMENT 'รายละเอียด'`); - } - -} diff --git a/src/migration/1721053734191-add_table_dev_add_reasonActual70.ts b/src/migration/1721053734191-add_table_dev_add_reasonActual70.ts deleted file mode 100644 index 09d2fff..0000000 --- a/src/migration/1721053734191-add_table_dev_add_reasonActual70.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTableDevAddReasonActual701721053734191 implements MigrationInterface { - name = 'AddTableDevAddReasonActual701721053734191' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned70\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 70 แผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned20\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 20 แผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual70\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 70 จริง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual20\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 20 จริง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual10\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual20\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonActual70\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned10\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned20\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`reasonPlanned70\``); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonActual\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ จริง'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`reasonPlanned\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ แผน'`); - } - -} diff --git a/src/migration/1750083465733-update30062025604.ts b/src/migration/1750083465733-update30062025604.ts deleted file mode 100644 index 8fcdedc..0000000 --- a/src/migration/1750083465733-update30062025604.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Update300620256041750083465733 implements MigrationInterface { - name = 'Update300620256041750083465733' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id dna หน่วยงาน'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`rootDnaId\``); - } - -} diff --git a/src/migration/1750083913468-update30062025605.ts b/src/migration/1750083913468-update30062025605.ts deleted file mode 100644 index 644e8c2..0000000 --- a/src/migration/1750083913468-update30062025605.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Update300620256051750083913468 implements MigrationInterface { - name = 'Update300620256051750083913468' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRootDnaId\``); - } - -} diff --git a/tsoa.json b/tsoa.json index 3475583..5bbc1e5 100644 --- a/tsoa.json +++ b/tsoa.json @@ -28,18 +28,6 @@ "tags": [ { "name": "Test", "description": "สำหรับทดสอบ" - }, - { - "name": "Development", "description": "ชื่อโครงการ/กิจกรรม/หลักสูตร" - }, - { - "name": "DevelopmentOfficerHistory", "description": "ประวัติการฝึกอบรม/ดูงาน ขรก." - }, - { - "name": "DevelopmentEmployeeHistory", "description": "ประวัติการฝึกอบรม/ดูงานลูกจ้าง." - }, - { - "name": "DevelopmentScholarship", "description": "ทุนการศึกษา/ฝึกอบรม" } ] },