Post is a table that store records about posts and published torrent, information like info_hash and bencode are stored in corresponding row. The idea behind this is that, any post must be accompanied by a related torrent file, of couse its info_hash and bencode will be stored together with the post for storage convenience.
Table structure
Postgresql provides byte array type bytea, thus I could store the bencoded torrent file into a line. The info_hash column is for searching by.
@Expose @Column(length = 50) private String title; //the title of the post showing in summary page
@Expose @Column(length = 2147483647) private String content; //Postgresql provides text type for unlimited content //We will store user post content in markdown
@Expose @Column(length = 50, name = "info_hash") private String infoHash; //The info hash for searching
@Expose @Column(name = "post_time") private Long postTime;
@Column @Expose private Integer size; //size of total file storage to be downloaded
@Column @Expose private Boolean enabled; //set if current post is visible by all
@JoinColumn(name = "min_level", referencedColumnName = "lid") @ManyToOne @Expose private UserLevel minLevel; //the minimum user level that could access this post.
@Transient @Expose privatefloat rate; //average rate for this post
@JoinColumn(name = "uid", referencedColumnName = "uid") @ManyToOne @Expose private User uid; //user who upload this post