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.DriveSchoolSeparate;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolSeparateService;
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 java.util.Map;

/**
 * 驾校分账Controller
 *
 * @author ruoyi
 * @date 2024-05-28
 */
@RestController
@RequestMapping("/system/driveSchool/separate")
public class DriveSchoolSeparateController extends BaseController
{
    @Autowired
    private IDriveSchoolSeparateService driveSchoolSeparateService;

    /**
     * 查询驾校分账列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolSeparate driveSchoolSeparate)
    {
        Page<DriveSchoolSeparate> page = new Page<>(driveSchoolSeparate.getPageNum(), driveSchoolSeparate.getPageSize());
        IPage<DriveSchoolSeparate> driveSchoolSeparateIPage = driveSchoolSeparateService.selectDriveSchoolSeparateList(driveSchoolSeparate, page);
        return CommonResult.success(driveSchoolSeparateIPage);
        //return getDataTable(list);
    }

    /**
     * 查询驾校分账列表
     */
    @GetMapping("/getAllMoney")
    public CommonResult getAllMoney(DriveSchoolSeparate driveSchoolSeparate)
    {
        Map<Object, Object> allMoney = driveSchoolSeparateService.getAllMoney(driveSchoolSeparate);
        return CommonResult.success(allMoney);
    }

    /**
     * 导出驾校分账列表
     */
    //@Log(title = "驾校分账", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolSeparate driveSchoolSeparate)
//    {
//        List<DriveSchoolSeparate> list = driveSchoolSeparateService.selectDriveSchoolSeparateList(driveSchoolSeparate);
//        ExcelUtil<DriveSchoolSeparate> util = new ExcelUtil<DriveSchoolSeparate>(DriveSchoolSeparate.class);
//        util.exportExcel(response, list, "驾校分账数据");
//    }

    /**
     * 获取驾校分账详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolSeparateService.selectDriveSchoolSeparateById(id));
    }

    /**
     * 新增驾校分账
     */
    //@Log(title = "驾校分账", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolSeparate driveSchoolSeparate)
    {
        return toAjax(driveSchoolSeparateService.insertDriveSchoolSeparate(driveSchoolSeparate));
    }

    /**
     * 修改驾校分账
     */
    //@Log(title = "驾校分账", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolSeparate driveSchoolSeparate)
    {
        return toAjax(driveSchoolSeparateService.updateDriveSchoolSeparate(driveSchoolSeparate));
    }

    /**
     * 删除驾校分账
     */
    //@Log(title = "驾校分账", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolSeparateService.deleteDriveSchoolSeparateByIds(ids));
    }
}
