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


/**
 * 路线交通量
 *
 * @author Xingyuyang
 * @date 2019-04-30 10:44:18
 */
@RestController
@AllArgsConstructor
@RequestMapping("/trafficroute")
public class TrafficRouteController extends BaseController  {

  private final  TrafficRouteService trafficRouteService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param trafficRoute 路线交通量
   * @return
   */
  @GetMapping("/page")
  public R getTrafficRoutePage(Page page, TrafficRoute trafficRoute) {
    return  new R<>(trafficRouteService.getTrafficRoutePage(page,trafficRoute));
  }


  /**
   * 通过id查询路线交通量
   * @param id id
   * @return R
   */
  @GetMapping("/{id}")
  public R getById(@PathVariable("id") Integer id){
    return new R<>(trafficRouteService.getById(id));
  }

  /**
   * 新增路线交通量
   * @param trafficRoute 路线交通量
   * @return R
   */
  @SysLog("新增路线交通量")
  @PostMapping
  public R save(@RequestBody TrafficRoute trafficRoute){
    return new R<>(trafficRouteService.save(trafficRoute));
  }

  /**
   * 修改路线交通量
   * @param trafficRoute 路线交通量
   * @return R
   */
  @SysLog("修改路线交通量")
  @PutMapping
  public R updateById(@RequestBody TrafficRoute trafficRoute){
    return new R<>(trafficRouteService.updateById(trafficRoute));
  }

  /**
   * 通过id删除路线交通量
   * @param id id
   * @return R
   */
  @SysLog("删除路线交通量")
  @DeleteMapping("/{id}")
  public R removeById(@PathVariable Integer id){
    return new R<>(trafficRouteService.removeById(id));
  }

}
