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.DriveSchoolNotice;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolNoticeService;
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.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 通知Controller
 *
 * @author ruoyi
 * @date 2024-05-28
 */
@RestController
@RequestMapping("/system/drive/notice")
public class DriveSchoolNoticeController extends BaseController
{
    @Autowired
    private IDriveSchoolNoticeService driveSchoolNoticeService;

    /**
     * 查询通知列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolNotice driveSchoolNotice)
    {
        Page<DriveSchoolNotice> page = new Page<>(driveSchoolNotice.getPageNum(), driveSchoolNotice.getPageSize());
        IPage<DriveSchoolNotice> driveSchoolNoticeIPage = driveSchoolNoticeService.selectDriveSchoolNoticeList(driveSchoolNotice, page);
        return CommonResult.success(driveSchoolNoticeIPage);
        //return getDataTable(list);
    }


    /**
     * 查询通知列表
     */
    @GetMapping("/applist")
    public CommonResult applist(DriveSchoolNotice driveSchoolNotice)
    {
        List<DriveSchoolNotice> list = driveSchoolNoticeService.selectDriveSchoolNoticeAppList(driveSchoolNotice);
            return CommonResult.success(list);
    }

    /**
     * 导出通知列表
     */
    //@Log(title = "通知", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolNotice driveSchoolNotice)
//    {
//        List<DriveSchoolNotice> list = driveSchoolNoticeService.selectDriveSchoolNoticeList(driveSchoolNotice);
//        ExcelUtil<DriveSchoolNotice> util = new ExcelUtil<DriveSchoolNotice>(DriveSchoolNotice.class);
//        util.exportExcel(response, list, "通知数据");
//    }

    /**
     * 获取通知详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolNoticeService.selectDriveSchoolNoticeById(id));
    }

    /**
     * 新增通知
     */
    //@Log(title = "通知", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolNotice driveSchoolNotice)
    {
        return toAjax(driveSchoolNoticeService.insertDriveSchoolNotice(driveSchoolNotice));
    }

    /**
     * 修改通知
     */
    //@Log(title = "通知", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolNotice driveSchoolNotice)
    {
        return toAjax(driveSchoolNoticeService.updateDriveSchoolNotice(driveSchoolNotice));
    }

    /**
     * 删除通知
     */
    //@PreAuthorize("@ss.hasPermi('system/drive:notice:remove')")
    //@Log(title = "通知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolNoticeService.deleteDriveSchoolNoticeByIds(ids));
    }
}
