提交 6983ee7d 编写于 作者: zhouweidong's avatar zhouweidong

uaa权限校验usr代码

上级 1977630f
......@@ -90,6 +90,7 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
"/**/img/**",
"/"
).permitAll()
.antMatchers("/ibzou/org/**").permitAll()
//放行登录请求
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll()
.anyRequest().authenticated()
......
package cn.ibizlab.ouapi.rest.extensions;
import cn.ibizlab.core.ou.service.IIBZOrganizationService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 上下级组织信息查询服务
*/
@RestController
public class OrgFeignService {
@Autowired
IIBZOrganizationService orgService;
/**
* 获取上下级组织、部门信息
* @return
*/
@GetMapping("/ibzou/org/{loginname}")
public JSONObject getOrgInfo(@PathVariable("loginname") String loginName){
String orgLevel="";
String deptLevel="";
JSONObject orgInfo= new JSONObject();
JSONObject org = new JSONObject();
JSONObject orgDept = new JSONObject();
//查询用户的levelCode
List<JSONObject> empInfo= orgService.select(String.format("select t1.ORGLEVEL,t2.DEPTLEVEL from ibzemp t left join ibzorg t1 on t.orgid =t1.orgid left join ibzdept t2 on t.MDEPTID=t2.DEPTID where t.LOGINNAME='%s' ",loginName));
if(empInfo.size()==0)
return null;
orgLevel=empInfo.get(0).getString("ORGLEVEL");
deptLevel=empInfo.get(0).getString("DEPTLEVEL");
//通过levelCode查询上下级组织信息
List<JSONObject> pOrgLists= orgService.select(String.format("select orgid from ibzorg t where INSTR('%s', t.orglevel )=1 ",orgLevel));
List<JSONObject> sOrgLists= orgService.select(String.format("select orgid from ibzorg t where INSTR(t.orglevel ,'%s' )=1 ",orgLevel));
List<JSONObject> pOrgDeptLists= orgService.select(String.format("select deptid from ibzdept t where INSTR(t.deptlevel ,'%s')=1 ",deptLevel));
List<JSONObject> sOrgDeptLists= orgService.select(String.format("select deptid from ibzdept t where INSTR('%s',t.deptlevel )=1 ",deptLevel));
org.put("porg",parseData(pOrgLists,"orgid"));
org.put("sorg",parseData(sOrgLists,"orgid"));
orgDept.put("porgdept",parseData(pOrgDeptLists,"deptid"));
orgDept.put("sorgdept",parseData(sOrgDeptLists,"deptid"));
orgInfo.put("org",org);
orgInfo.put("orgdept",orgDept);
return orgInfo;
}
/**
* 数据解析
* @param datas
* @return
*/
private JSONArray parseData(List<JSONObject> datas , String field ){
JSONArray array=new JSONArray();
if(datas.size()>0){
for(JSONObject org: datas){
array.add(org.getString(field));
}
}
return array;
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册