| | |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.NoticeClient; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | |
| | | @RequestMapping(value = "/all", method = RequestMethod.GET) |
| | | @Autowired |
| | | NoticeClient noticeClient; |
| | | @RequestMapping(value = "/all") |
| | | public Result<List<SysMenu>> getAll() { |
| | | EntityWrapper<SysMenu> sysMenuEntityWrapper = new EntityWrapper<>(); |
| | | sysMenuEntityWrapper.orderBy("parent_id, order_no"); |
| | |
| | | @RequestMapping(value = "/author/all", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> getAllBak(HttpServletRequest request) { |
| | | TUser user = DbUtils.getUser(request); |
| | | List<SysMenu> menu = masterAuthorService.getMenu(user.getUserId()); |
| | | List<SysMenu> menu = masterAuthorService.getMenu(user); |
| | | return Result.success(menu) ; |
| | | } |
| | | |
| | |
| | | flows = flows.stream().filter(flow -> flowsService.isNextAudit(flow, userId)).collect(Collectors.toList()); |
| | | |
| | | HashSet<String> tableNameSet = new HashSet<>(); |
| | | List<String> maintainIds = flows.stream().map(Flows::getBusinessId).collect(Collectors.toList()); |
| | | if (maintainIds.size() == 0) { |
| | | List<String> maintainIds = flows.stream().filter(flow -> flow.getBusinessType().equals(ActivitiBusinessType.maintain)).map(Flows::getBusinessId).collect(Collectors.toList()); |
| | | List<String> maintainFieldIds = flows.stream().filter(flow -> flow.getBusinessType().equals(ActivitiBusinessType.field)).map(Flows::getBusinessId).collect(Collectors.toList()); |
| | | |
| | | if (maintainIds.isEmpty() && maintainFieldIds.isEmpty()) { |
| | | return Result.success(null); |
| | | } |
| | | List<Maintain> maintains = maintainService.selectBatchIds(maintainIds); |
| | | List<String> tableNameList = maintains.stream().map(Maintain::getTableName).collect(Collectors.toList()); |
| | | tableNameSet.addAll(tableNameList); |
| | | // |
| | | List<MaintainField> maintainFields = maintainFieldService.selectBatchIds(maintainIds); |
| | | tableNameSet.addAll(maintainFields.stream().map(MaintainField::getTableName).collect(Collectors.toList())); |
| | | for (String maintainFieldId : maintainFieldIds) { |
| | | MaintainField maintainField = maintainFieldService.selectById(maintainFieldId); |
| | | if (maintainField == null) { |
| | | continue; |
| | | } |
| | | String tableName = maintainField.getTableName(); |
| | | if (StringUtils.isEmpty(tableName)) { |
| | | continue; |
| | | } |
| | | tableNameSet.add(tableName); |
| | | } |
| | | maintainIds = maintainIds.stream().filter(s -> masterAuthorService.checkMaintainAuthor(user,s)).collect(Collectors.toList()); |
| | | if (!maintainIds.isEmpty()) { |
| | | List<Maintain> maintains = maintainService.selectBatchIds(maintainIds); |
| | | |
| | | List<String> tableNameList = maintains.stream().map(Maintain::getTableName).collect(Collectors.toList()); |
| | | tableNameSet.addAll(tableNameList); |
| | | } |
| | | if (tableNameSet.size() == 0) { |
| | | return Result.success(null); |
| | | } |
| | | List<MenuMapping> menuMappingList = menuMappingService.selectList(new EntityWrapper<MenuMapping>().in("table_name", tableNameSet)); |
| | | List<String> menuIds = menuMappingList.stream().map(MenuMapping::getMenuId).collect(Collectors.toList()); |
| | | if (menuIds.isEmpty()) { |
| | | return Result.success(null); |
| | | } |
| | | LinkedHashSet<String> parentIdSet = new LinkedHashSet<>(menuIds); |
| | | Set<String> byParentId = menuService.getByParentId(parentIdSet); |
| | | List<SysMenu> parentList = menuService.selectBatchIds(byParentId); |
| | | List<SysMenu> parentList = menuService.getMenuByParentId(parentIdSet); |
| | | if (parentList == null) { |
| | | return Result.success(null); |
| | | } |
| | | |
| | | return Result.success(parentList); |
| | | } |
| | |
| | | } |
| | | parentIdSet.add(sysMenu.getId()); |
| | | } |
| | | Set<String> byParentId = menuService.getByParentId(parentIdSet); |
| | | List<SysMenu> parentList = menuService.selectBatchIds(byParentId); |
| | | List<SysMenu> parentList = menuService.getMenuByParentId(parentIdSet); |
| | | |
| | | return Result.success(parentList) ; |
| | | } |
| | |
| | | menu.setId(uuid); |
| | | menu.setParentId(parentId); |
| | | menu.setOrderNo(orderno); |
| | | menu.setMenuType(menuType); |
| | | menu.setMenuType(menuType).setCreateTime(new Date()); |
| | | boolean inserted = menuService.insert(menu); |
| | | if (inserted) { |
| | | return Result.success(menu); |
| | |
| | | }else { |
| | | orderno = Integer.valueOf(ordernoStr); |
| | | } |
| | | menu = new SysMenu().setId(id).setParentId(parentId).setMenuType(menuType).setName(name).setOrderNo(orderno); |
| | | menu = new SysMenu().setCreateTime(new Date()).setId(id).setParentId(parentId).setMenuType(menuType).setName(name).setOrderNo(orderno); |
| | | menu.insert(); |
| | | } |
| | | |
| | |
| | | @RequestMapping(value = "/update", method = RequestMethod.GET) |
| | | public Result<Object> update(@RequestParam String id, HttpServletRequest request) { |
| | | SysMenu menu = menuService.selectById(id); |
| | | |
| | | if (menu == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | | } |
| | | menu.setUpdateTime(new Date()); |
| | | String ordernoStr = request.getParameter("orderNo"); |
| | | String parentId = request.getParameter("parentId"); |
| | | String menuType = request.getParameter("menuType"); |
| | |
| | | return result; |
| | | } |
| | | @RequestMapping(value = "/delete/{menuid}", method = RequestMethod.GET) |
| | | public Result<Object> delete(@PathVariable String menuid) throws Exception { |
| | | public Result<Object> delete(@PathVariable String menuid, HttpServletRequest request) throws Exception { |
| | | TUser user = DbUtils.getUser(request); |
| | | Result<List<SysMenu>> all = getAll(); |
| | | List<SysMenu> data = all.getData(); |
| | | SysMenu parentMenu = menuService.selectById(menuid); |
| | | |
| | | HashSet<SysMenu> sysMenus = deleteMenuByParentId(data, menuid); |
| | | |
| | | 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(); |
| | | menuMapping.deleteById(); |
| | | |
| | | |
| | | } |
| | | |
| | | sysMenu.deleteById(); |
| | | } |
| | | boolean delete = menuService.deleteById(menuid); |
| | | if (parentMenu == null) { |
| | | return Result.success(null); |
| | | } |
| | | String menuType = parentMenu.getMenuType(); |
| | | |
| | | boolean delete = parentMenu.deleteById(); |
| | | if (delete) { |
| | | return Result.success(null); |
| | | } else { |