package com.consum.base.service.impl;
|
|
import com.consum.base.pojo.FinSysServerSearchParam;
|
import com.consum.base.pojo.FinSysServerVo;
|
import com.consum.base.service.FinSysServerService;
|
import com.consum.model.po.FinSysServer;
|
import com.iplatform.model.po.S_role;
|
import com.walker.db.page.GenericPager;
|
import com.walker.jdbc.service.BaseServiceImpl;
|
import com.walker.jdbc.util.StringUtils;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
import org.springframework.stereotype.Service;
|
|
@Service
|
public class FinSysServerServiceImpl extends BaseServiceImpl implements FinSysServerService {
|
|
private static final String SELECT_TREE_ALL = "select * from FIN_SYS_SERVER";
|
private static final String SELECT_CHILD_BY_ID = "select * from FIN_SYS_SERVER where 1=1";
|
|
// private static final String S
|
|
/**
|
* 查询所有服务目录
|
*
|
* @return
|
* @date 2023-07-11
|
*/
|
public List<FinSysServerVo> queryAllCategory() {
|
List<FinSysServer> finSysCategories = this.select(SELECT_TREE_ALL, new Object[]{}, new FinSysServer());
|
List<FinSysServerVo> result = null;
|
if (finSysCategories != null) {
|
List<FinSysServerVo> finSysCategoryVos = finSysCategories.stream().map(category -> {
|
FinSysServerVo finSysCategoryVo = new FinSysServerVo();
|
// BeanUtils.copyProperties(category, finSysCategoryVo);
|
finSysCategoryVo.setId(category.getId());
|
finSysCategoryVo.setLabel(category.getName());
|
finSysCategoryVo.setParentId(category.getParentId());
|
return finSysCategoryVo;
|
}).collect(Collectors.toList());
|
result = finSysCategoryVos.stream().filter(c -> c.getParentId() == 0).map(tree -> {
|
tree.setChildren(getChildren(tree, finSysCategoryVos));
|
return tree;
|
}).collect(Collectors.toList());
|
}
|
return result;
|
}
|
|
private List<FinSysServerVo> getChildren(FinSysServerVo tree, List<FinSysServerVo> finSysCategoryVos) {
|
return finSysCategoryVos.stream().filter(c -> c.getParentId() == tree.getId()).map(m -> {
|
m.setChildren(getChildren(m, finSysCategoryVos));
|
return m;
|
}).collect(Collectors.toList());
|
}
|
|
/**
|
* 根据id查询当下菜单所属子菜单
|
*/
|
public List<FinSysServer> findChildById(Long parentId) {
|
List<FinSysServer> children = this.select(SELECT_CHILD_BY_ID, new Object[]{parentId}, new FinSysServer());
|
return children;
|
}
|
|
/**
|
* 分页查询
|
*
|
* @param param
|
* @return
|
*/
|
public GenericPager<FinSysServer> selectServerListByPage(FinSysServerSearchParam param) {
|
Map<String, Object> parameter = new HashMap();
|
StringBuilder sql = new StringBuilder(SELECT_CHILD_BY_ID);
|
if (param.getName() != null && StringUtils.isNotEmpty(param.getName())) {
|
sql.append(" and NAME like :name");
|
parameter.put("name", StringUtils.CHAR_PERCENT + param.getName() + StringUtils.CHAR_PERCENT);
|
}
|
if (param.getParentId() != null) {
|
sql.append(" and PARENT_ID = :parentId");
|
parameter.put("parentId", param.getParentId());
|
}
|
return this.selectSplit(sql.toString(), parameter, new FinSysServer());
|
|
}
|
|
/**
|
* @Description 根据DataScope查询信息
|
* @Author wh
|
* @Date 2023/9/13 9:35
|
*/
|
public List<S_role> getByDataScope(Integer dataScope) {
|
Map<String, Object> parameter = new HashMap();
|
String sql = "SELECT * FROM S_ROLE sr WHERE status=0 and DATA_SCOPE = :dataScope";
|
parameter.put("dataScope", dataScope);
|
return this.select(sql.toString(), parameter, new S_role());
|
}
|
}
|