commit | author | age
|
a18bfa
|
1 |
package cn.autoform.web.controller.CscApi; |
Z |
2 |
|
|
3 |
import cn.autoform.bean.system.UserInfo; |
|
4 |
import cn.autoform.fw.exception.RestResult; |
|
5 |
import cn.autoform.fw.utility.RestResultGenerator; |
|
6 |
import cn.autoform.util.thread.Keys; |
|
7 |
import cn.autoform.util.thread.ThreadData; |
|
8 |
import cn.autoform.web.client.CscApiService; |
|
9 |
import cn.autoform.web.client.bean.*; |
|
10 |
import org.springframework.beans.factory.annotation.Autowired; |
|
11 |
import org.springframework.ui.ModelMap; |
|
12 |
import org.springframework.web.bind.annotation.RequestBody; |
|
13 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
14 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
15 |
import org.springframework.web.bind.annotation.RestController; |
|
16 |
|
|
17 |
import java.util.List; |
|
18 |
import java.util.Map; |
|
19 |
|
|
20 |
@RestController |
|
21 |
public class CscApiController { |
|
22 |
|
|
23 |
@Autowired |
|
24 |
private CscApiService cscApi; |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* 根据租户id查询租户对应的组织机构信息 |
|
29 |
* @return |
|
30 |
*/ |
|
31 |
@RequestMapping(value = "${requset.findOrganizationByTenantId}", method = RequestMethod.POST) |
|
32 |
public RestResult<Map<String,Object>> findOrganizationByTenantId(@RequestBody Map<String,Object> map){ |
|
33 |
return RestResultGenerator.genSuccessResult(cscApi.findOrganizationByTenantId(map)); |
|
34 |
} |
|
35 |
|
|
36 |
/** |
|
37 |
* 根据comanyID查询组织机构 |
|
38 |
*/ |
|
39 |
@RequestMapping(value = "${requset.findRelationDetail}", method = RequestMethod.POST) |
|
40 |
public RestResult<List<Organization>> findRelationDetail(@RequestBody Map<String,Object> map){ |
|
41 |
return RestResultGenerator.genSuccessResult( |
|
42 |
cscApi.findRelationDetail(new ModelMap("companyId", ThreadData.get(Keys.COMPANY_ID)))); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* 根据comanyID查询组织机构,用于切换公司信息 |
|
47 |
*/ |
|
48 |
@RequestMapping(value = "${requset.findTenantsAndCompanys}", method = RequestMethod.POST) |
|
49 |
public RestResult<TenantsAndCompanys> findTenantsAndCompanys(){ |
|
50 |
return RestResultGenerator.genSuccessResult(cscApi.findTenantsAndCompanys()); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* 根据comanyID查询组织机构,用于切换公司信息 |
|
55 |
*/ |
|
56 |
@RequestMapping(value = "${requset.userInfo}", method = RequestMethod.POST) |
|
57 |
public RestResult<UserInfo> userInfo(){ |
|
58 |
UserInfo user = new UserInfo(); |
|
59 |
//取出当前用户所在公司ID |
|
60 |
TenantsAndCompanys o = null; |
|
61 |
o = cscApi.findTenantsAndCompanys(); |
|
62 |
if(o==null){ |
|
63 |
return RestResultGenerator.genSuccessResult(user); |
|
64 |
} |
|
65 |
|
|
66 |
boolean flase = false; |
|
67 |
for(Tenant tenant :o.getTenants()){ |
|
68 |
user.setTenantId(tenant.getId()); |
|
69 |
for(Company com :tenant.getCompanys()){ |
|
70 |
user.setCompanyId(com.getId()); |
|
71 |
user.setHotInfoCompanyId(com.getHotInfoCompanyId()); |
|
72 |
for(SystemManager sys :com.getData()){ |
|
73 |
user.setServiceId(sys.getId()); |
|
74 |
} |
|
75 |
// flase = true; |
|
76 |
// break; |
|
77 |
} |
|
78 |
// if(flase){ |
|
79 |
// break; |
|
80 |
// } |
|
81 |
} |
|
82 |
if(user.getTenantId() == null){ |
|
83 |
|
|
84 |
System.out.println("进入"+user.getTenantId()); |
|
85 |
return RestResultGenerator.genSuccessResult(user); |
|
86 |
} |
|
87 |
Organization org = cscApi.findOrganization(user.getTenantId()); |
|
88 |
|
|
89 |
user.setUid(org.getCode()); |
|
90 |
return RestResultGenerator.genSuccessResult(user); |
|
91 |
} |
|
92 |
public Object getUserId(List<Organization> orgs,String openId,UserInfo user){ |
|
93 |
for(Organization org : orgs){ |
|
94 |
for(User users: org.getUsers()){ |
|
95 |
if(users.getOpenId().equals(openId)){ |
|
96 |
user.setUid(users.getId()); |
|
97 |
return null; |
|
98 |
} |
|
99 |
} |
|
100 |
} |
|
101 |
return null; |
|
102 |
} |
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
} |