# 샘플 레시피

# 기본 메뉴와 페이지

default.yml

select-configuration:
  title: Welcome to Select
  menus:
    - group: 회원
      name: 고객 관리
      path: users
      placement: menu-only
      redirect: users/active
    
    - group: 회원
      name: 최근가입자 목록
      path: users/active
      placement: tab-only

    - group: 회원
      name: 휴면회원 목록
      path: users/dormant
      placement: tab-only

    - group: 회원
      name: 마케팅 수신동의
      path: users/promotion
      placement: tab-only
    
    - group: 기타메뉴
      name: 공식 문서 
      path: https://docs.selectfromuser.com
      target: _blank

    - group: 기타메뉴
      name: 클라우드 이용
      path: https://selectfromuser.com
      target: _blank

  access-control:
    
  users:
    - id: admin
      pw: YWRtaW4=
      roles:
  
  integrations:
    google-sso:
      enabled: false
      restrict-domain: 
    google-spreadsheets:
      restrict-domain: 
  
  pages:
    - path: users/active
      blocks: 
        - type: markdown
          content: >
            ## 7일 가입자 조회
        
    - path: users/dormant
      blocks:
        - type: markdown
          content: >
            ## 휴면회원 조회
        
    - path: users/promotion
      blocks:
        - type: markdown
          content: >
            ## 동의/미동의 조회
        
  resources:
    # - key: mysql
    #   type: mysql
    #   host: YOUR_HOST.ap-northeast-2.rds.amazonaws.com
    #   port: 3306
    #   username: (계정이름)
    #   password: (base64 인코딩된 계정 비밀번호)
    #   database: (데이터베이스이름)
    #   timezone: '+00:00'
    #   extra:
    #     charset: utf8mb4_general_ci

redis:
  master:
    host: 127.0.0.1
    port: 6379
    db: 0

web: 
  base_url: http://localhost:9400

secret:
  access_token: SECRET

policy:
  session_expire: 48300

google:
  client_id: 
  redirect_uri: 
  client_secret: 

google_sheet:
  client_id: 
  redirect_uri: 
  client_secret: 

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

# 풀스펙 Full spec

