/*
*  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.printingApproval.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Getter;
import lombok.NoArgsConstructor;
import me.zhengjie.base.BaseEntity;
import me.zhengjie.modules.dm.printingRequest.domain.DmPrintingRequest;
import me.zhengjie.modules.dm.user.domain.DmUser;

import javax.persistence.*;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author xwx
* @date 2021-03-17
**/
@Entity
@Data
@Table(name="dm_printing_approval")
//@JsonIgnoreProperties({"printingRequest.device","printingRequest.approvalUser","printingRequest.requestUser",
//    "approvalUser.roles","approvalUser.jobs","approvalUser.dept"})
@NoArgsConstructor
@AllArgsConstructor
public class DmPrintingApproval extends BaseEntity implements Serializable {

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

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "request_id")
    @ApiModelProperty(value = "打印申请")
//    @Getter(onMethod_={@JsonIgnoreProperties(value = {"device"},allowGetters = false,allowSetters = false)})
    @JsonIgnoreProperties(value = {"device"})
    private DmPrintingRequest printingRequest;

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

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

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

    @Column(name = "approval_status")
    @ApiModelProperty(value = "审批状态")
    private String approvalStatus;

    @Column(name = "approval_leave")
    @ApiModelProperty(value = "审批节点")
    private Integer approvalLeave;

    @Column(name = "last_leave")
    @ApiModelProperty(value = "是否为叶子节点")
    private String lastLeave;

    @Column(name = "is_new")
    @ApiModelProperty(value = "是否为最新审批")
    private Boolean isNew;


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

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

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


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