123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- package com.ruoyi.project.VRdemo.controller;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- import javax.servlet.http.HttpServletResponse;
- import com.alibaba.excel.EasyExcel;
- import com.ruoyi.common.utils.excel.ExcelReadUtil;
- import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
- import com.ruoyi.framework.web.page.TableDataInfo;
- import com.ruoyi.project.VRdemo.domain.Thesis;
- import com.ruoyi.project.VRdemo.domain.imData.ResearchImData;
- 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.framework.aspectj.lang.annotation.Log;
- import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
- import com.ruoyi.project.VRdemo.domain.Research;
- import com.ruoyi.project.VRdemo.service.IResearchService;
- import com.ruoyi.framework.web.controller.BaseController;
- import com.ruoyi.framework.web.domain.AjaxResult;
- import com.ruoyi.common.utils.poi.ExcelUtil;
- import org.springframework.web.multipart.MultipartFile;
- /**
- * 研究Controller
- *
- * @author ruoyi
- * @date 2024-06-23
- */
- @RestController
- @RequestMapping("/vr/research")
- public class ResearchController extends BaseController {
- private final IResearchService researchService;
- public ResearchController(@Autowired IResearchService researchService) {
- this.researchService = researchService;
- }
- /**
- * 查询研究列表
- */
- @Anonymous
- @GetMapping("/list")
- public AjaxResult list(Research research) {
- List<Research> list = researchService.selectResearchList(research);
- AjaxResult ajaxResult = new AjaxResult();
- ajaxResult.put("code", 200);
- ajaxResult.put("rows", list);
- ajaxResult.put("total", list.size());
- return ajaxResult;
- }
- /**
- * 查询分页列表
- */
- @GetMapping("/pageList")
- public TableDataInfo pageList(Research research) {
- startPage();
- List<Research> list = researchService.selectResearchList(research);
- return getDataTable(list);
- }
- /**
- * 查询论文列表
- */
- @PreAuthorize("@ss.hasPermi('VRdemo:thesis:list')")
- @GetMapping("/allList")
- public TableDataInfo allList(Research research) {
- startPage();
- List<Research> list = researchService.selectResearchList(research);
- return getDataTable(list);
- }
- /**
- * 获取研究详细信息
- */
- @PreAuthorize("@ss.hasPermi('VRdemo:research:query')")
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") Long id) {
- return success(researchService.selectResearchById(id));
- }
- /**
- * 新增研究
- */
- @PreAuthorize("@ss.hasPermi('VRdemo:research:add')")
- @Log(title = "研究", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody Research research) {
- return toAjax(researchService.insertResearch(research));
- }
- /**
- * 修改研究
- */
- @PreAuthorize("@ss.hasPermi('VRdemo:research:edit')")
- @Log(title = "研究", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody Research research) {
- return toAjax(researchService.updateResearch(research));
- }
- /**
- * 删除研究
- */
- @PreAuthorize("@ss.hasPermi('VRdemo:research:remove')")
- @Log(title = "研究", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable Long[] ids) {
- return toAjax(researchService.deleteResearchByIds(ids));
- }
- /**
- * 导出研究列表
- */
- @PreAuthorize("@ss.hasPermi('VRdemo:research:export')")
- @Log(title = "研究", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, Research research) {
- List<Research> list = researchService.selectResearchList(research);
- ExcelUtil<Research> util = new ExcelUtil<>(Research.class);
- util.exportExcel(response, list, "研究数据");
- }
- /**
- * 下载导入模板
- */
- @Anonymous
- @PostMapping("/importTemplate")
- public void importTemplate(HttpServletResponse response) throws IOException {
- List<ResearchImData> dataList = new ArrayList<>();
- EasyExcel.write(response.getOutputStream(), ResearchImData.class).sheet("Sheet1").doWrite(dataList);
- }
- /**
- * 导入数据
- */
- @Anonymous
- @PostMapping("/import")
- public AjaxResult importData(MultipartFile file, boolean updateSupport) throws IOException {
- List<Research> list = ExcelReadUtil.read(file, ResearchImData.class, Research.class);
- // 调用服务层方法进行数据导入处理
- String message = researchService.importData(list, updateSupport);
- // 返回成功响应,携带导入结果信息
- return AjaxResult.success(message);
- }
- }
|