| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public MenuMapping create(MenuMapping menuMapping) { |
| | | menuMapping.setCreateTime(new Date()); |
| | | menuMapping.setId(DbUtils.getUUID()); |
| | |
| | | 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); |
| | |
| | | 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.getUserId(), tableName); |
| | | Maintain resultMaintain = masterAuthorService.getMaxVersionMaintain(user, tableName); |
| | | Maintain nowVersion = maintainService.getNowVersion(tableName); |
| | | |
| | | if (resultMaintain != null) { |
| | |
| | | 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 { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public MenuMapping getMenuMappingByTableName(String tableName) { |
| | | MenuMapping menuMapping = selectOne(new EntityWrapper<MenuMapping>().eq("table_name", tableName).orderBy("create_time desc")); |
| | | if (menuMapping == null) { |
| | | return null; |
| | | } |
| | | return menuMapping; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getTableNameByMenu(String menuId) { |
| | | MenuMapping menuMapping = selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", menuId).orderBy("create_time desc")); |
| | | if (menuMapping == null) { |