Java Code Examples for cn.hutool.core.collection.CollectionUtil

The following examples show how to use cn.hutool.core.collection.CollectionUtil. These examples are extracted from open source projects. 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 Project: sk-admin   Author: DengSinkiang   File: DeptController.java    License: 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 #2
Source Project: datax-web   Author: WeiYe-Jing   File: JobSpringExecutor.java    License: 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 #3
Source Project: mall4j   Author: gz-yami   File: OrderTask.java    License: 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 #4
Source Project: feiqu-opensource   Author: chen87548081   File: ApiDocInterfaceController.java    License: 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 #5
Source Project: feiqu-opensource   Author: chen87548081   File: ApiDocInterfaceController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 更新ApiDocInterface页面
 */
@RequestMapping("/debug/{apiDocInterfaceId}")
public Object debug(@PathVariable Long apiDocInterfaceId, Model model) {
    ApiDocInterface apiDocInterface = apiDocInterfaceService.selectByPrimaryKey(apiDocInterfaceId);
    apiDocInterface.setTrueexam(HtmlUtils.htmlUnescape(apiDocInterface.getTrueexam()));
    apiDocInterface.setFalseexam(HtmlUtils.htmlUnescape(apiDocInterface.getFalseexam()));
    model.addAttribute("apiDocInterface", JSON.toJSON(apiDocInterface));
    ApiDocModuleExample example = new ApiDocModuleExample();
    example.createCriteria().andProjectIdEqualTo(apiDocInterface.getProjectid());
    List<ApiDocModule> modules = apiDocModuleService.selectByExample(example);
    List<KeyValue> keyValues = Lists.newArrayList();
    if(CollectionUtil.isNotEmpty(modules)){
        modules.forEach(module -> {
            KeyValue keyValue = new KeyValue(module.getId().toString(),module.getModuleName());
            keyValues.add(keyValue);
        });
    }
    model.addAttribute("modules", keyValues);
    model.addAttribute("apiDocInterfaceId", apiDocInterfaceId);
    return "/apiDocInterface/debug.html";
}
 
Example #6
Source Project: mall4j   Author: gz-yami   File: ProdTagController.java    License: 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 #7
Source Project: zuihou-admin-boot   Author: zuihou   File: MsgsCenterInfoServiceImpl.java    License: 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 #8
Source Project: kvf-admin   Author: kalvinGit   File: UserRoleServiceImpl.java    License: 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 #9
Source Project: microservices-platform   Author: zlt2000   File: UserInfoHeaderFilter.java    License: 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 #10
Source Project: zuihou-admin-boot   Author: zuihou   File: FileServiceImpl.java    License: 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 #11
Source Project: zuihou-admin-cloud   Author: zuihou   File: MsgsCenterInfoServiceImpl.java    License: 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 #12
Source Project: yshopmall   Author: guchengwuyue   File: DeptController.java    License: 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 #13
Source Project: Aooms   Author: yuboon   File: ParamInterceptor.java    License: 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 #14
Source Project: HIS   Author: ZainZhao   File: PmsPatientServiceImpl.java    License: 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 #15
Source Project: md_blockchain   Author: tianyaleixiaowu   File: BlockController.java    License: 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));
}
 
Example #16
Source Project: HIS   Author: ZainZhao   File: DmsDrugServiceImpl.java    License: 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 #17
Source Project: redant   Author: all4you   File: DefaultBeanContext.java    License: 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 #18
Source Project: kvf-admin   Author: kalvinGit   File: DeptServiceImpl.java    License: 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 #19
Source Project: RuoYi   Author: lerry903   File: SysMenuServiceImpl.java    License: 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 #20
Source Project: HIS   Author: ZainZhao   File: PmsPatientServiceImpl.java    License: 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 #21
Source Project: bitchat   Author: all4you   File: AbstractSessionManager.java    License: 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 Project: HIS   Author: TANGKUO   File: PmsPatientServiceImpl.java    License: 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 Project: halo   Author: halo-dev   File: JournalCommentServiceImpl.java    License: 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 #24
Source Project: redant   Author: all4you   File: InterceptorProvider.java    License: 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 #25
Source Project: HIS   Author: TANGKUO   File: DmsDrugServiceImpl.java    License: 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 #26
Source Project: HIS   Author: TANGKUO   File: DmsDiseServiceImpl.java    License: 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 #27
Source Project: redant   Author: all4you   File: InterceptorProvider.java    License: Apache License 2.0 6 votes vote down vote up
public static List<Interceptor> getInterceptors(){
    // 优先获取用户自定义的 InterceptorBuilder 构造的 Interceptor
    if(!loaded){
        synchronized (InterceptorProvider.class) {
            if(!loaded) {
                Set<Class<?>> builders = ClassScaner.scanPackageBySuper(CommonConstants.INTERCEPTOR_SCAN_PACKAGE, InterceptorBuilder.class);
                if (CollectionUtil.isNotEmpty(builders)) {
                    try {
                        for (Class<?> cls : builders) {
                            builder = (InterceptorBuilder) cls.newInstance();
                            break;
                        }
                    } catch (IllegalAccessException | InstantiationException e) {
                        e.printStackTrace();
                    }
                }
                loaded = true;
            }
        }
    }
    if(builder!=null){
        return builder.build();
    }
    // 获取不到时,再扫描所有指定目录下的 Interceptor
    return InterceptorsHolder.interceptors;
}
 
Example #28
Source Project: HIS   Author: TANGKUO   File: DmsDrugServiceImpl.java    License: 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 #29
Source Project: HIS   Author: TANGKUO   File: DmsDiseServiceImpl.java    License: 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 #30
Source Project: eladmin   Author: elunez   File: UserController.java    License: 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);
}