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

/**
 * 联考一分一段Controller
 *
 * @author LCL
 * @date 2023-10-23
 */
@RestController
@RequestMapping("/mall/mallExamSection")
public class MallExamSectionController extends BaseController
{
    @Resource
    private IMallExamSectionService mallExamSectionService;

    /**
     * 查询联考一分一段列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamSection:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallExamSection mallExamSection)
    {
        startPage();
        List<MallExamSection> list = mallExamSectionService.selectMallExamSectionList(mallExamSection);
        return getDataTable(list);
    }

    /**
     * 导出联考一分一段列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamSection:export')")
    @Log(title = "联考一分一段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallExamSection mallExamSection)
    {
        List<MallExamSection> list = mallExamSectionService.selectMallExamSectionList(mallExamSection);
        ExcelUtil<MallExamSection> util = new ExcelUtil<MallExamSection>(MallExamSection.class);
        util.exportExcel(response, list, "联考一分一段数据");
    }

    /**
     * 获取联考一分一段详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamSection:query')")
    @GetMapping(value = "/{sectionId}")
    public AjaxResult getInfo(@PathVariable("sectionId") Long sectionId)
    {
        return AjaxResult.success(mallExamSectionService.selectMallExamSectionBySectionId(sectionId));
    }

    /**
     * 新增联考一分一段
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamSection:add')")
    @Log(title = "联考一分一段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallExamSection mallExamSection)
    {
        return toAjax(mallExamSectionService.insertMallExamSection(mallExamSection));
    }

    /**
     * 修改联考一分一段
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamSection:edit')")
    @Log(title = "联考一分一段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallExamSection mallExamSection)
    {
        return toAjax(mallExamSectionService.updateMallExamSection(mallExamSection));
    }

    /**
     * 删除联考一分一段
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamSection:remove')")
    @Log(title = "联考一分一段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sectionIds}")
    public AjaxResult remove(@PathVariable Long[] sectionIds)
    {
        return toAjax(mallExamSectionService.deleteMallExamSectionBySectionIds(sectionIds));
    }
}
