package org.agt.module.license.controller.admin.license.vo;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fhs.core.trans.anno.Trans;
import com.fhs.core.trans.constant.TransType;
import com.fhs.core.trans.vo.VO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.agt.framework.excel.core.annotations.DictFormat;
import org.agt.framework.excel.core.convert.DictConvert;
import org.agt.module.license.dal.dataobject.customer.CustomerDO;
import org.agt.module.license.dal.dataobject.project.ProjectDO;
import org.agt.module.system.api.user.AdminUserApi;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Schema(description = "管理后台 - License Response VO")
@Data
@ExcelIgnoreUnannotated
public class LicenseRespVO implements VO {

    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25585")
//    @ExcelProperty("主键")
    private Long id;

    @Schema(description = "客户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31667")
    @Trans(type = TransType.SIMPLE, target = CustomerDO.class, fields = "name", ref = "customerName")
    private Long customerId;

    @Schema(description = "客户名称")
    @ExcelProperty("客户名称")
    private String customerName;

    @Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2496")
    @Trans(type = TransType.SIMPLE, target = ProjectDO.class, fields = "name", ref = "projectName")
    private Long projectId;

    @Schema(description = "项目名称")
    @ExcelProperty("项目名称")
    private String projectName;

    @Schema(description = "sn", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("SN")
    private String serialNo;

    @Schema(description = "到期时间")
    private LocalDateTime expiryDate;

    @Schema(description = "到期时间导出")
    @ExcelProperty("到期时间")
    private LocalDate expiryDateExt;

    @Schema(description = "网元")
    @ExcelProperty("网元")
    private String neListStr;

    @Schema(description = "激活码")
    @ExcelProperty("激活码")
    private String activationCode;

    @Schema(description = "网元激活码列表")
    private List<LicenseDetailVO> neCodeList;

    @Schema(description = "用户数")
    @ExcelProperty("用户数")
    private Integer userNumber;

    @Schema(description = "基站数")
    @ExcelProperty("基站数")
    private Integer ranNumber;

    @Schema(description = "文件URL")
//    @ExcelProperty("文件URL")
    private String fileUrl;

    @Schema(description = "申请人ID")
    @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "applicantName")
    private Long applicant;

    @Schema(description = "申请人", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("申请人")
    private String applicantName;

    @Schema(description = "审批人")
    @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, fields = "nickname", ref = "approverName")
    private Long approver;

    @Schema(description = "审批人", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("审批人")
    private String approverName;

    @Schema(description = "状态", example = "1")
    @ExcelProperty(value = "状态", converter = DictConvert.class)
    @DictFormat("lic_license_status") // TODO 代码优化：建议设置到对应的 DictTypeConstants 枚举类中
    private Integer status;

    @Schema(description = "备注", example = "随便")
    @ExcelProperty("说明")
    private String remark;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
//    @ExcelProperty("创建时间")
    private LocalDateTime createTime;

    @Schema(description = "申请时间")
    @ExcelProperty("申请时间")
    private LocalDateTime applicationTime;

    @Schema(description = "license申请次数")
    @ExcelProperty("申请次数")
    private Integer applyCount;

    @Schema(description = "数据类型")
    private Integer dataType;

    private LicenseRespVO oldLicense;

    private boolean hasHistory;
}