package com.ruoyi.app.qiyefuwu;

import java.util.List;
import jakarta.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.system.domain.SysQiyejieshao;
import com.ruoyi.system.service.ISysQiyejieshaoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.MessageUtils;

/**
 * qiyejieshaoController
 *
 * @author ruoyi
 * @date 2023-05-16
 */
@RestController
@RequestMapping("/system/qiyejieshao")
public class SysQiyejieshaoController extends BaseController
{
    @Autowired
    private ISysQiyejieshaoService sysQiyejieshaoService;

    /**
     * 查询qiyejieshao列表
     */
    @PreAuthorize("@ss.hasPermi('system:qiyejieshao:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysQiyejieshao sysQiyejieshao)
    {
        startPage();
        List<SysQiyejieshao> list = sysQiyejieshaoService.selectSysQiyejieshaoList(sysQiyejieshao);
        return getDataTable(list);
    }

    /**
     * 导出qiyejieshao列表
     */
    @PreAuthorize("@ss.hasPermi('system:qiyejieshao:export')")
    @Log(title = "qiyejieshao", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysQiyejieshao sysQiyejieshao)
    {
        List<SysQiyejieshao> list = sysQiyejieshaoService.selectSysQiyejieshaoList(sysQiyejieshao);
        ExcelUtil<SysQiyejieshao> util = new ExcelUtil<SysQiyejieshao>(SysQiyejieshao.class);
        util.exportExcel(response, list, MessageUtils.message("no.export.excel.enterpriseintroduce"));
    }

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

    /**
     * 新增qiyejieshao
     */
    @PreAuthorize("@ss.hasPermi('system:qiyejieshao:add')")
    @Log(title = "qiyejieshao", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysQiyejieshao sysQiyejieshao)
    {
        return toAjax(sysQiyejieshaoService.insertSysQiyejieshao(sysQiyejieshao));
    }

    /**
     * 修改qiyejieshao
     */
    @PreAuthorize("@ss.hasPermi('system:qiyejieshao:edit')")
    @Log(title = "qiyejieshao", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysQiyejieshao sysQiyejieshao)
    {
        return toAjax(sysQiyejieshaoService.updateSysQiyejieshao(sysQiyejieshao));
    }

    /**
     * 删除qiyejieshao
     */
    @PreAuthorize("@ss.hasPermi('system:qiyejieshao:remove')")
    @Log(title = "qiyejieshao", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysQiyejieshaoService.deleteSysQiyejieshaoByIds(ids));
    }
}
