parent
5edb7a30d1
commit
eb53db701a
@ -0,0 +1,15 @@
|
||||
package com.tamguo.admin.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
|
||||
import com.tamguo.admin.model.BookEntity;
|
||||
|
||||
public interface BookMapper extends BaseMapper<BookEntity>{
|
||||
|
||||
List<BookEntity> queryPage(@Param(value="name")String name , Pagination page);
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.tamguo.admin.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotations.TableField;
|
||||
import com.baomidou.mybatisplus.annotations.TableName;
|
||||
import com.tamguo.admin.config.dao.SuperEntity;
|
||||
|
||||
@TableName(value="tiku_book")
|
||||
public class BookEntity extends SuperEntity<BookEntity>{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String subjectId;
|
||||
private String courseId;
|
||||
private String name;
|
||||
private String publishingHouse;
|
||||
private Integer questionNum;
|
||||
private Integer pointNum;
|
||||
private Integer orders;
|
||||
|
||||
@TableField(exist=false)
|
||||
private String courseName;
|
||||
|
||||
public String getCourseId() {
|
||||
return courseId;
|
||||
}
|
||||
|
||||
public void setCourseId(String courseId) {
|
||||
this.courseId = courseId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPublishingHouse() {
|
||||
return publishingHouse;
|
||||
}
|
||||
|
||||
public void setPublishingHouse(String publishingHouse) {
|
||||
this.publishingHouse = publishingHouse;
|
||||
}
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public Integer getQuestionNum() {
|
||||
return questionNum;
|
||||
}
|
||||
|
||||
public void setQuestionNum(Integer questionNum) {
|
||||
this.questionNum = questionNum;
|
||||
}
|
||||
|
||||
public Integer getPointNum() {
|
||||
return pointNum;
|
||||
}
|
||||
|
||||
public void setPointNum(Integer pointNum) {
|
||||
this.pointNum = pointNum;
|
||||
}
|
||||
|
||||
public Integer getOrders() {
|
||||
return orders;
|
||||
}
|
||||
|
||||
public void setOrders(Integer orders) {
|
||||
this.orders = orders;
|
||||
}
|
||||
|
||||
public String getCourseName() {
|
||||
return courseName;
|
||||
}
|
||||
|
||||
public void setCourseName(String courseName) {
|
||||
this.courseName = courseName;
|
||||
}
|
||||
|
||||
public String getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(String subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.tamguo.admin.service;
|
||||
/**
|
||||
* Service - 书籍
|
||||
*
|
||||
* @author tamguo
|
||||
*
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.baomidou.mybatisplus.service.IService;
|
||||
import com.tamguo.admin.model.BookEntity;
|
||||
|
||||
public interface IBookService extends IService<BookEntity>{
|
||||
|
||||
Page<BookEntity> queryPage(String name , Page<BookEntity> page);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.tamguo.admin.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
||||
import com.tamguo.admin.dao.BookMapper;
|
||||
import com.tamguo.admin.model.BookEntity;
|
||||
import com.tamguo.admin.service.IBookService;
|
||||
|
||||
@Service
|
||||
public class BookServiceImpl extends ServiceImpl<BookMapper, BookEntity> implements IBookService{
|
||||
|
||||
@Autowired
|
||||
BookMapper bookMapper;
|
||||
|
||||
@Override
|
||||
public Page<BookEntity> queryPage(String name, Page<BookEntity> page) {
|
||||
return page.setRecords(bookMapper.queryPage(name , page));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.tamguo.admin.web.tiku;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.tamguo.admin.model.BookEntity;
|
||||
import com.tamguo.admin.service.IBookService;
|
||||
import com.tamguo.admin.util.ExceptionSupport;
|
||||
import com.tamguo.admin.util.Result;
|
||||
|
||||
@Controller(value="tikuBookController")
|
||||
public class TikuBookController {
|
||||
|
||||
@Autowired
|
||||
IBookService iBookService;
|
||||
|
||||
@RequestMapping("book/queryPage")
|
||||
@ResponseBody
|
||||
public Map<String, Object> queryPage(String name , Integer page , Integer limit) {
|
||||
try {
|
||||
Page<BookEntity> bookPage = iBookService.queryPage(name, new Page<>(page, limit));
|
||||
return Result.jqGridResult(bookPage.getRecords(), bookPage.getTotal(), bookPage.getSize(), bookPage.getCurrent(), bookPage.getPages());
|
||||
} catch (Exception e) {
|
||||
ExceptionSupport.resolverResult("查询书籍错误", this.getClass(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("book/info/{bookId}.html")
|
||||
@ResponseBody
|
||||
public Result info(@PathVariable String bookId){
|
||||
try {
|
||||
return Result.result(0, iBookService.selectById(bookId), null);
|
||||
} catch (Exception e) {
|
||||
return ExceptionSupport.resolverResult("查询科目", this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?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.tamguo.admin.dao.BookMapper">
|
||||
|
||||
<select id="queryPage" resultType="BookEntity">
|
||||
SELECT
|
||||
b.uid,
|
||||
b.course_id,
|
||||
c. name as course_name,
|
||||
b. name,
|
||||
b.publishing_house,
|
||||
b.question_num,
|
||||
b.point_num,
|
||||
b.orders
|
||||
FROM
|
||||
tiku_book b
|
||||
LEFT JOIN tiku_course c ON b.course_id = c.uid
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
b.name like #{name}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,248 @@
|
||||
$(function () {
|
||||
$("#jqGrid").jqGrid({
|
||||
url: mainHttp + 'book/queryPage.html',
|
||||
datatype: "json",
|
||||
colModel: [
|
||||
{ label: '书籍ID', name: 'uid', width: 40, key: true , hidden:true},
|
||||
{ label: '科目名称', name: 'courseName', width: 60 },
|
||||
{ label: '书籍名称', name: 'name', width: 60 },
|
||||
{ label: '题目数量', name: 'questionNum', width: 60 },
|
||||
{ label: '知识点数量', name: 'pointNum', width: 100 },
|
||||
{ label: '排序', name: 'orders', width: 60 }
|
||||
],
|
||||
viewrecords: true,
|
||||
height: 385,
|
||||
rowNum: 10,
|
||||
rowList : [10,30,50],
|
||||
rownumbers: true,
|
||||
rownumWidth: 25,
|
||||
autowidth:true,
|
||||
multiselect: true,
|
||||
pager: "#jqGridPager",
|
||||
jsonReader : {
|
||||
root: "list",
|
||||
page: "currPage",
|
||||
total: "totalPage",
|
||||
records: "totalCount"
|
||||
},
|
||||
prmNames : {
|
||||
page:"page",
|
||||
rows:"limit",
|
||||
order: "order"
|
||||
},
|
||||
gridComplete:function(){
|
||||
//隐藏grid底部滚动条
|
||||
$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var setting = {
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: "uid",
|
||||
pIdKey: "parentId",
|
||||
rootPId: -1
|
||||
},
|
||||
key: {
|
||||
url:"nourl"
|
||||
}
|
||||
},
|
||||
view: {
|
||||
addHoverDom: addHoverDom,
|
||||
removeHoverDom: removeHoverDom,
|
||||
selectedMulti: false
|
||||
},
|
||||
edit: {
|
||||
enable: true,
|
||||
showRemoveBtn: showRemoveBtn
|
||||
}
|
||||
};
|
||||
var newCount = 1;
|
||||
function addHoverDom(treeId, treeNode) {
|
||||
var sObj = $("#" + treeNode.tId + "_span");
|
||||
if(treeNode.level <3){
|
||||
if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
|
||||
var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
|
||||
+ "' title='add node' onfocus='this.blur();'></span>";
|
||||
sObj.after(addStr);
|
||||
var btn = $("#addBtn_"+treeNode.tId);
|
||||
if (btn) btn.bind("click", function(){
|
||||
var zTree = $.fn.zTree.getZTreeObj("menuTree");
|
||||
zTree.addNodes(treeNode, {uid:(100 + newCount), parentId:treeNode.id, name:"章节" + (newCount++)});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
function removeHoverDom(treeId, treeNode) {
|
||||
$("#addBtn_"+treeNode.tId).unbind().remove();
|
||||
};
|
||||
function showRemoveBtn(treeId, treeNode) {
|
||||
if(treeNode.courseId != null){
|
||||
return false;
|
||||
}else{
|
||||
true;
|
||||
}
|
||||
}
|
||||
var ztree;
|
||||
var vm = new Vue({
|
||||
el:'#rrapp',
|
||||
data:{
|
||||
showList: true,
|
||||
title: null,
|
||||
subjectList:null,
|
||||
courseList:null,
|
||||
q:{
|
||||
name:null
|
||||
},
|
||||
book:{
|
||||
name:null,
|
||||
subjectId:null,
|
||||
courseId:null,
|
||||
pointNum:null,
|
||||
questionNum:null,
|
||||
orders:0,
|
||||
chapterList:[]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
query: function () {
|
||||
vm.reload();
|
||||
},
|
||||
getMenu: function(bookId){
|
||||
//加载菜单树
|
||||
return axios.get(mainHttp + "course/getChapterTree/"+bookId+".html");
|
||||
},
|
||||
getSubjectList: function(){
|
||||
return axios.get(mainHttp + "subject/getSubject.html");
|
||||
},
|
||||
getCouseList: function(){
|
||||
return axios.get(mainHttp + "course/findBySubjectId.html?subjectId="+vm.book.subjectId);
|
||||
},
|
||||
add: function(){
|
||||
vm.showList = false;
|
||||
vm.title = "新增";
|
||||
vm.book = {uid:null,name:null,subjectId:null,courseId:null,pointNum:null,questionNum:null,orders:0};
|
||||
axios.all([vm.getMenu() , vm.getSubjectList()]).then(axios.spread(function (mResponse,sResponse) {
|
||||
ztree = $.fn.zTree.init($("#menuTree"), setting, mResponse.data.result);
|
||||
|
||||
vm.subjectList = sResponse.data.result;
|
||||
}));
|
||||
},
|
||||
update: function (event) {
|
||||
var bookId = getSelectedRow();
|
||||
if(bookId == null){
|
||||
return ;
|
||||
}
|
||||
vm.showList = false;
|
||||
vm.title = "修改";
|
||||
axios.all([vm.getMenu(bookId) , vm.getSubjectList(), vm.getBook(bookId)]).then(axios.spread(function (mResponse , sResponse, cResponse) {
|
||||
ztree = $.fn.zTree.init($("#menuTree"), setting, mResponse.data.result);
|
||||
|
||||
vm.subjectList = sResponse.data.result;
|
||||
vm.book = cResponse.data.result;
|
||||
|
||||
// 获取科目
|
||||
axios.all([vm.getCouseList() , vm.getBook(bookId)]).then(axios.spread(function (cResponse , bResponse) {
|
||||
vm.courseList = cResponse.data.result;
|
||||
vm.book = bResponse.data.result;
|
||||
}));
|
||||
|
||||
}));
|
||||
},
|
||||
getBook:function(bookId){
|
||||
return axios.get(mainHttp + "book/info/"+bookId+".html");
|
||||
},
|
||||
del: function (event) {
|
||||
var bookIds = getSelectedRows();
|
||||
if(bookIds == null){
|
||||
return ;
|
||||
}
|
||||
confirm('确定要删除选中的记录?', function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: mainHttp + "book/delete.html",
|
||||
data: JSON.stringify(bookIds),
|
||||
success: function(r){
|
||||
if(r.code === 0){
|
||||
alert('操作成功', function(index){
|
||||
vm.reload();
|
||||
});
|
||||
}else{
|
||||
alert(r.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
saveOrUpdate: function (event) {
|
||||
var url = vm.book.uid == null ? mainHttp + "book/save.html" : mainHttp + "book/update.html";
|
||||
// 获取章节
|
||||
var node = ztree.getNodes();
|
||||
var nodes = ztree.transformToArray(node);
|
||||
Vue.set(vm.book, 'chapterList', nodes);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: JSON.stringify(vm.book),
|
||||
success: function(r){
|
||||
if(r.code === 0){
|
||||
alert('操作成功', function(index){
|
||||
vm.reload();
|
||||
});
|
||||
}else{
|
||||
alert(r.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
menuTree: function(){
|
||||
layer.open({
|
||||
type: 1,
|
||||
offset: '50px',
|
||||
skin: 'layui-layer-molv',
|
||||
title: "选择菜单",
|
||||
area: ['300px', '450px'],
|
||||
shade: 0,
|
||||
shadeClose: false,
|
||||
content: jQuery("#menuLayer"),
|
||||
btn: ['确定', '取消'],
|
||||
btn1: function (index) {
|
||||
var node = ztree.getSelectedNodes();
|
||||
//选择上级菜单
|
||||
vm.menu.parentId = node[0].uid;
|
||||
vm.menu.parentName = node[0].name;
|
||||
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
},
|
||||
reload: function (event) {
|
||||
vm.showList = true;
|
||||
var page = $("#jqGrid").jqGrid('getGridParam','page');
|
||||
$("#jqGrid").jqGrid('setGridParam',{
|
||||
postData:{'name': vm.q.name},
|
||||
page:page
|
||||
}).trigger("reloadGrid");
|
||||
},
|
||||
changeSubject:function(){
|
||||
axios.all([this.getCouseList()]).then(axios.spread(function (cResponse) {
|
||||
vm.courseList = cResponse.data.result;
|
||||
}));
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
// 数据修改时触发
|
||||
subjectList: function() {
|
||||
this.$nextTick(function(){
|
||||
$('#subjectId').selectpicker('refresh');
|
||||
})
|
||||
},
|
||||
courseList: function() {
|
||||
this.$nextTick(function(){
|
||||
$('#courseId').selectpicker('refresh');
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<title>书籍管理</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
<link rel="stylesheet" th:href="${setting.domain + 'css/bootstrap.min.css'}">
|
||||
<link rel="stylesheet" th:href="${setting.domain + 'css/font-awesome.min.css'}">
|
||||
<link rel="stylesheet" th:href="${setting.domain + 'plugins/jqgrid/ui.jqgrid-bootstrap.css'}">
|
||||
<link rel="stylesheet" th:href="${setting.domain + 'plugins/ztree/css/metroStyle/metroStyle.css'}">
|
||||
<link rel="stylesheet" th:href="${setting.domain + 'plugins/bootstrap-select/bootstrap-select.min.css'}">
|
||||
<link rel="stylesheet" th:href="${setting.domain + 'css/main.css'}">
|
||||
<script th:src="${setting.domain + 'libs/jquery.min.js'}"></script>
|
||||
<script th:src="${setting.domain + 'plugins/layer/layer.js'}"></script>
|
||||
<script th:src="${setting.domain + 'libs/bootstrap.min.js'}"></script>
|
||||
<script th:src="${setting.domain + 'libs/vue.min.js'}"></script>
|
||||
<script th:src="${setting.domain + 'plugins/jqgrid/grid.locale-cn.js'}"></script>
|
||||
<script th:src="${setting.domain + 'plugins/jqgrid/jquery.jqGrid.min.js'}"></script>
|
||||
<script th:src="${setting.domain + 'plugins/ztree/jquery.ztree.all.min.js'}"></script>
|
||||
<script th:src="${setting.domain + 'plugins/bootstrap-select/bootstrap-select.min.js'}"></script>
|
||||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
||||
<script th:src="${setting.domain + 'js/common.js'}"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="rrapp" v-cloak>
|
||||
<div v-show="showList">
|
||||
<div class="grid-btn">
|
||||
<div class="form-group col-sm-2">
|
||||
<input type="text" class="form-control" v-model="q.name" @keyup.enter="query" placeholder="用户名">
|
||||
</div>
|
||||
<a class="btn btn-default" @click="query">查询</a>
|
||||
<a shiro:hasPermission="tiku:course:save" class="btn btn-primary" @click="add"><i class="fa fa-plus"></i> 新增</a>
|
||||
<a shiro:hasPermission="tiku:course:update" class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i> 修改</a>
|
||||
<a shiro:hasPermission="tiku:course:delete" class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i> 删除</a>
|
||||
</div>
|
||||
<table id="jqGrid"></table>
|
||||
<div id="jqGridPager"></div>
|
||||
</div>
|
||||
|
||||
<div v-show="!showList" class="panel panel-default">
|
||||
<div class="panel-heading">{{title}}</div>
|
||||
<form class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label">考试</div>
|
||||
<div class="col-sm-10">
|
||||
<select id="subjectId" data-live-search="true" v-model="book.subjectId" @change="changeSubject">
|
||||
<option value="">请选择</option>
|
||||
<option v-bind:value="subject.uid" v-for="subject in subjectList">{{subject.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label">科目</div>
|
||||
<div class="col-sm-10">
|
||||
<select id="courseId" data-live-search="true" v-model="book.courseId">
|
||||
<option value="">请选择</option>
|
||||
<option v-bind:value="course.uid" v-for="course in courseList">{{course.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label">名称</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" v-model="book.name" placeholder="书籍名称"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label">题目数量</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" v-model="book.questionNum" placeholder="题目数量"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label">知识点数量</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" v-model="book.pointNum" placeholder="知识点数量"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label">排序</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" v-model="book.orders" placeholder="排序"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label">章节</div>
|
||||
<div class="col-sm-4" >
|
||||
<ul id="menuTree" class="ztree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label"></div>
|
||||
<input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
|
||||
<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 选择菜单 -->
|
||||
<div id="menuLayer" style="display: none;padding:10px;">
|
||||
<ul id="menuTree" class="ztree"></ul>
|
||||
</div>
|
||||
|
||||
<script th:src="${setting.domain + 'js/tiku/book/list.js?v=6'}"></script>
|
||||
<script type="text/javascript" th:inline="javascript">
|
||||
var mainHttp = [[${setting.domain}]];
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue