cn.hutool.core.collection.CollectionUtil Java Examples

The following examples show how to use cn.hutool.core.collection.CollectionUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InterceptorProvider.java    From redant with Apache License 2.0 6 votes vote down vote up
private static List<Interceptor> scanInterceptors() {
    Set<Class<?>> classSet = ClassScaner.scanPackageBySuper(CommonConstants.INTERCEPTOR_SCAN_PACKAGE,Interceptor.class);
    if(CollectionUtil.isEmpty(classSet)){
        return Collections.emptyList();
    }
    List<InterceptorWrapper> wrappers = new ArrayList<>(classSet.size());
    try {
        for (Class<?> cls : classSet) {
            Interceptor interceptor =(Interceptor)cls.newInstance();
            insertSorted(wrappers,interceptor);
        }
    }catch (IllegalAccessException | InstantiationException e) {
        e.printStackTrace();
    }
    return wrappers.stream()
            .map(InterceptorWrapper::getInterceptor)
            .collect(Collectors.toList());
}
 
Example #2
Source File: DmsDiseServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
@Override
public List<DmsDiseResult> parseList( String idsStr) {
    //解析ids->list<Id>
    List<Long> idList = strToList(idsStr);
   //根据list<Id>查询并封装诊断简单对象
    DmsDiseExample dmsDiseExample=new DmsDiseExample();
    dmsDiseExample.createCriteria().andIdIn(idList);
    List<DmsDise> dmsDiseList=dmsDiseMapper.selectByExample(dmsDiseExample);
    List<DmsDiseResult> dmsDiseResultList = new ArrayList<>();

    if(CollectionUtil.isEmpty(dmsDiseList)){
       return null;
    }

    //封装dto
    for(DmsDise dmsDise: dmsDiseList){
        DmsDiseResult dmsDiseResult=new DmsDiseResult();
        BeanUtils.copyProperties(dmsDise,dmsDiseResult);
        dmsDiseResultList.add(dmsDiseResult);
    }
    return dmsDiseResultList;
}
 
Example #3
Source File: ApiDocInterfaceController.java    From feiqu-opensource with Apache License 2.0 6 votes vote down vote up
/**
 * 跳转到ApiDocInterface首页
 */
@RequestMapping("")
public String index(ApiDocInterfaceCondition condition,Model model) {
    FqUserCache fqUserCache = getCurrentUser();
    if(fqUserCache == null){
        return USER_LOGIN_REDIRECT_URL;
    }
    model.addAttribute("condition",JSON.toJSON(condition));
    ApiDocProjectExample example = new ApiDocProjectExample();
    example.createCriteria().andUserIdEqualTo(fqUserCache.getId());
    List<ApiDocProject> apiDocProjects = apiDocProjectService.selectByExample(example);
    List<KeyValue> keyValues = Lists.newArrayList();
    if(CollectionUtil.isNotEmpty(apiDocProjects)){
        apiDocProjects.forEach(apiDocProject -> {
            KeyValue keyValue = new KeyValue(apiDocProject.getId().toString(),apiDocProject.getProjectName());
            keyValues.add(keyValue);
        });
    }
    model.addAttribute("projects", keyValues);
    return "/apiDocInterface/index.html";
}
 
Example #4
Source File: ProdTagController.java    From mall4j with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 新增商品分组标签
 *
 * @param prodTag 商品分组标签
 * @return 是否新增成功
 */
@SysLog("新增商品分组标签")
@PostMapping
@PreAuthorize("@pms.hasPermission('prod:prodTag:save')")
public ResponseEntity<Boolean> save(@RequestBody @Valid ProdTag prodTag) {
    // 查看是否相同的标签
    List<ProdTag> list = prodTagService.list(new LambdaQueryWrapper<ProdTag>().like(ProdTag::getTitle, prodTag.getTitle()));
    if (CollectionUtil.isNotEmpty(list)) {
        throw new YamiShopBindException("标签名称已存在,不能添加相同的标签");
    }
    prodTag.setIsDefault(0);
    prodTag.setProdCount(0L);
    prodTag.setCreateTime(new Date());
    prodTag.setUpdateTime(new Date());
    prodTag.setShopId(SecurityUtils.getSysUser().getShopId());
    prodTagService.removeProdTag();
    return ResponseEntity.ok(prodTagService.save(prodTag));
}
 
Example #5
Source File: MsgsCenterInfoServiceImpl.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class)
public MsgsCenterInfo saveMsgs(MsgsCenterInfoSaveDTO data) {
    MsgsCenterInfo info = BeanPlusUtil.toBean(data.getMsgsCenterInfoDTO(), MsgsCenterInfo.class);
    info.setTitle(getOrDef(info.getTitle(), info.getContent()));
    info.setAuthor(getOrDef(info.getAuthor(), BaseContextHandler.getName()));
    super.save(info);

    //公式公告,不会指定接收人
    Set<Long> userIdList = data.getUserIdList();
    if (CollectionUtil.isNotEmpty(userIdList)) {
        List<MsgsCenterInfoReceive> receiveList = userIdList.stream().map((userId) -> MsgsCenterInfoReceive.builder()
                .isRead(false)
                .userId(userId)
                .msgsCenterId(info.getId())
                .build()).collect(Collectors.toList());
        msgsCenterInfoReceiveService.saveBatch(receiveList);
    }
    return info;
}
 
Example #6
Source File: DmsDrugServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
/**
 * 描述:1.调用DmsDrugDao查询所有记录(不包括status=0)
 * <p>author: ma
 * <p>author: 赵煜 修改越界错误
 */
@Override
public List<DmsDrugResult> selectAllDrug(){
    DmsDrugExample example = new DmsDrugExample();
    example.createCriteria().andStatusNotEqualTo(0);
    //返回数据包装成Result
    List<DmsDrug> dmsDrugs = dmsDrugMapper.selectByExample(example);
    List<DmsDrugResult> dmsDrugResultList = new ArrayList<>();
    for (DmsDrug dmsDrug   : dmsDrugs) {
        DmsDrugResult dmsDrugResult = new DmsDrugResult();
        BeanUtils.copyProperties(dmsDrug, dmsDrugResult);

        DmsDosageExample dmsDosageExample = new DmsDosageExample();
        //封装剂型
        dmsDosageExample.createCriteria().andIdEqualTo(dmsDrug.getDosageId());
        List<DmsDosage> dmsDosageList = dmsDosageMapper.selectByExample(dmsDosageExample);
        if(!CollectionUtil.isEmpty(dmsDosageList)){
            dmsDrugResult.setDosage(dmsDosageList.get(0));
        }
        dmsDrugResultList.add(dmsDrugResult);
    }
    return dmsDrugResultList;
}
 
Example #7
Source File: OrderTask.java    From mall4j with GNU Affero General Public License v3.0 6 votes vote down vote up
public void cancelOrder(){
    Date now = new Date();
    logger.info("取消超时未支付订单。。。");
    // 获取30分钟之前未支付的订单
    List<Order> orders = orderService.listOrderAndOrderItems(OrderStatus.UNPAY.value(),DateUtil.offsetMinute(now, -30));
    if (CollectionUtil.isEmpty(orders)) {
        return;
    }
    orderService.cancelOrders(orders);
    for (Order order : orders) {
        List<OrderItem> orderItems = order.getOrderItems();
        for (OrderItem orderItem : orderItems) {
            productService.removeProductCacheByProdId(orderItem.getProdId());
            skuService.removeSkuCacheBySkuId(orderItem.getSkuId(),orderItem.getProdId());
        }
    }
}
 
Example #8
Source File: DmsDiseServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
@Override
public List<DmsDiseResult> parseList( String idsStr) {
    //解析ids->list<Id>
    List<Long> idList = strToList(idsStr);
   //根据list<Id>查询并封装诊断简单对象
    DmsDiseExample dmsDiseExample=new DmsDiseExample();
    dmsDiseExample.createCriteria().andIdIn(idList);
    List<DmsDise> dmsDiseList=dmsDiseMapper.selectByExample(dmsDiseExample);
    List<DmsDiseResult> dmsDiseResultList = new ArrayList<>();

    if(CollectionUtil.isEmpty(dmsDiseList)){
       return null;
    }

    //封装dto
    for(DmsDise dmsDise: dmsDiseList){
        DmsDiseResult dmsDiseResult=new DmsDiseResult();
        BeanUtils.copyProperties(dmsDise,dmsDiseResult);
        dmsDiseResultList.add(dmsDiseResult);
    }
    return dmsDiseResultList;
}
 
Example #9
Source File: UserController.java    From eladmin with Apache License 2.0 6 votes vote down vote up
@Log("查询用户")
@ApiOperation("查询用户")
@GetMapping
@PreAuthorize("@el.check('user:list')")
public ResponseEntity<Object> query(UserQueryCriteria criteria, Pageable pageable){
    if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
        criteria.getDeptIds().add(criteria.getDeptId());
        criteria.getDeptIds().addAll(deptService.getDeptChildren(criteria.getDeptId(),
                deptService.findByPid(criteria.getDeptId())));
    }
    // 数据权限
    List<Long> dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername()));
    // criteria.getDeptIds() 不为空并且数据权限不为空则取交集
    if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)){
        // 取交集
        criteria.getDeptIds().retainAll(dataScopes);
        if(!CollectionUtil.isEmpty(criteria.getDeptIds())){
            return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK);
        }
    } else {
        // 否则取并集
        criteria.getDeptIds().addAll(dataScopes);
        return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    return new ResponseEntity<>(PageUtil.toPage(null,0),HttpStatus.OK);
}
 
Example #10
Source File: AttachmentServiceImpl.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@Override
public boolean remove(List<Long> ids) {
    if (CollectionUtil.isEmpty(ids)) {
        return false;
    }

    List<Attachment> list = super.list(Wrappers.<Attachment>lambdaQuery().in(Attachment::getId, ids));
    if (list.isEmpty()) {
        return false;
    }
    boolean bool = super.removeByIds(ids);

    boolean boolDel = fileStrategy.delete(list.stream().map((fi) -> FileDeleteDO.builder()
            .relativePath(fi.getRelativePath())
            .fileName(fi.getFilename())
            .group(fi.getGroup())
            .path(fi.getPath())
            .file(false)
            .build())
            .collect(Collectors.toList()));
    return bool && boolDel;
}
 
Example #11
Source File: JobSpringExecutor.java    From datax-web with MIT License 6 votes vote down vote up
private void initJobHandlerRepository(ApplicationContext applicationContext) {
    if (applicationContext == null) {
        return;
    }

    // init job handler action
    Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHandler.class);

    if (CollectionUtil.isNotEmpty(serviceBeanMap)) {
        for (Object serviceBean : serviceBeanMap.values()) {
            if (serviceBean instanceof IJobHandler) {
                String name = serviceBean.getClass().getAnnotation(JobHandler.class).value();
                IJobHandler handler = (IJobHandler) serviceBean;
                if (loadJobHandler(name) != null) {
                    throw new RuntimeException("datax-web jobhandler[" + name + "] naming conflicts.");
                }
                registJobHandler(name, handler);
            }
        }
    }
}
 
Example #12
Source File: ParamInterceptor.java    From Aooms with Apache License 2.0 6 votes vote down vote up
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
    Map<String,String[]> paramMaps = request.getParameterMap();
    Map<String,Object> params = CollectionUtil.newHashMap();
    paramMaps.forEach((k,v) -> {
        params.put(k,convert(v));
    });

    // 文件上传
    if(request instanceof AbstractMultipartHttpServletRequest){
        //CommonsMultipartResolver commonsMultipartResolver = new CommonsMultipartResolver(request.getServletContext());
        StandardMultipartHttpServletRequest multipartHttpServletRequest = (StandardMultipartHttpServletRequest)request;
        Map<String,MultipartFile> multipartFileMap = multipartHttpServletRequest.getFileMap();
        DataBoss.self().getPara().setFiles(multipartFileMap);
    }

    // 请求参数
    DataBoss.self().getPara().setData(params);
    // 路径参数
    DataBoss.self().getPara().setPathVars((Map)request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE));
    return true;
}
 
Example #13
Source File: SysMenuServiceImpl.java    From mall4j with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public List<SysMenu> listMenuByUserId(Long userId) {
	// 用户的所有菜单信息
	List<SysMenu> sysMenus ;
	//系统管理员,拥有最高权限
	if(userId == Constant.SUPER_ADMIN_ID){
		sysMenus = sysMenuMapper.listMenu();
	}else {
		sysMenus = sysMenuMapper.listMenuByUserId(userId);
	}
	
	Map<Long, List<SysMenu>> sysMenuLevelMap = sysMenus.stream()
			.sorted(Comparator.comparing(SysMenu::getOrderNum))
			.collect(Collectors.groupingBy(SysMenu::getParentId));
	
	// 一级菜单
	List<SysMenu> rootMenu = sysMenuLevelMap.get(0L);
	if (CollectionUtil.isEmpty(rootMenu)) {
		return Collections.emptyList();
	}
	// 二级菜单
	for (SysMenu sysMenu : rootMenu) {
		sysMenu.setList(sysMenuLevelMap.get(sysMenu.getMenuId()));
	}
	return rootMenu;
}
 
