package com.chinaweal.aiccs.aiccs.business.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.chinaweal.aiccs.aiccs.business.entity.XrActivity;
import com.chinaweal.aiccs.aiccs.business.rules.model.SequenceFlowModel;
import com.chinaweal.aiccs.aiccs.business.service.IXrActivityService;
import com.chinaweal.youfool.framework.springboot.rest.RestResult;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 控制器
 * </p>
 *
 * @author quebh
 * @since 2023-05-04
 */
@Api(tags = "1.流程")
@ApiSort(1)
@RestController
@RequestMapping("/xrActivity")
public class XrActivityController {

    @Resource
    private IXrActivityService iXrActivityService;


    @ApiOperation(value = "1.查找当前节点的下一步路线", position = 2)
    @GetMapping("/findNextSequenceFlowList")
    public RestResult<List<SequenceFlowModel>> findNextSequenceFlowList(@RequestParam(name = "taskId") @ApiParam("taskId") String taskId) {
        return RestResult.ok(iXrActivityService.findNextSequenceFlowList(taskId));
    }

    @ApiOperation(value = "2.查找当前节点", position = 2)
    @GetMapping("/findCurrentNode")
    public RestResult<XrActivity> findCurrentNode(@RequestParam(name = "taskId") @ApiParam("taskId") String taskId) {
        LambdaQueryWrapper<XrActivity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(XrActivity::getTaskId, taskId).eq(XrActivity::getLinkStatus, "1");
        return RestResult.ok(iXrActivityService.getOne(queryWrapper, false));
    }
}
