OrganizaService.java
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.modules.model.BaseAreaDto;
import cn.com.glsx.usercenter.api.dto.response.Organization;
import cn.com.glsx.usercenter.api.feign.OrganizationService;
import com.glsx.plat.core.web.R;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Type;
import java.util.List;
@Service
public class OrganizaService {
@Autowired
private OrganizationService organizationService;
public void drawOrganization(List<? extends BaseAreaDto> list){
Type type = new TypeToken<List<Organization>>() {
}.getType();
list.forEach(efd -> {
R<List<Organization>> listR = organizationService.getTenantPathsByUserId(efd.getCreatedBy());
List<Organization> orgList = listR.getDataList(type);
if (CollectionUtils.isNotEmpty(orgList)) {
int size = orgList.size();
if(size<2){
return;
}else{
efd.setArea(orgList.get(1).getOrgName());
if(size>2){
efd.setProvince(orgList.get(2).getOrgName());
}
if(size>3){
efd.setCity(orgList.get(3).getOrgName());
}
}
}
});
}
}