| | |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.highdatas.mdm.entity.DeletedTableLog; |
| | | import com.highdatas.mdm.entity.MenuMapping; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.MaintainDataType; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.service.IDeletedTableLogService; |
| | | import com.highdatas.mdm.service.IMenuMappingService; |
| | | import com.highdatas.mdm.service.ISysFieldService; |
| | | import com.highdatas.mdm.service.ISysMenuService; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | |
| | | |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | IDeletedTableLogService deletedTableLogService; |
| | | |
| | |
| | | @RequestMapping(value = "/list", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> getMenuList() { |
| | | EntityWrapper<SysMenu> sysMenuEntityWrapper = new EntityWrapper<>(); |
| | | sysMenuEntityWrapper.eq("data_type","currentData"); |
| | | sysMenuEntityWrapper.eq("DataMenu", "DataMenu"); |
| | | sysMenuEntityWrapper.orderBy(" parent_id, order_no"); |
| | | List<SysMenu> sysMenus = menuService.selectList(sysMenuEntityWrapper); |
| | | LinkedHashSet<String> parentIdSet = new LinkedHashSet<>(); |
| | | for (SysMenu sysMenu : sysMenus) { |
| | | String parentId = sysMenu.getParentId(); |
| | | parentIdSet.add(parentId); |
| | | MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("menu_id", sysMenu.getId())); |
| | | if (menuMapping == null) { |
| | | continue; |
| | | } |
| | | String tableName = menuMapping.getTableName(); |
| | | List<SysField> fieldByTable = fieldService.getFieldByTable(tableName); |
| | | if (fieldByTable == null) { |
| | | continue; |
| | | } |
| | | parentIdSet.add(sysMenu.getId()); |
| | | } |
| | | Set<String> byParentId = menuService.getByParentId(parentIdSet); |
| | | List<SysMenu> parentList = menuService.selectBatchIds(byParentId); |
| | |
| | | menu.setId(uuid); |
| | | menu.setParentId(parentId); |
| | | menu.setOrderNo(orderno); |
| | | menu.setDataType(MaintainDataType.parse(dataType)); |
| | | menu.setMenuType(menuType); |
| | | boolean inserted = menuService.insert(menu); |
| | | if (inserted) { |
| | |
| | | menu.insert(); |
| | | } |
| | | |
| | | if (menu.getMenuType().equalsIgnoreCase(Constant.DataMenu)) { |
| | | Result<List<SysMenu>> listResult = menuByParentId(id); |
| | | List<SysMenu> data = listResult.getData(); |
| | | long count = data.stream().filter(sysMenu -> sysMenu.getDataType().equals(MaintainDataType.unkonwn)).count(); |
| | | if (count != data.size()) { |
| | | return Result.error(CodeMsg.SELECT_ERROR); |
| | | } |
| | | } |
| | | new SysMenu().setParentId(id).setId(DbUtils.getUUID()).setName(Constant.UnMatched).setOrderNo(1).setCreateTime(new Date()).setDataType(MaintainDataType.afterData).insert(); |
| | | new SysMenu().setParentId(id).setId(DbUtils.getUUID()).setName(Constant.Current).setOrderNo(2).setCreateTime(new Date()).setDataType(MaintainDataType.currentData).insert(); |
| | | new SysMenu().setParentId(id).setId(DbUtils.getUUID()).setName(Constant.History).setOrderNo(3).setCreateTime(new Date()).setDataType(MaintainDataType.beforeData).insert(); |
| | | // if (menu.getMenuType().equalsIgnoreCase(Constant.DataMenu)) { |
| | | // Result<List<SysMenu>> listResult = menuByParentId(id); |
| | | // List<SysMenu> data = listResult.getData(); |
| | | // long count = data.stream().filter(sysMenu -> sysMenu.getDataType().equals(MaintainDataType.unkonwn)).count(); |
| | | // if (count != data.size()) { |
| | | // return Result.error(CodeMsg.SELECT_ERROR); |
| | | // } |
| | | // } |
| | | |
| | | return Result.success(CodeMsg.SUCCESS); |
| | | } |
| | |
| | | for (SysMenu sysMenu : sysMenus) { |
| | | List<MenuMapping> menuMappingList = menuMappingService.selectList(new EntityWrapper<MenuMapping>().eq("menu_id", sysMenu.getId())); |
| | | for (MenuMapping menuMapping : menuMappingList) { |
| | | // 添加待删除表的日志 |
| | | //todo 添加待删除表的日志 |
| | | DeletedTableLog deletedTableLog = new DeletedTableLog(); |
| | | deletedTableLog.setId(DbUtils.getUUID()).setTableName(menuMapping.getTableName()).setCreateTime(new Date()); |
| | | deletedTableLog.insert(); |