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.DriveSchoolCredentials;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolCredentialsService;
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-23
 */
@RestController
@RequestMapping("/system/credentials")
public class DriveSchoolCredentialsController extends BaseController
{
    @Autowired
    private IDriveSchoolCredentialsService driveSchoolCredentialsService;

    /**
     * 查询驾校资质信息列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolCredentials driveSchoolCredentials)
    {
        Page<DriveSchoolCredentials> page = new Page<>(driveSchoolCredentials.getPageNum(), driveSchoolCredentials.getPageSize());
        IPage<DriveSchoolCredentials> driveSchoolCredentialsIPage = driveSchoolCredentialsService.selectDriveSchoolCredentialsList(driveSchoolCredentials, page);
        return success(driveSchoolCredentialsIPage);
        //return getDataTable(list);
    }

    /**
     * 导出驾校资质信息列表
     */
    //@Log(title = "驾校资质信息", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolCredentials driveSchoolCredentials)
//    {
//        List<DriveSchoolCredentials> list = driveSchoolCredentialsService.selectDriveSchoolCredentialsList(driveSchoolCredentials);
//        ExcelUtil<DriveSchoolCredentials> util = new ExcelUtil<DriveSchoolCredentials>(DriveSchoolCredentials.class);
//        util.exportExcel(response, list, "驾校资质信息数据");
//    }

    /**
     * 获取驾校资质信息详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolCredentialsService.selectDriveSchoolCredentialsById(id));
    }

    /**
     * 新增驾校资质信息
     */
    //@Log(title = "驾校资质信息", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolCredentials driveSchoolCredentials)
    {
        return toAjax(driveSchoolCredentialsService.insertDriveSchoolCredentials(driveSchoolCredentials));
    }

    /**
     * 修改驾校资质信息
     */
    //@Log(title = "驾校资质信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolCredentials driveSchoolCredentials)
    {
        return toAjax(driveSchoolCredentialsService.updateDriveSchoolCredentials(driveSchoolCredentials));
    }

    /**
     * 删除驾校资质信息
     */
    //@Log(title = "驾校资质信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolCredentialsService.deleteDriveSchoolCredentialsByIds(ids));
    }
}
