package com.erp.supplier.dto.response;

import com.erp.supplier.entity.SupplierContact;
import lombok.Data;
import lombok.Builder;
import java.time.LocalDateTime;

@Data
@Builder
public class SupplierContactResponse {

    private Long id;
    private Long supplierId;
    private String contactName;
    private String gender;
    private String genderText;
    private String department;
    private String position;
    private String mobile;
    private String phone;
    private String email;
    private String qq;
    private String wechat;
    private Integer isPrimary;
    private Integer isEmergency;
    private String remark;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;

    public static SupplierContactResponse fromEntity(SupplierContact contact) {
        return SupplierContactResponse.builder()
                .id(contact.getId())
                .supplierId(contact.getSupplierId())
                .contactName(contact.getContactName())
                .gender(contact.getGender())
                .genderText("male".equals(contact.getGender()) ? "男" : "female".equals(contact.getGender()) ? "女" : "")
                .department(contact.getDepartment())
                .position(contact.getPosition())
                .mobile(contact.getMobile())
                .phone(contact.getPhone())
                .email(contact.getEmail())
                .qq(contact.getQq())
                .wechat(contact.getWechat())
                .isPrimary(contact.getIsPrimary())
                .isEmergency(contact.getIsEmergency())
                .remark(contact.getRemark())
                .createdAt(contact.getCreatedAt())
                .updatedAt(contact.getUpdatedAt())
                .build();
    }
}
