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

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.elephant.framework.galaxy.aroad.response.R;
import com.elephant.framework.galaxy.aroad.module.common.annotation.SysLog;
import com.elephant.framework.galaxy.aroad.module.emergencyevent.entity.Evendeal;
import com.elephant.framework.galaxy.aroad.module.emergencyevent.service.EvendealService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController;


/**
 * 事件处置表
 *
 * @author songwenjie
 * @date 2019-05-08 14:43:56
 */
@RestController
@AllArgsConstructor
@RequestMapping("/evendeal")
public class EvendealController extends BaseController  {

  private final  EvendealService evendealService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param evendeal 事件处置表
   * @return
   */
  @GetMapping("/page")
  public R getEvendealPage(Page page, Evendeal evendeal) {
    return  new R<>(evendealService.page(page,Wrappers.query(evendeal)));
  }


  /**
   * 通过id查询事件处置表
   * @param id id
   * @return R
   */
  @GetMapping("/{id}")
  public R getById(@PathVariable("id") Integer id){
    return new R<>(evendealService.getById(id));
  }

  /**
   * 新增事件处置表
   * @param evendeal 事件处置表
   * @return R
   */
  @SysLog("新增事件处置表")
  @PostMapping
  public R save(@RequestBody Evendeal evendeal){
    return new R<>(evendealService.save(evendeal));
  }

  /**
   * 修改事件处置表
   * @param evendeal 事件处置表
   * @return R
   */
  @SysLog("修改事件处置表")
  @PutMapping
  public R updateById(@RequestBody Evendeal evendeal){
    return new R<>(evendealService.updateById(evendeal));
  }

  /**
   * 通过id删除事件处置表
   * @param id id
   * @return R
   */
  @SysLog("删除事件处置表")
  @DeleteMapping("/{id}")
  public R removeById(@PathVariable Integer id){
    return new R<>(evendealService.removeById(id));
  }

}
