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


/**
 * 信息表
 *
 * @author songwenjie
 * @date 2019-04-28 10:34:46
 */
@RestController
@AllArgsConstructor
@RequestMapping("/infoinformations")
public class InfoInformationsController extends BaseController  {

  private final  InfoInformationsService infoInformationsService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param infoInformations 信息表
   * @return
   */
  @GetMapping("/page")
  public R getInfoInformationsPage(Page page, InfoInformations infoInformations) {
    return  new R<>(infoInformationsService.page(page,Wrappers.query(infoInformations)));
  }


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

  /**
   * 新增信息表
   * @param infoInformations 信息表
   * @return R
   */
  @SysLog("新增信息表")
  @PostMapping
  public R save(@RequestBody InfoInformations infoInformations){
    return new R<>(infoInformationsService.save(infoInformations));
  }

  /**
   * 修改信息表
   * @param infoInformations 信息表
   * @return R
   */
  @SysLog("修改信息表")
  @PutMapping
  public R updateById(@RequestBody InfoInformations infoInformations){
    return new R<>(infoInformationsService.updateById(infoInformations));
  }

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

}
