- 修复文件权限 (600→644) - 删除调试日志 (global_func.py) - 添加 CRUD 生成的 wwwroot 文件 (pipeline_core/dist/ops) - 添加 mysql.ddl.sql 文件 - 更新 pyproject.toml 配置 - 添加 showcase 模块安装 (build.sh) - 更新 index.ui (sidebar toggle + 管理按钮) - 设置 start.sh/stop.sh 可执行权限 - 添加 wwwroot 符号链接 (appbase/rbac/pipeline_sdlc) - 更新 .gitignore (排除 pkgs/bricks/pipeline.pid)
148 lines
3.2 KiB
Plaintext
148 lines
3.2 KiB
Plaintext
|
|
ns = params_kw.copy()
|
|
|
|
|
|
debug(f'get_distributors.dspy:{ns=}')
|
|
if not ns.get('page'):
|
|
ns['page'] = 1
|
|
if not ns.get('sort'):
|
|
|
|
|
|
ns['sort'] = 'created_at'
|
|
|
|
|
|
|
|
sql = '''select a.*, b.status_text
|
|
from (select * from distributors where 1=1 [[filterstr]]) a left join (select k as status,
|
|
v as status_text from appcodes_kv where parentid='distributor_status') b on a.status = b.status'''
|
|
|
|
filterjson = params_kw.get('data_filter')
|
|
if filterjson and isinstance(filterjson, str):
|
|
try:
|
|
filterjson = json.loads(filterjson)
|
|
except (json.JSONDecodeError, TypeError):
|
|
filterjson = None
|
|
fields_str=r'''[
|
|
{
|
|
"name": "id",
|
|
"title": "主键",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "name",
|
|
"title": "分销商名称",
|
|
"type": "str",
|
|
"length": 200,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "org_id",
|
|
"title": "关联组织ID",
|
|
"type": "str",
|
|
"length": 32
|
|
},
|
|
{
|
|
"name": "contact_name",
|
|
"title": "联系人",
|
|
"type": "str",
|
|
"length": 50
|
|
},
|
|
{
|
|
"name": "contact_phone",
|
|
"title": "联系电话",
|
|
"type": "str",
|
|
"length": 20
|
|
},
|
|
{
|
|
"name": "contact_email",
|
|
"title": "联系邮箱",
|
|
"type": "str",
|
|
"length": 100
|
|
},
|
|
{
|
|
"name": "api_key",
|
|
"title": "API密钥",
|
|
"type": "str",
|
|
"length": 200
|
|
},
|
|
{
|
|
"name": "commission_rate",
|
|
"title": "佣金比例%",
|
|
"type": "double",
|
|
"length": 5,
|
|
"dec": 2,
|
|
"default": "0"
|
|
},
|
|
{
|
|
"name": "status",
|
|
"title": "状态",
|
|
"type": "str",
|
|
"length": 20,
|
|
"default": "active"
|
|
},
|
|
{
|
|
"name": "agreement_start",
|
|
"title": "协议开始日",
|
|
"type": "date"
|
|
},
|
|
{
|
|
"name": "agreement_end",
|
|
"title": "协议结束日",
|
|
"type": "date"
|
|
},
|
|
{
|
|
"name": "remarks",
|
|
"title": "备注",
|
|
"type": "text"
|
|
},
|
|
{
|
|
"name": "created_by",
|
|
"title": "创建人",
|
|
"type": "str",
|
|
"length": 32
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"title": "创建时间",
|
|
"type": "timestamp"
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"title": "更新时间",
|
|
"type": "timestamp"
|
|
}
|
|
]'''
|
|
ori_fields = json.loads(fields_str)
|
|
if not filterjson:
|
|
fields = [ f['name'] for f in ori_fields ]
|
|
filterjson = default_filterjson(fields, ns)
|
|
|
|
filterdic = ns.copy()
|
|
filterdic['filterstr'] = ''
|
|
filterdic['userorgid'] = '${userorgid}$'
|
|
filterdic['userid'] = '${userid}$'
|
|
if filterjson:
|
|
dbf = DBFilter(filterjson)
|
|
conds = dbf.gen(ns)
|
|
if conds:
|
|
ns.update(dbf.consts)
|
|
conds = f' and {conds}'
|
|
filterdic['filterstr'] = conds
|
|
ac = ArgsConvert('[[', ']]')
|
|
vars = ac.findAllVariables(sql)
|
|
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
|
|
filterdic.update(NameSpace)
|
|
sql = ac.convert(sql, filterdic)
|
|
|
|
debug(f'{sql=}')
|
|
db = DBPools()
|
|
dbname = get_module_dbname('pipeline_dist')
|
|
async with db.sqlorContext(dbname) as sor:
|
|
r = await sor.sqlPaging(sql, ns)
|
|
return r
|
|
return {
|
|
"total":0,
|
|
"rows":[]
|
|
} |