package com.xinelu.manage.controller.signpatientmanageroutenode;

import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.R;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode;
import com.xinelu.manage.dto.signpatientmanageroutenode.PatientTaskDto;
import com.xinelu.manage.dto.signpatientmanageroutenode.RouteNodeCheckDto;
import com.xinelu.manage.service.signpatientmanageroutenode.ISignPatientManageRouteNodeService;
import com.xinelu.manage.vo.signpatientmanageroutenode.PatientTaskVo;
import com.xinelu.manage.vo.signpatientmanageroutenode.SignPatientManageRouteNodeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 签约患者管理任务路径节点控制器
 * @author: haown
 * @create: 2024-04-02 15:08
 **/
@Api(tags = "签约患者管理任务路径节点控制器")
@RestController
@RequestMapping("/manage/signnode")
public class SignPatientManageRouteNodeController extends BaseController {

	@Resource
	private ISignPatientManageRouteNodeService signNodeService;

	/**
	 * 根据患者主键查询签约路径及节点
	 */
	@ApiOperation("患者任务列表查询")
	@GetMapping("/tasklist")
	public TableDataInfo tasklist(PatientTaskDto patientTaskDto) {
		startPage();
		List<PatientTaskVo> list = signNodeService.selectPatientTaskList(patientTaskDto);
		return getDataTable(list);
	}

	/**
	 * 查询患者任务节点列表
	 */
	@ApiOperation("查询患者任务节点列表")
	@GetMapping("/getNodeList")
	public R<List<SignPatientManageRouteNode>> getNodeList(PatientTaskDto patientTaskDto) {
		List<SignPatientManageRouteNode> list = signNodeService.getNodeList(patientTaskDto);
		return R.ok(list);
	}

	/**
	 * 查询管理任务路径及节点
	 */
	@ApiOperation("查询管理任务路径及节点")
	@GetMapping("/getRouteNodeList")
	public R<List<SignPatientManageRouteNodeVo>> getRouteNodeList(PatientTaskDto patientTaskDto) {
		List<SignPatientManageRouteNodeVo> list = signNodeService.getRouteNodeList(patientTaskDto);
		return R.ok(list);
	}

	/**
	 * 审核任务
	 */
	@ApiOperation("审核任务")
	@PostMapping("/audit")
	public R<String> audit(@RequestBody RouteNodeCheckDto routeNodeCheckDto) {
		int flag = signNodeService.audit(routeNodeCheckDto);
		return flag < 0 ? R.fail() : R.ok();
	}
}
