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_USERAPPROVE_T")
public class Userapprove implements BaseDto,java.io.Serializable {

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

	@ApiModelProperty(value = "审批用户主键，记录审批人的主键")
	@TableField(value="USERID")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long userid;

	@ApiModelProperty(value = "表单主键，业务表主键")
	@TableField(value="FORMID")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long formid;
	
	
	@ApiModelProperty(value = "审批节点名称")
	@TableField(value="TASKNAME")
	private String taskname;
	
	@ApiModelProperty(value = "审批状态，记录当前节点审批状态，1：.待审批 (只针对前端返回 库中逻辑上不存在) 2.通过 3.不通过")
	@TableField(value="STATSHIS")
	private Integer statshis;
	
	@ApiModelProperty(value = "审批意见")
	@TableField(value="COMMENTHIS")
	private String commenthis;
	
	@ApiModelProperty(value = "节点位置，待定字段，")
	@TableField(value="TASKINDEX")
	private String taskindex;
	
	@ApiModelProperty(value = "节点编号")
	@TableField(value="TASKNO")
	private String taskno;
	@ApiModelProperty(value = "用户名称")
	@TableField(value="USERNAME")
	private String username;
	@ApiModelProperty(value = "创建时间")
	@TableField(value="CREATEDATE")
	private Long createdate;
	@ApiModelProperty(value = "审批意见")
	@TableField(value="TASKCOMMENT")
	private String taskcomment;
	@ApiModelProperty(value = "审批不通过原因")
	@TableField(value="REASON")
	private String reason;
	@ApiModelProperty(value = "审批不通过处理方式")
	@TableField(value="PROCESSMETHOD")
	private String processMethod;

	//保存当前登录用户的数据权限范围的搜索条件
	@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<>("USERID","userid"),
		new SimpleEntry<>("FORMID","formid"),
		new SimpleEntry<>("TASKNAME","taskname"),
		new SimpleEntry<>("STATSHIS","statshis"),
		new SimpleEntry<>("COMMENTHIS","commenthis"),
		new SimpleEntry<>("TASKINDEX","taskindex"),
		new SimpleEntry<>("TASKNO","taskno")
	)
	.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;
	}
}
