fanli/src/main/java/com/yeshi/fanli/dao/mybatis/msg/MsgDeviceReadStateMapper.java
@@ -19,6 +19,9 @@ */ MsgDeviceReadState selectByDeviceAndPlatformAndType(@Param("device") String device, @Param("platform") int platform, @Param("type") String type); MsgDeviceReadState selectByDeviceAndPlatformAndTypeForUpdate(@Param("device") String device, @Param("platform") int platform, @Param("type") String type); /** * 设置所有消息已读 fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/DeviceTokenIOSMapper.java
@@ -18,6 +18,8 @@ DeviceTokenIOS selectByDevice(String device); DeviceTokenIOS selectByDeviceForUpdate(String device); DeviceTokenIOS selectByDeviceToken(String deviceToken); List<DeviceTokenIOS> selectByUid( @Param("uid")Long uid, @Param("list")List<Integer> list); fanli/src/main/java/com/yeshi/fanli/entity/push/DeviceTokenIOS.java
@@ -2,7 +2,6 @@ import java.util.Date; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; fanli/src/main/java/com/yeshi/fanli/mapping/msg/MsgDeviceReadStateMapper.xml
@@ -35,6 +35,15 @@ from yeshi_ec_msg_device_read_state where mdrs_device=#{device} and mdrs_platform=#{platform} and mdrs_type=#{type} </select> <select id="selectByDeviceAndPlatformAndTypeForUpdate" resultMap="BaseResultMap" useCache="false" flushCache="true"> select <include refid="Base_Column_List" /> from yeshi_ec_msg_device_read_state where mdrs_device=#{device} and mdrs_platform=#{platform} and mdrs_type=#{type} for update </select> <select id="listByDeviceAndPlatform" resultMap="BaseResultMap" useCache="false" flushCache="true"> select <include refid="Base_Column_List" /> fanli/src/main/java/com/yeshi/fanli/mapping/push/DeviceTokenIOSMapper.xml
@@ -27,6 +27,13 @@ <include refid="Base_Column_List" /> from yeshi_ec_uid_devicetoken_ios where device = #{0} limit 1 </select> <select id="selectByDeviceForUpdate" resultMap="BaseResultMap" parameterType="java.lang.String"> select <include refid="Base_Column_List" /> from yeshi_ec_uid_devicetoken_ios where device = #{0} limit 1 for update </select> <select id="selectByDeviceToken" resultMap="BaseResultMap" parameterType="java.lang.String"> fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgDeviceReadStateServiceImpl.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.msg.MsgDeviceReadStateMapper; import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState; @@ -31,7 +32,7 @@ } @Override public void addUnreadDeviceMsg(String type, String device, int platform, int msgCount, String msg,Date msgTime) { public void addUnreadDeviceMsg(String type, String device, int platform, int msgCount, String msg, Date msgTime) { MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndType(device, platform, type); if (state != null) { MsgDeviceReadState update = new MsgDeviceReadState(); @@ -55,9 +56,11 @@ } } @Transactional @Override public MsgDeviceReadState getByDeviceAndPlatformAndType(String type, String device, int platform) { MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndType(device, platform, type); MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndTypeForUpdate(device, platform, type); if (state == null) { state = new MsgDeviceReadState(); state.setCreateTime(new Date()); fanli/src/main/java/com/yeshi/fanli/service/impl/push/IOSPushServiceImpl.java
@@ -265,7 +265,7 @@ return; // 判断device是否存在 DeviceTokenIOS deviceTokenIos = deviceTokenIOSMapper.selectByDevice(device); DeviceTokenIOS deviceTokenIos = deviceTokenIOSMapper.selectByDeviceForUpdate(device); if (deviceTokenIos == null) { deviceTokenIos = new DeviceTokenIOS(); deviceTokenIos.setCreateTime(new Date());