package com.srs.web.controller.teacher;

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.teacher.domain.SysTeacherBasicmessage;
import com.srs.teacher.service.ISysTeacherBasicmessageService;
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;

/**
 * basicMessageController
 *
 * @author srs
 * @date 2024-06-07
 */
@RestController
@RequestMapping("/teacher/basicmessage")
@Api(value = "辅导员基本信息管理", tags = "辅导员基本信息管理")
public class SysTeacherBasicmessageController extends BaseController {
    @Autowired
    private ISysTeacherBasicmessageService sysTeacherBasicmessageService;

    /**
     * 查询basicMessage列表
     */
@PreAuthorize("@ss.hasPermi('teacher:basicmessage:list')")
@GetMapping("/list")
@ApiOperation("查询basicMessage列表")
    public TableDataInfo list(SysTeacherBasicmessage sysTeacherBasicmessage)
    {
        startPage();
        List<SysTeacherBasicmessage> list = sysTeacherBasicmessageService.selectSysTeacherBasicmessageList(sysTeacherBasicmessage);
        return getDataTable(list);
    }

    /**
     * 导出basicMessage列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:basicmessage:export')")
    @Log(title = "basicMessage", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出basicMessage列表")
    public void export(HttpServletResponse response, SysTeacherBasicmessage sysTeacherBasicmessage)
    {
        List<SysTeacherBasicmessage> list = sysTeacherBasicmessageService.selectSysTeacherBasicmessageList(sysTeacherBasicmessage);
        ExcelUtil<SysTeacherBasicmessage> util = new ExcelUtil<SysTeacherBasicmessage>(SysTeacherBasicmessage.class);
        util.exportExcel(response, list, "basicMessage数据");
    }

    /**
     * 获取basicMessage详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:basicmessage:query')")
    @GetMapping(value = "/{teacherId}")
    @ApiOperation("获取basicMessage详细信息")
    public AjaxResult getInfo(@PathVariable("teacherId") Long teacherId)
    {
        return success(sysTeacherBasicmessageService.selectSysTeacherBasicmessageByTeacherId(teacherId));
    }

    /**
     * 新增basicMessage
     */
    @PreAuthorize("@ss.hasPermi('teacher:basicmessage:add')")
    @Log(title = "basicMessage", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增basicMessage")
    public AjaxResult add(@RequestBody SysTeacherBasicmessage sysTeacherBasicmessage)
    {
        return toAjax(sysTeacherBasicmessageService.insertSysTeacherBasicmessage(sysTeacherBasicmessage));
    }

    /**
     * 修改basicMessage
     */
    @PreAuthorize("@ss.hasPermi('teacher:basicmessage:edit')")
    @Log(title = "basicMessage", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改basicMessage")
    public AjaxResult edit(@RequestBody SysTeacherBasicmessage sysTeacherBasicmessage)
    {
        return toAjax(sysTeacherBasicmessageService.updateSysTeacherBasicmessage(sysTeacherBasicmessage));
    }

    /**
     * 删除basicMessage
     */
    @PreAuthorize("@ss.hasPermi('teacher:basicmessage:remove')")
    @Log(title = "basicMessage", businessType = BusinessType.DELETE)
    @PostMapping("/{teacherIds}")
    @ApiOperation("删除basicMessage")
    public AjaxResult remove(@PathVariable Long[] teacherIds)
    {
        return toAjax(sysTeacherBasicmessageService.deleteSysTeacherBasicmessageByTeacherIds(teacherIds));
    }
}
