<?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.mcwl.resource.mapper.CollectMapper">

    <select id="selectCollect" resultType="com.mcwl.resource.domain.Collect">
        select
            id,product_id,user_id,product_type
            FROM collect where product_id = #{productId} and user_id = #{userId} and collect_type = #{collectType}
    </select>

    <select id="selectCollectById" resultType="com.mcwl.resource.domain.Collect">
        select
            id,product_id,user_id,product_type
        FROM collect where product_id = #{modelId} and user_id = #{userIdMax} and collect_type = #{type}
    </select>

    <select id="selectCollectWorkFlow" resultType="com.mcwl.resource.domain.response.ResponseCollect">
        SELECT c.product_id as id,w.cover_path as file_path,v.file_name,w.workflow_name as product_name,u.nick_name,v.file_size,c.create_time
        FROM collect as c
                 LEFT JOIN work_flow_version as v on c.product_id = v.id
                 LEFT JOIN work_flow as w on  v.work_flow_id = w.id
                 LEFT JOIN sys_user as u on w.user_id = u.user_id
        WHERE c.user_id = #{userIdMax} and  c.collect_type = 1
    </select>

    <select id="selectCollectModel" resultType="com.mcwl.resource.domain.response.ResponseCollect">
        SELECT 	c.product_id as id,m.surface_url as file_path,v.file_name,m.model_name as product_name,u.nick_name,
                v.file_size,c.create_time,v.model_version_type as type,v.trigger_words,v.is_encrypt,v.encryption_file_name
        FROM collect as c
                 LEFT JOIN model_version as v on c.product_id = v.id
                 LEFT JOIN model as m on  v.model_id = m.id
                 LEFT JOIN sys_user as u on m.user_id = u.user_id
        WHERE  c.user_id = #{userIdMax} and c.product_type = #{type} and c.collect_type = 0
    </select>

</mapper>
