package com.xdap.self_development.service;

import com.definesys.mpaas.query.db.PageQueryResult;
import com.xdap.self_development.controller.form.*;
import com.xdap.self_development.domain.dto.ApprovalNodesDTO;
import com.xdap.self_development.domain.pojo.ApprovalConfigPojo;
import com.xdap.self_development.domain.pojo.ApprovalFlowPojo;
import com.xdap.self_development.domain.pojo.ApprovalRecordPojo;
import com.xdap.self_development.domain.pojo.TemplatePojo;
import com.xdap.self_development.domain.view.ApprovalFlowNodeView;
import com.xdap.self_development.domain.view.TemplateChangeView;
import com.xdap.self_development.domain.view.TodoAndTemplateView;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;

public interface TemplateApprovalService {
    String startApproval(StartApprovalRequest request);

    void continueApproval(@NotBlank String flowId, @NotBlank String userId);

    void directSendingApproval(@NotBlank String templateId, @NotBlank String userId);

    PageQueryResult<TodoAndTemplateView> getApprovalList(ApprovalListForm form);

    void handleApproval(HandleApprovalRequest request);

    PageQueryResult<TemplateChangeView> getTemplateChanges(@Valid ApprovalAndParameterForm form);

    ApprovalFlowNodeView getApprovalProcess(@Valid ApprovalFlowForm form);

    void handleReturn(@Valid HandleApprovalRequest request);

    void handleReturnToNode(@Valid HandleReturnNodeForm form);

    void processApprovalLogic(
            ApprovalFlowPojo flow, HandleApprovalRequest request, ApprovalConfigPojo currentNode, ApprovalRecordPojo lastedRecord
    );

    void cancelProcess(ApprovalFlowPojo flow, ApprovalConfigPojo node, String status, String userId);

    void processNextNode(ApprovalFlowPojo flow, ApprovalConfigPojo currentNode, String userId);

    boolean checkNodeComplete(ApprovalFlowPojo flow, ApprovalConfigPojo node);

    void updateTasks(ApprovalFlowPojo flow, String status, Integer enableReturn, ApprovalConfigPojo currentNode);

    void addNodeTodo(ApprovalFlowPojo flow, ApprovalConfigPojo node, TemplatePojo template, String createBy, Integer enableReturn);

    List<String> getReturnNodes(@NotBlank String flowId);

    ApprovalNodesDTO getApprovalUsers(@NotBlank String templateId);

    boolean getIsDirect(String flowId);

    void updateFlowTitle(String flowId, String title);

    List<String> getEditableNodes(@NotBlank String flowId);

    void updateNode(UpdateNodeForm form);

    void updateNodeConfig(UpdateNodeForm form);
}
