From bb4f30069c96336dd960a2dff734d6a24ea86f72 Mon Sep 17 00:00:00 2001 From: kylin L <452061493@qq.com> Date: Wed, 3 Jan 2024 09:31:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=98=E5=BA=93=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/smallProgram/question/add.html | 327 +++++++++++++++ .../project/smallProgram/question/detail.html | 345 ++++++++++++++++ .../project/smallProgram/question/edit.html | 380 ++++++++++++++++++ .../project/smallProgram/question/view.html | 195 +++++++++ .../controller/AnswerBankController.java | 110 +++++ .../controller/QuestionBankController.java | 184 +++++++++ .../com/zdxt/knowledge/domain/AnswerBank.java | 80 ++++ .../zdxt/knowledge/domain/QuestionBank.java | 124 ++++++ .../knowledge/mapper/AnswerBankMapper.java | 63 +++ .../knowledge/mapper/QuestionBankMapper.java | 70 ++++ .../knowledge/service/IAnswerBankService.java | 62 +++ .../service/IQuestionBankService.java | 86 ++++ .../service/impl/AnswerBankServiceImpl.java | 95 +++++ .../service/impl/QuestionBankServiceImpl.java | 197 +++++++++ .../resources/mapper/AnswerBankMapper.xml | 104 +++++ .../resources/mapper/QuestionBankMapper.xml | 129 ++++++ .../zdxt/knowledge/dto/QuestionBankBean.java | 144 +++++++ 17 files changed, 2695 insertions(+) create mode 100644 lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/add.html create mode 100644 lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/detail.html create mode 100644 lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/edit.html create mode 100644 lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/view.html create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/AnswerBankController.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/QuestionBankController.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/AnswerBank.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/QuestionBank.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/AnswerBankMapper.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/QuestionBankMapper.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IAnswerBankService.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IQuestionBankService.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/AnswerBankServiceImpl.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/QuestionBankServiceImpl.java create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/AnswerBankMapper.xml create mode 100755 lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/QuestionBankMapper.xml create mode 100755 lib/EmergencyServiceApi/emergencyKnowledgeServiceApi/src/main/java/com/zdxt/knowledge/dto/QuestionBankBean.java diff --git a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/add.html b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/add.html new file mode 100644 index 00000000..aec53011 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/add.html @@ -0,0 +1,327 @@ + + + + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID标识内容操作
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ + + + + + diff --git a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/detail.html b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/detail.html new file mode 100644 index 00000000..cc5c5204 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/detail.html @@ -0,0 +1,345 @@ + + + + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ + + + + + + + + + + +
ID标识内容
+
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+ + + + + + diff --git a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/edit.html b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/edit.html new file mode 100644 index 00000000..6d3cf424 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/edit.html @@ -0,0 +1,380 @@ + + + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID标识内容操作
+
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+ + + + + + diff --git a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/view.html b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/view.html new file mode 100644 index 00000000..af6edde4 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/smallProgram/question/view.html @@ -0,0 +1,195 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/AnswerBankController.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/AnswerBankController.java new file mode 100755 index 00000000..573cf9a1 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/AnswerBankController.java @@ -0,0 +1,110 @@ +package com.zdxt.knowledge.controller; + +import java.util.List; + +import com.zdxt.common.ZDResponse; +import com.zdxt.common.controller.BaseController; +import com.zdxt.common.util.TableDataInfo; +import com.zdxt.knowledge.domain.AnswerBank; +import com.zdxt.knowledge.service.IAnswerBankService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * 答案库Controller + * + * @author ruoyi + * @date 2023-12-29 + */ +@Controller +@RequestMapping("/small/answer") +public class AnswerBankController extends BaseController +{ + private String prefix = "project/smallProgram/answer"; + + @Autowired + private IAnswerBankService answerBankService; + + @RequiresPermissions("small:answer:view") + @GetMapping() + public String bank() + { + return prefix + "/view"; + } + + /** + * 查询答案库列表 + */ + @RequiresPermissions("small:answer:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(AnswerBank answerBank) + { + startPage(); + List list = answerBankService.selectAnswerBankList(answerBank); + return getDataTable(list); + } + + /** + * 新增答案库 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存答案库 + */ + @RequiresPermissions("small:answer:add") + @PostMapping("/add") + @ResponseBody + public ZDResponse addSave(AnswerBank answerBank) + { + int resNum = answerBankService.insertAnswerBank(answerBank); + return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); + } + + /** + * 修改答案库 + */ + @GetMapping("/edit/{guid}") + public String edit(@PathVariable("guid") String guid, ModelMap mmap) + { + AnswerBank answerBank = answerBankService.selectAnswerBankById(guid); + mmap.put("answerBank", answerBank); + return prefix + "/edit"; + } + + /** + * 修改保存答案库 + */ + @RequiresPermissions("small:answer:edit") + @PostMapping("/edit") + @ResponseBody + public ZDResponse editSave(AnswerBank answerBank) + { + int resNum = answerBankService.updateAnswerBank(answerBank); + return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); + } + + /** + * 删除答案库 + */ + @RequiresPermissions("small:answer:remove") + @PostMapping( "/remove") + @ResponseBody + public ZDResponse remove(String ids) + { + int resNum = answerBankService.deleteAnswerBankByIds(ids); + return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); + } +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/QuestionBankController.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/QuestionBankController.java new file mode 100755 index 00000000..9f6e2a97 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/QuestionBankController.java @@ -0,0 +1,184 @@ +package com.zdxt.knowledge.controller; + +import java.util.HashMap; +import java.util.List; + +import cn.hutool.core.bean.BeanUtil; +import com.zdxt.common.ZDResponse; +import com.zdxt.common.controller.BaseController; +import com.zdxt.common.util.TableDataInfo; +import com.zdxt.knowledge.domain.AnswerBank; +import com.zdxt.knowledge.domain.QuestionBank; +import com.zdxt.knowledge.dto.QuestionBankBean; +import com.zdxt.knowledge.service.IAnswerBankService; +import com.zdxt.knowledge.service.IQuestionBankService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +/** + * 题库Controller + * + * @author ruoyi + * @date 2023-12-29 + */ +@Controller +@RequestMapping("/small/question") +public class QuestionBankController extends BaseController +{ + private String prefix = "project/smallProgram/question"; + + @Autowired private IQuestionBankService questionBankService; + @Autowired private IAnswerBankService answerBankService; + + @RequiresPermissions("small:question:view") + @GetMapping() + public String bank() + { + return prefix + "/view"; + } + + /** + * 查询题库列表 + */ + @RequiresPermissions("small:question:view") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(QuestionBank questionBank) + { + startPage(); + List list = questionBankService.selectQuestionBankList(questionBank); + return getDataTable(list); + } + + /** + * 新增题库 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存题库 + */ + @RequiresPermissions("small:question:add") + @PostMapping("/add") + @ResponseBody + public ZDResponse addSave(@RequestParam("file") MultipartFile[] files, QuestionBankBean bean) + { + int resNum = questionBankService.insertQuestionBank(bean, files); + return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); + } + + /** + * 修改题库 + */ + @GetMapping("/edit/{guid}") + public String edit(@PathVariable("guid") String guid, ModelMap mmap) + { + QuestionBank questionBank = questionBankService.selectQuestionBankById(guid); + mmap.put("questionBank", questionBank); + AnswerBank answerBank = new AnswerBank(); + answerBank.setQuestionBankId(questionBank.getGuid()); + List answerBankList = answerBankService.selectAnswerBankList(answerBank); + mmap.put("answerBanks", answerBankList); + return prefix + "/edit"; + } + + /** + * 修改保存题库 + */ + @RequiresPermissions("small:question:edit") + @PostMapping("/edit") + @ResponseBody + public ZDResponse editSave(@RequestParam("file") MultipartFile[] files, QuestionBankBean bean) + { + int resNum = questionBankService.updateQuestionBank(bean, files); + return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); + } + + /** + * 删除题库 + */ + @RequiresPermissions("small:question:remove") + @PostMapping( "/remove") + @ResponseBody + public ZDResponse remove(String ids) + { + int resNum = questionBankService.deleteQuestionBankByIds(ids); + return resNum>0? ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); + } + + /** + * 修改题库 + */ + @GetMapping("/detail/{guid}") + public String detail(@PathVariable("guid") String guid, ModelMap mmap) + { + QuestionBank questionBank = questionBankService.selectQuestionBankById(guid); + mmap.put("questionBank", questionBank); + AnswerBank answerBank = new AnswerBank(); + answerBank.setQuestionBankId(questionBank.getGuid()); + List answerBankList = answerBankService.selectAnswerBankList(answerBank); + mmap.put("answerBanks", answerBankList); + return prefix + "/detail"; + } + + /** + * 修改发布状态 + */ + @RequiresPermissions("small:library:edit") + @PostMapping("/toPublishState") + @ResponseBody + public ZDResponse toPublishState(String ids, String state) + { + int resNum = questionBankService.updatePublishState(ids, state); + return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); + } + + /** + * 查询附件信息 + * @param key + * @return + */ + @GetMapping( "/queryFiles/{key}") + @ResponseBody + public ZDResponse queryFiles(@PathVariable String key){ + HashMap map = new HashMap<>(); + map.put("filePreview", questionBankService.queryFiles(key)); + return ZDResponse.success("获取成功",map); + } + + /** + * 查询附件信息 + * @param key + * @return + */ + @PostMapping( "/queryFilesPost") + @ResponseBody + public ZDResponse queryFilesPost(String key){ + HashMap map = new HashMap<>(); + map.put("filePreview", questionBankService.queryFiles(key)); + return ZDResponse.success("获取成功",map); + } + + /** + * 删除案例要素附件 + * @param key + * @return + */ + @PostMapping("/removeFile") + @ResponseBody + public ZDResponse removeFile(String key) { + if (questionBankService.removeFile(key) > 0) { + return ZDResponse.success("操作成功"); + } else { + return ZDResponse.error("操作失败"); + } + } +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/AnswerBank.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/AnswerBank.java new file mode 100755 index 00000000..5da0d769 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/AnswerBank.java @@ -0,0 +1,80 @@ +package com.zdxt.knowledge.domain; + +import com.zdxt.common.BaseDomain; + +/** + * 答案库对象 answer_bank + * + * @author ruoyi + * @date 2023-12-29 + */ +public class AnswerBank extends BaseDomain +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private String guid; + + /** 关联问题库 */ + private String questionBankId; + + /** 标题 */ + private String title; + + /** 内容 */ + private String content; + + /** 状态(0:正常,1:停用) */ + private Integer status; + + /** 排序 */ + private Integer sort; + + public String getGuid() { + return guid; + } + + public void setGuid(String guid) { + this.guid = guid; + } + + public String getQuestionBankId() { + return questionBankId; + } + + public void setQuestionBankId(String questionBankId) { + this.questionBankId = questionBankId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/QuestionBank.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/QuestionBank.java new file mode 100755 index 00000000..dd207528 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/QuestionBank.java @@ -0,0 +1,124 @@ +package com.zdxt.knowledge.domain; + +import com.zdxt.common.BaseDomain; + +/** + * 题库对象 question_bank + * + * @author ruoyi + * @date 2023-12-29 + */ +public class QuestionBank extends BaseDomain +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private String guid; + + /** 标题 */ + private String title; + + /** 内容 */ + private String content; + + /** 提示 */ + private String tips; + + /** 答案 */ + private String answer; + + /** 排序 */ + private Long srot; + + /** 状态(0:正常,1:停用) */ + private Integer status; + + /** 类型(0:单选,1:多选,2:判断) */ + private Integer type; + + /** 发布时间 */ + private String publishdate; + + /** 发布状态(0:待发布,1:已发布,2:已上线,3:已下线) */ + private Integer publishstate; + + public String getGuid() { + return guid; + } + + public void setGuid(String guid) { + this.guid = guid; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getTips() { + return tips; + } + + public void setTips(String tips) { + this.tips = tips; + } + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + public Long getSrot() { + return srot; + } + + public void setSrot(Long srot) { + this.srot = srot; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getPublishdate() { + return publishdate; + } + + public void setPublishdate(String publishdate) { + this.publishdate = publishdate; + } + + public Integer getPublishstate() { + return publishstate; + } + + public void setPublishstate(Integer publishstate) { + this.publishstate = publishstate; + } +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/AnswerBankMapper.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/AnswerBankMapper.java new file mode 100755 index 00000000..b148c727 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/AnswerBankMapper.java @@ -0,0 +1,63 @@ +package com.zdxt.knowledge.mapper; + +import com.zdxt.knowledge.domain.AnswerBank; + +import java.util.List; + +/** + * 答案库Mapper接口 + * + * @author ruoyi + * @date 2023-12-29 + */ +public interface AnswerBankMapper +{ + /** + * 查询答案库 + * + * @param guid 答案库ID + * @return 答案库 + */ + public AnswerBank selectAnswerBankById(String guid); + + /** + * 查询答案库列表 + * + * @param answerBank 答案库 + * @return 答案库集合 + */ + public List selectAnswerBankList(AnswerBank answerBank); + + /** + * 新增答案库 + * + * @param answerBank 答案库 + * @return 结果 + */ + public int insertAnswerBank(AnswerBank answerBank); + + /** + * 修改答案库 + * + * @param answerBank 答案库 + * @return 结果 + */ + public int updateAnswerBank(AnswerBank answerBank); + + /** + * 删除答案库 + * + * @param guid 答案库ID + * @return 结果 + */ + public int deleteAnswerBankById(String guid); + + /** + * 批量删除答案库 + * + * @param guids 需要删除的数据ID + * @return 结果 + */ + public int deleteAnswerBankByIds(String[] guids); + public int deleteAnswerBankByQusetionIds(String[] guids); +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/QuestionBankMapper.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/QuestionBankMapper.java new file mode 100755 index 00000000..bc20b287 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/QuestionBankMapper.java @@ -0,0 +1,70 @@ +package com.zdxt.knowledge.mapper; + +import com.zdxt.knowledge.domain.QuestionBank; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 题库Mapper接口 + * + * @author ruoyi + * @date 2023-12-29 + */ +public interface QuestionBankMapper +{ + /** + * 查询题库 + * + * @param guid 题库ID + * @return 题库 + */ + public QuestionBank selectQuestionBankById(String guid); + + /** + * 查询题库列表 + * + * @param questionBank 题库 + * @return 题库集合 + */ + public List selectQuestionBankList(QuestionBank questionBank); + + /** + * 新增题库 + * + * @param questionBank 题库 + * @return 结果 + */ + public int insertQuestionBank(QuestionBank questionBank); + + /** + * 修改题库 + * + * @param questionBank 题库 + * @return 结果 + */ + public int updateQuestionBank(QuestionBank questionBank); + + /** + * 删除题库 + * + * @param guid 题库ID + * @return 结果 + */ + public int deleteQuestionBankById(String guid); + + /** + * 批量删除题库 + * + * @param guids 需要删除的数据ID + * @return 结果 + */ + public int deleteQuestionBankByIds(String[] guids); + + /** + * 批量修改发布状态 + * @param guids + * @return + */ + public int updatePublishState(@Param("guids") String[] guids, @Param("state") String state, @Param("publishdate") String publishdate); +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IAnswerBankService.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IAnswerBankService.java new file mode 100755 index 00000000..13036856 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IAnswerBankService.java @@ -0,0 +1,62 @@ +package com.zdxt.knowledge.service; + +import com.zdxt.knowledge.domain.AnswerBank; + +import java.util.List; + +/** + * 答案库Service接口 + * + * @author ruoyi + * @date 2023-12-29 + */ +public interface IAnswerBankService +{ + /** + * 查询答案库 + * + * @param guid 答案库ID + * @return 答案库 + */ + public AnswerBank selectAnswerBankById(String guid); + + /** + * 查询答案库列表 + * + * @param answerBank 答案库 + * @return 答案库集合 + */ + public List selectAnswerBankList(AnswerBank answerBank); + + /** + * 新增答案库 + * + * @param answerBank 答案库 + * @return 结果 + */ + public int insertAnswerBank(AnswerBank answerBank); + + /** + * 修改答案库 + * + * @param answerBank 答案库 + * @return 结果 + */ + public int updateAnswerBank(AnswerBank answerBank); + + /** + * 批量删除答案库 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteAnswerBankByIds(String ids); + + /** + * 删除答案库信息 + * + * @param guid 答案库ID + * @return 结果 + */ + public int deleteAnswerBankById(String guid); +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IQuestionBankService.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IQuestionBankService.java new file mode 100755 index 00000000..5e5e0159 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/IQuestionBankService.java @@ -0,0 +1,86 @@ +package com.zdxt.knowledge.service; + +import com.zdxt.common.zdxtFile.AttFileRespDTO; +import com.zdxt.knowledge.domain.QuestionBank; +import com.zdxt.knowledge.dto.QuestionBankBean; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * 题库Service接口 + * + * @author ruoyi + * @date 2023-12-29 + */ +public interface IQuestionBankService +{ + /** + * 查询题库 + * + * @param guid 题库ID + * @return 题库 + */ + public QuestionBank selectQuestionBankById(String guid); + + /** + * 查询题库列表 + * + * @param questionBank 题库 + * @return 题库集合 + */ + public List selectQuestionBankList(QuestionBank questionBank); + + /** + * 新增题库 + * + * @param bean 题库 + * @return 结果 + */ + public int insertQuestionBank(QuestionBankBean bean, MultipartFile[] files); + + /** + * 修改题库 + * + * @param bean 题库 + * @return 结果 + */ + public int updateQuestionBank(QuestionBankBean bean, MultipartFile[] files); + + /** + * 批量删除题库 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteQuestionBankByIds(String ids); + + /** + * 删除题库信息 + * + * @param guid 题库ID + * @return 结果 + */ + public int deleteQuestionBankById(String guid); + + /** + * 批量修改发布状态 + * @param ids + * @return + */ + public int updatePublishState(String ids, String state); + + /** + * 查询附件 + * @param key + * @return + */ + AttFileRespDTO queryFiles(String key); + + /** + * 删除案例要素图片 + * @param key 图片id + * @return + */ + public int removeFile(String key); +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/AnswerBankServiceImpl.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/AnswerBankServiceImpl.java new file mode 100755 index 00000000..7fc721bb --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/AnswerBankServiceImpl.java @@ -0,0 +1,95 @@ +package com.zdxt.knowledge.service.impl; + +import java.util.List; + +import com.zdxt.common.util.Convert; +import com.zdxt.knowledge.domain.AnswerBank; +import com.zdxt.knowledge.mapper.AnswerBankMapper; +import com.zdxt.knowledge.service.IAnswerBankService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 答案库Service业务层处理 + * + * @author ruoyi + * @date 2023-12-29 + */ +@Service +public class AnswerBankServiceImpl implements IAnswerBankService +{ + @Autowired + private AnswerBankMapper answerBankMapper; + + /** + * 查询答案库 + * + * @param guid 答案库ID + * @return 答案库 + */ + @Override + public AnswerBank selectAnswerBankById(String guid) + { + return answerBankMapper.selectAnswerBankById(guid); + } + + /** + * 查询答案库列表 + * + * @param answerBank 答案库 + * @return 答案库 + */ + @Override + public List selectAnswerBankList(AnswerBank answerBank) + { + return answerBankMapper.selectAnswerBankList(answerBank); + } + + /** + * 新增答案库 + * + * @param answerBank 答案库 + * @return 结果 + */ + @Override + public int insertAnswerBank(AnswerBank answerBank) + { + return answerBankMapper.insertAnswerBank(answerBank); + } + + /** + * 修改答案库 + * + * @param answerBank 答案库 + * @return 结果 + */ + @Override + public int updateAnswerBank(AnswerBank answerBank) + { + return answerBankMapper.updateAnswerBank(answerBank); + } + + /** + * 删除答案库对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteAnswerBankByIds(String ids) + { + return answerBankMapper.deleteAnswerBankByIds(Convert.toStrArray(ids)); + } + + /** + * 删除答案库信息 + * + * @param guid 答案库ID + * @return 结果 + */ + @Override + public int deleteAnswerBankById(String guid) + { + return answerBankMapper.deleteAnswerBankById(guid); + } +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/QuestionBankServiceImpl.java b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/QuestionBankServiceImpl.java new file mode 100755 index 00000000..bd39f5da --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/QuestionBankServiceImpl.java @@ -0,0 +1,197 @@ +package com.zdxt.knowledge.service.impl; + +import java.util.ArrayList; +import java.util.List; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import com.zdxt.auth.dto.ZdxtFileBean; +import com.zdxt.auth.feign.FileUploadApi; +import com.zdxt.auth.feign.ZdxtFileCommonApi; +import com.zdxt.common.util.Convert; +import com.zdxt.common.util.DateUtils; +import com.zdxt.common.util.StringUtils; +import com.zdxt.common.zdxtFile.AttFileRespDTO; +import com.zdxt.common.zdxtFile.FilePreviewUtilBean; +import com.zdxt.common.zdxtFile.ZdxtFileCommon; +import com.zdxt.knowledge.domain.AnswerBank; +import com.zdxt.knowledge.domain.QuestionBank; +import com.zdxt.knowledge.dto.QuestionBankBean; +import com.zdxt.knowledge.mapper.AnswerBankMapper; +import com.zdxt.knowledge.mapper.QuestionBankMapper; +import com.zdxt.knowledge.service.IQuestionBankService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +/** + * 题库Service业务层处理 + * + * @author ruoyi + * @date 2023-12-29 + */ +@Service +public class QuestionBankServiceImpl implements IQuestionBankService +{ + @Autowired private QuestionBankMapper questionBankMapper; + @Autowired private AnswerBankMapper answerBankMapper; + @Autowired private FileUploadApi fileUploadApi; + @Autowired private ZdxtFileCommonApi zdxtFileCommonApi; + + /** + * 查询题库 + * + * @param guid 题库ID + * @return 题库 + */ + @Override + public QuestionBank selectQuestionBankById(String guid) + { + return questionBankMapper.selectQuestionBankById(guid); + } + + /** + * 查询题库列表 + * + * @param questionBank 题库 + * @return 题库 + */ + @Override + public List selectQuestionBankList(QuestionBank questionBank) + { + return questionBankMapper.selectQuestionBankList(questionBank); + } + + /** + * 新增题库 + * + * @param bean 题库 + * @return 结果 + */ + @Override + public int insertQuestionBank(QuestionBankBean bean, MultipartFile[] files) + { + QuestionBank questionBank = new QuestionBank(); + BeanUtil.copyProperties(bean, questionBank); + + questionBank.setGuid(StringUtils.getUUID()); + questionBank.setSrot(0L); + int resNum = questionBankMapper.insertQuestionBank(questionBank); + String[] codes = bean.getCodes().split(","); + String[] values = bean.getValues().split(","); + if (resNum > 0 && codes.length > 0) { + for (int i=0; i 0 && ObjectUtil.isNotEmpty(files)) { + for (MultipartFile file : files) { +// todo 将原有关联附件删除在重新上传比较好 + zdxtFileCommonApi.insertZdxtFile(file, questionBank.getGuid(), fileUploadApi.upload(file)); + } + } + return resNum; + } + + /** + * 修改题库 + * + * @param bean 题库 + * @return 结果 + */ + @Override + public int updateQuestionBank(QuestionBankBean bean, MultipartFile[] files) + { + QuestionBank questionBank = new QuestionBank(); + BeanUtil.copyProperties(bean, questionBank); + int resNum = questionBankMapper.updateQuestionBank(questionBank); + + String[] codes = bean.getCodes().split(","); + String[] values = bean.getValues().split(","); + if (resNum > 0 && codes.length > 0) { + answerBankMapper.deleteAnswerBankByQusetionIds(Convert.toStrArray(questionBank.getGuid())); + for (int i=0; i 0 && ObjectUtil.isNotEmpty(files)) { + for (MultipartFile file : files) { +// todo 将原有关联附件删除在重新上传比较好 + zdxtFileCommonApi.insertZdxtFile(file, questionBank.getGuid(), fileUploadApi.upload(file)); + } + } + return resNum; + } + + /** + * 删除题库对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteQuestionBankByIds(String ids) + { + int resNum = questionBankMapper.deleteQuestionBankByIds(Convert.toStrArray(ids)); + if (resNum > 0) { + resNum = answerBankMapper.deleteAnswerBankByQusetionIds(Convert.toStrArray(ids)); + } + return resNum; + } + + /** + * 删除题库信息 + * + * @param guid 题库ID + * @return 结果 + */ + @Override + public int deleteQuestionBankById(String guid) + { + return questionBankMapper.deleteQuestionBankById(guid); + } + + @Override + public int updatePublishState(String ids, String state) { + String publishdate = DateUtils.getTime(); + return questionBankMapper.updatePublishState(Convert.toStrArray(ids), state, publishdate); + } + + @Override + public AttFileRespDTO queryFiles(String key) { + ZdxtFileBean zdxtFileBeanCondition = new ZdxtFileBean(); + zdxtFileBeanCondition.setBusinessId(key); + List fileBeanList = zdxtFileCommonApi.selectZdxtFileList(zdxtFileBeanCondition); + + ArrayList fileList = new ArrayList<>(); + for (ZdxtFileBean fileBean : fileBeanList) { + ZdxtFileCommon zdxtFileCommon = new ZdxtFileCommon(); + BeanUtil.copyProperties(fileBean, zdxtFileCommon); + fileList.add(zdxtFileCommon); + } + + FilePreviewUtilBean filePreviewUtilBean = new FilePreviewUtilBean(); + return filePreviewUtilBean.attachementToAttFileRespDTO(fileList); + } + + @Override + public int removeFile(String key) { + return zdxtFileCommonApi.deleteZdxtFileById(key); + } +} diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/AnswerBankMapper.xml b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/AnswerBankMapper.xml new file mode 100755 index 00000000..a17dcb35 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/AnswerBankMapper.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + select guid, question_bank_id, title, content, status, sort, creator, create_time, updator, update_time from answer_bank + + + + + + + + insert into answer_bank + + guid, + question_bank_id, + title, + content, + status, + sort, + creator, + create_time, + updator, + update_time, + + + #{guid}, + #{questionBankId}, + #{title}, + #{content}, + #{status}, + #{sort}, + #{creator}, + #{createTime}, + #{updator}, + #{updateTime}, + + + + + update answer_bank + + question_bank_id = #{questionBankId}, + title = #{title}, + content = #{content}, + status = #{status}, + sort = #{sort}, + creator = #{creator}, + create_time = #{createTime}, + updator = #{updator}, + update_time = #{updateTime}, + + where guid = #{guid} + + + + delete from answer_bank where guid = #{guid} + + + + delete from answer_bank where guid in + + #{guid} + + + + + delete from answer_bank where question_bank_id in + + #{guid} + + + + \ No newline at end of file diff --git a/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/QuestionBankMapper.xml b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/QuestionBankMapper.xml new file mode 100755 index 00000000..ebc56a27 --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/QuestionBankMapper.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + select guid, title, content, tips, answer, srot, status, type, publishDate, publishState, creator, create_time, updator, update_time from question_bank + + + + + + + + insert into question_bank + + guid, + title, + content, + tips, + answer, + srot, + status, + type, + publishDate, + publishState, + creator, + create_time, + updator, + update_time, + + + #{guid}, + #{title}, + #{content}, + #{tips}, + #{answer}, + #{srot}, + #{status}, + #{type}, + #{publishdate}, + #{publishstate}, + #{creator}, + #{createTime}, + #{updator}, + #{updateTime}, + + + + + update question_bank + + title = #{title}, + content = #{content}, + tips = #{tips}, + answer = #{answer}, + srot = #{srot}, + status = #{status}, + type = #{type}, + publishDate = #{publishdate}, + publishState = #{publishstate}, + creator = #{creator}, + create_time = #{createTime}, + updator = #{updator}, + update_time = #{updateTime}, + + where guid = #{guid} + + + + delete from question_bank where guid = #{guid} + + + + delete from question_bank where guid in + + #{guid} + + + + + update question_bank + + publishDate = #{publishdate}, + publishState = #{state}, + + where guid in + + #{guid} + + + + \ No newline at end of file diff --git a/lib/EmergencyServiceApi/emergencyKnowledgeServiceApi/src/main/java/com/zdxt/knowledge/dto/QuestionBankBean.java b/lib/EmergencyServiceApi/emergencyKnowledgeServiceApi/src/main/java/com/zdxt/knowledge/dto/QuestionBankBean.java new file mode 100755 index 00000000..9d03d1f3 --- /dev/null +++ b/lib/EmergencyServiceApi/emergencyKnowledgeServiceApi/src/main/java/com/zdxt/knowledge/dto/QuestionBankBean.java @@ -0,0 +1,144 @@ +package com.zdxt.knowledge.dto; + +import com.zdxt.common.BaseDomain; + +/** + * 题库对象 question_bank + * + * @author ruoyi + * @date 2023-12-29 + */ +public class QuestionBankBean extends BaseDomain +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private String guid; + + /** 标题 */ + private String title; + + /** 内容 */ + private String content; + + /** 提示 */ + private String tips; + + /** 答案 */ + private String answer; + + /** 排序 */ + private Long srot; + + /** 状态(0:正常,1:停用) */ + private Integer status; + + /** 类型(0:单选,1:多选,2:判断) */ + private Integer type; + + /** 发布时间 */ + private String publishdate; + + /** 发布状态(0:待发布,1:已发布,2:已上线,3:已下线) */ + private Integer publishstate; + + private String codes; + + private String values; + + public String getGuid() { + return guid; + } + + public void setGuid(String guid) { + this.guid = guid; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getTips() { + return tips; + } + + public void setTips(String tips) { + this.tips = tips; + } + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + public Long getSrot() { + return srot; + } + + public void setSrot(Long srot) { + this.srot = srot; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getPublishdate() { + return publishdate; + } + + public void setPublishdate(String publishdate) { + this.publishdate = publishdate; + } + + public Integer getPublishstate() { + return publishstate; + } + + public void setPublishstate(Integer publishstate) { + this.publishstate = publishstate; + } + + public String getCodes() { + return codes; + } + + public void setCodes(String codes) { + this.codes = codes; + } + + public String getValues() { + return values; + } + + public void setValues(String values) { + this.values = values; + } +}