|
@@ -51,26 +51,73 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="findAllAlbumInfo" resultType="com.redxun.knowledge.album.entity.dao.AlbumInfo" parameterType="java.util.Map">
|
|
|
- select ai.*,s2.FULLNAME_ from (
|
|
|
- select * from (
|
|
|
- select t1.*,nvl(t2.yelpCount,0) yelpTotal from (
|
|
|
- select av.ALBUM_ID,nvl(sum(count(*)) over (partition by VERSION_ID),0) knowledgeTotal,av.STATE versionState
|
|
|
+ select pk_id,
|
|
|
+ category_id,
|
|
|
+ name,
|
|
|
+ cover,
|
|
|
+ owner_company_id,
|
|
|
+ owner_department_id,
|
|
|
+ owner_id,
|
|
|
+ state,
|
|
|
+ views,
|
|
|
+ is_del,
|
|
|
+ company_id_,
|
|
|
+ create_dep_id_,
|
|
|
+ tenant_id_,
|
|
|
+ create_by_,
|
|
|
+ create_time_,
|
|
|
+ update_by_,
|
|
|
+ update_time_,
|
|
|
+ nvl(knowledgetotal,0) knowledgeTotal,
|
|
|
+ nvl(yelptotal,0) yelpTotal,
|
|
|
+ fullname_,
|
|
|
+ versionState
|
|
|
+ from (
|
|
|
+ select ai.*, nvl(t2.yelpCount, 0) yelpTotal, s2.FULLNAME_, av.versionState versionState
|
|
|
+ from (
|
|
|
+ select *
|
|
|
+ from (
|
|
|
+ select t1.*
|
|
|
+ --, nvl(t2.yelpCount, 0) yelpTotal
|
|
|
+ from (
|
|
|
+ select av.ALBUM_ID,
|
|
|
+ nvl(sum(nvl(count(*), 0)) over (partition by VERSION_ID), 0) knowledgeTotal,
|
|
|
+ av.STATE versionStates
|
|
|
from (
|
|
|
select *
|
|
|
- from (select b.*, (ROW_NUMBER() OVER (PARTITION BY b.ALBUM_ID ORDER BY b.CREATE_TIME_ desc)) rn
|
|
|
- from KM_ALBUM_VERSION b where IS_DEL = 0)
|
|
|
+ from (select b.*,
|
|
|
+ (ROW_NUMBER()
|
|
|
+ OVER (PARTITION BY b.ALBUM_ID ORDER BY b.CREATE_TIME_ desc)) rn
|
|
|
+ from KM_ALBUM_VERSION b
|
|
|
+ where IS_DEL = 0)
|
|
|
where rn = 1) av
|
|
|
- left join KM_ALBUM_CATALOGUE catalogue on av.PK_ID = catalogue.VERSION_ID and catalogue.IS_DEL = 0
|
|
|
- join KM_ALBUM_CATALOGUE_KNOWLEDGE knowledge ON catalogue.PK_ID = knowledge.CATALOGUE_ID and knowledge.IS_DEL = 0
|
|
|
- group by VERSION_ID,av.ALBUM_ID,av.STATE) t1 left join (select ALBUM_ID, count(*) yelpCount
|
|
|
- from KM_ALBUM_YELP
|
|
|
- where IS_DEL = 0 and STATE = 1
|
|
|
- group by ALBUM_ID) t2 on t1.ALBUM_ID = t2.ALBUM_ID) result1 join KM_ALBUM_INFO ai on result1.ALBUM_ID = ai.PK_ID where ai.IS_DEL = 0)
|
|
|
- ai JOIN LEARNING_USER_DEV.OS_USER s2
|
|
|
+ left join KM_ALBUM_CATALOGUE catalogue
|
|
|
+ on av.PK_ID = catalogue.VERSION_ID and catalogue.IS_DEL = 0
|
|
|
+ join KM_ALBUM_CATALOGUE_KNOWLEDGE knowledge
|
|
|
+ ON catalogue.PK_ID = knowledge.CATALOGUE_ID and knowledge.IS_DEL = 0
|
|
|
+ group by VERSION_ID, av.ALBUM_ID, av.STATE) t1) result1
|
|
|
+ right join KM_ALBUM_INFO ai on result1.ALBUM_ID = ai.PK_ID
|
|
|
+ where ai.IS_DEL = 0) ai
|
|
|
+ JOIN LEARNING_USER_DEV.OS_USER s2
|
|
|
ON OWNER_ID = USER_ID_
|
|
|
+ left join (select ALBUM_ID, count(*) yelpCount
|
|
|
+ from KM_ALBUM_YELP
|
|
|
+ where IS_DEL = 0
|
|
|
+ and STATE = 1
|
|
|
+ group by ALBUM_ID) t2 on ai.PK_ID = t2.ALBUM_ID
|
|
|
+ join (select av.ALBUM_ID,
|
|
|
+ av.STATE versionState
|
|
|
+ from (
|
|
|
+ select *
|
|
|
+ from (select b.*,
|
|
|
+ (ROW_NUMBER()
|
|
|
+ OVER (PARTITION BY b.ALBUM_ID ORDER BY b.CREATE_TIME_ desc)) rn
|
|
|
+ from KM_ALBUM_VERSION b
|
|
|
+ where IS_DEL = 0)
|
|
|
+ where rn = 1) av) av on av.ALBUM_ID = ai.PK_ID)
|
|
|
<where>
|
|
|
<if test="@rx.Ognl@isNotEmpty(params.name)">
|
|
|
- instr(ai.NAME,#{params.name}) > 0
|
|
|
+ instr(name,#{params.name}) > 0
|
|
|
</if>
|
|
|
<if test="@rx.Ognl@isNotEmpty(params.categoryId)">
|
|
|
and CATEGORY_ID IN (
|
|
@@ -82,20 +129,20 @@
|
|
|
and instr(FULLNAME_,#{params.ownerName}) > 0
|
|
|
</if>
|
|
|
<if test="@rx.Ognl@isNotEmpty(params.state) and params.state == 0">
|
|
|
- and ai.state = #{params.state}
|
|
|
+ and state = #{params.state}
|
|
|
</if>
|
|
|
<if test="@rx.Ognl@isNotEmpty(params.state) and params.state != 0">
|
|
|
- and ai.versionState = #{params.state}
|
|
|
+ and versionState = #{params.state} and state = 1
|
|
|
</if>
|
|
|
<if test="@rx.Ognl@isNotEmpty(params.createTimeStart)">
|
|
|
- and TO_CHAR(ai.CREATE_TIME_,'yyyy-mm-dd') >= #{params.createTimeStart}
|
|
|
+ and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') >= #{params.createTimeStart}
|
|
|
</if>
|
|
|
<if test="@rx.Ognl@isNotEmpty(params.createTimeEnd)">
|
|
|
- and TO_CHAR(ai.CREATE_TIME_,'yyyy-mm-dd') <= #{params.createTimeEnd}
|
|
|
+ and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') <= #{params.createTimeEnd}
|
|
|
</if>
|
|
|
</where>
|
|
|
<if test="@rx.Ognl@isEmpty(order)">
|
|
|
- ORDER BY ai.STATE DESC, ai.CREATE_TIME_ DESC
|
|
|
+ ORDER BY STATE DESC, CREATE_TIME_ DESC
|
|
|
</if>
|
|
|
<if test="@rx.Ognl@isNotEmpty(order)">
|
|
|
ORDER BY ${order}
|