/*
 * Copyright (c) 2023 codvision.com All Rights Reserved.
 */

package com.codvision.workflow.controller;

import com.codvision.commoncore.common.ResponseEntity;
import com.codvision.workflow.entity.vo.WorkFlowRecordVO;
import com.codvision.workflow.service.WorkFlowRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hxl
 */
@Slf4j
@Api(tags = "工作流流程记录管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/flowRecord")
public class WorkFlowRecordController {

    private final WorkFlowRecordService service;

    @PostMapping("/getListByInstanceId")
    @ApiOperation("根据流程实例ID获取列表")
    public ResponseEntity<List<WorkFlowRecordVO>> getListByInstanceId(@RequestParam(value = "instanceId") String instanceId) {
        return new ResponseEntity<List<WorkFlowRecordVO>>().data(service.getListByInstanceId(instanceId));
    }

    @PostMapping("/addCustomRecord")
    @ApiOperation("添加自定义记录")
    public ResponseEntity<String> addCustomRecord(@RequestParam(value = "taskId") String taskId,
                                                  @RequestParam(value = "operationType") Integer operationType) {
        service.addCustomRecord(taskId, operationType);
        return new ResponseEntity<String>().ok();
    }


}
