<?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.ai.da.mapper.primary.DesignItemMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ai.da.mapper.primary.entity.DesignItem">
        <id column="id" property="id" />
        <result column="account_id" property="accountId" />
        <result column="design_id" property="designId" />
        <result column="collection_id" property="collectionId" />
        <result column="print_scale" property="printScale" />
        <result column="design_url" property="designUrl" />
        <result column="high_design_url" property="highDesignUrl" />
        <result column="is_like" property="hasLike" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
    </resultMap>

    <insert id="insertDesignItem" parameterType="com.ai.da.mapper.primary.entity.DesignItem" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
        insert into t_design_item
        (account_id,design_id,collection_id,print_scale,design_url,high_design_url,is_like,create_date,model_id,model_type)
        values(
        #{accountId},
        #{designId},
        #{collectionId},
        #{printScale},
        #{designUrl},
        #{highDesignUrl},
        #{hasLike},
        #{createDate},
        #{modelId},
        #{modelType});
    </insert>

    <select id="selectDeleteList" resultType="com.ai.da.mapper.primary.entity.DesignItem">
        SELECT * FROM t_design_item
        WHERE collection_id not IN
              (SELECT collection_id FROM t_user_like_group
               WHERE collection_id != 0
        GROUP BY collection_id)
    </select>
</mapper>
