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.DriveSchoolPhone;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolPhoneService;
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-10
 */
@RestController
@RequestMapping("/drivingSchool/system/phone")
public class DriveSchoolPhoneController extends BaseController
{
    @Autowired
    private IDriveSchoolPhoneService driveSchoolPhoneService;

    /**
     * 查询客服列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolPhone driveSchoolPhone)
    {
        Page<DriveSchoolPhone> page = new Page<>(driveSchoolPhone.getPageNum(), driveSchoolPhone.getPageSize());
        IPage<DriveSchoolPhone> driveSchoolPhoneIPage = driveSchoolPhoneService.selectDriveSchoolPhoneList(driveSchoolPhone, page);
        return CommonResult.success(driveSchoolPhoneIPage);
        //return getDataTable(list);
    }

    /**
     * 查询客服列表
     */
    @GetMapping("/getPhone")
    public CommonResult getPhone(DriveSchoolPhone driveSchoolPhone)
    {
        DriveSchoolPhone driveSchoolPhone1 = driveSchoolPhoneService.getPhone(driveSchoolPhone);
        return CommonResult.success(driveSchoolPhone1);
    }

    /**
     * 导出客服列表
     */
    //@Log(title = "客服", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolPhone driveSchoolPhone)
//    {
//        List<DriveSchoolPhone> list = driveSchoolPhoneService.selectDriveSchoolPhoneList(driveSchoolPhone);
//        ExcelUtil<DriveSchoolPhone> util = new ExcelUtil<DriveSchoolPhone>(DriveSchoolPhone.class);
//        util.exportExcel(response, list, "客服数据");
//    }

    /**
     * 获取客服详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolPhoneService.selectDriveSchoolPhoneById(id));
    }

    /**
     * 新增客服
     */
    //@Log(title = "客服", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolPhone driveSchoolPhone)
    {
        return toAjax(driveSchoolPhoneService.insertDriveSchoolPhone(driveSchoolPhone));
    }

    /**
     * 修改客服
     */
    //@Log(title = "客服", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolPhone driveSchoolPhone)
    {
        return toAjax(driveSchoolPhoneService.updateDriveSchoolPhone(driveSchoolPhone));
    }

    /**
     * 删除客服
     */
    //@Log(title = "客服", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolPhoneService.deleteDriveSchoolPhoneByIds(ids));
    }
}
