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

/**
 * 校考院校Controller
 * 
 * @author ruoyi
 * @date 2023-11-01
 */
@RestController
@RequestMapping("/mall/mallTestSchool")
public class MallTestSchoolController extends BaseController
{
    @Autowired
    private IMallTestSchoolService mallTestSchoolService;

    /**
     * 查询校考院校列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTestSchool:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallTestSchool mallTestSchool)
    {
        startPage();
        List<MallTestSchool> list = mallTestSchoolService.selectMallTestSchoolList(mallTestSchool);
        return getDataTable(list);
    }

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

    /**
     * 获取校考院校详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTestSchool:query')")
    @GetMapping(value = "/{testSchoolId}")
    public AjaxResult getInfo(@PathVariable("testSchoolId") Long testSchoolId)
    {
        return AjaxResult.success(mallTestSchoolService.selectMallTestSchoolByTestSchoolId(testSchoolId));
    }

    /**
     * 新增校考院校
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTestSchool:add')")
    @Log(title = "校考院校", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallTestSchool mallTestSchool)
    {
        return toAjax(mallTestSchoolService.insertMallTestSchool(mallTestSchool));
    }

    /**
     * 修改校考院校
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTestSchool:edit')")
    @Log(title = "校考院校", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallTestSchool mallTestSchool)
    {
        return toAjax(mallTestSchoolService.updateMallTestSchool(mallTestSchool));
    }

    /**
     * 删除校考院校
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTestSchool:remove')")
    @Log(title = "校考院校", businessType = BusinessType.DELETE)
	@DeleteMapping("/{testSchoolIds}")
    public AjaxResult remove(@PathVariable Long[] testSchoolIds)
    {
        return toAjax(mallTestSchoolService.deleteMallTestSchoolByTestSchoolIds(testSchoolIds));
    }
}
