admin
2019-03-13 33b4ed2bbf28ec16b66e552680f56a691a4e908d
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserSystemMsgServiceImpl.java
@@ -7,6 +7,8 @@
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.config.SystemZnxDao;
import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
import com.yeshi.fanli.dao.mybatis.msg.UserSystemMsgMapper;
import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum;
@@ -25,6 +27,12 @@
   @Resource
   private UserMsgReadStateService userMsgReadStateService;
   @Resource
   private UserInfoMapper userInfoMapper;
   @Resource
   private SystemZnxDao systemZnxDao;
   @Override
   public void addUserSystemMsg(Long uid, UserSystemMsgTypeEnum type, String title, String content, int timeTag,
@@ -104,4 +112,25 @@
      userSystemMsgMapper.setMsgReadByUid(uid);
   }
   @Override
   public void syncSystemZNX(Long uid) {
      UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
      if (user == null)
         return;
      long createtTime = user.getCreatetime();
      List<SystemZnx> list = systemZnxDao.list("from SystemZnx s where s.createTime>=" + createtTime);
      if (list != null && list.size() > 0) {
         for (SystemZnx znx : list) {
            UserSystemMsg msg = userSystemMsgMapper.selectBySystemZNXId(znx.getId());
            if (msg == null)
               try {
                  addUserSystemMsg(uid, UserSystemMsgTypeEnum.common, null, null, UserSystemMsg.TIME_TAG_COMMON, znx);
               } catch (UserSystemMsgException e) {
                  e.printStackTrace();
               }
         }
      }
   }
}