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.DriveSchoolCheck;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolCheckService;
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-05-10
 */
@RestController
@RequestMapping("/drivingSchool/system/check")
public class DriveSchoolCheckController extends BaseController
{
    @Autowired
    private IDriveSchoolCheckService driveSchoolCheckService;

    /**
     * 查询车检管理列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolCheck driveSchoolCheck)
    {
        Page<DriveSchoolCheck> page = new Page<>(driveSchoolCheck.getPageNum(), driveSchoolCheck.getPageSize());
        IPage<DriveSchoolCheck> driveSchoolCheckIPage = driveSchoolCheckService.selectDriveSchoolCheckList(driveSchoolCheck, page);
        return success(driveSchoolCheckIPage);
        //return getDataTable(list);
    }

    /**
     * 导出车检管理列表
     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolCheck driveSchoolCheck)
//    {
//        List<DriveSchoolCheck> list = driveSchoolCheckService.selectDriveSchoolCheckList(driveSchoolCheck);
//        ExcelUtil<DriveSchoolCheck> util = new ExcelUtil<DriveSchoolCheck>(DriveSchoolCheck.class);
//        util.exportExcel(response, list, "车检管理数据");
//    }

    /**
     * 获取车检管理详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolCheckService.selectDriveSchoolCheckById(id));
    }

    /**
     * 新增车检管理
     */
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolCheck driveSchoolCheck) throws Exception {
        return toAjax(driveSchoolCheckService.insertDriveSchoolCheck(driveSchoolCheck));
    }

    /**
     * 修改车检管理
     */
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolCheck driveSchoolCheck)
    {
        return toAjax(driveSchoolCheckService.updateDriveSchoolCheck(driveSchoolCheck));
    }

    /**
     * 删除车检管理
     */
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolCheckService.deleteDriveSchoolCheckByIds(ids));
    }
}