Example #14
Source File: DmsDrugServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
/**
 * 描述:1.调用DmsDrugDao查询所有记录(不包括status=0)
 * <p>author: ma
 * <p>author: 赵煜 修改越界错误
 */
@Override
public List<DmsDrugResult> selectAllDrug(){
    DmsDrugExample example = new DmsDrugExample();
    example.createCriteria().andStatusNotEqualTo(0);
    //返回数据包装成Result
    List<DmsDrug> dmsDrugs = dmsDrugMapper.selectByExample(example);
    List<DmsDrugResult> dmsDrugResultList = new ArrayList<>();
    for (DmsDrug dmsDrug   : dmsDrugs) {
        DmsDrugResult dmsDrugResult = new DmsDrugResult();
        BeanUtils.copyProperties(dmsDrug, dmsDrugResult);

        DmsDosageExample dmsDosageExample = new DmsDosageExample();
        //封装剂型
        dmsDosageExample.createCriteria().andIdEqualTo(dmsDrug.getDosageId());
        List<DmsDosage> dmsDosageList = dmsDosageMapper.selectByExample(dmsDosageExample);
        if(!CollectionUtil.isEmpty(dmsDosageList)){
            dmsDrugResult.setDosage(dmsDosageList.get(0));
        }
        dmsDrugResultList.add(dmsDrugResult);
    }
    return dmsDrugResultList;
}
 
Example #15
Source File: UserInfoHeaderFilter.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@Override
public Object run() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
        Object principal = authentication.getPrincipal();
        RequestContext ctx = RequestContext.getCurrentContext();
        //客户端模式只返回一个clientId
        if (principal instanceof SysUser) {
            SysUser user = (SysUser)authentication.getPrincipal();
            ctx.addZuulRequestHeader(SecurityConstants.USER_ID_HEADER, String.valueOf(user.getId()));
            ctx.addZuulRequestHeader(SecurityConstants.USER_HEADER, user.getUsername());
        }
        OAuth2Authentication oauth2Authentication = (OAuth2Authentication)authentication;
        String clientId = oauth2Authentication.getOAuth2Request().getClientId();
        ctx.addZuulRequestHeader(SecurityConstants.TENANT_HEADER, clientId);
        ctx.addZuulRequestHeader(SecurityConstants.ROLE_HEADER, CollectionUtil.join(authentication.getAuthorities(), ","));
    }
    return null;
}
 
Example #16
Source File: UserRoleServiceImpl.java    From kvf-admin with MIT License 6 votes vote down vote up
@Transactional
@Override
public void saveOrUpdateBatchUserRole(List<Long> roleIds, Long userId) {
    if (CollectionUtil.isEmpty(roleIds)) {
        super.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, userId));
    } else {
        super.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, userId).notIn(UserRole::getRoleId, roleIds));
        List<UserRole> userRoles = new ArrayList<>();

        roleIds.forEach(roleId -> {
            UserRole userRole = super.getOne(new LambdaQueryWrapper<UserRole>()
                    .eq(UserRole::getRoleId, roleId).eq(UserRole::getUserId, userId));
            if (userRole == null) {
                userRole = new UserRole();
            }
            userRole.setUserId(userId).setRoleId(roleId);
            userRoles.add(userRole);
        });
        super.saveOrUpdateBatch(userRoles);
    }
}
 
Example #17
Source File: JournalCommentServiceImpl.java    From halo with GNU General Public License v3.0 6 votes vote down vote up
@Override
public List<JournalCommentWithJournalVO> convertToWithJournalVo(List<JournalComment> journalComments) {

    if (CollectionUtil.isEmpty(journalComments)) {
        return Collections.emptyList();
    }

    Set<Integer> journalIds = ServiceUtils.fetchProperty(journalComments, JournalComment::getPostId);

    // Get all journals
    List<Journal> journals = journalRepository.findAllById(journalIds);

    Map<Integer, Journal> journalMap = ServiceUtils.convertToMap(journals, Journal::getId);

    return journalComments.stream()
        .filter(journalComment -> journalMap.containsKey(journalComment.getPostId()))
        .map(journalComment -> {
            JournalCommentWithJournalVO journalCmtWithJournalVo = new JournalCommentWithJournalVO().convertFrom(journalComment);
            journalCmtWithJournalVo.setJournal(new JournalDTO().convertFrom(journalMap.get(journalComment.getPostId())));
            return journalCmtWithJournalVo;
        })
        .collect(Collectors.toList());
}
 
