From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 20 五月 2020 17:25:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenHWServiceImpl.java |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenHWServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenHWServiceImpl.java
index 49d8ca9..ef76ef9 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenHWServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/DeviceTokenHWServiceImpl.java
@@ -6,6 +6,7 @@
 import javax.annotation.Resource;
 
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import com.yeshi.fanli.dao.mybatis.push.DeviceTokenHWMapper;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -20,30 +21,32 @@
 	private DeviceTokenHWMapper deviceTokenHWMapper;
 
 	@Override
-	public List<DeviceTokenHW> getDeviceTokenList(int page, int pageSize) {
-		return deviceTokenHWMapper.selectList((page - 1) * pageSize, pageSize);
+	public List<DeviceTokenHW> getDeviceTokenList(int page, int pageSize, List<Integer> versionList) {
+		return deviceTokenHWMapper.selectList((page - 1) * pageSize, pageSize, versionList);
 	}
 
 	@Override
-	public Long getDeviceTokenCount() {
-		Long count = deviceTokenHWMapper.selectCount();
+	public Long countDeviceToken(List<Integer> versionList) {
+		Long count = deviceTokenHWMapper.selectCount(versionList);
 		return count == null ? 0 : count;
 	}
 
+	@Transactional
 	@Override
-	public void addDeviceToken(String token, String device, Long uid) {
+	public void addDeviceToken(String token, String device, Long uid, int version) {
 		if (StringUtil.isNullOrEmpty(device))
 			return;
 		//
 		if (uid != null && uid == 0)
 			uid = null;
 
-		List<DeviceTokenHW> list = deviceTokenHWMapper.selectByDevice(device);
+		List<DeviceTokenHW> list = deviceTokenHWMapper.selectByDeviceForUpdate(device);
 		if (list == null || list.size() == 0) {
 			DeviceTokenHW deviceTokenHW = new DeviceTokenHW();
 			deviceTokenHW.setDevice(device);
 			deviceTokenHW.setDeviceToken(token);
 			deviceTokenHW.setDeviceTokenMd5(StringUtil.Md5(token));
+			deviceTokenHW.setVersion(version);
 			deviceTokenHW.setUpdateTime(new Date());
 			if (uid != null)
 				deviceTokenHW.setUser(new UserInfo(uid));
@@ -55,6 +58,7 @@
 				if (!StringUtil.isNullOrEmpty(token)) {
 					update.setDeviceToken(token);
 					update.setDeviceTokenMd5(StringUtil.Md5(token));
+					update.setVersion(version);
 				}
 				update.setUpdateTime(new Date());
 				if (uid != null)
@@ -68,7 +72,7 @@
 	public List<DeviceTokenHW> getDeviceTokenByUid(Long uid) {
 		if (uid == null)
 			return null;
-		return deviceTokenHWMapper.selectByUid(uid);
+		return deviceTokenHWMapper.selectByUid(uid, null);
 	}
 
 	@Override
@@ -88,4 +92,15 @@
 		deviceTokenHWMapper.bindUidByDevice(uid, device);
 	}
 
+	@Override
+	public List<DeviceTokenHW> getDeviceTokenByUid(Long uid, List<Integer> versionList) {
+		if (uid == null)
+			return null;
+
+		if (versionList != null && versionList.size() == 0)
+			return null;
+
+		return deviceTokenHWMapper.selectByUid(uid, versionList);
+	}
+
 }

--
Gitblit v1.8.0