|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
<?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.zh.project0512.mapper.ReferenceMapper">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<resultMap id="referenceMap" type="com.zh.project0512.model.Reference">
|
|
|
|
|
<id property="id" column="id"/>
|
|
|
|
|
<collection property="tagList" ofType="java.util.Map" autoMapping="false">
|
|
|
|
@ -13,34 +15,81 @@
|
|
|
|
|
</collection>
|
|
|
|
|
</resultMap>
|
|
|
|
|
<select id="list" resultMap="referenceMap">
|
|
|
|
|
SELECT t1.*
|
|
|
|
|
select t1.*,t2.tagId,t3.title as tagTitle,t4.brandId,t5.name as brandName
|
|
|
|
|
<if test='openid!=null'>
|
|
|
|
|
,(SELECT count(*)!=0 from userReference as t4,user as t5
|
|
|
|
|
WHERE t1.id = t4.referenceId and t4.userId = t5.id and t5.openid = #{openid} ) as isCollected
|
|
|
|
|
,(SELECT count(*)!=0 from userReference as ur,user as u
|
|
|
|
|
WHERE t1.id = ur.referenceId and ur.userId = u.id and u.openid = #{openid} ) as isCollected
|
|
|
|
|
</if>
|
|
|
|
|
from reference as t1
|
|
|
|
|
<if test='groupId !=null'>
|
|
|
|
|
where groupId = #{groupId}
|
|
|
|
|
right join referenceTag as t2 on t1.id = t2.referenceId LEFT JOIN tag as t3 on t3.id = t2.tagId
|
|
|
|
|
right join referenceBrand as t4 on t1.id = t4.referenceId LEFT JOIN brand as t5 on t5.id = t4.brandId
|
|
|
|
|
WHERE t1.id
|
|
|
|
|
<if test="tagIdList !=null and tagIdList.size()!=0 ">
|
|
|
|
|
and t1.id in (SELECT referenceId from referenceBrand WHERE referenceBrand.brandId in
|
|
|
|
|
<foreach collection="tagIdList" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="brandIdList !=null and brandIdList.size()!=0 ">
|
|
|
|
|
and t1.id in (SELECT referenceId from referenceTag WHERE referenceTag.tagId in
|
|
|
|
|
<foreach collection="brandIdList" index="index" item="item" open="(" separator="," close=")">#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
ORDER BY t1.creatAt DESC
|
|
|
|
|
and t1.id in
|
|
|
|
|
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
|
|
<if test='ew != null'>
|
|
|
|
|
<if test='ew.nonEmptyOfWhere'>
|
|
|
|
|
AND
|
|
|
|
|
</if>
|
|
|
|
|
${ew.SqlSegment}
|
|
|
|
|
</if>
|
|
|
|
|
ORDER BY updateAt DESC,creatAt DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<resultMap id="referenceDateMap" type="java.util.Map" autoMapping="false">
|
|
|
|
|
<id property="dat" column="dat"/>
|
|
|
|
|
<collection property="referenceList" ofType="java.util.Map" javaType="java.util.List">
|
|
|
|
|
<collection property="referenceList" ofType="java.util.Map" javaType="java.util.List" autoMapping="false">
|
|
|
|
|
<id column="id" property="id"/>
|
|
|
|
|
<result column="title" property="title"/>
|
|
|
|
|
<result column="type" property="type"/>
|
|
|
|
|
<result column="fileUrl" property="fileUrl"/>
|
|
|
|
|
<result column="coverUrl" property="coverUrl"/>
|
|
|
|
|
<result column="groupId" property="groupId"/>
|
|
|
|
|
<result column="creatAt" property="creatAt"/>
|
|
|
|
|
<result column="updateAt" property="updateAt"/>
|
|
|
|
|
<result column="isCollected" property="isCollected"/>
|
|
|
|
|
<collection property="tagList" ofType="java.util.Map" javaType="java.util.List" autoMapping="false">
|
|
|
|
|
<id column="tagId" property="id"/>
|
|
|
|
|
<result column="tagTitle" property="title"/>
|
|
|
|
|
</collection>
|
|
|
|
|
<collection property="brandList" ofType="java.util.Map" javaType="java.util.List" autoMapping="false">
|
|
|
|
|
<id column="brandId" property="id"/>
|
|
|
|
|
<result column="brandName" property="name"/>
|
|
|
|
|
</collection>
|
|
|
|
|
</collection>
|
|
|
|
|
</resultMap>
|
|
|
|
|
<select id="referenceDateList" resultMap="referenceDateMap">
|
|
|
|
|
<!-- select t1.*,t2.tagId,t3.title as tagTitle,t4.brandId,t5.name as brandName from reference as t1-->
|
|
|
|
|
<!-- right join referenceTag as t2 on t1.id = t2.referenceId LEFT JOIN tag as t3 on t3.id = t2.tagId-->
|
|
|
|
|
<!-- right join referenceBrand as t4 on t1.id = t4.referenceId LEFT JOIN brand as t5 on t5.id = t4.brandId-->
|
|
|
|
|
<!-- WHERE t1.id ORDER BY updateAt DESC,creatAt DESC-->
|
|
|
|
|
|
|
|
|
|
select date_format(t1.creatAt, '%Y-%m-%d') dat,t1.*,t2.tagId, t3.title as tagTitle,t4.brandId,t5.name as brandName
|
|
|
|
|
from reference t1,referenceTag t2,tag t3
|
|
|
|
|
WHERE
|
|
|
|
|
t3.id = t2.tagId and t2.referenceId = t1.id
|
|
|
|
|
select date_format(t1.creatAt, '%Y-%m-%d') dat,t1.*,t2.tagId,t3.title as tagTitle,t4.brandId,t5.name as
|
|
|
|
|
brandName
|
|
|
|
|
<if test='openid!=null'>
|
|
|
|
|
,(SELECT count(*)!=0 from userReference as ur,user as u
|
|
|
|
|
WHERE t1.id = ur.referenceId and ur.userId = u.id and u.openid = #{openid} ) as isCollected
|
|
|
|
|
</if>
|
|
|
|
|
from reference as t1
|
|
|
|
|
right join referenceTag as t2 on t1.id = t2.referenceId LEFT JOIN tag as t3 on t3.id = t2.tagId
|
|
|
|
|
right join referenceBrand as t4 on t1.id = t4.referenceId LEFT JOIN brand as t5 on t5.id = t4.brandId
|
|
|
|
|
WHERE t1.id
|
|
|
|
|
<if test="tagIdList !=null and tagIdList.size()!=0 ">
|
|
|
|
|
and t1.id in (SELECT referenceId from referenceBrand WHERE referenceBrand.brandId in
|
|
|
|
|
<foreach collection="tagIdList" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="brandIdList !=null and brandIdList.size()!=0 ">
|
|
|
|
|
and t1.id in (SELECT referenceId from referenceTag WHERE referenceTag.tagId in
|
|
|
|
|
<foreach collection="brandIdList" index="index" item="item" open="(" separator="," close=")">#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
and date_format(t1.creatAt, '%Y-%m-%d') in
|
|
|
|
|
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
|
|
|
<if test='ew != null'>
|
|
|
|
|