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.TSyTracestate;
import com.ruoyi.nanjing.service.ITSyTracestateService;
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;

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

    @Autowired
    private ITSyTracestateService tSyTracestateService;

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

    /**
     * 查询traceState列表
     */
    @RequiresPermissions("nanjing:TraceState:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TSyTracestate tSyTracestate)
    {
        startPage();
        List<TSyTracestate> list = tSyTracestateService.selectTSyTracestateList(tSyTracestate);
        return getDataTable(list);
    }

    /**
     * 导出traceState列表
     */
    @RequiresPermissions("nanjing:TraceState:export")
    @Log(title = "traceState", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TSyTracestate tSyTracestate)
    {
        List<TSyTracestate> list = tSyTracestateService.selectTSyTracestateList(tSyTracestate);
        ExcelUtil<TSyTracestate> util = new ExcelUtil<TSyTracestate>(TSyTracestate.class);
        return util.exportExcel(list, "TraceState");
    }

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

    /**
     * 新增保存traceState
     */
    @RequiresPermissions("nanjing:TraceState:add")
    @Log(title = "traceState", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TSyTracestate tSyTracestate)
    {
        return toAjax(tSyTracestateService.insertTSyTracestate(tSyTracestate));
    }

    /**
     * 修改traceState
     */
    @GetMapping("/edit/{barcode}")
    public String edit(@PathVariable("barcode") String barcode, ModelMap mmap)
    {
        TSyTracestate tSyTracestate = tSyTracestateService.selectTSyTracestateById(barcode);
        mmap.put("tSyTracestate", tSyTracestate);
        return prefix + "/edit";
    }

    /**
     * 修改保存traceState
     */
    @RequiresPermissions("nanjing:TraceState:edit")
    @Log(title = "traceState", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TSyTracestate tSyTracestate)
    {
        return toAjax(tSyTracestateService.updateTSyTracestate(tSyTracestate));
    }

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