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.DriveSchoolInsurance;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolInsuranceService;
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-06
 */
@RestController
@RequestMapping("/drivingSchool/system/insurance")
public class DriveSchoolInsuranceController extends BaseController
{
    @Autowired
    private IDriveSchoolInsuranceService driveSchoolInsuranceService;

    /**
     * 查询保险管理列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolInsurance driveSchoolInsurance)
    {
        Page<DriveSchoolInsurance> page = new Page<>(driveSchoolInsurance.getPageNum(), driveSchoolInsurance.getPageSize());
        IPage<DriveSchoolInsurance> driveSchoolInsuranceIPage = driveSchoolInsuranceService.selectDriveSchoolInsuranceList(driveSchoolInsurance, page);
        return success(driveSchoolInsuranceIPage);
        //return getDataTable(list);
    }

    /**
     * 导出保险管理列表
     */
    //@Log(title = "保险管理", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolInsurance driveSchoolInsurance)
//    {
//        List<DriveSchoolInsurance> list = driveSchoolInsuranceService.selectDriveSchoolInsuranceList(driveSchoolInsurance);
//        ExcelUtil<DriveSchoolInsurance> util = new ExcelUtil<DriveSchoolInsurance>(DriveSchoolInsurance.class);
//        util.exportExcel(response, list, "保险管理数据");
//    }

    /**
     * 获取保险管理详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolInsuranceService.selectDriveSchoolInsuranceById(id));
    }

    /**
     * 新增保险管理
     */
    //@Log(title = "保险管理", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolInsurance driveSchoolInsurance) throws Exception {
        return toAjax(driveSchoolInsuranceService.insertDriveSchoolInsurance(driveSchoolInsurance));
    }

    /**
     * 修改保险管理
     */
    //@Log(title = "保险管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolInsurance driveSchoolInsurance)
    {
        return toAjax(driveSchoolInsuranceService.updateDriveSchoolInsurance(driveSchoolInsurance));
    }

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