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

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
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.modules.dm.dmVisitorsApply.service.dto.DmVisitorsApplyDto;
import me.zhengjie.modules.dm.dmVisitorsUser.domain.DmVisitorsUser;
import me.zhengjie.modules.dmuser.domain.DmUser;
import me.zhengjie.modules.system.domain.Dept;
import me.zhengjie.modules.system.domain.DictDetail;

import javax.persistence.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* @website https://el-admin.vip
* @description /
* @author juan
* @date 2021-11-19
**/
@Entity
@Data
@Table(name="dm_visitors_apply")
public class DmVisitorsApply extends BaseEntity implements Serializable {
    @Id
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long id;

    @OneToOne
    @JoinColumn(name = "user_number",referencedColumnName="id")
    @ApiModelProperty(value = "被访人员工号")
    private DmUser dmUser;

    @OneToOne
    @JoinColumn(name = "dept_id")
    @ApiModelProperty(value = "到访部门")
    private Dept dept;

    @Column(name = "start_time")
    @ApiModelProperty(value = "到访开始时间")
    private Timestamp startTime;

    @Column(name = "end_time")
    @ApiModelProperty(value = "到访结束时间")
    private Timestamp endTime;

    @Column(name = "administration")
    @ApiModelProperty(value = "到访办公室")
    private String administration;

    @Column(name = "qr_code")
    @ApiModelProperty(value = "访客二维码")
    private String qrCode;

    @Column(name = "qr_code_url")
    @ApiModelProperty(value = "访客二维码")
    private String qrCodeUrl;

    @Column(name = "vis_number")
    @ApiModelProperty(value = "到访人数")
    private String visNumber;

    @Column(name = "for_visiting")
    @ApiModelProperty(value = "到访事由")
    private String forVisiting;

    @Column(name = "type")
    @ApiModelProperty(value = "00-app,01-web")
    private String type;

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

//    @OneToMany(mappedBy = "visitorsApply")
//    private List<DmVisitorsUser> visitorsUsers;

    @Column(name = "apply_status")
    @ApiModelProperty(value = "申请列表状态")
    private Integer applyStatus;

    @Column(name = "approve_state")
    @ApiModelProperty(value = "状态(00-待审核、01-审核通过、02-审核驳回、03-待填写、04-进行中、05-已结束)")
    private String approveState;

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

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

    @Column(name = "apply_type")
    @ApiModelProperty(value = "申请类型(00.被访人发起 01.访客发起)")
    private String applyType;


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