OWL ITS + 탐지시스템(인터넷 진흥원)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="kr.wisestone.owl.mapper.DepartmentMapper">
 
    <select id="find" resultType="java.util.HashMap" parameterType="kr.wisestone.owl.web.condition.DepartmentCondition">
        SELECT
        d.id as id,
        d.department_name as departmentName,
        d.department_description as departmentDescription,
        (SELECT COUNT(ud.department_id) FROM user_department ud WHERE d.id = ud.department_id) AS departmentCount
        FROM
        department d
        WHERE 1=1
        <if test="departmentName != null and departmentName != ''">
            AND d.department_name like CONCAT('%',#{departmentName},'%')
        </if>
        <if test="id != null and id != ''">
            AND d.id like CONCAT('%',#{id},'%')
        </if>
        <choose>
            <when test="excludeIds != null and excludeIds.size != 0">
                AND d.id NOT IN
                <foreach collection="excludeIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <if test="pageSize != '' and pageSize != null">
            limit #{pageSize} offset #{page};
        </if>
    </select>
 
    <select id="count" resultType="java.lang.Long" parameterType="kr.wisestone.owl.web.condition.DepartmentCondition">
        SELECT
        count(d.id)
        FROM
        department d
        WHERE 1=1
        <if test="departmentName != '' and departmentName != null">
            AND d.department_name like CONCAT('%',#{departmentName},'%')
        </if>
        <if test="id != '' and id != null">
            AND d.id like CONCAT('%',#{id},'%')
        </if>
    </select>
 
    <select id="findByDepartmentIds" resultType="java.util.HashMap" parameterType="kr.wisestone.owl.web.condition.UserCondition">
        SELECT
        d.id as id,
        d.department_name as departmentName,
        d.department_description as departmentDescription
        FROM
        user_department ud
        INNER JOIN department d ON ud.department_id = d.id
        WHERE 1=1
        <if test="id != '' and id != null">
            AND ud.user_id = #{id}
        </if>
        <choose>
            <when test="excludeIds != null and excludeIds.size != 0">
                AND d.id NOT IN
                <foreach collection="excludeIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <select id="findProjectDepartment" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.UserCondition">
        select DISTINCT (d.id) as departmentId, d.department_name as departmentName from department d
         inner join project_role_department prd on prd.department_id = d.id
         inner join project_role pr on pr.id = prd.project_role_id
         inner join project p on p.id = pr.project_id
        where p.id = #{projectId};
    </select>
 
    <select id="findByIssueStatusId" resultType="java.util.HashMap" parameterType="kr.wisestone.owl.web.condition.DepartmentCondition">
        SELECT
        d.id as id,
        d.department_name as departmentName
        FROM
        department d
        INNER JOIN workflow_department wd ON wd.department_id = d.id
        WHERE 1=1
        <if test="issueStatusId != null and issueStatusId != ''">
            AND wd.issue_status_id = #{issueStatusId}
        </if>
        <if test="workflowId != null and workflowId != ''">
            AND wd.workflow_Id = #{workflowId}
        </if>
        <choose>
            <when test="excludeIds != null and excludeIds.size != 0">
                AND d.id NOT IN
                <foreach collection="excludeIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
 
</mapper>