@platform-modules/foreign-ministry 1.0.34 → 1.0.36
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/.env +2 -2
- package/dist/data-source.js +9 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/models/CategoriesModel.d.ts +6 -0
- package/dist/models/CategoriesModel.js +34 -0
- package/dist/models/CommentsModel.d.ts +16 -0
- package/dist/models/CommentsModel.js +75 -0
- package/dist/models/PostAttachmentsModel.d.ts +9 -0
- package/dist/models/PostAttachmentsModel.js +45 -0
- package/dist/models/PostsModel.d.ts +21 -0
- package/dist/models/PostsModel.js +87 -0
- package/package.json +1 -1
- package/src/data-source.ts +11 -1
- package/src/index.ts +4 -0
- package/src/models/CategoriesModel.ts +18 -0
- package/src/models/CommentsModel.ts +52 -0
- package/src/models/PostAttachmentsModel.ts +28 -0
- package/src/models/PostsModel.ts +62 -0
package/.env
CHANGED
package/dist/data-source.js
CHANGED
|
@@ -33,6 +33,10 @@ const FMServices_1 = require("./models/FMServices");
|
|
|
33
33
|
const FMSubservices_1 = require("./models/FMSubservices");
|
|
34
34
|
const serviceBookmarksModel_1 = require("./models/serviceBookmarksModel");
|
|
35
35
|
const feedbackModel_1 = require("./models/feedbackModel");
|
|
36
|
+
const CategoriesModel_1 = require("./models/CategoriesModel");
|
|
37
|
+
const PostsModel_1 = require("./models/PostsModel");
|
|
38
|
+
const CommentsModel_1 = require("./models/CommentsModel");
|
|
39
|
+
const PostAttachmentsModel_1 = require("./models/PostAttachmentsModel");
|
|
36
40
|
exports.AppDataSource = new typeorm_1.DataSource({
|
|
37
41
|
type: 'postgres',
|
|
38
42
|
host: process.env.DB_HOST || 'localhost',
|
|
@@ -70,6 +74,10 @@ exports.AppDataSource = new typeorm_1.DataSource({
|
|
|
70
74
|
FMServices_1.FMServices,
|
|
71
75
|
FMSubservices_1.FMSubServices,
|
|
72
76
|
serviceBookmarksModel_1.ServiceBookmarks,
|
|
73
|
-
feedbackModel_1.Feedback
|
|
77
|
+
feedbackModel_1.Feedback,
|
|
78
|
+
CategoriesModel_1.Categories,
|
|
79
|
+
PostsModel_1.Posts,
|
|
80
|
+
CommentsModel_1.Comments,
|
|
81
|
+
PostAttachmentsModel_1.PostAttachments
|
|
74
82
|
],
|
|
75
83
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -26,3 +26,7 @@ export * from './models/FMServices';
|
|
|
26
26
|
export * from './models/FMSubservices';
|
|
27
27
|
export * from './models/serviceBookmarksModel';
|
|
28
28
|
export * from './models/feedbackModel';
|
|
29
|
+
export * from './models/CategoriesModel';
|
|
30
|
+
export * from './models/PostsModel';
|
|
31
|
+
export * from './models/CommentsModel';
|
|
32
|
+
export * from './models/PostAttachmentsModel';
|
package/dist/index.js
CHANGED
|
@@ -42,3 +42,7 @@ __exportStar(require("./models/FMServices"), exports);
|
|
|
42
42
|
__exportStar(require("./models/FMSubservices"), exports);
|
|
43
43
|
__exportStar(require("./models/serviceBookmarksModel"), exports);
|
|
44
44
|
__exportStar(require("./models/feedbackModel"), exports);
|
|
45
|
+
__exportStar(require("./models/CategoriesModel"), exports);
|
|
46
|
+
__exportStar(require("./models/PostsModel"), exports);
|
|
47
|
+
__exportStar(require("./models/CommentsModel"), exports);
|
|
48
|
+
__exportStar(require("./models/PostAttachmentsModel"), exports);
|
|
@@ -0,0 +1,34 @@
|
|
|
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.Categories = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const BaseModel_1 = require("./BaseModel");
|
|
15
|
+
let Categories = class Categories extends BaseModel_1.BaseModel {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.name = '';
|
|
19
|
+
this.description = '';
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.Categories = Categories;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 150, nullable: false, unique: true }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], Categories.prototype, "name", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], Categories.prototype, "description", void 0);
|
|
31
|
+
exports.Categories = Categories = __decorate([
|
|
32
|
+
(0, typeorm_1.Entity)({ name: 'categories' }),
|
|
33
|
+
__metadata("design:paramtypes", [])
|
|
34
|
+
], Categories);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseModel } from './BaseModel';
|
|
2
|
+
import { Posts } from './PostsModel';
|
|
3
|
+
import { User } from './user';
|
|
4
|
+
export declare class Comments extends BaseModel {
|
|
5
|
+
post_id: number;
|
|
6
|
+
user_id: number;
|
|
7
|
+
parent_comment_id?: number;
|
|
8
|
+
content: string;
|
|
9
|
+
created_at: Date;
|
|
10
|
+
updated_at: Date;
|
|
11
|
+
post?: Posts;
|
|
12
|
+
user?: User;
|
|
13
|
+
parentComment?: Comments;
|
|
14
|
+
replies?: Comments[];
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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.Comments = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const BaseModel_1 = require("./BaseModel");
|
|
15
|
+
const PostsModel_1 = require("./PostsModel");
|
|
16
|
+
const user_1 = require("./user");
|
|
17
|
+
let Comments = class Comments extends BaseModel_1.BaseModel {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.post_id = 0;
|
|
21
|
+
this.user_id = 0;
|
|
22
|
+
this.parent_comment_id = 0;
|
|
23
|
+
this.content = '';
|
|
24
|
+
this.created_at = new Date();
|
|
25
|
+
this.updated_at = new Date();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.Comments = Comments;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: false }),
|
|
31
|
+
__metadata("design:type", Number)
|
|
32
|
+
], Comments.prototype, "post_id", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: false }),
|
|
35
|
+
__metadata("design:type", Number)
|
|
36
|
+
], Comments.prototype, "user_id", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
39
|
+
__metadata("design:type", Number)
|
|
40
|
+
], Comments.prototype, "parent_comment_id", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: false }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], Comments.prototype, "content", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
47
|
+
__metadata("design:type", Date)
|
|
48
|
+
], Comments.prototype, "created_at", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
51
|
+
__metadata("design:type", Date)
|
|
52
|
+
], Comments.prototype, "updated_at", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.ManyToOne)(() => PostsModel_1.Posts, post => post.id),
|
|
55
|
+
(0, typeorm_1.JoinColumn)({ name: 'post_id' }),
|
|
56
|
+
__metadata("design:type", PostsModel_1.Posts)
|
|
57
|
+
], Comments.prototype, "post", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.ManyToOne)(() => user_1.User, user => user.id),
|
|
60
|
+
(0, typeorm_1.JoinColumn)({ name: 'user_id' }),
|
|
61
|
+
__metadata("design:type", user_1.User)
|
|
62
|
+
], Comments.prototype, "user", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typeorm_1.ManyToOne)(() => Comments, comment => comment.id),
|
|
65
|
+
(0, typeorm_1.JoinColumn)({ name: 'parent_comment_id' }),
|
|
66
|
+
__metadata("design:type", Comments)
|
|
67
|
+
], Comments.prototype, "parentComment", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, typeorm_1.OneToMany)(() => Comments, comment => comment.parentComment),
|
|
70
|
+
__metadata("design:type", Array)
|
|
71
|
+
], Comments.prototype, "replies", void 0);
|
|
72
|
+
exports.Comments = Comments = __decorate([
|
|
73
|
+
(0, typeorm_1.Entity)({ name: 'comments' }),
|
|
74
|
+
__metadata("design:paramtypes", [])
|
|
75
|
+
], Comments);
|
|
@@ -0,0 +1,45 @@
|
|
|
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.PostAttachments = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const BaseModel_1 = require("./BaseModel");
|
|
15
|
+
const PostsModel_1 = require("./PostsModel");
|
|
16
|
+
let PostAttachments = class PostAttachments extends BaseModel_1.BaseModel {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.post_id = 0;
|
|
20
|
+
this.file_url = '';
|
|
21
|
+
this.uploaded_at = new Date();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.PostAttachments = PostAttachments;
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: false }),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], PostAttachments.prototype, "post_id", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: false }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], PostAttachments.prototype, "file_url", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
35
|
+
__metadata("design:type", Date)
|
|
36
|
+
], PostAttachments.prototype, "uploaded_at", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.ManyToOne)(() => PostsModel_1.Posts, post => post.id),
|
|
39
|
+
(0, typeorm_1.JoinColumn)({ name: 'post_id' }),
|
|
40
|
+
__metadata("design:type", PostsModel_1.Posts)
|
|
41
|
+
], PostAttachments.prototype, "post", void 0);
|
|
42
|
+
exports.PostAttachments = PostAttachments = __decorate([
|
|
43
|
+
(0, typeorm_1.Entity)({ name: 'post_attachments' }),
|
|
44
|
+
__metadata("design:paramtypes", [])
|
|
45
|
+
], PostAttachments);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseModel } from './BaseModel';
|
|
2
|
+
import { User } from './user';
|
|
3
|
+
import { Departments } from './DepartmentsModel';
|
|
4
|
+
import { Categories } from './CategoriesModel';
|
|
5
|
+
import { Comments } from './CommentsModel';
|
|
6
|
+
import { PostAttachments } from './PostAttachmentsModel';
|
|
7
|
+
export declare class Posts extends BaseModel {
|
|
8
|
+
title: string;
|
|
9
|
+
content: string;
|
|
10
|
+
user_id?: number;
|
|
11
|
+
department_id?: number;
|
|
12
|
+
category_id?: number;
|
|
13
|
+
created_at: Date;
|
|
14
|
+
updated_at: Date;
|
|
15
|
+
user?: User;
|
|
16
|
+
department?: Departments;
|
|
17
|
+
category?: Categories;
|
|
18
|
+
comments?: Comments[];
|
|
19
|
+
attachments?: PostAttachments[];
|
|
20
|
+
constructor();
|
|
21
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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.Posts = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const BaseModel_1 = require("./BaseModel");
|
|
15
|
+
const user_1 = require("./user");
|
|
16
|
+
const DepartmentsModel_1 = require("./DepartmentsModel");
|
|
17
|
+
const CategoriesModel_1 = require("./CategoriesModel");
|
|
18
|
+
const CommentsModel_1 = require("./CommentsModel");
|
|
19
|
+
const PostAttachmentsModel_1 = require("./PostAttachmentsModel");
|
|
20
|
+
let Posts = class Posts extends BaseModel_1.BaseModel {
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this.title = '';
|
|
24
|
+
this.content = '';
|
|
25
|
+
this.user_id = 0;
|
|
26
|
+
this.department_id = 0;
|
|
27
|
+
this.category_id = 0;
|
|
28
|
+
this.created_at = new Date();
|
|
29
|
+
this.updated_at = new Date();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.Posts = Posts;
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: false }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], Posts.prototype, "title", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: false }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], Posts.prototype, "content", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
43
|
+
__metadata("design:type", Number)
|
|
44
|
+
], Posts.prototype, "user_id", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
47
|
+
__metadata("design:type", Number)
|
|
48
|
+
], Posts.prototype, "department_id", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
51
|
+
__metadata("design:type", Number)
|
|
52
|
+
], Posts.prototype, "category_id", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
55
|
+
__metadata("design:type", Date)
|
|
56
|
+
], Posts.prototype, "created_at", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
59
|
+
__metadata("design:type", Date)
|
|
60
|
+
], Posts.prototype, "updated_at", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, typeorm_1.ManyToOne)(() => user_1.User, user => user.id),
|
|
63
|
+
(0, typeorm_1.JoinColumn)({ name: 'user_id' }),
|
|
64
|
+
__metadata("design:type", user_1.User)
|
|
65
|
+
], Posts.prototype, "user", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typeorm_1.ManyToOne)(() => DepartmentsModel_1.Departments, department => department.id),
|
|
68
|
+
(0, typeorm_1.JoinColumn)({ name: 'department_id' }),
|
|
69
|
+
__metadata("design:type", DepartmentsModel_1.Departments)
|
|
70
|
+
], Posts.prototype, "department", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, typeorm_1.ManyToOne)(() => CategoriesModel_1.Categories, category => category.id),
|
|
73
|
+
(0, typeorm_1.JoinColumn)({ name: 'category_id' }),
|
|
74
|
+
__metadata("design:type", CategoriesModel_1.Categories)
|
|
75
|
+
], Posts.prototype, "category", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, typeorm_1.OneToMany)(() => CommentsModel_1.Comments, comment => comment.post),
|
|
78
|
+
__metadata("design:type", Array)
|
|
79
|
+
], Posts.prototype, "comments", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, typeorm_1.OneToMany)(() => PostAttachmentsModel_1.PostAttachments, attachment => attachment.post),
|
|
82
|
+
__metadata("design:type", Array)
|
|
83
|
+
], Posts.prototype, "attachments", void 0);
|
|
84
|
+
exports.Posts = Posts = __decorate([
|
|
85
|
+
(0, typeorm_1.Entity)({ name: 'posts' }),
|
|
86
|
+
__metadata("design:paramtypes", [])
|
|
87
|
+
], Posts);
|
package/package.json
CHANGED
package/src/data-source.ts
CHANGED
|
@@ -32,6 +32,12 @@ import { FMServices } from './models/FMServices';
|
|
|
32
32
|
import { FMSubServices } from './models/FMSubservices';
|
|
33
33
|
import { ServiceBookmarks } from './models/serviceBookmarksModel';
|
|
34
34
|
import { Feedback } from './models/feedbackModel';
|
|
35
|
+
import { Categories } from './models/CategoriesModel';
|
|
36
|
+
import { Posts } from './models/PostsModel';
|
|
37
|
+
import { Comments } from './models/CommentsModel';
|
|
38
|
+
import { PostAttachments } from './models/PostAttachmentsModel';
|
|
39
|
+
|
|
40
|
+
|
|
35
41
|
|
|
36
42
|
|
|
37
43
|
export const AppDataSource = new DataSource({
|
|
@@ -71,6 +77,10 @@ export const AppDataSource = new DataSource({
|
|
|
71
77
|
FMServices,
|
|
72
78
|
FMSubServices,
|
|
73
79
|
ServiceBookmarks,
|
|
74
|
-
Feedback
|
|
80
|
+
Feedback,
|
|
81
|
+
Categories,
|
|
82
|
+
Posts,
|
|
83
|
+
Comments,
|
|
84
|
+
PostAttachments
|
|
75
85
|
],
|
|
76
86
|
});
|
package/src/index.ts
CHANGED
|
@@ -26,3 +26,7 @@ export * from './models/FMServices';
|
|
|
26
26
|
export * from './models/FMSubservices';
|
|
27
27
|
export * from './models/serviceBookmarksModel';
|
|
28
28
|
export * from './models/feedbackModel';
|
|
29
|
+
export * from './models/CategoriesModel';
|
|
30
|
+
export * from './models/PostsModel';
|
|
31
|
+
export * from './models/CommentsModel';
|
|
32
|
+
export * from './models/PostAttachmentsModel';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Column, Entity } from "typeorm";
|
|
2
|
+
import { BaseModel } from './BaseModel';
|
|
3
|
+
|
|
4
|
+
@Entity({ name: 'categories' })
|
|
5
|
+
export class Categories extends BaseModel {
|
|
6
|
+
|
|
7
|
+
@Column({ type: 'varchar', length: 150, nullable: false, unique: true })
|
|
8
|
+
name: string;
|
|
9
|
+
|
|
10
|
+
@Column({ type: 'text', nullable: true })
|
|
11
|
+
description?: string;
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.name = '';
|
|
16
|
+
this.description = '';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Column, Entity, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
|
2
|
+
import { BaseModel } from './BaseModel';
|
|
3
|
+
import { Posts } from './PostsModel';
|
|
4
|
+
import { User } from './user';
|
|
5
|
+
|
|
6
|
+
@Entity({ name: 'comments' })
|
|
7
|
+
export class Comments extends BaseModel {
|
|
8
|
+
|
|
9
|
+
@Column({ type: 'int', nullable: false })
|
|
10
|
+
post_id: number;
|
|
11
|
+
|
|
12
|
+
@Column({ type: 'int', nullable: false })
|
|
13
|
+
user_id: number;
|
|
14
|
+
|
|
15
|
+
@Column({ type: 'int', nullable: true })
|
|
16
|
+
parent_comment_id?: number;
|
|
17
|
+
|
|
18
|
+
@Column({ type: 'text', nullable: false })
|
|
19
|
+
content: string;
|
|
20
|
+
|
|
21
|
+
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
22
|
+
created_at: Date;
|
|
23
|
+
|
|
24
|
+
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
25
|
+
updated_at: Date;
|
|
26
|
+
|
|
27
|
+
// Relations
|
|
28
|
+
@ManyToOne(() => Posts, post => post.id)
|
|
29
|
+
@JoinColumn({ name: 'post_id' })
|
|
30
|
+
post?: Posts;
|
|
31
|
+
|
|
32
|
+
@ManyToOne(() => User, user => user.id)
|
|
33
|
+
@JoinColumn({ name: 'user_id' })
|
|
34
|
+
user?: User;
|
|
35
|
+
|
|
36
|
+
@ManyToOne(() => Comments, comment => comment.id)
|
|
37
|
+
@JoinColumn({ name: 'parent_comment_id' })
|
|
38
|
+
parentComment?: Comments;
|
|
39
|
+
|
|
40
|
+
@OneToMany(() => Comments, comment => comment.parentComment)
|
|
41
|
+
replies?: Comments[];
|
|
42
|
+
|
|
43
|
+
constructor() {
|
|
44
|
+
super();
|
|
45
|
+
this.post_id = 0;
|
|
46
|
+
this.user_id = 0;
|
|
47
|
+
this.parent_comment_id = 0;
|
|
48
|
+
this.content = '';
|
|
49
|
+
this.created_at = new Date();
|
|
50
|
+
this.updated_at = new Date();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Column, Entity, ManyToOne, JoinColumn } from "typeorm";
|
|
2
|
+
import { BaseModel } from './BaseModel';
|
|
3
|
+
import { Posts } from './PostsModel';
|
|
4
|
+
|
|
5
|
+
@Entity({ name: 'post_attachments' })
|
|
6
|
+
export class PostAttachments extends BaseModel {
|
|
7
|
+
|
|
8
|
+
@Column({ type: 'int', nullable: false })
|
|
9
|
+
post_id: number;
|
|
10
|
+
|
|
11
|
+
@Column({ type: 'text', nullable: false })
|
|
12
|
+
file_url: string;
|
|
13
|
+
|
|
14
|
+
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
15
|
+
uploaded_at: Date;
|
|
16
|
+
|
|
17
|
+
// Relations
|
|
18
|
+
@ManyToOne(() => Posts, post => post.id)
|
|
19
|
+
@JoinColumn({ name: 'post_id' })
|
|
20
|
+
post?: Posts;
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.post_id = 0;
|
|
25
|
+
this.file_url = '';
|
|
26
|
+
this.uploaded_at = new Date();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Column, Entity, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
|
2
|
+
import { BaseModel } from './BaseModel';
|
|
3
|
+
import { User } from './user';
|
|
4
|
+
import { Departments } from './DepartmentsModel';
|
|
5
|
+
import { Categories } from './CategoriesModel';
|
|
6
|
+
import { Comments } from './CommentsModel';
|
|
7
|
+
import { PostAttachments } from './PostAttachmentsModel';
|
|
8
|
+
|
|
9
|
+
@Entity({ name: 'posts' })
|
|
10
|
+
export class Posts extends BaseModel {
|
|
11
|
+
|
|
12
|
+
@Column({ type: 'varchar', length: 255, nullable: false })
|
|
13
|
+
title: string;
|
|
14
|
+
|
|
15
|
+
@Column({ type: 'text', nullable: false })
|
|
16
|
+
content: string;
|
|
17
|
+
|
|
18
|
+
@Column({ type: 'int', nullable: true })
|
|
19
|
+
user_id?: number;
|
|
20
|
+
|
|
21
|
+
@Column({ type: 'int', nullable: true })
|
|
22
|
+
department_id?: number;
|
|
23
|
+
|
|
24
|
+
@Column({ type: 'int', nullable: true })
|
|
25
|
+
category_id?: number;
|
|
26
|
+
|
|
27
|
+
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
28
|
+
created_at: Date;
|
|
29
|
+
|
|
30
|
+
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
31
|
+
updated_at: Date;
|
|
32
|
+
|
|
33
|
+
// Relations
|
|
34
|
+
@ManyToOne(() => User, user => user.id)
|
|
35
|
+
@JoinColumn({ name: 'user_id' })
|
|
36
|
+
user?: User;
|
|
37
|
+
|
|
38
|
+
@ManyToOne(() => Departments, department => department.id)
|
|
39
|
+
@JoinColumn({ name: 'department_id' })
|
|
40
|
+
department?: Departments;
|
|
41
|
+
|
|
42
|
+
@ManyToOne(() => Categories, category => category.id)
|
|
43
|
+
@JoinColumn({ name: 'category_id' })
|
|
44
|
+
category?: Categories;
|
|
45
|
+
|
|
46
|
+
@OneToMany(() => Comments, comment => comment.post)
|
|
47
|
+
comments?: Comments[];
|
|
48
|
+
|
|
49
|
+
@OneToMany(() => PostAttachments, attachment => attachment.post)
|
|
50
|
+
attachments?: PostAttachments[];
|
|
51
|
+
|
|
52
|
+
constructor() {
|
|
53
|
+
super();
|
|
54
|
+
this.title = '';
|
|
55
|
+
this.content = '';
|
|
56
|
+
this.user_id = 0;
|
|
57
|
+
this.department_id = 0;
|
|
58
|
+
this.category_id = 0;
|
|
59
|
+
this.created_at = new Date();
|
|
60
|
+
this.updated_at = new Date();
|
|
61
|
+
}
|
|
62
|
+
}
|