package com.ruoyi.web.controller.Ytj;

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.Qiyekunnandengjibiao;
import com.ruoyi.system.service.IQiyekunnandengjibiaoService;
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;

/**
 * 个人独资控制器
 */
@Controller
@RequestMapping("/Ytj/Sole")
public class ProprietorshipController extends BaseController {


    private String prefix = "Ytj/Sole";

    @Autowired
    private IQiyekunnandengjibiaoService qiyekunnandengjibiaoService;

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

    /**
     * 查询个人独资列表
     */
    @RequiresPermissions("system:qiyekunnandengjibiao:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Qiyekunnandengjibiao qiyekunnandengjibiao)
    {
        startPage();
        List<Qiyekunnandengjibiao> list = qiyekunnandengjibiaoService.selectQiyekunnandengjibiaoList(qiyekunnandengjibiao);
        return getDataTable(list);
    }

    /**
     * 导出个人独资列表
     */
    @RequiresPermissions("system:qiyekunnandengjibiao:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Qiyekunnandengjibiao qiyekunnandengjibiao)
    {
        List<Qiyekunnandengjibiao> list = qiyekunnandengjibiaoService.selectQiyekunnandengjibiaoList(qiyekunnandengjibiao);
        ExcelUtil<Qiyekunnandengjibiao> util = new ExcelUtil<Qiyekunnandengjibiao>(Qiyekunnandengjibiao.class);
        return util.exportExcel(list, "qiyekunnandengjibiao");
    }

    /**
     * 新增个人独资
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存个人独资
     */
    @RequiresPermissions("system:qiyekunnandengjibiao:add")
    @Log(title = "个人独资", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Qiyekunnandengjibiao qiyekunnandengjibiao)
    {
        return toAjax(qiyekunnandengjibiaoService.insertQiyekunnandengjibiao(qiyekunnandengjibiao));
    }

    /**
     * 修改个人独资
     */
    @GetMapping("/edit/{chukouqn}")
    public String edit(@PathVariable("chukouqn") Long chukouqn, ModelMap mmap)
    {
        Qiyekunnandengjibiao qiyekunnandengjibiao = qiyekunnandengjibiaoService.selectQiyekunnandengjibiaoById(chukouqn);
        mmap.put("qiyekunnandengjibiao", qiyekunnandengjibiao);
        return prefix + "/edit";
    }

    /**
     * 修改保存个人独资
     */
    @RequiresPermissions("system:qiyekunnandengjibiao:edit")
    @Log(title = "个人独资", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Qiyekunnandengjibiao qiyekunnandengjibiao)
    {
        return toAjax(qiyekunnandengjibiaoService.updateQiyekunnandengjibiao(qiyekunnandengjibiao));
    }

    /**
     * 删除个人独资
     */
    @RequiresPermissions("system:qiyekunnandengjibiao:remove")
    @Log(title = "个人独资", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qiyekunnandengjibiaoService.deleteQiyekunnandengjibiaoByIds(ids));
    }

    /**-----------------------------------------以上为自带方法---------------------------------------------------------**/





}
