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.DriveSchoolFacility;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolFacilityService;
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-23
 */
@RestController
@RequestMapping("/drivingSchool/system/facility")
public class DriveSchoolFacilityController extends BaseController
{
    @Autowired
    private IDriveSchoolFacilityService driveSchoolFacilityService;

    /**
     * 查询设备管理列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolFacility driveSchoolFacility)
    {
        Page<DriveSchoolFacility> page = new Page<>(driveSchoolFacility.getPageNum(), driveSchoolFacility.getPageSize());
        IPage<DriveSchoolFacility> driveSchoolFacilityIPage = driveSchoolFacilityService.selectDriveSchoolFacilityList(driveSchoolFacility, page);
        return success(driveSchoolFacilityIPage);
        //return getDataTable(list);
    }

    /**
     * 导出设备管理列表
     */
    //@Log(title = "设备管理", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolFacility driveSchoolFacility)
//    {
//        List<DriveSchoolFacility> list = driveSchoolFacilityService.selectDriveSchoolFacilityList(driveSchoolFacility);
//        ExcelUtil<DriveSchoolFacility> util = new ExcelUtil<DriveSchoolFacility>(DriveSchoolFacility.class);
//        util.exportExcel(response, list, "设备管理数据");
//    }

    /**
     * 获取设备管理详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolFacilityService.selectDriveSchoolFacilityById(id));
    }

    /**
     * 新增设备管理
     */
    //@Log(title = "设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolFacility driveSchoolFacility)
    {
        return toAjax(driveSchoolFacilityService.insertDriveSchoolFacility(driveSchoolFacility));
    }

    /**
     * 修改设备管理
     */
    //@Log(title = "设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolFacility driveSchoolFacility)
    {
        return toAjax(driveSchoolFacilityService.updateDriveSchoolFacility(driveSchoolFacility));
    }

    /**
     * 删除设备管理
     */
    //@Log(title = "设备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolFacilityService.deleteDriveSchoolFacilityByIds(ids));
    }
}
