package com.srs.web.controller.routine;

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.routine.domain.RtClassMettingHeld;
import com.srs.routine.service.IRtClassMettingHeldService;
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 LSD
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/routine/classMettingHeld")
@Api(value = "辅导员班会管理", tags = "辅导员班会管理")
public class RtClassMettingHeldController extends BaseController {
    @Autowired
    private IRtClassMettingHeldService rtClassMettingHeldService;


    @PreAuthorize("@ss.hasPermi('routine:classMettingHeld:listXg')")
    @GetMapping("/listXg")
    @ApiOperation("学工查询辅导员自设班会列表")
    public TableDataInfo listXg(RtClassMettingHeld rtClassMettingHeld)
    {
        startPage();
        List<RtClassMettingHeld> list = rtClassMettingHeldService.listView(rtClassMettingHeld);
        return getDataTable(list);
    }

    @GetMapping("/listFdy")
    @ApiOperation("辅导员查询辅导员自设班会列表")
    public TableDataInfo listFdy(RtClassMettingHeld rtClassMettingHeld)
    {
        rtClassMettingHeld.tNo = getUsername();
        startPage();
        List<RtClassMettingHeld> list = rtClassMettingHeldService.listView(rtClassMettingHeld);
        return getDataTable(list);
    }

    @PostMapping("/fdyAdd")
    @ApiOperation("查询辅导员班会列表")
    public AjaxResult fdyAdd(@RequestBody RtClassMettingHeld param){
        return rtClassMettingHeldService.fdyAdd(param);
    }


    /**
     * 查询辅导员班会列表
     */
    @PreAuthorize("@ss.hasPermi('routine:classMettingHeld:list')")
    @GetMapping("/list")
    @ApiOperation("查询辅导员班会列表")
    public TableDataInfo list(RtClassMettingHeld rtClassMettingHeld)
    {
        startPage();
        List<RtClassMettingHeld> list = rtClassMettingHeldService.selectRtClassMettingHeldList(rtClassMettingHeld);
        return getDataTable(list);
    }

    /**
     * 导出辅导员班会列表
     */
    @PreAuthorize("@ss.hasPermi('routine:classMettingHeld:export')")
    @Log(title = "辅导员班会", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出辅导员班会列表")
    public void export(HttpServletResponse response, RtClassMettingHeld rtClassMettingHeld)
    {
        List<RtClassMettingHeld> list = rtClassMettingHeldService.selectRtClassMettingHeldList(rtClassMettingHeld);
        ExcelUtil<RtClassMettingHeld> util = new ExcelUtil<RtClassMettingHeld>(RtClassMettingHeld.class);
        util.exportExcel(response, list, "辅导员班会数据");
    }

    /**
     * 获取辅导员班会详细信息
     */
    @PreAuthorize("@ss.hasPermi('routine:classMettingHeld:query')")
    @GetMapping(value = "/{cmhId}")
    @ApiOperation("获取辅导员班会详细信息")
    public AjaxResult getInfo(@PathVariable("cmhId") Long cmhId)
    {
        return success(rtClassMettingHeldService.selectRtClassMettingHeldByCmhId(cmhId));
    }

    /**
     * 新增辅导员班会
     */
    @PreAuthorize("@ss.hasPermi('routine:classMettingHeld:add')")
    @Log(title = "辅导员班会", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增辅导员班会")
    public AjaxResult add(@RequestBody RtClassMettingHeld rtClassMettingHeld)
    {
        return toAjax(rtClassMettingHeldService.insertRtClassMettingHeld(rtClassMettingHeld));
    }

    /**
     * 修改辅导员班会
     */
    @PreAuthorize("@ss.hasPermi('routine:classMettingHeld:edit')")
    @Log(title = "辅导员班会", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改辅导员班会")
    public AjaxResult edit(@RequestBody RtClassMettingHeld rtClassMettingHeld)
    {
        return toAjax(rtClassMettingHeldService.updateRtClassMettingHeld(rtClassMettingHeld));
    }

    /**
     * 删除辅导员班会
     */
    @PreAuthorize("@ss.hasPermi('routine:classMettingHeld:remove')")
    @Log(title = "辅导员班会", businessType = BusinessType.DELETE)
    @PostMapping("/{cmhIds}")
    @ApiOperation("删除辅导员班会")
    public AjaxResult remove(@PathVariable Long[] cmhIds)
    {
        return toAjax(rtClassMettingHeldService.deleteRtClassMettingHeldByCmhIds(cmhIds));
    }
}
