package com.flossom.system.controller;

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

import com.flossom.common.core.domain.SysFiringInfo;
import com.flossom.common.core.utils.poi.ExcelUtil;
import com.flossom.common.core.web.controller.BaseController;
import com.flossom.common.core.web.domain.AjaxResult;
import com.flossom.common.core.web.page.TableDataInfo;
import com.flossom.common.log.annotation.Log;
import com.flossom.common.log.enums.BusinessType;
import com.flossom.common.security.annotation.RequiresPermissions;
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.flossom.system.service.ISysFiringInfoService;

/**
 * 登录信息Controller
 *
 * @author flossom
 * @date 2023-11-29
 */
@RestController
@RequestMapping("/firing")
public class SysFiringInfoController extends BaseController
{
    @Autowired
    private ISysFiringInfoService sysFiringInfoService;

    /**
     * 查询登录信息列表
     */
    @RequiresPermissions("system:firing:list")
    @GetMapping("/list")
    public TableDataInfo list(SysFiringInfo sysFiringInfo)
    {
        startPage();
        List<SysFiringInfo> list = sysFiringInfoService.selectSysFiringInfoList(sysFiringInfo);
        return getDataTable(list);
    }

    /**
     * 导出登录信息列表
     */
    @RequiresPermissions("system:firing:export")
    @Log(title = "登录页面信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysFiringInfo sysFiringInfo)
    {
        List<SysFiringInfo> list = sysFiringInfoService.selectSysFiringInfoList(sysFiringInfo);
        ExcelUtil<SysFiringInfo> util = new ExcelUtil<SysFiringInfo>(SysFiringInfo.class);
        util.exportExcel(response, list, "登录信息数据");
    }

    /**
     * 获取登录信息详细信息
     */
    @RequiresPermissions("system:firing:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysFiringInfoService.selectSysFiringInfoById(id));
    }

    /**
     * 新增登录信息
     */
    @RequiresPermissions("system:firing:add")
    @Log(title = "新增登录页面信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysFiringInfo sysFiringInfo)
    {
        return toAjax(sysFiringInfoService.insertSysFiringInfo(sysFiringInfo));
    }

    /**
     * 修改登录信息
     */
    @RequiresPermissions("system:firing:edit")
    @Log(title = "修改登录页面信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysFiringInfo sysFiringInfo)
    {
        return toAjax(sysFiringInfoService.updateSysFiringInfo(sysFiringInfo));
    }

    /**
     * 删除登录信息
     */
    @RequiresPermissions("system:firing:remove")
    @Log(title = "删除登录页面信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysFiringInfoService.deleteSysFiringInfoByIds(ids));
    }
}
