def get_someday_values(uname, day, type_id):
	if not str_deal.is_day_str(day) or not type_id.isdigit():
		return error.raise_param_illegal()
	type_id = int(type_id)
	#检查权限
	if not authority.can_access_physical(type_id, uname):
		return error.raise_no_auth()
	datas = physical.get_someday_values(type_id, day)
	if datas:
		return generate_today_json(datas)
	return error.raise_error_with_info('没有对应的数据')
def get_last_one(uname, type_id):
	if not type_id.isdigit():
		return error.raise_param_illegal()
	type_id = int(type_id)
	#检查权限
	if not authority.can_access_physical(type_id, uname):
		return error.raise_no_auth()
	value = physical.get_last_one(type_id)
	if value == None:
		return error.raise_error_with_info('没有对应物理量的数据')
	return generate_json.data_json(value)
def get_today_values(uname, type_id):
	#参数合法性检查
	if not type_id.isdigit():
		return error.raise_param_illegal()
	type_id = int(type_id)
	#检查权限
	if not authority.can_access_physical(type_id, uname):
		return error.raise_no_auth()
	today = libtime.strftime('%Y-%m-%d')
	datas = physical.get_someday_values(type_id, today)
	if datas:
		return generate_today_json(datas)
	return error.raise_error_with_info('没有对应的数据')
示例#4
0
def register(uname, email, rname, pwd):
	#检测参数是否合法
	if(not security.is_uname_valid(uname)
		or not security.is_email_valid(email)
		or not security.is_rname_valid(rname)
		or not security.is_pwd_valid(pwd)):
		return error.raise_param_illegal()
	#用户名已被注册
	if not user.uname_registerable(uname):
		return error.raise_error_with_info(INFO_UNAME)
	#邮箱已被注册
	if not user.email_registerable(email):
		return error.raise_error_with_info(INFO_EMAIL)
	#插入数据库
	if user.insert(uname, email, rname, pwd):
		return generate_json.data_json(INFO_OK)
	return error.raise_internal()