package com.ruoyi.web.controller.school;

import java.util.List;

import com.ruoyi.system.domain.TbSchool;
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.TbSchoolFacilitiesContrastIcon;
import com.ruoyi.system.service.ITbSchoolFacilitiesContrastIconService;
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 2022-10-12
 */
@Controller
@RequestMapping("/system/icon")
public class TbSchoolFacilitiesContrastIconController extends BaseController
{
    private String prefix = "system/icon";

    @Autowired
    private ITbSchoolFacilitiesContrastIconService tbSchoolFacilitiesContrastIconService;

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

    /**
     * 查询院校设施名称和图片对照列表
     */
    @RequiresPermissions("system:icon:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbSchoolFacilitiesContrastIcon tbSchoolFacilitiesContrastIcon)
    {
        startPage();
        List<TbSchoolFacilitiesContrastIcon> list = tbSchoolFacilitiesContrastIconService.selectTbSchoolFacilitiesContrastIconList(tbSchoolFacilitiesContrastIcon);
        return getDataTable(list);
    }

    /**
     * 导出院校设施名称和图片对照列表
     */
    @RequiresPermissions("system:icon:export")
    @Log(title = "院校设施名称和图片对照", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbSchoolFacilitiesContrastIcon tbSchoolFacilitiesContrastIcon)
    {
        List<TbSchoolFacilitiesContrastIcon> list = tbSchoolFacilitiesContrastIconService.selectTbSchoolFacilitiesContrastIconList(tbSchoolFacilitiesContrastIcon);
        ExcelUtil<TbSchoolFacilitiesContrastIcon> util = new ExcelUtil<TbSchoolFacilitiesContrastIcon>(TbSchoolFacilitiesContrastIcon.class);
        return util.exportExcel(list, "院校设施名称和图片对照数据");
    }

    /**
     * 新增院校设施名称和图片对照
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存院校设施名称和图片对照
     */
    @RequiresPermissions("system:icon:add")
    @Log(title = "院校设施名称和图片对照", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbSchoolFacilitiesContrastIcon tbSchoolFacilitiesContrastIcon)
    {
        return success(tbSchoolFacilitiesContrastIconService.insertTbSchoolFacilitiesContrastIcon(tbSchoolFacilitiesContrastIcon));
    }

    /**
     * 修改院校设施名称和图片对照
     */
    @RequiresPermissions("system:icon:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TbSchoolFacilitiesContrastIcon tbSchoolFacilitiesContrastIcon = tbSchoolFacilitiesContrastIconService.selectTbSchoolFacilitiesContrastIconById(id);
        mmap.put("tbSchoolFacilitiesContrastIcon", tbSchoolFacilitiesContrastIcon);
        return prefix + "/edit";
    }

    /**
     * 修改保存院校设施名称和图片对照
     */
    @RequiresPermissions("system:icon:edit")
    @Log(title = "院校设施名称和图片对照", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbSchoolFacilitiesContrastIcon tbSchoolFacilitiesContrastIcon)
    {
        return toAjax(tbSchoolFacilitiesContrastIconService.updateTbSchoolFacilitiesContrastIcon(tbSchoolFacilitiesContrastIcon));
    }

    /**
     * 删除院校设施名称和图片对照
     */
    @RequiresPermissions("system:icon:remove")
    @Log(title = "院校设施名称和图片对照", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbSchoolFacilitiesContrastIconService.deleteTbSchoolFacilitiesContrastIconByIds(ids));
    }

    /**
     * 查询设施类型列表
     */
//    @RequiresPermissions("system:icon:list")
    @GetMapping("/getTypeList")
    @ResponseBody
    public List<String> getFacilitiesTypeList()
    {
        List<String> list = tbSchoolFacilitiesContrastIconService.getFacilitiesTypeList();
        return list;
    }

    /**
     * 根据设施类型查询设施列表
     */
//    @RequiresPermissions("system:icon:list")
    @GetMapping("/getFacilitiesList")
    @ResponseBody
    public List<TbSchoolFacilitiesContrastIcon> queryFacilitiesByType(String type){

        List<TbSchoolFacilitiesContrastIcon> list=tbSchoolFacilitiesContrastIconService.queryFacilitiesByType(type);
        return list;
    }
}
