---
title: Restful PMB API
description: PMB API
tags: pmb, Python, RD, moonshine
---
Restful PMB API
===
## 全部 API 網址列表
* http://192.168.1.37/pmb/projects/
* http://192.168.1.37/pmb/project/<int:project_id>
* http://192.168.1.37/pmb/projects/filter
* http://192.168.1.37/pmb/project/status/
* http://192.168.1.37/pmb/task_groups/<int:project_id>
* http://192.168.1.37/pmb/task_group/
* http://192.168.1.37/pmb/tasks/<int:project_id>
* http://192.168.1.37/pmb/task/<int:task_id>
* http://192.168.1.37/pmb/task/
* http://192.168.1.37/pmb/blocks/
* http://192.168.1.37/pmb/block/
* http://192.168.1.37/pmb/block/get_types/
* http://192.168.1.37/members/status?on_position=1&resigned=1&furloughed=1
* http://192.168.1.37/pmb/member/self
* http://192.168.1.37/pmb/member/<int:member_id>
* http://192.168.1.37/pmb/schedule/<int:year>
* http://192.168.1.37/pmb/schedule
* http://192.168.1.37/pmb/structure/groups
* http://192.168.1.37/pmb/structure/groups_memebr
## 各物件 CURL 表
|NAME|GET(查詢)|POST(建立)|PUT(修改)|DELETE(刪除)|
|-|-|-|-|-|
|projects|[●](http://192.168.5.55:10080/MS_RD/restful_pmb/wikis/Restful-PMB-API#%E5%8F%96%E5%BE%97%E6%89%80%E6%9C%89%E5%B0%88%E6%A1%88)||||
|project||[●](https://hackmd.io/clnSLPGJQ7W5OC3ZKl-5gQ#%E5%BB%BA%E7%AB%8B%E5%B0%88%E6%A1%88)||[●](https://hackmd.io/clnSLPGJQ7W5OC3ZKl-5gQ#%E5%88%AA%E9%99%A4%E5%B0%88%E6%A1%88%E7%9C%9F%E7%9A%84%E5%BE%9E%E8%B3%87%E6%96%99%E5%BA%AB%E8%A3%A1%E5%88%AA%E9%99%A4)|
|project/status|
|task_groups|●||||
|task_group||●|●|●|
|tasks|●||||
|task|
|blocks|
|block|
|block/get_types|
|members|●||||
|member/self|[●](https://hackmd.io/clnSLPGJQ7W5OC3ZKl-5gQ?both#%E5%8F%96%E5%BE%97%E7%9B%AE%E5%89%8D%E7%99%BB%E5%85%A5%E8%80%85)||||
|member|●|[●](https://hackmd.io/clnSLPGJQ7W5OC3ZKl-5gQ?both#%E5%BB%BA%E7%AB%8B%E6%88%90%E5%93%A1)|[●](https://hackmd.io/clnSLPGJQ7W5OC3ZKl-5gQ?both#%E4%BF%AE%E6%94%B9%E6%88%90%E5%93%A1)|[●](https://hackmd.io/clnSLPGJQ7W5OC3ZKl-5gQ?both#%E5%88%AA%E9%99%A4%E6%88%90%E5%93%A1)|
|schedule|[●](https://hackmd.io/clnSLPGJQ7W5OC3ZKl-5gQ?both#%E5%8F%96%E5%BE%97-Schedule)|[●](https://hackmd.io/clnSLPGJQ7W5OC3ZKl-5gQ?both#%E5%BB%BA%E7%AB%8B-Schedule)|[●](https://hackmd.io/@noflame/H11ZKABeE#%E4%BF%AE%E6%94%B9-Schedule)||
|structure/groups|●||||
|structure/groups_memebr|●||||
### 使用需知
- 設定 content-type 為 application/json
- cookies 要帶 auth_token
目前使用方法皆以 python 為例
## Project 專案相關功能
專案相關功能
### 取得所有專案
|URL|`http://192.168.1.37/pmb/projects/`|
|-|-|
|Method|GET|
|說明|這個 API 可以取得所有專案|
#### 引數
無
#### 回傳值
陣列 json格式的專案資料
#### 使用方式
```python
>>> url = "http://192.168.1.37/pmb/projects/"
>>> r = requests.get(url,
headers=self.header,
cookies=self.cookies,
timeout=30)
>>> pprint(r.json())
[{'id': 7, 'name': 'MoonShine LOGO', 'type': 2},
{'id': 16, 'name': 'Bugs Show 蟲蟲直播秀', 'type': 2},
{'id': 28, 'name': 'AsusMx34vqCampaign', 'type': 2},
{'id': 33, 'name': 'The Night of Dragons', 'type': 2},
{'id': 45, 'name': '宇峻奧丁_三國群英傳之王者歸來', 'type': 2},
{'id': 66, 'name': 'Asus_ZenBeamCampaign', 'type': 2},
{'id': 92, 'name': 'AsusBrandVideo', 'type': 2},
{'id': 110, 'name': '九鳳-神武幻想', 'type': 2},
{'id': 156, 'name': '新流星蝴蝶劍', 'type': 2},
{'id': 157, 'name': 'NMA程式開發', 'type': 8},
...
]
```
### 建立專案
|URL|`http://192.168.1.37/pmb/project/`|
|-|-|
|Method|POST|
|說明|建立專案|
#### 參數
- name(str): 專案名稱,預設為 "new project"
- type(int): 專案類型預設值為 0
- budget(int): 預算
- cost(int): 花費
- profit(int): 利潤
- deadline(date): 預計結案日
- note(str): 備忘
- time_start(date): 開始日
- time_end(date): 結案日
- member_id(int): PM id
- leader(int): 組長 id
- leader_agent(int): 組長代理人 id
- charge(int): 收款
- company(int): 公司
- payment_status(int): 1-已付,2-追帳中,3-未開發票, 預設為 0
- contracted(int): 合約,0為未簽定,1為已簽定
#### 回傳值
json格式的專案資料
#### 使用方式
```python
>>> payload = {'name':"test project"}
>>> url = "http://192.168.1.37/pmb/project/7"
>>> r = requests.post(url,
headers=self.header,
cookies=self.cookies,
data=json.dumps(payload)
timeout=30
>>>pprint(r.json())
{'alive': 1,
'budget': 0,
'budget_tax': 0,
'charge': 0,
'company': '0',
'contracted': 0,
'cost': 0,
'deadline': 'Thu, 07 Mar 2019 00:00:00 GMT',
'id': 633,
'leader': 0,
'leader_agent': 0,
'member_id': 0,
'money_received': 0,
'name': 'new_Project',
'note': '',
'payment_status': 0,
'profit': 0,
'sort_num': 0.0,
'status': 1,
'time_end': 'Thu, 07 Mar 2019 00:00:00 GMT',
'time_start': 'Mon, 07 Jan 2019 00:00:00 GMT',
'time_update': '0000-00-00 00:00:00',
'type': 0}
```
### 取得單一專案資訊
|URL|`http://192.168.1.37/pmb/project/<int:project_id>`|
|-|-|
|Method|GET|
|說明|取得專案的所有資訊|
#### 引數
無
#### 回傳值
json 格式的專案資訊
#### 使用方式
```python
>>> url = "http://192.168.1.37/pmb/project/7"
>>> r = requests.get(url,
headers=self.header,
cookies=self.cookies,
timeout=30
)
>>> pprint(r.json())
{'alive': 1,
'budget': 0,
'budget_tax': 0,
'charge': 0,
'company': '',
'contracted': 0,
'cost': 179488,
'deadline': 'Tue, 12 Jan 2016 00:00:00 GMT',
'id': 7,
'leader': 0,
'leader_agent': 0,
'member_id': 84,
'money_received': 0,
'name': 'MoonShine LOGO',
'note': '',
'payment_status': 0,
'profit': -179488,
'sort_num': 0.0,
'status': 3,
'time_end': 'Mon, 06 Feb 2017 00:00:00 GMT',
'time_start': 'Thu, 22 Dec 2016 00:00:00 GMT',
'time_update': 'Tue, 03 Apr 2018 21:31:39 GMT',
'type': 2}
```
### 刪除專案(真的從資料庫裡刪除)
|URL|`http://192.168.1.37/pmb/projects/`|
|-|-|
|Method|DELETE|
|說明|刪除專案,但專案內有任何工作群,工作,格子時,無法殺除該專案|
#### 引數
* project_id(int): 專案 id
#### 回傳值
None
#### 使用方式
```python
>>> url = "http://192.168.1.37/pmb/projects/"
>>> payload = {'project_id': 1}
>>> r = requests.get(url,
headers=self.header,
cookies=self.cookies,
data=json.dumps(payload),
timeout=30)
>>> print(r.status_code)
200
```
### 依條件取得專案
|URL|`http://192.168.1.37/pmb/projects/filter`|
|-|-|
|Method|GET|
|說明|取得專案,可以指定條件|
#### 引數
- member_id(int): 使用者的ID
#### 回傳值
json 格式的專案狀態陣列
#### 使用方式
```python
>>> url = 'http://192.168.1.37/pmb/projects/filter?user_id=20'
>>> r = requests.get(url,
headers=self.header,
cookies=self.cookies,
timeout=30
)
>>> pprint(r.json())
[{'alive': 1,
'budget': 7142857,
'budget_tax': 7500000,
'charge': 0,
'company': '',
'contracted': 1,
'cost': 6110075,
'deadline': 'Fri, 05 Jan 2018 00:00:00 GMT',
'id': 16,
'leader': 0,
'leader_agent': 0,
'member_id': 84,
'money_received': 0,
'name': 'Bugs Show 蟲蟲直播秀',
'note': '',
'payment_status': 0,
'profit': -1452699,
'sort_num': 0.0,
'status': 3,
'time_end': 'Wed, 31 Jan 2018 00:00:00 GMT',
'time_start': 'Mon, 24 Oct 2016 00:00:00 GMT',
'time_update': 'Tue, 22 May 2018 12:40:03 GMT',
'type': 2},
{'alive': 1,
'budget': 237500,
'budget_tax': 250000,
'charge': 0,
'company': '',
'contracted': 0,
'cost': 249750,
'deadline': 'Wed, 01 Feb 2017 00:00:00 GMT',
'id': 52,
'leader': 0,
'leader_agent': 0,
'member_id': 30,
'money_received': 0,
'name': 'Asus Brand Video2016',
'note': '',
'payment_status': 0,
'profit': -12250,
'sort_num': 0.0,
'status': 3,
'time_end': 'Fri, 10 Mar 2017 00:00:00 GMT',
'time_start': 'Thu, 01 Sep 2016 00:00:00 GMT',
'time_update': 'Mon, 04 Sep 2017 17:19:18 GMT',
'type': 0},
{'alive': 1,
'budget': 761904,
'budget_tax': 800000,
'charge': 0,
'company': '',
'contracted': 0,
'cost': 236483,
'deadline': '0000-00-00',
'id': 66,
'leader': 34,
'leader_agent': 60,
'member_id': 55,
'money_received': 0,
'name': 'Asus_ZenBeamCampaign',
'note': '',
'payment_status': 0,
'profit': 454901,
'sort_num': 0.0,
'status': 3,
'time_end': 'Mon, 19 Mar 2018 00:00:00 GMT',
'time_start': 'Mon, 20 Feb 2017 00:00:00 GMT',
'time_update': 'Tue, 20 Mar 2018 15:22:35 GMT',
'type': 2},...]
```
### 取得專案狀態
|URL|`http://192.168.1.37/pmb/project/status/`|
|-|-|
|Method|GET|
|說明|取得專案狀態|
#### 參數
無
#### 回傳值
json 格式的專案狀態陣列
#### 使用方式
```python
>>> url = 'http://192.168.1.37/pmb/project/status/'
>>> r = requests.get(url,
headers=self.header,
cookies=self.cookies,
timeout=30
)
>>> pprint(r.json())
[{'color': 'FFF5C4', 'id': 1, 'is_default': 1, 'name': '詢問中', 'sort_num': 1.0},
{'color': 'DFFFC4', 'id': 2, 'is_default': 1, 'name': '執行中', 'sort_num': 2.0},
{'color': 'C4FFEF', 'id': 3, 'is_default': 1, 'name': '已結案', 'sort_num': 4.0},
{'color': 'DBDBDB', 'id': 4, 'is_default': 1, 'name': '腰斬', 'sort_num': 0.0},
{'color': 'FFD0C4', 'id': 7, 'is_default': 1, 'name': '暫停', 'sort_num': 3.0},
{'color': 'C4EFFF', 'id': 8, 'is_default': 0, 'name': '自修', 'sort_num': 5.0},
{'color': 'DEC4FF', 'id': 9, 'is_default': 0, 'name': '自接案', 'sort_num': 10.0},
{'color': 'C4CBFF', 'id': 10, 'is_default': 0, 'name': '研發', 'sort_num': 6.0}]
```
## Task_Group 工作群相關功能
工作群相關功能
### 建立 Task Group
|URL|`http://192.168.1.37/pmb/projects/`|
|-|-|
|Method|POST|
|說明|建立工作群|
#### 參數
* project_id(int): 專案 id
* name(str): 工作群名 (option)
#### 回傳值
json 格式的工作群資料
#### 使用方式
```python
>>> url = 'http://192.168.1.37/pmb/task_group/'
>>> task_group_payload = {'project_id':xxxx, 'name':'測試工作組'}
>>> r = requests.post(url,
headers=self.header,
cookies=self.cookies_admin,
data=json.dumps(task_group_payload)
)
>>> pprint(r.json())
{'cost': 0, 'id': 2185, 'name': '測試工作組', 'project_id': 629, 'sort_num': 1945.0}
```
### 修改 Task Group
|URL|`http://192.168.1.37/pmb/task_group/`|
|-|-|
|Method|PUT|
|說明|修改工作群組資料|
#### 參數
* task_group_id(int): 工作群組 id
* name(str): 工作群名
#### 回傳值
json 格式的工作群資料
#### 使用方式
```python
>>> url = 'http://192.168.1.37/pmb/task_group/'
>>> payload = {"task_group_id":2185,
"name":"modified_name"}
>>> r = requests.put(url,
headers=self.header,
cookies=self.cookies,
data=json.dumps(payload),
timeout=30
)
>>> pprint(r.json())
{'cost': 0,
'id': 2184,
'name': 'modified_name', # 名稱已被修改
'project_id': 628,
'sort_num': 1945.0}
```
### 刪除
## Block 相關功能
格子相關功能
### 取得 Block
|URL|`http://192.168.1.37/pmb/blocks/<string:start>_<string:end>`|
|-|-|
|Method|GET|
|說明|取得指定日期內的所有格子|
#### 參數
|參數|型別|說明|必備|
|-|-|-|-|
|member|int|員工 Id, 如果指定了就只會回傳該員工的格子||
#### 回傳值
json 格式的格子資料
#### 使用方式
```python
>>> url = "http://192.168.1.37/pmb/blocks/2019-02-01_2019-02-27"
>>> params = {"member: 20"}
>>> r = requests.get(url,
headers=self.header,
cookies=self.cookies,
params=json.dumps(params)
timeout=30
)
>>> pprint(r.json())
[{'cost': 7500,
'creator_id': 20,
'date': 'Fri, 22 Feb 2019 00:00:00 GMT',
'duration': 480,
'group_id': 1571,
'id': 83930,
'member_id': 20,
'project_id': 256,
'sheet_id': 0,
'task_id': 8431,
'time_create': 'Fri, 22 Feb 2019 22:11:46 GMT',
'type': 2,
'value': 1.0}]
```
### 建立格子
|URL|`http://192.168.1.37/pmb/project/status/`|
|-|-|
|Method|POST|
|說明|建立格子|
#### 參數
格子在大分類上有分為二種。專案ID這些參數在請假時不一定需要,所以是選填
|參數|型別|說明|必備|
|-|-|-|-|
|type|int|格字類別|●|
|duration|int| 工作時間, 單位為分鐘|●|
|value|float|工作時間,數值1 代表 480 分(8小時) </br>**之後會棄用**但還是要填寫|●|
|member_id|int| 格子主人|●|
|creator_id|int| 誰建立這格|●|
|date|str|"yyyy-mm-dd" 格式的日期|●|
|project_id|int| 專案 id|
|task_group_id|int|工作群組 id|
|task_id|int|工作 id |
#### 回傳值
json 格式的格子資料
#### 使用方式
```python
>>> url = "http://192.168.1.37/pmb/blocks/"
>>> block_payload = { "project_id": 546,
"task_group_id":1884,
"task_id":7414,
"value": 0.5,
"duration":240,
"type":2,
"member_id":20,
"creator_id":20,
"date":"2018-12-02"
}
>>> r = requests.post(url,
headers=self.header,
cookies=self.cookies,
data=json.dumps(block_payload)
timeout=30
)
>>> pprint(r.json())
{"cost": 3500,
"creator_id": 20,
"date": "Sun, 02 Dec 2018 00:00:00 GMT",
"duration": 240,
"group_id": 1884,
"id": 68875,
"member_id": 20,
"project_id": 546,
"sheet_id": 0,
"task_id": 7414,
"time_create": "Fri, 21 Dec 2018 14:42:23 GMT",
"type": 2,
"value": 0.5}
```
## Member 相關功能
### 取得成員
|URL|`http://192.168.1.37/pmb/members/status`|
|-|-|
|Method|GET|
|說明|依指定狀態取的人員|
#### 引數
|引數|型別|說明|必備|
|-|-|-|-|
|on_position|int|在職人員 1或0|●|
|resigned|int|離職人員 1或0|●|
|furloughed|int|留職停薪 1或0|●|
#### 回傳值
json 格式的人員資料
#### 使用方式
```python
>>> url = 'http://192.168.1.37/pmb/members/status')
>>> params = {"resigned": 1}
>>> r = requests.get(url,
headers=self.header,
cookies=self.cookies,
params=params,
timeout=30
)
>>> members = r.json()
>>> print(members[0])
{'address': '新得市隆和區保順路17巷6弄5號2樓',
'annual_leave': 20,
'authority': None,
'bank_id': '',
'birthday': '',
'department': 'R研發組',
'email': '',
'first_work_day': 'Mon, 26 May 2014 00:00:00 GMT',
'health_insurance': 0,
'id': 19,
'id_number': '',
'message': '',
'name': '蕭國凱',
'name_eng': 'Hsiao Guo Kai',
'nickname': '',
'note': '',
'password': '',
'phone': '',
'phone2': '',
'salary': 0,
'status': 0,
'title': 'Technic Artist',
'username': ''}
```
### 取得目前登入者
|URL|`http://192.168.1.37/pmb/membe/self`|
|-|-|
|Method|GET|
|說明|取得目前登入者|
#### 引數
無
#### 回傳值
json 格式的人員資料
### 使用方式
```python
>>> url = '/'.join('http:/192.168.1.37/pmb', 'member', 'self'])
>>> r = requests.post(url,
headers=self.header,
cookies=self.cookies_admin
)
>>> print(r.json())
{'address': '',
'annual_leave': 0,
'authority': 1,
'bank_id': '',
'birthday': '0000-00-00',
'email': '',
'first_work_day': 'Thu, 13 Jun 2019 00:00:00 GMT',
'health_insurance': 0,
'id': 207,
'id_number': 'A122121212',
'message': '',
'name': '發大財',
'name_eng': '',
'nickname': '',
'note': '',
'password': 'A122121212',
'phone': '0958321456',
'phone2': '',
'salary': 0,
'status': 1,
'title': '',
'username': '0958321456'}
```
### 建立成員
|URL|`http://192.168.1.37/pmb/member/`|
|-|-|
|Method|POST|
|說明|建立人員</br>登入的使用者必需有 ```EDIT_MEMBER_ALL``` 的限權才能執行|
#### 引數
|引數|型別|說明|必備|
|-|-|-|-|
|name|str|姓名, 例:'助英台'|●|
|id_number|str|身份証字號, 例:'P123456789'|●|
|cell_phone|str|手機號碼, 例:'0955333666'|●|
|status|int|狀態,0為已離值,1是在職,2是留職停薪|●|
|first_work_day|str|第一天上班日, 例:2019-12-31|●|
|name_eng|str|英文名, 例:'Jhon'||
|nickname|str|暱稱, 例:'王董'||
|birthday|str|生日, 例:'2019-11-11'||
|email|str|電子信箱, 例:'ilovemoon@gmail.com'||
|address|str|地址, 例:'新德市重得路一段21號'||
|bank_id|str|銀行帳戶, 例:'12547891254789'||
|health_insurance|int|勞建保, 例:42000||
|title|str|職稱, 例:'3低動畫師'||
|annual_leave|int|姓名, 例:20||
|note|str|備注||
#### 回傳值
json 格式的人員資料
### 使用方式
```python
>>> name = '發大財'
>>> dy = datetime.date.today()
>>> payload = {'name': name,
'id_number': 'a122121212',
'cell_phone': '0958321456',
'status': 1,
'first_work_day': '{}-{:02g}-{:02g}'.format(dy.year,dy.month,dy.day)}
>>> url = '/'.join('http:/192.168.1.37/pmb', 'member/'])
>>> r = requests.post(url,
headers=self.header,
cookies=self.cookies_admin,
data=json.dumps(payload)
)
>>> pprint(r.json())
{'address': '',
'annual_leave': 0,
'authority': 1,
'bank_id': '',
'birthday': '0000-00-00',
'email': '',
'first_work_day': 'Thu, 13 Jun 2019 00:00:00 GMT',
'health_insurance': 0,
'id': 207,
'id_number': 'A122121212',
'message': '',
'name': '發大財',
'name_eng': '',
'nickname': '',
'note': '',
'password': 'A122121212',
'phone': '0958321456',
'phone2': '',
'salary': 0,
'status': 1,
'title': '',
'username': '0958321456'}
```
### 修改成員
|URL|`http://192.168.1.37/pmb/member/`|
|-|-|
|Method|PUT|
|說明|修改人員資料</br>登入的使用者必需有 ```EDIT_MEMBER_ALL``` 的限權才能執行|
#### 引數
|引數|型別|說明|必備|
|-|-|-|-|
|id|int|唯一識別碼, 例:1|●|
|name|str|姓名, 例:'助英台'||
|id_number|str|身份証字號, 例:'P123456789'||
|cell_phone|str|手機號碼, 例:'0955333666'||
|status|int|狀態,0為已離值,1是在職,2是留職停薪||
|first_work_day|str|第一天上班日, 例:2019-12-31||
|name_eng|str|英文名, 例:'Jhon'||
|nickname|str|暱稱, 例:'王董'||
|birthday|str|生日, 例:'2019-11-11'||
|email|str|電子信箱, 例:'ilovemoon@gmail.com'||
|address|str|地址, 例:'新德市重得路一段21號'||
|bank_id|str|銀行帳戶, 例:'12547891254789'||
|health_insurance|int|勞建保, 例:42000||
|title|str|職稱, 例:'3低動畫師'||
|annual_leave|int|姓名, 例:20||
|note|str|備注||
#### 回傳值
修改後 json 格式的人員資料
#### 使用方式
```python
>>> name = '發大財'
>>> dy = datetime.date.today()
>>> payload = {'name': name,
'id_number': 'a122121212',
'cell_phone': '0958321456',
'status': 1,
'first_work_day': '{}-{:02g}-{:02g}'.format(dy.year,dy.month,dy.day)}
>>> url = '/'.join([self.api_url, 'member/'])
>>> r = requests.post(url,
headers=self.header,
cookies=self.cookies_admin,
data=json.dumps(payload)
)
>>> member = r.json()
>>> member['name'] = '馬小九'
>>> member['first_work_day'] = '2018-01-01'
>>> r = requests.put(url,
headers=self.header,
cookies=self.cookies_admin,
data=json.dumps(member)
)
>>> pprint(r.json())
{'address': '',
'annual_leave': 0,
'authority': 1,
'bank_id': '',
'birthday': '0000-00-00',
'email': '',
'first_work_day': '2018-01-01',
'health_insurance': 0,
'id': 219,
'id_number': 'A122121212',
'message': '',
'name': '馬小九',
'name_eng': '',
'nickname': '',
'note': '',
'password': 'A122121212',
'phone': '0958321456',
'phone2': '',
'salary': 0,
'status': 1,
'title': '',
'username': '0958321456'}
.{'address': '',
'annual_leave': 0,
'authority': 1,
'bank_id': '',
'birthday': '0000-00-00',
'email': '',
'first_work_day': 'Thu, 13 Jun 2019 00:00:00 GMT',
'health_insurance': 0,
'id': 220,
'id_number': 'A122121212',
'message': '',
'name': '發大財',
'name_eng': '',
'nickname': '',
'note': '',
'password': 'A122121212',
'phone': '0958321456',
'phone2': '',
'salary': 0,
'status': 1,
'title': '',
'username': '0958321456'}
```
### 刪除成員
:::warning
:warning: 警告
請用修改成員狀態為離職來替代本功能
此功能請小心使用,是真的刪除資料,不保留
```如果還有任何格子跟本成員有關連,便無法刪除```
:::
|URL|`http://192.168.1.37/pmb/member/`|
|-|-|
|Method|DELETE|
|說明|刪除人員</br>登入的使用者必需有 ```EDIT_MEMBER_ALL``` 的限權才能執行|
#### 引數
|引數|型別|說明|必備|
|-|-|-|-|
|id|int|唯一識別碼, 例:1|●|
#### 回傳值
{'id': <int:該成員id>}
#### 使用方式
```python
>>> payload = {'id': member['id']}
>>> r = requests.delete(url,
headers=self.header,
cookies=self.cookies_admin,
data=json.dumps(payload)
)
>>> pprint(r.josn())
{'id': 13}
```
## Schedule 相關功能
### 取得 Schedule
|URL|`http://192.168.1.37/pmb/schedule/<int:year>`|
|-|-|
|Method|GET|
|說明|取得指定年份的行事曆|
#### 引數
|引數|型別|說明|必備|
|-|-|-|-|
|year|int|年, 例:2019|●|
#### 回傳值
json 格式的行事曆資料
#### 使用方式
```python
>>> url = "http://192.168.1.37/pmb/schedule/2019"
>>> r = requests.post(url,
headers=self.header,
cookies=self.cookies,
timeout=30
)
>>> pprint(r.json())
[{'date': 'Thu, 04 Apr 2019 00:00:00 GMT', 'id': 63, 'name': '兒童節', 'type': 0},
{'date': 'Fri, 05 Apr 2019 00:00:00 GMT', 'id': 64, 'name': '清明節', 'type': 0},
{'date': 'Wed, 01 May 2019 00:00:00 GMT', 'id': 65, 'name': '勞動節', 'type': 0},
{'date': 'Fri, 07 Jun 2019 00:00:00 GMT', 'id': 66, 'name': '端午節', 'type': 0},
{'date': 'Fri, 13 Sep 2019 00:00:00 GMT', 'id': 67, 'name': '中秋節', 'type': 0},
{'date': 'Sat, 05 Oct 2019 00:00:00 GMT', 'id': 68, 'name': '國慶補班', 'type': 1},
{'date': 'Thu, 10 Oct 2019 00:00:00 GMT', 'id': 69, 'name': '國慶日', 'type': 0},
{'date': 'Fri, 11 Oct 2019 00:00:00 GMT', 'id': 70, 'name': '國慶調休', 'type': 0}]
```
### 建立 Schedule
|URL|`http://192.168.1.37/pmb/schedule/`|
|-|-|
|Method|POST|
|說明|建立行事曆|
#### 參數
|引數|型別|說明|必備|
|-|-|-|-|
|name|string|title, 例:"國父紀念日"|●|
|date|string|日期, 例:"2019-03-01"|●|
|type|int|0 或 1,0 為放假,1 為要工作|●|
#### 回傳值
json 格式的行事曆資料
#### 使用方式
```python
>>> url = "http://192.168.1.37/pmb/schedule/"
>>> payload = { "name": "test_sch",
"type": 1,
"date": "2019-03-01"
}
>>> r = requests.post(url,
headers=self.header,
cookies=self.cookies,
data = json.dumps(payload),
timeout=30
)
>>> pprint(r.json())
{'date': 'Fri, 01 Mar 2019 00:00:00 GMT',
'id': 76,
'name': 'test_sch',
'type': 1}
```
### 修改 Schedule
|URL|`http://192.168.1.37/pmb/schedule/`|
|-|-|
|Method|PUT|
|說明|建立行事曆|
#### 參數
|引數|型別|說明|必備|
|-|-|-|-|
|id|int|要修改的schedule id|●|
|name|string|要修改的 title"||
|date|string|要修改的日期||
|type|int|要修改的 type||
#### 回傳值
json 格式的行事曆資料
#### 使用方式
```python
>>> url = "http://192.168.1.37/pmb/schedule/"
>>> schedule_id = 76 # 必需要是已經存在的 schedule id
>>> payload = {"id": schedule_id,
"name": "modify_sch",
"type": 0,
"date": "2019-03-02"
}
>>> r = requests.post(url,
headers=self.header,
cookies=self.cookies,
data = json.dumps(payload),
timeout=30
)
>>> pprint(r.json())
{'date': 'Sat, 02 Mar 2019 00:00:00 GMT',
'id': 76,
'name': 'modify_sch',
'type': 0}
```
## Structure 相關功能
這一部份的 API 主要是跟公司組織,結構有關的
### 取得群組
|URL|`http://192.168.1.37/pmb/structure/groups`|
|-|-|
|Method|GET|
|說明|取得群組|
#### 參數
無
#### 回傳值
陣列,裝載部門 json 資料
#### 使用方式
##### Python
```python
>>> url = "http://192.168.1.37/pmb/structure/groups"
>>> r = requests.get(url,
headers=self.header,
cookies=self.cookies)
>>> pprint(r.json())
[{"id":1,"name":"Manage","sort_num":1.0},
{"id":2,"name":"RD","sort_num":2.0},
{"id":3,"name":"Director","sort_num":3.0},
{"id":4,"name":"Design","sort_num":4.0},
{"id":5,"name":"MAX","sort_num":5.0},
{"id":6,"name":"MAYA","sort_num":6.0},
{"id":7,"name":"VFX","sort_num":7.0},
{"id":8,"name":"Comp","sort_num":8.0},
{"id":9,"name":"XSI","sort_num":9.0},
{"id":10,"name":"\u7d44\u9577","sort_num":10.0},
...
]
```
### 取得群組、會員列表
|URL|`http://192.168.1.37/pmb/structure/groups_member`|
|-|-|
|Method|GET|
|說明|取得群組、會員列表|
#### 參數
無
#### 回傳值
陣列,內含部門跟人員二元素的陣列
#### 使用方式
```python
>>> url = "http://192.168.1.37/pmb/structure/groups_member"
>>> r = requests.get(url,
headers=self.header,
cookies=self.cookies)
>>> pprint(r.json())
[
["Manage", "林家齊"],
["M管理組", "林家齊"],
["J導演組", "李劭謙"],
["組長", "鄭惠姍"],
["負責人", "鄭惠姍"],
...
]
```