<?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.diagbot.mapper.ServiceInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.ServiceInfo">
        <id column="id" property="id"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="gmt_modified" property="gmtModified"/>
        <result column="creator" property="creator"/>
        <result column="modifier" property="modifier"/>
        <result column="name" property="name"/>
        <result column="description" property="description"/>
        <result column="user_id" property="userId"/>
        <result column="type" property="type"/>
    </resultMap>

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultWrapperMap" type="com.diagbot.entity.wrapper.ServiceInfoWrapper">
        <id column="id" property="id"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="gmt_modified" property="gmtModified"/>
        <result column="creator" property="creator"/>
        <result column="modifier" property="modifier"/>
        <result column="name" property="name"/>
        <result column="description" property="description"/>
        <result column="user_id" property="userId"/>
        <result column="type" property="type"/>
        <result column="product_id" property="productId"/>
    </resultMap>

    <!--根据用户查询已开通产品-->
    <select id="selectWrapperListByUserId" resultMap="BaseResultWrapperMap" parameterType="java.lang.Long">
        select a.*,b.product_id
        from diag_service_info a,diag_product_service b
        where a.id=b.service_id
        and a.type=1
        and a.user_id= #{userId}
        and a.is_deleted='N' and b.is_deleted='N'
    </select>
</mapper>
