package com.cyksj.model.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.cyksj.model.request.corp.Attachments;
import com.ejlchina.searcher.bean.DbIgnore;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 项目名: yhlxj
 * 文件名: CorpWelcomeTemplate
 * 创建者: JavaZou
 * 创建时间:2023/12/5 18:19
 */
@Getter
@Setter
public class CorpWelcomeTemplate extends BaseEntity {
	@NotEmpty(message = "模板名不为空")
	private String name;

	@NotNull
	private Integer type;

	/**
	 * 群发文本内容
	 */
	@TableField(updateStrategy = FieldStrategy.IGNORED)
	private String text;

	@TableField(exist = false)
	@DbIgnore
	private List<Attachments> attachments;

	/**
	 * 附件字符串
	 */
	@TableField(updateStrategy = FieldStrategy.IGNORED)
	private String attachmentsStr;

	/**
	 * 优惠券id
	 */
	@TableField(updateStrategy = FieldStrategy.IGNORED)
	private String couponIds;

	@DbIgnore
	@TableField(exist = false)
	private String couponName;

	private Boolean deleted;

	@Getter
	public enum Type {
		natural("自然流量"), activeCode("渠道活码"), follow("加分链接");

		String desc;

		Type(String desc) {
			this.desc = desc;
		}

		public static Boolean checkType(Integer type) {
			return Arrays.stream(Type.values()).filter(t -> t.ordinal() == type.intValue()).findAny().isPresent();
		}
	}
}
