main
tamguo 7 years ago
parent 07d6d6fcbe
commit f6c1eb3d1f

@ -0,0 +1,8 @@
package com.tamguo.modules.tiku.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.tamguo.modules.tiku.model.BookEntity;
public interface BookMapper extends BaseMapper<BookEntity>{
}

@ -0,0 +1,5 @@
package com.tamguo.modules.tiku.model;
public class BookEntity {
}

@ -0,0 +1,8 @@
package com.tamguo.modules.tiku.service;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.tiku.model.BookEntity;
public interface IBookService extends IService<BookEntity>{
}

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

@ -0,0 +1,13 @@
package com.tamguo.modules.tiku.service.impl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.tiku.dao.BookMapper;
import com.tamguo.modules.tiku.model.BookEntity;
import com.tamguo.modules.tiku.service.IBookService;
@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, BookEntity> implements IBookService{
}

@ -1,19 +1,25 @@
package com.tamguo.modules.tiku.service.impl;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
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.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tamguo.modules.tiku.dao.CourseMapper;
import com.tamguo.modules.tiku.dao.SubjectMapper;
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.enums.CourseStatusEnum;
import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum;
import com.tamguo.modules.tiku.service.ICourseService;
@Service
@ -21,6 +27,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, CourseEntity> i
@Autowired
public CourseMapper courseMapper;
@Autowired
public SubjectMapper subjectMapper;
@SuppressWarnings("unchecked")
@Transactional(readOnly=true)
@ -86,4 +94,31 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, CourseEntity> i
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).getUid());
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).getUid());
entity.put("name", courseList.get(i).getName());
entity.put("pId", courseList.get(i).getSubjectId());
entitys.add(entity);
}
return entitys;
}
}

@ -0,0 +1,26 @@
package com.tamguo.modules.tiku.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.tamguo.modules.tiku.service.IBookService;
@Controller
@RequestMapping(path="tiku/book")
public class BookController {
/** 书籍*/
private final String BOOK_LIST_PAGE = "modules/tiku/book/list";
@Autowired
private IBookService iBookService;
@RequestMapping(path="list")
public ModelAndView index(ModelAndView model) {
model.setViewName(BOOK_LIST_PAGE);
return model;
}
}

@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.plugins.Page;
import com.tamguo.common.utils.ExceptionSupport;
@ -118,4 +119,10 @@ public class CourseController {
return ExceptionSupport.resolverResult("停用科目", this.getClass(), e);
}
}
@RequestMapping(path="treeData",method=RequestMethod.POST)
@ResponseBody
public JSONArray treeData() {
return iCourseService.treeData();
}
}

@ -41,7 +41,7 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
</div>
<div class="ui-layout-center">
<iframe id="mainFrame" name="mainFrame" class="ui-layout-content p0"
src="http://localhost/sys/user/list"></iframe>
th:src="${setting.domain + 'sys/user/list'}"></iframe>
</div>
<a id="scroll-up" href="#" class="btn btn-sm"><i class="fa fa-angle-double-up"></i></a>

@ -0,0 +1,109 @@
<!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/course/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 + 'sys/user/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.uid);
win.$('#companyName').val(treeNode.name);
win.page();
}}
}, tree, loadTree = function(){
js.ajaxSubmit(ctx + "tiku/course/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>
Loading…
Cancel
Save