package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysUser;
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.system.domain.OrhonFgqy;
import com.ruoyi.system.service.IOrhonFgqyService;
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;

/**
 * 非公企业信息Controller
 *
 * @author ruoyi
 * @date 2020-07-16
 */
@org.springframework.stereotype.Controller
@org.springframework.web.bind.annotation.RequestMapping("/system/fgqy")
public class OrhonFgqyController extends com.ruoyi.common.core.controller.BaseController
{
    private String prefix = "system/fgqy";

    @org.springframework.beans.factory.annotation.Autowired
    private com.ruoyi.system.service.IOrhonFgqyService orhonFgqyService;

    @org.apache.shiro.authz.annotation.RequiresPermissions("system:fgqy:view")
    @org.springframework.web.bind.annotation.GetMapping()
    public String fgqy()
    {
        return prefix + "/fgqy";
    }

    /**
     * 查询非公企业信息列表
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:fgqy:list")
    @org.springframework.web.bind.annotation.PostMapping("/list")
    @org.springframework.web.bind.annotation.ResponseBody
    public com.ruoyi.common.core.page.TableDataInfo list(com.ruoyi.system.domain.OrhonFgqy orhonFgqy)
    {
        SysUser sysUser = ShiroUtils.getSysUser();
        startPage();
        if ( !sysUser.getLoginName().equals("admin") ) {
            orhonFgqy.setDeptId(sysUser.getUserDeptId().longValue());
        }

        java.util.List<com.ruoyi.system.domain.OrhonFgqy> list = orhonFgqyService.selectOrhonFgqyList(orhonFgqy);
        return getDataTable(list);
    }

    /**
     * 导出非公企业信息列表
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:fgqy:export")
    @com.ruoyi.common.annotation.Log(title = "非公企业信息", businessType = com.ruoyi.common.enums.BusinessType.EXPORT)
    @org.springframework.web.bind.annotation.PostMapping("/export")
    @org.springframework.web.bind.annotation.ResponseBody
    public com.ruoyi.common.core.domain.AjaxResult export(com.ruoyi.system.domain.OrhonFgqy orhonFgqy)
    {
        java.util.List<com.ruoyi.system.domain.OrhonFgqy> list = orhonFgqyService.selectOrhonFgqyList(orhonFgqy);
        com.ruoyi.common.utils.poi.ExcelUtil<com.ruoyi.system.domain.OrhonFgqy> util = new com.ruoyi.common.utils.poi.ExcelUtil<com.ruoyi.system.domain.OrhonFgqy>( com.ruoyi.system.domain.OrhonFgqy.class);
        return util.exportExcel(list, "fgqy");
    }

    /**
     * 新增非公企业信息
     */
    @org.springframework.web.bind.annotation.GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存非公企业信息
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:fgqy:add")
    @com.ruoyi.common.annotation.Log(title = "非公企业信息", businessType = com.ruoyi.common.enums.BusinessType.INSERT)
    @org.springframework.web.bind.annotation.PostMapping("/add")
    @org.springframework.web.bind.annotation.ResponseBody
    public com.ruoyi.common.core.domain.AjaxResult addSave(com.ruoyi.system.domain.OrhonFgqy orhonFgqy)
    {
        orhonFgqy.setId( java.util.UUID.randomUUID().toString() );
        return toAjax(orhonFgqyService.insertOrhonFgqy(orhonFgqy));
    }

    /**
     * 修改非公企业信息
     */
    @org.springframework.web.bind.annotation.GetMapping("/edit/{id}")
    public String edit(@org.springframework.web.bind.annotation.PathVariable("id") String id, org.springframework.ui.ModelMap mmap)
    {
        com.ruoyi.system.domain.OrhonFgqy orhonFgqy = orhonFgqyService.selectOrhonFgqyById(id);
        mmap.put("orhonFgqy", orhonFgqy);
        return prefix + "/edit";
    }

    /**
     * 修改保存非公企业信息
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:fgqy:edit")
    @com.ruoyi.common.annotation.Log(title = "非公企业信息", businessType = com.ruoyi.common.enums.BusinessType.UPDATE)
    @org.springframework.web.bind.annotation.PostMapping("/edit")
    @org.springframework.web.bind.annotation.ResponseBody
    public com.ruoyi.common.core.domain.AjaxResult editSave(com.ruoyi.system.domain.OrhonFgqy orhonFgqy)
    {
        return toAjax(orhonFgqyService.updateOrhonFgqy(orhonFgqy));
    }

    /**
     * 删除非公企业信息
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:fgqy:remove")
    @com.ruoyi.common.annotation.Log(title = "非公企业信息", businessType = com.ruoyi.common.enums.BusinessType.DELETE)
    @org.springframework.web.bind.annotation.PostMapping( "/remove")
    @org.springframework.web.bind.annotation.ResponseBody
    public com.ruoyi.common.core.domain.AjaxResult remove(String ids)
    {
        return toAjax(orhonFgqyService.deleteOrhonFgqyByIds(ids));
    }
}
