
评论肯定是基于文章的,文章肯定有唯一的ID。
这样的话,可以让评论全部关联到这个ID上。
随便写写,代码不能运行,参考即可。
public class Comment {Long id
Article article//文章
User user//用户
Date date//时间
String content//内容
}
public class CommentService {
void addComment(Article article, User user, String content)
void updateComment(Comment comment)
void deleteComment(Comment commnet)
List<Comment> findCommentByArticle(Article article)
List<Comment> findCommentByUser(User user)
}
public class AddCommentAction {
private Long articleId
private Long userId
private String content
public String execute() {
Article article = articleService.getArticle(articleId)
User user = userService.getUser(userId)
commentService.addComment(article, user, comment)
return SUCCESS
}
}
m(model)模型,代表的是数据库层,通常用到的是:oracle、db2、mysql等sql知识;v(view)视图,代表的是页面(相关),通常用到的是:html5、jsp,js等页面知识;c(Controller)控制,代表的控制器,通常用到一些框架知识,如ssh(struts,spring,hibernate)。备注:mvc实际上是一个很宽泛的内容,根据用到的技术不同,需要实现的业务逻辑不一样,所以灵活开发配置即可。欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)