后管-线上课、资源:选择分类、部门递归查询该子类、子部门数据

This commit is contained in:
wsw
2024-05-30 14:44:03 +08:00
parent 8beae72101
commit eb02def070
11 changed files with 165 additions and 69 deletions

View File

@@ -33,9 +33,9 @@
SELECT `resources`.*
FROM `resources`
<choose>
<when test="categoryIds != null and categoryIds != ''">
<when test="categoryIds != null and !categoryIds.isEmpty()">
<choose>
<when test="categoryIds.indexOf('0') == 0">
<when test="categoryIds.get(0) == 0">
LEFT JOIN `resource_category` ON `resource_category`.`rid` = `resources`.`id`
WHERE `resources`.`is_hidden` = 0
AND `resource_category`.`cid` IS NULL
@@ -43,7 +43,8 @@
<otherwise>
INNER JOIN `resource_category` ON `resource_category`.`rid` = `resources`.`id`
WHERE `resources`.`is_hidden` = 0
AND `resource_category`.`cid` IN (#{categoryIds})
AND `resource_category`.`cid` IN (<foreach collection="categoryIds" item="tmpId" separator=",">
#{tmpId}</foreach>)
</otherwise>
</choose>
</when>
@@ -102,9 +103,9 @@
SELECT count(1)
FROM `resources`
<choose>
<when test="categoryIds != null and categoryIds != ''">
<when test="categoryIds != null and !categoryIds.isEmpty()">
<choose>
<when test="categoryIds.indexOf('0') == 0">
<when test="categoryIds.get(0) == 0">
LEFT JOIN `resource_category` ON `resource_category`.`rid` = `resources`.`id`
WHERE `resources`.`is_hidden` = 0
AND `resource_category`.`cid` IS NULL
@@ -112,7 +113,8 @@
<otherwise>
INNER JOIN `resource_category` ON `resource_category`.`rid` = `resources`.`id`
WHERE `resources`.`is_hidden` = 0
AND `resource_category`.`cid` IN (#{categoryIds})
AND `resource_category`.`cid` IN (<foreach collection="categoryIds" item="tmpId" separator=",">
#{tmpId}</foreach>)
</otherwise>
</choose>
</when>