package com.ruoyi.web.controller.register;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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 com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RegisterTeacher;
import com.ruoyi.system.service.IRegisterTeacherService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 注册-老师Controller
 * 
 * @author ruoyi
 * @date 2023-05-25
 */
@RestController
@RequestMapping("/register/teacher")
public class RegisterTeacherController extends BaseController
{
    @Autowired
    private IRegisterTeacherService registerTeacherService;

    /**
     * 查询注册-老师列表
     */
    @PreAuthorize("@ss.hasPermi('register:teacher:list')")
    @GetMapping("/list")
    public TableDataInfo list(RegisterTeacher registerTeacher)
    {
        startPage();
        List<RegisterTeacher> list = registerTeacherService.selectRegisterTeacherList(registerTeacher);
        return getDataTable(list);
    }

    /**
     * 导出注册-老师列表
     */
    @PreAuthorize("@ss.hasPermi('register:teacher:export')")
    @Log(title = "注册-老师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RegisterTeacher registerTeacher)
    {
        List<RegisterTeacher> list = registerTeacherService.selectRegisterTeacherList(registerTeacher);
        ExcelUtil<RegisterTeacher> util = new ExcelUtil<RegisterTeacher>(RegisterTeacher.class);
        util.exportExcel(response, list, "注册-老师数据");
    }

    /**
     * 获取注册-老师详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(registerTeacherService.selectRegisterTeacherById(id));
    }

    /**
     * 新增注册-老师
     */
    @Log(title = "注册-老师", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RegisterTeacher registerTeacher)
    {
        return registerTeacherService.insertRegisterTeacher(registerTeacher);
    }

    /**
     * 修改注册-老师
     */
    @Log(title = "注册-老师", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody RegisterTeacher registerTeacher)
    {
        return toAjax(registerTeacherService.updateRegisterTeacher(registerTeacher));
    }

    /**
     * 删除注册-老师
     */
    @PreAuthorize("@ss.hasPermi('register:teacher:remove')")
    @Log(title = "注册-老师", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(registerTeacherService.deleteRegisterTeacherByIds(ids));
    }
}
