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

/**
 * 学校保研记录Controller
 * 
 * @author ruoyi
 * @date 2023-10-26
 */
@RestController
@RequestMapping("/mall/mallSchoolMasterRecord")
public class MallSchoolMasterRecordController extends BaseController
{
    @Autowired
    private IMallSchoolMasterRecordService mallSchoolMasterRecordService;

    /**
     * 查询学校保研记录列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMasterRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallSchoolMasterRecord mallSchoolMasterRecord)
    {
        startPage();
        List<MallSchoolMasterRecord> list = mallSchoolMasterRecordService.selectMallSchoolMasterRecordList(mallSchoolMasterRecord);
        return getDataTable(list);
    }

    /**
     * 导出学校保研记录列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMasterRecord:export')")
    @Log(title = "学校保研记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallSchoolMasterRecord mallSchoolMasterRecord)
    {
        List<MallSchoolMasterRecord> list = mallSchoolMasterRecordService.selectMallSchoolMasterRecordList(mallSchoolMasterRecord);
        ExcelUtil<MallSchoolMasterRecord> util = new ExcelUtil<MallSchoolMasterRecord>(MallSchoolMasterRecord.class);
        util.exportExcel(response, list, "学校保研记录数据");
    }

    /**
     * 获取学校保研记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMasterRecord:query')")
    @GetMapping(value = "/{masterRecordId}")
    public AjaxResult getInfo(@PathVariable("masterRecordId") Long masterRecordId)
    {
        return AjaxResult.success(mallSchoolMasterRecordService.selectMallSchoolMasterRecordByMasterRecordId(masterRecordId));
    }

    /**
     * 新增学校保研记录
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMasterRecord:add')")
    @Log(title = "学校保研记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallSchoolMasterRecord mallSchoolMasterRecord)
    {
        return toAjax(mallSchoolMasterRecordService.insertMallSchoolMasterRecord(mallSchoolMasterRecord));
    }

    /**
     * 修改学校保研记录
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMasterRecord:edit')")
    @Log(title = "学校保研记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallSchoolMasterRecord mallSchoolMasterRecord)
    {
        return toAjax(mallSchoolMasterRecordService.updateMallSchoolMasterRecord(mallSchoolMasterRecord));
    }

    /**
     * 删除学校保研记录
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMasterRecord:remove')")
    @Log(title = "学校保研记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{masterRecordIds}")
    public AjaxResult remove(@PathVariable Long[] masterRecordIds)
    {
        return toAjax(mallSchoolMasterRecordService.deleteMallSchoolMasterRecordByMasterRecordIds(masterRecordIds));
    }
}
