admin
2019-11-20 8b2191df2f7d94aa299bd43dcbe97c94e5a61bbd
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserActiveLogServiceImpl.java
@@ -9,12 +9,16 @@
import com.yeshi.fanli.dao.mybatis.user.UserActiveLogMapper;
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
import com.yeshi.fanli.service.inter.user.UserActiveLogService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
@Service
public class UserActiveLogServiceImpl implements UserActiveLogService {
   @Resource
   private UserActiveLogMapper userActiveLogMapper;
   @Resource
   private UserInfoExtraService userInfoExtraService;
   @Override
   public void addUserActiveLog(UserActiveLog userActiveLog) {
@@ -28,13 +32,33 @@
         userActiveLog.setCreateTime(new Date());
         userActiveLog.setUpdateTime(new Date());
         userActiveLogMapper.insertSelective(userActiveLog);
         // 更新最新活跃时间
         userInfoExtraService.updateActiveTime(userActiveLog.getUid() , new Date());
      } else if (latestLog != null) {
         // 如果设备 ,版本,渠道有变化则需要更改
         String oldIdentify = latestLog.getDevice() + "#" + latestLog.getVersionCode() + "#"
               + latestLog.getChannel();
         String newIdentify = userActiveLog.getDevice() + "#" + userActiveLog.getVersionCode() + "#"
               + userActiveLog.getChannel();
         if (!oldIdentify.equalsIgnoreCase(newIdentify)) {// 设备信息变化要记录信息
            userActiveLog.setCreateTime(new Date());
            userActiveLog.setUpdateTime(new Date());
            userActiveLogMapper.insertSelective(userActiveLog);
            // 更新最新活跃时间
            userInfoExtraService.updateActiveTime(userActiveLog.getUid() , new Date());
         }
      }
   }
   @Override
   public UserActiveLog getUserLatestActiveInfo(Long uid) {
      return userActiveLogMapper.selectLatestByUid(uid);
   }
   @Override
   public UserActiveLog getFirstActiveInfo(Long uid) {
      return userActiveLogMapper.selectFirstActiveInfo(uid);
   }
}