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

/**
 * 招生简章Controller
 * 
 * @author lsm
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/mall/mallSchoolAcceptRules")
public class MallSchoolAcceptRulesController extends BaseController
{
    @Autowired
    private IMallSchoolAcceptRulesService mallSchoolAcceptRulesService;

    /**
     * 查询招生简章列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAcceptRules:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallSchoolAcceptRules mallSchoolAcceptRules)
    {
        startPage();
        List<MallSchoolAcceptRules> list = mallSchoolAcceptRulesService.selectMallSchoolAcceptRulesList(mallSchoolAcceptRules);
        return getDataTable(list);
    }

    /**
     * 导出招生简章列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAcceptRules:export')")
    @Log(title = "招生简章", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallSchoolAcceptRules mallSchoolAcceptRules)
    {
        List<MallSchoolAcceptRules> list = mallSchoolAcceptRulesService.selectMallSchoolAcceptRulesList(mallSchoolAcceptRules);
        ExcelUtil<MallSchoolAcceptRules> util = new ExcelUtil<MallSchoolAcceptRules>(MallSchoolAcceptRules.class);
        util.exportExcel(response, list, "招生简章数据");
    }

    /**
     * 获取招生简章详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAcceptRules:query')")
    @GetMapping(value = "/{acceptRulesId}")
    public AjaxResult getInfo(@PathVariable("acceptRulesId") Long acceptRulesId)
    {
        return AjaxResult.success(mallSchoolAcceptRulesService.selectMallSchoolAcceptRulesByAcceptRulesId(acceptRulesId));
    }

    /**
     * 新增招生简章
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAcceptRules:add')")
    @Log(title = "招生简章", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallSchoolAcceptRules mallSchoolAcceptRules)
    {
        return toAjax(mallSchoolAcceptRulesService.insertMallSchoolAcceptRules(mallSchoolAcceptRules));
    }

    /**
     * 修改招生简章
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAcceptRules:edit')")
    @Log(title = "招生简章", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallSchoolAcceptRules mallSchoolAcceptRules)
    {
        return toAjax(mallSchoolAcceptRulesService.updateMallSchoolAcceptRules(mallSchoolAcceptRules));
    }

    /**
     * 删除招生简章
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolAcceptRules:remove')")
    @Log(title = "招生简章", businessType = BusinessType.DELETE)
	@DeleteMapping("/{acceptRulesIds}")
    public AjaxResult remove(@PathVariable Long[] acceptRulesIds)
    {
        return toAjax(mallSchoolAcceptRulesService.deleteMallSchoolAcceptRulesByAcceptRulesIds(acceptRulesIds));
    }
}
