Commit 52ac481f3baf0de5bb948a7daad62f1c09126dc3
Exists in
dev
Merge remote-tracking branch 'origin/dev' into dev
Showing 2 changed files
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CourseController.java
View file @
52ac481
| ... | ... | @@ -11,21 +11,14 @@ |
| 11 | 11 | import com.lyms.platform.pojo.CourseEvaluateModel; |
| 12 | 12 | import com.lyms.platform.pojo.MsgModel; |
| 13 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | -import org.springframework.data.mongodb.core.MongoTemplate; | |
| 15 | 14 | |
| 16 | -import org.springframework.data.mongodb.gridfs.GridFsOperations; | |
| 17 | -import org.springframework.http.HttpStatus; | |
| 18 | 15 | import org.springframework.stereotype.Controller; |
| 19 | 16 | import org.springframework.web.bind.annotation.*; |
| 20 | 17 | import org.springframework.web.multipart.MultipartFile; |
| 21 | -import org.bson.types.ObjectId; | |
| 22 | 18 | import javax.servlet.http.HttpServletRequest; |
| 23 | -import javax.swing.text.Document; | |
| 24 | 19 | import java.io.File; |
| 25 | 20 | import java.io.IOException; |
| 26 | -import java.io.InputStream; | |
| 27 | -import org.springframework.http.ResponseEntity; | |
| 28 | -import org.springframework.web.servlet.mvc.support.RedirectAttributes; | |
| 21 | + | |
| 29 | 22 | |
| 30 | 23 | |
| 31 | 24 | /** |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CourseFacade.java
View file @
52ac481
| ... | ... | @@ -1228,9 +1228,10 @@ |
| 1228 | 1228 | if (parentId!=null){ |
| 1229 | 1229 | String readCount = model.getReadCount(); |
| 1230 | 1230 | //判断此条信息有没有值 |
| 1231 | - if (readCount==null){ | |
| 1231 | + if (readCount==null || readCount==""){ | |
| 1232 | 1232 | //如果没有值,直接添加数据 |
| 1233 | 1233 | model.setReadCount(parentId); |
| 1234 | + model.setReadNum(1); | |
| 1234 | 1235 | courseEvalService.updateMsgReadCount(model); |
| 1235 | 1236 | }else{ |
| 1236 | 1237 | // 判断 parentId 是否存在于 readCount 中 |
| 1237 | 1238 | |
| 1238 | 1239 | |
| ... | ... | @@ -1240,18 +1241,18 @@ |
| 1240 | 1241 | readCount += "," + parentId; |
| 1241 | 1242 | model.setReadCount(readCount); |
| 1242 | 1243 | |
| 1244 | + int commaCount = readCount.split(",").length-1; | |
| 1243 | 1245 | // 统计逗号数量,用于计算字段数量 |
| 1244 | - int commaCount = 0; | |
| 1245 | - for (int i = 0; i < readCount.length(); i++) { | |
| 1246 | - if (readCount.charAt(i) == ',') { | |
| 1247 | - commaCount++; | |
| 1248 | - } | |
| 1249 | - } | |
| 1246 | + //int commaCount = 0; | |
| 1247 | + //for (int i = 0; i < readCount.length(); i++) { | |
| 1248 | + // if (readCount.charAt(i) == ',') { | |
| 1249 | + // commaCount++; | |
| 1250 | + // } | |
| 1251 | + //} | |
| 1250 | 1252 | |
| 1251 | 1253 | // 计算字段数量 |
| 1252 | - int fieldCount = commaCount + 1; | |
| 1253 | - model.setReadNum(fieldCount); | |
| 1254 | - | |
| 1254 | + //int fieldCount = commaCount + 1; | |
| 1255 | + model.setReadNum(commaCount+1); | |
| 1255 | 1256 | // 更新消息阅读量 |
| 1256 | 1257 | courseEvalService.updateMsgReadCount(model); |
| 1257 | 1258 | } |
| 1258 | 1259 | |
| 1259 | 1260 | |
| ... | ... | @@ -1270,26 +1271,19 @@ |
| 1270 | 1271 | msgQuery.setYn(YnEnums.YES.getId()); |
| 1271 | 1272 | msgQuery.setNeed("true"); |
| 1272 | 1273 | List<MsgModel> models = courseEvalService.queryMsgList(msgQuery); |
| 1273 | - // 初始化计数器 | |
| 1274 | - int userIdCount = 0; | |
| 1275 | - // 遍历 models 列表 | |
| 1274 | +// 初始化计数器 | |
| 1275 | + int notContainCount = 0; | |
| 1276 | +// 遍历 models 列表 | |
| 1276 | 1277 | for (MsgModel model : models) { |
| 1277 | 1278 | // 获取当前消息的 readCount |
| 1278 | 1279 | String readCount = model.getReadCount(); |
| 1279 | - // 检查 readCount 是否包含当前登录人的 ID | |
| 1280 | - if (readCount != null && readCount.contains(parentId)) { | |
| 1281 | - return "该消息已经看过了"; | |
| 1282 | - }else if (readCount != null){ | |
| 1283 | - // 使用正则表达式将 readCount 拆分为多个 ID,并计算包含当前登录人 ID 的数量 | |
| 1284 | - String[] ids = readCount.split(","); | |
| 1285 | - for (String id : ids) { | |
| 1286 | - if (id.equals(parentId)) { | |
| 1287 | - userIdCount++; | |
| 1288 | - } | |
| 1289 | - } | |
| 1280 | + // 检查 readCount 是否为空,或者是否不包含当前登录人的 ID | |
| 1281 | + if (readCount == null || !readCount.contains(parentId)) { | |
| 1282 | + // readCount 为空,或者不包含当前登录人的 ID,则增加计数器 | |
| 1283 | + notContainCount++; | |
| 1290 | 1284 | } |
| 1291 | 1285 | } |
| 1292 | - return String.valueOf(userIdCount); | |
| 1286 | + return String.valueOf(notContainCount); | |
| 1293 | 1287 | } |
| 1294 | 1288 | } |