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

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.gpsboot.service.paln.TfYwpnStationReportService;
import com.tofly.pojo.plan.TfYwpnStationReport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
/**
 * 厂站巡检上报结果表
 *
 * @author JF
 * @date Wed Aug 09 00:00:00 CST 2023
 */
@RestController
@AllArgsConstructor
@RequestMapping("/tfywpnstationreport")
@Api(tags="厂站巡检上报结果表接口")
public class TfYwpnStationReportController {

    private final TfYwpnStationReportService tfYwpnStationReportService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param tfYwpnStationReport 厂站巡检上报结果表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getTfYwpnStationReportPage(Page page, @ModelAttribute TfYwpnStationReport tfYwpnStationReport) {
      return ResultRespone.success(tfYwpnStationReportService.page(page, Wrappers.query(tfYwpnStationReport)));
    }


    /**
     * 通过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(tfYwpnStationReportService.getById(id));
    }

    /**
     * 新增厂站巡检上报结果表
     * @param tfYwpnStationReport 厂站巡检上报结果表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增厂站巡检上报结果表" )
    @ApiOperation(value = "新增厂站巡检上报结果表")
    @PostMapping
    public ResultRespone save(@RequestBody TfYwpnStationReport tfYwpnStationReport) {
      return ResultRespone.success(tfYwpnStationReportService.save(tfYwpnStationReport));
    }

    /**
     * 修改厂站巡检上报结果表
     * @param tfYwpnStationReport 厂站巡检上报结果表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改厂站巡检上报结果表" )
    @ApiOperation(value = "修改厂站巡检上报结果表")
    @PutMapping
    public ResultRespone updateById(@RequestBody TfYwpnStationReport tfYwpnStationReport) {
      return ResultRespone.success(tfYwpnStationReportService.updateById(tfYwpnStationReport));
    }

    /**
     * 通过id删除厂站巡检上报结果表
     * @param id id
     * @return ResultRespone
     */
    @ToFlyAppLog(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(tfYwpnStationReportService.removeById(id));
    }

    /**
     * 通过id批量删除厂站巡检上报结果表
     * @param ids id
     * @return ResultRespone
     */
    @ToFlyAppLog(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(tfYwpnStationReportService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
