Java|直播课堂系统03-model类及实体


目录

  • enums
    • CouponType
    • CouponStatus
    • CouponRangeType
    • OrderStatus
    • PaymentStatus
    • PaymentType
  • model
    • base
      • BaseEntity
      • BaseMongoEntity
    • MqRepeatRecord
    • activity
      • CouponInfo
      • CouponUse
    • live
    • order
    • user
    • vod

enums Java|直播课堂系统03-model类及实体
文章图片

CouponType 优惠券的类型
package enums; import com.baomidou.mybatisplus.annotation.EnumValue; import lombok.Getter; @Getter public enum CouponType { //提供枚举类对象 REGISTER(1,"注册"), RECOMMEND(2,"推荐购买"); //声明此为枚举类 @EnumValue private Integer code; private String comment; //构造函数 CouponType(Integer code,String comment){ this.code = code; this.comment = comment; } }

CouponStatus 优惠券状态
import com.baomidou.mybatisplus.annotation.EnumValue; import lombok.Getter; @Getter public enum CouponStatus { NOT_USED(0,"未使用"), USED(1,"已使用"); @EnumValue private Integer code ; private String comment ; CouponStatus(Integer code, String comment ){ this.code=code; this.comment=comment; } }

CouponRangeType 优惠券作用范围
import com.baomidou.mybatisplus.annotation.EnumValue; import lombok.Getter; @Getter public enum CouponRangeType { ALL(1,"通用"), ; @EnumValue private Integer code ; private String comment ; CouponRangeType(Integer code, String comment ){ this.code=code; this.comment=comment; } }

OrderStatus 订单状态,目前只列了两个
import com.baomidou.mybatisplus.annotation.EnumValue; import lombok.Getter; @Getter public enum OrderStatus { //订单状态【0->待付款;1->待发货;2->待团长收货;3->待用户收货,已完成;-1->已取消】 UNPAID(0,"待支付"), PAID(1,"已支付"), ; @EnumValue private Integer code ; private String comment ; OrderStatus(Integer code, String comment ){ this.code = code; this.comment=comment; } }

PaymentStatus 支付的状态,应该是用户界面展示的
import com.baomidou.mybatisplus.annotation.EnumValue; import lombok.Getter; @Getter public enum PaymentStatus { UNPAID(1,"支付中"), PAID(2,"已支付"); //REFUND(-1,"已退款"); @EnumValue private Integer code ; private String comment ; PaymentStatus(Integer code, String comment) { this.code = code; this.comment = comment; }}

PaymentType 支付方式,支付宝还是微信
import com.baomidou.mybatisplus.annotation.EnumValue; import lombok.Getter; @Getter public enum PaymentType { ALIPAY(1,"支付宝"), WEIXIN(2,"微信" ); @EnumValue private Integer code ; private String comment ; PaymentType(Integer code, String comment ){ this.code = code; this.comment=comment; }}

model base BaseEntity
顾名思义,其是几乎所有实体类的父类,需要实现序列化接口。
@ApiModel是作用在接口相关实体类上的注解,用来对该接口相关实体类添加额外的描述信息
@ApiModelProperty 是作用在接口相关实体类的参数上的注解,用来对具体的接口相关实体类中的参数添加额外的描述信息
一般在实体类上声明@ApiModel,在其具体属性里声明@ApiModelProperty
@TableName可以映射到数据库中的表名
@JsonFormat用来表示json序列化的一种格式或者类型,比如存储在mysql中的数据是date类型的,当读取出来封装在实体类中的时候,就会变成英文时间格式,而不是yyyy-MM-dd HH:mm:ss这样的中文时间,因此需要用到JsonFormat注解来格式化时间。
@TableField(exist = false) 注解加载bean属性上,表示当前属性不是数据库的字段,但在项目中必须使用,这样在新增等使用bean的时候,mybatis-plus就会忽略这个,不会报错,单纯@TableField就是对应着数据库内的字段。
@JsonIgnore此注解用于属性或者方法上(最好是属性上),返回到前端的实体类中,有一些属性不想暴露出去,用这个注解返回的json数据即不包含该属性。
@Data public class BaseEntity implements Serializable {//value 对其进行描述 @ApiModelProperty(value = "https://www.it610.com/article/id") //AUTO为自增 @TableId(type = IdType.AUTO) private Long id; @ApiModelProperty(value="https://www.it610.com/article/创建时间") //固定数据库从其取出后被实体化后的格式 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") //声明数据库中有可能没有,但需要使用 @TableField("create_time") private Date createTime; @ApiModelProperty(value = "https://www.it610.com/article/更新时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField("update_time") private Date updateTime; @ApiModelProperty(value = "https://www.it610.com/article/逻辑删除(1:已删除,0:未删除)") //不让这个数据被返回 @JsonIgnore //是否能够逻辑删除 @TableLogic @TableField("is_deleted") private Integer isDeleted; @ApiModelProperty(value = "https://www.it610.com/article/其他参数") @TableField(exist = false) private Map param = new HashMap<>(); }

BaseMongoEntity
@CreatedDate @LastModifiedDate可以在实体插入或更新时自动赋值,其赋的就是声明的值。
@Data public class BaseMongoEntity { @ApiModelProperty(value = "https://www.it610.com/article/id") @Id private String id; @ApiModelProperty(value = "https://www.it610.com/article/创建时间") //可以在实体创建时自动赋值 @CreatedDate private Date createTime; @ApiModelProperty(value = "https://www.it610.com/article/更新时间") //可以在实体最后一次修改时自动赋值 @LastModifiedDate private Date updateTime; @ApiModelProperty(value = "https://www.it610.com/article/其他参数") @Transient //被该注解标注的,将不会被录入到数据库中。只作为普通的javaBean属性 private Map param = new HashMap<>(); }

MqRepeatRecord 这个原项目放在base里了,可是我寻思它是继承的baseEntity的,于是单独提出来了,没看懂这个实体是做什么的,它指的表也没找到,先放这吧。
@Data @ApiModel(description = "MqRepeatRecord") @TableName("mq_repeat_record") public class MqRepeatRecord extends BaseEntity { //实现序列化接口 private static final long serialVersionUID = 1L; @ApiModelProperty(value = "https://www.it610.com/article/业务编号") @TableField("business_no") private String businessNo; }

activity 去看数据库表,有两张表,所以对应创建两个实体,前面的base看懂了的话这块不用看。
Java|直播课堂系统03-model类及实体
文章图片

CouponInfo
//声明getter setter等一系列方法 @Data //注解表明这是作用在接口相关实体类上的注解,用来对该接口相关实体类添加额外的描述信息 @ApiModel(description = "CouponInfo") @TableName("coupon_info") public class CouponInfo extends BaseEntity { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "https://www.it610.com/article/购物券类型 1 现金券") @TableField("coupon_type") private String couponType; @ApiModelProperty(value = "https://www.it610.com/article/优惠卷名字") @TableField("coupon_name") private String couponName; @ApiModelProperty(value = "https://www.it610.com/article/金额") @TableField("amount") private BigDecimal amount; @ApiModelProperty(value = "https://www.it610.com/article/使用门槛 0->没门槛") @TableField("condition_amount") private BigDecimal conditionAmount; @ApiModelProperty(value = "https://www.it610.com/article/可以领取的开始日期") @TableField("start_time") @JsonFormat(pattern = "yyyy-MM-dd") private Date startTime; @ApiModelProperty(value = "https://www.it610.com/article/可以领取的结束日期") @TableField("end_time") @JsonFormat(pattern = "yyyy-MM-dd") private Date endTime; @ApiModelProperty(value = "https://www.it610.com/article/使用范围[1->全场通用]") @TableField("range_type") private String rangeType; @ApiModelProperty(value = "https://www.it610.com/article/使用范围描述") @TableField("rule_desc") private String ruleDesc; @ApiModelProperty(value = "https://www.it610.com/article/发行数量") @TableField("publish_count") private Integer publishCount; @ApiModelProperty(value = "https://www.it610.com/article/每人限领张数") @TableField("per_limit") private Integer perLimit; @ApiModelProperty(value = "https://www.it610.com/article/已使用数量") @TableField("use_count") private Integer useCount; @ApiModelProperty(value = "https://www.it610.com/article/领取数量") @TableField("receive_count") private Integer receiveCount; @ApiModelProperty(value = "https://www.it610.com/article/过期时间") @TableField("expire_time") @JsonFormat(pattern = "yyyy-MM-dd") private Date expireTime; @ApiModelProperty(value = "https://www.it610.com/article/发布状态[0-未发布,1-已发布]") @TableField("publish_status") private Boolean publishStatus; @ApiModelProperty(value = "https://www.it610.com/article/使用状态") @TableField(exist = false) private String couponStatus; @ApiModelProperty(value = "https://www.it610.com/article/优惠券领取表id") @TableField(exist = false) private Long couponUseId; @ApiModelProperty(value = "https://www.it610.com/article/领取时间") @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd") private Date getTime; }

CouponUse
@Data @ApiModel(description = "CouponUse") @TableName("coupon_use") public class CouponUse extends BaseEntity {private static final long serialVersionUID = 1L; @ApiModelProperty(value = "https://www.it610.com/article/购物券ID") @TableField("coupon_id") private Long couponId; @ApiModelProperty(value = "https://www.it610.com/article/用户ID") @TableField("user_id") private Long userId; @ApiModelProperty(value = "https://www.it610.com/article/订单ID") @TableField("order_id") private Long orderId; @ApiModelProperty(value = "https://www.it610.com/article/购物券状态(0:未使用 1:已使用)") @TableField("coupon_status") private String couponStatus; @ApiModelProperty(value = "https://www.it610.com/article/获取时间") @TableField("get_time") private Date getTime; @ApiModelProperty(value = "https://www.it610.com/article/使用时间") @TableField("using_time") private Date usingTime; @ApiModelProperty(value = "https://www.it610.com/article/支付时间") @TableField("used_time") private Date usedTime; @ApiModelProperty(value = "https://www.it610.com/article/过期时间") @TableField("expire_time") private Date expireTime; }

live 里面也没啥新东西,按照数据库表来建对应的实体而已,随便列举一个,直接跳过。
Java|直播课堂系统03-model类及实体
文章图片

package model.live; @Data @ApiModel(description = "LiveCourse") @TableName("live_course") public class LiveCourse extends BaseEntity { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "https://www.it610.com/article/课程id") @TableField("course_id") private Long courseId; @ApiModelProperty(value = "https://www.it610.com/article/直播名称") @TableField("course_name") private String courseName; @ApiModelProperty(value = "https://www.it610.com/article/直播开始时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField("start_time") private Date startTime; @ApiModelProperty(value = "https://www.it610.com/article/直播结束时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField("end_time") private Date endTime; @ApiModelProperty(value = "https://www.it610.com/article/主播老师id") @TableField("teacher_id") private Long teacherId; @ApiModelProperty(value = "https://www.it610.com/article/课程封面图片路径") @TableField("cover") private String cover; }

order 里面也差不多,注意下payment里面有几个是enum里的实体类即可。
@Data @ApiModel(description = "PaymentInfo") @TableName("payment_info") public class PaymentInfo extends BaseEntity { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "https://www.it610.com/article/对外业务编号") @TableField("out_trade_no") private String outTradeNo; @ApiModelProperty(value = "https://www.it610.com/article/订单编号") @TableField("order_id") private Long orderId; @ApiModelProperty(value = "https://www.it610.com/article/用户id") @TableField("user_id") private Long userId; @ApiModelProperty(value = "https://www.it610.com/article/支付宝交易编号") @TableField("alipay_trade_no") private String alipayTradeNo; @ApiModelProperty(value = "https://www.it610.com/article/支付金额") @TableField("total_amount") private BigDecimal totalAmount; @ApiModelProperty(value = "https://www.it610.com/article/交易内容") @TableField("trade_body") private String tradeBody; @ApiModelProperty(value = "https://www.it610.com/article/paymentType") @TableField("payment_type") private PaymentType paymentType; @ApiModelProperty(value = "https://www.it610.com/article/支付状态") @TableField("payment_status") private PaymentStatus paymentStatus; @ApiModelProperty(value = "https://www.it610.com/article/回调信息") @TableField("callback_content") private String callbackContent; @ApiModelProperty(value = "https://www.it610.com/article/回调时间") @TableField("callback_time") private Date callbackTime; }

user 跳过
package model.user; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import model.base.BaseEntity; @Data @ApiModel(description = "UserInfo") @TableName("user_info") public class UserInfo extends BaseEntity { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "https://www.it610.com/article/手机号") @TableField("phone") private String phone; @ApiModelProperty(value = "https://www.it610.com/article/用户密码") @TableField("password") private String password; @ApiModelProperty(value = "https://www.it610.com/article/用户姓名") @TableField("name") private String name; @ApiModelProperty(value = "https://www.it610.com/article/昵称") @TableField("nick_name") private String nickName; @ApiModelProperty(value = "https://www.it610.com/article/性别") @TableField("sex") private Integer sex; @ApiModelProperty(value = "https://www.it610.com/article/头像") @TableField("avatar") private String avatar; @ApiModelProperty(value = "https://www.it610.com/article/省") @TableField("province") private String province; @ApiModelProperty(value = "https://www.it610.com/article/0:未订阅 1:已订阅") @TableField("subscribe") private Integer subscribe; @ApiModelProperty(value = "https://www.it610.com/article/小程序open id") @TableField("open_id") private String openId; @ApiModelProperty(value = "https://www.it610.com/article/微信开放平台unionID") @TableField("union_id") private String unionId; @ApiModelProperty(value = "https://www.it610.com/article/推荐人用户id") @TableField("recommend_id") private Long recommendId; @ApiModelProperty(value = "https://www.it610.com/article/status") @TableField("status") private Integer status; }

vod 【Java|直播课堂系统03-model类及实体】vod就是直播板块,跳过。
@Data @ApiModel(description = "Subject") @TableName("subject") public class Subject { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "https://www.it610.com/article/id") private Long id; @ApiModelProperty(value = "https://www.it610.com/article/创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField("create_time") private Date createTime; @ApiModelProperty(value = "https://www.it610.com/article/更新时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField("update_time") private Date updateTime; @ApiModelProperty(value = "https://www.it610.com/article/逻辑删除(1:已删除,0:未删除)") @JsonIgnore @TableLogic @TableField("is_deleted") private Integer isDeleted; @ApiModelProperty(value = "https://www.it610.com/article/其他参数") @TableField(exist = false) private Map param = new HashMap<>(); @ApiModelProperty(value = "https://www.it610.com/article/类别名称") @TableField("title") private String title; @ApiModelProperty(value = "https://www.it610.com/article/父ID") @TableField("parent_id") private Long parentId; @ApiModelProperty(value = "https://www.it610.com/article/排序字段") @TableField("sort") private Integer sort; @ApiModelProperty(value = "https://www.it610.com/article/是否包含子节点") @TableField(exist = false) private boolean hasChildren; }

    推荐阅读