17 changed files with 953 additions and 14 deletions
@ -0,0 +1,35 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|||
<head> |
|||
<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-item-add"> |
|||
<div class="form-group"> |
|||
<label class="col-sm-2 control-label is-required">名称:</label> |
|||
<div class="col-sm-10"> |
|||
<input class="form-control" type="text" name="title" id="title" required> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label class="col-sm-2 control-label">描述:</label> |
|||
<div class="col-sm-10"> |
|||
<textarea name="desc" id="desc" class="form-control" type="text" style="height: 500px;"></textarea> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
<th:block th:include="zdxtInclude :: footer" /> |
|||
<script type="text/javascript"> |
|||
var prefix = ctx + "small/questionLib"; |
|||
|
|||
function submitHandler() { |
|||
if ($.validate.form()) { |
|||
$.operate.save(prefix + "/add", $('#form-item-add').serialize()); |
|||
} |
|||
} |
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,29 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|||
<head> |
|||
<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-item-add" th:object="${questionLibrary}"> |
|||
<input id="guid" name="guid" th:value="${questionLibrary.guid}" class="form-control" type="hidden"> |
|||
<div class="form-group"> |
|||
<label class="col-sm-2 control-label is-required">名称:</label> |
|||
<div class="col-sm-10"> |
|||
<input class="form-control" type="text" name="title" id="title" th:field="*{title}" disabled required> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label class="col-sm-2 control-label">描述:</label> |
|||
<div class="col-sm-10"> |
|||
<textarea name="desc" id="desc" class="form-control" type="text" th:field="*{desc}" disabled style="height: 500px;"></textarea> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
<th:block th:include="zdxtInclude :: footer" /> |
|||
<script type="text/javascript"> |
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,36 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|||
<head> |
|||
<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-item-add" th:object="${questionLibrary}"> |
|||
<input id="guid" name="guid" th:value="${questionLibrary.guid}" class="form-control" type="hidden"> |
|||
<div class="form-group"> |
|||
<label class="col-sm-2 control-label is-required">名称:</label> |
|||
<div class="col-sm-10"> |
|||
<input class="form-control" type="text" name="title" id="title" th:field="*{title}" required> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label class="col-sm-2 control-label">描述:</label> |
|||
<div class="col-sm-10"> |
|||
<textarea name="desc" id="desc" class="form-control" type="text" th:field="*{desc}" style="height: 500px;"></textarea> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
<th:block th:include="zdxtInclude :: footer" /> |
|||
<script type="text/javascript"> |
|||
var prefix = ctx + "small/questionLib"; |
|||
|
|||
function submitHandler() { |
|||
if ($.validate.form()) { |
|||
$.operate.save(prefix + "/edit", $('#form-item-add').serialize()); |
|||
} |
|||
} |
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,208 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> |
|||
<head> |
|||
<th:block th:include="zdxtInclude :: header('题库列表')"/> |
|||
</head> |
|||
<body class="gray-bg"> |
|||
<div class="container-div"> |
|||
<div class="row"> |
|||
<div class="col-sm-12 search-collapse"> |
|||
<form id="post-form"> |
|||
<div class="select-list"> |
|||
<ul> |
|||
<li> |
|||
标题:<input type="text" name="title" placeholder="请输入标题"/> |
|||
</li> |
|||
<li> |
|||
<a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a> |
|||
<a class="btn btn-reset btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a> |
|||
</li> |
|||
</ul> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
|
|||
<div class="btn-group-sm" id="toolbar" role="group"> |
|||
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="small:questionLib:add"> |
|||
<i class="fa fa-plus"></i> 新增 |
|||
</a> |
|||
<a class="btn btn-danger multiple disabled" onclick="removeAll()" shiro:hasPermission="small:questionLib:remove"> |
|||
<i class="fa fa-remove"></i> 全部删除 |
|||
</a> |
|||
<a class="btn btn-success" onclick="publishState(1)" shiro:hasPermission="small:questionLib:edit"> |
|||
<i class="fa fa-plus"></i> 发布 |
|||
</a> |
|||
<a class="btn btn-success" onclick="publishState(3)" shiro:hasPermission="small:questionLib:edit"> |
|||
<i class="fa fa-plus"></i> 下线 |
|||
</a> |
|||
</div> |
|||
|
|||
<div class="col-sm-12 select-table table-bordered"> |
|||
<table id="bootstrap-table"></table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<th:block th:include="zdxtInclude :: footer"/> |
|||
<script th:inline="javascript"> |
|||
var editFlag = [[${@permission.hasPermi('small:questionLib:edit')}]]; |
|||
var removeFlag = [[${@permission.hasPermi('small:questionLib:remove')}]]; |
|||
var publishStates = [[${@dict.getType('publish_state')}]]; |
|||
var prefix = ctx + "small/questionLib"; |
|||
|
|||
$(function () { |
|||
initTable(); |
|||
}); |
|||
|
|||
function initTable() { |
|||
var options = { |
|||
url: prefix + "/list", |
|||
createUrl: prefix + "/add", |
|||
updateUrl: prefix + "/edit/{id}", |
|||
detailUrl: prefix + "/detail/{id}", |
|||
removeUrl: prefix + "/remove", |
|||
importUrl: prefix + "/importData", |
|||
sortName: "srot", |
|||
modalName: "知识点", |
|||
uniqueId:"guid", |
|||
columns: [{ |
|||
checkbox: true |
|||
}, |
|||
{ |
|||
title: '序号', |
|||
align: 'center', |
|||
formatter: function (value, row, index) { |
|||
return $.table.serialNumber(index); |
|||
} |
|||
}, |
|||
{ |
|||
field: 'guid', |
|||
title: '主键', |
|||
visible: false |
|||
}, |
|||
{ |
|||
field: 'title', |
|||
title: '标题' |
|||
}, |
|||
{ |
|||
field : 'status', |
|||
title : '状态', |
|||
visible: false, |
|||
formatter : function (value, row, index) { |
|||
return $.table.selectDictLabel(statuss, value); |
|||
} |
|||
}, |
|||
{ |
|||
field: 'creator', |
|||
title: '创建人', |
|||
align: 'center', |
|||
}, |
|||
{ |
|||
field: 'createTime', |
|||
title: '创建时间', |
|||
align: 'center', |
|||
sortable: true |
|||
}, |
|||
{ |
|||
field: 'publishdate', |
|||
title: '发布时间', |
|||
align: 'center', |
|||
sortable: true |
|||
}, |
|||
{ |
|||
field: 'publishstate', |
|||
title: '发布状态', |
|||
align: 'center', |
|||
formatter: function (value, row, index) { |
|||
return $.table.selectDictLabel(publishStates, value); |
|||
} |
|||
}, |
|||
{ |
|||
title: '操作', |
|||
align: 'center', |
|||
formatter: function (value, row, index) { |
|||
var actions = []; |
|||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.guid + '\')"><i class="fa fa-edit"></i> 详情</a> '); |
|||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.guid + '\')"><i class="fa fa-edit"></i> 编辑</a> '); |
|||
actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="toBanks(\'' + row.guid + '\')"><i class="fa fa-list-ul"></i> 列表</a> '); |
|||
return actions.join(''); |
|||
} |
|||
}] |
|||
}; |
|||
$.table.init(options); |
|||
} |
|||
|
|||
/** 发布 */ |
|||
function toPublishState(key, state) { |
|||
$.ajax({ |
|||
type: "POST", |
|||
url: prefix + "/toPublishState", |
|||
data: {guid:key,publishstate:state}, |
|||
dataType: 'json', |
|||
success: function (result) { |
|||
console.log(result); |
|||
$.table.refresh(); |
|||
}, |
|||
error: function (error) { |
|||
$.modal.alertWarning("操作失败"); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
/*字典列表-详细*/ |
|||
function toBanks(key) { |
|||
var url = prefix + '/toBanks/' + key; |
|||
$.modal.openTab("题目", url); |
|||
} |
|||
|
|||
/** 批量发布/下线 */ |
|||
function publishState(state) { |
|||
var ids = ""; |
|||
var isRemove = true; |
|||
var row = $("#" + table.options.id).bootstrapTable('getSelections'); |
|||
for (var i=0; i<row.length; i++) { |
|||
if (row[i].publishstate == 0 && state == 3) { |
|||
$.modal.msgWarning("所选存在未发布数据, 无法执行下线操作!"); |
|||
isRemove = false; |
|||
return; |
|||
} |
|||
if (state == 1 && row[i].publishstate == 1) { |
|||
} else { |
|||
ids += row[i].guid +","; |
|||
} |
|||
} |
|||
if (isRemove && ids.length>0) { |
|||
$.modal.confirm("确定执行【所选数据】吗?", function() { |
|||
$.operate.submit(prefix+"/toPublishState", "post", "json", {ids: ids, state: state}, function(result) { |
|||
$.table.search(); |
|||
}) |
|||
}); |
|||
} else { |
|||
$.modal.msgWarning("没有需要执行的数据!"); |
|||
return; |
|||
} |
|||
} |
|||
|
|||
function removeAll() { |
|||
var ids = ""; |
|||
var isRemove = true; |
|||
var row = $("#" + table.options.id).bootstrapTable('getSelections'); |
|||
for (var i=0; i<row.length; i++) { |
|||
if (row[i].publishstate == 1) { |
|||
$.modal.msgWarning("所选存在已发布数据, 无法执行删除操作!"); |
|||
isRemove = false; |
|||
return; |
|||
} |
|||
ids += row[i].guid +","; |
|||
} |
|||
if (isRemove) { |
|||
$.modal.confirm("确定删除【所选数据】吗?", function() { |
|||
$.operate.submit(prefix+"/remove", "post", "json", {ids: ids}, function(result) { |
|||
$.table.search(); |
|||
}) |
|||
}); |
|||
} |
|||
} |
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,141 @@ |
|||
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.QuestionLibrary; |
|||
import com.zdxt.knowledge.service.IQuestionLibraryService; |
|||
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 2024-01-04 |
|||
*/ |
|||
@Controller |
|||
@RequestMapping("/small/questionLib") |
|||
public class QuestionLibraryController extends BaseController |
|||
{ |
|||
private String prefix = "project/smallProgram/questionLib"; |
|||
|
|||
@Autowired |
|||
private IQuestionLibraryService questionLibraryService; |
|||
|
|||
@RequiresPermissions("small:questionLib:view") |
|||
@GetMapping() |
|||
public String library() |
|||
{ |
|||
return prefix + "/view"; |
|||
} |
|||
|
|||
/** |
|||
* 查询题库列表 |
|||
*/ |
|||
@RequiresPermissions("small:questionLib:view") |
|||
@PostMapping("/list") |
|||
@ResponseBody |
|||
public TableDataInfo list(QuestionLibrary questionLibrary) |
|||
{ |
|||
startPage(); |
|||
List<QuestionLibrary> list = questionLibraryService.selectQuestionLibraryList(questionLibrary); |
|||
return getDataTable(list); |
|||
} |
|||
|
|||
/** |
|||
* 题库详情 |
|||
*/ |
|||
@GetMapping("/detail/{guid}") |
|||
public String detail(@PathVariable("guid") String guid, ModelMap mmap) |
|||
{ |
|||
QuestionLibrary questionLibrary = questionLibraryService.selectQuestionLibraryById(guid); |
|||
mmap.put("questionLibrary", questionLibrary); |
|||
return prefix + "/detail"; |
|||
} |
|||
|
|||
/** |
|||
* 新增题库 |
|||
*/ |
|||
@GetMapping("/add") |
|||
public String add() |
|||
{ |
|||
return prefix + "/add"; |
|||
} |
|||
|
|||
/** |
|||
* 新增保存题库 |
|||
*/ |
|||
@RequiresPermissions("small:questionLib:add") |
|||
@PostMapping("/add") |
|||
@ResponseBody |
|||
public ZDResponse addSave(QuestionLibrary questionLibrary) |
|||
{ |
|||
int resNum = questionLibraryService.insertQuestionLibrary(questionLibrary); |
|||
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|||
} |
|||
|
|||
/** |
|||
* 修改题库 |
|||
*/ |
|||
@GetMapping("/edit/{guid}") |
|||
public String edit(@PathVariable("guid") String guid, ModelMap mmap) |
|||
{ |
|||
QuestionLibrary questionLibrary = questionLibraryService.selectQuestionLibraryById(guid); |
|||
mmap.put("questionLibrary", questionLibrary); |
|||
return prefix + "/edit"; |
|||
} |
|||
|
|||
/** |
|||
* 修改保存题库 |
|||
*/ |
|||
@RequiresPermissions("small:questionLib:edit") |
|||
@PostMapping("/edit") |
|||
@ResponseBody |
|||
public ZDResponse editSave(QuestionLibrary questionLibrary) |
|||
{ |
|||
int resNum = questionLibraryService.updateQuestionLibrary(questionLibrary); |
|||
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|||
} |
|||
|
|||
/** |
|||
* 删除题库 |
|||
*/ |
|||
@RequiresPermissions("small:questionLib:remove") |
|||
@PostMapping( "/remove") |
|||
@ResponseBody |
|||
public ZDResponse remove(String ids) |
|||
{ |
|||
int resNum = questionLibraryService.deleteQuestionLibraryByIds(ids); |
|||
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|||
} |
|||
|
|||
/** |
|||
* 修改发布状态 |
|||
*/ |
|||
@RequiresPermissions("small:library:edit") |
|||
@PostMapping("/toPublishState") |
|||
@ResponseBody |
|||
public ZDResponse toPublishState(String ids, String state) |
|||
{ |
|||
int resNum = questionLibraryService.updatePublishState(ids, state); |
|||
return resNum>0?ZDResponse.success("操作成功", resNum):ZDResponse.error("操作失败", resNum); |
|||
} |
|||
|
|||
@RequiresPermissions("small:library:view") |
|||
@GetMapping("/toBanks/{key}") |
|||
public String toBanks(@PathVariable("key") String key, ModelMap mmap) |
|||
{ |
|||
mmap.put("questionLibId", key); |
|||
return "project/smallProgram/question/view"; |
|||
} |
|||
} |
|||
@ -0,0 +1,91 @@ |
|||
package com.zdxt.knowledge.domain; |
|||
|
|||
import com.zdxt.common.BaseDomain; |
|||
|
|||
/** |
|||
* 题库对象 question_library |
|||
* |
|||
* @author ruoyi |
|||
* @date 2024-01-04 |
|||
*/ |
|||
public class QuestionLibrary extends BaseDomain |
|||
{ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** 主键 */ |
|||
private String guid; |
|||
|
|||
/** 标题 */ |
|||
private String title; |
|||
|
|||
/** 描述 */ |
|||
private String desc; |
|||
|
|||
/** 排序 */ |
|||
private Long srot; |
|||
|
|||
/** 状态(0:正常,1:停用) */ |
|||
private Integer status; |
|||
|
|||
/** 发布时间 */ |
|||
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 getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
|
|||
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 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; |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
package com.zdxt.knowledge.mapper; |
|||
|
|||
import com.zdxt.knowledge.domain.QuestionLibrary; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 题库Mapper接口 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2024-01-04 |
|||
*/ |
|||
public interface QuestionLibraryMapper |
|||
{ |
|||
/** |
|||
* 查询题库 |
|||
* |
|||
* @param guid 题库ID |
|||
* @return 题库 |
|||
*/ |
|||
public QuestionLibrary selectQuestionLibraryById(String guid); |
|||
|
|||
/** |
|||
* 查询题库列表 |
|||
* |
|||
* @param questionLibrary 题库 |
|||
* @return 题库集合 |
|||
*/ |
|||
public List<QuestionLibrary> selectQuestionLibraryList(QuestionLibrary questionLibrary); |
|||
|
|||
/** |
|||
* 新增题库 |
|||
* |
|||
* @param questionLibrary 题库 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertQuestionLibrary(QuestionLibrary questionLibrary); |
|||
|
|||
/** |
|||
* 修改题库 |
|||
* |
|||
* @param questionLibrary 题库 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateQuestionLibrary(QuestionLibrary questionLibrary); |
|||
|
|||
/** |
|||
* 删除题库 |
|||
* |
|||
* @param guid 题库ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteQuestionLibraryById(String guid); |
|||
|
|||
/** |
|||
* 批量删除题库 |
|||
* |
|||
* @param guids 需要删除的数据ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteQuestionLibraryByIds(String[] guids); |
|||
|
|||
/** |
|||
* 批量修改发布状态 |
|||
* @param guids |
|||
* @return |
|||
*/ |
|||
public int updatePublishState(@Param("guids") String[] guids, @Param("state") String state, @Param("publishdate") String publishdate); |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
package com.zdxt.knowledge.service; |
|||
|
|||
import com.zdxt.knowledge.domain.QuestionLibrary; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 题库Service接口 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2024-01-04 |
|||
*/ |
|||
public interface IQuestionLibraryService |
|||
{ |
|||
/** |
|||
* 查询题库 |
|||
* |
|||
* @param guid 题库ID |
|||
* @return 题库 |
|||
*/ |
|||
public QuestionLibrary selectQuestionLibraryById(String guid); |
|||
|
|||
/** |
|||
* 查询题库列表 |
|||
* |
|||
* @param questionLibrary 题库 |
|||
* @return 题库集合 |
|||
*/ |
|||
public List<QuestionLibrary> selectQuestionLibraryList(QuestionLibrary questionLibrary); |
|||
|
|||
/** |
|||
* 新增题库 |
|||
* |
|||
* @param questionLibrary 题库 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertQuestionLibrary(QuestionLibrary questionLibrary); |
|||
|
|||
/** |
|||
* 修改题库 |
|||
* |
|||
* @param questionLibrary 题库 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateQuestionLibrary(QuestionLibrary questionLibrary); |
|||
|
|||
/** |
|||
* 批量删除题库 |
|||
* |
|||
* @param ids 需要删除的数据ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteQuestionLibraryByIds(String ids); |
|||
|
|||
/** |
|||
* 删除题库信息 |
|||
* |
|||
* @param guid 题库ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteQuestionLibraryById(String guid); |
|||
|
|||
/** |
|||
* 批量修改发布状态 |
|||
* @param ids |
|||
* @return |
|||
*/ |
|||
public int updatePublishState(String ids, String state); |
|||
} |
|||
@ -0,0 +1,107 @@ |
|||
package com.zdxt.knowledge.service.impl; |
|||
|
|||
import java.util.List; |
|||
|
|||
import com.zdxt.auth.feign.UserApi; |
|||
import com.zdxt.common.util.Convert; |
|||
import com.zdxt.common.util.DateUtils; |
|||
import com.zdxt.common.util.StringUtils; |
|||
import com.zdxt.knowledge.domain.QuestionLibrary; |
|||
import com.zdxt.knowledge.mapper.QuestionLibraryMapper; |
|||
import com.zdxt.knowledge.service.IQuestionLibraryService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 题库Service业务层处理 |
|||
* |
|||
* @author ruoyi |
|||
* @date 2024-01-04 |
|||
*/ |
|||
@Service |
|||
public class QuestionLibraryServiceImpl implements IQuestionLibraryService |
|||
{ |
|||
@Autowired private QuestionLibraryMapper questionLibraryMapper; |
|||
@Autowired private UserApi userApi; |
|||
|
|||
/** |
|||
* 查询题库 |
|||
* |
|||
* @param guid 题库ID |
|||
* @return 题库 |
|||
*/ |
|||
@Override |
|||
public QuestionLibrary selectQuestionLibraryById(String guid) |
|||
{ |
|||
return questionLibraryMapper.selectQuestionLibraryById(guid); |
|||
} |
|||
|
|||
/** |
|||
* 查询题库列表 |
|||
* |
|||
* @param questionLibrary 题库 |
|||
* @return 题库 |
|||
*/ |
|||
@Override |
|||
public List<QuestionLibrary> selectQuestionLibraryList(QuestionLibrary questionLibrary) |
|||
{ |
|||
return questionLibraryMapper.selectQuestionLibraryList(questionLibrary); |
|||
} |
|||
|
|||
/** |
|||
* 新增题库 |
|||
* |
|||
* @param questionLibrary 题库 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int insertQuestionLibrary(QuestionLibrary questionLibrary) |
|||
{ |
|||
questionLibrary.setGuid(StringUtils.getUUID()); |
|||
questionLibrary.setCreator(userApi.getCurrentUser().getUserName()); |
|||
return questionLibraryMapper.insertQuestionLibrary(questionLibrary); |
|||
} |
|||
|
|||
/** |
|||
* 修改题库 |
|||
* |
|||
* @param questionLibrary 题库 |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int updateQuestionLibrary(QuestionLibrary questionLibrary) |
|||
{ |
|||
questionLibrary.setUpdator(userApi.getCurrentUser().getUserName()); |
|||
return questionLibraryMapper.updateQuestionLibrary(questionLibrary); |
|||
} |
|||
|
|||
/** |
|||
* 删除题库对象 |
|||
* |
|||
* @param ids 需要删除的数据ID |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int deleteQuestionLibraryByIds(String ids) |
|||
{ |
|||
return questionLibraryMapper.deleteQuestionLibraryByIds(Convert.toStrArray(ids)); |
|||
} |
|||
|
|||
/** |
|||
* 删除题库信息 |
|||
* |
|||
* @param guid 题库ID |
|||
* @return 结果 |
|||
*/ |
|||
@Override |
|||
public int deleteQuestionLibraryById(String guid) |
|||
{ |
|||
return questionLibraryMapper.deleteQuestionLibraryById(guid); |
|||
} |
|||
|
|||
@Override |
|||
public int updatePublishState(String ids, String state) { |
|||
String publishdate = DateUtils.getTime(); |
|||
return questionLibraryMapper.updatePublishState(Convert.toStrArray(ids), state, publishdate); |
|||
} |
|||
} |
|||
@ -0,0 +1,114 @@ |
|||
<?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.zdxt.knowledge.mapper.QuestionLibraryMapper"> |
|||
|
|||
<resultMap type="com.zdxt.knowledge.domain.QuestionLibrary" id="QuestionLibraryResult"> |
|||
<result property="guid" column="guid" /> |
|||
<result property="title" column="title" /> |
|||
<result property="desc" column="desc" /> |
|||
<result property="srot" column="srot" /> |
|||
<result property="status" column="status" /> |
|||
<result property="publishdate" column="publishDate" /> |
|||
<result property="publishstate" column="publishState" /> |
|||
<result property="creator" column="creator" /> |
|||
<result property="createTime" column="create_time" /> |
|||
<result property="updator" column="updator" /> |
|||
<result property="updateTime" column="update_time" /> |
|||
</resultMap> |
|||
|
|||
<sql id="selectQuestionLibraryVo"> |
|||
select guid, title, `desc`, srot, status, publishDate, publishState, creator, create_time, updator, update_time from question_library |
|||
</sql> |
|||
|
|||
<select id="selectQuestionLibraryList" parameterType="QuestionLibrary" resultMap="QuestionLibraryResult"> |
|||
<include refid="selectQuestionLibraryVo"/> |
|||
<where> |
|||
<if test="title != null and title != ''"> and title = #{title}</if> |
|||
<if test="desc != null and desc != ''"> and `desc` = #{desc}</if> |
|||
<if test="srot != null "> and srot = #{srot}</if> |
|||
<if test="status != null "> and status = #{status}</if> |
|||
<if test="publishdate != null and publishdate != ''"> and publishDate = #{publishdate}</if> |
|||
<if test="publishstate != null "> and publishState = #{publishstate}</if> |
|||
<if test="creator != null and creator != ''"> and creator = #{creator}</if> |
|||
<if test="updator != null and updator != ''"> and updator = #{updator}</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectQuestionLibraryById" parameterType="String" resultMap="QuestionLibraryResult"> |
|||
<include refid="selectQuestionLibraryVo"/> |
|||
where guid = #{guid} |
|||
</select> |
|||
|
|||
<insert id="insertQuestionLibrary" parameterType="QuestionLibrary"> |
|||
insert into question_library |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="guid != null and guid != ''">guid,</if> |
|||
<if test="title != null and title != ''">title,</if> |
|||
<if test="desc != null and desc != ''">`desc`,</if> |
|||
<if test="srot != null ">srot,</if> |
|||
<if test="status != null ">status,</if> |
|||
<if test="publishdate != null and publishdate != ''">publishDate,</if> |
|||
<if test="publishstate != null ">publishState,</if> |
|||
<if test="creator != null and creator != ''">creator,</if> |
|||
<if test="createTime != null ">create_time,</if> |
|||
<if test="updator != null and updator != ''">updator,</if> |
|||
<if test="updateTime != null ">update_time,</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="guid != null and guid != ''">#{guid},</if> |
|||
<if test="title != null and title != ''">#{title},</if> |
|||
<if test="desc != null and desc != ''">#{desc},</if> |
|||
<if test="srot != null ">#{srot},</if> |
|||
<if test="status != null ">#{status},</if> |
|||
<if test="publishdate != null and publishdate != ''">#{publishdate},</if> |
|||
<if test="publishstate != null ">#{publishstate},</if> |
|||
<if test="creator != null and creator != ''">#{creator},</if> |
|||
<if test="createTime != null ">#{createTime},</if> |
|||
<if test="updator != null and updator != ''">#{updator},</if> |
|||
<if test="updateTime != null ">#{updateTime},</if> |
|||
</trim> |
|||
</insert> |
|||
|
|||
<update id="updateQuestionLibrary" parameterType="QuestionLibrary"> |
|||
update question_library |
|||
<trim prefix="SET" suffixOverrides=","> |
|||
<if test="title != null and title != ''">title = #{title},</if> |
|||
<if test="desc != null and desc != ''">`desc` = #{desc},</if> |
|||
<if test="srot != null ">srot = #{srot},</if> |
|||
<if test="status != null ">status = #{status},</if> |
|||
<if test="publishdate != null and publishdate != ''">publishDate = #{publishdate},</if> |
|||
<if test="publishstate != null ">publishState = #{publishstate},</if> |
|||
<if test="creator != null and creator != ''">creator = #{creator},</if> |
|||
<if test="createTime != null ">create_time = #{createTime},</if> |
|||
<if test="updator != null and updator != ''">updator = #{updator},</if> |
|||
<if test="updateTime != null ">update_time = #{updateTime},</if> |
|||
</trim> |
|||
where guid = #{guid} |
|||
</update> |
|||
|
|||
<delete id="deleteQuestionLibraryById" parameterType="String"> |
|||
delete from question_library where guid = #{guid} |
|||
</delete> |
|||
|
|||
<delete id="deleteQuestionLibraryByIds" parameterType="String"> |
|||
delete from question_library where guid in |
|||
<foreach item="guid" collection="array" open="(" separator="," close=")"> |
|||
#{guid} |
|||
</foreach> |
|||
</delete> |
|||
|
|||
<update id="updatePublishState" parameterType="String"> |
|||
update question_library |
|||
<trim prefix="SET" suffixOverrides=","> |
|||
<if test="state == 1">publishDate = #{publishdate},</if> |
|||
<if test="state != null">publishState = #{state},</if> |
|||
</trim> |
|||
where guid in |
|||
<foreach item="guid" collection="guids" open="(" separator="," close=")"> |
|||
#{guid} |
|||
</foreach> |
|||
</update> |
|||
|
|||
</mapper> |
|||
Loading…
Reference in new issue