admin
2019-12-06 cd637932a970e7935b17d41568fe89c92775bccc
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) {
   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();
@@ -39,6 +40,7 @@
         update.setUnReadCount(state.getUnReadCount() + msgCount);
         update.setUpdateTime(new Date());
         update.setLatestContent(msg);
         update.setLatestContentTime(msgTime);
         msgDeviceReadStateMapper.updateByPrimaryKeySelective(update);
      } else {
         state = new MsgDeviceReadState();
@@ -49,13 +51,16 @@
         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.selectByDeviceAndPlatformAndType(device, platform, type);
      MsgDeviceReadState state = msgDeviceReadStateMapper.selectByDeviceAndPlatformAndTypeForUpdate(device, platform,
            type);
      if (state == null) {
         state = new MsgDeviceReadState();
         state.setCreateTime(new Date());
@@ -99,4 +104,12 @@
      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();
   }
}