select-configuration:
  title: YSG 팀 어드민
  menus:
    - group: 회원
      name: 회원 목록
      path: users/list
    - group: 회원
      name: 카카오 가입자
      path: users/kakao
      placement: tab-only
    - group: 회원
      name: 고객 목록
      path: users/customer
      placement: tab-only
    - group: 회원
      name: 휴면회원 목록
      path: users/dormant
      placement: tab-only
    - group: 회원
      name: 메시지 목록
      path: users/dm
      placement: tab-only
    # - group: 회원
    #   name: 등급 관리
    #   path: users/level
    #   placement: tab-only
    - group: 회원
      name: 마케팅동의내역 관리
      path: users/agree_marketing
      placement: tab-only
      access-control: allow_qa
    - group: 워크스페이스
      name: 워크스페이스 관리
      path: workspaces/state
    - group: 구독자
      name: 구독자 관리
      path: subscriptions
    - group: 결제
      name: 카드승인 관리
      path: payment/cards
    - group: 결제
      name: 포인트 내역
      path: payment/point
    - type: divider
    - group: 메뉴2
      name: 뉴스탭 관리
      path: news
      permission: allow_qa
    - group: 메뉴2
      name: 배너전시 관리
      path: banner
      permission: allow_news
    - group: 메뉴2
      name: 배너 코드 
      path: https://selectfromuser.com
      target: _blank

  access-control:
    - name: allow_qa
      allow_list: 
        - cs
        - qa
        - admin
      allow_open: 
        - qa
        - admin
      allow_edit:
        - admin
      allow_export:
        - qa
    - name: allow_news
      allow_view: 
        - news
        - cs
        - qa
        - admin
      allow_edit:
        - news
        - qa
        - admin
  users:
    - id: admin
      pw: YWRtaW4=
      roles:
        - cs
        - qa
        - admin
        - news
  integrations:
    google-spreadsheets:
      restrict-domain: test.com
  pages:
    - path: users/list
      blocks:
        - type: query
          resource: mysql.qa
          name: 추가
          sql: >
            insert into user
            set email = :email, created_at = NOW()
          params:
            - key: email
        - type: query
          resource: mysql.qa
          name: 생성일 변경
          sql: >
            update user
            set created_at = :c
            where id = :id
          params:
            - key: c
              label: 가입일 (0000-00-00)
            - key: id
              label: 회원ID
            
        - type: query
          resource: mysql.qa
          # autoload: true
          name: 회원목록
          sql: > 
            SELECT id, email, provider_kakao_id, created_at, last_signed_at  FROM user
          viewModal:
            displayParentRow: true
            blocks:
              - type: query
                resource: mysql.qa
                name: 워크스페이스 이용중
                autoload: true
                sql: > 
                  SELECT DISTINCT w.id, w.name, w.created_at
                  FROM user, workspace_role, workspace AS w
                  WHERE user.id = :uid
                    AND workspace_role.user_id = user.id
                    AND w.id = workspace_role.workspace_id
                params:
                  - key: uid
                    label: 'ID'
                    format: 'number'
                    valueFromRow: id
                refs:
                  - column: id
                    param: wid
                    href: /workspaces/state
                    autoload: true
              - type: query
                resource: mysql.qa
                name: 카카오톡 로그인 초기화
                sql: >
                  update user
                  set provider_kakao_id = NULL
                  where id = :id
                params:
                  - key: id
                    valueFromRow: id
              - type: query
                resource: mysql.qa
                name: 카카오톡 계정 연결
                sql: >
                  update user
                  set provider_kakao_id = :provider_kakao_id
                  where id = :id
                params:
                  - key: provider_kakao_id
                    defaultValueFromRow: provider_kakao_id
                  - key: id
                    valueFromRow: id
        - type: query
          resource: mysql.qa
          autoload: true
          name: 회원목록 통계
          sql: > 
            SELECT 
              COUNT(id) AS '전체가입자', 
              COUNT(provider_kakao_id) AS '카카오 가입자',
              (
                SELECT COUNT(id) FROM user
                WHERE created_at > NOW() - INTERVAL 7 DAY
              ) AS '최근 7일 가입자'
            FROM user
        - type: query
          resource: mysql.qa
          sql: SELECT * FROM user WHERE id = :uid
          name: 회원개별조회
          params:
            - key: uid
              label: 'ID'
              format: 'number'
      
    - path: users/customer
      blocks:
        - type: query
          resource: mysql.qa
          autoload: true
          sql: >
            SELECT id, fullname AS '고객명' FROM customer
        
    - path: users/kakao
      blocks:
        - type: query
          resource: mysql.qa
          autoload: true
          sql: >
            SELECT id, email AS '이메일', provider_kakao_id AS '카카오ID', created_at AS '가입일', last_signed_at AS '최근활동일' FROM user
            WHERE provider_kakao_id IS NOT NULL
        - type: query
          resource: mysql.qa
          sql: > 
            SELECT * FROM user 
            WHERE provider_kakao_id IS NOT NULL 
              AND id = :uid
          params:
            - key: uid
              label: 'ID'
              format: 'number'
    - path: users/dm
      blocks:
        - type: query
          resource: mysql.qa
          sql: >
            SELECT id, workspace_id AS '업체ID', chat_id AS '채팅ID', label AS '구분코드', user_id AS '사용자ID', 
              created_at AS '시작일'
            FROM chat_message
            ORDER BY id DESC
        - type: query
          resource: mysql.qa
          sql: >
            SELECT id, body FROM chat_message
            WHERE chat_id = :cid
              AND label = :l
          params:
            - key: cid
              label: 채팅ID
              format: number
            - key: l
              label: 상태
              datalist:
                - CUS
                - EMP
                - NOTE
              # dropdown:
              #   - CUS
              #   - EMP
              #   - NOTE
      modal:
        path: id
        displayParentRow: false
        blocks:
          - type: query
            resource: mysql.qa
            name: 상세
            autoload: true
            sql: > 
              SELECT * FROM chat_message
              WHERE id = :mid
            params:
              - key: mid
                valueFromRow: id
    - path: workspaces/state
      blocks:
        - type: query
          resource: mysql.qa
          name: general info
          showSubmitButton: false
          sql: > 
            select id, name, created_at, public_domain, public_name from workspace
            where id = :wid
          editModal:
            blocks:
              - type: query
                resource: mysql.qa
                sql: >
                  update workspace
                  set name = :name,
                      public_domain = :public_domain
                  where id = :id
                params:
                  - key: name
                    format: text
                    label: '워크스페이스 이름'
                    defaultValueFromRow: name
                  - key: public_domain
                    format: text
                    label: '워크스페이스 도메인 (공개)'
                    defaultValueFromRow: public_domain
                  - key: id
                    valueFromRow: id
              
        - type: query
          resource: mysql.qa
          name: log
          showSubmitButton: false
          sql: > 
            select * from workspace_log
            where wid = :wid
        - type: query
          resource: mysql.qa
          name: profile
          showSubmitButton: false
          sql: > 
            select * from workspace_profile
            where workspace_id = :wid
        - type: action
          resource: mysql.qa
          label: 추가
          name: new workspace
          sql: > 
            insert into workspace_profile
            set name = :name
                created_at = NOW()
          params:
            - key: name
              format: text
      params:
        - key: wid
          label: 'ID'
          format: 'number'
        
    - path: subscriptions
      blocks:
        - type: markdown
          content: >
            1.  List item one.

                List item one continued with a second paragraph followed by an
                Indented block.

                    $ ls *.sh
                    $ mv *.sh ~/tmp

                List item continued with a third paragraph.

            2.  List item two continued with an open block.

                This paragraph is part of the preceding list item.

                1. This list is nested and does not require explicit item continuation.

                  This paragraph is part of the preceding list item.

                2. List item b.

                This paragraph belongs to item two of the outer list.
        - type: http
          axios:
            method: GET
            url: https://gist.githubusercontent.com/eces/c267436ddeec8917b47ee666b0d5e955/raw/892877e7035c4f61e946848a3f6da7e9983cab15/test.json
          rowsPath: rows

        - type: http
          axios:
            method: POST
            url: https://httpbin.org/anything?cid={{id}}
            data:
              '고객아이디': customer-{{id}}
          params:
            - key: id
              label: '고객ID (수신거부 대상자 처리)'
              format: 'number'

  resources:
    - key: mysql.qa
      type: mysql
      host: REMOVED.ap-northeast-2.rds.amazonaws.com
      port: 3306
      username: REMOVED
      password: REMOVED
      database: REMOVED
      requestTimeout: 3000
      timezone: '+00:00'
      charset: "utf8mb4_general_ci"
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370