V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
chenqh
V2EX  ›  Python

遇到关于 acl 的问题

  •  
  •   chenqh · 2020-02-29 11:59:37 +08:00 · 1257 次点击
    这是一个创建于 1515 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我有一个订单页面
    管理员要看到所有的订单, 还有管理
    下游有看到自己的订单,table 包括 downstream_id
    代理要看到代理下面的下游的所有订单, table 包括 proxy_id
    我现在是这么做的
    管理员 /admin/admin/order_list
    , 下游 /admin/downstream/order_list
    代理 /admin/proxy/order_list
    现在的问题就是页面要copy, 两次,刚刚群里问了一下,这居然属于acl的问题, 我理解里面acl只包括操作呀, 难道也包括数据的过滤?

    1 条回复    2020-02-29 16:17:45 +08:00
    lasuar
        1
    lasuar  
       2020-02-29 16:17:45 +08:00   ❤️ 1
    你这个场景其实是树形权限表结构,不太清楚你的表是如何设计的,按我的想法一个接口就可以了,接口的参数就是用户 id,查询订单的时候,订单有个商家 id,商家 id 可能有上级,在用户表中有个字段叫 father_id 表这个人的上级 id (当然这样设计需要限制代理商最大深度),查询语句:select * from order where agent_id in (select id from user where id=2 or father_id=2),这是最多两层的情况,如果有三个以上的层级,就需要递归查询把所有的 agent_id 拿到,再去查订单表了,如果是无限极那又是另一种处理情况了。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3982 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 10:21 · PVG 18:21 · LAX 03:21 · JFK 06:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.