package com.cusc.nirvana.user.rnr.fp.controller;

import com.cusc.nirvana.common.result.PageResult;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.fp.dto.CarInfoBindingDTO;
import com.cusc.nirvana.user.rnr.fp.dto.FpCarInfoDTO;
import com.cusc.nirvana.user.rnr.fp.service.IFpCarInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 车辆信息表(FpCarInfo)表控制层
 *
 * @author yuy336
 * @since 2022-06-28 19:58:53
 */
@RestController
@RequestMapping("/fpCarInfo")
public class FpCarInfoController {
    /**
     * 服务对象
     */
    @Autowired
    private IFpCarInfoService fpCarInfoService;

    /**
     * 分页查询
     *
     * @param bean 筛选条件
     * @return 查询结果
     */
    @PostMapping("/queryByPage")
    @ApiOperation(value = "分页查询", notes = "分页查询")
    public Response<PageResult<FpCarInfoDTO>> queryByPage(@RequestBody FpCarInfoDTO bean) {
        return Response.createSuccess(fpCarInfoService.queryByPage(bean));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param bean 实体
     * @return 单条数据
     */
   @PostMapping("/getByUuid")
    public Response<FpCarInfoDTO> getByUuid(@RequestBody FpCarInfoDTO bean) {
        return Response.createSuccess(fpCarInfoService.getByUuid(bean));
    }
    
     /**
     * 通过主键查询单条数据
     *
     * @param bean 实体
     * @return 单条数据
     */
   @PostMapping("/queryByList")
    public Response<List<FpCarInfoDTO>> queryByList(@RequestBody FpCarInfoDTO bean) {
        return Response.createSuccess(fpCarInfoService.queryByList(bean));
    }

    /**
     * 新增数据
     *
     * @param bean 实体
     * @return 新增结果
     */
    @PostMapping("/add")
    public Response add(@RequestBody FpCarInfoDTO bean) {
       return Response.createSuccess(fpCarInfoService.insert(bean));
    }

    @PostMapping("/addBatch")
    public Response addBatch(@RequestBody CarInfoBindingDTO bean) {
        return fpCarInfoService.addBatch(bean);
    }

    /**
     * 编辑数据
     *
     * @param bean 实体
     * @return 编辑结果
     */
    @PostMapping("/update")
    public Response update(@RequestBody FpCarInfoDTO bean) {
        return Response.createSuccess(fpCarInfoService.update(bean));
    }

    /**
     * 删除数据
     *
     * @param bean 实体
     * @return 删除是否成功
     */
    @PostMapping("/deleteById")
    public Response<Boolean> deleteById(@RequestBody FpCarInfoDTO bean) {
        return Response.createSuccess(fpCarInfoService.deleteById(bean));
    }

}

