package com.ruoyi.web.controller.nanjing;

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.nanjing.domain.TRpBarcoderelationship;
import com.ruoyi.nanjing.service.ITRpBarcoderelationshipService;
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;

/**
 * BarcodeRelationShipController
 * 
 * @author limy
 * @date 2021-01-29
 */
@Controller
@RequestMapping("/nanjing/BarcodeRelationShip")
public class TRpBarcoderelationshipController extends BaseController
{
    private String prefix = "nanjing/BarcodeRelationShip";

    @Autowired
    private ITRpBarcoderelationshipService tRpBarcoderelationshipService;

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

    /**
     * 查询BarcodeRelationShip列表
     */
    @RequiresPermissions("nanjing:BarcodeRelationShip:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TRpBarcoderelationship tRpBarcoderelationship)
    {
        startPage();
        List<TRpBarcoderelationship> list = tRpBarcoderelationshipService.selectTRpBarcoderelationshipList(tRpBarcoderelationship);
        return getDataTable(list);
    }

    /**
     * 导出BarcodeRelationShip列表
     */
    @RequiresPermissions("nanjing:BarcodeRelationShip:export")
    @Log(title = "BarcodeRelationShip", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TRpBarcoderelationship tRpBarcoderelationship)
    {
        List<TRpBarcoderelationship> list = tRpBarcoderelationshipService.selectTRpBarcoderelationshipList(tRpBarcoderelationship);
        ExcelUtil<TRpBarcoderelationship> util = new ExcelUtil<TRpBarcoderelationship>(TRpBarcoderelationship.class);
        return util.exportExcel(list, "BarcodeRelationShip");
    }

    /**
     * 新增BarcodeRelationShip
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存BarcodeRelationShip
     */
    @RequiresPermissions("nanjing:BarcodeRelationShip:add")
    @Log(title = "BarcodeRelationShip", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TRpBarcoderelationship tRpBarcoderelationship)
    {
        return toAjax(tRpBarcoderelationshipService.insertTRpBarcoderelationship(tRpBarcoderelationship));
    }

    /**
     * 修改BarcodeRelationShip
     */
    @GetMapping("/edit/{ID}")
    public String edit(@PathVariable("ID") Long ID, ModelMap mmap)
    {
        TRpBarcoderelationship tRpBarcoderelationship = tRpBarcoderelationshipService.selectTRpBarcoderelationshipById(ID);
        mmap.put("tRpBarcoderelationship", tRpBarcoderelationship);
        return prefix + "/edit";
    }

    /**
     * 修改保存BarcodeRelationShip
     */
    @RequiresPermissions("nanjing:BarcodeRelationShip:edit")
    @Log(title = "BarcodeRelationShip", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TRpBarcoderelationship tRpBarcoderelationship)
    {
        return toAjax(tRpBarcoderelationshipService.updateTRpBarcoderelationship(tRpBarcoderelationship));
    }

    /**
     * 删除BarcodeRelationShip
     */
    @RequiresPermissions("nanjing:BarcodeRelationShip:remove")
    @Log(title = "BarcodeRelationShip", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tRpBarcoderelationshipService.deleteTRpBarcoderelationshipByIds(ids));
    }
}
