package com.yeejoin.amos.boot.module.tzs.biz.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.RescueProcessDto;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.RescueProcessServiceImpl;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 救援过程表
 *
 * @author system_generator
 * @date 2021-08-03
 */
@RestController
@Api(tags = "救援过程表Api")
@RequestMapping(value = "/tzs/rescue-process")
public class RescueProcessController extends BaseController {

    @Autowired
    RescueProcessServiceImpl rescueProcessServiceImpl;


	@Autowired
	RedisUtils redisUtils;

	/**
	 * 根据警情id 更新救援信息表
	 * @param model
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@PostMapping(value = "/updateByAlertId")
	@ApiOperation(httpMethod = "POST", value = "根据警情id 更新救援信息表", notes = "根据警情id 更新救援信息表")
	public ResponseModel<Boolean> save(@RequestBody RescueProcessDto model) {
		ReginParams reginParams =getSelectedOrgInfo();
		boolean update = rescueProcessServiceImpl.updateByAlertId(model,reginParams.getUserModel());
		return ResponseHelper.buildResponse(update);
	}


	/**
	 * 根据警情id 获取救援过程表
	 * @param alertId
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@GetMapping(value = "/alert/{alertId}")
	@ApiOperation(httpMethod = "GET",value = "根据警情id 获取救援过程表",  notes = "根据警情id 获取救援过程表")
	public ResponseModel<RescueProcessDto> selectOne(@PathVariable Long alertId) {
	    return ResponseHelper.buildResponse(rescueProcessServiceImpl.getProcessByAlertId(alertId));
	}

}
