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

USR代码

上级 cd34d861
...@@ -19,7 +19,6 @@ import org.springframework.security.config.http.SessionCreationPolicy; ...@@ -19,7 +19,6 @@ import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.beans.factory.annotation.Qualifier;
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
...@@ -41,18 +40,6 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -41,18 +40,6 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
@Value("${ibiz.auth.path:v7/login}") @Value("${ibiz.auth.path:v7/login}")
private String loginPath; private String loginPath;
@Value("${ibiz.auth.logoutpath:v7/logout}")
private String logoutPath;
@Value("${ibiz.file.uploadpath:ibizutil/upload}")
private String uploadpath;
@Value("${ibiz.file.downloadpath:ibizutil/download}")
private String downloadpath;
@Value("${ibiz.file.previewpath:ibizutil/preview}")
private String previewpath;
@Autowired @Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth auth
...@@ -101,19 +88,13 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -101,19 +88,13 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
"/**/fonts/**", "/**/fonts/**",
"/**/js/**", "/**/js/**",
"/**/img/**", "/**/img/**",
"/", "/"
"webjars/**",
"/swagger-resources/**",
"/v2/**"
).permitAll() ).permitAll()
.antMatchers("/ibzou/org/**").permitAll()
.antMatchers("/ibzemployees/**/oumaps").permitAll()
.antMatchers("/dictionarys/**").permitAll()
//放行登录请求 //放行登录请求
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll() .antMatchers( HttpMethod.POST,"/"+loginPath).permitAll()
//放行注销请求
.antMatchers( HttpMethod.GET,"/"+logoutPath).permitAll()
// 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**").permitAll()
.anyRequest().authenticated() .anyRequest().authenticated()
// 防止iframe 造成跨域 // 防止iframe 造成跨域
.and().headers().frameOptions().disable(); .and().headers().frameOptions().disable();
......
package cn.ibizlab.core.ou.extensions.aspect;
import cn.ibizlab.core.ou.extensions.service.OUModelService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
* 实体属性默认值切面,只有新建(Create)时才会填充默认值
*/
@Aspect
@Order(0)
@Component
public class OUModelRefreshAspect
{
@Autowired
@Lazy
private OUModelService ouModelService;
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysOrganizationService.creat*(..))")
public void AfterCreateOrg(JoinPoint point) throws Exception {
ouModelService.refreshModel();
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysOrganizationService.updat*(..))")
public void AfterUpdateOrg(JoinPoint point) throws Exception {
ouModelService.refreshModel();
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysOrganizationService.remov*(..))")
public void AfterRemoveOrg(JoinPoint point) throws Exception {
ouModelService.refreshModel();
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysOrganizationService.sav*(..))")
public void AfterSaveOrg(JoinPoint point) throws Exception {
ouModelService.refreshModel();
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysDepartmentService.creat*(..))")
public void AfterCreateDept(JoinPoint point) throws Exception {
ouModelService.refreshModel();
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysDepartmentService.updat*(..))")
public void AfterUpdateDept(JoinPoint point) throws Exception {
ouModelService.refreshModel();
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysDepartmentService.remov*(..))")
public void AfterRemoveDept(JoinPoint point) throws Exception {
ouModelService.refreshModel();
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysDepartmentService.sav*(..))")
public void AfterSaveDept(JoinPoint point) throws Exception {
ouModelService.refreshModel();
}
}
package cn.ibizlab.core.ou.extensions.aspect;
import cn.ibizlab.core.ou.domain.SysDepartment;
import cn.ibizlab.core.ou.domain.SysEmployee;
import cn.ibizlab.core.ou.domain.SysOrganization;
import cn.ibizlab.core.ou.extensions.mapping.SysEmp2UserMapping;
import cn.ibizlab.core.ou.extensions.service.OUCoreService;
import cn.ibizlab.core.ou.service.ISysDepartmentService;
import cn.ibizlab.core.ou.service.ISysEmployeeService;
import cn.ibizlab.core.ou.service.ISysOrganizationService;
import cn.ibizlab.util.domain.IBZUSER;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.service.IBZUSERService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import java.util.List;
@Aspect
@Order(0)
@Component
public class SysEmp2UserAspect
{
@Autowired
@Lazy
@Qualifier("userservice")
private IBZUSERService ibzuserService;
@Autowired
@Lazy
private OUCoreService ouCoreService;
@Autowired
@Lazy
private ISysOrganizationService iibzOrganizationService;
@Autowired
@Lazy
private ISysDepartmentService iibzDepartmentService;
@Autowired
@Lazy
private SysEmp2UserMapping ibzEmp2UserMapping;
@Value("${ibiz.auth.pwencrymode:0}")
private int pwencrymode;
@Value("${ibiz.auth.defaultpasswd:123456}")
private String defaultPasswd;
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.getDraft*(..))")
public void BeforeGetDraft(JoinPoint point) throws Exception {
Object[] args = point.getArgs();
if (args.length > 0) {
Object obj = args[0];
if (obj instanceof SysEmployee) {
SysEmployee ibzEmployee = (SysEmployee) obj;
if(StringUtils.isEmpty(ibzEmployee.getOrgid())&&(!StringUtils.isEmpty(ibzEmployee.getMdeptid())))
{
ibzEmployee.setMaindept(iibzDepartmentService.get(ibzEmployee.getMdeptid()));
ibzEmployee.setOrgid(ibzEmployee.getMaindept().getOrgid());
ibzEmployee.setOrgname(ibzEmployee.getMaindept().getOrgname());
}
}
}
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.creat*(..))")
public void BeforeCreateEmp(JoinPoint point) throws Exception {
beforeSaveEmp(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.updat*(..))")
public void BeforeUpdateEmp(JoinPoint point) throws Exception {
beforeSaveEmp(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.sav*(..))")
public void BeforeSaveEmp(JoinPoint point) throws Exception {
beforeSaveEmp(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysOrganizationService.creat*(..))")
public void BeforeCreateOrg(JoinPoint point) throws Exception {
beforeSaveOrg(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysOrganizationService.updat*(..))")
public void BeforeUpdateOrg(JoinPoint point) throws Exception {
beforeSaveOrg(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysOrganizationService.sav*(..))")
public void BeforeSaveOrg(JoinPoint point) throws Exception {
beforeSaveOrg(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysDepartmentService.creat*(..))")
public void BeforeCreateDept(JoinPoint point) throws Exception {
beforeSaveDept(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysDepartmentService.save(..))")
public void BeforeSaveDept(JoinPoint point) throws Exception {
beforeSaveDept(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysDepartmentService.updat*(..))")
public void BeforeUpdateDept(JoinPoint point) throws Exception {
beforeSaveDept(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.ISysDepartmentService.saveBatch(..))")
public void BeforeSaveBatchDept(JoinPoint point) throws Exception {
beforeSaveDept(point);
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.creat*(..))")
public void AfterCreateEmp(JoinPoint point) throws Exception {
saveUser(point);
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.updat*(..))")
public void AfterUpdateEmp(JoinPoint point) throws Exception {
saveUser(point);
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.remove(..))")
public void AfterRemoveEmp(JoinPoint point) throws Exception {
removeUser(point);
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.removeBatch(..))")
public void AfterRemoveEmpBatch(JoinPoint point) throws Exception {
removeUser(point);
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.sav*(..))")
public void AfterSaveEmp(JoinPoint point) throws Exception {
saveUser(point);
}
@After(value = "execution(* cn.ibizlab.core.ou.service.ISysEmployeeService.initPwd(..))")
public void AfterInitPwd(JoinPoint point) throws Exception {
initPwd(point);
}
private void beforeSaveEmp(JoinPoint point)
{
Object[] args = point.getArgs();
if (args.length > 0)
{
Object obj = args[0];
if(obj instanceof SysEmployee)
{
prepareEmp((SysEmployee)obj,null);
}
else if (obj instanceof List)
{
List<SysEmployee> list=(List<SysEmployee>)obj;
Integer lastOrder = null;
for(SysEmployee emp:list)
{
prepareEmp(emp,lastOrder);
lastOrder=emp.getShoworder();
}
}
}
}
private void beforeSaveDept(JoinPoint point)
{
Object[] args = point.getArgs();
if (args.length > 0)
{
Object obj = args[0];
if(obj instanceof SysDepartment)
{
prepareDept((SysDepartment)obj,null);
}
else if (obj instanceof List)
{
List<SysDepartment> list=(List<SysDepartment>)obj;
Integer lastOrder = null;
for(SysDepartment dept:list)
{
prepareDept(dept,lastOrder);
lastOrder=dept.getShoworder();
}
}
}
}
private void beforeSaveOrg(JoinPoint point)
{
Object[] args = point.getArgs();
if (args.length > 0)
{
Object obj = args[0];
if(obj instanceof SysOrganization)
{
prepareOrg((SysOrganization)obj,null);
}
else if (obj instanceof List)
{
List<SysOrganization> list=(List<SysOrganization>)obj;
Integer lastOrder = null;
for(SysOrganization org:list)
{
prepareOrg(org,lastOrder);
lastOrder=org.getShoworder();
}
}
}
}
@Value("${ibiz.emp.defaultidformat:%s-%s}")
private String empdefaultidformat;
private void prepareEmp(SysEmployee emp,Integer lastOrder)
{
String userName=emp.getUsername();
if(StringUtils.isEmpty(emp.getUserid())&&(!StringUtils.isEmpty(emp.getUsercode()))&&(!StringUtils.isEmpty(emp.getOrgid())))
{
emp.setUserid(String.format(empdefaultidformat,emp.getOrgid(),emp.getUsercode()));
}
if(StringUtils.isEmpty(userName))
{
if(!StringUtils.isEmpty(emp.getDomains()))
userName= emp.getLoginname()+"|"+emp.getDomains();
else
userName = emp.getLoginname();
emp.setUsername(userName);
}
if((!StringUtils.isEmpty(emp.getMdeptid()))&&(!StringUtils.isEmpty(emp.getOrgid()))&&emp.getShoworder()==null)
{
if(lastOrder==null){
SysEmployee order=iibzEmployeeService.getOne(Wrappers.query(new SysEmployee()).select("max(showorder) as showorder").eq("mdeptid",emp.getMdeptid()).eq("orgid",emp.getOrgid()),false);
if(order!=null)
lastOrder=order.getShoworder();
}
if(lastOrder!=null)
lastOrder+=10;
else
lastOrder=10;
emp.setShoworder(lastOrder);
}
String password = emp.getPassword();
if(StringUtils.isEmpty(password))
{
password=defaultPasswd;
if(pwencrymode==1)
password = DigestUtils.md5DigestAsHex(password.getBytes());
else if(pwencrymode==2)
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", userName, password).getBytes());
emp.setPassword(password);
}
}
@Value("${ibiz.dept.defaultidformat:%s%s}")
private String deptdefaultidformat;
private void prepareDept(SysDepartment dept,Integer lastOrder)
{
if ((!StringUtils.isEmpty(dept.getDeptid()))&&(!StringUtils.isEmpty(dept.getParentdeptid())))
{
if(ouCoreService.getDeptModel(dept.getDeptid()).getSub().contains(dept.getParentdeptid()))
throw new BadRequestAlertException("上级部门选择有误","IBZDepartment",dept.getDeptid());
}
if (StringUtils.isEmpty(dept.getDeptid()) && (!StringUtils.isEmpty(dept.getDeptcode())) && (!StringUtils.isEmpty(dept.getOrgid())))
{
dept.setDeptid(String.format(deptdefaultidformat,dept.getOrgid() ,dept.getDeptcode()));
}
if((!StringUtils.isEmpty(dept.getOrgid()))&&dept.getShoworder()==null)
{
if(lastOrder==null){
SysDepartment order=iibzDepartmentService.getOne(Wrappers.query(new SysDepartment()).select("max(showorder) as showorder").eq("orgid",dept.getOrgid()),false);
if(order!=null)
lastOrder=order.getShoworder();
}
if(lastOrder!=null)
lastOrder+=10;
else
lastOrder=10;
dept.setShoworder(lastOrder);
}
}
private void prepareOrg(SysOrganization org,Integer lastOrder)
{
if ((!StringUtils.isEmpty(org.getOrgid()))&&(!StringUtils.isEmpty(org.getParentorgid())))
{
if(ouCoreService.getOrgModel(org.getOrgid()).getSub().contains(org.getParentorgid()))
throw new BadRequestAlertException("上级单位选择有误","IBZOrganization",org.getOrgid());
}
if(org.getShoworder()==null)
{
if(lastOrder==null)
{
SysOrganization order=iibzOrganizationService.getOne((Wrappers.query(new SysOrganization())).select("max(showorder) as showorder"),false);
if(order!=null)
lastOrder=order.getShoworder();
}
if(lastOrder!=null)
lastOrder+=10;
else
lastOrder=10;
org.setShoworder(lastOrder);
}
}
private void saveUser(JoinPoint point)
{
Object[] args = point.getArgs();
if (args.length > 0)
{
Object obj = args[0];
if(obj instanceof SysEmployee)
{
IBZUSER ibzuser=ibzEmp2UserMapping.toDto((SysEmployee)obj);
if(ibzuser.getLoginname().equalsIgnoreCase("ibzadmin"))
ibzuser.setSuperuser(1);
ibzuserService.saveOrUpdate(ibzuser);
}
else if (obj instanceof List)
{
ibzuserService.saveOrUpdateBatch(ibzEmp2UserMapping.toDto((List<SysEmployee>) obj));
}
}
}
private void removeUser(JoinPoint point)
{
Object[] args = point.getArgs();
if (args.length > 0)
{
Object obj = args[0];
if(obj instanceof String)
{
ibzuserService.removeById((String) obj);
}
else if (obj instanceof List)
{
ibzuserService.removeByIds((List) obj);
}
}
}
@Autowired
private ISysEmployeeService iibzEmployeeService;
public void initPwd(JoinPoint point) {
Object[] args = point.getArgs();
if (args.length > 0)
{
Object obj = args[0];
if (obj instanceof SysEmployee)
{
SysEmployee emp= ((SysEmployee)obj);
if(StringUtils.isEmpty(emp.getUserid()))
throw new BadRequestAlertException("没有找到要初始化密码的用户","IBZEMP","");
SysEmployee oldEmp=iibzEmployeeService.get(emp.getUserid());
if(StringUtils.isEmpty(oldEmp.getUsername()))
throw new BadRequestAlertException("没有找到要初始化密码的用户","IBZEMP","");
String password=defaultPasswd;
if(pwencrymode==1)
password = DigestUtils.md5DigestAsHex(password.getBytes());
else if(pwencrymode==2)
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", oldEmp.getUsername(), password).getBytes());
emp.setPassword(password);
this.iibzEmployeeService.update(emp);
}
}
}
}
package cn.ibizlab.core.ou.extensions.domain;
import cn.ibizlab.core.ou.domain.SysDepartment;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.util.LinkedHashSet;
import java.util.Set;
@Data
public class DeptMap {
private String deptid;
private SysDepartment dept;
private Set<String> parent=new LinkedHashSet<>();
private Set<String> sub=new LinkedHashSet<>();
private Set<String> father=new LinkedHashSet<>();
private Set<String> children=new LinkedHashSet<>();
public String getDeptid()
{
if(StringUtils.isEmpty(deptid)&&dept!=null)
deptid=dept.getDeptid();
return deptid;
}
public Set<String> getSub()
{
if(sub.size()==0&&(dept!=null||(!StringUtils.isEmpty(getDeptid()))))
sub.add(getDeptid());
return sub;
}
public Set<String> getParent()
{
if(parent.size()==0&&dept!=null&&(!StringUtils.isEmpty(dept.getParentdeptid())))
parent.add(dept.getParentdeptid());
return parent;
}
public Set<String> getFather()
{
if(father.size()==0&&getParent().size()>0)
father.add(parent.iterator().next());
return father;
}
}
package cn.ibizlab.core.ou.extensions.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class DeptNode {
@JSONField(name = "id")
@JsonProperty("id")
private String deptid;
@JSONField(name = "label")
@JsonProperty("label")
private String deptname;
@JSONField(name = "code")
@JsonProperty("code")
private String deptcode;
@JSONField(name = "level")
@JsonProperty("level")
private Integer deptlevel;
@JSONField(name = "bcode")
@JsonProperty("bcode")
private String bcode;
@JSONField(name = "filter")
@JsonProperty("filter")
private List<String> filter = new ArrayList<>();
private List<DeptNode> children = new ArrayList<>();
private boolean disabled = false;
public boolean getIsLeaf()
{
return children.size()==0;
}
}
package cn.ibizlab.core.ou.extensions.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class EmpNode {
@JSONField(name = "id")
@JsonProperty("id")
private String userid;
@JSONField(name = "label")
@JsonProperty("label")
private String personname;
@JSONField(name = "code")
@JsonProperty("code")
private String usercode;
private String loginname;
private String domains;
private String username;
private String bcode;
private String mdeptid;
private String mdeptcode;
private String mdeptname;
private String postid;
private String postcode;
private String postname;
private String orgid;
private String orgcode;
private String orgname;
private String nickname;
private String sex;
private String certcode;
private String phone;
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8")
@JSONField(format="yyyy-MM-dd")
private Timestamp birthday;
private String email;
private String avatar;
private String addr;
public String getGroup()
{
return mdeptname;
}
}
package cn.ibizlab.core.ou.extensions.domain;
import cn.ibizlab.core.ou.domain.SysOrganization;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.util.LinkedHashSet;
import java.util.Set;
@Data
public class OrgMap {
private String orgid;
private SysOrganization org;
private Set<String> parent=new LinkedHashSet<>();
private Set<String> sub=new LinkedHashSet<>();
private Set<String> father=new LinkedHashSet<>();
private Set<String> children=new LinkedHashSet<>();
public String getOrgid()
{
if(StringUtils.isEmpty(orgid)&&org!=null)
orgid=org.getOrgid();
return orgid;
}
public Set<String> getSub()
{
if(sub.size()==0&&(org!=null||(!StringUtils.isEmpty(getOrgid()))))
sub.add(getOrgid());
return sub;
}
public Set<String> getParent()
{
if(parent.size()==0&&org!=null&&(!StringUtils.isEmpty(org.getParentorgid())))
parent.add(org.getParentorgid());
return parent;
}
public Set<String> getFather()
{
if(father.size()==0&&getParent().size()>0)
father.add(parent.iterator().next());
return father;
}
}
package cn.ibizlab.core.ou.extensions.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class OrgNode {
@JSONField(name = "id")
@JsonProperty("id")
private String orgid;
@JSONField(name = "label")
@JsonProperty("label")
private String orgname;
@JSONField(name = "code")
@JsonProperty("code")
private String orgcode;
@JSONField(name = "level")
@JsonProperty("level")
private Integer orglevel;
@JSONField(name = "filter")
@JsonProperty("filter")
private List<String> filter = new ArrayList<>();
private List<OrgNode> children = new ArrayList<>();
private boolean disabled = false;
public boolean getIsLeaf()
{
return children.size()==0;
}
}
package cn.ibizlab.core.ou.extensions.mapping;
import cn.ibizlab.core.ou.domain.SysDepartment;
import cn.ibizlab.core.ou.extensions.domain.DeptNode;
import cn.ibizlab.util.domain.MappingBase;
import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
@Mapper(componentModel = "spring", uses = {},
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface SysDept2NodeMapping extends MappingBase<DeptNode, SysDepartment>
{
}
package cn.ibizlab.core.ou.extensions.mapping;
import cn.ibizlab.core.ou.domain.SysEmployee;
import cn.ibizlab.core.ou.extensions.domain.EmpNode;
import cn.ibizlab.util.domain.MappingBase;
import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
@Mapper(componentModel = "spring", uses = {},
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface SysEmp2NodeMapping extends MappingBase<EmpNode, SysEmployee>
{
}
package cn.ibizlab.core.ou.extensions.mapping;
import cn.ibizlab.core.ou.domain.SysEmployee;
import cn.ibizlab.util.domain.IBZUSER;
import cn.ibizlab.util.domain.MappingBase;
import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
@Mapper(componentModel = "spring", uses = {},
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface SysEmp2UserMapping extends MappingBase<IBZUSER, SysEmployee>
{
}
package cn.ibizlab.core.ou.extensions.mapping;
import cn.ibizlab.core.ou.domain.SysOrganization;
import cn.ibizlab.core.ou.extensions.domain.OrgNode;
import cn.ibizlab.util.domain.MappingBase;
import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
@Mapper(componentModel = "spring", uses = {},
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface SysOrg2NodeMapping extends MappingBase<OrgNode, SysOrganization>
{
}
package cn.ibizlab.core.ou.extensions.service;
import cn.ibizlab.core.ou.domain.SysDepartment;
import cn.ibizlab.core.ou.domain.SysEmployee;
import cn.ibizlab.core.ou.domain.SysOrganization;
import cn.ibizlab.core.ou.extensions.domain.*;
import cn.ibizlab.core.ou.extensions.mapping.SysDept2NodeMapping;
import cn.ibizlab.core.ou.extensions.mapping.SysEmp2NodeMapping;
import cn.ibizlab.core.ou.extensions.mapping.SysOrg2NodeMapping;
import cn.ibizlab.core.ou.service.ISysEmployeeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.*;
@Service
public class OUCoreService
{
@Autowired
@Lazy
private OUModelService ouModelService;
@Autowired
@Lazy
private ISysEmployeeService iibzEmployeeService;
public List<SysEmployee> getEmpByOrg(String orgid)
{
if(StringUtils.isEmpty(orgid) || "nullorgid".equals(orgid))
return new ArrayList<>();
return iibzEmployeeService.list(new QueryWrapper<SysEmployee>().eq("orgid",orgid).orderByAsc("showorder"));
}
public List<SysEmployee> getEmpByDept(String deptid)
{
if(StringUtils.isEmpty(deptid) || "nulldeptid".equals(deptid))
return new ArrayList<>();
return iibzEmployeeService.list(new QueryWrapper<SysEmployee>().eq("mdeptid",deptid).orderByAsc("showorder"));
}
public List<SysEmployee> getSubEmpByOrg(String orgid)
{
if(StringUtils.isEmpty(orgid) || "nullorgid".equals(orgid))
return new ArrayList<>();
Map<String, OrgMap> store=ouModelService.getOrgModel();
OrgMap orgmodel=this.getOrgModel(orgid);
if(orgmodel.getSub().size()==store.size())
return iibzEmployeeService.list();
return iibzEmployeeService.list(new QueryWrapper<SysEmployee>().in("orgid",orgmodel.getSub()));
}
public List<SysEmployee> getSubEmpByDept(String deptid)
{
if(StringUtils.isEmpty(deptid) || "nulldeptid".equals(deptid))
return new ArrayList<>();
DeptMap deptmodel=this.getDeptModel(deptid);
return iibzEmployeeService.list(new QueryWrapper<SysEmployee>().in("mdeptid",deptmodel.getSub()));
}
public List<SysEmployee> getParentEmpByOrg(String orgid,boolean bRecurrence)
{
if(StringUtils.isEmpty(orgid) || "nullorgid".equals(orgid))
return new ArrayList<>();
OrgMap orgmodel=this.getOrgModel(orgid);
List<String> parent=new ArrayList<>();
for(String str:orgmodel.getParent())
{
parent.add(str);
if(!bRecurrence)
break;
}
if(parent.size()==0)
return new ArrayList<>();
return iibzEmployeeService.list(new QueryWrapper<SysEmployee>().in("orgid",parent));
}
public List<SysEmployee> getParentEmpByDept(String deptid,boolean bRecurrence)
{
if(StringUtils.isEmpty(deptid) || "nulldeptid".equals(deptid))
return new ArrayList<>();
DeptMap deptmodel=this.getDeptModel(deptid);
List<String> parent=new ArrayList<>();
for(String str:deptmodel.getParent())
{
parent.add(str);
if(!bRecurrence)
break;
}
if(parent.size()==0)
return new ArrayList<>();
return iibzEmployeeService.list(new QueryWrapper<SysEmployee>().in("mdeptid",parent));
}
public OrgMap getOrgModel(String orgid)
{
Map<String, OrgMap> store=ouModelService.getOrgModel();
if(store.containsKey(orgid))
{
OrgMap map = store.get(orgid);
return map;
}
else
{
OrgMap map = new OrgMap();
map.setOrgid(orgid);
return map;
}
}
public DeptMap getDeptModel(String deptid)
{
Map<String, DeptMap> store=ouModelService.getDeptModel(ouModelService.getOrgModel());
if(store.containsKey(deptid))
{
DeptMap map = store.get(deptid);
return map;
}
else
{
DeptMap map = new DeptMap();
map.setDeptid(deptid);
return map;
}
}
@Autowired
private SysOrg2NodeMapping org2NodeMapping;
public List<OrgNode> getOrgNode(String root)
{
if(StringUtils.isEmpty(root))
root="alls";
List<OrgNode> list=new ArrayList<>();
Map<String,OrgMap> store=ouModelService.getOrgModel();
if(root.equals("alls"))
{
int rootcnt=0;
String tmp="";
for(OrgMap map:store.values()) {
SysOrganization org = map.getOrg();
if(StringUtils.isEmpty(org.getParentorgid())) {
rootcnt++;
tmp=org.getOrgid();
}
}
if(rootcnt==1)
root=tmp;
}
for(OrgMap map:store.values())
{
SysOrganization org=map.getOrg();
String parent=org.getParentorgid();
if(StringUtils.isEmpty(parent))
parent="alls";
if(parent.equals(root)||root.equals(org.getOrgid()))
{
OrgNode node=org2NodeMapping.toDto(org);
node.getFilter().addAll(map.getParent());
node.getFilter().add(node.getOrgid());
if(root.equals(org.getOrgid())) {
list.add(0,node);
}
else {
looporg(node, store);
list.add(node);
}
}
}
return list;
}
private void looporg(OrgNode node,Map<String,OrgMap> store)
{
Set<String> children=store.get(node.getOrgid()).getChildren();
for(String child:children)
{
OrgMap childMap=store.get(child);
OrgNode sub=org2NodeMapping.toDto(childMap.getOrg());
sub.getFilter().addAll(childMap.getParent());
sub.getFilter().add(sub.getOrgid());
node.getChildren().add(sub);
looporg(sub,store);
}
}
@Autowired
private SysDept2NodeMapping dept2NodeMapping;
public List<DeptNode> getDeptNode(String orgid)
{
List<DeptNode> list=new ArrayList<>();
if(StringUtils.isEmpty(orgid))
return list;
Map<String,DeptMap> store=ouModelService.getDeptModel(ouModelService.getOrgModel());
for(DeptMap map:store.values())
{
SysDepartment dept=map.getDept();
if(StringUtils.isEmpty(dept.getParentdeptid())&&orgid.equals(dept.getOrgid()))
{
DeptNode node=dept2NodeMapping.toDto(dept);
loopdept(node,store);
list.add(node);
}
}
return list;
}
public List<DeptNode> getOrgDeptNode(String orgid)
{
List<DeptNode> list=new ArrayList<>();
if(StringUtils.isEmpty(orgid))
orgid="alls";
Map<String,DeptNode> parentNode=new HashMap<>();
List<OrgNode> listOrg=getOrgNode(orgid);
for(OrgNode org:listOrg)
{
DeptNode node = changeOrgNode2DeptNode(org,parentNode);
list.add(node);
}
Map<String,DeptMap> store=ouModelService.getDeptModel(ouModelService.getOrgModel());
for(DeptMap map:store.values())
{
SysDepartment dept=map.getDept();
if(StringUtils.isEmpty(dept.getParentdeptid()))
{
DeptNode node=dept2NodeMapping.toDto(dept);
if(parentNode.containsKey(dept.getOrgid())) {
node.setFilter(parentNode.get(dept.getOrgid()).getFilter());
parentNode.get(dept.getOrgid()).getChildren().add(node);
loopdept(node,store);
}
}
}
return list;
}
private void loopdept(DeptNode node,Map<String,DeptMap> store)
{
Set<String> children=store.get(node.getDeptid()).getChildren();
for(String child:children)
{
DeptMap childMap=store.get(child);
DeptNode sub=dept2NodeMapping.toDto(childMap.getDept());
sub.setFilter(node.getFilter());
node.getChildren().add(sub);
loopdept(sub,store);
}
}
private DeptNode changeOrgNode2DeptNode(OrgNode orgnode,Map<String,DeptNode> parentNode)
{
DeptNode node = new DeptNode();
node.setDeptid(orgnode.getOrgid());
node.setDeptname(orgnode.getOrgname());
node.setFilter(orgnode.getFilter());
node.setDisabled(true);
parentNode.put(orgnode.getOrgid(),node);
for(OrgNode org:orgnode.getChildren())
{
node.getChildren().add(changeOrgNode2DeptNode(org,parentNode));
}
return node;
}
@Autowired
private SysEmp2NodeMapping emp2NodeMapping;
public List<EmpNode> getEmpNode(String orgid)
{
List<EmpNode> listemp=new ArrayList<>();
List<String> list=new ArrayList<>();
if(StringUtils.isEmpty(orgid))
return listemp;
Map<String,DeptMap> store=ouModelService.getDeptModel(ouModelService.getOrgModel());
for(DeptMap map:store.values())
{
SysDepartment dept=map.getDept();
if(StringUtils.isEmpty(dept.getParentdeptid())&&orgid.equals(dept.getOrgid()))
{
list.add(dept.getDeptid());
loopdept(dept.getDeptid(),store,list);
}
}
LinkedHashMap<String,List<EmpNode>> empmap=new LinkedHashMap<>();
for(String deptid:list)
{
empmap.put(deptid,new ArrayList<>());
}
for(EmpNode node:emp2NodeMapping.toDto(this.getEmpByOrg(orgid)))
{
if(empmap.containsKey(node.getMdeptid()))
empmap.get(node.getMdeptid()).add(node);
}
for(String deptid:list)
{
listemp.addAll(empmap.get(deptid));
}
return listemp;
}
private void loopdept(String node,Map<String,DeptMap> store,List<String> list)
{
Set<String> children=store.get(node).getChildren();
for(String child:children)
{
list.add(child);
loopdept(child,store,list);
}
}
}
package cn.ibizlab.core.ou.extensions.service;
import cn.ibizlab.core.ou.domain.SysDepartment;
import cn.ibizlab.core.ou.domain.SysOrganization;
import cn.ibizlab.core.ou.extensions.domain.DeptMap;
import cn.ibizlab.core.ou.extensions.domain.OrgMap;
import cn.ibizlab.core.ou.service.ISysDepartmentService;
import cn.ibizlab.core.ou.service.ISysOrganizationService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.*;
@Service
public class OUModelService
{
@Autowired
private ISysOrganizationService iibzOrganizationService;
@Autowired
private ISysDepartmentService iibzDepartmentService;
private Map<String, OrgMap> orgmap=null;
private Object lockOrg=new Object();
//@Cacheable( value="ibzou-model",key = "'orgmap'")
public Map<String, OrgMap> getOrgModel()
{
if(orgmap!=null)
return orgmap;
synchronized(lockOrg)
{
if(orgmap!=null)
return orgmap;
Map<String, OrgMap> store=new LinkedHashMap<>();
List<SysOrganization> listOrg=iibzOrganizationService.list(new QueryWrapper<SysOrganization>().orderByAsc("showorder","orgcode"));
for(SysOrganization org:listOrg)
{
OrgMap map=new OrgMap();
map.setOrg(org);
store.put(org.getOrgid(),map);
}
for(SysOrganization org:listOrg)
{
loopOrg(org,store);
if(!StringUtils.isEmpty(org.getParentorgid())) {
if (store.containsKey(org.getParentorgid())) {
store.get(org.getParentorgid()).getChildren().add(org.getOrgid());
}
}
}
for(SysOrganization org:listOrg)
{
for(String sub:store.get(org.getOrgid()).getSub())
{
if(!org.getOrgid().equals(sub))
store.get(sub).getParent().add(org.getOrgid());
}
}
orgmap=store;
}
return orgmap;
}
public void loopOrg(SysOrganization org,Map<String, OrgMap> store)
{
if(!StringUtils.isEmpty(org.getParentorgid()))
{
if(store.containsKey(org.getParentorgid()))
{
store.get(org.getParentorgid()).getSub().add(org.getOrgid());
loopOrg(store.get(org.getParentorgid()).getOrg(),store);
}
}
}
private Map<String, DeptMap> deptmap=null;
private Object lockDept=new Object();
//@Cacheable( value="ibzou-model",key = "'deptmap'")
public Map<String, DeptMap> getDeptModel(Map<String, OrgMap> orgstore)
{
if(deptmap!=null)
return deptmap;
synchronized(lockDept)
{
if(deptmap!=null)
return deptmap;
if(orgstore==null)
orgstore=this.getOrgModel();
Map<String, DeptMap> store=new LinkedHashMap<>();
Map<String, Set<String>> bcmap=new HashMap<>();
List<SysDepartment> listDept=iibzDepartmentService.list(new QueryWrapper<SysDepartment>().orderByAsc("showorder","deptcode"));
for(SysDepartment dept:listDept)
{
DeptMap map=new DeptMap();
map.setDept(dept);
store.put(dept.getDeptid(),map);
String bc=dept.getBcode();
if(!StringUtils.isEmpty(bc))
{
bc=bc.replace(";",",").replace(";",",").replace(",",",");
String[] bcs=bc.split(",");
for(String strbc:bcs)
{
strbc=strbc.trim();
if(!StringUtils.isEmpty(strbc))
{
if(!bcmap.containsKey(strbc))
{
Set<String> bcset=new HashSet<>();
bcmap.put(strbc,bcset);
}
bcmap.get(strbc).add(dept.getDeptid()+":"+dept.getOrgid());
}
}
}
}
for(SysDepartment dept:listDept)
{
loopDept(dept,store);
if(!StringUtils.isEmpty(dept.getParentdeptid())) {
if (store.containsKey(dept.getParentdeptid())) {
store.get(dept.getParentdeptid()).getChildren().add(dept.getDeptid());
}
}
}
for(SysDepartment dept:listDept)
{
for(String sub:store.get(dept.getDeptid()).getSub())
{
if(!dept.getDeptid().equals(sub))
store.get(sub).getParent().add(dept.getDeptid());
}
}
for(SysDepartment dept:listDept)
{
String orgid=dept.getOrgid();
if(StringUtils.isEmpty(orgid)||(!orgstore.containsKey(orgid)))
continue;
String bc=dept.getBcode();
if(!StringUtils.isEmpty(bc))
{
bc = bc.replace(";", ",").replace(";", ",").replace(",", ",");
String[] bcs = bc.split(",");
for (String strbc : bcs)
{
strbc = strbc.trim();
if (!StringUtils.isEmpty(strbc))
{
if(bcmap.containsKey(strbc))
{
Set<String> bcset=bcmap.get(strbc);
for(String bcstring:bcset)
{
String[] bcstringarr=bcstring.split(":");
if(bcstringarr.length==2)
{
String bcdept=bcstringarr[0];
String bcorg=bcstringarr[1];
for(String porg:orgstore.get(orgid).getParent())
{
if(bcorg.equals(porg))
store.get(dept.getDeptid()).getParent().add(bcdept);
}
for(String sorg:orgstore.get(orgid).getSub())
{
if(bcorg.equals(sorg))
store.get(dept.getDeptid()).getSub().add(bcdept);
}
}
}
}
}
}
}
}
deptmap=store;
}
return deptmap;
}
public void loopDept(SysDepartment dept,Map<String,DeptMap> store)
{
if(!StringUtils.isEmpty(dept.getParentdeptid()))
{
if(store.containsKey(dept.getParentdeptid()))
{
store.get(dept.getParentdeptid()).getSub().add(dept.getDeptid());
loopDept(store.get(dept.getParentdeptid()).getDept(),store);
}
}
}
@CacheEvict( value="ibzou-model",allEntries = true)
public synchronized void refreshModel()
{
synchronized (lockDept)
{
this.deptmap = null;
}
synchronized (lockOrg)
{
this.orgmap = null;
}
}
}
package cn.ibizlab.core.ou.extensions.service;
import cn.ibizlab.util.domain.IBZUSER;
import cn.ibizlab.util.mapper.IBZUSERMapper;
import cn.ibizlab.util.service.IBZUSERService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
@Service("userservice")
public class SysUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> implements IBZUSERService{
}
\ No newline at end of file
...@@ -106,10 +106,7 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -106,10 +106,7 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter {
"/**/fonts/**", "/**/fonts/**",
"/**/js/**", "/**/js/**",
"/**/img/**", "/**/img/**",
"/", "/"
"webjars/**",
"/swagger-resources/**",
"/v2/**"
).permitAll() ).permitAll()
//放行登录请求 //放行登录请求
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll() .antMatchers( HttpMethod.POST,"/"+loginPath).permitAll()
...@@ -119,6 +116,11 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -119,6 +116,11 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/"+downloadpath+"/**").permitAll() .antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll() .antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**").permitAll() .antMatchers("/"+previewpath+"/**").permitAll()
//开放组织机构关系查询
.antMatchers("/ibzemployees/**/oumaps").permitAll()
.antMatchers("/ibzorganizations/**/suborg/picker").permitAll()
.antMatchers("/dictionarys/**").permitAll()
// 所有请求都需要认证 // 所有请求都需要认证
.anyRequest().authenticated() .anyRequest().authenticated()
// 防止iframe 造成跨域 // 防止iframe 造成跨域
......
package cn.ibizlab.api.rest.extensions;
import cn.ibizlab.core.ou.domain.SysDepartment;
import cn.ibizlab.core.ou.domain.SysEmployee;
import cn.ibizlab.core.ou.domain.SysOrganization;
import cn.ibizlab.core.ou.extensions.domain.*;
import cn.ibizlab.core.ou.extensions.service.OUCoreService;
import cn.ibizlab.core.ou.service.ISysDepartmentService;
import cn.ibizlab.core.ou.service.ISysEmployeeService;
import cn.ibizlab.core.ou.service.ISysOrganizationService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@RestController
public class OUCoreResource
{
@Autowired
private OUCoreService ouCoreService;
@Autowired
private ISysEmployeeService iibzEmployeeService;
@Autowired
private ISysOrganizationService iibzOrganizationService;
@Autowired
private ISysDepartmentService iibzDepartmentService;
@GetMapping("/ibzemployees/{userId}/oumaps")
public ResponseEntity<Map<String, Set<String>>> getOUMapsByUserId(@PathVariable("userId") String userId)
{
SysEmployee emp=iibzEmployeeService.get(userId);
String orgid="nullorgid";
if(!StringUtils.isEmpty(emp.getOrgid()))
orgid=emp.getOrgid();
String deptid="nulldeptid";
if(!StringUtils.isEmpty(emp.getMdeptid()))
deptid=emp.getMdeptid();
return ResponseEntity.ok(this.getMaps(orgid,deptid));
}
@GetMapping("/ibzdepartments/{deptId}/emp")
public ResponseEntity<Map> getEmpByDept(@PathVariable("deptId") String deptId)
{
Map map=new LinkedHashMap<>();
List<SysEmployee> list=ouCoreService.getEmpByDept(deptId);
for(SysEmployee emp:list)
map.put(emp.getUserid(),emp);
return ResponseEntity.ok(map);
}
@GetMapping("/ibzdepartments/{deptId}/fatheremp")
public ResponseEntity<Map> getFatherEmpByDept(@PathVariable("deptId") String deptId)
{
Map map=new LinkedHashMap<>();
List<SysEmployee> list=ouCoreService.getParentEmpByDept(deptId,false);
for(SysEmployee emp:list)
map.put(emp.getUserid(),emp);
return ResponseEntity.ok(map);
}
@GetMapping("/ibzdepartments/{deptId}/parentemp")
public ResponseEntity<Map> getParentEmpByDept(@PathVariable("deptId") String deptId)
{
Map map=new LinkedHashMap<>();
List<SysEmployee> list=ouCoreService.getParentEmpByDept(deptId,true);
for(SysEmployee emp:list)
map.put(emp.getUserid(),emp);
return ResponseEntity.ok(map);
}
@GetMapping("/ibzdepartments/{deptId}/subemp")
public ResponseEntity<Map> getSubEmpByDept(@PathVariable("deptId") String deptId)
{
Map map=new LinkedHashMap<>();
List<SysEmployee> list=ouCoreService.getSubEmpByDept(deptId);
for(SysEmployee emp:list)
map.put(emp.getUserid(),emp);
return ResponseEntity.ok(map);
}
@GetMapping("/ibzorganizations/{orgId}/emp")
public ResponseEntity<Map> getEmpByOrg(@PathVariable("orgId") String orgId)
{
Map map=new LinkedHashMap<>();
List<SysEmployee> list=ouCoreService.getEmpByOrg(orgId);
for(SysEmployee emp:list)
map.put(emp.getUserid(),emp);
return ResponseEntity.ok(map);
}
@GetMapping("/ibzorganizations/{orgId}/fatheremp")
public ResponseEntity<Map> getFatherEmpByOrg(@PathVariable("orgId") String orgId)
{
Map map=new LinkedHashMap<>();
List<SysEmployee> list=ouCoreService.getParentEmpByOrg(orgId,false);
for(SysEmployee emp:list)
map.put(emp.getUserid(),emp);
return ResponseEntity.ok(map);
}
@GetMapping("/ibzorganizations/{orgId}/parentemp")
public ResponseEntity<Map> getParentEmpByOrg(@PathVariable("orgId") String orgId)
{
Map map=new LinkedHashMap<>();
List<SysEmployee> list=ouCoreService.getParentEmpByOrg(orgId,true);
for(SysEmployee emp:list)
map.put(emp.getUserid(),emp);
return ResponseEntity.ok(map);
}
@GetMapping("/ibzorganizations/{orgId}/subemp")
public ResponseEntity<Map> getSubEmpByOrg(@PathVariable("orgId") String orgId)
{
Map map=new LinkedHashMap<>();
List<SysEmployee> list=ouCoreService.getSubEmpByOrg(orgId);
for(SysEmployee emp:list)
map.put(emp.getUserid(),emp);
return ResponseEntity.ok(map);
}
@GetMapping("/ibzorganizations/picker")
public ResponseEntity<List<OrgNode>> getPicker()
{
List<OrgNode> list=ouCoreService.getOrgNode("alls");
return ResponseEntity.ok(list);
}
@GetMapping("/ibzorganizations/{orgId}/ibzdepartments/picker")
public ResponseEntity<List<DeptNode>> getOrgDeptPicker(@PathVariable("orgId") String orgId)
{
List<DeptNode> list=ouCoreService.getDeptNode(orgId);
return ResponseEntity.ok(list);
}
@GetMapping("/ibzorganizations/{orgId}/suborg/picker")
public ResponseEntity<List<OrgNode>> getSubOrgPicker(@PathVariable("orgId") String orgId)
{
List<OrgNode> list=ouCoreService.getOrgNode(orgId);
return ResponseEntity.ok(list);
}
@GetMapping("/ibzorganizations/{orgId}/suborg/ibzdepartments/picker")
public ResponseEntity<List<DeptNode>> getSubOrgDeptPicker(@PathVariable("orgId") String orgId)
{
List<DeptNode> list=ouCoreService.getOrgDeptNode(orgId);
return ResponseEntity.ok(list);
}
@GetMapping("/ibzorganizations/{orgId}/ibzemployees/picker")
public ResponseEntity<List<EmpNode>> getEmpPicker(@PathVariable("orgId") String orgId)
{
List<EmpNode> list=ouCoreService.getEmpNode(orgId);
return ResponseEntity.ok(list);
}
private Map<String, Set<String>> getMaps(String orgid,String deptid)
{
Map<String, Set<String>> map=new LinkedHashMap<>();
OrgMap storemap=ouCoreService.getOrgModel(orgid);
map.put("parentorg",storemap.getParent());
map.put("suborg",storemap.getSub());
map.put("fatherorg",storemap.getFather());
DeptMap storedeptmap=ouCoreService.getDeptModel(deptid);
map.put("parentdept",storedeptmap.getParent());
map.put("subdept",storedeptmap.getSub());
map.put("fatherdept",storedeptmap.getFather());
return map;
}
@Cacheable( value="ibzou-model",key = "'catalog:'+#p0")
@RequestMapping(method = RequestMethod.GET, value = "/dictionarys/catalogs/Ibzou{catalog}")
public ResponseEntity<JSONObject> getCatalog(@PathVariable("catalog") String catalog) {
return ResponseEntity.status(HttpStatus.OK).body(getItems("Ibzou"+catalog));
}
@Cacheable( value="ibzou-model",key = "'codelist:'+#p0")
@RequestMapping(method = RequestMethod.GET, value = "/dictionarys/codelist/Ibzou{catalog}")
public ResponseEntity<JSONObject> getCodeList(@PathVariable("catalog") String catalog) {
return ResponseEntity.status(HttpStatus.OK).body(getItems("Ibzou"+catalog));
}
@RequestMapping(method = RequestMethod.GET, value = "/dictionarys/catalogs/Ibzou{code}/options")
public ResponseEntity<List> getOptions(@PathVariable("code") String code) {
return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code).get("items"));
}
@RequestMapping(method = RequestMethod.GET, value = "/dictionarys/codelist/Ibzou{code}/items")
public ResponseEntity<List> getCodeItems(@PathVariable("code") String code) {
return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code).get("items"));
}
@RequestMapping(method = RequestMethod.POST, value = "/dictionarys/catalogs/Ibzou{code}/options")
public ResponseEntity<List> getOptions(@PathVariable("code") String code,@RequestBody List<String> values) {
return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code,values).get("items"));
}
@RequestMapping(method = RequestMethod.POST, value = "/dictionarys/codelist/Ibzou{code}/items")
public ResponseEntity<List> getCodeItems(@PathVariable("code") String code, @RequestBody List<String> values) {
return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code,values).get("items"));
}
public JSONObject getItems(String catalog) {
return getItems(catalog,null);
}
public JSONObject getItems(String catalog,List<String> values) {
JSONObject jo=new JSONObject();
jo.put("srfkey",catalog);
jo.put("emptytext","");
List<JSONObject> list=new ArrayList<>();
if("IbzouOrg".equalsIgnoreCase(catalog))
{
LambdaQueryWrapper<SysOrganization> queryWrapper = Wrappers.<SysOrganization>lambdaQuery();
if(!ObjectUtils.isEmpty(values))
queryWrapper.in(SysOrganization::getOrgid,values);
queryWrapper.orderByAsc(SysOrganization::getShoworder);
iibzOrganizationService.list(queryWrapper).forEach(item -> {
JSONObject option=new JSONObject();
option.put("id",item.getOrgid());
option.put("value",item.getOrgid());
option.put("label",item.getOrgname());
option.put("text",item.getOrgname());
list.add(option);
});
}
else if("IbzouDept".equalsIgnoreCase(catalog)||"IbzouOrgSector".equalsIgnoreCase(catalog))
{
LambdaQueryWrapper<SysDepartment> queryWrapper = Wrappers.<SysDepartment>lambdaQuery();
if(!ObjectUtils.isEmpty(values))
queryWrapper.in(SysDepartment::getDeptid,values);
queryWrapper.orderByAsc(SysDepartment::getShoworder);
iibzDepartmentService.list(queryWrapper).forEach(item -> {
JSONObject option=new JSONObject();
option.put("id",item.getDeptid());
option.put("value",item.getDeptid());
option.put("label",item.getDeptname());
option.put("text",item.getDeptname());
list.add(option);
});
}
else if("IbzouUser".equalsIgnoreCase(catalog)||"IbzouOperator".equalsIgnoreCase(catalog)||"IbzouEmp".equalsIgnoreCase(catalog)||"IbzouPerson".equalsIgnoreCase(catalog))
{
LambdaQueryWrapper<SysEmployee> queryWrapper = Wrappers.<SysEmployee>lambdaQuery();
if(!ObjectUtils.isEmpty(values))
queryWrapper.in(SysEmployee::getUserid,values);
queryWrapper.orderByAsc(SysEmployee::getShoworder);
iibzEmployeeService.list(queryWrapper).forEach(item -> {
JSONObject option=new JSONObject();
option.put("id",item.getUserid());
option.put("value",item.getUserid());
option.put("label",item.getPersonname());
option.put("text",item.getPersonname());
list.add(option);
});
}
jo.put("items",list);
return jo;
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册