package com.zbf.web.controller.system;

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.zbf.common.annotation.Log;
import com.zbf.common.core.controller.BaseController;
import com.zbf.common.core.domain.AjaxResult;
import com.zbf.common.core.page.TableDataInfo;
import com.zbf.common.enums.BusinessType;
import com.zbf.common.utils.poi.ExcelUtil;
import com.zbf.system.domain.TRkWareNoticeTab;
import com.zbf.system.service.ITRkWareNoticeTabService;

/**
 * 入库通知单明细Controller
 *
 * @author tony
 * @date 2024-08-16
 */
@RestController
@RequestMapping("/system/trkWareNoticeTab")
public class TRkWareNoticeTabController extends BaseController
{
    @Autowired
    private ITRkWareNoticeTabService tRkWareNoticeTabService;

/**
 * 查询入库通知单明细列表
 */
@PreAuthorize("@ss.hasPermi('system:trkNotice:list')")
@GetMapping("/list")
    public TableDataInfo list(TRkWareNoticeTab tRkWareNoticeTab)
    {
        startPage();
        List<TRkWareNoticeTab> list = tRkWareNoticeTabService.selectTRkWareNoticeTabList(tRkWareNoticeTab);
        return getDataTable(list);
    }

    /**
     * 导出入库通知单明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:trkWareNoticeTab:export')")
    @Log(title = "入库通知单明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TRkWareNoticeTab tRkWareNoticeTab)
    {
        List<TRkWareNoticeTab> list = tRkWareNoticeTabService.selectTRkWareNoticeTabList(tRkWareNoticeTab);
        ExcelUtil<TRkWareNoticeTab> util = new ExcelUtil<TRkWareNoticeTab>(TRkWareNoticeTab.class);
        util.exportExcel(response, list, "入库通知单明细数据");
    }

    /**
     * 获取入库通知单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:trkWareNoticeTab:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tRkWareNoticeTabService.selectTRkWareNoticeTabById(id));
    }

    /**
     * 新增入库通知单明细
     */
    @PreAuthorize("@ss.hasPermi('system:trkWareNoticeTab:add')")
    @Log(title = "入库通知单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRkWareNoticeTab tRkWareNoticeTab)
    {
        return toAjax(tRkWareNoticeTabService.insertTRkWareNoticeTab(tRkWareNoticeTab));
    }

    /**
     * 修改入库通知单明细
     */
    @PreAuthorize("@ss.hasPermi('system:trkWareNoticeTab:edit')")
    @Log(title = "入库通知单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRkWareNoticeTab tRkWareNoticeTab)
    {
        return toAjax(tRkWareNoticeTabService.updateTRkWareNoticeTab(tRkWareNoticeTab));
    }

    /**
     * 删除入库通知单明细
     */
    @PreAuthorize("@ss.hasPermi('system:trkWareNoticeTab:remove')")
    @Log(title = "入库通知单明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tRkWareNoticeTabService.deleteTRkWareNoticeTabByIds(ids));
    }

    /**
     * 启用
     */
    @PreAuthorize("@ss.hasPermi('system:trkWareNoticeTab:remove')")
    @Log(title = "入库通知单明细", businessType = BusinessType.UPDATE)
    @DeleteMapping("/disable/{ids}")
    public AjaxResult disable(@PathVariable String[] ids)
    {
        return toAjax(tRkWareNoticeTabService.disabledTRkWareNoticeTabByIds(ids));
    }

    /**
     * 禁用
     */
    @PreAuthorize("@ss.hasPermi('system:trkWareNoticeTab:edit')")
    @Log(title = "入库通知单明细", businessType = BusinessType.UPDATE)
    @DeleteMapping("/enable/{ids}")
    public AjaxResult enable(@PathVariable String[] ids)
    {
        return toAjax(tRkWareNoticeTabService.enableTRkWareNoticeTabByIds(ids));
    }

    /**
     * 修改状态
     */
    @PreAuthorize("@ss.hasPermi('system:trkWareNoticeTab:edit')")
    @Log(title = "入库通知单明细", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody TRkWareNoticeTab tRkWareNoticeTab) {
        return toAjax(tRkWareNoticeTabService.updateStatus(tRkWareNoticeTab));
    }

}

