package com.srs.web.controller.comprehensive;

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

import com.srs.common.annotation.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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 com.srs.comprehensive.domain.CphCarders;
import com.srs.comprehensive.service.ICphCardersService;
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.core.page.TableDataInfo;

/**
 * 班级干部管理Controller
 *
 * @author srs
 * @date 2023-09-15
 */
@RestController
@RequestMapping("/comprehensive/carders")
@Api(value = "班级干部管理管理", tags = "班级干部管理管理")
public class CphCardersController extends BaseController {
    @Autowired
    private ICphCardersService cphCardersService;

    /**
     * 查询班级干部管理列表
     */
//@PreAuthorize("@ss.hasPermi('comprehensive:carders:list')")
@GetMapping("/list")
@ApiOperation("查询班级干部管理列表")
    public TableDataInfo list(CphCarders cphCarders)
    {
        startPage();
        List<CphCarders> list = cphCardersService.selectCphCardersList(cphCarders);
        return getDataTable(list);
    }

    /**
     * 导出班级干部管理列表
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:carders:export')")
    @Log(title = "班级干部管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出班级干部管理列表")
    public void export(HttpServletResponse response, CphCarders cphCarders)
    {
        List<CphCarders> list = cphCardersService.selectCphCardersList(cphCarders);
        ExcelUtil<CphCarders> util = new ExcelUtil<CphCarders>(CphCarders.class);
        util.exportExcel(response, list, "班级干部管理数据");
    }

    /**
     * 获取班级干部管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:carders:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取班级干部管理详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cphCardersService.selectCphCardersById(id));
    }

    /**
     * 新增班级干部管理
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:carders:add')")
    @Log(title = "班级干部管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增班级干部管理")
    public AjaxResult add(@RequestBody CphCarders cphCarders)
    {
        return toAjax(cphCardersService.insertCphCarders(cphCarders));
    }

    /**
     * 修改班级干部管理
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:carders:edit')")
    @Log(title = "班级干部管理", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改班级干部管理")
    public AjaxResult edit(@RequestBody CphCarders cphCarders)
    {
        return toAjax(cphCardersService.updateCphCarders(cphCarders));
    }

    /**
     * 删除班级干部管理
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:carders:remove')")
    @Log(title = "班级干部管理", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除班级干部管理")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cphCardersService.deleteCphCardersByIds(ids));
    }
}
