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.DriveSchoolFile;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolFileService;
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/file")
public class DriveSchoolFileController extends BaseController
{
    @Autowired
    private IDriveSchoolFileService driveSchoolFileService;

    /**
     * 查询文件类型列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolFile driveSchoolFile)
    {
        Page<DriveSchoolFile> page = new Page<>(driveSchoolFile.getPageNum(), driveSchoolFile.getPageSize());
        IPage<DriveSchoolFile> driveSchoolFileIPage = driveSchoolFileService.selectDriveSchoolFileList(driveSchoolFile, page);
        return CommonResult.success(driveSchoolFileIPage);
        //return getDataTable(list);
    }


    /**
     * 查询文件类型列表
     */
    @GetMapping("/getOneFile")
    public CommonResult getOneFile(DriveSchoolFile driveSchoolFile)
    {
        DriveSchoolFile driveSchoolFile1 = driveSchoolFileService.getOneFile(driveSchoolFile);
        return CommonResult.success(driveSchoolFile1);
    }


    /**
     * 导出文件类型列表
     */
    //@Log(title = "文件类型", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolFile driveSchoolFile)
//    {
//        List<DriveSchoolFile> list = driveSchoolFileService.selectDriveSchoolFileList(driveSchoolFile);
//        ExcelUtil<DriveSchoolFile> util = new ExcelUtil<DriveSchoolFile>(DriveSchoolFile.class);
//        util.exportExcel(response, list, "文件类型数据");
//    }

    /**
     * 获取文件类型详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolFileService.selectDriveSchoolFileById(id));
    }

    /**
     * 新增文件类型
     */
    //@Log(title = "文件类型", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolFile driveSchoolFile) throws Exception {
        return toAjax(driveSchoolFileService.insertDriveSchoolFile(driveSchoolFile));
    }

    /**
     * 修改文件类型
     */
    //@Log(title = "文件类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolFile driveSchoolFile)
    {
        return toAjax(driveSchoolFileService.updateDriveSchoolFile(driveSchoolFile));
    }

    /**
     * 删除文件类型
     */
    //@Log(title = "文件类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolFileService.deleteDriveSchoolFileByIds(ids));
    }
}
