oca-shared-model 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helper/base-entity.d.ts +3 -0
- package/dist/helper/base-entity.js +20 -0
- package/dist/helper/base-service.d.ts +20 -0
- package/dist/helper/base-service.js +158 -0
- package/dist/helper/pagination-filter.d.ts +7 -0
- package/dist/helper/pagination-filter.js +6 -0
- package/dist/library/master_answers/entities/master_answer.entity.d.ts +2 -0
- package/dist/library/master_answers/entities/master_answer.entity.js +6 -0
- package/dist/library/master_answers/master_answers.service.d.ts +2 -12
- package/dist/library/master_answers/master_answers.service.js +3 -108
- package/dist/library/master_questions/entities/master_question.entity.d.ts +3 -0
- package/dist/library/master_questions/entities/master_question.entity.js +9 -0
- package/dist/library/master_questions/master_questions.service.d.ts +2 -12
- package/dist/library/master_questions/master_questions.service.js +3 -104
- package/dist/shared-model.module.js +0 -2
- package/package.json +2 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BaseEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
class BaseEntity {
|
|
15
|
+
}
|
|
16
|
+
exports.BaseEntity = BaseEntity;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
19
|
+
__metadata("design:type", Object)
|
|
20
|
+
], BaseEntity.prototype, "id", void 0);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Repository } from "typeorm";
|
|
2
|
+
import { OptionFilter } from "./option-filter";
|
|
3
|
+
import { BaseEntity } from "./base-entity";
|
|
4
|
+
import { PaginationFilter } from "./pagination-filter";
|
|
5
|
+
export declare class BaseService<T extends BaseEntity> {
|
|
6
|
+
protected readonly repository: Repository<T>;
|
|
7
|
+
constructor(repository: Repository<T>);
|
|
8
|
+
create(payload: any): Promise<T[]>;
|
|
9
|
+
findAll(): Promise<T[]>;
|
|
10
|
+
findOne(id: number): Promise<T | undefined>;
|
|
11
|
+
update(id: number, payload: any): Promise<any>;
|
|
12
|
+
remove(id: number): Promise<void>;
|
|
13
|
+
findByOption(filter: OptionFilter): Promise<T[] | undefined>;
|
|
14
|
+
findOneByOption(filter: OptionFilter): Promise<T | null | undefined>;
|
|
15
|
+
findPaginate(filter: PaginationFilter): Promise<{
|
|
16
|
+
data: T[];
|
|
17
|
+
total: number;
|
|
18
|
+
total_pages: number;
|
|
19
|
+
} | undefined>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.BaseService = void 0;
|
|
22
|
+
const common_1 = require("@nestjs/common");
|
|
23
|
+
const typeorm_1 = require("typeorm");
|
|
24
|
+
let BaseService = class BaseService {
|
|
25
|
+
constructor(repository) {
|
|
26
|
+
this.repository = repository;
|
|
27
|
+
}
|
|
28
|
+
create(payload) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
const data = this.repository.create(payload);
|
|
32
|
+
const result = yield this.repository.save(data);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error instanceof Error) {
|
|
37
|
+
throw new common_1.InternalServerErrorException(error.message);
|
|
38
|
+
}
|
|
39
|
+
throw new common_1.InternalServerErrorException("An unknown error occurred");
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
findAll() {
|
|
44
|
+
return this.repository.find();
|
|
45
|
+
}
|
|
46
|
+
findOne(id) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
try {
|
|
49
|
+
const result = yield this.repository.findOne({
|
|
50
|
+
where: { id: id },
|
|
51
|
+
});
|
|
52
|
+
if (!result) {
|
|
53
|
+
throw new common_1.NotFoundException(`Entity with ID ${id} not found`);
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof Error) {
|
|
59
|
+
throw new common_1.InternalServerErrorException(error.message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
update(id, payload) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
try {
|
|
67
|
+
const data = yield this.findOne(id);
|
|
68
|
+
if (!data) {
|
|
69
|
+
throw new common_1.NotFoundException(`Entity with ID ${id} not found`);
|
|
70
|
+
}
|
|
71
|
+
const update = Object.assign(data, payload);
|
|
72
|
+
const result = yield this.repository.save(update);
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error instanceof Error) {
|
|
77
|
+
throw new common_1.InternalServerErrorException(error.message);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
remove(id) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
yield this.repository.delete(id);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
findByOption(filter) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
try {
|
|
90
|
+
const { select, where, relations, order } = filter;
|
|
91
|
+
const result = yield this.repository.find({
|
|
92
|
+
select,
|
|
93
|
+
where,
|
|
94
|
+
relations,
|
|
95
|
+
order,
|
|
96
|
+
});
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (error instanceof Error) {
|
|
101
|
+
throw new common_1.InternalServerErrorException(error.message);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
findOneByOption(filter) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
try {
|
|
109
|
+
const { select, where, relations, order } = filter;
|
|
110
|
+
const result = yield this.repository.findOne({
|
|
111
|
+
select,
|
|
112
|
+
where,
|
|
113
|
+
relations,
|
|
114
|
+
order,
|
|
115
|
+
});
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (error instanceof Error) {
|
|
120
|
+
throw new common_1.InternalServerErrorException(error.message);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
findPaginate(filter) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
try {
|
|
128
|
+
let { page, size, where, relations, order } = filter;
|
|
129
|
+
if (page === 0 || page === undefined)
|
|
130
|
+
page = 1;
|
|
131
|
+
const offset = page * size;
|
|
132
|
+
const [data, total] = yield this.repository.findAndCount({
|
|
133
|
+
where: where,
|
|
134
|
+
relations: relations,
|
|
135
|
+
order: order,
|
|
136
|
+
take: size,
|
|
137
|
+
skip: offset,
|
|
138
|
+
});
|
|
139
|
+
const totalPages = Math.ceil(total / size);
|
|
140
|
+
return {
|
|
141
|
+
data: data,
|
|
142
|
+
total: total,
|
|
143
|
+
total_pages: totalPages,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (error instanceof Error) {
|
|
148
|
+
throw new common_1.InternalServerErrorException(error.message);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
exports.BaseService = BaseService;
|
|
155
|
+
exports.BaseService = BaseService = __decorate([
|
|
156
|
+
(0, common_1.Injectable)(),
|
|
157
|
+
__metadata("design:paramtypes", [typeorm_1.Repository])
|
|
158
|
+
], BaseService);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DefaultColumn } from "../../../helper/default-column";
|
|
2
|
+
import { MasterQuestion } from "../../master_questions/entities/master_question.entity";
|
|
2
3
|
export declare class MasterAnswer extends DefaultColumn {
|
|
3
4
|
id?: number;
|
|
4
5
|
question_id?: string;
|
|
5
6
|
answer?: string;
|
|
6
7
|
correct?: boolean;
|
|
8
|
+
question?: MasterQuestion;
|
|
7
9
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.MasterAnswer = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const default_column_1 = require("../../../helper/default-column");
|
|
15
|
+
const master_question_entity_1 = require("../../master_questions/entities/master_question.entity");
|
|
15
16
|
let MasterAnswer = class MasterAnswer extends default_column_1.DefaultColumn {
|
|
16
17
|
};
|
|
17
18
|
exports.MasterAnswer = MasterAnswer;
|
|
@@ -31,6 +32,11 @@ __decorate([
|
|
|
31
32
|
(0, typeorm_1.Column)(),
|
|
32
33
|
__metadata("design:type", Boolean)
|
|
33
34
|
], MasterAnswer.prototype, "correct", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.ManyToOne)(() => master_question_entity_1.MasterQuestion, (q) => q.answers),
|
|
37
|
+
(0, typeorm_1.JoinColumn)({ name: "question_id", referencedColumnName: "id" }),
|
|
38
|
+
__metadata("design:type", master_question_entity_1.MasterQuestion)
|
|
39
|
+
], MasterAnswer.prototype, "question", void 0);
|
|
34
40
|
exports.MasterAnswer = MasterAnswer = __decorate([
|
|
35
41
|
(0, typeorm_1.Entity)({
|
|
36
42
|
schema: "library",
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import { CreateMasterAnswerDto } from "./dto/create-master_answer.dto";
|
|
2
|
-
import { UpdateMasterAnswerDto } from "./dto/update-master_answer.dto";
|
|
3
1
|
import { MasterAnswer } from "./entities/master_answer.entity";
|
|
4
2
|
import { Repository } from "typeorm";
|
|
5
|
-
import {
|
|
6
|
-
export declare class MasterAnswersService {
|
|
7
|
-
private readonly repository;
|
|
3
|
+
import { BaseService } from "../../helper/base-service";
|
|
4
|
+
export declare class MasterAnswersService extends BaseService<MasterAnswer> {
|
|
8
5
|
constructor(repository: Repository<MasterAnswer>);
|
|
9
|
-
create(payload: CreateMasterAnswerDto): Promise<MasterAnswer>;
|
|
10
|
-
findAll(): Promise<MasterAnswer[]>;
|
|
11
|
-
findOne(id: number): Promise<MasterAnswer | undefined>;
|
|
12
|
-
update(id: number, payload: UpdateMasterAnswerDto): Promise<(MasterAnswer & UpdateMasterAnswerDto) | undefined>;
|
|
13
|
-
remove(id: number): string;
|
|
14
|
-
findByOption(filter: OptionFilter): Promise<MasterAnswer[] | undefined>;
|
|
15
|
-
findOneByOption(filter: OptionFilter): Promise<MasterAnswer | null | undefined>;
|
|
16
6
|
}
|
|
@@ -11,121 +11,16 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
15
|
exports.MasterAnswersService = void 0;
|
|
25
16
|
const common_1 = require("@nestjs/common");
|
|
26
17
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
27
18
|
const master_answer_entity_1 = require("./entities/master_answer.entity");
|
|
28
19
|
const typeorm_2 = require("typeorm");
|
|
29
|
-
|
|
20
|
+
const base_service_1 = require("../../helper/base-service");
|
|
21
|
+
let MasterAnswersService = class MasterAnswersService extends base_service_1.BaseService {
|
|
30
22
|
constructor(repository) {
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
create(payload) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
try {
|
|
36
|
-
const data = this.repository.create(payload);
|
|
37
|
-
const result = yield this.repository.save(data);
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
if (error instanceof Error) {
|
|
42
|
-
throw new common_1.InternalServerErrorException(error.message);
|
|
43
|
-
}
|
|
44
|
-
throw new common_1.InternalServerErrorException("An unknown error occurred");
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
findAll() {
|
|
49
|
-
return this.repository.find();
|
|
50
|
-
}
|
|
51
|
-
findOne(id) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
try {
|
|
54
|
-
const result = yield this.repository.findOne({
|
|
55
|
-
where: {
|
|
56
|
-
id: id,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
if (!result) {
|
|
60
|
-
throw new common_1.NotFoundException(`answer with ID ${id} not found`);
|
|
61
|
-
}
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
if (error instanceof Error) {
|
|
66
|
-
throw new common_1.InternalServerErrorException(error.message);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
update(id, payload) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
try {
|
|
74
|
-
const data = yield this.findOne(id);
|
|
75
|
-
if (!data) {
|
|
76
|
-
throw new common_1.NotFoundException(`MasterQuestion with ID ${id} not found`);
|
|
77
|
-
}
|
|
78
|
-
const update = Object.assign(data, payload);
|
|
79
|
-
const result = yield this.repository.save(update);
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
if (error instanceof Error) {
|
|
84
|
-
throw new common_1.InternalServerErrorException(error.message);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
remove(id) {
|
|
90
|
-
return `This action removes a #${id} masterAnswer`;
|
|
91
|
-
}
|
|
92
|
-
findByOption(filter) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
try {
|
|
95
|
-
const { select, where, relations, order } = filter;
|
|
96
|
-
const result = yield this.repository.find({
|
|
97
|
-
select: select,
|
|
98
|
-
where: where,
|
|
99
|
-
relations: relations,
|
|
100
|
-
order: order,
|
|
101
|
-
});
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
if (error instanceof Error) {
|
|
106
|
-
throw new common_1.InternalServerErrorException(error.message);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
findOneByOption(filter) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
try {
|
|
114
|
-
const { select, where, relations, order } = filter;
|
|
115
|
-
const result = yield this.repository.findOne({
|
|
116
|
-
select: select,
|
|
117
|
-
where: where,
|
|
118
|
-
relations: relations,
|
|
119
|
-
order: order,
|
|
120
|
-
});
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
if (error instanceof Error) {
|
|
125
|
-
throw new common_1.InternalServerErrorException(error.message);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
23
|
+
super(repository);
|
|
129
24
|
}
|
|
130
25
|
};
|
|
131
26
|
exports.MasterAnswersService = MasterAnswersService;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { DefaultColumn } from "../../../helper/default-column";
|
|
2
|
+
import { MasterAnswer } from "../../master_answers/entities/master_answer.entity";
|
|
2
3
|
export declare class MasterQuestion extends DefaultColumn {
|
|
3
4
|
id?: number;
|
|
4
5
|
question?: string;
|
|
6
|
+
type?: string;
|
|
5
7
|
image_url?: string;
|
|
6
8
|
rank?: string;
|
|
7
9
|
vessel_type?: string;
|
|
10
|
+
answers?: MasterAnswer[];
|
|
8
11
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.MasterQuestion = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const default_column_1 = require("../../../helper/default-column");
|
|
15
|
+
const master_answer_entity_1 = require("../../master_answers/entities/master_answer.entity");
|
|
15
16
|
let MasterQuestion = class MasterQuestion extends default_column_1.DefaultColumn {
|
|
16
17
|
};
|
|
17
18
|
exports.MasterQuestion = MasterQuestion;
|
|
@@ -23,6 +24,10 @@ __decorate([
|
|
|
23
24
|
(0, typeorm_1.Column)(),
|
|
24
25
|
__metadata("design:type", String)
|
|
25
26
|
], MasterQuestion.prototype, "question", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, typeorm_1.Column)(),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], MasterQuestion.prototype, "type", void 0);
|
|
26
31
|
__decorate([
|
|
27
32
|
(0, typeorm_1.Column)(),
|
|
28
33
|
__metadata("design:type", String)
|
|
@@ -35,6 +40,10 @@ __decorate([
|
|
|
35
40
|
(0, typeorm_1.Column)({ array: true }),
|
|
36
41
|
__metadata("design:type", String)
|
|
37
42
|
], MasterQuestion.prototype, "vessel_type", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.OneToMany)(() => master_answer_entity_1.MasterAnswer, (q) => q.question),
|
|
45
|
+
__metadata("design:type", Array)
|
|
46
|
+
], MasterQuestion.prototype, "answers", void 0);
|
|
38
47
|
exports.MasterQuestion = MasterQuestion = __decorate([
|
|
39
48
|
(0, typeorm_1.Entity)({ schema: "library", name: "master_questions" })
|
|
40
49
|
], MasterQuestion);
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import { CreateMasterQuestionDto } from "./dto/create-master_question.dto";
|
|
2
|
-
import { UpdateMasterQuestionDto } from "./dto/update-master_question.dto";
|
|
3
1
|
import { MasterQuestion } from "./entities/master_question.entity";
|
|
4
2
|
import { Repository } from "typeorm";
|
|
5
|
-
import {
|
|
6
|
-
export declare class MasterQuestionsService {
|
|
7
|
-
private readonly repository;
|
|
3
|
+
import { BaseService } from "../../helper/base-service";
|
|
4
|
+
export declare class MasterQuestionsService extends BaseService<MasterQuestion> {
|
|
8
5
|
constructor(repository: Repository<MasterQuestion>);
|
|
9
|
-
create(payload: CreateMasterQuestionDto): Promise<MasterQuestion>;
|
|
10
|
-
findAll(): Promise<MasterQuestion[]>;
|
|
11
|
-
findOne(id: number): Promise<MasterQuestion | undefined>;
|
|
12
|
-
update(id: number, payload: UpdateMasterQuestionDto): Promise<(MasterQuestion & UpdateMasterQuestionDto) | undefined>;
|
|
13
|
-
remove(id: number): Promise<import("typeorm").DeleteResult>;
|
|
14
|
-
findByOption(filter: OptionFilter): Promise<MasterQuestion[] | undefined>;
|
|
15
|
-
findOneByOption(filter: OptionFilter): Promise<MasterQuestion | null | undefined>;
|
|
16
6
|
}
|
|
@@ -11,117 +11,16 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
15
|
exports.MasterQuestionsService = void 0;
|
|
25
16
|
const common_1 = require("@nestjs/common");
|
|
26
17
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
27
18
|
const master_question_entity_1 = require("./entities/master_question.entity");
|
|
28
19
|
const typeorm_2 = require("typeorm");
|
|
29
|
-
|
|
20
|
+
const base_service_1 = require("../../helper/base-service");
|
|
21
|
+
let MasterQuestionsService = class MasterQuestionsService extends base_service_1.BaseService {
|
|
30
22
|
constructor(repository) {
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
create(payload) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
try {
|
|
36
|
-
const data = this.repository.create(payload);
|
|
37
|
-
const result = yield this.repository.save(data);
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
if (error instanceof Error) {
|
|
42
|
-
throw new common_1.InternalServerErrorException(error.message);
|
|
43
|
-
}
|
|
44
|
-
throw new common_1.InternalServerErrorException("An unknown error occurred");
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
findAll() {
|
|
49
|
-
return this.repository.find();
|
|
50
|
-
}
|
|
51
|
-
findOne(id) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
try {
|
|
54
|
-
const result = yield this.repository.findOne({
|
|
55
|
-
where: {
|
|
56
|
-
id: id,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
if (!result) {
|
|
60
|
-
throw new common_1.NotFoundException(`MasterQuestion with ID ${id} not found`);
|
|
61
|
-
}
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
catch (error) { }
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
update(id, payload) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
try {
|
|
70
|
-
const data = yield this.findOne(id);
|
|
71
|
-
if (!data) {
|
|
72
|
-
throw new common_1.NotFoundException(`MasterQuestion with ID ${id} not found`);
|
|
73
|
-
}
|
|
74
|
-
const update = Object.assign(data, payload);
|
|
75
|
-
const result = yield this.repository.save(update);
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
if (error instanceof Error) {
|
|
80
|
-
throw new common_1.InternalServerErrorException(error.message);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
remove(id) {
|
|
86
|
-
return this.repository.delete(id);
|
|
87
|
-
}
|
|
88
|
-
findByOption(filter) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
try {
|
|
91
|
-
const { select, where, relations, order } = filter;
|
|
92
|
-
const result = yield this.repository.find({
|
|
93
|
-
select: select,
|
|
94
|
-
where: where,
|
|
95
|
-
relations: relations,
|
|
96
|
-
order: order,
|
|
97
|
-
});
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
if (error instanceof Error) {
|
|
102
|
-
throw new common_1.InternalServerErrorException(error.message);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
findOneByOption(filter) {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
try {
|
|
110
|
-
const { select, where, relations, order } = filter;
|
|
111
|
-
const result = yield this.repository.findOne({
|
|
112
|
-
select: select,
|
|
113
|
-
where: where,
|
|
114
|
-
relations: relations,
|
|
115
|
-
order: order,
|
|
116
|
-
});
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
if (error instanceof Error) {
|
|
121
|
-
throw new common_1.InternalServerErrorException(error.message);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
23
|
+
super(repository);
|
|
125
24
|
}
|
|
126
25
|
};
|
|
127
26
|
exports.MasterQuestionsService = MasterQuestionsService;
|
|
@@ -8,14 +8,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.SharedModelModule = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
|
-
// import { SharedModelService } from "./shared-model.service";
|
|
12
11
|
const library_module_1 = require("./library/library.module");
|
|
13
12
|
let SharedModelModule = class SharedModelModule {
|
|
14
13
|
};
|
|
15
14
|
exports.SharedModelModule = SharedModelModule;
|
|
16
15
|
exports.SharedModelModule = SharedModelModule = __decorate([
|
|
17
16
|
(0, common_1.Module)({
|
|
18
|
-
// providers: [SharedModelService],
|
|
19
17
|
imports: [library_module_1.LibraryModule],
|
|
20
18
|
exports: [library_module_1.LibraryModule],
|
|
21
19
|
})
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oca-shared-model",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "onboard shared model",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "nest build",
|
|
8
8
|
"clean": "rm -rf dist",
|
|
9
9
|
"predeploy": "npm run clean && npm version patch && npm run build",
|
|
10
|
+
"deploy": "npm publish",
|
|
10
11
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
12
|
},
|
|
12
13
|
"author": "DONO",
|