package com.huijy.web.controller.management;

import java.util.List;
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.huijy.common.annotation.Log;
import com.huijy.common.core.controller.BaseController;
import com.huijy.common.core.domain.AjaxResult;
import com.huijy.common.enums.BusinessType;
import com.huijy.management.domain.EarlyWarningSendLog;
import com.huijy.management.service.IEarlyWarningSendLogService;
import com.huijy.common.utils.poi.ExcelUtil;
import com.huijy.common.core.page.TableDataInfo;

/**
 * 预警信息发送日志Controller
 *
 * @author luobo
 * @date 2021-09-12
 */
@RestController
@RequestMapping("/management/warningLog")
public class EarlyWarningSendLogController extends BaseController
{
    @Autowired
    private IEarlyWarningSendLogService earlyWarningSendLogService;

    /**
     * 查询预警信息发送日志列表
     */
    @PreAuthorize("@ss.hasPermi('management:warningLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(EarlyWarningSendLog earlyWarningSendLog)
    {
        startPage();
        List<EarlyWarningSendLog> list = earlyWarningSendLogService.selectEarlyWarningSendLogList(earlyWarningSendLog);
        return getDataTable(list);
    }

    /**
     * 导出预警信息发送日志列表
     */
    @PreAuthorize("@ss.hasPermi('management:warningLog:export')")
    @Log(title = "预警信息发送日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EarlyWarningSendLog earlyWarningSendLog)
    {
        List<EarlyWarningSendLog> list = earlyWarningSendLogService.selectEarlyWarningSendLogList(earlyWarningSendLog);
        ExcelUtil<EarlyWarningSendLog> util = new ExcelUtil<EarlyWarningSendLog>(EarlyWarningSendLog.class);
        return util.exportExcel(list, "预警信息发送日志数据");
    }

    /**
     * 获取预警信息发送日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('management:warningLog:query')")
    @GetMapping(value = "/{sendLogId}")
    public AjaxResult getInfo(@PathVariable("sendLogId") Long sendLogId)
    {
        return AjaxResult.success(earlyWarningSendLogService.selectEarlyWarningSendLogBySendLogId(sendLogId));
    }

    /**
     * 新增预警信息发送日志
     */
    @PreAuthorize("@ss.hasPermi('management:warningLog:add')")
    @Log(title = "预警信息发送日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EarlyWarningSendLog earlyWarningSendLog)
    {
        return toAjax(earlyWarningSendLogService.insertEarlyWarningSendLog(earlyWarningSendLog));
    }

    /**
     * 修改预警信息发送日志
     */
    @PreAuthorize("@ss.hasPermi('management:warningLog:edit')")
    @Log(title = "预警信息发送日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EarlyWarningSendLog earlyWarningSendLog)
    {
        return toAjax(earlyWarningSendLogService.updateEarlyWarningSendLog(earlyWarningSendLog));
    }

    /**
     * 删除预警信息发送日志
     */
    @PreAuthorize("@ss.hasPermi('management:warningLog:remove')")
    @Log(title = "预警信息发送日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sendLogIds}")
    public AjaxResult remove(@PathVariable Long[] sendLogIds)
    {
        return toAjax(earlyWarningSendLogService.deleteEarlyWarningSendLogBySendLogIds(sendLogIds));
    }
}
