package com.elephant.framework.galaxy.aroad.module.emergency.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.elephant.framework.galaxy.aroad.module.common.annotation.SysLog;
import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController;
import com.elephant.framework.galaxy.aroad.module.emergency.entity.EmergencyCar;
import com.elephant.framework.galaxy.aroad.module.emergency.service.EmergencyCarService;
import com.elephant.framework.galaxy.aroad.response.R;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 应急处置车辆
 *
 * @author songwenjie
 * @date 2019-03-21 14:50:26
 */
@RestController
@AllArgsConstructor
@RequestMapping("/emergencycar")
public class EmergencyCarController extends BaseController {

  private final EmergencyCarService emergencyCarService;

  /**
   * 分页查询
   *
   * @param page 分页对象
   * @param text 模糊查询
   * @return
   */
  @GetMapping("/page")
  public R getEmergencyCarPage(Page page, String text) {
    return new R<>(emergencyCarService.getEmergencyCarPage(page, text));
  }

  /**
   * @Description: 获取队伍车辆坐标信息
   *
   * @auther: XingYuyang
   * @date: 2019-4-9 14:20:33
   * @param: []
   * @return: com.elephant.framework.galaxy.aroad.response.R
   */
  @GetMapping("/coordinates/{teamids}")
  public R getCoordinates(@PathVariable("teamids") String teamIds) {
    return new R<>(emergencyCarService.getCoordinates(teamIds));
  }

  /**
   * 通过id查询应急处置车辆
   *
   * @param rowId id
   * @return R
   */
  @GetMapping("/{rowId}")
  public R getById(@PathVariable("rowId") Integer rowId) {
    return new R<>(emergencyCarService.getById(rowId));
  }

  /**
   * @Description: 获取队伍列表
   * @Param:
   * @return:
   * @Author: XingYuyang
   * @Date: 2019-04-15 10:08:18
   */
  @GetMapping("/getteams")
  public R getTeams() {
    return new R<>(emergencyCarService.getTeams());
  }

  /**
   * 新增应急处置车辆
   *
   * @param emergencyCar 应急处置车辆
   * @return R
   */
  @SysLog("新增应急处置车辆")
  @PostMapping
  public R save(@RequestBody EmergencyCar emergencyCar) {
    return new R<>(emergencyCarService.save(emergencyCar));
  }

  /**
   * 修改应急处置车辆
   *
   * @param emergencyCar 应急处置车辆
   * @return R
   */
  @SysLog("修改应急处置车辆")
  @PutMapping
  public R updateById(@RequestBody EmergencyCar emergencyCar) {
    return new R<>(emergencyCarService.updateById(emergencyCar));
  }

  /**
   * 通过id删除应急处置车辆
   *
   * @param rowId id
   * @return R
   */
  @SysLog("删除应急处置车辆")
  @DeleteMapping("/{rowId}")
  public R removeById(@PathVariable Integer rowId) {
    return new R<>(emergencyCarService.removeById(rowId));
  }
}
