| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.highdatas.mdm.entity.DeletedTableLog; |
| | | import com.highdatas.mdm.entity.MenuMapping; |
| | | import com.highdatas.mdm.entity.SysMenu; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.pojo.ActivitiBusinessType; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | 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.ISysMenuService; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Autowired |
| | | IMenuMappingService menuMappingService; |
| | | |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | @Autowired |
| | | IDeletedTableLogService deletedTableLogService; |
| | | |
| | | @Autowired |
| | | IFlowsService flowsService; |
| | | @Autowired |
| | | IMaintainService maintainService; |
| | | @Autowired |
| | | IMaintainFieldService maintainFieldService; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | |
| | | @RequestMapping(value = "/all", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> getAll() { |
| | | EntityWrapper<SysMenu> sysMenuEntityWrapper = new EntityWrapper<>(); |
| | | sysMenuEntityWrapper.orderBy(" parent_id, order_no"); |
| | | sysMenuEntityWrapper.orderBy("parent_id, order_no"); |
| | | return Result.success(menuService.selectList(sysMenuEntityWrapper)) ; |
| | | } |
| | | |
| | | @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()); |
| | | return Result.success(menu) ; |
| | | } |
| | | |
| | | @RequestMapping(value = "/audit", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> audit(HttpServletRequest request) { |
| | | HttpSession session = request.getSession(); |
| | | TUser user = (TUser) session.getAttribute("user"); |
| | | String userId = user.getUserId(); |
| | | List<Flows> flows = flowsService.selectList(new EntityWrapper<Flows>().ne("business_type", ActivitiBusinessType.exists).ne("status", ActivitiStatus.open).ne("status", ActivitiStatus.close)); |
| | | 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) { |
| | | return Result.success(null); |
| | | } |
| | | maintainIds = maintainIds.stream().filter(s -> masterAuthorService.checkMaintainAuthor(userId,s)).collect(Collectors.toList()); |
| | | if (maintainIds.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())); |
| | | 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()); |
| | | LinkedHashSet<String> parentIdSet = new LinkedHashSet<>(menuIds); |
| | | Set<String> byParentId = menuService.getByParentId(parentIdSet); |
| | | List<SysMenu> parentList = menuService.selectBatchIds(byParentId); |
| | | |
| | | return Result.success(parentList); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/list", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> getMenuList() { |
| | | EntityWrapper<SysMenu> sysMenuEntityWrapper = new EntityWrapper<>(); |
| | | sysMenuEntityWrapper.eq("menu_type", "DataMenu"); |
| | | sysMenuEntityWrapper.orderBy("parent_id, order_no"); |
| | | List<SysMenu> sysMenus = menuService.selectList(sysMenuEntityWrapper); |
| | | LinkedHashSet<String> parentIdSet = new LinkedHashSet<>(); |
| | | for (SysMenu sysMenu : sysMenus) { |
| | | 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 || fieldByTable.size() == 0) { |
| | | continue; |
| | | } |
| | | parentIdSet.add(sysMenu.getId()); |
| | | } |
| | | Set<String> byParentId = menuService.getByParentId(parentIdSet); |
| | | List<SysMenu> parentList = menuService.selectBatchIds(byParentId); |
| | | |
| | | return Result.success(parentList) ; |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/allTheme", method = RequestMethod.GET) |
| | | public Result<List<SysMenu>> getAllTheme() { |
| | | EntityWrapper<SysMenu> sysMenuEntityWrapper = new EntityWrapper<>(); |
| | | sysMenuEntityWrapper.eq("menu_type",Constant.StructureMenu).orderBy("parent_id desc "); |
| | | sysMenuEntityWrapper.eq("menu_type",Constant.StructureMenu).orderBy("parent_id desc"); |
| | | return Result.success(menuService.selectList(sysMenuEntityWrapper)) ; |
| | | } |
| | | |
| | |
| | | public Result<Page<SysMenu>> getAll(@PathVariable int pageno, HttpServletRequest request) { |
| | | String pageSize = request.getParameter("pageSize"); |
| | | if (StringUtils.isEmpty(pageSize)) { |
| | | pageSize = "20"; |
| | | pageSize = "15"; |
| | | } |
| | | Integer size = Integer.valueOf(pageSize); |
| | | Page page = new Page(pageno, size); |
| | |
| | | menu.setId(uuid); |
| | | menu.setParentId(parentId); |
| | | menu.setOrderNo(orderno); |
| | | menu.setDataType(MaintainDataType.parse(dataType)); |
| | | menu.setMenuType(menuType); |
| | | boolean inserted = menuService.insert(menu); |
| | | if (inserted) { |
| | | return Result.success("插入成功", null); |
| | | return Result.success(menu); |
| | | } else { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | |
| | | 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); |
| | | return Result.success(menu); |
| | | } |
| | | |
| | | @RequestMapping(value = "/update", method = RequestMethod.GET) |
| | |
| | | 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(); |
| | |
| | | List<SysMenu> sysMenus = menuService.selectList(menuEntityWrapper); |
| | | return Result.success(sysMenus); |
| | | } |
| | | |
| | | |
| | | } |