From 19464eb021cfa547dfbfba45a9c896837f7d0d98 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 18 七月 2024 15:35:15 +0800
Subject: [PATCH] 修改密码,登录接口增加密码解密逻辑(前端传递的密码加密传输);枚举和枚举项:查询、增加、修改、删除接口上传。

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java |  244 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 220 insertions(+), 24 deletions(-)

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 c9cb8d8..2173b0a 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
@@ -4,6 +4,8 @@
 import com.vci.corba.omd.data.BusinessObject;
 import com.vci.corba.omd.etm.EnumItem;
 import com.vci.corba.omd.etm.EnumType;
+import com.vci.dto.OsEnumDTO;
+import com.vci.dto.OsEnumItemDTO;
 import com.vci.omd.utils.ObjectTool;
 import com.vci.starter.web.annotation.log.VciUnLog;
 import com.vci.starter.web.enumpck.UserSecretEnum;
@@ -17,9 +19,11 @@
 import com.vci.pagemodel.OsEnumItemVO;
 import com.vci.pagemodel.OsEnumVO;
 import com.vci.pagemodel.OsStatusVO;
+import com.vci.starter.web.util.WebThreadLocalUtil;
 import com.vci.web.service.OsEnumServiceI;
 import com.vci.web.service.OsLifeCycleServiceI;
 import com.vci.web.service.WebBoServiceI;
+import com.vci.web.util.Func;
 import com.vci.web.util.PlatformClientUtil;
 import com.vci.web.util.WebUtil;
 import org.apache.commons.lang3.StringUtils;
@@ -72,14 +76,12 @@
 	 */
 	private Logger logger = LoggerFactory.getLogger(getClass());
 
-
 	/**
 	 * 鍔犺浇鑷韩
 	 */
 	@Autowired(required = false)
 	@Lazy
 	private OsEnumServiceI self;
