package com.ruoyi.web.controller.Ytjback;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.QyCzrxx;
import com.ruoyi.system.service.IQyCzrxxService;
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.*;

import java.util.List;

/**
 * czrxxController
 * 
 * @author ruoyi
 * @date 2019-09-10
 */
@Controller
@RequestMapping("/Ytj/czrxx")
public class QyCzrxxController extends BaseController
{
    private String prefix = "Ytj/czrxx";

    @Autowired
    private IQyCzrxxService qyCzrxxService;

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

    /**
     * 查询czrxx列表
     */
    @RequiresPermissions("system:czrxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QyCzrxx qyCzrxx)
    {
        startPage();
        List<QyCzrxx> list = qyCzrxxService.selectQyCzrxxList(qyCzrxx);
        return getDataTable(list);
    }

    /**
     * 导出czrxx列表
     */
    @RequiresPermissions("system:czrxx:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QyCzrxx qyCzrxx)
    {
        List<QyCzrxx> list = qyCzrxxService.selectQyCzrxxList(qyCzrxx);
        ExcelUtil<QyCzrxx> util = new ExcelUtil<QyCzrxx>(QyCzrxx.class);
        return util.exportExcel(list, "czrxx");
    }

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

    /**
     * 新增保存czrxx
     */
    @RequiresPermissions("system:czrxx:add")
    @Log(title = "czrxx", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QyCzrxx qyCzrxx)
    {
        return toAjax(qyCzrxxService.insertQyCzrxx(qyCzrxx));
    }

    /**
     * 修改czrxx
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        QyCzrxx qyCzrxx = qyCzrxxService.selectQyCzrxxById(id);
        mmap.put("qyCzrxx", qyCzrxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存czrxx
     */
    @RequiresPermissions("system:czrxx:edit")
    @Log(title = "czrxx", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QyCzrxx qyCzrxx)
    {
        return toAjax(qyCzrxxService.updateQyCzrxx(qyCzrxx));
    }

    /**
     * 删除czrxx
     */
    @RequiresPermissions("system:czrxx:remove")
    @Log(title = "czrxx", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qyCzrxxService.deleteQyCzrxxByIds(ids));
    }
}
