package com.codvision.workflow.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.codvision.commoncore.common.ResponseEntity;
import com.codvision.webcore.bean.QueryPage;
import com.codvision.workflow.entity.WorkFlowButton;
import com.codvision.workflow.service.WorkFlowButtonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author hxl
 */
@Slf4j
@Api(tags = "工作流按钮管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/flowButton")
public class WorkFlowButtonController {

    private final WorkFlowButtonService service;

    @PostMapping("/getPageList")
    @ApiOperation("分页列表")
    public ResponseEntity<IPage<WorkFlowButton>> getPageList(@RequestBody QueryPage<WorkFlowButton> queryPage) {
        return new ResponseEntity<IPage<WorkFlowButton>>().data(service.getPageResult(queryPage));
    }
    @PostMapping("/update")
    @ApiOperation("更新")
    public ResponseEntity<Boolean> update(@RequestBody WorkFlowButton workFlowButton) {
        return new ResponseEntity<>(service.updateButton(workFlowButton));
    }


    @PostMapping("/getListByTaskId")
    @ApiOperation("获取任务节点的按钮配置信息")
    public ResponseEntity<List<WorkFlowButton>> getListByTaskId(@RequestParam String taskId) {
        return new ResponseEntity<List<WorkFlowButton>>().data(service.getListByTaskId(taskId));
    }

}
