package com.zbf.web.controller.system;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

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.TRkWareNoticeBak;
import com.zbf.system.service.ITRkWareNoticeBakService;

/**
 * 入库通知单历史表Controller
 *
 * @author tony
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/system/rkWareNoticeBak")
public class TRkWareNoticeBakController extends BaseController {
    @Autowired
    private ITRkWareNoticeBakService tRkWareNoticeBakService;

    /**
     * 查询入库通知单历史表列表
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeBak:list')")
    @GetMapping("/list")
    @EnhanceDataList(entityType = TRkWareNoticeBak.class)
    public TableDataInfo list(TRkWareNoticeBak tRkWareNoticeBak) {
        startPage();
        tRkWareNoticeBak.setDeptId(getDeptId());
        List<TRkWareNoticeBak> list = tRkWareNoticeBakService.selectTRkWareNoticeBakList(tRkWareNoticeBak);
        return getDataTable(list);
    }

    /**
     * 导出入库通知单历史表列表
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeBak:export')")
    @Log(title = "入库通知单历史表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TRkWareNoticeBak tRkWareNoticeBak) {
        tRkWareNoticeBak.setDeptId(getDeptId());
        List<TRkWareNoticeBak> list = tRkWareNoticeBakService.selectTRkWareNoticeBakList(tRkWareNoticeBak);
        ExcelUtil<TRkWareNoticeBak> util = new ExcelUtil<TRkWareNoticeBak>(TRkWareNoticeBak.class);
        util.exportExcel(response, list, "入库通知单历史表数据");
    }

    /**
     * 获取入库通知单历史表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeBak:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(tRkWareNoticeBakService.selectTRkWareNoticeBakById(id));
    }

    /**
     * 新增入库通知单历史表
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeBak:add')")
    @Log(title = "入库通知单历史表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRkWareNoticeBak tRkWareNoticeBak) {
        tRkWareNoticeBak.setId(OrderCodeFactory.getOrderCode("TRK", ""));
        return toAjax(tRkWareNoticeBakService.insertTRkWareNoticeBak(tRkWareNoticeBak));
    }

    /**
     * 修改入库通知单历史表
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeBak:edit')")
    @Log(title = "入库通知单历史表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRkWareNoticeBak tRkWareNoticeBak) {
        return toAjax(tRkWareNoticeBakService.updateTRkWareNoticeBak(tRkWareNoticeBak));
    }

    /**
     * 删除入库通知单历史表
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeBak:remove')")
    @Log(title = "入库通知单历史表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tRkWareNoticeBakService.deleteTRkWareNoticeBakByIds(ids));
    }

    /**
     * 启用
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeBak:remove')")
    @Log(title = "入库通知单历史表", businessType = BusinessType.UPDATE)
    @DeleteMapping("/disable/{ids}")
    public AjaxResult disable(@PathVariable String[] ids) {
        return toAjax(tRkWareNoticeBakService.disabledTRkWareNoticeBakByIds(ids));
    }

    /**
     * 禁用
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeBak:edit')")
    @Log(title = "入库通知单历史表", businessType = BusinessType.UPDATE)
    @DeleteMapping("/enable/{ids}")
    public AjaxResult enable(@PathVariable String[] ids) {
        return toAjax(tRkWareNoticeBakService.enableTRkWareNoticeBakByIds(ids));
    }

    /**
     * 修改状态
     */
    @PreAuthorize("@ss.hasPermi('system:rkWareNoticeBak:edit')")
    @Log(title = "入库通知单历史表", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody TRkWareNoticeBak tRkWareNoticeBak) {
        return toAjax(tRkWareNoticeBakService.updateStatus(tRkWareNoticeBak));
    }

}

