package cn.iocoder.yudao.module.base.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.base.entity.DriveSchoolCourseDeduct;
import cn.iocoder.yudao.module.base.service.DlDriveSchoolCourseDeductService;
import cn.iocoder.yudao.module.base.vo.DriveSchoolCourseDeductVO;
import com.github.pagehelper.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/base/drive-school-course-deduct")
@RequiredArgsConstructor
public class DlDriveSchoolCourseDeductController {

    private final DlDriveSchoolCourseDeductService driveSchoolCourseDeductService;

    /**
     * 分页查询
     *
     * @param request  @class DriveSchoolCourseDeductVO
     * @param pageNo   页码
     * @param pageSize 每页条数
     * @return @class DriveSchoolCourseDeductVO
     */
    @GetMapping("/page")
    public CommonResult<?> page(DriveSchoolCourseDeductVO request,
                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<DriveSchoolCourseDeductVO> page = new Page<>(pageNo, pageSize);
        return CommonResult.success(driveSchoolCourseDeductService.queryPage(page, request));
    }

    /**
     * 新增
     *
     * @param list @class DriveSchoolCourseDeductVO
     * @return id
     */
    @PostMapping
    public CommonResult<?> add(List<DriveSchoolCourseDeductVO> list) {
        driveSchoolCourseDeductService.add(list);
        return CommonResult.ok();
    }

}
