@Test public void testUpdateSupperStatus() throws Exception{ RegisterInstanceRequest registerInstanceRequest = RegisterInstanceUtil.setRegisterInstanceRequest(); RegisterInstanceResponse response = instanceService.registerInstance(registerInstanceRequest); Thread.sleep(2 * 1000); InstanceEntity testInstanceEntity = RegisterInstanceUtil.createTestInstanceEntity(); HttpServletRequest request = new MockHttpServletRequest(); InstanceEntity instanceEntity = instanceService.findByCandInstanceId("w545878765"); Assert.assertEquals(testInstanceEntity.getAppClusterName(), instanceEntity.getAppClusterName()); int superStatus = instanceEntity.getSupperStatus(); String result = uiInstanceService.updateSupperStatus(request, Integer.toString(superStatus), "1", instanceEntity.getId()); Assert.assertEquals("false", result); }
@Transactional(rollbackFor = Exception.class) public String updateSupperStatus(HttpServletRequest request, String originalStatus, String supperStatus, long instanceId) { Map<String, AppEntity> appMap=appService.getCacheData(); List<CombinedInstanceDto> combinedInstanceDtos=uiInstanceRepository.findByInstanceId(Long.toString(instanceId)); int role = uiUserService.getRole(appMap.get(combinedInstanceDtos.get(0).getCandAppId())); AdjustSupperStatusRequest adjustSupperStatusRequest = new AdjustSupperStatusRequest(); try { adjustSupperStatusRequest.setStatus(Integer.parseInt(supperStatus)); } catch (Exception e) { return "false"; } List<Long> ids = new ArrayList<>(); ids.add(instanceId); adjustSupperStatusRequest.setIds(ids); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { instanceService.adjustSupperStatus(adjustSupperStatusRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了超级槽位,从" + originalStatus + "改为" + supperStatus + Constant.getSubDescription()); return "true"; } catch (Exception e) { return "false"; } } else { return "false"; } }
UiInstanceService { @Transactional(rollbackFor = Exception.class) public String updateSupperStatus(HttpServletRequest request, String originalStatus, String supperStatus, long instanceId) { Map<String, AppEntity> appMap=appService.getCacheData(); List<CombinedInstanceDto> combinedInstanceDtos=uiInstanceRepository.findByInstanceId(Long.toString(instanceId)); int role = uiUserService.getRole(appMap.get(combinedInstanceDtos.get(0).getCandAppId())); AdjustSupperStatusRequest adjustSupperStatusRequest = new AdjustSupperStatusRequest(); try { adjustSupperStatusRequest.setStatus(Integer.parseInt(supperStatus)); } catch (Exception e) { return "false"; } List<Long> ids = new ArrayList<>(); ids.add(instanceId); adjustSupperStatusRequest.setIds(ids); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { instanceService.adjustSupperStatus(adjustSupperStatusRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了超级槽位,从" + originalStatus + "改为" + supperStatus + Constant.getSubDescription()); return "true"; } catch (Exception e) { return "false"; } } else { return "false"; } } }
UiInstanceService { @Transactional(rollbackFor = Exception.class) public String updateSupperStatus(HttpServletRequest request, String originalStatus, String supperStatus, long instanceId) { Map<String, AppEntity> appMap=appService.getCacheData(); List<CombinedInstanceDto> combinedInstanceDtos=uiInstanceRepository.findByInstanceId(Long.toString(instanceId)); int role = uiUserService.getRole(appMap.get(combinedInstanceDtos.get(0).getCandAppId())); AdjustSupperStatusRequest adjustSupperStatusRequest = new AdjustSupperStatusRequest(); try { adjustSupperStatusRequest.setStatus(Integer.parseInt(supperStatus)); } catch (Exception e) { return "false"; } List<Long> ids = new ArrayList<>(); ids.add(instanceId); adjustSupperStatusRequest.setIds(ids); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { instanceService.adjustSupperStatus(adjustSupperStatusRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了超级槽位,从" + originalStatus + "改为" + supperStatus + Constant.getSubDescription()); return "true"; } catch (Exception e) { return "false"; } } else { return "false"; } }  }
UiInstanceService { @Transactional(rollbackFor = Exception.class) public String updateSupperStatus(HttpServletRequest request, String originalStatus, String supperStatus, long instanceId) { Map<String, AppEntity> appMap=appService.getCacheData(); List<CombinedInstanceDto> combinedInstanceDtos=uiInstanceRepository.findByInstanceId(Long.toString(instanceId)); int role = uiUserService.getRole(appMap.get(combinedInstanceDtos.get(0).getCandAppId())); AdjustSupperStatusRequest adjustSupperStatusRequest = new AdjustSupperStatusRequest(); try { adjustSupperStatusRequest.setStatus(Integer.parseInt(supperStatus)); } catch (Exception e) { return "false"; } List<Long> ids = new ArrayList<>(); ids.add(instanceId); adjustSupperStatusRequest.setIds(ids); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { instanceService.adjustSupperStatus(adjustSupperStatusRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了超级槽位,从" + originalStatus + "改为" + supperStatus + Constant.getSubDescription()); return "true"; } catch (Exception e) { return "false"; } } else { return "false"; } }  UiResponse findInstance(HttpServletRequest request, Map parameterMap); UiResponse findExpiredInstance(HttpServletRequest request, Map parameterMap); UiResponse deleteById(long instanceId); UiResponse findByInstanceId(HttpServletRequest request, String instanceId); void setFinalStatus(CombinedInstanceDto combinedInstanceDto); @Transactional(rollbackFor = Exception.class) String updateSupperStatus(HttpServletRequest request, String originalStatus, String supperStatus, long instanceId); @Transactional(rollbackFor = Exception.class) String updatePublishStatus(HttpServletRequest request, String pubStatus, long instanceId); List<String> getAllSdkVersion(); }
UiInstanceService { @Transactional(rollbackFor = Exception.class) public String updateSupperStatus(HttpServletRequest request, String originalStatus, String supperStatus, long instanceId) { Map<String, AppEntity> appMap=appService.getCacheData(); List<CombinedInstanceDto> combinedInstanceDtos=uiInstanceRepository.findByInstanceId(Long.toString(instanceId)); int role = uiUserService.getRole(appMap.get(combinedInstanceDtos.get(0).getCandAppId())); AdjustSupperStatusRequest adjustSupperStatusRequest = new AdjustSupperStatusRequest(); try { adjustSupperStatusRequest.setStatus(Integer.parseInt(supperStatus)); } catch (Exception e) { return "false"; } List<Long> ids = new ArrayList<>(); ids.add(instanceId); adjustSupperStatusRequest.setIds(ids); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { instanceService.adjustSupperStatus(adjustSupperStatusRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了超级槽位,从" + originalStatus + "改为" + supperStatus + Constant.getSubDescription()); return "true"; } catch (Exception e) { return "false"; } } else { return "false"; } }  UiResponse findInstance(HttpServletRequest request, Map parameterMap); UiResponse findExpiredInstance(HttpServletRequest request, Map parameterMap); UiResponse deleteById(long instanceId); UiResponse findByInstanceId(HttpServletRequest request, String instanceId); void setFinalStatus(CombinedInstanceDto combinedInstanceDto); @Transactional(rollbackFor = Exception.class) String updateSupperStatus(HttpServletRequest request, String originalStatus, String supperStatus, long instanceId); @Transactional(rollbackFor = Exception.class) String updatePublishStatus(HttpServletRequest request, String pubStatus, long instanceId); List<String> getAllSdkVersion();  }