| @@ -0,0 +1,91 @@ | |||||
| package com.ruoyi.platform.controller.kg; | |||||
| import com.ruoyi.common.core.domain.R; | |||||
| import com.ruoyi.common.core.utils.poi.ExcelUtil; | |||||
| import com.ruoyi.common.core.web.controller.BaseController; | |||||
| import com.ruoyi.common.core.web.page.TableDataInfo; | |||||
| import com.ruoyi.platform.domain.kg.KgEntityRelations; | |||||
| import com.ruoyi.platform.service.KgEntityRelationsService; | |||||
| import com.ruoyi.system.api.domain.SysDictData; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.validation.annotation.Validated; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("/kg/entityRelations") | |||||
| public class KgEntityRelationsController extends BaseController { | |||||
| @Autowired | |||||
| private KgEntityRelationsService kgEntityRelationsService; | |||||
| /** | |||||
| * 新增实体关系 | |||||
| * | |||||
| * @param entityRelations | |||||
| * @return | |||||
| */ | |||||
| @PostMapping() | |||||
| public R<String> createEntityRelations(@Validated @RequestBody KgEntityRelations entityRelations) { | |||||
| kgEntityRelationsService.insertEntityRelation(entityRelations); | |||||
| return R.ok(); | |||||
| } | |||||
| /** | |||||
| * 修改实体关系 | |||||
| * | |||||
| * @param entityRelations | |||||
| * @return | |||||
| */ | |||||
| @PutMapping | |||||
| public R<String> updateEntityRelations(@Validated @RequestBody KgEntityRelations entityRelations) { | |||||
| kgEntityRelationsService.updateEntityRelation(entityRelations); | |||||
| return R.ok(); | |||||
| } | |||||
| /** | |||||
| * 实体关系列表 | |||||
| * @return | |||||
| */ | |||||
| @GetMapping("/list") | |||||
| public TableDataInfo getEntityRelations(@RequestBody KgEntityRelations entityRelation) { | |||||
| startPage(); | |||||
| List<KgEntityRelations> entityRelations = kgEntityRelationsService.getEntityRelations(entityRelation); | |||||
| return getDataTable(entityRelations); | |||||
| } | |||||
| /** | |||||
| * 实体关系详情 | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| @GetMapping("/{id}") | |||||
| public R<KgEntityRelations> getEntityRelations(@PathVariable Long id) { | |||||
| return R.ok(kgEntityRelationsService.getEntityRelations(id)); | |||||
| } | |||||
| /** | |||||
| * 删除实体关系 | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| @DeleteMapping("/{id}") | |||||
| public R<String> deleteEntityRelationById(@PathVariable Long id) { | |||||
| kgEntityRelationsService.deleteEntityRelationById(id); | |||||
| return R.ok(); | |||||
| } | |||||
| /** | |||||
| * 实体关系导出 | |||||
| * @param response | |||||
| * @param id | |||||
| */ | |||||
| @GetMapping("/export/{id}") | |||||
| public void export(HttpServletResponse response,@PathVariable Long id) { | |||||
| KgEntityRelations entityRelations = kgEntityRelationsService.getEntityRelations(id); | |||||
| ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class); | |||||
| util.exportExcel(response, null, "实体关系数据"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,63 @@ | |||||
| package com.ruoyi.platform.domain.kg; | |||||
| import java.io.Serializable; | |||||
| import java.util.Date; | |||||
| import lombok.Data; | |||||
| /** | |||||
| * kg_entity_relations | |||||
| */ | |||||
| @Data | |||||
| public class KgEntityRelations implements Serializable { | |||||
| /** | |||||
| * 关系主键 | |||||
| */ | |||||
| private Integer id; | |||||
| /** | |||||
| * 关系名称 | |||||
| */ | |||||
| private String name; | |||||
| /** | |||||
| * 终点属性名 | |||||
| */ | |||||
| private String target; | |||||
| /** | |||||
| * 终点实体ID | |||||
| */ | |||||
| private Integer targetId; | |||||
| /** | |||||
| * 起点实体ID | |||||
| */ | |||||
| private Integer sourceId; | |||||
| /** | |||||
| * 创建时间 | |||||
| */ | |||||
| private Date createTime; | |||||
| /** | |||||
| * 更新时间 | |||||
| */ | |||||
| private Date updateTime; | |||||
| /** | |||||
| * 删除标志,0表示未删除,1表示已删除 | |||||
| */ | |||||
| private String delFlag; | |||||
| /** | |||||
| * 创建人 | |||||
| */ | |||||
| private String createBy; | |||||
| /** | |||||
| * 更新人 | |||||
| */ | |||||
| private String updateBy; | |||||
| private static final long serialVersionUID = 1L; | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.ruoyi.platform.mapper.kg; | |||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
| import com.ruoyi.platform.domain.kg.KgEntityRelations; | |||||
| import org.apache.ibatis.annotations.Mapper; | |||||
| import java.util.List; | |||||
| @Mapper | |||||
| public interface KgEntityRelationsMapper extends BaseMapper<KgEntityRelations> { | |||||
| int deleteByPrimaryKey(Long id); | |||||
| int insert(KgEntityRelations record); | |||||
| int insertSelective(KgEntityRelations record); | |||||
| KgEntityRelations selectByPrimaryKey(Long id); | |||||
| int updateByPrimaryKeySelective(KgEntityRelations record); | |||||
| int updateByPrimaryKey(KgEntityRelations record); | |||||
| List<KgEntityRelations> selectList(KgEntityRelations record); | |||||
| } | |||||
| @@ -0,0 +1,23 @@ | |||||
| package com.ruoyi.platform.service; | |||||
| import com.ruoyi.platform.domain.kg.KgEntityRelations; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author Administrator | |||||
| * @description 针对表【kg_entity_relations】的数据库操作Service | |||||
| * @createDate 2025-02-13 15:58:49 | |||||
| */ | |||||
| public interface KgEntityRelationsService { | |||||
| void insertEntityRelation(KgEntityRelations entityRelation); | |||||
| void updateEntityRelation(KgEntityRelations entityRelation); | |||||
| List<KgEntityRelations> getEntityRelations(KgEntityRelations entityRelations); | |||||
| KgEntityRelations getEntityRelations(Long id); | |||||
| void deleteEntityRelationById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,49 @@ | |||||
| package com.ruoyi.platform.service.impl; | |||||
| import com.ruoyi.platform.domain.kg.KgEntityRelations; | |||||
| import com.ruoyi.platform.mapper.kg.KgEntityRelationsMapper; | |||||
| import com.ruoyi.platform.service.KgEntityRelationsService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author Administrator | |||||
| * @description 针对表【kg_entity_relations】的数据库操作Service实现 | |||||
| * @createDate 2025-02-13 15:58:49 | |||||
| */ | |||||
| @Service | |||||
| public class KgEntityRelationsServiceImpl implements KgEntityRelationsService{ | |||||
| @Autowired | |||||
| private KgEntityRelationsMapper kgEntityRelationsMapper; | |||||
| @Override | |||||
| public void insertEntityRelation(KgEntityRelations entityRelation) { | |||||
| kgEntityRelationsMapper.insertSelective(entityRelation); | |||||
| } | |||||
| @Override | |||||
| public void updateEntityRelation(KgEntityRelations entityRelation) { | |||||
| kgEntityRelationsMapper.updateByPrimaryKey(entityRelation); | |||||
| } | |||||
| @Override | |||||
| public List<KgEntityRelations> getEntityRelations(KgEntityRelations entityRelations) { | |||||
| return kgEntityRelationsMapper.selectList(entityRelations); | |||||
| } | |||||
| @Override | |||||
| public KgEntityRelations getEntityRelations(Long id) { | |||||
| return kgEntityRelationsMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void deleteEntityRelationById(Long id) { | |||||
| kgEntityRelationsMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,153 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.ruoyi.platform.mapper.kg.KgEntityRelationsMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.ruoyi.platform.domain.kg.KgEntityRelations"> | |||||
| <id column="id" jdbcType="INTEGER" property="id" /> | |||||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||||
| <result column="target" jdbcType="VARCHAR" property="target" /> | |||||
| <result column="target_id" jdbcType="INTEGER" property="targetId" /> | |||||
| <result column="source_id" jdbcType="INTEGER" property="sourceId" /> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> | |||||
| <result column="del_flag" jdbcType="CHAR" property="delFlag" /> | |||||
| <result column="create_by" jdbcType="VARCHAR" property="createBy" /> | |||||
| <result column="update_by" jdbcType="VARCHAR" property="updateBy" /> | |||||
| </resultMap> | |||||
| <sql id="Base_Column_List"> | |||||
| id, `name`, target, target_id, source_id, create_time, update_time, del_flag, create_by, | |||||
| update_by | |||||
| </sql> | |||||
| <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="Base_Column_List" /> | |||||
| from kg_entity_relations | |||||
| where id = #{id,jdbcType=INTEGER} | |||||
| </select> | |||||
| <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | |||||
| delete from kg_entity_relations | |||||
| where id = #{id,jdbcType=INTEGER} | |||||
| </delete> | |||||
| <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.platform.domain.kg.KgEntityRelations" useGeneratedKeys="true"> | |||||
| insert into kg_entity_relations (`name`, target, target_id, | |||||
| source_id, create_time, update_time, | |||||
| del_flag, create_by, update_by | |||||
| ) | |||||
| values (#{name,jdbcType=VARCHAR}, #{target,jdbcType=VARCHAR}, #{targetId,jdbcType=INTEGER}, | |||||
| #{sourceId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, | |||||
| #{delFlag,jdbcType=CHAR}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR} | |||||
| ) | |||||
| </insert> | |||||
| <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.platform.domain.kg.KgEntityRelations" useGeneratedKeys="true"> | |||||
| insert into kg_entity_relations | |||||
| <trim prefix="(" suffix=")" suffixOverrides=","> | |||||
| <if test="name != null"> | |||||
| `name`, | |||||
| </if> | |||||
| <if test="target != null"> | |||||
| target, | |||||
| </if> | |||||
| <if test="targetId != null"> | |||||
| target_id, | |||||
| </if> | |||||
| <if test="sourceId != null"> | |||||
| source_id, | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| create_time, | |||||
| </if> | |||||
| <if test="updateTime != null"> | |||||
| update_time, | |||||
| </if> | |||||
| <if test="delFlag != null"> | |||||
| del_flag, | |||||
| </if> | |||||
| <if test="createBy != null"> | |||||
| create_by, | |||||
| </if> | |||||
| <if test="updateBy != null"> | |||||
| update_by, | |||||
| </if> | |||||
| </trim> | |||||
| <trim prefix="values (" suffix=")" suffixOverrides=","> | |||||
| <if test="name != null"> | |||||
| #{name,jdbcType=VARCHAR}, | |||||
| </if> | |||||
| <if test="target != null"> | |||||
| #{target,jdbcType=VARCHAR}, | |||||
| </if> | |||||
| <if test="targetId != null"> | |||||
| #{targetId,jdbcType=INTEGER}, | |||||
| </if> | |||||
| <if test="sourceId != null"> | |||||
| #{sourceId,jdbcType=INTEGER}, | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| #{createTime,jdbcType=TIMESTAMP}, | |||||
| </if> | |||||
| <if test="updateTime != null"> | |||||
| #{updateTime,jdbcType=TIMESTAMP}, | |||||
| </if> | |||||
| <if test="delFlag != null"> | |||||
| #{delFlag,jdbcType=CHAR}, | |||||
| </if> | |||||
| <if test="createBy != null"> | |||||
| #{createBy,jdbcType=VARCHAR}, | |||||
| </if> | |||||
| <if test="updateBy != null"> | |||||
| #{updateBy,jdbcType=VARCHAR}, | |||||
| </if> | |||||
| </trim> | |||||
| </insert> | |||||
| <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.platform.domain.kg.KgEntityRelations"> | |||||
| update kg_entity_relations | |||||
| <set> | |||||
| <if test="name != null"> | |||||
| `name` = #{name,jdbcType=VARCHAR}, | |||||
| </if> | |||||
| <if test="target != null"> | |||||
| target = #{target,jdbcType=VARCHAR}, | |||||
| </if> | |||||
| <if test="targetId != null"> | |||||
| target_id = #{targetId,jdbcType=INTEGER}, | |||||
| </if> | |||||
| <if test="sourceId != null"> | |||||
| source_id = #{sourceId,jdbcType=INTEGER}, | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| create_time = #{createTime,jdbcType=TIMESTAMP}, | |||||
| </if> | |||||
| <if test="updateTime != null"> | |||||
| update_time = #{updateTime,jdbcType=TIMESTAMP}, | |||||
| </if> | |||||
| <if test="delFlag != null"> | |||||
| del_flag = #{delFlag,jdbcType=CHAR}, | |||||
| </if> | |||||
| <if test="createBy != null"> | |||||
| create_by = #{createBy,jdbcType=VARCHAR}, | |||||
| </if> | |||||
| <if test="updateBy != null"> | |||||
| update_by = #{updateBy,jdbcType=VARCHAR}, | |||||
| </if> | |||||
| </set> | |||||
| where id = #{id,jdbcType=INTEGER} | |||||
| </update> | |||||
| <update id="updateByPrimaryKey" parameterType="com.ruoyi.platform.domain.kg.KgEntityRelations"> | |||||
| update kg_entity_relations | |||||
| set `name` = #{name,jdbcType=VARCHAR}, | |||||
| target = #{target,jdbcType=VARCHAR}, | |||||
| target_id = #{targetId,jdbcType=INTEGER}, | |||||
| source_id = #{sourceId,jdbcType=INTEGER}, | |||||
| create_time = #{createTime,jdbcType=TIMESTAMP}, | |||||
| update_time = #{updateTime,jdbcType=TIMESTAMP}, | |||||
| del_flag = #{delFlag,jdbcType=CHAR}, | |||||
| create_by = #{createBy,jdbcType=VARCHAR}, | |||||
| update_by = #{updateBy,jdbcType=VARCHAR} | |||||
| where id = #{id,jdbcType=INTEGER} | |||||
| </update> | |||||
| <select id="selectList" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="Base_Column_List" /> | |||||
| from kg_entity_relations | |||||
| </select> | |||||
| </mapper> | |||||