瀏覽代碼

培训系统V2

wuwen 5 年之前
父節點
當前提交
6c6b758244

+ 6 - 0
src/main/java/com/ssj/dao/sys/train/dao/VideoInfoDao.java

@@ -12,4 +12,10 @@ public interface VideoInfoDao extends JpaRepository<VideoInfo, String> {
 
 	@Query(nativeQuery = true,value =  "SELECT * FROM tr_video_info t WHERE t.`status`=1 AND t.role_type=?1 AND t.indes>( SELECT v.indes from `tr_video_info` v WHERE v.id=?2 ) ORDER BY t.indes ASC LIMIT 1 ")
 	public VideoInfo getVideoInfoByMax(Integer roleType,String id);
+	
+	@Query(nativeQuery = true,value =  "SELECT * FROM tr_video_info t WHERE t.role_type=?1 AND t.indes=?2 LIMIT 1 ")
+	public VideoInfo getVideoInfoByIndes(Integer roleType,Integer indes);
+	
+	@Query(nativeQuery = true,value =  "SELECT * from tr_video_info t WHERE t.role_type=?1 ORDER BY t.indes desc LIMIT 1 ")
+	public VideoInfo getVideoInfoByMaxIndes(Integer roleType);
 }

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

@@ -26,7 +26,7 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
 		List<Object> param = new ArrayList<>();
         sb.append(" SELECT * from tr_video_info t WHERE 1=1 ");
         if(params.get("roleType")!=null && StringUtils.isNotEmpty(params.get("roleType").toString())) {
-       	 	sb.append(" t.role_type=?  ");
+       	 	sb.append(" and t.role_type=?  ");
        	 	param.add(params.get("roleType"));
         }
         if(params.get("module")!=null && StringUtils.isNotEmpty(params.get("module").toString())) {
@@ -223,7 +223,7 @@ public class TrainQueryDaoImpl  implements TrainQueryDao {
        	  	sb.append(" AND t.title like concat('%',?,'%')  ");
        	  	param.add(params.get("name"));
         }
-        sb.append("  ORDER BY t.create_time DESC ");
+        sb.append("  ORDER BY t.type ASC,t.create_time DESC ");
         return dao.findPage(sb.toString(),param.toArray(),pageable);
 	}
 

+ 34 - 33
src/main/java/com/ssj/framework/core/xss/XssAndSqlHttpServletRequestWrapper.java

