package com.admin.web.controller.major;

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.admin.common.annotation.Log;
import com.admin.common.core.controller.BaseController;
import com.admin.common.core.domain.AjaxResult;
import com.admin.common.enums.BusinessType;
import com.admin.major.domain.SpecialCourseApply;
import com.admin.major.service.ISpecialCourseApplyService;
import com.admin.common.utils.poi.ExcelUtil;
import com.admin.common.core.page.TableDataInfo;

/**
 * 专业课申请Controller
 * 
 * @author ljx
 * @date 2022-05-12
 */
@RestController
@RequestMapping("/major/SpecialCourseApply")
public class SpecialCourseApplyController extends BaseController
{
    @Autowired
    private ISpecialCourseApplyService specialCourseApplyService;

    /**
     * 查询专业课申请列表
     */
    @PreAuthorize("@ss.hasPermi('major:SpecialCourseApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(SpecialCourseApply specialCourseApply)
    {
        startPage();
        List<SpecialCourseApply> list = specialCourseApplyService.selectSpecialCourseApplyList(specialCourseApply);
        return getDataTable(list);
    }

    /**
     * 导出专业课申请列表
     */
    @PreAuthorize("@ss.hasPermi('major:SpecialCourseApply:export')")
    @Log(title = "专业课申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SpecialCourseApply specialCourseApply)
    {
        List<SpecialCourseApply> list = specialCourseApplyService.selectSpecialCourseApplyList(specialCourseApply);
        ExcelUtil<SpecialCourseApply> util = new ExcelUtil<SpecialCourseApply>(SpecialCourseApply.class);
        util.exportExcel(response, list, "专业课申请数据");
    }

    /**
     * 获取专业课申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('major:SpecialCourseApply:query')")
    @GetMapping(value = "/{specialCourseApplyId}")
    public AjaxResult getInfo(@PathVariable("specialCourseApplyId") Long specialCourseApplyId)
    {
        return AjaxResult.success(specialCourseApplyService.selectSpecialCourseApplyBySpecialCourseApplyId(specialCourseApplyId));
    }

    /**
     * 新增专业课申请
     */
    @PreAuthorize("@ss.hasPermi('major:SpecialCourseApply:add')")
    @Log(title = "专业课申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpecialCourseApply specialCourseApply)
    {
        return toAjax(specialCourseApplyService.insertSpecialCourseApply(specialCourseApply));
    }

    /**
     * 修改专业课申请
     */
    @PreAuthorize("@ss.hasPermi('major:SpecialCourseApply:edit')")
    @Log(title = "专业课申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SpecialCourseApply specialCourseApply)
    {
        return toAjax(specialCourseApplyService.updateSpecialCourseApply(specialCourseApply));
    }

    /**
     * 删除专业课申请
     */
    @PreAuthorize("@ss.hasPermi('major:SpecialCourseApply:remove')")
    @Log(title = "专业课申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{specialCourseApplyIds}")
    public AjaxResult remove(@PathVariable Long[] specialCourseApplyIds)
    {
        return toAjax(specialCourseApplyService.deleteSpecialCourseApplyBySpecialCourseApplyIds(specialCourseApplyIds));
    }
}
