|
@ -39,6 +39,7 @@ public class SysFunctionService extends MybatisBaseService<SysFunctionMapper, Sy |
|
|
private SysSourceService sysSourceService; |
|
|
private SysSourceService sysSourceService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private SysSourceFunctionService sysSourceFunctionService; |
|
|
private SysSourceFunctionService sysSourceFunctionService; |
|
|
|
|
|
|
|
|
public PagerVo<SysFunction> listPage(PagerQuery<SysFunctionQuery> pq) { |
|
|
public PagerVo<SysFunction> listPage(PagerQuery<SysFunctionQuery> pq) { |
|
|
SysFunctionQuery query = pq.getParams(); |
|
|
SysFunctionQuery query = pq.getParams(); |
|
|
QueryWrapper<SysFunction> qw = createQueryWrapper(query); |
|
|
QueryWrapper<SysFunction> qw = createQueryWrapper(query); |
|
@ -47,10 +48,12 @@ public class SysFunctionService extends MybatisBaseService<SysFunctionMapper, Sy |
|
|
PagerVo<SysFunction> p = PagerUtil.pageToVo(pagging, null); |
|
|
PagerVo<SysFunction> p = PagerUtil.pageToVo(pagging, null); |
|
|
return p; |
|
|
return p; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<SysFunction> listAll(SysFunctionQuery query) { |
|
|
public List<SysFunction> listAll(SysFunctionQuery query) { |
|
|
QueryWrapper<SysFunction> qw = createQueryWrapper(query); |
|
|
QueryWrapper<SysFunction> qw = createQueryWrapper(query); |
|
|
return baseMapper.selectList(qw); |
|
|
return baseMapper.selectList(qw); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private QueryWrapper<SysFunction> createQueryWrapper(SysFunctionQuery query) { |
|
|
private QueryWrapper<SysFunction> createQueryWrapper(SysFunctionQuery query) { |
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
@ -100,53 +103,57 @@ public class SysFunctionService extends MybatisBaseService<SysFunctionMapper, Sy |
|
|
QueryWrapper<SysFunction> qw = new QueryWrapper<>(); |
|
|
QueryWrapper<SysFunction> qw = new QueryWrapper<>(); |
|
|
qw.eq("func.parentSid", "0"); |
|
|
qw.eq("func.parentSid", "0"); |
|
|
List<SysFunctionVo> sysFunctionVos = baseMapper.selectListAllVo(qw); |
|
|
List<SysFunctionVo> sysFunctionVos = baseMapper.selectListAllVo(qw); |
|
|
for(SysFunctionVo s:sysFunctionVos){ |
|
|
for (SysFunctionVo s : sysFunctionVos) { |
|
|
getChildrens(s); |
|
|
getChildrens(s); |
|
|
} |
|
|
} |
|
|
return sysFunctionVos; |
|
|
return sysFunctionVos; |
|
|
} |
|
|
} |
|
|
private void getChildrens(SysFunctionVo s){ |
|
|
|
|
|
|
|
|
private void getChildrens(SysFunctionVo s) { |
|
|
String sid = s.getSid(); |
|
|
String sid = s.getSid(); |
|
|
QueryWrapper<SysFunction> qw = new QueryWrapper<>(); |
|
|
QueryWrapper<SysFunction> qw = new QueryWrapper<>(); |
|
|
if (StringUtils.isNotBlank(sid)) { |
|
|
if (StringUtils.isNotBlank(sid)) { |
|
|
qw.eq("func.parentSid", sid); |
|
|
qw.eq("func.parentSid", sid); |
|
|
} |
|
|
} |
|
|
List<SysFunctionVo> sysFunctionVos = baseMapper.selectListAllVo(qw); |
|
|
List<SysFunctionVo> sysFunctionVos = baseMapper.selectListAllVo(qw); |
|
|
if(!sysFunctionVos.isEmpty()){ |
|
|
if (!sysFunctionVos.isEmpty()) { |
|
|
for(SysFunctionVo sfv:sysFunctionVos){ |
|
|
for (SysFunctionVo sfv : sysFunctionVos) { |
|
|
getChildrens(sfv); |
|
|
getChildrens(sfv); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
s.setChildren(sysFunctionVos); |
|
|
s.setChildren(sysFunctionVos); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<SysFunctionVo> listVo() { |
|
|
public List<SysFunctionVo> listVo() { |
|
|
return baseMapper.selectListVo(); |
|
|
return baseMapper.selectListVo(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void saveOrUpdateDto(SysFunctionDto dto){ |
|
|
public void saveOrUpdateDto(SysFunctionDto dto) { |
|
|
SysFunction entity = new SysFunction(); |
|
|
SysFunction entity = new SysFunction(); |
|
|
dto.fillEntity(entity); |
|
|
dto.fillEntity(entity); |
|
|
SysSourceFunction sysSourceFunction = new SysSourceFunction(); |
|
|
SysSourceFunction sysSourceFunction = new SysSourceFunction(); |
|
|
sysSourceFunction.setFunctionSid(entity.getSid()); |
|
|
sysSourceFunction.setFunctionSid(entity.getSid()); |
|
|
sysSourceFunction.setSourceSid(dto.getSourceSid()); |
|
|
sysSourceFunction.setSourceSid(dto.getSourceSid()); |
|
|
setRootSid(entity,sysSourceFunction); |
|
|
setRootSid(entity, sysSourceFunction); |
|
|
sysSourceFunctionService.save(sysSourceFunction); |
|
|
sysSourceFunctionService.save(sysSourceFunction); |
|
|
this.saveOrUpdate(entity); |
|
|
this.saveOrUpdate(entity); |
|
|
} |
|
|
} |
|
|
private void setRootSid(SysFunction entity,SysSourceFunction sysSourceFunction){ |
|
|
|
|
|
|
|
|
private void setRootSid(SysFunction entity, SysSourceFunction sysSourceFunction) { |
|
|
String pSid = entity.getParentSid(); |
|
|
String pSid = entity.getParentSid(); |
|
|
if("0".equals(pSid)){ |
|
|
if ("0".equals(pSid)) { |
|
|
sysSourceFunction.setFunctionRootSid(entity.getSid()); |
|
|
sysSourceFunction.setFunctionRootSid(entity.getSid()); |
|
|
}else{ |
|
|
} else { |
|
|
SysFunction sysFunction = this.fetchBySid(pSid); |
|
|
SysFunction sysFunction = this.fetchBySid(pSid); |
|
|
String pSid1 = sysFunction.getParentSid(); |
|
|
String pSid1 = sysFunction.getParentSid(); |
|
|
if("0".equals(pSid1)){ |
|
|
if ("0".equals(pSid1)) { |
|
|
sysSourceFunction.setFunctionRootSid(sysFunction.getSid()); |
|
|
sysSourceFunction.setFunctionRootSid(sysFunction.getSid()); |
|
|
} |
|
|
} |
|
|
setRootSid(sysFunction,sysSourceFunction); |
|
|
setRootSid(sysFunction, sysSourceFunction); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
public SysFunctionVo fetchByIdVo(String id){ |
|
|
|
|
|
|
|
|
public SysFunctionVo fetchByIdVo(String id) { |
|
|
SysFunction entity = this.fetchById(id); |
|
|
SysFunction entity = this.fetchById(id); |
|
|
SysFunctionVo vo = new SysFunctionVo(); |
|
|
SysFunctionVo vo = new SysFunctionVo(); |
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
BeanUtil.copyProperties(entity, vo); |
|
@ -154,17 +161,18 @@ public class SysFunctionService extends MybatisBaseService<SysFunctionMapper, Sy |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<SysFunctionVo> listAllByRoleSid(SysFunctionQuery query) { |
|
|
public List<SysFunctionVo> listAllByRoleSid(SysFunctionQuery query) { |
|
|
List<SysFunctionVo> sysFunctionVos = baseMapper.listAllParentByRoleSid(query.getRoleSid(),"0"); |
|
|
List<SysFunctionVo> sysFunctionVos = baseMapper.listAllParentByRoleSid(query.getRoleSid(), "0"); |
|
|
for(SysFunctionVo s:sysFunctionVos){ |
|
|
for (SysFunctionVo s : sysFunctionVos) { |
|
|
getChildrensByRoleSid(s,query.getRoleSid()); |
|
|
getChildrensByRoleSid(s, query.getRoleSid()); |
|
|
} |
|
|
} |
|
|
return sysFunctionVos; |
|
|
return sysFunctionVos; |
|
|
} |
|
|
} |
|
|
private void getChildrensByRoleSid(SysFunctionVo s,String roleSid){ |
|
|
|
|
|
List<SysFunctionVo> sysFunctionVos = baseMapper.listAllParentByRoleSid(roleSid,s.getSid()); |
|
|
private void getChildrensByRoleSid(SysFunctionVo s, String roleSid) { |
|
|
if(!sysFunctionVos.isEmpty()){ |
|
|
List<SysFunctionVo> sysFunctionVos = baseMapper.listAllParentByRoleSid(roleSid, s.getSid()); |
|
|
for(SysFunctionVo sfv:sysFunctionVos){ |
|
|
if (!sysFunctionVos.isEmpty()) { |
|
|
getChildrensByRoleSid(sfv,roleSid); |
|
|
for (SysFunctionVo sfv : sysFunctionVos) { |
|
|
|
|
|
getChildrensByRoleSid(sfv, roleSid); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
s.setChildren(sysFunctionVos); |
|
|
s.setChildren(sysFunctionVos); |
|
@ -239,42 +247,50 @@ public class SysFunctionService extends MybatisBaseService<SysFunctionMapper, Sy |
|
|
|
|
|
|
|
|
public List<ButtonPermissionVo> getButtonPermissions(ButtonPermissionQuery query) { |
|
|
public List<ButtonPermissionVo> getButtonPermissions(ButtonPermissionQuery query) { |
|
|
List<ButtonPermissionVo> buttonPermissions = baseMapper.getButtonPermissions(query); |
|
|
List<ButtonPermissionVo> buttonPermissions = baseMapper.getButtonPermissions(query); |
|
|
return buttonPermissions ; |
|
|
return buttonPermissions; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getFunctionAuthorization(String roleSid) { |
|
|
public List<Map<String, Object>> getFunctionAuthorization(String roleSid) { |
|
|
List<Map<String,Object>> list=new ArrayList<>(); |
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
List<Map<String, Object>> lsources=baseMapper.getSourceAuthorization(roleSid); |
|
|
List<Map<String, Object>> lsources = baseMapper.getSourceAuthorization(roleSid); |
|
|
lsources.forEach(f->{ |
|
|
lsources.forEach(f -> { |
|
|
Map<String,Object> map=new HashMap<>(); |
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
map.put("name",f.get("sourceName").toString()); |
|
|
map.put("name", f.get("sourceName").toString()); |
|
|
map.put("sid",f.get("sid").toString()); |
|
|
map.put("sid", f.get("sid").toString()); |
|
|
map.put("checked","1"); |
|
|
map.put("checked", "1"); |
|
|
list.add(map); |
|
|
list.add(map); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
list.forEach(f->{ |
|
|
list.forEach(f -> { |
|
|
List<Map<String,Object>> list2=new ArrayList<>(); |
|
|
List<Map<String, Object>> list2 = new ArrayList<>(); |
|
|
String sid = f.get("sid").toString(); |
|
|
String sid = f.get("sid").toString(); |
|
|
List<Map<String, Object>> lmenus=baseMapper.getMenuAuthorization(sid); |
|
|
List<Map<String, Object>> lmenus = baseMapper.getMenuAuthorization(sid); |
|
|
lmenus.forEach(ff->{ |
|
|
lmenus.forEach(ff -> { |
|
|
Map<String,Object> map=new HashMap<>(); |
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
map.put("name",ff.get("name")); |
|
|
map.put("name", ff.get("name")); |
|
|
String sids = ff.get("sid").toString(); |
|
|
String sids = ff.get("sid").toString(); |
|
|
map.put("sid",sids); |
|
|
map.put("sid", sids); |
|
|
map.put("checked","1"); |
|
|
map.put("checked", "1"); |
|
|
map.put("children",new ArrayList<>()); |
|
|
map.put("children", new ArrayList<>()); |
|
|
if( ff.get("pageUrl")!=null&& com.yxt.common.base.utils.StringUtils.isNotBlank(ff.get("pageUrl").toString())){ |
|
|
if (ff.get("pageUrl") != null && com.yxt.common.base.utils.StringUtils.isNotBlank(ff.get("pageUrl").toString())) { |
|
|
String pageUrl =ff.get("pageUrl").toString(); |
|
|
String pageUrl = ff.get("pageUrl").toString(); |
|
|
List<Map<String, Object>> lfuncs=baseMapper.getFunctionAuthorization(pageUrl); |
|
|
List<Map<String, Object>> lfuncs = baseMapper.getFunctionAuthorization(pageUrl); |
|
|
lfuncs.forEach(fun->{ |
|
|
List<Map<String, Object>> functionByRoleSid = baseMapper.getFunctionByRoleSid(pageUrl, roleSid); |
|
|
fun.put("children",new ArrayList<>()); |
|
|
if (lfuncs.size() > 0){ |
|
|
}); |
|
|
for (Map<String, Object> lfunc : lfuncs) { |
|
|
map.put("children",lfuncs); |
|
|
for (Map<String, Object> funByRole : functionByRoleSid) { |
|
|
|
|
|
if (lfunc.get("sid").equals(funByRole.get("sid"))) { |
|
|
|
|
|
lfunc.put("checked", "0"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
lfunc.put("children", new ArrayList<>()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
map.put("children", lfuncs); |
|
|
} |
|
|
} |
|
|
list2.add(map); |
|
|
list2.add(map); |
|
|
}); |
|
|
}); |
|
|
f.put("children",list2); |
|
|
f.put("children", list2); |
|
|
}); |
|
|
}); |
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|