/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.dm.order.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.modules.dm.food.domain.DmFood;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.List;

/**
* @website https://el-admin.vip
* @description /
* @author sunmz
* @date 2021-09-15
**/
@Entity
@Data
@Table(name="dm_order_item")
public class DmOrderItem implements Serializable {

    @Id
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

//    @OneToMany(mappedBy = "orderItem",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
//    private List<DmOrderItem> orderItems;

//    @OneToOne
//    @JoinColumn(name = "bh")
//    @ApiModelProperty(value = "商品编号")
//    private DmOrderItem orderItem;

    @Column(name = "bh")
    @ApiModelProperty(value = "编号")
    private String bh;

    @Column(name = "pj_type")
    @ApiModelProperty(value = "评价类型")
    private String pjType;

//    @OneToOne
    @Column(name = "pid")
    @ApiModelProperty(value = "商品编号")
    private Long food;

//    @Column(name = "pid")
//    @ApiModelProperty(value = "商品编号")
//    private Long pid;

    @Column(name = "code")
    @ApiModelProperty(value = "商品编号")
    private String code;

    @Column(name = "name")
    @ApiModelProperty(value = "商品名称")
    private String name;

    @Column(name = "price")
    @ApiModelProperty(value = "单价")
    private String price;

    @Column(name = "num")
    @ApiModelProperty(value = "数量")
    private Integer num;

    @Column(name = "money")
    @ApiModelProperty(value = "金额小计")
    private String money;

    @Column(name = "seq")
    @ApiModelProperty(value = "流水号")
    private Long seq;

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

    @Column(name = "amt")
    @ApiModelProperty(value = "商品售价")
    private Double amt;

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