package com.cyksj.model.request.corp;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/*
 *项目名: shanxing-admin
 *文件名: LinkTitle
 *创建者: JavaZou
 *创建时间:2022/6/20 16:01
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Attachments implements Serializable {

	private static final long serialVersionUID = 3529000560142115378L;

	/**
	 * 图片消息.
	 */
	public static final String IMAGE = "image";
	/**
	 * 图文消息.
	 */
	public static final String LINK = "link";
	/**
	 * 视频消息.
	 */
	public static final String VIDEO = "video";
	/**
	 * 小程序消息.
	 */
	public static final String MINIPROGRAM = "miniprogram";


	private String msgtype;

	private Image image;

	private Link link;

	@JsonProperty("miniprogram")
	private MiniProgram miniProgram;

	private Video video;

	public Attachments(String msgtype, Link link) {
		this.msgtype = msgtype;
		this.link = link;
	}

	public void setImage(Image image) {
		this.image = image;
		this.msgtype = IMAGE;
	}

	public void setLink(Link link) {
		this.link = link;
		this.msgtype = LINK;
	}

	public void setMiniProgram(MiniProgram miniProgram) {
		this.miniProgram = miniProgram;
		this.msgtype = MINIPROGRAM;
	}


	public void setVideo(Video video) {
		this.video = video;
		this.msgtype = VIDEO;
	}


	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	@JsonInclude(JsonInclude.Include.NON_NULL)
	public static class Link implements Serializable{
		private static final long serialVersionUID = -1036758941402144780L;

		/**
		 * 标题
		 */
		private String title;
		/**
		 * 封面
		 */
		private String picurl;

		/**
		 * 描述
		 */
		private String desc;

		/**
		 * 项目地址
		 */
		private String url;

		@JsonProperty("media_id")
		private String mediaId;

		public Link(String title, String picurl, String desc, String url) {
			this.title = title;
			this.picurl = picurl;
			this.desc = desc;
			this.url = url;
		}
	}

	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	@JsonInclude(JsonInclude.Include.NON_NULL)
	public static class Image implements Serializable {
		private static final long serialVersionUID = -606286372867787121L;

		@JsonProperty("media_id")
		private String mediaId;

		@JsonProperty("pic_url")
		private String picUrl;
	}


	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	@JsonInclude(JsonInclude.Include.NON_NULL)
	public static class MiniProgram implements Serializable {
		private static final long serialVersionUID = 4242074162638170679L;

		private String title;
		@JsonProperty("pic_media_id")
		private String picMediaId;
		private String appid;
		private String page;
		private String url;
	}

	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	@JsonInclude(JsonInclude.Include.NON_NULL)
	public static class Video implements Serializable {
		private static final long serialVersionUID = -6048642921382867138L;
		@JsonProperty("media_id")
		private String mediaId;
		@JsonProperty("thumb_media_id")
		private String thumbMediaId;
		private String url;
	}

}