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.DriveSchoolContract;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolContractService;
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-25
 */
@RestController
@RequestMapping("/system/driveSchool/contract")
public class DriveSchoolContractController extends BaseController
{
    @Autowired
    private IDriveSchoolContractService driveSchoolContractService;

    /**
     * 查询驾校合同列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolContract driveSchoolContract)
    {
        Page<DriveSchoolContract> page = new Page<>(driveSchoolContract.getPageNum(), driveSchoolContract.getPageSize());
        IPage<DriveSchoolContract> driveSchoolContractIPage = driveSchoolContractService.selectDriveSchoolContractList(driveSchoolContract, page);
        return success(driveSchoolContractIPage);
        //return getDataTable(list);
    }

    /**
     * 导出驾校合同列表
     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolContract driveSchoolContract)
//    {
//        List<DriveSchoolContract> list = driveSchoolContractService.selectDriveSchoolContractList(driveSchoolContract);
//        ExcelUtil<DriveSchoolContract> util = new ExcelUtil<DriveSchoolContract>(DriveSchoolContract.class);
//        util.exportExcel(response, list, "驾校合同数据");
//    }

    /**
     * 获取驾校合同详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolContractService.selectDriveSchoolContractById(id));
    }

    /**
     * 新增驾校合同
     */
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolContract driveSchoolContract)
    {
        return toAjax(driveSchoolContractService.insertDriveSchoolContract(driveSchoolContract));
    }

    /**
     * 修改驾校合同
     */
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolContract driveSchoolContract)
    {
        return toAjax(driveSchoolContractService.updateDriveSchoolContract(driveSchoolContract));
    }

    /**
     * 删除驾校合同
     */
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolContractService.deleteDriveSchoolContractByIds(ids));
    }
}
