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

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
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 lombok.Getter;
import me.zhengjie.base.BaseEntity;
import me.zhengjie.domain.LocalStorage;
import me.zhengjie.modules.dm.device.domain.DmDevice;
import me.zhengjie.modules.dm.floor.domain.DmFloor;
import me.zhengjie.modules.dm.user.domain.DmUser;
import me.zhengjie.modules.system.domain.User;
import net.bytebuddy.implementation.attribute.MethodAttributeAppender;
import org.hibernate.annotations.*;
import org.springframework.data.annotation.CreatedBy;

import java.sql.Timestamp;
import java.io.Serializable;
import java.util.List;

/**
* @website https://el-admin.vip
* @description /
* @author xwx
* @date 2021-03-15
**/
@Entity
@Data
@Table(name="dm_printing_request")
public class DmPrintingRequest extends BaseEntity implements Serializable {

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

    @Column(name = "task_code")
    @ApiModelProperty(value = "任务编号")
    private String taskCode;

    @Column(name = "task_name")
    @ApiModelProperty(value = "任务名称")
    private String taskName;

    @Column(name = "file_page_num")
    @ApiModelProperty(value = "文档总页数")
    private Integer filePageNum;

    @Column(name = "file_repeat_num")
    @ApiModelProperty(value = "文档份数")
    private Integer fileRepeatNum;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "printer_code")
    @ApiModelProperty(value = "打印机")
    private DmDevice device;

    @ApiModelProperty(value = "审批人")
    @OneToOne
    @JoinColumn(name = "approval_user")
    private DmUser approvalUser;

    @Column(name = "approval_remark")
    @ApiModelProperty(value = "审批意见")
    private String approvalRemark;

    @OneToOne
    @JoinColumn(name = "request_user",referencedColumnName = "id")
    @ApiModelProperty(value = "发起人")
    private DmUser requestUser;

    @OneToOne
    @JoinColumn(name = "fileid")
    @ApiModelProperty(value = "文件")
    private LocalStorage file;

    @Column(name = "status")
    @ApiModelProperty(value = "目前状态")
    private String status;

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

    @Column(name = "task_id")
    @ApiModelProperty(value = "任务ID")
    private String taskId;

    @Column(name = "proc_inst_id")
    @ApiModelProperty(value = "任务实例id")
    private String procInstId;

    @Column(name = "is_has_approval")
    @ApiModelProperty(value = "是否添加审批人")
    private Boolean isHasApproval ;

    @Transient
    private List<DmUser> approvalUserList;

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