From dba1e53cd7652f1b973ffec118e5b3312278c814 Mon Sep 17 00:00:00 2001
From: dangsn <dangsn@chicecm.com>
Date: 星期二, 11 六月 2024 15:45:24 +0800
Subject: [PATCH] 调整获取用户的接口
---
Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java | 11 ++
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/EnumIdConstant.java | 5 +
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java | 86 ++++++++++++++++++---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/enumpck/UserTypeEnum.java | 116 +++++++++++++++++++++++++++++
4 files changed, 204 insertions(+), 14 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java
index 1af32e7..76d5f81 100644
--- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java
+++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java
@@ -1929,4 +1929,15 @@
}
return new String(c);
}
+
+ /**
+ * 灏唖tring闆嗗悎杞负stirng鏁扮粍
+ * @param strCollection string闆嗗悎
+ * @return string鏁扮粍
+ */
+ public static String[] collection2StrArr(Collection<String> strCollection){
+ String[] strArr = new String[strCollection.size()];
+ strCollection.toArray(strArr);
+ return strArr;
+ }
}
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 b0ae3c0..45314e6 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
@@ -3,10 +3,12 @@
import com.vci.client.common.providers.ServiceProvider;
import com.vci.common.util.ThreeDES;
import com.vci.corba.common.PLException;
+import com.vci.corba.framework.data.UserInfo;
import com.vci.frameworkcore.compatibility.SmUserQueryServiceI;
import com.vci.frameworkcore.pagemodel.SmPasswordStrategyVO;
import com.vci.frameworkcore.pagemodel.SmUserVO;
import com.vci.starter.web.enumpck.BooleanEnum;
+import com.vci.starter.web.enumpck.UserSecretEnum;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.starter.web.pagemodel.PageHelper;
@@ -14,7 +16,9 @@
import com.vci.starter.web.pagemodel.TreeQueryObject;
import com.vci.starter.web.util.BeanUtil;
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.enumpck.UserTypeEnum;
import com.vci.web.model.SmPasswordStrategyDO;
import com.vci.web.model.SmUserDO;
import com.vci.web.service.WebBoServiceI;
@@ -22,7 +26,6 @@
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -80,13 +83,6 @@
public static final String QUERY_FIELD_ROLE = "roleUser.plroleuid";
/**
- * 鑷紩鐢�
- */
- @Autowired(required = false)
- @Lazy
- private SmUserQueryServiceI self;
-
- /**
* 鏍规嵁鐢ㄦ埛鍚嶈幏鍙栫敤鎴风殑瀵硅薄锛屼笉鍖哄垎澶у皬鍐�
* @param userId 鐢ㄦ埛鍚�
* @return 鐢ㄦ埛鐨勬樉绀哄璞★紝濡傛灉鐢ㄦ埛涓嶅瓨鍦ㄥ垯杩斿洖null锛屼笉浼氭姏鍑哄紓甯�
@@ -95,7 +91,41 @@
@Override
public SmUserVO getUserByUserId(String userId) throws VciBaseException {
WebUtil.alertNotNull(userId,"鐢ㄦ埛鍚�");
- return getUserByField("plusername",userId);
+ try {
+ UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByUserName(userId);
+ return userInfo2VO(userInfo);
+ } catch (PLException e) {
+ throw new VciBaseException("鐧诲綍鏃讹紝鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛�"+e.getMessage());
+ }
+ }
+
+ /**
+ * 涓氬姟鏁版嵁杞崲涓烘樉绀哄璞�
+ * @param userInfo 骞冲彴杩斿洖鐨勪笟鍔℃暟鎹�
+ * @return 鐢ㄦ埛鏄剧ず瀵硅薄
+ */
+ private SmUserVO userInfo2VO(UserInfo userInfo) {
+ SmUserVO smUserVO = new SmUserVO();
+ smUserVO.setOid(userInfo.id);
+ smUserVO.setId(userInfo.userName);
+ smUserVO.setName(userInfo.trueName);
+ smUserVO.setSecretGrade(userInfo.secretGrade);
+ smUserVO.setSecretGradeText(UserSecretEnum.getSecretText(smUserVO.getSecretGrade()));
+ smUserVO.setUserType(String.valueOf(userInfo.userType));
+ smUserVO.setUserTypeText(UserTypeEnum.getTextByValue(smUserVO.getUserType()));
+ smUserVO.setDescription(userInfo.desc);
+ smUserVO.setEmail(userInfo.email);
+ if(userInfo.status == 0){
+ smUserVO.setLockFlag(false);
+ }else{
+ smUserVO.setLockFlag(true);
+ }
+ smUserVO.setCreator(userInfo.createUser);
+ smUserVO.setCreateTime(VciDateUtil.long2Date(userInfo.createTime));
+ smUserVO.setLastModifier(userInfo.updateUser);
+ smUserVO.setLastLoginTime(VciDateUtil.long2Date(userInfo.updateTime));
+ smUserVO.setLastModifyPasswordTime(VciDateUtil.long2Date(userInfo.pwdUpdateTime));
+ return smUserVO;
}
/**
@@ -166,7 +196,12 @@
@Override
public List<SmUserVO> listUserByUserIds(Collection<String> userIdCollections)throws VciBaseException {
WebUtil.alertNotNull(userIdCollections,"鐢ㄦ埛鍚嶉泦鍚�");
- return listUserByField("plusername",userIdCollections);
+ try {
+ UserInfo[] userInfo = platformClientUtil.getFrameworkService().fetchUserInfoByNames(VciBaseUtil.collection2StrArr(userIdCollections));
+ return userInfoArr2VO(userInfo);
+ } catch (PLException e) {
+ throw new VciBaseException("鑾峰彇鐢ㄦ埛澶辫触锛�"+e.getMessage());
+ }
}
/**
* 鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇鐢ㄦ埛鐨勪俊鎭�
@@ -177,7 +212,12 @@
@Override
public SmUserVO getUserByUserOid(String userOid) throws VciBaseException {
WebUtil.alertNotNull(userOid,"鐢ㄦ埛涓婚敭");
- return getUserByField("pluid",userOid);
+ try {
+ UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByoid(userOid);
+ return userInfo2VO(userInfo);
+ } catch (PLException e) {
+ throw new VciBaseException("鑾峰彇鐢ㄦ埛澶辫触锛�"+e.getMessage());
+ }
}
/**
* 鎵归噺鑾峰彇鐢ㄦ埛鐨勪俊鎭� 锛堟牴鎹敤鎴蜂富閿級
@@ -189,7 +229,25 @@
public List<SmUserVO> listUserByUserOids(
Collection<String> userOidCollections) throws VciBaseException {
WebUtil.alertNotNull(userOidCollections,"鐢ㄦ埛涓婚敭闆嗗悎");
- return listUserByField("pluid",userOidCollections);
+ try {
+ UserInfo[] userInfoArr = platformClientUtil.getFrameworkService().getUserObjectByoids(VciBaseUtil.collection2StrArr(userOidCollections));
+ return userInfoArr2VO(userInfoArr);
+ } catch (PLException e) {
+ throw new VciBaseException("鑾峰彇鐢ㄦ埛淇℃伅澶辫触:"+e.getMessage());
+ }
+ }
+
+ /**
+ * 涓氬姟鏁版嵁鏁扮粍杞樉绀哄璞¢泦鍚�
+ * @param userInfoArr 涓氬姟鏁版嵁鏁扮粍
+ * @return 鏄剧ず瀵硅薄闆嗗悎
+ */
+ private List<SmUserVO> userInfoArr2VO(UserInfo[] userInfoArr) {
+ List<SmUserVO> userVOList = new ArrayList<>();
+ for(UserInfo userInfo : userInfoArr){
+ userVOList.add(userInfo2VO(userInfo));
+ }
+ return userVOList;
}
/**
@@ -351,7 +409,7 @@
*/
@Override
public String getUserNameByUserId(String userId) {
- SmUserVO userVO = self.getUserByUserId(userId);
+ SmUserVO userVO = getUserByUserId(userId);
return userVO == null?"":userVO.getName();
}
/**
@@ -361,7 +419,7 @@
*/
@Override
public String getUserNameByUserOid(String userOid) {
- SmUserVO userVO = self.getUserByUserOid(userOid);
+ SmUserVO userVO = getUserByUserOid(userOid);
return userVO.getName();
}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/EnumIdConstant.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/EnumIdConstant.java
index d154c6f..2e893e5 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/EnumIdConstant.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/constant/EnumIdConstant.java
@@ -57,4 +57,9 @@
*/
public static final String CODE_DATE_VALUE_TYPE = "codeDateValueType";
+ /**
+ * 鐢ㄦ埛绫诲瀷鏋氫妇
+ */
+ public static final String USER_TYPE_ENUM = "userTypeEnum";
+
}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/enumpck/UserTypeEnum.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/enumpck/UserTypeEnum.java
new file mode 100644
index 0000000..d8d8dc0
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/enumpck/UserTypeEnum.java
@@ -0,0 +1,116 @@
+package com.vci.web.enumpck;
+
+import com.vci.starter.web.annotation.VciEnum;
+import com.vci.starter.web.enumpck.BaseEnum;
+import com.vci.web.constant.EnumIdConstant;
+
+/**
+ * @Description
+ * @Author dangsn
+ * @Date 2024/6/11 15:00
+ */
+@VciEnum(name = EnumIdConstant.USER_TYPE_ENUM,text = "鐢ㄦ埛绫诲瀷鏋氫妇")
+public enum UserTypeEnum implements BaseEnum {
+
+ /**
+ * 瓒呯骇绠$悊鍛�
+ */
+ SUPPER_ADMIN("0","瓒呯骇绠$悊鍛�"),
+
+ /**
+ * 涓夊憳绠$悊鍛�/涓氬姟绠$悊鍛�
+ */
+ ADMIN("1","绠$悊鍛�"),
+
+ /**
+ * 鏅�氱敤鎴�
+ */
+ USER("2","鏅�氱敤鎴�"),
+
+ /**
+ * 瀹汉
+ */
+ GUEST("3","璁垮");
+
+ /**
+ * 鍊�
+ */
+ private String value;
+
+ /**
+ * 鏄剧ず鏂囨湰
+ */
+ private String text;
+
+ /**
+ * 鏋勯�犲嚱鏁�
+ * @param value 鍊�
+ * @param text 鏄剧ず鏂囨湰
+ */
+ private UserTypeEnum(String value,String text){
+ this.value = value;
+ this.text = text;
+ }
+
+ /**
+ * 鑾峰彇鏋氫妇鍊�
+ *
+ * @return 鏋氫妇鍊�
+ */
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * 鑾峰彇鏄剧ず鏂囨湰
+ *
+ * @return 鏄剧ず鏂囨湰
+ */
+ @Override
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * 鏍规嵁鍚嶇О鑾峰彇瀵瑰簲鐨勬灇涓惧��
+ * @param text 鍚嶇О
+ * @return 鏋氫妇鍊�
+ */
+ public static String getValueByText(String text){
+ for(UserTypeEnum wenum : UserTypeEnum.values()){
+ if(wenum.getText().equalsIgnoreCase(text)){
+ return wenum.getValue();
+ }
+ }
+ return "";
+ }
+
+ /**
+ * 鏍规嵁鏋氫妇鍊艰幏鍙栧悕绉�
+ * @param value 鏋氫妇鍊�
+ * @return 鍚嶇О
+ */
+ public static String getTextByValue(String value){
+ for(UserTypeEnum wenum : UserTypeEnum.values()){
+ if(wenum.getValue().equalsIgnoreCase(value)){
+ return wenum.getText();
+ }
+ }
+ return "";
+ }
+
+ /**
+ * 鏍规嵁鏋氫妇鍊艰幏鍙栨灇涓惧璞�
+ * @param value 鏋氫妇鍊�
+ * @return 瀵瑰簲鐨勬灇涓惧璞★紝涓嶅尮閰嶇殑鏃跺�欒繑鍥瀗ull
+ */
+ public static UserTypeEnum forValue(String value){
+ for(UserTypeEnum wenum : UserTypeEnum.values()){
+ if(wenum.getValue().equalsIgnoreCase(value)){
+ return wenum;
+ }
+ }
+ return null;
+ }
+}
--
Gitblit v1.9.3