Example #18
Source File: FileServiceImpl.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean removeList(Long userId, List<Long> ids) {
    if (CollectionUtil.isEmpty(ids)) {
        return Boolean.TRUE;
    }
    List<File> list = super.list(Wrappers.<File>lambdaQuery().in(File::getId, ids));
    if (list.isEmpty()) {
        return true;
    }
    super.removeByIds(ids);

    fileStrategy.delete(list.stream().map((fi) -> FileDeleteDO.builder()
            .relativePath(fi.getRelativePath())
            .fileName(fi.getFilename())
            .group(fi.getGroup())
            .path(fi.getPath())
            .file(false)
            .build())
            .collect(Collectors.toList()));
    return true;
}
 
Example #19
Source File: PmsPatientServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
@Override
public PmsPatientResult patientLogin(String identificationNo, String medicalRecordNo) {
   PmsPatientExample pmsPatientExample=new PmsPatientExample();
   pmsPatientExample.createCriteria().andIdentificationNoEqualTo(identificationNo).andMedicalRecordNoEqualTo(medicalRecordNo);
   List<PmsPatient> pmsPatientList = pmsPatientMapper.selectByExample(pmsPatientExample);
    if(CollectionUtil.isEmpty(pmsPatientList)||pmsPatientList.size()>1){
        return null;
    }

    //数据正常的情况下,只会返回一个病人
    PmsPatientResult pmsPatientResult=new PmsPatientResult();
    BeanUtils.copyProperties(pmsPatientList.get(0),pmsPatientResult);

    return pmsPatientResult;

}
 
Example #20
Source File: MsgsCenterInfoServiceImpl.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class)
public MsgsCenterInfo saveMsgs(MsgsCenterInfoSaveDTO data) {
    MsgsCenterInfo info = BeanPlusUtil.toBean(data.getMsgsCenterInfoDTO(), MsgsCenterInfo.class);
    info.setTitle(getOrDef(info.getTitle(), info.getContent()));
    info.setAuthor(getOrDef(info.getAuthor(), BaseContextHandler.getName()));
    super.save(info);

    //公式公告,不会指定接收人
    Set<Long> userIdList = data.getUserIdList();
    if (CollectionUtil.isNotEmpty(userIdList)) {
        List<MsgsCenterInfoReceive> receiveList = userIdList.stream().map((userId) -> MsgsCenterInfoReceive.builder()
                .isRead(false)
                .userId(userId)
                .msgsCenterId(info.getId())
                .build()).collect(Collectors.toList());
        msgsCenterInfoReceiveService.saveBatch(receiveList);
    }
    return info;
}
 
Example #21
Source File: AbstractSessionManager.java    From bitchat with Apache License 2.0 6 votes vote down vote up
@Override
public void removeSession(ChannelId channelId) {
    Assert.notNull(channelId, "channelId can not be null");
    Collection<Session> sessions = allSession();
    if (CollectionUtil.isEmpty(sessions)) {
        return;
    }
    Iterator<Session> iterator = sessions.iterator();
    while (iterator.hasNext()) {
        Session session = iterator.next();
        if (session.channelId() == channelId) {
            iterator.remove();
            log.info("remove a session, session={}, channelId={}", session, channelId);
            break;
        }
    }
}
 
Example #22
Source File: PmsPatientServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
@Override
public PmsPatientResult patientLogin(String identificationNo, String medicalRecordNo) {
   PmsPatientExample pmsPatientExample=new PmsPatientExample();
   pmsPatientExample.createCriteria().andIdentificationNoEqualTo(identificationNo).andMedicalRecordNoEqualTo(medicalRecordNo);
   List<PmsPatient> pmsPatientList = pmsPatientMapper.selectByExample(pmsPatientExample);
    if(CollectionUtil.isEmpty(pmsPatientList)||pmsPatientList.size()>1){
        return null;
    }

    //数据正常的情况下,只会返回一个病人
    PmsPatientResult pmsPatientResult=new PmsPatientResult();
    BeanUtils.copyProperties(pmsPatientList.get(0),pmsPatientResult);

    return pmsPatientResult;

}
 
