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.SysTeacherWorkexample;
import com.srs.teacher.service.ISysTeacherWorkexampleService;
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;

/**
 * workexampleController
 *
 * @author srs
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/teacher/workexample")
@Api(value = "workexample管理", tags = "workexample管理")
public class SysTeacherWorkexampleController extends BaseController {
    @Autowired
    private ISysTeacherWorkexampleService sysTeacherWorkexampleService;

    /**
     * 查询workexample列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:workexample:list')")
    @GetMapping("/list")
    @ApiOperation("查询workexample列表")
    public TableDataInfo list(SysTeacherWorkexample sysTeacherWorkexample) {
        startPage();
        List<SysTeacherWorkexample> list = sysTeacherWorkexampleService.selectSysTeacherWorkexampleList(sysTeacherWorkexample);
        return getDataTable(list);
    }

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

    /**
     * 获取workexample详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:workexample:query')")
    @GetMapping(value = "/{workexampleId}")
    @ApiOperation("获取workexample详细信息")
    public AjaxResult getInfo(@PathVariable("workexampleId") Long workexampleId) {
        return success(sysTeacherWorkexampleService.selectSysTeacherWorkexampleByWorkexampleId(workexampleId));
    }

    /**
     * 新增workexample
     */
    @PreAuthorize("@ss.hasPermi('teacher:workexample:add')")
    @Log(title = "workexample", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增workexample")
    public AjaxResult add(@RequestBody SysTeacherWorkexample sysTeacherWorkexample) {
        return toAjax(sysTeacherWorkexampleService.insertSysTeacherWorkexample(sysTeacherWorkexample));
    }

    /**
     * 修改workexample
     */
    @PreAuthorize("@ss.hasPermi('teacher:workexample:edit')")
    @Log(title = "workexample", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改workexample")
    public AjaxResult edit(@RequestBody SysTeacherWorkexample sysTeacherWorkexample) {
        return toAjax(sysTeacherWorkexampleService.updateSysTeacherWorkexample(sysTeacherWorkexample));
    }

    /**
     * 删除workexample
     */
    @PreAuthorize("@ss.hasPermi('teacher:workexample:remove')")
    @Log(title = "workexample", businessType = BusinessType.DELETE)
    @PostMapping("/{workexampleIds}")

    @ApiOperation("删除workexample")
    public AjaxResult remove(@PathVariable Long[] workexampleIds) {
        return toAjax(sysTeacherWorkexampleService.deleteSysTeacherWorkexampleByWorkexampleIds(workexampleIds));
    }
}
