package cn.iocoder.yudao.module.jx.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.jx.core.controller.BaseController;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolCarRepair;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolCarRepairService;
import cn.iocoder.yudao.module.jx.utils.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 车辆维修记录Controller
 *
 * @author ruoyi
 * @date 2024-04-01
 */
@RestController
@RequestMapping("/drivingSchool/system/drivingSchoolRepair")
public class DriveSchoolCarRepairController extends BaseController
{
    @Autowired
    private IDriveSchoolCarRepairService driveSchoolCarRepairService;

    /**
     * 查询车辆维修记录列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolCarRepair driveSchoolCarRepair)
    {
        Page<DriveSchoolCarRepair> page = new Page<>(driveSchoolCarRepair.getPageNum(), driveSchoolCarRepair.getPageSize());
        IPage<DriveSchoolCarRepair> driveSchoolCarRepairIPage = driveSchoolCarRepairService.selectDriveSchoolCarRepairList(driveSchoolCarRepair, page);
        return CommonResult.success(driveSchoolCarRepairIPage);
        //return getDataTable(list);
    }

    /**
     * 查询车辆维修记录列表不分页
     */
    @GetMapping("/listAll")
    public CommonResult listAll(DriveSchoolCarRepair driveSchoolCarRepair)
    {
        List<DriveSchoolCarRepair> list = driveSchoolCarRepairService.selectDriveSchoolCarRepairListAll(driveSchoolCarRepair);
        return CommonResult.success(list);
    }

    /**
     * 导出车辆维修记录列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, DriveSchoolCarRepair driveSchoolCarRepair)
    {
        List<DriveSchoolCarRepair> list = driveSchoolCarRepairService.selectDriveSchoolCarRepairListAll(driveSchoolCarRepair);
        ExcelUtil<DriveSchoolCarRepair> util = new ExcelUtil<DriveSchoolCarRepair>(DriveSchoolCarRepair.class);
        util.exportExcel(response, list, "车辆维修记录数据");
    }

    /**
     * 获取车辆维修记录详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolCarRepairService.selectDriveSchoolCarRepairById(id));
    }

    /**
     * 新增车辆维修记录
     */
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolCarRepair driveSchoolCarRepair)
    {
        return toAjax(driveSchoolCarRepairService.insertDriveSchoolCarRepair(driveSchoolCarRepair));
    }

    /**
     * 修改车辆维修记录
     */
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolCarRepair driveSchoolCarRepair)
    {
        return toAjax(driveSchoolCarRepairService.updateDriveSchoolCarRepair(driveSchoolCarRepair));
    }

    /**
     * 删除车辆维修记录
     */
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolCarRepairService.deleteDriveSchoolCarRepairByIds(ids));
    }
}
