From 7664ba49025a6c549885fc6019e4d3c1886f45a6 Mon Sep 17 00:00:00 2001 From: dangsn <dangsn@chicecm.com> Date: 星期五, 07 六月 2024 14:26:16 +0800 Subject: [PATCH] 调整项目BUG --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/CacheNameConstant.java | 102 +++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java | 6 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmSessionForLoginImpl.java | 5 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java | 6 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/BusAnnotationUtil.java | 2 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisService.java | 361 +++++++++--- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java | 527 +++++++++++------- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/initTask/VciWebInitTaskComponent.java | 2 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java | 3 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/LoginServiceI.java | 30 + Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java | 21 Source/plt-web/plt-web-parent/plt-web-base/pom.xml | 5 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java | 6 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebHomeTaskServiceImpl.java | 1 Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages_zh_CN.properties | 5 Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/JwtUtils.java | 135 ++++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisConfig.java | 2 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java | 6 Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages.properties | 5 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/constant/FrameWorkBusLangCodeConstant.java | 24 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java | 7 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmFunctionQueryServicePlatformImpl.java | 7 /dev/null | 80 -- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/PlatformClientUtil.java | 36 + Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/constant/TokenKeyConstant.java | 34 + Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/pagemodel/TokenVO.java | 52 + Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBoServiceImpl.java | 151 ++-- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/pagemodel/SmUserVO.java | 20 Source/plt-web/plt-web-parent/plt-web/src/main/resources/application-dev.yml | 8 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java | 6 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java | 7 31 files changed, 1,100 insertions(+), 562 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web-base/pom.xml b/Source/plt-web/plt-web-parent/plt-web-base/pom.xml index ae4b444..3b0dbc6 100644 --- a/Source/plt-web/plt-web-parent/plt-web-base/pom.xml +++ b/Source/plt-web/plt-web-parent/plt-web-base/pom.xml @@ -46,6 +46,11 @@ <artifactId>hutool-all</artifactId> <version>5.4.3</version> </dependency> + <dependency> + <groupId>io.jsonwebtoken</groupId> + <artifactId>jjwt</artifactId> + <version>0.9.1</version> + </dependency> </dependencies> </project> \ No newline at end of file diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/constant/TokenKeyConstant.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/constant/TokenKeyConstant.java index 37bdd93..e3baafd 100644 --- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/constant/TokenKeyConstant.java +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/constant/TokenKeyConstant.java @@ -37,4 +37,38 @@ */ public static final String REQUEST_TIMESTAMP = "vciHttpStartRequestTime"; + /** + * 鐢ㄦ埛璁稿彲鍦╮edis閲岀殑鍓嶇紑 + */ + public static final String TOKEN_KEY_PREFIX_IN_REDIS = "jwt-token:"; + + /** + * 浠ょ墝绉橀挜 + */ + public static final String SECRET = "thisissecretforjwt"; + + /** + * JWT涓殑鐢ㄦ埛涓婚敭鐨凨ey + */ + public static final String JWT_USER_KEY = "user_key"; + + /** + * JWT涓璽oken鐨刱ey + */ + public static final String JWT_TOKEN_KEY = "token_key"; + + /** + * JWT涓敤鎴疯处鍙风殑key + */ + public static final String JWT_USER_CODE_KEY = "user_code_key"; + + /** + * JWT涓敤鎴峰悕瀛梜ey + */ + public static final String JWT_USER_NAME_KEY = "user_name_key"; + + /** + * 缂撳瓨鏈夋晥鏈燂紝榛樿30锛堝垎閽燂級 + */ + public static final long EXPIRATION = 30; } diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/pagemodel/TokenVO.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/pagemodel/TokenVO.java new file mode 100644 index 0000000..5d7d644 --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/pagemodel/TokenVO.java @@ -0,0 +1,52 @@ +package com.vci.starter.web.pagemodel; + +/** + * @Description 璁稿彲鐨勬樉绀轰俊鎭� + * @Author dangsn + * @Date 2024/6/6 17:37 + */ +public class TokenVO { + + /** + * 搴忓垪鍖� + */ + private static final long serialVersionUID = -1067382417908970897L; + /** + * token鐨勫�� + */ + private String accessToken; + + /** + * 鏈夋晥鏈� + */ + private Long expireTime; + + /** + * 鏄惁鑾峰彇鎵嬫満鍙�,涓簍rue鐨勬椂鍊欒〃绀洪渶瑕佹墜鏈哄彿 + */ + private Boolean phoneFlag; + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public Long getExpireTime() { + return expireTime; + } + + public void setExpireTime(Long expireTime) { + this.expireTime = expireTime; + } + + public Boolean getPhoneFlag() { + return phoneFlag; + } + + public void setPhoneFlag(Boolean phoneFlag) { + this.phoneFlag = phoneFlag; + } +} diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/JwtUtils.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/JwtUtils.java new file mode 100644 index 0000000..6578c68 --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/JwtUtils.java @@ -0,0 +1,135 @@ +package com.vci.starter.web.util; + +import cn.hutool.core.convert.Convert; +import com.vci.starter.web.constant.TokenKeyConstant; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; + +import java.util.Map; + +/** + * @Description Jwt宸ュ叿绫� + * @Author dangsn + * @Date 2024/6/6 17:32 + */ +public class JwtUtils { + + /** + * 浠庢暟鎹0鏄庣敓鎴愪护鐗� + * + * @param claims 鏁版嵁澹版槑 + * @return 浠ょ墝 + */ + public static String createToken(Map<String, Object> claims) { + String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, TokenKeyConstant.SECRET).compact(); + return token; + } + + /** + * 浠庝护鐗屼腑鑾峰彇鏁版嵁澹版槑 + * + * @param token 浠ょ墝 + * @return 鏁版嵁澹版槑 + */ + public static Claims parseToken(String token) { + return Jwts.parser().setSigningKey(TokenKeyConstant.SECRET).parseClaimsJws(token).getBody(); + } + + /** + * 浣跨敤jwt鐨則oken鑾峰彇鍦╮edis閲屽瓨鍌ㄧ殑token + * @param token jwt鐨勮鍙� + * @return redis閲岀殑token鍊� + */ + public static final String getUserToken(String token){ + Claims claims = parseToken(token); + return getValue(claims, TokenKeyConstant.JWT_TOKEN_KEY); + } + + /** + * 浣跨敤jwt鐨勬暟鎹璞¤幏鍙杛edis閲屽瓨鍌ㄧ殑token + * @param claims 瀵硅薄 + * @return redis閲岀殑token鍊� + */ + public static final String getUserToken(Claims claims){ + return getValue(claims, TokenKeyConstant.JWT_TOKEN_KEY); + } + + /** + * 鏍规嵁浠ょ墝鑾峰彇鐢ㄦ埛鏍囪瘑 + * + * @param token 浠ょ墝 + * @return 鐢ㄦ埛ID + */ + public static String getUserKey(String token) { + Claims claims = parseToken(token); + return getValue(claims, TokenKeyConstant.JWT_USER_KEY); + } + + /** + * 鏍规嵁浠ょ墝鑾峰彇鐢ㄦ埛鏍囪瘑 + * + * @param claims 韬唤淇℃伅 + * @return 鐢ㄦ埛ID + */ + public static String getUserKey(Claims claims) + { + return getValue(claims, TokenKeyConstant.JWT_USER_KEY); + } + + /** + * 鏍规嵁浠ょ墝鑾峰彇鐢ㄦ埛ID + * + * @param token 浠ょ墝 + * @return 鐢ㄦ埛ID + */ + public static String getUserId(String token) { + Claims claims = parseToken(token); + return getValue(claims, TokenKeyConstant.JWT_USER_KEY); + } + + /** + * 鏍规嵁韬唤淇℃伅鑾峰彇鐢ㄦ埛ID + * + * @param claims 韬唤淇℃伅 + * @return 鐢ㄦ埛ID + */ + public static String getUserId(Claims claims) + { + return getValue(claims, TokenKeyConstant.JWT_USER_KEY); + } + + /** + * 鏍规嵁浠ょ墝鑾峰彇鐢ㄦ埛鍚� + * + * @param token 浠ょ墝 + * @return 鐢ㄦ埛鍚� + */ + public static String getUserCode(String token) { + Claims claims = parseToken(token); + return getValue(claims, TokenKeyConstant.JWT_USER_CODE_KEY); + } + + /** + * 鏍规嵁韬唤淇℃伅鑾峰彇鐢ㄦ埛鍚� + * + * @param claims 韬唤淇℃伅 + * @return 鐢ㄦ埛鍚� + */ + public static String getUserCode(Claims claims) + { + return getValue(claims, TokenKeyConstant.JWT_USER_CODE_KEY); + } + + /** + * 鏍规嵁韬唤淇℃伅鑾峰彇閿�� + * + * @param claims 韬唤淇℃伅 + * @param key 閿� + * @return 鍊� + */ + public static String getValue(Claims claims, String key) + { + return Convert.toStr(claims.get(key), ""); + } +} diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmFunctionQueryServicePlatformImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmFunctionQueryServicePlatformImpl.java index 58977d3..751c7ec 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmFunctionQueryServicePlatformImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmFunctionQueryServicePlatformImpl.java @@ -23,17 +23,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.*; import java.util.stream.Collectors; - -import static com.vci.web.constant.CacheKeyConstant.ALL_FUNCTION; -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; /** * 鑰佸钩鍙扮殑鏉冮檺鏈嶅姟 @@ -94,7 +89,6 @@ * @return 鍔熻兘鐨勬樉绀哄璞� */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key = ALL_FUNCTION,unless = "#result == null") public Map<String, SmFunctionVO> selectAllFunctionMap() { return Optional.ofNullable(self.selectAllFunction()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getOid(),t->t)); } @@ -678,7 +672,6 @@ * 娓呴櫎缂撳瓨 */ @Override - @CacheEvict(value = VCI_OBJECT_SERVICE,key = ALL_FUNCTION) public void clearCache() { } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmSessionForLoginImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmSessionForLoginImpl.java index e929a85..20a4a98 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmSessionForLoginImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmSessionForLoginImpl.java @@ -14,8 +14,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CachePut; -import org.springframework.cache.annotation.Cacheable; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -25,8 +23,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - -import static com.vci.web.constant.CacheNameConstant.VCI_SESSION; /** * 浼氳瘽瀛樺偍鐨勬湇鍔� @@ -155,7 +151,6 @@ * @return 鐢ㄦ埛浼氳瘽瀵硅薄 */ @Override - @Cacheable(value = VCI_SESSION,key = "#p0",unless = "#target == null") public SessionInfo getSessionInfoByToken(String userToken) { WebUtil.alertNotNull(userToken,"璁稿彲鐨勪俊鎭�"); List<Map> dataList = boService.queryBySqlForMap("select JSONSTRING as JSONSTRING from VCI_SESSIONINFO where TOKEN ='" + userToken.trim() + "'", new HashMap<>()); diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java index 2df4e7e..b0ae3c0 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java @@ -22,7 +22,6 @@ import com.vci.web.util.WebUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -31,7 +30,6 @@ import java.util.stream.Collectors; import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; -import static com.vci.web.constant.CacheNameConstant.VCI_USER; import static com.vci.web.util.WebUtil.arryAndSqlToClientBusinessObject; /** @@ -95,7 +93,6 @@ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呮暟鎹簱瀛樺湪闂鐨勬椂鍊欎細鎶涘嚭寮傚父 */ @Override - @Cacheable(value = VCI_USER,key = "#p0",unless = "#result == null") public SmUserVO getUserByUserId(String userId) throws VciBaseException { WebUtil.alertNotNull(userId,"鐢ㄦ埛鍚�"); return getUserByField("plusername",userId); diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/constant/FrameWorkBusLangCodeConstant.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/constant/FrameWorkBusLangCodeConstant.java index 313de53..8021cd2 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/constant/FrameWorkBusLangCodeConstant.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/constant/FrameWorkBusLangCodeConstant.java @@ -105,6 +105,11 @@ */ public static final String PASSWORD_REMAIN_DAY = "passwordRemainDay"; + /** + * 瀵嗙爜宸茶繃鏈� + */ + public static final String PASSWORD_EXPIRE = "passwordExpire"; + //缁勭粐 @@ -516,4 +521,23 @@ */ public static final String DISPATCH_TASK_NOT_EXIST_BY_PLAN = "dispatchTaskNotExistByPlan"; + /** + * 绯荤粺寮傚父 + */ + public static final String SYSTEM_ERROR = "systemError"; + + /** + * 鐧诲綍鎴愬姛 + */ + public static final String LOGIN_SUCCESS = "loginSuccess"; + + /** + * 鍒濆瀵嗙爜闇�瑕佷慨鏀� + */ + public static final String PASSWORD_INIT = "passwordInit"; + + /** + * 瀵嗙爜绛栫暐宸茬粡淇敼锛岄渶淇敼璐﹀彿瀵嗙爜 + */ + public static final String PASSWORD_POLICY_UPDATED = "passwordPolicyUpdated"; } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/pagemodel/SmUserVO.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/pagemodel/SmUserVO.java index dc5249f..e241856 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/pagemodel/SmUserVO.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/pagemodel/SmUserVO.java @@ -146,6 +146,11 @@ */ private String photo; + /** + * token鍊� + */ + private String token; + @Override public String getId() { return id; @@ -357,11 +362,18 @@ this.photo = photo; } + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + @Override public String toString() { return "SmUserVO{" + - "oid='" + getOid() + '\'' + - ",id='" + id + '\'' + + "id='" + id + '\'' + ", name='" + name + '\'' + ", userType='" + userType + '\'' + ", userTypeText='" + userTypeText + '\'' + @@ -385,9 +397,9 @@ ", sexText='" + sexText + '\'' + ", langCode='" + langCode + '\'' + ", langCodeText='" + langCodeText + '\'' + - ", lockFlag='" + lockFlag + '\'' + + ", lockFlag=" + lockFlag + ", photo='" + photo + '\'' + - ",description='" + getDescription() + '\'' + + ", token='" + token + '\'' + '}'; } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/CacheKeyConstant.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/CacheKeyConstant.java deleted file mode 100644 index 93f855f..0000000 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/CacheKeyConstant.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.vci.web.constant; - -/** - * 缂撳瓨鐨刱ey鐨勫父閲� - * @author weidy - * @date 2021/2/20 - */ -public class CacheKeyConstant { - - /** - * 鎵�鏈夌殑灞炴�� - */ - public static final String ALL_STATUS = "'allStatus'"; - - /** - * 鎵�鏈夌殑涓氬姟绫诲瀷 - */ - public static final String ALL_BTM = "'allBtm'"; - - /** - * 鎵�鏈夌殑鏋氫妇 - */ - public static final String ALL_ENUM = "'allEnum'"; - - /** - * 鎵�鏈夌敓鍛藉懆鏈� - */ - public static final String ALL_LIFE_CYCLE = "'allLife'"; - - /** - * 鎵�鏈夌殑閾炬帴鍏崇郴 - */ - public static final String ALL_Link = "'allLink'"; - - /** - * 鎵�鏈夌殑鐗堟湰瑙勫垯 - */ - public static final String ALL_REVISION = "'allRevisionRule'"; - - /** - * 鎵�鏈夌殑鍔熻兘 - */ - public static final String ALL_FUNCTION = "'allFunction'"; - - /** - * 鎵�鏈夌殑灞炴�� - */ - public static final String ALL_ATTRIBUTE = "'allAttribute'"; - /** - * 鎵�鏈夌殑UI鍖哄煙 - */ - public static final String ALL_LAYOUT = "'allLayout'" ; - - /** - * 鎵�鏈夌殑琛ㄥ崟鍜岃〃鏍� - */ - public static final String ALL_FORM_AND_TABLE = "'allFormAndTable'"; - /** - * 鎵�鏈夌殑琛ㄥ崟 - */ - public static final String ALL_FORM = "'allForm'"; - - /** - * 鎵�鏈夌殑琛ㄦ牸 - */ - public static final String ALL_TABLE = "'allTable'"; - /** - * 鎵�鏈夌殑action - */ - public static final String ALL_ACTION = "'allAction'"; - /** - * 鎵�鏈夌殑UI - */ - public static final String ALL_UI = "'allUI'"; - - /** - * 鎵�鏈夌殑缁勪欢 - */ - public static final String ALL_COMP = "'allComp'"; -} diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/CacheNameConstant.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/CacheNameConstant.java index 673f586..3b3072c 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/CacheNameConstant.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/CacheNameConstant.java @@ -8,6 +8,82 @@ public class CacheNameConstant { /** + * 鎵�鏈夌殑灞炴�� + */ + public static final String ALL_STATUS = "allStatus"; + + /** + * 鎵�鏈夌殑涓氬姟绫诲瀷 + */ + public static final String ALL_BTM = "allBtm"; + + /** + * 鎵�鏈夌殑鏋氫妇 + */ + public static final String ALL_ENUM = "allEnum"; + + /** + * 鎵�鏈夌敓鍛藉懆鏈� + */ + public static final String ALL_LIFE_CYCLE = "allLife"; + + /** + * 鎵�鏈夌殑閾炬帴鍏崇郴 + */ + public static final String ALL_Link = "allLink"; + + /** + * 鎵�鏈夌殑鐗堟湰瑙勫垯 + */ + public static final String ALL_REVISION = "allRevisionRule"; + + /** + * 鎵�鏈夌殑鍔熻兘 + */ + public static final String ALL_FUNCTION = "allFunction"; + + /** + * 鎵�鏈夌殑灞炴�� + */ + public static final String ALL_ATTRIBUTE = "allAttribute"; + + /** + * 鎵�鏈夌殑UI鍖哄煙 + */ + public static final String ALL_LAYOUT = "allLayout" ; + + /** + * 鎵�鏈夌殑琛ㄥ崟鍜岃〃鏍� + */ + public static final String ALL_FORM_AND_TABLE = "allFormAndTable"; + + /** + * 鎵�鏈夌殑琛ㄥ崟 + */ + public static final String ALL_FORM = "allForm"; + + /** + * 鎵�鏈夌殑琛ㄦ牸 + */ + public static final String ALL_TABLE = "allTable"; + + /** + * 鎵�鏈夌殑action + */ + public static final String ALL_ACTION = "allAction"; + + /** + * 鎵�鏈夌殑UI + */ + public static final String ALL_UI = "allUI"; + + + /** + * 鎵�鏈夌殑缁勪欢 + */ + public static final String ALL_COMP = "allComp"; + + /** * 浼氳瘽鐨勪俊鎭� */ public static final String VCI_SESSION = "vci_session_cache"; @@ -20,5 +96,29 @@ /** * 鐢ㄦ埛 */ - public static final String VCI_USER = "VCI_USER"; + public static final String VCI_USER = "vci_user:"; + + /** + * 鐢ㄦ埛鍞竴鏍囪瘑 + */ + public static final String VCI_USER_OID = "vci_user_oid:"; + + /** + * 鐢ㄦ埛 + */ + public static final String VCI_USER_LOGIN = "vci_user_login:"; + + /** + * 杩斿洖鎷兼帴鍚庣殑key + * + * @param cacheKey 缂撳瓨key + * @param cacheKeyValue 缂撳瓨key鍊� + * @return tenantKey + */ + public static String cacheKey(String cacheKey, String cacheKeyValue) { + if(cacheKeyValue == null){ + cacheKeyValue = ""; + } + return cacheKey.concat(cacheKeyValue); + } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/initTask/VciWebInitTaskComponent.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/initTask/VciWebInitTaskComponent.java index 20750b3..f33882e 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/initTask/VciWebInitTaskComponent.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/initTask/VciWebInitTaskComponent.java @@ -143,7 +143,7 @@ // secretService.getMinDataSecret(); // secretService.getMinIpSecret(); // secretService.getMinUserSecret(); - initService.clearAllCache(); +// initService.clearAllCache(); // initService.initServerCache(); mdService.scanAllMdFile(); initDefaultAttribute(); diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisConfig.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisConfig.java index 40b95ae..7e64afc 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisConfig.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisConfig.java @@ -20,8 +20,8 @@ * @author wang1 */ @Configuration -@ConditionalOnProperty(value = "spring.redis.enabled",havingValue = "true",matchIfMissing = false) @EnableCaching +@ConditionalOnProperty(value = "spring.redis.enabled",havingValue = "true",matchIfMissing = false) public class RedisConfig extends CachingConfigurerSupport { @Bean diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisService.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisService.java index e7a5a8e..ed55283 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisService.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisService.java @@ -1,25 +1,28 @@ package com.vci.web.redis; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.BoundSetOperations; -import org.springframework.data.redis.core.HashOperations; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ValueOperations; +import org.springframework.data.geo.Distance; +import org.springframework.data.geo.Metrics; +import org.springframework.data.geo.Point; +import org.springframework.data.redis.core.*; +import org.springframework.data.redis.core.script.DefaultRedisScript; +import org.springframework.data.redis.core.script.RedisScript; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.*; +import java.util.concurrent.TimeUnit; /** * spring redis 宸ュ叿绫� - * - * @author wang1 + * @author dangsn **/ @SuppressWarnings(value = { "unchecked", "rawtypes" }) @Component +@Slf4j public class RedisService { @Autowired(required = false) @@ -31,8 +34,7 @@ * @param key 缂撳瓨鐨勯敭鍊� * @param value 缂撳瓨鐨勫�� */ - public <T> void setCacheObject(final String key, final T value) - { + public <T> void setCacheObject(final String key, final T value) { redisTemplate.opsForValue().set(key, value); } @@ -44,8 +46,7 @@ * @param timeout 鏃堕棿 * @param timeUnit 鏃堕棿棰楃矑搴� */ - public <T> void setCacheObject(final String key, final T value, final Long timeout, final TimeUnit timeUnit) - { + public <T> void setCacheObject(final String key, final T value, final Long timeout, final TimeUnit timeUnit) { redisTemplate.opsForValue().set(key, value, timeout, timeUnit); } @@ -69,8 +70,7 @@ * @param unit 鏃堕棿鍗曚綅 * @return true=璁剧疆鎴愬姛锛沠alse=璁剧疆澶辫触 */ - public boolean expire(final String key, final long timeout, final TimeUnit unit) - { + public boolean expire(final String key, final long timeout, final TimeUnit unit) { return redisTemplate.expire(key, timeout, unit); } @@ -91,8 +91,7 @@ * @param key 閿� * @return true 瀛樺湪 false涓嶅瓨鍦� */ - public Boolean hasKey(String key) - { + public Boolean hasKey(String key) { return redisTemplate.hasKey(key); } @@ -102,8 +101,7 @@ * @param key 缂撳瓨閿�� * @return 缂撳瓨閿�煎搴旂殑鏁版嵁 */ - public <T> T getCacheObject(final String key) - { + public <T> T getCacheObject(final String key) { ValueOperations<String, T> operation = redisTemplate.opsForValue(); return operation.get(key); } @@ -111,7 +109,8 @@ /** * 鍒犻櫎鍗曚釜瀵硅薄 * - * @param key + * @param key 鍙互 + * @return 鍒犻櫎鏄惁鎴愬姛 */ public boolean deleteObject(final String key) { @@ -122,7 +121,7 @@ * 鍒犻櫎闆嗗悎瀵硅薄 * * @param collection 澶氫釜瀵硅薄 - * @return + * @return 鍒犻櫎鐨勪釜鏁� */ public long deleteObject(final Collection collection) { @@ -130,50 +129,14 @@ } /** - * list鐨勯暱搴� - * - * @param key 缂撳瓨鐨勯敭鍊� - * @return 缂撳瓨鐨勫璞� - */ - public <T> Long listSize(final String key) - { - return redisTemplate.opsForList().size(key); - } - - /** - * 浠庡乏杈瑰彇鍑轰竴涓猯ist鍏冪礌 - * - * @param key 缂撳瓨鐨勯敭鍊� - * @return 缂撳瓨鐨勫璞� - */ - public <T> Object leftPop(final String key) - { - return redisTemplate.opsForList().leftPop(key); - } - - /** - * 浠庡彸杈圭紦瀛楲ist鏁版嵁 + * 缂撳瓨List鏁版嵁 * * @param key 缂撳瓨鐨勯敭鍊� * @param dataList 寰呯紦瀛樼殑List鏁版嵁 * @return 缂撳瓨鐨勫璞� */ - public <T> long setCacheList(final String key, final List<T> dataList) - { + public <T> long setCacheList(final String key, final List<T> dataList) { Long count = redisTemplate.opsForList().rightPushAll(key, dataList); - return count == null ? 0 : count; - } - - /** - * 鍒犻櫎list涓厓绱爒alue - * @param key - * @param value - * @param <T> - * @return - */ - public <T> long deleteCacheListByKeyAndValue(final String key, final T value) - { - Long count = redisTemplate.opsForList().remove(key,0,value); return count == null ? 0 : count; } @@ -188,8 +151,6 @@ return redisTemplate.opsForList().range(key, 0, -1); } - - /** * 缂撳瓨Set * @@ -197,36 +158,21 @@ * @param dataSet 缂撳瓨鐨勬暟鎹� * @return 缂撳瓨鏁版嵁鐨勫璞� */ - public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) - { + public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) { BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key); Iterator<T> it = dataSet.iterator(); while (it.hasNext()) { setOperation.add(it.next()); } - String i = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + - "<Datas>\n" + - "\t<Data code=\"A1100012\" deptLevel=\"寮�鍙戦儴闂�#娴嬭瘯閮ㄩ棬\">\n" + - "\t\t<prop sName=\"渚涘簲鍟嗗悕绉癨" tName =\"渚涘簲鍟嗗悕绉�1\" >\n" + - "\t\t\t鍖椾含瀹忓崥杩滆揪绉戞妧鏈夐檺鍏徃2\n" + - "\t\t</prop>\n" + - "\t\t<prop sName=\"鎴峰ご\" tName =\"鎴峰ご1\">\n" + - "\t\t\t1111100012\n" + - "\t\t</prop>\n" + - "\t\t<prop sName=\"鑱旂郴浜篭" tName=\"鑱旂郴浜�1\">\n" + - "\t\t\t璋㈠啗2\n" + - "\t\t</prop>\n" + - "\t</Data>\n" + - "</Datas>"; return setOperation; } /** * 鑾峰緱缂撳瓨鐨剆et * - * @param key - * @return + * @param key key + * @return 闆嗗悎鐨勫唴瀹� */ public <T> Set<T> getCacheSet(final String key) { @@ -236,11 +182,10 @@ /** * 缂撳瓨Map * - * @param key - * @param dataMap + * @param key key + * @param dataMap 鏁版嵁鏄犲皠 */ - public <T> void setCacheMap(final String key, final Map<String, T> dataMap) - { + public <T> void setCacheMap(final String key, final Map<String, T> dataMap) { if (dataMap != null) { redisTemplate.opsForHash().putAll(key, dataMap); } @@ -249,8 +194,8 @@ /** * 鑾峰緱缂撳瓨鐨凪ap * - * @param key - * @return + * @param key key + * @return 鏄犲皠 */ public <T> Map<String, T> getCacheMap(final String key) { @@ -264,8 +209,7 @@ * @param hKey Hash閿� * @param value 鍊� */ - public <T> void setCacheMapValue(final String key, final String hKey, final T value) - { + public <T> void setCacheMapValue(final String key, final String hKey, final T value) { redisTemplate.opsForHash().put(key, hKey, value); } @@ -276,8 +220,7 @@ * @param hKey Hash閿� * @return Hash涓殑瀵硅薄 */ - public <T> T getCacheMapValue(final String key, final String hKey) - { + public <T> T getCacheMapValue(final String key, final String hKey) { HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash(); return opsForHash.get(key, hKey); } @@ -289,19 +232,243 @@ * @param hKeys Hash閿泦鍚� * @return Hash瀵硅薄闆嗗悎 */ - public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) - { + public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) { return redisTemplate.opsForHash().multiGet(key, hKeys); } /** * 鑾峰緱缂撳瓨鐨勫熀鏈璞″垪琛� - * + * * @param pattern 瀛楃涓插墠缂� * @return 瀵硅薄鍒楄〃 */ - public Collection<String> keys(final String pattern) - { + public Collection<String> keys(final String pattern) { return redisTemplate.keys(pattern); } + + /** + * 璁剧疆鍒嗗竷寮忛攣 + * @param key 閿佺殑key + * @param value 鍊� + * @return true琛ㄧず瀛樺湪锛宖alse琛ㄧず涓嶅瓨鍦� + */ + public synchronized Boolean setNX(final String key, final String value) throws Exception{ + Object obj = null; + try { + obj = redisTemplate.execute((RedisCallback<Object>) connection -> { + StringRedisSerializer serializer = new StringRedisSerializer(); + Boolean success = connection.setNX(serializer.serialize(key), serializer.serialize(value)); + connection.close(); + return success; + }); + } catch (Exception e) { + log.error("setNX redis error, key : {} - {}", key,e); + throw e; + } + return obj != null ? (Boolean) obj : false; + } + + /** + * 璁剧疆鍒嗗竷寮忛攣锛岃秴鏃堕棿鍗曚綅绉� + * @param key 閿佺殑key + * @param value 鍊� + * @param timeOut 瓒呮椂鏃堕棿 + * @return true琛ㄧず瀛樺湪锛宖alse琛ㄧず涓嶅瓨鍦� + */ + public synchronized Boolean setNX(final String key, final String value,long timeOut) throws Exception { + boolean b = this.setNX(key,value); + redisTemplate.expire(key,timeOut,TimeUnit.SECONDS); + return b; + } + + /** + * 鍒犻櫎閿� + * @param key 閿佺殑key + */ + public void unlock(final String key) { + redisTemplate.delete(key); + } + + /** + * 鑷噺 澶т簬绛変簬0 + * @param key 閿佺殑key + * @return Boolean + */ + public Boolean decrement(final String key) { + return redisTemplate.opsForValue().decrement(key) >= 0; + } + public Boolean decrement(final String key, long count) { + return redisTemplate.opsForValue().decrement(key,count) >= 0; + } + + /** + * 鑷噺 + * @param key 閿佺殑key + * @return Boolean + */ + public Long decrementLong(final String key) { + return redisTemplate.opsForValue().decrement(key); + } + /** + * 鑷 + * @param key 閿佺殑key + * @return Boolean + */ + public Long increment(final String key) { + return redisTemplate.opsForValue().increment(key); + } + public Long increment(final String key, long count) { + return redisTemplate.opsForValue().increment(key,count); + } + + /** + * 鍓嶇紑鍖归厤鍒犻櫎 + * @param keyPrefix key鍓嶇紑 + */ + public Boolean deleteByPrefix(final String keyPrefix) { + + List<String> list = new LinkedList<>(); + ScanOptions build = ScanOptions.scanOptions().match(keyPrefix+":*").count(5000).build(); + RedisSerializer<String> redisSerializer = redisTemplate.getKeySerializer(); + Cursor cursor = (Cursor) redisTemplate.executeWithStickyConnection(redis -> new ConvertingCursor<>(redis.scan(build), redisSerializer::deserialize)); + + if (cursor != null){ + try { + while ( cursor.hasNext()) { + list.add(cursor.next().toString()); + } + try { + cursor.close(); + } catch (IOException e) { + e.printStackTrace(); + log.error("redis涓殑Cursor鍏抽棴澶辫触锛�"); + } + } finally { + try { + cursor.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + Long delete = redisTemplate.delete(list); + log.info("鍒犻櫎鑿滃崟key: "+delete+"涓�俓n 璇︽儏:"+list.toString()); + return delete > 0L; + } + return false; + } + + /** + * 鍓嶇紑鍖归厤 + * @param keyPrefix key鍓嶇紑 + * + */ + public <T> List<T> findKeysByPrefix(final String keyPrefix) { + + List<T> list = new ArrayList<>(); + ScanOptions build = ScanOptions.scanOptions().match(keyPrefix+":*").count(5000).build(); + RedisSerializer<String> redisSerializer = redisTemplate.getKeySerializer(); + Cursor cursor = (Cursor) redisTemplate.executeWithStickyConnection(redis -> new ConvertingCursor<>(redis.scan(build), redisSerializer::deserialize)); + if (cursor != null){ + try { + while (cursor.hasNext()) { + list.add(getCacheObject(cursor.next().toString())); + } + try { + cursor.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } finally { + try { + cursor.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return list; + } + return new ArrayList<>(); + } + + + /** + * 鍩轰簬Lua鑴氭湰瀹炵幇鍘熷瓙鏌ヨ骞跺垹闄� + * @param key + * @return + */ + public Boolean deleteLuaByKey(String key) { + String str2 = "if redis.call('EXISTS', KEYS[1]) == 1 then redis.call('DEL', KEYS[1]) return 1 else return 0 end"; + RedisScript<Boolean> redisScript = new DefaultRedisScript<>(str2,Boolean.class); + Boolean execute = (Boolean) redisTemplate.execute(redisScript, Collections.singletonList(key)); + return execute; + } + /** + * GEO 娣诲姞鏁版嵁(缁忕含搴�) + * @param key + * @return + */ + public <T extends Point> void addGEO(String key, Map<String,T> map) { + redisTemplate.opsForGeo().add(key,map); + } + + /** + * GEO 娣诲姞鏁版嵁(缁忕含搴�) + * @param key + * @return + */ + public <T extends Point> void addGEO(String key, Point point, String member) { + redisTemplate.opsForGeo().add(key,point,member); + } + + + public <T extends Point> void removeGEO(String key,String... member) { + redisTemplate.opsForGeo().remove(key,member); + } + + + /** + * GEO 鏌ヨ璺濈 + * @param point 闇�瑕佹煡璇㈢殑鍦板潃 + * @param key 鍩庡競 + * @param members 鑺傜偣 + * @return map(鍟嗛摵,璺濈) + */ + public Map<String,String> distanceGEO(Point point,String key, List<String> members) { + GeoOperations geo = redisTemplate.opsForGeo(); + long l = System.currentTimeMillis(); + String member = "geo"+l; + addGEO(key,point,member); + Map<String,String> map = new HashMap<>(); + members.forEach(e->{ + Distance distance = geo.distance(key, member, e, Metrics.KILOMETERS); + map.put(e,String.valueOf(distance.getValue())); + }); + removeGEO(key,key,member); + return map; + + } + + /** + * 鑾峰彇List闆嗗悎鎿嶄綔 + * @return 鎿嶄綔 + */ + public ListOperations opsForList(){ + return this.redisTemplate.opsForList(); + } + + /** + * 鑾峰彇Set闆嗗悎鎿嶄綔 + * @return 鎿嶄綔 + */ + public SetOperations opsForSet(){ + return this.redisTemplate.opsForSet(); + } + + /** + * 鑾峰彇hash鎿嶄綔 + * @return 鎿嶄綔 + */ + public HashOperations opsForHash(){ + return this.redisTemplate.opsForHash(); + } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/LoginServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/LoginServiceI.java index 95b9cac..5b63e6c 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/LoginServiceI.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/LoginServiceI.java @@ -2,6 +2,8 @@ import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.RequestClientInfo; +import com.vci.starter.web.pagemodel.SessionInfo; +import com.vci.starter.web.pagemodel.TokenVO; import com.vci.web.bo.LoginResultBO; import com.vci.web.dto.LoginUserDTO; @@ -36,4 +38,32 @@ * @throws VciBaseException 鍒犻櫎浼氳瘽淇℃伅鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父 */ void logout(String userToken) throws VciBaseException; + + /** + * 鍒锋柊token + * @param sessionInfo session鐨勪俊鎭� + */ + void refreshToken(SessionInfo sessionInfo); + + /** + * 鍒锋柊token + * @param key token鍦╮edis涓殑key + * @param sessionInfo session鐨勪俊鎭� + */ + void refreshToken(String key, SessionInfo sessionInfo); + + /** + * 鍒涘缓璁稿彲鐨勪俊鎭� + * @param sessionInfo session鐨勪俊鎭� + * @return 璁稿彲淇℃伅 + */ + TokenVO createToken(SessionInfo sessionInfo) ; + + /** + * 鍒涘缓璁稿彲鐨勪俊鎭� + * @param key token鍦╮edis涓殑key銆� + * @param sessionInfo session鐨勪俊鎭� + * @return 璁稿彲淇℃伅 + */ + TokenVO createToken(String key, SessionInfo sessionInfo) ; } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java index eef1f76..17aa5b1 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java @@ -1,5 +1,8 @@ package com.vci.web.service.impl; +import com.vci.client.logon.base.LogonHandler; +import com.vci.corba.framework.data.LoginResult; +import com.vci.corba.framework.data.LoginState; import com.vci.frameworkcore.ajaxTask.SmUserUnLockTask; import com.vci.frameworkcore.ajaxTask.SmUserUnLockTaskManager; import com.vci.frameworkcore.compatibility.ISmFunctionQueryService; @@ -7,27 +10,41 @@ import com.vci.frameworkcore.compatibility.SmUserQueryServiceI; import com.vci.frameworkcore.pagemodel.SmUserVO; import com.vci.frameworkcore.properties.VciSecurityManageProperties; -import com.vci.starter.web.annotation.bus.*; +import com.vci.starter.web.annotation.bus.VciLoginAfter; +import com.vci.starter.web.annotation.bus.VciLogoutBefore; +import com.vci.starter.web.annotation.bus.VciLogoutPlugin; +import com.vci.starter.web.constant.TokenKeyConstant; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.interceptor.VciSessionForLoginI; import com.vci.starter.web.pagemodel.RequestClientInfo; import com.vci.starter.web.pagemodel.SessionInfo; +import com.vci.starter.web.pagemodel.TokenVO; import com.vci.starter.web.util.ApplicationContextProvider; +import com.vci.starter.web.util.JwtUtils; import com.vci.starter.web.util.Md5; import com.vci.starter.web.util.VciBaseUtil; import com.vci.web.bo.LoginResultBO; +import com.vci.web.constant.CacheNameConstant; import com.vci.web.dto.LoginUserDTO; +import com.vci.web.properties.WebProperties; +import com.vci.web.redis.RedisService; import com.vci.web.service.LoginServiceI; -import com.vci.web.util.BusAnnotationUtil; +import com.vci.web.util.PlatformClientUtil; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import javax.annotation.Resource; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; + +import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.*; /** * 鐧诲綍鐨勬湇鍔� @@ -45,38 +62,56 @@ /** * 浼氳瘽澶勭悊 */ - @Autowired + @Resource private VciSessionForLoginI sessionForLogin; /** * 瑙i攣浠诲姟 */ - @Autowired + @Resource private SmUserUnLockTaskManager unLockTaskManager; /** * 鏉冮檺绠$悊鐨勭浉鍏抽厤缃� */ - @Autowired + @Resource private VciSecurityManageProperties securityManageProperties; /** * 鐢ㄦ埛鏌ヨ鏈嶅姟锛屽彲浠ュ吋瀹硅�佸钩鍙� */ - @Autowired() + @Resource private SmUserQueryServiceI userQueryService; /** * 瑙掕壊鐨勬煡璇㈡湇鍔★紝鍙互鍏煎鑰佸钩鍙� */ - @Autowired + @Resource private SmRoleQueryServiceI roleQueryService; /** * 鏉冮檺鐨勬煡璇㈡湇鍔★紝鍙互鍏煎鑰佸钩鍙� */ - @Autowired + @Resource private ISmFunctionQueryService functionQueryService; + + /** + * redis鏈嶅姟 + */ + @Resource + private RedisService redisService; + + /** + * 瀹㈡埛绔厤缃枃浠� + */ + @Resource + private WebProperties webProperties; + + /** + * 骞冲彴璋冪敤瀹㈡埛绔� + */ + @Resource + private PlatformClientUtil platformClientUtil; /** * 鎵ц鐧诲綍 @@ -101,195 +136,200 @@ LoginResultBO loginResult = new LoginResultBO(); loginResult.setSuccess(false); //1.鍒ゆ柇鐢ㄦ埛鐨勫熀鏈俊鎭� -// VciBaseUtil.alertNotNull(userDTO, "鐧诲綍淇℃伅", userDTO.getUserId(), "鐢ㄦ埛璐﹀彿"); -// if (checkPassword) { -// VciBaseUtil.alertNotNull(userDTO.getPassword(), "鐧诲綍瀵嗙爜"); -// } - //鐧诲綍涔嬪墠璋冪敤鎻掍欢 - BusAnnotationUtil.callForAnnotation(VciLoginPlugin.class,VciLoginBefore.class,userDTO,clientInfo); + VciBaseUtil.alertNotNull(userDTO, "鐧诲綍淇℃伅", userDTO.getUserId(), "鐢ㄦ埛璐﹀彿"); + if (checkPassword) { + VciBaseUtil.alertNotNull(userDTO.getPassword(), "鐧诲綍瀵嗙爜"); + } -// String loginInfo = checkIsLogined(userDTO.getUserId()); -// if (!userDTO.isForceLogin() && securityManageProperties.isUserOneLogin()) { -// //闇�瑕佺湅鐪嬫槸鍚﹀凡缁忕櫥褰曚簡 -// if (StringUtils.isNotBlank(loginInfo)) { -// loginResult.setFailCode(USER_IS_LOGINED); -// loginResult.setFailMsg(loginInfo); -// return loginResult; -// } -// } - //2.鑾峰彇鐢ㄦ埛鐨勫璞�.杩欓噷闇�瑕佸吋瀹硅�佸钩鍙板拰鑰乸dm锛岃�佺紪鐮佸拰鑰佸钩鍙版槸涓�涓〃 -// SmUserVO user = userQueryService.getUserByUserId(userDTO.getUserId().trim()); -// if (user == null || StringUtils.isEmpty(user.getOid())) { -// loginResult.setFailCode(USER_NOT_FOUND); -// loginResult.setFailMsgArray(new String[]{userDTO.getUserId()}); -// return loginResult; -// } + //闇�瑕佺湅鐪嬫槸鍚﹀凡缁忕櫥褰曚簡 + String loginKey = CacheNameConstant.cacheKey(CacheNameConstant.VCI_USER_LOGIN, userDTO.getUserId()); + if(redisService.hasKey(loginKey) && !userDTO.isForceLogin() && securityManageProperties.isUserOneLogin()){ + loginResult.setFailCode(USER_IS_LOGINED); + loginResult.setFailMsg("褰撳墠鐢ㄦ埛宸茬粡鍦ㄥ叾浠栧湴鏂圭櫥褰曪紒"); + return loginResult; + } + //璇存槑宸茬粡鐧诲綍浜嗭紝閭e簲璇ュ彇娑堝師鏉ョ殑鐧诲綍 + if (redisService.hasKey(loginKey) && userDTO.isForceLogin() && securityManageProperties.isUserOneLogin()) { + redisService.deleteObject(CacheNameConstant.VCI_USER_LOGIN); + } + + //2.鑾峰彇鐢ㄦ埛鐨勫璞�. + SmUserVO user = getUserByUserId(userDTO.getUserId().trim()); + if (user == null || StringUtils.isBlank(user.getOid())) { + loginResult.setFailCode(USER_NOT_FOUND); + loginResult.setFailMsgArray(new String[]{userDTO.getUserId()}); + return loginResult; + } + + //3銆佸垽鏂瘑鐮佹槸鍚︽纭� + if (checkPassword) { + boolean passwordIsEqual = userQueryService.checkPasswordEqual(userDTO.getPassword(), user.getOid()); + if (!passwordIsEqual) { + if (logger.isDebugEnabled()) { + logger.debug("{}瀵嗙爜涓嶆纭�", user.getId()); + } + } + } + + //4銆佽皟鐢ㄥ钩鍙扮櫥褰曟帴鍙o紝杩涜鐧诲綍 + LogonHandler handler = new LogonHandler(); + try { + LoginResult chkRes = handler.checkLogin(userDTO.getUserId(), userDTO.getPassword()); + loginResult.setFailCode(getErrorCode(chkRes)); + loginResult.setFailMsgArray(new String[]{userDTO.getUserId(), String.valueOf(chkRes.auxInfo)}); + if(chkRes.state == LoginState.Error || chkRes.state == LoginState.Locked || chkRes.state == LoginState.Freeze){ + return loginResult; + } + } catch (Exception e) { + loginResult.setFailCode(SYSTEM_ERROR); + loginResult.setFailMsgArray(new String[]{userDTO.getUserId()}); + return loginResult; + } + //濡傛灉鐢ㄦ埛宸茬粡琚仠鐢ㄥ拰閿佸畾锛屼笉鑳界櫥褰� //濡傛灉鐢ㄦ埛鐨勫け鏁堟棩鏈熷凡缁忚秴杩囦簡褰撳墠鏃堕棿锛屼笉鑳界櫥褰� //鍙湁鏂板钩鍙扮殑鐢ㄦ埛鎵嶅垽鏂け鏁� -// if (FrameworkDataLCStatus.DISABLED.getValue().equals(user.getLcStatus())) { -// loginResult.setFailCode(USER_IS_DISABLED); -// loginResult.setFailMsgArray(new String[]{userDTO.getUserId()}); -// return loginResult; -// } -// if (userQueryService.checkUserLock(user, user.getPwdWrongCount())) { -// loginResult.setFailCode(USER_IS_LOCK); -// loginResult.setFailMsgArray(new String[]{userDTO.getUserId()}); -// return loginResult; -// } -// if (user.getDisabledate() != null) { -// //2021鐗堟湰鎵嶆湁杩欎釜灞炴�х殑鍊硷紝褰撳墠杩欎釜娌℃湁杩欎釜鍊� -// Date disableDate = VciDateUtil.addOrSubDate(user.getDisabledate(), Calendar.DATE, 1); -// if (disableDate != null && disableDate.getTime() < System.currentTimeMillis()) { -// loginResult.setFailCode(USER_MORE_THAN_DISABLE_DATE); -// loginResult.setFailMsgArray(new String[]{userDTO.getUserId()}); -// return loginResult; -// } -// } -// if (user.getPwdWrongCount() == null) { -// user.setPwdWrongCount(0); -// } -// SmPasswordStrategyVO passwordStrategyVO = userQueryService.getPasswordStrategyVOByUserOid(user.getOid()); -// if (checkPassword) { -// boolean passwordIsEqual = userQueryService.checkPasswordEqual(userDTO.getPassword(), user.getOid()); -// //3.鍒ゆ柇鐢ㄦ埛鐨勫瘑鐮佹槸鍚︽纭� -// if (!passwordIsEqual) { -// //鍓嶇闇�瑕佸厛md5涓�娆★紝鐒跺悗鍚庡彴鍐峂D5涓�娆★紝 -// if (logger.isDebugEnabled()) { -// logger.debug("{}瀵嗙爜涓嶆纭�", user.getId()); -// } -// if (passwordStrategyVO == null) { -// //鍙兘鏁版嵁闂娌℃湁璁剧疆瀵嗙爜绛栫暐 -// passwordStrategyVO = new SmPasswordStrategyVO(); -// passwordStrategyVO.setRetryTime(6); -// passwordStrategyVO.setLockTime(30); -// } -// if (passwordStrategyVO.getRetryTime() <= (user.getPwdWrongCount() + 1)) { -// user.setLockFlag(true); -// updateUserPwdWrongCount(user.getOid(), user.getPwdWrongCount() + 1); -// addUserToUnLock(userDTO.getUserId(), passwordStrategyVO.getLockTime()); -// updateUserPwdWrongCount(user.getOid(), user.getPwdWrongCount() + 1); -// loginResult.setFailCode(USER_PWD_LOCK); -// loginResult.setFailMsgArray(new String[]{userDTO.getUserId(), passwordStrategyVO.getLockTime() + ""}); -// return loginResult; -// } else { -// //杩樻病鏈夊埌閿佸畾鐨勬鏁� -// updateUserPwdWrongCount(user.getOid(), user.getPwdWrongCount() + 1); -// //5, 杩欐槸绗竴娆¢敊璇紝鍓╀笅鐨勬槸 5- 锛�0+1锛� -// loginResult.setFailCode(USER_PWD_NOT_EQUAL); -// loginResult.setFailMsgArray(new String[]{userDTO.getUserId(), (passwordStrategyVO.getRetryTime() - (user.getPwdWrongCount() + 1)) + ""}); -// return loginResult; -// } -// } -// } + /**if (FrameworkDataLCStatus.DISABLED.getValue().equals(user.getLcStatus())) { + loginResult.setFailCode(USER_IS_DISABLED); + loginResult.setFailMsgArray(new String[]{userDTO.getUserId()}); + return loginResult; + } + if (userQueryService.checkUserLock(user, user.getPwdWrongCount())) { + loginResult.setFailCode(USER_IS_LOCK); + loginResult.setFailMsgArray(new String[]{userDTO.getUserId()}); + return loginResult; + } + if (user.getDisabledate() != null) { + //2021鐗堟湰鎵嶆湁杩欎釜灞炴�х殑鍊硷紝褰撳墠杩欎釜娌℃湁杩欎釜鍊� + Date disableDate = VciDateUtil.addOrSubDate(user.getDisabledate(), Calendar.DATE, 1); + if (disableDate != null && disableDate.getTime() < System.currentTimeMillis()) { + loginResult.setFailCode(USER_MORE_THAN_DISABLE_DATE); + loginResult.setFailMsgArray(new String[]{userDTO.getUserId()}); + return loginResult; + } + } + + SmPasswordStrategyVO passwordStrategyVO = userQueryService.getPasswordStrategyVOByUserOid(user.getOid()); + if (checkPassword) { + boolean passwordIsEqual = userQueryService.checkPasswordEqual(userDTO.getPassword(), user.getOid()); + //3.鍒ゆ柇鐢ㄦ埛鐨勫瘑鐮佹槸鍚︽纭� + if (!passwordIsEqual) { + //鍓嶇闇�瑕佸厛md5涓�娆★紝鐒跺悗鍚庡彴鍐峂D5涓�娆★紝 + if (logger.isDebugEnabled()) { + logger.debug("{}瀵嗙爜涓嶆纭�", user.getId()); + } + if (passwordStrategyVO == null) { + //鍙兘鏁版嵁闂娌℃湁璁剧疆瀵嗙爜绛栫暐 + passwordStrategyVO = new SmPasswordStrategyVO(); + passwordStrategyVO.setRetryTime(6); + passwordStrategyVO.setLockTime(30); + } + if (passwordStrategyVO.getRetryTime() <= (user.getPwdWrongCount() + 1)) { + user.setLockFlag(true); + updateUserPwdWrongCount(user.getOid(), user.getPwdWrongCount() + 1); + addUserToUnLock(userDTO.getUserId(), passwordStrategyVO.getLockTime()); + updateUserPwdWrongCount(user.getOid(), user.getPwdWrongCount() + 1); + loginResult.setFailCode(USER_PWD_LOCK); + loginResult.setFailMsgArray(new String[]{userDTO.getUserId(), passwordStrategyVO.getLockTime() + ""}); + return loginResult; + } else { + //杩樻病鏈夊埌閿佸畾鐨勬鏁� + updateUserPwdWrongCount(user.getOid(), user.getPwdWrongCount() + 1); + //5, 杩欐槸绗竴娆¢敊璇紝鍓╀笅鐨勬槸 5- 锛�0+1锛� + loginResult.setFailCode(USER_PWD_NOT_EQUAL); + loginResult.setFailMsgArray(new String[]{userDTO.getUserId(), (passwordStrategyVO.getRetryTime() - (user.getPwdWrongCount() + 1)) + ""}); + return loginResult; + } + } + } + + //妫�鏌ユ槸鍚﹁淇敼瀵嗙爜 + if (!clientInfo.isSso() && checkPassword) { + //鏈�鍚庝慨鏀规椂闂�+ 澶辨晥鏃堕棿锛屽ぇ浜庣瓑浜庡綋鍓嶆棩鏈燂紝鍒欓渶瑕侀┈涓婁慨鏀瑰瘑鐮� + Date currentDay = null; + try { + currentDay = VciDateUtil.getNow(VciDateUtil.DateFormat); + } catch (Throwable e) { + if (logger.isErrorEnabled()) { + logger.error("鑾峰彇褰撳墠鏃ユ湡", e); + } + } + if (currentDay != null && passwordStrategyVO != null && passwordStrategyVO.getValidDay() != null) { + Date inValidDay = null; + if (user.getLastModifyPasswordTime() == null) { + //閲嶆潵娌℃湁鐧诲綍杩� + loginResult.setMustChangePassword(true); + } else { + inValidDay = VciDateUtil.addOrSubDate(user.getLastModifyPasswordTime(), Calendar.DATE, passwordStrategyVO.getValidDay()); + if (inValidDay.getTime() <= (currentDay).getTime()) { + loginResult.setMustChangePassword(true); + } + } + if (!loginResult.isMustChangePassword()) { + if (VciDateUtil.addOrSubDate(inValidDay, Calendar.DATE, -(passwordStrategyVO.getRemindDay())).getTime() + <= (currentDay).getTime()) { + //鎮ㄧ殑瀵嗙爜杩樻湁{0}澶╄繃鏈燂紝璇峰強鏃朵慨鏀瑰瘑鐮� + long remainDay = VciDateUtil.getDaySub(inValidDay, currentDay); + loginResult.setPasswordInfo(MessageFormat.format(PASSWORD_REMAIN_DAY, new String[]{String.valueOf(remainDay)})); + } + } + } + }*/ + //璇存槑瀵嗙爜姝g‘鐨� -// if (logger.isDebugEnabled()) { -// logger.debug("{}鐨勫瘑鐮佹纭�", user.getId()); -// } -// user.setLastLoginTime(new Date()); -// user.setPwdWrongCount(0); - SmUserVO user = new SmUserVO(); - user.setId("1"); - user.setName("1"); - user.setOid("1"); - user.setUserType("1"); - user.setUserTypeText("1"); - user.setSecretGrade(1); - user.setSecretGradeText("1"); - user.setSex("1"); - user.setSexText("1"); - user.setPkPerson("1"); - user.setPkPersonName("1"); - user.setPkDepartment("1"); - user.setPkDepartmentName("1"); - user.setPkDuty("1"); - user.setPkDutyName("1"); - user.setEmail("1"); - user.setTel("1"); - user.setRtxNo("1"); - user.setIMNo("1"); - - - + if (logger.isDebugEnabled()) { + logger.debug("{}鐨勫瘑鐮佹纭�", user.getId()); + } + user.setLastLoginTime(new Date()); + user.setPwdWrongCount(0); SessionInfo sessionInfo = new SessionInfo(); //鎷疯礉鐢ㄦ埛鐨勬柊鍒皊ession浼氳瘽涓� copyUser2SessionInfo(user, sessionInfo, userDTO.getLangCode()); //鎷疯礉璇锋眰淇℃伅鍒皊ession浼氳瘽涓� copyRequest2SessionInfo(clientInfo, sessionInfo); - //鏌ヨ鎵�鏈夌殑瑙掕壊 -// List<SmRoleVO> roleVOList = roleQueryService.listRoleByUserOid(user.getOid(), null); -// if (!CollectionUtils.isEmpty(roleVOList)) { -// Map<String, String> roleOidNameMap = roleVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t.getName())); -// sessionInfo.setRolesName(roleOidNameMap); -// } else { -// sessionInfo.setRolesName(new HashMap()); -// } + + /** //鏌ヨ鎵�鏈夌殑瑙掕壊 + List<SmRoleVO> roleVOList = roleQueryService.listRoleByUserOid(user.getOid(), null); + if (!CollectionUtils.isEmpty(roleVOList)) { + Map<String, String> roleOidNameMap = roleVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t.getName())); + sessionInfo.setRolesName(roleOidNameMap); + } else { + sessionInfo.setRolesName(new HashMap()); + } //鏌ヨ鎵�鏈夌殑鏉冮檺 -// List<SmFunctionVO> functionVOList = functionQueryService.listFunctionByUserOid(user.getOid(), null, ResourceControlTypeEnum.BS); -// if (!CollectionUtils.isEmpty(functionVOList)) { -// List<String> functionOidList = functionVOList.stream().map(s -> s.getOid()).collect(Collectors.toList()); -// sessionInfo.setFunctionOids(functionOidList); -// } else { -// sessionInfo.setFunctionOids(new ArrayList()); -// } + List<SmFunctionVO> functionVOList = functionQueryService.listFunctionByUserOid(user.getOid(), null, ResourceControlTypeEnum.BS); + if (!CollectionUtils.isEmpty(functionVOList)) { + List<String> functionOidList = functionVOList.stream().map(s -> s.getOid()).collect(Collectors.toList()); + sessionInfo.setFunctionOids(functionOidList); + } else { + sessionInfo.setFunctionOids(new ArrayList()); + }*/ loginResult.setSuccess(true); - //妫�鏌ユ槸鍚﹁淇敼瀵嗙爜 -// if (!clientInfo.isSso() && checkPassword) { -// //鏈�鍚庝慨鏀规椂闂�+ 澶辨晥鏃堕棿锛屽ぇ浜庣瓑浜庡綋鍓嶆棩鏈燂紝鍒欓渶瑕侀┈涓婁慨鏀瑰瘑鐮� -// Date currentDay = null; -// try { -// currentDay = VciDateUtil.getNow(VciDateUtil.DateFormat); -// } catch (Throwable e) { -// if (logger.isErrorEnabled()) { -// logger.error("鑾峰彇褰撳墠鏃ユ湡", e); -// } -// } -// if (currentDay != null && passwordStrategyVO != null && passwordStrategyVO.getValidDay() != null) { -// Date inValidDay = null; -// if (user.getLastModifyPasswordTime() == null) { -// //閲嶆潵娌℃湁鐧诲綍杩� -// loginResult.setMustChangePassword(true); -// } else { -// inValidDay = VciDateUtil.addOrSubDate(user.getLastModifyPasswordTime(), Calendar.DATE, passwordStrategyVO.getValidDay()); -// if (inValidDay.getTime() <= (currentDay).getTime()) { -// loginResult.setMustChangePassword(true); -// } -// } -// if (!loginResult.isMustChangePassword()) { -// if (VciDateUtil.addOrSubDate(inValidDay, Calendar.DATE, -(passwordStrategyVO.getRemindDay())).getTime() -// <= (currentDay).getTime()) { -// //鎮ㄧ殑瀵嗙爜杩樻湁{0}澶╄繃鏈燂紝璇峰強鏃朵慨鏀瑰瘑鐮� -// long remainDay = VciDateUtil.getDaySub(inValidDay, currentDay); -// loginResult.setPasswordInfo(MessageFormat.format(PASSWORD_REMAIN_DAY, new String[]{String.valueOf(remainDay)})); -// } -// } -// } -// } - - //鍘熸湰鎯充娇鐢╦wt鏉ョ敓鎴恡oken锛屼絾鏄湁浠ヤ笅闂 - //1.jwt涓嶈兘澶勭悊娉ㄩ攢鐨勯棶棰� - //2.jwt鐢熸垚鐨則oken澶暱浜� - //3.鍥犱负鏈钩鍙颁笉鏄簰鑱旂綉绯荤粺锛屽彧闇�瑕佽В鍐冲垎甯冨紡鐢ㄦ埛淇℃伅鐨勮幏鍙栧拰鏉冮檺鐨勬牎楠屽嵆鍙�� - //4.骞冲彴寮曠敤浜唕edis鍜屾暟鎹簱鏉ュ瓨鍌ㄤ細璇濈殑淇℃伅锛屽彧闇�瑕佷繚璇佹牴鎹畉oken鑳借幏鍙栧埌浼氳瘽淇℃伅鍗冲彲 - //5.鍦ㄦ湇鍔″惎鍔ㄧ殑鏃跺�欙紝灏嗕細璇濅俊鎭竻闄わ紝鍦ㄦ敞閿�鐨勬椂鍊欏皢浼氳瘽淇℃伅娓呴櫎 - //uuid鍦ㄩ珮骞跺彂鐨勬儏鍐典笅浼氶噸澶嶏紝浣嗘槸浼犵粺杞欢骞跺彂寰堝皬锛屾墍浠ュ嚭鐜扮殑閲嶅鐨勬鐜囧緢灏� - sessionInfo.setToken(Md5.md5(VciBaseUtil.getPk() + "_" + user.getId())); loginResult.setSessionInfo(sessionInfo); -// updateUserForLoginSuccess(user.getOid()); -// if (StringUtils.isNotBlank(loginInfo) && userDTO.isForceLogin() && securityManageProperties.isUserOneLogin()) { -// //璇存槑宸茬粡鐧诲綍浜嗭紝閭e簲璇ュ彇娑堝師鏉ョ殑鐧诲綍 -// popUser(userDTO.getUserId()); -// } //娣诲姞鍒颁細璇濅俊鎭� -// saveSessionInfo(sessionInfo); + saveSessionInfo(sessionInfo); - //鐧诲綍鍚庢墽琛� -// BusAnnotationUtil.callForAnnotation(VciLoginPlugin.class,VciLoginAfter.class,userDTO,clientInfo,loginResult); return loginResult; + } + + /** + * 鑾峰彇鐢ㄦ埛淇℃伅 + * @param userId userId + * @Return com.vci.frameworkcore.pagemodel.SmUserVO + */ + private SmUserVO getUserByUserId(String userId) { + String userKey = CacheNameConstant.cacheKey(CacheNameConstant.VCI_USER,userId); + String userOid = redisService.getCacheObject(userKey); + String oidKey = CacheNameConstant.cacheKey(CacheNameConstant.VCI_USER_OID, userOid); + SmUserVO userVO = redisService.getCacheObject(oidKey); + if(userVO == null || StringUtils.isBlank(userVO.getOid())){ + userVO = userQueryService.getUserByUserId(userId); + } + return userVO; } @@ -357,28 +397,7 @@ } } - /** - * 鏍¢獙鏄惁鐧诲綍 - * @param userId 鐢ㄦ埛鍚� - * @return 宸茬粡鐧诲綍鏃讹紝 - */ - private String checkIsLogined(String userId) { - if(sessionForLogin == null){ - throw new VciBaseException("娌℃湁閰嶇疆浼氳瘽瀛樺偍鐨勬湇鍔�"); - } - return sessionForLogin.checkIsLogined(userId); - } - /** - * 鎶婁互鍓嶇殑鐧诲綍淇℃伅绉婚櫎 - * @param userId 鐢ㄦ埛鍚� - */ - private void popUser(String userId){ - if(sessionForLogin == null){ - throw new VciBaseException("娌℃湁閰嶇疆浼氳瘽瀛樺偍鐨勬湇鍔�"); - } - sessionForLogin.popUser(userId); - } /** * 淇濆瓨浼氳瘽淇℃伅 @@ -388,6 +407,11 @@ if(sessionForLogin == null){ throw new VciBaseException("娌℃湁閰嶇疆浼氳瘽瀛樺偍鐨勬湇鍔�"); } + //灏嗘潈闄愪俊鎭紝鏀惧叆redis缂撳瓨涓�備互闃叉session涓殑淇℃伅杩囧锛屽瓨鍏ユ暟鎹簱涓嚭鐜伴敊璇� + redisService.setCacheList(sessionInfo.getToken(),sessionInfo.getFunctionOids()); + redisService.expire(sessionInfo.getToken(), 1, TimeUnit.HOURS); + + sessionInfo.setFunctionOids(new ArrayList<>()); sessionForLogin.saveSessionInfo(sessionInfo); } @@ -438,10 +462,6 @@ sessionInfo.setRtxNo(user.getRtxNo()); sessionInfo.setIMId(user.getIMNo()); sessionInfo.setPortalId(user.getId()); - -// sessionInfo.setWorkNo(user.getWorkNo()); -// sessionInfo.setWorkTypeOid(user.getPkWorkType()); -// sessionInfo.setWorkTypeName(user.getPkWorkTypeText()); } /** @@ -475,4 +495,105 @@ private void updateUserForLoginSuccess(String userOid){ userQueryService.updateUserLoginTime(userOid); } + + /** + * 鍒涘缓璁稿彲鐨勪俊鎭� + * + * @param sessionInfo session鐨勪俊鎭� + * @return 璁稿彲淇℃伅 + */ + @Override + public TokenVO createToken(SessionInfo sessionInfo) { + return createToken(TokenKeyConstant.TOKEN_KEY_PREFIX_IN_REDIS, sessionInfo); + } + + /** + * 鍒涘缓璁稿彲鐨勪俊鎭� + * @param key token鍦╮edis涓殑key + * @param sessionInfo session鐨勪俊鎭� + * @return 璁稿彲淇℃伅 + */ + @Override + public TokenVO createToken(String key, SessionInfo sessionInfo) { + if(StringUtils.isBlank(sessionInfo.getToken())) { + String token = Md5.md5(VciBaseUtil.getPk() + "_" + sessionInfo.getUserId()); + sessionInfo.setToken(token); + } + if(StringUtils.isBlank(key)){ + key = TokenKeyConstant.TOKEN_KEY_PREFIX_IN_REDIS; + } + refreshToken(key, sessionInfo); + Map<String,Object> claimsMap = new HashMap<>(); + claimsMap.put(TokenKeyConstant.JWT_TOKEN_KEY,sessionInfo.getToken()); + claimsMap.put(TokenKeyConstant.JWT_USER_KEY,sessionInfo.getUserOid()); + claimsMap.put(TokenKeyConstant.JWT_USER_NAME_KEY,sessionInfo.getUserName()); + claimsMap.put(TokenKeyConstant.JWT_USER_CODE_KEY,sessionInfo.getUserId()); + TokenVO tokenVO = new TokenVO(); + tokenVO.setAccessToken(JwtUtils.createToken(claimsMap)); + tokenVO.setExpireTime(TokenKeyConstant.EXPIRATION); + return tokenVO; + } + + /** + * 鍒锋柊token + * @param sessionInfo session鐨勪俊鎭� + */ + @Override + public void refreshToken(SessionInfo sessionInfo) { + refreshToken(TokenKeyConstant.TOKEN_KEY_PREFIX_IN_REDIS, sessionInfo); + } + + /** + * 鍒锋柊token + * @param key token鍦╮edis涓殑key + * @param sessionInfo session鐨勪俊鎭� + */ + @Override + public void refreshToken(String key, SessionInfo sessionInfo) { + if(sessionInfo!=null && StringUtils.isNotBlank(sessionInfo.getToken())){ + if(StringUtils.isBlank(key)){ + key = TokenKeyConstant.TOKEN_KEY_PREFIX_IN_REDIS; + } + String redisKey = key + sessionInfo.getToken(); + redisService.setCacheObject(redisKey, sessionInfo, webProperties.getClientSessionAliveMax()!=0?webProperties.getClientSessionAliveMax(): TokenKeyConstant.EXPIRATION, TimeUnit.MINUTES); + } + } + + /** + * 鑾峰彇鐧诲綍閿欒鐮� + * @param chkRes 骞冲彴鐧诲綍鏍¢獙缁撴灉 + * @Return java.lang.String + */ + public String getErrorCode(LoginResult chkRes){ + String message = ""; + switch(chkRes.state.value()) + { + case 0: + return ""; + case 1: + return LOGIN_SUCCESS; + case 10: + return USER_NOT_FOUND; + case 11: + return USER_PWD_NOT_EQUAL; + case 12: + return USER_IS_DISABLED; + case 13: + return USER_IS_LOCK; + case 14: + return PASSWORD_INIT; + case 15: + return PASSWORD_REMAIN_DAY; + case 16: + return PASSWORD_EXPIRE; + case 17: + return PASSWORD_POLICY_UPDATED; + case 20: + return SYSTEM_ERROR; + default: + message = SYSTEM_ERROR; + break; + } + return message; + } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java index f172326..bfa29fd 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java @@ -9,7 +9,6 @@ import com.vci.starter.web.pagemodel.DataGrid; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.VciDateUtil; -import com.vci.web.constant.CacheKeyConstant; import com.vci.web.model.OsAttributeDO; import com.vci.web.pageModel.OsAttributeVO; import com.vci.web.service.OsAttributeServiceI; @@ -19,8 +18,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -29,7 +26,6 @@ import java.util.stream.Collectors; import static com.vci.client.omd.attribpool.ui.VTDataTypePanel.*; -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; /** * 灞炴�ф睜鏈嶅姟 --宸茬粡璋冪敤浜嗗钩鍙扮殑鏈嶅姟锛屽洜姝や笉鍦ㄦ彁渚汥ao灞� @@ -126,7 +122,6 @@ * @return key鏄睘鎬х殑鑻辨枃鍚嶇О灏忓啓锛寁alue鏄睘鎬х殑鏄剧ず瀵硅薄 */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_ATTRIBUTE,unless = "#result == null") @VciUnLog public Map<String, OsAttributeVO> selectAllAttributeMap() { return Optional.ofNullable(self.selectAllAttribute()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getId().toLowerCase(),t->t,(o1,o2)->o1)); @@ -428,7 +423,6 @@ * 娓呴櫎缂撳瓨 */ @Override - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_ATTRIBUTE) public void clearCache() { } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java index 8735572..9ec152c 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java @@ -11,7 +11,6 @@ import com.vci.starter.web.util.BeanUtil; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.VciDateUtil; -import com.vci.web.constant.CacheKeyConstant; import com.vci.web.pageModel.*; import com.vci.web.service.*; import com.vci.web.util.ConcurrentDateFormat; @@ -20,16 +19,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.*; import java.util.stream.Collectors; - -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; /** * 涓氬姟绫诲瀷鏈嶅姟 @@ -106,7 +101,6 @@ */ @Override @VciUnLog - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_BTM,unless = "#result == null") public Map<String, OsBtmTypeVO> selectAllBtmMap() { return Optional.ofNullable(self.selectAllBtm()).orElseGet(()->new ArrayList<OsBtmTypeVO>()).stream().collect(Collectors.toMap(s->s.getId().toLowerCase(), t->t,(o1,o2)->o1)); } @@ -339,7 +333,6 @@ * 娓呴櫎缂撳瓨 */ @Override - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_BTM) public void clearCache() { } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java index 0384af9..a87274d 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java @@ -11,7 +11,6 @@ import com.vci.starter.web.pagemodel.PageHelper; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.VciDateUtil; -import com.vci.web.constant.CacheKeyConstant; import com.vci.web.constant.EnumIdConstant; import com.vci.web.pageModel.KeyValue; import com.vci.web.pageModel.OsEnumItemVO; @@ -26,8 +25,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -36,7 +33,6 @@ import java.util.*; import java.util.stream.Collectors; -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; import static com.vci.web.constant.EnumIdConstant.LC_STATUS_SUBFIX; /** @@ -226,7 +222,6 @@ */ @Override @VciUnLog - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_ENUM,unless = "#result ==null") public Map<String, OsEnumVO> selectAllEnumMap() { return Optional.ofNullable(self.selectAllEnum()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getId().toLowerCase(),t->t,(o1,o2)->o1)); } @@ -465,7 +460,6 @@ * 娓呴櫎缂撳瓨 */ @Override - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_ENUM) public void clearCache() { } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java index cd2fce1..3552e01 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java @@ -10,7 +10,6 @@ import com.vci.starter.web.pagemodel.BaseQueryObject; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.starter.web.util.VciDateUtil; -import com.vci.web.constant.CacheKeyConstant; import com.vci.web.model.OsLifeCycleDO; import com.vci.web.pageModel.*; import com.vci.web.service.OsLifeCycleServiceI; @@ -22,8 +21,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -32,7 +29,6 @@ import java.util.stream.Collectors; import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_ID_NOT_EXIST; -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; import static com.vci.web.constant.WebLangCodeConstant.LIFE_CYCLE_ROUTER_NULL; import static com.vci.web.constant.WebLangCodeConstant.LIFE_CYCLE_TRANS_ERROR; @@ -331,7 +327,6 @@ */ @Override @VciUnLog - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_LIFE_CYCLE,unless="#result == null") public Map<String,OsLifeCycleVO> selectAllLifeCycleMap() throws VciBaseException{ return Optional.ofNullable(self.selectAllLifeCycle()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getId(),t->t,(o1,o2)->o1)); } @@ -340,7 +335,6 @@ * 娓呴櫎缂撳瓨 */ @Override - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_LIFE_CYCLE) public void clearCache() { } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java index 330c7d1..9c8cfdf 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java @@ -9,7 +9,6 @@ import com.vci.starter.web.util.BeanUtil; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.VciDateUtil; -import com.vci.web.constant.CacheKeyConstant; import com.vci.web.model.OsLinkTypeDO; import com.vci.web.pageModel.*; import com.vci.web.service.*; @@ -19,16 +18,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.*; import java.util.stream.Collectors; - -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; /** * 閾炬帴绫诲瀷鏈嶅姟 @@ -103,7 +98,6 @@ */ @Override @VciUnLog - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_Link,unless = "#result == null") public Map<String, OsLinkTypeVO> selectAllLinkMap() { return Optional.ofNullable(self.selectAllLink()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getId().toLowerCase(),t->t,(o1,o2)->o1)); } @@ -328,7 +322,6 @@ * 娓呴櫎缂撳瓨 */ @Override - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_Link) public void clearCache() { } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java index cafde0d..dba1ef7 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java @@ -4,21 +4,17 @@ import com.vci.corba.omd.vrm.VersionRule; import com.vci.starter.web.annotation.log.VciUnLog; import com.vci.starter.web.util.VciDateUtil; -import com.vci.web.constant.CacheKeyConstant; import com.vci.web.pageModel.OsRevisionRuleVO; import com.vci.web.service.OsRevisionRuleServiceI; import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.WebUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CachePut; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import java.util.*; import java.util.stream.Collectors; - -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; /** * 鐗堟湰瑙勫垯鐨勬湇鍔� @@ -60,7 +56,6 @@ * @return key 鏄増鏈殑鑻辨枃鍚嶇О */ @Override - @CachePut(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_REVISION,unless = "#result ==null ") @VciUnLog public Map<String, OsRevisionRuleVO> selectAllRevisionMap() { return Optional.ofNullable(self.selectAllRevision()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getId().toLowerCase(),t->t,(o1,o2)->o1)); @@ -133,7 +128,6 @@ * 娓呴櫎缂撳瓨 */ @Override - @CachePut(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_REVISION) public void clearCache() { } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java index 9c4c8e1..0d2719c 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsStatusServiceImpl.java @@ -23,8 +23,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -33,8 +31,6 @@ import java.util.stream.Collectors; import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; -import static com.vci.web.constant.CacheKeyConstant.ALL_STATUS; -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; /** * 鐘舵�佺殑鏈嶅姟 @@ -139,7 +135,6 @@ /** * 娓呴櫎缂撳瓨 */ - @CacheEvict(value = VCI_OBJECT_SERVICE,key = ALL_STATUS) @Override public void clearCache(){ // @@ -151,7 +146,6 @@ */ @Override @VciUnLog - @Cacheable(value = VCI_OBJECT_SERVICE,key = ALL_STATUS,unless = "#result == null") public Map<String,OsStatusVO> selectAllStatusMap(){ return Optional.ofNullable(self.selectAllStatus()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getId(),t->t,(o1,o2)->o1)); } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java index 9d6182c..6237182 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java @@ -14,7 +14,6 @@ import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.VciDateUtil; import com.vci.starter.web.wrapper.VciQueryWrapperForDO; -import com.vci.web.constant.CacheKeyConstant; import com.vci.web.enumpck.UIComponentDisplayTypeEnum; import com.vci.web.enumpck.UIComponentTypeEnum; import com.vci.web.enumpck.UIFieldTypeEnum; @@ -33,9 +32,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.Caching; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -43,7 +39,6 @@ import java.util.*; import java.util.stream.Collectors; -import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE; import static com.vci.web.constant.EnumIdConstant.LC_STATUS_SUBFIX; /** @@ -175,7 +170,6 @@ * @return key鏄〃鍗曡嫳鏂囧悕绉� */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_FORM,unless = "#result == null") public Map<String, UIFormDefineVO> selectAllFormMap() { return Optional.ofNullable(self.selectAllForm()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getBtmType().toLowerCase() + SEP + s.getId().toLowerCase(),t->t,(o1,o2)->o1)); } @@ -404,7 +398,6 @@ * @return 琛ㄥ崟鐨勫畾涔� */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key = "#p0.concat('${formcache}').concat(#p1)",unless = "#result == null || #p0 == null || #p1 == null") public UIFormDefineVO getFormById(String btmId, String id) { if(StringUtils.isBlank(btmId) || StringUtils.isBlank(id)){ return null; @@ -450,7 +443,6 @@ * @return 琛ㄦ牸鐨勫畾涔� */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_TABLE,unless = "#result == null") @VciUnLog public List<UITableDefineVO> selectAllTable() { PortalVI[] portalVIS = null; @@ -724,7 +716,6 @@ * @return 琛ㄥ崟鐨勫畾涔� */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key = "#p0.concat('${tablecache}').concat(#p1)",unless = "#result == null || #p0 == null || #p1 == null") public UITableDefineVO getTableById(String btmId, String id) { if(StringUtils.isBlank(btmId) || StringUtils.isBlank(id)){ return null; @@ -786,7 +777,6 @@ * @return 鏄剧ず瀵硅薄锛宬ey鏄痑ction鐨勪富閿� */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key=CacheKeyConstant.ALL_ACTION,unless = "#result == null") public Map<String, UIActionVO> selectAllActionMap() { return Optional.ofNullable(self.selectAllAction()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getOid(),t->t)); } @@ -843,13 +833,6 @@ * 娓呴櫎缂撳瓨 */ @Override - @Caching(evict = { - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_UI), - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_ACTION), - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_FORM), - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_TABLE), - @CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_FORM_AND_TABLE) - }) public void clearCache() { } @@ -861,7 +844,6 @@ */ @Override @VciUnLog - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_UI,unless = "#result == null") public List<UIContentVO> selectAllUIContent() { try { return UIContentDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLUILayouts()).collect(Collectors.toList())); @@ -1067,7 +1049,6 @@ * @return 鍖哄煙鐨勬樉绀哄璞� */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_LAYOUT,unless = "#result == null") public List<UILayoutVO> selectAllUILayout() { // try { // return UILayoutDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLTabPages()).collect(Collectors.toList()),true); @@ -1173,7 +1154,6 @@ * @return UI缁勪欢 */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_COMP ,unless = "#result ==null") public List<UIComponentVO> selectAllUIComponent() { // try { // return uiComponentDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLPageDefinations()).collect(Collectors.toList()),false); @@ -1542,7 +1522,6 @@ * @return UI涓婁笅鏂囩殑淇℃伅 */ @Override - @Cacheable(value = VCI_OBJECT_SERVICE,key = "#p0.concat('${uicache}').concat(#p1)",unless = "#result == null || #p0 == null || #p1 ==null") public UIContentVO getUIContentByBtmTypeAndId(String btmType, String id) { WebUtil.alertNotNull(btmType,"涓氬姟绫诲瀷鎴栬�呴摼鎺ョ被鍨�",id,"UI涓婁笅鏂囩殑缂栧彿"); PLUILayout[] obj = null; diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBoServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBoServiceImpl.java index 92c1b6d..956faa7 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBoServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBoServiceImpl.java @@ -1,13 +1,14 @@ package com.vci.web.service.impl; import com.vci.client.bof.ClientBusinessObject; +import com.vci.client.bof.ClientLinkObject; import com.vci.client.common.oq.OQTool; -import com.vci.client.common.providers.ServiceProvider; import com.vci.common.qt.object.*; import com.vci.common.utility.ObjectUtility; import com.vci.corba.common.PLException; import com.vci.corba.omd.data.AttributeValue; import com.vci.corba.omd.data.BusinessObject; +import com.vci.corba.omd.data.LinkObject; import com.vci.corba.omd.qtm.QTInfo; import com.vci.corba.query.ObjectQueryService; import com.vci.corba.query.ObjectQueryServicePrx; @@ -36,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; - import java.lang.reflect.Field; import java.util.*; @@ -256,8 +256,8 @@ */ private ClientBusinessObject cloneClientBusinessObject(ClientBusinessObject cbo){ if(cbo !=null){ - com.vci.corba.omd.data.BusinessObject businessObject = new com.vci.corba.omd.data.BusinessObject(); - com.vci.corba.omd.data.BusinessObject bo = cbo.getBusinessObject(); + BusinessObject businessObject = new BusinessObject(); + BusinessObject bo = cbo.getBusinessObject(); businessObject.oid = new ObjectUtility().getNewObjectID36(); businessObject.revisionid = new ObjectUtility().getNewObjectID36(); businessObject.nameoid = new ObjectUtility().getNewObjectID36(); @@ -307,10 +307,10 @@ * @param newAttrValList 灞炴�у�煎璞℃暟缁� * @return 鎷疯礉鍚庣殑鏂板睘鎬ф暟缁� */ - private com.vci.corba.omd.data.AttributeValue[] clone(com.vci.corba.omd.data.AttributeValue[] newAttrValList) { - com.vci.corba.omd.data.AttributeValue[] n = new com.vci.corba.omd.data.AttributeValue[newAttrValList.length]; + private AttributeValue[] clone(AttributeValue[] newAttrValList) { + AttributeValue[] n = new AttributeValue[newAttrValList.length]; for (int i = 0; i < newAttrValList.length; i++) { - n[i] = new com.vci.corba.omd.data.AttributeValue(newAttrValList[i].attrName,newAttrValList[i].attrVal); + n[i] = new AttributeValue(newAttrValList[i].attrName,newAttrValList[i].attrVal); } return n; } @@ -400,7 +400,7 @@ Map<String,String> data = new HashMap<String, String>(); if(cbos!=null && cbos.size() > 0){ - for(com.vci.client.bof.ClientBusinessObject cbo : cbos){ + for(ClientBusinessObject cbo : cbos){ data.put(cbo.getAttributeValue(fieldName),cbo.getOid()); } } @@ -430,9 +430,9 @@ throw new VciBaseException("灞炴��" + columnName + "鐨勫�间负绌�"); } conditionMap.put(columnName,QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oidSet.toArray(new String[0])) + ")"); - List<com.vci.client.bof.ClientBusinessObject> cbos = queryCBO(btmName,conditionMap,null,Arrays.asList(new String[]{columnName})); + List<ClientBusinessObject> cbos = queryCBO(btmName,conditionMap,null,Arrays.asList(new String[]{columnName})); if(cbos !=null && cbos.size() >0){ - for(com.vci.client.bof.ClientBusinessObject cbo : cbos){ + for(ClientBusinessObject cbo : cbos){ String oid = cbo.getAttributeValue(columnName); if(oidSet.contains(oid)){ oidSet.remove(oid); @@ -470,7 +470,7 @@ * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬槸鎶涘嚭寮傚父 */ @Override - public List<com.vci.client.bof.ClientBusinessObject> queryCBO(String btmType, + public List<ClientBusinessObject> queryCBO(String btmType, Map<String, String> conditionMap) throws VciBaseException { List<String> clauseList = new ArrayList<String>(); clauseList.add("*"); @@ -487,7 +487,7 @@ * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬槸鎶涘嚭寮傚父 */ @Override - public List<com.vci.client.bof.ClientBusinessObject> queryCBO(String btmType, + public List<ClientBusinessObject> queryCBO(String btmType, Map<String, String> conditionMap, PageHelper ph) throws VciBaseException { List<String> clauseList = new ArrayList<String>(); @@ -505,7 +505,7 @@ * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬槸鎶涘嚭寮傚父 */ @Override - public List<com.vci.client.bof.ClientBusinessObject> queryCBO(String btmType, + public List<ClientBusinessObject> queryCBO(String btmType, Map<String, String> conditionMap, PageHelper ph, List<String> clauseList) throws VciBaseException { QueryTemplate qt = new QueryTemplate(); @@ -557,7 +557,7 @@ * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父 */ private List<ClientBusinessObject> baseQueryCBO(QueryTemplate qt,Map<String,String> conditionMap,PageHelper ph,List<String> clauseList) throws VciBaseException{ - List<com.vci.client.bof.ClientBusinessObject> allCbos = new ArrayList<com.vci.client.bof.ClientBusinessObject>(); + List<ClientBusinessObject> allCbos = new ArrayList<ClientBusinessObject>(); if(clauseList == null){ clauseList = new ArrayList<String>(); clauseList.add("*"); @@ -632,7 +632,7 @@ return allCbos; } - public AttributeValue[] copyToAttributeValue(com.vci.corba.omd.data.AttributeValue[] attributeValues){ + public AttributeValue[] copyToAttributeValue(AttributeValue[] attributeValues){ AttributeValue[] attributeValueList = new AttributeValue[attributeValues.length]; for (int i = 0; i < attributeValues.length; i++) { AttributeValue newAttributeValue = new AttributeValue(); @@ -716,7 +716,7 @@ * 鏌ヨ鐢熷懡鍛ㄦ湡鐨勫�� * @param cbos 涓氬姟瀵硅薄 */ - private void queryLcStatus(List<com.vci.client.bof.ClientBusinessObject> cbos){ + private void queryLcStatus(List<ClientBusinessObject> cbos){ if(!CollectionUtils.isEmpty(cbos)){ Map<String, OsStatusVO> statusVOMap = statusService.selectAllStatusMap(); @@ -736,7 +736,7 @@ * @param enumAttrName 鏋氫妇灞炴�х殑鍊� * @throws VciBaseException */ - private void queryEnumText(com.vci.client.bof.ClientBusinessObject cbo,List<String> enumAttrName) throws VciBaseException{ + private void queryEnumText(ClientBusinessObject cbo,List<String> enumAttrName) throws VciBaseException{ queryEnumText(cbo,null,enumAttrName); } @@ -748,7 +748,7 @@ * @throws VciBaseException 鏌ヨ鏋氫妇鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父 */ @Override - public void queryEnumText(com.vci.client.bof.ClientBusinessObject cbo, com.vci.client.bof.ClientLinkObject clo, List<String> enumAttrName) throws VciBaseException{ + public void queryEnumText(ClientBusinessObject cbo, ClientLinkObject clo, List<String> enumAttrName) throws VciBaseException{ if(enumAttrName.size()>0){//鏌ヨ鏋氫妇 for(String enumAttr:enumAttrName){//鏍煎紡涓� code_field code鏄灇涓剧殑缂栫爜锛宖ield鏄綋鍓嶄笟鍔$被鍨嬪瓨鍌ㄦ灇涓惧�肩殑瀛楁 if(enumAttr.toLowerCase().equals("creator_name")){ @@ -826,7 +826,7 @@ * @param attr 灞炴�у悕 * @param value 鍊� */ - private void setValueToCboOrClo(com.vci.client.bof.ClientBusinessObject cbo,com.vci.client.bof.ClientLinkObject clo,String attr,String value){ + private void setValueToCboOrClo(ClientBusinessObject cbo,ClientLinkObject clo,String attr,String value){ try { if (cbo != null) { cbo.setAttributeValueWithNoCheck(attr, value); @@ -845,13 +845,13 @@ * @param attributeValue 灞炴�х殑鍊� */ @Override - public void setAttributeValueForClo(com.vci.client.bof.ClientLinkObject clo, String attributeName, String attributeValue) { - com.vci.corba.omd.data.AttributeValue[] attrValues = clo.getLinkObject().newAttrValList; - ArrayList<com.vci.corba.omd.data.AttributeValue> attrValList = new ArrayList(); - com.vci.corba.omd.data.AttributeValue attrVal; + public void setAttributeValueForClo(ClientLinkObject clo, String attributeName, String attributeValue) { + AttributeValue[] attrValues = clo.getLinkObject().newAttrValList; + ArrayList<AttributeValue> attrValList = new ArrayList(); + AttributeValue attrVal; int i; if (attrValues != null && attrValues.length > 0) { - com.vci.corba.omd.data.AttributeValue[] var9 = attrValues; + AttributeValue[] var9 = attrValues; i = attrValues.length; for (int var7 = 0; var7 < i; ++var7) { @@ -864,7 +864,7 @@ boolean isExist = false; for (i = 0; i < attrValList.size(); ++i) { - attrVal = (com.vci.corba.omd.data.AttributeValue) attrValList.get(i); + attrVal = (AttributeValue) attrValList.get(i); if (attrVal.attrName.toUpperCase().equals(attributeName.toUpperCase())) { attrVal.attrVal = attributeValue; isExist = true; @@ -873,13 +873,13 @@ } if (!isExist) { - attrVal = new com.vci.corba.omd.data.AttributeValue(); + attrVal = new AttributeValue(); attrVal.attrName = attributeName.toUpperCase(); attrVal.attrVal = attributeValue; attrValList.add(attrVal); } - clo.getLinkObject().newAttrValList = (com.vci.corba.omd.data.AttributeValue[]) attrValList.toArray(new com.vci.corba.omd.data.AttributeValue[attrValList.size()]); + clo.getLinkObject().newAttrValList = (AttributeValue[]) attrValList.toArray(new AttributeValue[attrValList.size()]); } @@ -889,7 +889,7 @@ * @param enumAttrName 鏋氫妇灞炴�� * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父 */ - private void queryEnumTextClo(com.vci.client.bof.ClientLinkObject clo,List<String> enumAttrName) throws VciBaseException{ + private void queryEnumTextClo(ClientLinkObject clo,List<String> enumAttrName) throws VciBaseException{ queryEnumText(null,clo,enumAttrName); } @@ -902,7 +902,7 @@ * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父 */ @Override - public List<com.vci.client.bof.ClientBusinessObject> queryCBOByScheme(String queryScheme, + public List<ClientBusinessObject> queryCBOByScheme(String queryScheme, Map<String, String> conditionMap, Map<String, String> replaceMap) throws VciBaseException { PageHelper ph = new PageHelper(-1); @@ -920,7 +920,7 @@ * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父 */ @Override - public List<com.vci.client.bof.ClientBusinessObject> queryCBOByScheme(String queryScheme, + public List<ClientBusinessObject> queryCBOByScheme(String queryScheme, Map<String, String> conditionMap, Map<String, String> replaceMap, PageHelper ph) throws VciBaseException { List<String> clauseList = new ArrayList<String>(); @@ -940,8 +940,7 @@ QueryTemplate qt = null; try{ VciBaseUtil.alertNotNull(name,"鏌ヨ妯℃澘鐨勫悕绉�"); - // QTWrapper wrapper = platformClientUtil.getQueryService().getQT(name); - QTInfo wrapper = ServiceProvider.getOMDService().getQTDService().getQT(name); + QTInfo wrapper = platformClientUtil.getQTDService().getQT(name); qt = OQTool.getQTByDoc(DocumentHelper.parseText(wrapper.qtText), name); //鍥犱负涔嬪墠骞冲彴鐨凾ool.replaceQTValues 娌℃湁澶勭悊 ${xxx}銆傦紝 涓轰簡蹇界暐澶у皬鍐欙紝鎴戜滑杩欓噷鍗曠嫭澶勭悊 weidy@2021-3-10 //鎴戜滑杞崲涓哄皬鍐� @@ -1000,7 +999,7 @@ * @throws VciBaseException 鏌ヨ鍑洪敊浼氭姏鍑哄紓甯� */ @Override - public List<com.vci.client.bof.ClientBusinessObject> queryCBOByScheme(String queryScheme, + public List<ClientBusinessObject> queryCBOByScheme(String queryScheme, Map<String, String> conditionMap, Map<String, String> replaceMap, PageHelper ph, List<String> clauseList) throws VciBaseException { QueryTemplate qt = getQtByName(queryScheme,replaceMap); @@ -1132,11 +1131,11 @@ * @throws VciBaseException 鏌ヨ鍑洪敊浼氭姏鍑哄紓甯� */ @Override - public List<com.vci.client.bof.ClientBusinessObject> queryBySql(String sql, + public List<ClientBusinessObject> queryBySql(String sql, Map<String, String> conditionMap) throws VciBaseException { List<Map> allData = queryBySqlForMap(sql,conditionMap); if(allData == null || allData.size() == 0){ - return new ArrayList<com.vci.client.bof.ClientBusinessObject>(); + return new ArrayList<ClientBusinessObject>(); }else{ return map2Cbos(allData); } @@ -1149,10 +1148,10 @@ * @throws VciBaseException 鏌ヨ鍑洪敊娲绘姏鍑哄紓甯� */ @Override - public List<com.vci.client.bof.ClientBusinessObject> queryByOnlySql(String sql) throws VciBaseException{ + public List<ClientBusinessObject> queryByOnlySql(String sql) throws VciBaseException{ List<Map> allData = queryByOnlySqlForMap(sql); if(allData == null || allData.size() == 0){ - return new ArrayList<com.vci.client.bof.ClientBusinessObject>(); + return new ArrayList<ClientBusinessObject>(); }else{ return map2Cbos(allData); } @@ -1171,12 +1170,11 @@ } List<Map> dataList = new ArrayList<>(); try { -// KV[][] kvs = platformClientUtil.getQueryService().queryBySql(sql); - com.vci.corba.query.data.KV[][] kvs = ServiceProvider.getOQService().queryBySql(sql); + KV[][] kvs = platformClientUtil.getQueryService().queryBySql(sql); if(kvs!=null && kvs.length>0){ for (int i = 0; i < kvs.length; i++) { Map<String,String> data = new HashMap<>(); - com.vci.corba.query.data.KV[] kv = kvs[i]; + KV[] kv = kvs[i]; if(kv!=null && kv.length >0){ for (int j = 0; j < kv.length; j++) { KV kv1 = kv[j]; @@ -1260,9 +1258,9 @@ sql = sql.replaceAll(" FROM "," from "); } - com.vci.corba.omd.data.AttributeValue[] ava = null; + AttributeValue[] ava = null; if(conditionMap!=null&&!conditionMap.isEmpty()){ - ava = new com.vci.corba.omd.data.AttributeValue[conditionMap.size()]; + ava = new AttributeValue[conditionMap.size()]; Iterator<String> it = conditionMap.keySet().iterator(); int i = 0 ; while(it.hasNext()){ @@ -1271,16 +1269,15 @@ if(value == null){ value = ""; } - com.vci.corba.omd.data.AttributeValue av = new com.vci.corba.omd.data.AttributeValue(key, value); + AttributeValue av = new AttributeValue(key, value); ava[i] = av; i++; } }else{ - ava = new com.vci.corba.omd.data.AttributeValue[0]; + ava = new AttributeValue[0]; } try { -// String[][] results =platformClientUtil.getBOFactoryService().getSqlQueryResult(sql, ava); - String[][] results =ServiceProvider.getBOFService().getSqlQueryResult(sql, ava); + String[][] results =platformClientUtil.getSqlQueryService(sql, ava); if(results.length>0){ if(selectKeys==null) { String selectSql = sql.substring(sql.toLowerCase(Locale.ROOT).indexOf("select") + 6, sql.toLowerCase(Locale.ROOT).indexOf(" from")).trim(); @@ -1367,11 +1364,11 @@ allFieldAttrMap.put(columnName.toLowerCase(),fieldName); } List<T> allObject = new ArrayList<T>(); - List<com.vci.client.bof.ClientBusinessObject> allCbos = queryCBO(WebUtil.getBtmTypeByObject(c), conditionMap, ph, allFieldAttrMap.keySet().stream().collect(Collectors.toList()));//鎵ц鏌ヨ + List<ClientBusinessObject> allCbos = queryCBO(WebUtil.getBtmTypeByObject(c), conditionMap, ph, allFieldAttrMap.keySet().stream().collect(Collectors.toList()));//鎵ц鏌ヨ List<String> oids = new ArrayList<String>(); if(allCbos!=null&&allCbos.size()>0){ - for(com.vci.client.bof.ClientBusinessObject cbo : allCbos){ + for(ClientBusinessObject cbo : allCbos){ T obj = null; try { obj = c.newInstance(); @@ -1472,10 +1469,10 @@ allFieldAttrMap.put(columnName.toLowerCase(),fieldName); } List<T> allObject = new ArrayList<T>(); - List<com.vci.client.bof.ClientBusinessObject> allCbos = queryCBOByScheme(queryScheme, conditionMap, replaceMap,ph, allFieldAttrMap.keySet().stream().collect(Collectors.toList())); + List<ClientBusinessObject> allCbos = queryCBOByScheme(queryScheme, conditionMap, replaceMap,ph, allFieldAttrMap.keySet().stream().collect(Collectors.toList())); List<String> oids = new ArrayList<String>(); if(allCbos!=null&&allCbos.size()>0){ - for(com.vci.client.bof.ClientBusinessObject cbo : allCbos){ + for(ClientBusinessObject cbo : allCbos){ T obj = null; try { obj = c.newInstance(); @@ -1539,7 +1536,7 @@ * @param isEdit 鏄惁涓虹紪杈� * @throws VciBaseException 璁剧疆鍑洪敊浼氭姏鍑哄紓甯� */ - private void setValueToCbo(Object obj,String btmType,com.vci.client.bof.ClientBusinessObject cbo ,boolean isEdit) throws VciBaseException{ + private void setValueToCbo(Object obj,String btmType,ClientBusinessObject cbo ,boolean isEdit) throws VciBaseException{ Field pkField = WebUtil.getPkFieldForObj(obj.getClass()); if(pkField == null){ throw new VciBaseException("{0}绫讳腑娌℃湁瀹氫箟涓婚敭灞炴��",new Object[]{obj.getClass()}); @@ -1684,9 +1681,9 @@ if(list==null){ throw new VciBaseException(VciBaseException.paramNull); } - Set<com.vci.client.bof.ClientBusinessObject> allUpdateCbos = new HashSet<com.vci.client.bof.ClientBusinessObject>(); - Set<com.vci.client.bof.ClientBusinessObject> allDeleteCbos = new HashSet<com.vci.client.bof.ClientBusinessObject>(); - Set<com.vci.client.bof.ClientBusinessObject> allAddCbos = new HashSet<com.vci.client.bof.ClientBusinessObject>(); + Set<ClientBusinessObject> allUpdateCbos = new HashSet<ClientBusinessObject>(); + Set<ClientBusinessObject> allDeleteCbos = new HashSet<ClientBusinessObject>(); + Set<ClientBusinessObject> allAddCbos = new HashSet<ClientBusinessObject>(); Map<String,String> btmOidsMap = new HashMap<String, String>(); for(T obj : list){ String btmType = WebUtil.getBtmTypeByObject(obj.getClass()); @@ -1707,7 +1704,7 @@ } btmOidsMap.put(btmType, tempOids); } - List<com.vci.client.bof.ClientBusinessObject> needUpdateCbos = new ArrayList<com.vci.client.bof.ClientBusinessObject>(); + List<ClientBusinessObject> needUpdateCbos = new ArrayList<ClientBusinessObject>(); Iterator<String> it = btmOidsMap.keySet().iterator(); while(it.hasNext()){ String btmType = it.next(); @@ -1725,11 +1722,11 @@ } //涓婚敭 Object pkValue = WebUtil.getValueFromField(pkField.getName(), obj); - com.vci.client.bof.ClientBusinessObject cbo = null; + ClientBusinessObject cbo = null; if(pkValue == null || (pkValue instanceof String && WebUtil.isNull(pkValue.toString()))){ continue; }else{ - for(com.vci.client.bof.ClientBusinessObject tempCbo : needUpdateCbos){ + for(ClientBusinessObject tempCbo : needUpdateCbos){ if(tempCbo.getOid().equalsIgnoreCase(pkValue.toString().trim())){ cbo = tempCbo; break; @@ -1738,7 +1735,7 @@ } String btmType = WebUtil.getBtmTypeByObject(obj.getClass()); //鎷疯礉涔嬪墠鍏堟竻闄ゅ凡缁忔湁鐨勫�� - cbo.getBusinessObject().newAttrValList = new com.vci.corba.omd.data.AttributeValue[0]; + cbo.getBusinessObject().newAttrValList = new AttributeValue[0]; setValueToCbo(obj,btmType,cbo,true); allUpdateCbos.add(cbo); } @@ -2246,7 +2243,7 @@ * @throws VciBaseException 杞崲鍑洪敊浼氭姏鍑哄紓甯� */ @Override - public Map cbo2Map(com.vci.client.bof.ClientBusinessObject cbo) throws VciBaseException { + public Map cbo2Map(ClientBusinessObject cbo) throws VciBaseException { Map<String,String> map = new HashMap<String, String>(); WebUtil.copyValueToMapFromCbos(cbo, map); return map; @@ -2260,9 +2257,9 @@ * @throws VciBaseException 杞崲鍑洪敊浼氭姏鍑哄紓甯� */ @Override - public List<com.vci.client.bof.ClientBusinessObject> map2Cbos(List<Map> mapList) + public List<ClientBusinessObject> map2Cbos(List<Map> mapList) throws VciBaseException { - List<com.vci.client.bof.ClientBusinessObject> cboList = new ArrayList<com.vci.client.bof.ClientBusinessObject>(); + List<ClientBusinessObject> cboList = new ArrayList<ClientBusinessObject>(); for(Map map : mapList){ cboList.add(map2Cbo(map)); } @@ -2277,8 +2274,8 @@ * @throws VciBaseException 杞崲鍑洪敊浼氭姏鍑哄紓甯� */ @Override - public com.vci.client.bof.ClientBusinessObject map2Cbo(Map map) throws VciBaseException { - com.vci.client.bof.ClientBusinessObject cbo = new com.vci.client.bof.ClientBusinessObject(); + public ClientBusinessObject map2Cbo(Map map) throws VciBaseException { + ClientBusinessObject cbo = new ClientBusinessObject(); WebUtil.copyValueToCboFromMap(cbo, map); return cbo; } @@ -2311,13 +2308,7 @@ deleteReferAttrInCbo(batchCbos.getDeleteCbos()); } try { -// platformClientUtil.getBOFactoryService().batchCUDBOLO(new BusinessObjectListHolder(cboArray2Bo(batchCbos.getCreateCboArray())), -// new LinkObjectListHolder(cloArray2Lo(batchCbos.getCreateCloArray())), -// new BusinessObjectListHolder(cboArray2Bo(batchCbos.getUpdateCboArray())), -// new LinkObjectListHolder(cloArray2Lo(batchCbos.getUpdateCloArray())), -// cboArray2Bo(batchCbos.getDeleteCboArray()), cloArray2Lo(batchCbos.getDeleteCloArray())); -// new BusinessObjectListHolder(cboArray2Bo(batchCbos.getCreateCboArray())) - ServiceProvider.getBOFService().batchCUDBOLO(cboArray2Bo(batchCbos.getCreateCboArray()), + platformClientUtil.getBOFactoryService().batchCUDBOLO(cboArray2Bo(batchCbos.getCreateCboArray()), cloArray2Lo(batchCbos.getCreateCloArray()), cboArray2Bo(batchCbos.getUpdateCboArray()), cloArray2Lo(batchCbos.getUpdateCloArray()), @@ -2332,11 +2323,11 @@ * @param cbos 瀹㈡埛绔璞� * @return 涓氬姟瀵硅薄 */ - private com.vci.corba.omd.data.BusinessObject[] cboArray2Bo(ClientBusinessObject[] cbos){ + private BusinessObject[] cboArray2Bo(ClientBusinessObject[] cbos){ if(cbos == null ||cbos.length == 0){ - return new com.vci.corba.omd.data.BusinessObject[0]; + return new BusinessObject[0]; } - com.vci.corba.omd.data.BusinessObject[] bos = new com.vci.corba.omd.data.BusinessObject[cbos.length]; + BusinessObject[] bos = new BusinessObject[cbos.length]; for(int i = 0; i < cbos.length; i++){ bos[i] = cbos[i].getBusinessObject(); } @@ -2348,11 +2339,11 @@ * @param clos 瀹㈡埛绔璞� * @return 涓氬姟瀵硅薄 */ - private com.vci.corba.omd.data.LinkObject[] cloArray2Lo(com.vci.client.bof.ClientLinkObject[] clos){ + private LinkObject[] cloArray2Lo(ClientLinkObject[] clos){ if(clos == null ||clos.length == 0){ - return new com.vci.corba.omd.data.LinkObject[0]; + return new LinkObject[0]; } - com.vci.corba.omd.data.LinkObject[] bos = new com.vci.corba.omd.data.LinkObject[clos.length]; + LinkObject[] bos = new LinkObject[clos.length]; for(int i = 0; i < clos.length; i++){ bos[i] = clos[i].getLinkObject(); } @@ -2366,11 +2357,11 @@ private void deleteReferAttrInCbo(Set<ClientBusinessObject> cbos){ if(cbos !=null){ for(ClientBusinessObject cbo : cbos){ - com.vci.corba.omd.data.BusinessObject bo = cbo.getBusinessObject(); - List<com.vci.corba.omd.data.AttributeValue> newAttr = new ArrayList<com.vci.corba.omd.data.AttributeValue>(); + BusinessObject bo = cbo.getBusinessObject(); + List<AttributeValue> newAttr = new ArrayList<AttributeValue>(); if (bo.newAttrValList != null) { for (int i = 0; i < bo.newAttrValList.length; ++i) { - com.vci.corba.omd.data.AttributeValue av = bo.newAttrValList[i]; + AttributeValue av = bo.newAttrValList[i]; if (WebUtil.isNormalAttr(av.attrName)) { if(av.attrVal == null){ av.attrVal = ""; @@ -2379,7 +2370,7 @@ } } } - bo.newAttrValList = newAttr.toArray(new com.vci.corba.omd.data.AttributeValue[0]); + bo.newAttrValList = newAttr.toArray(new AttributeValue[0]); cbo.setBusinessObject(bo); } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebHomeTaskServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebHomeTaskServiceImpl.java index 6a9d61a..e2f6da0 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebHomeTaskServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebHomeTaskServiceImpl.java @@ -50,7 +50,6 @@ * @return 浠诲姟姹囨�荤殑鏁伴噺 */ @Override - @Cacheable(value = VCI_USER,key = "'userHomeTask'.concat(#root.target.getCurrentUserOid())", unless = "#result == null") public List<WebHomeTaskActionVO> listMyHomeTask() { List<WebHomeTaskActionVO> actionVOS = new ArrayList<>(); List<WebHomeTaskActionDO> allActions = boService.queryObject(WebHomeTaskActionDO.class,null); diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/BusAnnotationUtil.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/BusAnnotationUtil.java index af60ece..f97f961 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/BusAnnotationUtil.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/BusAnnotationUtil.java @@ -1,7 +1,5 @@ package com.vci.web.util; -import com.vci.starter.web.annotation.bus.VciLoginBefore; -import com.vci.starter.web.annotation.bus.VciLoginPlugin; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.util.ApplicationContextProvider; import org.slf4j.Logger; diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/PlatformClientUtil.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/PlatformClientUtil.java index fab4471..11f7abf 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/PlatformClientUtil.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/PlatformClientUtil.java @@ -4,11 +4,14 @@ import com.vci.corba.bofactory.BOFactoryServicePrx; import com.vci.corba.common.PLException; import com.vci.corba.framework.FrameworkServicePrx; +import com.vci.corba.log.LogServicePrx; import com.vci.corba.omd.atm.AttPoolServicePrx; import com.vci.corba.omd.btm.BTMServicePrx; +import com.vci.corba.omd.data.AttributeValue; import com.vci.corba.omd.etm.EnumServicePrx; import com.vci.corba.omd.lcm.LifeCycleServicePrx; import com.vci.corba.omd.ltm.LinkTypeServicePrx; +import com.vci.corba.omd.qtm.QTDServicePrx; import com.vci.corba.omd.stm.StatePoolServicePrx; import com.vci.corba.omd.vrm.VersionRuleServicePrx; import com.vci.corba.portal.PortalServicePrx; @@ -125,7 +128,6 @@ */ public EnumServicePrx getEnumService() throws PLException { return ServiceProvider.getOMDService().getEnumService(); -// return EnumServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(ENUM_SERVICE_NAME)); } /** @@ -134,7 +136,6 @@ */ public VersionRuleServicePrx getVersionService() throws PLException { return ServiceProvider.getOMDService().getVerRuleService(); -// return VersionRuleServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(VERSION_SERVICE_NAME)); } /** @@ -143,7 +144,6 @@ */ public AttPoolServicePrx getAttributeService() throws PLException { return ServiceProvider.getOMDService().getAttributeService(); -// return AttPoolServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(ATTRIBUTE_SERVICE_NAME)); } /** @@ -152,7 +152,6 @@ */ public BTMServicePrx getBtmService() throws PLException { return ServiceProvider.getOMDService().getBTMService(); -// return BTMServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(BTM_SERVICE_NAME)); } /** @@ -161,7 +160,6 @@ */ public LinkTypeServicePrx getLinkTypeService() throws PLException { return ServiceProvider.getOMDService().getLinkTypeService(); -// return LinkTypeServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(LINK_SERVICE_NAME)); } /** @@ -170,7 +168,6 @@ */ public PortalServicePrx getPortalService(){ return ServiceProvider.getUIService(); -// return PortalServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(PORTAL_SERVICE_NAME)); } /** @@ -179,7 +176,6 @@ */ public ObjectQueryServicePrx getQueryService(){ return ServiceProvider.getOQService(); -// return QTServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(QUERY_SERVICE_NAME)); } /** @@ -189,7 +185,31 @@ */ public VolumeServicePrx getVolumeService(String volumeName){ return ServiceProvider.getVolumeService(volumeName); -// return VolumnFactoryHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByUrlAndServiceName(serverUrl,volumeName)); } + /** + * 鏌ヨ妯℃澘鏈嶅姟 + * @return 鍗锋湇鍔$殑鐨勫璞� + */ + public QTDServicePrx getQTDService() throws PLException { + return ServiceProvider.getOMDService().getQTDService(); + } + + /** + * 鏌ヨ妯℃澘鏈嶅姟 + * @param sql sql璇彞 + * @param attrVals 鍗犱綅绗︾殑鍊� + * @return 鍗锋湇鍔$殑鐨勫璞� + */ + public String[][] getSqlQueryService(String sql, AttributeValue[] attrVals) throws PLException { + return ServiceProvider.getBOFService().getSqlQueryResult(sql, attrVals); + } + + /** + * 鑾峰彇鐧诲綍鏃ュ織鏈嶅姟 + * @Return com.vci.corba.log.LogServicePrx + */ + public LogServicePrx getLogService(){ + return ServiceProvider.getLogService(); + } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/resources/application-dev.yml b/Source/plt-web/plt-web-parent/plt-web/src/main/resources/application-dev.yml index a0b685b..5b48f4c 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/resources/application-dev.yml +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/resources/application-dev.yml @@ -38,11 +38,11 @@ spring: # redis閰嶇疆 redis: ###### redis 閰嶇疆 - enabled: false #true锛屽惎鐢╮edi锛宖alse涓嶅惎鐢紝榛樿false,閰嶇疆鏂囦欢娌℃湁杩欎簺榛樿涓嶅惎鐢╮edis - host: vciserver # ip鍦板潃 - database: 0 # redis鏁版嵁搴� 0-15 + enabled: true #true锛屽惎鐢╮edi锛宖alse涓嶅惎鐢紝榛樿false,閰嶇疆鏂囦欢娌℃湁杩欎簺榛樿涓嶅惎鐢╮edis + host: localhost # ip鍦板潃 + database: 2 # redis鏁版嵁搴� 0-15 port: 6379 # 绔彛鍙� - password: vcitest # 鏃犲瘑鐮佷笉濉� + password: 123456 # 鏃犲瘑鐮佷笉濉� timeout: 30000s # 杩炴帴瓒呮椂鏃堕棿 锛堥粯璁�1澶╋級 lettuce: shutdown-timeout: 100ms # 鍏抽棴瓒呮椂鏃堕棿 榛樿 100ms diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages.properties b/Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages.properties index c9c85b1..ebf5c64 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages.properties +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages.properties @@ -71,6 +71,11 @@ lessMinLength=\u5BC6\u7801\u4E0D\u6EE1\u8DB3\u6700\u4F4E\u957F\u5EA6\u8981\u6C42\uFF0C\u9700\u8981{0}\u957F\u5EA6 moreMaxLength=\u5BC6\u7801\u4E0D\u6EE1\u8DB3\u6700\u5927\u957F\u5EA6\u8981\u6C42\uFF0C\u4EC5\u80FD\u8F93\u5165{0}\u957F\u5EA6 passwordRemainDay=\u5BC6\u7801\u5373\u5C06\u8FC7\u671F\uFF0C\u8BF7\u5C3D\u5FEB\u4FEE\u6539 +systemError=\u7CFB\u7EDF\u5F02\u5E38 +loginSuccess=\u767B\u5F55\u6210\u529F +passwordInit=\u8D26\u53F7\u5BC6\u7801\u4E3A\u521D\u59CB\u5BC6\u7801\uFF0C\u9700\u8981\u4FEE\u6539\u540E\u624D\u80FD\u767B\u5F55 +passwordExpire=\u5BC6\u7801\u5DF2\u8FC7\u671F +passwordPolicyUpdated=\u5BC6\u7801\u7B56\u7565\u5DF2\u7ECF\u4FEE\u6539\uFF0C\u9700\u4FEE\u6539\u8D26\u53F7\u5BC6\u7801 #########\u7CFB\u7EDF\u8D44\u6E90\u76F8\u5173###### com.vci.web.menu.noHasFunction= {0}\u6CA1\u6709\u4EFB\u4F55\u7684\u6743\u9650 diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages_zh_CN.properties b/Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages_zh_CN.properties index 9272b11..1d24672 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages_zh_CN.properties +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/resources/i18n/messages_zh_CN.properties @@ -71,6 +71,11 @@ lessMinLength=\u5BC6\u7801\u4E0D\u6EE1\u8DB3\u6700\u4F4E\u957F\u5EA6\u8981\u6C42\uFF0C\u9700\u8981{0}\u957F\u5EA6 moreMaxLength=\u5BC6\u7801\u4E0D\u6EE1\u8DB3\u6700\u5927\u957F\u5EA6\u8981\u6C42\uFF0C\u4EC5\u80FD\u8F93\u5165{0}\u957F\u5EA6 passwordRemainDay=\u5BC6\u7801\u5373\u5C06\u8FC7\u671F\uFF0C\u8BF7\u5C3D\u5FEB\u4FEE\u6539 +systemError=\u7CFB\u7EDF\u5F02\u5E38 +loginSuccess=\u767B\u5F55\u6210\u529F +passwordInit=\u8D26\u53F7\u5BC6\u7801\u4E3A\u521D\u59CB\u5BC6\u7801\uFF0C\u9700\u8981\u4FEE\u6539\u540E\u624D\u80FD\u767B\u5F55 +passwordExpire=\u5BC6\u7801\u5DF2\u8FC7\u671F +passwordPolicyUpdated=\u5BC6\u7801\u7B56\u7565\u5DF2\u7ECF\u4FEE\u6539\uFF0C\u9700\u4FEE\u6539\u8D26\u53F7\u5BC6\u7801 #########\u7CFB\u7EDF\u8D44\u6E90\u76F8\u5173###### com.vci.web.menu.noHasFunction= {0}\u6CA1\u6709\u4EFB\u4F55\u7684\u6743\u9650 -- Gitblit v1.9.3