# 쇼룸(showroom) 사용자 관리 YAML 코드

**URL:** <https://ask.selectfromuser.com/t/showroom-yaml/93>\
**Category:** 자유게시판\
**Tags:** showroom\
**Created:** [12월 7, 2023, 3:33오전 UTC](https://ask.selectfromuser.com/t/showroom-yaml/93 "2023-12-07T03:33:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbkim](https://yyz2.discourse-cdn.com/flex032/user_avatar/ask.selectfromuser.com/hbkim/32/23_2.png) [@hbkim](https://ask.selectfromuser.com/u/hbkim)\
**Post date:** [12월 7, 2023, 3:33오전 UTC](https://ask.selectfromuser.com/t/showroom-yaml/93/1 "2023-12-07T03:33:16Z")

</div>

셀렉트 쇼룸의 [사용자 관리](https://showroom.selectfromuser.com/users) 페이지의 YAML 코드입니다.

궁금한 점은 댓글이나 [이메일](mailto:support@selectfromuser.com), 서비스 내 채팅, [슬랙](https://join.slack.com/t/selectcommunity/shared_invite/zt-161fvp0bn-SjJykcvL9ply0CQzUXrL9A) 등으로 편하게 문의주세요.

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/selectfromuser/original/1X/221e46715c58d3fc70d6478ae5a552f7e31057e4.png)

```yaml
menus:
- path: users
  name: 💁 사용자 관리

- type: search
  label: 찾기
  placeholder: "연락처 4자리 (예: 0000)"
  redirect: users?phone_number={{value}}

pages:
- path: users
  blocks: 
    - type: query
      resource: mysql.qa
      sqlType: select
      sql: >
        SELECT id, name, email, phone_number, role, created_at
        FROM users
        WHERE (LENGTH(:id)=0 OR id = :id)
        AND (LENGTH(:name)=0 OR name LIKE CONCAT('%', :name, '%'))
        AND (LENGTH(:email)=0 OR email LIKE CONCAT('%', :email, '%'))
        AND (LENGTH(:phone_number)=0 OR phone_number LIKE CONCAT('%', :phone_number, '%'))        
        AND (LENGTH(:created_at1 + :created_at2)=0 OR created_at BETWEEN :created_at1 AND :created_at2)
      params:
        - key: id
          label: ID
          placeholder: 12345
        - key: name
          label: 이름
          placeholder: 홍길동
        - key: email
          label: 이메일
          placeholder: mail@mail.com
        - key: phone_number
          label: 연락처
          placeholder: 010-0000-0000
        - key: created_at
          label: 생성일
          format: date
          range: true
          defaultValueFn:
            return [
              moment().add(-1, 'year').format('YYYY-MM-DD')
            , moment().add(1, 'day').format('YYYY-MM-DD')
            ]
          showButtons: true
          shortcuts:
            - label: 지난주
              relative: true
              from:
                offset: -7
                period: day
              to:
                offset: -7
                period: day
            - label: 다음주
              relative: true
              from:
                offset: 7
                period: day
              to:
                offset: 7
                period: day
            - label: 초기화
              reset: true
      columns:
        id:
          label: ID
        name:
          label: 이름
        email:
          label: 이메일
        phone_number:
          label: 연락처
        role:
          label: 역할
          color:
            PM: red
            개발자: blue
            마케터: green
            디자이너: yellow
            매니저: gray
        created_at:
          label: 생성일
      viewModal: 
        mode: side
        blocks:
          - type: query
            resource: mysql.qa
            sqlType: select
            sql: >
              SELECT * FROM users WHERE id = :id
            params:
              - key: id
                valueFromRow: id
            display: form
            columns: 
              id:
                label: ID
              name:
                label: 이름
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET name = :value, updated_at = NOW() WHERE id = :id
              email:
                label: 이메일
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET email = :value, updated_at = NOW() WHERE id = :id
                  params:
                    - key: id
                      valueFromRow: id
                format: email
              phone_number:
                label: 연락처
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET phone_number = :value, updated_at = NOW() WHERE id = :id        
              role:
                label: 역할
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET role = :value, updated_at = NOW() WHERE id = :id        
              created_at:
                label: 생성일 
              updated_at:
                label: 수정일 
              nick_name:
                label: 닉네임
                updateOptions:
                  type: query
                  resource: mysql.qa
                  sql: UPDATE users SET nick_name = :value, updated_at = NOW() WHERE id = :id        
              user_id:
                hidden: true
              is_withdrawal:
                label: 회수
                valueAs:
                  1: 회수됨
                  0: 복구
            actions:
              - label: 회수
                single: true
                placement: bottom right
                button:
                  type: danger-light
                type: query
                resource: mysql.qa
                sql: UPDATE users SET is_withdrawal = 1, updated_at = NOW() WHERE id = :id
                reloadAfterSubmit: true
              - label: 복구
                single: true
                placement: bottom left
                button:
                  type: primary
                type: query
                resource: mysql.qa
                sql: UPDATE users SET is_withdrawal = 0, updated_at = NOW() WHERE id = :id
                reloadAfterSubmit: true
      

```
