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.module.info.dto.InfoInformationsDto;
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.transaction.annotation.Transactional;
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));
  }


  /** 
  * @Description: 新增上报信息 
  * @Param: [info] 
  * @return: com.elephant.framework.galaxy.aroad.response.R 
  * @Author: songwenjie 
  * @Date: 2019/5/5 
  */ 
  @PostMapping
  public R saveInformations(@RequestBody InfoInformationsDto info){
    return new R<>(infoInformationsService.saveInformations(info));
  }


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

}
