¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import com.vci.client.common.providers.ClientServiceProvider; |
| | | import com.vci.common.exception.VciException; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.common.data.UserEntityInfo; |
| | | import com.vci.corba.framework.data.AppConfigCategoryInfo; |
| | | import com.vci.corba.framework.data.AppConfigDetailInfo; |
| | | import com.vci.corba.omd.etm.EnumItem; |
| | | import com.vci.corba.omd.etm.EnumType; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.util.WebThreadLocalUtil; |
| | | import com.vci.web.service.SecretGradeServiceI; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.swing.*; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * å¯çº§ç®¡çæå¡ |
| | | * @author ludc |
| | | * @date 2024/10/25 16:49 |
| | | */ |
| | | @Service |
| | | public class SecretGradeServiceImpl implements SecretGradeServiceI { |
| | | |
| | | @Autowired |
| | | private PlatformClientUtil platformClientUtil; |
| | | |
| | | /** |
| | | * æ¥å¿ |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | /** |
| | | * è·åå¯çº§ç®¡çé
ç½® |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Map<String, Boolean> getSecretGradeConfig() throws PLException { |
| | | Map<String, Boolean> returnMap = new HashMap<>(); |
| | | //map.put(); |
| | | String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | UserEntityInfo userEntityInfo = new UserEntityInfo(userId,""); |
| | | AppConfigDetailInfo userConfigDetail = platformClientUtil.getFrameworkService().getAppConfigDetailByKey("userSecuritySwith", userEntityInfo); |
| | | AppConfigDetailInfo ipConfigDetail = platformClientUtil.getFrameworkService().getAppConfigDetailByKey("ipSecuritySwitch",userEntityInfo); |
| | | if ("on".equals(userConfigDetail.value)) { |
| | | returnMap.put("userSecuritySwith",true); |
| | | }else{ |
| | | returnMap.put("userSecuritySwith",false); |
| | | } |
| | | |
| | | if ("on".equals(ipConfigDetail.value)) { |
| | | returnMap.put("ipSecuritySwitch",true); |
| | | }else{ |
| | | returnMap.put("ipSecuritySwitch",false); |
| | | } |
| | | return returnMap; |
| | | } |
| | | |
| | | /** |
| | | * ç¨æ·/æºå¨å¯çº§åå¯é
ç½®ä¿å |
| | | * @param secretGradeMap |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BaseResult saveSecretGrade(Map<String, Boolean> secretGradeMap){ |
| | | VciBaseUtil.alertNotNull(secretGradeMap,"å¯çº§é
置对象"); |
| | | Boolean userSecuritySwith = secretGradeMap.getOrDefault("userSecuritySwith", false); |
| | | Boolean ipSecuritySwitch = secretGradeMap.getOrDefault("ipSecuritySwitch", false); |
| | | |
| | | try{ |
| | | String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | UserEntityInfo userEntityInfo = new UserEntityInfo(userId,""); |
| | | AppConfigCategoryInfo[] categories = platformClientUtil.getFrameworkService().getAppConfigCategorys(userEntityInfo); |
| | | String secretGradeCategoryId = ""; |
| | | for (int i = 0; i < categories.length; i++) { |
| | | if ("ç³»ç»å¯çº§é
ç½®".equals(categories[i].name)) { |
| | | secretGradeCategoryId = categories[i].id; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if ("".equals(secretGradeCategoryId)) { |
| | | AppConfigCategoryInfo categoryObj = new AppConfigCategoryInfo(); |
| | | categoryObj.name = "ç³»ç»å¯çº§é
ç½®"; |
| | | categoryObj.desc = "ç³»ç»å¯çº§é
ç½®"; |
| | | secretGradeCategoryId = platformClientUtil.getFrameworkService().saveAppConfigCategory(categoryObj,userEntityInfo); |
| | | } |
| | | |
| | | AppConfigDetailInfo userConfigDetail = platformClientUtil.getFrameworkService().getAppConfigDetailByKey("userSecuritySwith", userEntityInfo); |
| | | AppConfigDetailInfo ipConfigDetail = platformClientUtil.getFrameworkService().getAppConfigDetailByKey("ipSecuritySwitch",userEntityInfo); |
| | | |
| | | if (ipSecuritySwitch) { |
| | | if (ipConfigDetail.id != null && !"".equals(ipConfigDetail.id)) { |
| | | ipConfigDetail.value = "on"; |
| | | boolean res = platformClientUtil.getFrameworkService().updateAppConfigDetail(ipConfigDetail,userEntityInfo); |
| | | System.out.println("ipé
置修æ¹ç»æ-------" + res); |
| | | } else { |
| | | ipConfigDetail = new AppConfigDetailInfo(); |
| | | ipConfigDetail.key = "ipSecuritySwitch"; |
| | | ipConfigDetail.value = "on"; |
| | | ipConfigDetail.name = "æºå¨å¯çº§åå¯"; |
| | | ipConfigDetail.desc = "valueå¼ä¸ºonæ¶ä»£è¡¨æºå¨å¯çº§å¼å¯ï¼å¼ä¸ºå
¶ä»æè
ä¸é
ç½®æ¶ä»£è¡¨ä¸å¼å¯ã"; |
| | | ipConfigDetail.categoryId = secretGradeCategoryId; |
| | | String res = platformClientUtil.getFrameworkService().saveAppConfigDetail(ipConfigDetail,userEntityInfo); |
| | | System.out.println("ipé
ç½®ä¿åç»æ-------" + res); |
| | | } |
| | | } else { |
| | | if (ipConfigDetail.id != null && !"".equals(ipConfigDetail.id)) { |
| | | ipConfigDetail.value = "off"; |
| | | platformClientUtil.getFrameworkService().updateAppConfigDetail(ipConfigDetail,userEntityInfo); |
| | | } |
| | | } |
| | | |
| | | if (userSecuritySwith) { |
| | | if (userConfigDetail.id != null && !"".equals(userConfigDetail.id)) { |
| | | userConfigDetail.value = "on"; |
| | | boolean res = platformClientUtil.getFrameworkService().updateAppConfigDetail(userConfigDetail,userEntityInfo); |
| | | System.out.println("useré
置修æ¹ç»æ-------" + res); |
| | | } else { |
| | | userConfigDetail = new AppConfigDetailInfo(); |
| | | userConfigDetail.key = "userSecuritySwith"; |
| | | userConfigDetail.value = "on"; |
| | | userConfigDetail.name = "ç¨æ·å¯çº§åå¯"; |
| | | userConfigDetail.categoryId = secretGradeCategoryId; |
| | | userConfigDetail.desc = ("valueå¼ä¸ºonæ¶ä»£è¡¨ç¨æ·å¯çº§å¼å¯ï¼å¼ä¸ºå
¶ä»æè
ä¸é
ç½®æ¶ä»£è¡¨ä¸å¼å¯ã"); |
| | | String res = platformClientUtil.getFrameworkService().saveAppConfigDetail(userConfigDetail,userEntityInfo); |
| | | System.out.println("useré
ç½®ä¿åç»æ-------" + res); |
| | | } |
| | | updateUserSecretGrade(); |
| | | } else { |
| | | if (userConfigDetail.id != null && !"".equals(userConfigDetail.id)) { |
| | | userConfigDetail.value = "off"; |
| | | boolean res = platformClientUtil.getFrameworkService().updateAppConfigDetail(userConfigDetail,userEntityInfo); |
| | | System.out.println("useré
置修æ¹ç»æ-------" + res); |
| | | } |
| | | } |
| | | return BaseResult.success("ä¿åé
ç½®æå"); |
| | | }catch (Exception e){ |
| | | String errorLog = "ä¿åé
置失败ï¼åå ï¼"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorLog); |
| | | return BaseResult.fail(errorLog); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ·çå¯é |
| | | * @throws PLException |
| | | */ |
| | | private void updateUserSecretGrade() throws PLException { |
| | | EnumType enumType = platformClientUtil.getEnumService().getEnumTypeByName("usersecurityenum"); |
| | | EnumItem[] children = enumType.items; |
| | | int grade = 10; |
| | | if (children.length > 0) { |
| | | grade = Integer.parseInt(children[0].value); |
| | | for (int i = 0; i < children.length; i++) { |
| | | EnumItem child = children[i]; |
| | | if (grade >= Integer.parseInt(child.value)) { |
| | | grade = Integer.parseInt(child.value); |
| | | } |
| | | } |
| | | } |
| | | String updateSql = "update pluser set plsecretgrade = '" + grade + "' " + |
| | | "where plsecretgrade is null"; |
| | | platformClientUtil.getBOFService().executeUpdateSql(updateSql); |
| | | } |
| | | |
| | | } |