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.DriveSchoolCourse;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolCourseService;
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-03-21
 */
@RestController
@RequestMapping("/drivingSchool/system/driveSchoolCourse")
public class DriveSchoolCourseController extends BaseController
{
    @Autowired
    private IDriveSchoolCourseService driveSchoolCourseService;

    /**
     * 查询驾校课程分类列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolCourse driveSchoolCourse)
    {
        if(null == driveSchoolCourse.getPageNum()){
            driveSchoolCourse.setPageNum(1);
        }
        if (null == driveSchoolCourse.getPageSize()){
            driveSchoolCourse.setPageSize(100);
        }
        Page<DriveSchoolCourse> page = new Page<>(driveSchoolCourse.getPageNum(), driveSchoolCourse.getPageSize());
        IPage<DriveSchoolCourse> driveSchoolCourseIPage = driveSchoolCourseService.selectDriveSchoolCourseList(driveSchoolCourse, page);
        return CommonResult.success(driveSchoolCourseIPage);
        //return getDataTable(list);
    }

    /**
     * 查询驾校课程分类列表
     */
    @GetMapping("/getOne")
    public CommonResult getOne(DriveSchoolCourse driveSchoolCourse)
    {
        DriveSchoolCourse driveSchoolCourse1 = driveSchoolCourseService.getOne(driveSchoolCourse);
        return CommonResult.success(driveSchoolCourse1);
    }

    /**
     * 导出驾校课程分类列表
     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolCourse driveSchoolCourse)
//    {
//        List<DriveSchoolCourse> list = driveSchoolCourseService.selectDriveSchoolCourseList(driveSchoolCourse);
//        ExcelUtil<DriveSchoolCourse> util = new ExcelUtil<DriveSchoolCourse>(DriveSchoolCourse.class);
//        util.exportExcel(response, list, "驾校课程分类数据");
//    }

    /**
     * 获取驾校课程分类详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolCourseService.selectDriveSchoolCourseById(id));
    }

    /**
     * 新增驾校课程分类
     */
    //@Log(title = "驾校课程分类", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolCourse driveSchoolCourse)
    {
        return toAjax(driveSchoolCourseService.insertDriveSchoolCourse(driveSchoolCourse));
    }

    /**
     * 修改驾校课程分类
     */
    //@Log(title = "驾校课程分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolCourse driveSchoolCourse)
    {
        return toAjax(driveSchoolCourseService.updateDriveSchoolCourse(driveSchoolCourse));
    }

    /**
     * 删除驾校课程分类
     */
    //@Log(title = "驾校课程分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolCourseService.deleteDriveSchoolCourseByIds(ids));
    }
}