-
 
 	/**
 	 * 浣跨敤缂栧彿鑾峰彇鏋氫妇鏄庣粏
@@ -98,13 +100,14 @@
 			int userSecret = WebUtil.getInt(WebUtil.getCurrentUserSessionInfoNotException().getUserSecret());
 			List<OsEnumItemVO> itemVOS = new ArrayList<>();
 			if(enumVO!=null && !CollectionUtils.isEmpty(enumVO.getItems())){
-				itemVOS = enumVO.getItems().stream().filter(item->WebUtil.getInt(item.getId()) <= userSecret).collect(Collectors.toList());
+				itemVOS = enumVO.getItems().stream().filter(item->WebUtil.getInt(item.getValue()) <= userSecret).collect(Collectors.toList());
 			}
 			return itemVOS;
 		}else{
 			return enumVOMap.getOrDefault(enumCode.toLowerCase(),new OsEnumVO()).getItems();
 		}
 	}
+
 	/**
 	 * 鑾峰彇鏋氫妇鐨勫唴瀹�
 	 * @param enumCode 鏋氫妇鐨勭紪鍙凤紙鑻辨枃鍚嶇О锛�
@@ -217,6 +220,197 @@
 	}
 
 	/**
+	 * 鏋氫妇瀹氫箟鍒楄〃鏌ヨ锛堢紦瀛橀噷闈㈡壘涓斿甫name鏌ヨ鏉′欢锛�
+	 * @param enumName
+	 * @return 鏋氫妇鐨勬樉绀哄璞�
+	 */
+	@Override
+	public List<OsEnumVO> getEnumTypeList(String enumName) throws PLException {
+		return enumDO2VOs(Arrays.stream(platformClientUtil.getEnumService().getEnumTypes(enumName,1,1)).collect(Collectors.toList()));
+	}
+
+	/**
+	 * 鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥�
+	 * @param enumName
+	 * @return
+	 * @throws PLException
+	 */
+	@Override
+	public List<OsEnumVO> getUsedEnumList(String enumName) throws PLException {
+		return null;
+	}
+
+	/**
+	 * 鏍规嵁鏋氫妇鑻辨枃鍚嶇О鑾峰彇鏋氫妇绫诲瀷
+	 * @param id
+	 * @return
+	 */
+	@Override
+	public OsEnumVO getEnumTypeById(String id) throws PLException {
+		if (Func.isBlank(id)) {
+			return null;
+		}
+		EnumType enumType = platformClientUtil.getEnumService().getEnumTypeByName(id);
+		return enumDO2VO(enumType);
+	}
+
+	/**
+	 * 鏂板鏋氫妇绫诲瀷
+	 * @param osEnumDTO
+	 * @return
+	 */
+	@Override
+	public boolean addEnumType(OsEnumDTO osEnumDTO) throws PLException {
+		//1銆佹灇涓惧�煎垽绌�
+		VciBaseUtil.alertNotNull(
+		osEnumDTO,"鏋氫妇绫诲瀷瀵硅薄",
+			osEnumDTO.getId(),"鏋氫妇鍚嶇О",
+			osEnumDTO.getEnumValueDataType(),"鏋氫妇鐨勭被鍨�",
+			osEnumDTO.getLength(),"鏋氫妇闀垮害"
+		);
+		//2銆佹灇涓剧被鍨嬪悕绉版鍒欐牎楠屽拰鏌ラ噸
+		if(!osEnumDTO.getId().matches("^[A-Za-z]+$")){
+			throw new PLException("500", new String[] { "鏋氫妇鍚嶇О鍙兘涓鸿嫳鏂囧瓧姣�!"});
+		}
+		OsEnumVO osEnumVO = this.getEnumTypeById(osEnumDTO.getId());
+		if(Func.isNotEmpty(osEnumVO) && Func.isNotBlank(osEnumVO.getOid())){
+			throw new PLException("500", new String[] { "鏋氫妇鍚嶇О宸插瓨鍦紝璇蜂慨鏀规灇涓惧悕绉�!"});
+		}
+		//鏋氫妇椤瑰悕绉板垽閲嶇瓑鎿嶄綔
+		checkOsEnumItem(osEnumDTO);
+		//榛樿鍊煎鐞�
+		String userId = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+		osEnumDTO.setCreator(userId);
+		osEnumDTO.setLastModifier(userId);
+		return platformClientUtil.getEnumService().addEnumType(this.osEnumDTO2EnumType(osEnumDTO));
+	}
+
+	/**
+	 * 淇敼鏋氫妇绫诲瀷
+	 * @param osEnumDTO
+	 * @return
+	 */
+	@Override
+	public boolean updateEnumType(OsEnumDTO osEnumDTO) throws PLException {
+		//1銆佹灇涓惧�煎垽绌�
+		VciBaseUtil.alertNotNull(
+				osEnumDTO,"鏋氫妇绫诲瀷瀵硅薄",
+				osEnumDTO.getOid(),"鏋氫妇鐨勪富閿�",
+				osEnumDTO.getId(),"鏋氫妇鍚嶇О",
+				osEnumDTO.getEnumValueDataType(),"鏋氫妇鐨勭被鍨�",
+				osEnumDTO.getLength(),"鏋氫妇闀垮害"
+		);
+		//2銆佹灇涓剧被鍨嬪悕绉�(鍚嶇О涓嶅厑璁镐慨鏀�)鎵�浠ュ彲浠ョ敤鍚嶇О鏌ヨ鏄惁瀛樺湪
+		OsEnumVO osEnumVO = this.getEnumTypeById(osEnumDTO.getId());
+		if(Func.isEmpty(osEnumVO) || Func.isBlank(osEnumVO.getOid())){
+			throw new PLException("500", new String[] { "褰撳墠淇敼鏋氫妇瀵硅薄涓嶅瓨鍦紝璇峰埛鏂板悗閲嶈瘯!"});
+		}
+		//3銆佹灇涓鹃」鍒ら噸锛屽拰闀垮害绛夋牎楠�
+		checkOsEnumItem(osEnumDTO);
+		//灏唎sEnumVO涓殑榛樿鍊艰祴鍊肩粰osEnumDTO瀵硅薄
+		String userId = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+		osEnumDTO.setLastModifier(userId);
+		osEnumDTO.setCreator(osEnumVO.getCreator());
+		osEnumDTO.setCreateTime(osEnumVO.getCreateTime());
+		//淇敼鍜屽垹闄ゆ椂ts鍙傛暟涓哄墠绔繀浼犲弬鏁�
+		return platformClientUtil.getEnumService().modifyEnumType(osEnumDTO2EnumType(osEnumDTO));
+	}
+
+	/**
+	 * 鍒犻櫎鏋氫妇绫诲瀷(鍖呭惈鍒犻櫎鏋氫妇椤瑰姛鑳�)
+	 * @param osEnumDTOS
+	 * @return
+	 */
+	@Override
+	public boolean deleteEnumTypes(List<OsEnumDTO> osEnumDTOS) throws PLException {
+		VciBaseUtil.alertNotNull(osEnumDTOS,"寰呭垹闄ょ殑鏋氫妇鍒楄〃");
+		//骞冲彴鐨刣eleteEnumTypes鏂规硶蹇呬紶涓変釜鍙傛暟锛宱id銆乶ame鍜宼s
+		List<EnumType> enumTypes = new ArrayList<>();
+		for(OsEnumDTO osEnumDTO : osEnumDTOS){
+			//oid鍜宼s鍒ょ┖
+			String oid = osEnumDTO.getOid();
+			//name涓昏鐢ㄦ潵瀵圭紦瀛樻暟鎹垹闄�
+			String name = osEnumDTO.getName();
+			Date ts = osEnumDTO.getTs();
+			if(Func.isBlank(oid) || Func.isBlank(name) || Func.isEmpty(ts)){
+				throw new PLException("500",new String[]{"寰呭垹闄ょ殑鏋氫妇鍒楄〃涓富閿�恛id銆戝拰璋冩暣鏃堕棿銆恡s銆戜笉鑳戒负绌猴紒"});
+			}
+			EnumType enumType = new EnumType();
+			enumType.oid = oid;
+			enumType.name = name;
+			enumType.ts = Func.format(ts,VciDateUtil.DateTimeMillFormat);
+			enumTypes.add(enumType);
+		}
+		if(Func.isEmpty(enumTypes)){
+			return false;
+		}
+		return platformClientUtil.getEnumService().deleteEnumTypes(enumTypes.toArray(new EnumType[enumTypes.size()]));
+	}
+
+	/**
+	 * 鏋氫妇椤规牎楠�
+	 * @param osEnumDTO
+	 * @return 鏍¢獙澶辫触鐩存帴鎶涘嚭寮傚父锛屽惁鍒欎笉浼氬仛浠讳綍杩斿洖
+	 */
+	private void checkOsEnumItem(OsEnumDTO osEnumDTO) throws PLException {
+		List<OsEnumItemDTO> items = osEnumDTO.getItems();
+		if (Func.isNotEmpty(items)) {
+			//鑾峰彇姝e垯锛屼富瑕佹槸閽堝Integer绫诲瀷鐨勬椂鍊�
+			String regular = "Integer".equals(osEnumDTO.getEnumValueDataType()) ? "^[0-9]+$" : "";
+			//鍒╃敤set鐨刟dd杩斿洖鍊艰繘琛宯ame鍒ら噸
+			Set<String> uniqueNames = new HashSet<>();
+			for (OsEnumItemDTO item : items) {
+				// 鍒ゆ柇name灞炴�ф槸鍚︽湁閲嶅鐨勫��
+				if (!uniqueNames.add(item.getName())) {
+					throw new PLException("500", new String[] {"浠ヤ笅鏋氫妇椤瑰悕绉�: 銆�" + item.getName()+ "銆戦噸澶嶏紝璇蜂慨鏀规灇涓鹃」鍚嶅悗閲嶈瘯!"});
+				}
+				//鍒ゆ柇鏋氫妇鍊兼槸鍚﹁秴杩囪瀹氶暱搴�
+				if (item.getValue().length() > osEnumDTO.getLength()) {
+					throw new PLException("500", new String[] {"鏋氫妇椤瑰悕绉颁负锛氥��" + item.getName() + "銆戠殑鏋氫妇鍊奸暱搴︼紝瓒呰繃闄愬畾闀垮害銆�" + osEnumDTO.getLength() + "銆�"});
+				}
+				//鏋氫妇绫诲瀷姝e垯鏍¢獙
+				if(Func.isNotBlank(regular) && !item.getValue().matches(regular)){
+					throw new PLException("500", new String[] { "鏋氫妇鍊煎彧鑳戒负銆�" +
+							("String".equals(osEnumDTO.getEnumValueDataType()) ? "瀛楃涓�":"鏁村瀷") + "銆戠被鍨�!"});
+				}
+			}
+		}
+	}
+
+	/**
+	 * 鏂板钩鍙版灇涓綝TO瀵硅薄杞钩鍙癊numType瀵硅薄
+	 * @param osEnumDTO
+	 * @return
+	 */
+	private EnumType osEnumDTO2EnumType(OsEnumDTO osEnumDTO){
+		EnumType enumType = new EnumType();
+		enumType.oid = osEnumDTO.getOid();
+		enumType.name = osEnumDTO.getId();
+		enumType.label = osEnumDTO.getName();
+		enumType.length = osEnumDTO.getLength();
+		enumType.creator = osEnumDTO.getCreator();
+		enumType.ts = Func.format((Func.isNotEmpty(osEnumDTO.getTs()) ? osEnumDTO.getTs():new Date()),VciDateUtil.DateTimeMillFormat);
+		enumType.createTime = Func.isNotEmpty(osEnumDTO.getCreateTime()) ? osEnumDTO.getCreateTime().getTime():System.currentTimeMillis();
+		enumType.modifier = osEnumDTO.getLastModifier();
+		enumType.modifyTime = System.currentTimeMillis();
+		enumType.type = osEnumDTO.getEnumValueDataType();
+		//澶勭悊鏋氫妇椤�
+		List<EnumItem> enumItems = new ArrayList<>();
+		List<OsEnumItemDTO> items = osEnumDTO.getItems();
+		if(Func.isNotEmpty(items)){
+			items.stream().forEach(item->{
+				EnumItem enumItem = new EnumItem();
+				enumItem.name = item.getName();
+				enumItem.value = item.getValue();
+				enumItem.description = item.getDescription();
+				enumItems.add(enumItem);
+			});
+		}
+		enumType.items = enumItems.toArray(new EnumItem[enumItems.size()]);
+		return enumType;
+	}
+
+	/**
 	 * 鏌ヨ鎵�鏈夌殑鏋氫妇鏄犲皠
 	 *
 	 * @return key鏄灇涓剧殑鑻辨枃鍚嶇О
@@ -246,43 +440,45 @@
 	/**
 	 * 鏋氫妇鐨勬暟鎹璞¤浆鎹负鏄剧ず瀵硅薄
 	 *
-	 * @param enumItem 鏁版嵁瀵硅薄
+	 * @param enumType 鏁版嵁瀵硅薄
 	 * @return 鏄剧ず瀵硅薄
 	 */
 	@Override
