1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 08:35:17 +00:00

Created first comment

This commit is contained in:
2020-03-21 11:28:32 +01:00
parent 932ae20403
commit 4ffa8a421b
2 changed files with 62 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import { Comment } from "../entities/Comment";
import { DatabaseHelper } from "./DatabaseHelper";
import { unlinkSync, existsSync } from "fs";
import { LikesHelper, LikesType } from "./LikesHelper";
import { mysql_date, time } from "../utils/DateUtils";
/**
* Comments helper
@ -13,6 +14,22 @@ const COMMENTS_TABLE = "commentaires";
export class CommentsHelper {
/**
* Create a new comment
*
* @param comment Information about the comment to create
*/
public static async Create(comment: Comment) : Promise<number> {
return await DatabaseHelper.InsertRow(COMMENTS_TABLE, {
ID_texte: comment.postID,
ID_personne: comment.userID,
date_envoi: mysql_date(),
time_insert: time(),
commentaire: comment.content,
image_commentaire: comment.hasImage ? comment.imagePath : ""
});
}
/**
* Get the comments of a POST
*