package com.yonge.cooleshow.biz.dal.vo.activity;

import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * 分享活动老师信息
 * Created by Eric.Shang on 2022/8/29.
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ActivityTeacherWrapper implements Serializable {

    private Long id;
    private Long teacherId;
    private String username;
    private String realName;
    private String phone;
    private String subjectId;

    private List<Long> subjectIds;
    private String subjectName;

    public List<Long> getSubjectIds() {
        if (StringUtils.isNotEmpty(getSubjectId())) {

            return Arrays.stream(getSubjectId().split(",")).map(Long::parseLong).collect(Collectors.toList());
        }
        return Optional.ofNullable(subjectIds).orElse(Lists.newArrayList());
    }

    public String getSubjectName() {
        return Optional.ofNullable(subjectName).orElse("");
    }
}
