package com.srs.web.controller.comprehensive;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.CphScienceScore;
import com.srs.comprehensive.service.ICphScienceScoreService;
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;

/**
 * 学生课程成绩Controller
 *
 * @author srs
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/comprehensive/scienceScore")
@Api(value = "学生课程成绩管理", tags = "学生课程成绩管理")
public class CphScienceScoreController extends BaseController {
    @Autowired
    private ICphScienceScoreService cphScienceScoreService;

    /**
     * 查询学生课程成绩列表
     */
@PreAuthorize("@ss.hasPermi('comprehensive:scienceScore:list')")
@GetMapping("/list")
@ApiOperation("查询学生课程成绩列表")
    public TableDataInfo list(CphScienceScore cphScienceScore)
    {
        startPage();
        List<CphScienceScore> list = cphScienceScoreService.selectCphScienceScoreList(cphScienceScore);
        return getDataTable(list);
    }

    /**
     * 导出学生课程成绩列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:scienceScore:export')")
    @Log(title = "学生课程成绩", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出学生课程成绩列表")
    public void export(HttpServletResponse response, CphScienceScore cphScienceScore)
    {
        List<CphScienceScore> list = cphScienceScoreService.selectCphScienceScoreList(cphScienceScore);
        ExcelUtil<CphScienceScore> util = new ExcelUtil<CphScienceScore>(CphScienceScore.class);
        util.exportExcel(response, list, "学生课程成绩数据");
    }

    /**
     * 获取学生课程成绩详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:scienceScore:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取学生课程成绩详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cphScienceScoreService.selectCphScienceScoreById(id));
    }

    /**
     * 新增学生课程成绩
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:scienceScore:add')")
    @Log(title = "学生课程成绩", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增学生课程成绩")
    public AjaxResult add(@RequestBody CphScienceScore cphScienceScore)
    {
        return toAjax(cphScienceScoreService.insertCphScienceScore(cphScienceScore));
    }

    /**
     * 修改学生课程成绩
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:scienceScore:edit')")
    @Log(title = "学生课程成绩", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改学生课程成绩")
    public AjaxResult edit(@RequestBody CphScienceScore cphScienceScore)
    {
        return toAjax(cphScienceScoreService.updateCphScienceScore(cphScienceScore));
    }

    /**
     * 删除学生课程成绩
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:scienceScore:remove')")
    @Log(title = "学生课程成绩", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除学生课程成绩")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cphScienceScoreService.deleteCphScienceScoreByIds(ids));
    }
}
