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

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.gpsboot.service.car.CarGpstocarService;
import com.tofly.pojo.car.CarGpstocar;
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.*;

/**
 * 车辆GPS绑定信息
 *
 * @author Zhangyu
 * @date Tue Apr 28 00:00:00 GMT+08:00 2020
 */
@RestController
@AllArgsConstructor
@RequestMapping("/cargpstocar")
@Api(tags="车辆GPS绑定信息接口")
public class CarGpstocarController {

    private final CarGpstocarService carGpstocarService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param carGpstocar 车辆GPS绑定信息
     * @return
     */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getCarGpstocarPage(Page page, @ModelAttribute CarGpstocar carGpstocar) {
        return ResultRespone.success(carGpstocarService.page(page, Wrappers.query(carGpstocar)));
    }


    /**
     * 通过id查询车辆GPS绑定信息
     * @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(carGpstocarService.getById(id));
    }

//    /**
//     * 新增车辆GPS绑定信息
//     * @param carGpstocar 车辆GPS绑定信息
//     * @return ResultRespone
//     */
//    @ToFlyAppLog(title="新增车辆GPS绑定信息" )
//    @ApiOperation(value = "新增车辆GPS绑定信息")
//    @PostMapping
//    public ResultRespone save(@RequestBody CarGpstocar carGpstocar) {
//      return ResultRespone.success(carGpstocarService.save(carGpstocar));
//    }
//
//    /**
//     * 修改车辆GPS绑定信息
//     * @param carGpstocar 车辆GPS绑定信息
//     * @return ResultRespone
//     */
//    @ToFlyAppLog(title="修改车辆GPS绑定信息" )
//    @ApiOperation(value = "修改车辆GPS绑定信息")
//    @PutMapping
//    public ResultRespone updateById(@RequestBody CarGpstocar carGpstocar) {
//      return ResultRespone.success(carGpstocarService.updateById(carGpstocar));
//    }
//
//    /**
//     * 通过id删除车辆GPS绑定信息
//     * @param id id
//     * @return ResultRespone
//     */
//    @ToFlyAppLog(title="通过id删除车辆GPS绑定信息" )
//    @ApiOperation(value = "通过ID删除车辆GPS绑定信息")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
//    })
//    @DeleteMapping("/{id}" )
//    public ResultRespone removeById(@PathVariable Long id) {
//      return ResultRespone.success(carGpstocarService.removeById(id));
//    }
//
//    /**
//     * 通过id批量删除车辆GPS绑定信息
//     * @param ids id
//     * @return ResultRespone
//     */
//    @ToFlyAppLog(title="通过id批量删除车辆GPS绑定信息" )
//    @ApiOperation(value = "通过ID批量删除车辆GPS绑定信息")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
//    })
//    @DeleteMapping("/deleteByIds" )
//    public ResultRespone removeById(String ids) {
//        return ResultRespone.success(carGpstocarService.removeByIds(Arrays.asList(ids.split(","))));
//    }
}
