Rights.java 2.38 KB
package com.topdraw.business.module.rights.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * @author XiangHan
 * @date 2021-10-22
 */
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="tr_rights")
public class Rights implements Serializable {

    /** 主键 */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /** 标识 */
    @Column(name = "code", nullable = false)
    private String code;

    /** 权益名称 */
    @Column(name = "name")
    private String name;

    /** 类型 1:实体类 (预留字段) */
    @Column(name = "type", nullable = false)
    private Integer type;

    /** 终端类型 0:大屏;1:微信小程序/公众号;2:App */
    @Column(name = "device_type", nullable = false)
    private Integer deviceType;

    /** 权益的实体类型  1:积分;2成长值;3优惠券 */
    @Column(name = "entity_type", nullable = false)
    private String entityType;

    /** 实体id */
    @Column(name = "entity_id", nullable = false)
    private Long entityId;

    /** 生效时间,为null表示获取后立即生效,不为空时,表示特定的生效时间 */
    @Column(name = "valid_time")
    private Timestamp validTime;

    /** 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 */
    @Column(name = "expire_time")
    private Long expireTime;

    /** 创建时间 */
    @CreatedDate
    @Column(name = "create_time")
    private Timestamp createTime;

    /** 更新时间 */
    @LastModifiedDate
    @Column(name = "update_time")
    private Timestamp updateTime;

    /** 图片 */
    @Column(name = "image")
    private String image;

    /** 图片 */
    @Column(name = "images")
    private String images;

    /** 描述 */
    @Column(name = "description")
    private String description;

    public void copy(Rights source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}