Browse Source

测试通知已读未读问题

koul 7 years ago
parent
commit
0c09c2a43c

+ 4 - 4
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/controller/WxNotifyController.java

@@ -105,9 +105,9 @@ public class WxNotifyController {
 	 * @return
 	 */
 	@PostMapping("/getNotifyDetails")
-	public ResultBean getNotifyDetails(@Param("notifyId")Long notifyId){
+	public ResultBean getNotifyDetails(@Param("notifyId")Long notifyId,@Param("stuId") Long stuId){
 		try {
-			NotifyDO stu = notifyService.getNotifyDetails(notifyId);
+			NotifyDO stu = notifyService.getNotifyDetails(stuId,notifyId);
 			return new ResultBean(stu);
 		}catch (Exception e){
 			return new ResultBean(e);
@@ -120,7 +120,7 @@ public class WxNotifyController {
 	 * @param teacherId
 	 * @return
 	 */
-	/*@PostMapping("/getNotifyDetailsByTeacher")
+	@PostMapping("/getNotifyDetailsByTeacher")
 	public ResultBean getNotifyDetailsByTeacher(@Param("notifyId")Long notifyId, @Param("teacherId")Long teacherId){
 		try {
 			NotifyDO teacher = notifyService.getNotifyDetailsByTeacher(notifyId, teacherId);
@@ -128,7 +128,7 @@ public class WxNotifyController {
 		}catch (Exception e){
 			return new ResultBean(e);
 		}
-	}*/
+	}
 
 	/**
 	 * 删除创建的通知

+ 2 - 2
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/WxNotifyService.java

@@ -55,7 +55,7 @@ public interface WxNotifyService {
 	 * @param
 	 * @return
 	 */
-	public NotifyDO getNotifyDetails(Long notifyId);
+	public NotifyDO getNotifyDetails(@Param("stuId") Long stuId,@Param("notifyId") Long notifyId) throws Exception;
 
 	/**
 	 * 教师端获取通知详情
@@ -63,7 +63,7 @@ public interface WxNotifyService {
 	 * @param teacherId
 	 * @return
 	 */
-	public NotifyDO getNotifyDetailsByTeacher(@Param("notifyId") Long notifyId, @Param("teacherId") Long teacherId);
+	public NotifyDO getNotifyDetailsByTeacher(@Param("notifyId") Long notifyId, @Param("teacherId") Long teacherId) throws Exception;
 
 	/**
 	 * 删除创建的通知

+ 26 - 4
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/impl/WxNotifyServiceImpl.java

@@ -178,9 +178,20 @@ public class WxNotifyServiceImpl implements WxNotifyService {
 	 * @param
 	 * @return
 	 */
-	public NotifyDO getNotifyDetails(Long notifyId){
+	public NotifyDO getNotifyDetails(Long stuId,Long notifyId) throws Exception {
 		NotifyDO notifyDO = notifyMapper.get(notifyId);
-		return getNotifyDetail(0L,0L,notifyDO);
+		NotifyrecordsDO byStu = notifyrecordsMapper.getByStu(stuId, notifyId);
+		if (ObjectUtils.isNotEmpty(byStu)){
+			byStu.setIsRead(2);
+			int update = notifyrecordsMapper.update(byStu);
+			if (update>0){
+				return getNotifyDetail(stuId,0L,notifyDO);
+			}else {
+				throw new Exception("系统内部错误,请联系管理员");
+			}
+		}else {
+			throw new Exception("通知已被删除,请刷新");
+		}
 	}
 
 	/**
@@ -189,9 +200,20 @@ public class WxNotifyServiceImpl implements WxNotifyService {
 	 * @param teacherId
 	 * @return
 	 */
-	public NotifyDO getNotifyDetailsByTeacher(Long notifyId, Long teacherId){
+	public NotifyDO getNotifyDetailsByTeacher(Long notifyId, Long teacherId) throws Exception {
 		NotifyDO notifyDO = notifyMapper.get(notifyId);
-		return getNotifyDetail(0L,teacherId,notifyDO);
+		NotifyrecordsDO byTeacher = notifyrecordsMapper.getByTeacher(notifyId, teacherId);
+		if (ObjectUtils.isNotEmpty(byTeacher)){
+			byTeacher.setIsRead(2);
+			int update = notifyrecordsMapper.update(byTeacher);
+			if (update>0){
+				return getNotifyDetail(0L,teacherId,notifyDO);
+			}else {
+				throw new Exception("系统内部错误,请联系管理员");
+			}
+		}else {
+			throw new Exception("通知已被删除,请刷新");
+		}
 
 	}
 

+ 5 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/mapper/WxNotifyrecordsMapper.java

@@ -2,6 +2,7 @@ package com.usoftchina.smartschool.school.wxschool.mapper;
 
 import com.usoftchina.smartschool.school.po.NotifyrecordsDO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -28,4 +29,8 @@ public interface WxNotifyrecordsMapper {
 	int remove(Long re_id);
 	
 	int batchRemove(Long[] reIds);
+
+	NotifyrecordsDO getByStu(@Param("stuId") Long stuId, @Param("notifyId") Long notifyId);
+
+	NotifyrecordsDO getByTeacher(@Param("notifyId") Long notifyId, @Param("teacherId") Long teacherId);
 }

+ 8 - 0
applications/school/school-server/src/main/resources/mapper/WxNotifyrecordsMapper.xml

@@ -88,4 +88,12 @@
 		</foreach>
 	</delete>
 
+	<select id="getByStu" resultType="com.usoftchina.smartschool.school.po.NotifyrecordsDO">
+		<include refid="NotifyrecordsVo"/> where notify_id = #{notifyId} and stu_id = #{stuId}
+	</select>
+
+	<select id="getByTeacher" resultType="com.usoftchina.smartschool.school.po.NotifyrecordsDO">
+		<include refid="NotifyrecordsVo"/> where notify_id = #{notifyId} and teacher_id = #{teacherId}
+	</select>
+
 </mapper>

+ 11 - 6
applications/wechat/wechat-server/src/main/java/com/usoftchina/smartschool/wechat/service/impl/WxPushServiceImpl.java

@@ -33,8 +33,8 @@ public class WxPushServiceImpl implements WxPushService{
                         + "\"keyword4\":{\"value\":\""+keyword4+"\",\"color\":\"#173177\"},"
                         + "\"remark\":{\"value\":\""+remark+"\",\"color\":\"#173177\"}}}";
                 String access_token=  getWxAcessToken(appId,secret);
-                String token= JSON.parseObject(access_token).getString("access_token");
-                HttpRequest hRequest=  HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+token)
+                //String token= JSON.parseObject(access_token).getString("access_token");
+                HttpRequest hRequest=  HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+access_token)
                         .header("Content-Type", "application/json")
                         .send(json.getBytes());
                 String result= hRequest.body();
@@ -57,9 +57,14 @@ public class WxPushServiceImpl implements WxPushService{
             params.put("appid", appId);
             params.put("secret", secret);
             params.put("grant_type", "client_credential");
-            HttpRequest httpRequest= HttpRequest.get("https://api.weixin.qq.com/sns/oauth2/access_token",params,false);
-            String content=httpRequest.body();
-           // System.err.println("WxPushToken======"+content);
-            return content;
+            //HttpRequest httpRequest= HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token",params,false);
+           // String content=httpRequest.body();
+           //System.err.println("WxPushToken======"+content);
+            HttpRequest response= HttpRequest.get("https://api.weixin.qq.com/sns/oauth2/access_token", params, true);
+            String result=response.body();
+            System.err.println("WxPushResult======"+result);
+            String token= JSON.parseObject(result).getString("access_token");
+            System.err.println("WxPushToken====="+token);
+            return token;
         }
 }