书籍管理

main
tamguo 7 years ago
parent dddfde2ed9
commit 02a27da72f

@ -17,16 +17,14 @@ public class ChapterEntity extends SuperEntity<ChapterEntity> implements Seriali
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String courseId; private String courseId;
private String name; private String name;
private String parentCode;
private String parentId; private String parentCodes;
private Integer questionNum; private Integer questionNum;
private Integer pointNum; private Integer pointNum;
private Integer orders; private Integer orders;
private Boolean treeLeaf;
private String treeLevel;
@TableField(exist=false) @TableField(exist=false)
private List<ChapterEntity> childChapterList; private List<ChapterEntity> childChapterList;
@ -50,14 +48,6 @@ public class ChapterEntity extends SuperEntity<ChapterEntity> implements Seriali
this.name = name; this.name = name;
} }
public String getParentId() {
return this.parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public List<ChapterEntity> getChildChapterList() { public List<ChapterEntity> getChildChapterList() {
return childChapterList; return childChapterList;
} }
@ -90,4 +80,36 @@ public class ChapterEntity extends SuperEntity<ChapterEntity> implements Seriali
this.orders = orders; this.orders = orders;
} }
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getParentCodes() {
return parentCodes;
}
public void setParentCodes(String parentCodes) {
this.parentCodes = parentCodes;
}
public Boolean getTreeLeaf() {
return treeLeaf;
}
public void setTreeLeaf(Boolean treeLeaf) {
this.treeLeaf = treeLeaf;
}
public String getTreeLevel() {
return treeLevel;
}
public void setTreeLevel(String treeLevel) {
this.treeLevel = treeLevel;
}
} }

@ -0,0 +1,28 @@
package com.tamguo.modules.tiku.model.condition;
public class ChapterCondition {
private String parentCode;
private String id;
private String name;
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -1,5 +1,6 @@
package com.tamguo.modules.tiku.service; package com.tamguo.modules.tiku.service;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService; import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.tiku.model.BookEntity; import com.tamguo.modules.tiku.model.BookEntity;
@ -19,4 +20,6 @@ public interface IBookService extends IService<BookEntity>{
void disabled(String id); void disabled(String id);
JSONArray treeData();
} }

@ -4,10 +4,14 @@ import java.util.List;
import com.baomidou.mybatisplus.service.IService; import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.tiku.model.ChapterEntity; import com.tamguo.modules.tiku.model.ChapterEntity;
import com.tamguo.modules.tiku.model.condition.ChapterCondition;
public interface IChapterService extends IService<ChapterEntity>{ public interface IChapterService extends IService<ChapterEntity>{
// 获取科目章节 // 获取科目章节
public List<ChapterEntity> findChapterTree(String bookId); public List<ChapterEntity> findChapterTree(String bookId);
// 章节列表
public List<ChapterEntity> listData(ChapterCondition condition);
} }

@ -1,6 +1,5 @@
package com.tamguo.modules.tiku.service; package com.tamguo.modules.tiku.service;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService; import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.tiku.model.CourseEntity; import com.tamguo.modules.tiku.model.CourseEntity;
@ -24,8 +23,4 @@ public interface ICourseService extends IService<CourseEntity>{
/** 停用科目*/ /** 停用科目*/
void disabled(String uid); void disabled(String uid);
/** 科目树形*/
JSONArray treeData();
} }

