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.DriveSchoolText;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolTextService;
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 jzy
 * @date 2024-04-16
 */
@RestController
@RequestMapping("/drivingSchool/text")
public class DriveSchoolTextController extends BaseController
{
    @Autowired
    private IDriveSchoolTextService driveSchoolTextService;

    /**
     * 查询驾校公告列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolText driveSchoolText)
    {
        Page<DriveSchoolText> page = new Page<>(driveSchoolText.getPageNum(), driveSchoolText.getPageSize());
        IPage<DriveSchoolText> driveSchoolTextIPage = driveSchoolTextService.selectDriveSchoolTextList(driveSchoolText, page);
        return CommonResult.success(driveSchoolTextIPage);
        //return getDataTable(list);
    }

    /**
     * 导出驾校公告列表
     */
    //@Log(title = "驾校公告", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolText driveSchoolText)
//    {
//        List<DriveSchoolText> list = driveSchoolTextService.selectDriveSchoolTextList(driveSchoolText);
//        ExcelUtil<DriveSchoolText> util = new ExcelUtil<DriveSchoolText>(DriveSchoolText.class);
//        util.exportExcel(response, list, "驾校公告数据");
//    }

    /**
     * 获取驾校公告详细信息
     */
    @GetMapping("/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolTextService.selectDriveSchoolTextById(id));
    }

    /**
     * 新增驾校公告
     */
    //@Log(title = "驾校公告", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolText driveSchoolText)
    {
        return toAjax(driveSchoolTextService.insertDriveSchoolText(driveSchoolText));
    }

    /**
     * 修改驾校公告
     */
    //@Log(title = "驾校公告", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolText driveSchoolText)
    {
        return toAjax(driveSchoolTextService.updateDriveSchoolText(driveSchoolText));
    }

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