<?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.xintong.visualinspection.dao.cluster.ItemDao" >
    <resultMap id="BaseResultMap" type="com.xintong.visualinspection.bean.Item" >
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="parent_id" property="parent_id" jdbcType="INTEGER" />
        <result column="name" property="name" jdbcType="VARCHAR" />
        <result column="content" property="content" jdbcType="VARCHAR" />
        <result column="score" property="score" jdbcType="INTEGER" />
        <result column="score_type" property="score_type" jdbcType="INTEGER" />
        <result column="type" property="type" jdbcType="INTEGER" />
    </resultMap>

    <select id="getAll" resultMap="BaseResultMap"  >
        SELECT *
        FROM check_item ORDER BY parent_id ASC , id ASC
    </select>

    <select id="getCheckItemName" parameterType="java.lang.Long" resultType="java.lang.String">
        select if(p.score is NULL,p.name,(select name from check_item where id = p.parent_id)) itemname from check_item p where p.id in (select item_id from check_rule_item where rule_id=#{id}) GROUP BY itemname
    </select>

</mapper>