package com.yonge.cooleshow.biz.dal.wrapper.im;

import com.alibaba.fastjson.JSON;
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections.CollectionUtils;

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

/**
 * 客服消息
 * Created by Eric.Shang on 2022/9/30.
 */
public class CustomerService {

    /**
     * 客服通知消息
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class NotifyMessage implements Serializable {

        private List<String> receives;
        private ClientEnum clientType;
        private String subjectId;
        private List<String> subjectIds;

        private String title;
        private String txtMessage;
        private String imgMessage;
        private String imgUrl;

        public static NotifyMessage from(String recv) {

            return JSON.parseObject(recv, NotifyMessage.class);
        }

        public List<String> getReceives() {
            if (CollectionUtils.isEmpty(receives)) {
                return null;
            }
            return receives;
        }
    }

    /**
     * 消息接收者
     */
    @Data
    public static class MessageReceives implements Serializable {

        private Long userId;
        private String nickname;
    }
}
