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

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.WorkFlowData;
import com.codvision.workflow.entity.vo.WorkFlowDataVO;
import com.codvision.workflow.service.WorkFlowDataService;
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.Map;

/**
 * @author hxl
 */
@Slf4j
@Api(tags = "工作流数据管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/flowData")
public class WorkFlowDataController {

    private final WorkFlowDataService service;

    @PostMapping("/getPageResult")
    @ApiOperation("分页列表")
    public ResponseEntity<IPage<WorkFlowDataVO>> getPageResult(@RequestBody QueryPage<Map<String, Object>> queryPage) {
        return new ResponseEntity<IPage<WorkFlowDataVO>>().data(service.getPageResult(queryPage));
    }

    @PostMapping("/myInitiatedList")
    @ApiOperation("我发起的列表")
    public ResponseEntity<IPage<WorkFlowDataVO>> myInitiatedList(@RequestBody QueryPage<Map<String, Object>> queryPage) {
        return new ResponseEntity<IPage<WorkFlowDataVO>>().data(service.myInitiatedList(queryPage));
    }

    @PostMapping("/todoList")
    @ApiOperation("我待办的列表")
    public ResponseEntity<IPage<WorkFlowDataVO>> todoList(@RequestBody QueryPage<Map<String, Object>> queryPage) {
        return new ResponseEntity<IPage<WorkFlowDataVO>>().data(service.todoList(queryPage));
    }

    @PostMapping("/finishedList")
    @ApiOperation("我已办的列表")
    public ResponseEntity<IPage<WorkFlowDataVO>> finishedList(@RequestBody QueryPage<Map<String, Object>> queryPage) {
        return new ResponseEntity<IPage<WorkFlowDataVO>>().data(service.finishedList(queryPage));
    }

    @PostMapping("/claimList")
    @ApiOperation("待签收列表")
    public ResponseEntity<IPage<WorkFlowDataVO>> claimList(@RequestBody QueryPage<Map<String, Object>> queryPage) {
        return new ResponseEntity<IPage<WorkFlowDataVO>>().data(service.claimList(queryPage));
    }

    @PostMapping("/getById")
    @ApiOperation("根据ID获取详情")
    public ResponseEntity<WorkFlowData> getById(@RequestParam(value = "id") Integer id) {
        return new ResponseEntity<WorkFlowData>().data(service.getById(id));
    }
}