@ -1,17 +1,26 @@
package com.tamguo.modules.tiku.service.impl; package com.tamguo.modules.tiku.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.tiku.dao.BookMapper; import com.tamguo.modules.tiku.dao.BookMapper;
import com.tamguo.modules.tiku.dao.CourseMapper; import com.tamguo.modules.tiku.dao.CourseMapper;
import com.tamguo.modules.tiku.dao.SubjectMapper;
import com.tamguo.modules.tiku.model.BookEntity; import com.tamguo.modules.tiku.model.BookEntity;
import com.tamguo.modules.tiku.model.CourseEntity; import com.tamguo.modules.tiku.model.CourseEntity;
import com.tamguo.modules.tiku.model.SubjectEntity;
import com.tamguo.modules.tiku.model.condition.BookCondition; import com.tamguo.modules.tiku.model.condition.BookCondition;
import com.tamguo.modules.tiku.model.enums.BookStatusEnum; import com.tamguo.modules.tiku.model.enums.BookStatusEnum;
import com.tamguo.modules.tiku.model.enums.CourseStatusEnum;
import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum;
import com.tamguo.modules.tiku.service.IBookService; import com.tamguo.modules.tiku.service.IBookService;
@Service @Service
@ -21,6 +30,8 @@ public class BookServiceImpl extends ServiceImpl<BookMapper, BookEntity> impleme
BookMapper bookMapper; BookMapper bookMapper;
@Autowired @Autowired
CourseMapper courseMapper; CourseMapper courseMapper;
@Autowired
SubjectMapper subjectMapper;
@Transactional(readOnly=false) @Transactional(readOnly=false)
@Override @Override
@ -80,4 +91,39 @@ public class BookServiceImpl extends ServiceImpl<BookMapper, BookEntity> impleme
bookMapper.updateById(book); bookMapper.updateById(book);
} }
@Transactional(readOnly=false)
@SuppressWarnings("unchecked")
@Override
public JSONArray treeData() {
List<SubjectEntity> subjectList = subjectMapper.selectList(Condition.create().eq("status", SubjectStatusEnum.NORMAL.getValue()));
List<CourseEntity> courseList = courseMapper.selectList(Condition.create().eq("status", CourseStatusEnum.NORMAL.getValue()));
List<BookEntity> bookList = bookMapper.selectList(Condition.create().eq("status", BookStatusEnum.NORMAL.getValue()));
return transform(subjectList, courseList , bookList);
}
private JSONArray transform(List<SubjectEntity> subjectList , List<CourseEntity> courseList , List<BookEntity> bookList) {
JSONArray entitys = new JSONArray();
for(int i=0 ; i<subjectList.size() ; i++) {
JSONObject entity = new JSONObject();
entity.put("id", subjectList.get(i).getId());
entity.put("name", subjectList.get(i).getName());
entity.put("pId", "0");
entitys.add(entity);
}
for(int i=0 ; i<courseList.size() ; i++) {
JSONObject entity = new JSONObject();
entity.put("id", courseList.get(i).getId());
entity.put("name", courseList.get(i).getName());
entity.put("pId", courseList.get(i).getSubjectId());
entitys.add(entity);
}
for(int i=0 ; i<bookList.size() ; i++) {
JSONObject entity = new JSONObject();
entity.put("id", bookList.get(i).getId());
entity.put("name", bookList.get(i).getName());
entity.put("pId", bookList.get(i).getCourseId());
entitys.add(entity);
}
return entitys;
}
} }

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -12,10 +13,14 @@ import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.common.utils.SystemConstant; import com.tamguo.common.utils.SystemConstant;
import com.tamguo.modules.tiku.dao.ChapterMapper; import com.tamguo.modules.tiku.dao.ChapterMapper;
import com.tamguo.modules.tiku.model.ChapterEntity; import com.tamguo.modules.tiku.model.ChapterEntity;
import com.tamguo.modules.tiku.model.condition.ChapterCondition;
import com.tamguo.modules.tiku.service.IChapterService; import com.tamguo.modules.tiku.service.IChapterService;
@Service @Service
public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity> implements IChapterService{ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity> implements IChapterService{
@Autowired
ChapterMapper chapterMapper;
@Transactional(readOnly=false) @Transactional(readOnly=false)
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -27,7 +32,7 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
String rootUid = StringUtils.EMPTY; String rootUid = StringUtils.EMPTY;
for(int i=0 ; i<chapterList.size() ; i++){ for(int i=0 ; i<chapterList.size() ; i++){
ChapterEntity chapter = chapterList.get(i); ChapterEntity chapter = chapterList.get(i);
if(chapter.getParentId().equals(SystemConstant.CHAPTER_DEFAULT_ROOT_UID)){ if(chapter.getParentCode().equals(SystemConstant.CHAPTER_DEFAULT_ROOT_UID)){
rootUid = chapter.getId(); rootUid = chapter.getId();
} }
} }
@ -35,7 +40,7 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
List<ChapterEntity> entitys = new ArrayList<>(); List<ChapterEntity> entitys = new ArrayList<>();
for(int i=0 ; i<chapterList.size() ; i++){ for(int i=0 ; i<chapterList.size() ; i++){
ChapterEntity chapter = chapterList.get(i); ChapterEntity chapter = chapterList.get(i);
if(rootUid.equals(chapter.getParentId())){ if(rootUid.equals(chapter.getParentCode())){
entitys.add(chapter); entitys.add(chapter);
} }
} }
@ -44,7 +49,7 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
List<ChapterEntity> childs = new ArrayList<>(); List<ChapterEntity> childs = new ArrayList<>();
for(int k=0 ; k<chapterList.size() ; k++){ for(int k=0 ; k<chapterList.size() ; k++){
ChapterEntity chapter = chapterList.get(k); ChapterEntity chapter = chapterList.get(k);
if(entity.getId().equals(chapter.getParentId())){ if(entity.getId().equals(chapter.getParentCode())){
childs.add(chapter); childs.add(chapter);
} }
} }
@ -57,7 +62,7 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
List<ChapterEntity> tmpChilds = new ArrayList<>(); List<ChapterEntity> tmpChilds = new ArrayList<>();
for(int n=0 ; n<chapterList.size() ; n++){ for(int n=0 ; n<chapterList.size() ; n++){
ChapterEntity chapter = chapterList.get(n); ChapterEntity chapter = chapterList.get(n);
if(child.getId().equals(chapter.getParentId())){ if(child.getId().equals(chapter.getParentCode())){
tmpChilds.add(chapter); tmpChilds.add(chapter);
} }
} }
@ -66,5 +71,17 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, ChapterEntity
} }
return entitys; return entitys;
} }
@SuppressWarnings("unchecked")
@Override
public List<ChapterEntity> listData(ChapterCondition condition) {
Condition query = Condition.create();
if(!StringUtils.isEmpty(condition.getParentCode())) {
query.eq("parent_code", condition.getParentCode());
}else {
query.eq("tree_level", "0");
}
return chapterMapper.selectList(query);
}
} }

