若依勾选框导出数据
效果图:
package com.ruoyi.web.controller.school;
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.school.domain.SchoolAnomaly;
import com.ruoyi.school.domain.SchoolTeacher;
import com.ruoyi.school.service.ISchoolTeacherService;
import org.apache.commons.lang3.ObjectUtils;
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 zzq
* @date 2023-11-08
*/
@RestController
@RequestMapping("/school/teacher")
public class SchoolTeacherController extends BaseController {
@Autowired
private ISchoolTeacherService schoolTeacherService;
/**
* 查询【请填写功能名称】列表
*/
@PreAuthorize("@ss.hasPermi('school:teacher:list')")
@GetMapping("/list")
public TableDataInfo list(SchoolTeacher schoolTeacher) {
startPage();
List<SchoolTeacher> list = schoolTeacherService.selectSchoolTeacherList(schoolTeacher);
return getDataTable(list);
}
/**
* 导出【请填写功能名称】列表
*/
@PreAuthorize("@ss.hasPermi('school:teacher:export')")
@Log(title = "任课管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SchoolTeacher schoolTeacher) {
if (ObjectUtils.isEmpty(schoolTeacher)) {
return;
}
Integer[] ids = schoolTeacher.getIds();
List<SchoolTeacher> teachers = schoolTeacherService.findSchoolTeachersByIds(ids);
// List<SchoolTeacher> list = schoolTeacherService.selectSchoolTeacherList(schoolTeacher);
ExcelUtil<SchoolTeacher> util = new ExcelUtil<SchoolTeacher>(SchoolTeacher.class);
util.exportExcel(response, teachers, "任课管理信息");
}
/**
* 获取【请填写功能名称】详细信息
*/
@PreAuthorize("@ss.hasPermi('school:teacher:query')")
@GetMapping(value = "/{teacherId}")
public AjaxResult getInfo(@PathVariable("teacherId") Long teacherId) {
return success(schoolTeacherService.selectSchoolTeacherByTeacherId(teacherId));
}
/**
* 新增【请填写功能名称】
*/
@PreAuthorize("@ss.hasPermi('school:teacher:add')")
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SchoolTeacher schoolTeacher) {
return toAjax(schoolTeacherService.insertSchoolTeacher(schoolTeacher));
}
/**
* 修改【请填写功能名称】
*/
@PreAuthorize("@ss.hasPermi('school:teacher:edit')")
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SchoolTeacher schoolTeacher) {
return toAjax(schoolTeacherService.updateSchoolTeacher(schoolTeacher));
}
/**
* 删除【请填写功能名称】
*/
@PreAuthorize("@ss.hasPermi('school:teacher:remove')")
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
@DeleteMapping("/{teacherIds}")
public AjaxResult remove(@PathVariable Long[] teacherIds) {
return toAjax(schoolTeacherService.deleteSchoolTeacherByTeacherIds(teacherIds));
}
}