package com.ruoyi.mall.controller;

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.mall.domain.MallSchoolTag;
import com.ruoyi.mall.service.IMallSchoolTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 学校标签分类idController
 *
 * @author Lsm
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/mall/mallSchoolTag")
public class MallSchoolTagController extends BaseController
{
    @Autowired
    private IMallSchoolTagService mallSchoolTagService;

    /**
     * 查询学校标签分类id列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolTag:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallSchoolTag mallSchoolTag)
    {
        startPage();
        List<MallSchoolTag> list = mallSchoolTagService.selectMallSchoolTagList(mallSchoolTag);
        return getDataTable(list);
    }

    /**
     * 导出学校标签分类id列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolTag:export')")
    @Log(title = "学校标签分类id", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallSchoolTag mallSchoolTag)
    {
        List<MallSchoolTag> list = mallSchoolTagService.selectMallSchoolTagList(mallSchoolTag);
        ExcelUtil<MallSchoolTag> util = new ExcelUtil<MallSchoolTag>(MallSchoolTag.class);
        util.exportExcel(response, list, "学校标签分类id数据");
    }

    /**
     * 获取学校标签分类id详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolTag:query')")
    @GetMapping(value = "/{schoolTagId}")
    public AjaxResult getInfo(@PathVariable("schoolTagId") Long schoolTagId)
    {
        return AjaxResult.success(mallSchoolTagService.selectMallSchoolTagBySchoolTagId(schoolTagId));
    }

    /**
     * 新增学校标签分类id
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolTag:add')")
    @Log(title = "学校标签分类id", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallSchoolTag mallSchoolTag)
    {
        return toAjax(mallSchoolTagService.insertMallSchoolTag(mallSchoolTag));
    }

    /**
     * 修改学校标签分类id
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolTag:edit')")
    @Log(title = "学校标签分类id", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallSchoolTag mallSchoolTag)
    {
        return toAjax(mallSchoolTagService.updateMallSchoolTag(mallSchoolTag));
    }

    /**
     * 删除学校标签分类id
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolTag:remove')")
    @Log(title = "学校标签分类id", businessType = BusinessType.DELETE)
	@DeleteMapping("/{schoolTagIds}")
    public AjaxResult remove(@PathVariable Long[] schoolTagIds)
    {
        return toAjax(mallSchoolTagService.deleteMallSchoolTagBySchoolTagIds(schoolTagIds));
    }

    /**
     * 标签列表
     * @return 结果
     */
    @GetMapping("/selectTagList")
    public AjaxResult selectTagList(){
        return AjaxResult.success(mallSchoolTagService.selectTagList());
    }
}
