@Override public void create(List<CreateResourceParameter> resources) throws BadRequestBusinessException { logger.debug("resources=" + resources); if (resources == null || resources.isEmpty() || resources.size() == 0) { throw new BadRequestBusinessException("失败,parameter为空"); } for (CreateResourceParameter resource : resources) { validateCreateOrUpdateParameter(resource, Constant.VALIDATION_CREATE); } for (CreateResourceParameter resource : resources) { resource.setId(idGenerator.next().toString()); resourceDao.create(resource); List<String> tagNames = resource.getTags(); if (tagNames != null && !tagNames.isEmpty() && tagNames.size() > 0) { for (String tagName : tagNames) { CreateResourceTagParameter parameter = new CreateResourceTagParameter(); parameter.setId(idGenerator.next().toString()); parameter.setResourceId(resource.getId()); Tag tag = tagDao.findByName(tagName); if (tag == null || tag.equals(null)) { CreateTagParameter createTagParameter = new CreateTagParameter(tagName); createTagParameter.setId(idGenerator.next().toString()); tagDao.create(createTagParameter); parameter.setTagId(createTagParameter.getId()); } else { parameter.setTagId(tag.getId()); } resourceTagDao.create(parameter); } } } }