nightly commit
This commit is contained in:
@@ -77,6 +77,7 @@ CREATE TABLE calendar(
|
|||||||
## API
|
## API
|
||||||
|
|
||||||
所有API均为POST请求
|
所有API均为POST请求
|
||||||
|
理论上,所有更新操作(名字里有update的),除去必要的鉴别字段外,其余字段均为可选字段,可选字段只需要提供至少一个即可。但一些可选字段只有1条的,就没有可选字段。
|
||||||
|
|
||||||
### Common类
|
### Common类
|
||||||
|
|
||||||
@@ -243,6 +244,8 @@ Calendar类下的为日历请求接口
|
|||||||
|
|
||||||
返回参数:新的lastChange,用以更新本地缓存
|
返回参数:新的lastChange,用以更新本地缓存
|
||||||
|
|
||||||
|
除去token,uuid,timezoneOffset和lastChange这4项用来鉴别的条目外,其余的条目均为可选项,提供则更新,不提供则不更新。
|
||||||
|
|
||||||
#### add
|
#### add
|
||||||
|
|
||||||
请求地址:`/api/calendar/add`
|
请求地址:`/api/calendar/add`
|
||||||
@@ -547,6 +550,8 @@ Admin类的操作不涉及任何客户端存储,因此不需要lastChange来
|
|||||||
|
|
||||||
返回参数:一个bool表示是否修改成功
|
返回参数:一个bool表示是否修改成功
|
||||||
|
|
||||||
|
除去token,username这2项用来鉴别的条目外,其余的条目均为可选项,提供则更新,不提供则不更新。
|
||||||
|
|
||||||
#### delete
|
#### delete
|
||||||
|
|
||||||
请求地址:`/api/admin/delete`
|
请求地址:`/api/admin/delete`
|
||||||
|
|||||||
@@ -72,29 +72,29 @@ def web_loginHandle():
|
|||||||
@app.route('/api/common/salt', methods=['POST'])
|
@app.route('/api/common/salt', methods=['POST'])
|
||||||
def api_common_saltHandle():
|
def api_common_saltHandle():
|
||||||
return SmartDbCaller(calendar_db.common_salt,
|
return SmartDbCaller(calendar_db.common_salt,
|
||||||
(('username', str), ))
|
(('username', str, False), ))
|
||||||
|
|
||||||
@app.route('/api/common/login', methods=['POST'])
|
@app.route('/api/common/login', methods=['POST'])
|
||||||
def api_common_loginHandle():
|
def api_common_loginHandle():
|
||||||
return SmartDbCaller(calendar_db.common_login,
|
return SmartDbCaller(calendar_db.common_login,
|
||||||
(('username', str),
|
(('username', str, False),
|
||||||
('password', str)))
|
('password', str, False)))
|
||||||
|
|
||||||
@app.route('/api/common/webLogin', methods=['POST'])
|
@app.route('/api/common/webLogin', methods=['POST'])
|
||||||
def api_common_webLoginHandle():
|
def api_common_webLoginHandle():
|
||||||
return SmartDbCaller(calendar_db.common_webLogin,
|
return SmartDbCaller(calendar_db.common_webLogin,
|
||||||
(('username', str),
|
(('username', str, False),
|
||||||
('password', str)))
|
('password', str, False)))
|
||||||
|
|
||||||
@app.route('/api/common/logout', methods=['POST'])
|
@app.route('/api/common/logout', methods=['POST'])
|
||||||
def api_common_logoutHandle():
|
def api_common_logoutHandle():
|
||||||
return SmartDbCaller(calendar_db.common_logout,
|
return SmartDbCaller(calendar_db.common_logout,
|
||||||
(('token', str), ))
|
(('token', str, False), ))
|
||||||
|
|
||||||
@app.route('/api/common/tokenValid', methods=['POST'])
|
@app.route('/api/common/tokenValid', methods=['POST'])
|
||||||
def api_common_tokenValidHandle():
|
def api_common_tokenValidHandle():
|
||||||
return SmartDbCaller(calendar_db.common_tokenValid,
|
return SmartDbCaller(calendar_db.common_tokenValid,
|
||||||
(('token', str), ))
|
(('token', str, False), ))
|
||||||
|
|
||||||
@app.route('/api/common/isAdmin', methods=['POST'])
|
@app.route('/api/common/isAdmin', methods=['POST'])
|
||||||
def api_common_isAdminHandle():
|
def api_common_isAdminHandle():
|
||||||
@@ -180,38 +180,38 @@ def api_collection_getSharedHandle():
|
|||||||
@app.route('/api/todo/getFull', methods=['POST'])
|
@app.route('/api/todo/getFull', methods=['POST'])
|
||||||
def api_todo_getFullHandle():
|
def api_todo_getFullHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_getFull,
|
return SmartDbCaller(calendar_db.todo_getFull,
|
||||||
(('token', str), ))
|
(('token', str, False), ))
|
||||||
|
|
||||||
@app.route('/api/todo/getList', methods=['POST'])
|
@app.route('/api/todo/getList', methods=['POST'])
|
||||||
def api_todo_getListHandle():
|
def api_todo_getListHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_getList,
|
return SmartDbCaller(calendar_db.todo_getList,
|
||||||
(('token', str), ))
|
(('token', str, False), ))
|
||||||
|
|
||||||
@app.route('/api/todo/getDetail', methods=['POST'])
|
@app.route('/api/todo/getDetail', methods=['POST'])
|
||||||
def api_todo_getDetailHandle():
|
def api_todo_getDetailHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_getDetail,
|
return SmartDbCaller(calendar_db.todo_getDetail,
|
||||||
(('token', str),
|
(('token', str, False),
|
||||||
('uuid', str)))
|
('uuid', str, False)))
|
||||||
|
|
||||||
@app.route('/api/todo/add', methods=['POST'])
|
@app.route('/api/todo/add', methods=['POST'])
|
||||||
def api_todo_addHandle():
|
def api_todo_addHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_add,
|
return SmartDbCaller(calendar_db.todo_add,
|
||||||
(('token', str), ))
|
(('token', str, False), ))
|
||||||
|
|
||||||
@app.route('/api/todo/update', methods=['POST'])
|
@app.route('/api/todo/update', methods=['POST'])
|
||||||
def api_todo_updateHandle():
|
def api_todo_updateHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_update,
|
return SmartDbCaller(calendar_db.todo_update,
|
||||||
(('token', str),
|
(('token', str, False),
|
||||||
('uuid', str),
|
('uuid', str, False),
|
||||||
('data', str),
|
('data', str, False),
|
||||||
('lastChange', str)))
|
('lastChange', str, False)))
|
||||||
|
|
||||||
@app.route('/api/todo/delete', methods=['POST'])
|
@app.route('/api/todo/delete', methods=['POST'])
|
||||||
def api_todo_deleteHandle():
|
def api_todo_deleteHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_delete,
|
return SmartDbCaller(calendar_db.todo_delete,
|
||||||
(('token', str),
|
(('token', str, False),
|
||||||
('uuid', str),
|
('uuid', str, False),
|
||||||
('lastChange', str)))
|
('lastChange', str, False)))
|
||||||
|
|
||||||
# ================================ admin
|
# ================================ admin
|
||||||
|
|
||||||
@@ -253,14 +253,25 @@ def UpdateStaticResources():
|
|||||||
|
|
||||||
def SmartDbCaller(dbMethod, paramTuple):
|
def SmartDbCaller(dbMethod, paramTuple):
|
||||||
result = (False, 'Invalid parameter', None)
|
result = (False, 'Invalid parameter', None)
|
||||||
|
optCount = 0
|
||||||
paramList = []
|
paramList = []
|
||||||
|
optParamDict = {}
|
||||||
|
# for each item, item[0] is field name. item[1] is type. item[2] is whether it is optional field
|
||||||
for item in paramTuple:
|
for item in paramTuple:
|
||||||
cache = request.form.get(item[0], default=None, type=item[1])
|
cache = request.form.get(item[0], default=None, type=item[1])
|
||||||
if cache is None:
|
if item[2]:
|
||||||
break
|
# optional param
|
||||||
paramList.append(cache)
|
if cache is not None:
|
||||||
|
optParamDict[item[0]] = cache
|
||||||
|
optCount += 1
|
||||||
|
else:
|
||||||
|
if cache is None:
|
||||||
|
break
|
||||||
|
paramList.append(cache)
|
||||||
else:
|
else:
|
||||||
result = dbMethod(*paramList)
|
# at least one opt param
|
||||||
|
if optCount == 0 or len(optParamDict) != 0:
|
||||||
|
result = dbMethod(*paramList, **optParamDict)
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
return ConstructResponseBody(result)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user