Browse Source

题目管理完善

master
yanyan 3 years ago
parent
commit
7aa5bbbff1
  1. 24
      lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/feign/RoleDcitApiImpl.java
  2. 23
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/add.html
  3. 121
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/bind.html
  4. 30
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/detail.html
  5. 18
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/edit.html
  6. 30
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/view.html
  7. 5
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/scene/detail.html
  8. 32
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneQuestionController.java
  9. 145
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneQuestion.java
  10. 39
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneQuestionBindRequest.java
  11. 8
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/SceneQuestionMapper.java
  12. 8
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/ISceneQuestionService.java
  13. 70
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/SceneQuestionServiceImpl.java
  14. 15
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneQuestionMapper.xml
  15. 5
      lib/EmergencyServiceApi/emergencyAuthServiceApi/src/main/java/com/zdxt/auth/feign/RoleApi.java

24
lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/feign/RoleDcitApiImpl.java

@ -4,12 +4,17 @@ import cn.hutool.core.bean.BeanUtil;
import com.zdxt.auth.dto.RoleBean;
import com.zdxt.auth.dto.RoleDictBean;
import com.zdxt.auth.project.system.role.mapper.RoleDictMapper;
import com.zdxt.auth.project.system.role.mapper.RoleMapper;
import com.zdxt.domain.auth.Role;
import com.zdxt.domain.auth.RoleDict;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created with IntelliJ IDEA.
@ -24,11 +29,14 @@ public class RoleDcitApiImpl implements RoleApi {
@Autowired
private RoleDictMapper roleDictMapper;
@Autowired
private RoleMapper roleMapper;
@Override
public List<RoleDictBean> getRoleDictItemByRoleId(String roleId) {
List<RoleDict> roleDictList = roleDictMapper.selectRoleDictById(roleId);
List<RoleDictBean> beanList = new ArrayList<>();
for(RoleDict roleDict : roleDictList){
for (RoleDict roleDict : roleDictList) {
RoleDictBean bean = new RoleDictBean();
BeanUtil.copyProperties(roleDict, bean);
beanList.add(bean);
@ -40,4 +48,18 @@ public class RoleDcitApiImpl implements RoleApi {
public RoleBean getRolesByCode(String roleCode) {
return null;
}
@Override
public List<RoleBean> getRolesAll() {
List<RoleBean> rolesList = new ArrayList<>();
List<Role> roles = roleMapper.selectRoleList(new Role());
if (CollectionUtils.isNotEmpty(roles)) {
rolesList = roles.stream().map(item -> {
RoleBean roleBean = new RoleBean();
BeanUtils.copyProperties(item, roleBean);
return roleBean;
}).collect(Collectors.toList());
}
return rolesList;
}
}

23
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/add.html

@ -1,35 +1,38 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增场景题目')" />
<th:block th:include="zdxtInclude :: header('新增场景题目')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-question-add">
<input name="parentId" type="text" hidden>
<div class="form-group">
<label class="col-sm-3 control-label">题目名称:</label>
<div class="col-sm-8">
<input name="name" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<input name="roleId" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<select name="status">
<select name="status" class="form-control">
<option value="0">有效</option>
<option value="1">无效</option>
</select>
</div>
</div>
<div class="form-group" shiro:hasPermission="system:user:isAllow">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<label th:each="role:${roles}" class="check-box">
<input name="roleId" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.status == '1'}">
</label>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="zdxtInclude :: footer" />
<script type="text/javascript">
var prefix = ctx + "project/question"
$("#form-question-add").validate({
@ -38,6 +41,8 @@
function submitHandler() {
if ($.validate.form()) {
var parentId = [[${parentId}]];
$("[name='parentId']").val(parentId);
$.operate.save(prefix + "/add", $('#form-question-add').serialize());
}
}

121
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/bind.html

@ -1,38 +1,125 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('场景题目绑定')" />
<th:block th:include="zdxtInclude :: header('场景题目绑定')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-question-detail" th:object="${sceneQuestion}">
<h2 th:value="*{name}"></h2>
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-question-bind" th:object="${sceneQuestion}">
<h2 th:text="*{name}" style="margin-bottom: 30px;"></h2>
<input name="id" th:field="*{id}" type="hidden">
<div class="form-group">
<div class="col-sm-8">
<input name="name" class="form-control" type="text" placeholder="A:...">
<div class="col-sm-6">
<input name="answer" class="form-control" type="text" placeholder="A...">
</div>
<div class="col-sm-2" style="width: 12%">
<input type="checkbox" name="check" onclick="inputCheck(this)">
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select th:each="li:${list}" class="form-control">
<option th:value="${li.id}" th:text="${li.name}"></option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-8">
<input name="groupId" class="form-control" type="text" placeholder="B:...">
<div class="col-sm-6">
<input name="answer" class="form-control" type="text" placeholder="B...">
</div>
<div class="col-sm-2" style="width: 12%">
<input type="checkbox" name="check" onclick="inputCheck(this)">
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select th:each="li:${list}" class="form-control">
<option th:value="${li.id}" th:text="${li.name}"></option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-8">
<input name="roleId" class="form-control" type="text" placeholder="C:...">
<div class="col-sm-6">
<input name="answer" class="form-control" type="text" placeholder="C...">
</div>
<div class="col-sm-2" style="width: 12%">
<input type="checkbox" name="check" onclick="inputCheck(this)">
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select th:each="li:${list}" class="form-control">
<option th:value="${li.id}" th:text="${li.name}"></option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-8">
<input name="roleId" class="form-control" type="text" placeholder="D:...">
<div class="col-sm-6">
<input name="answer" class="form-control" type="text" placeholder="D...">
</div>
<div class="col-sm-2" style="width: 12%">
<input type="checkbox" name="check" onclick="inputCheck(this)">
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select th:each="li:${list}" class="form-control">
<option th:value="${li.id}" th:text="${li.name}"></option>
</select>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
</form>
</div>
<th:block th:include="zdxtInclude :: footer"/>
<script th:inline="javascript">
var prefix = ctx + "project/question"
$("#form-question-add").validate({
focusCleanup: true
});
function inputCheck(obj) {
if ($(obj).prop('checked')) {
// 还原之前样式
$("[name='check']").prop('checked', false);
// $("[name='select']").val("");
$(".col-sm-4").hide();
//选中当前样式
$(obj).prop('checked', true)
$(obj).parent().next().show();
} else {
$(obj).parent().next().hide();
}
}
</script>
function submitHandler() {
if ($.validate.form()) {
var reqData = {};
var nextQuestionId;
var reqList = new Array();
var checkFlag = false;
var elements = document.getElementsByName("answer");
for (let i = 0; i < document.getElementsByName("answer").length; i++) {
if (elements[i].value === "") {
$.modal.alertWarning("请将选项填写完整");
return;
}
var req = {};
req.answer = elements[i].value;
req.check = elements[i].parentElement.nextElementSibling.firstElementChild.checked;
checkFlag = checkFlag === true ? true : req.check;
reqList.push(req);
debugger
if (req.check) {
let divData = elements[i].parentElement.nextElementSibling.nextElementSibling;
nextQuestionId = $(divData).find("select").val();
}
}
if (!checkFlag) {
$.modal.alertWarning("请勾选一个正确选项");
return;
}
reqData.id = $("[name = 'id']").val();
reqData.nextQuestionId = nextQuestionId;
reqData.answer = JSON.stringify(reqList);
$.operate.save(prefix + "/bindAnswer", reqData);
}
}
</script>
</body>
</html>

30
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/detail.html

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('场景题目详情')" />
<th:block th:include="zdxtInclude :: header('场景题目详情')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
@ -10,19 +10,13 @@
<div class="form-group">
<label class="col-sm-3 control-label">题目名称:</label>
<div class="col-sm-8">
<input name="name" th:field="*{name}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<input name="roleId" th:field="*{roleId}" class="form-control" type="text">
<input name="name" th:field="*{name}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<select name="status">
<select name="status" class="form-control" th:field="*{status}" readonly>
<option value="0">有效</option>
<option value="1">无效</option>
</select>
@ -31,12 +25,26 @@
<div class="form-group">
<label class="col-sm-3 control-label">创建人:</label>
<div class="col-sm-8">
<input name="creator" th:field="*{creator}" class="form-control" type="text">
<input name="creator" th:field="*{creator}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">创建时间:</label>
<div class="col-sm-8">
<input name="createTime" th:field="*{createTime}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<label th:each="role:${roles}" class="check-box">
<input name="roleId" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${sceneQuestion.roleId.contains(role.roleId.toString())}" th:disabled="${role.status == '1'}">
</label>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="zdxtInclude :: footer" />
<script type="text/javascript">
</script>

18
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/edit.html

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改场景题目')" />
<th:block th:include="zdxtInclude :: header('修改场景题目')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
@ -13,30 +13,26 @@
<input name="name" th:field="*{name}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<input name="roleId" th:field="*{roleId}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<select name="status">
<select name="status" class="form-control">
<option value="0">有效</option>
<option value="1">无效</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">创建人:</label>
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<input name="creator" th:field="*{creator}" class="form-control" type="text">
<label th:each="role:${roles}" class="check-box">
<input name="roleId" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${sceneQuestion.roleId.contains(role.roleId.toString())}" th:disabled="${role.status == '1'}">
</label>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="zdxtInclude :: footer" />
<script type="text/javascript">
var prefix = ctx + "project/question";
$("#form-question-edit").validate({

30
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/view.html

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('场景题目列表')"/>
<th:block th:include="zdxtInclude :: header('场景题目列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
@ -18,12 +18,12 @@
<li>
<p>创建时间:</p>
<input type="text" class="time-input" id="createTime" placeholder="年-月-日"
name="createTime" style="width: 200px;"/>
name="createTime" data-format="yyyy-MM-dd HH:mm:ss" style="width: 200px;"/>
</li>
<li>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-reset btn-rounded btn-sm" onclick="$.form.reset()"><i
<a class="btn btn-reset btn-rounded btn-sm" onclick="reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
@ -32,7 +32,7 @@
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:question:add">
<a class="btn btn-success" onclick="add()" shiro:hasPermission="system:question:add">
<i class="fa fa-plus"></i> 新增题目
</a>
</div>
@ -41,20 +41,21 @@
</div>
</div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="zdxtInclude :: footer"/>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('project:question:edit')}]];
var removeFlag = [[${@permission.hasPermi('project:question:remove')}]];
var detailFlag = [[${@permission.hasPermi('project:question:detail')}]];
var bindFlag = [[${@permission.hasPermi('project:question:bind')}]];
var prefix = ctx + "project/question";
var parentId = [[${parentId}]];
$(function () {
var parentId = [[${parentId}]];
$("[name='parentId']").val(parentId);
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
createUrl: prefix + "/add/{}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
@ -72,8 +73,11 @@
title: '题目名称'
},
{
field: 'roleId',
title: '角色'
field: 'roleIdStr',
title: '角色',
formatter: function (value, index) {
return value.length > 6 ? value.substr(0, 6) +"..." : value;
}
},
{
field: 'creator',
@ -110,9 +114,19 @@
$.modal.open("查看场景题目", ctx + "project/question/detail/" + id, width, height);
}
function add() {
$.modal.open("查看场景题目", ctx + "project/question/add/" + parentId, 800, 450);
}
function bind(id, width, height) {
$.modal.open("", ctx + "project/question/bind/" + id, width, height);
}
function reset() {
$("[name='name']").val("");
$("[name='createTime']").val("");
$.table.search()
}
</script>
</body>
</html>

5
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/scene/detail.html

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('场景详情')"/>
<th:block th:include="zdxtInclude :: header('场景详情')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
@ -69,7 +69,7 @@
</div>
</form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="zdxtInclude :: footer"/>
<script type="text/javascript" th:inline="javascript">
var sceneObj = [[${sceneManage}]];
var sceneType = [[${@dict.getType('scene_type')}]];
@ -81,7 +81,6 @@
debugger
if (sceneType.length > 0) {
for (var i = 0; i <= sceneType.length; i++) {
console.log(sceneType[i].dictValue);
if (type === sceneType[i].dictValue) {
$("[name = 'type']").val(sceneType[i].dictLabel)
break

32
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneQuestionController.java

@ -1,17 +1,22 @@
package com.zdxt.knowledge.controller;
import com.zdxt.auth.feign.RoleApi;
import com.zdxt.common.ZDResponse;
import com.zdxt.common.controller.BaseController;
import com.zdxt.common.util.TableDataInfo;
import com.zdxt.knowledge.domain.SceneQuestion;
import com.zdxt.knowledge.service.ISceneQuestionService;
import org.apache.commons.collections.CollectionUtils;
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 java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 场景题目Controller
@ -27,6 +32,9 @@ public class SceneQuestionController extends BaseController {
@Autowired
private ISceneQuestionService sceneQuestionService;
@Autowired
private RoleApi roleApi;
@RequiresPermissions("project:question:view")
@GetMapping("/view/{parentId}")
public String question(@PathVariable("parentId") Long parentId, ModelMap mmap) {
@ -51,6 +59,7 @@ public class SceneQuestionController extends BaseController {
public String detail(@PathVariable("id") Long id, ModelMap mmap) {
SceneQuestion sceneQuestion = sceneQuestionService.selectSceneQuestionById(id);
mmap.put("sceneQuestion", sceneQuestion);
mmap.put("roles", roleApi.getRolesAll());
return prefix + "/detail";
}
@ -58,7 +67,12 @@ public class SceneQuestionController extends BaseController {
@GetMapping("/bind/{id}")
public String bind(@PathVariable("id") Long id, ModelMap mmap) {
SceneQuestion sceneQuestion = sceneQuestionService.selectSceneQuestionById(id);
List<SceneQuestion> list = sceneQuestionService.selectSceneQuestionList(new SceneQuestion());
if (CollectionUtils.isNotEmpty(list)) {
list = list.stream().filter(item -> !Objects.equals(item.getId(), id)).collect(Collectors.toList());
}
mmap.put("sceneQuestion", sceneQuestion);
mmap.put("list", list);
return prefix + "/bind";
}
@ -78,8 +92,10 @@ public class SceneQuestionController extends BaseController {
/**
* 新增场景题目
*/
@GetMapping("/add")
public String add() {
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) {
mmap.put("parentId", parentId);
mmap.put("roles", roleApi.getRolesAll());
return prefix + "/add";
}
@ -101,6 +117,7 @@ public class SceneQuestionController extends BaseController {
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
SceneQuestion sceneQuestion = sceneQuestionService.selectSceneQuestionById(id);
mmap.put("sceneQuestion", sceneQuestion);
mmap.put("roles", roleApi.getRolesAll());
return prefix + "/edit";
}
@ -125,4 +142,15 @@ public class SceneQuestionController extends BaseController {
return sceneQuestionService.deleteSceneQuestionByIds(ids) > 0
? ZDResponse.success() : ZDResponse.error("删除失败");
}
/**
* 绑定场景题目
*/
@RequiresPermissions("project:question:bind")
@PostMapping("/bindAnswer")
@ResponseBody
public ZDResponse bindAnswer(SceneQuestion sceneQuestion) {
return sceneQuestionService.bindAnswer(sceneQuestion) > 0
? ZDResponse.success() : ZDResponse.error("绑定失败");
}
}

145
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneQuestion.java

@ -15,110 +15,135 @@ import java.util.Map;
* @author ruoyi
* @date 2023-12-26
*/
public class SceneQuestion implements Serializable
{
public class SceneQuestion implements Serializable {
private static final long serialVersionUID = 1L;
/** 主键 */
/**
* 主键
*/
private Long id;
/** 题目名称 */
/**
* 题目名称
*/
@Excel(name = "题目名称")
private String name;
/** 分组 */
/**
* 分组
*/
@Excel(name = "场景id")
private String parentId;
private Long parentId;
/** 角色 */
/**
* 角色
*/
@Excel(name = "角色")
private String roleId;
/** 状态0有效1无效 */
private String roleIdStr;
/**
* 状态0有效1无效
*/
@Excel(name = "状态0有效1无效")
private Integer status;
/** 创建人 */
/**
* 创建人
*/
@Excel(name = "创建人")
private String creator;
/** 创建时间 */
/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新时间 */
private Date createTimeEnd;
/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** 请求参数 */
/**
* 答案
*/
private String answer;
/**
* 下一个答案
*/
private Long nextQuestionId;
/**
* 请求参数
*/
private Map<String, Object> params;
public void setId(Long id)
{
public void setId(Long id) {
this.id = id;
}
public Long getId()
{
public Long getId() {
return id;
}
public void setName(String name)
{
public void setName(String name) {
this.name = name;
}
public String getName()
{
public String getName() {
return name;
}
public void setRoleId(String roleId)
{
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public String getRoleId()
{
public String getRoleId() {
return roleId;
}
public void setStatus(Integer status)
{
public void setStatus(Integer status) {
this.status = status;
}
public Integer getStatus()
{
public Integer getStatus() {
return status;
}
public void setCreator(String creator)
{
public void setCreator(String creator) {
this.creator = creator;
}
public String getCreator()
{
public String getCreator() {
return creator;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("roleId", getRoleId())
.append("parentId", getParentId())
.append("status", getStatus())
.append("answer", getAnswer())
.append("nextQuestionId", getNextQuestionId())
.append("creator", getCreator())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public Date getCreateTime() {
return createTime;
@ -143,4 +168,44 @@ public class SceneQuestion implements Serializable
public void setParams(Map<String, Object> params) {
this.params = params;
}
public Date getCreateTimeEnd() {
return createTimeEnd;
}
public void setCreateTimeEnd(Date createTimeEnd) {
this.createTimeEnd = createTimeEnd;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getRoleIdStr() {
return roleIdStr;
}
public void setRoleIdStr(String roleIdStr) {
this.roleIdStr = roleIdStr;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public Long getNextQuestionId() {
return nextQuestionId;
}
public void setNextQuestionId(Long nextQuestionId) {
this.nextQuestionId = nextQuestionId;
}
}

39
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneQuestionBindRequest.java

@ -0,0 +1,39 @@
package com.zdxt.knowledge.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 场景题目对象 scene_question
*
* @author ruoyi
* @date 2023-12-26
*/
@Data
public class SceneQuestionBindRequest implements Serializable {
/**
* 主键
*/
private Long id;
/**
* 答案
*/
private List<QuestionAnswer> answerList;
/**
* 下一个答案
*/
private Long nextQuestionId;
@Data
public static class QuestionAnswer {
public String answerEle;
public boolean checkFlag;
}
}

8
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/SceneQuestionMapper.java

@ -59,4 +59,12 @@ public interface SceneQuestionMapper
* @return 结果
*/
public int deleteSceneQuestionByIds(String[] ids);
/**
* 绑定场景题目
*
* @param sceneQuestion
* @return 结果
*/
public int bindAnswer(SceneQuestion sceneQuestion);
}

8
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/ISceneQuestionService.java

@ -59,4 +59,12 @@ public interface ISceneQuestionService
* @return 结果
*/
public int deleteSceneQuestionById(Long id);
/**
* 绑定场景题目信息
*
* @param sceneQuestion
* @return 结果
*/
public int bindAnswer(SceneQuestion sceneQuestion);
}

70
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/SceneQuestionServiceImpl.java

@ -1,14 +1,22 @@
package com.zdxt.knowledge.service.impl;
import com.zdxt.auth.dto.RoleBean;
import com.zdxt.auth.dto.UserBean;
import com.zdxt.auth.feign.RoleApi;
import com.zdxt.auth.feign.UserApi;
import com.zdxt.common.util.Convert;
import com.zdxt.common.util.DateUtils;
import com.zdxt.knowledge.domain.SceneQuestion;
import com.zdxt.knowledge.mapper.SceneQuestionMapper;
import com.zdxt.knowledge.service.ISceneQuestionService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 场景题目Service业务层处理
@ -17,11 +25,16 @@ import java.util.List;
* @date 2023-12-26
*/
@Service
public class SceneQuestionServiceImpl implements ISceneQuestionService
{
public class SceneQuestionServiceImpl implements ISceneQuestionService {
@Autowired
private SceneQuestionMapper sceneQuestionMapper;
@Autowired
private UserApi userApi;
@Autowired
private RoleApi roleApi;
/**
* 查询场景题目
*
@ -29,8 +42,7 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService
* @return 场景题目
*/
@Override
public SceneQuestion selectSceneQuestionById(Long id)
{
public SceneQuestion selectSceneQuestionById(Long id) {
return sceneQuestionMapper.selectSceneQuestionById(id);
}
@ -41,9 +53,26 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService
* @return 场景题目
*/
@Override
public List<SceneQuestion> selectSceneQuestionList(SceneQuestion sceneQuestion)
{
return sceneQuestionMapper.selectSceneQuestionList(sceneQuestion);
public List<SceneQuestion> selectSceneQuestionList(SceneQuestion sceneQuestion) {
List<RoleBean> rolesAll = roleApi.getRolesAll();
if (Objects.nonNull(sceneQuestion.getCreateTime())) {
sceneQuestion.setCreateTimeEnd(DateUtils.addDays(sceneQuestion.getCreateTime(), 1));
}
List<SceneQuestion> questionList = sceneQuestionMapper.selectSceneQuestionList(sceneQuestion);
if (CollectionUtils.isNotEmpty(questionList) && CollectionUtils.isNotEmpty(rolesAll)) {
Map<Long, String> roleMap = rolesAll.stream()
.collect(Collectors.toMap(RoleBean::getRoleId, RoleBean::getRoleName));
questionList = questionList.stream()
.filter(item -> Objects.nonNull(item.getRoleId()))
.peek(item -> {
item.setRoleIdStr(item.getRoleId());
String[] ids = item.getRoleIdStr().split(",");
for (int i = 0; i < ids.length; i++) {
item.setRoleIdStr(item.getRoleIdStr().replace(ids[i], roleMap.get(Long.valueOf(ids[i]))));
}
}).collect(Collectors.toList());
}
return questionList;
}
/**
@ -53,9 +82,12 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService
* @return 结果
*/
@Override
public int insertSceneQuestion(SceneQuestion sceneQuestion)
{
public int insertSceneQuestion(SceneQuestion sceneQuestion) {
UserBean userBean = userApi.getCurrentUser();
if (Objects.nonNull(userBean)) {
sceneQuestion.setCreator(userBean.getUserName());
sceneQuestion.setCreateTime(DateUtils.getNowDate());
}
return sceneQuestionMapper.insertSceneQuestion(sceneQuestion);
}
@ -66,8 +98,7 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService
* @return 结果
*/
@Override
public int updateSceneQuestion(SceneQuestion sceneQuestion)
{
public int updateSceneQuestion(SceneQuestion sceneQuestion) {
sceneQuestion.setUpdateTime(DateUtils.getNowDate());
return sceneQuestionMapper.updateSceneQuestion(sceneQuestion);
}
@ -79,8 +110,7 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService
* @return 结果
*/
@Override
public int deleteSceneQuestionByIds(String ids)
{
public int deleteSceneQuestionByIds(String ids) {
return sceneQuestionMapper.deleteSceneQuestionByIds(Convert.toStrArray(ids));
}
@ -91,8 +121,18 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService
* @return 结果
*/
@Override
public int deleteSceneQuestionById(Long id)
{
public int deleteSceneQuestionById(Long id) {
return sceneQuestionMapper.deleteSceneQuestionById(id);
}
/**
* 绑定场景题目信息
*
* @param sceneQuestion
* @return 结果
*/
@Override
public int bindAnswer(SceneQuestion sceneQuestion) {
return sceneQuestionMapper.bindAnswer(sceneQuestion);
}
}

15
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneQuestionMapper.xml

@ -27,6 +27,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roleId != null and roleId != ''"> and role_id = #{roleId}</if>
<if test="status != null "> and status = #{status}</if>
<if test="creator != null and creator != ''"> and creator = #{creator}</if>
<if test="createTime != null">
and create_time <![CDATA[>=]]> #{createTime}
</if>
<if test="createTimeEnd != null">
and create_time <![CDATA[<=]]> #{createTimeEnd}
</if>
</where>
</select>
@ -84,4 +90,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<update id="bindAnswer" parameterType="SceneQuestion">
update scene_question
<trim prefix="SET" suffixOverrides=",">
<if test="answer != null and answer != ''">answer = #{answer},</if>
<if test="nextQuestionId != null and nextQuestionId != ''">next_question_id = #{nextQuestionId},</if>
</trim>
where id = #{id}
</update>
</mapper>

5
lib/EmergencyServiceApi/emergencyAuthServiceApi/src/main/java/com/zdxt/auth/feign/RoleApi.java

@ -29,4 +29,9 @@ public interface RoleApi {
@PostMapping("/getRolesByCode")
@ApiOperation("根据编码获取角色")
public RoleBean getRolesByCode(String roleCode);
@PostMapping("/getRolesAll")
@ApiOperation("根据编码获取角色")
public List<RoleBean> getRolesAll();
}

Loading…
Cancel
Save