|
@@ -40,6 +40,8 @@ public class ZoneInfoService {
|
40
|
40
|
private final GeomInfoRepository geomInfoRepository;
|
41
|
41
|
private final ModelInfoRepository modelInfoRepository;
|
42
|
42
|
|
|
43
|
+ private static final Long ONEDAY = 24 * 60 * 60 * 1000L;
|
|
44
|
+
|
43
|
45
|
@Autowired
|
44
|
46
|
private LikesInfoRepository likesInfoRepository;
|
45
|
47
|
|
|
@@ -290,8 +292,13 @@ public class ZoneInfoService {
|
290
|
292
|
UserInfo shareUserInfo = userInfoRepository.findByUserCode(shareUserCode);
|
291
|
293
|
if (Objects.isNull(shareUserInfo)) throw new RuntimeException("未能找到与该手机号码相关的账户,请确认号码无误");
|
292
|
294
|
String shareCode = UUID.randomUUID().toString();
|
293
|
|
- if (shareInfoRepository.findByZoneIdAndSharedUserId(zoneId, shareUserInfo.getUserId()).size() > 0) throw new RuntimeException("该账户已分享过该作品");
|
294
|
|
- zoneInfoRepository.share(zoneId, userCode, shareCode, shareUserInfo.getUserId());
|
|
295
|
+ List<ShareInfo> shareInfoList = shareInfoRepository.findByZoneIdAndSharedUserId(zoneId, shareUserInfo.getUserId());
|
|
296
|
+ if (shareInfoList.size() > 0 && (shareTime(shareInfoList.get(0)) > System.currentTimeMillis())) throw new RuntimeException("该账户已分享过该作品");
|
|
297
|
+ else if (shareInfoList.size() > 0 && (shareTime(shareInfoList.get(0)) < System.currentTimeMillis())) {
|
|
298
|
+ shareInfoRepository.updateShareTime(zoneId, shareUserInfo.getUserId());
|
|
299
|
+ }else {
|
|
300
|
+ zoneInfoRepository.share(zoneId, userCode, shareCode, shareUserInfo.getUserId());
|
|
301
|
+ }
|
295
|
302
|
UserInfo userInfo = userInfoRepository.findByUserCode(userCode);
|
296
|
303
|
NoticeInfo noticeInfo = new NoticeInfo();
|
297
|
304
|
noticeInfo.setUserId(shareUserInfo.getUserId());
|
|
@@ -304,6 +311,10 @@ public class ZoneInfoService {
|
304
|
311
|
return shareCode;
|
305
|
312
|
}
|
306
|
313
|
|
|
314
|
+ private Long shareTime(ShareInfo shareInfo){
|
|
315
|
+ return shareInfo.getShareTime().getTime() + shareInfo.getCanUse() * ONEDAY;
|
|
316
|
+ }
|
|
317
|
+
|
307
|
318
|
@Transactional
|
308
|
319
|
public void view(Integer zoneId, String userCode) {
|
309
|
320
|
zoneInfoRepository.view(zoneId, userCode);
|
|
@@ -426,8 +437,7 @@ public class ZoneInfoService {
|
426
|
437
|
public boolean checkShareStatus(Integer zoneId, Integer userId) {
|
427
|
438
|
List<ShareInfo> shareInfos = shareInfoRepository.findByZoneIdAndSharedUserId(zoneId, userId);
|
428
|
439
|
if (shareInfos.size() < 1) return false;
|
429
|
|
- ShareInfo shareInfo = shareInfos.get(0);
|
430
|
|
- return (shareInfo.getShareTime().getTime() + (shareInfo.getCanUse() * 1000 * 60 * 60)) > System.currentTimeMillis();
|
|
440
|
+ return shareTime(shareInfos.get(0)) > System.currentTimeMillis();
|
431
|
441
|
}
|
432
|
442
|
|
433
|
443
|
|