|
|
|
package dao
|
|
|
|
|
|
|
|
import "github.com/rocboss/paopao-ce/internal/model"
|
|
|
|
|
|
|
|
func (d *dataServant) GetComments(conditions *model.ConditionsT, offset, limit int) ([]*model.Comment, error) {
|
|
|
|
return (&model.Comment{}).List(d.engine, conditions, offset, limit)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dataServant) GetCommentByID(id int64) (*model.Comment, error) {
|
|
|
|
comment := &model.Comment{
|
|
|
|
Model: &model.Model{
|
|
|
|
ID: id,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return comment.Get(d.engine)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dataServant) DeleteComment(comment *model.Comment) error {
|
|
|
|
return comment.Delete(d.engine)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dataServant) GetCommentCount(conditions *model.ConditionsT) (int64, error) {
|
|
|
|
return (&model.Comment{}).Count(d.engine, conditions)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dataServant) CreateComment(comment *model.Comment) (*model.Comment, error) {
|
|
|
|
return comment.Create(d.engine)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dataServant) CreateCommentReply(reply *model.CommentReply) (*model.CommentReply, error) {
|
|
|
|
return reply.Create(d.engine)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dataServant) GetCommentReplyByID(id int64) (*model.CommentReply, error) {
|
|
|
|
reply := &model.CommentReply{
|
|
|
|
Model: &model.Model{
|
|
|
|
ID: id,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return reply.Get(d.engine)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dataServant) DeleteCommentReply(reply *model.CommentReply) error {
|
|
|
|
return reply.Delete(d.engine)
|
|
|
|
}
|