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.DriveSchoolDeduct;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolDeductService;
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-07
 */
@RestController
@RequestMapping("/drivingSchool/system/deduct")
public class DriveSchoolDeductController extends BaseController
{
    @Autowired
    private IDriveSchoolDeductService driveSchoolDeductService;

    /**
     * 查询提成配置列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolDeduct driveSchoolDeduct)
    {
        Page<DriveSchoolDeduct> page = new Page<>(driveSchoolDeduct.getPageNum(), driveSchoolDeduct.getPageSize());
        IPage<DriveSchoolDeduct> driveSchoolDeductIPage = driveSchoolDeductService.selectDriveSchoolDeductList(driveSchoolDeduct, page);
        return CommonResult.success(driveSchoolDeductIPage);
        //return getDataTable(list);
    }

    /**
     * 导出提成配置列表
     */
    //@Log(title = "提成配置", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolDeduct driveSchoolDeduct)
//    {
//        List<DriveSchoolDeduct> list = driveSchoolDeductService.selectDriveSchoolDeductList(driveSchoolDeduct);
//        ExcelUtil<DriveSchoolDeduct> util = new ExcelUtil<DriveSchoolDeduct>(DriveSchoolDeduct.class);
//        util.exportExcel(response, list, "提成配置数据");
//    }

    /**
     * 获取提成配置详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolDeductService.selectDriveSchoolDeductById(id));
    }

    /**
     * 新增提成配置
     */
    //@Log(title = "提成配置", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolDeduct driveSchoolDeduct) throws Exception {
        return toAjax(driveSchoolDeductService.insertDriveSchoolDeduct(driveSchoolDeduct));
    }

    /**
     * 修改提成配置
     */
    //@Log(title = "提成配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolDeduct driveSchoolDeduct)
    {
        return toAjax(driveSchoolDeductService.updateDriveSchoolDeduct(driveSchoolDeduct));
    }

    /**
     * 删除提成配置
     */
    //@Log(title = "提成配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolDeductService.deleteDriveSchoolDeductByIds(ids));
    }
}
