/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.xrtygis.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.xrtygis.entity.Stationlinkpipe;
import com.tofly.xrtygis.service.StationlinkpipeService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.Arrays;
/**
 * 测站与管道关联信息表
 *
 * @author admin
 * @date Fri Apr 02 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/stationlinkpipe")
@Api(tags="测站与管道关联信息表接口")
public class StationlinkpipeController {

    private final  StationlinkpipeService stationlinkpipeService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param stationlinkpipe 测站与管道关联信息表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getStationlinkpipePage(Page page, @ModelAttribute Stationlinkpipe stationlinkpipe) {
      return ResultRespone.success(stationlinkpipeService.page(page, Wrappers.query(stationlinkpipe)));
    }


    /**
     * 通过id查询测站与管道关联信息表
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/{id}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    public ResultRespone getById(@PathVariable("id" ) Long id) {
      return ResultRespone.success(stationlinkpipeService.getById(id));
    }

    /**
     * 新增测站与管道关联信息表
     * @param stationlinkpipe 测站与管道关联信息表
     * @return ResultRespone
     */
    //(title="新增测站与管道关联信息表" )
    @ApiOperation(value = "新增测站与管道关联信息表")
    @PostMapping
    public ResultRespone save(@RequestBody Stationlinkpipe stationlinkpipe) {
      return ResultRespone.success(stationlinkpipeService.save(stationlinkpipe));
    }

    /**
     * 修改测站与管道关联信息表
     * @param stationlinkpipe 测站与管道关联信息表
     * @return ResultRespone
     */
    //(title="修改测站与管道关联信息表" )
    @ApiOperation(value = "修改测站与管道关联信息表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Stationlinkpipe stationlinkpipe) {
      return ResultRespone.success(stationlinkpipeService.updateById(stationlinkpipe));
    }

    /**
     * 通过id删除测站与管道关联信息表
     * @param id id
     * @return ResultRespone
     */
    //(title="通过id删除测站与管道关联信息表" )
    @ApiOperation(value = "通过ID删除测站与管道关联信息表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable Long id) {
      return ResultRespone.success(stationlinkpipeService.removeById(id));
    }

    /**
     * 通过id批量删除测站与管道关联信息表
     * @param ids id
     * @return ResultRespone
     */
    //(title="通过id批量删除测站与管道关联信息表" )
    @ApiOperation(value = "通过ID批量删除测站与管道关联信息表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeById(String ids) {
        return ResultRespone.success(stationlinkpipeService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
