package com.srs.web.controller.comprehensive;

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

import com.srs.comprehensive.domain.CphCardersStudent;
import com.srs.comprehensive.service.ICphCardersStudentService;
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.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 2023-09-15
 */
@RestController
@RequestMapping("/comprehensive/studentCadre")
@Api(value = "学生干部关联管理", tags = "学生干部关联管理")
public class CphCardersStudentController extends BaseController {
    @Autowired
    private ICphCardersStudentService cphCardersStudentService;

    /**
     * 查询学生干部关联列表
     */
//@PreAuthorize("@ss.hasPermi('system:student:list')")
@GetMapping("/list")
@ApiOperation("查询学生干部关联列表")
    public TableDataInfo list(CphCardersStudent cphCardersStudent)
    {
        startPage();
        List<CphCardersStudent> list = cphCardersStudentService.selectCphCardersStudentList(cphCardersStudent);
        return getDataTable(list);
    }

    /**
     * 导出学生干部关联列表
     */
//    @PreAuthorize("@ss.hasPermi('system:student:export')")
    @Log(title = "学生干部关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出学生干部关联列表")
    public void export(HttpServletResponse response, CphCardersStudent cphCardersStudent)
    {
        List<CphCardersStudent> list = cphCardersStudentService.selectCphCardersStudentList(cphCardersStudent);
        ExcelUtil<CphCardersStudent> util = new ExcelUtil<CphCardersStudent>(CphCardersStudent.class);
        util.exportExcel(response, list, "学生干部关联数据");
    }

    /**
     * 获取学生干部关联详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:student:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取学生干部关联详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cphCardersStudentService.selectCphCardersStudentById(id));
    }

    /**
     * 新增学生干部关联
     */
//    @PreAuthorize("@ss.hasPermi('system:student:add')")
    @Log(title = "学生干部关联", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增学生干部关联")
    public AjaxResult add(@RequestBody CphCardersStudent cphCardersStudent)
    {
        return toAjax(cphCardersStudentService.insertCphCardersStudent(cphCardersStudent));
    }

    /**
     * 修改学生干部关联
     */
//    @PreAuthorize("@ss.hasPermi('system:student:edit')")
    @Log(title = "学生干部关联", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改学生干部关联")
    public AjaxResult edit(@RequestBody CphCardersStudent cphCardersStudent)
    {
        return toAjax(cphCardersStudentService.updateCphCardersStudent(cphCardersStudent));
    }

    /**
     * 删除学生干部关联
     */
//    @PreAuthorize("@ss.hasPermi('system:student:remove')")
    @Log(title = "学生干部关联", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除学生干部关联")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cphCardersStudentService.deleteCphCardersStudentByIds(ids));
    }
}
