package com.srs.web.controller.comprehensive;

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

import com.srs.common.core.domain.entity.SysUser;
import com.srs.comprehensive.domain.CphProRanking;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.comprehensive.domain.CphProRankingAll;
import com.srs.comprehensive.service.ICphProRankingAllService;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 总学分绩排名Controller
 *
 * @author srs
 * @date 2025-07-10
 */
@RestController
@RequestMapping("/comprehensive/proRankingAll")
@Api(value = "总学分绩排名管理", tags = "总学分绩排名管理")
public class CphProRankingAllController extends BaseController {
    @Autowired
    private ICphProRankingAllService cphProRankingAllService;

    /**
     * 查询总学分绩排名列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:proRankingAll:list')")
    @GetMapping("/list")
    @ApiOperation("查询总学分绩排名列表")
    public TableDataInfo list(CphProRankingAll cphProRankingAll) {
        startPage();
        List<CphProRankingAll> list = cphProRankingAllService.selectCphProRankingAllList(cphProRankingAll);
        return getDataTable(list);
    }

    /**
     * 导出总学分绩排名列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:proRankingAll:export')")
    @Log(title = "总学分绩排名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出总学分绩排名列表")
    public void export(HttpServletResponse response, CphProRankingAll cphProRankingAll) {
        List<CphProRankingAll> list = cphProRankingAllService.selectCphProRankingAllList(cphProRankingAll);
        ExcelUtil<CphProRankingAll> util = new ExcelUtil<CphProRankingAll>(CphProRankingAll.class);
        util.exportExcel(response, list, "总学分绩排名数据");
    }

    /**
     * 获取总学分绩排名详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:proRankingAll:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取总学分绩排名详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(cphProRankingAllService.selectCphProRankingAllById(id));
    }

    /**
     * 新增总学分绩排名
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:proRankingAll:add')")
    @Log(title = "总学分绩排名", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增总学分绩排名")
    public AjaxResult add(@RequestBody CphProRankingAll cphProRankingAll) {
        return toAjax(cphProRankingAllService.insertCphProRankingAll(cphProRankingAll));
    }

    /**
     * 修改总学分绩排名
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:proRankingAll:edit')")
    @Log(title = "总学分绩排名", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改总学分绩排名")
    public AjaxResult edit(@RequestBody CphProRankingAll cphProRankingAll) {
        return toAjax(cphProRankingAllService.updateCphProRankingAll(cphProRankingAll));
    }

    /**
     * 删除总学分绩排名
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:proRankingAll:remove')")
    @Log(title = "总学分绩排名", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除总学分绩排名")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(cphProRankingAllService.deleteCphProRankingAllByIds(ids));
    }

    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response) {
        ExcelUtil<CphProRankingAll> util = new ExcelUtil<CphProRankingAll>(CphProRankingAll.class);
        util.importTemplateExcel(response, "总平均学分绩数据");
    }

    @PreAuthorize("@ss.hasPermi('comprehensive:proRankingAll:import')")
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file) throws Exception
    {
        ExcelUtil<CphProRankingAll> util = new ExcelUtil<CphProRankingAll>(CphProRankingAll.class);
        List<CphProRankingAll> list = util.importExcel(file.getInputStream());
        String message = cphProRankingAllService.importData(list);
        return success(message);
    }

}