@ -1,25 +1,18 @@
package com.tamguo.modules.tiku.service.impl; package com.tamguo.modules.tiku.service.impl;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.Condition; import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.tiku.dao.CourseMapper; import com.tamguo.modules.tiku.dao.CourseMapper;
import com.tamguo.modules.tiku.dao.SubjectMapper; import com.tamguo.modules.tiku.dao.SubjectMapper;
import com.tamguo.modules.tiku.model.CourseEntity; import com.tamguo.modules.tiku.model.CourseEntity;
import com.tamguo.modules.tiku.model.SubjectEntity;
import com.tamguo.modules.tiku.model.condition.CourseCondition; import com.tamguo.modules.tiku.model.condition.CourseCondition;
import com.tamguo.modules.tiku.model.enums.CourseStatusEnum; import com.tamguo.modules.tiku.model.enums.CourseStatusEnum;
import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum;
import com.tamguo.modules.tiku.service.ICourseService; import com.tamguo.modules.tiku.service.ICourseService;
@Service @Service
@ -94,31 +87,4 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, CourseEntity> i
courseMapper.updateById(entity); courseMapper.updateById(entity);
} }
@SuppressWarnings("unchecked")
@Override
public JSONArray treeData() {
List<SubjectEntity> subjectList = subjectMapper.selectList(Condition.create().eq("status", SubjectStatusEnum.NORMAL.getValue()));
List<CourseEntity> courseList = courseMapper.selectList(Condition.create().eq("status", CourseStatusEnum.NORMAL.getValue()));
return transform(subjectList, courseList);
}
private JSONArray transform(List<SubjectEntity> subjectList , List<CourseEntity> courseList) {
JSONArray entitys = new JSONArray();
for(int i=0 ; i<subjectList.size() ; i++) {
JSONObject entity = new JSONObject();
entity.put("id", subjectList.get(i).getId());
entity.put("name", subjectList.get(i).getName());
entity.put("pId", "0");
entitys.add(entity);
}
for(int i=0 ; i<courseList.size() ; i++) {
JSONObject entity = new JSONObject();
entity.put("id", courseList.get(i).getId());
entity.put("name", courseList.get(i).getName());
entity.put("pId", courseList.get(i).getSubjectId());
entitys.add(entity);
}
return entitys;
}
} }

