package com.ruoyi.web.bst;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.bst.softwareVersion.domain.SoftwareVersion;
import com.ruoyi.bst.softwareVersion.domain.SoftwareVersionQuery;
import com.ruoyi.bst.softwareVersion.domain.SoftwareVersionVO;
import com.ruoyi.bst.softwareVersion.service.SoftwareVersionService;
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.enums.LogBizType;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 软件版本Controller
 *
 * @author ruoyi
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/bst/softwareVersion")
public class SoftwareVersionController extends BaseController
{
    @Autowired
    private SoftwareVersionService softwareVersionService;

    /**
     * 查询软件版本列表
     */
    @PreAuthorize("@ss.hasPermi('bst:softwareVersion:list')")
    @GetMapping("/list")
    public TableDataInfo list(SoftwareVersionQuery query)
    {
        startPage();
        startOrderBy();
        List<SoftwareVersionVO> list = softwareVersionService.selectSoftwareVersionList(query);
        return getDataTable(list);
    }

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

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

    /**
     * 新增软件版本
     */
    @PreAuthorize("@ss.hasPermi('bst:softwareVersion:add')")
    @Log(title = "新增软件版本", businessType = BusinessType.INSERT, bizIdName = "arg0", bizType = LogBizType.SOFTWARE_VERSION)
    @PostMapping
    public AjaxResult add(@RequestBody SoftwareVersion softwareVersion)
    {
        return toAjax(softwareVersionService.insertSoftwareVersion(softwareVersion));
    }

    /**
     * 修改软件版本
     */
    @PreAuthorize("@ss.hasPermi('bst:softwareVersion:edit')")
    @Log(title = "修改软件版本", businessType = BusinessType.UPDATE, bizIdName = "arg0", bizType = LogBizType.SOFTWARE_VERSION)
    @PutMapping
    public AjaxResult edit(@RequestBody SoftwareVersion softwareVersion)
    {
        return toAjax(softwareVersionService.updateSoftwareVersion(softwareVersion));
    }

    /**
     * 删除软件版本
     */
    @PreAuthorize("@ss.hasPermi('bst:softwareVersion:remove')")
    @Log(title = "删除软件版本", businessType = BusinessType.DELETE, bizIdName = "arg0", bizType = LogBizType.SOFTWARE_VERSION)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(softwareVersionService.deleteSoftwareVersionByIds(ids));
    }
}
