liujunchi 3 лет назад
Родитель
Сommit
88bb26cc3f

+ 15 - 8
cooleshow-cms/src/main/resources/config/mybatis/SysNewsTypeMapper.xml

@@ -106,23 +106,30 @@
 	</sql>
 
 	<select id="queryAppPage" resultMap="SysNewsTypeDto">
-		SELECT snt.id_ as sntId
+		select a.*,sni.* from (
+		SELECT distinct snt.id_ as sntId
 		,snt.name_ as name,
 		snt.parent_id_ as parentId,
 		snt.order_ as sntOrder,
 		snt.del_flag_ as sntDelFlag,
 		snt.create_time_ as createTime,
 		snt.update_time_ as updateTime,
-		snt.url_ as url,
-		sni.*
+		snt.url_ as url
 		FROM sys_news_type snt
 		left join sys_news_information sni on sni.sub_type_ = snt.id_
 		where snt.del_flag_ = 0 and snt.parent_id_ = 6 and sni.del_flag_ = 0 and sni.status_ = 1
 		<if test="search != null and search != ''">
-			and  (sni.title_ like concat('%',#{search},'%') or snt.name_ like concat('%',#{search},'%'))
+			and (sni.title_ like concat('%',#{search},'%') or snt.name_ like concat('%',#{search},'%'))
 		</if>
 		ORDER BY snt.order_ , sni.order_
-		<include refid="global.limit" />
+		<include refid="global.limit"/>
+		) a
+
+		left join sys_news_information sni on sni.sub_type_ = a.sntId
+		where sni.del_flag_ = 0 and sni.status_ = 1
+
+		ORDER BY a.sntOrder , sni.order_
+
 	</select>
 
 	<resultMap type="com.yonge.cooleshow.cms.dto.SysNewsTypeDto" id="SysNewsTypeDto">
@@ -163,14 +170,14 @@
 	</resultMap>
 
 	<select id="queryAppCount" resultType="int">
-		SELECT count(1)
+		select count(1) from (
+		SELECT snt.id_
 		FROM sys_news_type snt
 		left join sys_news_information sni on sni.sub_type_ = snt.id_
 		where snt.del_flag_ = 0 and snt.parent_id_ = 6 and sni.del_flag_ = 0 and sni.status_ = 1
 		<if test="search != null and search != ''">
 			and  (sni.title_ like concat('%',#{search},'%') or snt.name_ like concat('%',#{search},'%'))
 		</if>
-		ORDER BY snt.order_ , sni.order_
-		<include refid="global.limit" />
+		group by snt.id_ ) a
 	</select>
 </mapper>