package com.gxwebsoft.hjm.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Map;

/**
 * 微信公众号模板消息请求
 *
 * @author 科技小王子
 * @since 2025-06-15
 */
@Data
@Schema(name = "TemplateMessageRequest", description = "微信公众号模板消息请求")
public class TemplateMessageRequest {

    @Schema(description = "接收者openid", required = true)
    private String toUser;

    @Schema(description = "模板ID", required = true)
    private String templateId;

    @Schema(description = "模板跳转链接（海外帐号没有跳转能力）")
    private String url;

    @Schema(description = "模板内容字体颜色，不填默认为黑色")
    private String topColor = "#173177";

    @Schema(description = "模板数据", required = true)
    private Map<String, TemplateDataItem> data;

    @Schema(description = "跳小程序所需数据，不需跳小程序可不用传该数据")
    private MiniProgram miniprogram;

    /**
     * 模板数据项
     */
    @Data
    @Schema(name = "TemplateDataItem", description = "模板数据项")
    public static class TemplateDataItem {
        @Schema(description = "数据值", required = true)
        private String value;

        @Schema(description = "数据颜色，不填默认为黑色")
        private String color = "#173177";

        public TemplateDataItem() {}

        public TemplateDataItem(String value) {
            this.value = value;
        }

        public TemplateDataItem(String value, String color) {
            this.value = value;
            this.color = color;
        }
    }

    /**
     * 小程序跳转信息
     */
    @Data
    @Schema(name = "MiniProgram", description = "小程序跳转信息")
    public static class MiniProgram {
        @Schema(description = "所需跳转到的小程序appid（该小程序appid必须与发模板消息的公众号是绑定关联关系，暂不支持小游戏）")
        private String appid;

        @Schema(description = "所需跳转到小程序的具体页面路径，支持带参数,（示例index?foo=bar），要求该小程序已发布，暂不支持小游戏")
        private String pagepath;
    }
}