Example #23
Source File: DeptController.java    From sk-admin with Apache License 2.0 6 votes vote down vote up
@Log("删除部门")
@ApiOperation("删除部门")
@DeleteMapping
@PreAuthorize("@sk.check('dept:del')")
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
    Set<DeptDTO> deptDtos = new HashSet<>();
    for (Long id : ids) {
        List<Dept> deptList = deptService.findByPid(id);
        deptDtos.add(deptService.findById(id));
        if(CollectionUtil.isNotEmpty(deptList)){
            deptDtos = deptService.getDeleteDepts(deptList, deptDtos);
        }
    }
    try {
        deptService.delete(deptDtos);
    }catch (Throwable e){
        ThrowableUtil.throwForeignKeyException(e, "所选部门中存在岗位或者角色关联,请取消关联后再试");
    }
    return new ResponseEntity<>(HttpStatus.OK);
}
 
Example #24
Source File: SysMenuServiceImpl.java    From RuoYi with Apache License 2.0 6 votes vote down vote up
/**
 * 对象转菜单树
 *
 * @param menuList     菜单列表
 * @param roleMenuList 角色已存在菜单列表
 * @param permsFlag    是否需要显示权限标识
 * @return 菜单树
 */
private List<Ztree> initZtree(List<SysMenu> menuList, List<String> roleMenuList, boolean permsFlag){
    List<Ztree> ztrees = new ArrayList<>();
    boolean isCheck = CollectionUtil.isNotEmpty(roleMenuList);
    if(CollectionUtil.isNotEmpty(menuList)){
        menuList.forEach(menu ->{
            Ztree ztree = new Ztree();
            ztree.setId(menu.getMenuId());
            ztree.setPId(menu.getParentId());
            ztree.setName(transMenuName(menu, permsFlag));
            ztree.setTitle(menu.getMenuName());
            if (isCheck){
                ztree.setChecked(roleMenuList.contains(menu.getMenuId() + menu.getPerms()));
            }
            ztrees.add(ztree);
        });
    }
    return ztrees;
}
 
Example #25
Source File: PmsPatientServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
@Override
public PmsPatientResult patientLogin(String identificationNo, String medicalRecordNo) {
   PmsPatientExample pmsPatientExample=new PmsPatientExample();
   pmsPatientExample.createCriteria().andIdentificationNoEqualTo(identificationNo).andMedicalRecordNoEqualTo(medicalRecordNo);
   List<PmsPatient> pmsPatientList = pmsPatientMapper.selectByExample(pmsPatientExample);
    if(CollectionUtil.isEmpty(pmsPatientList)||pmsPatientList.size()>1){
        return null;
    }

    //数据正常的情况下,只会返回一个病人
    PmsPatientResult pmsPatientResult=new PmsPatientResult();
    BeanUtils.copyProperties(pmsPatientList.get(0),pmsPatientResult);

    return pmsPatientResult;

}
 
Example #26
Source File: DeptServiceImpl.java    From kvf-admin with MIT License 6 votes vote down vote up
@Override
public List<Dept> listAllChildrenDept(Long deptId) {
    List<Dept> list = new ArrayList<>();
    Dept dept = getById(deptId);
    if (dept == null) {
        return list;
    }
    list.add(dept);
    List<Dept> children = this.listDeptByParentId(deptId);
    if (CollectionUtil.isEmpty(children)) {
        return list;
    }
    for (Dept child : children) {
        list.addAll(this.listAllChildrenDept(child.getId()));
    }
    return list;
}
 
Example #27
Source File: DeptController.java    From yshopmall with Apache License 2.0 6 votes vote down vote up
@Log("删除部门")
@ApiOperation("删除部门")
@DeleteMapping
@PreAuthorize("@el.check('admin','dept:del')")
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){

    List<Long> deptIds = new ArrayList<>();
    for (Long id : ids) {
        List<Dept> deptList = deptService.findByPid(id);
        Dept dept =  deptService.getOne(new QueryWrapper<Dept>().eq("id",id));
        if(null!=dept){
            deptIds.add(dept.getId());
        }
        if(CollectionUtil.isNotEmpty(deptList)){
            for(Dept d:deptList){
                deptIds.add(d.getId());
            }
        }
    }
    try {
        deptService.removeByIds(deptIds);
    }catch (Throwable e){
        throw new BadRequestException( "所选部门中存在岗位或者角色关联,请取消关联后再试");
    }
    return new ResponseEntity<>(HttpStatus.OK);
}
 
Example #28
Source File: DefaultBeanContext.java    From redant with Apache License 2.0 6 votes vote down vote up
/**
 * 处理BeanContextAware
 * 让那些实现了BeanContextAware接口的类能注入BeanContext
 */
private void processBeanContextAware() {
    LOGGER.info("[DefaultBeanContext] start processBeanContextAware");
    try {
        /*
         * 扫描指定package下指定的类,并返回set
         */
        Set<Class<?>> classSet = ClassScaner.scanPackageBySuper(CommonConstants.BEAN_SCAN_PACKAGE, BeanContextAware.class);
        if (CollectionUtil.isNotEmpty(classSet)) {
            for (Class<?> cls : classSet) {
                // 如果cls是BeanContextAware的实现类
                if (!cls.isInterface() && BeanContextAware.class.isAssignableFrom(cls)) {
                    Constructor<?> constructor = cls.getDeclaredConstructor();
                    constructor.setAccessible(true);
                    BeanContextAware aware = (BeanContextAware) constructor.newInstance();
                    aware.setBeanContext(getInstance());
                }
            }
        }
        LOGGER.info("[DefaultBeanContext] processBeanContextAware success!");
    } catch (Exception e) {
        LOGGER.error("[DefaultBeanContext] processBeanContextAware error,cause:{}", e.getMessage(), e);
    }
}
 
Example #29
Source File: DmsDrugServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
/**
 * 描述:1.调用DmsDrugDao查询所有记录(不包括status=0)
 * <p>author: ma
 * <p>author: 赵煜 修改越界错误
 */
@Override
public List<DmsDrugResult> selectAllDrug(){
    DmsDrugExample example = new DmsDrugExample();
    example.createCriteria().andStatusNotEqualTo(0);
    //返回数据包装成Result
    List<DmsDrug> dmsDrugs = dmsDrugMapper.selectByExample(example);
    List<DmsDrugResult> dmsDrugResultList = new ArrayList<>();
    for (DmsDrug dmsDrug   : dmsDrugs) {
        DmsDrugResult dmsDrugResult = new DmsDrugResult();
        BeanUtils.copyProperties(dmsDrug, dmsDrugResult);

        DmsDosageExample dmsDosageExample = new DmsDosageExample();
        //封装剂型
        dmsDosageExample.createCriteria().andIdEqualTo(dmsDrug.getDosageId());
        List<DmsDosage> dmsDosageList = dmsDosageMapper.selectByExample(dmsDosageExample);
        if(!CollectionUtil.isEmpty(dmsDosageList)){
            dmsDrugResult.setDosage(dmsDosageList.get(0));
        }
        dmsDrugResultList.add(dmsDrugResult);
    }
    return dmsDrugResultList;
}
 
Example #30
Source File: BlockController.java    From md_blockchain with Apache License 2.0 6 votes vote down vote up
/**
 * 测试生成一个Block,公钥私钥可以通过PairKeyController来生成
 * @param content
 * sql内容
 */
@GetMapping
public BaseData test(String content) throws Exception {
    InstructionBody instructionBody = new InstructionBody();
    instructionBody.setOperation(Operation.ADD);
    instructionBody.setTable("message");
    instructionBody.setJson("{\"content\":\"" + content + "\"}");
    instructionBody.setPublicKey("A8WLqHTjcT/FQ2IWhIePNShUEcdCzu5dG+XrQU8OMu54");
    instructionBody.setPrivateKey("yScdp6fNgUU+cRUTygvJG4EBhDKmOMRrK4XJ9mKVQJ8=");
    Instruction instruction = instructionService.build(instructionBody);

    BlockRequestBody blockRequestBody = new BlockRequestBody();
    blockRequestBody.setPublicKey("A8WLqHTjcT/FQ2IWhIePNShUEcdCzu5dG+XrQU8OMu54");
    com.mindata.blockchain.block.BlockBody blockBody = new com.mindata.blockchain.block.BlockBody();
    blockBody.setInstructions(CollectionUtil.newArrayList(instruction));

   blockRequestBody.setBlockBody(blockBody);

    return ResultGenerator.genSuccessResult(blockService.addBlock(blockRequestBody));
}