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

com.taotao.boot.dingtalk.entity.DingFeedCard 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.DingTalkMsgType;

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

/**
 * FeedCard类型
 *
 * @author shuigedeng
 * @version 2022.07
 * @since 2022-07-06 15:19:38
 */
public class DingFeedCard extends DingTalkMessage {

    /** {@link FeedCard} */
    private FeedCard feedCard;

    public DingFeedCard() {
        setMsgtype(DingTalkMsgType.FEED_CARD.type());
    }

    public DingFeedCard(List links) {
        this();
        this.feedCard = new FeedCard(links);
    }

    public FeedCard getFeedCard() {
        return feedCard;
    }

    public void setFeedCard(FeedCard feedCard) {
        this.feedCard = feedCard;
    }

    public static class FeedCard implements Serializable {

        /** {@link Link} */
        private List links;

        public FeedCard() {}

        public FeedCard(List links) {
            this.links = links;
        }

        public List getLinks() {
            return links;
        }

        public void setLinks(List links) {
            this.links = links;
        }

        public static class Link implements Serializable {

            /** 单条信息文本 */
            private String title;
            /** 点击单条信息到跳转链接 */
            private String messageURL;
            /** 单条信息后面图片的URL */
            private String picURL;

            public Link() {}

            public Link(String title, String messageURL, String picURL) {
                this.title = title;
                this.messageURL = messageURL;
                this.picURL = picURL;
            }

            public String getTitle() {
                return title;
            }

            public void setTitle(String title) {
                this.title = title;
            }

            public String getMessageURL() {
                return messageURL;
            }

            public void setMessageURL(String messageURL) {
                this.messageURL = messageURL;
            }

            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;
                for (ImageTextDeo imageText : imageTexts) {
                    this.feedCard.links.add(
                            new FeedCard.Link(imageText.getTitle(), imageText.getUrl(), imageText.getPicUrl()));
                }
                break;
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy