def profile(): """查询用户信息 """ user_meta = user_service.query_user_meta(session_helper.get_uid()) if not user_meta: user_meta = { "uid": session_helper.get_uid(), "cred": proto.EnumUserCred.GUEST } return result.Result.simple(obj=user_meta)
def doc_post(title, source, desc): creator = session_helper.get_uid() if not user_service.query_user_meta(creator): raise exception.AppMissingUser() if not source.endswith(".zip"): raise exception.AppNotSupportSource() doc_id = doc_service.generate_doc_id() doc_service.post_doc(doc_id, title, source, desc, creator) return result.Result.simple(obj={"doc_id": doc_id})
def token(path): uid = session_helper.get_uid() if not user_service.query_user_meta(uid): raise exception.AppMissingUser() actual_path = f"user/{uid}/{path}" upload_token = app.kodo_client.upload_token(actual_path) resp = { "token": upload_token, "path": actual_path, } return result.Result.simple(obj=resp)
def query_doc(doc_id): doc_item = query_doc_meta(doc_id) creator = doc_item["creator"] doc_item["creator"] = user_service.query_user_meta(creator) return doc_item
def list_doc(user, status, start, limit): page = doc_db.list_doc(user, status, start, limit) for item in page.items: creator = item["creator"] item["creator"] = user_service.query_user_meta(creator) return page
def login_as(uid): user_meta = user_service.query_user_meta(uid) if not user_meta: raise exception.AppMissingUser() session_helper.save_uid(user_meta["uid"]) return result.Result.simple()