package com.ruoyi.mall.controller;

import java.util.List;
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.MallSchoolSuggest;
import com.ruoyi.mall.service.IMallSchoolSuggestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 推荐度Controller
 *
 * @author ruoyi
 * @date 2023-10-28
 */
@RestController
@RequestMapping("/mall/mallSchoolSuggest")
public class MallSchoolSuggestController extends BaseController
{
    @Autowired
    private IMallSchoolSuggestService mallSchoolSuggestService;

    /**
     * 查询推荐度列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolSuggest:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallSchoolSuggest mallSchoolSuggest)
    {
        startPage();
        List<MallSchoolSuggest> list = mallSchoolSuggestService.selectMallSchoolSuggestList(mallSchoolSuggest);
        return getDataTable(list);
    }

    /**
     * 导出推荐度列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolSuggest:export')")
    @Log(title = "推荐度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallSchoolSuggest mallSchoolSuggest)
    {
        List<MallSchoolSuggest> list = mallSchoolSuggestService.selectMallSchoolSuggestList(mallSchoolSuggest);
        ExcelUtil<MallSchoolSuggest> util = new ExcelUtil<MallSchoolSuggest>(MallSchoolSuggest.class);
        util.exportExcel(response, list, "推荐度数据");
    }

    /**
     * 获取推荐度详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolSuggest:query')")
    @GetMapping(value = "/{suggestId}")
    public AjaxResult getInfo(@PathVariable("suggestId") Long suggestId)
    {
        return AjaxResult.success(mallSchoolSuggestService.selectMallSchoolSuggestBySuggestId(suggestId));
    }

    /**
     * 新增推荐度
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolSuggest:add')")
    @Log(title = "推荐度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallSchoolSuggest mallSchoolSuggest)
    {
        return toAjax(mallSchoolSuggestService.insertMallSchoolSuggest(mallSchoolSuggest));
    }

    /**
     * 修改推荐度
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolSuggest:edit')")
    @Log(title = "推荐度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallSchoolSuggest mallSchoolSuggest)
    {
        return toAjax(mallSchoolSuggestService.updateMallSchoolSuggest(mallSchoolSuggest));
    }

    /**
     * 删除推荐度
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolSuggest:remove')")
    @Log(title = "推荐度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{suggestIds}")
    public AjaxResult remove(@PathVariable Long[] suggestIds)
    {
        return toAjax(mallSchoolSuggestService.deleteMallSchoolSuggestBySuggestIds(suggestIds));
    }

    /**
     * 推荐度列表
     * @return 结果
     */
    @GetMapping("/selectSuggestList")
    public AjaxResult selectSuggestList(){
        return AjaxResult.success(mallSchoolSuggestService.selectSuggestList());
    }
}