@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.tamguo.common.utils.ExceptionSupport; import com.tamguo.common.utils.ExceptionSupport;
import com.tamguo.common.utils.Result; import com.tamguo.common.utils.Result;
@ -108,4 +109,10 @@ public class BookController {
return ExceptionSupport.resolverResult("停用书籍", this.getClass(), e); return ExceptionSupport.resolverResult("停用书籍", this.getClass(), e);
} }
} }
@RequestMapping(path="treeData",method=RequestMethod.POST)
@ResponseBody
public JSONArray treeData() {
return iBookService.treeData();
}
} }

@ -0,0 +1,25 @@
package com.tamguo.modules.tiku.web;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.tamguo.modules.tiku.model.ChapterEntity;
import com.tamguo.modules.tiku.model.condition.ChapterCondition;
import com.tamguo.modules.tiku.service.IChapterService;
@Controller
@RequestMapping(path="tiku/chapter")
public class ChapterController {
@Autowired
private IChapterService iChapterService;
@RequestMapping(path="listData",method=RequestMethod.POST)
@ResponseBody
public List<ChapterEntity> listData(ChapterCondition condition) {
return iChapterService.listData(condition);
}
}

@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.Condition; import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.tamguo.common.utils.ExceptionSupport; import com.tamguo.common.utils.ExceptionSupport;
@ -120,9 +119,4 @@ public class CourseController {
} }
} }
@RequestMapping(path="treeData",method=RequestMethod.GET)
@ResponseBody
public JSONArray treeData() {
return iCourseService.treeData();
}
} }

