diff --git a/servers/boe-server-all/src/main/java/com/xboe/data/service/impl/DataUserSyncServiceImpl.java b/servers/boe-server-all/src/main/java/com/xboe/data/service/impl/DataUserSyncServiceImpl.java index 61f61061..ebfa61e0 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/data/service/impl/DataUserSyncServiceImpl.java +++ b/servers/boe-server-all/src/main/java/com/xboe/data/service/impl/DataUserSyncServiceImpl.java @@ -2,11 +2,15 @@ package com.xboe.data.service.impl; import java.time.LocalDateTime; +import javax.annotation.Resource; import javax.transaction.Transactional; import com.boe.feign.api.serverall.entity.UserData; +import com.xboe.constants.CacheName; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; import org.springframework.retry.annotation.Recover; import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; @@ -39,6 +43,9 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService { @Autowired TeacherDao teacherDao; + @Resource + private CacheManager cacheManager; + @Override @Transactional @@ -76,6 +83,13 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService { accountDao.save(a); log.info("账号不存在,新添加账号【" + user.getId() + "】"); } + + Cache cache = cacheManager.getCache(CacheName.NAME_USER); + if(cache != null) { + String key = CacheName.KEY_ACCOUNT + user.getId(); + cache.evict(key); + } + if (u != null) { //更新部分用户字段 u.setDepartId(user.getDepartId());