package com.dy.pmsBase.privilege; import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper; import com.dy.pmsGlobal.pojoBa.BaPrivilege; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; import java.util.stream.Collectors; @Slf4j @Service public class PriSv { private BaPrivilegeMapper dao; @Autowired public void setDao(BaPrivilegeMapper dao) { this.dao = dao; } /** * 获取角色列表 */ public QueryResultVo> selectSome(QueryVo queryVo) { Map params = (Map) PojoUtils.generalize(queryVo); //查询符合条件的记录总数 Long itemTotal = dao.selectSomeCount(params); QueryResultVo> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ; //计算分页等信息 rsVo.calculateAndSet(itemTotal, params); //查询符合条件的记录 rsVo.obj = dao.selectSome(params) ; return rsVo ; } public List> selectByType(){ List priList = dao.selectAll(); Map> map = priList.stream() .collect(Collectors.groupingBy(BaPrivilege::getTypeName)); List> resultList=new ArrayList<>(); map.forEach((key, value) -> { Map temp = new HashMap<>(); temp.put("name", key); temp.put("list", value); resultList.add(temp); }); return resultList; } }