From bf13676673e9f0f090a68bd8cfbaefbf0d696d32 Mon Sep 17 00:00:00 2001
From: EricsHu <hrr145632>
Date: 星期日, 26 十一月 2023 13:03:00 +0800
Subject: [PATCH] 讨论区关键字过滤、首页班级显示班级信息

---
 src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java b/src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java
index 15fcc9a..c412c73 100644
--- a/src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java
+++ b/src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java
@@ -62,18 +62,32 @@
 	 * 棰樺簱鍒楄〃
 	 */
 	@RequestMapping(value = "/list", method = RequestMethod.GET)
-	public @ResponseBody Result pageList(String keyword,Short status, Integer pageSize, Integer pageNum) {
+	public @ResponseBody Result pageList(String keyword,Short status, Integer pageSize, Integer pageNum,String typeStatus) {
+		//鍒ゆ柇鏄惁鏄暀甯�
+//		String teacherId = ClientUtils.isAdmin() ? null : teacherService.getTeacherIdByUserId(ClientUtils.getUserId());
+		String teacherId = ClientUtils.isAdmin() ? null : ClientUtils.getUserId();
+
 		Result result = new Result(Boolean.TRUE);
 		Pager page = new Pager();
 		List<ExerciseGroup> listResult = null;
 		List<Object> queryParam = null;
 		// 鏌ヨ璁板綍鏁�
-		String hqlCount = "from ExerciseGroup where createId=? and type=? and name like ? and  deleteFlag is false ";
+		String hqlCount = "from ExerciseGroup where   type=? and name like ? and  deleteFlag is false ";
+
+
 		if(status!=null){
 			hqlCount = hqlCount.concat(" and status = ?");
-			queryParam = CollectionUtils.newList(ClientUtils.getUserId(), ExerciseGroup.TYPE_EXERCISE_GROUP_LIB,'%'+(keyword==null?"":keyword.trim())+'%',status);
+			queryParam = CollectionUtils.newList(ExerciseGroup.TYPE_EXERCISE_GROUP_LIB,'%'+(keyword==null?"":keyword.trim())+'%',status);
 		}else{
-			queryParam = CollectionUtils.newList(ClientUtils.getUserId(), ExerciseGroup.TYPE_EXERCISE_GROUP_LIB,'%'+(keyword==null?"":keyword.trim())+'%');
+			queryParam = CollectionUtils.newList( ExerciseGroup.TYPE_EXERCISE_GROUP_LIB,'%'+(keyword==null?"":keyword.trim())+'%');
+		}
+		if (StringUtils.isNotBlank(teacherId)) {
+			hqlCount = hqlCount.concat(" and createId=?");
+			queryParam.add(teacherId);
+		}
+		if (StringUtils.isNotBlank(typeStatus)) {
+			hqlCount = hqlCount.concat("  and typeStatus=?");
+			queryParam.add(typeStatus);
 		}
 		
 		int totalCount = commonDAO.findCount(hqlCount,queryParam);
@@ -83,10 +97,17 @@
 		page.setPageNum(pageNum != null && pageNum > 0 ? pageNum : DEFAULT_PAGE_NUM);
 
 		StringBuffer hqlBuffer =  new StringBuffer(500);
-		hqlBuffer.append("select g,s.name from ExerciseGroup g,Subject s where g.subjectId=s.subjectId and g.createId=? and g.type=? and g.name like ? and g.deleteFlag is false ");
+		hqlBuffer.append("select g,s.name from ExerciseGroup g,Subject s where g.subjectId=s.subjectId  and g.type=? and g.name like ? and g.deleteFlag is false ");
 		if(status!=null){
 			hqlBuffer.append(" and g.status = ? ");
 		}
+		if (StringUtils.isNotBlank(teacherId)) {
+			hqlBuffer.append(" and g.createId=?");
+		}
+
+		if (StringUtils.isNotBlank(typeStatus)) {
+			hqlBuffer.append(" and g.typeStatus=?");
+		}
 		hqlBuffer.append(" order by g.createTime DESC");
 		List<Object[]> list = commonDAO.findList(hqlBuffer.toString(), page,queryParam,Object[].class);
 		if(list!=null&& list.size()>0){

--
Gitblit v1.8.0