package com.ruoyi.hezhi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.hezhi.domain.TbEnterpriseProgress;
import com.ruoyi.hezhi.service.ITbEnterpriseProgressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 企业历程Controller
 *
 * @author ruoyi
 * @date 2024-11-21
 */
@RestController
@RequestMapping("/hezhi/enterpriseProgress")
public class TbEnterpriseProgressController extends BaseController
{
    @Autowired
    private ITbEnterpriseProgressService tbEnterpriseProgressService;

    /**
     * 查询企业历程列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:enterpriseProgress:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbEnterpriseProgress tbEnterpriseProgress)
    {
        startPage();
        List<TbEnterpriseProgress> list = tbEnterpriseProgressService.selectTbEnterpriseProgressList(tbEnterpriseProgress);
        return getDataTable(list);
    }

    /**
     * 导出企业历程列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:enterpriseProgress:export')")
    @Log(title = "企业历程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbEnterpriseProgress tbEnterpriseProgress)
    {
        List<TbEnterpriseProgress> list = tbEnterpriseProgressService.selectTbEnterpriseProgressList(tbEnterpriseProgress);
        ExcelUtil<TbEnterpriseProgress> util = new ExcelUtil<TbEnterpriseProgress>(TbEnterpriseProgress.class);
        util.exportExcel(response, list, "企业历程数据");
    }

    /**
     * 获取企业历程详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:enterpriseProgress:query')")
    @GetMapping(value = "/{enterpriseProgressId}")
    public AjaxResult getInfo(@PathVariable("enterpriseProgressId") Long enterpriseProgressId)
    {
        return success(tbEnterpriseProgressService.selectTbEnterpriseProgressByEnterpriseProgressId(enterpriseProgressId));
    }

    /**
     * 新增企业历程
     */
    @PreAuthorize("@ss.hasPermi('hezhi:enterpriseProgress:add')")
    @Log(title = "企业历程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbEnterpriseProgress tbEnterpriseProgress)
    {
        return toAjax(tbEnterpriseProgressService.insertTbEnterpriseProgress(tbEnterpriseProgress));
    }

    /**
     * 修改企业历程
     */
    @PreAuthorize("@ss.hasPermi('hezhi:enterpriseProgress:edit')")
    @Log(title = "企业历程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbEnterpriseProgress tbEnterpriseProgress)
    {
        return toAjax(tbEnterpriseProgressService.updateTbEnterpriseProgress(tbEnterpriseProgress));
    }

    /**
     * 删除企业历程
     */
    @PreAuthorize("@ss.hasPermi('hezhi:enterpriseProgress:remove')")
    @Log(title = "企业历程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{enterpriseProgressIds}")
    public AjaxResult remove(@PathVariable Long[] enterpriseProgressIds)
    {
        return toAjax(tbEnterpriseProgressService.deleteTbEnterpriseProgressByEnterpriseProgressIds(enterpriseProgressIds));
    }
}
