大继的基础级业务实战设计记录(五),活动

2018-09-28  本文已影响0人  大继

场景描述

实现一个类似活动吧的服务。

结构

ArtivtiyDetail -<> Artivtiy --<> ActivityParticipate
--<> ActivityParticipateDetail
--<> Location(通用地址)
--<> Media(通用媒体)
--<> Category(通用分类)
ArtivtiyDetail : 用于详情页,关联所有详情也所需
Artivtiy: 用于列表查询,热管联ActivityParticipateDetail ,Location,Category

具体设计

@Entity
@Table(name = "activity")
public class Activity {

    @Id
    @Column(length = 37)
    private String id;

    @Column
    private String name;

    @Column(length = 765)
    private String image;

    @Column
    private String summary;

    @Column
    private Long userId;

    /**
     * 参与价格
     */
    @Column
    private Double price;

    /**
     * 最大参与人数
     */
    @Column
    private Integer max;

    /**
     * 媒体
     */
    @OneToMany(fetch=FetchType.EAGER)
    @JoinColumn(name="subjectId", referencedColumnName="id",
            foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT),insertable = false,updatable = false)
    private List<Media> medium;

    @ManyToMany(fetch= FetchType.EAGER)
    @JoinTable(name="category_item",
            joinColumns=@JoinColumn(name="subjectId", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT),updatable = false,insertable = false),
            inverseJoinColumns=@JoinColumn(name="categoryId", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT),updatable = false,insertable = false))
    private Set<Category> categories;

    @OneToOne(mappedBy = "activity_participate_detail")
    private ActivityParticipateDetail activityParticipateDetail;

    @Column
    private Date beginTime;

    @Column
    private Date endTime;

    @Column(length = 16)
    private String status;

    @Column
    private Date updateTime;

    @Column
    private Date createTime;

    //略. getter setter..
}
**
 * 用于介绍详情
 */
@Entity
@Table(name = "activity_detail", uniqueConstraints=@UniqueConstraint(columnNames={"activity_id"}))
public class ActivityDetail {

    @Id
    @Column(length = 37)
    private String id;

    @Column(name = "activity_id",length = 37)
    private String activityId;

    @Column(length = 16)
    private String contentType;

    @Column
    private Date createDate;

    @Lob
    @Column(columnDefinition="TEXT")
    private String content;

   //略. getter setter..
}
/**
 * 报名人列表
 */
@Entity
@Table(name = "activity_participate")
public class ActivityParticipate {

    @Id
    @Column(length = 37)
    private String id;

    @Column(length = 37)
    private String activityId;

    @Column
    private String name;

    @Column
    private String phone;

    @Column
    private String mobile;

    @Column
    private String country;

    @Column
    private String province;

    @Column
    private String city;

    @Column
    private String area;

    @Column
    private String street;

    @Column
    private String detailed;

    @Column
    private Long userId;

    @Column
    private String status;

    @Column
    private Date updateTime;

    @Column
    private Date createTime;
 //略. getter setter..
}


/**
 * 参与列表详情
 */
@Entity
@Table(name = "activity_participate_detail")
public class ActivityParticipateDetail {

    @Id
    @Column(length = 37)
    private String id;

    @OneToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="activityId")
    private Activity  activity;

    @Column
    private Integer participatedNumber;

    @Column
    private Integer lockedNumber;

    @Column
    private Date    createTime;
 //略. getter setter..
}

完结

希望对你在设计活动是有点帮助。

上一篇下一篇

猜你喜欢

热点阅读