package cn.autoform.web.controller.CscApi;
|
|
import cn.autoform.bean.system.UserInfo;
|
import cn.autoform.fw.exception.RestResult;
|
import cn.autoform.fw.utility.RestResultGenerator;
|
import cn.autoform.util.thread.Keys;
|
import cn.autoform.util.thread.ThreadData;
|
import cn.autoform.web.client.CscApiService;
|
import cn.autoform.web.client.bean.*;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.ui.ModelMap;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.List;
|
import java.util.Map;
|
|
@RestController
|
public class CscApiController {
|
|
@Autowired
|
private CscApiService cscApi;
|
|
|
/**
|
* 根据租户id查询租户对应的组织机构信息
|
* @return
|
*/
|
@RequestMapping(value = "${requset.findOrganizationByTenantId}", method = RequestMethod.POST)
|
public RestResult<Map<String,Object>> findOrganizationByTenantId(@RequestBody Map<String,Object> map){
|
return RestResultGenerator.genSuccessResult(cscApi.findOrganizationByTenantId(map));
|
}
|
|
/**
|
* 根据comanyID查询组织机构
|
*/
|
@RequestMapping(value = "${requset.findRelationDetail}", method = RequestMethod.POST)
|
public RestResult<List<Organization>> findRelationDetail(@RequestBody Map<String,Object> map){
|
return RestResultGenerator.genSuccessResult(
|
cscApi.findRelationDetail(new ModelMap("companyId", ThreadData.get(Keys.COMPANY_ID))));
|
}
|
|
/**
|
* 根据comanyID查询组织机构,用于切换公司信息
|
*/
|
@RequestMapping(value = "${requset.findTenantsAndCompanys}", method = RequestMethod.POST)
|
public RestResult<TenantsAndCompanys> findTenantsAndCompanys(){
|
return RestResultGenerator.genSuccessResult(cscApi.findTenantsAndCompanys());
|
}
|
|
/**
|
* 根据comanyID查询组织机构,用于切换公司信息
|
*/
|
@RequestMapping(value = "${requset.userInfo}", method = RequestMethod.POST)
|
public RestResult<UserInfo> userInfo(){
|
UserInfo user = new UserInfo();
|
//取出当前用户所在公司ID
|
TenantsAndCompanys o = null;
|
o = cscApi.findTenantsAndCompanys();
|
if(o==null){
|
return RestResultGenerator.genSuccessResult(user);
|
}
|
|
boolean flase = false;
|
for(Tenant tenant :o.getTenants()){
|
user.setTenantId(tenant.getId());
|
for(Company com :tenant.getCompanys()){
|
user.setCompanyId(com.getId());
|
user.setHotInfoCompanyId(com.getHotInfoCompanyId());
|
for(SystemManager sys :com.getData()){
|
user.setServiceId(sys.getId());
|
}
|
// flase = true;
|
// break;
|
}
|
// if(flase){
|
// break;
|
// }
|
}
|
if(user.getTenantId() == null){
|
|
System.out.println("进入"+user.getTenantId());
|
return RestResultGenerator.genSuccessResult(user);
|
}
|
Organization org = cscApi.findOrganization(user.getTenantId());
|
|
user.setUid(org.getCode());
|
return RestResultGenerator.genSuccessResult(user);
|
}
|
public Object getUserId(List<Organization> orgs,String openId,UserInfo user){
|
for(Organization org : orgs){
|
for(User users: org.getUsers()){
|
if(users.getOpenId().equals(openId)){
|
user.setUid(users.getId());
|
return null;
|
}
|
}
|
}
|
return null;
|
}
|
|
|
|
}
|