diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/kg/KgEntityRelationsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/kg/KgEntityRelationsController.java new file mode 100644 index 00000000..ac2b30d9 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/kg/KgEntityRelationsController.java @@ -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 createEntityRelations(@Validated @RequestBody KgEntityRelations entityRelations) { + kgEntityRelationsService.insertEntityRelation(entityRelations); + return R.ok(); + } + + /** + * 修改实体关系 + * + * @param entityRelations + * @return + */ + @PutMapping + public R updateEntityRelations(@Validated @RequestBody KgEntityRelations entityRelations) { + kgEntityRelationsService.updateEntityRelation(entityRelations); + return R.ok(); + } + + /** + * 实体关系列表 + * @return + */ + @GetMapping("/list") + public TableDataInfo getEntityRelations(@RequestBody KgEntityRelations entityRelation) { + startPage(); + List entityRelations = kgEntityRelationsService.getEntityRelations(entityRelation); + return getDataTable(entityRelations); + } + + /** + * 实体关系详情 + * @param id + * @return + */ + @GetMapping("/{id}") + public R getEntityRelations(@PathVariable Long id) { + return R.ok(kgEntityRelationsService.getEntityRelations(id)); + } + + /** + * 删除实体关系 + * @param id + * @return + */ + @DeleteMapping("/{id}") + public R 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 util = new ExcelUtil(SysDictData.class); + util.exportExcel(response, null, "实体关系数据"); + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/KgEntityRelations.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/KgEntityRelations.java new file mode 100644 index 00000000..12939064 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/KgEntityRelations.java @@ -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; +} \ No newline at end of file diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/kg/KgEntityRelationsMapper.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/kg/KgEntityRelationsMapper.java new file mode 100644 index 00000000..ba5efdf3 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/kg/KgEntityRelationsMapper.java @@ -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 { + 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 selectList(KgEntityRelations record); +} \ No newline at end of file diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/KgEntityRelationsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/KgEntityRelationsService.java new file mode 100644 index 00000000..4cbf08ab --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/KgEntityRelationsService.java @@ -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 getEntityRelations(KgEntityRelations entityRelations); + + KgEntityRelations getEntityRelations(Long id); + + void deleteEntityRelationById(Long id); +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/KgEntityRelationsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/KgEntityRelationsServiceImpl.java new file mode 100644 index 00000000..daadcbee --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/KgEntityRelationsServiceImpl.java @@ -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 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); + } +} + + + + diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/KgEntityRelationsMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/KgEntityRelationsMapper.xml new file mode 100644 index 00000000..cc025501 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/KgEntityRelationsMapper.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + id, `name`, target, target_id, source_id, create_time, update_time, del_flag, create_by, + update_by + + + + delete from kg_entity_relations + where id = #{id,jdbcType=INTEGER} + + + 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 into kg_entity_relations + + + `name`, + + + target, + + + target_id, + + + source_id, + + + create_time, + + + update_time, + + + del_flag, + + + create_by, + + + update_by, + + + + + #{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}, + + + + + update kg_entity_relations + + + `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 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} + + + + \ No newline at end of file