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.SysDisMate;
import com.srs.routine.service.ISysDisMateService;
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 2025-10-28
 */
@RestController
@RequestMapping("/routine/mate")
@Api(value = "退伍复学材料管理", tags = "退伍复学材料管理")
public class SysDisMateController extends BaseController {
    @Autowired
    private ISysDisMateService sysDisMateService;

    /**
     * 查询退伍复学材料列表
     */
@PreAuthorize("@ss.hasPermi('routine:mate:list')")
@GetMapping("/list")
@ApiOperation("查询退伍复学材料列表")
    public TableDataInfo list(SysDisMate sysDisMate)
    {
        startPage();
        List<SysDisMate> list = sysDisMateService.selectSysDisMateList(sysDisMate);
        return getDataTable(list);
    }

    /**
     * 导出退伍复学材料列表
     */
    @PreAuthorize("@ss.hasPermi('routine:mate:export')")
    @Log(title = "退伍复学材料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出退伍复学材料列表")
    public void export(HttpServletResponse response, SysDisMate sysDisMate)
    {
        List<SysDisMate> list = sysDisMateService.selectSysDisMateList(sysDisMate);
        ExcelUtil<SysDisMate> util = new ExcelUtil<SysDisMate>(SysDisMate.class);
        util.exportExcel(response, list, "退伍复学材料数据");
    }

    /**
     * 获取退伍复学材料详细信息
     */
    @PreAuthorize("@ss.hasPermi('routine:mate:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取退伍复学材料详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysDisMateService.selectSysDisMateById(id));
    }

    /**
     * 新增退伍复学材料
     */
    @PreAuthorize("@ss.hasPermi('routine:mate:add')")
    @Log(title = "退伍复学材料", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增退伍复学材料")
    public AjaxResult add(@RequestBody SysDisMate sysDisMate)
    {
        return toAjax(sysDisMateService.insertSysDisMate(sysDisMate));
    }

    /**
     * 修改退伍复学材料
     */
    @PreAuthorize("@ss.hasPermi('routine:mate:edit')")
    @Log(title = "退伍复学材料", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改退伍复学材料")
    public AjaxResult edit(@RequestBody SysDisMate sysDisMate)
    {
        return toAjax(sysDisMateService.updateSysDisMate(sysDisMate));
    }

    /**
     * 删除退伍复学材料
     */
    @PreAuthorize("@ss.hasPermi('routine:mate:remove')")
    @Log(title = "退伍复学材料", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除退伍复学材料")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysDisMateService.deleteSysDisMateByIds(ids));
    }
}
