package com.zbf.web.controller.system;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import com.zbf.system.domain.TRkWareNoticeBak;
import com.zbf.system.mapper.TRkWareNoticeTabBakMapper;
import com.zbf.web.controller.section.EnhanceDataList;
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.OrderCodeFactory;
import com.zbf.common.utils.poi.ExcelUtil;
import com.zbf.system.domain.TRkWareNoticeTabBak;
import com.zbf.system.service.ITRkWareNoticeTabBakService;

/**
 * 入库通知单明细备份Controller
 *
 * @author tony
 * @date 2024-06-14
 */
@RestController
@RequestMapping("/system/rkWareNoticeTabBak")
public class TRkWareNoticeTabBakController extends BaseController
{
    @Autowired
    private ITRkWareNoticeTabBakService tRkWareNoticeTabBakService;

    @Autowired
    private TRkWareNoticeTabBakMapper tRkWareNoticeTabBakMapper;

/**
 * 查询入库通知单明细备份列表
 */
@GetMapping("/list")
@EnhanceDataList(entityType = TRkWareNoticeTabBak.class)
    public TableDataInfo list(TRkWareNoticeTabBak tRkWareNoticeTabBak)
    {
        startPage();
//        tMiStock.setDeptId(getDeptId());
        if (tRkWareNoticeTabBak.getDate()!=null){
            String[] date = tRkWareNoticeTabBak.getDate();
            tRkWareNoticeTabBak.setStartTime(date[0]);
            tRkWareNoticeTabBak.setEndTime(date[1]);
        }
        List<TRkWareNoticeTabBak> list = tRkWareNoticeTabBakService.selectTRkWareNoticeTabBakList(tRkWareNoticeTabBak);
        return getDataTable(list);
    }

    @GetMapping("/listSupplier")
    @EnhanceDataList(entityType = TRkWareNoticeTabBak.class)
    public TableDataInfo listSupplier()
    {
       TRkWareNoticeTabBak tRkWareNoticeTabBak = new TRkWareNoticeTabBak();
        List<TRkWareNoticeTabBak> list = tRkWareNoticeTabBakService.selectTRkWareNoticeTabBakList(tRkWareNoticeTabBak);
        return getDataTable(list);
    }




    @GetMapping("/syList")
    public TableDataInfo syList(TRkWareNoticeTabBak tRkWareNoticeTabBak)
    {
        if (tRkWareNoticeTabBak.getDate()!=null){
            String[] date = tRkWareNoticeTabBak.getDate();
            tRkWareNoticeTabBak.setStartTime(date[0]);
            tRkWareNoticeTabBak.setEndTime(date[1]);
        }
        List<TRkWareNoticeTabBak> list = tRkWareNoticeTabBakMapper.selectTRkWareNoticeTabBakLists();
        return getDataTable(list);
    }

    @GetMapping("/listTotal")
    public AjaxResult listTotal(TRkWareNoticeTabBak tRkWareNoticeTabBak)
    {
        if (tRkWareNoticeTabBak.getDate()!=null){
            String[] date = tRkWareNoticeTabBak.getDate();
            tRkWareNoticeTabBak.setStartTime(date[0]);
            tRkWareNoticeTabBak.setEndTime(date[1]);
        }
        List<TRkWareNoticeTabBak> list = tRkWareNoticeTabBakService.select(tRkWareNoticeTabBak);
        return AjaxResult.success(list);
    }



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

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

    /**
     * 新增入库通知单明细备份
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeTabBak:add')")
    @Log(title = "入库通知单明细备份", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRkWareNoticeTabBak tRkWareNoticeTabBak)
    {
        tRkWareNoticeTabBak.setId(OrderCodeFactory.getOrderCode("TRKTAB", ""));
        return toAjax(tRkWareNoticeTabBakService.insertTRkWareNoticeTabBak(tRkWareNoticeTabBak));
    }

    /**
     * 修改入库通知单明细备份
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeTabBak:edit')")
    @Log(title = "入库通知单明细备份", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRkWareNoticeTabBak tRkWareNoticeTabBak)
    {
        return toAjax(tRkWareNoticeTabBakService.updateTRkWareNoticeTabBak(tRkWareNoticeTabBak));
    }

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

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

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

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

}

