package com.ruoyi.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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.cs.domain.CsExpireRemind;
import com.ruoyi.cs.service.ICsExpireRemindService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 到期提醒Controller
 *
 * @author ruoyi
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/cs/csExpireRemind")
public class CsExpireRemindController extends BaseController
{
    @Resource
    private ICsExpireRemindService csExpireRemindService;

    /**
     * 查询到期提醒列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csExpireRemind:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsExpireRemind csExpireRemind)
    {
        startPage();
        csExpireRemind.setDelFlag("0");
        List<CsExpireRemind> list = csExpireRemindService.selectCsExpireRemindList(csExpireRemind);
        return getDataTable(list);
    }

    /**
     * 导出到期提醒列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csExpireRemind:export')")
    @Log(title = "到期提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsExpireRemind csExpireRemind)
    {
        List<CsExpireRemind> list = csExpireRemindService.selectCsExpireRemindList(csExpireRemind);
        ExcelUtil<CsExpireRemind> util = new ExcelUtil<CsExpireRemind>(CsExpireRemind.class);
        util.exportExcel(response, list, "到期提醒数据");
    }

    /**
     * 获取到期提醒详细信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csExpireRemind:query')")
    @GetMapping(value = "/{remindId}")
    public AjaxResult getInfo(@PathVariable("remindId") String remindId)
    {
        return AjaxResult.success(csExpireRemindService.selectCsExpireRemindByRemindId(remindId));
    }

    /**
     * 新增到期提醒
     */
    @PreAuthorize("@ss.hasPermi('cs:csExpireRemind:add')")
    @Log(title = "到期提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsExpireRemind csExpireRemind)
    {
        return toAjax(csExpireRemindService.insertCsExpireRemind(csExpireRemind));
    }

    /**
     * 修改到期提醒
     */
    @PreAuthorize("@ss.hasPermi('cs:csExpireRemind:edit')")
    @Log(title = "到期提醒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsExpireRemind csExpireRemind)
    {
        return toAjax(csExpireRemindService.updateCsExpireRemind(csExpireRemind));
    }

    /**
     * 删除到期提醒
     */
    @PreAuthorize("@ss.hasPermi('cs:csExpireRemind:remove')")
    @Log(title = "到期提醒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{remindIds}")
    public AjaxResult remove(@PathVariable String[] remindIds)
    {
        return toAjax(csExpireRemindService.deleteCsExpireRemindByRemindIds(remindIds));
    }
}
