/*
*  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.system.domain;

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 javax.persistence.Entity;
import javax.persistence.Table;

import me.zhengjie.base.BaseEntity;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author author
* 
**/
@Entity
@Data
@Table(name="purchase")
public class Purchase extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`purchase_id`")
    @ApiModelProperty(value = "ID")
    private Long purchaseId;

    @ApiModelProperty(value = "申请人")
    @ManyToOne
    @JoinColumn(name = "user_id")
    private User user;

    @Column(name = "`reason`")
    @ApiModelProperty(value = "申请事由")
    private String reason;

    @Column(name = "`fee`")
    @ApiModelProperty(value = "申请金额")
    private String fee;

    @Column(name = "`product_name`")
    @ApiModelProperty(value = "货物/服务名称")
    private String productName;

    @Column(name = "`purchase_type`")
    @ApiModelProperty(value = "申请类型")
    private String purchaseType;

    @Column(name = "`product_info`")
    @ApiModelProperty(value = "品牌/规格/参数")
    private String productInfo;

    @Column(name = "`product_count`")
    @ApiModelProperty(value = "数量")
    private BigDecimal productCount;

    @Column(name = "`product_price`")
    @ApiModelProperty(value = "预算单价")
    private BigDecimal productPrice;

    @Column(name = "`total_fee`")
    @ApiModelProperty(value = "预算总价")
    private BigDecimal totalFee;

    @Column(name = "`fee_source`")
    @ApiModelProperty(value = "资金来源")
    private String feeSource;

    @Column(name = "`project_name`")
    @ApiModelProperty(value = "项目名称")
    private String projectName;

    @Column(name = "`project_no`")
    @ApiModelProperty(value = "项目编号")
    private String projectNo;

    @Column(name = "`purchase_time`")
    @ApiModelProperty(value = "预计采购时间")
    private Timestamp purchaseTime;

    @Column(name = "`apply_time`")
    @ApiModelProperty(value = "申请时间")
    private Timestamp applyTime;

    @Column(name = "`remark`")
    @ApiModelProperty(value = "备注")
    private String remark;


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