package jnpf.model.personnels.dto.emp;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jnpf.model.personnels.po.FtbPersonnelsStaffEmploymentApply;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.util.Date;

/**
 * @Author: peng.hao
 * @create: 2025/4/7
 */
@Data
public class FtbEmpAddNewDTO {

    private String id;

    /**
     * 姓名
     */
    private String workerName;

    /**
     * 手机号
     */
    @NotBlank(message = "手机号码不能为空")
    @Length(min = 11, max = 11, message = "手机号码长度不能超过11位")
    @Pattern(regexp = "(?:0|86|\\+86)?1[03-9]\\d{9}", message = "手机号码格式不正确")
    private String phone;

    /**
     * 身份证号码
     */
    private String idCard;
    /**
     * 入职日期
     */
    private Date actualStartDate;

    /**
     * 入职所属组织id
     */
    private String currOrgId;
    /**
     * 班组id
     */
    private String currGroupId;
    /**
     * 入职岗位id
     */
    private String currPositionId;
    /**
     * 入职职级Id
     */
    private String currRankId;


    /**
     * 来源，0、后台办理 1、APP端个人内推  2、门店招聘、3、组织招聘
     */
    @JsonIgnore
    private Integer source;


    /**
     * app入职签名承诺截图
     */
    @JsonIgnore
    private String registerImg;

    /**
     * 是否提交了入职登记表：0、未提交  1、已提交
     */
    @JsonIgnore
    private Integer isSubmitForm;

    public static FtbPersonnelsStaffEmploymentApply covert(FtbEmpAddNewDTO dto) {
        if (dto == null) {
            return null;
        }
        FtbPersonnelsStaffEmploymentApply ftbPersonnelsStaffEmploymentApply = new FtbPersonnelsStaffEmploymentApply();
        ftbPersonnelsStaffEmploymentApply.setId(dto.getId());
        ftbPersonnelsStaffEmploymentApply.setWorkerName(dto.getWorkerName());
        ftbPersonnelsStaffEmploymentApply.setPhone(dto.getPhone());
        ftbPersonnelsStaffEmploymentApply.setCurrOrg(dto.getCurrOrgId());
        ftbPersonnelsStaffEmploymentApply.setCurrGroupId(dto.getCurrGroupId());
        ftbPersonnelsStaffEmploymentApply.setCurrPosition(dto.getCurrPositionId());
        ftbPersonnelsStaffEmploymentApply.setCurrRank(dto.getCurrRankId());
        ftbPersonnelsStaffEmploymentApply.setIdCardNum(dto.getIdCard());
        ftbPersonnelsStaffEmploymentApply.setSource(dto.getSource());
        ftbPersonnelsStaffEmploymentApply.setRegisterImg(dto.getRegisterImg());
        ftbPersonnelsStaffEmploymentApply.setIsSubmitForm(dto.getIsSubmitForm());
        if (dto.getActualStartDate() != null) {
            ftbPersonnelsStaffEmploymentApply.setActualStartDate(dto.getActualStartDate());
        }
        return ftbPersonnelsStaffEmploymentApply;
    }
}
