package org.jeecg.module.custom.ocr.dataobject;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jeecg.module.custom.ocr.common.dto.BaseDto;
import org.jeecg.module.custom.ocr.utils.requestFormat.SearchQuery;

import java.util.AbstractMap.SimpleEntry;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 多租户管理
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "S_TENANT_T")
public class Tenant implements BaseDto,java.io.Serializable {

	private static final long serialVersionUID = -421629635552978382L;

	/**
	 * 流水号
	 */
	@TableId(value = "id",type = IdType.ASSIGN_ID)
	@JsonSerialize(using = ToStringSerializer.class)
	@TableField(value="ID")
	private Long id;

	/**
	 * 租户名称
	 */
	@TableField(value="NAME")
	private String name;

	/**
	 * 开始时间
	 */
	@TableField(value="STARTDATE")
	private Long startdate;

	/**
	 * 结束时间
	 */
	@TableField(value="ENDDATE")
	private Long enddate;

	/**
	 * 状态 1正常 0冻结
	 */
	@TableField(value="STATUS")
	private Integer status;

	/**
	 * 所属行业
	 */
	@TableField(value="TRADE")
	private String trade;

	/**
	 * 公司规模
	 */
	@TableField(value="COMPANYSIZE")
	private String companysize;

	/**
	 * 公司地址
	 */
	@TableField(value="COMPANYADDRESS")
	private String companyaddress;

	/**
	 * 公司LOGO
	 */
	@TableField(value="COMPANYLOGO")
	private String companylogo;

	/**
	 * 门牌号
	 */
	@TableField(value="COMPANTNO")
	private String compantno;

	/**
	 * 工作地点
	 */
	@TableField(value="COMPANYPLACE")
	private String companyplace;

	/**
	 * 域名
	 */
	@TableField(value="DOMAIN")
	private String domain;

	/**
	 * 登录背景图片
	 */
	@TableField(value="BACKIMG")
	private String backimg;

	/**
	 * 允许申请管理员 1允许 0不允许
	 */
	@TableField(value="APPLYADMIN")
	private Integer applyadmin;

	/**
	 * 创建人，记录创建人的帐号
	 */
	@TableField(value="CREATEUSER")
	private String createuser;

	/**
	 * 创建时间
	 */
	@TableField(value="CREATEDATE")
	private Long createdate;

	/**
	 * 修改人，记录创建人的帐号
	 */
	@TableField(value="UPDATEUSER")
	private String updateuser;

	/**
	 * 更新时间
	 */
	@TableField(value="UPDATETIME")
	private Long updatetime;

	/**
	 * 三方系统标识，用于第三方系统标志使用
	 */
	@TableField(value="OTHERNO")
	private String otherno;


	//保存当前登录用户的数据权限范围的搜索条件
	@TableField(exist = false)
	@JsonIgnore
	private SearchQuery searchQueryrolesShowleave;

	@TableField(exist = false)
	@JsonIgnore
	private final Map<String,String> query = Stream.of(
		new SimpleEntry<>("listdept","deptid"),
		new SimpleEntry<>("ID","id"),
		new SimpleEntry<>("NAME","name"),
		new SimpleEntry<>("STARTDATE","startdate"),
		new SimpleEntry<>("ENDDATE","enddate"),
		new SimpleEntry<>("STATUS","status"),
		new SimpleEntry<>("TRADE","trade"),
		new SimpleEntry<>("COMPANYSIZE","companysize"),
		new SimpleEntry<>("COMPANYADDRESS","companyaddress"),
		new SimpleEntry<>("COMPANYLOGO","companylogo"),
		new SimpleEntry<>("COMPANTNO","compantno"),
		new SimpleEntry<>("COMPANYPLACE","companyplace"),
		new SimpleEntry<>("DOMAIN","domain"),
		new SimpleEntry<>("BACKIMG","backimg"),
		new SimpleEntry<>("APPLYADMIN","applyadmin"),
		new SimpleEntry<>("CREATEUSER","createuser"),
		new SimpleEntry<>("CREATEDATE","createdate"),
		new SimpleEntry<>("UPDATEUSER","updateuser"),
		new SimpleEntry<>("UPDATETIME","updatetime"),
		new SimpleEntry<>("OTHERNO","otherno")
	)
	.collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue));
	@Override
	public String getQueryFiled(String filedname){
		String obj = null;
		if(null != query && query.size() > 0){
		obj = query.get(filedname);
		}
		return obj;
	}
}