-	public OsEnumVO enumDO2VO(EnumType enumItem) {
+	public OsEnumVO enumDO2VO(EnumType enumType) {
 		OsEnumVO enumVO = new OsEnumVO();
-		if(enumItem!=null){
-			enumVO.setOid(enumItem.oid);
-			enumVO.setCreator(enumItem.creator);
-			enumVO.setLastModifier(enumItem.modifier);
-			enumVO.setId(enumItem.name);
-			enumVO.setName(enumItem.label);
-			enumVO.setEnumValueDataType(enumItem.type);
-			enumVO.setLength((int) enumItem.length);
+		if(enumType!=null){
+			enumVO.setOid(enumType.oid);
+			enumVO.setCreator(enumType.creator);
+			enumVO.setLastModifier(enumType.modifier);
+			enumVO.setId(enumType.name);
+			enumVO.setName(enumType.label);
+			enumVO.setEnumValueDataType(enumType.type);
+			enumVO.setEnumValueDataTypeText("String".equalsIgnoreCase(enumType.type) ? "瀛楃涓�":"鏁村瀷");
+			enumVO.setLength((int) enumType.length);
 
 			try {
-				enumVO.setLastModifyTime(new Date(enumItem.createTime));
+				enumVO.setLastModifyTime(new Date(enumType.createTime));
 			} catch (Exception e) {
 				e.printStackTrace();
 			}
 			try {
-				enumVO.setCreateTime(new Date(enumItem.createTime));
+				enumVO.setCreateTime(new Date(enumType.createTime));
 			} catch (Exception e) {
 				e.printStackTrace();
 			}
 			try {
-				enumVO.setTs(VciDateUtil.str2Date(enumItem.ts,VciDateUtil.DateTimeMillFormat));
+				enumVO.setTs(VciDateUtil.str2Date(enumType.ts,VciDateUtil.DateTimeMillFormat));
 			} catch (Exception e) {
 				e.printStackTrace();
 			}
+			//鏋氫妇椤瑰鐞�
 			List<OsEnumItemVO> itemVOS = new ArrayList<>();
 			Map<String,String> itemVOMap = new HashMap<>();
-			if(enumItem.items!=null && enumItem.items.length > 0){
-				for(int i = 0 ; i < enumItem.items.length ; i ++){
+			if(enumType.items!=null && enumType.items.length > 0){
+				for(int i = 0 ; i < enumType.items.length ; i ++){
 					OsEnumItemVO enumItemVO = new OsEnumItemVO();
-					EnumItem enumChild = enumItem.items[i];
-					enumItemVO.setId(enumChild.value);
+					EnumItem enumChild = enumType.items[i];
+					enumItemVO.setValue(enumChild.value);
 					enumItemVO.setName(enumChild.name);
 					enumItemVO.setDescription(enumChild.description);
 					itemVOS.add(enumItemVO);
@@ -307,7 +503,7 @@
 		if(!CollectionUtils.isEmpty(enumItemVO)){
 			enumItemVO.forEach(itemVO->{
 				KeyValue keyValue = new KeyValue();
-				keyValue.setKey(itemVO.getId());
+				keyValue.setKey(itemVO.getValue());
 				keyValue.setValue(itemVO.getName());
 				keyValueList.add(keyValue);
 			});
@@ -421,7 +617,7 @@
 	}
 
 	/**
-	 * 鍙傜収鏋氫妇鐨勪俊鎭�
+	 * 鍙傜収鏋氫妇鐨勪俊鎭� 涓嶅缓璁娇鐢ㄨ繖涓柟娉曪紝鍥犱负鏄痵ql鎷兼帴鍋氱殑鏌ヨ
 	 *
 	 * @param conditionMap 鏌ヨ鏉′欢
 	 * @param pageHelper   鍒嗛〉
@@ -429,7 +625,7 @@
 	 */
 	@Override
 	public DataGrid<OsEnumVO> referDataGrid(Map<String, String> conditionMap, PageHelper pageHelper) {
-		DataGrid<OsEnumVO> dataGrid = queryObjectServiceInfoBySql(conditionMap, pageHelper, "plenum",OsEnumVO.class,null);
+		DataGrid<OsEnumVO> dataGrid = queryObjectServiceInfoBySql(conditionMap, pageHelper, "plenumtype",OsEnumVO.class,null);
 		return dataGrid;
 	}
 
@@ -454,7 +650,6 @@
 		return dataGrid;
 	}
 
-
 	/**
 	 * 娓呴櫎缂撳瓨
 	 */
@@ -462,4 +657,5 @@
 	public void clearCache() {
 
 	}
+
 }

--
Gitblit v1.9.3