@NoRepositoryBeanpublic interface CrudRepository<T, ID> extends Repository<T, ID> {<S extends T> S save(S var1);<S extends T> Iterable<S> saveAll(Iterable<S> var1);Optional<T> findById(ID var1);boolean existsById(ID var1);Iterable<T> findAll();Iterable<T> findAllById(Iterable<ID> var1);long count();void deleteById(ID var1);void delete(T var1);void deleteAll(Iterable<? extends T> var1);void deleteAll();}@NoRepositoryBeanpublic interface PagingAndSortingRepository<T, ID> extends CrudRepository<T, ID> {Iterable<T> findAll(Sort var1);Page<T> findAll(Pageable var1);}
@Repositorypublic interface CompanyEntryRepository extends Neo4jRepository<CompanyEntryNode, String> {}
public interface CompanyEntryService {/*** 获取所有数据** @return*/List<CompanyEntryNode> getAll();/*** 修改* @param companyEntryNode*/void modifyCompanyEntry(CompanyEntryNode companyEntryNode);/*** 删除* @param companyId*/void deleteById(String companyId);/*** 查询* @param companyId* @return*/CompanyEntryNode findById(String companyId);}
@Service@Slf4jpublic class CompanyEntryServiceImpl implements CompanyEntryService {@Autowiredprivate CompanyEntryRepository companyEntryRepository;/*** 获取所有数据** @return*/@Overridepublic List<CompanyEntryNode> getAll() {Iterable<CompanyEntryNode> all = companyEntryRepository.findAll();List<CompanyEntryNode> companyEntryNodes = Lists.newArrayList(all);return companyEntryNodes;}/*** 修改** @param companyEntryNode*/@Overridepublic void modifyCompanyEntry(CompanyEntryNode companyEntryNode) {if(StringUtils.isEmpty(companyEntryNode.getUuid())){companyEntryNode.setUuid(UUID.randomUUID().toString());}companyEntryRepository.save(companyEntryNode);}/*** 删除** @param companyId*/@Overridepublic void deleteById(String companyId) {companyEntryRepository.deleteById(companyId);}/*** 查询** @param companyId* @return*/@Overridepublic CompanyEntryNode findById(String companyId) {Optional<CompanyEntryNode> byId = companyEntryRepository.findById(companyId);if (byId.isPresent()) {return byId.get();}return new CompanyEntryNode();}}
@RestController@RequestMapping(value = "companyEntry")@Slf4jpublic class CompanyEntryController {@Autowiredprivate CompanyEntryService companyEntryService;/*** 获取公司词条** @return*/@PostMapping(value = "save")public WebResInfo save(@RequestBody CompanyEntryNode companyEntryNode) {log.info("save->companyEntryNode{}", companyEntryNode);WebResInfo webResInfo = new WebResInfo();try {webResInfo.setCode(WebResCode.Successful);companyEntryService.modifyCompanyEntry(companyEntryNode);} catch (Exception e) {log.error("save error:{}", e);webResInfo.setCode(WebResCode.Server_Bug_Exception);webResInfo.setMessage(e.getMessage());}return webResInfo;}


,其实是我懒!文章转载自Neo4j权威指南,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




