package com.ruoyi.web.controller.kaoqin;

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

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
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.system.domain.RecordInfo;
import com.ruoyi.system.service.IRecordInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 记录信息Controller
 * 
 * @author ruoyi
 * @date 2023-02-07
 */
@RestController
@RequestMapping("/system/info")
public class  RecordInfoController extends BaseController
{
    @Autowired
    private IRecordInfoService recordInfoService;

    /**
     * 查询记录信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RecordInfo recordInfo)
    {
        startPage();
        List<RecordInfo> list = recordInfoService.selectRecordInfoList(recordInfo);
        return getDataTable(list);
    }

    /**
     * 导出记录信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "记录信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RecordInfo recordInfo)
    {
        List<RecordInfo> list = recordInfoService.selectRecordInfoList(recordInfo);
        ExcelUtil<RecordInfo> util = new ExcelUtil<RecordInfo>(RecordInfo.class);
        util.exportExcel(response, list, "记录信息数据");
    }

    /**
     * 获取记录信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(recordInfoService.selectRecordInfoById(id));
    }

    /**
     * 新增记录信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "记录信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecordInfo recordInfo)
    {
        return toAjax(recordInfoService.insertRecordInfo(recordInfo));
    }

    /**
     * 修改记录信息
     */
    @Log(title = "记录信息", businessType = BusinessType.UPDATE)
    @PostMapping("put")
    public AjaxResult edit(@RequestBody RecordInfo recordInfo)
    {
        return toAjax(recordInfoService.updateRecordInfo(recordInfo));
    }

    /**
     * 删除记录信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "记录信息", businessType = BusinessType.DELETE)
    @GetMapping(value = "/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(recordInfoService.deleteRecordInfoByIds(ids));
    }

    /***
     * 查询未读消息
     * @return
     */
    @GetMapping("/numberInfo")
    public AjaxResult numberInfo()
    {
        return recordInfoService.numberInfo();
    }

    /**
     * 将消息改为已读状态
     */
    @GetMapping("isChange")
    public AjaxResult isChange(Long[] ids)
    {
        return toAjax(recordInfoService.isChange(ids));
    }

}
