package com.zbf.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.zbf.common.annotation.Log;
import com.zbf.common.core.controller.BaseController;
import com.zbf.common.core.domain.AjaxResult;
import com.zbf.common.enums.BusinessType;
import com.zbf.system.domain.TMiStockBak;
import com.zbf.system.service.ITMiStockBakService;
import com.zbf.common.utils.poi.ExcelUtil;
import com.zbf.common.core.page.TableDataInfo;

/**
 * 库存备份Controller
 *
 * @author tony
 * @date 2024-06-14
 */
@RestController
@RequestMapping("/system/tMiStockbak")
public class TMiStockBakController extends BaseController
{
    @Autowired
    private ITMiStockBakService tMiStockBakService;

/**
 * 查询库存备份列表
 */
@PreAuthorize("@ss.hasPermi('system:tMiStockbak:list')")
@GetMapping("/list")
    public TableDataInfo list(TMiStockBak tMiStockBak)
    {
        startPage();
        tMiStockBak.setDeptId(getDeptId());
        List<TMiStockBak> list = tMiStockBakService.selectTMiStockBakList(tMiStockBak);
        return getDataTable(list);
    }

    /**
     * 导出库存备份列表
     */
    @PreAuthorize("@ss.hasPermi('system:tMiStockbak:export')")
    @Log(title = "库存备份", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TMiStockBak tMiStockBak)
    {
        tMiStockBak.setDeptId(getDeptId());
        List<TMiStockBak> list = tMiStockBakService.selectTMiStockBakList(tMiStockBak);
        ExcelUtil<TMiStockBak> util = new ExcelUtil<TMiStockBak>(TMiStockBak.class);
        util.exportExcel(response, list, "库存备份数据");
    }

    /**
     * 获取库存备份详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tMiStockbak:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tMiStockBakService.selectTMiStockBakById(id));
    }

    /**
     * 新增库存备份
     */
    @PreAuthorize("@ss.hasPermi('system:tMiStockbak:add')")
    @Log(title = "库存备份", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMiStockBak tMiStockBak)
    {
        return toAjax(tMiStockBakService.insertTMiStockBak(tMiStockBak));
    }

    /**
     * 修改库存备份
     */
    @PreAuthorize("@ss.hasPermi('system:tMiStockbak:edit')")
    @Log(title = "库存备份", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMiStockBak tMiStockBak)
    {
        return toAjax(tMiStockBakService.updateTMiStockBak(tMiStockBak));
    }

    /**
     * 删除库存备份
     */
    @PreAuthorize("@ss.hasPermi('system:tMiStockbak:remove')")
    @Log(title = "库存备份", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMiStockBakService.deleteTMiStockBakByIds(ids));
    }

    /**
     * 启用
     */
    @PreAuthorize("@ss.hasPermi('system:tMiStockbak:remove')")
    @Log(title = "库存备份", businessType = BusinessType.UPDATE)
    @DeleteMapping("/disable/{ids}")
    public AjaxResult disable(@PathVariable Long[] ids)
    {
        return toAjax(tMiStockBakService.disabledTMiStockBakByIds(ids));
    }

    /**
     * 禁用
     */
    @PreAuthorize("@ss.hasPermi('system:tMiStockbak:edit')")
    @Log(title = "库存备份", businessType = BusinessType.UPDATE)
    @DeleteMapping("/enable/{ids}")
    public AjaxResult enable(@PathVariable Long[] ids)
    {
        return toAjax(tMiStockBakService.enableTMiStockBakByIds(ids));
    }

    /**
     * 修改状态
     */
    @PreAuthorize("@ss.hasPermi('system:tMiStockbak:edit')")
    @Log(title = "库存备份", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody TMiStockBak tMiStockBak) {
        return toAjax(tMiStockBakService.updateStatus(tMiStockBak));
    }

}

