diff --git a/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/sysfunvisturl/service/ISyChanmgfunVistUrlService.java b/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/sysfunvisturl/service/ISyChanmgfunVistUrlService.java index f53d7f42b1a0a029966624b1e1ce1c548dbeddf1..b4bf789b952b1303c3695db4814d6ba4e99364db 100644 --- a/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/sysfunvisturl/service/ISyChanmgfunVistUrlService.java +++ b/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/sysfunvisturl/service/ISyChanmgfunVistUrlService.java @@ -2,7 +2,6 @@ package tech.mhuang.interchan.sso.sysfunvisturl.service; import org.springframework.scheduling.annotation.Async; import tech.mhuang.ext.interchan.core.service.BaseService; -import tech.mhuang.interchan.protocol.sso.sysfunvisturl.SyChanmgfunExcludeUrlDTO; import tech.mhuang.interchan.protocol.sso.sysfunvisturl.SyChanmgfunVistUrlmAddDTO; import tech.mhuang.interchan.protocol.sso.sysfunvisturl.SyChanmgfunVistUrlmQryDTO; import tech.mhuang.interchan.sso.sysfunvisturl.entity.SyChanmgfunVistUrlm; @@ -53,13 +52,6 @@ public interface ISyChanmgfunVistUrlService extends BaseService queryFunVist(String funid); - /** - * @return void - * @Title: setExcludeUrl - * @Description: 设置排除url - */ - List setExcludeUrl(); - /** * @param userid * @return void diff --git a/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/sysfunvisturl/service/impl/SyChanmgfunVistUrlService.java b/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/sysfunvisturl/service/impl/SyChanmgfunVistUrlService.java index f67783c53a88e7c2dd0b632896e90177326e1466..5c19b42f54c4c2917c4dddcf086b028568a726ef 100644 --- a/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/sysfunvisturl/service/impl/SyChanmgfunVistUrlService.java +++ b/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/sysfunvisturl/service/impl/SyChanmgfunVistUrlService.java @@ -1,6 +1,5 @@ package tech.mhuang.interchan.sso.sysfunvisturl.service.impl; -import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -13,16 +12,15 @@ import tech.mhuang.ext.interchan.auth.constant.AuthConstant; import tech.mhuang.ext.interchan.core.service.impl.BaseServiceImpl; import tech.mhuang.ext.interchan.protocol.InsertInto; import tech.mhuang.ext.spring.util.DataUtil; -import tech.mhuang.interchan.protocol.sso.sysfunvisturl.SyChanmgfunExcludeUrlDTO; import tech.mhuang.interchan.protocol.sso.sysfunvisturl.SyChanmgfunVistUrlmAddDTO; import tech.mhuang.interchan.protocol.sso.sysfunvisturl.SyChanmgfunVistUrlmQryDTO; -import tech.mhuang.interchan.sso.sysfunvisturl.entity.SyChanmgfunExcludeUrl; +import tech.mhuang.interchan.sso.sysfunvisturl.cache.SysFunvisturlRedisOperator; import tech.mhuang.interchan.sso.sysfunvisturl.entity.SyChanmgfunVistUrlm; import tech.mhuang.interchan.sso.sysfunvisturl.mapper.SyChanmgfunVistUrlmMapper; import tech.mhuang.interchan.sso.sysfunvisturl.service.ISyChanmgfunVistUrlService; -import tech.mhuang.interchan.sso.sysfunvisturl.cache.SysFunvisturlRedisOperator; import tech.mhuang.interchan.sso.sysrole.entity.SysRole; import tech.mhuang.interchan.sso.sysuser.entity.SysUser; +import tech.mhuang.interchan.sso.util.RedisCacheStartup; import java.util.ArrayList; import java.util.Date; @@ -39,7 +37,7 @@ import java.util.stream.Collectors; @Service("syChanmgfunVistUrlService") @Transactional(readOnly = true) public class SyChanmgfunVistUrlService - extends BaseServiceImpl implements ISyChanmgfunVistUrlService, InitializingBean { + extends BaseServiceImpl implements ISyChanmgfunVistUrlService { @Autowired private BaseIdeable snowflake; @@ -50,6 +48,9 @@ public class SyChanmgfunVistUrlService @Autowired private SysFunvisturlRedisOperator syChanmgfunRedisOperator; + @Autowired + private RedisCacheStartup redisCacheStartup; + /** * @param funid * @return void @@ -89,7 +90,7 @@ public class SyChanmgfunVistUrlService @Transactional(propagation = Propagation.REQUIRED) @Override public void insertPowersUrl(List dtos, String userId, String seqno) { - dtos.forEach((value) -> { + dtos.forEach(value -> { SyChanmgfunVistUrlm url = DataUtil.copyTo(value, SyChanmgfunVistUrlm.class); url.setOperateTime(new Date()); url.setOperateUser(userId); @@ -120,35 +121,6 @@ public class SyChanmgfunVistUrlService return DataUtil.copyTo(urlm, SyChanmgfunVistUrlmQryDTO.class); } - /** - * @return void - * @Title: setExcludeUrl - * @Description: 设置排除地址 - */ - @Override - public List setExcludeUrl() { - List vos = null; - //查询数据库,并放入缓存中 - List urls = this.syChanmgfunVistUrlmMapper.getExcludeUrl(); - if (CollectionUtil.isNotEmpty(urls)) { - Map datas = - urls.parallelStream().collect(Collectors.groupingBy(SyChanmgfunExcludeUrl::getType)); - syChanmgfunRedisOperator.cacheData(AuthConstant.AUTH_DICT_KEY, datas); - } - return vos; - } - - /** - *

Title: afterPropertiesSet

- *

Description:

- * - * @throws Exception - * @see InitializingBean#afterPropertiesSet() - */ - @Override - public void afterPropertiesSet() throws Exception { - setExcludeUrl(); - } /** *

Title: setVistUrlPower

@@ -170,7 +142,7 @@ public class SyChanmgfunVistUrlService public void setVistUrlPowerNow(String userId) { String cacheKey = AuthConstant.USER_VIST_URL_CACHEKEY; List urlms = this.syChanmgfunVistUrlmMapper.getUserUrlPower(userId); - Map params = urlms.parallelStream().collect(Collectors.toMap((k) -> { + Map params = urlms.parallelStream().collect(Collectors.toMap(k -> { return userId.concat("-").concat(k.getUrl()); }, v -> v, (oldValue, newValue) -> oldValue)); syChanmgfunRedisOperator.cacheData(cacheKey, params); @@ -248,7 +220,7 @@ public class SyChanmgfunVistUrlService if (StringUtil.isNotBlank(userId)) { this.setVistUrlPowerNow(userId); } else { - this.setExcludeUrl(); + redisCacheStartup.afterPropertiesSet(); } } diff --git a/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/util/RedisCacheStartup.java b/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/util/RedisCacheStartup.java new file mode 100644 index 0000000000000000000000000000000000000000..168f10259738fed09d3bb36590f9763ce954724b --- /dev/null +++ b/inter-boot-sso/src/main/java/tech/mhuang/interchan/sso/util/RedisCacheStartup.java @@ -0,0 +1,43 @@ +package tech.mhuang.interchan.sso.util; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import tech.mhuang.core.util.CollectionUtil; +import tech.mhuang.ext.interchan.auth.constant.AuthConstant; +import tech.mhuang.interchan.sso.sysfunvisturl.cache.SysFunvisturlRedisOperator; +import tech.mhuang.interchan.sso.sysfunvisturl.entity.SyChanmgfunExcludeUrl; +import tech.mhuang.interchan.sso.sysfunvisturl.mapper.SyChanmgfunVistUrlmMapper; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @ClassName: RedisCacheStartup + * @Author: Ever + * @Description: Redis + * @Date: 2019/12/28 0:11 + * @Version: 1.0 + */ +@Component("redisCacheStartup") +public class RedisCacheStartup implements InitializingBean { + + @Autowired + private SyChanmgfunVistUrlmMapper syChanmgfunVistUrlmMapper; + + @Autowired + private SysFunvisturlRedisOperator syChanmgfunRedisOperator; + + + @Override + public void afterPropertiesSet() { + //查询数据库,并放入缓存中 + List urls = this.syChanmgfunVistUrlmMapper.getExcludeUrl(); + if (CollectionUtil.isNotEmpty(urls)) { + Map datas = + urls.parallelStream().collect(Collectors.groupingBy(SyChanmgfunExcludeUrl::getType)); + syChanmgfunRedisOperator.cacheData(AuthConstant.AUTH_DICT_KEY, datas); + } + } +}