package com.ruoyi.mall.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallMajorRanking;
import com.ruoyi.mall.service.IMallMajorRankingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专业榜单Controller
 *
 * @author LCL
 * @date 2023-10-24
 */
@RestController
@RequestMapping("/mall/mallMajorRanking")
public class MallMajorRankingController extends BaseController
{
    @Resource
    private IMallMajorRankingService mallMajorRankingService;

    /**
     * 查询专业榜单列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMajorRanking:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallMajorRanking mallMajorRanking)
    {
        startPage();
        List<MallMajorRanking> list = mallMajorRankingService.selectMallMajorRankingList(mallMajorRanking);
        return getDataTable(list);
    }

    /**
     * 导出专业榜单列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMajorRanking:export')")
    @Log(title = "专业榜单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallMajorRanking mallMajorRanking)
    {
        List<MallMajorRanking> list = mallMajorRankingService.selectMallMajorRankingList(mallMajorRanking);
        ExcelUtil<MallMajorRanking> util = new ExcelUtil<MallMajorRanking>(MallMajorRanking.class);
        util.exportExcel(response, list, "专业榜单数据");
    }

    /**
     * 获取专业榜单详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMajorRanking:query')")
    @GetMapping(value = "/{rankingId}")
    public AjaxResult getInfo(@PathVariable("rankingId") Long rankingId)
    {
        return AjaxResult.success(mallMajorRankingService.selectMallMajorRankingByRankingId(rankingId));
    }

    /**
     * 新增专业榜单
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMajorRanking:add')")
    @Log(title = "专业榜单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallMajorRanking mallMajorRanking)
    {
        return toAjax(mallMajorRankingService.insertMallMajorRanking(mallMajorRanking));
    }

    /**
     * 修改专业榜单
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMajorRanking:edit')")
    @Log(title = "专业榜单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallMajorRanking mallMajorRanking)
    {
        return toAjax(mallMajorRankingService.updateMallMajorRanking(mallMajorRanking));
    }

    /**
     * 删除专业榜单
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMajorRanking:remove')")
    @Log(title = "专业榜单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rankingIds}")
    public AjaxResult remove(@PathVariable Long[] rankingIds)
    {
        return toAjax(mallMajorRankingService.deleteMallMajorRankingByRankingIds(rankingIds));
    }
}
