package com.cyksj.model.views;

import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.DbIgnore;
import com.ejlchina.searcher.bean.SearchBean;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.List;

/**
 * 项目名: yhlxj
 * 文件名: SysCorpFollowView
 * 创建者: JavaZou
 * 创建时间:2024/6/12 12:02
 */
@Getter
@Setter
@SearchBean(tables = "sys_corp_follow sf left join sys_corp_follow_relate sfr on sf.id = sfr.mid",
		where = "sf.deleted is true and sfr.deleted is true",
		orderBy = "sf.id,sfr.update_time desc")
public class SysCorpFollowView {
	@DbField("sf.id")
	private Long mid;

	@DbField("sf.name")
	private String name;

	@DbField("sfr.id")
	private Long sid;

	@DbField("sfr.name")
	private String followName;

	@DbField("sfr.follow_id")
	private String followId;

	@DbField("sfr.img")
	private String img;

	/**
	 * 激活状态: 1=已激活，2=已禁用，4=未激活，5=退出企业
	 */
	@DbField("sfr.status")
	private Integer status;

	@DbField("sfr.update_time")
	private Date updateTime;

	@DbIgnore
	private Integer numOfCorpUser;

	@DbIgnore
	List<SysCorpFollowRelateView> subList;

	/**
	 * 是否开启企业会话
	 */
	@DbIgnore
	private Boolean isOpen = false;

	/**
	 * 登录账号用户id
	 */
	@DbField("sf.cms_user_id")
	private Long cmsUserId;

	@DbField("select nickname from cms_user where id = cms_user_id limit 1")
	private String cmsUserName;

	public String getShowName() {
		StringBuilder sb = new StringBuilder();
		sb.append(name).append("(").append(followName).append(")");
		return sb.toString();
	}


	@Getter
	@Setter
	@SearchBean(tables = "sys_corp_follow_relate sfr",
			where = "sfr.deleted is true"
			, orderBy = "sfr.update_time desc")
	public class SysCorpFollowRelateView {

		@DbField("sfr.id")
		private Long sid;

		@DbField("sfr.mid")
		private Long mid;

		@DbField("sfr.name")
		private String followName;

		@DbField("sfr.follow_id")
		private String followId;

		@DbField("sfr.img")
		private String img;

		/**
		 * 激活状态: 1=已激活，2=已禁用，4=未激活，5=退出企业
		 */
		@DbField("sfr.status")
		private Integer status;
	}
}
