package cn.stylefeng.workflow.design.modular.controller;

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.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.workflow.api.pojo.config.node.form.FormPermission;
import cn.stylefeng.workflow.design.modular.pojo.request.FormPermissionRequest;
import cn.stylefeng.workflow.design.modular.service.DesignConfigService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiResource(name = "流程设计器节点中配置详情")
public class DesignConfigController {

    @Resource
    private DesignConfigService designConfigService;

    @GetResource(name = "获取系统中的工作流定时任务列表", path = "/nodeTimer/getActionClasses")
    public ResponseData<List<String>> getActionClasses() {
        List<String> actionClasses = designConfigService.getActionClasses();
        return new SuccessResponseData<>(actionClasses);
    }

    @PostResource(name = "获取表单配置列表", path = "/flowDesignConfig/getFormPermissionList")
    public ResponseData<List<FormPermission>> getFormPermissionList(
            @RequestBody @Validated(BaseRequest.detail.class) FormPermissionRequest formPermissionRequest) {
        return new SuccessResponseData<>(designConfigService.getFormPermissionList(formPermissionRequest));
    }

}
