package com.njcn.gather.icd.pojo.param;

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * @author caozehui
 * @data 2025-02-11
 */
@Data
public class PqIcdPathParam {
    @ApiModelProperty(value = "angle", required = true)
    private Integer angle;

    @ApiModelProperty(value = "usePhaseIndex", required = true)
    private Integer usePhaseIndex;

    @ApiModelProperty(value = "jsonStr")
    private String jsonStr;

    @ApiModelProperty(value = "xmlStr")
    private String xmlStr;

    @ApiModelProperty(value = "result")
    private Integer result;

    @ApiModelProperty(value = "msg")
    private String msg;

    @ApiModelProperty(value = "type")
    private Integer type;

    @ApiModelProperty(value = "referenceIcdId")
    private String referenceIcdId;

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class QueryParam extends BaseParam {
        @ApiModelProperty(value = "name", required = true)
        private String name;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class CreateParam extends PqIcdPathParam {
        @ApiModelProperty(value = "icdFile", required = true)
        private MultipartFile icdFile;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class ExternalCreateParam extends PqIcdPathParam {
        @ApiModelProperty(value = "id", required = true)
        @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
        private String id;

        @ApiModelProperty(value = "name", required = true)
        @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SCRIPT_NAME_REGEX, message = DetectionValidMessage.ICD_NAME_FORMAT_ERROR)
        private String name;

        @ApiModelProperty(value = "icd", required = true)
        @NotBlank(message = IcdExternalValidMessage.ICD_FILE_NOT_BLANK)
        private String icd;

    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UpdateParam extends PqIcdPathParam {
        @ApiModelProperty(value = "id", required = true)
        @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
        private String id;

        @ApiModelProperty(value = "icdFile")
        private MultipartFile icdFile;
    }

    private interface IcdExternalValidMessage {
        String ICD_FILE_NOT_BLANK = "ICD原始文件不能为空";
    }
}
