/*
*  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 me.zhengjie.base.BaseEntity;
import me.zhengjie.exception.BadRequestException;

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

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

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

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

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

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

    @Column(name = "`reimburse_type`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "报销类型")
    private String reimburseType;

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

    @Column(name = "`business_fee_type`",nullable = false)
    @ApiModelProperty(value = "业务费类型")
    private String businessFeeType;

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

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

    @Column(name = "`project_fee`")
    @ApiModelProperty(value = "项目预算")
    private String projectFee;

    @Column(name = "`reimburse_time`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "花费产生时间")
    private Timestamp reimburseTime;

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

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

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