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.domain.DriveSchoolSwiper;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolSwiperService;
import cn.iocoder.yudao.module.jx.utils.ExcelUtil;
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 javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 驾校-轮播图Controller
 *
 * @author ruoyi
 * @date 2024-03-19
 */
@RestController
@RequestMapping("/drivingSchool/system/swiper")
public class DriveSchoolSwiperController extends BaseController
{
    @Autowired
    private IDriveSchoolSwiperService driveSchoolSwiperService;

    /**
     * 查询驾校-轮播图列表
     */
    ////@PreAuthorize("@ss.hasPermi('system:swiper:list')")
    @GetMapping("/list")
    public CommonResult list(DriveSchoolSwiper driveSchoolSwiper)
    {
        List<DriveSchoolSwiper> list = driveSchoolSwiperService.selectDriveSchoolSwiperList(driveSchoolSwiper);
        return CommonResult.success(list);
    }

    /**
     * 分页查询驾校-轮播图列表
     */
    @GetMapping("/pclist")
    @PermitAll
    public CommonResult pclist(DriveSchoolSwiper driveSchoolSwiper) {
        Page<DriveSchoolSwiper> page = new Page<>(driveSchoolSwiper.getPageNum(), driveSchoolSwiper.getPageSize());
        IPage<DriveSchoolSwiper> driveSchoolSeparateIPage = driveSchoolSwiperService.selectDriveSchoolSwiperPclist(driveSchoolSwiper, page);

//        IPage<DriveSchoolSwiper> page = driveSchoolSwiperService.selectDriveSchoolSwiperPclist(driveSchoolSwiper, current, size);
        return CommonResult.success(driveSchoolSeparateIPage);
    }



    /**
     * 导出驾校-轮播图列表
     */
    ////@PreAuthorize("@ss.hasPermi('system:swiper:export')")
    //@Log(title = "驾校-轮播图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DriveSchoolSwiper driveSchoolSwiper)
    {
        List<DriveSchoolSwiper> list = driveSchoolSwiperService.selectDriveSchoolSwiperList(driveSchoolSwiper);
        ExcelUtil<DriveSchoolSwiper> util = new ExcelUtil<DriveSchoolSwiper>(DriveSchoolSwiper.class);
        util.exportExcel(response, list, "驾校-轮播图数据");
    }

    /**
     * 获取驾校-轮播图详细信息
     */
   ////@PreAuthorize("@ss.hasPermi('system:swiper:query')")
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolSwiperService.selectDriveSchoolSwiperById(id));
    }

    /**
     * 新增驾校-轮播图
     */
    ////@PreAuthorize("@ss.hasPermi('system:swiper:add')")
    //@Log(title = "驾校-轮播图", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolSwiper driveSchoolSwiper)
    {
        return toAjax(driveSchoolSwiperService.insertDriveSchoolSwiper(driveSchoolSwiper));
    }

    /**
     * 修改驾校-轮播图
     */
    ////@PreAuthorize("@ss.hasPermi('system:swiper:edit')")
    //@Log(title = "驾校-轮播图", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolSwiper driveSchoolSwiper)
    {
        return toAjax(driveSchoolSwiperService.updateDriveSchoolSwiper(driveSchoolSwiper));
    }

    /**
     * 删除驾校-轮播图
     */
   // //@PreAuthorize("@ss.hasPermi('system:swiper:remove')")
    //@Log(title = "驾校-轮播图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolSwiperService.deleteDriveSchoolSwiperByIds(ids));
    }
}
