package com.ruoyi.web.controller.business;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TSysVersion;
import com.ruoyi.business.service.ITSysVersionService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统版本更新记录Controller
 * 
 * @author xiatao
 * @date 2022-01-18
 */
@Controller
@RequestMapping("/business/version")
public class TSysVersionController extends BaseController
{
    private String prefix = "business/version";

    @Autowired
    private ITSysVersionService tSysVersionService;

    @RequiresPermissions("business:version:view")
    @GetMapping()
    public String version()
    {
        return prefix + "/version";
    }

    /**
     * 查询系统版本更新记录列表
     */
    @RequiresPermissions("business:version:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TSysVersion tSysVersion)
    {
        startPage();
        List<TSysVersion> list = tSysVersionService.selectTSysVersionList(tSysVersion);
        return getDataTable(list);
    }

    /**
     * 导出系统版本更新记录列表
     */
    @RequiresPermissions("business:version:export")
    @Log(title = "系统版本更新记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TSysVersion tSysVersion)
    {
        List<TSysVersion> list = tSysVersionService.selectTSysVersionList(tSysVersion);
        ExcelUtil<TSysVersion> util = new ExcelUtil<TSysVersion>(TSysVersion.class);
        return util.exportExcel(list, "系统版本更新记录数据");
    }

    /**
     * 新增系统版本更新记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存系统版本更新记录
     */
    @RequiresPermissions("business:version:add")
    @Log(title = "系统版本更新记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TSysVersion tSysVersion)
    {
        return toAjax(tSysVersionService.insertTSysVersion(tSysVersion));
    }

    /**
     * 修改系统版本更新记录
     */
    @RequiresPermissions("business:version:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TSysVersion tSysVersion = tSysVersionService.selectTSysVersionById(id);
        mmap.put("tSysVersion", tSysVersion);
        return prefix + "/edit";
    }

    /**
     * 修改保存系统版本更新记录
     */
    @RequiresPermissions("business:version:edit")
    @Log(title = "系统版本更新记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TSysVersion tSysVersion)
    {
        return toAjax(tSysVersionService.updateTSysVersion(tSysVersion));
    }

    /**
     * 删除系统版本更新记录
     */
    @RequiresPermissions("business:version:remove")
    @Log(title = "系统版本更新记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tSysVersionService.deleteTSysVersionByIds(ids));
    }
}