package com.sooka.system.controller;

import java.util.List;

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.common.annotation.Log;
import com.sooka.system.domain.TgjjKjhzb;
import com.sooka.system.service.ITgjjKjhzbService;

/**
 * 会计汇总报（年、季、月）Controller
 * 
 * @author lei
 * @date 2021-11-16
 */
@Controller
@RequestMapping("/system/kjhzb")
public class TgjjKjhzbController extends BaseController
{
    private String prefix = "system/kjhzb";

    @Autowired
    private ITgjjKjhzbService tgjjKjhzbService;

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

    /**
     * 查询会计汇总报（年、季、月）列表
     */
    @RequiresPermissions("system:kjhzb:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TgjjKjhzb tgjjKjhzb)
    {
        startPage();
        List<TgjjKjhzb> list = tgjjKjhzbService.selectTgjjKjhzbList(tgjjKjhzb);
        return getDataTable(list);
    }

    /**
     * 导出会计汇总报（年、季、月）列表
     */
    @RequiresPermissions("system:kjhzb:export")
    @Log(title = "会计汇总报（年、季、月）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TgjjKjhzb tgjjKjhzb)
    {
        List<TgjjKjhzb> list = tgjjKjhzbService.selectTgjjKjhzbList(tgjjKjhzb);
        ExcelUtil<TgjjKjhzb> util = new ExcelUtil<TgjjKjhzb>(TgjjKjhzb.class);
        return util.exportExcel(list, "kjhzb");
    }

    /**
     * 新增会计汇总报（年、季、月）
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会计汇总报（年、季、月）
     */
    @RequiresPermissions("system:kjhzb:add")
    @Log(title = "会计汇总报（年、季、月）", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TgjjKjhzb tgjjKjhzb)
    {
        return toAjax(tgjjKjhzbService.insertTgjjKjhzb(tgjjKjhzb));
    }

    /**
     * 修改会计汇总报（年、季、月）
     */
    @GetMapping("/edit/{ID}")
    public String edit(@PathVariable("ID") Long ID, ModelMap mmap)
    {
        TgjjKjhzb tgjjKjhzb = tgjjKjhzbService.selectTgjjKjhzbById(ID);
        mmap.put("tgjjKjhzb", tgjjKjhzb);
        return prefix + "/edit";
    }

    /**
     * 修改保存会计汇总报（年、季、月）
     */
    @RequiresPermissions("system:kjhzb:edit")
    @Log(title = "会计汇总报（年、季、月）", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TgjjKjhzb tgjjKjhzb)
    {
        return toAjax(tgjjKjhzbService.updateTgjjKjhzb(tgjjKjhzb));
    }

    /**
     * 删除会计汇总报（年、季、月）
     */
    @RequiresPermissions("system:kjhzb:remove")
    @Log(title = "会计汇总报（年、季、月）", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tgjjKjhzbService.deleteTgjjKjhzbByIds(ids));
    }
}
