| @@ -10,6 +10,7 @@ import com.ruoyi.platform.domain.kg.dto.KgInfoIdDTO; | |||
| import com.ruoyi.platform.service.KgInfoService; | |||
| 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; | |||
| @@ -32,7 +33,7 @@ public class KgInfoController extends BaseController { | |||
| * @return | |||
| */ | |||
| @PostMapping() | |||
| public R<String> createKgInfo(@RequestBody KgInfo kgInfo) { | |||
| public R<String> createKgInfo(@Validated @RequestBody KgInfo kgInfo) { | |||
| kgInfoService.insertKgInfo(kgInfo); | |||
| return R.ok(); | |||
| } | |||
| @@ -44,7 +45,7 @@ public class KgInfoController extends BaseController { | |||
| * @return | |||
| */ | |||
| @PutMapping | |||
| public R<String> updateKgInfo(@RequestBody KgInfo kgInfo) { | |||
| public R<String> updateKgInfo(@Validated @RequestBody KgInfo kgInfo) { | |||
| kgInfoService.updateKgInfo(kgInfo); | |||
| return R.ok(); | |||
| } | |||
| @@ -6,6 +6,8 @@ import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.page.TableDataInfo; | |||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||
| import com.ruoyi.platform.domain.kg.KgOntologyInfo; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyInfoPageDTO; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyNameAndIdDTO; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyUpdateDTO; | |||
| import com.ruoyi.platform.service.KgOntologyInfoService; | |||
| import com.ruoyi.system.api.domain.SysDictData; | |||
| @@ -67,13 +69,22 @@ public class KgOntologyInfoController extends BaseController { | |||
| * 主体列表 | |||
| * @return | |||
| */ | |||
| @GetMapping("/list") | |||
| public TableDataInfo getOntologies(@RequestBody KgOntologyInfo ontology) { | |||
| @PostMapping("/list") | |||
| public TableDataInfo getOntologies(@RequestBody KgOntologyInfoPageDTO ontology) { | |||
| startPage(); | |||
| List<KgOntologyInfo> ontologies = kgOntologyInfoService.getOntologies(ontology); | |||
| return getDataTable(ontologies); | |||
| } | |||
| /** | |||
| * 新增图谱时关联主体内容 | |||
| * @return | |||
| */ | |||
| @GetMapping("/getBasicInfo") | |||
| public R<List<KgOntologyNameAndIdDTO>> getNameAndIds() { | |||
| return R.ok(kgOntologyInfoService.getNameAndIds()); | |||
| } | |||
| /** | |||
| * 主体详情 | |||
| * @param id | |||
| @@ -4,6 +4,8 @@ import java.io.Serializable; | |||
| import java.util.Date; | |||
| import lombok.Data; | |||
| import javax.validation.constraints.NotNull; | |||
| /** | |||
| * kg_entity_info | |||
| */ | |||
| @@ -17,6 +19,7 @@ public class KgEntityInfo implements Serializable { | |||
| /** | |||
| * 实体名称 | |||
| */ | |||
| @NotNull(message = "实体名称不能为空") | |||
| private String name; | |||
| /** | |||
| @@ -32,11 +35,13 @@ public class KgEntityInfo implements Serializable { | |||
| /** | |||
| * 横坐标 | |||
| */ | |||
| @NotNull(message = "横坐标不能为空") | |||
| private Integer displayX; | |||
| /** | |||
| * 纵坐标 | |||
| */ | |||
| @NotNull(message = "纵坐标不能为空") | |||
| private Integer displayY; | |||
| /** | |||
| @@ -47,6 +52,7 @@ public class KgEntityInfo implements Serializable { | |||
| /** | |||
| * 主体主键 | |||
| */ | |||
| @NotNull(message = "主体主键不能为空") | |||
| private Long ontologyId; | |||
| /** | |||
| @@ -4,6 +4,8 @@ import java.io.Serializable; | |||
| import java.util.Date; | |||
| import lombok.Data; | |||
| import javax.validation.constraints.NotNull; | |||
| /** | |||
| * kg_entity_properties | |||
| */ | |||
| @@ -17,11 +19,13 @@ public class KgEntityProperty implements Serializable { | |||
| /** | |||
| * 属性名 | |||
| */ | |||
| @NotNull(message = "属性名不能为空") | |||
| private String name; | |||
| /** | |||
| * 属性类型(String/Integer等) | |||
| */ | |||
| @NotNull(message = "属性类型不能为空") | |||
| private String type; | |||
| /** | |||
| @@ -32,6 +36,7 @@ public class KgEntityProperty implements Serializable { | |||
| /** | |||
| * '是否多值(0否/1是) | |||
| */ | |||
| @NotNull(message = "是否多值不能为空") | |||
| private Boolean isMultivalued; | |||
| /** | |||
| @@ -4,6 +4,8 @@ import java.io.Serializable; | |||
| import java.util.Date; | |||
| import lombok.Data; | |||
| import javax.validation.constraints.NotNull; | |||
| /** | |||
| * kg_entity_relations | |||
| */ | |||
| @@ -17,6 +19,7 @@ public class KgEntityRelation implements Serializable { | |||
| /** | |||
| * 关系名称 | |||
| */ | |||
| @NotNull(message = "属性名不能为空") | |||
| private String name; | |||
| /** | |||
| @@ -27,11 +30,13 @@ public class KgEntityRelation implements Serializable { | |||
| /** | |||
| * 终点实体ID | |||
| */ | |||
| @NotNull(message = "终点实体ID不能为空") | |||
| private Long targetId; | |||
| /** | |||
| * 起点实体ID | |||
| */ | |||
| @NotNull(message = "起点实体ID不能为空") | |||
| private Long sourceId; | |||
| /** | |||
| @@ -0,0 +1,30 @@ | |||
| package com.ruoyi.platform.domain.kg.dto; | |||
| import lombok.Data; | |||
| import javax.validation.constraints.NotNull; | |||
| /** | |||
| * kg_ontology_info | |||
| */ | |||
| @Data | |||
| public class KgOntologyInfoPageDTO { | |||
| /** | |||
| * 主体名称 | |||
| */ | |||
| private String name; | |||
| /** | |||
| * 每页大小 | |||
| */ | |||
| @NotNull(message = "每页大小不能为空") | |||
| private Integer pageSize; | |||
| /** | |||
| * 页码 | |||
| */ | |||
| @NotNull(message = "页码不能为空") | |||
| private Integer pageNum; | |||
| } | |||
| @@ -0,0 +1,19 @@ | |||
| package com.ruoyi.platform.domain.kg.dto; | |||
| import lombok.Data; | |||
| import javax.validation.constraints.NotNull; | |||
| @Data | |||
| public class KgOntologyNameAndIdDTO { | |||
| /** | |||
| * 主体主键 | |||
| */ | |||
| private Long id; | |||
| /** | |||
| * 主体名称 | |||
| */ | |||
| @NotNull(message = "主体名称不能为空") | |||
| private String name; | |||
| } | |||
| @@ -23,5 +23,5 @@ public interface KgEntityPropertiesMapper extends BaseMapper<KgEntityProperty> { | |||
| List<KgEntityProperty> selectList(KgEntityProperty record); | |||
| List<KgEntityProperty> selectListByEntityIds(@Param("list") List<Long> entityIds); | |||
| List<KgEntityProperty> selectListByEntityIds( List<Long> entityIds); | |||
| } | |||
| @@ -2,6 +2,8 @@ package com.ruoyi.platform.mapper.kg; | |||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
| import com.ruoyi.platform.domain.kg.KgOntologyInfo; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyInfoPageDTO; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyNameAndIdDTO; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyUpdateDTO; | |||
| import org.apache.ibatis.annotations.Mapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| @@ -25,9 +27,12 @@ public interface KgOntologyInfoMapper extends BaseMapper<KgOntologyInfo> { | |||
| void deleteByPrimaryKey(@Param("id") Long id); | |||
| List<KgOntologyInfo> selectList(KgOntologyInfo ontology); | |||
| void deleteByIds(List<Long> ids); | |||
| List<KgOntologyInfo> selectList(KgOntologyInfoPageDTO ontology); | |||
| List<KgOntologyNameAndIdDTO> getNameAndIds(); | |||
| } | |||
| @@ -2,6 +2,8 @@ package com.ruoyi.platform.service; | |||
| import com.ruoyi.platform.domain.kg.KgOntologyInfo; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyInfoPageDTO; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyNameAndIdDTO; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyUpdateDTO; | |||
| import java.util.List; | |||
| @@ -17,7 +19,7 @@ public interface KgOntologyInfoService { | |||
| void updateOntology(KgOntologyUpdateDTO ontology); | |||
| List<KgOntologyInfo> getOntologies(KgOntologyInfo ontology); | |||
| List<KgOntologyInfo> getOntologies(KgOntologyInfoPageDTO ontology); | |||
| KgOntologyUpdateDTO getOntology(Long id); | |||
| @@ -28,4 +30,6 @@ public interface KgOntologyInfoService { | |||
| String importOntology(List<KgOntologyInfo> ontologyList, boolean updateSupport, String operName); | |||
| void updateDetail(KgOntologyUpdateDTO ontology); | |||
| List<KgOntologyNameAndIdDTO> getNameAndIds(); | |||
| } | |||
| @@ -1,12 +1,15 @@ | |||
| package com.ruoyi.platform.service.impl; | |||
| import cn.hutool.core.collection.CollectionUtil; | |||
| import cn.hutool.core.util.ObjectUtil; | |||
| import com.ruoyi.platform.domain.kg.KgEntityProperty; | |||
| import com.ruoyi.platform.mapper.kg.KgEntityPropertiesMapper; | |||
| import com.ruoyi.platform.service.KgEntityPropertiesService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| /** | |||
| @@ -30,6 +33,7 @@ public class KgEntityPropertiesServiceImpl implements KgEntityPropertiesService | |||
| } | |||
| @Override | |||
| @Transactional | |||
| public void batchUpdateByEntityId(Long entityId, List<KgEntityProperty> entityProperties) { | |||
| entityProperties.forEach(item -> { | |||
| if (ObjectUtil.isNull(item.getId())) { | |||
| @@ -48,6 +52,9 @@ public class KgEntityPropertiesServiceImpl implements KgEntityPropertiesService | |||
| @Override | |||
| public List<KgEntityProperty> getEntityPropertiesByEntityIds(List<Long> ids) { | |||
| if (CollectionUtil.isEmpty(ids)){ | |||
| return Collections.emptyList(); | |||
| } | |||
| return kgEntityPropertiesMapper.selectListByEntityIds(ids); | |||
| } | |||
| @@ -1,12 +1,15 @@ | |||
| package com.ruoyi.platform.service.impl; | |||
| import cn.hutool.core.collection.CollectionUtil; | |||
| import cn.hutool.core.util.ObjectUtil; | |||
| import com.ruoyi.platform.domain.kg.KgEntityRelation; | |||
| 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 org.springframework.transaction.annotation.Transactional; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| /** | |||
| @@ -30,6 +33,7 @@ public class KgEntityRelationsServiceImpl implements KgEntityRelationsService{ | |||
| } | |||
| @Override | |||
| @Transactional | |||
| public void batchUpdateByEntityId(Long entityId, List<KgEntityRelation> entityRelations) { | |||
| entityRelations.forEach(item -> { | |||
| if (ObjectUtil.isNull(item.getId())) { | |||
| @@ -48,6 +52,9 @@ public class KgEntityRelationsServiceImpl implements KgEntityRelationsService{ | |||
| @Override | |||
| public List<KgEntityRelation> getEntityRelationsByEntityIds(List<Long> ids) { | |||
| if (CollectionUtil.isEmpty(ids)){ | |||
| return Collections.emptyList(); | |||
| } | |||
| return kgEntityRelationsMapper.selectListByEntityIds(ids); | |||
| } | |||
| @@ -4,6 +4,8 @@ import com.ruoyi.platform.domain.kg.KgEntityProperty; | |||
| import com.ruoyi.platform.domain.kg.KgEntityRelation; | |||
| import com.ruoyi.platform.domain.kg.KgOntologyInfo; | |||
| import com.ruoyi.platform.domain.kg.dto.KgEntityInfoDTO; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyInfoPageDTO; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyNameAndIdDTO; | |||
| import com.ruoyi.platform.domain.kg.dto.KgOntologyUpdateDTO; | |||
| import com.ruoyi.platform.mapper.kg.KgOntologyInfoMapper; | |||
| import com.ruoyi.platform.service.KgEntityInfoService; | |||
| @@ -12,6 +14,7 @@ import com.ruoyi.platform.service.KgEntityRelationsService; | |||
| import com.ruoyi.platform.service.KgOntologyInfoService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| @@ -46,7 +49,7 @@ public class KgOntologyInfoServiceImpl implements KgOntologyInfoService { | |||
| } | |||
| @Override | |||
| public List<KgOntologyInfo> getOntologies(KgOntologyInfo ontology) { | |||
| public List<KgOntologyInfo> getOntologies(KgOntologyInfoPageDTO ontology) { | |||
| List<KgOntologyInfo> kgOntologyInfos = kgOntologyInfoMapper.selectList(ontology); | |||
| kgOntologyInfos.forEach(item -> { | |||
| List<KgEntityInfoDTO> kgEntityInfos = kgEntityInfoService.getEntitiesByOntologyId(item.getId()); | |||
| @@ -71,12 +74,13 @@ public class KgOntologyInfoServiceImpl implements KgOntologyInfoService { | |||
| @Override | |||
| public void deleteOntologyById(Long id) { | |||
| kgOntologyInfoMapper.deleteById(id); | |||
| kgOntologyInfoMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| @Transactional | |||
| public void batchDelete(List<Long> ids) { | |||
| kgOntologyInfoMapper.deleteBatchIds(ids); | |||
| kgOntologyInfoMapper.deleteByIds(ids); | |||
| } | |||
| @Override | |||
| @@ -85,6 +89,7 @@ public class KgOntologyInfoServiceImpl implements KgOntologyInfoService { | |||
| } | |||
| @Override | |||
| @Transactional | |||
| public void updateDetail(KgOntologyUpdateDTO ontology) { | |||
| List<KgEntityInfoDTO> concepts = ontology.getConcepts(); | |||
| concepts.forEach(item->{ | |||
| @@ -95,6 +100,11 @@ public class KgOntologyInfoServiceImpl implements KgOntologyInfoService { | |||
| kgEntityRelationsService.batchUpdateByEntityId(entityId,relations); | |||
| }); | |||
| } | |||
| @Override | |||
| public List<KgOntologyNameAndIdDTO> getNameAndIds() { | |||
| return kgOntologyInfoMapper.getNameAndIds(); | |||
| } | |||
| } | |||
| @@ -20,13 +20,13 @@ | |||
| id, `name`, description, bk_color, display_x, display_y, icon, ontology_id, create_time, | |||
| update_time, del_flag, create_by, update_by | |||
| </sql> | |||
| <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | |||
| <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="Base_Column_List" /> | |||
| from kg_entity_info | |||
| where id = #{id,jdbcType=INTEGER} | |||
| </select> | |||
| <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | |||
| <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> | |||
| delete from kg_entity_info | |||
| where id = #{id,jdbcType=INTEGER} | |||
| </delete> | |||
| @@ -17,13 +17,13 @@ | |||
| id, `name`, `type`, entity_id, is_multivalued, create_time, update_time, del_flag, | |||
| create_by, update_by | |||
| </sql> | |||
| <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | |||
| <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="Base_Column_List" /> | |||
| from kg_entity_properties | |||
| where id = #{id,jdbcType=INTEGER} | |||
| </select> | |||
| <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | |||
| <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> | |||
| delete from kg_entity_properties | |||
| where id = #{id,jdbcType=INTEGER} | |||
| </delete> | |||
| @@ -163,8 +163,8 @@ | |||
| select | |||
| <include refid="Base_Column_List" /> | |||
| from kg_entity_properties | |||
| where entity_id IN | |||
| <foreach item="id" index="index" collection="list" open="(" separator="," close=")"> | |||
| where entity_id in | |||
| <foreach collection="list" item="id" open="(" separator="," close=")"> | |||
| #{id} | |||
| </foreach> | |||
| </select> | |||
| @@ -18,13 +18,13 @@ | |||
| id, `name`, target, target_id, source_id, entity_id, create_time, update_time, del_flag, create_by, | |||
| update_by | |||
| </sql> | |||
| <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | |||
| <select id="selectByPrimaryKey" parameterType="java.lang.Long" 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 id="deleteByPrimaryKey" parameterType="java.lang.Long"> | |||
| delete from kg_entity_relations | |||
| where id = #{id,jdbcType=INTEGER} | |||
| </delete> | |||
| @@ -17,13 +17,17 @@ | |||
| id, `name`, description, concepts_count, relations_count, create_time, update_time, | |||
| create_by, update_by, del_flag | |||
| </sql> | |||
| <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | |||
| <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="Base_Column_List" /> | |||
| from kg_ontology_info | |||
| where id = #{id,jdbcType=INTEGER} | |||
| </select> | |||
| <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | |||
| <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> | |||
| delete from kg_ontology_info | |||
| where id = #{id,jdbcType=INTEGER} | |||
| </delete> | |||
| <delete id="deleteByIds" parameterType="java.lang.Long"> | |||
| delete from kg_ontology_info | |||
| where id = #{id,jdbcType=INTEGER} | |||
| </delete> | |||
| @@ -149,6 +153,15 @@ | |||
| select | |||
| <include refid="Base_Column_List" /> | |||
| from kg_ontology_info | |||
| order by update_time desc | |||
| <!-- where--> | |||
| <!-- <if test="name != null and name != ''">--> | |||
| <!-- `name` = #{name}--> | |||
| <!-- </if>--> | |||
| <!-- order by update_time desc--> | |||
| </select> | |||
| <select id="getNameAndIds" resultType="com.ruoyi.platform.domain.kg.dto.KgOntologyNameAndIdDTO"> | |||
| select | |||
| id,name | |||
| from kg_ontology_info | |||
| </select> | |||
| </mapper> | |||