package cn.stylefeng.workflow.instance.modular.draft.controller;

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.workflow.instance.api.pojo.task.CommonTaskItem;
import cn.stylefeng.workflow.instance.modular.draft.entity.FlowEngineDraft;
import cn.stylefeng.workflow.instance.modular.draft.pojo.request.FlowEngineDraftRequest;
import cn.stylefeng.workflow.instance.modular.draft.service.FlowEngineDraftService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ApiResource(name = "流程草稿")
public class FlowEngineDraftController {

    @Resource
    private FlowEngineDraftService flowEngineDraftService;

    @GetResource(name = "获取流程草稿列表（带分页）", path = "/flowEngineDraft/page")
    public ResponseData<PageResult<CommonTaskItem>> page(FlowEngineDraftRequest flowEngineDraftRequest) {
        return new SuccessResponseData<>(flowEngineDraftService.findPage(flowEngineDraftRequest));
    }

    @GetResource(name = "获取草稿详情", path = "/flowEngineDraft/getDetail")
    public ResponseData<FlowEngineDraft> getDetail(
            @Validated(BaseRequest.detail.class) FlowEngineDraftRequest flowEngineDraftRequest) {
        return new SuccessResponseData<>(flowEngineDraftService.getDetail(flowEngineDraftRequest));
    }


}
