From c007f0ca1785db093d48f4846cda82fe8e955765 Mon Sep 17 00:00:00 2001 From: kimi <kimi42345@gmail.com> Date: 星期三, 27 五月 2020 09:59:29 +0800 Subject: [PATCH] merage --- src/main/java/com/highdatas/mdm/service/impl/MenuMappingServiceImpl.java | 78 ++++++++++++++++++++++++++++++++++----- 1 files changed, 68 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/highdatas/mdm/service/impl/MenuMappingServiceImpl.java b/src/main/java/com/highdatas/mdm/service/impl/MenuMappingServiceImpl.java index 50c2c10..2b4a844 100644 --- a/src/main/java/com/highdatas/mdm/service/impl/MenuMappingServiceImpl.java +++ b/src/main/java/com/highdatas/mdm/service/impl/MenuMappingServiceImpl.java @@ -24,6 +24,7 @@ import org.springframework.stereotype.Service; import javax.servlet.http.HttpSession; +import java.io.UnsupportedEncodingException; import java.util.Date; import java.util.Map; @@ -57,7 +58,14 @@ IMasterAuthorService masterAuthorService; public static final String key = "process"; - + /** + * + * @description: 鍒涘缓menumapping瀵硅薄 + * @param json menu mapping josn鏁版嵁 + * @param session 鐢ㄦ埛浠巗ession閲岃幏鍙� + * @return: menu mapping瀵硅薄 + * + */ @Override public MenuMapping create(String json, HttpSession session) { JSONObject jsonObject = JSONObject.parseObject(json); @@ -95,7 +103,7 @@ //menuMapping.setMaintainFieldId(maintainId); return create(menuMapping); } - + @Deprecated private Maintain createMaintain(String userId, JSONObject jsonObject, String flowsId) { Maintain maintain = new Maintain(); maintain.setCreateTime(new Date()); @@ -117,7 +125,14 @@ } return null; } - + /** + * + * @description: 淇濆瓨menumapping瀵硅薄 + * @param menuMapping menumapping 瀵硅薄 + * @return: menu mapping瀵硅薄 + * + */ + @Override public MenuMapping create(MenuMapping menuMapping) { menuMapping.setCreateTime(new Date()); menuMapping.setId(DbUtils.getUUID()); @@ -126,8 +141,21 @@ String tableName = WorkflowUtils.toFirstChar(name.toLowerCase()); tableName = Constant.MD + tableName; String tableByName = tableInfoMapper.selectTableByName(tableName); + if (!StringUtils.isEmpty(tableByName)){ - tableName = tableName + "_" + DbUtils.getUUID(5); + int sameCount = selectCount(new EntityWrapper<MenuMapping>().eq("table_name", tableName)); + if (sameCount > 0) { + tableName = tableName + "_" + DbUtils.getUUID(5); + } + } + int length = 0; + try { + length = tableName.getBytes("UTF-8").length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + if (length > 18) { + tableName = Constant.MD + DbUtils.getUUID(10); } menuMapping.setTableName(tableName); boolean insert = this.insert(menuMapping); @@ -161,7 +189,14 @@ return this.updateById(menuMapping); } - + /** + * + * @description: 閫氳繃涓婚鑾峰彇menumapping + * @param id 涓婚id + * @param session 鐢ㄦ埛浠巗ession閲岃幏鍙� + * @return: menu mapping瀵硅薄 + * + */ @Override public Result getMapping(HttpSession session, String id) { SysMenu sysMenu = menuService.selectById(id); @@ -184,8 +219,10 @@ if (menuMapping == null) { return Result.error(new CodeMsg(10008,"褰撳墠涓婚鏃犵増鏈暟鎹�")); } - String tableName = menuMapping.getTableName(); + String chargeId = menuMapping.getChargeId(); + TUser userByChargeId = DbUtils.getUserById(chargeId); + TUser user = (TUser) session.getAttribute(Constant.USER); Maintain resultMaintain = masterAuthorService.getMaxVersionMaintain(user, tableName); @@ -200,7 +237,9 @@ mapping.put("version", resultMaintain.getVersion()); mapping.put("maintainId", resultMaintain.getId()); } - + if (userByChargeId != null) { + mapping.put("userName", userByChargeId.getUserName()); + } if (nowVersion != null) { mapping.put("hasData", true); }else { @@ -209,7 +248,13 @@ return Result.success(mapping); } - + /** + * + * @description: 閫氳繃琛ㄥ悕鑾峰彇涓婚 + * @param tableName 琛ㄥ悕 + * @return: 涓婚瀵硅薄 + * + */ @Override public SysMenu getMenuByTableName(String tableName) { MenuMapping menuMapping = selectOne(new EntityWrapper<MenuMapping>().eq("table_name", tableName).orderBy("create_time desc")); @@ -220,7 +265,14 @@ SysMenu sysMenu = menuService.selectById(menuId); return sysMenu; } - + /** + * + * @description: 閫氳繃涓婚鑾峰彇menumapping + * @param id 涓婚id + * @param session 鐢ㄦ埛浠巗ession閲岃幏鍙� + * @return: menu mapping瀵硅薄 + * + */ @Override public MenuMapping getMenuMappingByTableName(String tableName) { MenuMapping menuMapping = selectOne(new EntityWrapper<MenuMapping>().eq("table_name", tableName).orderBy("create_time desc")); @@ -231,7 +283,13 @@ } - + /** + * + * @description: 閫氳繃涓婚鑾峰彇menumapping + * @param menuId 涓婚id + * @return: menumapping瀵硅薄 + * + */ @Override public String getTableNameByMenu(String menuId) { MenuMapping menuMapping = selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", menuId).orderBy("create_time desc")); -- Gitblit v1.8.0