package cn.axzo.msg.center.domain.entity;

import cn.axzo.msg.center.api.custombutton.ProposedButtons;
import cn.axzo.msg.center.domain.persistence.BaseEntityExt;
import cn.axzo.msg.center.domain.utils.IgnorePropsJsonTypeHandler;
import cn.axzo.msg.center.service.enums.BizCategoryEnum;
import cn.axzo.msg.center.service.enums.BizFinalStateEnum;
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
import cn.axzo.msg.center.service.enums.OrganizationTypeEnum;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * @author yanglin
 */
@Setter
@Getter
@TableName(value = "todo_business", autoResultMap = true)
public class TodoBusiness extends BaseEntityExt<TodoBusiness> {

    /**
      * 模板编码
      */
    private String templateCode;

    /**
     * 样板待办code, 兼容老接口
     */
    private String sampleTodoCode;

    /**
     * 关联业务编码
     */
    private String bizCode;

    /**
     * 消息标题
     */
    private String title;

    /**
     * 消息内容
     */
    private String content;

    /**
     * 发起者ID
     */
    private Long promoterId;

    /**
     * 发起者的自然人ID
     */
    private Long promoterPersonId;

    /**
     * 发起者姓名
     */
    private String promoterName;

    /**
     * 发起者身份 WORKER:工人,WORKER_LEADER:班组长,PRACTITIONER:从业人员,REGULATOR:监管人员,OPERATOR:运营人员
     */
    private IdentityTypeEnum promoterType;

    /**
     * 业务状态
     */
    private BizFinalStateEnum bizFinalState;

    /**
     * 业务标签
     */
    private String bizFlag;

    /**
     * 业务类型
     */
    private BizCategoryEnum bizCategory;

    /**
     * 业务扩展参数
     */
    @TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
    private JSONObject bizExtParam;

    /**
     * 路由参数
     */
    @TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
    private JSONObject routerParams;

    /**
     * 待办的截止时间
     */
    private Date deadline;

    /**
     * 企业id
     */
    private Long ouId;

    /**
     * 消息所属组织Id
     */
    private Long orgId;

    /**
     * 消息所属组织名称
     */
    private String orgName;
    /**
     * 组织类型
     */
    private OrganizationTypeEnum orgType;

    /**
     * 保存额外的数据信息
     */
    @TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
    private TodoBusinessExt recordExt = new TodoBusinessExt();

    /**
     * 自定义按钮
     */
    @TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
    private ProposedButtons proposedButtons;

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}