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

/**
 * 评估分类Controller
 *
 * @author lsm
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/mall/mallSchoolAppraiseClass")
public class MallSchoolAppraiseClassController extends BaseController
{
    @Autowired
    private IMallSchoolAppraiseClassService mallSchoolAppraiseClassService;

    /**
     * 查询评估分类列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAppraiseClass:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallSchoolAppraiseClass mallSchoolAppraiseClass)
    {
        startPage();
        List<MallSchoolAppraiseClass> list = mallSchoolAppraiseClassService.selectMallSchoolAppraiseClassList(mallSchoolAppraiseClass);
        return getDataTable(list);
    }

    /**
     * 导出评估分类列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAppraiseClass:export')")
    @Log(title = "评估分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallSchoolAppraiseClass mallSchoolAppraiseClass)
    {
        List<MallSchoolAppraiseClass> list = mallSchoolAppraiseClassService.selectMallSchoolAppraiseClassList(mallSchoolAppraiseClass);
        ExcelUtil<MallSchoolAppraiseClass> util = new ExcelUtil<MallSchoolAppraiseClass>(MallSchoolAppraiseClass.class);
        util.exportExcel(response, list, "评估分类数据");
    }

    /**
     * 获取评估分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAppraiseClass:query')")
    @GetMapping(value = "/{appraiseClassId}")
    public AjaxResult getInfo(@PathVariable("appraiseClassId") Long appraiseClassId)
    {
        return AjaxResult.success(mallSchoolAppraiseClassService.selectMallSchoolAppraiseClassByAppraiseClassId(appraiseClassId));
    }

    /**
     * 新增评估分类
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAppraiseClass:add')")
    @Log(title = "评估分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallSchoolAppraiseClass mallSchoolAppraiseClass)
    {
        return toAjax(mallSchoolAppraiseClassService.insertMallSchoolAppraiseClass(mallSchoolAppraiseClass));
    }

    /**
     * 修改评估分类
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAppraiseClass:edit')")
    @Log(title = "评估分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallSchoolAppraiseClass mallSchoolAppraiseClass)
    {
        return toAjax(mallSchoolAppraiseClassService.updateMallSchoolAppraiseClass(mallSchoolAppraiseClass));
    }

    /**
     * 删除评估分类
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAppraiseClass:remove')")
    @Log(title = "评估分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{appraiseClassIds}")
    public AjaxResult remove(@PathVariable Long[] appraiseClassIds)
    {
        return toAjax(mallSchoolAppraiseClassService.deleteMallSchoolAppraiseClassByAppraiseClassIds(appraiseClassIds));
    }

    /**
     * 评估分类列表
     * @return 结果
     */
    @GetMapping("/selectAppraiseClassList")
    public AjaxResult selectAppraiseClassList(){
        return AjaxResult.success(mallSchoolAppraiseClassService.selectAppraiseClassList());
    }
}
