123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- package com.kgraph.web.controller;
- import java.io.IOException;
- import java.util.List;
- import javax.servlet.http.HttpServletResponse;
- import com.kgraph.common.service.IFileService;
- import com.kgraph.common.utils.file.FileUtils;
- 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.kgraph.common.annotation.Log;;
- import com.kgraph.common.core.controller.BaseController;;
- import com.kgraph.common.core.domain.AjaxResult;;
- import com.kgraph.common.enums.BusinessType;;
- import com.kgraph.web.domain.TextbookDoc;
- import com.kgraph.web.service.ITextbookDocService;
- import com.kgraph.common.utils.poi.ExcelUtil;;
- import com.kgraph.common.core.page.TableDataInfo;;
- /**
- * 教材Controller
- *
- * @author Allen
- * @date 2023-04-13
- */
- @RestController
- @RequestMapping("/doc/textbook")
- public class TextbookDocController extends BaseController
- {
- @Autowired
- private ITextbookDocService textbookDocService;
- @Autowired
- private IFileService fileService;
- /**
- * 查询教材列表
- */
- @PreAuthorize("@ss.hasPermi('doc:textbook:list')")
- @GetMapping("/list")
- public TableDataInfo list(TextbookDoc textbookDoc)
- {
- startPage();
- List<TextbookDoc> list = textbookDocService.selectTextbookDocList(textbookDoc);
- return getDataTable(list);
- }
- /**
- * 导出教材列表
- */
- @PreAuthorize("@ss.hasPermi('doc:textbook:export')")
- @Log(title = "教材", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, TextbookDoc textbookDoc)
- {
- List<TextbookDoc> list = textbookDocService.selectTextbookDocList(textbookDoc);
- ExcelUtil<TextbookDoc> util = new ExcelUtil<TextbookDoc>(TextbookDoc.class);
- util.exportExcel(response, list, "教材数据");
- }
- /**
- * 获取教材详细信息
- */
- @PreAuthorize("@ss.hasPermi('doc:textbook:query')")
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") Long id)
- {
- return success(textbookDocService.selectTextbookDocById(id));
- }
- /**
- * 新增教材
- */
- @PreAuthorize("@ss.hasPermi('doc:textbook:add')")
- @Log(title = "教材", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody TextbookDoc textbookDoc) throws IOException {
- int rows = textbookDocService.insertTextbookDoc(textbookDoc);
- if (rows > 0) {
- fileService.copyFileToESPath(FileUtils.getFileRealPath(textbookDoc.getFilePath()));
- }
- return toAjax(rows);
- }
- /**
- * 修改教材
- */
- @PreAuthorize("@ss.hasPermi('doc:textbook:edit')")
- @Log(title = "教材", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody TextbookDoc textbookDoc) throws IOException {
- int rows = textbookDocService.updateTextbookDoc(textbookDoc);
- if (rows > 0) {
- fileService.copyFileToESPath(FileUtils.getFileRealPath(textbookDoc.getFilePath()));
- }
- return toAjax(rows);
- }
- /**
- * 删除教材
- */
- @PreAuthorize("@ss.hasPermi('doc:textbook:remove')")
- @Log(title = "教材", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable Long[] ids)
- {
- return toAjax(textbookDocService.deleteTextbookDocByIds(ids));
- }
- }
|