def get(self): """ 根据用户经纬度获取附近的动态列表 """ user = self.params['user'] param_object = ParamObject({ 'account_longitude': self.params['longitude'], 'account_latitude': self.params['latitude'] }) target_page = TargetPage(self.params) filters = self.params.get('filters') dynamics = DynamicRepository(user).get_nearby_dynamics( param_object, filters, target_page) fill_option = self.params.get('with_options', { 'with_resource': False, 'with_approval': False, 'with_comment': False }) FillDynamicService(user).fill(dynamics, fill_option) return { 'dynamics': [ EncodeDynamicService(user).encode(dynamic) for dynamic in dynamics ], 'page_info': target_page.to_dict() if target_page else {} }
def put(self): user = self.params['user'] param_object = ParamObject({ 'name': self.params['name'], 'desc': self.params.get('desc', '') }) permission_group = PermissionGroupFactory(user).create(param_object) return {'group_id': permission_group.id}
def post(self): user = self.params['user'] param_object = ParamObject({ 'id': self.params['group_id'], 'name': self.params['name'], 'desc': self.params.get('desc', '') }) PermissionGroupFactory(user).update(param_object) return {}
def delete(self): """ 解禁圈子(限管理员操作) """ if not self.params['user'].is_manager: raise BusinessError(u'操作无权限') user = self.params['user'] param_object = ParamObject({'topic_id': self.params['topic_id']}) BanService(user).unban(param_object) return {}
def delete(self): """ 删除动态(限管理员或本人操作) """ user = self.params['user'] dynamic = DynamicRepository(user).get_dynamic_by_id(self.params['id']) if not user.is_manager or user.id != dynamic.user_id: raise BusinessError(u'操作无权限') param_object = ParamObject({'id': self.params['id']}) DynamicFactory(user).delete(param_object) return {}
def post(args): member = args['member'] if not member.is_manager(): return 500, u'没有权限' param_object = ParamObject({ 'id': args['id'], 'name': args['name'], 'remark': args.get('remark', '') }) PropertyItemFactory(member).update(param_object) return {}
def put(self): """ 创建话题(限管理员操作) """ if not self.params['user'].is_manager: raise BusinessError(u'操作无权限') user = self.params['user'] param_object = ParamObject({ 'name': self.params['name'], 'avatar': self.params['avatar'], 'description': self.params['description'] }) topic = TopicFactory(user).create(param_object) visit_history = ParamObject({ 'topic_id': topic.id, 'user_id': user.id }) VisitService(user).visit(visit_history) return { 'id': topic.id }
def delete(self): """ 点赞取消 """ user = self.params['user'] approval = LikeService(user).get_approval_by_id(self.params['id']) if approval.user_id != user.id: raise BusinessError(u'操作无权限') param_object = ParamObject({'id': self.params['id']}) LikeService(user).dislike(param_object) return {}
def put(self): """ 点赞 """ user = self.params['user'] param_object = ParamObject({ 'user_id': user.id, 'dynamic_id': self.params['dynamic_id'] }) approval = LikeService(user).like(param_object) return {'id': approval.id}
def post(self): param_object = ParamObject({ 'nickname': self.params.get('nickname'), 'password': self.params.get('password'), 'avatar': self.params.get('avatar') }) UserFactory(self.params['user']).update(param_object) if self.params.get('group_id'): group = PermissionGroupRepository().get_by_id( self.params['group_id']) if group: group.add_user(self.params['user']) return {}
def put(args): member = args['member'] if not member.is_manager(): return 500, u'没有权限' param_object = ParamObject({ 'name': args['name'], 'group': args['group'].upper(), 'remark': args.get('remark', '') }) item = PropertyItemFactory(member).create(param_object) return { 'id': item.id }
def put(self): param_object = ParamObject({ 'username': self.params['username'], 'password': self.params['password'], 'nickname': self.params['nickname'], 'avatar': self.params.get('avatar'), }) user = UserFactory().create(param_object) if self.params.get('group_id'): group = PermissionGroupRepository().get_by_id( self.params['group_id']) if group: group.add_user(user) return {'id': user.id}
def post(self): """ 修改话题(限管理员操作) """ if not self.params['user'].is_manager: raise BusinessError(u'操作无权限') user = self.params['user'] param_object = ParamObject({ 'id': self.params['id'], 'name': self.params.get('name'), 'avatar': self.params.get('avatar'), 'description': self.params.get('description') }) TopicFactory(user).update(param_object) return {}
def put(self): """ 发布动态 """ user = self.params['user'] param_object = ParamObject({ 'user_id': user.id, 'content': self.params['content'], 'topic_id': self.params['topic_id'], 'longitude': self.params['longitude'], 'latitude': self.params['latitude'] }) dynamic = DynamicFactory(user).create(param_object) if self.params.get('resources'): dynamic.update_resources(self.params['resources']) return {'id': dynamic.id}
def post(self): """ 修改动态(限管理员或本人操作) """ user = self.params['user'] dynamic = DynamicRepository(user).get_dynamic_by_id(self.params['id']) if not user.is_manager or user.id != dynamic.user_id: raise BusinessError(u'操作无权限') param_object = ParamObject({ 'content': self.params['content'], 'topic_id': self.params['topic_id'], 'longitude': self.params['longitude'], 'latitude': self.params['latitude'] }) DynamicFactory(user).update(param_object) if self.params.get('resources'): dynamic.update_resources(self.params['resources']) return {}
def put(self): """ 创建用户只能由管理员操作,且只能初始化登录名和分组(角色) """ if not self.params['user'].is_manager: raise BusinessError(u'操作无权限') param_object = ParamObject({ 'username': self.params['username'], 'password': settings.DEFAULT_PASSWORD if hasattr(settings, 'DEFAULT_PASSWORD') else '123456' }) user = UserFactory().create(param_object) if self.params.get('group_id'): group = PermissionGroupRepository().get_by_id( self.params['group_id']) if group: group.add_user(user) return {'id': user.id}
def get(self): """ 获取评论列表 """ user = self.params['user'] target_page = TargetPage(self.params) filters = self.params.get('filters') param_object = ParamObject({'dynamic_id': self.params['dynamic_id']}) comments = CommentService(user).get_comments(param_object, filters, target_page) return { 'dynamics': [ EncodeCommentService(user).encode(comment) for comment in comments ], 'page_info': target_page.to_dict() if target_page else {} }