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.DriveSchoolUpkeep;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolUpkeepService;
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.*;

/**
 * 车辆保养记录Controller
 *
 * @author ruoyi
 * @date 2024-04-01
 */
@RestController
@RequestMapping("/drivingSchool/system/drivingSchoolUpkeep")
public class DriveSchoolUpkeepController extends BaseController
{
    @Autowired
    private IDriveSchoolUpkeepService driveSchoolUpkeepService;

    /**
     * 查询车辆保养记录列表
     */
    //@PreAuthorize("@ss.hasPermi('drivingSchool/system:drivingSchoolUpkeep:list')")
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolUpkeep driveSchoolUpkeep)
    {
        Page<DriveSchoolUpkeep> page = new Page<>(driveSchoolUpkeep.getPageNum(), driveSchoolUpkeep.getPageSize());
        IPage<DriveSchoolUpkeep> driveSchoolUpkeepIPage = driveSchoolUpkeepService.selectDriveSchoolUpkeepList(driveSchoolUpkeep, page);
        return CommonResult.success(driveSchoolUpkeepIPage);
        //return getDataTable(list);
    }

    /**
     * 导出车辆保养记录列表
     */
    //@Log(title = "车辆保养记录", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolUpkeep driveSchoolUpkeep)
//    {
//        List<DriveSchoolUpkeep> list = driveSchoolUpkeepService.selectDriveSchoolUpkeepList(driveSchoolUpkeep);
//        ExcelUtil<DriveSchoolUpkeep> util = new ExcelUtil<DriveSchoolUpkeep>(DriveSchoolUpkeep.class);
//        util.exportExcel(response, list, "车辆保养记录数据");
//    }

    /**
     * 获取车辆保养记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('drivingSchool/system:drivingSchoolUpkeep:query')")
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolUpkeepService.selectDriveSchoolUpkeepById(id));
    }

    /**
     * 新增车辆保养记录
     */
    //@PreAuthorize("@ss.hasPermi('drivingSchool/system:drivingSchoolUpkeep:add')")
    //@Log(title = "车辆保养记录", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolUpkeep driveSchoolUpkeep)
    {
        return toAjax(driveSchoolUpkeepService.insertDriveSchoolUpkeep(driveSchoolUpkeep));
    }

    /**
     * 修改车辆保养记录
     */
    //@PreAuthorize("@ss.hasPermi('drivingSchool/system:drivingSchoolUpkeep:edit')")
    //@Log(title = "车辆保养记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolUpkeep driveSchoolUpkeep)
    {
        return toAjax(driveSchoolUpkeepService.updateDriveSchoolUpkeep(driveSchoolUpkeep));
    }

    /**
     * 删除车辆保养记录
     */
    //@PreAuthorize("@ss.hasPermi('drivingSchool/system:drivingSchoolUpkeep:remove')")
    //@Log(title = "车辆保养记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolUpkeepService.deleteDriveSchoolUpkeepByIds(ids));
    }
}
