package com.admin.web.controller.major;

import com.admin.common.annotation.Log;
import com.admin.common.core.controller.BaseController;
import com.admin.common.core.domain.AjaxResult;
import com.admin.common.core.page.TableDataInfo;
import com.admin.common.enums.BusinessType;
import com.admin.common.utils.poi.ExcelUtil;
import com.admin.major.domain.SummaryApply;
import com.admin.major.domain.dto.SummaryApplyDTO;
import com.admin.major.service.ISummaryApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 学生志愿填报情况汇总Controller
 * 
 * @author zewei
 * @date 2022-03-30
 */
@RestController
@RequestMapping("/summaryApply/summaryApply")
public class SummaryApplyController extends BaseController
{
    @Autowired
    private ISummaryApplyService summaryApplyService;

    /**
     * 查询学生志愿填报情况汇总列表
     */
    @PreAuthorize("@ss.hasPermi('summaryApply:summaryApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(SummaryApplyDTO summaryApply)
    {
        startPage();
        List<SummaryApplyDTO> list = summaryApplyService.viewSummaryApply(summaryApply);
        return getDataTable(list);
    }

    /**
     * 获取学生志愿填报情况汇总详细信息
     */
    @PreAuthorize("@ss.hasPermi('summaryApply:summaryApply:query')")
    @GetMapping(value = "/{studentNo}")
    public AjaxResult getInfo(@PathVariable("studentNo") String studentNo)
    {
        return AjaxResult.success(summaryApplyService.selectSummaryApplyByStudentNo(studentNo));
    }

    /**
     * 导出学生志愿填报情况汇总列表
     */
    @PreAuthorize("@ss.hasPermi('summaryApply:summaryApply:export')")
    @Log(title = "学生志愿填报情况汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SummaryApplyDTO summaryApply)
    {
        List<SummaryApplyDTO> list = summaryApplyService.viewSummaryApply(summaryApply);
        ExcelUtil<SummaryApplyDTO> util = new ExcelUtil<SummaryApplyDTO>(SummaryApplyDTO.class);
        util.exportExcel(response, list, "学生志愿填报情况汇总数据");
    }

    /**
     * 修改学生志愿填报情况汇总
     */
    @PreAuthorize("@ss.hasPermi('summaryApply:summaryApply:edit')")
    @Log(title = "学生志愿填报情况汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SummaryApplyDTO summaryApplyDTO)
    {
        return toAjax(summaryApplyService.updateSummaryApply(summaryApplyDTO));
    }

}
