<?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="org.jeecg.modules.stm.rectify.assin.mapper.StProblemTaskAssinMapper">

	<update id="updateTreeNodeStatus" parameterType="java.lang.String">
		update st_problem_task_assin set has_child = #{status} where id = #{id}
	</update>

  	<!-- 【vue3专用】 -->
	<select id="queryListByPid" parameterType="java.lang.Object" resultType="org.jeecg.common.system.vo.SelectTreeModel">
		select
		  id as "key",
		  id as "title",
		  (case when has_child = '1' then 0 else 1 end) as isLeaf,
		  pid as parentId
		from st_problem_task_assin
		where pid = #{pid}
		<if test="query != null">
			<foreach collection="query.entrySet()" item="value" index="key">
				and ${key} = #{value}
			</foreach>
		</if>
	</select>

	<select id="statProblemLevel"  resultType="java.util.Map">
		SELECT severity as riskLevel,COUNT(*) as cnt FROM st_problem_task_assin GROUP BY severity
	</select>

</mapper>