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

/**
 * 报考数据Controller
 * 
 * @author LCL
 * @date 2023-10-24
 */
@RestController
@RequestMapping("/mall/mallExamData")
public class MallExamDataController extends BaseController
{
    @Autowired
    private IMallExamDataService mallExamDataService;

    /**
     * 查询报考数据列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamData:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallExamData mallExamData)
    {
        startPage();
        List<MallExamData> list = mallExamDataService.selectMallExamDataList(mallExamData);
        return getDataTable(list);
    }

    /**
     * 导出报考数据列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamData:export')")
    @Log(title = "报考数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallExamData mallExamData)
    {
        List<MallExamData> list = mallExamDataService.selectMallExamDataList(mallExamData);
        ExcelUtil<MallExamData> util = new ExcelUtil<MallExamData>(MallExamData.class);
        util.exportExcel(response, list, "报考数据数据");
    }

    /**
     * 获取报考数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamData:query')")
    @GetMapping(value = "/{examDataId}")
    public AjaxResult getInfo(@PathVariable("examDataId") Long examDataId)
    {
        return AjaxResult.success(mallExamDataService.selectMallExamDataByExamDataId(examDataId));
    }

    /**
     * 新增报考数据
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamData:add')")
    @Log(title = "报考数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallExamData mallExamData)
    {
        return toAjax(mallExamDataService.insertMallExamData(mallExamData));
    }

    /**
     * 修改报考数据
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamData:edit')")
    @Log(title = "报考数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallExamData mallExamData)
    {
        return toAjax(mallExamDataService.updateMallExamData(mallExamData));
    }

    /**
     * 删除报考数据
     */
    @PreAuthorize("@ss.hasPermi('mall:mallExamData:remove')")
    @Log(title = "报考数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examDataIds}")
    public AjaxResult remove(@PathVariable Long[] examDataIds)
    {
        return toAjax(mallExamDataService.deleteMallExamDataByExamDataIds(examDataIds));
    }
}
