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

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.xrtymis.custom.dto.TfYwpnValveDTO;
import com.tofly.xrtymis.custom.dto.TfywpnGatherrecorsUsertaskDTO;
import com.tofly.xrtymis.custom.service.TfYwpnGatherrecordService;
import com.tofly.xrtymis.custom.service.TfYwpnValveService;
import com.tofly.xrtymis.entity.TfYwpnGatherrecord;
import com.tofly.xrtymis.entity.TfYwpnValve;
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 org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;
import java.util.List;

/**
 * 控制阀信息采集数据表：TF_YWPN_VALVE_W
 *
 * @author fcl
 * @date Fri Apr 16 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/tfywpnvalve")
@Api(tags="控制阀信息采集数据表：TF_YWPN_VALVE_W接口")
public class TfYwpnValveController {

    private final TfYwpnValveService tfYwpnValveService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param tfYwpnValve 控制阀信息采集数据表：TF_YWPN_VALVE_W
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getTfYwpnValvePage(Page page, @ModelAttribute TfYwpnValve tfYwpnValve) {
      return ResultRespone.success(tfYwpnValveService.page(page, Wrappers.query(tfYwpnValve)));
    }


    /**
     * 通过id查询控制阀信息采集数据表：TF_YWPN_VALVE_W
     * @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(tfYwpnValveService.getById(id));
    }

    /**
     * 新增控制阀信息采集数据表：TF_YWPN_VALVE_W
     * @param tfYwpnValve 控制阀信息采集数据表：TF_YWPN_VALVE_W
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增控制阀信息采集数据表：TF_YWPN_VALVE_W" )
    @ApiOperation(value = "新增控制阀信息采集数据表：TF_YWPN_VALVE_W")
    @PostMapping("/add")
    public ResultRespone save( TfYwpnValve tfYwpnValve) {
      return tfYwpnValveService.saveControlValve(tfYwpnValve);
    }

//    /**
//     * 审核后提交到最终库
//     */
//    @ToFlyAppLog(title="消防栓信息采集数据审核后提交到最终库" )
//    @ApiOperation(value = "消防栓信息采集数据审核后提交到最终库")
//    @PostMapping("/addEnd")
//    public ResultRespone addEnd(@RequestBody TfywpnGatherrecorsUsertaskDTO tfYwpnGatherrecord){
//        tfYwpnGatherrecord.setTableName("TF_YWPN_VALVE_W");
//        return ResultRespone.success(tfYwpnGatherrecordService.saveStates(tfYwpnGatherrecord));
//    }

    /**
     * 修改控制阀信息采集数据表：TF_YWPN_VALVE_W
     * @param tfYwpnValve 控制阀信息采集数据表：TF_YWPN_VALVE_W
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改控制阀信息采集数据表：TF_YWPN_VALVE_W" )
    @ApiOperation(value = "修改控制阀信息采集数据表：TF_YWPN_VALVE_W")
    @PostMapping("/update")
    public ResultRespone updateById(List<MultipartFile> fileList, TfYwpnValve tfYwpnValve) {
      return tfYwpnValveService.updateValveById(fileList,tfYwpnValve);
    }

    /**
     * 通过id删除控制阀信息采集数据表：TF_YWPN_VALVE_W
     * @param id id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id删除控制阀信息采集数据表：TF_YWPN_VALVE_W" )
    @ApiOperation(value = "通过ID删除控制阀信息采集数据表：TF_YWPN_VALVE_W")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable Long id) {
      return tfYwpnValveService.removeValveById(id);
    }

//    /**
//     * 通过id批量删除控制阀信息采集数据表：TF_YWPN_VALVE_W
//     * @param ids id
//     * @return ResultRespone
//     */
//    @ToFlyAppLog(title="通过id批量删除控制阀信息采集数据表：TF_YWPN_VALVE_W" )
//    @ApiOperation(value = "通过ID批量删除控制阀信息采集数据表：TF_YWPN_VALVE_W")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
//    })
//    @DeleteMapping("/deleteByIds" )
//    public ResultRespone removeById(String ids) {
//        return ResultRespone.success(tfYwpnValveService.removeByIds(Arrays.asList(ids.split(","))));
//    }
}
