All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.taotao.boot.dingtalk.entity.WeNews Maven / Gradle / Ivy

There is a newer version: 2024.10
Show newest version
/*
 * Copyright (c) 2020-2030, Shuigedeng ([email protected] & https://blog.taotaocloud.top/).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.taotao.boot.dingtalk.entity;

import com.taotao.boot.dingtalk.enums.WeTalkMsgType;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 企业微信-消息类型-图文类型
 *
 * @author shuigedeng
 * @version 2022.07
 * @since 2022-07-06 15:20:26
 */
public class WeNews extends WeTalkMessage {

    private static final int ARTICLE_LIMIT = 8;
    /** 图文类型 */
    private News news;

    public WeNews() {
        setMsgtype(WeTalkMsgType.NEWS.type());
    }

    public WeNews(List articles) {
        this();
        this.news = new News(articles);
    }

    public News getNews() {
        return news;
    }

    public void setNews(News news) {
        this.news = news;
    }

    public static class News implements Serializable {

        /** 图文消息,一个图文消息支持1到8条图文 */
        private List
articles; public News() {} public News(List
articles) { this.articles = articles; } public List
getArticles() { return articles; } public void setArticles(List
articles) { this.articles = articles; } public static class Article implements Serializable { /** 标题,不超过128个字节,超过会自动截断 */ private String title; /** 描述,不超过512个字节,超过会自动截断 */ private String description; /** 点击后跳转的链接。 */ private String url; /** 图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图 1068*455,小图150*150。 */ private String picurl; public Article() {} public Article(String title, String description, String url, String picurl) { this.title = title; this.description = description; this.url = url; this.picurl = picurl; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getPicurl() { return picurl; } public void setPicurl(String picurl) { this.picurl = picurl; } } } @Override public void transfer(Map params) { for (Map.Entry entry : params.entrySet()) { Object value = entry.getValue(); if (value instanceof List) { @SuppressWarnings("unchecked") List imageTexts = (List) value; int size = imageTexts.size(); size = Math.min(size, ARTICLE_LIMIT); for (int i = 0; i < size; i++) {} for (ImageTextDeo imageText : imageTexts) { this.news.articles.add(new News.Article( imageText.getTitle(), imageText.getDescription(), imageText.getUrl(), imageText.getPicUrl())); } } break; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy