Browse Source

处理公告获取数据异常问题

hejq 7 years ago
parent
commit
a107cfe694
1 changed files with 22 additions and 14 deletions
  1. 22 14
      src/main/java/com/uas/platform/b2b/controller/NoticeController.java

+ 22 - 14
src/main/java/com/uas/platform/b2b/controller/NoticeController.java

@@ -1,20 +1,15 @@
 package com.uas.platform.b2b.controller;
 package com.uas.platform.b2b.controller;
 
 
-import com.uas.platform.b2b.support.SystemSession;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Sort.Direction;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
 import com.uas.platform.b2b.model.Notice;
 import com.uas.platform.b2b.model.Notice;
 import com.uas.platform.b2b.model.NoticeBody;
 import com.uas.platform.b2b.model.NoticeBody;
 import com.uas.platform.b2b.service.NoticeService;
 import com.uas.platform.b2b.service.NoticeService;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import com.uas.platform.core.model.PageParams;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
 
 
 /**
 /**
  * 系统公告
  * 系统公告
@@ -29,6 +24,11 @@ public class NoticeController {
 	@Autowired
 	@Autowired
 	private NoticeService noticeService;
 	private NoticeService noticeService;
 
 
+	/**
+	 * UU号正则表达式
+	 */
+	static final String UU_REGEXP = "^\\d{4,}$";
+
 	/**
 	/**
 	 * 系统公告分页查找
 	 * 系统公告分页查找
 	 * 
 	 * 
@@ -36,10 +36,14 @@ public class NoticeController {
 	 */
 	 */
 	@RequestMapping(method = RequestMethod.GET)
 	@RequestMapping(method = RequestMethod.GET)
 	@ResponseBody
 	@ResponseBody
-	public Page<Notice> getNotices(PageParams params, Long useruu) {
+	public Page<Notice> getNotices(PageParams params, @RequestParam(value = "useruu", defaultValue = "0", required = false) String useruu) {
 		PageInfo info = new PageInfo(params);
 		PageInfo info = new PageInfo(params);
 		info.sorting("date", Direction.DESC);
 		info.sorting("date", Direction.DESC);
-        return noticeService.findAllByPageInfo(info, useruu);
+		Long userUU = 0L;
+		if (useruu.matches(UU_REGEXP)) {
+            userUU = Long.valueOf(useruu);
+        }
+        return noticeService.findAllByPageInfo(info, userUU);
 	}
 	}
 	
 	
 	/**
 	/**
@@ -59,8 +63,12 @@ public class NoticeController {
      */
      */
 	@RequestMapping(value = "/setReadStatus", method = RequestMethod.POST)
 	@RequestMapping(value = "/setReadStatus", method = RequestMethod.POST)
     @ResponseBody
     @ResponseBody
-    public void setReadStauts(Long id, Long useruu) {
-        noticeService.setReadStatus(id, useruu);
+    public void setReadStatus(Long id, @RequestParam(value = "useruu", defaultValue = "0", required = false) String useruu) {
+        Long userUU = 0L;
+        if (useruu.matches(UU_REGEXP)) {
+            userUU = Long.valueOf(useruu);
+        }
+        noticeService.setReadStatus(id, userUU);
     }
     }
 
 
 }
 }