@hed-hog/faq 0.0.3 → 0.0.4
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/dto/faq.dto.d.ts +4 -2
- package/dist/dto/faq.dto.d.ts.map +1 -1
- package/dist/dto/faq.dto.js +3 -8
- package/dist/dto/faq.dto.js.map +1 -1
- package/dist/faq.controller.d.ts +3 -34
- package/dist/faq.controller.d.ts.map +1 -1
- package/dist/faq.controller.js +9 -12
- package/dist/faq.controller.js.map +1 -1
- package/dist/faq.service.d.ts +3 -34
- package/dist/faq.service.d.ts.map +1 -1
- package/dist/faq.service.js +7 -57
- package/dist/faq.service.js.map +1 -1
- package/hedhog/table/faq.yaml +4 -1
- package/package.json +1 -1
- package/src/dto/faq.dto.ts +3 -7
- package/src/faq.controller.ts +3 -6
- package/src/faq.service.ts +7 -68
package/dist/dto/faq.dto.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faq.dto.d.ts","sourceRoot":"","sources":["../../src/dto/faq.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,MAAM;IAGf,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"faq.dto.d.ts","sourceRoot":"","sources":["../../src/dto/faq.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,MAAM;IAGf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChE"}
|
package/dist/dto/faq.dto.js
CHANGED
|
@@ -15,13 +15,8 @@ class FAQDTO {
|
|
|
15
15
|
}
|
|
16
16
|
exports.FAQDTO = FAQDTO;
|
|
17
17
|
__decorate([
|
|
18
|
-
(0, class_validator_1.
|
|
18
|
+
(0, class_validator_1.IsObject)(),
|
|
19
19
|
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
-
__metadata("design:type",
|
|
21
|
-
], FAQDTO.prototype, "
|
|
22
|
-
__decorate([
|
|
23
|
-
(0, class_validator_1.IsString)(),
|
|
24
|
-
(0, class_validator_1.IsNotEmpty)(),
|
|
25
|
-
__metadata("design:type", String)
|
|
26
|
-
], FAQDTO.prototype, "answer", void 0);
|
|
20
|
+
__metadata("design:type", Object)
|
|
21
|
+
], FAQDTO.prototype, "locale", void 0);
|
|
27
22
|
//# sourceMappingURL=faq.dto.js.map
|
package/dist/dto/faq.dto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faq.dto.js","sourceRoot":"","sources":["../../src/dto/faq.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,MAAM;
|
|
1
|
+
{"version":3,"file":"faq.dto.js","sourceRoot":"","sources":["../../src/dto/faq.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,MAAM;CAIlB;AAJD,wBAIC;AADG;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;sCACgD"}
|
package/dist/faq.controller.d.ts
CHANGED
|
@@ -15,40 +15,9 @@ export declare class FAQController {
|
|
|
15
15
|
getFAQStats(): Promise<{
|
|
16
16
|
total: number;
|
|
17
17
|
}>;
|
|
18
|
-
getById(id: number
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
created_at: Date;
|
|
22
|
-
locale_id: number;
|
|
23
|
-
updated_at: Date;
|
|
24
|
-
faq_id: number;
|
|
25
|
-
question: string;
|
|
26
|
-
answer: string;
|
|
27
|
-
}[];
|
|
28
|
-
} & {
|
|
29
|
-
id: number;
|
|
30
|
-
created_at: Date;
|
|
31
|
-
updated_at: Date;
|
|
32
|
-
}>;
|
|
33
|
-
create(body: FAQDTO, locale: string): Promise<{
|
|
34
|
-
faq_locale: {
|
|
35
|
-
id: number;
|
|
36
|
-
created_at: Date;
|
|
37
|
-
locale_id: number;
|
|
38
|
-
updated_at: Date;
|
|
39
|
-
faq_id: number;
|
|
40
|
-
question: string;
|
|
41
|
-
answer: string;
|
|
42
|
-
}[];
|
|
43
|
-
} & {
|
|
44
|
-
id: number;
|
|
45
|
-
created_at: Date;
|
|
46
|
-
updated_at: Date;
|
|
47
|
-
}>;
|
|
48
|
-
update(id: number, body: Partial<FAQDTO>, locale: string): Promise<{
|
|
49
|
-
updated: number;
|
|
50
|
-
message: string;
|
|
51
|
-
}>;
|
|
18
|
+
getById(id: number): Promise<any>;
|
|
19
|
+
create(body: FAQDTO): Promise<any>;
|
|
20
|
+
update(id: number, body: Partial<FAQDTO>): Promise<any>;
|
|
52
21
|
delete(id: number): Promise<{
|
|
53
22
|
deleted: boolean;
|
|
54
23
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faq.controller.d.ts","sourceRoot":"","sources":["../src/faq.controller.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,qBACa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAG7C,IAAI,CACM,gBAAgB,KAAA,EACpB,MAAM,EAAE,MAAM;;;;;;;;;IAMpB,WAAW;;;IAKX,OAAO,CACgB,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"faq.controller.d.ts","sourceRoot":"","sources":["../src/faq.controller.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,qBACa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAG7C,IAAI,CACM,gBAAgB,KAAA,EACpB,MAAM,EAAE,MAAM;;;;;;;;;IAMpB,WAAW;;;IAKX,OAAO,CACgB,EAAE,EAAE,MAAM;IAYjC,MAAM,CACF,IAAI,EAAE,MAAM;IAMhB,MAAM,CACiB,EAAE,EAAE,MAAM,EAC7B,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;IAMzB,MAAM,CAA4B,EAAE,EAAE,MAAM;;;;CAGnD"}
|
package/dist/faq.controller.js
CHANGED
|
@@ -28,18 +28,18 @@ let FAQController = class FAQController {
|
|
|
28
28
|
async getFAQStats() {
|
|
29
29
|
return this.faqService.getStats();
|
|
30
30
|
}
|
|
31
|
-
async getById(id
|
|
32
|
-
const faq = await this.faqService.getById(id
|
|
31
|
+
async getById(id) {
|
|
32
|
+
const faq = await this.faqService.getById(id);
|
|
33
33
|
if (!faq) {
|
|
34
34
|
throw new common_1.NotFoundException('FAQ not found');
|
|
35
35
|
}
|
|
36
36
|
return faq;
|
|
37
37
|
}
|
|
38
|
-
async create(body
|
|
39
|
-
return this.faqService.create(body
|
|
38
|
+
async create(body) {
|
|
39
|
+
return this.faqService.create(body);
|
|
40
40
|
}
|
|
41
|
-
async update(id, body
|
|
42
|
-
return this.faqService.update(id, body
|
|
41
|
+
async update(id, body) {
|
|
42
|
+
return this.faqService.update(id, body);
|
|
43
43
|
}
|
|
44
44
|
async delete(id) {
|
|
45
45
|
return this.faqService.delete(id);
|
|
@@ -63,26 +63,23 @@ __decorate([
|
|
|
63
63
|
__decorate([
|
|
64
64
|
(0, common_1.Get)(':id'),
|
|
65
65
|
__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
|
|
66
|
-
__param(1, (0, api_locale_1.Locale)()),
|
|
67
66
|
__metadata("design:type", Function),
|
|
68
|
-
__metadata("design:paramtypes", [Number
|
|
67
|
+
__metadata("design:paramtypes", [Number]),
|
|
69
68
|
__metadata("design:returntype", Promise)
|
|
70
69
|
], FAQController.prototype, "getById", null);
|
|
71
70
|
__decorate([
|
|
72
71
|
(0, common_1.Post)(),
|
|
73
72
|
__param(0, (0, common_1.Body)()),
|
|
74
|
-
__param(1, (0, api_locale_1.Locale)()),
|
|
75
73
|
__metadata("design:type", Function),
|
|
76
|
-
__metadata("design:paramtypes", [faq_dto_1.FAQDTO
|
|
74
|
+
__metadata("design:paramtypes", [faq_dto_1.FAQDTO]),
|
|
77
75
|
__metadata("design:returntype", Promise)
|
|
78
76
|
], FAQController.prototype, "create", null);
|
|
79
77
|
__decorate([
|
|
80
78
|
(0, common_1.Patch)(':id'),
|
|
81
79
|
__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
|
|
82
80
|
__param(1, (0, common_1.Body)()),
|
|
83
|
-
__param(2, (0, api_locale_1.Locale)()),
|
|
84
81
|
__metadata("design:type", Function),
|
|
85
|
-
__metadata("design:paramtypes", [Number, Object
|
|
82
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
86
83
|
__metadata("design:returntype", Promise)
|
|
87
84
|
], FAQController.prototype, "update", null);
|
|
88
85
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faq.controller.js","sourceRoot":"","sources":["../src/faq.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA6C;AAC7C,4DAAqD;AACrD,2CAUwB;AACxB,2CAAuC;AACvC,+CAA2C;AAGpC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAI,CAAC;IAGlD,AAAN,KAAK,CAAC,IAAI,CACM,gBAAgB,EACpB,MAAc;QAEzB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAA;IACtD,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAA;IACnC,CAAC;IAGK,AAAN,KAAK,CAAC,OAAO,CACgB,EAAU
|
|
1
|
+
{"version":3,"file":"faq.controller.js","sourceRoot":"","sources":["../src/faq.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA6C;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O,CAAC;;;;gDAGZ;AAGK;IADL,IAAA,YAAG,EAAC,KAAK,CAAC;IAER,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;;;;4CAS3B;AAGK;IADL,IAAA,aAAI,GAAE;IAEJ,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,gBAAM;;2CAGrB;AAGK;IADL,IAAA,cAAK,EAAC,KAAK,CAAC;IAEV,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;IACzB,WAAA,IAAA,aAAI,GAAE,CAAA;;;;2CAGR;AAGK;IADL,IAAA,eAAM,EAAC,KAAK,CAAC;IACA,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;;;;2CAEtC;wBA/CU,aAAa;IADzB,IAAA,mBAAU,EAAC,KAAK,CAAC;qCAEyB,wBAAU;GADxC,aAAa,CAgDzB"}
|
package/dist/faq.service.d.ts
CHANGED
|
@@ -17,40 +17,9 @@ export declare class FAQService {
|
|
|
17
17
|
getStats(): Promise<{
|
|
18
18
|
total: number;
|
|
19
19
|
}>;
|
|
20
|
-
create(body: FAQDTO
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
created_at: Date;
|
|
24
|
-
locale_id: number;
|
|
25
|
-
updated_at: Date;
|
|
26
|
-
faq_id: number;
|
|
27
|
-
question: string;
|
|
28
|
-
answer: string;
|
|
29
|
-
}[];
|
|
30
|
-
} & {
|
|
31
|
-
id: number;
|
|
32
|
-
created_at: Date;
|
|
33
|
-
updated_at: Date;
|
|
34
|
-
}>;
|
|
35
|
-
getById(id: number, locale: string): Promise<{
|
|
36
|
-
faq_locale: {
|
|
37
|
-
id: number;
|
|
38
|
-
created_at: Date;
|
|
39
|
-
locale_id: number;
|
|
40
|
-
updated_at: Date;
|
|
41
|
-
faq_id: number;
|
|
42
|
-
question: string;
|
|
43
|
-
answer: string;
|
|
44
|
-
}[];
|
|
45
|
-
} & {
|
|
46
|
-
id: number;
|
|
47
|
-
created_at: Date;
|
|
48
|
-
updated_at: Date;
|
|
49
|
-
}>;
|
|
50
|
-
update(id: number, body: Partial<FAQDTO>, locale: string): Promise<{
|
|
51
|
-
updated: number;
|
|
52
|
-
message: string;
|
|
53
|
-
}>;
|
|
20
|
+
create(body: FAQDTO): Promise<any>;
|
|
21
|
+
getById(id: number): Promise<any>;
|
|
22
|
+
update(id: number, body: Partial<FAQDTO>): Promise<any>;
|
|
54
23
|
delete(id: number): Promise<{
|
|
55
24
|
deleted: boolean;
|
|
56
25
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faq.service.d.ts","sourceRoot":"","sources":["../src/faq.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,qBACa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAFb,MAAM,EAAE,aAAa,EAErB,aAAa,EAAE,aAAa;IAGzC,IAAI,CAAC,gBAAgB,KAAA,EAAE,MAAM,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"faq.service.d.ts","sourceRoot":"","sources":["../src/faq.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,qBACa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAFb,MAAM,EAAE,aAAa,EAErB,aAAa,EAAE,aAAa;IAGzC,IAAI,CAAC,gBAAgB,KAAA,EAAE,MAAM,EAAE,MAAM;cAkEzB,GAAG,EAAE;;;;;;;;IAUjB,QAAQ;;;IAOR,MAAM,CAAC,IAAI,EAAE,MAAM;IAInB,OAAO,CAAC,EAAE,EAAE,MAAM;IAIlB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;IAIxC,MAAM,CAAC,EAAE,EAAE,MAAM;;;;CAqBxB"}
|
package/dist/faq.service.js
CHANGED
|
@@ -43,8 +43,7 @@ let FAQService = class FAQService {
|
|
|
43
43
|
ON fl.faq_id = f.id
|
|
44
44
|
WHERE fl.locale_id = ${localeId}
|
|
45
45
|
AND (
|
|
46
|
-
LOWER(
|
|
47
|
-
OR LOWER(fl.question) LIKE ${like}
|
|
46
|
+
LOWER(fl.question) LIKE ${like}
|
|
48
47
|
OR LOWER(fl.answer) LIKE ${like}
|
|
49
48
|
)
|
|
50
49
|
ORDER BY f.id DESC
|
|
@@ -95,63 +94,14 @@ let FAQService = class FAQService {
|
|
|
95
94
|
total,
|
|
96
95
|
};
|
|
97
96
|
}
|
|
98
|
-
async create(body
|
|
99
|
-
|
|
100
|
-
if (!localeRecord) {
|
|
101
|
-
throw new Error(`Locale ${locale} not found`);
|
|
102
|
-
}
|
|
103
|
-
const { question, answer } = body;
|
|
104
|
-
const faq = await this.prisma.faq.create({
|
|
105
|
-
data: {
|
|
106
|
-
faq_locale: {
|
|
107
|
-
create: {
|
|
108
|
-
locale_id: localeRecord.id,
|
|
109
|
-
question,
|
|
110
|
-
answer,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
include: {
|
|
115
|
-
faq_locale: true,
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
return faq;
|
|
97
|
+
async create(body) {
|
|
98
|
+
return this.localeService.createModelWithLocale('faq', 'faq_id', body);
|
|
119
99
|
}
|
|
120
|
-
async getById(id
|
|
121
|
-
|
|
122
|
-
if (!localeRecord) {
|
|
123
|
-
throw new Error(`Locale ${locale} not found`);
|
|
124
|
-
}
|
|
125
|
-
const faq = await this.prisma.faq.findUnique({
|
|
126
|
-
where: { id },
|
|
127
|
-
include: {
|
|
128
|
-
faq_locale: {
|
|
129
|
-
where: { locale_id: localeRecord.id },
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
if (!faq) {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
return faq;
|
|
100
|
+
async getById(id) {
|
|
101
|
+
return this.localeService.getModelWithLocale('faq', id);
|
|
137
102
|
}
|
|
138
|
-
async update(id, body
|
|
139
|
-
|
|
140
|
-
if (!localeRecord) {
|
|
141
|
-
throw new Error(`Locale ${locale} not found`);
|
|
142
|
-
}
|
|
143
|
-
const { question, answer } = body;
|
|
144
|
-
const updated = await this.prisma.faq_locale.updateMany({
|
|
145
|
-
where: {
|
|
146
|
-
faq_id: id,
|
|
147
|
-
locale_id: localeRecord.id,
|
|
148
|
-
},
|
|
149
|
-
data: Object.assign(Object.assign({}, (question && { question })), (answer && { answer })),
|
|
150
|
-
});
|
|
151
|
-
return {
|
|
152
|
-
updated: updated.count,
|
|
153
|
-
message: updated.count > 0 ? 'FAQ updated successfully' : 'FAQ not found',
|
|
154
|
-
};
|
|
103
|
+
async update(id, body) {
|
|
104
|
+
return this.localeService.updateModelWithLocale('faq', 'faq_id', id, body);
|
|
155
105
|
}
|
|
156
106
|
async delete(id) {
|
|
157
107
|
const faq = await this.prisma.faq.findUnique({
|
package/dist/faq.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faq.service.js","sourceRoot":"","sources":["../src/faq.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoD;AACpD,oDAAoD;AACpD,2CAAgE;AAIzD,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YACmB,MAAqB,EAErB,aAA4B;QAF5B,WAAM,GAAN,MAAM,CAAe;QAErB,kBAAa,GAAb,aAAa,CAAe;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,aAAa,CAAC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;YAC3C,KAAK,EAAE,EAAE,EAAE,EAAE;SACd,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,eAAe;aACzB,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YAC3B,KAAK,EAAE,EAAE,EAAE,EAAE;SACd,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,0BAA0B;SACpC,CAAC;IACJ,CAAC;CACF,CAAA;AA3HY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;qCADf,0BAAa;QAEN,0BAAa;GAJpC,UAAU,CA2HtB"}
|
package/hedhog/table/faq.yaml
CHANGED
package/package.json
CHANGED
package/src/dto/faq.dto.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { IsNotEmpty,
|
|
1
|
+
import { IsNotEmpty, IsObject } from "class-validator";
|
|
2
2
|
|
|
3
3
|
export class FAQDTO{
|
|
4
|
-
@
|
|
4
|
+
@IsObject()
|
|
5
5
|
@IsNotEmpty()
|
|
6
|
-
question: string;
|
|
7
|
-
|
|
8
|
-
@IsString()
|
|
9
|
-
@IsNotEmpty()
|
|
10
|
-
answer: string;
|
|
6
|
+
locale: Record<string, { question: string; answer: string }>;
|
|
11
7
|
}
|
package/src/faq.controller.ts
CHANGED
|
@@ -34,9 +34,8 @@ export class FAQController {
|
|
|
34
34
|
@Get(':id')
|
|
35
35
|
async getById(
|
|
36
36
|
@Param('id', ParseIntPipe) id: number,
|
|
37
|
-
@Locale() locale: string,
|
|
38
37
|
) {
|
|
39
|
-
const faq = await this.faqService.getById(id
|
|
38
|
+
const faq = await this.faqService.getById(id);
|
|
40
39
|
|
|
41
40
|
if (!faq) {
|
|
42
41
|
throw new NotFoundException('FAQ not found');
|
|
@@ -48,18 +47,16 @@ export class FAQController {
|
|
|
48
47
|
@Post()
|
|
49
48
|
async create(
|
|
50
49
|
@Body() body: FAQDTO,
|
|
51
|
-
@Locale() locale: string,
|
|
52
50
|
) {
|
|
53
|
-
return this.faqService.create(body
|
|
51
|
+
return this.faqService.create(body)
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
@Patch(':id')
|
|
57
55
|
async update(
|
|
58
56
|
@Param('id', ParseIntPipe) id: number,
|
|
59
57
|
@Body() body: Partial<FAQDTO>,
|
|
60
|
-
@Locale() locale: string,
|
|
61
58
|
) {
|
|
62
|
-
return this.faqService.update(id, body
|
|
59
|
+
return this.faqService.update(id, body);
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
@Delete(':id')
|
package/src/faq.service.ts
CHANGED
|
@@ -34,8 +34,7 @@ export class FAQService {
|
|
|
34
34
|
ON fl.faq_id = f.id
|
|
35
35
|
WHERE fl.locale_id = ${localeId}
|
|
36
36
|
AND (
|
|
37
|
-
LOWER(
|
|
38
|
-
OR LOWER(fl.question) LIKE ${like}
|
|
37
|
+
LOWER(fl.question) LIKE ${like}
|
|
39
38
|
OR LOWER(fl.answer) LIKE ${like}
|
|
40
39
|
)
|
|
41
40
|
ORDER BY f.id DESC
|
|
@@ -95,76 +94,16 @@ export class FAQService {
|
|
|
95
94
|
};
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
async create(body: FAQDTO
|
|
99
|
-
|
|
100
|
-
if (!localeRecord) {
|
|
101
|
-
throw new Error(`Locale ${locale} not found`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const { question, answer } = body;
|
|
105
|
-
const faq = await this.prisma.faq.create({
|
|
106
|
-
data: {
|
|
107
|
-
faq_locale: {
|
|
108
|
-
create: {
|
|
109
|
-
locale_id: localeRecord.id,
|
|
110
|
-
question,
|
|
111
|
-
answer,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
include: {
|
|
116
|
-
faq_locale: true,
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
return faq;
|
|
97
|
+
async create(body: FAQDTO){
|
|
98
|
+
return this.localeService.createModelWithLocale('faq', 'faq_id', body);
|
|
121
99
|
}
|
|
122
100
|
|
|
123
|
-
async getById(id: number
|
|
124
|
-
|
|
125
|
-
if (!localeRecord) {
|
|
126
|
-
throw new Error(`Locale ${locale} not found`);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const faq = await this.prisma.faq.findUnique({
|
|
130
|
-
where: { id },
|
|
131
|
-
include: {
|
|
132
|
-
faq_locale: {
|
|
133
|
-
where: { locale_id: localeRecord.id },
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
if (!faq) {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return faq;
|
|
101
|
+
async getById(id: number){
|
|
102
|
+
return this.localeService.getModelWithLocale('faq', id);
|
|
143
103
|
}
|
|
144
104
|
|
|
145
|
-
async update(id: number, body: Partial<FAQDTO
|
|
146
|
-
|
|
147
|
-
if (!localeRecord) {
|
|
148
|
-
throw new Error(`Locale ${locale} not found`);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const { question, answer } = body;
|
|
152
|
-
|
|
153
|
-
const updated = await this.prisma.faq_locale.updateMany({
|
|
154
|
-
where: {
|
|
155
|
-
faq_id: id,
|
|
156
|
-
locale_id: localeRecord.id,
|
|
157
|
-
},
|
|
158
|
-
data: {
|
|
159
|
-
...(question && { question }),
|
|
160
|
-
...(answer && { answer }),
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
return {
|
|
165
|
-
updated: updated.count,
|
|
166
|
-
message: updated.count > 0 ? 'FAQ updated successfully' : 'FAQ not found',
|
|
167
|
-
};
|
|
105
|
+
async update(id: number, body: Partial<FAQDTO>){
|
|
106
|
+
return this.localeService.updateModelWithLocale('faq', 'faq_id', id, body);
|
|
168
107
|
}
|
|
169
108
|
|
|
170
109
|
async delete(id: number){
|