first commit
This commit is contained in:
commit
ca411740e1
8
.env
Normal file
8
.env
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
POSTGRES_HOST=127.0.0.1
|
||||||
|
POSTGRES_PORT=5432
|
||||||
|
POSTGRES_USER=postgres
|
||||||
|
POSTGRES_PASSWORD=postgres
|
||||||
|
POSTGRES_DATABASE=wastecare
|
||||||
|
PORT=3000
|
||||||
|
MODE=DEV
|
||||||
|
RUN_MIGRATIONS=false
|
||||||
24
.eslintrc.js
Normal file
24
.eslintrc.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
module.exports = {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
project: 'tsconfig.json',
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||||
|
extends: [
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
],
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
jest: true,
|
||||||
|
},
|
||||||
|
ignorePatterns: ['.eslintrc.js'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
},
|
||||||
|
};
|
||||||
36
.gitignore
vendored
Normal file
36
.gitignore
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# compiled output
|
||||||
|
/dist
|
||||||
|
/node_modules
|
||||||
|
/uploads/*
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
/coverage
|
||||||
|
/.nyc_output
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
1
Insomnia_2024-01-21.json
Normal file
1
Insomnia_2024-01-21.json
Normal file
File diff suppressed because one or more lines are too long
73
README.md
Normal file
73
README.md
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<p align="center">
|
||||||
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||||
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||||
|
|
||||||
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||||
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||||
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||||
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||||
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||||
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||||
|
</p>
|
||||||
|
<!--[](https://opencollective.com/nest#backer)
|
||||||
|
[](https://opencollective.com/nest#sponsor)-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the app
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# development
|
||||||
|
$ npm run start
|
||||||
|
|
||||||
|
# watch mode
|
||||||
|
$ npm run start:dev
|
||||||
|
|
||||||
|
# production mode
|
||||||
|
$ npm run start:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# unit tests
|
||||||
|
$ npm run test
|
||||||
|
|
||||||
|
# e2e tests
|
||||||
|
$ npm run test:e2e
|
||||||
|
|
||||||
|
# test coverage
|
||||||
|
$ npm run test:cov
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||||
|
|
||||||
|
## Stay in touch
|
||||||
|
|
||||||
|
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||||
|
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||||
|
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Nest is [MIT licensed](LICENSE).
|
||||||
1
config/system.config.json
Normal file
1
config/system.config.json
Normal file
File diff suppressed because one or more lines are too long
203
create table assessment microservice.sql
Normal file
203
create table assessment microservice.sql
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
CREATE TABLE "test" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"userId" BIGINT,
|
||||||
|
"title" TEXT,
|
||||||
|
"description" TEXT,
|
||||||
|
"textbookId" BIGINT,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "test_detail" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"testId" BIGINT,
|
||||||
|
"questionType" TEXT,
|
||||||
|
"hardness" NUMERIC,
|
||||||
|
"count" NUMERIC,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "question" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"content" TEXT,
|
||||||
|
"questionType" TEXT,
|
||||||
|
"hardness" NUMERIC,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "test_question_rel" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"testId" BIGINT,
|
||||||
|
"questionId" BIGINT,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "test_assign" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"testId" BIGINT,
|
||||||
|
"userId" BIGINT,
|
||||||
|
"assignedAt" DATE,
|
||||||
|
"startTime" DATE,
|
||||||
|
"endTime" DATE,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "user_answers" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"testId" BIGINT,
|
||||||
|
"userId" BIGINT,
|
||||||
|
"questionId" BIGINT,
|
||||||
|
"answers" TEXT,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "results" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"testId" BIGINT,
|
||||||
|
"userId" BIGINT,
|
||||||
|
"score" NUMERIC,
|
||||||
|
"passing" BOOLEAN,
|
||||||
|
"description" TEXT,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "feedback" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"testId" BIGINT,
|
||||||
|
"userId" BIGINT,
|
||||||
|
"feedbackText" TEXT,
|
||||||
|
"rating" NUMERIC,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "question_tag" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"questionId" BIGINT,
|
||||||
|
"tagName" TEXT,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE "question_additional_details" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"questionId" BIGINT,
|
||||||
|
"addlDataType" TEXT,
|
||||||
|
"addlDataName" TEXT,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "test_tag" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"testId" BIGINT,
|
||||||
|
"tagName" TEXT,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "test_additional_details" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"testId" BIGINT,
|
||||||
|
"addlDataType" TEXT,
|
||||||
|
"addlDataName" TEXT,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE "ranking" (
|
||||||
|
"id" BIGSERIAL PRIMARY KEY,
|
||||||
|
"bookId" BIGINT,
|
||||||
|
"testId" BIGINT,
|
||||||
|
"userId" BIGINT,
|
||||||
|
"rank" NUMERIC,
|
||||||
|
"validFrom" DATE,
|
||||||
|
"validTill" DATE,
|
||||||
|
"createdAt" DATE,
|
||||||
|
"updatedAt" DATE,
|
||||||
|
"createdBy" TEXT,
|
||||||
|
"modifiedBy" TEXT,
|
||||||
|
"deletedAt" DATE,
|
||||||
|
"version" NUMERIC,
|
||||||
|
"status" TEXT
|
||||||
|
);
|
||||||
283
dump-wastecare-202401222136.sql
Normal file
283
dump-wastecare-202401222136.sql
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
CREATE TABLE public.actions_ref (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"appCode" text,
|
||||||
|
"actionCode" text,
|
||||||
|
"actionName" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE public.apps_ref (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"appCode" text,
|
||||||
|
"appName" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.companies (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"companyCode" text,
|
||||||
|
"companyName" text,
|
||||||
|
address text,
|
||||||
|
gst text,
|
||||||
|
status text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.company_details (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"companyId" numeric,
|
||||||
|
"companyCode" text,
|
||||||
|
"addlDataType" text,
|
||||||
|
"addlDataName" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE public.crud_config_info (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"endPtNm" text,
|
||||||
|
"opsTypeName" text,
|
||||||
|
"sqlQueryText" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE public.item_category_ref (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"categoryName" text,
|
||||||
|
"categoryCode" text,
|
||||||
|
"categoryDescription" text,
|
||||||
|
"parentCode" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.items_ref (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"itemCode" text,
|
||||||
|
"itemName" text,
|
||||||
|
"itemCategoryCode" text,
|
||||||
|
"itemDesc" text,
|
||||||
|
"parentCode" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.policies_ref (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"appCode" text,
|
||||||
|
"roleCode" text,
|
||||||
|
"resourceCode" text,
|
||||||
|
"actionCode" text,
|
||||||
|
"canAllow" boolean,
|
||||||
|
priority boolean,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.resources_ref (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"appCode" text,
|
||||||
|
"resourceCode" text,
|
||||||
|
"resourceName" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.roles_ref (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"appCode" text,
|
||||||
|
"roleCode" text,
|
||||||
|
"roleName" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE public.user_additional_details (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"userId" numeric,
|
||||||
|
"addlDataType" text,
|
||||||
|
"addlDataName" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.users (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
email text,
|
||||||
|
password text,
|
||||||
|
name text,
|
||||||
|
"userTypeCode" text,
|
||||||
|
"primaryRole" text,
|
||||||
|
"companyCode" text,
|
||||||
|
status text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.master_config_category_ref (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"categoryName" text,
|
||||||
|
"categoryCode" text,
|
||||||
|
"categoryDescription" text,
|
||||||
|
"categoryType" text,
|
||||||
|
"parentCode" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.master_config_ref (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"configCode" text,
|
||||||
|
"configName" text,
|
||||||
|
"configCategoryCode" text,
|
||||||
|
"configDesc" text,
|
||||||
|
"parentCode" text,
|
||||||
|
"configType" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.master_config_mapping (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"configCode" text,
|
||||||
|
"companyCode" text,
|
||||||
|
"status" text,
|
||||||
|
"dispSerialNumber" text,
|
||||||
|
"defaultValue" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE public.config_transcations (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"configCode" text,
|
||||||
|
"companyCode" text,
|
||||||
|
"itemCategoryCode" text,
|
||||||
|
"itemCode" text,
|
||||||
|
"status" text,
|
||||||
|
"value" text,
|
||||||
|
"fileUrl" text,
|
||||||
|
"weight" numeric,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE public.config_logs (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"tableName" text,
|
||||||
|
"prevValue" text,
|
||||||
|
"currValue" text,
|
||||||
|
"validFrom" date,
|
||||||
|
"validTill" date,
|
||||||
|
"createdAt" date,
|
||||||
|
"updatedAt" date,
|
||||||
|
"createBy" text,
|
||||||
|
"modifiedBy" text,
|
||||||
|
"deletedAt" date,
|
||||||
|
version numeric
|
||||||
|
)
|
||||||
10
nest-cli.json
Normal file
10
nest-cli.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/nest-cli",
|
||||||
|
"collection": "@nestjs/schematics",
|
||||||
|
"sourceRoot": "src",
|
||||||
|
"compilerOptions": {
|
||||||
|
"deleteOutDir": true,
|
||||||
|
"assets": ["mail/templates/**/*"],
|
||||||
|
"watchAssets": true
|
||||||
|
}
|
||||||
|
}
|
||||||
11
nodemon.json
Normal file
11
nodemon.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"watch": [
|
||||||
|
"src"
|
||||||
|
],
|
||||||
|
"ext": "ts",
|
||||||
|
"ignore": [
|
||||||
|
"src/**/*.spec.ts"
|
||||||
|
],
|
||||||
|
"exec": "node --inspect=127.0.0.1:9223 -r ts-node/register -- src/main.ts",
|
||||||
|
"env": {}
|
||||||
|
}
|
||||||
20337
package-lock.json
generated
Normal file
20337
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
88
package.json
Normal file
88
package.json
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
{
|
||||||
|
"name": "abnandan-skeleton-be",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"author": "",
|
||||||
|
"private": true,
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"scripts": {
|
||||||
|
"build": "node script-util.js config.local.json config.json && nest build",
|
||||||
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
|
"start": "node script-util.js config.local.json config.json && nest start",
|
||||||
|
"start:local": "node script-util.js config.local.json config.json && nest start --watch",
|
||||||
|
"start:debug": "node script-util.js config.local.json config.json && nest start --debug --watch",
|
||||||
|
"start:prod": "node dist/main",
|
||||||
|
"build:dev": "node script-util.js config.dev.json config.json && nest build && cp package.json dist/package.json && cp -r config dist/",
|
||||||
|
"build:prod": "node script-util.js config.prod.json config.json && nest build && cp package.json dist/package.json && cp -r config dist/",
|
||||||
|
"build:test": "node script-util.js config.test.json config.json && nest build && cp package.json dist/package.json && cp -r config dist/",
|
||||||
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
|
"test": "jest",
|
||||||
|
"test:watch": "jest --watch",
|
||||||
|
"test:cov": "jest --coverage",
|
||||||
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||||
|
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nestjs-modules/mailer": "^1.10.3",
|
||||||
|
"@nestjs/common": "^10.0.0",
|
||||||
|
"@nestjs/config": "^3.1.1",
|
||||||
|
"@nestjs/core": "^10.0.0",
|
||||||
|
"@nestjs/platform-express": "^10.0.0",
|
||||||
|
"@nestjs/typeorm": "^10.0.1",
|
||||||
|
"dotenv": "^16.3.1",
|
||||||
|
"handlebars": "^4.7.8",
|
||||||
|
"moment": "^2.30.1",
|
||||||
|
"nodemailer": "^6.9.9",
|
||||||
|
"otp-generator": "^4.0.1",
|
||||||
|
"pg": "^8.11.3",
|
||||||
|
"reflect-metadata": "^0.1.14",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
|
"sequelize": "^6.35.2",
|
||||||
|
"sequelize-typescript": "^2.1.6",
|
||||||
|
"typeorm": "^0.3.17"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nestjs/cli": "^10.0.0",
|
||||||
|
"@nestjs/schematics": "^10.0.0",
|
||||||
|
"@nestjs/testing": "^10.0.0",
|
||||||
|
"@types/express": "^4.17.17",
|
||||||
|
"@types/jest": "^29.5.2",
|
||||||
|
"@types/multer": "^1.4.11",
|
||||||
|
"@types/node": "^20.10.6",
|
||||||
|
"@types/nodemailer": "^6.4.14",
|
||||||
|
"@types/supertest": "^2.0.12",
|
||||||
|
"@types/validator": "^13.11.7",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||||
|
"@typescript-eslint/parser": "^6.0.0",
|
||||||
|
"eslint": "^8.42.0",
|
||||||
|
"eslint-config-prettier": "^9.0.0",
|
||||||
|
"eslint-plugin-prettier": "^5.0.0",
|
||||||
|
"jest": "^29.5.0",
|
||||||
|
"nodemon": "^3.0.2",
|
||||||
|
"prettier": "^3.0.0",
|
||||||
|
"source-map-support": "^0.5.21",
|
||||||
|
"supertest": "^6.3.3",
|
||||||
|
"ts-jest": "^29.1.0",
|
||||||
|
"ts-loader": "^9.4.3",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"tsconfig-paths": "^4.2.0",
|
||||||
|
"typescript": "^5.1.3"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"rootDir": "src",
|
||||||
|
"testRegex": ".*\\.spec\\.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
},
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"**/*.(t|j)s"
|
||||||
|
],
|
||||||
|
"coverageDirectory": "../coverage",
|
||||||
|
"testEnvironment": "node"
|
||||||
|
}
|
||||||
|
}
|
||||||
11
script-util.js
Normal file
11
script-util.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
|
|
||||||
|
// Import the required modules
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// Get the source and destination file paths from the command-line arguments
|
||||||
|
const sourcePath = `src/app-config/${process.argv[2]}`;
|
||||||
|
const destinationPath = `src/app-config/${process.argv[3]}`;
|
||||||
|
|
||||||
|
// Read the source file
|
||||||
|
fs.writeFileSync(destinationPath, fs.readFileSync(sourcePath));
|
||||||
18
src/app-config/app-config.controller.spec.ts
Normal file
18
src/app-config/app-config.controller.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AppConfigController } from './app-config.controller';
|
||||||
|
|
||||||
|
describe('AppConfigController', () => {
|
||||||
|
let controller: AppConfigController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [AppConfigController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<AppConfigController>(AppConfigController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
41
src/app-config/app-config.controller.ts
Normal file
41
src/app-config/app-config.controller.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Controller, Get, Post, Query, Req, Res } from '@nestjs/common';
|
||||||
|
import { getFile, updateFile } from './file.util';
|
||||||
|
import { Request, Response } from 'express';
|
||||||
|
import { Utility } from 'src/common/Utility';
|
||||||
|
@Controller('app-config')
|
||||||
|
export class AppConfigController {
|
||||||
|
@Get('/')
|
||||||
|
async get(@Req() req: Request, @Query() query, @Res() res: Response) {
|
||||||
|
console.log('Inside Config Controller GET', query);
|
||||||
|
const filePath = (query.path) ? `${Utility.fileConfig.configPath}/${query.path}` : `${Utility.fileConfig.configPath}`;
|
||||||
|
const response = await getFile(filePath, 'UTF-8');
|
||||||
|
return res.status(200).send(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/')
|
||||||
|
async post(@Req() req: Request, @Res() res: Response) {
|
||||||
|
const filePath = `${Utility.fileConfig.configPath}`;
|
||||||
|
const fileName = (req.body && req.body.fileName) ? req.body.fileName : null;
|
||||||
|
let data = (req.body && req.body.data) ? req.body.data : null;
|
||||||
|
let resultSet = {};
|
||||||
|
console.log('Inside Config Controller Post');
|
||||||
|
console.log(`File Path ${filePath}`);
|
||||||
|
console.log(`File Name ${fileName}`);
|
||||||
|
console.log(`File Data ${data}`);
|
||||||
|
|
||||||
|
if (!filePath || !fileName || !data) {
|
||||||
|
resultSet = {
|
||||||
|
exception: true,
|
||||||
|
exceptionMessage: 'Invalid Params',
|
||||||
|
exceptionSeverity: 'high'
|
||||||
|
}
|
||||||
|
return res.status(400).send(resultSet);
|
||||||
|
}
|
||||||
|
if(typeof data === 'object') {
|
||||||
|
data = JSON.stringify(data);
|
||||||
|
}
|
||||||
|
const response = await updateFile(filePath,fileName,data);
|
||||||
|
resultSet['result'] = response;
|
||||||
|
return res.status(200).send(resultSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/app-config/app-config.service.spec.ts
Normal file
18
src/app-config/app-config.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AppConfigService } from './app-config.service';
|
||||||
|
|
||||||
|
describe('AppConfigService', () => {
|
||||||
|
let service: AppConfigService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [AppConfigService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<AppConfigService>(AppConfigService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
44
src/app-config/app-config.service.ts
Normal file
44
src/app-config/app-config.service.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import * as configMaster from './config.json';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AppConfigService {
|
||||||
|
defaultEnv = 'local';
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private getValue(key: string, throwOnMissing = true): any {
|
||||||
|
const value = configMaster[this.defaultEnv].dbConfig[key];
|
||||||
|
if (!value && throwOnMissing) {
|
||||||
|
throw new Error(`config error - missing env.${key}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ensureValues(keys: string[]) {
|
||||||
|
keys.forEach(k => this.getValue(k, true));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getPort() {
|
||||||
|
return this.getValue('PORT', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public isProduction() {
|
||||||
|
const mode = this.getValue('MODE', false);
|
||||||
|
return mode != 'DEV';
|
||||||
|
}
|
||||||
|
|
||||||
|
getDbConfig() {
|
||||||
|
return configMaster[this.defaultEnv].dbConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeFileSystem() {
|
||||||
|
return configMaster[this.defaultEnv].fileConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
getMailConfig() {
|
||||||
|
return configMaster[this.defaultEnv].mailConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/app-config/config.dev.json
Normal file
34
src/app-config/config.dev.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"local": {
|
||||||
|
"appConfig": {
|
||||||
|
"port": 3003
|
||||||
|
},
|
||||||
|
"dbConfig": {
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 5432,
|
||||||
|
"user": "postgres",
|
||||||
|
"password": "postgres",
|
||||||
|
"database": "epr",
|
||||||
|
"MODE": "DEV",
|
||||||
|
"loggerEnabled": true
|
||||||
|
},
|
||||||
|
"fileConfig": {
|
||||||
|
"storagePath": "/opt/www/wastecare-uploads/dev",
|
||||||
|
"configPath": "/opt/wastecare/config/dev"
|
||||||
|
},
|
||||||
|
"mailConfig": {
|
||||||
|
"transport": {
|
||||||
|
"host": "smtppro.zoho.in",
|
||||||
|
"secure": true,
|
||||||
|
"port": 465,
|
||||||
|
"auth": {
|
||||||
|
"user": "admin@wct.co.in",
|
||||||
|
"pass": "Wastecare@123"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaults": {
|
||||||
|
"from": "\"No Reply\" <admin@wct.co.in>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/app-config/config.json
Normal file
34
src/app-config/config.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"local": {
|
||||||
|
"appConfig": {
|
||||||
|
"port": 3003
|
||||||
|
},
|
||||||
|
"dbConfig": {
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 5432,
|
||||||
|
"user": "postgres",
|
||||||
|
"password": "postgres",
|
||||||
|
"database": "remedify-assessment-local",
|
||||||
|
"MODE": "DEV",
|
||||||
|
"loggerEnabled": true
|
||||||
|
},
|
||||||
|
"fileConfig": {
|
||||||
|
"storagePath": "./uploads",
|
||||||
|
"configPath": "./config"
|
||||||
|
},
|
||||||
|
"mailConfig": {
|
||||||
|
"transport": {
|
||||||
|
"host": "smtppro.zoho.in",
|
||||||
|
"secure": true,
|
||||||
|
"port": 465,
|
||||||
|
"auth": {
|
||||||
|
"user": "admin@wct.co.in",
|
||||||
|
"pass": "Wastecare@123"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaults": {
|
||||||
|
"from": "\"No Reply\" <admin@wct.co.in>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/app-config/config.local.json
Normal file
34
src/app-config/config.local.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"local": {
|
||||||
|
"appConfig": {
|
||||||
|
"port": 3003
|
||||||
|
},
|
||||||
|
"dbConfig": {
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 5432,
|
||||||
|
"user": "postgres",
|
||||||
|
"password": "postgres",
|
||||||
|
"database": "remedify-assessment-local",
|
||||||
|
"MODE": "DEV",
|
||||||
|
"loggerEnabled": true
|
||||||
|
},
|
||||||
|
"fileConfig": {
|
||||||
|
"storagePath": "./uploads",
|
||||||
|
"configPath": "./config"
|
||||||
|
},
|
||||||
|
"mailConfig": {
|
||||||
|
"transport": {
|
||||||
|
"host": "smtppro.zoho.in",
|
||||||
|
"secure": true,
|
||||||
|
"port": 465,
|
||||||
|
"auth": {
|
||||||
|
"user": "admin@wct.co.in",
|
||||||
|
"pass": "Wastecare@123"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaults": {
|
||||||
|
"from": "\"No Reply\" <admin@wct.co.in>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/app-config/config.prod.json
Normal file
34
src/app-config/config.prod.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"local": {
|
||||||
|
"appConfig": {
|
||||||
|
"port": 3003
|
||||||
|
},
|
||||||
|
"dbConfig": {
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 5432,
|
||||||
|
"user": "postgres",
|
||||||
|
"password": "postgres",
|
||||||
|
"database": "epr",
|
||||||
|
"MODE": "PROD",
|
||||||
|
"loggerEnabled": true
|
||||||
|
},
|
||||||
|
"fileConfig": {
|
||||||
|
"storagePath": "/opt/www/wastecare-uploads/prod",
|
||||||
|
"configPath": "/opt/wastecare/config/prod"
|
||||||
|
},
|
||||||
|
"mailConfig": {
|
||||||
|
"transport": {
|
||||||
|
"host": "smtppro.zoho.in",
|
||||||
|
"secure": true,
|
||||||
|
"port": 465,
|
||||||
|
"auth": {
|
||||||
|
"user": "admin@wct.co.in",
|
||||||
|
"pass": "Wastecare@123"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaults": {
|
||||||
|
"from": "\"No Reply\" <admin@wct.co.in>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/app-config/config.test.json
Normal file
34
src/app-config/config.test.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"local": {
|
||||||
|
"appConfig": {
|
||||||
|
"port": 3003
|
||||||
|
},
|
||||||
|
"dbConfig": {
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 5432,
|
||||||
|
"user": "postgres",
|
||||||
|
"password": "postgres",
|
||||||
|
"database": "epr",
|
||||||
|
"MODE": "TEST",
|
||||||
|
"loggerEnabled": true
|
||||||
|
},
|
||||||
|
"fileConfig": {
|
||||||
|
"storagePath": "/opt/www/wastecare-uploads/test",
|
||||||
|
"configPath": "/opt/wastecare/config/test"
|
||||||
|
},
|
||||||
|
"mailConfig": {
|
||||||
|
"transport": {
|
||||||
|
"host": "smtppro.zoho.in",
|
||||||
|
"secure": true,
|
||||||
|
"port": 465,
|
||||||
|
"auth": {
|
||||||
|
"user": "admin@wct.co.in",
|
||||||
|
"pass": "Wastecare@123"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaults": {
|
||||||
|
"from": "\"No Reply\" <admin@wct.co.in>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
82
src/app-config/file.util.ts
Normal file
82
src/app-config/file.util.ts
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
// This file should exist in `src/common/helpers`
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import { promisify } from 'util';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a file exists at a given path.
|
||||||
|
*
|
||||||
|
* @param {string} path
|
||||||
|
*
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export const checkIfFileOrDirectoryExists = (path: string): boolean => {
|
||||||
|
return fs.existsSync(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets file data from a given path via a promise interface.
|
||||||
|
*
|
||||||
|
* @param {string} path
|
||||||
|
* @param {string} encoding
|
||||||
|
*
|
||||||
|
* @returns {Promise<Buffer>}
|
||||||
|
*/
|
||||||
|
export const getFile = async (
|
||||||
|
path: string,
|
||||||
|
encoding: string,
|
||||||
|
): Promise<string | Buffer> => {
|
||||||
|
const readFile = promisify(fs.readFile);
|
||||||
|
|
||||||
|
return encoding ? readFile(path) : readFile(path, {});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a file at a given path via a promise interface.
|
||||||
|
*
|
||||||
|
* @param {string} path
|
||||||
|
* @param {string} fileName
|
||||||
|
* @param {string} data
|
||||||
|
*
|
||||||
|
* @return {Promise<void>}
|
||||||
|
*/
|
||||||
|
export const createFile = async (
|
||||||
|
path: string,
|
||||||
|
fileName: string,
|
||||||
|
data: string,
|
||||||
|
): Promise<void> => {
|
||||||
|
if (!checkIfFileOrDirectoryExists(path)) {
|
||||||
|
fs.mkdirSync(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
const writeFile = promisify(fs.writeFile);
|
||||||
|
|
||||||
|
return await writeFile(`${path}/${fileName}`, data, 'utf8');
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateFile = async (
|
||||||
|
path: string,
|
||||||
|
fileName: string,
|
||||||
|
data: string,
|
||||||
|
): Promise<void> => {
|
||||||
|
const fqdn = `${path}/${fileName}`
|
||||||
|
if (!checkIfFileOrDirectoryExists(path)) {
|
||||||
|
fs.mkdirSync(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// const writeFile = promisify(fs.writeFile);
|
||||||
|
|
||||||
|
return fs.writeFileSync(`${fqdn}`, data);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete file at the given path via a promise interface
|
||||||
|
*
|
||||||
|
* @param {string} path
|
||||||
|
*
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
export const deleteFile = async (path: string): Promise<void> => {
|
||||||
|
const unlink = promisify(fs.unlink);
|
||||||
|
|
||||||
|
return await unlink(path);
|
||||||
|
};
|
||||||
22
src/app.controller.spec.ts
Normal file
22
src/app.controller.spec.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AppController } from './app.controller';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
|
||||||
|
describe('AppController', () => {
|
||||||
|
let appController: AppController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const app: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [AppController],
|
||||||
|
providers: [AppService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
appController = app.get<AppController>(AppController);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('root', () => {
|
||||||
|
it('should return "Hello World!"', () => {
|
||||||
|
expect(appController.getHello()).toBe('Hello World!');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
14
src/app.controller.ts
Normal file
14
src/app.controller.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { Controller, Get } from '@nestjs/common';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
export class AppController {
|
||||||
|
constructor(private readonly appService: AppService) {
|
||||||
|
this.appService.initializeSequelize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
getHello(): string {
|
||||||
|
return this.appService.getHello();
|
||||||
|
}
|
||||||
|
}
|
||||||
47
src/app.module.ts
Normal file
47
src/app.module.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { AppController } from './app.controller';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
import { CommonService } from './common/common.service';
|
||||||
|
import { AppConfigService } from './app-config/app-config.service';
|
||||||
|
import { DataModule } from './data/data.module';
|
||||||
|
import { MailModule } from './mail/mail.module';
|
||||||
|
import { AppConfigController } from './app-config/app-config.controller';
|
||||||
|
import { MasterConfigModule } from './master-config/master-config.module';
|
||||||
|
import { ConfigModule } from './config/config.module';
|
||||||
|
import { FeedbackModule } from './feedback/feedback.module';
|
||||||
|
import { QuestionModule } from './question/question.module';
|
||||||
|
import { QuestionAddlDetailModule } from './question-addl-detail/question-addl-detail.module';
|
||||||
|
import { QuestionTagModule } from './question-tag/question-tag.module';
|
||||||
|
import { RankingModule } from './ranking/ranking.module';
|
||||||
|
import { ResultsModule } from './results/results.module';
|
||||||
|
import { TestModule } from './test/test.module';
|
||||||
|
import { TestAddlDetailModule } from './test-addl-detail/test-addl-detail.module';
|
||||||
|
import { TestAssignModule } from './test-assign/test-assign.module';
|
||||||
|
import { TestDetailModule } from './test-detail/test-detail.module';
|
||||||
|
import { TestQuestionRelModule } from './test-question-rel/test-question-rel.module';
|
||||||
|
import { TestTagModule } from './test-tag/test-tag.module';
|
||||||
|
import { UserAnswersModule } from './user-answers/user-answers.module';
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
DataModule,
|
||||||
|
MailModule,
|
||||||
|
FeedbackModule,
|
||||||
|
QuestionModule,
|
||||||
|
QuestionAddlDetailModule,
|
||||||
|
QuestionTagModule,
|
||||||
|
RankingModule,
|
||||||
|
ResultsModule,
|
||||||
|
TestModule,
|
||||||
|
TestAddlDetailModule,
|
||||||
|
TestAssignModule,
|
||||||
|
TestDetailModule,
|
||||||
|
TestQuestionRelModule,
|
||||||
|
TestTagModule,
|
||||||
|
UserAnswersModule,
|
||||||
|
MasterConfigModule,
|
||||||
|
ConfigModule,
|
||||||
|
],
|
||||||
|
controllers: [AppController, AppConfigController],
|
||||||
|
providers: [CommonService, AppConfigService, AppService],
|
||||||
|
})
|
||||||
|
export class AppModule { }
|
||||||
76
src/app.service.ts
Normal file
76
src/app.service.ts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { CommonService } from './common/common.service';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
|
import { AppConfigService } from './app-config/app-config.service';
|
||||||
|
import { Utility } from './common/Utility';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AppService {
|
||||||
|
|
||||||
|
modelFilePaths: string[] = [] as string[];
|
||||||
|
|
||||||
|
|
||||||
|
constructor(private commonService: CommonService, private configService: AppConfigService) { }
|
||||||
|
|
||||||
|
getHello(): string {
|
||||||
|
return 'Hello World!';
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeSequelize() {
|
||||||
|
this.getModels();
|
||||||
|
const dbConfig = this.configService.getDbConfig();
|
||||||
|
if (this.modelFilePaths.length > 0) {
|
||||||
|
this.commonService.sequelize = new Sequelize({
|
||||||
|
database: dbConfig.database,
|
||||||
|
dialect: 'postgres',
|
||||||
|
username: dbConfig.user,
|
||||||
|
password: dbConfig.password,
|
||||||
|
models: this.modelFilePaths,
|
||||||
|
modelMatch: (filename, member) => {
|
||||||
|
return filename.substring(0, filename.indexOf('.entity')) === member.toLowerCase();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
Utility.sequelize = this.commonService.sequelize;
|
||||||
|
}
|
||||||
|
const fileConfig = this.configService.initializeFileSystem();
|
||||||
|
this.commonService.fileConfig = fileConfig;
|
||||||
|
Utility.fileConfig = fileConfig;
|
||||||
|
|
||||||
|
const emailConfig = this.configService.getMailConfig();
|
||||||
|
this.commonService.mailConfig = emailConfig;
|
||||||
|
Utility.mailConfig = emailConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
getModels() {
|
||||||
|
this.fromDir(__dirname, '.entity', ['.js', '.ts']);
|
||||||
|
if (this.modelFilePaths.length > 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fromDir(startPath, filter, extensions) {
|
||||||
|
if (!fs.existsSync(startPath) || !extensions || extensions.length === 0) {
|
||||||
|
console.log("no dir ", startPath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = fs.readdirSync(startPath);
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
const filename = path.join(startPath, files[i]);
|
||||||
|
const stat = fs.lstatSync(filename);
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
this.fromDir(filename, filter, extensions); //recurse
|
||||||
|
} else if (filename.includes(filter)) {
|
||||||
|
extensions.map((extension) => {
|
||||||
|
if (filename.endsWith(`${filter}${extension}`)) {
|
||||||
|
this.modelFilePaths.push(filename);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
18
src/common/Exception.model.ts
Normal file
18
src/common/Exception.model.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export class Exception {
|
||||||
|
public exception: boolean;
|
||||||
|
public exceptionSeverity: 'HIGH' | 'MEDIUM' | 'LOW';
|
||||||
|
public exceptionMessage: string;
|
||||||
|
public stackTrace: any;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
exception,
|
||||||
|
exceptionSeverity,
|
||||||
|
exceptionMessage,
|
||||||
|
stackTrace = null,
|
||||||
|
) {
|
||||||
|
this.exception = exception;
|
||||||
|
this.exceptionSeverity = exceptionSeverity;
|
||||||
|
this.exceptionMessage = exceptionMessage;
|
||||||
|
this.stackTrace = stackTrace;
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/common/GenericResponse.model.ts
Normal file
14
src/common/GenericResponse.model.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { Exception } from "./Exception.model";
|
||||||
|
|
||||||
|
export class GenericResponse {
|
||||||
|
public notification: Exception;
|
||||||
|
data: any
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
exception: Exception,
|
||||||
|
data
|
||||||
|
) {
|
||||||
|
this.notification = exception;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/common/Utility.ts
Normal file
22
src/common/Utility.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { Sequelize } from "sequelize";
|
||||||
|
|
||||||
|
export class Utility {
|
||||||
|
static sequelize: Sequelize;
|
||||||
|
static appPort: number = 3000;
|
||||||
|
static models: any;
|
||||||
|
static fileConfig: any = {"storagePath": "./uploads"};
|
||||||
|
static mailConfig: any = {
|
||||||
|
"transport": {
|
||||||
|
"host": "smtppro.zoho.in",
|
||||||
|
"secure": true,
|
||||||
|
"port": 465,
|
||||||
|
"auth": {
|
||||||
|
"user": "admin@wct.co.in",
|
||||||
|
"pass": "Wastecare@123"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaults": {
|
||||||
|
"from": "\"No Reply\" <admin@wct.co.in>"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
13
src/common/common.service.ts
Normal file
13
src/common/common.service.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import {Sequelize} from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CommonService {
|
||||||
|
sequelize: Sequelize;
|
||||||
|
models: any;
|
||||||
|
fileConfig: any;
|
||||||
|
mailConfig: any;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/config/config-logs/config-logs.controller.spec.ts
Normal file
18
src/config/config-logs/config-logs.controller.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ConfigLogsController } from './config-logs.controller';
|
||||||
|
|
||||||
|
describe('ConfigLogsController', () => {
|
||||||
|
let controller: ConfigLogsController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [ConfigLogsController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<ConfigLogsController>(ConfigLogsController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
103
src/config/config-logs/config-logs.controller.ts
Normal file
103
src/config/config-logs/config-logs.controller.ts
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { ConfigLogsService } from './config-logs.service';
|
||||||
|
import ConfigLog from './config-logs.entity';
|
||||||
|
import { GenericResponse } from 'src/common/GenericResponse.model';
|
||||||
|
|
||||||
|
@Controller('config/logs')
|
||||||
|
export class ConfigLogsController {
|
||||||
|
constructor(private configService: ConfigLogsService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAll(@Res() res: Response) {
|
||||||
|
const response = await this.configService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.configService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() config: ConfigLog, @Res() res: Response) {
|
||||||
|
if(!config) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.configService.filter(config) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() config: ConfigLog, @Res() res: Response) {
|
||||||
|
if(!config) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete config.id;
|
||||||
|
const response = await this.configService.upsert(config, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() config: ConfigLog, @Res() res: Response) {
|
||||||
|
if(!config || !config.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.configService.upsert(config, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.configService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/config/config-logs/config-logs.entity.ts
Normal file
29
src/config/config-logs/config-logs.entity.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({tableName: 'config_logs'})
|
||||||
|
export default class ConfigLog extends Model {
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
tableName: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
prevValue: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
currValue: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
createBy: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
}
|
||||||
18
src/config/config-logs/config-logs.service.spec.ts
Normal file
18
src/config/config-logs/config-logs.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ConfigLogsService } from './config-logs.service';
|
||||||
|
|
||||||
|
describe('ConfigLogsService', () => {
|
||||||
|
let service: ConfigLogsService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [ConfigLogsService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<ConfigLogsService>(ConfigLogsService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
37
src/config/config-logs/config-logs.service.ts
Normal file
37
src/config/config-logs/config-logs.service.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import ConfigLog from './config-logs.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ConfigLogsService {
|
||||||
|
async findAll(): Promise<{rows: ConfigLog[], count: number}> {
|
||||||
|
return ConfigLog.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<ConfigLog> {
|
||||||
|
return ConfigLog.findByPk(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(config: ConfigLog) : Promise<ConfigLog[]> {
|
||||||
|
return ConfigLog.findAll({where: config as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(config: ConfigLog): Promise<ConfigLog> {
|
||||||
|
return ConfigLog.findOne({where: config as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return ConfigLog.destroy({where: {id: id}});
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(config: ConfigLog, insertIfNotFound: boolean): Promise<ConfigLog | [affectedCount: number]> {
|
||||||
|
if(config.id) {
|
||||||
|
const existingUser = await this.findByPk(config.id);
|
||||||
|
if(existingUser) {
|
||||||
|
return ConfigLog.update(config, {where: {id: config.id}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(insertIfNotFound) {
|
||||||
|
return ConfigLog.create(config as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/config/config.controller.spec.ts
Normal file
18
src/config/config.controller.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ConfigController } from './config.controller';
|
||||||
|
|
||||||
|
describe('ConfigController', () => {
|
||||||
|
let controller: ConfigController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [ConfigController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<ConfigController>(ConfigController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
104
src/config/config.controller.ts
Normal file
104
src/config/config.controller.ts
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { ConfigService } from './config.service';
|
||||||
|
import Config from './config.entity';
|
||||||
|
import { GenericResponse } from 'src/common/GenericResponse.model';
|
||||||
|
|
||||||
|
@Controller('config')
|
||||||
|
export class ConfigController {
|
||||||
|
|
||||||
|
constructor(private configService: ConfigService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAll(@Res() res: Response) {
|
||||||
|
const response = await this.configService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.configService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() config: Config, @Res() res: Response) {
|
||||||
|
if(!config) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.configService.filter(config) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() config: Config, @Res() res: Response) {
|
||||||
|
if(!config) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete config.id;
|
||||||
|
const response = await this.configService.upsert(config, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() config: Config, @Res() res: Response) {
|
||||||
|
if(!config || !config.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.configService.upsert(config, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.configService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
44
src/config/config.entity.ts
Normal file
44
src/config/config.entity.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({tableName: 'config_transcations'})
|
||||||
|
export default class Config extends Model {
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
configCode: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
companyCode: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
itemCategoryCode: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
itemCode: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
status: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
value: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
fileUrl: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.NUMBER})
|
||||||
|
weight: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
createBy: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
}
|
||||||
11
src/config/config.module.ts
Normal file
11
src/config/config.module.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ConfigController } from './config.controller';
|
||||||
|
import { ConfigService } from './config.service';
|
||||||
|
import { ConfigLogsController } from './config-logs/config-logs.controller';
|
||||||
|
import { ConfigLogsService } from './config-logs/config-logs.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [ConfigController, ConfigLogsController],
|
||||||
|
providers: [ConfigService, ConfigLogsService]
|
||||||
|
})
|
||||||
|
export class ConfigModule {}
|
||||||
18
src/config/config.service.spec.ts
Normal file
18
src/config/config.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ConfigService } from './config.service';
|
||||||
|
|
||||||
|
describe('ConfigService', () => {
|
||||||
|
let service: ConfigService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [ConfigService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<ConfigService>(ConfigService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
37
src/config/config.service.ts
Normal file
37
src/config/config.service.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import Config from './config.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ConfigService {
|
||||||
|
async findAll(): Promise<{rows: Config[], count: number}> {
|
||||||
|
return Config.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<Config> {
|
||||||
|
return Config.findByPk(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(config: Config) : Promise<Config[]> {
|
||||||
|
return Config.findAll({where: config as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(config: Config): Promise<Config> {
|
||||||
|
return Config.findOne({where: config as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return Config.destroy({where: {id: id}});
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(config: Config, insertIfNotFound: boolean): Promise<Config | [affectedCount: number]> {
|
||||||
|
if(config.id) {
|
||||||
|
const existingUser = await this.findByPk(config.id);
|
||||||
|
if(existingUser) {
|
||||||
|
return Config.update(config, {where: {id: config.id}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(insertIfNotFound) {
|
||||||
|
return Config.create(config as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/data/data.controller.spec.ts
Normal file
18
src/data/data.controller.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { DataController } from './data.controller';
|
||||||
|
|
||||||
|
describe('DataController', () => {
|
||||||
|
let controller: DataController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [DataController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<DataController>(DataController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
132
src/data/data.controller.ts
Normal file
132
src/data/data.controller.ts
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { GenericResponse } from 'src/common/GenericResponse.model';
|
||||||
|
import DataModel from './data.entity';
|
||||||
|
import { DataService } from './data.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
|
||||||
|
@Controller('data')
|
||||||
|
export class DataController {
|
||||||
|
|
||||||
|
constructor(private dataService: DataService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllUsers(@Res() res: Response) {
|
||||||
|
const response: any = await this.dataService.findAll() || [];
|
||||||
|
res.send((response && response.rows) ? response.rows : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.dataService.findByPk(id) || {};
|
||||||
|
res.send(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Post('/:endPtNm/:opType')
|
||||||
|
async performOperation(@Param('endPtNm') endPtNm: string, @Param('opType') opType: string, @Body() body, @Res() res: Response) {
|
||||||
|
if(!opType || !endPtNm) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response: DataModel = await this.dataService.findOne({endPtNm: endPtNm, opsTypeName: opType.toUpperCase()} as any);
|
||||||
|
if(response && response.sqlQueryText) {
|
||||||
|
if(body) {
|
||||||
|
for(const key in body) {
|
||||||
|
response.sqlQueryText = response.sqlQueryText.replaceAll(`:${key}`, (typeof body[key] === 'string') ? `'${body[key]}'` : body[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let dataResponse = await this.dataService.executeQuery(response.sqlQueryText);
|
||||||
|
if(dataResponse && dataResponse.length && Array.isArray(dataResponse[0])) {
|
||||||
|
dataResponse = dataResponse[0];
|
||||||
|
}
|
||||||
|
res.send(dataResponse);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return new GenericResponse(null, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() quote: DataModel, @Res() res: Response) {
|
||||||
|
if(!quote) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.dataService.filter(quote) || [];
|
||||||
|
res.send(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() quote: DataModel, @Res() res: Response) {
|
||||||
|
if(!quote) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete quote.id;
|
||||||
|
const response = await this.dataService.upsert(quote, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() quote: DataModel, @Res() res: Response) {
|
||||||
|
if(!quote || !quote.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.dataService.upsert(quote, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.dataService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/data/data.entity.ts
Normal file
29
src/data/data.entity.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({tableName: 'crud_config_info'})
|
||||||
|
export default class DataModel extends Model {
|
||||||
|
|
||||||
|
@Column({type: DataType.NUMBER})
|
||||||
|
endPtNm: number;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
sqlQueryText: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
opsTypeName: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
createBy: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
}
|
||||||
9
src/data/data.module.ts
Normal file
9
src/data/data.module.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { DataService } from './data.service';
|
||||||
|
import { DataController } from './data.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [DataService],
|
||||||
|
controllers: [DataController]
|
||||||
|
})
|
||||||
|
export class DataModule {}
|
||||||
18
src/data/data.service.spec.ts
Normal file
18
src/data/data.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { DataService } from './data.service';
|
||||||
|
|
||||||
|
describe('DataService', () => {
|
||||||
|
let service: DataService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [DataService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<DataService>(DataService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
44
src/data/data.service.ts
Normal file
44
src/data/data.service.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import DataModel from './data.entity';
|
||||||
|
import { Utility } from 'src/common/Utility';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class DataService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{rows: DataModel[], count: number}> {
|
||||||
|
return DataModel.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<DataModel> {
|
||||||
|
return DataModel.findByPk(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(dataDetail: DataModel): Promise<DataModel> {
|
||||||
|
return DataModel.findOne({where: dataDetail as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(dataDetail: DataModel) : Promise<DataModel[]> {
|
||||||
|
return DataModel.findAll({where: dataDetail as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return DataModel.destroy({where: {id: id}});
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(dataDetail: DataModel, insertIfNotFound: boolean): Promise<DataModel | [affectedCount: number]> {
|
||||||
|
if(dataDetail.id) {
|
||||||
|
const existingUser = await this.findByPk(dataDetail.id);
|
||||||
|
if(existingUser) {
|
||||||
|
return DataModel.update(dataDetail, {where: {id: dataDetail.id}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(insertIfNotFound) {
|
||||||
|
return DataModel.create(dataDetail as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
executeQuery(sqlQueryText: string): Promise<any> {
|
||||||
|
return Utility.sequelize.query(sqlQueryText);
|
||||||
|
}
|
||||||
|
}
|
||||||
106
src/feedback/feedback.controller.ts
Normal file
106
src/feedback/feedback.controller.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { FeedbackService } from './feedback.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import Feedback from './feedback.entity';
|
||||||
|
|
||||||
|
@Controller('feedback')
|
||||||
|
export class FeedbackController {
|
||||||
|
constructor(private feedbackService: FeedbackService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllFeedbacks(@Res() res: Response) {
|
||||||
|
const response = await this.feedbackService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.feedbackService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() feedback: Feedback, @Res() res: Response) {
|
||||||
|
if(!feedback) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.feedbackService.filter(feedback) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() feedback: Feedback, @Res() res: Response) {
|
||||||
|
if(!feedback) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete feedback.id;
|
||||||
|
|
||||||
|
const response = await this.feedbackService.upsert(feedback, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() feedback: Feedback, @Res() res: Response) {
|
||||||
|
if(!feedback || !feedback.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.feedbackService.upsert(feedback, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.feedbackService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
46
src/feedback/feedback.entity.ts
Normal file
46
src/feedback/feedback.entity.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({ tableName: 'feedback' })
|
||||||
|
export default class Feedback extends Model {
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
testId: number;
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
feedbackText: string;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
rating: number;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
updatedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
createdBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
deletedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
10
src/feedback/feedback.module.ts
Normal file
10
src/feedback/feedback.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { FeedbackController } from './feedback.controller';
|
||||||
|
import { FeedbackService } from './feedback.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [FeedbackService],
|
||||||
|
controllers: [FeedbackController],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class FeedbackModule { }
|
||||||
41
src/feedback/feedback.service.ts
Normal file
41
src/feedback/feedback.service.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import Feedback from './feedback.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class FeedbackService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{ rows: Feedback[], count: number }> {
|
||||||
|
return Feedback.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<Feedback> {
|
||||||
|
return Feedback.findByPk(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(feedback: Feedback): Promise<Feedback> {
|
||||||
|
return Feedback.findOne({ where: feedback as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(feedback: Feedback): Promise<Feedback[]> {
|
||||||
|
return Feedback.findAll({ where: feedback as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return Feedback.destroy({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(feedback: Feedback, insertIfNotFound: boolean): Promise<Feedback | [affectedCount: number]> {
|
||||||
|
if (feedback.id) {
|
||||||
|
const existingFeedback = await this.findByPk(feedback.id);
|
||||||
|
if (existingFeedback) {
|
||||||
|
return Feedback.update(feedback, { where: { id: feedback.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIfNotFound) {
|
||||||
|
return Feedback.create(feedback as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
27
src/mail/mail.module.ts
Normal file
27
src/mail/mail.module.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { MailerModule } from '@nestjs-modules/mailer';
|
||||||
|
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter';
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { MailService } from './mail.service';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { Utility } from 'src/common/Utility';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
MailerModule.forRoot({
|
||||||
|
// transport: 'smtps://user@example.com:topsecret@smtp.example.com',
|
||||||
|
// or
|
||||||
|
transport: Utility.mailConfig.transport,
|
||||||
|
defaults: Utility.mailConfig.defaults,
|
||||||
|
template: {
|
||||||
|
dir: join(__dirname, 'templates'),
|
||||||
|
adapter: new HandlebarsAdapter(), // or new PugAdapter() or new EjsAdapter()
|
||||||
|
options: {
|
||||||
|
strict: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
providers: [MailService],
|
||||||
|
exports: [MailService], // 👈 export for DI
|
||||||
|
})
|
||||||
|
export class MailModule {}
|
||||||
18
src/mail/mail.service.spec.ts
Normal file
18
src/mail/mail.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { MailService } from './mail.service';
|
||||||
|
|
||||||
|
describe('MailService', () => {
|
||||||
|
let service: MailService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [MailService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<MailService>(MailService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
19
src/mail/mail.service.ts
Normal file
19
src/mail/mail.service.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { MailerService } from '@nestjs-modules/mailer';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class MailService {
|
||||||
|
constructor(private mailerService: MailerService) { }
|
||||||
|
|
||||||
|
|
||||||
|
async sendEmail(templateName: string, subject: string, context: any, toEmail: string, ccEmails?: string[], bccEmails?: string[]) {
|
||||||
|
await this.mailerService.sendMail({
|
||||||
|
to: toEmail,
|
||||||
|
cc: ccEmails,
|
||||||
|
bcc: bccEmails,
|
||||||
|
subject: subject,
|
||||||
|
template: templateName, // `.hbs` extension is appended automatically
|
||||||
|
context,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
82
src/mail/templates/confirmation.hbs
Normal file
82
src/mail/templates/confirmation.hbs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gjs-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: stretch;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gjs-cell {
|
||||||
|
min-height: 75px;
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-basis: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#im43 {
|
||||||
|
background-repeat: repeat;
|
||||||
|
background-position: left top;
|
||||||
|
background-attachment: scroll;
|
||||||
|
background-size: auto;
|
||||||
|
background-image: linear-gradient(#39960c 0%, #39960c 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ij93 {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ilfj {
|
||||||
|
color: #ffffff;
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 900;
|
||||||
|
font-size: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ihfp {
|
||||||
|
height: 577px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#i23r {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.gjs-row {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body id="iohk">
|
||||||
|
<div class="gjs-row" id="iir1">
|
||||||
|
<div class="gjs-cell" id="im43">
|
||||||
|
<div id="ij93">
|
||||||
|
<span id="ilfj">Waste Care Technologies</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="gjs-row" id="ihfp">
|
||||||
|
<div class="gjs-cell">
|
||||||
|
<div id="i23r">Dear {{ name }},
|
||||||
|
<br />
|
||||||
|
<br />Welcome to Waste Care Technologies.
|
||||||
|
<br />
|
||||||
|
<br />Use Password {{ password }} to login to your account.
|
||||||
|
<br />
|
||||||
|
<br />Contact our Support if you need any queries.
|
||||||
|
<br />
|
||||||
|
<br />Thank you for choosing us
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
79
src/mail/templates/quoteCreated.hbs
Normal file
79
src/mail/templates/quoteCreated.hbs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gjs-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: stretch;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gjs-cell {
|
||||||
|
min-height: 75px;
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-basis: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#im43 {
|
||||||
|
background-repeat: repeat;
|
||||||
|
background-position: left top;
|
||||||
|
background-attachment: scroll;
|
||||||
|
background-size: auto;
|
||||||
|
background-image: linear-gradient(#39960c 0%, #39960c 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ij93 {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ilfj {
|
||||||
|
color: #ffffff;
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 900;
|
||||||
|
font-size: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ihfp {
|
||||||
|
height: 577px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#i23r {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.gjs-row {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body id="iohk">
|
||||||
|
<div class="gjs-row" id="iir1">
|
||||||
|
<div class="gjs-cell" id="im43">
|
||||||
|
<div id="ij93">
|
||||||
|
<span id="ilfj">Waste Care Technologies</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="gjs-row" id="ihfp">
|
||||||
|
<div class="gjs-cell" id="ihbs">
|
||||||
|
<div id="i23r">Dear {{ email }},
|
||||||
|
<br/>
|
||||||
|
<br/>A Quote with {{ quoteID }} is created by you.
|
||||||
|
<br/>
|
||||||
|
<br/>Current Quote is in {{ status }} status.
|
||||||
|
<br/>
|
||||||
|
<br/>Thank you for choosing us
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
16
src/main.ts
Normal file
16
src/main.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import { AppModule } from './app.module';
|
||||||
|
import * as bodyParser from 'body-parser';
|
||||||
|
import * as configMaster from './app-config/config.json';
|
||||||
|
import { Utility } from './common/Utility';
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
Utility.appPort = configMaster.local.appConfig.port;
|
||||||
|
Utility.mailConfig = configMaster.local.mailConfig;
|
||||||
|
Utility.fileConfig = configMaster.local.fileConfig;
|
||||||
|
const app = await NestFactory.create(AppModule, { cors: true });
|
||||||
|
app.use(bodyParser.json({limit: '50mb'}));
|
||||||
|
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
|
||||||
|
await app.listen(Utility.appPort);
|
||||||
|
}
|
||||||
|
bootstrap();
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { Response } from 'express';
|
||||||
|
|
||||||
|
import { GenericResponse } from 'src/common/GenericResponse.model';
|
||||||
|
import MasterConfigCategory from './master-config-category.entity';
|
||||||
|
import { MasterConfigCategoryService } from './master-config-category.service';
|
||||||
|
|
||||||
|
@Controller('master-config/category')
|
||||||
|
export class MasterConfigCategoryController {
|
||||||
|
constructor(private masterConfigService: MasterConfigCategoryService) { }
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAll(@Res() res: Response) {
|
||||||
|
const response = await this.masterConfigService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if (!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_IN_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() masterConfig: MasterConfigCategory, @Res() res: Response) {
|
||||||
|
if (!masterConfig) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.filter(masterConfig) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() masterConfig: MasterConfigCategory, @Res() res: Response) {
|
||||||
|
if (!masterConfig) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete masterConfig.id;
|
||||||
|
const response = await this.masterConfigService.upsert(masterConfig, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() masterConfig: MasterConfigCategory, @Res() res: Response) {
|
||||||
|
if (!masterConfig || !masterConfig.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.upsert(masterConfig, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if (!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({tableName: 'master_config_category_ref'})
|
||||||
|
export default class MasterConfigCategory extends Model {
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
categoryName: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
categoryCode: number;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
categoryDescription: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
categoryType: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
parentCode: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
createBy: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
modifiedBy: string;
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import MasterConfigCategory from './master-config-category.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class MasterConfigCategoryService {
|
||||||
|
async findAll(): Promise<{rows: MasterConfigCategory[], count: number}> {
|
||||||
|
return MasterConfigCategory.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<MasterConfigCategory> {
|
||||||
|
return MasterConfigCategory.findByPk(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(masterConfig: MasterConfigCategory) : Promise<MasterConfigCategory[]> {
|
||||||
|
return MasterConfigCategory.findAll({where: masterConfig as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(masterConfig: MasterConfigCategory): Promise<MasterConfigCategory> {
|
||||||
|
return MasterConfigCategory.findOne({where: masterConfig as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return MasterConfigCategory.destroy({where: {id: id}});
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(masterConfig: MasterConfigCategory, insertIfNotFound: boolean): Promise<MasterConfigCategory | [affectedCount: number]> {
|
||||||
|
if(masterConfig.id) {
|
||||||
|
const existingmasterConfig = await this.findByPk(masterConfig.id);
|
||||||
|
if(existingmasterConfig) {
|
||||||
|
return MasterConfigCategory.update(masterConfig, {where: {id: masterConfig.id}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(insertIfNotFound) {
|
||||||
|
return MasterConfigCategory.create(masterConfig as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from 'src/common/GenericResponse.model';
|
||||||
|
import { MasterConfigMappingService } from './master-config-mapping.service';
|
||||||
|
import MasterConfigMapping from './master-config-mapping.entity';
|
||||||
|
|
||||||
|
@Controller('master-config/mapping')
|
||||||
|
export class MasterConfigMappingController {
|
||||||
|
|
||||||
|
constructor(private masterConfigService: MasterConfigMappingService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAll(@Res() res: Response) {
|
||||||
|
const response = await this.masterConfigService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_IN_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() masterConfig: MasterConfigMapping, @Res() res: Response) {
|
||||||
|
if(!masterConfig) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.filter(masterConfig) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() masterConfig: MasterConfigMapping, @Res() res: Response) {
|
||||||
|
if(!masterConfig) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete masterConfig.id;
|
||||||
|
const response = await this.masterConfigService.upsert(masterConfig, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() masterConfig: MasterConfigMapping, @Res() res: Response) {
|
||||||
|
if(!masterConfig || !masterConfig.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.upsert(masterConfig, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({tableName: 'master_config_mapping'})
|
||||||
|
export default class MasterConfigMapping extends Model {
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
configCode: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
companyCode: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
status: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
dispSerialNumber: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
defaultValue: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
createBy: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
modifiedBy: string;
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import MasterConfigMapping from './master-config-mapping.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class MasterConfigMappingService {
|
||||||
|
|
||||||
|
async findAll(): Promise<{rows: MasterConfigMapping[], count: number}> {
|
||||||
|
return MasterConfigMapping.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<MasterConfigMapping> {
|
||||||
|
return MasterConfigMapping.findByPk(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
filter(masterConfig: MasterConfigMapping) : Promise<MasterConfigMapping[]> {
|
||||||
|
return MasterConfigMapping.findAll({where: masterConfig as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(masterConfig: MasterConfigMapping): Promise<MasterConfigMapping> {
|
||||||
|
return MasterConfigMapping.findOne({where: masterConfig as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return MasterConfigMapping.destroy({where: {id: id}});
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(masterConfig: MasterConfigMapping, insertIfNotFound: boolean): Promise<MasterConfigMapping | [affectedCount: number]> {
|
||||||
|
if(masterConfig.id) {
|
||||||
|
const existingUser = await this.findByPk(masterConfig.id);
|
||||||
|
if(existingUser) {
|
||||||
|
return MasterConfigMapping.update(masterConfig, {where: {id: masterConfig.id}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(insertIfNotFound) {
|
||||||
|
return MasterConfigMapping.create(masterConfig as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
102
src/master-config/master-config.controller.ts
Normal file
102
src/master-config/master-config.controller.ts
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { MasterConfigService } from './master-config.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import MasterConfig from './master-config.entity';
|
||||||
|
|
||||||
|
@Controller('master-config')
|
||||||
|
export class MasterConfigController {
|
||||||
|
constructor(private masterConfigService: MasterConfigService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAll(@Res() res: Response) {
|
||||||
|
const response = await this.masterConfigService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() masterConfig: MasterConfig, @Res() res: Response) {
|
||||||
|
if(!masterConfig) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.filter(masterConfig) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() masterConfig: MasterConfig, @Res() res: Response) {
|
||||||
|
if(!masterConfig) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.upsert(masterConfig, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() masterConfig: MasterConfig, @Res() res: Response) {
|
||||||
|
if(!masterConfig || !masterConfig.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.upsert(masterConfig, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.masterConfigService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/master-config/master-config.entity.ts
Normal file
38
src/master-config/master-config.entity.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType, Unique } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({tableName: 'master_config_ref'})
|
||||||
|
export default class MasterConfig extends Model {
|
||||||
|
|
||||||
|
@Unique(true)
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
configCode: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
configName: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
configCategoryCode: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
configDesc: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
parentCode: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
configType: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column({type: DataType.DATEONLY})
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
createBy: string;
|
||||||
|
|
||||||
|
@Column({type: DataType.TEXT})
|
||||||
|
modifiedBy: string;
|
||||||
|
}
|
||||||
14
src/master-config/master-config.module.ts
Normal file
14
src/master-config/master-config.module.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { MasterConfigMappingController } from './master-config-mapping/master-config-mapping.controller';
|
||||||
|
import { MasterConfigCategoryController } from './master-config-category/master-config-category.controller';
|
||||||
|
import { MasterConfigController } from './master-config.controller';
|
||||||
|
import { MasterConfigService } from './master-config.service';
|
||||||
|
import { MasterConfigMappingService } from './master-config-mapping/master-config-mapping.service';
|
||||||
|
import { MasterConfigCategoryService } from './master-config-category/master-config-category.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [MasterConfigController, MasterConfigMappingController, MasterConfigCategoryController],
|
||||||
|
providers: [MasterConfigService, MasterConfigMappingService, MasterConfigCategoryService],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class MasterConfigModule { }
|
||||||
43
src/master-config/master-config.service.ts
Normal file
43
src/master-config/master-config.service.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import MasterConfig from './master-config.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class MasterConfigService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{rows: MasterConfig[], count: number}> {
|
||||||
|
return MasterConfig.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<MasterConfig> {
|
||||||
|
return MasterConfig.findByPk(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(masterConfig: MasterConfig): Promise<MasterConfig> {
|
||||||
|
return MasterConfig.findOne({where: masterConfig as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(masterConfig: MasterConfig) : Promise<MasterConfig[]> {
|
||||||
|
return MasterConfig.findAll({where: masterConfig as any})
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return MasterConfig.destroy({where: {id: id}});
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(masterConfig: MasterConfig, insertIfNotFound: boolean): Promise<MasterConfig | [affectedCount: number]> {
|
||||||
|
if(masterConfig.id) {
|
||||||
|
const existingUser = await this.findByPk(masterConfig.id);
|
||||||
|
if(existingUser) {
|
||||||
|
return MasterConfig.update(masterConfig, {where: {id: masterConfig.id}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(insertIfNotFound) {
|
||||||
|
return MasterConfig.create(masterConfig as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async login(masterConfig: MasterConfig): Promise<MasterConfig> {
|
||||||
|
return MasterConfig.findOne({where: masterConfig as any})
|
||||||
|
}
|
||||||
|
}
|
||||||
106
src/question-addl-detail/question-addl-detail.controller.ts
Normal file
106
src/question-addl-detail/question-addl-detail.controller.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { QuestionAddlDetailService } from './question-addl-detail.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import QuestionAddlDetail from './question-addl-detail.entity';
|
||||||
|
|
||||||
|
@Controller('questionAddlDetail')
|
||||||
|
export class QuestionAddlDetailController {
|
||||||
|
constructor(private questionAddlDetailService: QuestionAddlDetailService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllQuestionAddlDetails(@Res() res: Response) {
|
||||||
|
const response = await this.questionAddlDetailService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.questionAddlDetailService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() questionAddlDetail: QuestionAddlDetail, @Res() res: Response) {
|
||||||
|
if(!questionAddlDetail) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.questionAddlDetailService.filter(questionAddlDetail) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() questionAddlDetail: QuestionAddlDetail, @Res() res: Response) {
|
||||||
|
if(!questionAddlDetail) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete questionAddlDetail.id;
|
||||||
|
|
||||||
|
const response = await this.questionAddlDetailService.upsert(questionAddlDetail, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() questionAddlDetail: QuestionAddlDetail, @Res() res: Response) {
|
||||||
|
if(!questionAddlDetail || !questionAddlDetail.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.questionAddlDetailService.upsert(questionAddlDetail, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.questionAddlDetailService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
src/question-addl-detail/question-addl-detail.entity.ts
Normal file
43
src/question-addl-detail/question-addl-detail.entity.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({ tableName: 'question_additional_details' })
|
||||||
|
export default class QuestionAddlDetail extends Model {
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
questionId: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
addlDataType: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
addlDataName: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
updatedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
createdBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
deletedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
10
src/question-addl-detail/question-addl-detail.module.ts
Normal file
10
src/question-addl-detail/question-addl-detail.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { QuestionAddlDetailController } from './question-addl-detail.controller';
|
||||||
|
import { QuestionAddlDetailService } from './question-addl-detail.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [QuestionAddlDetailService],
|
||||||
|
controllers: [QuestionAddlDetailController],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class QuestionAddlDetailModule { }
|
||||||
41
src/question-addl-detail/question-addl-detail.service.ts
Normal file
41
src/question-addl-detail/question-addl-detail.service.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import QuestionAddlDetail from './question-addl-detail.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class QuestionAddlDetailService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{ rows: QuestionAddlDetail[], count: number }> {
|
||||||
|
return QuestionAddlDetail.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<QuestionAddlDetail> {
|
||||||
|
return QuestionAddlDetail.findByPk(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(questionAddlDetail: QuestionAddlDetail): Promise<QuestionAddlDetail> {
|
||||||
|
return QuestionAddlDetail.findOne({ where: questionAddlDetail as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(questionAddlDetail: QuestionAddlDetail): Promise<QuestionAddlDetail[]> {
|
||||||
|
return QuestionAddlDetail.findAll({ where: questionAddlDetail as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return QuestionAddlDetail.destroy({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(questionAddlDetail: QuestionAddlDetail, insertIfNotFound: boolean): Promise<QuestionAddlDetail | [affectedCount: number]> {
|
||||||
|
if (questionAddlDetail.id) {
|
||||||
|
const existingQuestionAddlDetail = await this.findByPk(questionAddlDetail.id);
|
||||||
|
if (existingQuestionAddlDetail) {
|
||||||
|
return QuestionAddlDetail.update(questionAddlDetail, { where: { id: questionAddlDetail.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIfNotFound) {
|
||||||
|
return QuestionAddlDetail.create(questionAddlDetail as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
106
src/question-tag/question-tag.controller.ts
Normal file
106
src/question-tag/question-tag.controller.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { QuestionTagService } from './question-tag.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import QuestionTag from './question-tag.entity';
|
||||||
|
|
||||||
|
@Controller('question-tag')
|
||||||
|
export class QuestionTagController {
|
||||||
|
constructor(private questionTagService: QuestionTagService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllQuestionTags(@Res() res: Response) {
|
||||||
|
const response = await this.questionTagService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.questionTagService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() questionTag: QuestionTag, @Res() res: Response) {
|
||||||
|
if(!questionTag) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.questionTagService.filter(questionTag) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() questionTag: QuestionTag, @Res() res: Response) {
|
||||||
|
if(!questionTag) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete questionTag.id;
|
||||||
|
|
||||||
|
const response = await this.questionTagService.upsert(questionTag, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() questionTag: QuestionTag, @Res() res: Response) {
|
||||||
|
if(!questionTag || !questionTag.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.questionTagService.upsert(questionTag, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.questionTagService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
src/question-tag/question-tag.entity.ts
Normal file
40
src/question-tag/question-tag.entity.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({ tableName: 'question_tag' })
|
||||||
|
export default class QuestionTag extends Model {
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
questionId: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
tagName: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
updatedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
createdBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
deletedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
10
src/question-tag/question-tag.module.ts
Normal file
10
src/question-tag/question-tag.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { QuestionTagController } from './question-tag.controller';
|
||||||
|
import { QuestionTagService } from './question-tag.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [QuestionTagService],
|
||||||
|
controllers: [QuestionTagController],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class QuestionTagModule { }
|
||||||
41
src/question-tag/question-tag.service.ts
Normal file
41
src/question-tag/question-tag.service.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import QuestionTag from './question-tag.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class QuestionTagService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{ rows: QuestionTag[], count: number }> {
|
||||||
|
return QuestionTag.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<QuestionTag> {
|
||||||
|
return QuestionTag.findByPk(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(questionTag: QuestionTag): Promise<QuestionTag> {
|
||||||
|
return QuestionTag.findOne({ where: questionTag as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(questionTag: QuestionTag): Promise<QuestionTag[]> {
|
||||||
|
return QuestionTag.findAll({ where: questionTag as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return QuestionTag.destroy({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(questionTag: QuestionTag, insertIfNotFound: boolean): Promise<QuestionTag | [affectedCount: number]> {
|
||||||
|
if (questionTag.id) {
|
||||||
|
const existingQuestionTag = await this.findByPk(questionTag.id);
|
||||||
|
if (existingQuestionTag) {
|
||||||
|
return QuestionTag.update(questionTag, { where: { id: questionTag.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIfNotFound) {
|
||||||
|
return QuestionTag.create(questionTag as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
106
src/question/question.controller.ts
Normal file
106
src/question/question.controller.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { QuestionService } from './question.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import Question from './question.entity';
|
||||||
|
|
||||||
|
@Controller('question')
|
||||||
|
export class QuestionController {
|
||||||
|
constructor(private questionService: QuestionService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllQuestions(@Res() res: Response) {
|
||||||
|
const response = await this.questionService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.questionService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() question: Question, @Res() res: Response) {
|
||||||
|
if(!question) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.questionService.filter(question) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() question: Question, @Res() res: Response) {
|
||||||
|
if(!question) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete question.id;
|
||||||
|
|
||||||
|
const response = await this.questionService.upsert(question, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() question: Question, @Res() res: Response) {
|
||||||
|
if(!question || !question.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.questionService.upsert(question, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.questionService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
src/question/question.entity.ts
Normal file
43
src/question/question.entity.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({ tableName: 'question' })
|
||||||
|
export default class Question extends Model {
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
content: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
questionType: string;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
hardness: number;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
updatedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
createdBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
deletedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
10
src/question/question.module.ts
Normal file
10
src/question/question.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { QuestionController } from './question.controller';
|
||||||
|
import { QuestionService } from './question.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [QuestionService],
|
||||||
|
controllers: [QuestionController],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class QuestionModule { }
|
||||||
41
src/question/question.service.ts
Normal file
41
src/question/question.service.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import Question from './question.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class QuestionService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{ rows: Question[], count: number }> {
|
||||||
|
return Question.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<Question> {
|
||||||
|
return Question.findByPk(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(question: Question): Promise<Question> {
|
||||||
|
return Question.findOne({ where: question as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(question: Question): Promise<Question[]> {
|
||||||
|
return Question.findAll({ where: question as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return Question.destroy({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(question: Question, insertIfNotFound: boolean): Promise<Question | [affectedCount: number]> {
|
||||||
|
if (question.id) {
|
||||||
|
const existingQuestion = await this.findByPk(question.id);
|
||||||
|
if (existingQuestion) {
|
||||||
|
return Question.update(question, { where: { id: question.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIfNotFound) {
|
||||||
|
return Question.create(question as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
106
src/ranking/ranking.controller.ts
Normal file
106
src/ranking/ranking.controller.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { RankingService } from './ranking.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import Ranking from './ranking.entity';
|
||||||
|
|
||||||
|
@Controller('ranking')
|
||||||
|
export class RankingController {
|
||||||
|
constructor(private rankingService: RankingService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllRankings(@Res() res: Response) {
|
||||||
|
const response = await this.rankingService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.rankingService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() ranking: Ranking, @Res() res: Response) {
|
||||||
|
if(!ranking) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.rankingService.filter(ranking) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() ranking: Ranking, @Res() res: Response) {
|
||||||
|
if(!ranking) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete ranking.id;
|
||||||
|
|
||||||
|
const response = await this.rankingService.upsert(ranking, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() ranking: Ranking, @Res() res: Response) {
|
||||||
|
if(!ranking || !ranking.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.rankingService.upsert(ranking, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.rankingService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
46
src/ranking/ranking.entity.ts
Normal file
46
src/ranking/ranking.entity.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({ tableName: 'ranking' })
|
||||||
|
export default class Ranking extends Model {
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
bookId: number;
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
testId: number;
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
rank: number;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
updatedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
createdBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
deletedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
10
src/ranking/ranking.module.ts
Normal file
10
src/ranking/ranking.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { RankingController } from './ranking.controller';
|
||||||
|
import { RankingService } from './ranking.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [RankingService],
|
||||||
|
controllers: [RankingController],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class RankingModule { }
|
||||||
41
src/ranking/ranking.service.ts
Normal file
41
src/ranking/ranking.service.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import Ranking from './ranking.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class RankingService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{ rows: Ranking[], count: number }> {
|
||||||
|
return Ranking.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<Ranking> {
|
||||||
|
return Ranking.findByPk(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(ranking: Ranking): Promise<Ranking> {
|
||||||
|
return Ranking.findOne({ where: ranking as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(ranking: Ranking): Promise<Ranking[]> {
|
||||||
|
return Ranking.findAll({ where: ranking as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return Ranking.destroy({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(ranking: Ranking, insertIfNotFound: boolean): Promise<Ranking | [affectedCount: number]> {
|
||||||
|
if (ranking.id) {
|
||||||
|
const existingRanking = await this.findByPk(ranking.id);
|
||||||
|
if (existingRanking) {
|
||||||
|
return Ranking.update(ranking, { where: { id: ranking.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIfNotFound) {
|
||||||
|
return Ranking.create(ranking as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
106
src/results/results.controller.ts
Normal file
106
src/results/results.controller.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { ResultsService } from './results.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import Results from './results.entity';
|
||||||
|
|
||||||
|
@Controller('results')
|
||||||
|
export class ResultsController {
|
||||||
|
constructor(private resultsService: ResultsService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllResultss(@Res() res: Response) {
|
||||||
|
const response = await this.resultsService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.resultsService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() results: Results, @Res() res: Response) {
|
||||||
|
if(!results) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.resultsService.filter(results) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() results: Results, @Res() res: Response) {
|
||||||
|
if(!results) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete results.id;
|
||||||
|
|
||||||
|
const response = await this.resultsService.upsert(results, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() results: Results, @Res() res: Response) {
|
||||||
|
if(!results || !results.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.resultsService.upsert(results, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.resultsService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
49
src/results/results.entity.ts
Normal file
49
src/results/results.entity.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({ tableName: 'results' })
|
||||||
|
export default class Results extends Model {
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
testId: number;
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
score: number;
|
||||||
|
|
||||||
|
@Column(DataType.BOOLEAN)
|
||||||
|
passing: boolean;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
updatedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
createdBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
deletedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
10
src/results/results.module.ts
Normal file
10
src/results/results.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ResultsController } from './results.controller';
|
||||||
|
import { ResultsService } from './results.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [ResultsService],
|
||||||
|
controllers: [ResultsController],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class ResultsModule { }
|
||||||
41
src/results/results.service.ts
Normal file
41
src/results/results.service.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import Results from './results.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ResultsService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{ rows: Results[], count: number }> {
|
||||||
|
return Results.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<Results> {
|
||||||
|
return Results.findByPk(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(results: Results): Promise<Results> {
|
||||||
|
return Results.findOne({ where: results as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(results: Results): Promise<Results[]> {
|
||||||
|
return Results.findAll({ where: results as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return Results.destroy({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(results: Results, insertIfNotFound: boolean): Promise<Results | [affectedCount: number]> {
|
||||||
|
if (results.id) {
|
||||||
|
const existingResults = await this.findByPk(results.id);
|
||||||
|
if (existingResults) {
|
||||||
|
return Results.update(results, { where: { id: results.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIfNotFound) {
|
||||||
|
return Results.create(results as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
106
src/test-addl-detail/test-addl-detail.controller.ts
Normal file
106
src/test-addl-detail/test-addl-detail.controller.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { TestAddlDetailService } from './test-addl-detail.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import TestAddlDetail from './test-addl-detail.entity';
|
||||||
|
|
||||||
|
@Controller('testAddlDetail')
|
||||||
|
export class TestAddlDetailController {
|
||||||
|
constructor(private testAddlDetailService: TestAddlDetailService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllTestAddlDetails(@Res() res: Response) {
|
||||||
|
const response = await this.testAddlDetailService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.testAddlDetailService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() testAddlDetail: TestAddlDetail, @Res() res: Response) {
|
||||||
|
if(!testAddlDetail) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.testAddlDetailService.filter(testAddlDetail) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() testAddlDetail: TestAddlDetail, @Res() res: Response) {
|
||||||
|
if(!testAddlDetail) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete testAddlDetail.id;
|
||||||
|
|
||||||
|
const response = await this.testAddlDetailService.upsert(testAddlDetail, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() testAddlDetail: TestAddlDetail, @Res() res: Response) {
|
||||||
|
if(!testAddlDetail || !testAddlDetail.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.testAddlDetailService.upsert(testAddlDetail, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.testAddlDetailService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
src/test-addl-detail/test-addl-detail.entity.ts
Normal file
43
src/test-addl-detail/test-addl-detail.entity.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({ tableName: 'test_additional_details' })
|
||||||
|
export default class TestAddlDetail extends Model {
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
testId: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
addlDataType: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
addlDataName: string;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
updatedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
createdBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
deletedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
10
src/test-addl-detail/test-addl-detail.module.ts
Normal file
10
src/test-addl-detail/test-addl-detail.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { TestAddlDetailController } from './test-addl-detail.controller';
|
||||||
|
import { TestAddlDetailService } from './test-addl-detail.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [TestAddlDetailService],
|
||||||
|
controllers: [TestAddlDetailController],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class TestAddlDetailModule { }
|
||||||
41
src/test-addl-detail/test-addl-detail.service.ts
Normal file
41
src/test-addl-detail/test-addl-detail.service.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import TestAddlDetail from './test-addl-detail.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TestAddlDetailService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{ rows: TestAddlDetail[], count: number }> {
|
||||||
|
return TestAddlDetail.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<TestAddlDetail> {
|
||||||
|
return TestAddlDetail.findByPk(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(testAddlDetail: TestAddlDetail): Promise<TestAddlDetail> {
|
||||||
|
return TestAddlDetail.findOne({ where: testAddlDetail as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(testAddlDetail: TestAddlDetail): Promise<TestAddlDetail[]> {
|
||||||
|
return TestAddlDetail.findAll({ where: testAddlDetail as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return TestAddlDetail.destroy({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(testAddlDetail: TestAddlDetail, insertIfNotFound: boolean): Promise<TestAddlDetail | [affectedCount: number]> {
|
||||||
|
if (testAddlDetail.id) {
|
||||||
|
const existingTestAddlDetail = await this.findByPk(testAddlDetail.id);
|
||||||
|
if (existingTestAddlDetail) {
|
||||||
|
return TestAddlDetail.update(testAddlDetail, { where: { id: testAddlDetail.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIfNotFound) {
|
||||||
|
return TestAddlDetail.create(testAddlDetail as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
106
src/test-assign/test-assign.controller.ts
Normal file
106
src/test-assign/test-assign.controller.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { TestAssignService } from './test-assign.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import TestAssign from './test-assign.entity';
|
||||||
|
|
||||||
|
@Controller('testAssign')
|
||||||
|
export class TestAssignController {
|
||||||
|
constructor(private testAssignService: TestAssignService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllTestAssigns(@Res() res: Response) {
|
||||||
|
const response = await this.testAssignService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.testAssignService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() testAssign: TestAssign, @Res() res: Response) {
|
||||||
|
if(!testAssign) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.testAssignService.filter(testAssign) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() testAssign: TestAssign, @Res() res: Response) {
|
||||||
|
if(!testAssign) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete testAssign.id;
|
||||||
|
|
||||||
|
const response = await this.testAssignService.upsert(testAssign, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() testAssign: TestAssign, @Res() res: Response) {
|
||||||
|
if(!testAssign || !testAssign.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.testAssignService.upsert(testAssign, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.testAssignService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
49
src/test-assign/test-assign.entity.ts
Normal file
49
src/test-assign/test-assign.entity.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({ tableName: 'test_assign' })
|
||||||
|
export default class TestAssign extends Model {
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
testId: number;
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
userId: number;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
assignedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
startTime: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
endTime: Date;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
updatedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
createdBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
deletedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
10
src/test-assign/test-assign.module.ts
Normal file
10
src/test-assign/test-assign.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { TestAssignController } from './test-assign.controller';
|
||||||
|
import { TestAssignService } from './test-assign.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [TestAssignService],
|
||||||
|
controllers: [TestAssignController],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class TestAssignModule { }
|
||||||
41
src/test-assign/test-assign.service.ts
Normal file
41
src/test-assign/test-assign.service.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import TestAssign from './test-assign.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TestAssignService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{ rows: TestAssign[], count: number }> {
|
||||||
|
return TestAssign.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<TestAssign> {
|
||||||
|
return TestAssign.findByPk(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(testAssign: TestAssign): Promise<TestAssign> {
|
||||||
|
return TestAssign.findOne({ where: testAssign as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(testAssign: TestAssign): Promise<TestAssign[]> {
|
||||||
|
return TestAssign.findAll({ where: testAssign as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return TestAssign.destroy({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(testAssign: TestAssign, insertIfNotFound: boolean): Promise<TestAssign | [affectedCount: number]> {
|
||||||
|
if (testAssign.id) {
|
||||||
|
const existingTestAssign = await this.findByPk(testAssign.id);
|
||||||
|
if (existingTestAssign) {
|
||||||
|
return TestAssign.update(testAssign, { where: { id: testAssign.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIfNotFound) {
|
||||||
|
return TestAssign.create(testAssign as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
106
src/test-detail/test-detail.controller.ts
Normal file
106
src/test-detail/test-detail.controller.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Post, Put, Res } from '@nestjs/common';
|
||||||
|
import { TestDetailService } from './test-detail.service';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { GenericResponse } from '../common/GenericResponse.model';
|
||||||
|
import TestDetail from './test-detail.entity';
|
||||||
|
|
||||||
|
@Controller('testDetail')
|
||||||
|
export class TestDetailController {
|
||||||
|
constructor(private testDetailService: TestDetailService) {}
|
||||||
|
|
||||||
|
@Get("/all")
|
||||||
|
async getAllTestDetails(@Res() res: Response) {
|
||||||
|
const response = await this.testDetailService.findAll() || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.testDetailService.findByPk(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/filter')
|
||||||
|
async filter(@Body() testDetail: TestDetail, @Res() res: Response) {
|
||||||
|
if(!testDetail) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.testDetailService.filter(testDetail) || [];
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.status(200).send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async insert(@Body() testDetail: TestDetail, @Res() res: Response) {
|
||||||
|
if(!testDetail) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete testDetail.id;
|
||||||
|
|
||||||
|
const response = await this.testDetailService.upsert(testDetail, true);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put()
|
||||||
|
async update(@Body() testDetail: TestDetail, @Res() res: Response) {
|
||||||
|
if(!testDetail || !testDetail.id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.testDetailService.upsert(testDetail, false);
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async deleteById(@Param('id') id: number, @Res() res: Response) {
|
||||||
|
if(!id) {
|
||||||
|
const response = new GenericResponse({
|
||||||
|
exception: true,
|
||||||
|
exceptionSeverity: 'HIGH',
|
||||||
|
exceptionMessage: 'ERR.NO_ID_REQ',
|
||||||
|
stackTrace: 'Request'
|
||||||
|
}, null);
|
||||||
|
res.send(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await this.testDetailService.remove(id) || {};
|
||||||
|
const httpResponse = new GenericResponse(null, response)
|
||||||
|
res.send(httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
46
src/test-detail/test-detail.entity.ts
Normal file
46
src/test-detail/test-detail.entity.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { Table, Column, Model, Default, DataType } from 'sequelize-typescript';
|
||||||
|
|
||||||
|
@Table({ tableName: 'test_detail' })
|
||||||
|
export default class TestDetail extends Model {
|
||||||
|
|
||||||
|
@Column(DataType.BIGINT)
|
||||||
|
testId: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
questionType: string;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
hardness: number;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
count: number;
|
||||||
|
|
||||||
|
@Default(new Date())
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validFrom: Date;
|
||||||
|
|
||||||
|
@Default(new Date("2070-12-31"))
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
validTill: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
updatedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
createdBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
modifiedBy: string;
|
||||||
|
|
||||||
|
@Column(DataType.DATEONLY)
|
||||||
|
deletedAt: Date;
|
||||||
|
|
||||||
|
@Column(DataType.NUMBER)
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@Column(DataType.TEXT)
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
10
src/test-detail/test-detail.module.ts
Normal file
10
src/test-detail/test-detail.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { TestDetailController } from './test-detail.controller';
|
||||||
|
import { TestDetailService } from './test-detail.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [TestDetailService],
|
||||||
|
controllers: [TestDetailController],
|
||||||
|
imports: []
|
||||||
|
})
|
||||||
|
export class TestDetailModule { }
|
||||||
41
src/test-detail/test-detail.service.ts
Normal file
41
src/test-detail/test-detail.service.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import TestDetail from './test-detail.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TestDetailService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async findAll(): Promise<{ rows: TestDetail[], count: number }> {
|
||||||
|
return TestDetail.findAndCountAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
findByPk(id: number): Promise<TestDetail> {
|
||||||
|
return TestDetail.findByPk(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(testDetail: TestDetail): Promise<TestDetail> {
|
||||||
|
return TestDetail.findOne({ where: testDetail as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
filter(testDetail: TestDetail): Promise<TestDetail[]> {
|
||||||
|
return TestDetail.findAll({ where: testDetail as any, })
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number): Promise<number> {
|
||||||
|
return TestDetail.destroy({ where: { id: id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async upsert(testDetail: TestDetail, insertIfNotFound: boolean): Promise<TestDetail | [affectedCount: number]> {
|
||||||
|
if (testDetail.id) {
|
||||||
|
const existingTestDetail = await this.findByPk(testDetail.id);
|
||||||
|
if (existingTestDetail) {
|
||||||
|
return TestDetail.update(testDetail, { where: { id: testDetail.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (insertIfNotFound) {
|
||||||
|
return TestDetail.create(testDetail as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user