forked from masssal0501/00_Semi_Workspace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapper.sql
More file actions
184 lines (162 loc) · 5.29 KB
/
Copy pathmapper.sql
File metadata and controls
184 lines (162 loc) · 5.29 KB
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
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="storeMapper">
<!-- 점주 존재 여부 확인 -->
<select id="checkOwner"
parameterType="string"
resultType="int">
SELECT COUNT(*)
FROM MANAGER
WHERE MANAGER_ID = #{ownerId}
</select>
<!-- 점포 등록 -->
<insert id="insertStore"
parameterType="com.kh.burgerstack.store.model.vo.Store">
<selectKey keyProperty="storeCode"
resultType="int"
order="BEFORE">
SELECT SEQ_STORE_NO.NEXTVAL
FROM DUAL
</selectKey>
INSERT INTO STORE
(
STORE_CODE,
STORE_NAME,
MANAGER_ID,
STORE_PHONE,
STORE_ADDRESS,
STORE_DETAIL_ADDRESS,
STORE_STATUS,
OPEN_DATE
)
VALUES
(
#{storeCode},
#{storeName},
#{ownerId},
#{storePhone},
#{storeAddress},
#{storeDetailAddress},
'영업중',
SYSDATE
)
</insert>
<!-- 전체 자재 기준 점포 재고 생성 -->
<insert id="insertStoreStockMaterial"
parameterType="int">
INSERT INTO STORE_STOCK
(
STORE_CODE,
MATERIAL_NO,
STOCK_QTY
)
SELECT
#{storeCode},
MATERIAL_NO,
0
FROM MATERIAL
</insert>
<!-- 관리자 점포 목록 조회 -->
<select id="selectStoreList"
parameterType="map"
resultType="com.kh.burgerstack.store.model.vo.SelectStoreList">
SELECT
STORE_CODE AS storeCode,
STORE_NAME AS storeName,
STORE_ADDRESS AS storeAddress,
STORE_PHONE AS storePhone,
STORE_STATUS AS storeStatus,
TO_CHAR(OPEN_DATE, 'YYYY.MM.DD') AS openDate
FROM STORE
WHERE 1 = 1
<if test="status != null and status != ''">
AND STORE_STATUS = #{status}
</if>
<if test="startDate != null and startDate != ''">
AND OPEN_DATE <![CDATA[ >= ]]> TO_DATE(#{startDate}, 'YYYY-MM-DD')
</if>
<if test="endDate != null and endDate != ''">
AND OPEN_DATE <![CDATA[ <= ]]> TO_DATE(#{endDate}, 'YYYY-MM-DD')
</if>
<if test="keyword != null and keyword != ''">
AND (
STORE_NAME LIKE '%' || #{keyword} || '%'
OR STORE_ADDRESS LIKE '%' || #{keyword} || '%'
OR STORE_PHONE LIKE '%' || #{keyword} || '%'
)
</if>
ORDER BY STORE_CODE DESC
</select>
<!-- 점포 개수 조회 -->
<select id="selectStoreCount"
parameterType="map"
resultType="int">
SELECT COUNT(*)
FROM STORE
WHERE 1 = 1
<if test="status != null and status != ''">
AND STORE_STATUS = #{status}
</if>
<if test="startDate != null and startDate != ''">
AND OPEN_DATE <![CDATA[ >= ]]> TO_DATE(#{startDate}, 'YYYY-MM-DD')
</if>
<if test="endDate != null and endDate != ''">
AND OPEN_DATE <![CDATA[ <= ]]> TO_DATE(#{endDate}, 'YYYY-MM-DD')
</if>
<if test="keyword != null and keyword != ''">
AND (
STORE_NAME LIKE '%' || #{keyword} || '%'
OR STORE_ADDRESS LIKE '%' || #{keyword} || '%'
OR STORE_PHONE LIKE '%' || #{keyword} || '%'
)
</if>
</select>
<!-- 점포 상세 조회 -->
<select id="selectStoreDetail"
parameterType="int"
resultType="com.kh.burgerstack.store.model.vo.Store">
SELECT
STORE_CODE AS storeCode,
STORE_NAME AS storeName,
STORE_STATUS AS storeStatus,
STORE_PHONE AS storePhone,
STORE_ADDRESS AS storeAddress,
STORE_DETAIL_ADDRESS AS storeDetailAddress
FROM STORE
WHERE STORE_CODE = #{storeCode}
</select>
<!-- 점포 점장 조회 -->
<select id="selectStoreManager"
parameterType="int"
resultType="com.kh.burgerstack.store.model.vo.Manager">
SELECT
M.MANAGER_ID AS managerId,
M.MANAGER_NAME AS managerName,
M.MANAGER_PHONE AS managerPhone,
M.MANAGER_EMAIL AS managerEmail
FROM MANAGER M
JOIN STORE S
ON M.MANAGER_ID = S.MANAGER_ID
WHERE S.STORE_CODE = #{storeCode}
</select>
<!-- 점포 수정 -->
<update id="updateStore"
parameterType="com.kh.burgerstack.store.model.vo.Store">
UPDATE STORE
SET
STORE_NAME = #{storeName},
STORE_STATUS = #{storeStatus},
STORE_PHONE = #{storePhone},
STORE_ADDRESS = #{storeAddress},
STORE_DETAIL_ADDRESS = #{storeDetailAddress}
WHERE STORE_CODE = #{storeCode}
</update>
<!-- 점포 삭제/폐점 처리 -->
<update id="deleteStore"
parameterType="int">
UPDATE STORE
SET STORE_STATUS = '폐점'
WHERE STORE_CODE = #{storeCode}
</update>
</mapper>