package com.elephant.framework.galaxy.aroad.module.traffic.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.traffic.entity.TrafficSpot;
import com.elephant.framework.galaxy.aroad.module.traffic.service.TrafficSpotService;
import com.elephant.framework.galaxy.aroad.response.R;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 观测站点表
 *
 * @author Xingyuyang
 * @date 2019-04-29 14:38:10
 */
@RestController
@AllArgsConstructor
@RequestMapping("/trafficspot")
public class TrafficSpotController extends BaseController  {

  private final  TrafficSpotService trafficSpotService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param trafficSpot 观测站点表
   * @return
   */
  @GetMapping("/page")
  public R getTrafficSpotPage(Page page, TrafficSpot trafficSpot) {
    return  new R<>(trafficSpotService.getTrafficSpotPage(page,trafficSpot));
  }

  /**
   * 查询坐标
   *
   * @param
   * @return R
   */
  @GetMapping("/coordinates")
  public R getCoordinates() {
    return new R<>(trafficSpotService.getCoordinates());
  }

  /**
   * 通过id查询观测站点表
   * @param rowId id
   * @return R
   */
  @GetMapping("/{rowId}")
  public R getById(@PathVariable Integer rowId){
    return new R<>(trafficSpotService.getById(rowId));
  }

  /**
   * 新增观测站点表
   * @param trafficSpot 观测站点表
   * @return R
   */
  @SysLog("新增观测站点表")
  @PostMapping
  public R save(@RequestBody TrafficSpot trafficSpot){
    return new R<>(trafficSpotService.save(trafficSpot));
  }

  /**
   * 修改观测站点表
   * @param trafficSpot 观测站点表
   * @return R
   */
  @SysLog("修改观测站点表")
  @PutMapping
  public R updateById(@RequestBody TrafficSpot trafficSpot){
    return new R<>(trafficSpotService.updateById(trafficSpot));
  }

  /**
   * 通过id删除观测站点表
   * @param rowId id
   * @return R
   */
  @SysLog("删除观测站点表")
  @DeleteMapping("/{rowId}")
  public R removeById(@PathVariable Integer rowId){
    return new R<>(trafficSpotService.removeById(rowId));
  }

}
