package com.izouma.zhirongip.domain;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.izouma.zhirongip.annotations.EnumFormat;
import com.izouma.zhirongip.converter.StringArrayConverter;
import com.izouma.zhirongip.enums.DocumentType;
import com.izouma.zhirongip.utils.excel.EnumExcelConverter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@ApiModel(value = "留言")
@Where(clause = "del = 0")
public class Message extends BaseEntity{
    @ExcelIgnore
    private Long userId;

    @ApiModelProperty(value = "姓名")
    private String name;

    @ApiModelProperty(value = "职业")
    private String occupation;

    @ApiModelProperty(value = "电话")
    private String phone;

    @ApiModelProperty(value = "邮箱")
    private String email;

    @EnumFormat(value = DocumentType.class,
            fromExcel = {"身份证", "军官证"},
            toJavaEnum = {"ID_CARD", "OFFICER_ID"})
    @ExcelProperty(value = "证件类型", converter = EnumExcelConverter.class)
    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "证件类型")
    private DocumentType type;

    @ApiModelProperty(value = "证件编号")
    private String documentNumber;

    @ApiModelProperty(value = "咨询标题")
    private String title;

    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "正文详情")
    private String content;

    @ExcelIgnore
    @Convert(converter = StringArrayConverter.class)
    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "图片")
    private List<String> img;

    @ApiModelProperty(value = "是否回复")
    private boolean isReply;

    @ApiModelProperty(value = "回复内容")
    @Column(columnDefinition = "TEXT")
    private String replyContent;
}
