package com.sooka.system.controller;

import java.util.List;
import com.sooka.common.annotation.Log;
import com.sooka.common.core.controller.BaseController;
import com.sooka.common.core.domain.AjaxResult;
import com.sooka.common.core.page.TableDataInfo;
import com.sooka.common.enums.BusinessType;
import com.sooka.common.utils.poi.ExcelUtil;
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.sooka.system.domain.TgjjBsxx;
import com.sooka.system.service.ITgjjBsxxService;

/**
 * 报税信息Controller
 * 
 * @author lei
 * @date 2021-11-16
 */
@Controller
@RequestMapping("/system/bsxx")
public class TgjjBsxxController extends BaseController
{
    private String prefix = "system/bsxx";

    @Autowired
    private ITgjjBsxxService tgjjBsxxService;

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

    /**
     * 查询报税信息列表
     */
    @RequiresPermissions("system:bsxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TgjjBsxx tgjjBsxx)
    {
        startPage();
        List<TgjjBsxx> list = tgjjBsxxService.selectTgjjBsxxList(tgjjBsxx);
        return getDataTable(list);
    }

    /**
     * 导出报税信息列表
     */
    @RequiresPermissions("system:bsxx:export")
    @Log(title = "报税信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TgjjBsxx tgjjBsxx)
    {
        List<TgjjBsxx> list = tgjjBsxxService.selectTgjjBsxxList(tgjjBsxx);
        ExcelUtil<TgjjBsxx> util = new ExcelUtil<TgjjBsxx>(TgjjBsxx.class);
        return util.exportExcel(list, "bsxx");
    }

    /**
     * 新增报税信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存报税信息
     */
    @RequiresPermissions("system:bsxx:add")
    @Log(title = "报税信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TgjjBsxx tgjjBsxx)
    {
        return toAjax(tgjjBsxxService.insertTgjjBsxx(tgjjBsxx));
    }

    /**
     * 修改报税信息
     */
    @GetMapping("/edit/{ID}")
    public String edit(@PathVariable("ID") Long ID, ModelMap mmap)
    {
        TgjjBsxx tgjjBsxx = tgjjBsxxService.selectTgjjBsxxById(ID);
        mmap.put("tgjjBsxx", tgjjBsxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存报税信息
     */
    @RequiresPermissions("system:bsxx:edit")
    @Log(title = "报税信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TgjjBsxx tgjjBsxx)
    {
        return toAjax(tgjjBsxxService.updateTgjjBsxx(tgjjBsxx));
    }

    /**
     * 删除报税信息
     */
    @RequiresPermissions("system:bsxx:remove")
    @Log(title = "报税信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tgjjBsxxService.deleteTgjjBsxxByIds(ids));
    }
}
