import "../base.api"

type (
    // The response data of sop stage information | SopStage信息
    SopStageInfo {
        BaseIDInfo

        // Status 1: normal 2: ban | 状态 1 正常 2 禁用 
        Status  *uint8 `json:"status,optional"`

        // SOP 任务 ID 
        TaskId  *uint64 `json:"taskId,optional"`

        // 阶段名称 
        Name  *string `json:"name,optional"`

        // 客群筛选条件类型  1 按标签筛选 2 按客户基本信息筛选 
        ConditionType  *int `json:"conditionType,optional"`

        // 筛选条件关系  1 满足所有条件(and) 2 满足任意条件(or) 
        ConditionOperator  *int `json:"conditionOperator,optional"`

        // 筛选条件列表 
        ConditionList  []Condition `json:"conditionList,optional"`

        // 命中后发送的消息内容 
        ActionMessage  []Action `json:"actionMessage,optional"`

        // 命中后需要打的标签 
        ActionLabel  []uint64 `json:"actionLabel,optional"`

        // 阶段顺序 
        IndexSort  *int `json:"indexSort,optional"`

        // sop 任务信息
        TaskInfo  *SopTaskInfo `json:"taskInfo,optional"`

        // node 信息
        NodeList  []SopNodeInfo `json:"nodeList,optional"`
    }

    // The response data of sop task information | SopTask信息
    SopTaskInfo {
        BaseIDInfo

        // Status 1: normal 2: ban | 状态 1 正常 2 禁用
        Status  *uint8 `json:"status,optional"`

        // SOP 任务名称
        Name  *string `json:"name,optional"`

        // 机器人微信 id 列表
        BotWxidList  []string `json:"botWxidList,optional"`

        // 标签类型:1好友,2群组,3企业微信联系人
        Type  *int `json:"type,optional"`

        // 任务计划开始时间
        PlanStartTime  *int64 `json:"planStartTime,optional"`

        // 任务计划结束时间
        PlanEndTime  *int64 `json:"planEndTime,optional"`

        // 创建者 id
        CreatorId  *string `json:"creatorId,optional"`

        // 阶段信息
        StageList  []SopStageInfo `json:"stageList,optional"`

        // 组织ID
        OrganizationId *uint64 `json:"organizationId,optional"`
    }

    // The response data of sop node information | SopNode信息
    SopNodeInfo {
        BaseIDInfo

        // Status 1: normal 2: ban | 状态 1 正常 2 禁用
        Status  *uint8 `json:"status,optional"`

        // 阶段 ID
        StageId  *uint64 `json:"stageId,optional"`

        // 父节点 ID
        ParentId  *uint64 `json:"parentId,optional"`

        // 节点名称
        Name  *string `json:"name,optional"`

        // 触发条件类型 1 客户回复后触发 2 超时后触发
        ConditionType  *int `json:"conditionType,optional"`

        // 触发语义列表 当为空时则代表用户回复任意内容后触发
        ConditionList  []string `json:"conditionList,optional"`

        // 超时触发时间(分钟)
        NoReplyCondition  *uint64 `json:"noReplyCondition,optional"`

        // 命中后发送的消息内容
        ActionMessage  []Action `json:"actionMessage,optional"`

        // 命中后需要打的标签
        ActionLabel  []uint64 `json:"actionLabel,optional"`

        // 阶段信息
        StageInfo  *SopStageInfo `json:"stageInfo,optional"`
    }

    // The response data of sop stage list | SopStage列表数据
    SopStageListResp {
        BaseDataInfo

        // SopStage list data | SopStage列表数据
        Data SopStageListInfo `json:"data"`
    }

    // SopStage list data | SopStage列表数据
    SopStageListInfo {
        BaseListInfo

        // The API list data | SopStage列表数据
        Data  []SopStageInfo  `json:"data"`
    }

    // Get sop stage list request params | SopStage列表请求参数
    SopStageListReq {
        TaskId  *uint64 `json:"taskId"`
    }

    // SopStage information response | SopStage信息返回体
    SopStageInfoResp {
        BaseDataInfo

        // SopStage information | SopStage数据
        Data SopStageInfo `json:"data"`
    }

    // SopStage create response | SopStage创建回体
    SopStageCreateResp {
        BaseDataInfo

        // SopStage id | SopStage id
        Data uint64 `json:"data"`
    }

    // Move sop stage request params | 移动阶段请求参数
    SopStageMoveReq {
        BaseIDInfo

        // 阶段名称
        Offset  *int `json:"offset,optional"`
    }
)

@server(
    jwt: Auth
    group: sop_stage
    middleware: Authority
)

service Wechat {
    // Create sop stage information | 创建SopStage
    @handler createSopStage
    post /sop_stage/create (SopStageInfo) returns (SopStageCreateResp)

    // Update sop stage information | 更新SopStage
    @handler updateSopStage
    post /sop_stage/update (SopStageInfo) returns (BaseMsgResp)

    // Delete sop stage information | 删除SopStage信息
    @handler deleteSopStage
    post /sop_stage/delete (IDReq) returns (BaseMsgResp)

    // Get sop stage list | 获取SopStage列表
    @handler getSopStageList
    post /sop_stage/list (SopStageListReq) returns (SopStageListResp)

    // Get sop stage by ID | 通过ID获取SopStage
    @handler getSopStageById
    post /sop_stage (IDReq) returns (SopStageInfoResp)

    // Get sop stage by ID | 通过ID获取SopStage详情
    @handler getSopStageDetail
    post /sop_stage/detail (IDReq) returns (SopStageInfoResp)

    // Get sop stage move | 移动阶段顺序
    @handler moveSopStage
    post /sop_stage/move (SopStageMoveReq) returns (BaseMsgResp)
}