50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
|
#ifndef __COMMENT_H__
|
||
|
#define __COMMENT_H__
|
||
|
|
||
|
#include <Wt/Dbo/Types.h>
|
||
|
#include <Wt/Dbo/WtSqlTraits.h>
|
||
|
#include <Wt/WDateTime.h>
|
||
|
|
||
|
class Comment;
|
||
|
using Comments = Wt::Dbo::collection<Wt::Dbo::ptr<Comment>>;
|
||
|
class Post;
|
||
|
class User;
|
||
|
|
||
|
class Comment {
|
||
|
public:
|
||
|
Wt::Dbo::ptr<User> author;
|
||
|
Wt::Dbo::ptr<Post> post;
|
||
|
Wt::Dbo::ptr<Comment> parent;
|
||
|
|
||
|
Wt::WDateTime date;
|
||
|
|
||
|
void setText(const Wt::WString &text);
|
||
|
void setDeleted();
|
||
|
|
||
|
const Wt::WString &textSrc() const {
|
||
|
return textSrc_;
|
||
|
}
|
||
|
const Wt::WString &textHtml() const {
|
||
|
return textHtml_;
|
||
|
}
|
||
|
|
||
|
Comments children;
|
||
|
|
||
|
template <class Action>
|
||
|
void persist(Action &a) {
|
||
|
Wt::Dbo::field(a, date, "date");
|
||
|
Wt::Dbo::field(a, textSrc_, "text_source");
|
||
|
Wt::Dbo::field(a, textHtml_, "text_html");
|
||
|
|
||
|
Wt::Dbo::belongsTo(a, post, "post", Wt::Dbo::OnDeleteCascade);
|
||
|
Wt::Dbo::belongsTo(a, author, "author");
|
||
|
Wt::Dbo::belongsTo(a, parent, "parent", Wt::Dbo::OnDeleteCascade);
|
||
|
|
||
|
Wt::Dbo::hasMany(a, children, Wt::Dbo::ManyToOne, "parent");
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
Wt::WString textSrc_;
|
||
|
Wt::WString textHtml_;
|
||
|
};
|
||
|
#endif // __COMMENT_H__
|