package com.elephant.framework.galaxy.aroad.module.info.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.info.entity.InfoReceivers;
import com.elephant.framework.galaxy.aroad.module.info.service.InfoReceiversService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController;


/**
 * 信息接收人表
 *
 * @author songwenjie
 * @date 2019-05-05 09:46:46
 */
@RestController
@AllArgsConstructor
@RequestMapping("/inforeceivers")
public class InfoReceiversController extends BaseController  {

  private final  InfoReceiversService infoReceiversService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param infoReceivers 信息接收人表
   * @return
   */
  @GetMapping("/page")
  public R getInfoReceiversPage(Page page, InfoReceivers infoReceivers) {
    return  new R<>(infoReceiversService.page(page,Wrappers.query(infoReceivers)));
  }


  /**
   * 通过id查询信息接收人表
   * @param id id
   * @return R
   */
  @GetMapping("/{id}")
  public R getById(@PathVariable("id") Integer id){
    return new R<>(infoReceiversService.getById(id));
  }

  /**
   * 新增信息接收人表
   * @param infoReceivers 信息接收人表
   * @return R
   */
  @SysLog("新增信息接收人表")
  @PostMapping
  public R save(@RequestBody InfoReceivers infoReceivers){
    return new R<>(infoReceiversService.save(infoReceivers));
  }

  /**
   * 修改信息接收人表
   * @param infoReceivers 信息接收人表
   * @return R
   */
  @SysLog("修改信息接收人表")
  @PutMapping
  public R updateById(@RequestBody InfoReceivers infoReceivers){
    return new R<>(infoReceiversService.updateById(infoReceivers));
  }

  /**
   * 通过id删除信息接收人表
   * @param id id
   * @return R
   */
  @SysLog("删除信息接收人表")
  @DeleteMapping("/{id}")
  public R removeById(@PathVariable Integer id){
    return new R<>(infoReceiversService.removeById(id));
  }

}
