wuwen 5 年之前
父节点
当前提交
71a54acdb8

+ 10 - 0
src/main/java/com/ssj/bean/sys/train/bean/ExamInfo.java

@@ -29,6 +29,8 @@ public class ExamInfo extends BaseEntity {
 	
 	private Integer score;
 	
+	private Integer status;
+	
 	private Date createTime;
 
 	public Integer getRoleType() {
@@ -103,6 +105,14 @@ public class ExamInfo extends BaseEntity {
 		this.score = score;
 	}
 
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
 	
 	
 }

+ 1 - 1
src/main/java/com/ssj/dao/sys/train/dao/ExamInfoDao.java

@@ -12,7 +12,7 @@ import com.ssj.bean.sys.train.bean.ExamInfo;
 @Repository
 public interface ExamInfoDao extends JpaRepository<ExamInfo, String> {
 
-	@Query(nativeQuery = true,value = "SELECT * from tr_exam_info t WHERE t.video_id=?1 ORDER BY t.exam_num asc ")
+	@Query(nativeQuery = true,value = "SELECT * from tr_exam_info t WHERE t.status=1 and t.video_id=?1 ORDER BY t.exam_num asc ")
 	List<ExamInfo> findExamInfoByVideoId(String videoId);
 
 }

+ 2 - 2
src/main/java/com/ssj/dao/sys/train/dao/impl/TrainQueryDaoImpl.java

@@ -24,7 +24,7 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
 	public Page<Map<String, Object>> findTrainVideoInfoByPage(Map<String, Object> params, Pageable pageable) {
 		StringBuilder sb = new StringBuilder();
 		List<Object> param = new ArrayList<>();
-        sb.append(" SELECT * from tr_video_info t WHERE 1=1 ");
+        sb.append(" SELECT *,(SELECT count(1) from tr_exam_info e WHERE e.status=1 and e.video_id=t.id ) as exam_num from tr_video_info t WHERE 1=1 ");
         if(params.get("roleType")!=null && StringUtils.isNotEmpty(params.get("roleType").toString())) {
        	 	sb.append(" and t.role_type=?  ");
        	 	param.add(params.get("roleType"));
@@ -41,7 +41,7 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
        	  	sb.append(" and t.status =? ");
        	  	param.add(params.get("status"));
         }
-        sb.append(" ORDER BY t.indes ASC,t.create_time DESC ");
+        sb.append(" ORDER BY t.role_type ASC,t.indes ASC ");
         return dao.findPage(sb.toString(),param.toArray(),pageable);
 	}
 

+ 16 - 6
src/main/java/com/ssj/sys/controller/TrainController.java

@@ -54,7 +54,7 @@ public class TrainController extends BaseController {
 			throws Exception {
 		
 		Map<String, Object> params = new HashMap<String, Object>();
-		params.put("roleType", request.getParameter("roleType")==null?"":request.getParameter("roleType"));
+		params.put("roleType", request.getParameter("roleType")==null?"1":request.getParameter("roleType"));
 		params.put("module", request.getParameter("module")==null?"":request.getParameter("module"));
 		params.put("title", request.getParameter("title")==null?"":request.getParameter("title"));
 		params.put("index", request.getParameter("index")==null?"":request.getParameter("index"));
@@ -199,12 +199,13 @@ public class TrainController extends BaseController {
 	
 	@RequestMapping("/import/exam/info")
 	@ResponseBody
-    public ResponseEntity importDeviceData(HttpServletRequest request, HttpServletResponse response,
+    public Response importDeviceData(HttpServletRequest request, 
     		@RequestParam("file") MultipartFile file,String videoId)
     				throws Exception {
-		ResponseEntity responseEntity = new  ResponseEntity();
+		Response response = new  Response();
 		try {
 			VideoInfo videoInfo=videoInfoService.getById(videoId);
+			List<ExamInfo> oldExamInfos=examInfoService.findExamInfoByVideoId(videoId);
 			List<Map<String,String>> datas=ImLibUserController.analysisExFile(file);
 			if(datas!=null && datas.size()>0){
 				List<ExamInfo> examInfos=new ArrayList<ExamInfo>();
@@ -219,6 +220,7 @@ public class TrainController extends BaseController {
 					examInfo.setOptions(map.get("data_3"));
 					examInfo.setAnswer(map.get("data_4"));
 					examInfo.setScore(Integer.valueOf(map.get("data_5")));
+					examInfo.setStatus(1);
 					if(map.containsKey("data_6") && StringUtils.isNotEmpty(map.get("data_6"))) {
 						examInfo.setId(map.get("data_6"));
 					}
@@ -227,12 +229,18 @@ public class TrainController extends BaseController {
 				}
 				examInfoService.save(examInfos);
 			}
-			
+			if(oldExamInfos!=null && oldExamInfos.size()>0){
+				for (ExamInfo examInfo : oldExamInfos) {
+					examInfo.setStatus(2);
+				}
+				examInfoService.save(oldExamInfos);
+			}
+			response.success();
 		} catch (Exception e) {
 			logger.error("异常", e);
-			responseEntity.failure("导入异常:"+e.getMessage());
+			response.failure("导入异常:"+e.getMessage());
 		}
-		return responseEntity;
+		return response;
     }
 	
 	
@@ -285,10 +293,12 @@ public class TrainController extends BaseController {
     	if(StringUtils.isNotEmpty(param.getId())) {
     		VideoFile videoFile=videoFileService.getById(param.getId());
     		videoFile.setModule(param.getModule());
+    		videoFile.setType(param.getType());
     		videoFile.setRoleType(param.getRoleType());
     		videoFile.setStatus(param.getStatus());
     		videoFile.setTitle(param.getTitle());
     		videoFile.setFormat(param.getFormat());
+    		videoFile.setUrl(param.getUrl());
     		videoFile.setUpdateTime(new Date());
     		videoFileService.save(videoFile);
     	}else {

+ 4 - 48
src/main/resources/templates/sys/train/file_edit.html

@@ -129,51 +129,9 @@
 </div>
 </body>
 
-<!--视频插件调用方法-->
-<script>
-$(function () {
-	//视频
-	jsModern.video("#video");
-	//播放视频
-	$(".VideoBtn").click(function () {
-		var video = document.getElementById("videoShow");
-		video.play();
-		$('.VideoBtn').hide();
-	})
-})
-</script>
 
-<script type="text/javascript">
-var tool = 
-	[
-		"fullscreen", "undo", "redo", "|",
-		"bold", "italic", "underline", "fontborder", "strikethrough", "superscript", "subscript", "removeformat", "formatmatch", "autotypeset", "blockquote", "pasteplain", "|", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist", "selectall", "cleardoc", "|",
-		"rowspacingtop", "rowspacingbottom", "lineheight", "|",
-		"customstyle", "paragraph", "fontfamily", "fontsize", "|",
-		"directionalityltr", "directionalityrtl", "indent", "|",
-		"justifyleft", "justifycenter", "justifyright", "justifyjustify", "|", "touppercase", "tolowercase", "|",
-		"imagenone", "imageleft", "imageright", "imagecenter", "|",
-		"emotion","pagebreak", "template", "|",
-		"horizontal", "date", "time", "spechars",  "|",
-		"inserttable", "deletetable", "insertparagraphbeforetable", "insertrow", "deleterow", "insertcol", "deletecol", "mergecells", "mergeright", "mergedown", "splittocells", "splittorows", "splittocols", "charts", "|",
-		"preview", "searchreplace","drafts" 
-		];
-          
-var editor = new baidu.editor.ui.Editor({
-	//toolbars: [tool],
-	elementPathEnabled : false
-    ,wordCount:false         //是否开启字数统计
-    ,maximumWords:2000       //允许的最大字符数
-    ,wordCountMsg:'当前已输入 {#count} 个字符,您还可以输入{#leave} 个字符'
-    //超出字数限制提示  留空支持多语言自动切换,否则按此配置显示
-    ,wordOverFlowMsg:'<span style="color:red;">你输入的字符个数已经超出最大允许值!</span>' 
-});
-
-$(function(){
-	editor.render('editor');
-	editor.ready( function () { editor.setContent( $('#description').val() ); });  
-});
-</script>
+
+
 
 <script type="text/javascript">
 $(function () {
@@ -181,16 +139,14 @@ $(function () {
 })
 
 function saveFrom(){
-	var contents = UE.getEditor('editor').getContent();
-	$('#description').val(contents);
-	var url="[[${sysUrl}]]/sys/train/video/save";
+	var url="[[${sysUrl}]]/sys/train/file/save";
 	var params = $("#submitFrom").serialize();
 	$.post(url,params,function(data){
 		if(data != null){
 				if(data.meta.success){
 					layer.msg("操作成功!",{icon:1});
 			    	setTimeout(function(){
-			    		window.location.href ='[[${sysUrl}]]/sys/train/video/list.html';
+			    		window.location.href ='[[${sysUrl}]]/sys//train/file/list.html';
 					},1000);
 				}else{
 					layer.msg(data.meta.message,{icon:11});

+ 7 - 3
src/main/resources/templates/sys/train/video_list.html

@@ -102,6 +102,7 @@
 		    	<th >排序(从小到大)</th>
 		    	<th >状态 </th>
 		    	<th >上传时间 </th>
+		    	<th >小测题量 </th>
 		    	<th >操作 </th>
 		    </tr> 
 		</thead>
@@ -126,6 +127,7 @@
 				   <span th:case="2" style="color:red">已下架</span>
 				</td>
 				<td th:text="${item.create_time}"></td>
+				<td th:text="${item.exam_num}"></td>
 				<td >
 					<a th:href="@{/sys/train/video/edit.html(id=${item.id})}" class="tablelink">编辑</a>
 					<a href="javascript:;"  th:if="${item.status==0 || item.status==2 }" th:onclick="'joinServiceEdit(\''+${item.id}+'\')'" class="tablelink">发布</a>
@@ -160,10 +162,10 @@ $(function () {
 	            contentType: false,
 	            processData: false,
 	            success: function (data) {
-	                if (data.status == "success") {
+	            	if(data.meta.success){
 	                	parent.layer.msg("导入成功",{icon:1});
 				    	setTimeout(function(){
-				    		location.reload();
+				    		$(".scbtn").click();
 						},500);
 	                }else {
 	                    alert(data.msg);
@@ -189,7 +191,9 @@ function updateIndes(id,obj){
 			if(data != null){
 				if(data.meta.success){
 					layer.msg("操作成功!",{icon:1});
-					$(".scbtn").click();
+					setTimeout(function(){
+						$(".scbtn").click();
+					},500);
 				}else{
 					layer.msg(data.meta.message,{icon:11});
 				}