80,330
社区成员
发帖
与我相关
我的任务
分享
public class Comment extends DateRecord{
/**
*
*/
private static final long serialVersionUID = 1L;
String text;
Article atc;
User author;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@ManyToOne(optional = false)
public Article getAtc() {
return atc;
}
public void setAtc(Article atc) {
this.atc = atc;
}
@ManyToOne(optional = false)
public User getAuthor() {
return author;
}
public void setAuthor(User author) {
this.author = author;
}
}
@Configuration
@Component
@Service
@Transactional
public class DefaultCommentService implements ICommentService{
@Autowired
ICommentRepository commentRepo;
@Override
public Page<Comment> findAllArticleId(int id, Pageable page) {
return commentRepo.findAllArticleId(id, page);
}
@Override
public Page<Comment> findCommentsOfArticle(int atc_id,int page) {
Sort sort = new Sort(Direction.DESC, "createDate");
PageRequest request = new PageRequest(atc_id, 10, sort);
return commentRepo.findAllArticleId(atc_id, request);
}
@Override
public Comment save(Comment commment) {
// TODO Auto-generated method stub
return commentRepo.save(commment);
}
}