package com.yunfeiyun.agmp.pts.controller;

import java.util.List;

import com.yunfeiyun.agmp.pts.domain.PtsLinkVersion;
import com.yunfeiyun.agmp.pts.service.IPtsLinkVersionService;
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.yunfeiyun.agmp.common.annotation.Log;
import com.yunfeiyun.agmp.common.core.controller.BaseController;
import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
import com.yunfeiyun.agmp.common.enums.BusinessType;
import com.yunfeiyun.agmp.common.core.page.TableDataInfo;

/**
 * 版本Controller
 * 
 * @author 杨晓辉
 * @date 2023-06-01
 */
@RestController
@RequestMapping("/system/sysversion")
public class PtsLinkVersionController extends BaseController
{
    @Autowired
    private IPtsLinkVersionService ptsLinkVersionService;

    /**
     * 查询版本列表
     */
    @PreAuthorize("@ss.hasPermi('system:sysversion:list')")
    @GetMapping("/list")
    public TableDataInfo list(PtsLinkVersion ptsLinkVersion)
    {
        startPage();
        List<PtsLinkVersion> list = ptsLinkVersionService.selectPtsLinkVersionList(ptsLinkVersion);
        return getDataTable(list);
    }


    /**
     * 获取版本详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sysversion:query')")
    @GetMapping(value = "/info/{versionId}")
    public AjaxResult getInfo(@PathVariable("versionId") String versionId)
    {
        return success(ptsLinkVersionService.selectPtsLinkVersionByVersionId(versionId));
    }

    /**
     * 新增版本
     */
    @PreAuthorize("@ss.hasPermi('yunfeiyun:sysversion:add')")
    @Log(title = "版本", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PtsLinkVersion ptsLinkVersion)
    {
        return toAjax(ptsLinkVersionService.insertPtsLinkVersion(ptsLinkVersion));
    }

    /**
     * 修改版本
     */
    @PreAuthorize("@ss.hasPermi('yunfeiyun:sysversion:edit')")
    @Log(title = "版本", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody PtsLinkVersion ptsLinkVersion)
    {
        return toAjax(ptsLinkVersionService.updatePtsLinkVersion(ptsLinkVersion));
    }

    /**
     * 删除版本
     */
    @PreAuthorize("@ss.hasPermi('yunfeiyun:sysversion:remove')")
    @Log(title = "版本", businessType = BusinessType.DELETE)
	@DeleteMapping("/delete/{versionIds}")
    public AjaxResult remove(@PathVariable String[] versionIds)
    {
        return toAjax(ptsLinkVersionService.deletePtsLinkVersionByVersionIds(versionIds));
    }
}
