package com.ruoyi.system.controller;

import java.util.List;
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.TbMajorIconCollection;
import com.ruoyi.system.service.ITbMajorIconCollectionService;
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-11
 */
@Controller
@RequestMapping("/system/collection")
public class TbMajorIconCollectionController extends BaseController
{
    private String prefix = "system/collection";

    @Autowired
    private ITbMajorIconCollectionService tbMajorIconCollectionService;

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

    /**
     * 查询专业图标列表
     */
    @RequiresPermissions("system:collection:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbMajorIconCollection tbMajorIconCollection)
    {
        startPage();
        List<TbMajorIconCollection> list = tbMajorIconCollectionService.selectTbMajorIconCollectionList(tbMajorIconCollection);
        return getDataTable(list);
    }

    /**
     * 导出专业图标列表
     */
    @RequiresPermissions("system:collection:export")
    @Log(title = "专业图标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbMajorIconCollection tbMajorIconCollection)
    {
        List<TbMajorIconCollection> list = tbMajorIconCollectionService.selectTbMajorIconCollectionList(tbMajorIconCollection);
        ExcelUtil<TbMajorIconCollection> util = new ExcelUtil<TbMajorIconCollection>(TbMajorIconCollection.class);
        return util.exportExcel(list, "专业图标数据");
    }

    /**
     * 新增专业图标
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存专业图标
     */
    @RequiresPermissions("system:collection:add")
    @Log(title = "专业图标", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbMajorIconCollection tbMajorIconCollection)
    {
        return toAjax(tbMajorIconCollectionService.insertTbMajorIconCollection(tbMajorIconCollection));
    }

    /**
     * 修改专业图标
     */
    @RequiresPermissions("system:collection:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TbMajorIconCollection tbMajorIconCollection = tbMajorIconCollectionService.selectTbMajorIconCollectionById(id);
        mmap.put("tbMajorIconCollection", tbMajorIconCollection);
        return prefix + "/edit";
    }

    /**
     * 修改保存专业图标
     */
    @RequiresPermissions("system:collection:edit")
    @Log(title = "专业图标", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbMajorIconCollection tbMajorIconCollection)
    {
        return toAjax(tbMajorIconCollectionService.updateTbMajorIconCollection(tbMajorIconCollection));
    }

    /**
     * 删除专业图标
     */
    @RequiresPermissions("system:collection:remove")
    @Log(title = "专业图标", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbMajorIconCollectionService.deleteTbMajorIconCollectionByIds(ids));
    }
}
