点赞功能的设计
每一次点赞,需要记录:
(1)谁点的赞;
(2)为那篇文章点的赞;
(3)点赞时间
(4)是否已经取消点赞
?
数据表设计
点赞记录表
列名 |
数据类型 |
说明 |
id |
N |
数据表id |
user_id |
N |
用户id |
vote_time |
S |
点赞时间,格式”2016-02-22 12:01:45” |
bbs_id |
N |
被点赞帖子id |
status |
N |
状态:有效或取消 |
?
继续讨论E-R关系
点赞记录表与用户是多对1关系
点赞记录表与帖子也是多对1关系
实体类:
package com.girltest.entity; import java.util.List; import javax.persistence.*; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; /** * Created by huangweii on 2016/2/21. */ @Entity @Table(name = "t_vote_log") public class VoteLog { private int id; private User user; /** * 点赞的时间 */ private String voteTime; private int status; private Convention convention; @Id @GeneratedValue public int getId() { return id; } public void setId(int id) { this.id = id; } @ManyToOne @JoinColumn (name="userId") public User getUser() { return user; } public void setUser(User user) { this.user = user; } @Column(name = "vote_time") public String getVoteTime() { return voteTime; } public void setVoteTime(String voteTime) { this.voteTime = voteTime; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } @ManyToOne @JoinColumn (name="conventionId") public Convention getConvention() { return convention; } public void setConvention(Convention convention) { this.convention = convention; } }
?
?
?
原文:http://hw1287789687.iteye.com/blog/2277799