From 091b698701b0f77c3746ac9cfe03e0c4d272cbfd Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 금, 24 12월 2021 18:14:58 +0900
Subject: [PATCH] 헤더에서 전체 프로젝트 선택 시 속해있지 않는 다른 프로젝트의 이슈유형리스트까지 보이는 문제 해결

---
 src/main/resources/mybatis/query-template/widget-template.xml |   93 ++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 85 insertions(+), 8 deletions(-)

diff --git a/src/main/resources/mybatis/query-template/widget-template.xml b/src/main/resources/mybatis/query-template/widget-template.xml
index 22cd788..6da8334 100644
--- a/src/main/resources/mybatis/query-template/widget-template.xml
+++ b/src/main/resources/mybatis/query-template/widget-template.xml
@@ -47,6 +47,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
     </select>
 
@@ -90,6 +93,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         AND i.complete_date IS NOT NULL
         AND i.complete_date <![CDATA[ < ]]> #{completeDate}
@@ -217,6 +223,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         AND i.register_date BETWEEN (CURDATE()) AND (CURDATE() + INTERVAL 1 DAY)
     </select>
@@ -325,6 +334,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
     </select>
 
@@ -539,12 +551,15 @@
         INNER JOIN user_department ud ON ud.department_id = isd.department_id
         where isd.issue_id = i.id
         <choose>
-            <when test="myDepartmentIds.size != 0">
+            <when test="myDepartmentIds != null and myDepartmentIds.size != 0">
                 AND isd.department_id IN
                 <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         and isd.register_date
         BETWEEN (CURDATE()) AND (CURDATE() + INTERVAL 1 DAY))
@@ -603,6 +618,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         And iss.issue_status_type != 'CLOSE'
     </select>
@@ -677,6 +695,7 @@
         select
         distinct i.id as id,
         i.title as title,
+        i.issue_type_id as issueTypeId,
         p.name as projectName,
         CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
         p.project_key as projectKey,
@@ -699,12 +718,15 @@
             </when>
         </choose>
         <choose>
-            <when test="myDepartmentIds.size != 0">
+            <when test="myDepartmentIds != null and myDepartmentIds.size != 0">
                 AND isd.department_id IN
                 <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         and iss.issue_status_type != 'CLOSE'
         GROUP by i.id
@@ -794,7 +816,8 @@
         CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
         i.issue_number as issueNumber,
         p.project_key as projectKey,
-        p.name as projectName
+        p.name as projectName,
+        i.issue_type_id as issueTypeId
         from issue i
         inner join issue_risk ir on ir.issue_id = i.id
         inner join issue_status iss on iss.id = i.issue_status_id
@@ -853,6 +876,7 @@
             , i.issue_number as issueNumber
             , p.project_key as projectKey
             , CONCAT(p.project_key, '-', i.issue_number) AS issueKey
+            , i.issue_type_id as issueTypeId
         </if>
         FROM issue i
         <if test="page != null and !page.equals('')">
@@ -922,6 +946,7 @@
             , iss.name as issueStatusName
             , i.issue_number as issueNumber
             , p.project_key as projectKey
+            , i.issue_type_id as issueTypeId
             , CONCAT(p.project_key, '-', i.issue_number) AS issueKey
         </if>
         FROM issue i
@@ -988,7 +1013,8 @@
             </when>
         </choose>
         ,p.id,
-        p.name as projectName
+        p.name as projectName,
+        i.issue_type_id as issueTypeId
         from issue i
         inner join project p on p.id = i.project_id
         inner join issue_status iss on iss.id = i.issue_status_id
@@ -1015,7 +1041,8 @@
             </when>
         </choose>
         ,p.id,
-        p.name as projectName
+        p.name as projectName,
+        i.issue_type_id as issueTypeId
         from issue i
         inner join project p on p.id = i.project_id
         inner join issue_status iss on iss.id = i.issue_status_id
@@ -1029,6 +1056,17 @@
                     #{item}
                 </foreach>
             </when>
+        </choose>
+        <choose>
+            <when test="myDepartmentIds != null and myDepartmentIds.size != 0">
+                AND isd.department_id IN
+                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         group by p.id
     </select>
@@ -1136,6 +1174,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         and p.status = '02';
     </select>
@@ -1213,6 +1254,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         and iss.issue_status_type = 'CLOSE'
         <choose>
@@ -1258,6 +1302,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         <choose>
             <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
@@ -1278,7 +1325,15 @@
             parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
         SELECT issue_type.name as name, COUNT(issue.id) as issueCount FROM issue
         INNER JOIN issue_type ON issue.issue_type_id = issue_type.id
-        WHERE issue.project_id = #{projectId}
+        WHERE 1=1
+        <choose>
+            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+                AND issue.project_id IN
+                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </when>
+        </choose>
         GROUP BY issue_type.name
     </select>
 
@@ -1289,6 +1344,17 @@
         INNER JOIN issue_department isd ON isd.issue_id = issue.id
         INNER JOIN user_department ud ON ud.department_id = isd.department_id
         WHERE issue.project_id = #{projectId}
+        <choose>
+            <when test="myDepartmentIds != null and myDepartmentIds.size != 0">
+                AND isd.department_id IN
+                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
+        </choose>
         GROUP BY issue_type.name
     </select>
 
@@ -1350,6 +1416,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
     </select>
 
@@ -1366,7 +1435,8 @@
         p.project_key AS projectKey,
         p.name AS projectName,
         iss.name AS issueStatusName,
-        CONCAT(p.project_key, '-', i.issue_number) AS issueKey
+        CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
+        i.issue_type_id as issueTypeId
         FROM issue i
         INNER JOIN project p ON p.id = i.project_id
         INNER JOIN workspace w ON w.id = p.workspace_id
@@ -1400,7 +1470,8 @@
         p.project_key AS projectKey,
         p.name AS projectName,
         iss.name AS issueStatusName,
-        CONCAT(p.project_key, '-', i.issue_number) AS issueKey
+        CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
+        i.issue_type_id as issueTypeId
         FROM issue i
         INNER JOIN project p ON p.id = i.project_id
         INNER JOIN workspace w ON w.id = p.workspace_id
@@ -1426,6 +1497,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         <if test="page != null and !page.equals('')">
             limit #{pageSize} offset #{page};
@@ -1481,6 +1555,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
     </select>
 

--
Gitblit v1.8.0