Sfoglia il codice sorgente

添加研究/论文模块和导入

seeseele 11 mesi fa
parent
commit
f42c222c5e

+ 40 - 0
src/main/java/com/ruoyi/common/utils/poi/ResearchImportListener.java

@@ -0,0 +1,40 @@
+package com.ruoyi.common.utils.poi;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.ruoyi.project.VRdemo.domain.Research;
+import com.ruoyi.project.VRdemo.mapper.DataExcelMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ResearchImportListener extends AnalysisEventListener<Research> {
+
+
+    @Autowired
+    private com.ruoyi.project.VRdemo.mapper.DataExcelMapper DataExcelMapper;
+
+
+    // 存储读取到的数据
+    private List<Research> dataList = new ArrayList<Research>();
+
+    public List<Research> getDataList() {
+        return dataList;
+    }
+
+    public ResearchImportListener(DataExcelMapper DataExcelMapper) {
+        this.DataExcelMapper = DataExcelMapper;
+    }
+
+    @Override
+    public void invoke(Research Research, AnalysisContext analysisContext) {
+        dataList.add(Research);
+    }
+
+    // 所有数据解析完成后的回调方法,其中analysisContext包含解析的统计信息
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+    }
+}

+ 42 - 0
src/main/java/com/ruoyi/common/utils/poi/ThesisImportListener.java

@@ -0,0 +1,42 @@
+package com.ruoyi.common.utils.poi;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.ruoyi.project.VRdemo.domain.Thesis;
+import com.ruoyi.project.VRdemo.mapper.DataExcelMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+public class ThesisImportListener extends AnalysisEventListener<Thesis> {
+
+
+    @Autowired
+    private DataExcelMapper DataExcelMapper;
+
+
+    // 存储读取到的数据
+    private List<Thesis> dataList = new ArrayList<Thesis>();
+
+    public List<Thesis> getDataList() {
+        return dataList;
+    }
+
+    public ThesisImportListener(DataExcelMapper DataExcelMapper) {
+        this.DataExcelMapper = DataExcelMapper;
+    }
+
+    @Override
+    public void invoke(Thesis Thesis, AnalysisContext analysisContext) {
+        dataList.add(Thesis);
+    }
+
+    // 所有数据解析完成后的回调方法,其中analysisContext包含解析的统计信息
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+    }
+}

+ 62 - 8
src/main/java/com/ruoyi/project/VRdemo/controller/DataIoController.java

@@ -7,9 +7,8 @@ import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.project.VRdemo.domain.*;
 import com.ruoyi.project.VRdemo.mapper.DataExcelMapper;
