From 42411e4a26461229c6bca6e89ca55e98a80f5a4e Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 30 九月 2021 18:08:17 +0800
Subject: [PATCH] bug修改
---
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgDeviceReadStateServiceImpl.java | 230 ++++++++++++++++++++++++++++----------------------------
1 files changed, 115 insertions(+), 115 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgDeviceReadStateServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgDeviceReadStateServiceImpl.java
index 7885691..b50cf77 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgDeviceReadStateServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgDeviceReadStateServiceImpl.java
@@ -1,115 +1,115 @@
-package com.yeshi.fanli.service.impl.msg;
-
-import java.util.Date;
-import java.util.List;
-
-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;
-import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
-
-@Service
-public class MsgDeviceReadStateServiceImpl implements MsgDeviceReadStateService {
-
- @Resource
- private MsgDeviceReadStateMapper msgDeviceReadStateMapper;
-
- @Override
- public void setDeviceMsgRead(String type, String device, int platform) {
- MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndType(device, platform, type);
- if (state != null) {
- MsgDeviceReadState update = new MsgDeviceReadState();
- update.setId(state.getId());
- update.setReadTime(new Date());
- update.setUnReadCount(0);
- update.setUpdateTime(new Date());
- msgDeviceReadStateMapper.updateByPrimaryKeySelective(update);
- }
- }
-
- @Override
- 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();
- update.setId(state.getId());
- update.setUnReadCount(state.getUnReadCount() + msgCount);
- update.setUpdateTime(new Date());
- update.setLatestContent(msg);
- update.setLatestContentTime(msgTime);
- msgDeviceReadStateMapper.updateByPrimaryKeySelective(update);
- } else {
- state = new MsgDeviceReadState();
- state.setCreateTime(new Date());
- state.setDevice(device);
- state.setPlatform(platform);
- state.setType(type);
- state.setUnReadCount(msgCount);
- state.setUpdateTime(new Date());
- state.setLatestContent(msg);
- state.setLatestContentTime(msgTime);
- msgDeviceReadStateMapper.insertSelective(state);
- }
- }
-
- @Transactional
- @Override
- public MsgDeviceReadState getByDeviceAndPlatformAndType(String type, String device, int platform) {
- MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndTypeForUpdate(device, platform,
- type);
- if (state == null) {
- state = new MsgDeviceReadState();
- state.setCreateTime(new Date());
- state.setDevice(device);
- state.setPlatform(platform);
- state.setType(type);
- state.setUnReadCount(0);
- state.setUpdateTime(new Date());
- msgDeviceReadStateMapper.insertSelective(state);
- }
- return state;
- }
-
- @Override
- public void setAllMsgRead(String device, int platform) {
- msgDeviceReadStateMapper.setAllMsgRead(device, platform);
- }
-
- @Override
- public void initReadState(String device, int platform, String type) {
- MsgDeviceReadState state = getByDeviceAndPlatformAndType(type, device, platform);
- if (state == null) {
- state = new MsgDeviceReadState();
- state.setCreateTime(new Date());
- state.setDevice(device);
- state.setPlatform(platform);
- state.setReadTime(null);
- state.setType(type);
- state.setUnReadCount(0);
- msgDeviceReadStateMapper.insertSelective(state);
- }
- }
-
- @Override
- public int getUnReadCount(String device, int platform) {
- int totalCount = 0;
- List<MsgDeviceReadState> stateList = msgDeviceReadStateMapper.listByDeviceAndPlatform(device, platform);
- for (MsgDeviceReadState state : stateList) {
- totalCount += state.getUnReadCount();
- }
- return totalCount;
- }
-
- @Override
- public int getUnReadCount(String device, int platform, String type) {
- MsgDeviceReadState state = getByDeviceAndPlatformAndType(type, device, platform);
- if (state == null)
- return 0;
- return state.getUnReadCount() == null ? 0 : state.getUnReadCount();
- }
-
-}
+package com.yeshi.fanli.service.impl.msg;
+
+import java.util.Date;
+import java.util.List;
+
+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;
+import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
+
+@Service
+public class MsgDeviceReadStateServiceImpl implements MsgDeviceReadStateService {
+
+ @Resource
+ private MsgDeviceReadStateMapper msgDeviceReadStateMapper;
+
+ @Override
+ public void setDeviceMsgRead(String type, String device, int platform) {
+ MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndType(device, platform, type);
+ if (state != null) {
+ MsgDeviceReadState update = new MsgDeviceReadState();
+ update.setId(state.getId());
+ update.setReadTime(new Date());
+ update.setUnReadCount(0);
+ update.setUpdateTime(new Date());
+ msgDeviceReadStateMapper.updateByPrimaryKeySelective(update);
+ }
+ }
+
+ @Override
+ 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();
+ update.setId(state.getId());
+ update.setUnReadCount(state.getUnReadCount() + msgCount);
+ update.setUpdateTime(new Date());
+ update.setLatestContent(msg);
+ update.setLatestContentTime(msgTime);
+ msgDeviceReadStateMapper.updateByPrimaryKeySelective(update);
+ } else {
+ state = new MsgDeviceReadState();
+ state.setCreateTime(new Date());
+ state.setDevice(device);
+ state.setPlatform(platform);
+ state.setType(type);
+ state.setUnReadCount(msgCount);
+ state.setUpdateTime(new Date());
+ state.setLatestContent(msg);
+ state.setLatestContentTime(msgTime);
+ msgDeviceReadStateMapper.insertSelective(state);
+ }
+ }
+
+ @Transactional
+ @Override
+ public MsgDeviceReadState getByDeviceAndPlatformAndType(String type, String device, int platform) {
+ MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndTypeForUpdate(device, platform,
+ type);
+ if (state == null) {
+ state = new MsgDeviceReadState();
+ state.setCreateTime(new Date());
+ state.setDevice(device);
+ state.setPlatform(platform);
+ state.setType(type);
+ state.setUnReadCount(0);
+ state.setUpdateTime(new Date());
+ msgDeviceReadStateMapper.insertSelective(state);
+ }
+ return state;
+ }
+
+ @Override
+ public void setAllMsgRead(String device, int platform) {
+ msgDeviceReadStateMapper.setAllMsgRead(device, platform);
+ }
+
+ @Override
+ public void initReadState(String device, int platform, String type) {
+ MsgDeviceReadState state = getByDeviceAndPlatformAndType(type, device, platform);
+ if (state == null) {
+ state = new MsgDeviceReadState();
+ state.setCreateTime(new Date());
+ state.setDevice(device);
+ state.setPlatform(platform);
+ state.setReadTime(null);
+ state.setType(type);
+ state.setUnReadCount(0);
+ msgDeviceReadStateMapper.insertSelective(state);
+ }
+ }
+
+ @Override
+ public int getUnReadCount(String device, int platform) {
+ int totalCount = 0;
+ List<MsgDeviceReadState> stateList = msgDeviceReadStateMapper.listByDeviceAndPlatform(device, platform);
+ for (MsgDeviceReadState state : stateList) {
+ totalCount += state.getUnReadCount();
+ }
+ return totalCount;
+ }
+
+ @Override
+ public int getUnReadCount(String device, int platform, String type) {
+ MsgDeviceReadState state = getByDeviceAndPlatformAndType(type, device, platform);
+ if (state == null)
+ return 0;
+ return state.getUnReadCount() == null ? 0 : state.getUnReadCount();
+ }
+
+}
--
Gitblit v1.8.0