1.修复添加观影记录时同样的观影记录重复添加的bug
Showing
2 changed files
with
16 additions
and
7 deletions
... | @@ -829,9 +829,9 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -829,9 +829,9 @@ public class UserOperationServiceImpl implements UserOperationService { |
829 | //处理接口调用 中文不显示问题 | 829 | //处理接口调用 中文不显示问题 |
830 | content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8))); | 830 | content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8))); |
831 | 831 | ||
832 | log.info("receive addCollection add message, content {}", content); | ||
833 | |||
834 | JSONObject jsonObject = JSONObject.parseObject(content); | 832 | JSONObject jsonObject = JSONObject.parseObject(content); |
833 | log.info("receive addCollection add message, content {}", jsonObject); | ||
834 | |||
835 | String platformAccount = jsonObject.getString("platformAccount"); | 835 | String platformAccount = jsonObject.getString("platformAccount"); |
836 | String data = jsonObject.getString("data"); | 836 | String data = jsonObject.getString("data"); |
837 | 837 | ||
... | @@ -840,6 +840,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -840,6 +840,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
840 | 840 | ||
841 | 841 | ||
842 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | 842 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); |
843 | log.info("大屏账号信息 userTvDTO ==>> {}", userTvDTO); | ||
843 | 844 | ||
844 | Long tvUserId = userTvDTO.getId(); | 845 | Long tvUserId = userTvDTO.getId(); |
845 | List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class); | 846 | List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class); |
... | @@ -859,7 +860,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -859,7 +860,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
859 | 860 | ||
860 | UserCollection userCollection = this.userCollectionService | 861 | UserCollection userCollection = this.userCollectionService |
861 | .findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName()); | 862 | .findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName()); |
862 | 863 | log.info("收藏夹信息,大屏账号(uc_user_tv)id ==>> {} || 收藏夹name ==>> {} || 收藏夹type ==>> {}", tvUserId, | |
864 | userCollectionMq.getName(), userCollectionMq.getType()); | ||
863 | 865 | ||
864 | if (Objects.isNull(userCollection.getId())) { | 866 | if (Objects.isNull(userCollection.getId())) { |
865 | userCollection.setAppId(userCollectionMq.getAppId()) | 867 | userCollection.setAppId(userCollectionMq.getAppId()) |
... | @@ -879,7 +881,11 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -879,7 +881,11 @@ public class UserOperationServiceImpl implements UserOperationService { |
879 | .findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(), | 881 | .findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(), |
880 | userCollectionDetail.getDetailType(), userCollection.getId()); | 882 | userCollectionDetail.getDetailType(), userCollection.getId()); |
881 | 883 | ||
884 | log.info("检查观影记录是否存在,内容id ==>> {} || 内容type ==>> {} || 收藏夹id ==>> {}", userCollectionDetail.getDetailId(), | ||
885 | userCollectionDetail.getDetailType(), userCollection.getId()); | ||
886 | |||
882 | if (CollectionUtils.isEmpty(userCollectionDetailOptional)) { | 887 | if (CollectionUtils.isEmpty(userCollectionDetailOptional)) { |
888 | log.info("观影记录不存在,直接新增"); | ||
883 | 889 | ||
884 | userCollectionDetail.setId(null) | 890 | userCollectionDetail.setId(null) |
885 | .setUserCollectionId(userCollection.getId()); | 891 | .setUserCollectionId(userCollection.getId()); |
... | @@ -890,11 +896,14 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -890,11 +896,14 @@ public class UserOperationServiceImpl implements UserOperationService { |
890 | //观影记录同一天只存一条记录 | 896 | //观影记录同一天只存一条记录 |
891 | boolean sameDay = DateUtil.isSameDay(new Date(userCollectionDetail.getCreateTime().getTime()), new Date()); | 897 | boolean sameDay = DateUtil.isSameDay(new Date(userCollectionDetail.getCreateTime().getTime()), new Date()); |
892 | if (sameDay) { | 898 | if (sameDay) { |
893 | continue; | 899 | log.info("传过来的观影时间 ==>> {} 和今天的时间 ==>> {} 相同,修改观影记录,id ==>> {}",userCollectionDetail.getCreateTime().getTime(), |
894 | } else { | 900 | new Date(), userCollectionDetailOptional.get(0).getId()); |
895 | userCollectionDetail.setId(null) | 901 | userCollectionDetail.setId(userCollectionDetailOptional.get(0).getId()) |
896 | .setUserCollectionId(userCollection.getId()); | 902 | .setUserCollectionId(userCollection.getId()); |
897 | userCollectionDetailRepository.save(userCollectionDetail); | 903 | userCollectionDetailRepository.save(userCollectionDetail); |
904 | } else { | ||
905 | log.info("传过来的观影时间 ==>> {} 和今天的时间 ==>> {} 不相同,不做处理", userCollectionDetail.getCreateTime().getTime(), | ||
906 | new Date().toInstant().getEpochSecond()); | ||
898 | continue; | 907 | continue; |
899 | } | 908 | } |
900 | 909 | ... | ... |
... | @@ -45,7 +45,7 @@ spring: | ... | @@ -45,7 +45,7 @@ spring: |
45 | hibernate: | 45 | hibernate: |
46 | # 生产环境设置成 none,避免程序运行时自动更新数据库结构 | 46 | # 生产环境设置成 none,避免程序运行时自动更新数据库结构 |
47 | ddl-auto: none | 47 | ddl-auto: none |
48 | show-sql: false | 48 | show-sql: true |
49 | servlet: | 49 | servlet: |
50 | multipart: | 50 | multipart: |
51 | file-size-threshold: 2KB | 51 | file-size-threshold: 2KB | ... | ... |
-
Please register or sign in to post a comment