def view_api_activity_query_mine(request): params = request.data page = int(params.get("page", 0)) size = int(params.get("size", 20)) user_id = request.uid ret = service_di.activityService.query_mine_page(user_id, page, size) return response_ok(request, ret)
def view_api_activity_query_comments(request): params = request.data activity_id = long(params.get("activity_id", 0)) page = int(params.get("page", 0)) size = int(params.get("size", 20)) ret = service_di.activityService.query_comments(activity_id, page, size) return response_ok(request, ret)
def view_api_activity_join(request): params = request.data now = time_utils.unix_time() activity_id = long(params.get("activity_id", 0)) is_join = "True" == params.get("is_join", "True") user_id = request.uid service_di.activityService.join(user_id, activity_id, is_join) return response_ok(request, True)
def view_api_activity_comment(request): params = request.data now = time_utils.unix_time() activity_id = long(params.get("activity_id", 0)) refer_id = long(params.get("refer_id", 0)) content = params.get("content", None) user_id = request.uid service_di.activityService.comment(user_id, activity_id, refer_id, content) return response_ok(request, True)
def view_api_ops_channel_update(request): params = request.data now = time_utils.unix_time() admin_id = request.uid params["update_time"] = now params["admin_id"] = admin_id channel_id = params["id"] params.pop("id") service_di.activityChannelService.update(channel_id, **params) return response_ok(request, True)
def view_api_ops_channel_query(request): params = request.data name = params.get("name", None) page = int(params.get("page", 0)) size = int(params.get("size", 20)) params = {} if common_utils.is_not_empty(name): params = {"name__contains": name} params["page"] = page params["size"] = size ret_dict = service_di.activityChannelService.query_page(**params) return response_ok(request, ret_dict)
def view_api_ops_activity_add(request): params = request.data now = time_utils.unix_time() admin_id = request.uid params["create_time"] = now params["update_time"] = now params["admin_id"] = admin_id end_time = long(params["end_time"]) if end_time < now: raise error.MessageError("end_time can not less than current time") if id in params:params.pop("id") service_di.activityService.create(**params) return response_ok(request, True)
def view_api_ops_auth_login(request): params = request.data username = params.get("username", None) password = params.get("password", None) admin = service_di.adminService.get(username) if not admin or password != admin.password: raise error.MessageError("username error or password error") ret = {"username": admin.username} response = response_ok(request, ret) session = AuthSession(request, 1) uuid_str = session.save(admin.admin_id) response.set_cookie("admid", uuid_str) return response
def view_api_auth_login(request): params = request.data username = params.get("username", None) password = params.get("password", None) user = service_di.userService.get(username) if not user or password != user.password: raise error.MessageError("username error or password error") ret = { "username": user.username, "photo_url": user.photo_url, "email": user.email } response = response_ok(request, ret) session = AuthSession(request) uuid_str = session.save(user.user_id) response.set_cookie("uid", uuid_str) return response
def view_api_activity_query(request): params = request.data channel_id = long(params.get("channel_id", 0)) begin_time = long(params.get("begin_time", 0)) end_time = long(params.get("end_time", 0)) page = int(params.get("page", 0)) size = int(params.get("size", 20)) now = time_utils.unix_time() fields_dict = {"page": page, "size": size} if channel_id > 0: fields_dict["a.channel_id"] = channel_id if begin_time > 0: fields_dict["end_time__gte"] = begin_time if end_time > 0: fields_dict["begin_time__lte"] = end_time else: fields_dict["end_time__gte"] = now fields_dict["order_by"] = "order by a.id desc" ret = service_di.activityService.query_summary_page(**fields_dict) return response_ok(request, ret)
def view_api_ops_activity_query(request): params = request.data name = params.get("name", None) channel_id = long(params.get("channel_id", 0)) begin_time = long(params.get("begin_time", 0)) end_time = long(params.get("end_time", 0)) page = int(params.get("page", 0)) size = int(params.get("size", 20)) params = {} if common_utils.is_not_empty(name): params["name__contains"] = name if channel_id > 0: params["channel_id"] = channel_id if begin_time > 0: params["begin_time__gte"] = begin_time if end_time > 0: params["end_time__lte"] = end_time fields = ("id","name","desc","location","begin_time","end_time") params["page"] = page params["size"] = size params["fields"] = fields ret_dict = service_di.activityService.query_page(**params) return response_ok(request, ret_dict)
def view_api_activity_detail(request): params = request.data activity_id = int(params.get("activity_id", 0)) ret = service_di.activityService.detail_summary(activity_id) return response_ok(request, ret)
def view_api_channel_get_all(request): ret = service_di.activityChannelService.get_all() return response_ok(request, ret)
def view_api_ops_channel_delete(request): params = request.data id = params.get("id", None) service_di.activityChannelService.delete(id) return response_ok(request, True)
def view_api_ops_activity_detail(request): params = request.data id = params.get("id", 0) ret_dict = service_di.activityService.detail(id) return response_ok(request, ret_dict)
def view_api_ops_activity_delete(request): params = request.data id = params.get("id", 0) service_di.activityService.delete(id) return response_ok(request, True)