package cn.ysk.cashier.pojo.product;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author lyf
* @date 2023-12-16
**/
@Entity
@Data
@Table(name="tb_product_group")
public class TbProductGroup implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "`name`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "分组名称")
    private String name;

    @Column(name = "`merchant_id`")
    @ApiModelProperty(value = "商户Id")
    private String merchantId;

    @Column(name = "`shop_id`")
    @ApiModelProperty(value = "店铺Id")
    private Integer shopId;

    @Column(name = "`pic`")
    @ApiModelProperty(value = "图标")
    private String pic;

    @Column(name = "`is_show`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否显示")
    private Integer isShow;

    @Column(name = "`detail`")
    @ApiModelProperty(value = "分类描述")
    private String detail;

    @Column(name = "`style`")
    @ApiModelProperty(value = "style")
    private String style;

    @Column(name = "`sort`")
    @ApiModelProperty(value = "排序")
    private Integer sort;

    @Column(name = "`product_ids`")
    @ApiModelProperty(value = "商品列表")
    private String productIds;

    @Column(name = "`created_at`")
    @ApiModelProperty(value = "createdAt")
    private Long createdAt;

    @Column(name = "`updated_at`")
    @ApiModelProperty(value = "updatedAt")
    private Long updatedAt;

    @NotNull
    @Column(name = "`use_time`",nullable = false)
    @ApiModelProperty(value = "是否开启时间管控")
    private Integer useTime = 0;

    @Column(name = "`sale_start_time`")
    private String saleStartTime;

    @Column(name = "`sale_end_time`")
    private String saleEndTime;

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