@ -0,0 +1,226 @@
<!DOCTYPE html><html><head><meta charset="utf-8"><meta content="webkit" name="renderer"/><meta http-equiv="X-UA-Compatible"
content="IE=edge"><meta name="keywords" content="PoweredByJeeSiteV4.0"/><meta http-equiv="Cache-Control"
content="no-cache, no-store, must-revalidate"/><meta name="description" content="PoweredByJeeSiteV4.0"/><meta
content="no-cache" http-equiv="Pragma"/><meta http-equiv="Expires" content="0"/><meta
content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<title>书籍管理 - JeeSite Demo</title>
<script th:src="${setting.domain + 'global.min.js'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-1.12.4.min.js'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-migrate-1.4.1.min.js'}"></script>
<!--[if lt IE 9]><script src="/js/static/common/h5fix.min.js"></script><![endif]-->
<link rel="stylesheet" th:href="${setting.domain + 'fonts/font-icons.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'bootstrap/css/bootstrap.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'select2/4.0/select2.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'icheck/1.0/minimal/grey.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'adminlte/css/AdminLTE.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'common/jeesite.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'common/common.css'}">
</head><body class="hold-transition ">
<div class="wrapper"><div class="main-content">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-trophy"></i> 新增书籍
</div>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
<form id="inputForm" th:action="${setting.domain + 'tiku/book/save'}" method="post" class="form-horizontal">
<div class="box-body">
<div class="form-unit">基本信息</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required ">*</span> 书籍名称:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="name" name="name" value="" maxlength="100" class="form-control required "/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required ">*</span> 出版社:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="publishingHouse" name="publishingHouse" value="" maxlength="64" class="form-control required"/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required">*</span> 归属科目:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<div class="input-group treeselect" id="companyDiv" data-url="tiku/course/treeData?">
<input id="courseId" type="hidden" name="courseId" value="" class="isReset"/>
<input id="courseName" type="text" name="courseName" value=""
class="form-control " readonly="readonly"
/><span class="input-group-btn"><a id="companyButton" href="javascript:"
class="btn btn-default "><i class="fa fa-search"></i></a>
</span>
</div>
<script>
$("#companyButton,#courseName").click(function(){
if ($("#companyButton").hasClass("disabled")){
return true;
}
var options = {
type: 2,
maxmin: true,
shadeClose: true,
title: '公司选择',
area: ['300px', '400px'],
content: 'sys/treeselect',
contentFormData: {
url: $('#companyDiv').attr('data-url'),
checkbox: 'false',
expandLevel: '-1',
selectCodes: $("#courseId").val(),
isReturnValue: 'false'
},
success: function(layero, index){
if ($(js.layer.window).width() < 300
|| $(js.layer.window).height() < 400){
js.layer.full(index);
}
},
btn: ['<i class="fa fa-check"></i> 确定'],
btn1: function(index, layero){
var win = js.layer.iframeWindow(index);
win.$('#keyword').val('').change(); var codes = [], names = [], nodes;
if ("false" == "true"){
nodes = win.tree.getCheckedNodes(true);
}else{
nodes = win.tree.getSelectedNodes();
}
for(var i=0; i<nodes.length; i++) {
if (nodes[i].level == 0 && nodes[i].isParent){
js.showMessage("不能选择根节点("+nodes[i].name+")请重新选择。");
return false;
}
if (nodes[i].isParent){
js.showMessage("不能选择父节点("+nodes[i].name+")请重新选择。");
return false;
}
var code = nodes[i]['false'=='true'?'value':'id'], name = nodes[i]['name'];
codes.push(code.replace(/^u_/g,''));
names.push(name.replace(/\([0-9]*\)/g,''));
break;
}
if(typeof treeselectCheck == 'function'){
if (!treeselectCheck('course', nodes)){
return false;
}
}
$("#courseId").val(codes.join(',')).change();
$("#courseName").val(names.join(',')).change();
try { $('#courseId,#courseName').valid(); }catch(e){}
if(typeof treeselectCallback == 'function'){
treeselectCallback('course', 'ok', index, layero, nodes);
}
}
};
options.btn.push('<i class="fa fa-eraser"></i> 清除');
options['btn'+options.btn.length] = function(index, layero){
$("#courseId").val('').change();
$("#courseName").val('').change();
if(typeof treeselectCallback == 'function'){
treeselectCallback('course', 'clear', index, layero);
}
};
options.btn.push('<i class="fa fa-close"></i> 关闭');
options['btn'+options.btn.length] = function(index, layero){
if(typeof treeselectCallback == 'function'){
treeselectCallback('course', 'cancel', index, layero);
}
};
js.layer.open(options);
});
</script> </div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required hide">*</span> 排序号:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="sort" name="sort" value="" maxlength="10" class="form-control digits"/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required hide">*</span> 问题数量:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="questionNum" name="questionNum" value="" maxlength="64" class="form-control required abc"/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required hide">*</span> 知识点数量:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="pointNum" name="pointNum" value="" maxlength="10" class="form-control digits"/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label class="control-label col-sm-2" title="">
<span class="required hide">*</span> 备注信息:<i class="fa icon-question hide"></i></label>
<div class="col-sm-10">
<textarea id="remarks" name="remarks" rows="4" maxlength="500" class="form-control "></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="box-footer">
<div class="row">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>&nbsp;
<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> 关 闭</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<a id="scroll-up" href="#" class="btn btn-sm"><i class="fa fa-angle-double-up"></i></a>
<script th:src="${setting.domain + 'bootstrap/js/bootstrap.min.js'}"></script>
<script th:src="${setting.domain + 'select2/4.0/select2.js'}"></script>
<script th:src="${setting.domain + 'select2/4.0/i18n/zh_CN.js'}"></script>
<script th:src="${setting.domain + 'layer/3.1/layer.js'}"></script>
<script th:src="${setting.domain + 'my97/WdatePicker.js'}"></script>
<script th:src="${setting.domain + 'jquery-validation/1.16/jquery.validate.js'}"></script>
<script th:src="${setting.domain + 'jquery-validation/1.16/localization/messages_zh_CN.js'}"></script>
<script th:src="${setting.domain + 'jquery-validation/1.16/jquery.validate.extend.js'}"></script>
<script th:src="${setting.domain + 'common/jeesite.js'}"></script>
<script th:src="${setting.domain + 'common/i18n/jeesite_zh_CN.js'}"></script>
<script th:src="${setting.domain + 'common/common.js'}"></script>
<script>
$("#inputForm").validate({
submitHandler: function(form){
js.ajaxSubmitForm($(form), function(data){
js.showMessage(data.message);
if(data.code == 0){
js.closeCurrentTabPage(function(contentWindow){
contentWindow.page();
});
}
}, "json");
}
});
</script>

