@Test public void testUpdatePublishStatus() 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 publishStatus = instanceEntity.getPubStatus(); String result = uiInstanceService.updatePublishStatus(request, Integer.toString(publishStatus), instanceEntity.getId()); Assert.assertEquals("false", result); }
@Transactional(rollbackFor = Exception.class) public String updatePublishStatus(HttpServletRequest request, String pubStatus, 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())); List<Long> instanceIds = new ArrayList<>(); instanceIds.add(instanceId); char[] arr = pubStatus.toCharArray(); arr[0] = (arr[0] == '0' ? '1' : '0'); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { AdjustRequest adjustRequest = new AdjustRequest(); adjustRequest.setIds(instanceIds); adjustRequest.setUp(!"1".equals(pubStatus)); instanceService.adjust(adjustRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了发布槽位,从" + pubStatus + "改为" + new String(arr, 0, arr.length) + Constant.getPubDescription()); return "true"; } catch (Exception e) { return "false"; } } else { return "false"; } }
UiInstanceService { @Transactional(rollbackFor = Exception.class) public String updatePublishStatus(HttpServletRequest request, String pubStatus, 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())); List<Long> instanceIds = new ArrayList<>(); instanceIds.add(instanceId); char[] arr = pubStatus.toCharArray(); arr[0] = (arr[0] == '0' ? '1' : '0'); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { AdjustRequest adjustRequest = new AdjustRequest(); adjustRequest.setIds(instanceIds); adjustRequest.setUp(!"1".equals(pubStatus)); instanceService.adjust(adjustRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了发布槽位,从" + pubStatus + "改为" + new String(arr, 0, arr.length) + Constant.getPubDescription()); return "true"; } catch (Exception e) { return "false"; } } else { return "false"; } } }
UiInstanceService { @Transactional(rollbackFor = Exception.class) public String updatePublishStatus(HttpServletRequest request, String pubStatus, 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())); List<Long> instanceIds = new ArrayList<>(); instanceIds.add(instanceId); char[] arr = pubStatus.toCharArray(); arr[0] = (arr[0] == '0' ? '1' : '0'); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { AdjustRequest adjustRequest = new AdjustRequest(); adjustRequest.setIds(instanceIds); adjustRequest.setUp(!"1".equals(pubStatus)); instanceService.adjust(adjustRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了发布槽位,从" + pubStatus + "改为" + new String(arr, 0, arr.length) + Constant.getPubDescription()); return "true"; } catch (Exception e) { return "false"; } } else { return "false"; } }  }
UiInstanceService { @Transactional(rollbackFor = Exception.class) public String updatePublishStatus(HttpServletRequest request, String pubStatus, 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())); List<Long> instanceIds = new ArrayList<>(); instanceIds.add(instanceId); char[] arr = pubStatus.toCharArray(); arr[0] = (arr[0] == '0' ? '1' : '0'); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { AdjustRequest adjustRequest = new AdjustRequest(); adjustRequest.setIds(instanceIds); adjustRequest.setUp(!"1".equals(pubStatus)); instanceService.adjust(adjustRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了发布槽位,从" + pubStatus + "改为" + new String(arr, 0, arr.length) + Constant.getPubDescription()); 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 updatePublishStatus(HttpServletRequest request, String pubStatus, 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())); List<Long> instanceIds = new ArrayList<>(); instanceIds.add(instanceId); char[] arr = pubStatus.toCharArray(); arr[0] = (arr[0] == '0' ? '1' : '0'); if (role == Constant.getSuperUser() || role == Constant.getAppManager()) { try { AdjustRequest adjustRequest = new AdjustRequest(); adjustRequest.setIds(instanceIds); adjustRequest.setUp(!"1".equals(pubStatus)); instanceService.adjust(adjustRequest); uiAuditLogService.insertLog(request, "instance", instanceId, "修改了发布槽位,从" + pubStatus + "改为" + new String(arr, 0, arr.length) + Constant.getPubDescription()); 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();  }