<?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.wx.application.core.mapper.OntologyConceptMapper">
	
	<insert id="insertBatch" useGeneratedKeys="true" keyProperty="id">
       	insert into dn_ontology_concept(
			ontology_id,
			own_id,
			label,
			parent_id,
			create_time
       	) values(
			#{ontologyId},
			#{ownId},
			#{label},
			#{parentId},
			now()
		) ON duplicate KEY UPDATE id = LAST_INSERT_ID(id),is_remove=0
	</insert>
	
	<select id="countByOntologyId" resultType="int">
		select count(id) from dn_ontology_concept where is_remove = 0 and ontology_id = #{ontologyId}
	</select>
	
	<select id="countChildbyid" resultType="int">
		select count(id) from dn_ontology_concept where is_remove = 0 and parent_id = #{parentId}
	</select>
	
	<select id="findByOntologyIdAndLabel" resultType="com.wx.application.core.entity.OntologyConcept">
		select * from dn_ontology_concept 
		where is_remove = 0 and ontology_id = #{ontologyId} and label = #{label}
		limit 1
	</select>
	
	
</mapper>
