package com.ruoyi.web.controller.system;

import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.OrhonShzz;
import com.ruoyi.system.domain.SysUser;

/**
 * 社会组织信息Controller
 *
 * @author ruoyi
 * @date 2020-07-20
 */
@org.springframework.stereotype.Controller
@org.springframework.web.bind.annotation.RequestMapping("/system/shzz")
public class OrhonShzzController extends com.ruoyi.common.core.controller.BaseController
{
    private String prefix = "system/shzz";

    @org.springframework.beans.factory.annotation.Autowired
    private com.ruoyi.system.service.IOrhonShzzService orhonShzzService;

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

    /**
     * 查询社会组织信息列表
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:shzz: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.OrhonShzz orhonShzz)
    {
        SysUser sysUser = ShiroUtils.getSysUser();
        startPage();
        if ( !sysUser.getLoginName().equals("admin") ) {
            orhonShzz.setDeptId(sysUser.getUserDeptId().longValue());
        }
        java.util.List<com.ruoyi.system.domain.OrhonShzz> list = orhonShzzService.selectOrhonShzzList(orhonShzz);
        return getDataTable(list);
    }

    /**
     * 导出社会组织信息列表
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:shzz: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.OrhonShzz orhonShzz)
    {
        java.util.List<com.ruoyi.system.domain.OrhonShzz> list = orhonShzzService.selectOrhonShzzList(orhonShzz);
        com.ruoyi.common.utils.poi.ExcelUtil<com.ruoyi.system.domain.OrhonShzz> util = new com.ruoyi.common.utils.poi.ExcelUtil<com.ruoyi.system.domain.OrhonShzz>( com.ruoyi.system.domain.OrhonShzz.class);
        return util.exportExcel(list, "shzz");
    }

    /**
     * 新增社会组织信息
     */
    @org.springframework.web.bind.annotation.GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存社会组织信息
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:shzz: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.OrhonShzz orhonShzz)
    {
        orhonShzz.setId( java.util.UUID.randomUUID().toString() );
        return toAjax(orhonShzzService.insertOrhonShzz(orhonShzz));
    }

    /**
     * 修改社会组织信息
     */
    @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.OrhonShzz orhonShzz = orhonShzzService.selectOrhonShzzById(id);
        mmap.put("orhonShzz", orhonShzz);
        return prefix + "/edit";
    }

    /**
     * 修改保存社会组织信息
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:shzz: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.OrhonShzz orhonShzz)
    {
        return toAjax(orhonShzzService.updateOrhonShzz(orhonShzz));
    }

    /**
     * 删除社会组织信息
     */
    @org.apache.shiro.authz.annotation.RequiresPermissions("system:shzz: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(orhonShzzService.deleteOrhonShzzByIds(ids));
    }
}
