一 、java后台
1.1
package com.admin.domain;
/**
- 功能描述:
* - @author wangwei
@date 2024-01-15 22:13
*/
public class ConnectWeb {private String connectWebId;
private String connectWebName;
private String connectWebInfo;
private String personWebIdAlpha;
private String personWebIdBeta;
private String personWebIdAlphaName;
private String personWebIdBetaName;
public String getPersonWebIdAlphaName() {
return personWebIdAlphaName;
}
public void setPersonWebIdAlphaName(String personWebIdAlphaName) {
this.personWebIdAlphaName = personWebIdAlphaName;
}
public String getPersonWebIdBetaName() {
return personWebIdBetaName;
}
public void setPersonWebIdBetaName(String personWebIdBetaName) {
this.personWebIdBetaName = personWebIdBetaName;
}
public String getConnectWebId() {
return connectWebId;
}
public void setConnectWebId(String connectWebId) {
this.connectWebId = connectWebId;
}
public String getConnectWebName() {
return connectWebName;
}
public void setConnectWebName(String connectWebName) {
this.connectWebName = connectWebName;
}
public String getConnectWebInfo() {
return connectWebInfo;
}
public void setConnectWebInfo(String connectWebInfo) {
this.connectWebInfo = connectWebInfo;
}
public String getPersonWebIdAlpha() {
return personWebIdAlpha;
}
public void setPersonWebIdAlpha(String personWebIdAlpha) {
this.personWebIdAlpha = personWebIdAlpha;
}
public String getPersonWebIdBeta() {
return personWebIdBeta;
}
public void setPersonWebIdBeta(String personWebIdBeta) {
this.personWebIdBeta = personWebIdBeta;
}
@Override
public String toString() {return "ConnectWeb{" + "connectWebId='" + connectWebId + '\'' + ", connectWebName='" + connectWebName + '\'' + ", connectWebInfo='" + connectWebInfo + '\'' + ", personWebIdAlpha='" + personWebIdAlpha + '\'' + ", personWebIdBeta='" + personWebIdBeta + '\'' + ", personWebIdAlphaName='" + personWebIdAlphaName + '\'' + ", personWebIdBetaName='" + personWebIdBetaName + '\'' + '}';
}
}
1.2
package com.admin.domain;
/**
- 功能描述:
人物属性实体描述 - @author wangwei
@date 2024-01-15 22:12
*/
public class PersonWeb {private String personWebId;
private String personWebName;
private String personWebPic;
private String personWebShow;
private String personWebLink;
private String personWebPlatform;
private String personWebField;
private String personWebInfo;
private String personWebKey;
public String getPersonWebId() {
return personWebId;
}
public void setPersonWebId(String personWebId) {
this.personWebId = personWebId;
}
public String getPersonWebName() {
return personWebName;
}
public void setPersonWebName(String personWebName) {
this.personWebName = personWebName;
}
public String getPersonWebPlatform() {
return personWebPlatform;
}
public void setPersonWebPlatform(String personWebPlatform) {
this.personWebPlatform = personWebPlatform;
}
public String getPersonWebField() {
return personWebField;
}
public void setPersonWebField(String personWebField) {
this.personWebField = personWebField;
}
public String getPersonWebInfo() {
return personWebInfo;
}
public void setPersonWebInfo(String personWebInfo) {
this.personWebInfo = personWebInfo;
}
public String getPersonWebKey() {
return personWebKey;
}
public void setPersonWebKey(String personWebKey) {
this.personWebKey = personWebKey;
}
public String getPersonWebPic() {
return personWebPic;
}
public void setPersonWebPic(String personWebPic) {
this.personWebPic = personWebPic;
}
public String getPersonWebShow() {
return personWebShow;
}
public void setPersonWebShow(String personWebShow) {
this.personWebShow = personWebShow;
}
public String getPersonWebLink() {
return personWebLink;
}
public void setPersonWebLink(String personWebLink) {
this.personWebLink = personWebLink;
}
@Override
public String toString() {
return "PersonWeb{" +
"personWebId='" + personWebId + '\'' +
", personWebName='" + personWebName + '\'' +
", personWebPic='" + personWebPic + '\'' +
", personWebShow='" + personWebShow + '\'' +
", personWebLink='" + personWebLink + '\'' +
", personWebPlatform='" + personWebPlatform + '\'' +
", personWebField='" + personWebField + '\'' +
", personWebInfo='" + personWebInfo + '\'' +
", personWebKey='" + personWebKey + '\'' +
'}';
}
}
1.3
package com.admin.controller;
import com.admin.common.core.controller.BaseController;
import com.admin.common.core.domain.AjaxResult;
import com.admin.common.core.page.TableDataInfo;
import com.admin.domain.ConnectWeb;
import com.admin.domain.PersonWeb;
import com.admin.service.WebService;
import com.admin.utils.transport.Result;
import org.neo4j.driver.Record;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
- 功能描述:
* - @author wangwei
@date 2024-01-16 11:09
*/
@RestController
@RequestMapping("/people/web")
public class WebController extends BaseController {@Autowired
private WebService webService;@GetMapping("/map")
public TableDataInfo getPersonWebMap() {List<Record> list = webService.selectPersonWebMap(); return getDataTable(list);
}
@GetMapping("/list")
public TableDataInfo getPersonWebList() {List<PersonWeb> list = webService.selectPersonWebList(); return getDataTable(list);
}
@GetMapping("/search/{personWebName}")
public AjaxResult getPersonWebSearchList(@PathVariable("personWebName") String personWebName) {List<PersonWeb> list = webService.selectPersonWebSearchList(personWebName); return AjaxResult.success(list);
}
@GetMapping("/search/{personWebId}/{personWebName}")
public AjaxResult getPersonWebSearchListOther(@PathVariable("personWebName") String personWebName, @PathVariable("personWebId") String personWebId) {List<PersonWeb> list = webService.selectPersonWebSearchListOther(personWebName, personWebId); return AjaxResult.success(list);
}
@GetMapping(value = "/person/{personWebId}")
public AjaxResult getPersonWebInfo(@PathVariable("personWebId") String personWebId) {return AjaxResult.success(webService.selectPersonWebById(personWebId));
}
@PostMapping("/person")
public AjaxResult addPersonWeb(@RequestBody PersonWeb personWeb) {return toAjax(webService.insertPersonWeb(personWeb));
}
@PutMapping("/person")
public AjaxResult editPersonWeb(@RequestBody PersonWeb personWeb) {return toAjax(webService.updatePersonWeb(personWeb));
}
@DeleteMapping("/person/{personWebId}")
public AjaxResult removePersonWeb(@PathVariable String personWebId) {try{ int rsg = webService.deletePersonWeb(personWebId); return toAjax(rsg); } catch (Exception e){ return AjaxResult.error(500, "此节点仍与其他节点有关联关系!"); }
}
@GetMapping(value = "/connect/{connectWebId}")
public AjaxResult getInfoConnectWeb(@PathVariable("connectWebId") String connectWebId) {return AjaxResult.success(webService.selectConnectWebById(connectWebId));
}
@PostMapping("/connect")
public AjaxResult addConnectWeb(@RequestBody ConnectWeb connectWeb) {return toAjax(webService.insertConnectWeb(connectWeb));
}
@PutMapping("/connect")
public AjaxResult editConnectWeb(@RequestBody ConnectWeb connectWeb) {return toAjax(webService.updateConnectWeb(connectWeb));
}
@DeleteMapping("/connect/{connectWebId}")
public AjaxResult removeConnectWeb(@PathVariable String connectWebId) {return toAjax(webService.deleteConnectWeb(connectWebId));
}
}
1.4
package com.admin.service;
import com.admin.domain.ConnectWeb;
import com.admin.domain.PersonWeb;
import org.neo4j.driver.Record;
import java.util.List;
public interface WebService {
List selectPersonWebMap();
public List<PersonWeb> selectPersonWebList() ;
public List<PersonWeb> selectPersonWebSearchList(String personWebName) ;
public List<PersonWeb> selectPersonWebSearchListOther(String personWebName, String personWebId) ;
public PersonWeb selectPersonWebById(String personWebId) ;
public int insertPersonWeb(PersonWeb personWeb) ;
public int updatePersonWeb(PersonWeb personWeb) ;
public int deletePersonWeb(String personWebId) ;
public ConnectWeb selectConnectWebById(String connectWebId) ;
public int insertConnectWeb(ConnectWeb connectWeb) ;
public int updateConnectWeb(ConnectWeb connectWeb) ;
public int deleteConnectWeb(String connectWebId) ;
}
1.5
package com.admin.service.impl;
import com.admin.common.annotation.DataSource;
import com.admin.common.enums.DataSourceType;
import com.admin.domain.ConnectWeb;
import com.admin.domain.PersonWeb;
import com.admin.mapper.ConnectWebMapper;
import com.admin.mapper.PersonWebMapper;
import com.admin.service.WebService;
import com.admin.utils.SnowflakeIdWorker;
import org.neo4j.driver.Record;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class WebServiceImpl implements WebService {
@Autowired
private PersonWebMapper personWebMapper;
@Autowired
private ConnectWebMapper connectWebMapper;
@Autowired
private SnowflakeIdWorker snowflakeIdWorker;
@DataSource(value = DataSourceType.SLAVE)
public List<Record> selectPersonWebMap() {
return personWebMapper.selectPersonWebMap();
}
@DataSource(value = DataSourceType.SLAVE)
public List<PersonWeb> selectPersonWebList() {
List<PersonWeb> personWebs = personWebMapper.selectPersonWebList();
return personWebs;
}
@DataSource(value = DataSourceType.SLAVE)
public List<PersonWeb> selectPersonWebSearchList(String personWebName) {
// System.out.println(personWebName);
return personWebMapper.selectPersonWebSearchList(personWebName);
}
@DataSource(value = DataSourceType.SLAVE)
public List<PersonWeb> selectPersonWebSearchListOther(String personWebName, String personWebId) {
// System.out.println(personWebName);
return personWebMapper.selectPersonWebSearchListOther(personWebName, personWebId);
}
@DataSource(value = DataSourceType.SLAVE)
public PersonWeb selectPersonWebById(String personWebId) {
return personWebMapper.selectPersonWebById(personWebId);
}
@DataSource(value = DataSourceType.SLAVE)
public int insertPersonWeb(PersonWeb personWeb) {
personWeb.setPersonWebId(snowflakeIdWorker.nextId());
return personWebMapper.insertPersonWeb(personWeb);
}
@DataSource(value = DataSourceType.SLAVE)
public int updatePersonWeb(PersonWeb personWeb) {
return personWebMapper.updatePersonWeb(personWeb);
}
@DataSource(value = DataSourceType.SLAVE)
public int deletePersonWeb(String personWebId) {
return personWebMapper.deletePersonWeb(personWebId);
}
@DataSource(value = DataSourceType.SLAVE)
public ConnectWeb selectConnectWebById(String connectWebId) {
return connectWebMapper.selectConnectWebById(connectWebId);
}
@DataSource(value = DataSourceType.SLAVE)
public int insertConnectWeb(ConnectWeb connectWeb) {
connectWeb.setConnectWebId(snowflakeIdWorker.nextId());
return connectWebMapper.insertConnectWeb(connectWeb);
}
@DataSource(value = DataSourceType.SLAVE)
public int updateConnectWeb(ConnectWeb connectWeb) {
return connectWebMapper.updateConnectWeb(connectWeb);
}
@DataSource(value = DataSourceType.SLAVE)
public int deleteConnectWeb(String connectWebId) {
return connectWebMapper.deleteConnectWeb(connectWebId);
}
}
1.6
package com.admin.mapper;
import com.admin.domain.ConnectWeb;
import org.springframework.stereotype.Repository;
/**
@author wangwei
*/
@Repository
public interface ConnectWebMapper {/**
- 查询单个连接信息
* - @param connectWebId 连接id
@return ConnectWeb实体信息
*/
ConnectWeb selectConnectWebById(String connectWebId);/**
- 插入单个连接信息
* - @param connectWeb 连接实体
@return 插入个数
*/
int insertConnectWeb(ConnectWeb connectWeb);/**
- 修改单个连接信息
* - @param connectWeb 修改实体
@return 插入个数
*/
int updateConnectWeb(ConnectWeb connectWeb);/**
- 删除单个连接
* - @param connectWebId 连接实体
- @return 删除个数
*/
int deleteConnectWeb(String connectWebId);
}
- 查询单个连接信息
1.7
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org/DTD Mapper 3.0" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
MATCH (m)-[c:ConnectWeb{
connectWebId: #{connectWebId}
}]->(n)
RETURN
c.connectWebId as connectWebId,
c.connectWebName as connectWebName,
c.connectWebInfo as connectWebInfo,
m.personWebId as personWebIdAlpha,
m.personWebName as personWebIdAlphaName,
n.personWebId as personWebIdBeta,
n.personWebName as personWebIdBetaName
match(pa:PersonWeb{
personWebId: #{personWebIdAlpha}
}),(pb:PersonWeb{
personWebId: #{personWebIdBeta}
})
merge (pa)-[c:ConnectWeb{
connectWebId: #{connectWebId},
connectWebName: #{connectWebName},
connectWebInfo: #{connectWebInfo}
}]->(pb)
MATCH (m)-[c:ConnectWeb{
connectWebId: #{connectWebId}
}]->(n)
c.connectWebName = #{connectWebName},
c.connectWebInfo = #{connectWebInfo},
m.personWebId = #{personWebIdAlpha},
n.personWebId = #{personWebIdBeta},
MATCH ()-[c:ConnectWeb{
connectWebId: #{connectWebId}
}]-()
DELETE c
1.81.8 maven
<!--手动添加-->
<!--neo4j-jdbc-driver-->
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-jdbc-driver</artifactId>
<version>4.0.1</version>
</dependency>
1.9 数据库配置
#TODO 从库数据源 neo4j
slave:
# 从数据源开关/默认关闭
enabled: true
url: jdbc:neo4j:bolt://127.0.0.1:1273
username: neo4j
password: neo4j
driverClassName: org.neo4j.jdbc.bolt.BoltDriver
#TODO NEO4J 配置检测连接是否有效
validationQuery: match (n) return id(n) limit 2
二、vue前台
2.1
新增成员
修改成员
新增关系
{ { scope.row.personWebName }}
{ { scope.row.personWebName }}
{ {ikey}}
{ { scope.row.personWebShow | statusShowFilter}}
修改
删除
删除
取消
确定
上传图片
更新图片
预览
{ {dict.dictLabel}}
{ {tag}}
+ 新标签
{ {dict.dictLabel}}
2.2
import request from '@/utils/request'
export function getPersonWebMap() {
return request({
url: '/people/web/map',
method: 'get'
})
}
export function getPersonWebList() {
return request({
url: '/people/web/list',
method: 'get'
})
}
export function getPersonWebSearch(personName) {
return request({
url: '/people/web/search/' + personName,
method: 'get'
})
}
export function getPersonWebSearchOther(personId, personName) {
return request({
url: '/people/web/search/' + personId + '/' + personName,
method: 'get'
})
}
export function getPersonWebInfo(personId) {
return request({
url: '/people/web/person/' + personId,
method: 'get'
})
}
export function addPersonWeb(data) {
return request({
url: '/people/web/person',
method: 'post',
data: data
})
}
export function editPersonWeb(data) {
return request({
url: '/people/web/person',
method: 'put',
data: data
})
}
export function removePersonWeb(personId) {
return request({
url: '/people/web/person/' + personId,
method: 'delete'
})
}
export function getInfoConnectWeb(connectId) {
return request({
url: '/people/web/connect/' + connectId,
method: 'get'
})
}
export function addConnectWeb(data) {
return request({
url: '/people/web/connect',
method: 'post',
data: data
})
}
export function editConnectWeb(data) {
return request({
url: '/people/web/connect',
method: 'put',
data: data
})
}
export function removeConnectWeb(connectId) {
return request({
url: '/people/web/connect/' + connectId,
method: 'delete'
})
}
三、展示