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 io.swagger.annotations.ApiModelProperty;
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 = "OA_CATEGORY_T")
public class Category implements BaseDto,java.io.Serializable {

	private static final long serialVersionUID = 3650775877135330041L;
	@ApiModelProperty(value = "流水号")
	@TableId(value = "id",type = IdType.ASSIGN_ID)
	@JsonSerialize(using = ToStringSerializer.class)
	@TableField(value="ID")
	private Long id;

	@ApiModelProperty(value = "项目名称")
	@TableField(value="CATEGORYNAME")
	private String categoryname;

	@ApiModelProperty(value = "项目编码")
	@TableField(value="CATEGORY")
	private String category;

	@ApiModelProperty(value = "对应的Service名，主要是spring的service名")
	@TableField(value="SERVICENAME")
	private String servicename;

	@ApiModelProperty(value = "内置表单，使用flowable表单，0：使用本地数据，1：使用flowable表单，3:外置表单，4：其他自定义表单")
	@TableField(value="BUILTFORM")
	private Integer builtform;

	@ApiModelProperty(value = "表单地址，用户展示用户表单使用")
	@TableField(value="FORMURL")
	private String formurl;

	@ApiModelProperty(value = "表单详情")
	@TableField(value="FORMDETAIL")
	private String formdetail;

	@ApiModelProperty(value = "是否启用，0：禁用，1：启用")
	@TableField(value="HAVEUSE")
	private Integer haveuse;

	@ApiModelProperty(value = "表单分类")
	@TableField(value="FORMTYPE")
	private String formtype;

	@ApiModelProperty(value = "流程定义id")
	@TableField(value="PROCESSDEFINITIONID")
	private String processdefinitionid;

	@ApiModelProperty(value = "排序")
	@TableField(value="FORMNO")
	private Integer formno;

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

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

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

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

	@ApiModelProperty(value = "隶属机构")
	@TableField(value="DEPTID")
	private Long deptid;

	@ApiModelProperty(value = "租户主键")
	@TableField(value="TENANTID")
	private String tenantid;

	//租户对象
	@TableField(exist = false)
	private Tenant tenant;

	//业务表主键
	@ApiModelProperty(value = "业务表主键")
	@TableField(exist = false)
	private String formid;

	//节点描述信息，用于判断是否存在多个下级界面
	@TableField(exist = false)
	String documentation;

	@ApiModelProperty(value = "状态，审批状态 1:未提交 2:审批中 3:审批通过 ")
	@TableField(exist = false)
	private Integer states;

	//保存当前登录用户的数据权限范围的搜索条件
	@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<>("CATEGORYNAME","categoryname"),
		new SimpleEntry<>("CATEGORY","category"),
		new SimpleEntry<>("SERVICENAME","servicename"),
		new SimpleEntry<>("BUILTFORM","builtform"),
		new SimpleEntry<>("FORMURL","formurl"),
		new SimpleEntry<>("HAVEUSE","haveuse"),
		new SimpleEntry<>("FORMTYPE","formtype"),
		new SimpleEntry<>("PROCESSDEFINITIONID","processdefinitionid"),
		new SimpleEntry<>("FORMNO","formno"),
		new SimpleEntry<>("CREATEUSER","createuser"),
		new SimpleEntry<>("CREATEDATE","createdate"),
		new SimpleEntry<>("UPDATEUSER","updateuser"),
		new SimpleEntry<>("UPDATETIME","updatetime"),
		new SimpleEntry<>("TENANTID","tenantid")
	)
	.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;
	}
}
