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

/**
 * 学校硕士点Controller
 * 
 * @author ruoyi
 * @date 2023-10-26
 */
@RestController
@RequestMapping("/mall/mallSchoolMaster")
public class MallSchoolMasterController extends BaseController
{
    @Autowired
    private IMallSchoolMasterService mallSchoolMasterService;

    /**
     * 查询学校硕士点列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMaster:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallSchoolMaster mallSchoolMaster)
    {
        startPage();
        List<MallSchoolMaster> list = mallSchoolMasterService.selectMallSchoolMasterList(mallSchoolMaster);
        return getDataTable(list);
    }

    /**
     * 导出学校硕士点列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMaster:export')")
    @Log(title = "学校硕士点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallSchoolMaster mallSchoolMaster)
    {
        List<MallSchoolMaster> list = mallSchoolMasterService.selectMallSchoolMasterList(mallSchoolMaster);
        ExcelUtil<MallSchoolMaster> util = new ExcelUtil<MallSchoolMaster>(MallSchoolMaster.class);
        util.exportExcel(response, list, "学校硕士点数据");
    }

    /**
     * 获取学校硕士点详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMaster:query')")
    @GetMapping(value = "/{masterId}")
    public AjaxResult getInfo(@PathVariable("masterId") Long masterId)
    {
        return AjaxResult.success(mallSchoolMasterService.selectMallSchoolMasterByMasterId(masterId));
    }

    /**
     * 新增学校硕士点
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMaster:add')")
    @Log(title = "学校硕士点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallSchoolMaster mallSchoolMaster)
    {
        return toAjax(mallSchoolMasterService.insertMallSchoolMaster(mallSchoolMaster));
    }

    /**
     * 修改学校硕士点
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMaster:edit')")
    @Log(title = "学校硕士点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallSchoolMaster mallSchoolMaster)
    {
        return toAjax(mallSchoolMasterService.updateMallSchoolMaster(mallSchoolMaster));
    }

    /**
     * 删除学校硕士点
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolMaster:remove')")
    @Log(title = "学校硕士点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{masterIds}")
    public AjaxResult remove(@PathVariable Long[] masterIds)
    {
        return toAjax(mallSchoolMasterService.deleteMallSchoolMasterByMasterIds(masterIds));
    }
}
