package com.sikey.wa04.business.infrastructure.dto.request.messaging;

import com.sikey.wa04.common.dto.header.GenericManufacturerHeader;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

@Data
@Accessors(chain = true)
public class MessagingPublishRequest<T> implements Serializable {
    @Serial
    private static final long serialVersionUID = -9151951858562015064L;

    /**
     * header
     */
    GenericManufacturerHeader header;

    /**
     * 消息类型
     */
    @NotNull(message = "消息类型不能为空")
    private Integer msgType;

    /**
     * 消息发送的时间戳
     */
    @NotNull(message = "发送时间不能为空")
    private Long sendTime;

    /**
     * 接收者ID
     */
    @NotBlank(message = "接收者ID不能为空")
    private String recvId;

    /**
     * 是否是群聊
     */
    @NotNull(message = "是否群聊不能为空")
    private Boolean isGroup;

    /**
     * 群组id
     */
    private String groupId;

    /**
     * 消息内容
     */
    @NotNull(message = "消息内容不能为空")
    private T content;

    @Data
    @Accessors(chain = true)
    public static class VideoContent implements Serializable {
        @Serial
        private static final long serialVersionUID = -9151951858562015064L;
        @NotNull(message = "消息时长不能为空")
        private Integer duration;
        @NotBlank(message = "文件地址不能为空")
        private String fileUrl;
        @NotBlank(message = "文件类型不能为空")
        private String fileType;
    }

    @Data
    @Accessors(chain = true)
    public static class VoiceContent implements Serializable {
        @Serial
        private static final long serialVersionUID = -9151951858562015064L;

        @NotNull(message = "消息时长不能为空")
        private Integer duration;
        @NotBlank(message = "文件地址不能为空")
        private String fileUrl;
        @NotBlank(message = "文件类型不能为空")
        private String fileType;
    }

    @Data
    @Accessors(chain = true)
    public static class ImageContent implements Serializable {
        @Serial
        private static final long serialVersionUID = -9151951858562015064L;

        @NotBlank(message = "文件地址不能为空")
        private String fileUrl;
        @NotBlank(message = "文件类型不能为空")
        private String fileType;
    }

    @Data
    @Accessors(chain = true)
    public static class EmojiContent implements Serializable {
        @Serial
        private static final long serialVersionUID = -9151951858562015064L;

        @NotBlank(message = "表情ID不能为空")
        private String eid;
    }

    @Data
    @Accessors(chain = true)
    public static class TextContent implements Serializable {
        @Serial
        private static final long serialVersionUID = -9151951858562015064L;

        @NotBlank(message = "消息内容不能为空")
        private String raw;
    }

    /**
     * 询问地址通知
     */
    @Data
    @Accessors(chain = true)
    public static class AskLocationPointNoticeContent implements Serializable {
        @Serial
        private static final long serialVersionUID = -4588029278678812223L;
        /**
         * 追踪ID
         */
        private String traceId;
    }
}
