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

/**
 * 招生计划Controller
 * 
 * @author Lsm
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/mall/mallAcceptPlan")
public class MallAcceptPlanController extends BaseController
{
    @Autowired
    private IMallAcceptPlanService mallAcceptPlanService;

    /**
     * 查询招生计划列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAcceptPlan:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallAcceptPlan mallAcceptPlan)
    {
        startPage();
        List<MallAcceptPlan> list = mallAcceptPlanService.selectMallAcceptPlanList(mallAcceptPlan);
        return getDataTable(list);
    }

    /**
     * 导出招生计划列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAcceptPlan:export')")
    @Log(title = "招生计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallAcceptPlan mallAcceptPlan)
    {
        List<MallAcceptPlan> list = mallAcceptPlanService.selectMallAcceptPlanList(mallAcceptPlan);
        ExcelUtil<MallAcceptPlan> util = new ExcelUtil<MallAcceptPlan>(MallAcceptPlan.class);
        util.exportExcel(response, list, "招生计划数据");
    }

    /**
     * 获取招生计划详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAcceptPlan:query')")
    @GetMapping(value = "/{acceptPlanId}")
    public AjaxResult getInfo(@PathVariable("acceptPlanId") Long acceptPlanId)
    {
        return AjaxResult.success(mallAcceptPlanService.selectMallAcceptPlanByAcceptPlanId(acceptPlanId));
    }

    /**
     * 新增招生计划
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAcceptPlan:add')")
    @Log(title = "招生计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallAcceptPlan mallAcceptPlan)
    {
        return toAjax(mallAcceptPlanService.insertMallAcceptPlan(mallAcceptPlan));
    }

    /**
     * 修改招生计划
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAcceptPlan:edit')")
    @Log(title = "招生计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallAcceptPlan mallAcceptPlan)
    {
        return toAjax(mallAcceptPlanService.updateMallAcceptPlan(mallAcceptPlan));
    }

    /**
     * 删除招生计划
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAcceptPlan:remove')")
    @Log(title = "招生计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{acceptPlanIds}")
    public AjaxResult remove(@PathVariable Long[] acceptPlanIds)
    {
        return toAjax(mallAcceptPlanService.deleteMallAcceptPlanByAcceptPlanIds(acceptPlanIds));
    }
}
