package org.security.trans.prevent.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.security.common.Constant;
import org.security.flow.core.constant.ProcessConstant;
import org.security.ht.vo.common.UploadVO;
import org.security.trans.prevent.entity.PreventMaterial;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;

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

/**
 * 案件材料报送表视图实体类
 *
 * @author BladeX
 * @since 2022-07-07
 */
@Data
@ApiModel(value = "PreventMaterialVO对象", description = "案件材料报送表")
public class PreventMaterialVO extends PreventMaterial {
	private static final long serialVersionUID = 1L;

	@ApiModelProperty(value = "任务名称")
	private String taskName;


	@ApiModelProperty(value = "机构名称")
	private String deptName;

	private List<UploadVO> fileList;

	private boolean editable;

	private boolean deletable;

	public boolean isEditable() {
		if ((Constant.HANDIN_STATE_DRAFT.equals(this.getState()) || Constant.HANDIN_STATE_REFUSE.equals(this.getState()) || ProcessConstant.CANCEL_STATE.equals(this.getState())) &&
			((Func.isNotBlank(this.getCreatedBy()) && this.getCreatedBy().contains(String.valueOf(AuthUtil.getUserId()))) || (Func.isNotBlank(this.getUserId()) && this.getUserId().contains(String.valueOf(AuthUtil.getUserId())))) ) {
			return true;
		}
		return false;
	}

	public boolean isDeletable() {
		if (Constant.HANDIN_STATE_DRAFT.equals(this.getState()) && Func.isEmpty(this.getDeadline()) ) {
			return true;
		}
		return false;
	}
}