@@ -111,39 +111,40 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe
      * @return
      */
     private static String xssEncode(String s) {
-        if (s == null || s.isEmpty()) {
-            return s;
-        } else {
-            s = stripXSSAndSql(s);
-        }
-        StringBuilder sb = new StringBuilder(s.length() + 16);
-        for (int i = 0; i < s.length(); i++) {
-            char c = s.charAt(i);
-            switch (c) {
-                case '>':
-                    sb.append(">");// 转义大于号
-                    break;
-                case '<':
-                    sb.append("<");// 转义小于号
-                    break;
-                // case '\'':
-                // sb.append("'");// 转义单引号
-                // break;
-                // case '\"':
-                // sb.append(""");// 转义双引号
-                // break;
-                case '&':
-                    sb.append("&");// 转义&
-                    break;
-                case '#':
-                    sb.append("#");// 转义#
-                    break;
-                default:
-                    sb.append(c);
-                    break;
-            }
-        }
-        return sb.toString();
+    	return s;
+//        if (s == null || s.isEmpty()) {
+//            return s;
+//        } else {
+//            s = stripXSSAndSql(s);
+//        }
+//        StringBuilder sb = new StringBuilder(s.length() + 16);
+//        for (int i = 0; i < s.length(); i++) {
+//            char c = s.charAt(i);
+//            switch (c) {
+//                case '>':
+//                    sb.append(">");// 转义大于号
+//                    break;
+//                case '<':
+//                    sb.append("<");// 转义小于号
+//                    break;
+//                // case '\'':
+//                // sb.append("'");// 转义单引号
+//                // break;
+//                // case '\"':
+//                // sb.append(""");// 转义双引号
+//                // break;
+//                case '&':
+//                    sb.append("&");// 转义&
+//                    break;
+//                case '#':
+//                    sb.append("#");// 转义#
+//                    break;
+//                default:
+//                    sb.append(c);
+//                    break;
+//            }
+//        }
+//        return sb.toString();
     }
 
     /**

+ 4 - 0
src/main/java/com/ssj/service/sys/train/service/VideoInfoService.java

@@ -20,4 +20,8 @@ public interface VideoInfoService extends BaseService<VideoInfo, String> {
 	
 	public VideoInfo getVideoInfoByMax(Integer roleType,String id);
 	
+	public VideoInfo getVideoInfoByIndes(Integer roleType,Integer indes);
+	
+	public VideoInfo getVideoInfoByMaxIndes(Integer roleType);
+	
 }

+ 10 - 0
src/main/java/com/ssj/service/sys/train/service/impl/VideoInfoServiceImpl.java

@@ -50,6 +50,16 @@ public class VideoInfoServiceImpl extends BaseServiceImpl<VideoInfo, String> imp
 	public VideoInfo getVideoInfoByMax(Integer roleType, String id) {
 		return videoInfoDao.getVideoInfoByMax(roleType, id);
 	}
+
+	@Override
+	public VideoInfo getVideoInfoByIndes(Integer roleType, Integer indes) {
+		return videoInfoDao.getVideoInfoByIndes(roleType, indes);
+	}
+
+	@Override
+	public VideoInfo getVideoInfoByMaxIndes(Integer roleType) {
+		return videoInfoDao.getVideoInfoByMaxIndes(roleType);
+	}
 	
 	
 

+ 27 - 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("rolType", request.getParameter("rolType")==null?"":request.getParameter("rolType"));
+		params.put("roleType", request.getParameter("roleType")==null?"":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"));
@@ -95,7 +95,6 @@ public class TrainController extends BaseController {
     	if(StringUtils.isNotEmpty(param.getId())) {
 	    	VideoInfo videoInfo=videoInfoService.getById(param.getId());
 	    	videoInfo.setDescription(param.getDescription());
-	    	videoInfo.setIndes(param.getIndes());
 	    	videoInfo.setModule(param.getModule());
 	    	videoInfo.setRoleType(param.getRoleType());
 	    	videoInfo.setStatus(param.getStatus());
@@ -103,17 +102,39 @@ public class TrainController extends BaseController {
 	    	videoInfo.setUpdateTime(new Date());
 	    	videoInfoService.save(videoInfo);
     	}else {
+    		Integer indes=1;
+    		VideoInfo maxVideoInfo=videoInfoService.getVideoInfoByMaxIndes(param.getRoleType());
+    		if(maxVideoInfo!=null) {
+    			indes=maxVideoInfo.getIndes()+1;
+    		}
+    		param.setIndes(indes);
     		param.setCreateTime(new Date());
     		videoInfoService.save(param);
     	}
     	response.success();
     	return response;
 	 }
+	 
+	 
+	 @RequestMapping("/video/indes/update")
+	 @ResponseBody
+	 public Response videoIndesUpdate(Model model,String id,Integer indes) throws Exception{
+    	Response response = new  Response();
+    	if(StringUtils.isNotEmpty(id)) {
+	    	VideoInfo videoInfo=videoInfoService.getById(id);
+	    	VideoInfo indesVideoInfo=videoInfoService.getVideoInfoByIndes(videoInfo.getRoleType(), indes);
+	    	if(indesVideoInfo!=null) {
+	    		response.failure("排序号,同端下不可重复喔,请重新填写。");
+	    		return response;
+	    	}
+	    	videoInfo.setIndes(indes);
+	    	videoInfoService.save(videoInfo);
+    	}
+    	response.success();
+    	return response;
+	 }
 	
 	
-	
-
-	
 	@RequestMapping("/pace/list")
 	public String paceList(Model model,
 			@RequestParam(required = false, defaultValue = "10") int pageSize,
@@ -224,7 +245,7 @@ public class TrainController extends BaseController {
 		
 		Map<String, Object> params = new HashMap<String, Object>();
 		params.put("type", request.getParameter("type")==null?"":request.getParameter("type"));
-		params.put("rolType", request.getParameter("rolType")==null?"":request.getParameter("rolType"));
+		params.put("roleType", request.getParameter("roleType")==null?"":request.getParameter("roleType"));
 		params.put("module", request.getParameter("module")==null?"":request.getParameter("module"));
 		params.put("title", request.getParameter("title")==null?"":request.getParameter("title"));
 		

+ 3 - 3
src/main/resources/templates/sys/fx/merchantAdd.html

@@ -126,9 +126,9 @@ dtext{
 				<div class="vocation" style="margin-right: 5px; width: 345px">
 					<select name="signType" id="signType" class="select1"  > 
 						<option value="0" th:selected="${merchant.signType==0 ? true : false}">旧模式</option>
-						<option value="1" th:selected="${merchant.signType==1 ? true : false}">优选套餐</option>
-						<option value="2" th:selected="${merchant.signType==2 ? true : false}">VIP套餐</option>
-						<option value="3" th:selected="${merchant.signType==3 ? true : false}">尊享套餐</option>
+						<option value="1" th:selected="${merchant.signType==1 ? true : false}">优选套餐(服务包1)</option>
+						<option value="2" th:selected="${merchant.signType==2 ? true : false}">VIP套餐(服务包2)</option>
+						<option value="3" th:selected="${merchant.signType==3 ? true : false}">尊享套餐(服务包3)</option>
 					</select>
 				</div>
 				<label th:if="${merchant.id!=null}"  style="width: 230px;color:red">[修改套餐模式,不会影响加油包有效性 ]</label>

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

@@ -103,10 +103,10 @@
 				<label>资料路径:<b>*</b></label>
 				<input type="text" name="url" class="dfinput fl" id="url" th:value="${videoInfo.url}"/>
 			</li>
-			<li class="clearfix" >
-				<label>排序(顺序):<b>*</b></label>
-				<input type="text" name="indes" class="dfinput fl" id="index" th:value="${videoInfo.indes}"/>
-			</li>
+<!-- 			<li class="clearfix" > -->
+<!-- 				<label>排序(顺序):<b>*</b></label> -->
+<!-- 				<input type="number" name="indes" class="dfinput fl" id="index" th:value="${videoInfo.indes}"/> -->
+<!-- 			</li> -->
 			<li class="clearfix" >
 				<label>发布状态:<b>*</b></label>
 				<select class="scinput select_width"  name="status"   style="width: 345px;" >

+ 26 - 6
src/main/resources/templates/sys/train/video_list.html

@@ -117,7 +117,9 @@
 				<td th:text="${item.module}"></td>
 				<td th:text="${item.title}"></td>
 				<td th:text="${item.url}"></td>
-				<td th:text="${item.indes}"></td>
+				<td >
+					<input type="number" th:value="${item.indes}" th:onBlur="'updateIndes(\''+${item.id}+'\',this)'" class="dfinput" style="width: 60px; height: 30px;">
+				</td>
 				<td  th:switch="${item.status}">
 				   <span th:case="0" >未发布</span>
 				   <span th:case="1" >发布</span>
@@ -176,11 +178,29 @@ $(function () {
 	
 })
 
-	
-	function importexaminfo(videoId) {
-		$("#importexaminfo_file_id").val(videoId);
-		$("#importexaminfo_file").click();
-    };
+
+function updateIndes(id,obj){
+	var url="[[${sysUrl}]]/sys/train/video/indes/update";
+	var params = {
+			"id":id,
+			"indes":$(obj).val()
+	};
+	$.post(url,params,function(data){
+			if(data != null){
+				if(data.meta.success){
+					layer.msg("操作成功!",{icon:1});
+					$(".scbtn").click();
+				}else{
+					layer.msg(data.meta.message,{icon:11});
+				}
+		}
+	});
+}
+
+function importexaminfo(videoId) {
+	$("#importexaminfo_file_id").val(videoId);
+	$("#importexaminfo_file").click();
+};
 
 </script>