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.MallLinkRankingSchool;
import com.ruoyi.mall.service.IMallLinkRankingSchoolService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 榜单与学校关联Controller
 *
 * @author LCL
 * @date 2023-10-24
 */
@RestController
@RequestMapping("/mall/mallLinkRankingSchool")
public class MallLinkRankingSchoolController extends BaseController
{
    @Resource
    private IMallLinkRankingSchoolService mallLinkRankingSchoolService;

    /**
     * 查询榜单与学校关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkRankingSchool:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallLinkRankingSchool mallLinkRankingSchool)
    {
        startPage();
        List<MallLinkRankingSchool> list = mallLinkRankingSchoolService.selectMallLinkRankingSchoolList(mallLinkRankingSchool);
        return getDataTable(list);
    }

    /**
     * 导出榜单与学校关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkRankingSchool:export')")
    @Log(title = "榜单与学校关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallLinkRankingSchool mallLinkRankingSchool)
    {
        List<MallLinkRankingSchool> list = mallLinkRankingSchoolService.selectMallLinkRankingSchoolList(mallLinkRankingSchool);
        ExcelUtil<MallLinkRankingSchool> util = new ExcelUtil<MallLinkRankingSchool>(MallLinkRankingSchool.class);
        util.exportExcel(response, list, "榜单与学校关联数据");
    }

    /**
     * 获取榜单与学校关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkRankingSchool:query')")
    @GetMapping(value = "/{linkId}")
    public AjaxResult getInfo(@PathVariable("linkId") Long linkId)
    {
        return AjaxResult.success(mallLinkRankingSchoolService.selectMallLinkRankingSchoolByLinkId(linkId));
    }

    /**
     * 新增榜单与学校关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkRankingSchool:add')")
    @Log(title = "榜单与学校关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallLinkRankingSchool mallLinkRankingSchool)
    {
        return toAjax(mallLinkRankingSchoolService.insertMallLinkRankingSchool(mallLinkRankingSchool));
    }

    /**
     * 修改榜单与学校关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkRankingSchool:edit')")
    @Log(title = "榜单与学校关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallLinkRankingSchool mallLinkRankingSchool)
    {
        return toAjax(mallLinkRankingSchoolService.updateMallLinkRankingSchool(mallLinkRankingSchool));
    }

    /**
     * 删除榜单与学校关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkRankingSchool:remove')")
    @Log(title = "榜单与学校关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{linkIds}")
    public AjaxResult remove(@PathVariable Long[] linkIds)
    {
        return toAjax(mallLinkRankingSchoolService.deleteMallLinkRankingSchoolByLinkIds(linkIds));
    }
}
