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-api/src/main/java/com/vci/dto/OsEnumItemDTO.java | 43 +++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/OrgDepartmentQueryController.java | 2 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsEnumDTO.java | 72 ++++++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/SmUserQueryServiceI.java | 2 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/Func.java | 10 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java | 5 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsEnumItemVO.java | 12 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java | 22 + Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBaseServiceI.java | 4 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmPwdStrategyQueryController.java | 4 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java | 49 ++++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/DigestUtil.java | 40 +++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmUserQueryController.java | 6 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java | 129 ++++++++++- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java | 244 ++++++++++++++++++++-- 15 files changed, 575 insertions(+), 69 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsEnumDTO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsEnumDTO.java index 4597459..2e7effa 100644 --- a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsEnumDTO.java +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsEnumDTO.java @@ -1,6 +1,10 @@ package com.vci.dto; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.vci.starter.web.util.VciDateUtil; + import java.util.Date; +import java.util.List; import java.util.Map; /** @@ -8,7 +12,7 @@ * @author weidy * @date 2019/10/14 17:25 */ -public class OsEnumDTO implements java.io.Serializable{ +public class OsEnumDTO implements java.io.Serializable { /** * 绂佹淇敼杩欎釜鍊� @@ -48,7 +52,28 @@ /** * 鏃堕棿鎴筹紝鏍煎紡鏄痽yyy-MM-dd HH:mm:ss.SSS */ + @JsonFormat(pattern = VciDateUtil.DateTimeMillFormat) private Date ts; + + /** + * 鍒涘缓浜� + */ + private String creator; + + /** + * 鍒涘缓鏃堕棿 + */ + private Date createTime; + + /** + * 鏈�鍚庝慨鏀逛汉 + */ + private String lastModifier; + + /** + * 鏈�鍚庝慨鏀规椂闂达紝鏍煎紡鏄痽yyy-MM-dd HH:mm:ss + */ + private Date lastModifyTime; /** * 绫荤殑鍏ㄨ矾寰� @@ -65,6 +90,51 @@ */ private Map<String,String> itemOidMaps; + /** + * 鏋氫妇椤� + */ + private List<OsEnumItemDTO> items; + + public String getCreator() { + return creator; + } + + public Date getCreateTime() { + return createTime; + } + + public String getLastModifier() { + return lastModifier; + } + + public Date getLastModifyTime() { + return lastModifyTime; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public void setLastModifier(String lastModifier) { + this.lastModifier = lastModifier; + } + + public void setLastModifyTime(Date lastModifyTime) { + this.lastModifyTime = lastModifyTime; + } + + public void setItems(List<OsEnumItemDTO> items) { + this.items = items; + } + + public List<OsEnumItemDTO> getItems() { + return items; + } + public String getOid() { return oid; } diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsEnumItemDTO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsEnumItemDTO.java new file mode 100644 index 0000000..b1e243e --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsEnumItemDTO.java @@ -0,0 +1,43 @@ +package com.vci.dto; + + +/** + * 鏋氫妇椤规暟鎹紶杈撳璞� + * @author ludc + * @date 2024/7/17 14:23 + */ +public class OsEnumItemDTO implements java.io.Serializable{ + + private static final long serialVersionUID = -900528102L; + + private String name; + + private String value; + + private String description; + + public void setName(String name) { + this.name = name; + } + + public void setValue(String value) { + this.value = value; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public String getValue() { + return value; + } + + public String getDescription() { + return description; + } + +} diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsEnumItemVO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsEnumItemVO.java index cf5b330..ea24796 100644 --- a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsEnumItemVO.java +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsEnumItemVO.java @@ -31,7 +31,7 @@ /** * 鏋氫妇鍊� */ - private String id; + private String value; /** * 鏋氫妇鏄剧ず鍚嶇О @@ -95,12 +95,12 @@ this.pkEnum = pkEnum; } - public String getId() { - return id; + public String getValue() { + return value; } - public void setId(String id) { - this.id = id; + public void setValue(String id) { + this.value = id; } public String getName() { @@ -181,7 +181,7 @@ return "OsEnumItemVO{" + "oid='" + oid + '\'' + ", pkEnum='" + pkEnum + '\'' + - ", id='" + id + '\'' + + ", value='" + value + '\'' + ", name='" + name + '\'' + ", description='" + description + '\'' + ", btmname='" + btmname + '\'' + diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/SmUserQueryServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/SmUserQueryServiceI.java index 96dd533..139b5d8 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/SmUserQueryServiceI.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/SmUserQueryServiceI.java @@ -195,7 +195,7 @@ * @param password 鏂扮殑瀵嗙爜 * @param confirmPassword 纭瀵嗙爜 */ - boolean changePassword(String userOid,String oldPassword, String password, String confirmPassword) throws PLException; + boolean changePassword(String userOid,String oldPassword, String password, String confirmPassword) throws Exception; /** * 鏇存柊鐢ㄦ埛鐨勫瘑鐮侀敊璇鏁� 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 80dd56a..e56db37 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 @@ -1028,15 +1028,18 @@ @Override @Transactional(rollbackFor = Exception.class) public boolean changePassword(String userOid,String oldPassword, String password, - String confirmPassword) throws PLException { + String confirmPassword) throws Exception { WebUtil.alertNotNull(userOid,"鐢ㄦ埛涓婚敭",oldPassword,"鐧诲綍瀵嗙爜",password,"瀵嗙爜",confirmPassword,"纭瀵嗙爜"); + if(!password.equals(confirmPassword)){ + throw new VciBaseException("瀵嗙爜鍜岀‘璁ゅ瘑鐮佷笉鐩哥瓑"); + } + //瀵规棫瀵嗙爜鍜屽瘑鐮佽繘琛岃В瀵嗭紝渚夸簬姣斿瀵嗙爜鐢� + oldPassword = Func.decryptAes(oldPassword,"daliantan0v0vcip"); + password = Func.decryptAes(password,"daliantan0v0vcip"); //瀵规瘮鏃у瘑鐮� boolean b = this.checkPasswordEqual(oldPassword, userOid); if(!b){ throw new PLException("500", new String[] { "鎮ㄨ緭鍏ョ殑瀵嗙爜涓庣櫥褰曞瘑鐮佷笉涓�鑷�,璇烽噸鏂拌緭鍏�!"}); - } - if(!password.equals(confirmPassword)){ - throw new VciBaseException("瀵嗙爜鍜岀‘璁ゅ瘑鐮佷笉鐩哥瓑"); } SmUserVO smUserVO = getUserByUserOid(userOid); if(Func.isEmpty(smUserVO)){ @@ -1047,12 +1050,21 @@ if (!StringUtils.isBlank(error)) { throw new VciBaseException("褰撳墠璁剧疆鐨勫瘑鐮侊紝瀵嗙爜绛栫暐鏍¢獙鏈�氳繃!"); } + + //TODO:鑰冭檻鏄惁闇�瑕佸皢淇敼鏂瑰紡鏀规垚鐩存帴璋冪敤骞冲彴鐨勬帴鍙o紝鍥犱负鐜板湪鐨勪慨鏀规柟寮忔病鑳芥纭殑鏇存柊缂撳瓨 + /*UserInfo userInfo = new UserInfo(); + userInfo.id = userOid.trim(); + userInfo.pwd = password; + userInfo.pwdUpdateTime = System.currentTimeMillis(); + boolean updateBoolean = platformClientUtil.getFrameworkService().updateUser(userInfo, new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(), null)); + return updateBoolean;*/ + ThreeDES des = new ThreeDES();// 瀹炰緥鍖栦竴涓锟�? des.getKey("daliantan0v0");// 鐢熸垚瀵嗗寵 String encPassword = des.getEncString(password); //淇敼瀵嗙爜鐨勫悓鏃堕渶瑕佸皢瀵嗙爜淇敼鏃堕棿涔熸洿鏂� String sql = "update pluser set plpassword = '" + encPassword + "', plpwdupdatetime = TO_DATE('" - + Func.format(new Date(),"yyyy-MM-dd HH:mm:ss") +"','yyyy-MM-dd hh24:mi:ssxff') where pluid = '" + userOid.trim() + "'"; + + Func.format(new Date(),"yyyy-MM-dd HH:mm:ss") +"','yyyy-MM-dd hh24:mi:ss') where pluid = '" + userOid.trim() + "'"; try { return platformClientUtil.getBOFactoryService().executeUpdateSql(sql); } catch (PLException vciError) { diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/OrgDepartmentQueryController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/OrgDepartmentQueryController.java index cec47dc..05821b2 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/OrgDepartmentQueryController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/OrgDepartmentQueryController.java @@ -62,7 +62,7 @@ e.printStackTrace(); String exceptionMessage = "閮ㄩ棬鏍戞煡璇㈡椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); logger.error(exceptionMessage); - return BaseResult.fail(e.getMessage()); + return BaseResult.fail(exceptionMessage); } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmPwdStrategyQueryController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmPwdStrategyQueryController.java index eaf03f4..f0b45cc 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmPwdStrategyQueryController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmPwdStrategyQueryController.java @@ -55,7 +55,7 @@ e.printStackTrace(); String exceptionMessage = "瀵嗙爜瀹夊叏绛栫暐鍒楄〃鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); logger.error(exceptionMessage); - return BaseResult.fail(e.getMessage()); + return BaseResult.fail(exceptionMessage); } } @@ -75,7 +75,7 @@ e.printStackTrace(); String exceptionMessage = "瀵嗙爜瀹夊叏绛栫暐涓嬫媺鍒楄〃鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); logger.error(exceptionMessage); - return BaseResult.fail(e.getMessage()); + return BaseResult.fail(exceptionMessage); } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmUserQueryController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmUserQueryController.java index 7dda639..375ec71 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmUserQueryController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmUserQueryController.java @@ -206,7 +206,7 @@ @RequestMapping(value = "/changePassword",method = RequestMethod.POST) public BaseResult changePassword(String userOid,String oldPassword, String password, String confirmPassword) throws PLException { try { - return BaseResult.success(userQueryService.changePassword(userOid, oldPassword, password, confirmPassword) ? "淇敼瀵嗙爜鎴愬姛锛�":"淇敼瀵嗙爜澶辫触锛�"); + return userQueryService.changePassword(userOid, oldPassword, password, confirmPassword) ? BaseResult.success("鐢ㄦ埛淇敼鎴愬姛锛�"):BaseResult.fail("鐢ㄦ埛淇敼澶辫触锛�"); }catch (Exception e){ e.printStackTrace(); String exceptionMessage = "淇敼瀵嗙爜鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); @@ -230,7 +230,7 @@ e.printStackTrace(); String exceptionMessage = "鐢ㄦ埛绠$悊鍒楄〃鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); logger.error(exceptionMessage); - return BaseResult.fail(e.getMessage()); + return BaseResult.fail(exceptionMessage); } } @@ -259,7 +259,7 @@ @RequestMapping(value = "/updateUser",method = RequestMethod.PUT) public BaseResult updateUser(@RequestBody SmUserDTO smUserDTO){ try { - return BaseResult.success(userQueryService.updateUser(smUserDTO) ? "鐢ㄦ埛淇敼鎴愬姛锛�":"鐢ㄦ埛淇敼澶辫触锛�"); + return userQueryService.updateUser(smUserDTO) ? BaseResult.success("鐢ㄦ埛淇敼鎴愬姛锛�"):BaseResult.fail("鐢ㄦ埛淇敼澶辫触锛�"); }catch (Exception e){ e.printStackTrace(); String exceptionMessage = "淇敼鐢ㄦ埛鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java index 14f0e92..e8beb3e 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java @@ -1,5 +1,6 @@ package com.vci.web.controller; +import com.vci.dto.OsEnumDTO; import com.vci.starter.web.annotation.controller.VciUnCheckRight; import com.vci.starter.web.annotation.log.VciBusinessLog; import com.vci.starter.web.pagemodel.BaseQueryObject; @@ -8,11 +9,12 @@ import com.vci.pagemodel.KeyValue; import com.vci.pagemodel.OsEnumItemVO; import com.vci.pagemodel.OsEnumVO; +import com.vci.starter.web.util.VciBaseUtil; import com.vci.web.service.OsEnumServiceI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -34,6 +36,11 @@ private OsEnumServiceI enumService; /** + * 鏃ュ織 + */ + private Logger logger = LoggerFactory.getLogger(getClass()); + + /** * 鑾峰彇鏋氫妇鐨勪笅鎷夋 * @param comboxKey 鏋氫妇鐨勫悕绉� * @return 鏋氫妇鐨勪笅鎷夊�� @@ -45,6 +52,27 @@ return BaseResult.success(enumService.getEnum(comboxKey)); } + /** + * 鍙傜収鏋氫妇鍒楄〃 + * @param baseQueryObject 鏌ヨ鏉′欢 + * @return 鍒楄〃鐨勫唴瀹� + */ + @GetMapping( "/referDataGrid") + @VciBusinessLog(operateName = "鍙傜収鏋氫妇鍒楄〃") + public DataGrid<OsEnumVO> referDataGrid(BaseQueryObject baseQueryObject){ + return enumService.referDataGrid(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper()); + } + + /** + * 鑾峰彇鏋氫妇鐨勬槑缁� + * @param pkEnum 鏋氫妇鐨勪富閿� + * @return 鏋氫妇鐨勯�夐」 + */ + @GetMapping("/gridEnumItemByOid") + @VciBusinessLog(operateName = "鑾峰彇鏋氫妇鐨勬槑缁�") + public DataGrid<OsEnumItemVO> gridEnumItemByOid(String pkEnum){ + return enumService.gridEnumItemByOid(pkEnum); + } /** * 鑾峰彇鏁版嵁鐨勫瘑绾� @@ -60,24 +88,97 @@ /** * 鏋氫妇鍒楄〃 - * @param baseQueryObject 鏌ヨ鏉′欢 + * @param enumName 鏌ヨ鏉′欢name * @return 鍒楄〃鐨勫唴瀹� */ - @GetMapping( "/gridEnum") + @GetMapping( "/getEnumTypeList") @VciBusinessLog(operateName = "鏋氫妇鍒楄〃") - public DataGrid<OsEnumVO> gridEnum(BaseQueryObject baseQueryObject){ - return enumService.referDataGrid(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper()); + @VciUnCheckRight + public BaseResult<List<OsEnumVO>> getEnumTypeList(String enumName) { + try { + return BaseResult.dataList(enumService.getEnumTypeList(enumName)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鏋氫妇绠$悊鍒楄〃鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } } /** - * 鑾峰彇鏋氫妇鐨勬槑缁� - * @param pkEnum 鏋氫妇鐨勪富閿� - * @return 鏋氫妇鐨勯�夐」 + * 娣诲姞鍗曟潯鏋氫妇 + * @param osEnumDTO + * @return 鍒楄〃鐨勫唴瀹� */ - @GetMapping("/gridEnumItemByOid") - @VciBusinessLog(operateName = "鑾峰彇鏋氫妇鐨勬槑缁�") - public DataGrid<OsEnumItemVO> gridEnumItemByOid(String pkEnum){ - return enumService.gridEnumItemByOid(pkEnum); + @PostMapping( "/addEnumType") + @VciBusinessLog(operateName = "娣诲姞鏋氫妇") + @VciUnCheckRight + public BaseResult addEnumType(@RequestBody OsEnumDTO osEnumDTO) { + try { + return enumService.addEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷娣诲姞鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷娣诲姞澶辫触锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "澧炲姞鏋氫妇绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 淇敼鍗曟潯鏋氫妇锛堝甫淇敼鏋氫妇椤瑰姛鑳斤級 + * @param osEnumDTO + * @return 鍒楄〃鐨勫唴瀹� + */ + @PutMapping( "/updateEnumType") + @VciBusinessLog(operateName = "淇敼鏋氫妇") + @VciUnCheckRight + public BaseResult updateEnumType(@RequestBody OsEnumDTO osEnumDTO) { + try { + return enumService.updateEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷淇敼鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷淇敼澶辫触锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "淇敼鏋氫妇绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒犻櫎鏋氫妇 + * @param osEnumDTOS + * @return 鍒楄〃鐨勫唴瀹� + */ + @DeleteMapping( "/deleteEnumTypes") + @VciBusinessLog(operateName = "鍒犻櫎鏋氫妇") + @VciUnCheckRight + public BaseResult deleteEnumTypes(@RequestBody List<OsEnumDTO> osEnumDTOS) { + try { + return enumService.deleteEnumTypes(osEnumDTOS) ? BaseResult.success("鏋氫妇绫诲瀷鍒犻櫎鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷鍒犻櫎澶辫触锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒犻櫎鏋氫妇绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥� + * @param enumName + * @return 鍒楄〃鐨勫唴瀹� + */ + @GetMapping( "/getUsedEnumList") + @VciBusinessLog(operateName = "鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥�") + @VciUnCheckRight + public BaseResult getUsedEnumList(String enumName) { + try { + return BaseResult.dataList(enumService.getUsedEnumList(enumName)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鑾峰彇鏋氫妇鐨勪娇鐢ㄨ寖鍥存椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } } } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBaseServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBaseServiceI.java index 491fee7..4fbf26c 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBaseServiceI.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBaseServiceI.java @@ -63,7 +63,7 @@ } } String baseSql = "select oid,to_char(ts,'yyyy-mm-dd hh24:mi:ss') as ts,creator,to_char(createTime,'yyyy-mm-dd hh24:mi:ss') as createTime,modifier,to_char(modifyTime,'yyyy-mm-dd hh24:mi:ss') as modifyTime,name,label," + - ("plenum".equalsIgnoreCase(tableName)?" '' as " :"") + "description from " + tableName + ("plenumtype".equalsIgnoreCase(tableName)?" '' as " :"") + "description from " + tableName + (StringUtils.isNotBlank(whereSql)?(" where " + whereSql):""); baseSql += " order by lower(name) asc "; String sql = (StringUtils.isNotBlank(pageSql)?" select oid,ts,creator,createTime,modifier,modifyTime,name,label,description from (select A.* , rownum RN from (":"") @@ -99,7 +99,7 @@ dataList.add(obj); }); dataGrid.setData(dataList); - List<Map> maps = boService.queryBySqlForMap("select count(oid) as total from plbtmtype " + (StringUtils.isNotBlank(whereSql)?(" where " + whereSql):""), null); + List<Map> maps = boService.queryBySqlForMap("select count(*) as total from "+ tableName + (StringUtils.isNotBlank(whereSql)?(" where " + whereSql):""), null); dataGrid.setTotal(VciBaseUtil.getInt(maps.get(0).get("total").toString())); } return dataGrid; diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java index 49dfc6f..21881ba 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsEnumServiceI.java @@ -1,5 +1,7 @@ package com.vci.web.service; +import com.vci.corba.common.PLException; import com.vci.corba.omd.etm.EnumType; +import com.vci.dto.OsEnumDTO; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.starter.web.pagemodel.PageHelper; @@ -59,6 +61,49 @@ List<OsEnumVO> selectAllEnum(); /** + * 鏋氫妇瀹氫箟鍒楄〃鏌ヨ锛堝甫鏌ヨ鏉′欢锛� + * @param enumName + * @return 鏋氫妇鐨勬樉绀哄璞� + */ + List<OsEnumVO> getEnumTypeList(String enumName) throws PLException; + + /** + * 鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥� + * @param enumName + * @return + * @throws PLException + */ + List<OsEnumVO> getUsedEnumList(String enumName) throws PLException; + + /** + * 鏍规嵁鏋氫妇鑻辨枃鍚嶇О鑾峰彇鏋氫妇绫诲瀷 + * @param id + * @return + */ + OsEnumVO getEnumTypeById(String id) throws PLException; + + /** + * 鏂板鏋氫妇绫诲瀷 + * @param osEnumDTO + * @return + */ + boolean addEnumType(OsEnumDTO osEnumDTO) throws PLException ; + + /** + * 淇敼鏋氫妇绫诲瀷 + * @param osEnumDTO + * @return + */ + boolean updateEnumType(OsEnumDTO osEnumDTO) throws PLException ; + + /** + * 鍒犻櫎鏋氫妇绫诲瀷 + * @param osEnumDTOS + * @return + */ + boolean deleteEnumTypes(List<OsEnumDTO> osEnumDTOS) throws PLException; + + /** * 鏌ヨ鎵�鏈夌殑鏋氫妇鏄犲皠 * @return key鏄灇涓剧殑鑻辨枃鍚嶇О */ @@ -73,10 +118,10 @@ /** * 鏋氫妇鐨勬暟鎹璞¤浆鎹负鏄剧ず瀵硅薄 - * @param enumItem 鏁版嵁瀵硅薄 + * @param enumType 鏁版嵁瀵硅薄 * @return 鏄剧ず瀵硅薄 */ - OsEnumVO enumDO2VO(EnumType enumItem); + OsEnumVO enumDO2VO(EnumType enumType); /** * 鏋氫妇鏄庣粏杞崲涓篕V 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 e860eee..fbe28cb 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 @@ -195,9 +195,8 @@ machine.machine = clientInfo.getMachine(); String token = null; try { - /*ThreeDES des = new ThreeDES();// 瀹炰緥鍖栦竴涓锟�? - des.getKey("daliantan0v0");// 鐢熸垚瀵嗗寵 - String encPassword = des.getDesString(userDTO.getPassword());*/ + //鍓嶇浼犺繃鏉ョ殑瀵嗙爜鏄粡杩囧姞瀵嗕紶杈撶殑锛屾墍浠ラ渶瑕佹寜鐓х害瀹氳В瀵嗭紝鍐嶄紶缁欏钩鍙拌繘琛屾瘮瀵� + userDTO.setPassword(Func.decryptAes(userDTO.getPassword(),"daliantan0v0vcip")); LoginResult chkRes = platformClientUtil.getFrameworkService().checkLogin(userDTO.getUserId(),userDTO.getPassword(), machine); loginResult.setFailCode(getErrorCode(chkRes)); //loginResult.setFailMsgArray(new String[]{userDTO.getUserId(), String.valueOf(chkRes.auxInfo)}); 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() { } + } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/DigestUtil.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/DigestUtil.java index 5daa93e..929ee15 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/DigestUtil.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/DigestUtil.java @@ -1,14 +1,18 @@ package com.vci.web.util; +import com.vci.corba.common.PLException; +import com.vci.starter.web.exception.VciBaseException; +import org.apache.commons.codec.binary.Hex; import org.springframework.lang.Nullable; import org.springframework.util.DigestUtils; -import javax.crypto.Mac; -import javax.crypto.SecretKey; +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -import java.security.InvalidKeyException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; +import java.security.*; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; +import java.util.Base64; /** * 鍔犲瘑鐩稿叧宸ュ叿绫荤洿鎺ヤ娇鐢⊿pring util灏佽锛屽噺灏慾ar渚濊禆 @@ -327,6 +331,32 @@ } /** + * aes瑙e瘑 + * @param secretKey 绉橀挜 + * @param encryptedData Data + * @return digest as a hex string + */ + public static String decryptAes(String encryptedData, String secretKey) throws Exception { + // AES 瀵嗛挜闀垮害闇�瑕佹槸 128, 192, 鎴� 256 浣嶏紙16, 24, 鎴� 32 瀛楄妭锛� + byte[] keyBytes = secretKey.getBytes("UTF-8"); + SecretKeySpec key = new SecretKeySpec(keyBytes, "AES"); + + // 鍒濆鍖栧悜閲� IV 涔熼渶瑕佹槸 128 浣嶏紙16 瀛楄妭锛� + byte[] ivBytes = secretKey.substring(0, 16).getBytes("UTF-8"); + IvParameterSpec iv = new IvParameterSpec(ivBytes); + + // 瑙e瘑 + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, key, iv); + + // 瑙e瘑鐨勬暟鎹渶瑕佹槸 Base64 缂栫爜鐨勶紝鍥犱负 JavaScript 鐨� CryptoJS 榛樿杩斿洖 Base64 缂栫爜鐨勫瓧绗︿覆 + byte[] decodedValue = Base64.getDecoder().decode(encryptedData); + byte[] decryptedBytes = cipher.doFinal(decodedValue); + + return new String(decryptedBytes, "UTF-8"); + } + + /** * digest HMac * * @param algorithm 绠楁硶 diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/Func.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/Func.java index eefb170..14206fd 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/Func.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/util/Func.java @@ -1232,6 +1232,16 @@ } /** + * AES 瑙e瘑 + * @param encryptedData + * @param secretKey + * @return + */ + public static String decryptAes(String encryptedData, String secretKey) throws Exception { + return DigestUtil.decryptAes(encryptedData, secretKey); + } + + /** * hmacMd5 Hex * * @param bytes Data to digest -- Gitblit v1.9.3