package com.ruoyi.web.controller.system;

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.ss.softwareVersion.domain.SoftwareVersion;
import com.ruoyi.ss.softwareVersion.service.ISoftwareVersionService;
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 qiuzhenzhao
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/system/softwareVersion")
public class SoftwareVersionController extends BaseController
{
    @Autowired
    private ISoftwareVersionService etSoftwareVersionService;

    /**
     * 查询软件版本列表
     */
    @PreAuthorize("@ss.hasPermi('system:softwareVersion:list')")
    @GetMapping("/list")
    public TableDataInfo list(SoftwareVersion etSoftwareVersion)
    {
        startPage();
        List<SoftwareVersion> list = etSoftwareVersionService.selectEtSoftwareVersionList(etSoftwareVersion);
        return getDataTable(list);
    }

    /**
     * 导出软件版本列表
     */
    @PreAuthorize("@ss.hasPermi('system:softwareVersion:export')")
    @Log(title = "软件版本", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SoftwareVersion etSoftwareVersion)
    {
        List<SoftwareVersion> list = etSoftwareVersionService.selectEtSoftwareVersionList(etSoftwareVersion);
        ExcelUtil<SoftwareVersion> util = new ExcelUtil<SoftwareVersion>(SoftwareVersion.class);
        util.exportExcel(response, list, "软件版本数据");
    }

    /**
     * 获取软件版本详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:softwareVersion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(etSoftwareVersionService.selectEtSoftwareVersionById(id));
    }

    /**
     * 新增软件版本
     */
    @PreAuthorize("@ss.hasPermi('system:softwareVersion:add')")
    @Log(title = "软件版本", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SoftwareVersion etSoftwareVersion)
    {
        return toAjax(etSoftwareVersionService.insertEtSoftwareVersion(etSoftwareVersion));
    }

    /**
     * 修改软件版本
     */
    @PreAuthorize("@ss.hasPermi('system:softwareVersion:edit')")
    @Log(title = "软件版本", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SoftwareVersion etSoftwareVersion)
    {
        return toAjax(etSoftwareVersionService.updateEtSoftwareVersion(etSoftwareVersion));
    }

    /**
     * 删除软件版本
     */
    @PreAuthorize("@ss.hasPermi('system:softwareVersion:remove')")
    @Log(title = "软件版本", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(etSoftwareVersionService.deleteEtSoftwareVersionByIds(ids));
    }
}
