Search in sources :

Example 1 with BaseFeignClient

use of io.choerodon.agile.infra.feign.BaseFeignClient in project agile-service by open-hand.

the class FieldValueUtil method handleDefaultValue.

/**
 * 处理默认值
 *
 * @param fieldDetail
 */
public static void handleDefaultValue(ObjectSchemeFieldDetailVO fieldDetail) {
    switch(fieldDetail.getFieldType()) {
        case FieldType.CHECKBOX:
        case FieldType.MULTIPLE:
        case FieldType.RADIO:
        case FieldType.SINGLE:
        case FieldType.DATETIME:
        case FieldType.DATE:
        case FieldType.TIME:
        case FieldType.NUMBER:
        case FieldType.INPUT:
        case FieldType.TEXT:
            break;
        case FieldType.MEMBER:
            BaseFeignClient baseFeignClient = SpringBeanUtil.getBean(BaseFeignClient.class);
            if (fieldDetail.getDefaultValue() != null && !"".equals(fieldDetail.getDefaultValue())) {
                Long defaultValue = Long.valueOf(String.valueOf(fieldDetail.getDefaultValue()));
                fieldDetail.setDefaultValue(EncryptionUtils.encrypt(defaultValue));
                List<UserDTO> list = baseFeignClient.listUsersByIds(Arrays.asList(defaultValue).toArray(new Long[1]), false).getBody();
                if (!list.isEmpty()) {
                    fieldDetail.setDefaultValueObj(list.get(0));
                }
            }
            break;
        case FieldType.MULTI_MEMBER:
            BaseFeignClient baseFeignClient1 = SpringBeanUtil.getBean(BaseFeignClient.class);
            if (fieldDetail.getDefaultValue() != null && !"".equals(fieldDetail.getDefaultValue())) {
                String[] split = fieldDetail.getDefaultValue().split(",");
                List<UserDTO> defaultValueObjects = new ArrayList<>();
                List<Long> defaultValues = new ArrayList<>();
                for (String userId : split) {
                    Long defaultValue = Long.valueOf(userId);
                    defaultValues.add(defaultValue);
                    List<UserDTO> list = baseFeignClient1.listUsersByIds(Arrays.asList(defaultValue).toArray(new Long[1]), false).getBody();
                    if (!list.isEmpty()) {
                        defaultValueObjects.addAll(list);
                    }
                }
                fieldDetail.setDefaultValue(EncryptionUtils.encryptList(defaultValues).stream().collect(Collectors.joining(",")));
                fieldDetail.setDefaultValueObj(defaultValueObjects);
            }
            break;
        default:
            break;
    }
}
Also used : BaseFeignClient(io.choerodon.agile.infra.feign.BaseFeignClient) UserDTO(io.choerodon.agile.infra.dto.UserDTO)

Example 2 with BaseFeignClient

use of io.choerodon.agile.infra.feign.BaseFeignClient in project agile-service by open-hand.

the class FieldValueUtil method handleUserMap.

/**
 * 获取人员信息
 *
 * @param userIds
 * @return
 */
public static Map<Long, UserDTO> handleUserMap(List<Long> userIds) {
    Map<Long, UserDTO> map = new HashMap<>(userIds.size());
    BaseFeignClient baseFeignClient = SpringBeanUtil.getBean(BaseFeignClient.class);
    if (!userIds.isEmpty()) {
        map = baseFeignClient.listUsersByIds(userIds.toArray(new Long[userIds.size()]), false).getBody().stream().collect(Collectors.toMap(UserDTO::getId, x -> x));
    }
    return map;
}
Also used : BaseFeignClient(io.choerodon.agile.infra.feign.BaseFeignClient) UserDTO(io.choerodon.agile.infra.dto.UserDTO)

Example 3 with BaseFeignClient

use of io.choerodon.agile.infra.feign.BaseFeignClient in project agile-service by open-hand.

the class FeignConfigure method baseFeignClient.

@Bean
@Primary
BaseFeignClient baseFeignClient() {
    BaseFeignClient baseFeignClient = Mockito.mock(BaseFeignClientFallback.class);
    ProjectVO projectVO = new ProjectVO();
    projectVO.setId(1L);
    projectVO.setName("test");
    projectVO.setOrganizationId(1L);
    Mockito.when(baseFeignClient.queryProject(Matchers.anyLong())).thenReturn(new ResponseEntity<>(projectVO, HttpStatus.OK));
    List<ProjectRelationshipVO> rel = new ArrayList<>(2);
    ProjectRelationshipVO rel1 = new ProjectRelationshipVO();
    rel1.setProjectId(2L);
    rel1.setUserCount(2);
    rel1.setParentId(1L);
    rel1.setEnabled(true);
    rel1.setProgramId(1L);
    rel1.setProjCode("test1");
    rel1.setProjName("敏捷项目1");
    ProjectRelationshipVO rel2 = new ProjectRelationshipVO();
    rel2.setProjectId(3L);
    rel2.setUserCount(2);
    rel2.setParentId(1L);
    rel2.setEnabled(true);
    rel2.setProgramId(1L);
    rel2.setProjCode("test2");
    rel2.setProjName("敏捷项目2");
    rel.add(rel1);
    rel.add(rel2);
    Mockito.when(baseFeignClient.getProjUnderGroup(Matchers.anyLong(), Matchers.anyLong(), Matchers.anyBoolean())).thenReturn(new ResponseEntity<>(rel, HttpStatus.OK));
    return baseFeignClient;
}
Also used : BaseFeignClient(io.choerodon.agile.infra.feign.BaseFeignClient) ArrayList(java.util.ArrayList) ProjectRelationshipVO(io.choerodon.agile.api.vo.ProjectRelationshipVO) ProjectVO(io.choerodon.agile.api.vo.ProjectVO) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Aggregations

BaseFeignClient (io.choerodon.agile.infra.feign.BaseFeignClient)3 UserDTO (io.choerodon.agile.infra.dto.UserDTO)2 ProjectRelationshipVO (io.choerodon.agile.api.vo.ProjectRelationshipVO)1 ProjectVO (io.choerodon.agile.api.vo.ProjectVO)1 ArrayList (java.util.ArrayList)1 Bean (org.springframework.context.annotation.Bean)1 Primary (org.springframework.context.annotation.Primary)1