-import com.ruoyi.project.VRdemo.service.INoticeDataService;
-import com.ruoyi.project.VRdemo.service.IPressService;
-import com.ruoyi.project.VRdemo.service.IStudyDataService;
+import com.ruoyi.project.VRdemo.service.*;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -43,8 +42,16 @@ public class DataIoController extends BaseController {
 
     @Autowired
     private IStudyDataService studyDataService;
+
     @Autowired
     private IPressService pressService;
+
+    @Autowired
+    private IThesisService thesisService;
+
+    @Autowired
+    private IResearchService researchService;
+
     //        应用导出数据
     @PreAuthorize("@ss.hasAnyRoles('admin,company')")
     @GetMapping("/export/app")
@@ -82,7 +89,7 @@ public class DataIoController extends BaseController {
         EasyExcel.write(response.getOutputStream(), ImportApp.class).sheet("Sheet1").doWrite(dataList);
     }
 
-    //        活动预告导出数据
+    // 活动预告导出数据
     @PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
     @GetMapping("/export/noticeData")
     public void exNoticeData(HttpServletResponse response) throws IOException {
@@ -108,7 +115,7 @@ public class DataIoController extends BaseController {
     }
 
 
-    //        活动预告导入数据
+    // 活动预告导入数据
     @PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
     @PostMapping("/import/notice")
     public AjaxResult imNoticeData(MultipartFile file, boolean updateSupport) throws IOException {
@@ -121,7 +128,7 @@ public class DataIoController extends BaseController {
         return success(message);
     }
 
-    //      活动预告下载模板
+    // 活动预告下载模板
     @PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
     @PostMapping("/importTemplate/notice")
     public void imNoticeTemplate(HttpServletResponse response) throws IOException {
@@ -129,7 +136,7 @@ public class DataIoController extends BaseController {
         EasyExcel.write(response.getOutputStream(), NoticeImData.class).sheet("Sheet1").doWrite(dataList);
     }
 
-    //        研究导出数据
+    // 研究导出数据
     @PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
     @GetMapping("/export/studydata")
     public void exStudyData(HttpServletResponse response) throws IOException {
@@ -169,7 +176,7 @@ public class DataIoController extends BaseController {
         EasyExcel.write(response.getOutputStream(), StudyExData.class).registerWriteHandler(new CustomCellWriteWeightConfig()).sheet("Sheet1").doWrite(dataList);
     }
 
-    //        研究导入数据
+    // 研究导入数据
     @PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
     @PostMapping("/import/study")
     public AjaxResult imStudyData(MultipartFile file, boolean updateSupport) throws IOException {
@@ -212,4 +219,51 @@ public class DataIoController extends BaseController {
         // 返回成功响应,携带导入结果信息
         return AjaxResult.success(message);
     }
+
+    /**
+     * 导入Thesis数据
+     */
+//    @PreAuthorize("@ss.hasAnyRoles('admin,company')")
+    @Anonymous
+    @PostMapping("/import/thesis")
+    public AjaxResult importThesisData(MultipartFile file, boolean updateSupport) throws IOException {
+        // 初始化监听器以处理导入逻辑
+        ThesisImportListener dataImportListener = new ThesisImportListener(DataExcelMapper);
+
+        // 使用EasyExcel读取Excel文件内容
+        EasyExcel.read(file.getInputStream(), Thesis.class, dataImportListener)
+                .sheet() // 默认读取第一个sheet
+                .headRowNumber(1) // 指定表头所在行数
+                .doRead(); // 执行读取操作
+
+        // 调用服务层方法进行数据导入处理
+        String message = thesisService.importThesis(dataImportListener.getDataList(), updateSupport);
+
+        // 返回成功响应,携带导入结果信息
+        return AjaxResult.success(message);
+    }
+
+    /**
+     * 导入research数据
+     */
+//    @PreAuthorize("@ss.hasAnyRoles('admin,company')")
+    @Anonymous
+    @PostMapping("/import/research")
+    public AjaxResult importResearchData(MultipartFile file, boolean updateSupport) throws IOException {
+        // 初始化监听器以处理导入逻辑
+        ResearchImportListener dataImportListener = new ResearchImportListener(DataExcelMapper);
+
+        // 使用EasyExcel读取Excel文件内容
+        EasyExcel.read(file.getInputStream(), Research.class, dataImportListener)
+                .sheet() // 默认读取第一个sheet
+                .headRowNumber(1) // 指定表头所在行数
+                .doRead(); // 执行读取操作
+
+        // 调用服务层方法进行数据导入处理
+        String message = researchService.importResearch(dataImportListener.getDataList(), updateSupport);
+
+        // 返回成功响应,携带导入结果信息
+        return AjaxResult.success(message);
+    }
+
 }

+ 104 - 0
src/main/java/com/ruoyi/project/VRdemo/controller/ResearchController.java

@@ -0,0 +1,104 @@
+package com.ruoyi.project.VRdemo.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+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 com.ruoyi.framework.web.page.TableDataInfo;
+
+/**
+ * 研究Controller
+ * 
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+@RestController
+@RequestMapping("/VRdemo/research")
+public class ResearchController extends BaseController
+{
+    @Autowired
+    private IResearchService researchService;
+
+    /**
+     * 查询研究列表
+     */
+    @PreAuthorize("@ss.hasPermi('VRdemo:research:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(Research research)
+    {
+        startPage();
+        List<Research> list = researchService.selectResearchList(research);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出研究列表
+     */
+    @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>(Research.class);
+        util.exportExcel(response, 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));
+    }
+}

+ 104 - 0
src/main/java/com/ruoyi/project/VRdemo/controller/ThesisController.java

@@ -0,0 +1,104 @@
+package com.ruoyi.project.VRdemo.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+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.Thesis;
+import com.ruoyi.project.VRdemo.service.IThesisService;
+import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.web.page.TableDataInfo;
+
+/**
+ * 论文Controller
+ * 
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+@RestController
+@RequestMapping("/VRdemo/thesis")
+public class ThesisController extends BaseController
+{
+    @Autowired
+    private IThesisService thesisService;
+
+    /**
+     * 查询论文列表
+     */
+    @PreAuthorize("@ss.hasPermi('VRdemo:thesis:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(Thesis thesis)
+    {
+        startPage();
+        List<Thesis> list = thesisService.selectThesisList(thesis);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出论文列表
+     */
+    @PreAuthorize("@ss.hasPermi('VRdemo:thesis:export')")
+    @Log(title = "论文", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, Thesis thesis)
+    {
+        List<Thesis> list = thesisService.selectThesisList(thesis);
+        ExcelUtil<Thesis> util = new ExcelUtil<Thesis>(Thesis.class);
+        util.exportExcel(response, list, "论文数据");
+    }
+
+    /**
+     * 获取论文详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('VRdemo:thesis:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(thesisService.selectThesisById(id));
+    }
+
+    /**
+     * 新增论文
+     */
+    @PreAuthorize("@ss.hasPermi('VRdemo:thesis:add')")
+    @Log(title = "论文", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Thesis thesis)
+    {
+        return toAjax(thesisService.insertThesis(thesis));
+    }
+
+    /**
+     * 修改论文
+     */
+    @PreAuthorize("@ss.hasPermi('VRdemo:thesis:edit')")
+    @Log(title = "论文", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody Thesis thesis)
+    {
+        return toAjax(thesisService.updateThesis(thesis));
+    }
+
+    /**
+     * 删除论文
+     */
+    @PreAuthorize("@ss.hasPermi('VRdemo:thesis:remove')")
+    @Log(title = "论文", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(thesisService.deleteThesisByIds(ids));
+    }
+}

+ 124 - 0
src/main/java/com/ruoyi/project/VRdemo/domain/Research.java

@@ -0,0 +1,124 @@
+package com.ruoyi.project.VRdemo.domain;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import com.ruoyi.framework.web.domain.BaseEntity;
+
+/**
+ * 研究对象 vr_research
+ * 
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+public class Research extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 序号 */
+    private Long id;
+
+    /** 书名 */
+    @Excel(name = "书名")
+    private String title;
+
+    /** 作者 */
+    @Excel(name = "作者")
+    private String author;
+
+    /** 出版机构 */
+    @Excel(name = "出版机构")
+    private String institution;
+
+    /** 主题词 */
+    @Excel(name = "主题词")
+    private String topic;
+
+    /** 出版年 */
+    @JsonFormat(pattern = "yyyy")
+    @Excel(name = "出版年")
+    private Date publicationTime;
+
+    /** 分类号 */
+    @Excel(name = "分类号")
+    private String category;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setTitle(String title) 
+    {
+        this.title = title;
+    }
+
+    public String getTitle() 
+    {
+        return title;
+    }
+    public void setAuthor(String author) 
+    {
+        this.author = author;
+    }
+
+    public String getAuthor() 
+    {
+        return author;
+    }
+    public void setInstitution(String institution) 
+    {
+        this.institution = institution;
+    }
+
+    public String getInstitution() 
+    {
+        return institution;
+    }
+    public void setTopic(String topic) 
+    {
+        this.topic = topic;
+    }
+
+    public String getTopic() 
+    {
+        return topic;
+    }
+    public void setPublicationTime(Date publicationTime) 
+    {
+        this.publicationTime = publicationTime;
+    }
+
+    public Date getPublicationTime() 
+    {
+        return publicationTime;
+    }
+    public void setCategory(String category) 
+    {
+        this.category = category;
+    }
+
+    public String getCategory() 
+    {
+        return category;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("title", getTitle())
+            .append("author", getAuthor())
+            .append("institution", getInstitution())
+            .append("topic", getTopic())
+            .append("publicationTime", getPublicationTime())
+            .append("category", getCategory())
+            .toString();
+    }
+}

+ 140 - 0
src/main/java/com/ruoyi/project/VRdemo/domain/Thesis.java

@@ -0,0 +1,140 @@
+package com.ruoyi.project.VRdemo.domain;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import com.ruoyi.framework.web.domain.BaseEntity;
+
+import java.util.Date;
+
+/**
+ * 论文对象 vr_thesis
+ * 
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+public class Thesis extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 序号 */
+    private Long id;
+
+    /** 作者姓名 */
+    @Excel(name = "作者姓名")
+    private String name;
+
+    /** 指导教师 */
+    @Excel(name = "指导教师")
+    private String teacher;
+
+    /** 专业 */
+    @Excel(name = "专业")
+    private String major;
+
+    /** 题名 */
+    @Excel(name = "题名")
+    private String title;
+
+    /** 关键词 */
+    @Excel(name = "关键词")
+    private String keyword;
+
+    /** 答辩时间 */
+    @JsonFormat(pattern = "yyyy")
+    @Excel(name = "答辩时间")
+    private Date replyTime;
+
+    /** 学位 */
+    @Excel(name = "学位")
+    private String degree;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setName(String name) 
+    {
+        this.name = name;
+    }
+
+    public String getName() 
+    {
+        return name;
+    }
+    public void setTeacher(String teacher) 
+    {
+        this.teacher = teacher;
+    }
+
+    public String getTeacher() 
+    {
+        return teacher;
+    }
+    public void setMajor(String major) 
+    {
+        this.major = major;
+    }
+
+    public String getMajor() 
+    {
+        return major;
+    }
+    public void setTitle(String title) 
+    {
+        this.title = title;
+    }
+
+    public String getTitle() 
+    {
+        return title;
+    }
+    public void setKeyword(String keyword) 
+    {
+        this.keyword = keyword;
+    }
+
+    public String getKeyword() 
+    {
+        return keyword;
+    }
+    public void setReplyTime(Date replyTime)
+    {
+        this.replyTime = replyTime;
+    }
+
+    public Date getReplyTime()
+    {
+        return replyTime;
+    }
+    public void setDegree(String degree) 
+    {
+        this.degree = degree;
+    }
+
+    public String getDegree() 
+    {
+        return degree;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("name", getName())
+            .append("teacher", getTeacher())
+            .append("major", getMajor())
+            .append("title", getTitle())
+            .append("keyword", getKeyword())
+            .append("replyTime", getReplyTime())
+            .append("degree", getDegree())
+            .toString();
+    }
+}

+ 46 - 0
src/main/java/com/ruoyi/project/VRdemo/mapper/DataExcelMapper.java

@@ -154,4 +154,50 @@ public interface DataExcelMapper {
      * @param dataList press列表
      */
     void insertPressDataList(List<Press> dataList);
+
+    /**
+     * thesis表根据题目进行查询
+     *
+     * @param titleAsLong 题目
+     * @return press数据对象
+     */
+    Thesis selectThesisByTitle(String titleAsLong);
+
+    /**
+     * 更新thesis,根据标题进行更新操作。
+     *
+     * @param thesis
+     * @return 更新操作影响的行数
+     */
+    int updateThesisByImport(Thesis thesis);
+
+    /**
+     * 批量插入thesis
+     *
+     * @param dataList thesis列表
+     */
+    void insertThesisDataList(List<Thesis> dataList);
+
+    /**
+     * research表根据题目进行查询
+     *
+     * @param titleAsLong 题目
+     * @return research数据对象
+     */
+    Research selectResearchByTitle(String titleAsLong);
+
+    /**
+     * 更新research,根据标题进行更新操作。
+     *
+     * @param research
+     * @return 更新操作影响的行数
+     */
+    int updateResearchByImport(Research research);
+
+    /**
+     * 批量插入research
+     *
+     * @param dataList research列表
+     */
+    void insertResearchDataList(List<Research> dataList);
 }

+ 61 - 0
src/main/java/com/ruoyi/project/VRdemo/mapper/ResearchMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.project.VRdemo.mapper;
+
+import java.util.List;
+import com.ruoyi.project.VRdemo.domain.Research;
+
+/**
+ * 研究Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+public interface ResearchMapper 
+{
+    /**
+     * 查询研究
+     * 
+     * @param id 研究主键
+     * @return 研究
+     */
+    public Research selectResearchById(Long id);
+
+    /**
+     * 查询研究列表
+     * 
+     * @param research 研究
+     * @return 研究集合
+     */
+    public List<Research> selectResearchList(Research research);
+
+    /**
+     * 新增研究
+     * 
+     * @param research 研究
+     * @return 结果
+     */
+    public int insertResearch(Research research);
+
+    /**
+     * 修改研究
+     * 
+     * @param research 研究
+     * @return 结果
+     */
+    public int updateResearch(Research research);
+
+    /**
+     * 删除研究
+     * 
+     * @param id 研究主键
+     * @return 结果
+     */
+    public int deleteResearchById(Long id);
+
+    /**
+     * 批量删除研究
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteResearchByIds(Long[] ids);
+}

+ 61 - 0
src/main/java/com/ruoyi/project/VRdemo/mapper/ThesisMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.project.VRdemo.mapper;
+
+import java.util.List;
+import com.ruoyi.project.VRdemo.domain.Thesis;
+
+/**
+ * 论文Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+public interface ThesisMapper 
+{
+    /**
+     * 查询论文
+     * 
+     * @param id 论文主键
+     * @return 论文
+     */
+    public Thesis selectThesisById(Long id);
+
+    /**
+     * 查询论文列表
+     * 
+     * @param thesis 论文
+     * @return 论文集合
+     */
+    public List<Thesis> selectThesisList(Thesis thesis);
+
+    /**
+     * 新增论文
+     * 
+     * @param thesis 论文
+     * @return 结果
+     */
+    public int insertThesis(Thesis thesis);
+
+    /**
+     * 修改论文
+     * 
+     * @param thesis 论文
+     * @return 结果
+     */
+    public int updateThesis(Thesis thesis);
+
+    /**
+     * 删除论文
+     * 
+     * @param id 论文主键
+     * @return 结果
+     */
+    public int deleteThesisById(Long id);
+
+    /**
+     * 批量删除论文
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteThesisByIds(Long[] ids);
+}

+ 69 - 0
src/main/java/com/ruoyi/project/VRdemo/service/IResearchService.java

@@ -0,0 +1,69 @@
+package com.ruoyi.project.VRdemo.service;
+
+import java.util.List;
+
+import com.ruoyi.project.VRdemo.domain.Research;
+import com.ruoyi.project.VRdemo.domain.Research;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * 研究Service接口
+ * 
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+public interface IResearchService 
+{
+    /**
+     * 查询研究
+     * 
+     * @param id 研究主键
+     * @return 研究
+     */
+    public Research selectResearchById(Long id);
+
+    /**
+     * 查询研究列表
+     * 
+     * @param research 研究
+     * @return 研究集合
+     */
+    public List<Research> selectResearchList(Research research);
+
+    /**
+     * 新增研究
+     * 
+     * @param research 研究
+     * @return 结果
+     */
+    public int insertResearch(Research research);
+
+    /**
+     * 修改研究
+     * 
+     * @param research 研究
+     * @return 结果
+     */
+    public int updateResearch(Research research);
+
+    /**
+     * 批量删除研究
+     * 
+     * @param ids 需要删除的研究主键集合
+     * @return 结果
+     */
+    public int deleteResearchByIds(Long[] ids);
+
+    /**
+     * 删除研究信息
+     * 
+     * @param id 研究主键
+     * @return 结果
+     */
+    public int deleteResearchById(Long id);
+
+    //EasyExcel批量导入
+    @Transactional(isolation = Isolation.READ_COMMITTED)
+    String importResearch(List<Research> studyList, Boolean updateSupport);
+}

+ 69 - 0
src/main/java/com/ruoyi/project/VRdemo/service/IThesisService.java

@@ -0,0 +1,69 @@
+package com.ruoyi.project.VRdemo.service;
+
+import java.util.List;
+
+import com.ruoyi.project.VRdemo.domain.Thesis;
+import com.ruoyi.project.VRdemo.domain.Thesis;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * 论文Service接口
+ * 
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+public interface IThesisService 
+{
+    /**
+     * 查询论文
+     * 
+     * @param id 论文主键
+     * @return 论文
+     */
+    public Thesis selectThesisById(Long id);
+
+    /**
+     * 查询论文列表
+     * 
+     * @param thesis 论文
+     * @return 论文集合
+     */
+    public List<Thesis> selectThesisList(Thesis thesis);
+
+    /**
+     * 新增论文
+     * 
+     * @param thesis 论文
+     * @return 结果
+     */
+    public int insertThesis(Thesis thesis);
+
+    /**
+     * 修改论文
+     * 
+     * @param thesis 论文
+     * @return 结果
+     */
+    public int updateThesis(Thesis thesis);
+
+    /**
+     * 批量删除论文
+     * 
+     * @param ids 需要删除的论文主键集合
+     * @return 结果
+     */
+    public int deleteThesisByIds(Long[] ids);
+
+    /**
+     * 删除论文信息
+     * 
+     * @param id 论文主键
+     * @return 结果
+     */
+    public int deleteThesisById(Long id);
+
+    //EasyExcel批量导入
+    @Transactional(isolation = Isolation.READ_COMMITTED)
+    String importThesis(List<Thesis> studyList, Boolean updateSupport);
+}

+ 189 - 0
src/main/java/com/ruoyi/project/VRdemo/service/impl/ResearchServiceImpl.java

@@ -0,0 +1,189 @@
+package com.ruoyi.project.VRdemo.service.impl;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.project.VRdemo.domain.Research;
+import com.ruoyi.project.VRdemo.mapper.DataExcelMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.project.VRdemo.mapper.ResearchMapper;
+import com.ruoyi.project.VRdemo.domain.Research;
+import com.ruoyi.project.VRdemo.service.IResearchService;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * 研究Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+@Service
+public class ResearchServiceImpl implements IResearchService 
+{
+    @Autowired
+    private ResearchMapper researchMapper;
+
+    @Autowired
+    private DataExcelMapper dataExcelMapper;
+    private static final Logger logger = LoggerFactory.getLogger(Research.class);
+
+    private static final int BATCH_COUNT = 10000;
+
+    /**
+     * 查询研究
+     * 
+     * @param id 研究主键
+     * @return 研究
+     */
+    @Override
+    public Research selectResearchById(Long id)
+    {
+        return researchMapper.selectResearchById(id);
+    }
+
+    /**
+     * 查询研究列表
+     * 
+     * @param research 研究
+     * @return 研究
+     */
+    @Override
+    public List<Research> selectResearchList(Research research)
+    {
+        return researchMapper.selectResearchList(research);
+    }
+
+    /**
+     * 新增研究
+     * 
+     * @param research 研究
+     * @return 结果
+     */
+    @Override
+    public int insertResearch(Research research)
+    {
+        return researchMapper.insertResearch(research);
+    }
+
+    /**
+     * 修改研究
+     * 
+     * @param research 研究
+     * @return 结果
+     */
+    @Override
+    public int updateResearch(Research research)
+    {
+        return researchMapper.updateResearch(research);
+    }
+
+    /**
+     * 批量删除研究
+     * 
+     * @param ids 需要删除的研究主键
+     * @return 结果
+     */
+    @Override
+    public int deleteResearchByIds(Long[] ids)
+    {
+        return researchMapper.deleteResearchByIds(ids);
+    }
+
+    /**
+     * 删除研究信息
+     * 
+     * @param id 研究主键
+     * @return 结果
+     */
+    @Override
+    public int deleteResearchById(Long id)
+    {
+        return researchMapper.deleteResearchById(id);
+    }
+
+    //EasyExcel批量导入
+    @Override
+    @Transactional(isolation = Isolation.READ_COMMITTED)
+    public String importResearch(List<Research> researchList, Boolean updateSupport) {
+        if (StringUtils.isNull(researchList) || researchList.size() == 0) {
+            throw new ServiceException("导入用户数据不能为空!");
+        }
+
+        List<Research> batchDataList = new ArrayList<>();
+        int successNum = 0;
+        int failureNum = 0;
+        StringBuilder successMsg = new StringBuilder();
+        StringBuilder failureMsg = new StringBuilder();
+
+        // 遍历用户数据列表,逐条处理数据
+        for (Research research : researchList) {
+            try {
+                // 对每一条数据进行处理
+                // 根据title字段判断数据合法性
+                if (StringUtils.isEmpty(research.getTitle())) {
+                    throw new ServiceException("模板标题不能为空!");
+                }
+
+                // 如果更新支持,检查数据库中是否存在相同的记录,如果存在,则进行更新操作
+                // 判断数据库中是否存在相同标题的记录
+                Research existingResearch = null;
+                if(updateSupport){
+                    String titleAsString = research.getTitle();
+                    existingResearch= dataExcelMapper.selectResearchByTitle(titleAsString);
+                }
+                if (existingResearch != null) {
+                    research.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
+                    research.setUpdateTime(DateUtils.getNowDate());
+                    // 更新操作
+                    dataExcelMapper.updateResearchByImport(research);
+                    successNum++;
+                    successMsg.append("成功更新数据:").append(research.getTitle()).append("\n");
+                } else {
+                    // 检查是否已经存在于 batchDataList 中,避免重复插入
+                    if (!batchDataList.contains(research)) {
+//                        research.setCreateBy(SecurityUtils.getLoginUser().getUsername());
+                        research.setCreateTime(DateUtils.getNowDate());
+                        batchDataList.add(research);
+                    }
+                    // 判断是否达到BATCH_COUNT,或者已经是最后一个数据
+                    if (batchDataList.size() >= BATCH_COUNT || researchList.indexOf(research) == researchList.size() - 1) {
+                        System.out.println( "batchDataList size: " + batchDataList);
+                        // 执行批量插入操作
+                        dataExcelMapper.insertResearchDataList(batchDataList);
+                        successNum += batchDataList.size();
+                        for (Research insertedResearch : batchDataList) {
+                            successMsg.append("成功导入数据:").append(insertedResearch.getTitle()).append("\n");
+                        }
+                        batchDataList.clear();
+                    }
+                }
+            } catch (Exception e) {
+                // 输出异常信息和上下文信息到日志
+                logger.error("导入数据时发生异常:", e);
+                logger.error("异常发生时的数据:{}", research); // 这里的 study 是导致异常的数据对象
+                // 处理导入失败的情况
+                failureNum++;
+                failureMsg.append("导入失败,模板标题为:").append(research.getTitle()).append("\n");
+            }
+        }
+        // 判断是否有导入失败的数据
+        if (failureNum > 0) {
+            failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确或插入数据库出错,错误如下:\n");
+            throw new ServiceException(failureMsg.toString());
+        } else {
+            // 若全部数据导入成功,则返回成功导入的信息
+            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:\n");
+        }
+        return successMsg.toString();
+    }
+}

+ 181 - 0
src/main/java/com/ruoyi/project/VRdemo/service/impl/ThesisServiceImpl.java

@@ -0,0 +1,181 @@
+package com.ruoyi.project.VRdemo.service.impl;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.project.VRdemo.mapper.DataExcelMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.project.VRdemo.mapper.ThesisMapper;
+import com.ruoyi.project.VRdemo.domain.Thesis;
+import com.ruoyi.project.VRdemo.service.IThesisService;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * 论文Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2024-06-23
+ */
+@Service
+public class ThesisServiceImpl implements IThesisService {
+    @Autowired
+    private ThesisMapper thesisMapper;
+
+    @Autowired
+    private DataExcelMapper dataExcelMapper;
+    private static final Logger logger = LoggerFactory.getLogger(Thesis.class);
+
+    private static final int BATCH_COUNT = 10000;
+
+    /**
+     * 查询论文
+     *
+     * @param id 论文主键
+     * @return 论文
+     */
+    @Override
+    public Thesis selectThesisById(Long id) {
+        return thesisMapper.selectThesisById(id);
+    }
+
+    /**
+     * 查询论文列表
+     *
+     * @param thesis 论文
+     * @return 论文
+     */
+    @Override
+    public List<Thesis> selectThesisList(Thesis thesis) {
+        return thesisMapper.selectThesisList(thesis);
+    }
+
+    /**
+     * 新增论文
+     *
+     * @param thesis 论文
+     * @return 结果
+     */
+    @Override
+    public int insertThesis(Thesis thesis) {
+        return thesisMapper.insertThesis(thesis);
+    }
+
+    /**
+     * 修改论文
+     *
+     * @param thesis 论文
+     * @return 结果
+     */
+    @Override
+    public int updateThesis(Thesis thesis) {
+        return thesisMapper.updateThesis(thesis);
+    }
+
+    /**
+     * 批量删除论文
+     *
+     * @param ids 需要删除的论文主键
+     * @return 结果
+     */
+    @Override
+    public int deleteThesisByIds(Long[] ids) {
+        return thesisMapper.deleteThesisByIds(ids);
+    }
+
+    /**
+     * 删除论文信息
+     *
+     * @param id 论文主键
+     * @return 结果
+     */
+    @Override
+    public int deleteThesisById(Long id) {
+        return thesisMapper.deleteThesisById(id);
+    }
+
+    //EasyExcel批量导入
+    @Override
+    @Transactional(isolation = Isolation.READ_COMMITTED)
+    public String importThesis(List<Thesis> thesisList, Boolean updateSupport) {
+        if (StringUtils.isNull(thesisList) || thesisList.size() == 0) {
+            throw new ServiceException("导入用户数据不能为空!");
+        }
+
+        List<Thesis> batchDataList = new ArrayList<>();
+        int successNum = 0;
+        int failureNum = 0;
+        StringBuilder successMsg = new StringBuilder();
+        StringBuilder failureMsg = new StringBuilder();
+
+        // 遍历用户数据列表,逐条处理数据
+        for (Thesis thesis : thesisList) {
+            try {
+                // 对每一条数据进行处理
+                // 根据title字段判断数据合法性
+                if (StringUtils.isEmpty(thesis.getTitle())) {
+                    throw new ServiceException("模板标题不能为空!");
+                }
+
+                // 如果更新支持,检查数据库中是否存在相同的记录,如果存在,则进行更新操作
+                // 判断数据库中是否存在相同标题的记录
+                Thesis existingThesis = null;
+                if (updateSupport) {
+                    String titleAsString = thesis.getTitle();
+                    existingThesis = dataExcelMapper.selectThesisByTitle(titleAsString);
+                }
+                if (existingThesis != null) {
+                    thesis.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
+                    thesis.setUpdateTime(DateUtils.getNowDate());
+                    // 更新操作
+                    dataExcelMapper.updateThesisByImport(thesis);
+                    successNum++;
+                    successMsg.append("成功更新数据:").append(thesis.getTitle()).append("\n");
+                } else {
+                    // 检查是否已经存在于 batchDataList 中,避免重复插入
+                    if (!batchDataList.contains(thesis)) {
+//                        thesis.setCreateBy(SecurityUtils.getLoginUser().getUsername());
+                        thesis.setCreateTime(DateUtils.getNowDate());
+                        batchDataList.add(thesis);
+                    }
+                    // 判断是否达到BATCH_COUNT,或者已经是最后一个数据
+                    if (batchDataList.size() >= BATCH_COUNT || thesisList.indexOf(thesis) == thesisList.size() - 1) {
+                        System.out.println("batchDataList size: " + batchDataList);
+                        // 执行批量插入操作
+                        dataExcelMapper.insertThesisDataList(batchDataList);
+                        successNum += batchDataList.size();
+                        for (Thesis insertedThesis : batchDataList) {
+                            successMsg.append("成功导入数据:").append(insertedThesis.getTitle()).append("\n");
+                        }
+                        batchDataList.clear();
+                    }
+                }
+            } catch (Exception e) {
+                // 输出异常信息和上下文信息到日志
+                logger.error("导入数据时发生异常:", e);
+                logger.error("异常发生时的数据:{}", thesis); // 这里的 study 是导致异常的数据对象
+                // 处理导入失败的情况
+                failureNum++;
+                failureMsg.append("导入失败,模板标题为:").append(thesis.getTitle()).append("\n");
+            }
+        }
+        // 判断是否有导入失败的数据
+        if (failureNum > 0) {
+            failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确或插入数据库出错,错误如下:\n");
+            throw new ServiceException(failureMsg.toString());
+        } else {
+            // 若全部数据导入成功,则返回成功导入的信息
+            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:\n");
+        }
+        return successMsg.toString();
+    }
+}

+ 59 - 0
src/main/resources/mybatis/VRdemo/DataExcelMapper.xml

@@ -150,6 +150,18 @@
         WHERE title = #{titleAsLong}
     </select>
 
+    <select id="selectThesisByTitle" resultType="com.ruoyi.project.VRdemo.domain.Thesis">
+        SELECT *
+        FROM vr_thesis
+        WHERE title = #{titleAsLong}
+    </select>
+
+    <select id="selectResearchByTitle" resultType="com.ruoyi.project.VRdemo.domain.Research">
+        SELECT *
+        FROM vr_research
+        WHERE title = #{titleAsLong}
+    </select>
+
     <!-- 批量插入活动预告数据列表 -->
     <insert id="insertStudyDataList" parameterType="java.util.List">
         INSERT INTO vr_study_data (title, long_title, year, month, author, create_time, update_time)
@@ -190,6 +202,37 @@
         where title = #{title}
     </update>
 
+    <update id="updateThesisByImport" parameterType="com.ruoyi.project.VRdemo.domain.Thesis">
+        update vr_thesis
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="title != null">name = #{name},</if>
+            <if test="author != null">teacher = #{teacher},</if>
+            <if test="pressTitle != null">major = #{major},</if>
+            <if test="issue != null">title = #{title},</if>
+            <if test="pages != null">keyword = #{keyword},</if>
+            <if test="keyword != null">reply_time = #{replyTime},</if>
+            <if test="classify != null">degree = #{degree},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where title = #{title}
+    </update>
+
+    <update id="updateResearchByImport" parameterType="com.ruoyi.project.VRdemo.domain.Research">
+        update vr_research
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="title != null">title = #{title},</if>
+            <if test="author != null">author = #{author},</if>
+            <if test="pressTitle != null">institution = #{institution},</if>
+            <if test="issue != null">topic = #{topic},</if>
+            <if test="pages != null">publication_time = #{publicationTime},</if>
+            <if test="keyword != null">category = #{category},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where title = #{title}
+    </update>
+
     <insert id="insertPressDataList" parameterType="java.util.List">
         INSERT INTO vr_press (title, author, press_title, issue, date, pages, keyword, classify,area,create_by,create_time)
         VALUES
@@ -197,4 +240,20 @@
             (#{item.title}, #{item.author}, #{item.pressTitle}, #{item.issue}, #{item.date}, #{item.pages}, #{item.keyword}, #{item.classify}, #{item.area}, #{item.createBy}, #{item.createTime})
         </foreach>
     </insert>
+
+    <insert id="insertThesisDataList" parameterType="java.util.List">
+        INSERT INTO vr_thesis (name, teacher, major, title, keyword, reply_time, degree, create_by,create_time)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+            (#{item.name}, #{item.teacher}, #{item.major}, #{item.title}, #{item.keyword}, #{item.replyTime}, #{item.degree}, #{item.createBy}, #{item.createTime})
+        </foreach>
+    </insert>
+
+    <insert id="insertResearchDataList" parameterType="java.util.List">
+        INSERT INTO vr_research (title, author, institution, topic, publication_time, category, create_by,create_time)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+            (#{item.title}, #{item.author}, #{item.institution}, #{item.topic}, #{item.publicationTime}, #{item.category}, #{item.createBy}, #{item.createTime})
+        </foreach>
+    </insert>
 </mapper>

+ 81 - 0
src/main/resources/mybatis/VRdemo/ResearchMapper.xml

@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.project.VRdemo.mapper.ResearchMapper">
+    
+    <resultMap type="Research" id="ResearchResult">
+        <result property="id"    column="id"    />
+        <result property="title"    column="title"    />
+        <result property="author"    column="author"    />
+        <result property="institution"    column="institution"    />
+        <result property="topic"    column="topic"    />
+        <result property="publicationTime"    column="publication_time"    />
+        <result property="category"    column="category"    />
+    </resultMap>
+
+    <sql id="selectResearchVo">
+        select id, title, author, institution, topic, publication_time, category from vr_research
+    </sql>
+
+    <select id="selectResearchList" parameterType="Research" resultMap="ResearchResult">
+        <include refid="selectResearchVo"/>
+        <where>  
+            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
+            <if test="author != null  and author != ''"> and author like concat('%', #{author}, '%')</if>
+            <if test="institution != null  and institution != ''"> and institution like concat('%', #{institution}, '%')</if>
+            <if test="topic != null  and topic != ''"> and topic like concat('%', #{topic}, '%')</if>
+            <if test="publicationTime != null "> and publication_time = #{publicationTime}</if>
+            <if test="category != null  and category != ''"> and category = #{category}</if>
+        </where>
+    </select>
+    
+    <select id="selectResearchById" parameterType="Long" resultMap="ResearchResult">
+        <include refid="selectResearchVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertResearch" parameterType="Research" useGeneratedKeys="true" keyProperty="id">
+        insert into vr_research
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="title != null">title,</if>
+            <if test="author != null">author,</if>
+            <if test="institution != null">institution,</if>
+            <if test="topic != null">topic,</if>
+            <if test="publicationTime != null">publication_time,</if>
+            <if test="category != null">category,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="title != null">#{title},</if>
+            <if test="author != null">#{author},</if>
+            <if test="institution != null">#{institution},</if>
+            <if test="topic != null">#{topic},</if>
+            <if test="publicationTime != null">#{publicationTime},</if>
+            <if test="category != null">#{category},</if>
+         </trim>
+    </insert>
+
+    <update id="updateResearch" parameterType="Research">
+        update vr_research
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="title != null">title = #{title},</if>
+            <if test="author != null">author = #{author},</if>
+            <if test="institution != null">institution = #{institution},</if>
+            <if test="topic != null">topic = #{topic},</if>
+            <if test="publicationTime != null">publication_time = #{publicationTime},</if>
+            <if test="category != null">category = #{category},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteResearchById" parameterType="Long">
+        delete from vr_research where id = #{id}
+    </delete>
+
+    <delete id="deleteResearchByIds" parameterType="String">
+        delete from vr_research where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 86 - 0
src/main/resources/mybatis/VRdemo/ThesisMapper.xml

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.project.VRdemo.mapper.ThesisMapper">
+    
+    <resultMap type="Thesis" id="ThesisResult">
+        <result property="id"    column="id"    />
+        <result property="name"    column="name"    />
+        <result property="teacher"    column="teacher"    />
+        <result property="major"    column="major"    />
+        <result property="title"    column="title"    />
+        <result property="keyword"    column="keyword"    />
+        <result property="replyTime"    column="reply_time"    />
+        <result property="degree"    column="degree"    />
+    </resultMap>
+
+    <sql id="selectThesisVo">
+        select id, name, teacher, major, title, keyword, reply_time, degree from vr_thesis
+    </sql>
+
+    <select id="selectThesisList" parameterType="Thesis" resultMap="ThesisResult">
+        <include refid="selectThesisVo"/>
+        <where>  
+            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
+            <if test="teacher != null  and teacher != ''"> and teacher = #{teacher}</if>
+            <if test="major != null  and major != ''"> and major = #{major}</if>
+            <if test="title != null  and title != ''"> and title = #{title}</if>
+            <if test="keyword != null  and keyword != ''"> and keyword = #{keyword}</if>
+            <if test="replyTime != null  and replyTime != ''"> and reply_time = #{replyTime}</if>
+            <if test="degree != null  and degree != ''"> and degree = #{degree}</if>
+        </where>
+    </select>
+    
+    <select id="selectThesisById" parameterType="Long" resultMap="ThesisResult">
+        <include refid="selectThesisVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertThesis" parameterType="Thesis" useGeneratedKeys="true" keyProperty="id">
+        insert into vr_thesis
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="name != null">name,</if>
+            <if test="teacher != null">teacher,</if>
+            <if test="major != null">major,</if>
+            <if test="title != null">title,</if>
+            <if test="keyword != null">keyword,</if>
+            <if test="replyTime != null">reply_time,</if>
+            <if test="degree != null">degree,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="name != null">#{name},</if>
+            <if test="teacher != null">#{teacher},</if>
+            <if test="major != null">#{major},</if>
+            <if test="title != null">#{title},</if>
+            <if test="keyword != null">#{keyword},</if>
+            <if test="replyTime != null">#{replyTime},</if>
+            <if test="degree != null">#{degree},</if>
+         </trim>
+    </insert>
+
+    <update id="updateThesis" parameterType="Thesis">
+        update vr_thesis
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="name != null">name = #{name},</if>
+            <if test="teacher != null">teacher = #{teacher},</if>
+            <if test="major != null">major = #{major},</if>
+            <if test="title != null">title = #{title},</if>
+            <if test="keyword != null">keyword = #{keyword},</if>
+            <if test="replyTime != null">reply_time = #{replyTime},</if>
+            <if test="degree != null">degree = #{degree},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteThesisById" parameterType="Long">
+        delete from vr_thesis where id = #{id}
+    </delete>
+
+    <delete id="deleteThesisByIds" parameterType="String">
+        delete from vr_thesis where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>