package com.ruoyi.hezhi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.hezhi.domain.TbTeacherAuthentication;
import com.ruoyi.hezhi.service.ITbTeacherAuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 名师认证Controller
 *
 * @author ruoyi
 * @date 2024-12-13
 */
@RestController
@RequestMapping("/hezhi/tbTeacherAuthentication")
public class TbTeacherAuthenticationController extends BaseController
{
    @Autowired
    private ITbTeacherAuthenticationService tbTeacherAuthenticationService;

    /**
     * 查询名师认证列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:tbTeacherAuthentication:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbTeacherAuthentication tbTeacherAuthentication)
    {
        startPage();
        List<TbTeacherAuthentication> list = tbTeacherAuthenticationService.selectTbTeacherAuthenticationList(tbTeacherAuthentication);
        return getDataTable(list);
    }

    /**
     * 导出名师认证列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:tbTeacherAuthentication:export')")
    @Log(title = "名师认证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbTeacherAuthentication tbTeacherAuthentication)
    {
        List<TbTeacherAuthentication> list = tbTeacherAuthenticationService.selectTbTeacherAuthenticationList(tbTeacherAuthentication);
        ExcelUtil<TbTeacherAuthentication> util = new ExcelUtil<TbTeacherAuthentication>(TbTeacherAuthentication.class);
        util.exportExcel(response, list, "名师认证数据");
    }

    /**
     * 获取名师认证详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:tbTeacherAuthentication:query')")
    @GetMapping(value = "/{teacherAuthenticationId}")
    public AjaxResult getInfo(@PathVariable("teacherAuthenticationId") Long teacherAuthenticationId)
    {
        return success(tbTeacherAuthenticationService.selectTbTeacherAuthenticationByTeacherAuthenticationId(teacherAuthenticationId));
    }

    /**
     * 新增名师认证
     */
    @PreAuthorize("@ss.hasPermi('hezhi:tbTeacherAuthentication:add')")
    @Log(title = "名师认证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbTeacherAuthentication tbTeacherAuthentication)
    {
        return toAjax(tbTeacherAuthenticationService.insertTbTeacherAuthentication(tbTeacherAuthentication));
    }

    /**
     * 修改名师认证
     */
    @PreAuthorize("@ss.hasPermi('hezhi:tbTeacherAuthentication:edit')")
    @Log(title = "名师认证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbTeacherAuthentication tbTeacherAuthentication)
    {
        return toAjax(tbTeacherAuthenticationService.updateTbTeacherAuthentication(tbTeacherAuthentication));
    }

    /**
     * 删除名师认证
     */
    @PreAuthorize("@ss.hasPermi('hezhi:tbTeacherAuthentication:remove')")
    @Log(title = "名师认证", businessType = BusinessType.DELETE)
	@DeleteMapping("/{teacherAuthenticationIds}")
    public AjaxResult remove(@PathVariable Long[] teacherAuthenticationIds)
    {
        return toAjax(tbTeacherAuthenticationService.deleteTbTeacherAuthenticationByTeacherAuthenticationIds(teacherAuthenticationIds));
    }
}
