OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2021-12-15 de2abff4377c9ee83161c954a51de4c9390fff76
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="kr.wisestone.owl.mapper.UserMapper">
 
    <select id="find" resultType="java.util.HashMap" parameterType="kr.wisestone.owl.web.condition.UserCondition">
        SELECT
        DISTINCT u.id as id,
        u.name as name,
        u.account as account,
        u.profile as profile,
        u.status as status
        FROM
        user u
        INNER JOIN user_workspace uw on u.id = uw.user_id
        INNER JOIN workspace w on w.id = uw.workspace_id
        <if test="projectId != '' and projectId != null">
            INNER JOIN project_role_user pru on pru.user_id = u.id
            INNER JOIN project_role pr on pr.id = pru.project_role_id
            INNER JOIN project p on p.id = pr.project_id
        </if>
 
        WHERE w.id = #{workspaceId}
        <if test="name != '' and name != null">
            AND u.name like CONCAT('%',#{name},'%')
        </if>
        <choose>
            <when test="statuses.size != 0">
                AND u.status IN
                <foreach collection="statuses" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <choose>
            <when test="excludeIds.size != 0">
                AND u.id NOT IN
                <foreach collection="excludeIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <if test="projectId != '' and projectId != null">
            AND p.id = #{projectId}
        </if>
        limit #{pageSize} offset #{page};
    </select>
 
    <select id="count" resultType="java.lang.Long" parameterType="kr.wisestone.owl.web.condition.UserCondition">
        SELECT
        COUNT(DISTINCT u.id)
        FROM
        user u
        INNER JOIN user_workspace uw on u.id = uw.user_id
        INNER JOIN workspace w on w.id = uw.workspace_id
        <if test="projectId != '' and projectId != null">
            INNER JOIN project_role_user pru on pru.user_id = u.id
            INNER JOIN project_role pr on pr.id = pru.project_role_id
            INNER JOIN project p on p.id = pr.project_id
        </if>
        WHERE w.id = #{workspaceId}
        <if test="name != '' and name != null">
            AND u.name like CONCAT('%',#{name},'%')
        </if>
        <choose>
            <when test="statuses.size != 0">
                AND u.status IN
                <foreach collection="statuses" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <choose>
            <when test="excludeIds.size != 0">
                AND u.id NOT IN
                <foreach collection="excludeIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <if test="projectId != '' and projectId != null">
            AND p.id = #{projectId}
        </if>
    </select>
 
    <select id="findProjectMember" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.UserCondition">
        select DISTINCT (u.id) as userId, u.account as account from user u
        inner join project_role_user pru on pru.user_id = u.id
        inner join project_role pr on pr.id = pru.project_role_id
        inner join project p on p.id = pr.project_id
        where p.id = #{projectId}
    </select>
 
    <!--  회원 탈퇴를 진행할 때 연관 테이블 정보를 삭제한다. -->
    <delete id="deleteCascadeUser" parameterType="kr.wisestone.owl.web.condition.UserCondition">
        <!--    관심 이슈 정보 삭제 -->
        DELETE FROM user_like_issue WHERE user_id = #{id};
 
        <!--    이슈 검색 조건 삭제 -->
        DELETE FROM issue_search WHERE user_id = #{id};
 
        <!--    이슈 담당자 정보 삭제 -->
        DELETE FROM issue_user WHERE user_id = #{id};
 
        <!--    해당 사용자의 업무 공간에 참여하는 사용자 정보 삭제 -->
        DELETE FROM user_workspace WHERE user_id = #{id} AND manager_yn = 'N';
 
        <!--    탈퇴하는 사용자가 발송받을 이메일 정보 삭제 -->
        DELETE FROM system_email WHERE send_address = #{account};
 
    </delete>
 
    <!--    이메일 예약 시간 찾기    -->
    <select id="findByReservationNotifyTime" resultType="java.util.HashMap" parameterType="java.util.HashMap">
        select account from user
        where reservation_notify_time between #{startTime} and #{endTime}
    </select>
 
    <!--    이메일 실시간 찾기    -->
    <select id="findByRealTimeNotifyTime" resultType="java.util.HashMap" parameterType="java.util.HashMap">
        select account from user
        where reservation_notify_time = "realTime"
    </select>
 
    <select id="findByAllWorkspace" resultType="java.util.HashMap" parameterType="kr.wisestone.owl.web.condition.UserCondition">
        SELECT
        DISTINCT u.id as id,
        u.name as name,
        u.account as account,
        u.profile as profile,
        u.status as status
        FROM
        user u
        WHERE 1=1
        <if test="name != '' and name != null">
            AND u.name like CONCAT('%',#{name},'%')
        </if>
        AND u.status = '01'
        <choose>
            <when test="excludeIds.size != 0">
                AND u.id NOT IN
                <foreach collection="excludeIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        limit #{pageSize} offset #{page};
    </select>
 
    <select id="countByAllWorkspace" resultType="java.lang.Long" parameterType="kr.wisestone.owl.web.condition.UserCondition">
        SELECT
        COUNT(DISTINCT u.id)
        FROM
        user u
        WHERE 1=1
        <if test="name != '' and name != null">
            AND u.name like CONCAT('%',#{name},'%')
        </if>
        AND u.status = '01'
        <choose>
            <when test="excludeIds.size != 0">
                AND u.id NOT IN
                <foreach collection="excludeIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <select id="findEvent" resultType="java.util.HashMap">
        SELECT u.id, u.name as name, u.account, u.phone, u.register_id, u.register_date, COUNT(lh.user_id) AS loginCount,
        (SELECT COUNT(i.id) FROM issue i WHERE i.register_id = u.id) AS issueCount  FROM login_history lh
        INNER JOIN user u ON u.id = lh.user_id
        WHERE DATE(u.register_date) BETWEEN '2019-05-31' AND '2019-06-14' AND u.STATUS = '01'
        GROUP BY u.id ORDER BY issueCount desc, loginCount DESC;
    </select>
 
    <select id="findByLevelId" resultType="java.lang.Long" parameterType="java.lang.Long">
        SELECT count(u.id)
        FROM user u
        WHERE u.level_id = #{id}
    </select>
 
    <select id="findByMyLevelAndDepartment" resultType="java.util.HashMap" parameterType="java.lang.Long">
        SELECT
        DISTINCT u.id as id,
                 ul.level_name AS levelName,
                 GROUP_CONCAT(d.department_name) AS departmentName,
                 u.name as name,
                 u.account as account,
                 u.profile as profile,
                 u.status as STATUS
        FROM user u
        LEFT OUTER JOIN user_level ul ON u.level_id = ul.id
        LEFT OUTER JOIN user_department ud ON ud.user_id = u.id
        LEFT OUTER JOIN department d ON d.id = ud.department_id
        WHERE u.id = #{id}
    </select>
 
</mapper>