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<List<BaPrivilege>> selectSome(QueryVo queryVo) { 
 | 
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); 
 | 
        //查询符合条件的记录总数 
 | 
        Long itemTotal = dao.selectSomeCount(params); 
 | 
        QueryResultVo<List<BaPrivilege>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ; 
 | 
        //计算分页等信息 
 | 
        rsVo.calculateAndSet(itemTotal, params); 
 | 
        //查询符合条件的记录 
 | 
        rsVo.obj = dao.selectSome(params) ; 
 | 
        return rsVo ; 
 | 
    } 
 | 
  
 | 
    public List<Map<String, Object>> selectByType(){ 
 | 
        List<BaPrivilege> priList = dao.selectAll(); 
 | 
        Map<String, List<BaPrivilege>> map = priList.stream() 
 | 
                .collect(Collectors.groupingBy(BaPrivilege::getTypeName)); 
 | 
        List<Map<String,Object>> resultList=new ArrayList<>(); 
 | 
        map.forEach((key, value) -> { 
 | 
            Map<String, Object> temp = new HashMap<>(); 
 | 
            temp.put("name", key); 
 | 
            temp.put("list", value); 
 | 
            resultList.add(temp); 
 | 
        }); 
 | 
        return resultList; 
 | 
    } 
 | 
} 
 |