package com.fs.his.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.his.domain.FsAppVersion;
import com.fs.his.service.IFsAppVersionService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * app版本Controller
 *
 * @author fs
 * @date 2023-08-03
 */
@RestController
@RequestMapping("/his/appVersion")
public class FsAppVersionController extends BaseController
{
    @Autowired
    private IFsAppVersionService fsAppVersionService;

    /**
     * 查询app版本列表
     */
    @PreAuthorize("@ss.hasPermi('his:appVersion:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsAppVersion fsAppVersion)
    {
        startPage();
        List<FsAppVersion> list = fsAppVersionService.selectFsAppVersionList(fsAppVersion);
        return getDataTable(list);
    }

    /**
     * 导出app版本列表
     */
    @PreAuthorize("@ss.hasPermi('his:appVersion:export')")
    @Log(title = "app版本", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsAppVersion fsAppVersion)
    {
        List<FsAppVersion> list = fsAppVersionService.selectFsAppVersionList(fsAppVersion);
        ExcelUtil<FsAppVersion> util = new ExcelUtil<FsAppVersion>(FsAppVersion.class);
        return util.exportExcel(list, "app版本数据");
    }

    /**
     * 获取app版本详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:appVersion:query')")
    @GetMapping(value = "/{versionId}")
    public AjaxResult getInfo(@PathVariable("versionId") Long versionId)
    {
        return AjaxResult.success(fsAppVersionService.selectFsAppVersionByVersionId(versionId));
    }

    /**
     * 新增app版本
     */
    @PreAuthorize("@ss.hasPermi('his:appVersion:add')")
    @Log(title = "app版本", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsAppVersion fsAppVersion)
    {
        return toAjax(fsAppVersionService.insertFsAppVersion(fsAppVersion));
    }

    /**
     * 修改app版本
     */
    @PreAuthorize("@ss.hasPermi('his:appVersion:update')")
    @Log(title = "app版本", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsAppVersion fsAppVersion)
    {
        return toAjax(fsAppVersionService.updateFsAppVersion(fsAppVersion));
    }

    /**
     * 删除app版本
     */
    @PreAuthorize("@ss.hasPermi('his:appVersion:remove')")
    @Log(title = "app版本", businessType = BusinessType.DELETE)
	@DeleteMapping("/{versionIds}")
    public AjaxResult remove(@PathVariable Long[] versionIds)
    {
        return toAjax(fsAppVersionService.deleteFsAppVersionByVersionIds(versionIds));
    }
}
