package com.ruoyi.web.controller.remind;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.remind.WaitRemind;
import com.ruoyi.system.service.remind.IWaitRemindService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 待办提醒Controller
 *
 * @author boman
 * @date 2024-04-29
 */
@RestController
@RequestMapping("/remind")
public class WaitRemindController extends BaseController {
    @Autowired
    private IWaitRemindService waitRemindService;

    /**
     * 查询待办提醒列表
     */
    @PreAuthorize("@ss.hasPermi('system:remind:list')")
    @GetMapping("/list")
    public TableDataInfo list(WaitRemind waitRemind) {
        startPage();
        List<WaitRemind> list = waitRemindService.selectWaitRemindList(waitRemind);
        return getDataTable(list);
    }

    /**
     * 导出待办提醒列表
     */
    @PreAuthorize("@ss.hasPermi('system:remind:export')")
    @Log(title = "待办提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WaitRemind waitRemind) {
        List<WaitRemind> list = waitRemindService.selectWaitRemindList(waitRemind);
        ExcelUtil<WaitRemind> util = new ExcelUtil<WaitRemind>(WaitRemind.class);
        util.exportExcel(response, list, "待办提醒数据");
    }

    /**
     * 获取待办提醒详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:remind:query')")
    @GetMapping(value = "/{remindId}")
    public AjaxResult getInfo(@PathVariable("remindId") Integer remindId) {
        return success(waitRemindService.selectWaitRemindByRemindId(remindId));
    }

    /**
     * 新增待办提醒
     */
    @PreAuthorize("@ss.hasPermi('system:remind:add')")
    @Log(title = "待办提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WaitRemind waitRemind) {
        return toAjax(waitRemindService.insertWaitRemind(waitRemind));
    }

    /**
     * 修改待办提醒
     */
    @PreAuthorize("@ss.hasPermi('system:remind:edit')")
    @Log(title = "待办提醒", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody WaitRemind waitRemind) {
        return toAjax(waitRemindService.updateWaitRemind(waitRemind));
    }

    /**
     * 删除待办提醒
     */
    @PreAuthorize("@ss.hasPermi('system:remind:remove')")
    @Log(title = "待办提醒", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{remindIds}")
    public AjaxResult remove(@PathVariable Integer[] remindIds) {
        return toAjax(waitRemindService.deleteWaitRemindByRemindIds(remindIds));
    }
}