@ -0,0 +1,108 @@
<!DOCTYPE html><html><head><meta charset="utf-8"><meta content="webkit" name="renderer"/><meta http-equiv="X-UA-Compatible"
content="IE=edge"><meta name="keywords" content="PoweredByJeeSiteV4.0"/><meta http-equiv="Cache-Control"
content="no-cache, no-store, must-revalidate"/><meta name="description" content="PoweredByJeeSiteV4.0"/><meta
content="no-cache" http-equiv="Pragma"/><meta http-equiv="Expires" content="0"/><meta
content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<title>章节管理 - JeeSite Demo</title>
<script th:src="${setting.domain + 'global.min.js'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-1.12.4.min.js'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-migrate-1.4.1.min.js'}"></script>
<!--[if lt IE 9]><script src="http://localhost/common/h5fix.min.js"></script><![endif]-->
<link rel="stylesheet" th:href="${setting.domain + 'fonts/font-icons.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'bootstrap/css/bootstrap.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'select2/4.0/select2.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'icheck/1.0/minimal/grey.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'jquery-ztree/3.5/css/metro/zTreeStyle.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'jquery-plugins/jquery.layout-latest.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'adminlte/css/AdminLTE.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'common/jeesite.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'common/common.css'}">
</head><body class="hold-transition ">
<div class="ui-layout-west">
<div class="main-content">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 书籍列表
</div>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool addTabPage" data-href="sys/chapter/list" title="章节管理"><i class="fa fa-edit"></i></button>
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i></button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
</div>
<div class="ui-layout-center">
<iframe id="mainFrame" name="mainFrame" class="ui-layout-content p0"
th:src="${setting.domain + 'tiku/chapter/list'}"></iframe>
</div>
<a id="scroll-up" href="#" class="btn btn-sm"><i class="fa fa-angle-double-up"></i></a>
<script th:src="${setting.domain + 'bootstrap/js/bootstrap.min.js'}"></script>
<script th:src="${setting.domain + 'select2/4.0/select2.js'}"></script>
<script th:src="${setting.domain + 'select2/4.0/i18n/zh_CN.js'}"></script>
<script th:src="${setting.domain + 'layer/3.1/layer.js'}"></script>
<script th:src="${setting.domain + 'my97/WdatePicker.js'}"></script>
<script th:src="${setting.domain + 'jquery-ztree/3.5/js/jquery.ztree.all-3.5.js'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-ui-draggable-1.12.1.min.js'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-ui-effect-1.12.1.min.js'}"></script>
<script th:src="${setting.domain + 'jquery-plugins/jquery.layout-latest.js'}"></script>
<script th:src="${setting.domain + 'common/jeesite.js'}"></script>
<script th:src="${setting.domain + 'common/i18n/jeesite_zh_CN.js'}"></script>
<script th:src="${setting.domain + 'common/common.js'}"></script>
<script>
// 初始化布局
$('body').layout({
west__size: 180
});
// 主页框架
var win = $("#mainFrame")[0].contentWindow;
// 树结构初始化加载
var setting = {view:{selectedMulti:false},data:{key:{title:"title"},simpleData: {enable: true},key: {url:"nourl"}},
callback:{onClick:function(event, treeId, treeNode){
tree.expandNode(treeNode);
win.$('input[type=reset]').click();
win.$('#companyCode').val(treeNode.id);
win.$('#companyName').val(treeNode.name);
win.page();
}}
}, tree, loadTree = function(){
js.ajaxSubmit(ctx + "tiku/book/treeData?___t=" + new Date().getTime(), {ctrlPermi:'2'/*1拥有的权限 2管理的权限*/}, function(data){
tree = $.fn.zTree.init($("#tree"), setting, data);//.expandAll(true);
// 展开第一级节点
/* var nodes = tree.getNodesByParam("level", 0);
for(var i=0; i<nodes.length; i++) {
tree.expandNode(nodes[i], true, false, false);
} */
// 展开第二级节点
// nodes = tree.getNodesByParam("level", 1);
// for(var i=0; i<nodes.length; i++) {
// tree.expandNode(nodes[i], true, false, false);
// }
}, null, null, js.text('loading.message'));
};loadTree();
// 工具栏按钮绑定
$('#btnExpand').click(function(){
tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function(){
tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function(){
loadTree();
});
//调用子页分页函数
function page(){
win.page();
}
</script>

@ -0,0 +1,115 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8"><meta content="webkit" name="renderer"/>
<meta http-equiv="X-UA-Compatible"
content="IE=edge"><meta name="keywords" content="PoweredByJeeSiteV4.0"/><meta http-equiv="Cache-Control"
content="no-cache, no-store, must-revalidate"/><meta name="description" content="PoweredByJeeSiteV4.0"/><meta
content="no-cache" http-equiv="Pragma"/><meta http-equiv="Expires" content="0"/><meta
content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<title>章节管理 - JeeSite Demo</title>
<script th:src="${setting.domain + 'global.min.js?ctx=/js/a'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-1.12.4.min.js'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-migrate-1.4.1.min.js'}"></script>
<!--[if lt IE 9]><script src="/js/static/common/h5fix.min.js"></script><![endif]-->
<link rel="stylesheet" th:href="${setting.domain + 'fonts/font-icons.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'bootstrap/css/bootstrap.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'select2/4.0/select2.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'icheck/1.0/minimal/grey.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'jqGrid/4.7/css/ui.jqgrid.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'adminlte/css/AdminLTE.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'common/jeesite.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'common/common.css'}">
</head><body class="hold-transition ">
<div class="wrapper"><div class="main-content">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 章节管理
</div>
<div class="box-tools pull-right">
<a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
<a href="#" class="btn btn-default" id="btnRefreshTree" title="刷新"><i class="fa fa-refresh"></i> 刷新</a>
<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="展开一级"><i class="fa fa-angle-double-down"></i> 展开</a>
<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="折叠全部"><i class="fa fa-angle-double-up"></i> 折叠</a>
</div>
</div>
<div class="box-body">
<form id="searchForm" th:action="${setting.domain + 'tiku/chapter/listData'}" method="post" class="form-inline hide" data-page-no="" data-page-size="" data-order-by="">
<div class="form-group">
<label class="control-label">章节代码:</label>
<div class="control-inline">
<input type="text" id="id" name="id" value="" maxlength="100" class="form-control width-120"/>
</div>
</div>
<div class="form-group">
<label class="control-label">章节名称:</label>
<div class="control-inline">
<input type="text" id="name" name="name" value="" maxlength="100" class="form-control width-120"/>
</div>
</div>
<div class="form-group">
<label class="control-label">状态:</label>
<div class="control-inline width-60">
<select id="status" name="status" class="form-control">
<option value="">&nbsp;</option>
<option value="0">正常</option>
<option value="2">停用</option>
</select>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-sm">查询</button>
<button type="reset" class="btn btn-default btn-sm">重置</button>
</div>
</form>
<table id="dataGrid"></table>
</div>
</div>
</div>
</div>
<a id="scroll-up" href="#" class="btn btn-sm"><i class="fa fa-angle-double-up"></i></a>
<script th:src="${setting.domain + 'bootstrap/js/bootstrap.min.js'}"></script>
<script th:src="${setting.domain + 'select2/4.0/select2.js'}"></script>
<script th:src="${setting.domain + 'select2/4.0/i18n/zh_CN.js'}"></script>
<script th:src="${setting.domain + 'layer/3.1/layer.js'}"></script>
<script th:src="${setting.domain + 'my97/WdatePicker.js'}"></script>
<script th:src="${setting.domain + 'jqGrid/4.7/js/jquery.jqGrid.js'}"></script>
<script th:src="${setting.domain + 'jqGrid/4.7/js/jquery.jqGrid.extend.js'}"></script>
<script th:src="${setting.domain + 'jqGrid/4.7/js/i18n/zh_CN.js'}"></script>
<script th:src="${setting.domain + 'common/jeesite.js'}"></script>
<script th:src="${setting.domain + 'common/i18n/jeesite_zh_CN.js'}"></script>
<script th:src="${setting.domain + 'common/common.js'}"></script>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
searchForm: $("#searchForm"),
columnModel: [
{header:'章节名称', name:'name', index:'a.office_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '( '+row.id+' ) '+'<a href="sys/office/update?officeCode='+row.officeCode+'" class="btnList" data-title="编辑机构">'+(val||row.id)+'</a>';
}},
{header:'问题数量', name:'questionNum', index:'a.question_num', width:100, align:"center"},
{header:'知识点数量', name:'pointNum', index:'a.pointNum', width:100, align:"center"},
{header:'操作', name:'actions', width:150, sortable:false, title:false, formatter: function(val, obj, row, act){
var actions = [];
actions.push('<a href="sys/chapter/update?officeCode='+row.officeCode+'" class="btnList" title="编辑机构"><i class="fa fa-pencil"></i></a>&nbsp;');
if (row.status == Global.STATUS_NORMAL){
actions.push('<a href="sys/chapter/disable?officeCode='+row.officeCode+'" class="btnList" title="停用机构" data-confirm="确认要停用该机构吗?"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
}
if (row.status == Global.STATUS_DISABLE){
actions.push('<a href="sys/chapter/enable?officeCode='+row.officeCode+'" class="btnList" title="启用机构" data-confirm="确认要启用该机构吗?"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
}
actions.push('<a href="sys/chapter/delete?officeCode='+row.officeCode+'" class="btnList" title="删除机构" data-confirm="确认要删除该机构及所有子机构吗?" data-deltreenode="'+row.id+'"><i class="fa fa-trash-o"></i></a>&nbsp;');
actions.push('<a href="sys/chapter/add?parentCode='+row.id+'" class="btnList" title="新增下级机构"><i class="fa fa-plus-square"></i></a>&nbsp;');
return actions.join('');
}}
],
treeGrid: true, // 启用树结构表格
defaultExpandLevel: 0, // 默认展开的层次
expandNodeClearPostData: 'viewCode,officeName,fullName,officeType,', // 展开节点清理请求参数数据(一般设置查询条件的字段属性,否则在查询后,不能展开子节点数据) // 加载成功后执行事件
ajaxSuccess: function(data){
}
});
</script>

@ -42,7 +42,7 @@ public class QuestionContrller {
ChapterEntity chapter = iChapterService.selectById(chapterId); ChapterEntity chapter = iChapterService.selectById(chapterId);
CourseEntity course = iCourseService.selectById(chapter.getCourseId()); CourseEntity course = iCourseService.selectById(chapter.getCourseId());
SubjectEntity subject = iSubjectService.selectById(course.getSubjectId()); SubjectEntity subject = iSubjectService.selectById(course.getSubjectId());
ChapterEntity parentChapter = iChapterService.selectById(chapter.getParentId()); ChapterEntity parentChapter = iChapterService.selectById(chapter.getParentCode());
ChapterEntity nextChapter = iChapterService.selectById(chapter.getId()); ChapterEntity nextChapter = iChapterService.selectById(chapter.getId());
Page<QuestionEntity> page = new Page<>(); Page<QuestionEntity> page = new Page<>();

Loading…
Cancel
Save