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.DriveContractTest;
import cn.iocoder.yudao.module.jx.service.IDriveContractTestService;
import cn.iocoder.yudao.module.jx.utils.ExcelUtil;
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.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 合同模板Controller
 *
 * @author ruoyi
 * @date 2024-05-25
 */
@RestController
@RequestMapping("/system/driveSchool/test")
public class DriveContractTestController extends BaseController
{
    @Autowired
    private IDriveContractTestService driveContractTestService;

    /**
     * 查询合同模板列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveContractTest driveContractTest)
    {
        Page<DriveContractTest> page = new Page<>(driveContractTest.getPageNum(), driveContractTest.getPageSize());
        IPage<DriveContractTest> driveContractTestIPage = driveContractTestService.selectDriveContractTestList(driveContractTest, page);
        return CommonResult.success(driveContractTestIPage);
        //return getDataTable(list);
    }

    /**
     * 导出合同模板列表
     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveContractTest driveContractTest)
//    {
//        List<DriveContractTest> list = driveContractTestService.selectDriveContractTestList(driveContractTest);
//        ExcelUtil<DriveContractTest> util = new ExcelUtil<DriveContractTest>(DriveContractTest.class);
//        util.exportExcel(response, list, "合同模板数据");
//    }

    /**
     * 获取合同模板详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveContractTestService.selectDriveContractTestById(id));
    }

    /**
     * 新增合同模板
     */
    @PostMapping
    public CommonResult add(@RequestBody DriveContractTest driveContractTest)
    {
        return toAjax(driveContractTestService.insertDriveContractTest(driveContractTest));
    }

    /**
     * 修改合同模板
     */
    @PutMapping
    public CommonResult edit(@RequestBody DriveContractTest driveContractTest)
    {
        return toAjax(driveContractTestService.updateDriveContractTest(driveContractTest));
    }

    /**
     * 删除合同模板
     */
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveContractTestService.deleteDriveContractTestByIds(ids));
    }
}
